public static function replaceBillingMailPlaceholders($a_message, $a_user_id)
 {
     global $lng;
     $user = new ilObjUser($a_user_id);
     // determine salutation
     switch ($user->getGender()) {
         case 'f':
             $gender_salut = $lng->txt('salutation_f');
             break;
         case 'm':
             $gender_salut = $lng->txt('salutation_m');
             break;
     }
     $a_message = str_replace('[MAIL_SALUTATION]', $gender_salut, $a_message);
     $a_message = str_replace('[LOGIN]', $user->getLogin(), $a_message);
     $a_message = str_replace('[FIRST_NAME]', $user->getFirstname(), $a_message);
     $a_message = str_replace('[LAST_NAME]', $user->getLastname(), $a_message);
     $a_message = str_replace('[ILIAS_URL]', ILIAS_HTTP_PATH . '/login.php?client_id=' . CLIENT_ID, $a_message);
     $a_message = str_replace('[CLIENT_NAME]', CLIENT_NAME, $a_message);
     include_once './Services/Payment/classes/class.ilShopLinkBuilder.php';
     $shopLB = new ilShopLinkBuilder();
     $bought_objects_url = $shopLB->buildLink('ilShopBoughtObjectsGUI');
     $shop_url = $shopLB->buildLink('ilShopGUI');
     $a_message = str_replace('[SHOP_BOUGHT_OBJECTS_URL]', $bought_objects_url, $a_message);
     $a_message = str_replace('[SHOP_URL]', $shop_url, $a_message);
     unset($user);
     return $a_message;
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl, $ilAccess;
     $news_set = new ilSetting("news");
     $enable_internal_rss = $news_set->get("enable_rss_for_internal");
     // user
     if ($a_set["user_id"] > 0) {
         $this->tpl->setCurrentBlock("user_info");
         $user_obj = new ilObjUser($a_set["user_id"]);
         $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
         $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
         $this->tpl->parseCurrentBlock();
     }
     // access
     if ($enable_internal_rss) {
         $this->tpl->setCurrentBlock("access");
         $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
         if ($a_set["visibility"] == NEWS_PUBLIC || $a_set["priority"] == 0 && ilBlockSetting::_lookup("news", "public_notifications", 0, $a_set["context_obj_id"])) {
             $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
         } else {
             $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
         }
         $this->tpl->parseCurrentBlock();
     }
     // last update
     if ($a_set["creation_date"] != $a_set["update_date"]) {
         $this->tpl->setCurrentBlock("ni_update");
         $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
         $this->tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME)));
         $this->tpl->parseCurrentBlock();
     }
     // creation date
     $this->tpl->setVariable("VAL_CREATION_DATE", ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME)));
     $this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
     // title
     $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
     // content
     if ($a_set["content"] != "") {
         $this->tpl->setCurrentBlock("content");
         $this->tpl->setVariable("VAL_CONTENT", ilUtil::shortenText($a_set["content"], 80, true, true), true);
         $this->tpl->parseCurrentBlock();
     }
     $perm_ref_id = $this->perm_ref_id > 0 ? $this->perm_ref_id : $a_set["ref_id"];
     if ($ilAccess->checkAccess("write", "", $perm_ref_id)) {
         $this->tpl->setCurrentBlock("edit");
         $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
         $ilCtrl->setParameterByClass("ilnewsitemgui", "news_item_id", $a_set["id"]);
         $this->tpl->setVariable("CMD_EDIT", $ilCtrl->getLinkTargetByClass("ilnewsitemgui", "editNewsItem"));
         $this->tpl->parseCurrentBlock();
     }
     // context
     $this->tpl->setVariable("CONTEXT", $lng->txt("obj_" . $a_set["context_obj_type"]) . ":<br />" . ilObject::_lookupTitle($a_set["context_obj_id"]));
     $this->tpl->setVariable("VAL_ID", $a_set["id"]);
 }
 /**
  * Creates Toolbar entries
  */
 function addToolbar()
 {
     global $ilToolbar;
     $ilToolbar->setFormAction($this->ilCtrl->getFormAction($this, "perminfo"));
     $ilToolbar->addText($this->lng->txt('user'));
     include_once "./Services/Form/classes/class.ilTextInputGUI.php";
     $login = new ilTextInputGUI($this->lng->txt("username"), "user_login");
     $login->setDataSource($this->ilCtrl->getLinkTargetByClass(array(get_class($this), 'ilRepositorySearchGUI'), 'doUserAutoComplete', '', true));
     $login->setSize(15);
     $login->setValue($this->user->getLogin());
     $ilToolbar->addInputItem($login);
     $ilToolbar->addFormButton($this->lng->txt("info_change_user_view"), "perminfo");
     //$ilToolbar->addText($lng->txt("info_enter_login_or_id"));
 }
 function userDataArrayForExport($user, $b_allowExportPrivacy = false)
 {
     $userArray = array();
     if ($b_allowExportPrivacy == false) {
         $userArray["user"] = $user;
     } else {
         global $ilUser;
         $userArray["login"] = "";
         $userArray["user"] = "";
         $userArray["email"] = "";
         $userArray["department"] = "";
         if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
             $e_user = new ilObjUser($user);
             $userArray["login"] = $e_user->getLogin();
             $userArray["user"] = $e_user->getLastname() . ', ' . $e_user->getFirstname();
             $userArray["email"] = "" . $e_user->getEmail();
             $userArray["department"] = "" . $e_user->getDepartment();
         }
     }
     return $userArray;
 }
Пример #5
0
 public function add()
 {
     global $lng, $ilUser;
     if ($_GET["mail_id"] != "") {
         if (is_array($mail_data = $this->umail->getMail($_GET["mail_id"]))) {
             require_once "Services/Contact/classes/class.ilAddressbook.php";
             $abook = new ilAddressbook($ilUser->getId());
             $tmp_user = new ilObjUser($mail_data["sender_id"]);
             if ($abook->checkEntryByLogin($tmp_user->getLogin()) > 0) {
                 ilUtil::sendInfo($lng->txt("mail_entry_exists"));
             } else {
                 $abook->addEntry($tmp_user->getLogin(), $tmp_user->getFirstname(), $tmp_user->getLastname(), $tmp_user->getEmail());
                 ilUtil::sendInfo($lng->txt("mail_entry_added"));
             }
         }
     }
     $this->showMail();
 }
Пример #6
0
 /**
  * @param ilObjUser $ilUser
  *
  * @return mixed
  */
 public function getIliasUser(ilObjUser $ilUser)
 {
     return str_replace('@', '-at-', $ilUser->getLogin());
 }
Пример #7
0
 /**
  * Returns an multidimensional array containing userdata from users
  * having an entry in banTable with matching roomId.
  *
  * @global ilDBMySQL $ilDB
  * @return array
  */
 public function getBannedUsers()
 {
     global $ilDB;
     $query = 'SELECT * FROM ' . self::$banTable . ' WHERE room_id = %s ';
     $types = array('integer');
     $values = array($this->getRoomId());
     $rset = $ilDB->queryF($query, $types, $values);
     $result = array();
     if ($rset) {
         while ($row = $ilDB->fetchAssoc($rset)) {
             if ($row['user_id'] > 0) {
                 $user = new ilObjUser($row['user_id']);
                 $userdata = array('user_id' => $user->getId(), 'firstname' => $user->getFirstname(), 'lastname' => $user->getLastname(), 'login' => $user->getLogin(), 'remark' => $row['remark']);
                 $result[] = $userdata;
             } else {
                 //@todo anonymous user
             }
         }
     }
     return $result;
 }
 /**
  * display activation confirmation screen
  */
 function showActionConfirmation($action, $a_from_search = false)
 {
     $user_ids = $this->getActionUserIds();
     if (!$user_ids) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     if (strcmp($action, "accessRestrict") == 0) {
         return $this->setAccessRestrictionObject(null, $a_from_search);
     }
     if (strcmp($action, "mail") == 0) {
         return $this->mailObject();
     }
     unset($this->data);
     if (!$a_from_search) {
         $cancel = "cancelUserFolderAction";
     } else {
         $cancel = "cancelSearchAction";
     }
     // display confirmation message
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setFormAction($this->ctrl->getFormAction($this));
     $cgui->setHeaderText($this->lng->txt("info_" . $action . "_sure"));
     $cgui->setCancel($this->lng->txt("cancel"), $cancel);
     $cgui->setConfirm($this->lng->txt("confirm"), "confirm" . $action);
     if ($a_from_search) {
         $cgui->addHiddenItem("frsrch", 1);
     }
     foreach ($user_ids as $id) {
         $user = new ilObjUser($id);
         $login = $user->getLastLogin();
         if (!$login) {
             $login = $this->lng->txt("never");
         } else {
             $login = ilDatePresentation::formatDate(new ilDateTime($login, IL_CAL_DATETIME));
         }
         $caption = $user->getFullname() . " (" . $user->getLogin() . ")" . ", " . $user->getEmail() . " -  " . $this->lng->txt("last_login") . ": " . $login;
         $cgui->addItem("id[]", $id, $caption);
     }
     $this->tpl->setContent($cgui->getHTML());
     return true;
 }
Пример #9
0
 public static function _createRandomUserAccount($keyarray)
 {
     global $ilDB, $ilUser, $ilSetting, $rbacadmin;
     if ($_SESSION['create_user_account'] != NULL) {
         $obj_user = new ilObjUser($_SESSION['create_user_account']);
         return $obj_user;
     } else {
         $userLogin = array();
         $res = $ilDB->query('SELECT sequence FROM object_data_seq');
         $row = $ilDB->fetchAssoc($res);
         $temp_user_id = (int) $row['sequence'] + 1;
         $userLogin['login'] = '******' . $temp_user_id;
         $userLogin['passwd'] = ilUtil::generatePasswords(1);
         require_once 'Services/User/classes/class.ilObjUser.php';
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         $obj_user = new ilObjUser();
         $obj_user->setId($temp_user_id);
         $obj_user->setLogin($userLogin['login']);
         $obj_user->setPasswd((string) $userLogin['passwd'][0], IL_PASSWD_PLAIN);
         $_SESSION['tmp_user_account']['login'] = $userLogin['login'];
         $_SESSION['tmp_user_account']['passwd'] = $userLogin['passwd'];
         $obj_user->setFirstname($keyarray['first_name']);
         $obj_user->setLastname($keyarray['last_name']);
         $obj_user->setEmail($keyarray['payer_email']);
         #	$obj_user->setEmail('*****@*****.**');
         $obj_user->setGender('f');
         $obj_user->setLanguage($ilSetting->get("language"));
         $obj_user->setActive(true);
         $obj_user->setTimeLimitUnlimited(true);
         $obj_user->setTitle($obj_user->getFullname());
         $obj_user->setDescription($obj_user->getEmail());
         $obj_user->setTimeLimitOwner(7);
         $obj_user->setTimeLimitUnlimited(1);
         $obj_user->setTimeLimitMessage(0);
         $obj_user->setApproveDate(date("Y-m-d H:i:s"));
         // Set default prefs
         $obj_user->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
         $obj_user->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
         $obj_user->writePrefs();
         // at the first login the user must complete profile
         $obj_user->setProfileIncomplete(true);
         $obj_user->create();
         $obj_user->saveAsNew();
         $user_role = ilObject::_exists(4, false);
         if (!$user_role) {
             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
             $reg_allowed = ilObjRole::_lookupRegisterAllowed();
             $user_role = $reg_allowed[0]['id'];
         } else {
             $user_role = 4;
         }
         $rbacadmin->assignUser((int) $user_role, $obj_user->getId(), true);
         include_once "Services/Mail/classes/class.ilMimeMail.php";
         global $ilias, $lng;
         $settings = $ilias->getAllSettings();
         $mmail = new ilMimeMail();
         $mmail->autoCheck(false);
         $mmail->From($settings["admin_email"]);
         $mmail->To($obj_user->getEmail());
         // mail subject
         $subject = $lng->txt("reg_mail_subject");
         // mail body
         $body = $lng->txt("reg_mail_body_salutation") . " " . $obj_user->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . $ilias->client_id . "\n";
         $body .= $lng->txt("login") . ": " . $obj_user->getLogin() . "\n";
         $body .= $lng->txt("passwd") . ": " . $userLogin['passwd'][0] . "\n";
         $body .= "\n";
         $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
         $body .= $obj_user->getProfileAsString($lng);
         $mmail->Subject($subject);
         $mmail->Body($body);
         $mmail->Send();
         $_SESSION['create_user_account'] = $obj_user->getId();
         return $obj_user;
     }
 }
 /**
  * Deliver vcard information.
  */
 function deliverVCard()
 {
     // get user object
     if (!ilObject::_exists($this->getUserId())) {
         return "";
     }
     $user = new ilObjUser($this->getUserId());
     require_once "./Services/User/classes/class.ilvCard.php";
     $vcard = new ilvCard();
     // ilsharedresourceGUI: embedded in shared portfolio
     if ($user->getPref("public_profile") != "y" && $user->getPref("public_profile") != "g" && $_GET["baseClass"] != "ilsharedresourceGUI") {
         return;
     }
     $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
     $vcard->setNickname($user->getLogin());
     $webspace_dir = ilUtil::getWebspaceDir("output");
     $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
     if ($user->getPref("public_upload") == "y" && @is_file($imagefile)) {
         $fh = fopen($imagefile, "r");
         if ($fh) {
             $image = fread($fh, filesize($imagefile));
             fclose($fh);
             require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             $mimetype = ilObjMediaObject::getMimeType($imagefile);
             if (preg_match("/^image/", $mimetype)) {
                 $type = $mimetype;
             }
             $vcard->setPhoto($image, $type);
         }
     }
     $val_arr = array("getInstitution" => "institution", "getDepartment" => "department", "getStreet" => "street", "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country", "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home", "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email", "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
     $org = array();
     $adr = array();
     foreach ($val_arr as $key => $value) {
         // if value "y" show information
         if ($user->getPref("public_" . $value) == "y") {
             switch ($value) {
                 case "institution":
                     $org[0] = $user->{$key}();
                     break;
                 case "department":
                     $org[1] = $user->{$key}();
                     break;
                 case "street":
                     $adr[2] = $user->{$key}();
                     break;
                 case "zipcode":
                     $adr[5] = $user->{$key}();
                     break;
                 case "city":
                     $adr[3] = $user->{$key}();
                     break;
                 case "country":
                     $adr[6] = $user->{$key}();
                     break;
                 case "phone_office":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_WORK);
                     break;
                 case "phone_home":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_HOME);
                     break;
                 case "phone_mobile":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_CELL);
                     break;
                 case "fax":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_FAX);
                     break;
                 case "email":
                     $vcard->setEmail($user->{$key}());
                     break;
                 case "hobby":
                     $vcard->setNote($user->{$key}());
                     break;
             }
         }
     }
     if (count($org)) {
         $vcard->setOrganization(join(";", $org));
     }
     if (count($adr)) {
         $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
     }
     ilUtil::deliverData(utf8_decode($vcard->buildVCard()), $vcard->getFilename(), $vcard->getMimetype());
 }
Пример #11
0
 /**
  * Returns the user information from an active_id (survey_finished.finished_id)
  *
  * @param integer $active_id The active id of the user
  * @return array An array containing the user data
  * @access public
  */
 function getUserDataFromActiveId($active_id)
 {
     global $ilDB;
     $surveySetting = new ilSetting("survey");
     $use_anonymous_id = array_key_exists("use_anonymous_id", $_GET) ? $_GET["use_anonymous_id"] : $surveySetting->get("use_anonymous_id");
     $result = $ilDB->queryF("SELECT * FROM svy_finished WHERE finished_id = %s", array('integer'), array($active_id));
     $row = array();
     $foundrows = $result->numRows();
     if ($foundrows) {
         $row = $ilDB->fetchAssoc($result);
     }
     $name = $use_anonymous_id ? $row["anonymous_id"] : $this->lng->txt("anonymous");
     $userdata = array("fullname" => $name, "sortname" => $name, "firstname" => "", "lastname" => "", "login" => "", "gender" => "", "active_id" => "{$active_id}");
     if ($foundrows) {
         if ($row["user_fi"] > 0 && $row["user_fi"] != ANONYMOUS_USER_ID && $this->getAnonymize() == 0) {
             include_once './Services/User/classes/class.ilObjUser.php';
             if (strlen(ilObjUser::_lookupLogin($row["user_fi"])) == 0) {
                 $userdata["fullname"] = $userdata["sortname"] = $this->lng->txt("deleted_user");
             } else {
                 $user = new ilObjUser($row["user_fi"]);
                 $userdata["fullname"] = $user->getFullname();
                 $gender = $user->getGender();
                 if (strlen($gender) == 1) {
                     $gender = $this->lng->txt("gender_{$gender}");
                 }
                 $userdata["gender"] = $gender;
                 $userdata["firstname"] = $user->getFirstname();
                 $userdata["lastname"] = $user->getLastname();
                 $userdata["sortname"] = $user->getLastname() . ", " . $user->getFirstname();
                 $userdata["login"] = $user->getLogin();
             }
         }
     }
     return $userdata;
 }
Пример #12
0
 /**
  * Load function to handle Identities of *different* users
  */
 public function findUserByID($userid)
 {
     $retval = null;
     // first verify the userid
     $oUser = new ilObjUser($userid);
     $oUser->read();
     if ($oUser->getLogin()) {
         $tData = $this->loadUserToken($userid);
         $retval = $this->makeUserInfo($oUser, $tData);
     }
     return $retval;
 }
 /**
  * update existing user
  *
  * @access protected
  */
 protected function updateUser(ilECSUser $user, $a_local_user_id)
 {
     global $ilClientIniFile, $ilLog, $rbacadmin;
     $user_obj = new ilObjUser($a_local_user_id);
     $user_obj->setFirstname($user->getFirstname());
     $user_obj->setLastname($user->getLastname());
     $user_obj->setEmail($user->getEmail());
     $user_obj->setInstitution($user->getInstitution());
     $user_obj->setActive(true);
     $until = $user_obj->getTimeLimitUntil();
     $user_obj->setTimeLimitFrom(time() - 5);
     if ($until < time() + $ilClientIniFile->readVariable('session', 'expire')) {
         $user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session", "expire"));
     }
     $user_obj->update();
     $user_obj->refreshLogin();
     if ($global_role = $this->getCurrentServer()->getGlobalRole()) {
         $rbacadmin->assignUser($this->getCurrentServer()->getGlobalRole(), $user_obj->getId(), true);
     }
     $ilLog->write(__METHOD__ . ': Finished update of remote user with usr_id: ' . $user->getImportId());
     return $user_obj->getLogin();
 }
Пример #14
0
 /**
  * Get item properties
  *
  * Overwrite this method to add properties at
  * the bottom of the item html
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 public function getProperties($a_item = '')
 {
     global $objDefinition;
     $props = array();
     // please list alert properties first
     // example (use $lng->txt instead of "Status"/"Offline" strings):
     // $props[] = array("alert" => true, "property" => "Status", "value" => "Offline");
     // $props[] = array("alert" => false, "property" => ..., "value" => ...);
     // ...
     // #8280: WebDav is only supported in repository
     if ($this->context == self::CONTEXT_REPOSITORY) {
         // BEGIN WebDAV Display locking information
         require_once 'Services/WebDAV/classes/class.ilDAVActivationChecker.php';
         if (ilDAVActivationChecker::_isActive()) {
             require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
             global $ilias, $lng;
             // Show lock info
             require_once 'Services/WebDAV/classes/class.ilDAVLocks.php';
             $davLocks = new ilDAVLocks();
             if ($ilias->account->getId() != ANONYMOUS_USER_ID) {
                 $locks =& $davLocks->getLocksOnObjectObj($this->obj_id);
                 if (count($locks) > 0) {
                     $lockUser = new ilObjUser($locks[0]['ilias_owner']);
                     $props[] = array("alert" => false, "property" => $lng->txt("in_use_by"), "value" => $lockUser->getLogin(), "link" => "./ilias.php?user="******"alert" => false, "property" => $lng->txt("filename_interoperability"), "value" => $lng->txt("filename_special_filename"), 'propertyNameVisible' => false);
             } else {
                 if (preg_match('/^\\./', $this->title)) {
                     $props[] = array("alert" => false, "property" => $lng->txt("filename_visibility"), "value" => $lng->txt("filename_hidden_unix_file"), 'propertyNameVisible' => false);
                 } else {
                     if (preg_match('/~$/', $this->title)) {
                         $props[] = array("alert" => false, "property" => $lng->txt("filename_visibility"), "value" => $lng->txt("filename_hidden_backup_file"), 'propertyNameVisible' => false);
                     } else {
                         if (preg_match('/[\\/]/', $this->title)) {
                             $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"), "value" => $lng->txt("filename_special_characters"), 'propertyNameVisible' => false);
                         } else {
                             if (preg_match('/[\\\\\\/:*?"<>|]/', $this->title)) {
                                 $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"), "value" => $lng->txt("filename_windows_special_characters"), 'propertyNameVisible' => false);
                             } else {
                                 if (preg_match('/\\.$/', $this->title)) {
                                     $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"), "value" => $lng->txt("filename_windows_empty_extension"), 'propertyNameVisible' => false);
                                 } else {
                                     if (preg_match('/^(\\.|\\.\\.)$/', $this->title)) {
                                         $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"), "value" => $lng->txt("filename_special_filename"), 'propertyNameVisible' => false);
                                     } else {
                                         if (preg_match('/#/', $this->title)) {
                                             $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"), "value" => $lng->txt("filename_windows_webdav_issue"), 'propertyNameVisible' => false);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // END WebDAV Display warning for invisible files and files with special characters
         // BEGIN ChangeEvent: display changes.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         if (ilChangeEvent::_isActive()) {
             global $ilias, $lng, $ilUser;
             if ($ilias->account->getId() != ANONYMOUS_USER_ID) {
                 // Performance improvement: for container objects
                 // we only display 'changed inside' events, for
                 // leaf objects we only display 'object new/changed'
                 // events
                 $isContainer = in_array($this->type, array('cat', 'fold', 'crs', 'grp'));
                 if ($isContainer) {
                     $state = ilChangeEvent::_lookupInsideChangeState($this->obj_id, $ilUser->getId());
                     if ($state > 0) {
                         $props[] = array("alert" => true, "value" => $lng->txt('state_changed_inside'), 'propertyNameVisible' => false);
                     }
                 } elseif ($this->type == "file") {
                     $state = ilChangeEvent::_lookupChangeState($this->obj_id, $ilUser->getId());
                     if ($state > 0) {
                         $props[] = array("alert" => true, "value" => $lng->txt($state == 1 ? 'state_unread' : 'state_changed'), 'propertyNameVisible' => false);
                     }
                 }
             }
         }
         // END ChangeEvent: display changes.
     }
     return $props;
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     $news_set = new ilSetting("news");
     $enable_internal_rss = $news_set->get("enable_rss_for_internal");
     // context
     $obj_id = ilObject::_lookupObjId($a_set["ref_id"]);
     $obj_type = ilObject::_lookupType($obj_id);
     $obj_title = ilObject::_lookupTitle($obj_id);
     // user
     if ($a_set["user_id"] > 0) {
         $this->tpl->setCurrentBlock("user_info");
         if ($obj_type == "frm") {
             include_once "./Modules/Forum/classes/class.ilForumProperties.php";
             if (ilForumProperties::_isAnonymized($a_set["context_obj_id"])) {
                 if ($a_set["context_sub_obj_type"] == "pos" && $a_set["context_sub_obj_id"] > 0) {
                     include_once "./Modules/Forum/classes/class.ilForumPost.php";
                     $post = new ilForumPost($a_set["context_sub_obj_id"]);
                     if ($post->getUserAlias() != "") {
                         $this->tpl->setVariable("VAL_AUTHOR", ilUtil::stripSlashes($post->getUserAlias()));
                     } else {
                         $this->tpl->setVariable("VAL_AUTHOR", $lng->txt("forums_anonymous"));
                     }
                 } else {
                     $this->tpl->setVariable("VAL_AUTHOR", $lng->txt("forums_anonymous"));
                 }
             } else {
                 if (ilObject::_exists($a_set["user_id"])) {
                     $user_obj = new ilObjUser($a_set["user_id"]);
                     $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
                 }
             }
         } else {
             if (ilObject::_exists($a_set["user_id"])) {
                 $user_obj = new ilObjUser($a_set["user_id"]);
                 $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
             }
         }
         $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
         $this->tpl->parseCurrentBlock();
     }
     // media player
     if ($a_set["content_type"] == NEWS_AUDIO && $a_set["mob_id"] > 0 && ilObject::_exists($a_set["mob_id"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php";
         $mob = new ilObjMediaObject($a_set["mob_id"]);
         $med = $mob->getMediaItem("Standard");
         $mpl = new ilMediaPlayerGUI();
         $mpl->setFile(ilObjMediaObject::_getDirectory($a_set["mob_id"]) . "/" . $med->getLocation());
         $this->tpl->setCurrentBlock("player");
         $this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
         $this->tpl->parseCurrentBlock();
     }
     // access
     if ($enable_internal_rss) {
         $this->tpl->setCurrentBlock("access");
         include_once "./Services/Block/classes/class.ilBlockSetting.php";
         $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
         if ($a_set["visibility"] == NEWS_PUBLIC || $a_set["priority"] == 0 && ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id)) {
             $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
         } else {
             $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
         }
         $this->tpl->parseCurrentBlock();
     }
     // content
     if ($a_set["content"] != "") {
         $this->tpl->setCurrentBlock("content");
         $this->tpl->setVariable("VAL_CONTENT", ilUtil::makeClickable($a_set["content"], true));
         $this->tpl->parseCurrentBlock();
     }
     if ($a_set["content_long"] != "") {
         $this->tpl->setCurrentBlock("long");
         $this->tpl->setVariable("VAL_LONG_CONTENT", ilUtil::makeClickable($a_set["content_long"], true));
         $this->tpl->parseCurrentBlock();
     }
     if ($a_set["update_date"] != $a_set["creation_date"]) {
         $this->tpl->setCurrentBlock("ni_update");
         $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
         $this->tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME)));
         $this->tpl->parseCurrentBlock();
     }
     // forum hack, not nice
     $add = "";
     if ($obj_type == "frm" && $a_set["context_sub_obj_type"] == "pos" && $a_set["context_sub_obj_id"] > 0) {
         include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
         $pos = $a_set["context_sub_obj_id"];
         $thread = ilObjForumAccess::_getThreadForPosting($pos);
         if ($thread > 0) {
             $add = "_" . $thread . "_" . $pos;
         }
     }
     $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . $obj_type . "_" . $a_set["ref_id"] . $add;
     $this->tpl->setCurrentBlock("context");
     $cont_loc = new ilLocatorGUI();
     $cont_loc->addContextItems($a_set["ref_id"], true);
     $this->tpl->setVariable("CONTEXT_LOCATOR", $cont_loc->getHTML());
     $this->tpl->setVariable("HREF_CONTEXT_TITLE", $url_target);
     $this->tpl->setVariable("CONTEXT_TITLE", $obj_title);
     $this->tpl->setVariable("ALT_CONTEXT_TITLE", $lng->txt("icon") . " " . $lng->txt("obj_" . $obj_type));
     $this->tpl->setVariable("IMG_CONTEXT_TITLE", ilUtil::getImagePath("icon_" . $obj_type . "_b.png"));
     $this->tpl->parseCurrentBlock();
     $this->tpl->setVariable("HREF_TITLE", $url_target);
     // title
     if ($a_set["content_is_lang_var"]) {
         $this->tpl->setVariable("VAL_TITLE", $lng->txt($a_set["title"]));
     } else {
         $this->tpl->setVariable("VAL_TITLE", ilUtil::stripSlashes($a_set["title"]));
         // title
     }
     // creation date
     $this->tpl->setVariable("VAL_CREATION_DATE", ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME)));
     $this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
     $this->tpl->parseCurrentBlock();
 }
 /**
  * Reads the submitted data from the password assistance form.
  * The following form fields are read as HTTP POST parameters:
  * key
  * username
  * password1
  * password2
  * The key is used to retrieve the password assistance session.
  * If the key is missing, or if the password assistance session has expired, the
  * password assistance form will be shown instead of this form.
  * If the password assistance session is valid, and if the username matches the
  * username, for which the password assistance has been requested, and if the
  * new password is valid, ILIAS assigns the password to the user.
  * Note: To prevent replay attacks, the session is deleted when the
  * password has been assigned successfully.
  */
 public function submitAssignPasswordForm()
 {
     require_once 'include/inc.pwassist_session_handler.php';
     // We need to fetch this before form instantiation
     $pwassist_id = ilUtil::stripSlashes($_POST['key']);
     $form = $this->getAssignPasswordForm($pwassist_id);
     if (!$form->checkInput()) {
         $form->setValuesByPost();
         return;
     }
     $username = $form->getInput('username');
     $password = $form->getInput('password');
     $pwassist_id = $form->getInput('key');
     // Retrieve the session
     $pwassist_session = db_pwassist_session_read($pwassist_id);
     if (count($pwassist_session) == 0 || $pwassist_session['expires'] < time()) {
         ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt('pwassist_session_expired')));
         $form->setValuesByPost();
         $this->showAssistanceForm($form);
         return;
     } else {
         $is_successful = true;
         $message = '';
         $userObj = new ilObjUser($pwassist_session['user_id']);
         if ($userObj == null) {
             $message = $this->lng->txt('user_does_not_exist');
             $is_successful = false;
         }
         // check if the username entered by the user matches the
         // one of the user object.
         if ($is_successful && strcasecmp($userObj->getLogin(), $username) != 0) {
             $message = $this->lng->txt('pwassist_login_not_match');
             $is_successful = false;
         }
         $error_lng_var = '';
         if (!ilUtil::isPasswordValidForUserContext($password, $userObj, $error_lng_var)) {
             $message = $this->lng->txt($error_lng_var);
             $is_successful = false;
         }
         // End of validation
         // If the validation was successful, we change the password of the
         // user.
         // ------------------
         if ($is_successful) {
             $is_successful = $userObj->resetPassword($password, $password);
             if (!$is_successful) {
                 $message = $this->lng->txt('passwd_invalid');
             }
         }
         // If we are successful so far, we update the user object.
         // ------------------
         if ($is_successful) {
             $userObj->update();
         }
         // If we are successful, we destroy the password assistance
         // session and redirect to the login page.
         // Else we display the form again along with an error message.
         // ------------------
         if ($is_successful) {
             db_pwassist_session_destroy($pwassist_id);
             $this->showMessageForm(sprintf($this->lng->txt('pwassist_password_assigned'), $username));
         } else {
             ilUtil::sendFailure(str_replace("\\n", '', $message));
             $form->setValuesByPost();
             $this->showAssignPasswordForm($form, $pwassist_id);
         }
     }
 }
 public function initFormSearch(ilObjUser $user = NULL)
 {
     global $ilCtrl;
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($this->ctrl->getFormAction($this, 'search'));
     $this->form->setTitle($this->getTitle());
     $this->form->addCommandButton('performSearch', $this->lng->txt('search'));
     $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
     $kind = new ilRadioGroupInputGUI($this->lng->txt('search_type'), 'search_for');
     $kind->setValue($this->search_type);
     $this->form->addItem($kind);
     // Users
     $users = new ilRadioOption($this->lng->txt('search_for_users'), 'usr');
     // UDF
     include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
     foreach (ilUserSearchOptions::_getSearchableFieldsInfo(!$this->isSearchableCheckEnabled()) as $info) {
         switch ($info['type']) {
             case FIELD_TYPE_UDF_SELECT:
             case FIELD_TYPE_SELECT:
                 $sel = new ilSelectInputGUI($info['lang'], "rep_query[usr][" . $info['db'] . "]");
                 $sel->setOptions($info['values']);
                 $users->addSubItem($sel);
                 break;
             case FIELD_TYPE_MULTI:
             case FIELD_TYPE_UDF_TEXT:
             case FIELD_TYPE_TEXT:
                 if (isset($info['autoComplete']) and $info['autoComplete']) {
                     $ilCtrl->setParameterByClass(get_class($this), 'autoCompleteField', $info['db']);
                     $ul = new ilTextInputGUI($info['lang'], "rep_query[usr][" . $info['db'] . "]");
                     $ul->setDataSourceSubmitOnSelection(TRUE);
                     $ul->setDataSourceSubmitUrl($this->ctrl->getLinkTarget($this, 'showSearchSelected', '', FALSE, FALSE));
                     $ul->setDataSource($ilCtrl->getLinkTarget($this, "doUserAutoComplete", "", true));
                     $ul->setSize(30);
                     $ul->setMaxLength(120);
                     if ($user instanceof ilObjUser) {
                         switch ($info['db']) {
                             case 'firstname':
                                 $ul->setValue($user->getFirstname());
                                 break;
                             case 'lastname':
                                 $ul->setValue($user->getLastname());
                                 break;
                             case 'login':
                                 $ul->setValue($user->getLogin());
                                 break;
                         }
                     }
                     $users->addSubItem($ul);
                 } else {
                     $txt = new ilTextInputGUI($info['lang'], "rep_query[usr][" . $info['db'] . "]");
                     $txt->setSize(30);
                     $txt->setMaxLength(120);
                     $users->addSubItem($txt);
                 }
                 break;
         }
     }
     $kind->addOption($users);
     // Role
     $roles = new ilRadioOption($this->lng->txt('search_for_role_members'), 'role');
     $role = new ilTextInputGUI($this->lng->txt('search_role_title'), 'rep_query[role][title]');
     $role->setSize(30);
     $role->setMaxLength(120);
     $roles->addSubItem($role);
     $kind->addOption($roles);
     // Course
     $groups = new ilRadioOption($this->lng->txt('search_for_crs_members'), 'crs');
     $group = new ilTextInputGUI($this->lng->txt('search_crs_title'), 'rep_query[crs][title]');
     $group->setSize(30);
     $group->setMaxLength(120);
     $groups->addSubItem($group);
     $kind->addOption($groups);
     // Group
     $groups = new ilRadioOption($this->lng->txt('search_for_grp_members'), 'grp');
     $group = new ilTextInputGUI($this->lng->txt('search_grp_title'), 'rep_query[grp][title]');
     $group->setSize(30);
     $group->setMaxLength(120);
     $groups->addSubItem($group);
     $kind->addOption($groups);
 }
Пример #18
0
 /**
  * get reply recipient
  * @access	public
  * @return string
  */
 function formatReplyRecipient()
 {
     if (empty($this->mail_data)) {
         return false;
     }
     require_once './Services/User/classes/class.ilObjUser.php';
     $user = new ilObjUser($this->mail_data["sender_id"]);
     return $this->mail_data["rcp_to"] = $user->getLogin();
 }
 /**
  * handler for end of element when in verify mode.
  */
 function verifyEndTag($a_xml_parser, $a_name)
 {
     global $lng, $ilAccess, $ilSetting, $ilObjDataCache;
     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 "User":
             $this->userObj->setFullname();
             if ($this->user_id != -1 && $this->action == "Update") {
                 $user_exists = !is_null(ilObjUser::_lookupLogin($this->user_id));
             } else {
                 $user_exists = ilObjUser::getUserIdByLogin($this->userObj->getLogin()) != 0;
             }
             if (is_null($this->userObj->getLogin())) {
                 $this->logFailure("---", sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Login", "Insert"));
             }
             switch ($this->action) {
                 case "Insert":
                     if ($user_exists and $this->conflict_rule == IL_FAIL_ON_CONFLICT) {
                         $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_insert"));
                     }
                     if (is_null($this->userObj->getGender()) && $this->isFieldRequired("gender")) {
                         $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Gender", "Insert"));
                     }
                     if (is_null($this->userObj->getFirstname())) {
                         $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Firstname", "Insert"));
                     }
                     if (is_null($this->userObj->getLastname())) {
                         $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Lastname", "Insert"));
                     }
                     if (count($this->roles) == 0) {
                         $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Role", "Insert"));
                     } else {
                         $has_global_role = false;
                         foreach ($this->roles as $role) {
                             if ($role['type'] == 'Global') {
                                 $has_global_role = true;
                                 break;
                             }
                         }
                         if (!$has_global_role) {
                             $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_global_role_for_action_required"), "Insert"));
                         }
                     }
                     break;
                 case "Update":
                     if (!$user_exists) {
                         $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_update"));
                     } elseif ($this->user_id != -1 && !is_null($this->userObj->getLogin())) {
                         $someonesId = ilObjUser::_lookupId($this->userObj->getLogin());
                         if (is_numeric($someonesId) && $someonesId != $this->user_id) {
                             $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_login_is_not_unique"));
                         }
                     }
                     break;
                 case "Delete":
                     if (!$user_exists) {
                         $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_delete"));
                     }
                     break;
             }
             // init role array for next user
             $this->roles = array();
             break;
         case "Login":
             if (array_key_exists($this->cdata, $this->logins)) {
                 $this->logWarning($this->cdata, $lng->txt("usrimport_login_is_not_unique"));
             } else {
                 $this->logins[$this->cdata] = $this->cdata;
             }
             $this->userObj->setLogin($this->cdata);
             break;
         case "Password":
             switch ($this->currPasswordType) {
                 case "ILIAS2":
                     $this->userObj->setPasswd($this->cdata, IL_PASSWD_CRYPT);
                     break;
                 case "ILIAS3":
                     $this->userObj->setPasswd($this->cdata, IL_PASSWD_MD5);
                     break;
                 case "PLAIN":
                     $this->userObj->setPasswd($this->cdata, IL_PASSWD_PLAIN);
                     $this->acc_mail->setUserPassword($this->currPassword);
                     break;
                 default:
                     $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "Type", "Password", $this->currPasswordType));
                     break;
             }
             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":
             if ($this->cdata != "m" && $this->cdata != "f") {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "Gender", $this->cdata));
             }
             $this->userObj->setGender($this->cdata);
             break;
         case "Email":
             $this->userObj->setEmail($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 "ExternalAccount":
             //echo "-".$this->userObj->getAuthMode()."-".$this->userObj->getLogin()."-";
             $am = $this->userObj->getAuthMode() == "default" || $this->userObj->getAuthMode() == "" ? ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode')) : $this->userObj->getAuthMode();
             $loginForExternalAccount = trim($this->cdata) == "" ? "" : ilObjUser::_checkExternalAuthAccount($am, trim($this->cdata));
             switch ($this->action) {
                 case "Insert":
                     if ($loginForExternalAccount != "") {
                         $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_insert_ext_account_exists") . " (" . $this->cdata . ")");
                     }
                     break;
                 case "Update":
                     if ($loginForExternalAccount != "") {
                         $externalAccountHasChanged = trim($this->cdata) != ilObjUser::_lookupExternalAccount($this->user_id);
                         if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin())) {
                             $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_update_ext_account_exists") . " (" . $this->cdata . " for " . $loginForExternalAccount . ")");
                         }
                     }
                     break;
             }
             if ($externalAccountHasChanged) {
                 $this->userObj->setExternalAccount(trim($this->cdata));
             }
             break;
         case "Active":
             if ($this->cdata != "true" && $this->cdata != "false") {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "Active", $this->cdata));
             }
             $this->currActive = $this->cdata;
             break;
         case "TimeLimitOwner":
             if (!preg_match("/\\d+/", $this->cdata)) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitOwner", $this->cdata));
             } elseif (!$ilAccess->checkAccess('cat_administrate_users', '', $this->cdata)) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitOwner", $this->cdata));
             } elseif ($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($this->cdata)) != 'cat' && !(int) $this->cdata == USER_FOLDER_ID) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitOwner", $this->cdata));
             }
             $this->userObj->setTimeLimitOwner($this->cdata);
             break;
         case "TimeLimitUnlimited":
             switch (strtolower($this->cdata)) {
                 case "true":
                 case "1":
                     $this->userObj->setTimeLimitUnlimited(1);
                     break;
                 case "false":
                 case "0":
                     $this->userObj->setTimeLimitUnlimited(0);
                     break;
                 default:
                     $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitUnlimited", $this->cdata));
                     break;
             }
             break;
         case "TimeLimitFrom":
             // Accept datetime or Unix timestamp
             if (strtotime($this->cdata) === false && !is_numeric($this->cdata)) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitFrom", $this->cdata));
             }
             $this->userObj->setTimeLimitFrom($this->cdata);
             break;
         case "TimeLimitUntil":
             // Accept datetime or Unix timestamp
             if (strtotime($this->cdata) === false && !is_numeric($this->cdata)) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitUntil", $this->cdata));
             }
             $this->userObj->setTimeLimitUntil($this->cdata);
             break;
         case "TimeLimitMessage":
             switch (strtolower($this->cdata)) {
                 case "1":
                     $this->userObj->setTimeLimitMessage(1);
                     break;
                 case "0":
                     $this->userObj->setTimeLimitMessage(0);
                     break;
                 default:
                     $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitMessage", $this->cdata));
                     break;
             }
             break;
         case "ApproveDate":
             // Accept datetime or Unix timestamp
             if (strtotime($this->cdata) === false && !is_numeric($this->cdata) && !$this->cdata == "0000-00-00 00:00:00") {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "ApproveDate", $this->cdata));
             }
             break;
         case "AgreeDate":
             // Accept datetime or Unix timestamp
             if (strtotime($this->cdata) === false && !is_numeric($this->cdata) && !$this->cdata == "0000-00-00 00:00:00") {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "AgreeDate", $this->cdata));
             }
             break;
         case "iLincID":
             if (!preg_match("/\\d+/", $this->cdata)) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "iLincID", $this->cdata));
             }
             break;
         case "iLincUser":
             if (!preg_match("/\\w+/", $this->cdata)) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "iLincUser", $this->cdata));
             }
             break;
         case "iLincPasswd":
             if (!preg_match("/\\w+/", $this->cdata)) {
                 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "iLincPasswd", $this->cdata));
             }
             break;
         case "Pref":
             if ($this->currentPrefKey != null) {
                 $this->verifyPref($this->currentPrefKey, $this->cdata);
             }
             $this->currentPrefKey == null;
     }
 }
Пример #20
0
 /**
  * Login function
  *
  * @access private
  * @return void
  */
 function login()
 {
     global $ilias, $rbacadmin, $ilSetting;
     if (!empty($_SERVER[$ilias->getSetting('shib_login')])) {
         // Store user's Shibboleth sessionID for logout
         $this->session['shibboleth_session_id'] = $_SERVER['Shib-Session-ID'];
         // Get loginname of user, new login name is generated if user is new
         $username = $this->generateLogin();
         // Authorize this user
         $this->setAuth($username);
         $userObj = new ilObjUser();
         // Check wether this account exists already, if not create it
         if (!ilObjUser::getUserIdByLogin($username)) {
             $newUser["firstname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]);
             $newUser["lastname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]);
             $newUser["login"] = $username;
             // Password must be random to prevent users from manually log in using the login data from Shibboleth users
             $newUser["passwd"] = md5(end(ilUtil::generatePasswords(1)));
             $newUser["passwd_type"] = IL_PASSWD_MD5;
             if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
                 $newUser["gender"] = $_SERVER[$ilias->getSetting('shib_gender')];
             }
             // Save mapping between ILIAS user and Shibboleth uniqueID
             $newUser["ext_account"] = $_SERVER[$ilias->getSetting('shib_login')];
             // other data
             $newUser["title"] = $_SERVER[$ilias->getSetting('shib_title')];
             $newUser["institution"] = $_SERVER[$ilias->getSetting('shib_institution')];
             $newUser["department"] = $_SERVER[$ilias->getSetting('shib_department')];
             $newUser["street"] = $_SERVER[$ilias->getSetting('shib_street')];
             $newUser["city"] = $_SERVER[$ilias->getSetting('shib_city')];
             $newUser["zipcode"] = $_SERVER[$ilias->getSetting('shib_zipcode')];
             $newUser["country"] = $_SERVER[$ilias->getSetting('shib_country')];
             $newUser["phone_office"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_office')]);
             $newUser["phone_home"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_home')]);
             $newUser["phone_mobile"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_mobile')]);
             $newUser["fax"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_fax')]);
             $newUser["matriculation"] = $_SERVER[$ilias->getSetting('shib_matriculation')];
             $newUser["email"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_email')]);
             $newUser["hobby"] = $_SERVER[$ilias->getSetting('shib_hobby')];
             $newUser["auth_mode"] = "shibboleth";
             // system data
             $userObj->assignData($newUser);
             $userObj->setTitle($userObj->getFullname());
             $userObj->setDescription($userObj->getEmail());
             $userObj->setLanguage($this->getFirstString($_SERVER[$ilias->getSetting('shib_language')]));
             // Time limit
             $userObj->setTimeLimitOwner(7);
             $userObj->setTimeLimitUnlimited(1);
             $userObj->setTimeLimitFrom(time());
             $userObj->setTimeLimitUntil(time());
             // Modify user data before creating the user
             // Include custom code that can be used to further modify
             // certain Shibboleth user attributes
             if ($ilias->getSetting('shib_data_conv') && $ilias->getSetting('shib_data_conv') != '' && is_readable($ilias->getSetting('shib_data_conv'))) {
                 include $ilias->getSetting('shib_data_conv');
             }
             // Create use in DB
             $userObj->create();
             $userObj->setActive(1);
             $userObj->updateOwner();
             //insert user data in table user_data
             $userObj->saveAsNew();
             // store acceptance of user agreement
             //$userObj->writeAccepted();
             // Default prefs
             $userObj->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
             $userObj->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
             // setup user preferences
             $userObj->writePrefs();
             //set role entries
             #$rbacadmin->assignUser($ilias->getSetting('shib_user_default_role'), $userObj->getId(),true);
             // New role assignment
             include_once './Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
             ilShibbolethRoleAssignmentRules::doAssignments($userObj->getId(), $_SERVER);
             // Authorize this user
             $this->setAuth($userObj->getLogin());
         } else {
             // Update user account
             $uid = $userObj->checkUserId();
             $userObj->setId($uid);
             $userObj->read($uid);
             if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
                 $userObj->setGender($_SERVER[$ilias->getSetting('shib_gender')]);
             }
             if ($ilias->getSetting('shib_update_title')) {
                 $userObj->setTitle($_SERVER[$ilias->getSetting('shib_title')]);
             }
             $userObj->setFirstname($this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]));
             $userObj->setLastname($this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]));
             $userObj->setFullname();
             if ($ilias->getSetting('shib_update_institution')) {
                 $userObj->setInstitution($_SERVER[$ilias->getSetting('shib_institution')]);
             }
             if ($ilias->getSetting('shib_update_department')) {
                 $userObj->setDepartment($_SERVER[$ilias->getSetting('shib_department')]);
             }
             if ($ilias->getSetting('shib_update_street')) {
                 $userObj->setStreet($_SERVER[$ilias->getSetting('shib_street')]);
             }
             if ($ilias->getSetting('shib_update_city')) {
                 $userObj->setCity($_SERVER[$ilias->getSetting('shib_city')]);
             }
             if ($ilias->getSetting('shib_update_zipcode')) {
                 $userObj->setZipcode($_SERVER[$ilias->getSetting('shib_zipcode')]);
             }
             if ($ilias->getSetting('shib_update_country')) {
                 $userObj->setCountry($_SERVER[$ilias->getSetting('shib_country')]);
             }
             if ($ilias->getSetting('shib_update_phone_office')) {
                 $userObj->setPhoneOffice($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_office')]));
             }
             if ($ilias->getSetting('shib_update_phone_home')) {
                 $userObj->setPhoneHome($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_home')]));
             }
             if ($ilias->getSetting('shib_update_phone_mobile')) {
                 $userObj->setPhoneMobile($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_mobile')]));
             }
             if ($ilias->getSetting('shib_update_fax')) {
                 $userObj->setFax($_SERVER[$ilias->getSetting('shib_fax')]);
             }
             if ($ilias->getSetting('shib_update_matriculation')) {
                 $userObj->setMatriculation($_SERVER[$ilias->getSetting('shib_matriculation')]);
             }
             if ($ilias->getSetting('shib_update_email')) {
                 $userObj->setEmail($this->getFirstString($_SERVER[$ilias->getSetting('shib_email')]));
             }
             if ($ilias->getSetting('shib_update_hobby')) {
                 $userObj->setHobby($_SERVER[$ilias->getSetting('shib_hobby')]);
             }
             if ($ilias->getSetting('shib_update_language')) {
                 $userObj->setLanguage($_SERVER[$ilias->getSetting('shib_language')]);
             }
             // Include custom code that can be used to further modify
             // certain Shibboleth user attributes
             if ($ilias->getSetting('shib_data_conv') && $ilias->getSetting('shib_data_conv') != '' && is_readable($ilias->getSetting('shib_data_conv'))) {
                 include $ilias->getSetting('shib_data_conv');
             }
             $userObj->update();
             // Update role assignments
             include_once './Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
             ilShibbolethRoleAssignmentRules::updateAssignments($userObj->getId(), $_SERVER);
         }
         // we are authenticated: redirect, if possible
         if ($_GET["target"] != "") {
             ilUtil::redirect("goto.php?target=" . $_GET["target"] . "&client_id=" . CLIENT_ID);
         }
     } else {
         // This should never occur unless Shibboleth is not configured properly
         $this->status = AUTH_WRONG_LOGIN;
     }
 }
 /**
  * Load user data from ilias user object
  * @param stdclass $user
  * @param ilObjUser $iu
  */
 private function loadFromUser($user, ilObjUser $iu)
 {
     $prefix = ilViteroSettings::getInstance()->getUserPrefix();
     $user->username = $prefix . $iu->getLogin();
     $user->surname = $iu->getLastname();
     $user->firstname = $iu->getFirstname();
     $user->email = $iu->getEmail();
     $user->company = $iu->getInstitution();
     $user->locale = in_array($iu->getLanguage(), $this->available_locales) ? $iu->getLanguage() : "en";
     #$user->timezone = trim($iu->getTimeZone());
     $GLOBALS['ilLog']->write(__METHOD__ . ': Time zone is ' . $iu->getTimeZone());
     $user->phone = $iu->getPhoneOffice();
     $user->fax = $iu->getFax();
     $user->mobile = $iu->getPhoneMobile();
     $user->country = $iu->getCountry();
     $user->zip = $iu->getZipcode();
     $user->city = $iu->getCity();
     $user->street = $iu->getStreet();
 }
 /** Reads the submitted data from the password assistance form.
  * 
  * The following form fields are read as HTTP POST parameters:
  * key
  * username
  * password1
  * password2
  *
  * The key is used to retrieve the password assistance session.
  * If the key is missing, or if the password assistance session has expired, the
  * password assistance form will be shown instead of this form.
  *
  * If the password assistance session is valid, and if the username matches the
  * username, for which the password assistance has been requested, and if the
  * new password is valid, ILIAS assigns the password to the user.
  *
  * Note: To prevent replay attacks, the session is deleted when the
  * password has been assigned successfully.
  */
 function submitAssignPasswordForm()
 {
     global $tpl, $ilias, $lng, $rbacadmin, $rbacreview;
     require_once "include/inc.pwassist_session_handler.php";
     // Retrieve form data
     $pwassist_id = ilUtil::stripSlashes($_POST["key"]);
     $username = ilUtil::stripSlashes($_POST["username"]);
     $password1 = ilUtil::stripSlashes($_POST["password1"]);
     $password2 = ilUtil::stripSlashes($_POST["password2"]);
     // Retrieve the session
     $pwassist_session = db_pwassist_session_read($pwassist_id);
     if (count($pwassist_session) == 0 || $pwassist_session["expires"] < time()) {
         $this->showAssistanceForm($lng->txt("pwassist_session_expired"));
     } else {
         $is_successful = true;
         $message = "";
         $userObj = new ilObjUser($pwassist_session["user_id"]);
         // Validate the entries of the user
         // ----------------------------------
         // check if the user still exists
         if ($userObj == null) {
             $message = $lng->txt("user_does_not_exist");
             $is_successful = false;
         }
         // check if the username entered by the user matches the
         // one of the user object.
         if ($is_successful && strcasecmp($userObj->getLogin(), $username) != 0) {
             $message = $lng->txt("pwassist_login_not_match");
             $is_successful = false;
         }
         // check if the user entered the password correctly into the
         // two entry fields.
         if ($is_successful && $password1 != $password2) {
             $message = $lng->txt("passwd_not_match");
             $is_successful = false;
         }
         // validate the password
         if ($is_successful && !ilUtil::isPassword($password1)) {
             $message = $lng->txt("passwd_invalid");
             $is_successful = false;
         }
         // End of validation
         // If the validation was successful, we change the password of the
         // user.
         // ------------------
         if ($is_successful) {
             $is_successful = $userObj->resetPassword($password1, $password2);
             if (!$is_successful) {
                 $message = $lng->txt("passwd_invalid");
             }
         }
         // If we are successful so far, we update the user object.
         // ------------------
         if ($is_successful) {
             $is_successfull = $userObj->update();
             if (!$is_successful) {
                 $message = $lng->txt("update_error");
             }
         }
         // If we are successful, we destroy the password assistance
         // session and redirect to the login page.
         // Else we display the form again along with an error message.
         // ------------------
         if ($is_successful) {
             db_pwassist_session_destroy($pwassist_id);
             $this->showMessageForm(null, sprintf($lng->txt("pwassist_password_assigned"), $username));
         } else {
             $this->showAssignPasswordForm($message, $username, $password1, $password2, $pwassist_id);
         }
     }
 }
Пример #23
0
 protected function buildUserRelatedData($row)
 {
     global $lng;
     if ($row['pos_usr_id'] && $row['pos_pk']) {
         require_once 'Services/User/classes/class.ilObjUser.php';
         $tmp_user = new ilObjUser();
         $tmp_user->setFirstname($row['firstname']);
         $tmp_user->setLastname($row['lastname']);
         $tmp_user->setUTitle($row['title']);
         $tmp_user->setLogin($row['login']);
         $this->fullname = $tmp_user->getFullname();
         $this->loginname = $tmp_user->getLogin();
         $this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt('unknown'));
         return true;
     }
 }
Пример #24
0
 /**
  * get data of parent node from frm_posts_tree and frm_posts
  * @access	private
  * @param	object	db	db result object containing node_data
  * @return	array		2-dim (int/str) node_data
  */
 public function fetchPostNodeData($a_row)
 {
     global $lng;
     require_once './Services/User/classes/class.ilObjUser.php';
     if (ilObject::_exists($a_row->pos_usr_id)) {
         $tmp_user = new ilObjUser($a_row->pos_usr_id);
         $fullname = $tmp_user->getFullname();
         $loginname = $tmp_user->getLogin();
     }
     $fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $lng->txt("unknown"));
     $data = array("pos_pk" => $a_row->pos_pk, "child" => $a_row->pos_pk, "author" => $a_row->pos_usr_id, "alias" => $a_row->pos_usr_alias, "title" => $fullname, "loginname" => $loginname, "type" => "post", "message" => $a_row->pos_message, "subject" => $a_row->pos_subject, "pos_cens_com" => $a_row->pos_cens_com, "pos_cens" => $a_row->pos_cens, "date" => $a_row->fpt_date, "create_date" => $a_row->pos_date, "update" => $a_row->pos_update, "update_user" => $a_row->update_user, "tree" => $a_row->thr_fk, "parent" => $a_row->parent_pos, "lft" => $a_row->lft, "rgt" => $a_row->rgt, "depth" => $a_row->depth, "id" => $a_row->fpt_pk, "notify" => $a_row->notify, "import_name" => $a_row->import_name, "pos_status" => $a_row->pos_status);
     // why this line? data should be stored without slashes in db
     //$data["message"] = stripslashes($data["message"]);
     return $data ? $data : array();
 }
 /**
  * show news
  */
 function showNews()
 {
     global $lng, $ilCtrl, $ilUser;
     // workaround for dynamic mode (if cache is disabled, showNews has no data)
     if (empty(self::$st_data)) {
         $this->setData($this->getNewsData());
     }
     $news_set = new ilSetting("news");
     $enable_internal_rss = $news_set->get("enable_rss_for_internal");
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $news = new ilNewsItem($_GET["news_id"]);
     $tpl = new ilTemplate("tpl.show_news.html", true, true, "Services/News");
     // get current item in data set
     $previous = $next = "";
     reset($this->data);
     $c = current($this->data);
     $curr_cnt = 1;
     while ($c["id"] > 0 && $c["id"] != $_GET["news_id"]) {
         $previous = $c;
         $c = next($this->data);
         $curr_cnt++;
     }
     // collect news items to show
     $news_list = array();
     if (is_array($c["aggregation"])) {
         //$agg_obj_id = ilObject::_lookupObjId($c["agg_ref_id"]);
         //$agg_obj_type = ilObject::_lookupType($agg_obj_id);
         //$agg_obj_title = ilObject::_lookupObjId($agg_obj_id);
         $news_list[] = array("ref_id" => $c["agg_ref_id"], "agg_ref_id" => $c["agg_ref_id"], "aggregation" => $c["aggregation"], "user_id" => "", "content_type" => "text", "mob_id" => 0, "visibility" => "", "content" => "", "content_long" => "", "update_date" => $news->getUpdateDate(), "creation_date" => "", "content_is_lang_var" => false, "loc_context" => $_GET["news_context"], "context_obj_type" => $news->getContextObjType(), "title" => "");
         foreach ($c["aggregation"] as $c_item) {
             ilNewsItem::_setRead($ilUser->getId(), $c_item["id"]);
             $c_item["loc_context"] = $c_item["ref_id"];
             $c_item["loc_stop"] = $_GET["news_context"];
             $news_list[] = $c_item;
         }
     } else {
         $news_list[] = array("ref_id" => $_GET["news_context"], "user_id" => $news->getUserId(), "content_type" => $news->getContentType(), "mob_id" => $news->getMobId(), "visibility" => $news->getVisibility(), "priority" => $news->getPriority(), "content" => $news->getContent(), "content_long" => $news->getContentLong(), "update_date" => $news->getUpdateDate(), "creation_date" => $news->getCreationDate(), "context_sub_obj_type" => $news->getContextSubObjType(), "context_obj_type" => $news->getContextObjType(), "context_sub_obj_id" => $news->getContextSubObjId(), "content_is_lang_var" => $news->getContentIsLangVar(), "content_text_is_lang_var" => $news->getContentTextIsLangVar(), "loc_context" => $_GET["news_context"], "title" => $news->getTitle());
         ilNewsItem::_setRead($ilUser->getId(), $_GET["news_id"]);
     }
     foreach ($news_list as $item) {
         // user
         if ($item["user_id"] > 0 && ilObject::_exists($item["user_id"])) {
             // get login
             if (ilObjUser::_exists($item["user_id"])) {
                 $user = new ilObjUser($item["user_id"]);
                 $displayname = $user->getLogin();
             } else {
                 // this should actually not happen, since news entries
                 // should be deleted when the user is going to be removed
                 $displayname = "&lt;" . strtolower($lng->txt("deleted")) . "&gt;";
             }
             $tpl->setCurrentBlock("user_info");
             $tpl->setVariable("VAL_AUTHOR", $displayname);
             $tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
             $tpl->parseCurrentBlock();
         }
         // media player
         if ($item["content_type"] == NEWS_AUDIO && $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
             include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php";
             $mob = new ilObjMediaObject($item["mob_id"]);
             $med = $mob->getMediaItem("Standard");
             $mpl = new ilMediaPlayerGUI();
             if (strcasecmp("Reference", $med->getLocationType()) == 0) {
                 $mpl->setFile($med->getLocation());
             } else {
                 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
             }
             $mpl->setDisplayHeight($med->getHeight());
             $tpl->setCurrentBlock("player");
             $tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
             $tpl->parseCurrentBlock();
         }
         // access
         if ($enable_internal_rss && $item["visibility"] != "") {
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $tpl->setCurrentBlock("access");
             $tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
             if ($item["visibility"] == NEWS_PUBLIC || $item["priority"] == 0 && ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id)) {
                 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
             } else {
                 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
             }
             $tpl->parseCurrentBlock();
         }
         // content
         if (trim($item["content"]) != "") {
             $tpl->setCurrentBlock("content");
             $tpl->setVariable("VAL_CONTENT", nl2br($this->makeClickable(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))));
             //$tpl->setVariable("VAL_CONTENT", nl2br($item["content"]));
             $tpl->parseCurrentBlock();
         }
         if (trim($item["content_long"]) != "") {
             $tpl->setCurrentBlock("long");
             $tpl->setVariable("VAL_LONG_CONTENT", $this->makeClickable($item["content_long"]));
             $tpl->parseCurrentBlock();
         }
         if ($item["update_date"] != $item["creation_date"]) {
             $tpl->setCurrentBlock("ni_update");
             $tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
             $tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($item["update_date"], IL_CAL_DATETIME)));
             $tpl->parseCurrentBlock();
         }
         // creation date
         if ($item["creation_date"] != "") {
             $tpl->setCurrentBlock("ni_update");
             $tpl->setVariable("VAL_CREATION_DATE", ilDatePresentation::formatDate(new ilDateTime($item["creation_date"], IL_CAL_DATETIME)));
             $tpl->setVariable("TXT_CREATED", $lng->txt("created"));
             $tpl->parseCurrentBlock();
         }
         // context / title
         if ($_GET["news_context"] > 0) {
             //$obj_id = ilObject::_lookupObjId($_GET["news_context"]);
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $obj_type = ilObject::_lookupType($obj_id);
             $obj_title = ilObject::_lookupTitle($obj_id);
             // file hack, not nice
             if ($obj_type == "file") {
                 $tpl->setCurrentBlock("download");
                 $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
                 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $item["ref_id"]);
                 $tpl->setVariable("HREF_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilrepositorygui", "sendfile"));
                 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
                 $tpl->parseCurrentBlock();
             }
             // forum hack, not nice
             $add = "";
             if ($obj_type == "frm" && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
                 $pos = $item["context_sub_obj_id"];
                 $thread = ilObjForumAccess::_getThreadForPosting($pos);
                 if ($thread > 0) {
                     $add = "_" . $thread . "_" . $pos;
                 }
             }
             // wiki hack, not nice
             if ($obj_type == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                 $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
                 if ($wptitle != "") {
                     $add = "_" . ilWikiUtil::makeUrlTitle($wptitle);
                 }
             }
             $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . $obj_type . "_" . $item["ref_id"] . $add;
             // lm page hack, not nice
             if (in_array($obj_type, array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) {
                 $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . "pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"];
             }
             $context_opened = false;
             if ($item["loc_context"] != null && $item["loc_context"] != $item["loc_stop"]) {
                 $tpl->setCurrentBlock("context");
                 $context_opened = true;
                 $cont_loc = new ilLocatorGUI();
                 $cont_loc->addContextItems($item["loc_context"], true, $item["loc_stop"]);
                 $tpl->setVariable("CONTEXT_LOCATOR", $cont_loc->getHTML());
             }
             //var_dump($item);
             if ($item["no_context_title"] !== true) {
                 if (!$context_opened) {
                     $tpl->setCurrentBlock("context");
                 }
                 $tpl->setVariable("HREF_CONTEXT_TITLE", $url_target);
                 $tpl->setVariable("CONTEXT_TITLE", $obj_title);
                 $tpl->setVariable("IMG_CONTEXT_TITLE", ilObject::_getIcon($obj_id, "big", $obj_type));
             }
             if ($context_opened) {
                 $tpl->parseCurrentBlock();
             }
             $tpl->setVariable("HREF_TITLE", $url_target);
         }
         // title
         $tpl->setVariable("VAL_TITLE", ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]));
         $row_css = $row_css != "tblrow1" ? "tblrow1" : "tblrow2";
         $tpl->setCurrentBlock("item");
         $tpl->setVariable("ITEM_ROW_CSS", $row_css);
         $tpl->parseCurrentBlock();
     }
     include_once "./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php";
     $content_block = new ilPDContentBlockGUI();
     $content_block->setContent($tpl->get());
     if ($this->getProperty("title") != "") {
         $content_block->setTitle($this->getProperty("title"));
     } else {
         $content_block->setTitle($lng->txt("news_internal_news"));
     }
     //$content_block->setColSpan(2);
     $content_block->setImage(ilUtil::getImagePath("icon_news.png"));
     $this->addCloseCommand($content_block);
     // previous
     if ($previous != "") {
         if ($previous["ref_id"] > 0) {
             $ilCtrl->setParameter($this, "news_context", $previous["ref_id"]);
         }
         $ilCtrl->setParameter($this, "news_id", $previous["id"]);
         $content_block->addFooterLink($lng->txt("previous"), $ilCtrl->getLinkTarget($this, "showNews"), "", "", true);
         $ilCtrl->setParameter($this, "news_context", "");
     }
     // next
     if ($c = next($this->data)) {
         if ($c["ref_id"] > 0) {
             $ilCtrl->setParameter($this, "news_context", $c["ref_id"]);
         }
         $ilCtrl->setParameter($this, "news_id", $c["id"]);
         $content_block->addFooterLink($lng->txt("next"), $ilCtrl->getLinkTarget($this, "showNews"), "", "", true);
     }
     $ilCtrl->setParameter($this, "news_context", "");
     $ilCtrl->setParameter($this, "news_id", "");
     $content_block->setCurrentItemNumber($curr_cnt);
     $content_block->setEnableNumInfo(true);
     $content_block->setData($this->getData());
     return $content_block->getHTML();
 }
 function exportSelected($a_exportall = 0, $a_user = array())
 {
     global $ilDB, $ilUser;
     $scos = array();
     //get all SCO's of this object
     $query = 'SELECT cp_node.cp_node_id ' . 'FROM cp_node, cp_resource, cp_item ' . 'WHERE cp_item.cp_node_id = cp_node.cp_node_id ' . 'AND cp_item.resourceid = cp_resource.id AND scormtype = %s ' . 'AND nodename = %s	AND cp_node.slm_id = %s';
     $res = $ilDB->queryF($query, array('text', 'text', 'integer'), array('sco', 'item', $this->getId()));
     while ($row = $ilDB->fetchAssoc($res)) {
         $scos[] = $row['cp_node_id'];
     }
     $csv = null;
     //a module is completed when all SCO's are completed
     $user_array = array();
     if ($a_exportall == 1) {
         $query = 'SELECT user_id ' . 'FROM cmi_node, cp_node ' . 'WHERE cmi_node.cp_node_id = cp_node.cp_node_id AND cp_node.slm_id = %s ' . 'GROUP BY user_id';
         $res = $ilDB->queryF($query, array('integer'), array($this->getId()));
         while ($row = $ilDB->fetchAssoc($res)) {
             $user_array[] = $row['user_id'];
         }
     } else {
         $user_array = $a_user;
     }
     foreach ($user_array as $user) {
         $scos_c = $scos;
         //copy SCO_array
         //check if all SCO's are completed
         for ($i = 0; $i < count($scos); $i++) {
             $query = 'SELECT * FROM cmi_node ' . 'WHERE user_id = %s AND cp_node_id = %s ' . 'AND completion_status = %s OR success_status = %s';
             $res = $ilDB->queryF($query, array('integer', 'integer', 'text', 'text'), array($user, $scos[$i], 'completed', 'passed'));
             $data = $ilDB->fetchAssoc($res);
             if (is_array($data) && count($data)) {
                 //delete from array
                 $key = array_search($scos[$i], $scos_c);
                 unset($scos_c[$key]);
             }
         }
         //check for completion
         if (count($scos_c) == 0) {
             $completion = 1;
         } else {
             $completion = 0;
         }
         //write export entry
         if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
             $e_user = new ilObjUser($user);
             $login = $e_user->getLogin();
             $firstname = $e_user->getFirstname();
             $lastname = $e_user->getLastname();
             $email = $e_user->getEmail();
             $department = $e_user->getDepartment();
             $query = 'SELECT user_id, MAX(c_timestamp) exp_date ' . 'FROM cmi_node, cp_node ' . 'WHERE cmi_node.cp_node_id = cp_node.cp_node_id ' . 'AND cp_node.slm_id = %s ' . 'GROUP BY user_id';
             $res = $ilDB->queryF($query, array('integer'), array($this->getId()));
             $data = $ilDB->fetchAssoc($res);
             if (is_array($data) && count($data)) {
                 $validDate = false;
                 $datetime = explode(' ', $data['exp_date']);
                 if (count($datetime) == 2) {
                     $date = explode('-', $datetime[0]);
                     if (count($date) == 3 && checkdate($date[1], $date[2], $date[0])) {
                         $validDate = true;
                     }
                 }
                 if ($validDate) {
                     $date = date('d.m.Y', strtotime($data['exp_date']));
                 } else {
                     $date = '';
                 }
             } else {
                 $date = '';
             }
             $csv = $csv . "{$department};{$login};{$lastname};{$firstname};{$email};{$date};{$completion}\n";
         }
     }
     $header = "Department;Login;Lastname;Firstname;Email;Date;Status\n";
     $this->sendExportFile($header, $csv);
 }
Пример #27
0
 /**
  * Get User List HTML (to be displayed besides the map)
  */
 function getUserListHtml()
 {
     $list_tpl = new ilTemplate("tpl.openlayers_map_user_list.html", true, true, "Services/Maps");
     $cnt = 0;
     foreach ($this->user_marker as $user_id) {
         if (ilObject::_exists($user_id)) {
             $user = new ilObjUser($user_id);
             $this->css_row = $this->css_row != "tblrow1_mo" ? "tblrow1_mo" : "tblrow2_mo";
             if ($user->getLatitude() != 0 && $user->getLongitude() != 0 && $user->getPref("public_location") == "y") {
                 $list_tpl->setCurrentBlock("item");
                 $list_tpl->setVariable("MARKER_CNT", $cnt);
                 $list_tpl->setVariable("MAP_ID", $this->getMapId());
                 $cnt++;
             } else {
                 $list_tpl->setCurrentBlock("item_no_link");
             }
             $list_tpl->setVariable("CSS_ROW", $this->css_row);
             $list_tpl->setVariable("TXT_USER", $user->getLogin());
             $list_tpl->setVariable("IMG_USER", $user->getPersonalPicturePath("xxsmall"));
             $list_tpl->parseCurrentBlock();
             $list_tpl->touchBlock("row");
         }
     }
     return $list_tpl->get();
 }
Пример #28
0
 /**
  * migrate account
  *
  * @access public
  * 
  */
 public function migrateAccount()
 {
     global $lng, $ilClientIniFile, $ilLog, $rbacadmin;
     $lng->loadLanguageModule('auth');
     if (!isset($_POST['account_migration'])) {
         $this->showAccountMigration($lng->txt('err_choose_migration_type'));
         return false;
     }
     if ($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password']))) {
         $this->showAccountMigration($lng->txt('err_wrong_login'));
         return false;
     }
     if ($_POST['account_migration'] == 1) {
         if (!($user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))) {
             $this->showAccountMigration($lng->txt('err_wrong_login'));
             return false;
         }
         $_POST['username'] = $_POST['mig_username'];
         $_POST['password'] = $_POST['mig_password'];
         include_once './Services/Authentication/classes/class.ilAuthFactory.php';
         include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
         $ilAuth = ilAuthFactory::factory(new ilAuthContainerMDB2());
         $ilAuth->start();
         if (!$ilAuth->checkAuth()) {
             $ilAuth->logout();
             $this->showAccountMigration($lng->txt('err_wrong_login'));
             return false;
         }
         $user = new ilObjUser($user_id);
         $user->setAuthMode(ilSession::get('tmp_auth_mode'));
         $user->setExternalAccount(ilSession::get('tmp_external_account'));
         $user->setActive(true);
         $user->update();
         // Assign to default role
         if (is_array(ilSession::get('tmp_roles'))) {
             foreach (ilSession::get('tmp_roles') as $role) {
                 $rbacadmin->assignUser((int) $role, $user->getId());
             }
         }
         // Log migration
         $ilLog->write(__METHOD__ . ': Migrated ' . ilSession::get('tmp_external_account') . ' to ILIAS account ' . $user->getLogin() . '.');
     } elseif ($_POST['account_migration'] == 2) {
         switch (ilSession::get('tmp_auth_mode')) {
             case 'apache':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once 'Services/AuthApache/classes/class.ilAuthContainerApache.php';
                 $container = new ilAuthContainerApache();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'ldap':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once 'Services/LDAP/classes/class.ilAuthContainerLDAP.php';
                 $container = new ilAuthContainerLDAP();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'radius':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
                 include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
                 $container = new ilAuthContainerRadius();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'openid':
                 $_POST['username'] = ilSession::get('dummy');
                 $_POST['password'] = ilSession::get('dummy');
                 $_POST['oid_username'] = ilSession::get('tmp_oid_username');
                 $_POST['oid_provider'] = ilSession::get('tmp_oid_provider');
                 //ilSession::set('force_creation', true);
                 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
                 include_once './Services/OpenId/classes/class.ilAuthContainerOpenId.php';
                 $container = new ilAuthContainerOpenId();
                 $container->forceCreation(true);
                 ilAuthFactory::setContext(ilAuthFactory::CONTEXT_OPENID);
                 include_once './Services/OpenId/classes/class.ilAuthOpenId.php';
                 $ilAuth = ilAuthFactory::factory($container);
                 // logout first to initiate a new login session
                 $ilAuth->logout();
                 ilSession::_destroy(session_id());
                 ilSession::set('force_creation', true);
                 $ilAuth->start();
         }
         // Redirect to acceptance
         ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=" . $_GET["target"] . "&cmd=getAcceptance");
     }
     // show personal desktop
     ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
 }
Пример #29
0
    /**
     * @param ilObjUser $usr
     */
    public static function onUserDeletion(ilObjUser $usr)
    {
        /**
         * @var $ilDB ilDB
         */
        global $ilDB;
        $ilDB->manipulateF('UPDATE addressbook SET login = NULL, auto_update = %s WHERE login = %s AND email IS NOT NULL', array('integer', 'text'), array(0, $usr->getLogin()));
        $ilDB->manipulateF('DELETE FROM addressbook_mlist_ass WHERE addr_id IN(
				SELECT addr_id FROM addressbook WHERE login = %s AND email IS NULL
			)', array('text'), array($usr->getLogin()));
        $ilDB->manipulateF('DELETE FROM addressbook WHERE login = %s AND email IS NULL', array('text'), array($usr->getLogin()));
    }
 /**
  * Return all Placeholders of user data
  *
  * @param ilObjUser $user
  * @return array
  */
 protected function parseUserPlaceholders(ilObjUser $user)
 {
     return array('USER_LOGIN' => $this->anonymized ? 'johndoe' : $user->getLogin(), 'USER_TITLE' => $this->anonymized ? 'Mister' : $user->getUTitle(), 'USER_FULLNAME' => $this->anonymized ? 'John Doe' : $user->getFullname(), 'USER_FIRSTNAME' => $this->anonymized ? 'John' : $user->getFirstname(), 'USER_LASTNAME' => $this->anonymized ? 'Doe' : $user->getLastname(), 'USER_BIRTHDAY' => $user->getBirthday(), 'USER_INSTITUTION' => $user->getInstitution(), 'USER_DEPARTMENT' => $user->getDepartment(), 'USER_STREET' => $this->anonymized ? 'Manhattan Street' : $user->getStreet(), 'USER_CITY' => $this->anonymized ? 'New York' : $user->getCity(), 'USER_ZIPCODE' => $this->anonymized ? 10026 : $user->getZipcode(), 'USER_COUNTRY' => $this->anonymized ? 'USA' : $user->getCountry());
 }