OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / modules / System / actions / EditUserAction.class.php
1 <?php
2 /**
3  * ¥·¥¹¥Æ¥à¡¡¥æ¡¼¥¶´ÉÍý¡¡¥æ¡¼¥¶¾ðÊóÊѹ¹²èÌÌ action¥¯¥é¥¹
4  * @package  acs/webapp/modules/System/actions
5  * EditUserAction
6  * @author   akitsu  
7  * @since       PHP 4.0
8  */
9 // $Id: EditUserAction.class.php,v 1.8 2008/04/24 16:00:00 y-yuki Exp $
10
11 class EditUserAction extends BaseAction
12 {
13         // GET([Êѹ¹]¥ê¥ó¥¯¤«¤é¤ÎÁ«°Ü)
14         function getDefaultView() {
15                 $context = $this->getContext();
16                 $controller = $context->getController();
17                 $request = $context->getRequest();
18                 $user = $context->getUser();
19         
20                 // ´ÉÍý¼Ô¤«¤É¤¦¤«³Îǧ
21                 if (!$this->get_execute_privilege()) {
22                         $controller->forward(SECURE_MODULE, SECURE_ACTION);
23                         return;
24                 }
25                 
26                 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
27                 $user_id = $request->getParameter('id');
28                 $user_info_row = ACSUser::get_user_profile_row($user_id, 'include_private_flag');
29                 
30                 $request->setAttribute('user_info_row', $user_info_row);
31                 $user->setAttribute('user_id', $user_id);
32                 return View::INPUT;
33         }
34
35         // POST¡Ê[Êѹ¹]¥Ü¥¿¥ó¤«¤é¤ÎÁ«°Ü¡Ë
36         function execute() {
37                 $context = $this->getContext();
38                 $controller = $context->getController();
39                 $request = $context->getRequest();
40                 $user = $context->getUser();
41         
42                 // ´ÉÍý¼Ô¤«¤É¤¦¤«³Îǧ
43                 if (!$this->get_execute_privilege()) {
44                         $controller->forward(SECURE_MODULE, SECURE_ACTION);
45                         return;
46                 }
47                 
48                 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
49
50                 // get
51                 $form = $request->ACSGetParameters();
52                 $user_community_id = $user->getAttribute('user_id');
53
54                 $form['user_community_id'] = $user_community_id;
55                 $target_user_info_row = ACSUser::get_user_profile_row($user_community_id, 'include_private_flag');
56                 $post_user_info_row = ACSUser::get_user_info_row_by_user_id($form['user_id']);
57                 if ($post_user_info_row 
58                                 && $user_community_id != $post_user_info_row['user_community_id'])
59                         {
60                                 echo ACSMsg::get_msg('System', 'EditUserAction.class.php', 'M002');
61                                 return;
62                 }
63
64                 //¥Ñ¥¹¥ï¡¼¥É¥Á¥§¥Ã¥¯
65                 if($form['passwd_change'] == 'change_on' && $form['passwd'] == $form['passwd2'] || $form['passwd_change'] == ''){
66                         // ¥æ¡¼¥¶¾ðÊó¤òÊѹ¹¤¹¤ë
67                         $ret = ACSUser::update_user_info($form);
68                         if(!$ret){
69                                 echo "Warning: Update user information failed.";
70                                 return;
71                         }
72                 }else{
73                         echo ACSMsg::get_msg('System', 'EditUserAction.class.php', 'M001');
74                         return;
75                 }
76
77                 // ¥í¥°ÅÐÏ¿: ¥æ¡¼¥¶¾ðÊóÊѹ¹
78                 ACSLog::set_log($acs_user_info_row, 'Change User Information', $ret, "[UserID:$target_user_info_row[user_id]]");
79
80                 // ¥æ¡¼¥¶°ìÍ÷¤òɽ¼¨
81                 $user_list_url = $this->getControllerPath('System', 'UserList');
82                 header("Location: $user_list_url");
83         }
84
85         function getRequestMethods() {
86                 return Request::POST;
87         }
88
89         function isSecure () {
90                 return false;
91         }
92
93         function getCredential () {
94                 return array('SYSTEM_ADMIN_USER');
95         }
96
97         function get_execute_privilege () {
98                 $context = $this->getContext();
99                 $user = $context->getUser();
100
101                 // ´ÉÍý¼Ô¤Î¾ì¹ç¤ÏOK
102                 if ($user->hasCredential('SYSTEM_ADMIN_USER')) {
103                         return true;
104                 }
105                 return false;
106         }
107
108
109
110 }
111
112 ?>