ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilObjiLincUserGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
35require_once ('./Modules/ILinc/classes/class.ilnetucateXMLAPI.php');
36require_once ('./Modules/ILinc/classes/class.ilObjiLincUser.php');
37
39{
47 function ilObjiLincUserGUI(&$a_user_obj,&$a_usrf_ref_id)
48 {
49 global $ilias, $tpl, $ilCtrl, $ilErr, $lng;
50
51 if (!isset($ilErr))
52 {
53 $ilErr = new ilErrorHandling();
54 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
55 }
56 else
57 {
58 $this->ilErr =& $ilErr;
59 }
60
61 $this->ilias =& $ilias;
62 $this->tpl =& $tpl;
63 $this->lng =& $lng;
64 $this->ctrl =& $ilCtrl;
65
66 $this->lng->loadLanguageModule('ilinc');
67
68 $this->usrf_ref_id =& $a_usrf_ref_id;
69
70 $this->user =& $a_user_obj;
71
72 $this->ilinc_user = new ilObjiLincUser($a_user_obj);
73 }
74
75 function &executeCommand()
76 {
77 global $rbacsystem, $ilErr;
78
79 // User folder
80 if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
81 {
82 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
83 }
84 // if called from local administration $this->usrf_ref_id is category id
85 // Todo: this has to be fixed. Do not mix user folder id and category id
86 if($this->usrf_ref_id != USER_FOLDER_ID)
87 {
88 // check if user is assigned to category
89 if(!$rbacsystem->checkAccess('cat_administrate_users',$this->user->getTimeLimitOwner()))
90 {
91 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
92 }
93 }
94
95 $next_class = $this->ctrl->getNextClass($this);
96
97 switch($next_class)
98 {
99 default:
100 $cmd = $this->ctrl->getCmd();
101
102 if ($cmd == '')
103 {
104 $cmd = "view";
105 }
106
107 $this->$cmd();
108 break;
109 }
110
111 return true;
112 }
113
114 function view()
115 {
116 // return iLinc user account data if user already exists on iLinc server
117 if ($this->ilinc_user->id)
118 {
119 if (!$data = $this->ilinc_user->find($this->ilinc_user->id))
120 {
121 $this->ilErr->raiseError($this->ilinc_user->getErrorMsg(),$this->ilErr->MESSAGE);
122 }
123
124 $this->ilinc_user->setVar('akuservalue1',$data['users'][$this->ilinc_user->id]['akuservalue1']);
125 $this->ilinc_user->setVar('akuservalue2',$data['users'][$this->ilinc_user->id]['akuservalue2']);
126 }
127
128 if (!$this->ilinc_user->id)
129 {
130 $ilinc_id = $this->lng->txt("ilinc_no_account_yet");
131 $ilinc_login = $ilinc_id;
132 $ilinc_passwd = $ilinc_id;
133
134 $submit_button_title = $this->lng->txt("ilinc_add_user");
135 }
136 else
137 {
138 $ilinc_id = $this->ilinc_user->id;
139 $ilinc_login = $this->ilinc_user->login;
140 $ilinc_passwd = $this->ilinc_user->passwd;
141
142 $submit_button_title = $this->lng->txt("refresh");
143 }
144
145 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.icrs_usr_edit.html","Modules/ILinc");
146
147 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
148 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("ilinc_user_settings"));
149 $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
150 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
151
152 $this->tpl->setVariable("TXT_SUBMIT", $submit_button_title);
153 $this->tpl->setVariable("CMD_SUBMIT", "save");
154
155 $this->tpl->setVariable("TXT_ILINC_ID", $this->lng->txt("ilinc_user_id"));
156 $this->tpl->setVariable("ILINC_ID", $ilinc_id);
157 $this->tpl->setVariable("TXT_ILINC_LOGIN", $this->lng->txt("login"));
158 $this->tpl->setVariable("ILINC_LOGIN", $ilinc_login);
159 /*
160 $this->tpl->setVariable("TXT_ILINC_PASSWD", $this->lng->txt("passwd"));
161 $this->tpl->setVariable("ILINC_PASSWD", $ilinc_passwd);
162 */
163
164 $this->tpl->setVariable("TXT_ILINC_AKUSERVALUES", $this->lng->txt("ilinc_akuservalues"));
165 $this->tpl->setVariable("TXT_ILINC_AKUSERVALUES_DESC", $this->lng->txt("ilinc_akuservalues_desc"));
166 $this->tpl->setVariable("TXT_ILINC_AKUSERVALUE1", $this->lng->txt("ilinc_akuservalue1"));
167 $this->tpl->setVariable("ILINC_AKUSERVALUE1", $this->ilinc_user->akuservalue1);
168 $this->tpl->setVariable("TXT_ILINC_AKUSERVALUE2", $this->lng->txt("ilinc_akuservalue2"));
169 $this->tpl->setVariable("ILINC_AKUSERVALUE2", $this->ilinc_user->akuservalue2);
170 }
171
172 function cancel()
173 {
174 ilSession::clear("saved_post");
175
176 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
177
178 if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
179 {
180 $this->ctrl->redirectByClass("ilobjusergui", "view");
181 }
182 else
183 {
184 $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
185 }
186 }
187
188 function save()
189 {
190 if (!$this->ilinc_user->id)
191 {
192 $this->ilinc_user->setVar('akuservalue1',$_POST['Fobject']['ilinc_akuservalue1']);
193 $this->ilinc_user->setVar('akuservalue2',$_POST['Fobject']['ilinc_akuservalue2']);
194
195 if (!$this->ilinc_user->add())
196 {
197 $this->ilErr->raiseError($this->ilinc_user->getErrorMsg(),$this->ilErr->MESSAGE);
198 }
199
200 $info_message = $this->lng->txt("ilinc_user_added");
201 }
202 else
203 {
204 $this->ilinc_user->setVar('akuservalue1',$_POST['Fobject']['ilinc_akuservalue1']);
205 $this->ilinc_user->setVar('akuservalue2',$_POST['Fobject']['ilinc_akuservalue2']);
206
207 if (!$this->ilinc_user->edit())
208 {
209 $this->ilErr->raiseError($this->ilinc_user->getErrorMsg(),$this->ilErr->MESSAGE);
210 }
211
212 $info_message = $this->lng->txt("ilinc_akuservalues_refreshed");
213 }
214
215 ilUtil::sendInfo($info_message,true);
216
217 $this->ctrl->redirectByClass("ilobjilincusergui", "view");
218 }
219
220 // init sub tabs
221 // not used yet
222 function __initSubTabs($a_cmd)
223 {
224 global $ilTabs;
225
226 $perm = ($a_cmd == 'perm') ? true : false;
227 $info = ($a_cmd == 'info') ? true : false;
228 $owner = ($a_cmd == 'owner') ? true : false;
229
230 $ilTabs->addSubTabTarget("permission_settings", $this->ctrl->getLinkTarget($this, "perm"),
231 "", "", "", $perm);
232 $ilTabs->addSubTabTarget("info_status_info", $this->ctrl->getLinkTarget($this, "info"),
233 "", "", "", $info);
234 $ilTabs->addSubTabTarget("owner", $this->ctrl->getLinkTarget($this, "owner"),
235 "", "", "", $owner);
236 }
237} // END class.ilObjiLincUserGUI
238?>
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
const USER_FOLDER_ID
Class ilObjUserFolder.
Error Handling & global info handling uses PEAR error class.
Class ilObjiLincUserGUI iLinc related user settings.
ilObjiLincUserGUI(&$a_user_obj, &$a_usrf_ref_id)
Constructor @access public.
Class ilObjiLincUser iLinc related user settings.
static clear($a_var)
Unset a value.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35