/**
  * delete category and all related data	
  *
  * @access	public
  * @return	boolean	true if all object data were removed; false if only a references were removed
  */
 function delete()
 {
     global $ilDB, $ilAppEventHandler;
     // always call parent delete function first!!
     if (!parent::delete()) {
         return false;
     }
     // put here category specific stuff
     include_once './Services/User/classes/class.ilObjUserFolder.php';
     ilObjUserFolder::_updateUserFolderAssignment($this->ref_id, USER_FOLDER_ID);
     $query = "DELETE FROM object_translation WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer');
     $res = $ilDB->manipulate($query);
     $ilAppEventHandler->raise('Modules/Category', 'delete', array('object' => $this, 'obj_id' => $this->getId()));
     return true;
 }
예제 #2
0
 function __handleUser($row)
 {
     global $ilDB, $lng;
     if (!is_array($this->settings)) {
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $this->setSettings(ilObjUserFolder::getExportSettings());
     }
     $prefs = ilObjUser::_getPreferences($row["usr_id"]);
     if (strlen($row["language"]) == 0) {
         $row["language"] = $lng->getDefaultLanguage();
     }
     $attrs = array('Id' => "il_" . IL_INST_ID . "_usr_" . $row["usr_id"], 'Language' => $row["language"], 'Action' => "Update");
     $this->xmlStartTag("User", $attrs);
     $this->xmlElement("Login", null, $row["login"]);
     if ($this->attachRoles == TRUE) {
         include_once './Services/AccessControl/classes/class.ilObjRole.php';
         $query = sprintf("SELECT object_data.title, object_data.description,  rbac_fa.* " . "FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.usr_id = %s " . "AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id", $ilDB->quote($row["usr_id"], 'integer'));
         $rbacresult = $ilDB->query($query);
         while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC)) {
             if ($rbacrow["assign"] != "y") {
                 continue;
             }
             $type = "";
             if ($rbacrow["parent"] == ROLE_FOLDER_ID) {
                 $type = "Global";
             } else {
                 $type = "Local";
             }
             if (strlen($type)) {
                 $this->xmlElement("Role", array("Id" => "il_" . IL_INST_ID . "_role_" . $rbacrow["rol_id"], "Type" => $type), $rbacrow["title"]);
             }
         }
     }
     $this->__addElement("Firstname", $row["firstname"]);
     $this->__addElement("Lastname", $row["lastname"]);
     $this->__addElement("Title", $row["title"]);
     if ($this->canExport("PersonalPicture", "upload")) {
         $imageData = $this->getPictureValue($row["usr_id"]);
         if ($imageData) {
             $value = array_shift($imageData);
             //$imageData["value"];
             $this->__addElement("PersonalPicture", $value, $imageData, "upload");
         }
     }
     $this->__addElement("Gender", $row["gender"]);
     $this->__addElement("Email", $row["email"]);
     $this->__addElement("Birthday", $row["birthday"]);
     $this->__addElement("Institution", $row["institution"]);
     $this->__addElement("Street", $row["street"]);
     $this->__addElement("City", $row["city"]);
     $this->__addElement("PostalCode", $row["zipcode"], null, "zipcode");
     $this->__addElement("Country", $row["country"]);
     $this->__addElement("PhoneOffice", $row["phone_office"], null, "phone_office");
     $this->__addElement("PhoneHome", $row["phone_home"], null, "phone_home");
     $this->__addElement("PhoneMobile", $row["phone_mobile"], null, "phone_mobile");
     $this->__addElement("Fax", $row["fax"]);
     $this->__addElement("Hobby", $row["hobby"]);
     $this->__addElementMulti("GeneralInterest", $row["interests_general"], null, "interests_general");
     $this->__addElementMulti("OfferingHelp", $row["interests_help_offered"], null, "interests_help_offered");
     $this->__addElementMulti("LookingForHelp", $row["interests_help_looking"], null, "interests_help_looking");
     $this->__addElement("Department", $row["department"]);
     $this->__addElement("Comment", $row["referral_comment"], null, "referral_comment");
     $this->__addElement("Matriculation", $row["matriculation"]);
     $this->__addElement("Active", $row["active"] ? "true" : "false");
     $this->__addElement("ClientIP", $row["client_ip"], null, "client_ip");
     $this->__addElement("TimeLimitOwner", $row["time_limit_owner"], null, "time_limit_owner");
     $this->__addElement("TimeLimitUnlimited", $row["time_limit_unlimited"], null, "time_limit_unlimited");
     $this->__addElement("TimeLimitFrom", $row["time_limit_from"], null, "time_limit_from");
     $this->__addElement("TimeLimitUntil", $row["time_limit_until"], null, "time_limit_until");
     $this->__addElement("TimeLimitMessage", $row["time_limit_message"], null, "time_limit_message");
     $this->__addElement("ApproveDate", $row["approve_date"], null, "approve_date");
     $this->__addElement("AgreeDate", $row["agree_date"], null, "agree_date");
     if (strlen($row["auth_mode"]) > 0) {
         $this->__addElement("AuthMode", null, array("type" => $row["auth_mode"]), "auth_mode", true);
     }
     if (strlen($row["ext_account"]) > 0) {
         $this->__addElement("ExternalAccount", $row["ext_account"], null, "ext_account", true);
     }
     if ($this->canExport("Look", "skin_style")) {
         $this->__addElement("Look", null, array("Skin" => $prefs["skin"], "Style" => $prefs["style"]), "skin_style", true);
     }
     $this->__addElement("LastUpdate", $row["last_update"], null, "last_update");
     $this->__addElement("LastLogin", $row["last_login"], null, "last_login");
     include_once "./Services/User/classes/class.ilUserDefinedData.php";
     $udf_data = new ilUserDefinedData($row['usr_id']);
     $udf_data->addToXML($this, $this->settings);
     $msgrs = array("skype" => "im_skype", "yahoo" => "im_yahoo", "msn" => "im_msn", "aim" => "im_aim", "icq" => "im_icq", "delicious" => "delicious", "external" => "ext_account", "jabber" => "im_jabber", "voip" => "im_voip");
     foreach ($msgrs as $type => $fieldname) {
         $this->__addElement("AccountInfo", $row[$fieldname], array("Type" => $type), "instant_messengers");
     }
     $this->__addElement("GMapsInfo", null, array("longitude" => $row["longitude"], "latitude" => $row["latitude"], "zoom" => $row["loc_zoom"]));
     $this->__addElement("Feedhash", $row["feed_hash"]);
     if ($this->attachPreferences || $this->canExport("prefs", "preferences")) {
         $this->__handlePreferences($prefs, $row);
     }
     $this->xmlEndTag('User');
 }
 /**
  * display form for user import
  */
 function importUserRoleAssignmentObject()
 {
     global $ilUser, $rbacreview, $tpl, $lng, $ilCtrl;
     // Blind out tabs for local user import
     if ($_GET["baseClass"] == 'ilRepositoryGUI') {
         $this->tabs_gui->clearTargets();
     }
     $this->initUserImportForm();
     if ($this->form->checkInput()) {
         include_once './Services/AccessControl/classes/class.ilObjRole.php';
         include_once './Services/User/classes/class.ilUserImportParser.php';
         global $rbacreview, $rbacsystem, $tree, $lng;
         $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html", "Services/User");
         $import_dir = $this->getImportDir();
         // recreate user import directory
         if (@is_dir($import_dir)) {
             ilUtil::delDir($import_dir);
         }
         ilUtil::makeDir($import_dir);
         // move uploaded file to user import directory
         $file_name = $_FILES["importFile"]["name"];
         $parts = pathinfo($file_name);
         $full_path = $import_dir . "/" . $file_name;
         // check if import file exists
         if (!is_file($_FILES["importFile"]["tmp_name"])) {
             ilUtil::delDir($import_dir);
             $this->ilias->raiseError($this->lng->txt("no_import_file_found"), $this->ilias->error_obj->MESSAGE);
         }
         ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $_FILES["importFile"]["name"], $full_path);
         // handle zip file
         if (strtolower($parts["extension"]) == "zip") {
             // unzip file
             ilUtil::unzip($full_path);
             $xml_file = null;
             $file_list = ilUtil::getDir($import_dir);
             foreach ($file_list as $a_file) {
                 if (substr($a_file['entry'], -4) == '.xml') {
                     $xml_file = $import_dir . "/" . $a_file['entry'];
                     break;
                 }
             }
             if (is_null($xml_file)) {
                 $subdir = basename($parts["basename"], "." . $parts["extension"]);
                 $xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml";
             }
         } else {
             $xml_file = $full_path;
         }
         // check xml file
         if (!is_file($xml_file)) {
             ilUtil::delDir($import_dir);
             $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip") . " " . $subdir . "/" . $subdir . ".xml", $this->ilias->error_obj->MESSAGE);
         }
         require_once "./Services/User/classes/class.ilUserImportParser.php";
         // Verify the data
         // ---------------
         $importParser = new ilUserImportParser($xml_file, IL_VERIFY);
         $importParser->startParsing();
         switch ($importParser->getErrorLevel()) {
             case IL_IMPORT_SUCCESS:
                 break;
             case IL_IMPORT_WARNING:
                 $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
                 break;
             case IL_IMPORT_FAILURE:
                 ilUtil::delDir($import_dir);
                 $this->ilias->raiseError($lng->txt("verification_failed") . $importParser->getProtocolAsHTML($lng->txt("verification_failure_log")), $this->ilias->error_obj->MESSAGE);
                 return;
         }
         // Create the role selection form
         // ------------------------------
         $this->tpl->setCurrentBlock("role_selection_form");
         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
         $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
         $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
         $this->tpl->setVariable("IMPORT_FILE", $file_name);
         $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
         $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
         $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
         $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
         $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
         $this->tpl->setVariable("XML_FILE_NAME", $xml_file);
         // Extract the roles
         $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
         $importParser->startParsing();
         $roles = $importParser->getCollectedRoles();
         // get global roles
         $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
         $gl_roles = array();
         $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
         foreach ($all_gl_roles as $obj_data) {
             // check assignment permission if called from local admin
             if ($this->object->getRefId() != USER_FOLDER_ID) {
                 if (!in_array(SYSTEM_ROLE_ID, $roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) {
                     continue;
                 }
             }
             // exclude anonymous role from list
             if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID) {
                 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
                 if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID, $roles_of_user)) {
                     $gl_roles[$obj_data["obj_id"]] = $obj_data["title"];
                 }
             }
         }
         // global roles
         $got_globals = false;
         foreach ($roles as $role_id => $role) {
             if ($role["type"] == "Global") {
                 if (!$got_globals) {
                     $got_globals = true;
                     $this->tpl->setCurrentBlock("global_role_section");
                     $this->tpl->setVariable("TXT_GLOBAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_global"));
                     $this->tpl->setVariable("TXT_GLOBAL_ROLES", $this->lng->txt("assign_global_role"));
                 }
                 // pre selection for role
                 $pre_select = array_search($role[name], $gl_roles);
                 if (!$pre_select) {
                     switch ($role["name"]) {
                         case "Administrator":
                             // ILIAS 2/3 Administrator
                             $pre_select = array_search("Administrator", $gl_roles);
                             break;
                         case "Autor":
                             // ILIAS 2 Author
                             $pre_select = array_search("User", $gl_roles);
                             break;
                         case "Lerner":
                             // ILIAS 2 Learner
                             $pre_select = array_search("User", $gl_roles);
                             break;
                         case "Gast":
                             // ILIAS 2 Guest
                             $pre_select = array_search("Guest", $gl_roles);
                             break;
                         default:
                             $pre_select = array_search("User", $gl_roles);
                             break;
                     }
                 }
                 $this->tpl->setCurrentBlock("global_role");
                 $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $gl_roles, false, true);
                 $this->tpl->setVariable("TXT_IMPORT_GLOBAL_ROLE", $role["name"] . " [" . $role_id . "]");
                 $this->tpl->setVariable("SELECT_GLOBAL_ROLE", $role_select);
                 $this->tpl->parseCurrentBlock();
             }
         }
         // Check if local roles need to be assigned
         $got_locals = false;
         foreach ($roles as $role_id => $role) {
             if ($role["type"] == "Local") {
                 $got_locals = true;
                 break;
             }
         }
         if ($got_locals) {
             $this->tpl->setCurrentBlock("local_role_section");
             $this->tpl->setVariable("TXT_LOCAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_local"));
             $this->tpl->setVariable("TXT_LOCAL_ROLES", $this->lng->txt("assign_local_role"));
             // get local roles
             if ($this->object->getRefId() == USER_FOLDER_ID) {
                 // The import function has been invoked from the user folder
                 // object. In this case, we show only matching roles,
                 // because the user folder object is considered the parent of all
                 // local roles and may contains thousands of roles on large ILIAS
                 // installations.
                 $loc_roles = array();
                 foreach ($roles as $role_id => $role) {
                     if ($role["type"] == "Local") {
                         $searchName = substr($role['name'], 0, 1) == '#' ? $role['name'] : '#' . $role['name'];
                         $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
                         foreach ($matching_role_ids as $mid) {
                             if (!in_array($mid, $loc_roles)) {
                                 $loc_roles[] = array('obj_id' => $mid);
                             }
                         }
                     }
                 }
             } else {
                 // The import function has been invoked from a locally
                 // administrated category. In this case, we show all roles
                 // contained in the subtree of the category.
                 $loc_roles = $rbacreview->getAssignableRolesInSubtree($this->object->getRefId());
             }
             $l_roles = array();
             // create a search array with  .
             $l_roles_mailbox_searcharray = array();
             foreach ($loc_roles as $key => $loc_role) {
                 // fetch context path of role
                 $rolf = $rbacreview->getFoldersAssignedToRole($loc_role["obj_id"], true);
                 // only process role folders that are not set to status "deleted"
                 // and for which the user has write permissions.
                 // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
                 // (The ROLE_FOLDER_ID folder contains the global roles).
                 if (!$rbacreview->isDeleted($rolf[0]) && $rbacsystem->checkAccess('write', $tree->getParentId($rolf[0])) && $rolf[0] != ROLE_FOLDER_ID) {
                     // A local role is only displayed, if it is contained in the subtree of
                     // the localy administrated category. If the import function has been
                     // invoked from the user folder object, we show all local roles, because
                     // the user folder object is considered the parent of all local roles.
                     // Thus, if we start from the user folder object, we initialize the
                     // isInSubtree variable with true. In all other cases it is initialized
                     // with false, and only set to true if we find the object id of the
                     // locally administrated category in the tree path to the local role.
                     $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID;
                     $path = "";
                     if ($this->tree->isInTree($rolf[0])) {
                         // Create path. Paths which have more than 4 segments
                         // are truncated in the middle.
                         $tmpPath = $this->tree->getPathFull($rolf[0]);
                         for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++) {
                             if ($i > 1) {
                                 $path = $path . ' > ';
                             }
                             if ($i < 3 || $i > $n - 3) {
                                 $path = $path . $tmpPath[$i]['title'];
                             } else {
                                 if ($i == 3 || $i == $n - 3) {
                                     $path = $path . '...';
                                 }
                             }
                             $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId();
                         }
                     } else {
                         $path = "<b>Rolefolder " . $rolf[0] . " not found in tree! (Role " . $loc_role["obj_id"] . ")</b>";
                     }
                     $roleMailboxAddress = $rbacreview->getRoleMailboxAddress($loc_role['obj_id']);
                     $l_roles[$loc_role['obj_id']] = $roleMailboxAddress . ', ' . $path;
                 }
             }
             //foreach role
             $l_roles[""] = "";
             natcasesort($l_roles);
             $l_roles[""] = $this->lng->txt("usrimport_ignore_role");
             foreach ($roles as $role_id => $role) {
                 if ($role["type"] == "Local") {
                     $this->tpl->setCurrentBlock("local_role");
                     $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]);
                     $searchName = substr($role['name'], 0, 1) == '#' ? $role['name'] : '#' . $role['name'];
                     $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
                     $pre_select = count($matching_role_ids) == 1 ? $matching_role_ids[0] : "";
                     if ($this->object->getRefId() == USER_FOLDER_ID) {
                         // There are too many roles in a large ILIAS installation
                         // that's why whe show only a choice with the the option "ignore",
                         // and the matching roles.
                         $selectable_roles = array();
                         $selectable_roles[""] = $this->lng->txt("usrimport_ignore_role");
                         foreach ($matching_role_ids as $id) {
                             $selectable_roles[$id] = $l_roles[$id];
                         }
                         $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $selectable_roles, false, true);
                     } else {
                         $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $l_roles, false, true);
                     }
                     $this->tpl->setVariable("SELECT_LOCAL_ROLE", $role_select);
                     $this->tpl->parseCurrentBlock();
                 }
             }
         }
         //
         $this->tpl->setVariable("TXT_CONFLICT_HANDLING", $lng->txt("conflict_handling"));
         $handlers = array(IL_IGNORE_ON_CONFLICT => "ignore_on_conflict", IL_UPDATE_ON_CONFLICT => "update_on_conflict");
         $this->tpl->setVariable("TXT_CONFLICT_HANDLING_INFO", str_replace('\\n', '<br>', $this->lng->txt("usrimport_conflict_handling_info")));
         $this->tpl->setVariable("TXT_CONFLICT_CHOICE", $lng->txt("conflict_handling"));
         $this->tpl->setVariable("SELECT_CONFLICT", ilUtil::formSelect(IL_IGNORE_ON_CONFLICT, "conflict_handling_choice", $handlers, false, false));
         // new account mail
         $this->lng->loadLanguageModule("mail");
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage());
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             $this->tpl->setCurrentBlock("inform_user");
             $this->tpl->setVariable("TXT_ACCOUNT_MAIL", $lng->txt("mail_account_mail"));
             if (true) {
                 $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
             }
             $this->tpl->setVariable("TXT_INFORM_USER_MAIL", $this->lng->txt("user_send_new_account_mail"));
             $this->tpl->parseCurrentBlock();
         }
     } else {
         $this->form->setValuesByPost();
         $tpl->setContent($this->form->getHtml());
     }
 }
예제 #4
0
 public function confirmRegistration()
 {
     global $lng, $ilias, $ilLog;
     ilUtil::setCookie('iltest', 'cookie', false);
     if (!isset($_GET['rh']) || !strlen(trim($_GET['rh']))) {
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
     }
     try {
         require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
         $oRegSettings = new ilRegistrationSettings();
         $usr_id = ilObjUser::_verifyRegistrationHash(trim($_GET['rh']));
         $oUser = ilObjectFactory::getInstanceByObjId($usr_id);
         $oUser->setActive(true);
         if ($oRegSettings->passwordGenerationEnabled()) {
             $passwd = ilUtil::generatePasswords(1);
             $password = $passwd[0];
             $oUser->setPasswd($password, IL_PASSWD_PLAIN);
             $oUser->setLastPasswordChangeTS(time());
         }
         $oUser->update();
         $usr_lang = $oUser->getPref('language');
         if ($lng->getLangKey() != $usr_lang) {
             $lng = new ilLanguage($usr_lang);
         }
         // send email
         // try individual account mail in user administration
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($usr_lang);
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             $acc_mail = new ilAccountMail();
             $acc_mail->setUser($oUser);
             if ($oRegSettings->passwordGenerationEnabled()) {
                 $acc_mail->setUserPassword($password);
             }
             $acc_mail->send();
         } else {
             include_once 'Services/Mail/classes/class.ilMail.php';
             $mail_obj = new ilMail(ANONYMOUS_USER_ID);
             // mail subject
             $subject = $lng->txt("reg_mail_subject");
             // mail body
             $body = $lng->txt("reg_mail_body_salutation") . " " . $oUser->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=" . CLIENT_ID . "\n";
             $body .= $lng->txt("login") . ": " . $oUser->getLogin() . "\n";
             if ($oRegSettings->passwordGenerationEnabled()) {
                 $body .= $lng->txt("passwd") . ": " . $password . "\n";
             }
             $body .= "\n";
             $body .= $lng->txt('reg_mail_body_forgot_password_info') . "\n";
             $body .= "\n";
             $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
             $body .= $oUser->getProfileAsString($lng);
             $mail_obj->enableSoap(false);
             $mail_obj->appendInstallationSignature(true);
             $mail_obj->sendMail($oUser->getEmail(), '', '', $subject, $body, array(), array('normal'));
         }
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful&lang=' . $usr_lang);
     } catch (ilRegConfirmationLinkExpiredException $exception) {
         include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
         $soap_client = new ilSoapClient();
         $soap_client->setResponseTimeout(1);
         $soap_client->enableWSDL(true);
         $soap_client->init();
         $ilLog->write(__METHOD__ . ': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
         $soap_client->call('deleteExpiredDualOptInUserObjects', array($_COOKIE['PHPSESSID'] . '::' . $_COOKIE['ilClientId'], $exception->getCode()));
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     } catch (ilRegistrationHashNotFoundException $exception) {
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     }
 }
 protected function __distributeMails($password, $a_language = null)
 {
     global $ilSetting;
     include_once './Services/Language/classes/class.ilLanguage.php';
     include_once './Services/User/classes/class.ilObjUser.php';
     include_once "Services/Mail/classes/class.ilFormatMail.php";
     include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
     // Always send mail to approvers
     if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) {
         $mail = new ilRegistrationMailNotification();
         $mail->setType(ilRegistrationMailNotification::TYPE_NOTIFICATION_CONFIRMATION);
         $mail->setRecipients($this->registration_settings->getApproveRecipients());
         $mail->setAdditionalInformation(array('usr' => $this->userObj));
         $mail->send();
     } else {
         $mail = new ilRegistrationMailNotification();
         $mail->setType(ilRegistrationMailNotification::TYPE_NOTIFICATION_APPROVERS);
         $mail->setRecipients($this->registration_settings->getApproveRecipients());
         $mail->setAdditionalInformation(array('usr' => $this->userObj));
         $mail->send();
     }
     // Send mail to new user
     // Registration with confirmation link ist enabled
     if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used) {
         include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
         $mail = new ilRegistrationMimeMailNotification();
         $mail->setType(ilRegistrationMimeMailNotification::TYPE_NOTIFICATION_ACTIVATION);
         $mail->setRecipients(array($this->userObj));
         $mail->setAdditionalInformation(array('usr' => $this->userObj, 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()));
         $mail->send();
     } else {
         // try individual account mail in user administration
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($a_language);
         if (trim($amail["body"]) == "" || trim($amail["subject"]) == "") {
             $amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage());
         }
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             $acc_mail = new ilAccountMail();
             $acc_mail->setUser($this->userObj);
             if ($this->registration_settings->passwordGenerationEnabled()) {
                 $acc_mail->setUserPassword($password);
             }
             if ($amail["att_file"]) {
                 include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
                 $fs = new ilFSStorageUserFolder(USER_FOLDER_ID);
                 $fs->create();
                 $path = $fs->getAbsolutePath() . "/";
                 $acc_mail->addAttachment($path . "/" . $amail["lang"], $amail["att_file"]);
             }
             $acc_mail->send();
         } else {
             include_once "Services/Mail/classes/class.ilMimeMail.php";
             $mmail = new ilMimeMail();
             $mmail->autoCheck(false);
             $mmail->From($ilSetting->get("admin_email"));
             $mmail->To($this->userObj->getEmail());
             // mail subject
             $subject = $this->lng->txt("reg_mail_subject");
             // mail body
             $body = $this->lng->txt("reg_mail_body_salutation") . " " . $this->userObj->getFullname() . ",\n\n" . $this->lng->txt("reg_mail_body_text1") . "\n\n" . $this->lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . CLIENT_ID . "\n";
             $body .= $this->lng->txt("login") . ": " . $this->userObj->getLogin() . "\n";
             if ($this->registration_settings->passwordGenerationEnabled()) {
                 $body .= $this->lng->txt("passwd") . ": " . $password . "\n";
             }
             $body .= "\n";
             // Info about necessary approvement
             if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) {
                 $body .= $this->lng->txt('reg_mail_body_pwd_generation') . "\n\n";
             }
             $body .= $this->lng->txt("reg_mail_body_text3") . "\n\r";
             $body .= $this->userObj->getProfileAsString($this->lng);
             $mmail->Subject($subject);
             $mmail->Body($body);
             $mmail->Send();
         }
     }
 }
예제 #6
0
 /**
  * @param $lang_key
  * @return mixed
  */
 private function readAccountMailFromCache($lang_key)
 {
     if (!isset(self::$account_mail_cache[$lang_key])) {
         $default_lang_key = $GLOBALS["lng"]->getDefaultLanguage();
         // try individual account mail in user administration
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($lang_key);
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             self::$account_mail_cache[$lang_key] = $amail;
         } else {
             $lang_key = $default_lang_key;
         }
         if (!isset(self::$account_mail_cache[$default_lang_key])) {
             $amail = ilObjUserFolder::_lookupNewAccountMail($default_lang_key);
             self::$account_mail_cache[$default_lang_key] = $amail;
         }
     }
     return self::$account_mail_cache[$lang_key];
 }
 /**
  * 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;
 }
예제 #8
0
 /**
  * get new account mail array (including subject and message body)
  */
 function readAccountMail($a_lang)
 {
     if (!is_array($this->amail[$a_lang])) {
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $this->amail[$a_lang] = ilObjUserFolder::_lookupNewAccountMail($a_lang);
         $amail["body"] = trim($amail["body"]);
         $amail["subject"] = trim($amail["subject"]);
     }
     return $this->amail[$a_lang];
 }