Esempio n. 1
0
 /**
  * Generate Users
  *
  * @param
  * @return
  */
 function generateUsers($a_login_base = "learner", $a_start = 1, $a_end = 1000, $a_firstname = "John", $a_lastname_base = "Learner", $a_pw = "learnerpw", $a_email = "*****@*****.**", $a_gender = "m", $a_lang = "en")
 {
     global $rbacadmin;
     // new users
     $this->log("Creating Users");
     for ($i = $a_start; $i <= $a_end; $i++) {
         $this->log($a_login_base . $i);
         $user = new ilObjUser();
         $user->setLogin($a_login_base . $i);
         $user->setFirstname($a_firstname);
         $user->setLastname($a_lastname_base . " " . $i);
         $user->setGender($a_gender);
         $user->setEmail($a_email);
         $user->setAgreeDate(ilUtil::now());
         $user->setPasswd($a_pw, IL_PASSWD_PLAIN);
         $user->setTitle($user->getFullname());
         $user->setDescription($user->getEmail());
         $user->setLastPasswordChangeTS(time());
         $user->setActive(true);
         $user->setTimeLimitUnlimited(true);
         $user->create();
         $user->setLanguage($a_lang);
         $user->saveAsNew(false);
         $user->writePrefs();
         $rbacadmin->assignUser(4, $user->getId(), true);
     }
 }
 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;
 }
 /**
  * display activation confirmation screen
  */
 function showActionConfirmation($action, $a_from_search = false)
 {
     $user_ids = $this->getActionUserIds();
     if (!$user_ids) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     if (strcmp($action, "accessRestrict") == 0) {
         return $this->setAccessRestrictionObject(null, $a_from_search);
     }
     if (strcmp($action, "mail") == 0) {
         return $this->mailObject();
     }
     unset($this->data);
     if (!$a_from_search) {
         $cancel = "cancelUserFolderAction";
     } else {
         $cancel = "cancelSearchAction";
     }
     // display confirmation message
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setFormAction($this->ctrl->getFormAction($this));
     $cgui->setHeaderText($this->lng->txt("info_" . $action . "_sure"));
     $cgui->setCancel($this->lng->txt("cancel"), $cancel);
     $cgui->setConfirm($this->lng->txt("confirm"), "confirm" . $action);
     if ($a_from_search) {
         $cgui->addHiddenItem("frsrch", 1);
     }
     foreach ($user_ids as $id) {
         $user = new ilObjUser($id);
         $login = $user->getLastLogin();
         if (!$login) {
             $login = $this->lng->txt("never");
         } else {
             $login = ilDatePresentation::formatDate(new ilDateTime($login, IL_CAL_DATETIME));
         }
         $caption = $user->getFullname() . " (" . $user->getLogin() . ")" . ", " . $user->getEmail() . " -  " . $this->lng->txt("last_login") . ": " . $login;
         $cgui->addItem("id[]", $id, $caption);
     }
     $this->tpl->setContent($cgui->getHTML());
     return true;
 }
 /**
  * @see ilAuthContainerBase::loginObserver()
  */
 public function loginObserver($a_username, $a_auth)
 {
     global $ilias, $rbacadmin, $ilSetting, $ilLog, $PHPCAS_CLIENT;
     $ilLog->write(__METHOD__ . ': Successful CAS login.');
     // Radius with ldap as data source
     include_once './Services/LDAP/classes/class.ilLDAPServer.php';
     if (ilLDAPServer::isDataSourceActive(AUTH_CAS)) {
         return $this->handleLDAPDataSource($a_auth, $a_username);
     }
     include_once "./Services/CAS/lib/CAS.php";
     if ($PHPCAS_CLIENT->getUser() != "") {
         $username = $PHPCAS_CLIENT->getUser();
         $ilLog->write(__METHOD__ . ': Username: '******'./Services/User/classes/class.ilObjUser.php';
         $local_user = ilObjUser::_checkExternalAuthAccount("cas", $username);
         if ($local_user != "") {
             $a_auth->setAuth($local_user);
         } else {
             if (!$ilSetting->get("cas_create_users")) {
                 $a_auth->status = AUTH_CAS_NO_ILIAS_USER;
                 $a_auth->logout();
                 return false;
             }
             $userObj = new ilObjUser();
             $local_user = ilAuthUtils::_generateLogin($username);
             $newUser["firstname"] = $local_user;
             $newUser["lastname"] = "";
             $newUser["login"] = $local_user;
             // set "plain md5" password (= no valid password)
             $newUser["passwd"] = "";
             $newUser["passwd_type"] = IL_PASSWD_MD5;
             //$newUser["gender"] = "m";
             $newUser["auth_mode"] = "cas";
             $newUser["ext_account"] = $username;
             $newUser["profile_incomplete"] = 1;
             // system data
             $userObj->assignData($newUser);
             $userObj->setTitle($userObj->getFullname());
             $userObj->setDescription($userObj->getEmail());
             // set user language to system language
             $userObj->setLanguage($ilSetting->get("language"));
             // Time limit
             $userObj->setTimeLimitOwner(7);
             $userObj->setTimeLimitUnlimited(1);
             $userObj->setTimeLimitFrom(time());
             $userObj->setTimeLimitUntil(time());
             // Create user in DB
             $userObj->setOwner(0);
             $userObj->create();
             $userObj->setActive(1);
             $userObj->updateOwner();
             //insert user data in table user_data
             $userObj->saveAsNew();
             // setup user preferences
             $userObj->writePrefs();
             // to do: test this
             $rbacadmin->assignUser($ilSetting->get('cas_user_default_role'), $userObj->getId(), true);
             unset($userObj);
             $a_auth->setAuth($local_user);
             return true;
         }
     } else {
         $ilLog->write(__METHOD__ . ': Login failed.');
         // This should never occur unless CAS is not configured properly
         $a_auth->status = AUTH_WRONG_LOGIN;
         return false;
     }
     return false;
 }
 /**
  * send account mail
  */
 function sendAccountMail()
 {
     //var_dump($_POST["send_mail"]);
     if ($_POST["send_mail"] != "" || $this->isSendMail() && $this->userObj->getEmail() != "") {
         $this->acc_mail->setUser($this->userObj);
         $this->acc_mail->send();
     }
 }
 /**
  * @param integer $obj_id
  * @param string $title
  * @param string $description
  * @param ilDateTime $start_date
  * @param ilDateTime $end_date
  * @param string $instructions
  * @param string $contact_info
  * @param integer $permanent_room
  * @param string $access_level
  * @param integer $read_contents
  * @param integer $read_records
  * @param integer $folder_id
  * @throws ilException
  */
 public function publishCreationAC($obj_id, $title, $description, $start_date, $end_date, $instructions, $contact_info, $permanent_room, $access_level = self::ACCESS_LEVEL_PROTECTED, $read_contents, $read_records, $folder_id)
 {
     /**
      * @var $ilDB   ilDB
      * */
     global $ilDB;
     $owner_id = ilObject::_lookupOwner($obj_id);
     $ownerObj = new ilObjUser($owner_id);
     // receive breeze session
     $session = $this->xmlApi->getBreezeSession();
     if (!$session) {
         throw new ilException('xavc_connection_error');
     }
     // access check
     if (!$this->xmlApi->login($this->adminLogin, $this->adminPass, $session)) {
         throw new ilException('xavc_authentication_error');
     }
     // receive folder id
     $this->externalLogin = $this->checkExternalUser($ownerObj->getId());
     $folder_id = $this->getFolderIdByLogin($this->externalLogin);
     if (!$folder_id) {
         throw new ilException('xavc_folder_not_available');
     }
     $obj_title_suffix_enabled = ilAdobeConnectServer::getSetting('obj_title_suffix');
     if ($obj_title_suffix_enabled) {
         $title = $title . '_' . CLIENT_ID . '_' . $obj_id;
     }
     // create meeting room
     $arr_meeting = $this->xmlApi->addMeeting($title, $description, date('Y-m-d', $start_date->getUnixTime()), date('H:i', $start_date->getUnixTime()), date('Y-m-d', $end_date->getUnixTime()), date('H:i', $end_date->getUnixTime()), $folder_id, $session);
     $meeting_id = $arr_meeting['meeting_id'];
     $meeting_url = $arr_meeting['meeting_url'];
     if (!$meeting_id) {
         throw new ilException('xavc_meeting_creation_error');
     }
     if (ilAdobeConnectServer::getSetting('user_assignment_mode') != ilAdobeConnectServer::ASSIGN_USER_SWITCH) {
         //Normal Case (not SWITCH aai)
         if ($this->externalLogin == NULL) {
             throw new ilException('xavc_external_login_error');
         } else {
             $this->xmlApi->addUser($this->externalLogin, $ownerObj->getEmail(), $ownerObj->getPasswd(), $ownerObj->getFirstName(), $ownerObj->getLastName(), $session);
         }
         $this->xmlApi->updateMeetingParticipant($meeting_id, $this->externalLogin, $session, 'host');
     } else {
         //In the SWITCH aai case, every user already exists thanks to "cave"
         //Add ILIAS-user himself
         $this->xmlApi->addMeetingHost($meeting_id, $ownerObj->getEmail(), $session);
         //Add technical user
         $this->xmlApi->updateMeetingParticipant($meeting_id, ilAdobeConnectServer::getSetting('login'), $session, 'host');
     }
     $this->xmlApi->updatePermission($meeting_id, $session, $access_level);
     $ilDB->insert('rep_robj_xavc_data', array('id' => array('integer', $obj_id), 'sco_id' => array('integer', $meeting_id), 'start_date' => array('integer', $start_date->getUnixTime()), 'end_date' => array('integer', $end_date->getUnixTime()), 'instructions' => array('text', $instructions), 'contact_info' => array('text', $contact_info), 'permanent_room' => array('integer', (int) $permanent_room), 'perm_read_contents' => array('integer', (int) $this->getReadContents()), 'perm_read_records' => array('integer', (int) $this->getReadRecords()), 'folder_id' => array('integer', $folder_id), 'url_path' => array('text', $meeting_url)));
 }
Esempio n. 7
0
 public function add()
 {
     global $lng, $ilUser;
     if ($_GET["mail_id"] != "") {
         if (is_array($mail_data = $this->umail->getMail($_GET["mail_id"]))) {
             require_once "Services/Contact/classes/class.ilAddressbook.php";
             $abook = new ilAddressbook($ilUser->getId());
             $tmp_user = new ilObjUser($mail_data["sender_id"]);
             if ($abook->checkEntryByLogin($tmp_user->getLogin()) > 0) {
                 ilUtil::sendInfo($lng->txt("mail_entry_exists"));
             } else {
                 $abook->addEntry($tmp_user->getLogin(), $tmp_user->getFirstname(), $tmp_user->getLastname(), $tmp_user->getEmail());
                 ilUtil::sendInfo($lng->txt("mail_entry_added"));
             }
         }
     }
     $this->showMail();
 }
Esempio n. 8
0
 /**
  * Login function
  *
  * @access private
  * @return void
  */
 function login()
 {
     global $ilias, $rbacadmin, $ilSetting;
     if (phpCAS::getUser() != "") {
         $username = phpCAS::getUser();
         // Authorize this user
         include_once './Services/User/classes/class.ilObjUser.php';
         $local_user = ilObjUser::_checkExternalAuthAccount("cas", $username);
         if ($local_user != "") {
             $this->setAuth($local_user);
         } else {
             if (!$ilSetting->get("cas_create_users")) {
                 $this->status = AUTH_CAS_NO_ILIAS_USER;
                 $this->logout();
                 return;
             }
             $userObj = new ilObjUser();
             $local_user = ilAuthUtils::_generateLogin($username);
             $newUser["firstname"] = $local_user;
             $newUser["lastname"] = "";
             $newUser["login"] = $local_user;
             // set "plain md5" password (= no valid password)
             $newUser["passwd"] = "";
             $newUser["passwd_type"] = IL_PASSWD_MD5;
             //$newUser["gender"] = "m";
             $newUser["auth_mode"] = "cas";
             $newUser["ext_account"] = $username;
             $newUser["profile_incomplete"] = 1;
             // system data
             $userObj->assignData($newUser);
             $userObj->setTitle($userObj->getFullname());
             $userObj->setDescription($userObj->getEmail());
             // set user language to system language
             $userObj->setLanguage($ilSetting->get("language"));
             // Time limit
             $userObj->setTimeLimitOwner(7);
             $userObj->setTimeLimitUnlimited(1);
             $userObj->setTimeLimitFrom(time());
             $userObj->setTimeLimitUntil(time());
             // Create user in DB
             $userObj->setOwner(0);
             $userObj->create();
             $userObj->setActive(1);
             $userObj->updateOwner();
             //insert user data in table user_data
             $userObj->saveAsNew();
             // setup user preferences
             $userObj->writePrefs();
             // to do: test this
             $rbacadmin->assignUser($ilSetting->get('cas_user_default_role'), $userObj->getId(), true);
             unset($userObj);
             $this->setAuth($local_user);
         }
     } else {
         // This should never occur unless CAS is not configured properly
         $this->status = AUTH_WRONG_LOGIN;
     }
 }
 /** Reads the submitted data from the password assistance form.
  * 
  * The following form fields are read as HTTP POST parameters:
  * username
  * email
  *
  * If the submitted username and email address matches an entry in the user data 
  * table, then ILIAS creates a password assistance session for the user, and
  * sends a password assistance mail to the email address.
  * For details about the creation of the session and the e-mail see function
  * sendPasswordAssistanceMail().
  */
 function submitAssistanceForm()
 {
     global $tpl, $ilias, $lng, $rbacadmin, $rbacreview;
     require_once './Services/User/classes/class.ilObjUser.php';
     require_once "./Services/Utilities/classes/class.ilUtil.php";
     // Retrieve form data
     $username = ilUtil::stripSlashes($_POST["username"]);
     $email = ilUtil::stripSlashes($_POST["email"]);
     // Retrieve a user object with matching user name and email address.
     $userObj = null;
     $userid = ilObjUser::getUserIdByLogin($username);
     $txt_key = "pwassist_invalid_username_or_email";
     if ($userid != 0) {
         $userObj = new ilObjUser($userid);
         if (strcasecmp($userObj->getEmail(), $email) != 0) {
             $userObj = null;
         } elseif (!strlen($email)) {
             $userObj = null;
             $txt_key = 'pwassist_no_email_found';
         } else {
             if ($userObj->getAuthMode(true) != AUTH_LOCAL || $userObj->getAuthMode(true) == AUTH_DEFAULT && AUTH_DEFAULT != AUTH_LOCAL) {
                 $userObj = null;
                 $txt_key = "pwassist_invalid_auth_mode";
             }
         }
     }
     // No matching user object found?
     // Show the password assistance form again, and display an error message.
     if ($userObj == null) {
         $this->showAssistanceForm($lng->txt($txt_key), $username, $email);
     } else {
         // FIXME: Extend this if-statement to check whether the user
         // has the permission to use the password assistance function.
         // The anonymous user and users who are system administrators are
         // not allowed to use this feature
         if ($rbacreview->isAssigned($userObj->getID, ANONYMOUS_ROLE_ID) || $rbacreview->isAssigned($userObj->getID, SYSTEM_ROLE_ID)) {
             $this->showAssistanceForm($lng->txt("pwassist_not_permitted"), $username, $email);
         } else {
             $this->sendPasswordAssistanceMail($userObj);
             $this->showMessageForm(null, sprintf($lng->txt("pwassist_mail_sent"), $email));
         }
     }
 }
Esempio n. 10
0
 /**
  * Login function
  *
  * @access private
  * @return void
  */
 function login()
 {
     global $ilias, $rbacadmin, $ilSetting;
     if (!empty($_SERVER[$ilias->getSetting('shib_login')])) {
         // Store user's Shibboleth sessionID for logout
         $this->session['shibboleth_session_id'] = $_SERVER['Shib-Session-ID'];
         // Get loginname of user, new login name is generated if user is new
         $username = $this->generateLogin();
         // Authorize this user
         $this->setAuth($username);
         $userObj = new ilObjUser();
         // Check wether this account exists already, if not create it
         if (!ilObjUser::getUserIdByLogin($username)) {
             $newUser["firstname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]);
             $newUser["lastname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]);
             $newUser["login"] = $username;
             // Password must be random to prevent users from manually log in using the login data from Shibboleth users
             $newUser["passwd"] = md5(end(ilUtil::generatePasswords(1)));
             $newUser["passwd_type"] = IL_PASSWD_MD5;
             if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
                 $newUser["gender"] = $_SERVER[$ilias->getSetting('shib_gender')];
             }
             // Save mapping between ILIAS user and Shibboleth uniqueID
             $newUser["ext_account"] = $_SERVER[$ilias->getSetting('shib_login')];
             // other data
             $newUser["title"] = $_SERVER[$ilias->getSetting('shib_title')];
             $newUser["institution"] = $_SERVER[$ilias->getSetting('shib_institution')];
             $newUser["department"] = $_SERVER[$ilias->getSetting('shib_department')];
             $newUser["street"] = $_SERVER[$ilias->getSetting('shib_street')];
             $newUser["city"] = $_SERVER[$ilias->getSetting('shib_city')];
             $newUser["zipcode"] = $_SERVER[$ilias->getSetting('shib_zipcode')];
             $newUser["country"] = $_SERVER[$ilias->getSetting('shib_country')];
             $newUser["phone_office"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_office')]);
             $newUser["phone_home"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_home')]);
             $newUser["phone_mobile"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_mobile')]);
             $newUser["fax"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_fax')]);
             $newUser["matriculation"] = $_SERVER[$ilias->getSetting('shib_matriculation')];
             $newUser["email"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_email')]);
             $newUser["hobby"] = $_SERVER[$ilias->getSetting('shib_hobby')];
             $newUser["auth_mode"] = "shibboleth";
             // system data
             $userObj->assignData($newUser);
             $userObj->setTitle($userObj->getFullname());
             $userObj->setDescription($userObj->getEmail());
             $userObj->setLanguage($this->getFirstString($_SERVER[$ilias->getSetting('shib_language')]));
             // Time limit
             $userObj->setTimeLimitOwner(7);
             $userObj->setTimeLimitUnlimited(1);
             $userObj->setTimeLimitFrom(time());
             $userObj->setTimeLimitUntil(time());
             // Modify user data before creating the user
             // Include custom code that can be used to further modify
             // certain Shibboleth user attributes
             if ($ilias->getSetting('shib_data_conv') && $ilias->getSetting('shib_data_conv') != '' && is_readable($ilias->getSetting('shib_data_conv'))) {
                 include $ilias->getSetting('shib_data_conv');
             }
             // Create use in DB
             $userObj->create();
             $userObj->setActive(1);
             $userObj->updateOwner();
             //insert user data in table user_data
             $userObj->saveAsNew();
             // store acceptance of user agreement
             //$userObj->writeAccepted();
             // Default prefs
             $userObj->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
             $userObj->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
             // setup user preferences
             $userObj->writePrefs();
             //set role entries
             #$rbacadmin->assignUser($ilias->getSetting('shib_user_default_role'), $userObj->getId(),true);
             // New role assignment
             include_once './Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
             ilShibbolethRoleAssignmentRules::doAssignments($userObj->getId(), $_SERVER);
             // Authorize this user
             $this->setAuth($userObj->getLogin());
         } else {
             // Update user account
             $uid = $userObj->checkUserId();
             $userObj->setId($uid);
             $userObj->read($uid);
             if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
                 $userObj->setGender($_SERVER[$ilias->getSetting('shib_gender')]);
             }
             if ($ilias->getSetting('shib_update_title')) {
                 $userObj->setTitle($_SERVER[$ilias->getSetting('shib_title')]);
             }
             $userObj->setFirstname($this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]));
             $userObj->setLastname($this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]));
             $userObj->setFullname();
             if ($ilias->getSetting('shib_update_institution')) {
                 $userObj->setInstitution($_SERVER[$ilias->getSetting('shib_institution')]);
             }
             if ($ilias->getSetting('shib_update_department')) {
                 $userObj->setDepartment($_SERVER[$ilias->getSetting('shib_department')]);
             }
             if ($ilias->getSetting('shib_update_street')) {
                 $userObj->setStreet($_SERVER[$ilias->getSetting('shib_street')]);
             }
             if ($ilias->getSetting('shib_update_city')) {
                 $userObj->setCity($_SERVER[$ilias->getSetting('shib_city')]);
             }
             if ($ilias->getSetting('shib_update_zipcode')) {
                 $userObj->setZipcode($_SERVER[$ilias->getSetting('shib_zipcode')]);
             }
             if ($ilias->getSetting('shib_update_country')) {
                 $userObj->setCountry($_SERVER[$ilias->getSetting('shib_country')]);
             }
             if ($ilias->getSetting('shib_update_phone_office')) {
                 $userObj->setPhoneOffice($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_office')]));
             }
             if ($ilias->getSetting('shib_update_phone_home')) {
                 $userObj->setPhoneHome($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_home')]));
             }
             if ($ilias->getSetting('shib_update_phone_mobile')) {
                 $userObj->setPhoneMobile($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_mobile')]));
             }
             if ($ilias->getSetting('shib_update_fax')) {
                 $userObj->setFax($_SERVER[$ilias->getSetting('shib_fax')]);
             }
             if ($ilias->getSetting('shib_update_matriculation')) {
                 $userObj->setMatriculation($_SERVER[$ilias->getSetting('shib_matriculation')]);
             }
             if ($ilias->getSetting('shib_update_email')) {
                 $userObj->setEmail($this->getFirstString($_SERVER[$ilias->getSetting('shib_email')]));
             }
             if ($ilias->getSetting('shib_update_hobby')) {
                 $userObj->setHobby($_SERVER[$ilias->getSetting('shib_hobby')]);
             }
             if ($ilias->getSetting('shib_update_language')) {
                 $userObj->setLanguage($_SERVER[$ilias->getSetting('shib_language')]);
             }
             // Include custom code that can be used to further modify
             // certain Shibboleth user attributes
             if ($ilias->getSetting('shib_data_conv') && $ilias->getSetting('shib_data_conv') != '' && is_readable($ilias->getSetting('shib_data_conv'))) {
                 include $ilias->getSetting('shib_data_conv');
             }
             $userObj->update();
             // Update role assignments
             include_once './Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
             ilShibbolethRoleAssignmentRules::updateAssignments($userObj->getId(), $_SERVER);
         }
         // we are authenticated: redirect, if possible
         if ($_GET["target"] != "") {
             ilUtil::redirect("goto.php?target=" . $_GET["target"] . "&client_id=" . CLIENT_ID);
         }
     } else {
         // This should never occur unless Shibboleth is not configured properly
         $this->status = AUTH_WRONG_LOGIN;
     }
 }
 /**
  * create new user
  *
  * @access protected
  */
 protected function createUser(ilECSUser $user)
 {
     global $ilClientIniFile, $ilSetting, $rbacadmin, $ilLog;
     $userObj = new ilObjUser();
     include_once './Services/Authentication/classes/class.ilAuthUtils.php';
     $local_user = ilAuthUtils::_generateLogin($this->getAbreviation() . '_' . $user->getLogin());
     $newUser["login"] = $local_user;
     $newUser["firstname"] = $user->getFirstname();
     $newUser["lastname"] = $user->getLastname();
     $newUser['email'] = $user->getEmail();
     $newUser['institution'] = $user->getInstitution();
     // set "plain md5" password (= no valid password)
     $newUser["passwd"] = "";
     $newUser["passwd_type"] = IL_PASSWD_MD5;
     $newUser["auth_mode"] = "ecs";
     $newUser["profile_incomplete"] = 0;
     // system data
     $userObj->assignData($newUser);
     $userObj->setTitle($userObj->getFullname());
     $userObj->setDescription($userObj->getEmail());
     // set user language to system language
     $userObj->setLanguage($ilSetting->get("language"));
     // Time limit
     $userObj->setTimeLimitOwner(7);
     $userObj->setTimeLimitUnlimited(0);
     $userObj->setTimeLimitFrom(time() - 5);
     $userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session", "expire"));
     $now = new ilDateTime(time(), IL_CAL_UNIX);
     $userObj->setAgreeDate($now->get(IL_CAL_DATETIME));
     // Create user in DB
     $userObj->setOwner(6);
     $userObj->create();
     $userObj->setActive(1);
     $userObj->updateOwner();
     $userObj->saveAsNew();
     $userObj->writePrefs();
     if ($global_role = $this->getCurrentServer()->getGlobalRole()) {
         $rbacadmin->assignUser($this->getCurrentServer()->getGlobalRole(), $userObj->getId(), true);
     }
     ilObject::_writeImportId($userObj->getId(), $user->getImportId());
     $ilLog->write(__METHOD__ . ': Created new remote user with usr_id: ' . $user->getImportId());
     // Send Mail
     #$this->sendNotification($userObj);
     return $userObj->getLogin();
 }
 /**
  * send account mail
  */
 function sendAccountMail()
 {
     if ($_POST["send_mail"] != "" || $this->isSendMail() && $this->userObj->getEmail() != "") {
         $this->acc_mail->setUser($this->userObj);
         $amail = $this->readAccountMailFromCache($this->userObj->getLanguage());
         if ($amail["att_file"]) {
             include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
             $fs = new ilFSStorageUserFolder(USER_FOLDER_ID);
             $fs->create();
             $path = $fs->getAbsolutePath() . "/";
             $this->acc_mail->addAttachment($path . "/" . $amail["lang"], $amail["att_file"]);
         }
         $this->acc_mail->send();
     }
 }
 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());
 }
 /**
  * Called after login and successful call of fetch data
  * @return 
  * @param object $a_username
  * @param object $a_auth
  */
 public function loginObserver($a_username, $a_auth)
 {
     global $ilias, $rbacadmin, $lng, $ilSetting;
     $GLOBALS['ilLog']->write(__METHOD__ . ': SOAP login observer called');
     // TODO: handle passed credentials via GET
     /*
     if (empty($_GET["ext_uid"]) || empty($_GET["soap_pw"]))
     {
     	$this->status = AUTH_WRONG_LOGIN;
     	return;
     }
     */
     // Not required anymore
     /*
     $validation_data = $this->validateSoapUser($_GET["ext_uid"], $_GET["soap_pw"]);
     
     if (!$validation_data["valid"])
     {
     	$this->status = AUTH_WRONG_LOGIN;
     	return;
     }
     */
     $local_user = $this->response["local_user"];
     if ($local_user != "") {
         // to do: handle update of user
         $a_auth->setAuth($local_user);
         return true;
     }
     if (!$ilSetting->get("soap_auth_create_users")) {
         $a_auth->status = AUTH_SOAP_NO_ILIAS_USER;
         $a_auth->logout();
         return false;
     }
     //echo "1";
     // try to map external user via e-mail to ILIAS user
     if ($this->response["email"] != "") {
         //echo "2";
         //var_dump ($_POST);
         $email_user = ilObjUser::_getLocalAccountsForEmail($this->response["email"]);
         // check, if password has been provided in user mapping screen
         // (see ilStartUpGUI::showUserMappingSelection)
         // FIXME
         if ($_POST["LoginMappedUser"] != "") {
             if (count($email_user) > 0) {
                 $user = ilObjectFactory::getInstanceByObjId($_POST["usr_id"]);
                 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
                 if (ilUserPasswordManager::getInstance()->verifyPassword($user, ilUtil::stripSlashes($_POST["password"]))) {
                     // password is correct -> map user
                     //$this->setAuth($local_user); (use login not id)
                     ilObjUser::_writeExternalAccount($_POST["usr_id"], $_GET["ext_uid"]);
                     ilObjUser::_writeAuthMode($_POST["usr_id"], "soap");
                     $_GET["cmd"] = $_POST["cmd"] = $_GET["auth_stat"] = "";
                     $local_user = ilObjUser::_lookupLogin($_POST["usr_id"]);
                     $a_auth->status = '';
                     $a_auth->setAuth($local_user);
                     return true;
                 } else {
                     //echo "6"; exit;
                     $a_auth->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL;
                     $a_auth->setSubStatus(AUTH_WRONG_LOGIN);
                     $a_auth->logout();
                     return false;
                 }
             }
         }
         if (count($email_user) > 0 && $_POST["CreateUser"] == "") {
             $_GET["email"] = $this->response["email"];
             $a_auth->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL;
             $a_auth->logout();
             return false;
         }
     }
     $userObj = new ilObjUser();
     $local_user = ilAuthUtils::_generateLogin($a_username);
     $newUser["firstname"] = $this->response["firstname"];
     $newUser["lastname"] = $this->response["lastname"];
     $newUser["email"] = $this->response["email"];
     $newUser["login"] = $local_user;
     // to do: set valid password and send mail
     $newUser["passwd"] = "";
     $newUser["passwd_type"] = IL_PASSWD_CRYPTED;
     // generate password, if local authentication is allowed
     // and account mail is activated
     $pw = "";
     if ($ilSetting->get("soap_auth_allow_local") && $ilSetting->get("soap_auth_account_mail")) {
         $pw = ilUtil::generatePasswords(1);
         $pw = $pw[0];
         $newUser["passwd"] = $pw;
         $newUser["passwd_type"] = IL_PASSWD_PLAIN;
     }
     //$newUser["gender"] = "m";
     $newUser["auth_mode"] = "soap";
     $newUser["ext_account"] = $a_username;
     $newUser["profile_incomplete"] = 1;
     // system data
     $userObj->assignData($newUser);
     $userObj->setTitle($userObj->getFullname());
     $userObj->setDescription($userObj->getEmail());
     // set user language to system language
     $userObj->setLanguage($lng->lang_default);
     // Time limit
     $userObj->setTimeLimitOwner(7);
     $userObj->setTimeLimitUnlimited(1);
     $userObj->setTimeLimitFrom(time());
     $userObj->setTimeLimitUntil(time());
     // Create user in DB
     $userObj->setOwner(0);
     $userObj->create();
     $userObj->setActive(1);
     $userObj->updateOwner();
     //insert user data in table user_data
     $userObj->saveAsNew(false);
     // setup user preferences
     $userObj->writePrefs();
     // to do: test this
     $rbacadmin->assignUser($ilSetting->get('soap_auth_user_default_role'), $userObj->getId(), true);
     // send account mail
     if ($ilSetting->get("soap_auth_account_mail")) {
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($ilSetting->get("language"));
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             include_once "Services/Mail/classes/class.ilAccountMail.php";
             $acc_mail = new ilAccountMail();
             if ($pw != "") {
                 $acc_mail->setUserPassword($pw);
             }
             $acc_mail->setUser($userObj);
             $acc_mail->send();
         }
     }
     unset($userObj);
     $a_auth->setAuth($local_user);
     return true;
 }
 /**
  * Creates (or reuses) a password assistance session, and sends a password
  * assistance mail to the specified user.
  * Note: To prevent DOS attacks, a new session is created only, if no session
  * exists, or if the existing session has been expired.
  * The password assistance mail contains an URL, which points to this script
  * and contains the following URL parameters:
  * client_id
  * key
  * @param $userObj ilObjUser
  */
 public function sendPasswordAssistanceMail(ilObjUser $userObj)
 {
     require_once 'Services/Mail/classes/class.ilMailbox.php';
     require_once 'Services/Mail/classes/class.ilMimeMail.php';
     require_once 'include/inc.pwassist_session_handler.php';
     // Check if we need to create a new session
     $pwassist_session = db_pwassist_session_find($userObj->getId());
     if (count($pwassist_session) == 0 || $pwassist_session['expires'] < time() || true) {
         // Create a new session id
         // #9700 - this didn't do anything before?!
         // db_set_save_handler();
         session_start();
         $pwassist_session['pwassist_id'] = db_pwassist_create_id();
         session_destroy();
         db_pwassist_session_write($pwassist_session['pwassist_id'], 3600, $userObj->getId());
     }
     $protocol = $this->https->isDetected() ? 'https://' : 'http://';
     // Compose the mail
     $server_url = $protocol . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')) . '/';
     // XXX - Werner Randelshofer - Insert code here to dynamically get the
     //      the delimiter. For URL's that are sent by e-mail to a user,
     //      it is best to use semicolons as parameter delimiter
     $delimiter = '&';
     $pwassist_url = $protocol . $_SERVER['HTTP_HOST'] . str_replace('ilias.php', 'pwassist.php', $_SERVER['PHP_SELF']) . '?client_id=' . $this->ilias->getClientId() . $delimiter . 'lang=' . $this->lng->getLangKey() . $delimiter . 'key=' . $pwassist_session['pwassist_id'];
     $alternative_pwassist_url = $protocol . $_SERVER['HTTP_HOST'] . str_replace('ilias.php', 'pwassist.php', $_SERVER['PHP_SELF']) . '?client_id=' . $this->ilias->getClientId() . $delimiter . 'lang=' . $this->lng->getLangKey() . $delimiter . 'key=' . $pwassist_session['pwassist_id'];
     $contact_address = $this->settings->get('admin_email');
     $mm = new ilMimeMail();
     $mm->Subject($this->lng->txt('pwassist_mail_subject'));
     $mm->From($contact_address);
     $mm->To($userObj->getEmail());
     $mm->Body(str_replace(array("\\n", "\\t"), array("\n", "\t"), sprintf($this->lng->txt('pwassist_mail_body'), $pwassist_url, $server_url, $_SERVER['REMOTE_ADDR'], $userObj->getLogin(), 'mailto:' . $contact_address, $alternative_pwassist_url)));
     $mm->Send();
 }
Esempio n. 16
0
 public static function _createRandomUserAccount($keyarray)
 {
     global $ilDB, $ilUser, $ilSetting, $rbacadmin;
     if ($_SESSION['create_user_account'] != NULL) {
         $obj_user = new ilObjUser($_SESSION['create_user_account']);
         return $obj_user;
     } else {
         $userLogin = array();
         $res = $ilDB->query('SELECT sequence FROM object_data_seq');
         $row = $ilDB->fetchAssoc($res);
         $temp_user_id = (int) $row['sequence'] + 1;
         $userLogin['login'] = '******' . $temp_user_id;
         $userLogin['passwd'] = ilUtil::generatePasswords(1);
         require_once 'Services/User/classes/class.ilObjUser.php';
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         $obj_user = new ilObjUser();
         $obj_user->setId($temp_user_id);
         $obj_user->setLogin($userLogin['login']);
         $obj_user->setPasswd((string) $userLogin['passwd'][0], IL_PASSWD_PLAIN);
         $_SESSION['tmp_user_account']['login'] = $userLogin['login'];
         $_SESSION['tmp_user_account']['passwd'] = $userLogin['passwd'];
         $obj_user->setFirstname($keyarray['first_name']);
         $obj_user->setLastname($keyarray['last_name']);
         $obj_user->setEmail($keyarray['payer_email']);
         #	$obj_user->setEmail('*****@*****.**');
         $obj_user->setGender('f');
         $obj_user->setLanguage($ilSetting->get("language"));
         $obj_user->setActive(true);
         $obj_user->setTimeLimitUnlimited(true);
         $obj_user->setTitle($obj_user->getFullname());
         $obj_user->setDescription($obj_user->getEmail());
         $obj_user->setTimeLimitOwner(7);
         $obj_user->setTimeLimitUnlimited(1);
         $obj_user->setTimeLimitMessage(0);
         $obj_user->setApproveDate(date("Y-m-d H:i:s"));
         // Set default prefs
         $obj_user->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
         $obj_user->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
         $obj_user->writePrefs();
         // at the first login the user must complete profile
         $obj_user->setProfileIncomplete(true);
         $obj_user->create();
         $obj_user->saveAsNew();
         $user_role = ilObject::_exists(4, false);
         if (!$user_role) {
             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
             $reg_allowed = ilObjRole::_lookupRegisterAllowed();
             $user_role = $reg_allowed[0]['id'];
         } else {
             $user_role = 4;
         }
         $rbacadmin->assignUser((int) $user_role, $obj_user->getId(), true);
         include_once "Services/Mail/classes/class.ilMimeMail.php";
         global $ilias, $lng;
         $settings = $ilias->getAllSettings();
         $mmail = new ilMimeMail();
         $mmail->autoCheck(false);
         $mmail->From($settings["admin_email"]);
         $mmail->To($obj_user->getEmail());
         // mail subject
         $subject = $lng->txt("reg_mail_subject");
         // mail body
         $body = $lng->txt("reg_mail_body_salutation") . " " . $obj_user->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . $ilias->client_id . "\n";
         $body .= $lng->txt("login") . ": " . $obj_user->getLogin() . "\n";
         $body .= $lng->txt("passwd") . ": " . $userLogin['passwd'][0] . "\n";
         $body .= "\n";
         $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
         $body .= $obj_user->getProfileAsString($lng);
         $mmail->Subject($subject);
         $mmail->Body($body);
         $mmail->Send();
         $_SESSION['create_user_account'] = $obj_user->getId();
         return $obj_user;
     }
 }
 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);
 }
 /**
  * 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();
 }