/**
  * Constructor
  * @access	public
  */
 function ilObjectStatusGUI(&$a_obj)
 {
     global $ilUser, $ilCtrl, $ilias, $ilErr, $lng, $rbacreview;
     $this->ctrl =& $ilCtrl;
     $this->object =& $a_obj;
     $this->tpl = new ilTemplate("tpl.info_layout.html", false, false, "Services/AccessControl");
     $this->tpl->setVariable("INFO_REMARK_INTERRUPTED", $lng->txt('info_remark_interrupted'));
     if (empty($_POST['Fuserid'])) {
         $this->user =& $ilUser;
     } else {
         if ($_POST['Fselect_type'] == "id") {
             $this->user = $ilias->obj_factory->getInstanceByObjId($_POST['Fuserid'], false);
         } else {
             include_once 'Services/User/classes/class.ilObjUser.php';
             $user_id = ilObjUser::_lookupId($_POST['Fuserid']);
             $this->user = $ilias->obj_factory->getInstanceByObjId($user_id, false);
         }
         if ($this->user === false or $this->user->getType() != 'usr') {
             $this->user =& $ilUser;
             ilUtil::sendFailure($lng->txt('info_err_user_not_exist'));
         } else {
             ilUtil::sendInfo($lng->txt('info_user_view_changed'));
         }
     }
     // get all user roles and all valid roles in scope
     $this->user_roles = $rbacreview->assignedRoles($this->user->getId());
     $this->global_roles = $rbacreview->getGlobalRoles();
     $this->valid_roles = $rbacreview->getParentRoleIds($this->object->getRefId());
     $this->assigned_valid_roles = $this->getAssignedValidRoles();
     $this->getPermissionInfo();
     $this->getRoleAssignmentInfo();
     $this->getObjectSummary();
 }
 function changeOwner()
 {
     global $rbacsystem, $ilObjDataCache;
     if (!($user_id = ilObjUser::_lookupId($_POST['owner']))) {
         ilUtil::sendFailure($this->lng->txt('user_not_known'));
         $this->owner();
         return true;
     }
     // no need to change?
     if ($user_id != $this->gui_obj->object->getOwner()) {
         $this->gui_obj->object->setOwner($user_id);
         $this->gui_obj->object->updateOwner();
         $ilObjDataCache->deleteCachedEntry($this->gui_obj->object->getId());
         include_once "Services/AccessControl/classes/class.ilRbacLog.php";
         if (ilRbacLog::isActive()) {
             ilRbacLog::add(ilRbacLog::CHANGE_OWNER, $this->gui_obj->object->getRefId(), array($user_id));
         }
     }
     ilUtil::sendSuccess($this->lng->txt('owner_updated'), true);
     if (!$rbacsystem->checkAccess("edit_permission", $this->gui_obj->object->getRefId())) {
         $this->ctrl->redirect($this->gui_obj);
         return true;
     }
     $this->ctrl->redirect($this, 'owner');
     return true;
 }
    /**
     * 
     * Send notifications	 
     *  
     * @access	public
     *  
     */
    public function send()
    {
        global $ilDB;
        // parent::send();
        if (count($this->getRecipients())) {
            $res = $ilDB->queryf("SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active," . "u.time_limit_unlimited, " . $ilDB->fromUnixtime("u.time_limit_from") . ", " . $ilDB->fromUnixtime("u.time_limit_until") . "," . "CASE WHEN u.active = 0 THEN '0001-01-01' ELSE CASE WHEN u.time_limit_unlimited=1 THEN '9999-12-31' ELSE " . $ilDB->fromUnixtime("u.time_limit_until") . " END END access_until," . " CASE WHEN " . $ilDB->unixTimestamp() . " BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired," . "rq.role_disk_quota, system_role.rol_id role_id, " . "p1.value+0 user_disk_quota," . "p2.value+0 disk_usage, " . "p3.value last_update, " . "p5.value language, " . "CASE WHEN rq.role_disk_quota>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota ELSE p1.value+0 END disk_quota\t" . "FROM usr_data u  " . "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " . "FROM usr_data u " . "JOIN rbac_ua ua ON ua.usr_id=u.usr_id " . "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s  " . "JOIN role_data rd ON rd.role_id=ua.rol_id WHERE u.usr_id=ua.usr_id GROUP BY u.usr_id) rq ON rq.usr_id=u.usr_id " . "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " . "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota'  " . "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage'  " . "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update'  " . "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language'  " . 'WHERE (((p1.value+0 > rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR 
					((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ' . 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR ' . $ilDB->unixTimestamp() . ' BETWEEN u.time_limit_from AND u.time_limit_until)) ', array('integer', 'integer'), array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID));
            $users = array();
            $counter = 0;
            while ($row = $ilDB->fetchAssoc($res)) {
                $details = ilDiskQuotaChecker::_lookupDiskUsage($row['usr_id']);
                $users[$counter]['disk_quota'] = $row['disk_quota'];
                $users[$counter]['disk_usage'] = $details['disk_usage'];
                $users[$counter]['email'] = $row['email'];
                $users[$counter]['firstname'] = $row['firstname'];
                $users[$counter]['lastname'] = $row['lastname'];
                ++$counter;
            }
            if (count($users)) {
                foreach ($this->getRecipients() as $rcp) {
                    $usrId = ilObjUser::_lookupId($rcp);
                    $this->initLanguage($usrId);
                    $this->initMail();
                    $this->setSubject($this->getLanguage()->txt('disk_quota_summary_subject'));
                    $this->setBody(ilMail::getSalutation($usrId, $this->getLanguage()));
                    $this->appendBody("\n\n");
                    $this->appendBody($this->getLanguage()->txt('disk_quota_exceeded_headline'));
                    $this->appendBody("\n\n");
                    $first = true;
                    $counter = 0;
                    $numUsers = count($users);
                    foreach ($users as $user) {
                        if (!$first) {
                            $this->appendBody("\n---------------------------------------------------\n\n");
                        }
                        $this->appendBody($this->getLanguage()->txt('fullname') . ': ' . $user['lastname'] . ', ' . $user['firstname'] . "\n");
                        $this->appendBody($this->getLanguage()->txt('email') . ': ' . $user['email'] . "\n");
                        $this->appendBody($this->getLanguage()->txt('disk_quota') . ': ' . ilFormat::formatSize($user['disk_quota'], 'short', $this->getLanguage()) . "\n");
                        $this->appendBody($this->getLanguage()->txt('currently_used_disk_space') . ': ' . ilFormat::formatSize($user['disk_usage'], 'short', $this->getLanguage()) . "\n");
                        $this->appendBody($this->getLanguage()->txt('usrf_profile_link') . ': ' . ilUtil::_getHttpPath() . '/goto.php?target=usrf&client_id=' . CLIENT_ID);
                        if ($counter < $numUsers - 1) {
                            $this->appendBody("\n");
                        }
                        ++$counter;
                        $first = false;
                    }
                    $this->getMail()->appendInstallationSignature(true);
                    $this->sendMail(array($rcp), array('system'), false);
                }
            }
        }
    }
 /** 
  * Called from fetchData after successful login.
  *
  * @param string username
  */
 public function loginObserver($a_username, $a_auth)
 {
     $usr_id = ilObjUser::_lookupId($a_username);
     $auth_mode = ilObjUser::_lookupAuthMode($usr_id);
     $auth_id = ilAuthUtils::_getAuthMode($auth_mode);
     $GLOBALS['ilLog']->write(__METHOD__ . ': auth id =  ' . $auth_id);
     switch ($auth_id) {
         case AUTH_LOCAL:
             return true;
         default:
             if (ilAuthUtils::isPasswordModificationEnabled($auth_id)) {
                 return true;
             }
     }
     $a_auth->status = AUTH_WRONG_LOGIN;
     $a_auth->logout();
     return false;
 }
 /**
  * Sends a notification message to all users responsible for vat assignment.
  * 
  * @access	public
  * @static
  * @param	ilPaymentObject $oPaymentObject
  */
 public static function _sendNotificationToVATAdministration($oPaymentObject)
 {
     global $ilSetting, $lng, $ilClientIniFile;
     $payment_vat_admins = $ilSetting->get('payment_vat_admins');
     $users = explode(',', $payment_vat_admins);
     $subject = $lng->txt('payment_vat_assignment_notification_subject');
     $tmp_obj = ilObjectFactory::getInstanceByRefId($oPaymentObject->getRefId());
     $message = sprintf($lng->txt('payment_vat_assignment_notification_body'), $tmp_obj->getTitle()) . "\n\n";
     $message .= "------------------------------------------------------------\n";
     $message .= sprintf($lng->txt('payment_vat_assignment_notification_intro'), $ilClientIniFile->readVariable('client', 'name'), ILIAS_HTTP_PATH . '/?client_id=' . CLIENT_ID);
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail_obj = new ilMail(ANONYMOUS_USER_ID);
     foreach ((array) $users as $login) {
         if (strlen(trim($login)) && (int) ilObjUser::_lookupId(trim($login))) {
             $success = $mail_obj->sendMail(trim($login), '', '', $subject, $message, array(), array("system"));
         }
     }
 }
 /**
  * @param $id
  * @param $type
  *
  * @return bool
  */
 private function buildUserId($id, $type)
 {
     global $ilDB;
     if ($type == 'ilias_login') {
         $user_id = ilObjUser::_lookupId($id);
         return $user_id ? $user_id : false;
     } elseif ($type == 'external_id') {
         $user_id = ilObjUser::_lookupObjIdByImportId($id);
         return $user_id ? $user_id : false;
     } elseif ($type == 'email') {
         $q = 'SELECT usr_id FROM usr_data WHERE email = ' . $ilDB->quote($id, 'text');
         $set = $ilDB->query($q);
         $user_id = $ilDB->fetchAssoc($set);
         return $user_id ? $user_id : false;
     } elseif ($type == 'user_id') {
         return $id;
     } else {
         return false;
     }
 }
 /**
  * Check user's input
  */
 function checkInput($addr_id = 0)
 {
     // check if user login and e-mail-address are empty
     if (!strcmp(trim($_POST["login"]), "") && !strcmp(trim($_POST["email"]), "")) {
         ilUtil::sendInfo($this->lng->txt("mail_enter_login_or_email_addr"));
         $error = true;
     } else {
         if ($_POST["login"] != "" && !ilObjUser::_lookupId(ilUtil::stripSlashes($_POST["login"]))) {
             ilUtil::sendInfo($this->lng->txt("mail_enter_valid_login"));
             $error = true;
         } else {
             if ($_POST["email"] && !ilUtil::is_email($_POST["email"])) {
                 ilUtil::sendInfo($this->lng->txt("mail_enter_valid_email_addr"));
                 $error = true;
             }
         }
     }
     if (($this->existingEntry = $this->abook->checkEntryByLogin(ilUtil::stripSlashes($_POST["login"]))) > 0 && ($this->existingEntry != $addr_id && $addr_id > 0 || !$addr_id)) {
         ilUtil::sendInfo($this->lng->txt("mail_entry_exists"));
         $error = true;
     }
     return $error ? false : true;
 }
 /**
  * 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');
 }
 /**
  * save Record
  *
  * @param string $a_mode values: create | edit
  */
 public function save()
 {
     global $tpl, $ilUser, $lng, $ilCtrl;
     $this->initForm();
     if ($this->form->checkInput()) {
         $record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
         $date_obj = new ilDateTime(time(), IL_CAL_UNIX);
         $record_obj->setTableId($this->table_id);
         $record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
         $record_obj->setLastEditBy($ilUser->getId());
         $create_mode = false;
         if (ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id)) {
             $all_fields = $this->table->getRecordFields();
         } else {
             $all_fields = $this->table->getEditableFields();
         }
         $fail = "";
         //Check if we can create this record.
         foreach ($all_fields as $field) {
             try {
                 $value = $this->form->getInput("field_" . $field->getId());
                 $field->checkValidity($value, $this->record_id);
             } catch (ilDataCollectionInputException $e) {
                 $fail .= $field->getTitle() . ": " . $e . "<br>";
             }
         }
         if ($fail) {
             ilUtil::sendFailure($fail, true);
             $this->sendFailure();
             return;
         }
         if (!isset($this->record_id)) {
             if (!$this->table->hasPermissionToAddRecord($this->parent_obj->ref_id)) {
                 $this->accessDenied();
                 return;
             }
             $record_obj->setOwner($ilUser->getId());
             $record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
             $record_obj->setTableId($this->table_id);
             $record_obj->doCreate();
             $this->record_id = $record_obj->getId();
             $create_mode = true;
         } else {
             if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
                 $this->accessDenied();
                 return;
             }
         }
         //edit values, they are valid we already checked them above
         foreach ($all_fields as $field) {
             $value = $this->form->getInput("field_" . $field->getId());
             //deletion flag on MOB inputs.
             if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB && $this->form->getItemByPostVar("field_" . $field->getId())->getDeletionFlag()) {
                 $value = -1;
             }
             $record_obj->setRecordFieldValue($field->getId(), $value);
         }
         // Do we need to set a new owner for this record?
         if (!$create_mode) {
             $owner_id = ilObjUser::_lookupId($_POST['field_owner']);
             if (!$owner_id) {
                 ilUtil::sendFailure($lng->txt('user_not_known'));
                 $this->sendFailure();
                 return;
             }
             $record_obj->setOwner($owner_id);
         }
         if ($create_mode) {
             ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId());
         }
         $record_obj->doUpdate();
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
         $ilCtrl->setParameter($this, "table_id", $this->table_id);
         $ilCtrl->setParameter($this, "record_id", $this->record_id);
         $ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
     } else {
         global $tpl;
         $this->form->setValuesByPost();
         $tpl->setContent($this->form->getHTML());
     }
 }
 function addUserFromAutoComplete()
 {
     if (!strlen(trim($_POST['user_login']))) {
         ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
         $this->showSubmissions();
         return false;
     }
     $users = explode(',', $_POST['user_login']);
     $user_ids = array();
     foreach ($users as $user) {
         $user_id = ilObjUser::_lookupId($user);
         if (!$user_id) {
             ilUtil::sendFailure($this->lng->txt('user_not_known'));
             return $this->showSubmissions();
         }
         $user_ids[] = $user_id;
     }
     if (!$this->addParticipant($user_ids)) {
     }
     $this->showSubmissions();
     return false;
     return true;
 }
Beispiel #11
0
} else {
    if ($_GET["user_id"] != "" && ilObjUser::_getFeedPass($_GET["user_id"]) != "" && (md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass($_GET["user_id"]) && $_SERVER['PHP_AUTH_USER'] == ilObjUser::_lookupLogin($_GET["user_id"])) && $feed_set->get("enable_private_feed")) {
        include_once "./Services/Feeds/classes/class.ilUserFeedWriter.php";
        // Third parameter is true for private feed
        $writer = new ilUserFeedWriter($_GET["user_id"], $_GET["hash"], true);
        $writer->showFeed();
    } else {
        if ($_GET["ref_id"] != "" && md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']))) {
            include_once "./Services/Feeds/classes/class.ilObjectFeedWriter.php";
            // Second parameter is optional to pass on to database-level to get news for logged-in users
            $writer = new ilObjectFeedWriter($_GET["ref_id"], ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']));
            $writer->showFeed();
        } else {
            // send appropriate header, if password is wrong, otherwise
            // there is no chance to re-enter it (unless, e.g. the browser is closed)
            if (md5($_SERVER['PHP_AUTH_PW']) != ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']))) {
                Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
                Header("HTTP/1.0 401 Unauthorized");
                exit;
            }
            include_once "./Services/Feeds/classes/class.ilFeedItem.php";
            include_once "./Services/Feeds/classes/class.ilFeedWriter.php";
            $blankFeedWriter = new ilFeedWriter();
            $feed_item = new ilFeedItem();
            $lng->loadLanguageModule("news");
            if ($ilSetting->get('short_inst_name') != "") {
                $blankFeedWriter->setChannelTitle($ilSetting->get('short_inst_name'));
            } else {
                $blankFeedWriter->setChannelTitle("ILIAS");
            }
            if (!$feed_set->get("enable_private_feed")) {
 /**
  * when current session is allowed to be created it marks it with
  * type regarding to the sessions user context.
  * when session is not allowed to be created it will be destroyed.
  */
 public static function handleLoginEvent($a_login, $a_auth)
 {
     global $ilSetting;
     require_once 'Services/User/classes/class.ilObjUser.php';
     $user_id = ilObjUser::_lookupId($a_login);
     // we need the session type for the session statistics
     // regardless of the current session handling type
     switch (true) {
         case isset($_ENV['SHELL']):
             $type = self::SESSION_TYPE_SYSTEM;
             break;
         case $user_id == ANONYMOUS_USER_ID:
             $type = self::SESSION_TYPE_ANONYM;
             break;
         case self::checkAdministrationPermission($user_id):
             $type = self::SESSION_TYPE_ADMIN;
             break;
         default:
             $type = self::SESSION_TYPE_USER;
             break;
     }
     $_SESSION['SessionType'] = $type;
     self::debug(__METHOD__ . " --> update sessions type to (" . $type . ")");
     // do not handle login event in fixed duration mode
     if ($ilSetting->get('session_handling_type', 0) != 1) {
         return;
     }
     if (in_array($type, self::$session_types_controlled)) {
         self::checkCurrentSessionIsAllowed($a_auth, $user_id);
     }
 }
 /**
  *
  */
 public function byLogin()
 {
     $this->inviteById(ilObjUser::_lookupId($_REQUEST['users']));
 }
 function getUserIdByLogin($a_login)
 {
     return (int) ilObjUser::_lookupId($a_login);
 }
 /**
  * Autocomplete submit
  */
 public function addUserFromAutoComplete()
 {
     global $lng;
     if (!strlen(trim($_POST['user_login']))) {
         ilUtil::sendFailure($lng->txt('msg_no_search_string'));
         return $this->contributors();
     }
     $users = explode(',', $_POST['user_login']);
     $user_ids = array();
     foreach ($users as $user) {
         $user_id = ilObjUser::_lookupId($user);
         if (!$user_id) {
             ilUtil::sendFailure($lng->txt('user_not_known'));
             return $this->contributors();
         }
         $user_ids[] = $user_id;
     }
     return $this->addContributor($user_ids);
 }
 /**
  * Save the survey properties
  *
  * Save the survey properties
  *
  * @access private
  */
 function savePropertiesObject()
 {
     global $rbacsystem;
     $form = $this->initPropertiesForm();
     if ($form->checkInput()) {
         $valid = true;
         if (!$this->object->get360Mode()) {
             if ($form->getInput("tut")) {
                 // check if given "tutors" have write permission
                 $tut_ids = array();
                 $tut_logins = $form->getInput("tut_ids");
                 foreach ($tut_logins as $tut_login) {
                     $tut_id = ilObjUser::_lookupId($tut_login);
                     if ($tut_id && $rbacsystem->checkAccessOfUser($tut_id, "write", $this->object->getRefId())) {
                         $tut_ids[] = $tut_id;
                     }
                 }
                 if (!$tut_ids) {
                     $tut_ids = $form->getItemByPostVar("tut_ids");
                     $tut_ids->setAlert($this->lng->txt("survey_notification_tutor_recipients_invalid"));
                     $valid = false;
                 }
             }
         }
         if ($valid) {
             if (!$this->object->get360Mode()) {
                 if ($form->getInput("rmd")) {
                     $rmd_start = $form->getInput("rmd_start");
                     $rmd_start = $rmd_start["date"];
                     $rmd_end = null;
                     if ($form->getInput("rmd_end_tgl")) {
                         $rmd_end = $form->getInput("rmd_end");
                         $rmd_end = $rmd_end["date"];
                         if ($rmd_start > $rmd_end) {
                             $tmp = $rmd_start;
                             $rmd_start = $rmd_end;
                             $rmd_end = $tmp;
                         }
                         $rmd_end = new ilDate($rmd_end, IL_CAL_DATE);
                     }
                     $rmd_start = new ilDate($rmd_start, IL_CAL_DATE);
                     $this->object->setReminderStatus(true);
                     $this->object->setReminderStart($rmd_start);
                     $this->object->setReminderEnd($rmd_end);
                     $this->object->setReminderFrequency($form->getInput("rmd_freq"));
                     $this->object->setReminderTarget($form->getInput("rmd_grp"));
                 } else {
                     $this->object->setReminderStatus(false);
                 }
                 if ($form->getInput("tut")) {
                     $this->object->setTutorNotificationStatus(true);
                     $this->object->setTutorNotificationRecipients($tut_ids);
                     // see above
                     $this->object->setTutorNotificationTarget($form->getInput("tut_grp"));
                 } else {
                     $this->object->setTutorNotificationStatus(false);
                 }
             }
             // #10055
             if ($_POST['online'] && count($this->object->questions) == 0) {
                 $_POST['online'] = null;
                 ilUtil::sendFailure($this->lng->txt("cannot_switch_to_online_no_questions"), true);
             }
             $template_settings = null;
             $template = $this->object->getTemplate();
             if ($template) {
                 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
                 $template = new ilSettingsTemplate($template);
                 $template_settings = $template->getSettings();
             }
             include_once 'Services/MetaData/classes/class.ilMD.php';
             $md_obj =& new ilMD($this->object->getId(), 0, "svy");
             $md_section = $md_obj->getGeneral();
             // title
             $md_section->setTitle(ilUtil::stripSlashes($_POST['title']));
             $md_section->update();
             // Description
             $md_desc_ids = $md_section->getDescriptionIds();
             if ($md_desc_ids) {
                 $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
                 $md_desc->setDescription(ilUtil::stripSlashes($_POST['description']));
                 $md_desc->update();
             }
             $this->object->setViewOwnResults($_POST["view_own"]);
             $this->object->setMailOwnResults($_POST["mail_own"]);
             // both are saved in object, too
             $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
             $this->object->setDescription(ilUtil::stripSlashes($_POST['description']));
             $this->object->update();
             $this->object->setStatus($_POST['online']);
             // activation
             if ($_POST["access_type"]) {
                 $this->object->setActivationLimited(true);
                 $this->object->setActivationVisibility($_POST["access_visiblity"]);
                 $period = $form->getItemByPostVar("access_period");
                 $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
                 $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
             } else {
                 $this->object->setActivationLimited(false);
             }
             if (!$template_settings["enabled_start_date"]["hide"]) {
                 if ($_POST["enabled_start_date"]) {
                     $this->object->setStartDateAndTime($_POST["start_date"]['date'], $_POST["start_date"]['time']);
                 } else {
                     $this->object->setStartDate(null);
                 }
             }
             if (!$template_settings["enabled_end_date"]["hide"]) {
                 if ($_POST["enabled_end_date"]) {
                     $this->object->setEndDateAndTime($_POST["end_date"]['date'], $_POST["end_date"]['time']);
                 } else {
                     $this->object->setEndDate(null);
                 }
             }
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $introduction = $_POST["introduction"];
             $this->object->setIntroduction($introduction);
             $outro = $_POST["outro"];
             $this->object->setOutro($outro);
             if (!$template_settings["show_question_titles"]["hide"]) {
                 $this->object->setShowQuestionTitles($_POST["show_question_titles"]);
             }
             if (!$template_settings["use_pool"]["hide"]) {
                 $this->object->setPoolUsage($_POST["use_pool"]);
             }
             $this->object->setMailNotification($_POST['mailnotification']);
             $this->object->setMailAddresses($_POST['mailaddresses']);
             $this->object->setMailParticipantData($_POST['mailparticipantdata']);
             // 360°
             if ($this->object->get360Mode()) {
                 $this->object->set360SelfEvaluation((bool) $_POST["self_eval"]);
                 $this->object->set360SelfAppraisee((bool) $_POST["self_appr"]);
                 $this->object->set360SelfRaters((bool) $_POST["self_rate"]);
                 $this->object->set360Results((int) $_POST["ts_res"]);
                 $this->object->set360SkillService((int) $_POST["skill_service"]);
             } else {
                 $this->object->setEvaluationAccess($_POST["evaluation_access"]);
                 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
                 if (!$hasDatasets) {
                     $codes = (bool) $_POST["acc_codes"];
                     $anon = (string) $_POST["anonymization_options"] == "statanon";
                     if (!$anon) {
                         if (!$codes) {
                             $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_OFF);
                         } else {
                             $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_CODE_ALL);
                         }
                     } else {
                         if ($codes) {
                             $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_ON);
                         } else {
                             $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_FREEACCESS);
                         }
                     }
                     // if settings were changed get rid of existing code
                     unset($_SESSION["anonymous_id"][$this->object->getId()]);
                 }
             }
             $this->object->saveToDb();
             if (strcmp($_SESSION["info"], "") != 0) {
                 ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("settings_saved"), true);
             } else {
                 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
             }
             $this->ctrl->redirect($this, "properties");
         }
     }
     $form->setValuesByPost();
     $this->propertiesObject($form);
 }
Beispiel #17
0
 /**
  * Creates a user, sets preferences, lookups data, delete user
  * @group IL_Init
  */
 public function testCreateSetLookupDelete()
 {
     include_once "./Services/User/classes/class.ilObjUser.php";
     // delete all aatestuser from previous runs
     while (($i = ilObjUser::_lookupId("aatestuser")) > 0) {
         $user = new ilObjUser($i);
         $user->delete();
     }
     $user = new ilObjUser();
     // creation
     $d = array("login" => "aatestuser", "passwd_type" => IL_PASSWD_PLAIN, "passwd" => "password", "gender" => "m", "firstname" => "Max", "lastname" => "Mutzke", "email" => "*****@*****.**", "client_ip" => "1.2.3.4", "ext_account" => "ext_mutzke");
     $user->assignData($d);
     $user->create();
     $user->saveAsNew();
     $user->setLanguage("no");
     $user->writePrefs();
     $id = $user->getId();
     $value .= $user->getFirstname() . "-";
     // update
     $user->setFirstname("Maxi");
     $user->update();
     $value .= $user->getFirstname() . "-";
     // other update methods
     $user->refreshLogin();
     // lookups
     $value .= ilObjUser::_lookupEmail($id) . "-";
     $value .= ilObjUser::_lookupGender($id) . "-";
     $value .= ilObjUser::_lookupClientIP($id) . "-";
     $n = ilObjUser::_lookupName($id);
     $value .= $n["lastname"] . "-";
     ilObjUser::_lookupFields($id);
     $value .= ilObjUser::_lookupLogin($id) . "-";
     $value .= ilObjUser::_lookupExternalAccount($id) . "-";
     $value .= ilObjUser::_lookupId("aatestuser") . "-";
     ilObjUser::_lookupLastLogin($id);
     $value .= ilObjUser::_lookupLanguage($id) . "-";
     ilObjUser::_readUsersProfileData(array($id));
     if (ilObjUser::_loginExists("aatestuser")) {
         $value .= "le-";
     }
     // preferences...
     $user->writePref("testpref", "pref1");
     $value .= ilObjUser::_lookupPref($id, "testpref") . "-";
     $user->deletePref("testpref");
     if (ilObjUser::_lookupPref($id, "testpref") == "") {
         $value .= "pref2" . "-";
     }
     // activation
     $user->setActive(false);
     if (!ilObjUser::getStoredActive($id)) {
     }
     $value .= "act1-";
     $user->setActive(true);
     if (ilObjUser::getStoredActive($id)) {
     }
     $value .= "act2-";
     ilObjUser::_toggleActiveStatusOfUsers(array($id), false);
     if (!ilObjUser::getStoredActive($id)) {
     }
     $value .= "act3-";
     // deletion
     $user->delete();
     $this->assertEquals("Max-Maxi-de@de.de-m-1.2.3.4-Mutzke-aatestuser-ext_mutzke-{$id}-no-le-" . "pref1-pref2-act1-act2-act3-", $value);
 }
 function initIlias($context = "web")
 {
     global $ilDB, $ilUser, $ilLog, $ilErr, $ilClientIniFile, $ilIliasIniFile, $ilSetting, $ilias, $https, $ilObjDataCache, $ilLog, $objDefinition, $lng, $ilCtrl, $ilBrowser, $ilHelp, $ilTabs, $ilMainMenu, $rbacsystem, $ilNavigationHistory;
     // remove unsafe characters
     $this->removeUnsafeCharacters();
     // error reporting
     // remove notices from error reporting
     if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
         error_reporting(ini_get("error_reporting") & ~E_NOTICE & ~E_DEPRECATED);
     } else {
         error_reporting(ini_get('error_reporting') & ~E_NOTICE);
     }
     // include common code files
     $this->requireCommonIncludes();
     global $ilBench;
     // set error handler (to do: check preconditions for error handler to work)
     $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
     $ilErr = new ilErrorHandling();
     $GLOBALS['ilErr'] =& $ilErr;
     $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, 'errorHandler'));
     $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
     // prepare file access to work with safe mode (has been done in class ilias before)
     umask(0117);
     // set cookie params
     $this->setCookieParams();
     // $ilIliasIniFile initialisation
     $this->initIliasIniFile();
     // CLIENT_ID determination
     $this->determineClient();
     // $ilAppEventHandler initialisation
     $this->initEventHandling();
     // $ilClientIniFile initialisation
     $this->initClientIniFile();
     // removed redirection madness the service should respond with SERVICE UNAVAILABLE
     // $ilDB initialisation
     $this->initDatabase();
     // init plugin admin class
     include_once "Services/Component/classes/class.ilPluginAdmin.php";
     $ilPluginAdmin = new ilPluginAdmin();
     $GLOBALS['ilPluginAdmin'] = $ilPluginAdmin;
     // set session handler
     $this->setSessionHandler();
     // $ilSetting initialisation
     $this->initSettings();
     // $ilLog initialisation
     $this->initLog();
     // $https initialisation
     require_once 'classes/class.ilHTTPS.php';
     $https = new ilHTTPS();
     $GLOBALS['https'] =& $https;
     $https->enableSecureCookies();
     $https->checkPort();
     if ($this->returnBeforeAuth()) {
         return;
     }
     $ilCtrl = new ilCtrl2();
     $GLOBALS['ilCtrl'] =& $ilCtrl;
     // $ilAuth initialisation
     include_once "Services/Authentication/classes/class.ilAuthUtils.php";
     ilAuthUtils::_initAuth();
     global $ilAuth;
     $this->includePhp5Compliance();
     // Do not accept external session ids
     if (!ilSession::_exists(session_id())) {
         // $_GET["PHPSESSID"] = "";
         session_regenerate_id();
     }
     // $ilias initialisation
     global $ilias, $ilBench;
     $ilBench->start("Core", "HeaderInclude_GetILIASObject");
     $ilias = new ILIAS();
     $GLOBALS['ilias'] =& $ilias;
     $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
     // $ilObjDataCache initialisation
     $ilObjDataCache = new ilObjectDataCache();
     $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
     // workaround: load old post variables if error handler 'message' was called
     if (isset($_SESSION["message"]) && $_SESSION["message"]) {
         $_POST = $_SESSION["post_vars"];
     }
     // put debugging functions here
     require_once "include/inc.debug.php";
     // $objDefinition initialisation
     $ilBench->start("Core", "HeaderInclude_getObjectDefinitions");
     $objDefinition = new ilObjectDefinition();
     $GLOBALS['objDefinition'] =& $objDefinition;
     // $objDefinition->startParsing();
     $ilBench->stop("Core", "HeaderInclude_getObjectDefinitions");
     // init tree
     $tree = new ilTree(ROOT_FOLDER_ID);
     $GLOBALS['tree'] =& $tree;
     // $ilAccess and $rbac... initialisation
     $this->initAccessHandling();
     // authenticate & start session
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
     $ilBench->start("Core", "HeaderInclude_Authentication");
     //var_dump($_SESSION);
     ////require_once('Log.php');
     ////$ilAuth->logger = Log::singleton('error_log',PEAR_LOG_TYPE_SYSTEM,'TEST');
     ////$ilAuth->enableLogging = true;
     if (!defined("IL_PHPUNIT_TEST")) {
         $oldSid = session_id();
         $ilAuth->start();
         $newSid = session_id();
         include_once 'Services/Payment/classes/class.ilPaymentShoppingCart.php';
         ilPaymentShoppingCart::_migrateShoppingCart($oldSid, $newSid);
     }
     //var_dump($_SESSION);
     $ilias->setAuthError($ilErr->getLastError());
     $ilBench->stop("Core", "HeaderInclude_Authentication");
     // workaround: force login
     if (!empty($_GET["cmd"]) && $_GET["cmd"] == "force_login" || $this->script == "login.php") {
         $ilAuth->logout();
         if (!isset($_GET['forceShoppingCartRedirect'])) {
             $_SESSION = array();
         }
         $_SESSION["AccountId"] = "";
         $ilAuth->start();
         $ilias->setAuthError($ilErr->getLastError());
     }
     // check correct setup
     if (!$ilias->getSetting("setup_ok")) {
         die("Setup is not completed. Please run setup routine again.");
     }
     // $ilUser initialisation (1)
     $ilBench->start("Core", "HeaderInclude_getCurrentUser");
     $ilUser = new ilObjUser();
     $ilias->account =& $ilUser;
     $GLOBALS['ilUser'] =& $ilUser;
     $ilBench->stop("Core", "HeaderInclude_getCurrentUser");
     // $ilCtrl initialisation
     //$ilCtrl = new ilCtrl();
     // determin current script and up-path to main directory
     // (sets $this->script and $this->updir)
     $this->determineScriptAndUpDir();
     // $styleDefinition initialisation and style handling for login and co.
     $this->initStyle();
     if (in_array($this->script, array("login.php", "register.php", "view_usr_agreement.php")) || $_GET["baseClass"] == "ilStartUpGUI") {
         $this->handleStyle();
     }
     // init locale
     $this->initLocale();
     // handle ILIAS 2 imported users:
     // check ilias 2 password, if authentication failed
     // only if AUTH_LOCAL
     //echo "A";
     if (AUTH_CURRENT == AUTH_LOCAL && !$ilAuth->getAuth() && $this->script == "login.php" && $_POST["username"] != "") {
         if (ilObjUser::_lookupHasIlias2Password(ilUtil::stripSlashes($_POST["username"]))) {
             if (ilObjUser::_switchToIlias3Password(ilUtil::stripSlashes($_POST["username"]), ilUtil::stripSlashes($_POST["password"]))) {
                 $ilAuth->start();
                 $ilias->setAuthError($ilErr->getLastError());
                 ilUtil::redirect("index.php");
             }
         }
     }
     //
     // SUCCESSFUL AUTHENTICATION
     //
     if ($ilAuth->getStatus() == '' && $ilias->account->isCurrentUserActive() || defined("IL_PHPUNIT_TEST") && DEVMODE) {
         //echo "C"; exit;
         $ilBench->start("Core", "HeaderInclude_getCurrentUserAccountData");
         //var_dump($_SESSION);
         // get user data
         $this->initUserAccount();
         //var_dump($_SESSION);
         // differentiate account security mode
         require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
         $security_settings = ilSecuritySettings::_getInstance();
         if ($security_settings->getAccountSecurityMode() == ilSecuritySettings::ACCOUNT_SECURITY_MODE_CUSTOMIZED) {
             // reset counter for failed logins
             ilObjUser::_resetLoginAttempts($ilUser->getId());
         }
         $ilBench->stop("Core", "HeaderInclude_getCurrentUserAccountData");
     } else {
         if (!$ilAuth->getAuth()) {
             require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
             // differentiate account security mode
             $security = ilSecuritySettings::_getInstance();
             if ($security->getAccountSecurityMode() == ilSecuritySettings::ACCOUNT_SECURITY_MODE_CUSTOMIZED) {
                 if (isset($_POST['username']) && $_POST['username'] && $ilUser->getId() == 0) {
                     $username = ilUtil::stripSlashes($_POST['username']);
                     $usr_id = ilObjUser::_lookupId($username);
                     if ($usr_id != ANONYMOUS_USER_ID) {
                         ilObjUser::_incrementLoginAttempts($usr_id);
                         $login_attempts = ilObjUser::_getLoginAttempts($usr_id);
                         $max_attempts = $security->getLoginMaxAttempts();
                         if ($login_attempts >= $max_attempts && $usr_id != SYSTEM_USER_ID && $max_attempts > 0) {
                             ilObjUser::_setUserInactive($usr_id);
                         }
                     }
                 }
             }
         }
     }
     //
     // SUCCESSFUL AUTHENTICATED or NON-AUTH-AREA (Login, Registration, ...)
     //
     // $lng initialisation
     $this->initLanguage();
     // store user language in tree
     $GLOBALS['tree']->initLangCode();
     // ### AA 03.10.29 added new LocatorGUI class ###
     // when locator data array does not exist, initialise
     if (!isset($_SESSION["locator_level"])) {
         $_SESSION["locator_data"] = array();
         $_SESSION["locator_level"] = -1;
     }
     // initialise global ilias_locator object
     // ECS Tasks
     include_once 'Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php';
     $scheduler = ilECSTaskScheduler::start();
     $ilBench->stop("Core", "HeaderInclude");
 }
Beispiel #19
0
 /**
  * Called after failed login
  * @return 
  * @param array $a_username
  * @param object $a_auth
  */
 protected function failedLoginObserver($a_username, $a_auth)
 {
     global $ilLog;
     $ilLog->write(__METHOD__ . ': login failed for user ' . $a_username . ', remote:' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] . ', server:' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT']);
     if ($a_username) {
         $usr_id = ilObjUser::_lookupId($a_username);
         if (!in_array($usr_id, array(ANONYMOUS_USER_ID, SYSTEM_USER_ID))) {
             ilObjUser::_incrementLoginAttempts($usr_id);
             $login_attempts = ilObjUser::_getLoginAttempts($usr_id);
             require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
             $security = ilSecuritySettings::_getInstance();
             $max_attempts = $security->getLoginMaxAttempts();
             if ((int) $max_attempts && $login_attempts >= $max_attempts) {
                 ilObjUser::_setUserInactive($usr_id);
             }
         }
     }
     return $this->getContainer()->failedLoginObserver($a_username, $a_auth);
 }
 function validate()
 {
     $this->unknown = array();
     $this->mail_perm = array();
     $login_arr = explode(',', $this->getApproveRecipientLogins());
     $login_arr = $login_arr ? $login_arr : array();
     foreach ($login_arr as $recipient) {
         if (!($recipient = trim($recipient))) {
             continue;
         }
         if (!ilObjUser::_lookupId($recipient)) {
             $this->unknown[] = $recipient;
             continue;
         } else {
             $valid = $recipient;
         }
     }
     if (count($this->unknown)) {
         return self::ERR_UNKNOWN_RCP;
     }
     if ($this->getRegistrationType() == IL_REG_APPROVE and !count((array) $valid)) {
         return self::ERR_MISSING_RCP;
     }
     return 0;
 }
 /**
  * Refresh status of course member assignments
  * @param object $course_member
  * @param int $obj_id
  */
 protected function refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned)
 {
     include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberAssignment.php';
     $type = ilObject::_lookupType($obj_id);
     if ($type == 'crs') {
         include_once './Modules/Course/classes/class.ilCourseParticipants.php';
         $part = ilCourseParticipants::_getInstanceByObjId($obj_id);
     } else {
         include_once './Modules/Group/classes/class.ilGroupParticipants.php';
         $part = ilGroupParticipants::_getInstanceByObjId($obj_id);
     }
     $course_id = (int) $course_member->lectureID;
     $usr_ids = ilECSCourseMemberAssignment::lookupUserIds($course_id, $sub_id, $obj_id);
     // Delete remote deleted
     foreach ((array) $usr_ids as $usr_id) {
         if (!isset($assigned[$usr_id])) {
             $ass = ilECSCourseMemberAssignment::lookupAssignment($course_id, $sub_id, $obj_id, $usr_id);
             if ($ass instanceof ilECSCourseMemberAssignment) {
                 $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $usr_id);
                 if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                     // this removes also admin, tutor roles
                     $part->delete($il_usr_id);
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id));
                 } else {
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning unknown ILIAS user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id));
                 }
                 $ass->delete();
             }
         }
     }
     // Assign new participants
     foreach ((array) $assigned as $person_id => $person) {
         $role = $this->lookupRole($person['role']);
         $role_info = ilECSMappingUtils::getRoleMappingInfo($role);
         $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $person_id);
         $GLOBALS['ilLog']->write(__METHOD__ . ': Handling user ' . (string) $person_id);
         if (in_array($person_id, $usr_ids)) {
             if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($role, true));
                 $part->updateRoleAssignments($il_usr_id, array($role));
                 // Nothing to do, user is member or is locally deleted
             }
         } else {
             if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                 if ($role) {
                     // Add user
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Assigning new user ' . $person_id . ' ' . 'to ' . ilObject::_lookupTitle($obj_id));
                     $part->add($il_usr_id, $role);
                 }
             } else {
                 if ($role_info['create']) {
                     $this->createMember($person_id);
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Added new user ' . $person_id);
                 }
             }
             $assignment = new ilECSCourseMemberAssignment();
             $assignment->setServer($this->getServer()->getServerId());
             $assignment->setMid($this->mid);
             $assignment->setCmsId($course_id);
             $assignment->setCmsSubId($sub_id);
             $assignment->setObjId($obj_id);
             $assignment->setUid($person_id);
             $assignment->save();
         }
     }
     return true;
 }
 function addObject($sid, $a_target_id, $a_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!strlen($a_xml)) {
         return $this->__raiseError('No valid xml string given.', 'Client');
     }
     global $rbacsystem, $objDefinition, $ilUser, $lng, $ilObjDataCache;
     if (!($target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id, false))) {
         return $this->__raiseError('No valid target given.', 'Client');
     }
     if (ilObject::_isInTrash($a_target_id)) {
         return $this->__raiseError("Parent with ID {$a_target_id} has been deleted.", 'Client');
     }
     $allowed_types = array('root', 'cat', 'grp', 'crs', 'fold');
     if (!in_array($target_obj->getType(), $allowed_types)) {
         return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
     }
     $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
     foreach ($allowed_subtypes as $row) {
         if ($row['name'] != 'rolf') {
             $allowed[] = $row['name'];
         }
     }
     include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
     $xml_parser =& new ilObjectXMLParser($a_xml, true);
     try {
         $xml_parser->startParsing();
     } catch (ilSaxParserException $se) {
         return $this->__raiseError($se->getMessage(), 'Client');
     } catch (ilObjectXMLException $e) {
         return $this->__raiseError($e->getMessage(), 'Client');
     }
     foreach ($xml_parser->getObjectData() as $object_data) {
         $res = $this->validateReferences('create', $object_data, $a_target_id);
         if ($this->isFault($res)) {
             return $res;
         }
         // Check possible subtype
         if (!in_array($object_data['type'], $allowed)) {
             return $this->__raiseError('Objects of type: ' . $object_data['type'] . ' are not allowed to be subobjects of type ' . $target_obj->getType() . '!', 'Client');
         }
         if (!$rbacsystem->checkAccess('create', $a_target_id, $object_data['type'])) {
             return $this->__raiseError('No permission to create objects of type ' . $object_data['type'] . '!', 'Client');
         }
         // begin-patch fm
         /*
         if($object_data['type'] == 'crs')
         {
         	return $this->__raiseError('Cannot create course objects. Use method addCourse() ',
         							   'Client');
         }
         */
         // end-patch fm
         // It's not possible to add objects with non unique import ids
         if (strlen($object_data['import_id']) and ilObject::_lookupObjIdByImportId($object_data['import_id'])) {
             return $this->__raiseError('An object with import id ' . $object_data['import_id'] . ' already exists!', 'Server');
         }
         // call gui object method
         $class_name = $objDefinition->getClassName($object_data['type']);
         $location = $objDefinition->getLocation($object_data['type']);
         $class_constr = "ilObj" . $class_name;
         require_once $location . "/class.ilObj" . $class_name . ".php";
         $newObj = new $class_constr();
         if (isset($object_data['owner']) && strlen($object_data['owner'])) {
             if ((int) $object_data['owner']) {
                 if (ilObject::_exists((int) $object_data['owner']) && $ilObjDataCache->lookupType((int) $object_data['owner']) == 'usr') {
                     $newObj->setOwner((int) $object_data['owner']);
                 }
             } else {
                 $usr_id = ilObjUser::_lookupId(trim($object_data['owner']));
                 if ((int) $usr_id) {
                     $newObj->setOwner((int) $usr_id);
                 }
             }
         }
         $newObj->setType($object_data['type']);
         if (strlen($object_data['import_id'])) {
             $newObj->setImportId($object_data['import_id']);
         }
         $newObj->setTitle($object_data['title']);
         $newObj->setDescription($object_data['description']);
         $newObj->create();
         // true for upload
         $newObj->createReference();
         $newObj->putInTree($a_target_id);
         $newObj->setPermissions($a_target_id);
         switch ($object_data['type']) {
             case 'grp':
                 // Add member
                 $newObj->addMember($object_data['owner'] ? $object_data['owner'] : $ilUser->getId(), $newObj->getDefaultAdminRole());
                 break;
                 // begin-patch fm
             // begin-patch fm
             case 'crs':
                 $newObj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
                 break;
                 // end-patch fm
             // end-patch fm
             case 'lm':
             case 'dbk':
                 $newObj->createLMTree();
                 break;
             case 'cat':
                 $newObj->addTranslation($object_data["title"], $object_data["description"], $lng->getLangKey(), $lng->getLangKey());
                 break;
         }
         $this->addReferences($newObj, $object_data);
     }
     $ref_id = $newObj->getRefId();
     return $ref_id ? $ref_id : "0";
 }
 function __getEmailRecipients($a_rcp)
 {
     if (ilMail::_usePearMail()) {
         $rcp = array();
         $tmp_rcp = $this->explodeRecipients($a_rcp);
         if (!is_a($tmp_rcp, 'PEAR_Error')) {
             foreach ($tmp_rcp as $to) {
                 if (substr($to->mailbox, 0, 1) != '#' && $to->host != 'ilias') {
                     // Fixed mantis bug #5875
                     if (ilObjUser::_lookupId($to->mailbox . '@' . $to->host)) {
                         continue;
                     }
                     $rcp[] = $to->mailbox . '@' . $to->host;
                 }
             }
         }
         return implode(',', $rcp);
     } else {
         foreach ($this->explodeRecipients($a_rcp) as $to) {
             $to = $this->__substituteRecipients($to, "resubstitute");
             if (strpos($to, '@')) {
                 // Fixed mantis bug #5875
                 if (ilObjUser::_lookupId($to)) {
                     continue;
                 }
                 $rcp[] = $to;
             }
         }
         return implode(',', $rcp ? $rcp : array());
     }
 }
Beispiel #24
0
 public function inviteUserToPrivateRoomByLogin($login, $proom_id)
 {
     global $ilDB;
     $user_id = ilObjUser::_lookupId($login);
     $this->inviteUserToPrivateRoom($user_id, $proom_id);
 }
 public function showResults()
 {
     global $lng, $ilUser, $rbacreview, $ilObjDataCache;
     $form = $this->initSearchForm();
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_search.html", "Services/Contact");
     $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
     $this->tpl->setTitle($this->lng->txt("mail"));
     $this->tpl->setVariable('SEARCHFORM', $form->getHtml());
     // #14109
     if (strlen($_SESSION['mail_search_search']) < 3) {
         if ($_GET["ref"] != "wsp") {
             $this->tpl->show();
         }
         return;
     }
     $abook = new ilAddressbook($ilUser->getId());
     $entries = $abook->searchUsers(addslashes(urldecode($_SESSION['mail_search_search'])));
     // remove all contacts who are not registered users for personal workspace
     if ($_GET["ref"] == "wsp") {
         foreach ($entries as $idx => $entry) {
             if (!$entry["login"]) {
                 unset($entries[$idx]);
             }
         }
     }
     if (count($entries)) {
         $tbl_addr = new ilTable2GUI($this);
         $tbl_addr->setTitle($lng->txt('mail_addressbook'));
         $tbl_addr->setRowTemplate('tpl.mail_search_addr_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         foreach ($entries as $entry) {
             if ($_GET["ref"] != "wsp") {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_addr[]', $entry['login'] ? $entry['login'] : $entry['email']) . ilUtil::formCheckbox(0, 'search_name_cc[]', $entry['login'] ? $entry['login'] : $entry['email']) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $entry['login'] ? $entry['login'] : $entry['email']);
             } else {
                 $user_id = ilObjUser::_loginExists($entry["login"]);
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_addr[]', $user_id);
             }
             $result[$counter]['login'] = $entry['login'];
             $result[$counter]['firstname'] = $entry['firstname'];
             $result[$counter]['lastname'] = $entry['lastname'];
             $id = ilObjUser::_lookupId($entry['login']);
             if (ilObjUser::_lookupPref($id, 'public_email') == 'y' || !$entry['login']) {
                 $has_mail_addr = true;
                 $result[$counter]['email'] = $entry['email'];
             }
             ++$counter;
         }
         if ($_GET["ref"] != "wsp") {
             $tbl_addr->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
         } else {
             $tbl_addr->addColumn("", "", "1%");
         }
         $tbl_addr->addColumn($this->lng->txt('login'), 'login', "15%");
         $tbl_addr->addColumn($this->lng->txt('firstname'), 'firstname', "15%");
         $tbl_addr->addColumn($this->lng->txt('lastname'), 'lastname', "15%");
         if ($has_mail_addr) {
             foreach ($result as $key => $val) {
                 if ($val['email'] == '') {
                     $result[$key]['email'] = '&nbsp;';
                 }
             }
             $tbl_addr->addColumn($this->lng->txt('email'), 'email', "15%");
         }
         $tbl_addr->setData($result);
         $tbl_addr->setDefaultOrderField('login');
         $tbl_addr->setPrefix('addr_');
         $tbl_addr->enable('select_all');
         $tbl_addr->setSelectAllCheckbox('search_name_to_addr');
         $tbl_addr->setFormName('recipients');
         $this->tpl->setVariable('TABLE_ADDR', $tbl_addr->getHTML());
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $all_results = new ilSearchResult();
     $query_parser = new ilQueryParser(addcslashes($_SESSION['mail_search_search'], '%_'));
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     $user_search =& ilObjectSearchFactory::_getUserSearchInstance($query_parser);
     $user_search->enableActiveCheck(true);
     $user_search->setFields(array('login'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $user_search->setFields(array('firstname'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $user_search->setFields(array('lastname'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $all_results->setMaxHits(100000);
     $all_results->preventOverwritingMaxhits(true);
     $all_results->filter(ROOT_FOLDER_ID, true);
     // Filter users (depends on setting in user accounts)
     include_once 'Services/User/classes/class.ilUserFilter.php';
     $users = ilUserFilter::getInstance()->filter($all_results->getResultIds());
     if (count($users)) {
         $tbl_users = new ilTable2GUI($this);
         $tbl_users->setTitle($lng->txt('system') . ': ' . $lng->txt('persons'));
         $tbl_users->setRowTemplate('tpl.mail_search_users_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         foreach ($users as $user) {
             $login = ilObjUser::_lookupLogin($user);
             if ($_GET["ref"] != "wsp") {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_usr[]', $login) . ilUtil::formCheckbox(0, 'search_name_cc[]', $login) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $login);
             } else {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_usr[]', $user);
             }
             $result[$counter]['login'] = $login;
             if (in_array(ilObjUser::_lookupPref($user, 'public_profile'), array('y', "g"))) {
                 $name = ilObjUser::_lookupName($user);
                 $result[$counter]['firstname'] = $name['firstname'];
                 $result[$counter]['lastname'] = $name['lastname'];
             } else {
                 $result[$counter]['firstname'] = '';
                 $result[$counter]['lastname'] = '';
             }
             if (ilObjUser::_lookupPref($user, 'public_email') == 'y') {
                 $has_mail_usr = true;
                 $result[$counter]['email'] = ilObjUser::_lookupEmail($user);
             }
             ++$counter;
         }
         if ($_GET["ref"] != "wsp") {
             $tbl_users->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
         } else {
             $tbl_users->addColumn("", "", "1%");
         }
         $tbl_users->addColumn($this->lng->txt('login'), 'login', '15%');
         $tbl_users->addColumn($this->lng->txt('firstname'), 'firstname', '15%');
         $tbl_users->addColumn($this->lng->txt('lastname'), 'lastname', '15%');
         if ($has_mail_usr == true) {
             foreach ($result as $key => $val) {
                 if ($val['email'] == '') {
                     $result[$key]['email'] = '&nbsp;';
                 }
             }
             $tbl_users->addColumn($this->lng->txt('email'), 'email', '15%');
         }
         $tbl_users->setData($result);
         $tbl_users->setDefaultOrderField('login');
         $tbl_users->setPrefix('usr_');
         $tbl_users->enable('select_all');
         $tbl_users->setSelectAllCheckbox('search_name_to_usr');
         $tbl_users->setFormName('recipients');
         $this->tpl->setVariable('TABLE_USERS', $tbl_users->getHTML());
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     include_once 'Services/Membership/classes/class.ilParticipants.php';
     $group_results = new ilSearchResult();
     $query_parser = new ilQueryParser(addcslashes($_SESSION['mail_search_search'], '%_'));
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     $search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
     $search->setFilter(array('grp'));
     $result = $search->performSearch();
     $group_results->mergeEntries($result);
     $group_results->setMaxHits(PHP_INT_MAX);
     $group_results->preventOverwritingMaxhits(true);
     $group_results->setRequiredPermission('read');
     $group_results->filter(ROOT_FOLDER_ID, true);
     $visible_groups = array();
     if ($group_results->getResults()) {
         $tbl_grp = new ilTable2GUI($this);
         $tbl_grp->setTitle($lng->txt('system') . ': ' . $lng->txt('groups'));
         $tbl_grp->setRowTemplate('tpl.mail_search_groups_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         $ilObjDataCache->preloadReferenceCache(array_keys($group_results->getResults()));
         $groups = $group_results->getResults();
         foreach ($groups as $grp) {
             if (!ilParticipants::hasParticipantListAccess($grp['obj_id'])) {
                 continue;
             }
             if ($_GET["ref"] != "wsp") {
                 $members = array();
                 $roles = $rbacreview->getAssignableChildRoles($grp['ref_id']);
                 foreach ($roles as $role) {
                     if (substr($role['title'], 0, 14) == 'il_grp_member_' || substr($role['title'], 0, 13) == 'il_grp_admin_') {
                         // does not work if Pear is enabled and Mailbox Address contain special chars!!
                         //array_push($members, $rbacreview->getRoleMailboxAddress($role['obj_id']));
                         // FIX for Mantis: 7523
                         array_push($members, '#' . $role['title']);
                     }
                 }
                 $str_members = implode(',', $members);
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_grp[]', $str_members) . ilUtil::formCheckbox(0, 'search_name_cc[]', $str_members) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $str_members);
             } else {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_grp[]', $grp['obj_id']);
             }
             $result[$counter]['title'] = $ilObjDataCache->lookupTitle($grp['obj_id']);
             $result[$counter]['description'] = $ilObjDataCache->lookupDescription($grp['obj_id']);
             ++$counter;
             $visible_groups[] = $grp;
         }
         if ($visible_groups) {
             $tbl_grp->setData($result);
             if ($_GET["ref"] != "wsp") {
                 $tbl_grp->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
             } else {
                 $tbl_grp->addColumn("", "", "1%");
             }
             $tbl_grp->addColumn($this->lng->txt('title'), 'title', '15%');
             $tbl_grp->addColumn($this->lng->txt('description'), 'description', '15%');
             $tbl_grp->setDefaultOrderField('title');
             $tbl_grp->setPrefix('grp_');
             $tbl_grp->enable('select_all');
             $tbl_grp->setSelectAllCheckbox('search_name_to_grp');
             $tbl_grp->setFormName('recipients');
             $this->tpl->setVariable('TABLE_GRP', $tbl_grp->getHTML());
         }
     }
     if (count($users) || count($visible_groups) || count($entries)) {
         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
         $this->tpl->setVariable("ALT_ARROW", '');
         if ($_GET["ref"] != "wsp") {
             $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('adopt'));
         } else {
             $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('wsp_share_with_users'));
         }
     } else {
         $this->lng->loadLanguageModule('search');
         ilUtil::sendInfo($this->lng->txt('search_no_match'));
     }
     if ($_GET["ref"] != "wsp") {
         $this->tpl->show();
     }
 }
 /**
  *
  * Setter for summary recipients
  * 
  * @param	String	Recipients
  * @access	public
  * 
  */
 public function setSummaryRecipients($s_recipients)
 {
     if ($s_recipients) {
         $s_recipients = explode(',', $s_recipients);
         $loginnames = array();
         foreach ($s_recipients as $loginname) {
             $loginname = trim($loginname);
             if (ilObjUser::_lookupId($loginname)) {
                 $loginnames[] = $loginname;
             }
         }
         $s_recipients = implode(',', $loginnames);
     }
     $this->summary_recipients = $s_recipients;
     return $this;
 }
 /**
  * Add user from auto complete input
  */
 protected function addUserFromAutoComplete()
 {
     $class = $this->callback['class'];
     $method = $this->callback['method'];
     $users = explode(',', $_POST['user_login']);
     $user_ids = array();
     foreach ($users as $user) {
         $user_id = ilObjUser::_lookupId($user);
         if ($user_id) {
             $user_ids[] = $user_id;
         }
     }
     $user_type = isset($_POST['user_type']) ? $_POST['user_type'] : 0;
     if (!$class->{$method}($user_ids, $user_type)) {
         $GLOBALS['ilCtrl']->returnToParent($this);
     }
 }
 /**
  * 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;
     }
 }
 /**
  * Add user as member
  */
 public function addUserFromAutoCompleteObject()
 {
     if (!strlen(trim($_POST['user_login']))) {
         ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
         $this->membersObject();
         return false;
     }
     $users = explode(',', $_POST['user_login']);
     $user_ids = array();
     foreach ($users as $user) {
         $user_id = ilObjUser::_lookupId($user);
         if (!$user_id) {
             ilUtil::sendFailure($this->lng->txt('user_not_known'));
             // add team member
             if ($_REQUEST['ctx']) {
                 return $this->submissionScreenTeamObject();
             } else {
                 return $this->membersObject();
             }
         }
         $user_ids[] = $user_id;
     }
     if ($_REQUEST['ctx']) {
         return $this->addTeamMemberActionObject($user_ids);
     }
     if (!$this->addMembersObject($user_ids)) {
     }
     $this->membersObject();
     return false;
     return true;
 }
 /**
  * ilUser
  * @return ilObjUser|object
  */
 function getUser()
 {
     global $ilUser;
     if (!isset($_POST['user_login'])) {
         $user =& $ilUser;
     } else {
         include_once 'Services/User/classes/class.ilObjUser.php';
         $user_id = ilObjUser::_lookupId($_POST['user_login']);
         $factory = new ilObjectFactory();
         $user = $factory->getInstanceByObjId($user_id, false);
         if ($user === false or $user->getType() != 'usr') {
             $user =& $ilUser;
             ilUtil::sendFailure($this->lng->txt('info_err_user_not_exist'));
         } else {
             ilUtil::sendInfo($this->lng->txt('info_user_view_changed'));
         }
     }
     return $user;
 }