aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Models
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-12-25 01:56:57 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-12-25 01:56:57 +0000
commitb5d776bc5c8261ac75a74ed3070ca13a6eb741ca (patch)
tree3c769ed0f74963cf1e1b2ade33846deb9cb9e043 /h-source/Application/Models
parentfe4d464805d9c6d3471dbfab6e20cc960fdfd329 (diff)
a mail notification is now sent when a user add a message to the help page of a wiki page
Diffstat (limited to 'h-source/Application/Models')
-rw-r--r--h-source/Application/Models/WikitalkModel.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/h-source/Application/Models/WikitalkModel.php b/h-source/Application/Models/WikitalkModel.php
index 2595a1a..8739984 100644
--- a/h-source/Application/Models/WikitalkModel.php
+++ b/h-source/Application/Models/WikitalkModel.php
@@ -26,6 +26,12 @@ class WikitalkModel extends BaseModel
public function __construct() {
$this->_tables = 'wiki_talk';
$this->_idFields = 'id_talk';
+
+ $this->_where=array(
+ 'id_wiki' => 'wiki_talk',
+ 'has_confirmed' => 'regusers',
+ '-deleted' => 'regusers',
+ );
$this->orderBy = 'wiki_talk.id_talk';
@@ -48,6 +54,48 @@ class WikitalkModel extends BaseModel
{
//update the history
$this->updateHistory('wiki_talk_ins');
+
+ $clean['id_wiki'] = (int)$this->values['id_wiki'];
+ $clean['created_by'] = (int)$this->values['created_by'];
+
+ $hard = new WikiModel();
+ $users = $hard->select('username,e_mail')
+ ->where(array('id_wiki'=>$clean['id_wiki'],'has_confirmed'=>0,'deleted'=>'no'))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send('Boxes');
+
+ $talkUsers = $this->select('username,e_mail')
+ ->inner('regusers')
+ ->on('wiki_talk.created_by = regusers.id_user')
+ ->where(array('id_wiki'=>$clean['id_wiki'],'has_confirmed'=>0,'-deleted'=>'no'))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send();
+
+ $allUsers = array_merge($users,$talkUsers);
+
+ $userObj = new UsersModel();
+ $myName = $userObj->getUser($clean['created_by']);
+
+ $arrayE = new ArrayExt();
+ $fusers = $arrayE->subsetComplementary($allUsers,$myName);
+
+ //remove users that do not want the email notification
+ $inString = "'".implode("','",array_keys($fusers))."'";
+ $profile = new ProfileModel();
+ $ffusers = $profile->select('username,e_mail')
+ ->from('regusers inner join profile')
+ ->on('regusers.id_user = profile.created_by')
+ ->where(array('send_notification'=>'yes','username'=>"in($inString)"))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send();
+
+ $ffusers = array_flip($ffusers);
+
+ //send the notice
+ Account::sendWikiTalkNotice($myName,$ffusers,$clean['id_wiki']);
+
+ header('Refresh: 0;url=http://'.DOMAIN_NAME."/wiki/talk/".Lang::$current."/".$clean['id_wiki']);
+ exit;
}
}