예제 #1
0
 function up()
 {
     $sql = "CREATE TABLE IF NOT EXISTS `user_visibility_settings` (\n  `user_id` varchar(32)  NOT NULL DEFAULT '',\n  `visibilityid` int(11) NOT NULL AUTO_INCREMENT,\n  `parent_id` int(11) NOT NULL,\n  `category` int(2)  NOT NULL,\n  `name` varchar(128)  NOT NULL,\n  `state` int(2) NULL,\n  `plugin` int(11),\n  `identifier` varchar(64)  NOT NULL,\n  PRIMARY KEY (`visibilityid`),\n  KEY `parent_id` (`parent_id`),\n  KEY `identifier` (`identifier`),\n  KEY `userid` (`user_id`)\n) ENGINE=MyISAM";
     $db = DBManager::get();
     $stmt = $db->prepare($sql);
     $stmt->execute();
     $category = array('Studien-/Einrichtungsdaten' => 'studdata', 'Private Daten' => 'privatedata', 'Zusätzliche Datenfelder' => 'additionaldata', 'Eigene Kategorien' => 'owncategory', 'Allgemeine Daten' => 'commondata');
     $result = $db->query("SELECT value FROM config WHERE field = 'HOMEPAGE_VISIBILITY_DEFAULT' ORDER BY is_default LIMIT 1");
     $default_visibility = constant($result->fetchColumn());
     $sql = "SELECT `username` FROM `auth_user_md5`";
     $stmt = $db->prepare($sql);
     $stmt->execute();
     while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $about = new about($result['username'], '');
         Visibility::createDefaultCategories($about->auth_user['user_id']);
         //copy all homepage visibility
         $elements = $about->get_homepage_elements();
         if (is_array($elements)) {
             foreach ($elements as $key => $state) {
                 if ($state['visibility'] != $default_visibility) {
                     Visibility::addPrivacySetting($state['name'], $key, $category[$state['category']], 1, $about->auth_user['user_id'], $state['visibility']);
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * Returns all the categorys and it's items
  * @return array categorys and it's items
  */
 public function getProfileSettings()
 {
     if (!isset($this->profileSettings)) {
         // if the default categories have not been created, do this now
         if (User_Visibility_Settings::countBySQL('user_id = ? AND category = 0', array($this->userid)) == 0) {
             Visibility::createDefaultCategories($this->userid);
         }
         $this->profileSettings = User_Visibility_Settings::findBySQL("user_id = ? AND parent_id = 0 AND identifier <> 'plugins'", array($this->userid));
         foreach ($this->profileSettings as $i => $vis) {
             $vis->loadChildren();
             // remap child settings to default categories
             if ($vis->category == 1) {
                 $idmap[$vis->identifier] = $vis;
                 unset($this->profileSettings[$i]);
             }
         }
         $about = new about($GLOBALS['user']->username, '');
         $elements = $about->get_homepage_elements();
         foreach ($elements as $key => $element) {
             foreach ($this->profileSettings as $vis) {
                 if ($vis->name === $element['category']) {
                     foreach ($vis->children as $child) {
                         if ($child->identifier === $key) {
                             $child->name = $element['name'];
                             break 2;
                         }
                     }
                     $child = $idmap[$key] ?: new User_Visibility_Settings();
                     $child->setData(array('user_id' => $this->userid, 'parent_id' => $vis->id, 'category' => 1, 'name' => $element['name'], 'state' => $element['visibility'], 'identifier' => $key));
                     $child->store();
                     $child->parent = $vis;
                     $child->setDisplayed();
                     $vis->children[] = $child;
                     break;
                 }
             }
         }
     }
     return $this->profileSettings;
 }
예제 #3
0
 /**
  * Create a new preliminary studip user with the given parameters
  *
  * @access   public
  * @param    array   structure: array('string table_name.field_name'=>'string value')
  * @return   bool Creation successful?
  */
 function createPreliminaryUser($newuser)
 {
     global $perm;
     $this->getFromDatabase(null);
     $this->user_data->setData($newuser);
     // Do we have permission to do so?
     if (!$perm->have_perm("admin")) {
         $this->msg .= "error§" . _("Sie haben keine Berechtigung Accounts anzulegen.") . "§";
         return FALSE;
     }
     if (in_array($this->user->perms, words('root admin'))) {
         $this->msg .= "error§" . _("Es können keine vorläufigen Administrationsaccounts angelegt werden.") . "§";
         return FALSE;
     }
     if (!$this->user->id) {
         $this->user->setId($this->user->getNewId());
     }
     if (!$this->user->username) {
         $this->user->username = $this->user->id;
     }
     $this->user->auth_plugin = null;
     $this->user->visible = 'never';
     // Do we have all necessary data?
     if (empty($this->user->perms) || empty($this->user->vorname) || empty($this->user->nachname)) {
         $this->msg .= "error§" . _("Bitte geben Sie <em>Status</em>, <em>Vorname</em> und <em>Nachname</em> an!") . "§";
         return FALSE;
     }
     // Is the username correct?
     if (!$this->validator->ValidateUsername($this->user->username)) {
         $this->msg .= "error§" . _("Der gewählte Benutzername ist zu kurz oder enthält unzulässige Zeichen!") . "§";
         return FALSE;
     }
     // Does the user already exist?
     // NOTE: This should be a transaction, but it is not...
     $temp = User::findByUsername($this->user->username);
     if ($temp) {
         $this->msg .= "error§" . sprintf(_("BenutzerIn <em>%s</em> ist schon vorhanden!"), $this->user->username) . "§";
         return FALSE;
     }
     if (!$this->storeToDatabase()) {
         $this->msg .= "error§" . sprintf(_("BenutzerIn \"%s\" konnte nicht angelegt werden."), $this->user->username) . "§";
         return FALSE;
     }
     $this->msg .= "msg§" . sprintf(_("BenutzerIn \"%s\" (vorläufig) angelegt."), $this->user->username) . "§";
     // add default visibility settings
     Visibility::createDefaultCategories($this->user->id);
     return TRUE;
 }