OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / ec_main / include / container / ec_mainSendpwdWidgetContainer.php
1 <?php
2 /**
3  * index.php用コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2012 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: ec_mainSendpwdWidgetContainer.php 5572 2013-01-23 08:43:39Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() .    '/ec_mainBaseWidgetContainer.php');
17
18 class ec_mainSendpwdWidgetContainer extends ec_mainBaseWidgetContainer
19 {
20 //      const USE_EMAIL         = 'use_email';          // EMAIL機能が使用可能かどうか
21 //      const AUTO_EMAIL_SENDER = 'auto_email_sender';          // 自動送信メール用送信者アドレス
22                 
23         /**
24          * コンストラクタ
25          */
26         function __construct()
27         {
28                 // 親クラスを呼び出す
29                 parent::__construct();
30         }
31         /**
32          * テンプレートファイルを設定
33          *
34          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
35          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
36          *
37          * @param RequestManager $request               HTTPリクエスト処理クラス
38          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
39          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
40          */
41         function _setTemplate($request, &$param)
42         {       
43                 return 'sendpwd.tmpl.html';
44         }
45         /**
46          * テンプレートにデータ埋め込む
47          *
48          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
49          *
50          * @param RequestManager $request               HTTPリクエスト処理クラス
51          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
52          * @param                                                               なし
53          */
54         function _assign($request, &$param)
55         {
56                 $act = $request->trimValueOf('act');
57                 $useEmail = $this->_getConfig(photo_shopCommonDef::CF_USE_EMAIL);
58                 if ($act == 'sendpassword'){                    // パスワード再送信のとき
59                         $account = $request->trimValueOf('photo_account');
60                         if ($useEmail == '1'){          // メール送信可能のとき
61                                 $isSend = false;
62                                 $errMessage = '';
63                                 if ($this->_db->getLoginUserRecord($account, $row)){            // アカウントからログインIDを取得
64                                         // パスワード作成
65                                         $password = $this->makePassword();
66                         
67                                         // パスワード変更
68                                         $ret = $this->_db->updateLoginUserPassword($row['lu_id'], $password);
69                                         if ($ret){
70                                                 $fromAddress = $this->_getConfig(photo_shopCommonDef::CF_AUTO_EMAIL_SENDER);    // 自動送信送信元
71                                                 if (empty($fromAddress)) $fromAddress = $this->gEnv->getSiteEmail();// 送信元が取得できないときは、システムのデフォルトメールアドレスを使用
72                                                 $toAddress = $account;                  // eメール(ログインアカウント)
73                                                 
74                                                 //$url = $this->gEnv->createCurrentPageUrl() . sprintf(photo_shopCommonDef::EMAIL_LOGIN_URL, urlencode($account), urlencode($password));                // ログイン用URL
75                                                 //$url = $this->gPage->getDefaultPageUrlByWidget($this->gEnv->getCurrentWidgetId(), 
76                                                 //                              sprintf(photo_shopCommonDef::EMAIL_LOGIN_URL, urlencode($toAddress), urlencode($password)));            // ログイン用URL
77                                                 $url = photo_shopCommonDef::createLoginUrl($toAddress, $password);              // ログイン用URL
78                                                 $mailParam = array();
79                                                 $mailParam['PASSWORD'] = $password;
80                                                 $mailParam['URL']               = $this->getUrl($url, true);            // ログイン用URL
81                                                 $mailParam['SIGNATURE'] = self::$_mainDb->getCommerceConfig(photo_shopCommonDef::CF_E_SHOP_SIGNATURE);  // ショップメール署名
82                                                 $ret = $this->gInstance->getMailManager()->sendFormMail(1/*自動送信*/, $this->gEnv->getCurrentWidgetId(), $toAddress, $fromAddress, '', '',
83                                                                                                                                                                 photo_shopCommonDef::MAIL_FORM_SEND_PASSWORD, $mailParam);// 自動送信
84                                                 $isSend = true;         // 送信完了
85                                         }
86                                 } else {
87                                         $errMessage = '登録されていないアカウントが入力されました。';
88                                 }
89                                 if ($isSend){
90                                         $this->setGuidanceMsg('パスワード送信しました');
91                                         $this->tmpl->addVar("_widget", "account_disabled", 'disabled');         // アカウント編集不可
92                                         $this->tmpl->addVar("_widget", "button_disabled", 'disabled');          // ボタン使用不可
93                                 } else {
94                                         $this->setAppErrorMsg('パスワード送信に失敗しました');
95                                         $this->writeUserError(__METHOD__, 'パスワード送信に失敗しました。アカウント: ' . $account, 2200, $errMessage);
96                                 }
97                         } else {
98                                 $this->setAppErrorMsg('パスワード送信できません');
99                         }
100                         $this->tmpl->addVar("_widget", "account", $account);            // アカウント再設定
101                 }
102                 if ($useEmail == 0){            // メール送信機能が使用可能になっていないとき
103                         $this->tmpl->addVar("_widget", "account_disabled", 'disabled');         // アカウント編集不可
104                         $this->tmpl->addVar("_widget", "button_disabled", 'disabled');          // ボタン使用不可
105                         $this->tmpl->addVar("_widget", "button_label", '送信機能停止中');                // ボタンのラベル
106                 } else {
107                         $this->tmpl->addVar("_widget", "button_label", 'パスワード送信');                // ボタンのラベル
108                 }
109         }
110 }
111 ?>