7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
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
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/ec_mainBaseWidgetContainer.php');
18 class ec_mainSendpwdWidgetContainer extends ec_mainBaseWidgetContainer
20 // const USE_EMAIL = 'use_email'; // EMAIL機能が使用可能かどうか
21 // const AUTO_EMAIL_SENDER = 'auto_email_sender'; // 自動送信メール用送信者アドレス
26 function __construct()
29 parent::__construct();
34 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
35 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
37 * @param RequestManager $request HTTPリクエスト処理クラス
38 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
39 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
41 function _setTemplate($request, &$param)
43 return 'sendpwd.tmpl.html';
48 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
50 * @param RequestManager $request HTTPリクエスト処理クラス
51 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
54 function _assign($request, &$param)
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'){ // メール送信可能のとき
63 if ($this->_db->getLoginUserRecord($account, $row)){ // アカウントからログインIDを取得
65 $password = $this->makePassword();
68 $ret = $this->_db->updateLoginUserPassword($row['lu_id'], $password);
70 $fromAddress = $this->_getConfig(photo_shopCommonDef::CF_AUTO_EMAIL_SENDER); // 自動送信送信元
71 if (empty($fromAddress)) $fromAddress = $this->gEnv->getSiteEmail();// 送信元が取得できないときは、システムのデフォルトメールアドレスを使用
72 $toAddress = $account; // eメール(ログインアカウント)
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
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; // 送信完了
87 $errMessage = '登録されていないアカウントが入力されました。';
90 $this->setGuidanceMsg('パスワード送信しました');
91 $this->tmpl->addVar("_widget", "account_disabled", 'disabled'); // アカウント編集不可
92 $this->tmpl->addVar("_widget", "button_disabled", 'disabled'); // ボタン使用不可
94 $this->setAppErrorMsg('パスワード送信に失敗しました');
95 $this->writeUserError(__METHOD__, 'パスワード送信に失敗しました。アカウント: ' . $account, 2200, $errMessage);
98 $this->setAppErrorMsg('パスワード送信できません');
100 $this->tmpl->addVar("_widget", "account", $account); // アカウント再設定
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", '送信機能停止中'); // ボタンのラベル
107 $this->tmpl->addVar("_widget", "button_label", 'パスワード送信'); // ボタンのラベル