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;
 }
 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;
 }
 public function parse($userSelected, $report, $reports)
 {
     global $ilCtrl, $lng;
     $lng->loadLanguageModule("scormtrac");
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($ilCtrl->getFormAction($this->parent_obj));
     $options = array("all" => $lng->txt("all"));
     include_once "Services/Tracking/classes/class.ilTrQuery.php";
     $users = ilTrQuery::getParticipantsForObject($this->parent_obj->object->ref_id);
     include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     $privacy = ilPrivacySettings::_getInstance();
     $allowExportPrivacy = $privacy->enabledExportSCORM();
     //$users = $this->parent_obj->object->getTrackedUsers("");
     foreach ($users as $user) {
         if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
             if ($allowExportPrivacy == true) {
                 $e_user = new ilObjUser($user);
                 $options[$user] = $e_user->getLastname() . ", " . $e_user->getFirstname();
             } else {
                 $options[$user] = 'User Id: ' . $user;
             }
         }
     }
     $si = new ilSelectInputGUI($lng->txt("user"), "userSelected");
     $si->setOptions($options);
     $si->setValue($userSelected);
     $this->form->addItem($si);
     $options = array("choose" => $lng->txt("please_choose"));
     for ($i = 0; $i < count($reports); $i++) {
         $options[$reports[$i]] = $lng->txt(strtolower($reports[$i]));
     }
     $si = new ilSelectInputGUI($lng->txt("report"), "report");
     $si->setOptions($options);
     $si->setValue($report);
     $this->form->addItem($si);
     $this->form->addCommandButton($this->parent_cmd, $lng->txt("apply_filter"));
 }
 protected function setRowForUser(&$set, $user_id)
 {
     $user = new ilObjUser($user_id);
     $set["first_name"] = $user->getFirstname();
     $set["last_name"] = $user->getLastname();
     $set["user_object"] = $user;
     $set["user_id"] = $user_id;
     if ($this->recursive) {
         $set["org_units"] = ilObjOrgUnitTree::_getInstance()->getOrgUnitOfUser($user_id, (int) $_GET['ref_id']);
     }
 }
 /**
  * display deletion confirmation screen
  */
 function deleteTrackingForUser()
 {
     if (!isset($_POST["user"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     // 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_delete_sure"));
     $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
     $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
     foreach ($_POST["user"] as $id) {
         if (ilObject::_exists($id) && ilObject::_lookUpType($id) == "usr") {
             $user = new ilObjUser($id);
             $caption = ilUtil::getImageTagByType("sahs", $this->tpl->tplPath) . " " . $this->lng->txt("cont_tracking_data") . ": " . $user->getLastname() . ", " . $user->getFirstname();
             $cgui->addItem("user[]", $id, $caption);
         }
     }
     $this->tpl->setContent($cgui->getHTML());
 }
 /**
  * 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;
     }
 }
 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();
 }
Exemple #8
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;
 }
 /**
  * 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();
 }
 /**
  * Stop offline mode for selected users
  */
 protected function stopUserOfflineMode()
 {
     if (!count((array) $_POST['user'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'), true);
         $this->ctrl->redirect($this, 'offlineModeManager');
     }
     // 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_stop_offline_mode_sure"));
     $cgui->setCancel($this->lng->txt("cancel"), "cancelStopUserOfflineMode");
     $cgui->setConfirm($this->lng->txt("confirm"), "confirmedStopUserOfflineMode");
     foreach ($_POST["user"] as $id) {
         if (ilObject::_exists($id) && ilObject::_lookUpType($id) == "usr") {
             $user = new ilObjUser($id);
             $caption = ilUtil::getImageTagByType("sahs_offline", $this->tpl->tplPath) . " " . $this->lng->txt("stop_user_offline_mode_for_user") . ": " . $user->getLastname() . ", " . $user->getFirstname();
             $cgui->addItem("user[]", $id, $caption);
         }
     }
     $this->tpl->setContent($cgui->getHTML());
 }
 public function addCrsGrpMembers()
 {
     global $ilCtrl, $lng;
     $this->pluginObj->includeClass('class.ilXAVCTableGUI.php');
     $this->tabs->activateTab('participants');
     $this->__setSubTabs('participants');
     $this->tabs->activateSubTab("addCrsGrpMembers");
     $lng->loadLanguageModule('crs');
     $my_tpl = new ilTemplate($this->pluginObj->getDirectory() . "/templates/default/tpl.meeting_participant_table.html", true, true);
     $oParticipants = $this->object->getParticipantsObject();
     /** @var $oParticipants  ilGroupParticipants */
     $admins = $oParticipants->getAdmins();
     $tutors = $oParticipants->getTutors();
     $members = $oParticipants->getMembers();
     $all_crs_members = array_unique(array_merge($admins, $tutors, $members));
     $counter = 0;
     $f_result_1 = NULL;
     foreach ($all_crs_members as $user_id) {
         if ($user_id > 0) {
             $tmp_user = new ilObjUser($user_id);
             $firstname = $tmp_user->getFirstname();
             $lastname = $tmp_user->getLastname();
             if ($tmp_user->hasPublicProfile() && $tmp_user->getPref('public_email') == 'y') {
                 $user_mail = $tmp_user->getEmail();
             } else {
                 $user_mail = '';
             }
         }
         $f_result_1[$counter]['checkbox'] = ilUtil::formCheckbox('', 'usr_id[]', $user_id);
         $f_result_1[$counter]['user_name'] = $lastname . ', ' . $firstname;
         $f_result_1[$counter]['email'] = $user_mail;
         ++$counter;
     }
     // show Administrator Table
     $tbl_admin = new ilXAVCTableGUI($this, 'addCrsGrpMembers');
     $ilCtrl->setParameter($this, 'cmd', 'editParticipants');
     $tbl_admin->setTitle($lng->txt("crs_members"));
     $tbl_admin->setId('tbl_admins');
     $tbl_admin->setRowTemplate($this->pluginObj->getDirectory() . "/templates/default/tpl.meeting_participant_row.html", false);
     $tbl_admin->addColumn('', 'checkbox', '1%', true);
     $tbl_admin->addColumn($this->pluginObj->txt('user_name'), 'user_name', '30%');
     $tbl_admin->addColumn($lng->txt('email'), 'email');
     $tbl_admin->setSelectAllCheckbox('usr_id[]');
     $tbl_admin->addMultiCommand('performAddCrsGrpMembers', $this->pluginObj->txt('add_crs_grp_members'));
     $tbl_admin->addCommandButton('editParticipants', $this->pluginObj->txt('cancel'));
     $tbl_admin->setData($f_result_1);
     $my_tpl->setVariable('ADMINS', $tbl_admin->getHTML());
     $this->tpl->setContent($my_tpl->get());
 }
 protected function setRowForUser(&$set, $user_id)
 {
     $user = new ilObjUser($user_id);
     $set["first_name"] = $user->getFirstname();
     $set["last_name"] = $user->getLastname();
     $set["user_object"] = $user;
     $set["user_id"] = $user_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);
 }
 /**
  * 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());
 }
 /**
  * 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;
 }
 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);
 }
 /**
  * Returns first letter of users firstname, followed by dot lastname
  *
  * @return string
  */
 public function buildShortname()
 {
     $firstname = $this->user->getFirstname();
     return $firstname[0] . '. ' . $this->user->getLastname();
 }