Esempio n. 1
0
 /**
  * Stores the account informations of a user
  */
 public function store_action()
 {
     $this->check_ticket();
     $errors = $info = $success = array();
     $logout = false;
     //erstmal die "unwichtigen" Daten
     $geschlecht = Request::int('geschlecht');
     if ($this->shallChange('user_info.geschlecht', 'gender', $geschlecht)) {
         $this->user->geschlecht = $geschlecht;
     }
     $title_front = Request::get('title_front') ?: Request::get('title_front_chooser');
     if ($this->shallChange('user_info.title_front', 'title', $title_front)) {
         $this->user->title_front = $title_front;
     }
     $title_rear = Request::get('title_rear') ?: Request::get('title_rear_chooser');
     if ($this->shallChange('user_info.title_rear', 'title', $title_rear)) {
         $this->user->title_rear = $title_rear;
     }
     if ($this->user->store()) {
         $success[] = _('Ihre persönlichen Daten wurden geändert.');
         // Inform the user about this change
         setTempLanguage($this->user->user_id);
         $this->postPrivateMessage(_("Ihre persönlichen Daten wurden geändert.\n"));
         restoreLanguage();
     }
     //nur nötig wenn der user selbst seine daten ändert
     if (!$this->restricted) {
         // Vorname verändert ?
         $vorname = trim(Request::get('vorname'));
         if ($this->shallChange('auth_user_md5.Vorname', 'name', $vorname)) {
             // Vorname nicht korrekt oder fehlend
             if (!$this->validator->ValidateName($vorname)) {
                 $errors[] = _('Der Vorname fehlt oder ist unsinnig!');
             } else {
                 $this->user->Vorname = $vorname;
                 $success[] = _('Ihr Vorname wurde geändert!');
             }
         }
         // Nachname verändert ?
         $nachname = trim(Request::get('nachname'));
         if ($this->shallChange('auth_user_md5.Nachname', 'name', $nachname)) {
             // Nachname nicht korrekt oder fehlend
             if (!$this->validator->ValidateName($nachname)) {
                 $errors[] = _('Der Nachname fehlt oder ist unsinnig!');
             } else {
                 $this->user->Nachname = $nachname;
                 $success[] = _('Ihr Nachname wurde geändert!');
             }
         }
         // Username
         $new_username = trim(Request::get('new_username'));
         if ($this->shallChange('auth_user_md5.username', 'username', $new_username)) {
             if (!$this->validator->ValidateUsername($new_username)) {
                 $errors[] = _('Der gewählte Benutzername ist nicht lang genug!');
             } else {
                 if ($check_uname = StudipAuthAbstract::CheckUsername($new_username) && $check_uname['found']) {
                     $errors[] = _('Der Benutzername wird bereits von einem anderen Benutzer verwendet. Bitte wählen Sie einen anderen Usernamen!');
                 } else {
                     $this->user->username = $new_username;
                     $success[] = _('Ihr Benutzername wurde geändert!');
                     URLHelper::addLinkParam('username', $this->user->username);
                     $logout = true;
                 }
             }
         }
         // Email
         $email1 = trim(Request::get('email1'));
         $email2 = trim(Request::get('email2'));
         if ($this->shallChange('auth_user_md5.Email', 'email', $email1)) {
             $auth = StudipAuthAbstract::GetInstance($this->user->auth_plugin ?: 'standard');
             $is_sso = $auth instanceof StudipAuthSSO;
             if (!$is_sso && !$auth->isAuthenticated($this->user->username, Request::get('password'))) {
                 $errors[] = _('Das aktuelle Passwort wurde nicht korrekt eingegeben.');
             } else {
                 if ($email1 !== $email2) {
                     $errors[] = _('Die Wiederholung der E-Mail-Adresse stimmt nicht mit Ihrer Eingabe überein.');
                 } else {
                     $result = edit_email($this->user, $email1);
                     $messages = explode('§', $result[1]);
                     if ($result[0]) {
                         $this->user->Email = $email1;
                         if (count($messages) < 2) {
                             $success[] = _('Ihre E-Mail-Adresse wurde geändert!');
                         }
                     }
                     for ($i = 0; $i < count($messages); $i += 2) {
                         $type = $messages[$i];
                         if ($type === 'msg') {
                             $type = 'success';
                         } else {
                             if ($type === 'error') {
                                 $type = 'errors';
                             }
                         }
                         ${$type}[] = $messages[$i + 1];
                     }
                 }
             }
         }
     }
     if (count($errors) > 0) {
         $this->reportErrorWithDetails(_('Bitte überprüfen Sie Ihre Eingaben:'), $errors);
     } else {
         if ($this->user->store()) {
             $this->reportSuccessWithDetails(_('Ihre Nutzerdaten wurden geändert.'), $success);
             if (count($info) > 0) {
                 $this->reportInfoWithDetails(_('Bitte beachten Sie:'), $info);
             }
         }
     }
     if ($logout) {
         $token = uniqid('logout', true);
         $this->flash['logout-token'] = $token;
         $this->redirect('settings/account/logout?token=' . $token);
     } else {
         $this->redirect('settings/account');
     }
 }
Esempio n. 2
0
 /**
  * get preferences
  *
  * shows additional settings.
  * @access public
  */
 function getPreferences()
 {
     global $connected_cms;
     $role_template_name = Request::get('role_template_name');
     $cat_name = Request::get('cat_name');
     $this->soap_client->setCachingStatus(false);
     if ($cat_name != "") {
         $cat = $this->soap_client->getReferenceByTitle(trim($cat_name), "cat");
         if ($cat == false) {
             $messages["error"] .= sprintf(_("Das Objekt mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($cat_name), htmlReady($this->getName())) . "<br>\n";
         } elseif ($cat != "") {
             ELearningUtils::setConfigValue("category_id", $cat, $this->cms_type);
             $this->main_category_node_id = $cat;
         }
     }
     if ($this->main_category_node_id != false and ELearningUtils::getConfigValue("user_category_id", $this->cms_type) == "") {
         $object_data["title"] = sprintf(_("User-Daten"));
         $object_data["description"] = _("Hier befinden sich die persönlichen Ordner der Stud.IP-User.");
         $object_data["type"] = "cat";
         $object_data["owner"] = $this->user->getId();
         $user_cat = $connected_cms[$this->cms_type]->soap_client->addObject($object_data, $connected_cms[$this->cms_type]->main_category_node_id);
         if ($user_cat != false) {
             $this->user_category_node_id = $user_cat;
             ELearningUtils::setConfigValue("user_category_id", $user_cat, $this->cms_type);
         } else {
             $messages["error"] .= _("Die Kategorie für User-Daten konnte nicht angelegt werden.") . "<br>\n";
         }
     }
     if ($role_template_name != "") {
         $role_template = $this->soap_client->getObjectByTitle(trim($role_template_name), "rolt");
         if ($role_template == false) {
             $messages["error"] .= sprintf(_("Das Rollen-Template mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($role_template_name), htmlReady($this->getName())) . "<br>\n";
         }
         if (is_array($role_template)) {
             ELearningUtils::setConfigValue("user_role_template_id", $role_template["obj_id"], $this->cms_type);
             ELearningUtils::setConfigValue("user_role_template_name", $role_template["title"], $this->cms_type);
             $this->user_role_template_id = $role_template["obj_id"];
         }
     }
     if (Request::submitted('submit')) {
         ELearningUtils::setConfigValue("encrypt_passwords", Request::option("encrypt_passwords"), $this->cms_type);
         $encrypt_passwords = Request::option("encrypt_passwords");
         ELearningUtils::setConfigValue("ldap_enable", Request::option("ldap_enable"), $this->cms_type);
         $this->ldap_enable = Request::option("ldap_enable");
     } else {
         if (ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type) != "") {
             $encrypt_passwords = ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type);
         }
     }
     $cat = $this->soap_client->getObjectByReference($this->main_category_node_id);
     $user_cat = $this->soap_client->getObjectByReference($this->user_category_node_id);
     $title = $this->link->getModuleLink($user_cat["title"], $this->user_category_node_id, "cat");
     $ldap_options = array();
     foreach (StudipAuthAbstract::GetInstance() as $plugin) {
         if ($plugin instanceof StudipAuthLdap) {
             $ldap_options[] = '<option ' . ($plugin->plugin_name == $this->ldap_enable ? 'selected' : '') . '>' . $plugin->plugin_name . '</option>';
         }
     }
     ob_start();
     ConnectedCMS::getPreferences();
     $module_types = ob_get_clean();
     $template = $GLOBALS['template_factory']->open('elearning/ilias4_connected_cms_preferences.php');
     $template->set_attribute('messages', $messages);
     $template->set_attribute('soap_error', $this->soap_client->getError());
     $template->set_attribute('soap_data', $this->soap_data);
     $template->set_attribute('main_category_node_id', $this->main_category_node_id);
     $template->set_attribute('main_category_node_id_title', $cat['title']);
     $template->set_attribute('user_category_node_id', $this->user_category_node_id);
     $template->set_attribute('user_category_node_id_title', $title);
     $template->set_attribute('user_role_template_name', ELearningUtils::getConfigValue("user_role_template_name", $this->cms_type));
     $template->set_attribute('user_role_template_id', $this->user_role_template_id);
     $template->set_attribute('encrypt_passwords', $encrypt_passwords);
     $template->set_attribute('ldap_options', count($ldap_options) ? join("\n", array_merge(array('<option></option>'), $ldap_options)) : '');
     $template->set_attribute('module_types', $module_types);
     echo $template->render();
 }
Esempio n. 3
0
 /**
  * @return bool
  */
 function auth_preauth()
 {
     // is Single Sign On activated?
     if ($provider = Request::option('sso')) {
         Metrics::increment('core.sso_login.attempted');
         // then do login
         if ($authplugin = StudipAuthAbstract::GetInstance($provider)) {
             $authplugin->authenticateUser("", "", "");
             if ($authplugin->getUser()) {
                 $user = $authplugin->getStudipUser($authplugin->getUser());
                 $this->auth["jscript"] = true;
                 $this->auth["perm"] = $user->perms;
                 $this->auth["uname"] = $user->username;
                 $this->auth["auth_plugin"] = $user->auth_plugin;
                 $this->auth_set_user_settings($user);
                 Metrics::increment('core.sso_login.succeeded');
                 return $user->id;
             }
         } else {
             return false;
         }
     }
     // end of single sign on
 }
Esempio n. 4
0
 /**
  * static method to check for a mapped field
  *
  * this method checks in the plugin with the passed name, if the passed
  * Stud.IP DB field is mapped to an external data source
  *
  * @access public
  * @static
  * @param    string  the name of the db field must be in form '<table name>.<field name>'
  * @param    string  the name of the plugin to check
  * @return   bool    true if the field is mapped, else false
  */
 static function CheckField($field_name, $plugin_name)
 {
     if (!$plugin_name) {
         return false;
     }
     $plugin = StudipAuthAbstract::GetInstance($plugin_name);
     return is_object($plugin) ? $plugin->isMappedField($field_name) : false;
 }
Esempio n. 5
0
require '../lib/bootstrap.php';
page_open(array("sess" => "Seminar_Session", "auth" => "Seminar_Default_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"));
require_once 'lib/messaging.inc.php';
//nur wenn wir angemeldet sind sollten wir dies tun!
if ($auth->auth["uid"] != "nobody") {
    $sms = new messaging();
    $my_messaging_settings = UserConfig::get($user->id)->MESSAGING_SETTINGS;
    //Wenn Option dafuer gewaehlt, alle ungelsesenen Nachrichten als gelesen speichern
    if ($my_messaging_settings["logout_markreaded"]) {
        $sms->set_read_all_messages();
    }
    $logout_user = $user->id;
    // TODO this needs to be generalized or removed
    //erweiterung cas
    if ($auth->auth["auth_plugin"] == "cas") {
        $casauth = StudipAuthAbstract::GetInstance('cas');
        $docaslogout = true;
    }
    //Logout aus dem Sessionmanagement
    $auth->logout();
    $sess->delete();
    page_close();
    //Session changed zuruecksetzen
    $timeout = time() - 15 * 60;
    $user->set_last_action($timeout);
    //der logout() Aufruf fuer CAS (dadurch wird das Cookie (Ticket) im Browser zerstoert)
    if ($docaslogout) {
        $casauth->logout();
    }
} else {
    $sess->delete();