/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd, ilUDFPermissionHelper $a_permissions) { global $ilCtrl, $lng, $ilAccess, $lng; $this->permissions = $a_permissions; $this->perm_map = ilCustomUserFieldsGUI::getAccessPermissions(); parent::__construct($a_parent_obj, $a_parent_cmd); $this->setTitle($lng->txt("user_defined_list")); $this->setLimit(9999); $this->addColumn("", "", 1); $this->addColumn($this->lng->txt("user_field"), ""); $this->addColumn($this->lng->txt("access"), ""); $this->addColumn($this->lng->txt("export") . " / " . $this->lng->txt("search") . " / " . $this->lng->txt("certificate"), ""); $this->addColumn($this->lng->txt("actions"), ""); $this->setEnableHeader(true); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User"); $this->disable("footer"); $this->setEnableTitle(true); $user_field_definitions = ilUserDefinedFields::_getInstance(); $fds = $user_field_definitions->getDefinitions(); foreach ($fds as $k => $f) { $fds[$k]["key"] = $k; } $this->setData($fds); $this->addCommandButton("updateFields", $lng->txt("save")); $this->addMultiCommand("askDeleteField", $lng->txt("delete")); }
function start() { if (!is_array($this->users)) { return false; } $this->__buildHeader(); include_once "./Services/User/classes/class.ilUserDefinedFields.php"; $udf_data =& ilUserDefinedFields::_getInstance(); $udf_data->addToXML($this); foreach ($this->users as $user) { $this->__handleUser($user); } $this->__buildFooter(); return true; }
/** * constructor */ function ilPersonalProfileGUI() { global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl; include_once './Services/User/classes/class.ilUserDefinedFields.php'; $this->user_defined_fields =& ilUserDefinedFields::_getInstance(); $this->tpl =& $tpl; $this->lng =& $lng; $this->ilias =& $ilias; $this->ctrl =& $ilCtrl; $this->settings = $ilias->getAllSettings(); $lng->loadLanguageModule("jsmath"); $lng->loadLanguageModule("pd"); $this->upload_error = ""; $this->password_error = ""; $lng->loadLanguageModule("user"); // $ilCtrl->saveParameter($this, "user_page"); }
/** * get public profile html code * * Used in Personal Profile (as preview) and Portfolio (as page block) */ function getEmbeddable($a_add_goto = false) { global $ilSetting, $lng, $ilCtrl, $lng, $ilSetting, $ilUser; // get user object if (!ilObject::_exists($this->getUserId())) { return ""; } $user = new ilObjUser($this->getUserId()); $tpl = new ilTemplate("tpl.usr_public_profile.html", true, true, "Services/User"); $tpl->setVariable("ROWCOL1", "tblrow1"); $tpl->setVariable("ROWCOL2", "tblrow2"); if (!$this->offline && $ilUser->getId() != ANONYMOUS_USER_ID) { $ref_url = str_replace("&", "&", $this->getBackUrl()); if (!$ref_url) { $ref_url = basename($_SERVER['REQUEST_URI']); } $tpl->setCurrentBlock("mail"); $tpl->setVariable("TXT_MAIL", $lng->txt("send_mail")); require_once 'Services/Mail/classes/class.ilMailFormCall.php'; $tpl->setVariable('HREF_MAIL', ilMailFormCall::getLinkTarget($ref_url, '', array(), array('type' => 'new', 'rcp_to' => urlencode($user->getLogin())))); $tpl->parseCurrentBlock(); } $first_name = ""; if ($this->getPublicPref($user, "public_title") == "y") { $first_name .= $user->getUTitle() . " "; } $first_name .= $user->getFirstName(); $tpl->setVariable("TXT_NAME", $lng->txt("name")); $tpl->setVariable("FIRSTNAME", $first_name); $tpl->setVariable("LASTNAME", $user->getLastName()); if (!$this->offline) { // vcard $tpl->setCurrentBlock("vcard"); $tpl->setVariable("TXT_VCARD", $lng->txt("vcard")); $tpl->setVariable("TXT_DOWNLOAD_VCARD", $lng->txt("vcard_download")); $ilCtrl->setParameter($this, "user", $this->getUserId()); $tpl->setVariable("HREF_VCARD", $ilCtrl->getLinkTarget($this, "deliverVCard")); //$tpl->setVariable("IMG_VCARD", ilUtil::getImagePath("vcard.png")); } $webspace_dir = ilUtil::getWebspaceDir("user"); $check_dir = ilUtil::getWebspaceDir(); $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image") . "?dummy=" . rand(1, 999999); $check_file = $check_dir . "/usr_images/" . $user->getPref("profile_image"); if (!@is_file($check_file)) { $imagefile = $check_file = ilObjUser::_getPersonalPicturePath($user->getId(), "small", false, true); } if ($this->getPublicPref($user, "public_upload") == "y" && $imagefile != "") { //Getting the flexible path of image form ini file //$webspace_dir = ilUtil::getWebspaceDir("output"); $tpl->setCurrentBlock("image"); $tpl->setVariable("TXT_IMAGE", $lng->txt("image")); $tpl->setVariable("IMAGE_PATH", $imagefile); $tpl->setVariable("IMAGE_ALT", $lng->txt("personal_picture")); $tpl->parseCurrentBlock(); } // address if ($this->getPublicPref($user, "public_street") == "y" || $this->getPublicPref($user, "public_zipcode") == "y" || $this->getPublicPref($user, "public_city") == "y" || $this->getPublicPref($user, "public_country") == "y") { $address = array(); $val_arr = array("getStreet" => "street", "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country", "getSelectedCountry" => "sel_country"); foreach ($val_arr as $key => $value) { // if value "y" show information if ($this->getPublicPref($user, "public_" . $value) == "y") { $address_value = $user->{$key}(); // only if set if (trim($address_value) != "") { switch ($value) { case "street": $address[0] = $address_value; break; case "zipcode": case "city": $address[1] .= " " . $address_value; break; case "sel_country": $lng->loadLanguageModule("meta"); $address[2] = $lng->txt("meta_c_" . $address_value); break; case "country": $address[2] = $address_value; break; } } } } if (sizeof($address)) { $tpl->setCurrentBlock("address_line"); foreach ($address as $line) { if (trim($line)) { $tpl->setVariable("TXT_ADDRESS_LINE", trim($line)); $tpl->parseCurrentBlock(); } } $tpl->setCurrentBlock("address"); $tpl->setVariable("TXT_ADDRESS", $lng->txt("address")); $tpl->parseCurrentBlock(); } } // institution / department if ($this->getPublicPref($user, "public_institution") == "y" || $this->getPublicPref($user, "public_department") == "y") { $tpl->setCurrentBlock("inst_dep"); $sep = ""; if ($this->getPublicPref($user, "public_institution") == "y") { $h = $lng->txt("institution"); $v = $user->getInstitution(); $sep = " / "; } if ($this->getPublicPref($user, "public_department") == "y") { $h .= $sep . $lng->txt("department"); $v .= $sep . $user->getDepartment(); } $tpl->setVariable("TXT_INST_DEP", $h); $tpl->setVariable("INST_DEP", $v); $tpl->parseCurrentBlock(); } // contact $val_arr = array("getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home", "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email"); $v = $sep = ""; foreach ($val_arr as $key => $value) { // if value "y" show information if ($this->getPublicPref($user, "public_" . $value) == "y") { $v .= $sep . $lng->txt($value) . ": " . $user->{$key}(); $sep = "<br />"; } } if ($ilSetting->get("usr_settings_hide_instant_messengers") != 1) { $im_arr = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip"); foreach ($im_arr as $im_name) { if ($im_id = $user->getInstantMessengerId($im_name)) { if ($this->getPublicPref($user, "public_im_" . $im_name) != "n") { $v .= $sep . $lng->txt('im_' . $im_name) . ": " . $im_id; $sep = "<br />"; } } } } if ($v != "") { $tpl->parseCurrentBlock("contact"); $tpl->setVariable("TXT_CONTACT", $lng->txt("contact")); $tpl->setVariable("CONTACT", $v); $tpl->parseCurrentBlock(); } $val_arr = array("getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip"); foreach ($val_arr as $key => $value) { // if value "y" show information if ($this->getPublicPref($user, "public_" . $value) == "y") { $tpl->setCurrentBlock("profile_data"); $tpl->setVariable("TXT_DATA", $lng->txt($value)); $tpl->setVariable("DATA", $user->{$key}()); $tpl->parseCurrentBlock(); } } // delicious row //$d_set = new ilSetting("delicious"); if ($this->getPublicPref($user, "public_delicious") == "y") { $tpl->setCurrentBlock("delicious_row"); $tpl->setVariable("TXT_DELICIOUS", $lng->txt("delicious")); $tpl->setVariable("TXT_DEL_ICON", $lng->txt("delicious")); $tpl->setVariable("SRC_DEL_ICON", ilUtil::getImagePath("icon_delicious.png")); $tpl->setVariable("DEL_ACCOUNT", $user->getDelicious()); $tpl->parseCurrentBlock(); } // map include_once "./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php"; if (ilGoogleMapUtil::isActivated() && $this->getPublicPref($user, "public_location") == "y" && $user->getLatitude() != "") { $tpl->setVariable("TXT_LOCATION", $lng->txt("location")); include_once "./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php"; $map_gui = new ilGoogleMapGUI(); $map_gui->setMapId("user_map"); $map_gui->setWidth("350px"); $map_gui->setHeight("230px"); $map_gui->setLatitude($user->getLatitude()); $map_gui->setLongitude($user->getLongitude()); $map_gui->setZoom($user->getLocationZoom()); $map_gui->setEnableNavigationControl(true); $map_gui->addUserMarker($user->getId()); $tpl->setVariable("MAP_CONTENT", $map_gui->getHTML()); } // additional defined user data fields include_once './Services/User/classes/class.ilUserDefinedFields.php'; $this->user_defined_fields =& ilUserDefinedFields::_getInstance(); $user_defined_data = $user->getUserDefinedData(); foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) { // public setting if ($this->getPublicPref($user, "public_udf_" . $definition["field_id"]) == "y") { if ($user_defined_data["f_" . $definition["field_id"]] != "") { $tpl->setCurrentBlock("udf_data"); $tpl->setVariable("TXT_UDF_DATA", $definition["field_name"]); $tpl->setVariable("UDF_DATA", $user_defined_data["f_" . $definition["field_id"]]); $tpl->parseCurrentBlock(); } } } // additional information $additional = $this->getAdditional(); if (is_array($additional)) { foreach ($additional as $key => $val) { $tpl->setCurrentBlock("profile_data"); $tpl->setVariable("TXT_DATA", $key); $tpl->setVariable("DATA", $val); $tpl->parseCurrentBlock(); } } $goto = ""; if ($a_add_goto) { include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php'; $goto = new ilPermanentLinkGUI("usr", $user->getId()); $goto = $goto->getHTML(); } return $tpl->get() . $goto; }
/** * Check if all required personal data fields are set * * @param ilObjUser $a_user * @param bool $a_include_udf check custom fields, too * @param bool $a_personal_data_only only check fields which are visible in personal data * @return bool */ static function isProfileIncomplete($a_user, $a_include_udf = true, $a_personal_data_only = true) { global $ilSetting; // standard fields foreach (self::$user_field as $field => $definition) { // only if visible in personal data if ($a_personal_data_only && $ilSetting->get("usr_settings_hide_" . $field)) { continue; } if ($ilSetting->get("require_" . $field) && $definition["method"]) { $value = $a_user->{$definition["method"]}(); if ($value == "") { return true; } } } // custom fields if ($a_include_udf) { $user_defined_data = $a_user->getUserDefinedData(); include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields = ilUserDefinedFields::_getInstance(); foreach ($user_defined_fields->getRequiredDefinitions() as $field => $definition) { // only if visible in personal data if ($a_personal_data_only && !$definition["visible"]) { continue; } if (!$user_defined_data["f_" . $field]) { return true; } } } return false; }
/** * handler for end of element when in import user mode. */ function importEndTag($a_xml_parser, $a_name) { global $ilias, $rbacadmin, $rbacreview, $ilUser, $lng, $ilSetting; switch ($a_name) { case "Role": $this->roles[$this->current_role_id]["name"] = $this->cdata; $this->roles[$this->current_role_id]["type"] = $this->current_role_type; $this->roles[$this->current_role_id]["action"] = $this->current_role_action; break; case "PersonalPicture": switch ($this->personalPicture["encoding"]) { case "Base64": $this->personalPicture["content"] = base64_decode($this->cdata); break; case "UUEncode": // this only works with PHP >= 5 if (version_compare(PHP_VERSION, '5', '>=')) { $this->personalPicture["content"] = convert_uudecode($this->cdata); } break; } break; case "User": $this->userObj->setFullname(); // Fetch the user_id from the database, if we didn't have it in xml file // fetch as well, if we are trying to insert -> recognize duplicates! if ($this->user_id == -1 || $this->action == "Insert") { $user_id = ilObjUser::getUserIdByLogin($this->userObj->getLogin()); } else { $user_id = $this->user_id; } //echo $user_id.":".$this->userObj->getLogin(); // Handle conflicts switch ($this->conflict_rule) { case IL_FAIL_ON_CONFLICT: // do not change action break; case IL_UPDATE_ON_CONFLICT: switch ($this->action) { case "Insert": if ($user_id) { $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_replaced"), "Insert", "Update")); $this->action = "Update"; } break; case "Update": if (!$user_id) { $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_replaced"), "Update", "Insert")); $this->action = "Insert"; } break; case "Delete": if (!$user_id) { $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Delete")); $this->action = "Ignore"; } break; } break; case IL_IGNORE_ON_CONFLICT: switch ($this->action) { case "Insert": if ($user_id) { $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Insert")); $this->action = "Ignore"; } break; case "Update": if (!$user_id) { $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Update")); $this->action = "Ignore"; } break; case "Delete": if (!$user_id) { $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Delete")); $this->action = "Ignore"; } break; } break; } // check external account conflict (if external account is already used) // note: we cannot apply conflict rules in the same manner as to logins here // so we ignore records with already existing external accounts. //echo $this->userObj->getAuthMode().'h'; $am = $this->userObj->getAuthMode() == "default" || $this->userObj->getAuthMode() == "" ? ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode')) : $this->userObj->getAuthMode(); $loginForExternalAccount = $this->userObj->getExternalAccount() == "" ? "" : ilObjUser::_checkExternalAuthAccount($am, $this->userObj->getExternalAccount()); switch ($this->action) { case "Insert": if ($loginForExternalAccount != "") { $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_insert_ext_account_exists") . " (" . $this->userObj->getExternalAccount() . ")"); $this->action = "Ignore"; } break; case "Update": // this variable describes the ILIAS login which belongs to the given external account!!! // it is NOT nescessarily the ILIAS login of the current user record !! // so if we found an ILIAS login according to the authentication method // check if the ILIAS login belongs to the current user record, otherwise somebody else is using it! if ($loginForExternalAccount != "") { // check if we changed the value! $externalAccountHasChanged = $this->userObj->getExternalAccount() != ilObjUser::_lookupExternalAccount($this->user_id); // if it has changed and the external login if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin())) { $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_update_ext_account_exists") . " (" . $this->userObj->getExternalAccount() . ")"); $this->action = "Ignore"; } } break; } // Perform the action switch ($this->action) { case "Insert": if ($user_id) { $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_cant_insert")); } else { if (!strlen($this->currPassword) == 0) { switch ($this->currPasswordType) { case "ILIAS2": $this->userObj->setPasswd($this->currPassword, IL_PASSWD_CRYPT); break; case "ILIAS3": $this->userObj->setPasswd($this->currPassword, IL_PASSWD_MD5); break; case "PLAIN": $this->userObj->setPasswd($this->currPassword, IL_PASSWD_PLAIN); $this->acc_mail->setUserPassword($this->currPassword); break; } } else { // this does the trick for empty passwords // since a MD5 string has always 32 characters, // no hashed password combination will ever equal to // an empty string $this->userObj->setPasswd("", IL_PASSWD_MD5); } $this->userObj->setTitle($this->userObj->getFullname()); $this->userObj->setDescription($this->userObj->getEmail()); if (!$this->time_limit_owner_set) { $this->userObj->setTimeLimitOwner($this->getFolderId()); } // default time limit settings if (!$this->time_limit_set) { $this->userObj->setTimeLimitUnlimited(1); $this->userObj->setTimeLimitMessage(0); if (!$this->approve_date_set) { $this->userObj->setApproveDate(date("Y-m-d H:i:s")); } } $this->userObj->setActive($this->currActive == 'true' || is_null($this->currActive)); // Finally before saving new user. // Check if profile is incomplete // #8759 if (count($this->udf_data)) { $this->userObj->setUserDefinedData($this->udf_data); } $this->userObj->setProfileIncomplete($this->checkProfileIncomplete($this->userObj)); $this->userObj->create(); //insert user data in table user_data $this->userObj->saveAsNew(false); // Set default prefs $this->userObj->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30)); $this->userObj->setPref('show_users_online', $ilSetting->get('show_users_online', 'y')); if (count($this->prefs)) { foreach ($this->prefs as $key => $value) { if ($key != "mail_incoming_type" && $key != "mail_signature" && $key != "mail_linebreak") { $this->userObj->setPref($key, $value); } } } $this->userObj->writePrefs(); // update mail preferences, to be extended $this->updateMailPreferences($this->userObj->getId()); if (is_array($this->personalPicture)) { if (strlen($this->personalPicture["content"])) { $extension = "jpg"; if (preg_match("/.*(png|jpg|gif|jpeg)\$/", $this->personalPicture["imagetype"], $matches)) { $extension = $matches[1]; } $tmp_name = $this->saveTempImage($this->personalPicture["content"], ".{$extension}"); if (strlen($tmp_name)) { ilObjUser::_uploadPersonalPicture($tmp_name, $this->userObj->getId()); unlink($tmp_name); } } } if ($this->ilincdata["id"]) { include_once 'Modules/ILinc/classes/class.ilObjiLincUser.php'; $ilinc_user = new ilObjiLincUser($this->userObj); $ilinc_user->setVar("id", $this->ilincdata["id"]); $ilinc_user->setVar("login", $this->ilincdata["login"]); $ilinc_user->setVar("passwd", $this->ilincdata["password"]); $ilinc_user->update(); } //set role entries foreach ($this->roles as $role_id => $role) { if ($this->role_assign[$role_id]) { $this->assignToRole($this->userObj, $this->role_assign[$role_id]); } } if (count($this->udf_data)) { include_once './Services/User/classes/class.ilUserDefinedData.php'; $udd = new ilUserDefinedData($this->userObj->getId()); foreach ($this->udf_data as $field => $value) { $udd->set("f_" . $field, $value); } $udd->update(); } $this->sendAccountMail(); $this->logSuccess($this->userObj->getLogin(), $this->userObj->getId(), "Insert"); // reset account mail object $this->acc_mail->reset(); } break; case "Update": if (!$user_id) { $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_cant_update")); } else { $updateUser = new ilObjUser($user_id); $updateUser->read(); $updateUser->readPrefs(); if ($this->currPassword != null) { switch ($this->currPasswordType) { case "ILIAS2": $updateUser->setPasswd($this->currPassword, IL_PASSWD_CRYPT); break; case "ILIAS3": $updateUser->setPasswd($this->currPassword, IL_PASSWD_MD5); break; case "PLAIN": $updateUser->setPasswd($this->currPassword, IL_PASSWD_PLAIN); $this->acc_mail->setUserPassword($this->currPassword); break; } } if (!is_null($this->userObj->getFirstname())) { $updateUser->setFirstname($this->userObj->getFirstname()); } if (!is_null($this->userObj->getLastname())) { $updateUser->setLastname($this->userObj->getLastname()); } if (!is_null($this->userObj->getUTitle())) { $updateUser->setUTitle($this->userObj->getUTitle()); } if (!is_null($this->userObj->getGender())) { $updateUser->setGender($this->userObj->getGender()); } if (!is_null($this->userObj->getEmail())) { $updateUser->setEmail($this->userObj->getEmail()); } if (!is_null($this->userObj->getBirthday())) { $updateUser->setBirthday($this->userObj->getBirthday()); } if (!is_null($this->userObj->getInstitution())) { $updateUser->setInstitution($this->userObj->getInstitution()); } if (!is_null($this->userObj->getStreet())) { $updateUser->setStreet($this->userObj->getStreet()); } if (!is_null($this->userObj->getCity())) { $updateUser->setCity($this->userObj->getCity()); } if (!is_null($this->userObj->getZipCode())) { $updateUser->setZipCode($this->userObj->getZipCode()); } if (!is_null($this->userObj->getCountry())) { $updateUser->setCountry($this->userObj->getCountry()); } if (!is_null($this->userObj->getPhoneOffice())) { $updateUser->setPhoneOffice($this->userObj->getPhoneOffice()); } if (!is_null($this->userObj->getPhoneHome())) { $updateUser->setPhoneHome($this->userObj->getPhoneHome()); } if (!is_null($this->userObj->getPhoneMobile())) { $updateUser->setPhoneMobile($this->userObj->getPhoneMobile()); } if (!is_null($this->userObj->getFax())) { $updateUser->setFax($this->userObj->getFax()); } if (!is_null($this->userObj->getHobby())) { $updateUser->setHobby($this->userObj->getHobby()); } if (!is_null($this->userObj->getComment())) { $updateUser->setComment($this->userObj->getComment()); } if (!is_null($this->userObj->getDepartment())) { $updateUser->setDepartment($this->userObj->getDepartment()); } if (!is_null($this->userObj->getMatriculation())) { $updateUser->setMatriculation($this->userObj->getMatriculation()); } if (!is_null($this->currActive)) { $updateUser->setActive($this->currActive == "true", is_object($ilUser) ? $ilUser->getId() : 0); } if (!is_null($this->userObj->getClientIP())) { $updateUser->setClientIP($this->userObj->getClientIP()); } if (!is_null($this->userObj->getTimeLimitUnlimited())) { $updateUser->setTimeLimitUnlimited($this->userObj->getTimeLimitUnlimited()); } if (!is_null($this->userObj->getTimeLimitFrom())) { $updateUser->setTimeLimitFrom($this->userObj->getTimeLimitFrom()); } if (!is_null($this->userObj->getTimeLimitUntil())) { $updateUser->setTimeLimitUntil($this->userObj->getTimeLimitUntil()); } if (!is_null($this->userObj->getTimeLimitMessage())) { $updateUser->setTimeLimitMessage($this->userObj->getTimeLimitMessage()); } if (!is_null($this->userObj->getApproveDate())) { $updateUser->setApproveDate($this->userObj->getApproveDate()); } if (!is_null($this->userObj->getAgreeDate())) { $updateUser->setAgreeDate($this->userObj->getAgreeDate()); } if (!is_null($this->userObj->getLanguage())) { $updateUser->setLanguage($this->userObj->getLanguage()); } if (!is_null($this->userObj->getExternalAccount())) { $updateUser->setExternalAccount($this->userObj->getExternalAccount()); } // Fixed: if auth_mode is not set, it was always overwritten with auth_default #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode()); if ($this->auth_mode_set) { $updateUser->setAuthMode($this->userObj->getAuthMode()); } if (!is_null($this->userObj->getInstantMessengerId("aim"))) { $updateUser->setInstantMessengerId("aim", $this->userObj->getInstantMessengerId("aim")); } if (!is_null($this->userObj->getInstantMessengerId("msn"))) { $updateUser->setInstantMessengerId("msn", $this->userObj->getInstantMessengerId("msn")); } if (!is_null($this->userObj->getInstantMessengerId("icq"))) { $updateUser->setInstantMessengerId("icq", $this->userObj->getInstantMessengerId("icq")); } if (!is_null($this->userObj->getInstantMessengerId("yahoo"))) { $updateUser->setInstantMessengerId("yahoo", $this->userObj->getInstantMessengerId("yahoo")); } if (!is_null($this->userObj->getInstantMessengerId("skype"))) { $updateUser->setInstantMessengerId("skype", $this->userObj->getInstantMessengerId("skype")); } if (!is_null($this->userObj->getInstantMessengerId("jabber"))) { $updateUser->setInstantMessengerId("jabber", $this->userObj->getInstantMessengerId("jabber")); } if (!is_null($this->userObj->getInstantMessengerId("voip"))) { $updateUser->setInstantMessengerId("voip", $this->userObj->getInstantMessengerId("voip")); } // Special handlin since it defaults to 7 (USER_FOLDER_ID) if ($this->time_limit_owner_set) { $updateUser->setTimeLimitOwner($this->userObj->getTimeLimitOwner()); } if (count($this->prefs)) { foreach ($this->prefs as $key => $value) { if ($key != "mail_incoming_type" && $key != "mail_signature" && $key != "mail_linebreak") { $updateUser->setPref($key, $value); } } } // save user preferences (skin and style) if ($this->updateLookAndSkin) { $updateUser->setPref("skin", $this->userObj->getPref("skin")); $updateUser->setPref("style", $this->userObj->getPref("style")); } $updateUser->writePrefs(); // update mail preferences, to be extended $this->updateMailPreferences($updateUser->getId()); // #8759 if (count($this->udf_data)) { $updateUser->setUserDefinedData($this->udf_data); } $updateUser->setProfileIncomplete($this->checkProfileIncomplete($updateUser)); $updateUser->setTitle($updateUser->getFullname()); $updateUser->setDescription($updateUser->getEmail()); $updateUser->update(); if ($this->ilincdata["id"]) { include_once 'Modules/ILinc/classes/class.ilObjiLincUser.php'; $ilinc_user = new ilObjiLincUser($updateUser); $ilinc_user->setVar("id", $this->ilincdata["id"]); $ilinc_user->setVar("login", $this->ilincdata["login"]); $ilinc_user->setVar("passwd", $this->ilincdata["password"]); $ilinc_user->update(); } if (count($this->udf_data)) { include_once './Services/User/classes/class.ilUserDefinedData.php'; $udd = new ilUserDefinedData($updateUser->getId()); foreach ($this->udf_data as $field => $value) { $udd->set("f_" . $field, $value); } $udd->update(); } // update login if (!is_null($this->userObj->getLogin()) && $this->user_id != -1) { try { $updateUser->updateLogin($this->userObj->getLogin()); } catch (ilUserException $e) { } } // if language has changed if (is_array($this->personalPicture)) { if (strlen($this->personalPicture["content"])) { $extension = "jpg"; if (preg_match("/.*(png|jpg|gif|jpeg)\$/", $this->personalPicture["imagetype"], $matches)) { $extension = $matches[1]; } $tmp_name = $this->saveTempImage($this->personalPicture["content"], ".{$extension}"); if (strlen($tmp_name)) { ilObjUser::_uploadPersonalPicture($tmp_name, $this->userObj->getId()); unlink($tmp_name); } } } //update role entries //------------------- foreach ($this->roles as $role_id => $role) { if ($this->role_assign[$role_id]) { switch ($role["action"]) { case "Assign": $this->assignToRole($updateUser, $this->role_assign[$role_id]); break; case "AssignWithParents": $this->assignToRoleWithParents($updateUser, $this->role_assign[$role_id]); break; case "Detach": $this->detachFromRole($updateUser, $this->role_assign[$role_id]); break; } } } $this->logSuccess($updateUser->getLogin(), $user_id, "Update"); } break; case "Delete": if (!$user_id) { $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_cant_delete")); } else { $deleteUser = new ilObjUser($user_id); $deleteUser->delete(); $this->logSuccess($this->userObj->getLogin(), $user_id, "Delete"); } break; } // init role array for next user $this->roles = array(); break; case "Login": $this->userObj->setLogin($this->cdata); break; case "Password": $this->currPassword = $this->cdata; break; case "Firstname": $this->userObj->setFirstname($this->cdata); break; case "Lastname": $this->userObj->setLastname($this->cdata); break; case "Title": $this->userObj->setUTitle($this->cdata); break; case "Gender": $this->userObj->setGender($this->cdata); break; case "Email": $this->userObj->setEmail($this->cdata); break; case "Birthday": $timestamp = strtotime($this->cdata); if ($timestamp !== false) { $this->userObj->setBirthday($this->cdata); } break; case "Institution": $this->userObj->setInstitution($this->cdata); break; case "Street": $this->userObj->setStreet($this->cdata); break; case "City": $this->userObj->setCity($this->cdata); break; case "PostalCode": $this->userObj->setZipCode($this->cdata); break; case "Country": $this->userObj->setCountry($this->cdata); break; case "PhoneOffice": $this->userObj->setPhoneOffice($this->cdata); break; case "PhoneHome": $this->userObj->setPhoneHome($this->cdata); break; case "PhoneMobile": $this->userObj->setPhoneMobile($this->cdata); break; case "Fax": $this->userObj->setFax($this->cdata); break; case "Hobby": $this->userObj->setHobby($this->cdata); break; case "Comment": $this->userObj->setComment($this->cdata); break; case "Department": $this->userObj->setDepartment($this->cdata); break; case "Matriculation": $this->userObj->setMatriculation($this->cdata); break; case "Active": $this->currActive = $this->cdata; break; case "ClientIP": $this->userObj->setClientIP($this->cdata); break; case "TimeLimitOwner": $this->time_limit_owner_set = true; $this->userObj->setTimeLimitOwner($this->cdata); break; case "TimeLimitUnlimited": $this->time_limit_set = true; $this->userObj->setTimeLimitUnlimited($this->cdata); break; case "TimeLimitFrom": if (is_numeric($this->cdata)) { // Treat cdata as a unix timestamp $this->userObj->setTimeLimitFrom($this->cdata); } else { // Try to convert cdata into unix timestamp, or ignore it $timestamp = strtotime($this->cdata); if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") { $this->userObj->setTimeLimitFrom($timestamp); } elseif ($this->cdata == "0000-00-00 00:00:00") { $this->userObj->setTimeLimitFrom(null); } } break; case "TimeLimitUntil": if (is_numeric($this->cdata)) { // Treat cdata as a unix timestamp $this->userObj->setTimeLimitUntil($this->cdata); } else { // Try to convert cdata into unix timestamp, or ignore it $timestamp = strtotime($this->cdata); if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") { $this->userObj->setTimeLimitUntil($timestamp); } elseif ($this->cdata == "0000-00-00 00:00:00") { $this->userObj->setTimeLimitUntil(null); } } break; case "TimeLimitMessage": $this->userObj->setTimeLimitMessage($this->cdata); break; case "ApproveDate": $this->approve_date_set = true; if (is_numeric($this->cdata)) { // Treat cdata as a unix timestamp $tmp_date = new ilDateTime($this->cdata, IL_CAL_UNIX); $this->userObj->setApproveDate($tmp_date->get(IL_CAL_DATETIME)); } else { // Try to convert cdata into unix timestamp, or ignore it $timestamp = strtotime($this->cdata); if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") { $tmp_date = new ilDateTime($timestamp, IL_CAL_UNIX); $this->userObj->setApproveDate($tmp_date->get(IL_CAL_DATETIME)); } elseif ($this->cdata == "0000-00-00 00:00:00") { $this->userObj->setApproveDate(null); } } break; case "AgreeDate": if (is_numeric($this->cdata)) { // Treat cdata as a unix timestamp $tmp_date = new ilDateTime($this->cdata, IL_CAL_UNIX); $this->userObj->setAgreeDate($tmp_date->get(IL_CAL_DATETIME)); } else { // Try to convert cdata into unix timestamp, or ignore it $timestamp = strtotime($this->cdata); if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") { $tmp_date = new ilDateTime($timestamp, IL_CAL_UNIX); $this->userObj->setAgreeDate($tmp_date->get(IL_CAL_DATETIME)); } elseif ($this->cdata == "0000-00-00 00:00:00") { $this->userObj->setAgreeDate(null); } } break; case "iLincID": $this->ilincdata["id"] = $this->cdata; break; case "iLincLogin": $this->{$ilincdata}["login"] = $this->cdata; break; case "iLincPasswd": $this->{$ilincdata}["password"] = $this->cdata; //$this->userObj->setiLincData($this->ilincdata); break; case "ExternalAccount": $this->userObj->setExternalAccount($this->cdata); break; case "Look": $this->updateLookAndSkin = false; if (!$this->hideSkin) { // TODO: what to do with disabled skins? is it possible to change the skin via import? if (strlen($this->skin) > 0 && strlen($this->style) > 0) { if (is_array($this->userStyles)) { if (in_array($this->skin . ":" . $this->style, $this->userStyles)) { $this->userObj->setPref("skin", $this->skin); $this->userObj->setPref("style", $this->style); $this->updateLookAndSkin = true; } } } } break; case 'UserDefinedField': include_once './Services/User/classes/class.ilUserDefinedFields.php'; $udf = ilUserDefinedFields::_getInstance(); if ($field_id = $udf->fetchFieldIdFromImportId($this->tmp_udf_id)) { $this->udf_data[$field_id] = $this->cdata; } elseif ($field_id = $udf->fetchFieldIdFromName($this->tmp_udf_name)) { $this->udf_data[$field_id] = $this->cdata; } break; case 'AccountInfo': if ($this->current_messenger_type == "delicious") { $this->userObj->setDelicious($this->cdata); } elseif ($this->current_messenger_type == "external") { $this->userObj->setExternalAccount($this->cdata); } else { $this->userObj->setInstantMessengerId($this->current_messenger_type, $this->cdata); } break; case 'Pref': if ($this->currentPrefKey != null && strlen(trim($this->cdata)) > 0 && ilUserXMLWriter::isPrefExportable($this->currentPrefKey)) { $this->prefs[$this->currentPrefKey] = trim($this->cdata); } $this->currentPrefKey = null; break; } }
/** * Update custom fields properties (from table gui) */ function updateFields($action = "") { global $lng, $ilCtrl; $user_field_definitions = ilUserDefinedFields::_getInstance(); $a_fields = $user_field_definitions->getDefinitions(); $perm_map = self::getAccessPermissions(); foreach ($a_fields as $field_id => $definition) { $perms = $this->permissions->hasPermissions(ilUDFPermissionHelper::CONTEXT_FIELD, $field_id, array(array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_REGISTRATION), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_LOCAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_COURSES), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_GROUPS), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_REQUIRED), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_EXPORT), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_SEARCHABLE), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_CERTIFICATE))); // disabled field foreach ($perm_map as $prop => $perm) { if (!$perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm]) { $_POST['chb'][$prop . '_' . $field_id] = $definition[$prop]; } } } foreach ($a_fields as $field_id => $definition) { if (isset($_POST['chb']['required_' . $field_id]) && (int) $_POST['chb']['required_' . $field_id] && (!isset($_POST['chb']['visib_reg_' . $field_id]) || !(int) $_POST['chb']['visib_reg_' . $field_id])) { $this->confirm_change = true; ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected')); $this->listUserDefinedFields(); return false; } } foreach ($a_fields as $field_id => $definition) { $user_field_definitions->setFieldName($definition['field_name']); $user_field_definitions->setFieldType($definition['field_type']); $user_field_definitions->setFieldValues($definition['field_values']); $user_field_definitions->enableVisible((int) $_POST['chb']['visible_' . $field_id]); $user_field_definitions->enableChangeable((int) $_POST['chb']['changeable_' . $field_id]); $user_field_definitions->enableRequired((int) $_POST['chb']['required_' . $field_id]); $user_field_definitions->enableSearchable((int) $_POST['chb']['searchable_' . $field_id]); $user_field_definitions->enableExport((int) $_POST['chb']['export_' . $field_id]); $user_field_definitions->enableCourseExport((int) $_POST['chb']['course_export_' . $field_id]); $user_field_definitions->enableVisibleLocalUserAdministration((int) $_POST['chb']['visib_lua_' . $field_id]); $user_field_definitions->enableChangeableLocalUserAdministration((int) $_POST['chb']['changeable_lua_' . $field_id]); $user_field_definitions->enableGroupExport((int) $_POST['chb']['group_export_' . $field_id]); $user_field_definitions->enableVisibleRegistration((int) $_POST['chb']['visib_reg_' . $field_id]); $user_field_definitions->enableCertificate((int) $_POST['chb']['certificate_' . $field_id]); $user_field_definitions->update($field_id); } ilUtil::sendSuccess($lng->txt('settings_saved'), true); $ilCtrl->redirect($this); }
/** * Get formatted mail body text of user profile data. * * @param object Language object (choose user language of recipient) or null to use language of current user */ function getProfileAsString(&$a_language) { include_once './Services/AccessControl/classes/class.ilObjRole.php'; include_once './Services/Utilities/classes/class.ilFormat.php'; global $lng, $rbacreview; $language =& $a_language; $language->loadLanguageModule('registration'); $language->loadLanguageModule('crs'); $body = ''; $body .= $language->txt("login") . ": " . $this->getLogin() . "\n"; if (strlen($this->getUTitle())) { $body .= $language->txt("title") . ": " . $this->getUTitle() . "\n"; } if (strlen($this->getGender())) { $gender = $this->getGender() == 'm' ? $language->txt('gender_m') : $language->txt('gender_f'); $body .= $language->txt("gender") . ": " . $gender . "\n"; } if (strlen($this->getFirstname())) { $body .= $language->txt("firstname") . ": " . $this->getFirstname() . "\n"; } if (strlen($this->getLastname())) { $body .= $language->txt("lastname") . ": " . $this->getLastname() . "\n"; } if (strlen($this->getInstitution())) { $body .= $language->txt("institution") . ": " . $this->getInstitution() . "\n"; } if (strlen($this->getDepartment())) { $body .= $language->txt("department") . ": " . $this->getDepartment() . "\n"; } if (strlen($this->getStreet())) { $body .= $language->txt("street") . ": " . $this->getStreet() . "\n"; } if (strlen($this->getCity())) { $body .= $language->txt("city") . ": " . $this->getCity() . "\n"; } if (strlen($this->getZipcode())) { $body .= $language->txt("zipcode") . ": " . $this->getZipcode() . "\n"; } if (strlen($this->getCountry())) { $body .= $language->txt("country") . ": " . $this->getCountry() . "\n"; } if (strlen($this->getSelectedCountry())) { $body .= $language->txt("sel_country") . ": " . $this->getSelectedCountry() . "\n"; } if (strlen($this->getPhoneOffice())) { $body .= $language->txt("phone_office") . ": " . $this->getPhoneOffice() . "\n"; } if (strlen($this->getPhoneHome())) { $body .= $language->txt("phone_home") . ": " . $this->getPhoneHome() . "\n"; } if (strlen($this->getPhoneMobile())) { $body .= $language->txt("phone_mobile") . ": " . $this->getPhoneMobile() . "\n"; } if (strlen($this->getFax())) { $body .= $language->txt("fax") . ": " . $this->getFax() . "\n"; } if (strlen($this->getEmail())) { $body .= $language->txt("email") . ": " . $this->getEmail() . "\n"; } if (strlen($this->getHobby())) { $body .= $language->txt("hobby") . ": " . $this->getHobby() . "\n"; } if (strlen($this->getComment())) { $body .= $language->txt("referral_comment") . ": " . $this->getComment() . "\n"; } if (strlen($this->getMatriculation())) { $body .= $language->txt("matriculation") . ": " . $this->getMatriculation() . "\n"; } if (strlen($this->getCreateDate())) { ilDatePresentation::setUseRelativeDates(false); ilDatePresentation::setLanguage($language); $date = ilDatePresentation::formatDate(new ilDateTime($this->getCreateDate(), IL_CAL_DATETIME)); ilDatePresentation::resetToDefaults(); $body .= $language->txt("create_date") . ": " . $date . "\n"; } foreach ($rbacreview->getGlobalRoles() as $role) { if ($rbacreview->isAssigned($this->getId(), $role)) { $gr[] = ilObjRole::_lookupTitle($role); } } if (count($gr)) { $body .= $language->txt('reg_role_info') . ': ' . implode(',', $gr) . "\n"; } // Time limit if ($this->getTimeLimitUnlimited()) { $body .= $language->txt('time_limit') . ": " . $language->txt('crs_unlimited') . "\n"; } else { ilDatePresentation::setUseRelativeDates(false); ilDatePresentation::setLanguage($language); $period = ilDatePresentation::formatPeriod(new ilDateTime($this->getTimeLimitFrom(), IL_CAL_UNIX), new ilDateTime($this->getTimeLimitUntil(), IL_CAL_UNIX)); ilDatePresentation::resetToDefaults(); $start = new ilDateTime($this->getTimeLimitFrom(), IL_CAL_UNIX); $end = new ilDateTime($this->getTimeLimitUntil(), IL_CAL_UNIX); $body .= $language->txt('time_limit') . ': ' . $start->get(IL_CAL_DATETIME); $body .= $language->txt('time_limit') . ': ' . $end->get(IL_CAL_DATETIME); #$body .= $language->txt('time_limit').': '.$period; /* $body .= ($language->txt('time_limit').": ".$language->txt('crs_from')." ". ilFormat::formatUnixTime($this->getTimeLimitFrom(), true)." ". $language->txt('crs_to')." ". ilFormat::formatUnixTime($this->getTimeLimitUntil(), true)."\n"); */ } include_once './Services/User/classes/class.ilUserDefinedFields.php'; /** * @var ilUserDefinedFields $user_defined_fields */ $user_defined_fields = ilUserDefinedFields::_getInstance(); $user_defined_data = $this->getUserDefinedData(); foreach ($user_defined_fields->getDefinitions() as $field_id => $definition) { $data = $user_defined_data["f_" . $field_id]; if (strlen($data)) { if ($definition['field_type'] == UDF_TYPE_WYSIWYG) { $data = preg_replace('/\\<br(\\s*)?\\/?\\>/i', "\n", $data); $data = strip_tags($data); } $body .= $definition['field_name'] . ': ' . $data . "\n"; } } return $body; }
/** * Get custom certificate fields */ static function getCustomCertificateFields() { include_once "./Services/User/classes/class.ilUserDefinedFields.php"; $user_field_definitions = ilUserDefinedFields::_getInstance(); $fds = $user_field_definitions->getDefinitions(); $fields = array(); foreach ($fds as $f) { if ($f["certificate"]) { $fields[$f["field_id"]] = array("name" => $f["field_name"], "ph" => "[#" . str_replace(" ", "_", strtoupper($f["field_name"])) . "]"); } } return $fields; }
private function initUserDefinedFields() { include_once "./Services/User/classes/class.ilUserDefinedFields.php"; $this->udf = ilUserDefinedFields::_getInstance(); }
/** * Write data * @return */ protected function write() { // Add header line $row = 0; $col = 0; foreach ($all_fields = $this->getOrderedExportableFields() as $field) { switch ($field) { case 'role': #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status')); $this->addCol($this->lng->txt($this->getType() . '_role_status'), $row, $col++); break; case 'agreement': #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted')); $this->addCol($this->lng->txt('ps_agreement_accepted'), $row, $col++); break; case 'consultation_hour': $this->lng->loadLanguageModule('dateplaner'); $this->addCol($this->lng->txt('cal_ch_field_ch'), $row, $col++); break; default: if (substr($field, 0, 4) == 'udf_') { $field_id = explode('_', $field); include_once 'Services/User/classes/class.ilUserDefinedFields.php'; $udf = ilUserDefinedFields::_getInstance(); $def = $udf->getDefinition($field_id[1]); #$this->csv->addColumn($def['field_name']); $this->addCol($def['field_name'], $row, $col++); } elseif (substr($field, 0, 4) == 'cdf_') { $field_id = explode('_', $field); #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1])); $this->addCol(ilCourseDefinedFieldDefinition::_lookupName($field_id[1]), $row, $col++); } else { #$this->csv->addColumn($this->lng->txt($field)); $this->addCol($this->lng->txt($field), $row, $col++); } break; } } #$this->csv->addRow(); $this->addRow(); // Add user data foreach ($this->user_ids as $usr_id) { $row++; $col = 0; $udf_data = new ilUserDefinedData($usr_id); foreach ($all_fields as $field) { // Handle course defined fields if ($this->addUserDefinedField($udf_data, $field, $row, $col)) { $col++; continue; } if ($this->addCourseField($usr_id, $field, $row, $col)) { $col++; continue; } switch ($field) { case 'role': switch ($this->user_course_data[$usr_id]['role']) { case IL_CRS_ADMIN: #$this->csv->addColumn($this->lng->txt('crs_admin')); $this->addCol($this->lng->txt('crs_admin'), $row, $col++); break; case IL_CRS_TUTOR: #$this->csv->addColumn($this->lng->txt('crs_tutor')); $this->addCol($this->lng->txt('crs_tutor'), $row, $col++); break; case IL_CRS_MEMBER: #$this->csv->addColumn($this->lng->txt('crs_member')); $this->addCol($this->lng->txt('crs_member'), $row, $col++); break; case IL_GRP_ADMIN: #$this->csv->addColumn($this->lng->txt('il_grp_admin')); $this->addCol($this->lng->txt('il_grp_admin'), $row, $col++); break; case IL_GRP_MEMBER: #$this->csv->addColumn($this->lng->txt('il_grp_member')); $this->addCol($this->lng->txt('il_grp_member'), $row, $col++); break; case 'subscriber': #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber')); $this->addCol($this->lng->txt($this->getType() . '_subscriber'), $row, $col++); break; default: #$this->csv->addColumn($this->lng->txt('crs_waiting_list')); $this->addCol($this->lng->txt('crs_waiting_list'), $row, $col++); break; } break; case 'agreement': if (isset($this->agreement[$usr_id])) { if ($this->agreement[$usr_id]['accepted']) { #$this->csv->addColumn(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'],true)); $this->addCol(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'], true), $row, $col++); } else { #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); $this->addCol($this->lng->txt('ps_not_accepted'), $row, $col++); } } else { #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); $this->addCol($this->lng->txt('ps_not_accepted'), $row, $col++); } break; // These fields are always enabled // These fields are always enabled case 'username': #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']); $this->addCol($this->user_profile_data[$usr_id]['login'], $row, $col++); break; case 'firstname': case 'lastname': #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); $this->addCol($this->user_profile_data[$usr_id][$field], $row, $col++); break; case 'consultation_hour': include_once './Services/Booking/classes/class.ilBookingEntry.php'; $bookings = ilBookingEntry::lookupManagedBookingsForObject($this->obj_id, $GLOBALS['ilUser']->getId()); $uts = array(); foreach ((array) $bookings[$usr_id] as $ut) { ilDatePresentation::setUseRelativeDates(false); $tmp = ilDatePresentation::formatPeriod(new ilDateTime($ut['dt'], IL_CAL_UNIX), new ilDateTime($ut['dtend'], IL_CAL_UNIX)); if (strlen($ut['explanation'])) { $tmp .= ' ' . $ut['explanation']; } $uts[] = $tmp; } $uts_str = implode(',', $uts); $this->addCol($uts_str, $row, $col++); break; default: // Check aggreement if (!$this->privacy->courseConfirmationRequired() and !ilCourseDefinedFieldDefinition::_getFields($this->obj_id) or $this->agreement[$usr_id]['accepted']) { #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); $this->addCol($this->user_profile_data[$usr_id][$field], $row, $col++); } else { #$this->csv->addColumn(''); $this->addCol('', $row, $col++); } break; } } #$this->csv->addRow(); $this->addRow(); } }
protected function __createUser($a_role) { global $ilSetting, $rbacadmin; $this->userObj = new ilObjUser(); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->setMode(ilUserProfile::MODE_REGISTRATION); $map = array(); $up->skipGroup("preferences"); $up->skipGroup("settings"); $up->skipGroup("instant_messengers"); $up->skipField("password"); $up->skipField("birthday"); $up->skipField("upload"); foreach ($up->getStandardFields() as $k => $v) { if ($v["method"]) { $method = "set" . substr($v["method"], 3); if (method_exists($this->userObj, $method)) { if ($k != "username") { $k = "usr_" . $k; } $field_obj = $this->form->getItemByPostVar($k); if ($field_obj) { $this->userObj->{$method}($this->form->getInput($k)); } } } } $this->userObj->setFullName(); $birthday_obj = $this->form->getItemByPostVar("usr_birthday"); if ($birthday_obj) { $birthday = $this->form->getInput("usr_birthday"); $birthday = $birthday["date"]; // when birthday was not set, array will not be substituted with string by ilBirthdayInputGui if (!is_array($birthday)) { $this->userObj->setBirthday($birthday); } } // messenger $map = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip"); foreach ($map as $client) { $field = "usr_im_" . $client; $field_obj = $this->form->getItemByPostVar($field); if ($field_obj) { $this->userObj->setInstantMessengerId($client, $this->form->getInput($field)); } } $this->userObj->setTitle($this->userObj->getFullname()); $this->userObj->setDescription($this->userObj->getEmail()); if ($this->registration_settings->passwordGenerationEnabled()) { $password = ilUtil::generatePasswords(1); $password = $password[0]; } else { $password = $this->form->getInput("usr_password"); } $this->userObj->setPasswd($password); // Set user defined data include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields =& ilUserDefinedFields::_getInstance(); $defs = $user_defined_fields->getRegistrationDefinitions(); $udf = array(); foreach ($_POST as $k => $v) { if (substr($k, 0, 4) == "udf_") { $f = substr($k, 4); $udf[$f] = $v; } } $this->userObj->setUserDefinedData($udf); $this->userObj->setTimeLimitOwner(7); $this->code_was_used = false; if ($this->code_enabled) { // #10853 - could be optional $code = $this->form->getInput('usr_registration_code'); if ($code) { // set code to used include_once './Services/Registration/classes/class.ilRegistrationCode.php'; ilRegistrationCode::useCode($code); $this->code_was_used = true; } } // something went wrong with the form validation if (!$a_role) { global $ilias; $ilias->raiseError("Invalid role selection in registration" . ", IP: " . $_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL); } if ($this->registration_settings->getAccessLimitation()) { include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php'; $access_limitations_obj = new ilRegistrationRoleAccessLimitations(); $access_limit_mode = $access_limitations_obj->getMode($a_role); if ($access_limit_mode == 'absolute') { $access_limit = $access_limitations_obj->getAbsolute($a_role); $this->userObj->setTimeLimitUnlimited(0); $this->userObj->setTimeLimitUntil($access_limit); } elseif ($access_limit_mode == 'relative') { $rel_d = (int) $access_limitations_obj->getRelative($a_role, 'd'); $rel_m = (int) $access_limitations_obj->getRelative($a_role, 'm'); $rel_y = (int) $access_limitations_obj->getRelative($a_role, 'y'); $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time(); $this->userObj->setTimeLimitUnlimited(0); $this->userObj->setTimeLimitUntil($access_limit); } else { $this->userObj->setTimeLimitUnlimited(1); $this->userObj->setTimeLimitUntil(time()); } } else { $this->userObj->setTimeLimitUnlimited(1); $this->userObj->setTimeLimitUntil(time()); } $this->userObj->setTimeLimitFrom(time()); $this->userObj->create(); if ($this->registration_settings->getRegistrationType() == IL_REG_DIRECT || $this->registration_settings->getRegistrationType() == IL_REG_CODES || $this->code_was_used) { $this->userObj->setActive(1, 0); } else { if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) { $this->userObj->setActive(0, 0); } else { $this->userObj->setActive(0, 0); } } $this->userObj->updateOwner(); // set a timestamp for last_password_change // this ts is needed by the ACCOUNT_SECURITY_MODE_CUSTOMIZED // in ilSecuritySettings $this->userObj->setLastPasswordChangeTS(time()); //insert user data in table user_data $this->userObj->saveAsNew(); // store acceptance of user agreement $this->userObj->writeAccepted(); // setup user preferences $this->userObj->setLanguage($this->form->getInput('usr_language')); $hits_per_page = $ilSetting->get("hits_per_page"); if ($hits_per_page < 10) { $hits_per_page = 10; } $this->userObj->setPref("hits_per_page", $hits_per_page); $show_online = $ilSetting->get("show_users_online"); if ($show_online == "") { $show_online = "y"; } $this->userObj->setPref("show_users_online", $show_online); $this->userObj->writePrefs(); $rbacadmin->assignUser((int) $a_role, $this->userObj->getId(), true); return $password; }
protected function __createUser($a_role) { /** * @var $ilSetting ilSetting * @var $rbacadmin ilRbacAdmin * @var $lng ilLanguage */ global $ilSetting, $rbacadmin, $lng; // something went wrong with the form validation if (!$a_role) { global $ilias; $ilias->raiseError("Invalid role selection in registration" . ", IP: " . $_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL); } $this->userObj = new ilObjUser(); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->setMode(ilUserProfile::MODE_REGISTRATION); $map = array(); $up->skipGroup("preferences"); $up->skipGroup("settings"); $up->skipGroup("instant_messengers"); $up->skipField("password"); $up->skipField("birthday"); $up->skipField("upload"); foreach ($up->getStandardFields() as $k => $v) { if ($v["method"]) { $method = "set" . substr($v["method"], 3); if (method_exists($this->userObj, $method)) { if ($k != "username") { $k = "usr_" . $k; } $field_obj = $this->form->getItemByPostVar($k); if ($field_obj) { $this->userObj->{$method}($this->form->getInput($k)); } } } } $this->userObj->setFullName(); $birthday_obj = $this->form->getItemByPostVar("usr_birthday"); if ($birthday_obj) { $birthday = $this->form->getInput("usr_birthday"); $birthday = $birthday["date"]; // when birthday was not set, array will not be substituted with string by ilBirthdayInputGui if (!is_array($birthday)) { $this->userObj->setBirthday($birthday); } } // messenger $map = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip"); foreach ($map as $client) { $field = "usr_im_" . $client; $field_obj = $this->form->getItemByPostVar($field); if ($field_obj) { $this->userObj->setInstantMessengerId($client, $this->form->getInput($field)); } } $this->userObj->setTitle($this->userObj->getFullname()); $this->userObj->setDescription($this->userObj->getEmail()); if ($this->registration_settings->passwordGenerationEnabled()) { $password = ilUtil::generatePasswords(1); $password = $password[0]; } else { $password = $this->form->getInput("usr_password"); } $this->userObj->setPasswd($password); // Set user defined data include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields =& ilUserDefinedFields::_getInstance(); $defs = $user_defined_fields->getRegistrationDefinitions(); $udf = array(); foreach ($_POST as $k => $v) { if (substr($k, 0, 4) == "udf_") { $f = substr($k, 4); $udf[$f] = $v; } } $this->userObj->setUserDefinedData($udf); $this->userObj->setTimeLimitOwner(7); $access_limit = null; $this->code_was_used = false; if ($this->code_enabled) { $code_local_roles = $code_has_access_limit = null; // #10853 - could be optional $code = $this->form->getInput('usr_registration_code'); if ($code) { include_once './Services/Registration/classes/class.ilRegistrationCode.php'; // set code to used ilRegistrationCode::useCode($code); $this->code_was_used = true; // handle code attached local role(s) and access limitation $code_data = ilRegistrationCode::getCodeData($code); if ($code_data["role_local"]) { // need user id before we can assign role(s) $code_local_roles = explode(";", $code_data["role_local"]); } if ($code_data["alimit"]) { // see below $code_has_access_limit = true; switch ($code_data["alimit"]) { case "absolute": $abs = date_parse($code_data["alimitdt"]); $access_limit = mktime(23, 59, 59, $abs['month'], $abs['day'], $abs['year']); break; case "relative": $rel = unserialize($code_data["alimitdt"]); $access_limit = $rel["d"] * 86400 + $rel["m"] * 2592000 + $rel["y"] * 31536000 + time(); break; } } } } // code access limitation will override any other access limitation setting if (!($this->code_was_used && $code_has_access_limit) && $this->registration_settings->getAccessLimitation()) { include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php'; $access_limitations_obj = new ilRegistrationRoleAccessLimitations(); switch ($access_limitations_obj->getMode($a_role)) { case 'absolute': $access_limit = $access_limitations_obj->getAbsolute($a_role); break; case 'relative': $rel_d = (int) $access_limitations_obj->getRelative($a_role, 'd'); $rel_m = (int) $access_limitations_obj->getRelative($a_role, 'm'); $rel_y = (int) $access_limitations_obj->getRelative($a_role, 'y'); $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time(); break; } } if ($access_limit) { $this->userObj->setTimeLimitUnlimited(0); $this->userObj->setTimeLimitUntil($access_limit); } else { $this->userObj->setTimeLimitUnlimited(1); $this->userObj->setTimeLimitUntil(time()); } $this->userObj->setTimeLimitFrom(time()); $this->userObj->create(); if ($this->registration_settings->getRegistrationType() == IL_REG_DIRECT || $this->registration_settings->getRegistrationType() == IL_REG_CODES || $this->code_was_used) { $this->userObj->setActive(1, 0); } else { if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) { $this->userObj->setActive(0, 0); } else { $this->userObj->setActive(0, 0); } } $this->userObj->updateOwner(); // set a timestamp for last_password_change // this ts is needed by ilSecuritySettings $this->userObj->setLastPasswordChangeTS(time()); $this->userObj->setIsSelfRegistered(true); //insert user data in table user_data $this->userObj->saveAsNew(); try { require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php'; ilTermsOfServiceHelper::trackAcceptance($this->userObj, ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng)); } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) { } // setup user preferences $this->userObj->setLanguage($this->form->getInput('usr_language')); $hits_per_page = $ilSetting->get("hits_per_page"); if ($hits_per_page < 10) { $hits_per_page = 10; } $this->userObj->setPref("hits_per_page", $hits_per_page); $show_online = $ilSetting->get("show_users_online"); if ($show_online == "") { $show_online = "y"; } $this->userObj->setPref("show_users_online", $show_online); $this->userObj->writePrefs(); $rbacadmin->assignUser((int) $a_role, $this->userObj->getId()); // local roles from code if ($this->code_was_used && is_array($code_local_roles)) { foreach (array_unique($code_local_roles) as $local_role_obj_id) { // is given role (still) valid? if (ilObject::_lookupType($local_role_obj_id) == "role") { $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId()); } } } return $password; }
/** * Get selectable fields * @return */ public function getSelectableFieldsInfo($a_obj_id) { global $lng; $fields = array(); foreach ($this->getExportableFields() as $field) { switch ($field) { case 'lastname': case 'firstname': break; case 'username': $fields['login']['txt'] = $lng->txt('login'); $fields['login']['default'] = 1; break; default: $fields[$field]['txt'] = $lng->txt($field); $fields[$field]['default'] = 0; break; } } include_once './Services/Booking/classes/class.ilBookingEntry.php'; if (ilBookingEntry::hasObjectBookingEntries($a_obj_id, $GLOBALS['ilUser']->getId())) { $GLOBALS['lng']->loadLanguageModule('dateplaner'); $fields['consultation_hour']['txt'] = $GLOBALS['lng']->txt('cal_ch_field_ch'); $fields['consultation_hour']['default'] = 0; } include_once './Services/User/classes/class.ilUserDefinedFields.php'; if ($this->getType() == 'crs') { $udf = ilUserDefinedFields::_getInstance()->getCourseExportableFields(); } elseif ($this->getType() == 'grp') { $udf = ilUserDefinedFields::_getInstance()->getGroupExportableFields(); } if ($udf) { foreach ($udf as $field_id => $field) { $fields['udf_' . $field_id]['txt'] = $field['field_name']; $fields['udf_' . $field_id]['default'] = 0; } } include_once './Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php'; $cdf = ilCourseDefinedFieldDefinition::_getFields($a_obj_id); foreach ($cdf as $def) { $fields['odf_' . $def->getId()]['txt'] = $def->getName(); $fields['odf_' . $def->getId()]['default'] = 0; } if (count($cdf)) { // add last edit $fields['odf_last_update']['txt'] = $GLOBALS['lng']->txt($this->getType() . '_cdf_tbl_last_edit'); $fields['odf_last_update']['default'] = 0; } return $fields; }
/** * Update custom fields properties (from table gui) */ function updateFields($action = "") { global $lng, $ilCtrl; $user_field_definitions = ilUserDefinedFields::_getInstance(); $a_fields = $user_field_definitions->getDefinitions(); foreach ($a_fields as $field_id => $definition) { if (isset($_POST['chb']['required_' . $field_id]) && (int) $_POST['chb']['required_' . $field_id] && (!isset($_POST['chb']['visib_reg_' . $field_id]) || !(int) $_POST['chb']['visib_reg_' . $field_id])) { $this->confirm_change = true; ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected')); $this->listUserDefinedFields(); return false; } } foreach ($a_fields as $field_id => $definition) { $user_field_definitions->setFieldName($definition['field_name']); $user_field_definitions->setFieldType($definition['field_type']); $user_field_definitions->setFieldValues($definition['field_values']); $user_field_definitions->enableVisible((int) $_POST['chb']['visible_' . $field_id]); $user_field_definitions->enableChangeable((int) $_POST['chb']['changeable_' . $field_id]); $user_field_definitions->enableRequired((int) $_POST['chb']['required_' . $field_id]); $user_field_definitions->enableSearchable((int) $_POST['chb']['searchable_' . $field_id]); $user_field_definitions->enableExport((int) $_POST['chb']['export_' . $field_id]); $user_field_definitions->enableCourseExport((int) $_POST['chb']['course_export_' . $field_id]); $user_field_definitions->enableVisibleLocalUserAdministration((int) $_POST['chb']['visib_lua_' . $field_id]); $user_field_definitions->enableChangeableLocalUserAdministration((int) $_POST['chb']['changeable_lua_' . $field_id]); $user_field_definitions->enableGroupExport((int) $_POST['chb']['group_export_' . $field_id]); $user_field_definitions->enableVisibleRegistration((int) $_POST['chb']['visib_reg_' . $field_id]); $user_field_definitions->enableCertificate((int) $_POST['chb']['certificate_' . $field_id]); $user_field_definitions->update($field_id); } ilUtil::sendSuccess($lng->txt('settings_saved'), true); $ilCtrl->redirect($this); }
/** * Get all exportable user defined fields */ function getUserDefinedExportFields() { include_once './Services/User/classes/class.ilUserDefinedFields.php'; $udf_obj =& ilUserDefinedFields::_getInstance(); $udf_ex_fields = array(); foreach ($udf_obj->getDefinitions() as $definition) { if ($definition["export"] != FALSE) { $udf_ex_fields[] = array("name" => $definition["field_name"], "id" => $definition["field_id"]); } } return $udf_ex_fields; }
/** * @return array */ public static function getAllDefinitions() { $return = array(); /** * @var $ilUserDefinedFields ilUserDefinedFields */ $ilUserDefinedFields = ilUserDefinedFields::_getInstance(); foreach ($ilUserDefinedFields->getDefinitions() as $def) { if ($def['visib_reg'] == 1) { $return[] = $def; } } return $return; }
public static function __appendUserDefinedFields($fields, $counter) { include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields = ilUserDefinedFields::_getInstance(); foreach ($user_defined_fields->getSearchableDefinitions() as $definition) { $fields[$counter]['values'] = ilUserSearchOptions::__prepareValues($definition['field_values']); $fields[$counter]['lang'] = $definition['field_name']; $fields[$counter]['db'] = $definition['field_id']; switch ($definition['field_type']) { case UDF_TYPE_TEXT: $fields[$counter]['type'] = FIELD_TYPE_UDF_TEXT; break; case UDF_TYPE_SELECT: $fields[$counter]['type'] = FIELD_TYPE_UDF_SELECT; break; } ++$counter; } return $fields ? $fields : array(); }
/** * add user defined field data to xml (using usr dtd) * @param ilXmlWriter $xml_writer */ function addToXML($xml_writer) { include_once './Services/User/classes/class.ilUserDefinedFields.php'; $udf_obj =& ilUserDefinedFields::_getInstance(); foreach ($udf_obj->getDefinitions() as $definition) { if ($definition["export"] != FALSE) { $xml_writer->xmlElement('UserDefinedField', array('Id' => $definition['il_id'], 'Name' => $definition['field_name']), (string) $this->user_data['f_' . (int) $definition['field_id']]); } } }
protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false) { global $lng, $ilSetting; $cols = $privacy_fields = array(); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->skipGroup("preferences"); $up->skipGroup("settings"); $up->skipGroup("interests"); $ufs = $up->getStandardFields(); // default fields $cols["login"] = array("txt" => $lng->txt("login"), "default" => true); if (!$this->anonymized) { $cols["firstname"] = array("txt" => $lng->txt("firstname"), "default" => true); $cols["lastname"] = array("txt" => $lng->txt("lastname"), "default" => true); } // show only if extended data was activated in lp settings include_once 'Services/Tracking/classes/class.ilObjUserTracking.php'; $tracking = new ilObjUserTracking(); if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) { $cols["first_access"] = array("txt" => $lng->txt("trac_first_access"), "default" => true); $cols["last_access"] = array("txt" => $lng->txt("trac_last_access"), "default" => true); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) { $cols["read_count"] = array("txt" => $lng->txt("trac_read_count"), "default" => true); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) { $cols["spent_seconds"] = array("txt" => $lng->txt("trac_spent_seconds"), "default" => true); } if ($this->isPercentageAvailable($this->obj_id)) { $cols["percentage"] = array("txt" => $lng->txt("trac_percentage"), "default" => true); } // do not show status if learning progress is deactivated $olp = ilObjectLP::getInstance($this->obj_id); if ($olp->isActive()) { $cols["status"] = array("txt" => $lng->txt("trac_status"), "default" => true); $cols['status_changed'] = array('txt' => $lng->txt('trac_status_changed'), 'default' => false); } if ($this->type != "lm") { $cols["mark"] = array("txt" => $lng->txt("trac_mark"), "default" => true); } $cols["u_comment"] = array("txt" => $lng->txt("trac_comment"), "default" => false); $cols["create_date"] = array("txt" => $lng->txt("create_date"), "default" => false); $cols["language"] = array("txt" => $lng->txt("language"), "default" => false); // add user data only if object is [part of] course if (!$this->anonymized && ($a_in_course || $a_in_group)) { // only show if export permission is granted include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; if (ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id)) { // other user profile fields foreach ($ufs as $f => $fd) { if (!isset($cols[$f]) && $f != "username" && !$fd["lists_hide"]) { if ($a_in_course && !($fd["course_export_fix_value"] || $ilSetting->get("usr_settings_course_export_" . $f))) { continue; } if ($a_in_group && !($fd["group_export_fix_value"] || $ilSetting->get("usr_settings_group_export_" . $f))) { continue; } $cols[$f] = array("txt" => $lng->txt($f), "default" => false); $privacy_fields[] = $f; } } // additional defined user data fields include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields = ilUserDefinedFields::_getInstance(); if ($a_in_course) { $user_defined_fields = $user_defined_fields->getCourseExportableFields(); } else { $user_defined_fields = $user_defined_fields->getGroupExportableFields(); } foreach ($user_defined_fields as $definition) { if ($definition["field_type"] != UDF_TYPE_WYSIWYG) { $f = "udf_" . $definition["field_id"]; $cols[$f] = array("txt" => $definition["field_name"], "default" => false); $privacy_fields[] = $f; } } } } return array($cols, $privacy_fields); }
/** * Get selectable fields * @return */ public function getSelectableFieldsInfo($a_obj_id) { global $lng; $fields = array(); foreach ($this->getExportableFields() as $field) { switch ($field) { case 'lastname': case 'firstname': break; case 'username': $fields['login']['txt'] = $lng->txt('username'); $fields['login']['default'] = 1; break; default: $fields[$field]['txt'] = $lng->txt($field); $fields[$field]['default'] = 0; break; } } include_once './Services/User/classes/class.ilUserDefinedFields.php'; if ($this->getType() == 'crs') { $udf = ilUserDefinedFields::_getInstance()->getCourseExportableFields(); } elseif ($this->getType() == 'grp') { $udf = ilUserDefinedFields::_getInstance()->getGroupExportableFields(); } if ($udf) { foreach ($udf as $field_id => $field) { $fields['udf_' . $field_id]['txt'] = $field['field_name']; $fields['udf_' . $field_id]['default'] = 0; } } include_once './Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php'; $cdf = ilCourseDefinedFieldDefinition::_getFields($a_obj_id); foreach ($cdf as $def) { $fields['odf_' . $def->getId()]['txt'] = $def->getName(); $fields['odf_' . $def->getId()]['default'] = 0; } return $fields; }
/** * create client tag * * @param ilSetting $setting */ private function __buildClient($setting) { $auth_modes = ilAuthUtils::_getActiveAuthModes(); $auth_mode_default = strtoupper(ilAuthUtils::_getAuthModeName(array_shift($auth_modes))); $auth_mode_names = array(); foreach ($auth_modes as $mode) { $auth_mode_names[] = strtoupper(ilAuthUtils::_getAuthModeName($mode)); } // determine skins/styles $skin_styles = array(); include_once "./Services/Style/classes/class.ilStyleDefinition.php"; $styleDefinition = new ilStyleDefinition(); include_once "./Services/Style/classes/class.ilObjStyleSettings.php"; $templates = $styleDefinition->getAllTemplates(); if (is_array($templates)) { foreach ($templates as $template) { // get styles information of template $styleDef =& new ilStyleDefinition($template["id"]); $styleDef->startParsing(); $styles = $styleDef->getStyles(); foreach ($styles as $style) { if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"], $style["id"])) { continue; } $skin_styles[] = $template["id"] . ":" . $style["id"]; } } } // timezones include_once 'Services/Calendar/classes/class.ilTimeZone.php'; $this->xmlStartTag("Client", array("inst_id" => $setting->get("inst_id"), "id" => $setting->clientid, "enabled" => $setting->access == 1 ? "TRUE" : "FALSE", "default_lang" => $setting->language)); $this->xmlEndTag("Client"); return; // END here due to security reasons. $this->xmlElement("Name", null, $setting->get("inst_name")); $this->xmlElement("Description", null, $setting->description); $this->xmlElement("Institution", null, $setting->get("inst_institution")); $this->xmlStartTag("Responsible"); $this->xmlElement("Firstname", null, $setting->get("admin_firstname")); $this->xmlElement("Lastname", null, $setting->get("admin_lastname")); $this->xmlElement("Title", null, $setting->get("admin_title")); $this->xmlElement("Institution", null, $setting->get("admin_institution")); $this->xmlElement("Position", null, $setting->get("admin_position")); $this->xmlElement("Email", null, $setting->get("admin_email")); $this->xmlElement("Street ", null, $setting->get("admin_street")); $this->xmlElement("ZipCode ", null, $setting->get("admin_zipcode")); $this->xmlElement("City", null, $setting->get("admin_city")); $this->xmlElement("Country", null, $setting->get("admin_country")); $this->xmlElement("Phone", null, $setting->get("admin_phone")); $this->xmlEndTag("Responsible"); $this->xmlStartTag("Settings"); $this->xmlElement("Setting", array("key" => "error_recipient"), $setting->get("error_recipient")); $this->xmlElement("Setting", array("key" => "feedback_recipient"), $setting->get("feedback_recipient")); $this->xmlElement("Setting", array("key" => "session_expiration"), $setting->session); $this->xmlElement("Setting", array("key" => "soap_enabled"), $setting->get("soap_user_administration")); $this->xmlElement("Setting", array("key" => "authentication_methods"), join(",", $auth_mode_names)); $this->xmlElement("Setting", array("key" => "authentication_default_method"), $auth_mode_default); $this->xmlElement("Setting", array("key" => "skins"), join(",", $skin_styles)); $this->xmlElement("Setting", array("key" => "default_skin"), $setting->default_skin_style); $this->xmlElement("Setting", array("key" => "default_timezone"), ilTimeZone::_getDefaultTimeZone()); $this->xmlElement("Setting", array("key" => "default_hits_per_page"), $setting->default_hits_per_page); $this->xmlElement("Setting", array("key" => "default_show_users_online"), $setting->default_show_users_online); $this->xmlEndTag("Settings"); if ($this->exportAdvMDDefs) { // create advanced meta data record xml include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php'; $record_ids = array(); $record_types = ilAdvancedMDRecord::_getAssignableObjectTypes(); foreach ($record_types as $type) { $records = ilAdvancedMDRecord::_getActivatedRecordsByObjectType($type); foreach ($records as $record) { $record_ids[] = $record->getRecordId(); } } $record_ids = array_unique($record_ids); $this->xmlStartTag('AdvancedMetaDataRecords'); if (count($record_ids) > 0) { foreach ($record_ids as $record_id) { $record_obj = ilAdvancedMDRecord::_getInstanceByrecordId($record_id); $record_obj->toXML($this); } } $this->xmlEndTag('AdvancedMetaDataRecords'); } if ($this->exportUDFDefs) { // create user defined fields record xml include_once "./Services/User/classes/class.ilUserDefinedFields.php"; $udf_data =& ilUserDefinedFields::_newInstance(); $udf_data->addToXML($this); } $this->xmlEndTag("Client"); }
/** * Write data * @return */ protected function write() { // Add header line $row = 0; $col = 0; foreach ($all_fields = $this->getOrderedExportableFields() as $field) { switch ($field) { case 'role': #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status')); $this->addCol($this->lng->txt($this->getType() . '_role_status'), $row, $col++); break; case 'agreement': #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted')); $this->addCol($this->lng->txt('ps_agreement_accepted'), $row, $col++); break; default: if (substr($field, 0, 4) == 'udf_') { $field_id = explode('_', $field); include_once 'Services/User/classes/class.ilUserDefinedFields.php'; $udf = ilUserDefinedFields::_getInstance(); $def = $udf->getDefinition($field_id[1]); #$this->csv->addColumn($def['field_name']); $this->addCol($def['field_name'], $row, $col++); } elseif (substr($field, 0, 4) == 'cdf_') { $field_id = explode('_', $field); #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1])); $this->addCol(ilCourseDefinedFieldDefinition::_lookupName($field_id[1]), $row, $col++); } else { #$this->csv->addColumn($this->lng->txt($field)); $this->addCol($this->lng->txt($field), $row, $col++); } break; } } #$this->csv->addRow(); $this->addRow(); // Add user data foreach ($this->user_ids as $usr_id) { $row++; $col = 0; $udf_data = new ilUserDefinedData($usr_id); foreach ($all_fields as $field) { // Handle course defined fields if ($this->addUserDefinedField($udf_data, $field, $row, $col)) { $col++; continue; } if ($this->addCourseField($usr_id, $field, $row, $col)) { $col++; continue; } switch ($field) { case 'role': switch ($this->user_course_data[$usr_id]['role']) { case IL_CRS_ADMIN: #$this->csv->addColumn($this->lng->txt('crs_admin')); $this->addCol($this->lng->txt('crs_admin'), $row, $col++); break; case IL_CRS_TUTOR: #$this->csv->addColumn($this->lng->txt('crs_tutor')); $this->addCol($this->lng->txt('crs_tutor'), $row, $col++); break; case IL_CRS_MEMBER: #$this->csv->addColumn($this->lng->txt('crs_member')); $this->addCol($this->lng->txt('crs_member'), $row, $col++); break; case IL_GRP_ADMIN: #$this->csv->addColumn($this->lng->txt('il_grp_admin')); $this->addCol($this->lng->txt('il_grp_admin'), $row, $col++); break; case IL_GRP_MEMBER: #$this->csv->addColumn($this->lng->txt('il_grp_member')); $this->addCol($this->lng->txt('il_grp_member'), $row, $col++); break; case 'subscriber': #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber')); $this->addCol($this->lng->txt($this->getType() . '_subscriber'), $row, $col++); break; default: #$this->csv->addColumn($this->lng->txt('crs_waiting_list')); $this->addCol($this->lng->txt('crs_waiting_list'), $row, $col++); break; } break; case 'agreement': if (isset($this->agreement[$usr_id])) { if ($this->agreement[$usr_id]['accepted']) { #$this->csv->addColumn(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'],true)); $this->addCol(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'], true), $row, $col++); } else { #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); $this->addCol($this->lng->txt('ps_not_accepted'), $row, $col++); } } else { #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); $this->addCol($this->lng->txt('ps_not_accepted'), $row, $col++); } break; // These fields are always enabled // These fields are always enabled case 'username': #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']); $this->addCol($this->user_profile_data[$usr_id]['login'], $row, $col++); break; case 'firstname': case 'lastname': #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); $this->addCol($this->user_profile_data[$usr_id][$field], $row, $col++); break; default: // Check aggreement if (!$this->privacy->courseConfirmationRequired() and !ilCourseDefinedFieldDefinition::_getFields($this->obj_id) or $this->agreement[$usr_id]['accepted']) { #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); $this->addCol($this->user_profile_data[$usr_id][$field], $row, $col++); } else { #$this->csv->addColumn(''); $this->addCol('', $row, $col++); } break; } } #$this->csv->addRow(); $this->addRow(); } }
/** * Show list of export files * * @access public * */ public function show($a_deliver_file = false) { $this->showFileList(); $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.member_export.html', 'Modules/Course'); $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this)); $this->tpl->setVariable('TXT_EXPORT_SETTINGS', $this->lng->txt('ps_export_settings')); $this->tpl->setVariable('TXT_USER_SELECTION', $this->lng->txt('ps_user_selection')); $this->tpl->setVariable('TXT_EXPORT_ADMIN', $this->lng->txt('ps_export_admin')); $this->tpl->setVariable('TXT_EXPORT_MEMBER', $this->lng->txt('ps_export_member')); $this->tpl->setVariable('TXT_EXPORT_WAIT', $this->lng->txt('ps_export_wait')); $this->tpl->setVariable('TXT_EXPORT_SUB', $this->lng->txt('ps_export_sub')); // Check user selection $this->exportSettings = new ilUserFormSettings('memexp'); $this->tpl->setVariable('CHECK_EXPORT_ADMIN', ilUtil::formCheckbox($this->exportSettings->enabled('admin'), 'export_members[admin]', 1)); if ($this->type == 'crs') { $this->tpl->setVariable('CHECK_EXPORT_TUTOR', ilUtil::formCheckbox($this->exportSettings->enabled('tutor'), 'export_members[tutor]', 1)); $this->tpl->setVariable('TXT_EXPORT_TUTOR', $this->lng->txt('ps_export_tutor')); } $this->tpl->setVariable('CHECK_EXPORT_MEMBER', ilUtil::formCheckbox($this->exportSettings->enabled('member'), 'export_members[member]', 1)); $this->tpl->setVariable('CHECK_EXPORT_SUB', ilUtil::formCheckbox($this->exportSettings->enabled('subscribers'), 'export_members[subscribers]', 1)); $this->tpl->setVariable('CHECK_EXPORT_WAIT', ilUtil::formCheckbox($this->exportSettings->enabled('waiting_list'), 'export_members[waiting_list]', 1)); $this->tpl->setVariable('TXT_EXPORT', $this->lng->txt('ps_perform_export')); $this->tpl->setVariable('TXT_EXPORT_EXCEL', $this->lng->txt('ps_export_excel')); // User Data $this->tpl->setVariable('TXT_USER_DATA_SELECTION', $this->lng->txt('ps_export_data')); $this->tpl->setVariable('TXT_EXPORT_USER_DATA_HEADER', $this->lng->txt('ps_export_user_data')); include_once './Services/Booking/classes/class.ilBookingEntry.php'; if (ilBookingEntry::hasObjectBookingEntries($this->obj_id, $GLOBALS['ilUser']->getId())) { $this->tpl->setCurrentBlock('consultation'); $this->lng->loadLanguageModule('dateplaner'); $this->tpl->setVariable('TXT_CH', $this->lng->txt('cal_ch_field_ch')); $this->tpl->setVariable('TXT_EXPORT_CH', $this->lng->txt('cal_ch_export_apps')); $this->tpl->setVariable('CHECK_EXPORT_CH', ilUtil::formCheckbox($this->exportSettings->enabled('consultation_hour'), 'export_members[consultation_hour]', 1)); $this->tpl->parseCurrentBlock(); } $fields = $this->fields_info->getFieldsInfo(); foreach ($fields as $field => $exportable) { if (!$exportable) { continue; } $this->tpl->setCurrentBlock('user_data_row'); $this->tpl->setVariable('CHECK_EXPORT_USER_DATA', ilUtil::formCheckbox($this->exportSettings->enabled($field), 'export_members[' . $field . ']', 1)); $this->tpl->setVariable('TXT_EXPORT_USER_DATA', $this->lng->txt($field)); $this->tpl->parseCurrentBlock(); } $udf = ilUserDefinedFields::_getInstance(); foreach ($exp = $udf->getExportableFields($this->obj_id) as $field_id => $udf_data) { $this->tpl->setCurrentBlock('user_data_row'); $this->tpl->setVariable('CHECK_EXPORT_USER_DATA', ilUtil::formCheckbox($this->exportSettings->enabled('udf_' . $field_id), 'export_members[udf_' . $field_id . ']', 1)); $this->tpl->setVariable('TXT_EXPORT_USER_DATA', $udf_data['field_name']); $this->tpl->parseCurrentBlock(); } $cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->obj_id); foreach ($cdf_fields as $field_obj) { $this->tpl->setCurrentBlock('cdf_row'); $this->tpl->setVariable('CHECK_CDF_DATA', ilUtil::formCheckbox($this->exportSettings->enabled('cdf_' . $field_obj->getId()), 'export_members[cdf_' . $field_obj->getId() . ']', 1)); $this->tpl->setVariable('TXT_CDF_NAME', $field_obj->getName()); $this->tpl->parseCurrentBlock(); } if (count($cdf_fields)) { $this->tpl->setCurrentBlock('cdf_fields'); $this->tpl->setVariable('TXT_CDF_SELECTION', $this->lng->txt('ps_' . $this->type . '_user_fields')); $this->tpl->parseCurrentBlock(); } if ($a_deliver_file and 0) { $this->tpl->setCurrentBlock('iframe'); $this->tpl->setVariable('SOURCE', $this->ctrl->getLinkTarget($this, 'deliverData')); } }
/** * * Handles ignored required fields by changing the required flag of form elements * * @access protected * @return boolean A flag whether the user profile is maybe incomplete after saving the form data * */ protected function handleIgnoredRequiredFields() { $profileMaybeIncomplete = false; require_once 'Services/User/classes/class.ilUserProfile.php'; foreach (ilUserProfile::getIgnorableRequiredSettings() as $fieldName) { $elm = $this->form_gui->getItemByPostVar($fieldName); if (!$elm) { continue; } if ($elm->getRequired()) { $profileMaybeIncomplete = true; // Flag as optional $elm->setRequired(false); } } include_once 'Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields = ilUserDefinedFields::_getInstance(); foreach ($user_defined_fields->getDefinitions() as $field_id => $definition) { $elm = $this->form_gui->getItemByPostVar('udf_' . $definition['field_id']); if (!$elm) { continue; } if ($elm->getRequired() && $definition['changeable'] && $definition['required'] && $definition['visible']) { $profileMaybeIncomplete = true; // Flag as optional $elm->setRequired(false); } } return $profileMaybeIncomplete; }