Last active
February 17, 2016 07:43
-
-
Save akagane99/9b24033718cfbca7956b to your computer and use it in GitHub Desktop.
NC3メール送信 model実装例 登録時(仮)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* sampleModel | |
* | |
* @author Noriko Arai <arai@nii.ac.jp> | |
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp> | |
* @link http://www.netcommons.org NetCommons Project | |
* @license http://www.netcommons.org/license.txt NetCommons License | |
* @copyright Copyright 2014, NetCommons Project | |
*/ | |
App::uses('AppModel', 'Model'); | |
/** | |
* sampleModel | |
* | |
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp> | |
*/ | |
class SampleModel extends AppModel { | |
/** | |
* use behaviors | |
* | |
* @var array | |
*/ | |
public $actsAs = array( | |
'Mails.MailSetting', // メール設定 | |
); | |
/** | |
* 登録処理イメージ。各プラグイン (キューに一時的にためて送るパターン。各プラグインはほとんどこれの想定) | |
* | |
* @param array $data received post data | |
* @return mixed On success Model::$data if its not empty or true, false on failure | |
* @throws InternalErrorException | |
*/ | |
public function addSamplePlugin($data) { | |
// -------------------------------- | |
// 色々な処理 | |
// -------------------------------- | |
// aftersaveでやった方が良い | |
// -------------------------------- | |
// メール送信処理 | |
// setupでどう動くかセットできる。 | |
// -------------------------------- | |
// ・メール送信する定型文をセットする | |
// ※ このメソッド内でやってる処理 | |
// ・ブロックキー、プラグインキーをセットする | |
// ・定型文を取得する | |
// ・メール通知フラグをセットする | |
// ・定型文をセットする | |
// ・返信先アドレスをセットする | |
// ・その他に通知するメールアドレスをセットする | |
//$this->setSendMailSetting($blockKey); | |
// ⇒setup行き | |
// 通知する場合 | |
if ($this->getIsMailSend()) { | |
// ・定型文の変換タグの追加 | |
// 例)レポート | |
//$mailTags["X-ASSIGNMENT_NAME"] = '課題名称'; | |
//$mailTags["X-BODY"] = 'レポート内容'; | |
//$mailTags["X-USER"] = '解答者(ハンドル名)'; | |
//$mailTags["X-TO_DATE"] = '解答日時'; | |
//$mailTags["X-URL"] = 'http://hogehoge.com/xxxx/yyyy/'; | |
//$this->assignMail($mailTags); | |
// ビヘイビア呼び出し $actasのoptionでセットする。 | |
// 複数人の送信先ユーザ取得 ※まだ決められない実装 | |
// blockeyをセットしたら、複数人を取得して、セットするまでやる。 | |
//$users = $this->getSendMailUsers($wwww, $zzzz); | |
$this->setSendMailUsers($blockKey); | |
// 複数人の送信先ユーザ追加 | |
//$this->addMailToUsers($users); | |
// キューに保存する | |
$this->saveQueue($contentKey, $languageId, $roomId, $sendTime); | |
// メール送信 | |
$this->sendMail(); | |
} | |
// -------------------------------- | |
// 色々な処理 | |
// -------------------------------- | |
} | |
/** | |
* 登録処理イメージ。システム管理等 (キューにためない直送パターン。パスワード送信とか、キューにためたらダメなやつはこれの想定) | |
* | |
* @param array $data received post data | |
* @return mixed On success Model::$data if its not empty or true, false on failure | |
* @throws InternalErrorException | |
*/ | |
public function addSampleSystem($data) { | |
// -------------------------------- | |
// 色々な処理 | |
// -------------------------------- | |
// 通知する場合 | |
if ($this->getIsMailSend()) { | |
// 送信先ユーザ追加 | |
// 値の例) | |
// $user = Array | |
// ( | |
// [handle] => ippan | |
// [lang_dirname] => japanese | |
// [to_address] => mutaguchi@xxxx.jp | |
// ) | |
$this->addToUser($user); | |
// メール送信 | |
$this->sendMail(); | |
} | |
// -------------------------------- | |
// 色々な処理 | |
// -------------------------------- | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment