diff options
author | Antonio Gallo <tonicucoz@gmail.com> | 2011-12-25 01:56:57 +0000 |
---|---|---|
committer | Antonio Gallo <tonicucoz@gmail.com> | 2011-12-25 01:56:57 +0000 |
commit | b5d776bc5c8261ac75a74ed3070ca13a6eb741ca (patch) | |
tree | 3c769ed0f74963cf1e1b2ade33846deb9cb9e043 /h-source/Application | |
parent | fe4d464805d9c6d3471dbfab6e20cc960fdfd329 (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')
-rw-r--r-- | h-source/Application/Controllers/WikiController.php | 10 | ||||
-rw-r--r-- | h-source/Application/Include/params.php | 30 | ||||
-rw-r--r-- | h-source/Application/Models/WikitalkModel.php | 48 | ||||
-rw-r--r-- | h-source/Application/Views/Desktop/Meet/talk.php | 2 |
4 files changed, 83 insertions, 7 deletions
diff --git a/h-source/Application/Controllers/WikiController.php b/h-source/Application/Controllers/WikiController.php index 7b5c7ba..72f4220 100644 --- a/h-source/Application/Controllers/WikiController.php +++ b/h-source/Application/Controllers/WikiController.php @@ -489,11 +489,11 @@ class WikiController extends BaseController $this->m['WikitalkModel']->updateTable('insert'); - if ($this->m['WikitalkModel']->queryResult) - { - header('Refresh: 0;url=http://'.DOMAIN_NAME.$_SERVER['REQUEST_URI']); - die(); - } +// if ($this->m['WikitalkModel']->queryResult) +// { +// header('Refresh: 0;url=http://'.DOMAIN_NAME.$_SERVER['REQUEST_URI']); +// die(); +// } } } diff --git a/h-source/Application/Include/params.php b/h-source/Application/Include/params.php index ba4fef3..007a3f8 100644 --- a/h-source/Application/Include/params.php +++ b/h-source/Application/Include/params.php @@ -170,5 +170,33 @@ class Account $result = $mailer->batchSend($message); } - + + static public function sendWikiTalkNotice($who,$e_mails,$id_wiki) + { + require_once (ROOT.'/External/swiftmailer/lib/swift_required.php'); + + $who = sanitizeAll($who); + $id_wiki = (int)$id_wiki; + + $siteName = Website::$generalName; + $siteMail = Website::$generalMail; + + $wiki = new WikiModel(); + $pageUrl = $wiki->toWikiPage($id_wiki); + $talkUrl = "http://".DOMAIN_NAME."/wiki/talk/".Lang::$current."/$id_wiki"; + + $mess = "$who has added a message to the talk page of a wiki page you have contributed to maintain at $siteName\n\nThe whole conversation is here:\n\n".$talkUrl."\n\nThe wiki page is here:\n\n".$pageUrl."\n\nBest regards\nthe ".Website::$projectName." team\n\nP.S: you can disable the mail notifications in the profile page of your control panel"; + + $message = Swift_Message::newInstance()->setSubject("$who sent a notice to your attention")->setFrom(array($siteMail => $siteName))->setTo($e_mails)->setBody($mess); + + //Create the Transport + $transport = Swift_SmtpTransport::newInstance(Website::$mailServer, 25)->setUsername(Website::$generalMail)->setPassword(Website::$mailPassword); + + //Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + //Send the message + $result = $mailer->batchSend($message); + + } }
\ No newline at end of file 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; } } diff --git a/h-source/Application/Views/Desktop/Meet/talk.php b/h-source/Application/Views/Desktop/Meet/talk.php index cd36c33..9ddc5b3 100644 --- a/h-source/Application/Views/Desktop/Meet/talk.php +++ b/h-source/Application/Views/Desktop/Meet/talk.php @@ -26,7 +26,7 @@ $t_title = $item['talk']['title']; $t_id = $item['talk']['id_hard']; $t_id_talk = $item['talk']['id_talk']; - $controller = MyStrings::$reverse[$item['hardware']['type']]; + $controller = Hardware::getControllerFromType($item['hardware']['type']); ?> <?php echo "<a href='".$this->baseUrl."/$controller/talk/$lang/$t_id#talk-$t_id_talk'>".$t_title."</a> at ".smartDate($t_date);?>
\ No newline at end of file |