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_loginWidgetContainer.php 5425 2012-12-05 01:57:48Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/ec_loginDb.php');
19 class ec_loginWidgetContainer extends BaseWidgetContainer
21 const DEFAULT_CART_WIDGET = 'photo_shop'; // カート内容表示用呼び出しウィジェットID
22 const MAIL_OBJ_ID = 'ecmail'; // メール連携オブジェクト
23 const EC_LIB_ID = "eclib"; // EC共通ライブラリオブジェクトID
24 const DEFAULT_TITLE = '会員ログイン';
25 const CSS_FILE = '/style.css'; // CSSファイルのパス
26 const CF_AUTO_REGIST_MEMBER = 'auto_regist_member'; // 自動会員登録
27 const SHOP_WIDGET_TYPE = 'product'; // ショップ機能ウィジェットのウィジェットタイプ
28 const WORD_KEY_ACCOUNT = 'word_account'; // 用語取得キー(アカウント)
33 function __construct()
36 parent::__construct();
39 $this->db = new ec_loginDb();
42 $this->ecMailObj = $this->gInstance->getObject(self::MAIL_OBJ_ID);
47 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
48 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
50 * @param RequestManager $request HTTPリクエスト処理クラス
51 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
52 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
54 function _setTemplate($request, &$param)
56 return 'index.tmpl.html';
61 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
63 * @param RequestManager $request HTTPリクエスト処理クラス
64 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
67 function _assign($request, &$param)
69 $act = $request->trimValueOf('act');
70 if ($act == 'eclogin_login'){ // 会員ログインのとき
72 $account = $request->trimValueOf('account');
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 $ret = $this->_db->makeNormalLoginUser($userId);// 一般ログインユーザに設定
84 // ######## 会員登録のメールをイントラネット側に送信 ########
85 //$this->ecMailObj->sendMemberInfoToBackoffice(0/*新規登録*/, $userId);
89 $this->gPage->redirect($this->gEnv->getCurrentRequestUri());
93 $this->gAccess->userLogout();
95 $this->tmpl->setAttribute('login_status', 'visibility', 'visible'); // ログイン状況
96 $this->tmpl->addVar("login_status", "message", 'ログインに失敗しました');
98 } else if ($act == 'eclogin_logout'){ // 会員ログアウトのとき
99 $this->gAccess->userLogout();
102 $this->gPage->redirect($this->gEnv->getCurrentRequestUri());
107 $userName = $this->gEnv->getCurrentUserName();
108 if (empty($userName)){ // ユーザがログインしていないとき
110 $this->tmpl->setAttribute('login_field', 'visibility', 'visible');
111 $this->tmpl->setAttribute('login_button', 'visibility', 'visible');
114 $value = $this->db->getConfig(self::CF_AUTO_REGIST_MEMBER);
115 if (!empty($value)) $this->tmpl->setAttribute('regmember_button', 'visibility', 'visible'); // 自動会員登録機能を使用する場合のみ会員登録ボタンを表示
118 $this->tmpl->addVar("login_field", "word_account", $this->convertToDispString($this->gInstance->getMessageManager()->getWord(self::WORD_KEY_ACCOUNT))); // 用語(アカウント)
119 } else { // ユーザがログイン中のとき
121 $ret = $this->db->getMember($this->gEnv->getCurrentUserId(), $memberRow);
123 $this->tmpl->addVar("login_status", "user_name", 'ログイン: ' . $userName . ' 様');
126 $this->tmpl->setAttribute('login_status', 'visibility', 'visible'); // ログイン状況
127 $this->tmpl->setAttribute('logout_button', 'visibility', 'visible');
128 if ($ret) $this->tmpl->setAttribute('member_button', 'visibility', 'visible'); // 会員の場合のみ表示
130 $shopWidget = $this->gPage->getActiveMainWidgetIdByWidgetType(self::SHOP_WIDGET_TYPE); // ショップ機能ウィジェット取得
131 if (empty($shopWidget)) $shopWidget = self::DEFAULT_CART_WIDGET;
134 $sendpwdUrl = $this->createCmdUrlToWidget($shopWidget, 'task=sendpwd');
135 $this->tmpl->addVar("regmember_button", "sendpwd_url", $this->getUrl($sendpwdUrl, true));
138 $regMemberUrl = $this->createCmdUrlToWidget($shopWidget, 'task=regmember');
139 $this->tmpl->addVar("regmember_button", "regmember_url", $this->getUrl($regMemberUrl, true));
142 $changepwdUrl = $this->createCmdUrlToWidget($shopWidget, 'task=changepwd');
143 $this->tmpl->addVar("member_button", "changepwd_url", $this->getUrl($changepwdUrl, true));
146 $memberUrl = $this->createCmdUrlToWidget($shopWidget, 'task=memberinfo');
147 $this->tmpl->addVar("member_button", "member_url", $this->getUrl($memberUrl, true));
150 $historyUrl = $this->createCmdUrlToWidget($shopWidget, 'task=purchasehistory');
151 $this->tmpl->addVar("member_button", "purchasehistory_url", $this->getUrl($historyUrl, true));
154 $memberNoticeUrl = $this->createCmdUrlToWidget($shopWidget, 'task=membernotice');
155 $this->tmpl->addVar("member_button", "member_notice_url", $this->getUrl($memberNoticeUrl, true));
158 * CSSファイルをHTMLヘッダ部に設定
160 * CSSファイルをHTMLのheadタグ内に追加出力する。
161 * _assign()よりも後に実行される。
163 * @param RequestManager $request HTTPリクエスト処理クラス
164 * @param object $param 任意使用パラメータ。
165 * @return string CSS文字列。出力しない場合は空文字列を設定。
167 function _addCssFileToHead($request, &$param)
169 return $this->getUrl($this->gEnv->getCurrentWidgetCssUrl() . self::CSS_FILE);
174 * @param RequestManager $request HTTPリクエスト処理クラス
175 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
176 * @return string ウィジェットのタイトル名
178 function _setTitle($request, &$param)
180 return self::DEFAULT_TITLE;