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_mainLoginWidgetContainer.php 5440 2012-12-08 09:37:39Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/ec_mainBaseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/ec_mainMemberDb.php');
19 class ec_mainLoginWidgetContainer extends ec_mainBaseWidgetContainer
22 private $ecMailObj; // メール連携オブジェクト
23 const MAIL_OBJ_ID = 'ecmail';
24 const EC_LIB_ID = "eclib"; // EC共通ライブラリオブジェクトID
25 const WORD_KEY_ACCOUNT = 'word_account'; // 用語取得キー(アカウント)
30 function __construct()
33 parent::__construct();
36 $this->memberDb = new ec_mainMemberDb();
39 $this->ecMailObj = $this->gInstance->getObject(self::MAIL_OBJ_ID);
44 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
45 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
47 * @param RequestManager $request HTTPリクエスト処理クラス
48 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
49 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
51 function _setTemplate($request, &$param)
53 return 'login.tmpl.html';
58 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
60 * @param RequestManager $request HTTPリクエスト処理クラス
61 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
64 function _assign($request, &$param)
66 $task = $request->trimValueOf('task');
67 $act = $request->trimValueOf('act');
68 $forward = $request->trimValueOf(M3_REQUEST_PARAM_FORWARD); // 画面遷移用パラメータ
69 $account = $request->trimValueOf('photo_account');
71 if ($act == 'photo_login'){ // 会員ログインのとき
73 $password = $request->trimValueOf('password');
76 if ($this->gAccess->userLoginByAccount($account, $password)){
77 // 初回ログインのときは、仮会員を正会員にする
78 $userId = $this->gEnv->getCurrentUserId();
80 $ret = $this->gInstance->getObject(self::EC_LIB_ID)->makeTmpMemberToProperMember($userId);
82 $this->_db->makeNormalLoginUser($userId);// 一般ログインユーザに設定
84 // ######## 会員登録のメールをイントラネット側に送信 ########
85 $this->ecMailObj->sendMemberInfoToBackoffice(0/*新規登録*/, $userId);
90 $memberPage = $this->gEnv->createCurrentPageUrl() . '&task=' . self::DEFAULT_MEMBER_TASK;
91 $this->gPage->redirect($memberPage);
93 $forwardPage = $this->gEnv->createCurrentPageUrl() . '&' . $forward;
94 $this->gPage->redirect($forwardPage);
99 $this->gAccess->userLogout();
101 $this->tmpl->addVar("_widget", "message", 'ログインに失敗しました');
103 //} else if ($act == photo_shopCommonDef::EMAIL_LOGIN_ACT){ // メールからの会員ログインのとき
106 if ($task == 'emaillogin'){
107 // メールからのアクセスの場合は、ログイン後最初にパスワードを変更する
108 //$account = $request->trimValueOf('account');
109 $pwd = $request->trimValueOf('pwd');
110 $forward = 'task=changepwd'; // パスワードを変更
112 $this->tmpl->addVar("_widget", "photo_account", $account);
113 $this->tmpl->addVar("_widget", "photo_password", $pwd);
114 $this->tmpl->addVar("_widget", "savepwd", $pwd);
118 if ($task == 'emaillogin'){
119 $this->tmpl->setAttribute('field_regmember', 'visibility', 'hidden');// 会員登録への遷移を削除
121 // 非会員の購入を許可している場合は、遷移可能にする
122 $value = $this->_getConfig(photo_shopCommonDef::CF_PERMIT_NON_MEMBER_ORDER);
124 $this->tmpl->setAttribute('field_nonmember', 'visibility', 'visible');
125 //$this->tmpl->addVar("field_nonmember", "url_order", $this->getUrl($this->gEnv->createCurrentPageUrl() . '&task=order', true)); // 購入画面遷移用
126 $this->tmpl->addVar("field_nonmember", "url_order", $this->getUrl($this->gEnv->createCurrentPageUrl() . '&' . $forward, true)); // 購入画面遷移用
131 $this->tmpl->addVar("field_regmember", "url_regmember", $this->getUrl($this->gEnv->createCurrentPageUrl() . '&task=regmember', true)); // 会員登録画面遷移用
132 $this->tmpl->addVar("_widget", "forward", $forward); // 遷移先を維持
133 $this->tmpl->addVar("_widget", "task", $task);
134 $this->tmpl->addVar("_widget", "word_account", $this->convertToDispString($this->gInstance->getMessageManager()->getWord(self::WORD_KEY_ACCOUNT))); // 用語(アカウント)
135 $this->tmpl->addVar("field_regmember", "word_account", $this->convertToDispString($this->gInstance->getMessageManager()->getWord(self::WORD_KEY_ACCOUNT))); // 用語(アカウント)