OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / reserve_main / include / container / reserve_mainChangepwdWidgetContainer.php
1 <?php
2 /**
3  * コンテナクラス
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-2007 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: reserve_mainChangepwdWidgetContainer.php 2363 2009-09-26 14:45:44Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() .   '/ec_mainDb.php');
18
19 class reserve_mainChangepwdWidgetContainer extends BaseWidgetContainer
20 {
21         private $mainDb;        // DB接続オブジェクト
22         private $sysDb;         // システムDBオブジェクト
23         const USE_EMAIL         = 'use_email';          // EMAIL機能が使用可能かどうか
24         const SEND_PASSWORD_FORM = 'send_password';             // パスワード送信用フォーム
25         const AUTO_EMAIL_SENDER = 'auto_email_sender';          // 自動送信メール用送信者アドレス
26                 
27         /**
28          * コンストラクタ
29          */
30         function __construct()
31         {
32                 global $gInstanceManager;
33                 
34                 // 親クラスを呼び出す
35                 parent::__construct();
36                 
37                 // DB接続オブジェクト作成
38                 $this->mainDb = new ec_mainDb();
39                 $this->sysDb = $gInstanceManager->getSytemDbObject();
40         }
41         /**
42          * テンプレートファイルを設定
43          *
44          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
45          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
46          *
47          * @param RequestManager $request               HTTPリクエスト処理クラス
48          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
49          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
50          */
51         function _setTemplate($request, &$param)
52         {       
53                 return 'changepwd.tmpl.html';
54         }
55         /**
56          * テンプレートにデータ埋め込む
57          *
58          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
59          *
60          * @param RequestManager $request               HTTPリクエスト処理クラス
61          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
62          * @param                                                               なし
63          */
64         function _assign($request, &$param)
65         {
66                 global $gEnvManager;
67                 
68                 $act = $request->trimValueOf('act');
69                 $password = $request->trimValueOf('password');
70                 $length = $request->trimValueOf('length');              // パスワード長
71                 if ($act == 'update'){                  // パスワード更新のとき
72                         // パスワード変更
73                         $ret = $this->sysDb->updateLoginUserPassword($gEnvManager->getCurrentUserId(), $password, true/*MD5化されているパスワード*/);
74                         if ($ret){
75                                 $this->tmpl->addVar("_widget", "message", 'パスワード変更が完了しました');
76                                 $this->tmpl->addVar("_widget", "button_disabled", 'disabled');          // ボタン使用不可
77                                 $this->tmpl->addVar("_widget", "pwd1_disabled", 'disabled');            // 入力フィールド不可
78                                 $this->tmpl->addVar("_widget", "pwd2_disabled", 'disabled');            // 入力フィールド不可
79                                 
80                                 $this->tmpl->addVar("_widget", "pwd_value", str_repeat('*', $length));          // ダミー値を設定
81                         } else {
82                                 $this->tmpl->addVar("_widget", "message", 'パスワード変更に失敗しました');
83                         }
84                 }
85                 $this->tmpl->addVar("_widget", "button_label", 'パスワード変更');                // ボタンのラベル
86                 
87                 // ディレクトリを設定
88                 $this->tmpl->addVar("_widget", "script_url", $gEnvManager->getScriptsUrl());
89         }
90 }
91 ?>