8 * @author Cake <cake_67@users.sourceforge.jp>
9 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
10 * @link http://trpgtools-onweb.sourceforge.jp/
12 class RegistMailsController extends AppController {
14 var $name = 'RegistMails';
16 var $components = array(
21 var $disableTokenActions = array();
23 // listView用のpagenate設定
24 var $paginate = array(
25 'conditions' => array(
31 // 'RegistMail.key_code',
32 // 'RegistMail.is_mobile',
33 'RegistMail.modified',
39 'RegistMail.modified' => 'asc'
43 function beforeFilter() {
45 parent::beforeFilter();
48 $this->AuthPlus->allow('add');
50 if (!empty($this->user_id)) {
51 $this->disableTokenActions = array(
61 $this->redirect(array('action'=>'add'));
65 // メンバー登録にメールアドレス登録必須設定
66 if ($this->user_id = null && !$this->site_configs['Site.registMail']['value']) {
67 $this->redirect(array('controller' => 'users', 'action'=>'add'));
70 if (!empty($this->data)) {
72 $this->RegistMail->set($this->data);
73 if ($this->RegistMail->validates()) {
77 if (!$user_id = $this->RegistMail->isUniquePcMail($this->data['RegistMail'])) {
78 $this->Session->setFlash(__('This Address has been registed.', true));
82 if ($id = $this->RegistMail->getRegistId4address($this->data['RegistMail'])) {
83 $this->RegistMail->id = $id;
85 $this->RegistMail->create();
88 $to = $this->data['RegistMail']['mail'];
89 $this->data['RegistMail']['mail'] = $this->Crypt->crypt($this->data['RegistMail']['mail']);
90 $this->data['RegistMail']['key_code'] = $this->setKeyCode();
91 $this->data['RegistMail']['is_mobile'] = false;
94 if ($this->AuthPlus->user("id")) {
95 $this->data['RegistMail']['user_id'] = $this->AuthPlus->user("id");
96 $subject = sprintf(__('Address Registration for %s', true), $this->site_configs['Site.siteName']['value']);
98 $this->data['RegistMail']['user_id'] = null;
99 $subject = sprintf(__('Member Registration for %s', true), $this->site_configs['Site.siteName']['value']);
102 if ($this->RegistMail->save($this->data, array('validate' => false))) {
103 if ($this->AuthPlus->user("id")) {
104 $this->Mail->send_mail_regist(
105 $this->data['RegistMail']['key_code'],
110 $this->Mail->send_member_regist(
111 $this->data['RegistMail']['key_code'],
117 $this->AuthPlus->logout();
118 $this->redirect(array('controller' => 'users','action'=>'regist_end'));
120 $this->data['RegistMail']['mail'] = $to;
121 $this->Session->setFlash(__('The Mail Regist could not be done. Please, try again.', true));
127 $this->pageTitle .= " - ". __('Regist Mail', true);
130 function admin_index() {
131 $this->RegistMail->recursive = 0;
132 $regist_mails = $this->paginate();
134 foreach ($regist_mails as $k => $v) {
136 if (isset($v['RegistMail']['mail']) && !empty($v['RegistMail']['mail'])) {
137 $regist_mails[$k]['RegistMail']['mail'] = $this->Crypt->decrypt($v['RegistMail']['mail']);
141 $this->set('registMails', $regist_mails);
143 $this->pageTitle .= " - ". __('RegistMails', true);
146 function admin_delete($id = null) {
148 $this->Session->setFlash(__('Invalid id for RegistMail', true));
149 $this->redirect(array('action'=>'index'));
151 if ($this->RegistMail->del($id)) {
152 $this->Session->setFlash(__('RegistMail deleted', true));
153 $this->redirect(array('action'=>'index'));
160 function setKeyCode()
162 return Security::generateAuthKey();