00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00038 require_once "class.ilObjectGUI.php";
00039
00040 class ilObjUserGUI extends ilObjectGUI
00041 {
00042 var $ilCtrl;
00043
00049 var $gender;
00050
00056 var $type;
00057
00063 var $user_ref_id;
00064
00069 function ilObjUserGUI($a_data,$a_id,$a_call_by_reference = false, $a_prepare_output = true)
00070 {
00071 global $ilCtrl;
00072
00073 define('USER_FOLDER_ID',7);
00074
00075 $this->type = "usr";
00076 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00077 $this->usrf_ref_id =& $this->ref_id;
00078
00079 $this->ctrl =& $ilCtrl;
00080 $this->ctrl->saveParameter($this,'obj_id');
00081
00082
00083
00084 $this->gender = array(
00085 'm' => "salutation_m",
00086 'f' => "salutation_f"
00087 );
00088 }
00089
00090 function &executeCommand()
00091 {
00092 global $rbacsystem;
00093
00094 $next_class = $this->ctrl->getNextClass($this);
00095 $cmd = $this->ctrl->getCmd();
00096
00097 if ($cmd != "deliverVCard" && $cmd != "getPublicProfile")
00098 {
00099 $this->prepareOutput();
00100 }
00101
00102 switch($next_class)
00103 {
00104 case "illearningprogressgui":
00105 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
00106 $new_gui =& new ilLearningProgressGUI(LP_MODE_USER_FOLDER,USER_FOLDER_ID,$this->object->getId());
00107 $this->ctrl->forwardCommand($new_gui);
00108 break;
00109
00110 case "ilobjilincusergui":
00111 include_once './ilinc/classes/class.ilObjiLincUserGUI.php';
00112 $new_gui =& new ilObjiLincUserGUI($this->object,$this->usrf_ref_id);
00113 $this->ctrl->forwardCommand($new_gui);
00114 break;
00115
00116
00117 default:
00118 if($cmd == "" || $cmd == "view")
00119 {
00120 $cmd = "edit";
00121 }
00122 $cmd .= "Object";
00123 $return = $this->$cmd();
00124
00125 break;
00126 }
00127 return $return;
00128 }
00129
00130
00131 function cancelObject()
00132 {
00133 session_unregister("saved_post");
00134
00135 sendInfo($this->lng->txt("msg_cancel"),true);
00136
00137 if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
00138 {
00139 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
00140
00141
00142 }
00143 else
00144 {
00145 $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
00146 }
00147 }
00148
00152 function getAdminTabs(&$tabs_gui)
00153 {
00154 $this->getTabs($tabs_gui);
00155 }
00156
00160 function getTabs(&$tabs_gui)
00161 {
00162 global $rbacsystem;
00163
00164 $tabs_gui->addTarget("properties",
00165 $this->ctrl->getLinkTarget($this, "edit"), array("edit","","view"), get_class($this));
00166
00167 $tabs_gui->addTarget("role_assignment",
00168 $this->ctrl->getLinkTarget($this, "roleassignment"), array("roleassignment"), get_class($this));
00169
00170
00171 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
00172 if($rbacsystem->checkAccess('read',$this->ref_id) and ilObjUserTracking::_enabledLearningProgress())
00173 {
00174
00175 $tabs_gui->addTarget('learning_progress',
00176 $this->ctrl->getLinkTargetByClass('illearningprogressgui',''),
00177 '',
00178 array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
00179 }
00180
00181 if ($this->ilias->getSetting("ilinc_active"))
00182 {
00183 $tabs_gui->addTarget("extt_ilinc",
00184 $this->ctrl->getLinkTargetByClass('ilobjilincusergui',''),
00185 '',
00186 array('ilobjilincusergui'));
00187 }
00188 }
00189
00193 function createObject()
00194 {
00195 global $ilias, $rbacsystem, $rbacreview, $styleDefinition, $ilSetting;
00196
00197
00198 $settings = $ilias->getAllSettings();
00199
00200 if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
00201 !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
00202 {
00203 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00204 }
00205
00206 if($this->usrf_ref_id != USER_FOLDER_ID)
00207 {
00208 $this->tabs_gui->clearTargets();
00209 }
00210
00211
00212 $obj_list = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
00213 $rol = array();
00214 foreach ($obj_list as $obj_data)
00215 {
00216
00217 if($this->object->getRefId() != USER_FOLDER_ID and !in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00218 {
00219 include_once './classes/class.ilObjRole.php';
00220
00221 if(!ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
00222 {
00223 continue;
00224 }
00225 }
00226
00227 if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
00228 {
00229
00230 if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
00231 {
00232 $rol[$obj_data["obj_id"]] = $obj_data["title"];
00233 }
00234 }
00235 }
00236
00237
00238 if(!count($rol))
00239 {
00240 $this->ilias->raiseError($this->lng->txt("msg_no_roles_users_can_be_assigned_to"),$this->ilias->error_obj->MESSAGE);
00241 }
00242
00243 $keys = array_keys($rol);
00244
00245
00246 if (in_array(4,$keys))
00247 {
00248 $default_role = 4;
00249 }
00250 else
00251 {
00252 if (count($keys) > 1 and in_array(2,$keys))
00253 {
00254
00255 foreach ($keys as $key => $val)
00256 {
00257 if ($val == 2)
00258 {
00259 unset($keys[$key]);
00260 break;
00261 }
00262 }
00263 }
00264
00265 $default_role = array_shift($keys);
00266 }
00267
00268 $pre_selected_role = (isset($_SESSION["error_post_vars"]["Fobject"]["default_role"])) ? $_SESSION["error_post_vars"]["Fobject"]["default_role"] : $default_role;
00269
00270 $roles = ilUtil::formSelect($pre_selected_role,"Fobject[default_role]",$rol,false,true);
00271
00272 $data = array();
00273 $data["fields"] = array();
00274 $data["fields"]["login"] = "";
00275 $data["fields"]["passwd"] = "";
00276 $data["fields"]["passwd2"] = "";
00277 $data["fields"]["title"] = "";
00278 $data["fields"]["ext_account"] = "";
00279 $data["fields"]["gender"] = "";
00280 $data["fields"]["firstname"] = "";
00281 $data["fields"]["lastname"] = "";
00282 $data["fields"]["institution"] = "";
00283 $data["fields"]["department"] = "";
00284 $data["fields"]["street"] = "";
00285 $data["fields"]["city"] = "";
00286 $data["fields"]["zipcode"] = "";
00287 $data["fields"]["country"] = "";
00288 $data["fields"]["phone_office"] = "";
00289 $data["fields"]["phone_home"] = "";
00290 $data["fields"]["phone_mobile"] = "";
00291 $data["fields"]["fax"] = "";
00292 $data["fields"]["email"] = "";
00293 $data["fields"]["hobby"] = "";
00294 $data["fields"]["matriculation"] = "";
00295 $data["fields"]["client_ip"] = "";
00296 $data["fields"]["referral_comment"] = "";
00297 $data["fields"]["create_date"] = "";
00298 $data["fields"]["approve_date"] = "";
00299 $data["fields"]["active"] = " checked=\"checked\"";
00300 $data["fields"]["default_role"] = $roles;
00301 $data["fields"]["auth_mode"] = "";
00302
00303 $this->getTemplateFile("edit","usr");
00304
00305
00306 foreach ($data["fields"] as $key => $val)
00307 {
00308 $str = $this->lng->txt($key);
00309 if ($key == "title")
00310 {
00311 $str = $this->lng->txt("person_title");
00312 }
00313 if ($key == "ext_account")
00314 {
00315 continue;
00316 }
00317
00318
00319 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00320 {
00321 $str = $str . '<span class="asterisk">*</span>';
00322 }
00323
00324 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00325
00326 if ($key == "default_role")
00327 {
00328 $this->tpl->setVariable(strtoupper($key), $val);
00329 }
00330 else
00331 {
00332 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00333 }
00334
00335 if ($this->prepare_output)
00336 {
00337 $this->tpl->parseCurrentBlock();
00338 }
00339 }
00340
00341
00342 include_once 'classes/class.ilObjUserFolder.php';
00343 $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage());
00344 if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
00345 {
00346 $this->tpl->setCurrentBlock("inform_user");
00347 if (true)
00348 {
00349 $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
00350 }
00351 $this->tpl->setVariable("TXT_INFORM_USER_MAIL",
00352 $this->lng->txt("user_send_new_account_mail"));
00353 $this->tpl->parseCurrentBlock();
00354 }
00355
00356 $this->ctrl->setParameter($this,'new_type',$this->type);
00357 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00358 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->type."_new"));
00359 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00360 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($this->type."_add"));
00361 $this->tpl->setVariable("CMD_SUBMIT", "save");
00362 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00363 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00364
00365 $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
00366 $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
00367 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
00368 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
00369 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
00370 $this->tpl->setVariable("TXT_PASSWD2", $this->lng->txt("retype_password"));
00371 $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
00372 $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
00373 $this->tpl->setVariable("TXT_HITS_PER_PAGE",$this->lng->txt("usr_hits_per_page"));
00374 $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE",$this->lng->txt("show_users_online"));
00375 $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
00376 $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
00377 $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
00378
00379 if ($ilSetting->get("cas_active") || $ilSetting->get("soap_auth_active"))
00380 {
00381 $this->tpl->setCurrentBlock("ext_account");
00382 $this->tpl->setVariable("TXT_EXT_ACCOUNT",$this->lng->txt("user_ext_account"));
00383 $this->tpl->setVariable("TXT_EXT_ACCOUNT_DESC",$this->lng->txt("user_ext_account_desc"));
00384 if (isset($_SESSION["error_post_vars"]["Fobject"]["ext_account"]))
00385 {
00386 $this->tpl->setVariable("EXT_ACCOUNT",
00387 $_SESSION["error_post_vars"]["Fobject"]["ext_account"]);
00388 }
00389 $this->tpl->parseCurrentBlock();
00390 }
00391
00392
00393
00394
00395 $this->tpl->setVariable("TXT_CURRENT_IP_ALERT",$this->lng->txt("current_ip_alert"));
00396
00397
00398 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00399 {
00400 if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
00401 {
00402 $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
00403 }
00404
00405 foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
00406 {
00407 if ($key != "default_role" and $key != "language"
00408 and $key != "skin_style" and $key != "hits_per_page"
00409 and $key != "show_users_online")
00410 {
00411 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
00412 }
00413 }
00414
00415
00416 $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00417
00418 if (!empty($gender))
00419 {
00420 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
00421 }
00422
00423 $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
00424 if ($active)
00425 {
00426 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
00427 }
00428 }
00429
00430
00431 include_once('classes/class.ilAuthUtils.php');
00432 $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
00433
00434
00435 $selected_auth_mode = (isset($_SESSION["error_post_vars"]["Fobject"]["auth_mode"])) ?
00436 $_SESSION["error_post_vars"]["Fobject"]["auth_mode"] : 'default';
00437
00438 foreach ($active_auth_modes as $auth_name => $auth_key)
00439 {
00440 $this->tpl->setCurrentBlock("auth_mode_selection");
00441
00442 if ($auth_name == 'default')
00443 {
00444 $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
00445 }
00446 else
00447 {
00448 $name = $this->lng->txt('auth_'.$auth_name);
00449 }
00450
00451 $this->tpl->setVariable("AUTH_MODE_NAME", $name);
00452
00453 $this->tpl->setVariable("AUTH_MODE", $auth_name);
00454
00455 if ($selected_auth_mode == $auth_name)
00456 {
00457 $this->tpl->setVariable("SELECTED_AUTH_MODE", "selected=\"selected\"");
00458 }
00459
00460 $this->tpl->parseCurrentBlock();
00461 }
00462
00463
00464 $languages = $this->lng->getInstalledLanguages();
00465
00466
00467 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ?
00468 $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->ilias->getSetting("language");
00469
00470 foreach ($languages as $lang_key)
00471 {
00472 $this->tpl->setCurrentBlock("language_selection");
00473 $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
00474 $this->tpl->setVariable("LANGSHORT", $lang_key);
00475
00476 if ($selected_lang == $lang_key)
00477 {
00478 $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
00479 }
00480
00481 $this->tpl->parseCurrentBlock();
00482 }
00483
00484
00485 $templates = $styleDefinition->getAllTemplates();
00486
00487
00488
00489 if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
00490 {
00491 $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
00492
00493 $selected_style = $sknst[1];
00494 $selected_skin = $sknst[0];
00495 }
00496 else
00497 {
00498 $selected_style = $this->ilias->ini->readVariable("layout","style");;
00499 $selected_skin = $this->ilias->ini->readVariable("layout","skin");;
00500 }
00501 include_once("classes/class.ilObjStyleSettings.php");
00502 foreach ($templates as $template)
00503 {
00504
00505
00506 $styleDef =& new ilStyleDefinition($template["id"]);
00507 $styleDef->startParsing();
00508 $styles = $styleDef->getStyles();
00509
00510 foreach($styles as $style)
00511 {
00512 if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
00513 {
00514 continue;
00515 }
00516
00517 $this->tpl->setCurrentBlock("selectskin");
00518
00519 if ($selected_skin == $template["id"] &&
00520 $selected_style == $style["id"])
00521 {
00522 $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00523 }
00524
00525 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00526 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00527 $this->tpl->parseCurrentBlock();
00528 }
00529 }
00530
00531
00532 $hits_options = array(2,10,15,20,30,40,50,100,9999);
00533
00534 if (isset($_SESSION["error_post_vars"]["Fobject"]["hits_per_page"]))
00535 {
00536 $selected_option = $_SESSION["error_post_vars"]["Fobject"]["hits_per_page"];
00537 }
00538 else
00539 {
00540 $selected_option = $this->ilias->getSetting("hits_per_page");
00541 }
00542 foreach($hits_options as $hits_option)
00543 {
00544 $this->tpl->setCurrentBlock("selecthits");
00545
00546 if ($hits_option == $selected_option)
00547 {
00548 $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
00549 }
00550
00551 $this->tpl->setVariable("HITSVALUE", $hits_option);
00552
00553 if ($hits_option == 9999)
00554 {
00555 $hits_option = $this->lng->txt("no_limit");
00556 }
00557
00558 $this->tpl->setVariable("HITSOPTION", $hits_option);
00559 $this->tpl->parseCurrentBlock();
00560 }
00561
00562
00563
00564
00565 if (isset($_SESSION["error_post_vars"]["Fobject"]["show_users_online"]))
00566 {
00567 $selected_option = $_SESSION["error_post_vars"]["Fobject"]["show_users_online"];
00568 }
00569 else
00570 {
00571 $selected_option = $this->ilias->getSetting("show_users_online");
00572 }
00573 $users_online_options = array("y","associated","n");
00574 foreach($users_online_options as $an_option)
00575 {
00576 $this->tpl->setCurrentBlock("show_users_online");
00577
00578 if ($selected_option == $an_option)
00579 {
00580 $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
00581 }
00582
00583 $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
00584
00585 $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
00586 $this->tpl->parseCurrentBlock();
00587 }
00588
00589
00590
00591 if (is_array($_SESSION["error_post_vars"]))
00592 {
00593 $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"];
00594 }
00595 else
00596 {
00597 $time_limit_unlimited = 1;
00598 }
00599
00600 $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
00601 $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
00602 time();
00603
00604 $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
00605 $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
00606 time();
00607
00608 $this->lng->loadLanguageModule('crs');
00609
00610 $this->tpl->setCurrentBlock("time_limit");
00611 $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
00612 $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
00613 $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
00614 $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
00615 $this->tpl->setVariable("TXT_TIME_LIMIT_CLOCK", $this->lng->txt("clock"));
00616 $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
00617 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
00618 date("i",$time_limit_from)));
00619 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
00620 date("G",$time_limit_from)));
00621 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
00622 date("d",$time_limit_from)));
00623 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
00624 date("m",$time_limit_from)));
00625 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
00626 date("Y",$time_limit_from)));
00627 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
00628 date("i",$time_limit_until)));
00629 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
00630 date("G",$time_limit_until)));
00631 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
00632 date("d",$time_limit_until)));
00633 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
00634 date("m",$time_limit_until)));
00635 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
00636 date("Y",$time_limit_until)));
00637 $this->tpl->parseCurrentBlock();
00638
00639
00640 $this->__showUserDefinedFields();
00641
00642 }
00643
00644 function __checkUserDefinedRequiredFields()
00645 {
00646 include_once './classes/class.ilUserDefinedFields.php';
00647 $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
00648
00649 foreach($this->user_defined_fields->getDefinitions() as $field_id => $definition)
00650 {
00651 if($definition['required'] and !strlen($_POST['udf'][$field_id]))
00652 {
00653 return false;
00654 }
00655 }
00656 return true;
00657 }
00658
00659
00660 function __showUserDefinedFields()
00661 {
00662 include_once './classes/class.ilUserDefinedFields.php';
00663 $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
00664
00665 if($this->object->getType() == 'usr')
00666 {
00667 $user_defined_data = $this->object->getUserDefinedData();
00668 }
00669 foreach($this->user_defined_fields->getDefinitions() as $field_id => $definition)
00670 {
00671 $old = isset($_SESSION["error_post_vars"]["udf"][$field_id]) ?
00672 $_SESSION["error_post_vars"]["udf"][$field_id] : $user_defined_data[$field_id];
00673
00674 if($definition['field_type'] == UDF_TYPE_TEXT)
00675 {
00676 $this->tpl->setCurrentBlock("field_text");
00677 $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
00678 $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($old));
00679 $this->tpl->parseCurrentBlock();
00680 }
00681 else
00682 {
00683 $this->tpl->setCurrentBlock("field_select");
00684 $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($old,
00685 'udf['.$definition['field_id'].']',
00686 $this->user_defined_fields->fieldValuesToSelectArray(
00687 $definition['field_values']),
00688 false,
00689 true));
00690 $this->tpl->parseCurrentBlock();
00691 }
00692 $this->tpl->setCurrentBlock("user_defined");
00693
00694 if($definition['required'])
00695 {
00696 $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
00697 }
00698 else
00699 {
00700 $name = $definition['field_name'];
00701 }
00702 $this->tpl->setVariable("TXT_FIELD_NAME",$name);
00703 $this->tpl->parseCurrentBlock();
00704 }
00705 return true;
00706 }
00707
00708
00833 function editObject()
00834 {
00835 global $ilias, $rbacsystem, $rbacreview, $rbacadmin, $styleDefinition, $ilUser
00836 ,$ilSetting;
00837
00838
00839 $settings = $ilias->getAllSettings();
00840
00841
00842 if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
00843 {
00844 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
00845 }
00846
00847
00848 if($this->usrf_ref_id != USER_FOLDER_ID)
00849 {
00850
00851 if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
00852 {
00853 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
00854 }
00855 }
00856
00857 if($this->usrf_ref_id != USER_FOLDER_ID)
00858 {
00859 $this->tabs_gui->clearTargets();
00860 }
00861
00862 $data = array();
00863 $data["fields"] = array();
00864 $data["fields"]["login"] = $this->object->getLogin();
00865 $data["fields"]["passwd"] = "********";
00866 $data["fields"]["passwd2"] = "********";
00867 $data["fields"]["ext_account"] = $this->object->getExternalAccount();
00868 $data["fields"]["title"] = $this->object->getUTitle();
00869 $data["fields"]["gender"] = $this->object->getGender();
00870 $data["fields"]["firstname"] = $this->object->getFirstname();
00871 $data["fields"]["lastname"] = $this->object->getLastname();
00872 $data["fields"]["institution"] = $this->object->getInstitution();
00873 $data["fields"]["department"] = $this->object->getDepartment();
00874 $data["fields"]["street"] = $this->object->getStreet();
00875 $data["fields"]["city"] = $this->object->getCity();
00876 $data["fields"]["zipcode"] = $this->object->getZipcode();
00877 $data["fields"]["country"] = $this->object->getCountry();
00878 $data["fields"]["phone_office"] = $this->object->getPhoneOffice();
00879 $data["fields"]["phone_home"] = $this->object->getPhoneHome();
00880 $data["fields"]["phone_mobile"] = $this->object->getPhoneMobile();
00881 $data["fields"]["fax"] = $this->object->getFax();
00882 $data["fields"]["email"] = $this->object->getEmail();
00883 $data["fields"]["hobby"] = $this->object->getHobby();
00884 $data["fields"]["matriculation"] = $this->object->getMatriculation();
00885 $data["fields"]["client_ip"] = $this->object->getClientIP();
00886 $data["fields"]["referral_comment"] = $this->object->getComment();
00887 $data["fields"]["create_date"] = $this->object->getCreateDate();
00888 $data["fields"]["approve_date"] = $this->object->getApproveDate();
00889 $data["fields"]["active"] = $this->object->getActive();
00890 $data["fields"]["auth_mode"] = $this->object->getAuthMode();
00891 $data["fields"]["ext_account"] = $this->object->getExternalAccount();
00892
00893 if (!count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
00894 {
00895 $user_is_online = false;
00896 }
00897 else
00898 {
00899 $user_is_online = true;
00900
00901
00902 preg_match("/RoleId.*?;\}/",$user_online[$this->object->getId()]["data"],$matches);
00903 $active_roles = unserialize(substr($matches[0],7));
00904
00905 $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
00906
00907 foreach ($assigned_roles as $key => $role)
00908 {
00909 $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role);
00910
00911
00912 $rolf = $rbacreview->getFoldersAssignedToRole($role,true);
00913
00914
00915 if (count($rolf) > 0)
00916 {
00917 if (!$rbacreview->isDeleted($rolf[0]))
00918 {
00919 $path = "";
00920
00921 if ($this->tree->isInTree($rolf[0]))
00922 {
00923 $tmpPath = $this->tree->getPathFull($rolf[0]);
00924
00925
00926 for ($i = 0; $i < (count($tmpPath)-1); $i++)
00927 {
00928 if ($path != "")
00929 {
00930 $path .= " > ";
00931 }
00932
00933 $path .= $tmpPath[$i]["title"];
00934 }
00935 }
00936 else
00937 {
00938 $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role.")</b>";
00939 }
00940
00941 if (in_array($role,$active_roles))
00942 {
00943 $data["active_role"][$role]["active"] = true;
00944 }
00945
00946 $data["active_role"][$role]["title"] = $roleObj->getTitle();
00947 $data["active_role"][$role]["context"] = $path;
00948
00949 unset($roleObj);
00950 }
00951 }
00952 else
00953 {
00954 $path = "<b>No role folder found for role ".$role."!</b>";
00955 }
00956 }
00957 }
00958
00959 $this->getTemplateFile("edit","usr");
00960
00961
00962 if (isset($_SESSION["error_post_vars"]["Fobject"]))
00963 {
00964 if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
00965 {
00966 $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
00967 }
00968
00969 foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
00970 {
00971 $str = $this->lng->txt($key);
00972 if ($key == "title")
00973 {
00974 $str = $this->lng->txt("person_title");
00975 }
00976
00977
00978 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
00979 {
00980 $str = $str . '<span class="asterisk">*</span>';
00981 }
00982
00983 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
00984
00985 if ($key != "default_role" and $key != "language"
00986 and $key != "skin_style" and $key != "hits_per_page"
00987 and $key != "show_users_online")
00988 {
00989 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
00990 }
00991 }
00992
00993
00994 $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
00995
00996
00997 if (!empty($gender))
00998 {
00999 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
01000 }
01001
01002 $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
01003 if ($active)
01004 {
01005 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
01006 }
01007 }
01008 else
01009 {
01010 if (!isset($data["fields"]["active"]))
01011 {
01012 $data["fields"]["active"] = 0;
01013 }
01014
01015 foreach ($data["fields"] as $key => $val)
01016 {
01017 $str = $this->lng->txt($key);
01018 if ($key == "title")
01019 {
01020 $str = $this->lng->txt("person_title");
01021 }
01022 if ($key == "ext_account")
01023 {
01024 continue;
01025 }
01026
01027
01028 if (isset($settings["require_" . $key]) && $settings["require_" . $key])
01029 {
01030 $str = $str . '<span class="asterisk">*</span>';
01031 }
01032
01033 $this->tpl->setVariable("TXT_".strtoupper($key), $str);
01034
01035 $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
01036 #$this->tpl->parseCurrentBlock();
01037 }
01038
01039
01040 $gender = strtoupper($data["fields"]["gender"]);
01041
01042 if (!empty($gender))
01043 {
01044 $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
01045 }
01046
01047 $active = $data["fields"]["active"];
01048 if ($active)
01049 {
01050 $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
01051 }
01052 }
01053
01054
01055 if ($ilSetting->get("cas_active") || $ilSetting->get("soap_auth_active")
01056 || $ilSetting->get("shib_active"))
01057 {
01058 $this->tpl->setCurrentBlock("ext_account");
01059 $this->tpl->setVariable("TXT_EXT_ACCOUNT",$this->lng->txt("user_ext_account"));
01060 $this->tpl->setVariable("TXT_EXT_ACCOUNT_DESC",$this->lng->txt("user_ext_account_desc"));
01061 if (isset($_SESSION["error_post_vars"]["Fobject"]["ext_account"]))
01062 {
01063 $this->tpl->setVariable("EXT_ACCOUNT",
01064 $_SESSION["error_post_vars"]["Fobject"]["ext_account"]);
01065 }
01066 else
01067 {
01068 $this->tpl->setVariable("EXT_ACCOUNT",
01069 $data["fields"]["ext_account"]);
01070 }
01071 if ($this->object->getAuthMode(true) != AUTH_LOCAL &&
01072 $this->object->getAuthMode(true) != AUTH_CAS &&
01073 $this->object->getAuthMode(true) != AUTH_SHIBBOLETH &&
01074 $this->object->getAuthMode(true) != AUTH_SOAP)
01075 {
01076 $this->tpl->setVariable("OPTION_DISABLED_EXT", "\"disabled=disabled\"");
01077 }
01078 $this->tpl->parseCurrentBlock();
01079 }
01080
01081 if ($this->object->getAuthMode(true) != AUTH_LOCAL &&
01082 $this->object->getAuthMode(true) != AUTH_CAS &&
01083 $this->object->getAuthMode(true) != AUTH_SHIBBOLETH &&
01084 $this->object->getAuthMode(true) != AUTH_SOAP
01085 )
01086 {
01087 $this->tpl->setVariable("OPTION_DISABLED", "\"disabled=disabled\"");
01088 }
01089
01090 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
01091
01092 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01093 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
01094 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01095 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01096 $this->tpl->setVariable("CMD_SUBMIT", "update");
01097 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
01098 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01099
01100 $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
01101 $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
01102 $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
01103 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
01104 $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
01105 $this->tpl->setVariable("TXT_PASSWD2", $this->lng->txt("retype_password"));
01106 $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
01107 $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
01108 $this->tpl->setVariable("TXT_HITS_PER_PAGE",$this->lng->txt("hits_per_page"));
01109 $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE",$this->lng->txt("show_users_online"));
01110 $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
01111 $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
01112 $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
01113 if ($this->object->getId() == $ilUser->getId())
01114 {
01115 $this->tpl->setVariable("TXT_CURRENT_IP","(".$this->lng->txt("current_ip")." ".$_SERVER["REMOTE_ADDR"].")");
01116 }
01117 $this->tpl->setVariable("TXT_CURRENT_IP_ALERT",$this->lng->txt("current_ip_alert"));
01118
01119
01120 include_once('classes/class.ilAuthUtils.php');
01121 $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
01122
01123
01124 $selected_auth_mode = (isset($_SESSION["error_post_vars"]["Fobject"]["auth_mode"])) ? $_SESSION["error_post_vars"]["Fobject"]["auth_mode"] : $this->object->getAuthMode();
01125
01126 foreach ($active_auth_modes as $auth_name => $auth_key)
01127 {
01128 $this->tpl->setCurrentBlock("auth_mode_selection");
01129
01130 if ($auth_name == 'default')
01131 {
01132 $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
01133 }
01134 else
01135 {
01136 $name = $this->lng->txt('auth_'.$auth_name);
01137 }
01138
01139 $this->tpl->setVariable("AUTH_MODE_NAME", $name);
01140
01141 $this->tpl->setVariable("AUTH_MODE", $auth_name);
01142
01143 if ($selected_auth_mode == $auth_name)
01144 {
01145 $this->tpl->setVariable("SELECTED_AUTH_MODE", "selected=\"selected\"");
01146 }
01147
01148 $this->tpl->parseCurrentBlock();
01149 }
01150
01151
01152
01153 $languages = $this->lng->getInstalledLanguages();
01154
01155
01156 $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->object->getLanguage();
01157
01158 foreach ($languages as $lang_key)
01159 {
01160 $this->tpl->setCurrentBlock("language_selection");
01161 $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
01162 $this->tpl->setVariable("LANGSHORT", $lang_key);
01163
01164 if ($selected_lang == $lang_key)
01165 {
01166 $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
01167 }
01168
01169 $this->tpl->parseCurrentBlock();
01170 }
01171
01172
01173
01174 $templates = $styleDefinition->getAllTemplates();
01175
01176
01177 if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
01178 {
01179 $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
01180
01181 $selected_style = $sknst[1];
01182 $selected_skin = $sknst[0];
01183 }
01184 else
01185 {
01186 $selected_style = $this->object->prefs["style"];
01187 $selected_skin = $this->object->skin;
01188 }
01189
01190 include("classes/class.ilObjStyleSettings.php");
01191 foreach ($templates as $template)
01192 {
01193
01194
01195 $styleDef =& new ilStyleDefinition($template["id"]);
01196 $styleDef->startParsing();
01197 $styles = $styleDef->getStyles();
01198 foreach ($styles as $style)
01199 {
01200 if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
01201 {
01202 continue;
01203 }
01204
01205 $this->tpl->setCurrentBlock("selectskin");
01206
01207 if ($selected_skin == $template["id"] &&
01208 $selected_style == $style["id"])
01209 {
01210 $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
01211 }
01212
01213 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
01214 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
01215 $this->tpl->parseCurrentBlock();
01216 }
01217 }
01218
01219
01220 $hits_options = array(2,10,15,20,30,40,50,100,9999);
01221
01222 if (isset($_SESSION["error_post_vars"]["Fobject"]["hits_per_page"]))
01223 {
01224 $selected_option = $_SESSION["error_post_vars"]["Fobject"]["hits_per_page"];
01225 }
01226 else
01227 {
01228 $selected_option = $this->object->prefs["hits_per_page"];
01229 }
01230 foreach($hits_options as $hits_option)
01231 {
01232 $this->tpl->setCurrentBlock("selecthits");
01233
01234 if ($selected_option == $hits_option)
01235 {
01236 $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
01237 }
01238
01239 $this->tpl->setVariable("HITSVALUE", $hits_option);
01240
01241 if ($hits_option == 9999)
01242 {
01243 $hits_option = $this->lng->txt("no_limit");
01244 }
01245
01246 $this->tpl->setVariable("HITSOPTION", $hits_option);
01247 $this->tpl->parseCurrentBlock();
01248 }
01249
01250
01251
01252 $users_online_options = array("y","associated","n");
01253
01254 if (isset($_SESSION["error_post_vars"]["Fobject"]["show_users_online"]))
01255 {
01256 $selected_option = $_SESSION["error_post_vars"]["Fobject"]["show_users_online"];
01257 }
01258 else
01259 {
01260 $selected_option = $this->object->prefs["show_users_online"];
01261 }
01262 foreach($users_online_options as $an_option)
01263 {
01264 $this->tpl->setCurrentBlock("show_users_online");
01265
01266 if ($selected_option == $an_option)
01267 {
01268 $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
01269 }
01270
01271 $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
01272
01273 $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
01274 $this->tpl->parseCurrentBlock();
01275 }
01276
01277
01278
01279 $this->tpl->setCurrentBlock("inform_user");
01280
01281
01282 if (true)
01283 {
01284 $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
01285 }
01286
01287 $this->tpl->setVariable("TXT_INFORM_USER_MAIL", $this->lng->txt("inform_user_mail"));
01288 $this->tpl->parseCurrentBlock();
01289
01290 $this->lng->loadLanguageModule('crs');
01291
01292 $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"] ?
01293 $_SESSION["error_post_vars"]["time_limit"]["unlimited"] :
01294 $this->object->getTimeLimitUnlimited();
01295 $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
01296 $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
01297 $this->object->getTimeLimitFrom();
01298
01299 $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
01300 $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
01301 $this->object->getTimeLimitUntil();
01302
01303 $this->tpl->setCurrentBlock("time_limit");
01304 $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
01305 $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
01306 $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
01307 $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
01308
01309 $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
01310 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
01311 date("i",$time_limit_from)));
01312 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
01313 date("G",$time_limit_from)));
01314 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
01315 date("d",$time_limit_from)));
01316 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
01317 date("m",$time_limit_from)));
01318 $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
01319 date("Y",$time_limit_from)));
01320 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
01321 date("i",$time_limit_until)));
01322 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
01323 date("G",$time_limit_until)));
01324 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
01325 date("d",$time_limit_until)));
01326 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
01327 date("m",$time_limit_until)));
01328 $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
01329 date("Y",$time_limit_until)));
01330 $this->tpl->parseCurrentBlock();
01331
01332
01333 if ($user_is_online)
01334 {
01335
01336 $this->tpl->setCurrentBlock("TABLE_ROLES");
01337
01338 $counter = 0;
01339
01340 foreach ($data["active_role"] as $role_id => $role)
01341 {
01342 ++$counter;
01343 $css_row = ilUtil::switchColor($counter,"tblrow2","tblrow1");
01344 ($role["active"]) ? $checked = "checked=\"checked\"" : $checked = "";
01345
01346 $this->tpl->setVariable("ACTIVE_ROLE_CSS_ROW",$css_row);
01347 $this->tpl->setVariable("ROLECONTEXT",$role["context"]);
01348 $this->tpl->setVariable("ROLENAME",$role["title"]);
01349 $this->tpl->setVariable("CHECKBOX_ID", $role_id);
01350 $this->tpl->setVariable("CHECKED", $checked);
01351 $this->tpl->parseCurrentBlock();
01352 }
01353
01354
01355
01356 $this->tpl->setCurrentBlock("ACTIVE_ROLE");
01357 $this->tpl->setVariable("ACTIVE_ROLE_FORMACTION",
01358 $this->ctrl->getFormAction($this));
01359 $this->tpl->setVariable("TXT_ACTIVE_ROLES",$this->lng->txt("active_roles"));
01360 $this->tpl->setVariable("TXT_ASSIGN",$this->lng->txt("change_active_assignment"));
01361 $this->tpl->parseCurrentBlock();
01362
01363 }
01364 $this->__showUserDefinedFields();
01365 }
01366
01371 function saveObject()
01372 {
01373 global $ilias, $rbacsystem, $rbacadmin, $ilSetting;
01374
01375
01376 $settings = $ilias->getAllSettings();
01377
01378
01379 if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
01380 !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
01381 {
01382 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01383 }
01384
01385
01386 foreach ($settings as $key => $val)
01387 {
01388 if (substr($key,0,8) == "require_")
01389 {
01390 $require_keys[] = substr($key,8);
01391 }
01392 }
01393
01394 foreach ($require_keys as $key => $val)
01395 {
01396 if (isset($settings["require_" . $val]) && $settings["require_" . $val])
01397 {
01398 if (empty($_POST["Fobject"][$val]))
01399 {
01400 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
01401 $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
01402 }
01403 }
01404 }
01405
01406 if(!$this->__checkUserDefinedRequiredFields())
01407 {
01408 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
01409 }
01410
01411
01412 if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
01413 {
01414 $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
01415 }
01416
01417
01418 if (loginExists($_POST["Fobject"]["login"]))
01419 {
01420 $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
01421 }
01422
01423
01424 if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
01425 {
01426 $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
01427 }
01428
01429
01430 if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
01431 {
01432 $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
01433 }
01434
01435
01436 require_once "class.ilObjUser.php";
01437 $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
01438
01439
01440 if (!ilUtil::is_email($_POST["Fobject"]["email"]))
01441 {
01442 $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
01443 }
01444
01445
01446 if ($_POST["time_limit"]["unlimited"] != 1 and
01447 ($this->__toUnix($_POST["time_limit"]["until"]) < $this->__toUnix($_POST["time_limit"]["from"])))
01448 {
01449 $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
01450 }
01451 if(!$this->ilias->account->getTimeLimitUnlimited())
01452 {
01453 if($this->__toUnix($_POST["time_limit"]["from"]) < $this->ilias->account->getTimeLimitFrom() or
01454 $this->__toUnix($_POST["time_limit"]["until"])> $this->ilias->account->getTimeLimitUntil() or
01455 $_POST['time_limit']['unlimited'])
01456 {
01457 $this->ilias->raiseError($this->lng->txt("time_limit_not_within_owners"),$this->ilias->error_obj->MESSAGE);
01458 }
01459 }
01460
01461
01462
01463
01464
01465 $userObj = new ilObjUser();
01466 $userObj->assignData($_POST["Fobject"]);
01467 $userObj->setTitle($userObj->getFullname());
01468 $userObj->setDescription($userObj->getEmail());
01469
01470 $userObj->setTimeLimitOwner($this->object->getRefId());
01471 $userObj->setTimeLimitUnlimited($_POST["time_limit"]["unlimited"]);
01472 $userObj->setTimeLimitFrom($this->__toUnix($_POST["time_limit"]["from"]));
01473 $userObj->setTimeLimitUntil($this->__toUnix($_POST["time_limit"]["until"]));
01474
01475 $userObj->setUserDefinedData($_POST['udf']);
01476
01477 $userObj->create();
01478
01479 if ($ilSetting->get("cas_active") || $ilSetting->get("soap_auth_active"))
01480 {
01481 $userObj->setExternalAccount($_POST["Fobject"]["ext_account"]);
01482 }
01483
01484
01485
01486
01487 $userObj->saveAsNew();
01488
01489
01490 $userObj->setLanguage($_POST["Fobject"]["language"]);
01491
01492
01493 $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
01494
01495 if ($userObj->getPref("style") != $sknst[1] ||
01496 $userObj->getPref("skin") != $sknst[0])
01497 {
01498 $userObj->setPref("skin", $sknst[0]);
01499 $userObj->setPref("style", $sknst[1]);
01500 }
01501
01502
01503 $userObj->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
01504
01505 $userObj->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
01506
01507 $userObj->writePrefs();
01508
01509
01510 $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
01511
01512 $msg = $this->lng->txt("user_added");
01513
01514
01515 if ($_POST["send_mail"] != "")
01516 {
01517 include_once("classes/class.ilAccountMail.php");
01518 $acc_mail = new ilAccountMail();
01519 $acc_mail->setUserPassword($_POST["Fobject"]["passwd"]);
01520 $acc_mail->setUser($userObj);
01521
01522 if ($acc_mail->send())
01523 {
01524 $msg = $msg."<br />".$this->lng->txt("mail_sent");
01525 }
01526 else
01527 {
01528 $msg = $msg."<br />".$this->lng->txt("mail_not_sent");
01529 }
01530 }
01531
01532 sendInfo($msg, true);
01533
01534 if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
01535 {
01536 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
01537 }
01538 else
01539 {
01540 $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01541 }
01542 }
01543
01548 function updateObject()
01549 {
01550 global $ilias, $rbacsystem, $rbacadmin,$ilUser;
01551
01552
01553 $settings = $ilias->getAllSettings();
01554
01555
01556 if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read,write',$this->usrf_ref_id))
01557 {
01558 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
01559 }
01560
01561
01562 if($this->usrf_ref_id != USER_FOLDER_ID)
01563 {
01564
01565 if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
01566 {
01567 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
01568 }
01569 }
01570
01571 foreach ($_POST["Fobject"] as $key => $val)
01572 {
01573 $_POST["Fobject"][$key] = ilUtil::stripSlashes($val);
01574 }
01575
01576
01577 if ($this->object->getAuthMode(true) == AUTH_LOCAL ||
01578 $this->object->getAuthMode(true) == AUTH_CAS ||
01579 $this->object->getAuthMode(true) == AUTH_SOAP)
01580 {
01581
01582 foreach ($settings as $key => $val)
01583 {
01584 if (substr($key,0,8) == "require_")
01585 {
01586 $require_keys[] = substr($key,8);
01587 }
01588 }
01589
01590 foreach ($require_keys as $key => $val)
01591 {
01592
01593 $system_fields = array("default_role");
01594 if (!in_array($val, $system_fields))
01595 {
01596 if (isset($settings["require_" . $val]) && $settings["require_" . $val])
01597 {
01598 if (empty($_POST["Fobject"][$val]))
01599 {
01600 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
01601 $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
01602 }
01603 }
01604 }
01605 }
01606
01607 if(!$this->__checkUserDefinedRequiredFields())
01608 {
01609 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
01610 }
01611
01612
01613 if ($this->object->getLogin() != $_POST["Fobject"]["login"] &&
01614 !ilUtil::isLogin($_POST["Fobject"]["login"]))
01615 {
01616 $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
01617 }
01618
01619
01620 if (loginExists($_POST["Fobject"]["login"],$this->id))
01621 {
01622 $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
01623 }
01624
01625
01626 if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
01627 {
01628 $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
01629 }
01630
01631
01632 if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
01633 {
01634 $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
01635 }
01636
01637
01638 if ($_POST["Fobject"]["ext_account"] != "")
01639 {
01640 $am = $_POST["Fobject"]["auth_mode"];
01641 if ($am == "default")
01642 {
01643 $am = ilAuthUtils::_getAuthModeName($this->ilias->getSetting('auth_mode'));
01644 }
01645 $elogin = ilObjUser::_checkExternalAuthAccount($am, $_POST["Fobject"]["ext_account"]);
01646 if ($elogin != "" && $elogin != $this->object->getLogin())
01647 {
01648 $this->ilias->raiseError(
01649 sprintf($this->lng->txt("err_auth_ext_user_exists"),
01650 $_POST["Fobject"]["ext_account"], $am, $elogin),
01651 $this->ilias->error_obj->MESSAGE);
01652 }
01653 }
01654
01655 if ($_POST["Fobject"]["passwd"] != "********")
01656 {
01657 $this->object->resetPassword($_POST["Fobject"]["passwd"],$_POST["Fobject"]["passwd2"]);
01658 }
01659 }
01660
01661
01662 include_once ('classes/class.ilObjUser.php');
01663 $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
01664
01665
01666 if (!ilUtil::is_email($_POST["Fobject"]["email"]))
01667 {
01668 $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
01669 }
01670
01671 $start = $this->__toUnix($_POST["time_limit"]["from"]);
01672 $end = $this->__toUnix($_POST["time_limit"]["until"]);
01673
01674
01675 if (!$_POST["time_limit"]["unlimited"] and
01676 ( $start > $end))
01677 {
01678 $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
01679 }
01680
01681 if(!$this->ilias->account->getTimeLimitUnlimited())
01682 {
01683 if($start < $this->ilias->account->getTimeLimitFrom() or
01684 $end > $this->ilias->account->getTimeLimitUntil() or
01685 $_POST['time_limit']['unlimited'])
01686 {
01687 $_SESSION['error_post_vars'] = $_POST;
01688
01689 sendInfo($this->lng->txt('time_limit_not_within_owners'));
01690 $this->editObject();
01691
01692 return false;
01693 }
01694 }
01695
01696
01697
01698
01699 $_POST['Fobject']['time_limit_owner'] = $this->object->getTimeLimitOwner();
01700
01701 $_POST['Fobject']['time_limit_unlimited'] = (int) $_POST['time_limit']['unlimited'];
01702 $_POST['Fobject']['time_limit_from'] = $this->__toUnix($_POST['time_limit']['from']);
01703 $_POST['Fobject']['time_limit_until'] = $this->__toUnix($_POST['time_limit']['until']);
01704
01705 if($_POST['Fobject']['time_limit_unlimited'] != $this->object->getTimeLimitUnlimited() or
01706 $_POST['Fobject']['time_limit_from'] != $this->object->getTimeLimitFrom() or
01707 $_POST['Fobject']['time_limit_until'] != $this->object->getTimeLimitUntil())
01708 {
01709 $_POST['Fobject']['time_limit_message'] = 0;
01710 }
01711 else
01712 {
01713 $_POST['Fobject']['time_limit_message'] = $this->object->getTimeLimitMessage();
01714 }
01715
01716
01717
01718 if ($this->object->getAuthMode(true) != AUTH_LOCAL &&
01719 $this->object->getAuthMode(true) != AUTH_CAS &&
01720 $this->object->getAuthMode(true) != AUTH_SOAP)
01721 {
01722 $_POST['Fobject']['login'] = $this->object->getLogin();
01723 $_POST['Fobject']['passwd'] = "********";
01724 }
01725
01726 $this->object->assignData($_POST["Fobject"]);
01727 $this->object->setUserDefinedData($_POST['udf']);
01728
01729 if ($this->object->getAuthMode(true) == AUTH_LOCAL ||
01730 $this->object->getAuthMode(true) == AUTH_CAS ||
01731 $this->object->getAuthMode(true) == AUTH_SOAP)
01732 {
01733 $this->object->updateLogin($_POST["Fobject"]["login"]);
01734 }
01735
01736 $this->object->setTitle($this->object->getFullname());
01737 $this->object->setDescription($this->object->getEmail());
01738 $this->object->setLanguage($_POST["Fobject"]["language"]);
01739
01740
01741 $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
01742
01743 if ($this->object->getPref("style") != $sknst[1] ||
01744 $this->object->getPref("skin") != $sknst[0])
01745 {
01746 $this->object->setPref("skin", $sknst[0]);
01747 $this->object->setPref("style", $sknst[1]);
01748 }
01749
01750
01751 $this->object->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
01752
01753 $this->object->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
01754
01755 $this->update = $this->object->update();
01756
01757
01758 $mail_message = $this->__sendProfileMail();
01759 $msg = $this->lng->txt('saved_successfully').$mail_message;
01760
01761
01762 sendInfo($msg,true);
01763
01764 if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
01765 {
01766 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
01767 }
01768 else
01769 {
01770 $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01771 }
01772 }
01773
01774
01781 function activeRoleSaveObject()
01782 {
01783 global $rbacreview;
01784
01785 $_POST["id"] = $_POST["id"] ? $_POST["id"] : array();
01786
01787
01788 $global_roles_all = $rbacreview->getGlobalRoles();
01789 $assigned_global_roles = array_intersect($_POST["id"],$global_roles_all);
01790
01791 if (!count($_POST["id"]) or count($assigned_global_roles) < 1)
01792 {
01793 $this->ilias->raiseError($this->lng->txt("msg_min_one_active_role"),$this->ilias->error_obj->MESSAGE);
01794 }
01795
01796 if ($this->object->getId() == $_SESSION["AccountId"])
01797 {
01798 $_SESSION["RoleId"] = $_POST["id"];
01799 }
01800 else
01801 {
01802 if (count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
01803 {
01804
01805
01806 $roles = "RoleId|".serialize($_POST["id"]);
01807 $modified_data = preg_replace("/RoleId.*?;\}/",$roles,$user_online[$this->object->getId()]["data"]);
01808
01809 $q = "UPDATE usr_session SET data='".$modified_data."' WHERE user_id = '".$this->object->getId()."'";
01810 $this->ilias->db->query($q);
01811 }
01812 else
01813 {
01814
01815 }
01816 }
01817
01818 sendInfo($this->lng->txt("msg_roleassignment_active_changed").".<br/>".$this->lng->txt("msg_roleassignment_active_changed_comment"),true);
01819 $this->ctrl->redirect($this, "edit");
01820 }
01821
01827 function assignSaveObject()
01828 {
01829 global $rbacsystem, $rbacadmin, $rbacreview;
01830
01831 if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
01832 {
01833 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
01834 }
01835
01836 $selected_roles = $_POST["role_id"] ? $_POST["role_id"] : array();
01837 $posted_roles = $_POST["role_id_ctrl"] ? $_POST["role_id_ctrl"] : array();
01838
01839
01840 if ($this->object->getId() == SYSTEM_USER_ID and in_array(SYSTEM_ROLE_ID, $posted_roles))
01841 {
01842 array_push($selected_roles,SYSTEM_ROLE_ID);
01843 }
01844
01845 $global_roles_all = $rbacreview->getGlobalRoles();
01846 $assigned_roles_all = $rbacreview->assignedRoles($this->object->getId());
01847 $assigned_roles = array_intersect($assigned_roles_all,$posted_roles);
01848 $assigned_global_roles_all = array_intersect($assigned_roles_all,$global_roles_all);
01849 $assigned_global_roles = array_intersect($assigned_global_roles_all,$posted_roles);
01850 $posted_global_roles = array_intersect($selected_roles,$global_roles_all);
01851
01852 if ((empty($selected_roles) and count($assigned_roles_all) == count($assigned_roles))
01853 or (empty($posted_global_roles) and count($assigned_global_roles_all) == count($assigned_global_roles)))
01854 {
01855
01856
01857 sendInfo($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),true);
01858 $this->ctrl->redirect($this,'roleassignment');
01859 }
01860
01861 foreach (array_diff($assigned_roles,$selected_roles) as $role)
01862 {
01863 $rbacadmin->deassignUser($role,$this->object->getId());
01864 }
01865
01866 foreach (array_diff($selected_roles,$assigned_roles) as $role)
01867 {
01868 $rbacadmin->assignUser($role,$this->object->getId(),false);
01869 }
01870
01871 include_once "./classes/class.ilObjRole.php";
01872 ilObjRole::_updateSessionRoles(array($this->object->getId()));
01873
01874
01875 $this->object->update();
01876
01877 sendInfo($this->lng->txt("msg_roleassignment_changed"),true);
01878
01879 if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
01880 {
01881 $this->ctrl->redirect($this,'roleassignment');
01882 }
01883 else
01884 {
01885 $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
01886 }
01887
01888 }
01889
01895 function roleassignmentObject ()
01896 {
01897 global $rbacreview,$rbacsystem;
01898
01899 if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
01900 {
01901 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
01902 }
01903
01904 $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
01905
01906 if ($_SESSION['filtered_roles'] > 5)
01907 {
01908 $_SESSION['filtered_roles'] = 0;
01909 }
01910
01911 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_role_assignment.html');
01912
01913 if(true)
01914 {
01915 $this->tpl->setCurrentBlock("filter");
01916 $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
01917 $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect());
01918 $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
01919 $this->tpl->setVariable("FILTER_NAME",'roleassignment');
01920 $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
01921 $this->tpl->parseCurrentBlock();
01922 }
01923
01924
01925 $role_list = $rbacreview->getRolesByFilter($_SESSION["filtered_roles"],$this->object->getId());
01926 $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
01927
01928 $counter = 0;
01929
01930 include_once ('class.ilObjRole.php');
01931
01932 foreach ($role_list as $role)
01933 {
01934
01935 $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
01936
01937
01938 if ($rbacreview->isDeleted($rolf[0]))
01939 {
01940 continue;
01941 }
01942
01943
01944 $path = "";
01945
01946 if ($this->tree->isInTree($rolf[0]))
01947 {
01948 if ($rolf[0] == ROLE_FOLDER_ID)
01949 {
01950 $path = $this->lng->txt("global");
01951 }
01952 else
01953 {
01954 $tmpPath = $this->tree->getPathFull($rolf[0]);
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967 $path = $tmpPath[count($tmpPath)-2]["title"];
01968 }
01969 }
01970 else
01971 {
01972 $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role["obj_id"].")</b>";
01973 }
01974
01975 $disabled = false;
01976
01977
01978 if (($this->object->getId() == SYSTEM_USER_ID and $role["obj_id"] == SYSTEM_ROLE_ID)
01979 or (!in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]) and $role["obj_id"] == SYSTEM_ROLE_ID))
01980 {
01981 $disabled = true;
01982 }
01983
01984 if (substr($role["title"],0,3) == "il_")
01985 {
01986 if (!$assignable)
01987 {
01988 $rolf_arr = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
01989 $rolf2 = $rolf_arr[0];
01990 }
01991 else
01992 {
01993 $rolf2 = $rolf;
01994 }
01995
01996 $parent_node = $this->tree->getParentNodeData($rolf2);
01997
01998 $role["description"] = $this->lng->txt("obj_".$parent_node["type"])." (#".$parent_node["obj_id"].")";
01999 }
02000
02001 $role_ids[$counter] = $role["obj_id"];
02002
02003 $result_set[$counter][] = ilUtil::formCheckBox(in_array($role["obj_id"],$assigned_roles),"role_id[]",$role["obj_id"],$disabled)."<input type=\"hidden\" name=\"role_id_ctrl[]\" value=\"".$role["obj_id"]."\"/>";
02004 $this->ctrl->setParameterByClass("ilobjrolegui", "ref_id", $rolf[0]);
02005 $this->ctrl->setParameterByClass("ilobjrolegui", "obj_id", $role["obj_id"]);
02006 $result_set[$counter][] = "<a href=\"".$this->ctrl->getLinkTargetByClass("ilobjrolegui", "perm")."\">".ilObjRole::_getTranslation($role["title"])."</a>";
02007 $result_set[$counter][] = $role["description"];
02008 $result_set[$counter][] = $path;
02009
02010 ++$counter;
02011 }
02012
02013 return $this->__showRolesTable($result_set,$role_ids);
02014 }
02015
02026 function insertPublicProfile($a_template_var, $a_template_block_name, $a_additional = "")
02027 {
02028 if ($_GET["vcard"] == 1)
02029 {
02030 $this->deliverVCardObject();
02031 }
02032 else
02033 {
02034 $this->tpl->setVariable($a_template_var,
02035 $this->getPublicProfile($a_additional, true));
02036 }
02037 }
02038
02039
02040 function getPublicProfileObject($a_additional = "", $no_ilctrl = false)
02041 {
02042 return $this->getPublicProfile($a_additional, $no_ilctrl);
02043 }
02044
02052 function getPublicProfile($a_additional = "", $no_ilctrl = false)
02053 {
02054 $tpl = new ilTemplate("tpl.usr_public_profile.html", true, true);
02055
02056 $tpl->setVariable("USR_PROFILE", $this->lng->txt("profile_of")." ".$this->object->getLogin());
02057
02058 $tpl->setVariable("ROWCOL1", "tblrow1");
02059 $tpl->setVariable("ROWCOL2", "tblrow2");
02060
02061
02062
02063 if ($this->object->getPref("public_profile") != "y")
02064 {
02065 return;
02066 }
02067
02068 $tpl->setVariable("TXT_NAME", $this->lng->txt("name"));
02069 $tpl->setVariable("FIRSTNAME", $this->object->getFirstName());
02070 $tpl->setVariable("LASTNAME", $this->object->getLastName());
02071
02072 $tpl->setCurrentBlock("vcard");
02073 $tpl->setVariable("TXT_VCARD", $this->lng->txt("vcard"));
02074 $tpl->setVariable("TXT_DOWNLOAD_VCARD", $this->lng->txt("vcard_download"));
02075 if ($no_ilctrl)
02076 {
02077
02078 $tpl->setVariable("HREF_VCARD", basename($_SERVER["PHP_SELF"]) . "?ref_id=".
02079 $_GET["ref_id"]."&user=" . $_GET["user"] . "&vcard=1");
02080 }
02081 else
02082 {
02083 $this->ctrl->setParameter($this, "user", $this->object->getId());
02084 $tpl->setVariable("HREF_VCARD", $this->ctrl->getLinkTarget($this, "deliverVCard"));
02085 }
02086 $tpl->setVariable("IMG_VCARD", ilUtil::getImagePath("vcard.png"));
02087
02088 $webspace_dir = ilUtil::getWebspaceDir("user");
02089 $check_dir = ilUtil::getWebspaceDir();
02090 $imagefile = $webspace_dir."/usr_images/".$this->object->getPref("profile_image");
02091 $check_file = $check_dir."/usr_images/".$this->object->getPref("profile_image");
02092
02093 if ($this->object->getPref("public_upload")=="y" && @is_file($check_file))
02094 {
02095
02096
02097 $tpl->setCurrentBlock("image");
02098 $tpl->setVariable("TXT_IMAGE",$this->lng->txt("image"));
02099 $tpl->setVariable("IMAGE_PATH", $webspace_dir."/usr_images/".$this->object->getPref("profile_image")."?dummy=".rand(1,999999));
02100 $tpl->parseCurrentBlock();
02101 }
02102
02103 $val_arr = array("getInstitution" => "institution", "getDepartment" => "department",
02104 "getStreet" => "street",
02105 "getZipcode" => "zip", "getCity" => "city", "getCountry" => "country",
02106 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
02107 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
02108 "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
02109
02110 foreach ($val_arr as $key => $value)
02111 {
02112
02113 if ($this->object->getPref("public_".$value) == "y")
02114 {
02115 $tpl->setCurrentBlock("profile_data");
02116 $tpl->setVariable("TXT_DATA", $this->lng->txt($value));
02117 $tpl->setVariable("DATA", $this->object->$key());
02118 $tpl->parseCurrentBlock();
02119 }
02120 }
02121
02122 if (is_array($a_additional))
02123 {
02124 foreach($a_additional as $key => $val)
02125 {
02126 $tpl->setCurrentBlock("profile_data");
02127 $tpl->setVariable("TXT_DATA", $key);
02128 $tpl->setVariable("DATA", $val);
02129 $tpl->parseCurrentBlock();
02130 }
02131 }
02132 return $tpl->get();
02133 }
02134
02138 function deliverVCardObject()
02139 {
02140 require_once "./classes/class.ilvCard.php";
02141 $vcard = new ilvCard();
02142
02143 if ($this->object->getPref("public_profile")!="y")
02144 {
02145 return;
02146 }
02147
02148 $vcard->setName($this->object->getLastName(), $this->object->getFirstName(), "", $this->object->getUTitle());
02149 $vcard->setNickname($this->object->getLogin());
02150
02151 $webspace_dir = ilUtil::getWebspaceDir("output");
02152 $imagefile = $webspace_dir."/usr_images/".$this->object->getPref("profile_image");
02153 if ($this->object->getPref("public_upload")=="y" && @is_file($imagefile))
02154 {
02155 $fh = fopen($imagefile, "r");
02156 if ($fh)
02157 {
02158 $image = fread($fh, filesize($imagefile));
02159 fclose($fh);
02160 require_once "./content/classes/Media/class.ilObjMediaObject.php";
02161 $mimetype = ilObjMediaObject::getMimeType($imagefile);
02162 if (preg_match("/^image/", $mimetype))
02163 {
02164 $type = $mimetype;
02165 }
02166 $vcard->setPhoto($image, $type);
02167 }
02168 }
02169
02170 $val_arr = array("getInstitution" => "institution", "getDepartment" => "department",
02171 "getStreet" => "street",
02172 "getZipcode" => "zip", "getCity" => "city", "getCountry" => "country",
02173 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
02174 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
02175 "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
02176
02177 $org = array();
02178 $adr = array();
02179 foreach ($val_arr as $key => $value)
02180 {
02181
02182 if ($this->object->getPref("public_".$value) == "y")
02183 {
02184 switch ($value)
02185 {
02186 case "institution":
02187 $org[0] = $this->object->$key();
02188 break;
02189 case "department":
02190 $org[1] = $this->object->$key();
02191 break;
02192 case "street":
02193 $adr[2] = $this->object->$key();
02194 break;
02195 case "zip":
02196 $adr[5] = $this->object->$key();
02197 break;
02198 case "city":
02199 $adr[3] = $this->object->$key();
02200 break;
02201 case "country":
02202 $adr[6] = $this->object->$key();
02203 break;
02204 case "phone_office":
02205 $vcard->setPhone($this->object->$key(), TEL_TYPE_WORK);
02206 break;
02207 case "phone_home":
02208 $vcard->setPhone($this->object->$key(), TEL_TYPE_HOME);
02209 break;
02210 case "phone_mobile":
02211 $vcard->setPhone($this->object->$key(), TEL_TYPE_CELL);
02212 break;
02213 case "fax":
02214 $vcard->setPhone($this->object->$key(), TEL_TYPE_FAX);
02215 break;
02216 case "email":
02217 $vcard->setEmail($this->object->$key());
02218 break;
02219 case "hobby":
02220 $vcard->setNote($this->object->$key());
02221 break;
02222 }
02223 }
02224 }
02225
02226 if (count($org))
02227 {
02228 $vcard->setOrganization(join(";", $org));
02229 }
02230 if (count($adr))
02231 {
02232 $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
02233 }
02234
02235 ilUtil::deliverData(utf8_decode($vcard->buildVCard()), $vcard->getFilename(), $vcard->getMimetype());
02236 }
02237
02238
02239 function __getDateSelect($a_type,$a_varname,$a_selected)
02240 {
02241 switch($a_type)
02242 {
02243 case "minute":
02244 for($i=0;$i<=60;$i++)
02245 {
02246 $days[$i] = $i < 10 ? "0".$i : $i;
02247 }
02248 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
02249
02250 case "hour":
02251 for($i=0;$i<24;$i++)
02252 {
02253 $days[$i] = $i < 10 ? "0".$i : $i;
02254 }
02255 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
02256
02257 case "day":
02258 for($i=1;$i<32;$i++)
02259 {
02260 $days[$i] = $i < 10 ? "0".$i : $i;
02261 }
02262 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
02263
02264 case "month":
02265 for($i=1;$i<13;$i++)
02266 {
02267 $month[$i] = $i < 10 ? "0".$i : $i;
02268 }
02269 return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
02270
02271 case "year":
02272 if($a_selected < date('Y',time()))
02273 {
02274 $start = $a_selected;
02275 }
02276 else
02277 {
02278 $start = date('Y',time());
02279 }
02280
02281 for($i = $start;$i < date("Y",time()) + 11;++$i)
02282 {
02283 $year[$i] = $i;
02284 }
02285 return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
02286 }
02287 }
02288
02289 function __toUnix($a_time_arr)
02290 {
02291 return mktime($a_time_arr["hour"],
02292 $a_time_arr["minute"],
02293 $a_time_arr["second"],
02294 $a_time_arr["month"],
02295 $a_time_arr["day"],
02296 $a_time_arr["year"]);
02297 }
02298
02299 function __showRolesTable($a_result_set,$a_role_ids = NULL)
02300 {
02301 global $rbacsystem;
02302
02303 $actions = array("assignSave" => $this->lng->txt("change_assignment"));
02304
02305 $tbl =& $this->__initTableGUI();
02306 $tpl =& $tbl->getTemplateObject();
02307
02308 $tpl->setCurrentBlock("tbl_form_header");
02309 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02310 $tpl->parseCurrentBlock();
02311
02312 $tpl->setCurrentBlock("tbl_action_row");
02313
02314 $tpl->setVariable("COLUMN_COUNTS",4);
02315 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02316
02317 foreach ($actions as $name => $value)
02318 {
02319 $tpl->setCurrentBlock("tbl_action_btn");
02320 $tpl->setVariable("BTN_NAME",$name);
02321 $tpl->setVariable("BTN_VALUE",$value);
02322 $tpl->parseCurrentBlock();
02323 }
02324
02325 if (!empty($a_role_ids))
02326 {
02327
02328 $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
02329 $tpl->setVariable("JS_VARNAME","role_id");
02330 $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_role_ids));
02331 $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
02332 $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
02333 $tpl->parseCurrentBlock();
02334 }
02335
02336 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
02337
02338
02339 $this->ctrl->setParameter($this,"cmd","roleassignment");
02340
02341
02342 $tbl->setTitle($this->lng->txt("edit_roleassignment"),"icon_role.gif",$this->lng->txt("roles"));
02343
02344
02345 $tbl->setHeaderNames(array("",$this->lng->txt("role"),$this->lng->txt("description"),$this->lng->txt("context")));
02346 $tbl->setHeaderVars(array("","title","description","context"),$this->ctrl->getParameterArray($this,"",false));
02347 $tbl->setColumnWidth(array("","30%","40%","30%"));
02348
02349 $this->__setTableGUIBasicData($tbl,$a_result_set,"roleassignment");
02350 $tbl->render();
02351 $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
02352
02353 return true;
02354 }
02355
02356 function &__initTableGUI()
02357 {
02358 include_once "class.ilTableGUI.php";
02359
02360 return new ilTableGUI(0,false);
02361 }
02362
02363 function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
02364 {
02365 switch($from)
02366 {
02367 default:
02368 $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
02369 break;
02370 }
02371
02372
02373 $tbl->setOrderColumn($order);
02374 $tbl->setOrderDirection($_GET["sort_order"]);
02375 $tbl->setOffset($_GET["offset"]);
02376 $tbl->setLimit($_GET["limit"]);
02377 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02378 $tbl->setData($result_set);
02379 }
02380
02381 function __unsetSessionVariables()
02382 {
02383 unset($_SESSION["filtered_roles"]);
02384 }
02385
02386 function __buildFilterSelect()
02387 {
02388 $action[0] = $this->lng->txt('assigned_roles');
02389 $action[1] = $this->lng->txt('all_roles');
02390 $action[2] = $this->lng->txt('all_global_roles');
02391 $action[3] = $this->lng->txt('all_local_roles');
02392 $action[4] = $this->lng->txt('internal_local_roles_only');
02393 $action[5] = $this->lng->txt('non_internal_local_roles_only');
02394
02395 return ilUtil::formSelect($_SESSION['filtered_roles'],"filter",$action,false,true);
02396 }
02397
02398 function hitsperpageObject()
02399 {
02400 parent::hitsperpageObject();
02401 $this->roleassignmentObject();
02402 }
02403
02408 function addAdminLocatorItems()
02409 {
02410 global $ilLocator;
02411
02412 if ($_GET["admin_mode"] == "settings")
02413 {
02414 $ilLocator->addItem($this->lng->txt("administration"),
02415 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
02416 ilFrameTargetInfo::_getFrame("MainContent"));
02417
02418 $ilLocator->addItem($this->lng->txt("obj_".ilObject::_lookupType(
02419 ilObject::_lookupObjId($_GET["ref_id"]))),
02420 $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view"));
02421
02422 if ($_GET["obj_id"] > 0)
02423 {
02424 $ilLocator->addItem($this->object->getTitle(),
02425 $this->ctrl->getLinkTarget($this, "view"));
02426 }
02427 }
02428 else
02429 {
02430
02431 }
02432 }
02433
02434 function showUpperIcon()
02435 {
02436 global $tree, $tpl, $objDefinition;
02437
02438 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
02439 {
02440 $tpl->setUpperIcon(
02441 $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view"));
02442 }
02443 else
02444 {
02445 if ($this->object->getRefId() != ROOT_FOLDER_ID &&
02446 $this->object->getRefId() != SYSTEM_FOLDER_ID)
02447 {
02448 $par_id = $tree->getParentId($this->usrf_ref_id);
02449 $tpl->setUpperIcon("repository.php?ref_id=".$par_id);
02450 }
02451 }
02452 }
02453
02454 function __sendProfileMail()
02455 {
02456 global $ilUser,$ilias;
02457
02458 if($_POST['send_mail'] != 'y')
02459 {
02460 return '';
02461 }
02462
02463
02464 $usr_lang = new ilLanguage($this->object->getLanguage());
02465 $usr_lang->loadLanguageModule('crs');
02466 $usr_lang->loadLanguageModule('registration');
02467
02468 include_once "classes/class.ilMimeMail.php";
02469
02470 $mmail = new ilMimeMail();
02471 $mmail->autoCheck(false);
02472 $mmail->From($ilUser->getEmail());
02473 $mmail->To($this->object->getEmail());
02474
02475
02476 $subject = $usr_lang->txt("profile_changed");
02477
02478
02479
02480 $body = ($usr_lang->txt("reg_mail_body_salutation")." ".$this->object->getFullname().",\n\n");
02481
02482 $date = $this->object->getApproveDate();
02483
02484 if((time() - strtotime($date)) < 10)
02485 {
02486 $body .= ($usr_lang->txt('reg_mail_body_approve')."\n\n");
02487 }
02488 else
02489 {
02490 $body .= ($usr_lang->txt('reg_mail_body_profile_changed')."\n\n");
02491 }
02492
02493
02494 if($_POST['Fobject']['passwd'] != '********')
02495 {
02496 $body .= $usr_lang->txt("reg_mail_body_text2")."\n".
02497 ILIAS_HTTP_PATH."/login.php?client_id=".$ilias->client_id."\n".
02498 $usr_lang->txt("login").": ".$this->object->getLogin()."\n".
02499 $usr_lang->txt("passwd").": ".$_POST["Fobject"]["passwd"]."\n\n";
02500 }
02501 $body .= ($usr_lang->txt("reg_mail_body_text3")."\n");
02502 $body .= $this->object->getProfileAsString($usr_lang);
02503
02504 $mmail->Subject($subject);
02505 $mmail->Body($body);
02506 $mmail->Send();
02507
02508
02509 return "<br/>".$this->lng->txt("mail_sent");
02510 }
02511
02512 }
02513 ?>