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-2009 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: m_default_loginWidgetContainer.php 2007 2009-06-26 16:00:54Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseMobileWidgetContainer.php');
18 class m_default_loginWidgetContainer extends BaseMobileWidgetContainer
20 private $db; // DB接続オブジェクト
21 private $sysDb; // システムDBオブジェクト
22 const DEFAULT_TITLE = 'ログイン'; // デフォルトのウィジェットタイトル
27 function __construct()
30 parent::__construct();
33 $this->sysDb = $this->gInstance->getSytemDbObject();
38 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
39 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
41 * @param RequestManager $request HTTPリクエスト処理クラス
42 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
43 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
45 function _setTemplate($request, &$param)
47 return 'index.tmpl.html';
52 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
54 * @param RequestManager $request HTTPリクエスト処理クラス
55 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
58 function _assign($request, &$param)
60 $act = $request->trimValueOf('act');
61 if ($act == 'login'){ // ログインのとき
63 $account = $request->trimValueOf('account');
64 $password = $request->trimValueOf('password');
65 if (!empty($password)) $password = md5($password); // パスワードはプレーンで送られてくる
68 if ($this->gAccess->userLoginByAccount($account, $password)){
70 $this->gPage->redirect($this->gEnv->createCurrentPageUrlForMobile(), true/*遷移時のダイアログ表示を抑止*/); // セッションを維持
74 $this->gAccess->userLogout();
76 $this->tmpl->addVar('login_status', 'message', 'ログインに失敗しました'); // メッセージ
77 $this->tmpl->setAttribute('login_status', 'visibility', 'visible'); // ログイン状況
79 } else if ($act == 'logout'){ // ログアウトのとき
80 $this->gAccess->userLogout();
83 $this->gPage->redirect($this->gEnv->createCurrentPageUrl(), true/*遷移時のダイアログ表示を抑止*/); // セッションを終了する
88 $userName = $this->gEnv->getCurrentUserName();
89 if (empty($userName)){ // ユーザがログインしていないとき
91 $this->tmpl->setAttribute('login_field', 'visibility', 'visible');
92 $this->tmpl->setAttribute('login_button', 'visibility', 'visible');
93 $this->tmpl->addVar("_widget", "act", 'login'); // ログイン処理
94 } else { // ユーザがログイン中のとき
95 $this->tmpl->addVar("login_status", "user_name", 'ログイン:' . $userName . '様');
98 $this->tmpl->setAttribute('login_status', 'visibility', 'visible'); // ログイン状況
99 $this->tmpl->setAttribute('logout_button', 'visibility', 'visible');
100 $this->tmpl->addVar("_widget", "act", 'logout'); // ログアウト処理
104 $this->tmpl->addVar('_widget', 'url', $this->gEnv->createCurrentPageUrlForMobile());
109 * @param RequestManager $request HTTPリクエスト処理クラス
110 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
111 * @return string ウィジェットのタイトル名
113 function _setTitle($request, &$param)
115 return self::DEFAULT_TITLE;