Beispiel #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']);
                 }
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Stores the study information of a user (subject and degree-wise).
  */
 public function store_sg_action()
 {
     $this->check_ticket();
     $any_change = false;
     $fach_abschluss_delete = Request::getArray('fach_abschluss_delete');
     if (count($fach_abschluss_delete) > 0) {
         $query = "DELETE FROM user_studiengang\n                      WHERE user_id = ? AND studiengang_id = ? AND abschluss_id IN (?)";
         $statement = DBManager::get()->prepare($query);
         foreach ($fach_abschluss_delete as $studiengang_id => $abschluesse) {
             $statement->execute(array($this->user->user_id, $studiengang_id, $abschluesse));
             if ($statement->rowCount() > 0) {
                 $any_change = true;
             }
             // if we have no studies anymore we delete the visibilitysetting
             if (!$this->hasStudiengang()) {
                 Visibility::removePrivacySetting('studying');
             }
         }
     }
     if (!$any_change) {
         $query = "UPDATE IGNORE user_studiengang\n                      SET semester = ?\n                      WHERE user_id = ? AND studiengang_id = ? AND abschluss_id = ?";
         $statement = DBManager::get()->prepare($query);
         $change_fachsem = Request::getArray('change_fachsem');
         foreach ($change_fachsem as $studiengang_id => $abschluesse) {
             foreach ($abschluesse as $abschluss_id => $semester) {
                 $statement->execute(array($semester, $this->user->user_id, $studiengang_id, $abschluss_id));
                 if ($statement->rowCount() > 0) {
                     $any_change = true;
                 }
             }
         }
         $new_studiengang = Request::option('new_studiengang');
         if ($new_studiengang && $new_studiengang != 'none') {
             if (!$this->hasStudiengang()) {
                 Visibility::addPrivacySetting(_("Wo ich studiere"), 'studying', 'studdata');
             }
             $query = "INSERT IGNORE INTO user_studiengang\n                            (user_id, studiengang_id, abschluss_id, semester)\n                          VALUES (?, ?, ?, ?)";
             $statement = DBManager::get()->prepare($query);
             $statement->execute(array($this->user->user_id, $new_studiengang, Request::option('new_abschluss'), Request::int('fachsem')));
             if ($statement->rowCount() > 0) {
                 $any_change = true;
             }
         }
     }
     if ($any_change) {
         $this->reportSuccess(_('Die Zuordnung zu Studiengängen wurde geändert.'));
         setTempLanguage($this->user->user_id);
         $this->postPrivateMessage(_("Die Zuordnung zu Studiengängen wurde geändert!\n"));
         restoreLanguage();
     }
     $this->redirect('settings/studies');
 }
Beispiel #3
0
 /**
  * Creates a new category
  */
 public function create_action()
 {
     Kategorie::increatePrioritiesByUserId($this->user->user_id);
     $category = new Kategorie();
     $category->range_id = $this->user->user_id;
     $category->name = _('neue Kategorie');
     $category->content = _('Inhalt der Kategorie');
     $category->priority = 0;
     if ($category->store()) {
         $this->reportSuccess(_('Neue Kategorie angelegt.'));
         Visibility::addPrivacySetting($category->name, 'kat_' . $category->id, 'owncategory');
     } else {
         $this->reportSuccess(_('Anlegen der Kategorie fehlgeschlagen.'));
     }
     $this->redirect('settings/categories');
 }
Beispiel #4
0
 /**
  * Upload a new avatar or removes the current avatar.
  * Upon Sends an information email to the user if the action was not invoked
  * by himself.
  */
 public function upload_action()
 {
     $this->check_ticket();
     if (Request::submitted('reset')) {
         Avatar::getAvatar($this->user->user_id)->reset();
         Visibility::removePrivacySetting('picture', $this->user->user_id);
         $this->reportSuccess(_('Bild gelöscht.'));
     } elseif (Request::submitted('upload')) {
         try {
             Avatar::getAvatar($this->user->user_id)->createFromUpload('imgfile');
             NotificationCenter::postNotification('AvatarDidUpload', $this->user->user_id);
             $message = _('Die Bilddatei wurde erfolgreich hochgeladen. ' . 'Eventuell sehen Sie das neue Bild erst, nachdem Sie diese Seite ' . 'neu geladen haben (in den meisten Browsern F5 drücken).');
             $this->reportSuccess($message);
             setTempLanguage($this->user->user_id);
             $this->postPrivateMessage(_("Ein neues Bild wurde hochgeladen.\n"));
             restoreLanguage();
             Visibility::addPrivacySetting(_('Eigenes Bild'), 'picture', 'commondata', 1, $this->user->user_id);
         } catch (Exception $e) {
             $this->reportError($e->getMessage());
         }
     }
     $this->redirect('settings/avatar');
 }
Beispiel #5
0
 /**
  * Updates a privacySetting. Important: The whole privacySetting gets
  * deleted and recreated if the teststring is not empty. Therefore a new
  * visibilityID is created. If you use the privacyID you will have to update
  * it as well.
  *
  * @param string $test A teststring to determine if the privacySetting is
  * only deleted or if it is deleted and recreated. Use this with a request-
  * string for example.
  *
  * @param string $name The setting's name, that will be displayed in the
  * user's settingtab (Important: Don't mix the name up with the identifier)
  *
  * @param string $identifier the identifier is used to simplify the usage
  * of the visibilityAPI. An identifier maps a string to a visibilityid
  * (under the usage of a userid) therefore all identifier set for one user
  * MUST be unique.
  *
  * @param int|string $parent Determines the parent of the visibility to add.
  * Use the direct visibilityid of the parent visibility or the identifier.
  * If the visibility should be created on the top level the value has to be
  * 0. Plugins creating a privacysetting will automaticly be added to the
  * parent "plugins". Important: If u add a visibility without a parent and
  * without beeing a toplevelpoint itself it will NEVER be displayed.
  *
  * @param int $category Sets the type of the visibilitysetting. Currently
  * there are only 2 types available:
  * 0 - The setting is only a header without any options
  * 1 (Default) - Normal setting
  *
  * @param string $user Userid of the user that should be added the visibility.
  * Default: The current logged on user
  *
  * @param int $default int representation of the visibility that should be
  * set. Use with caution since the API provides the easy change of the
  * visibility int representation
  *
  * @param int $pluginid Connects the created visibility with a plugin.
  * Important: If addPrivacySetting is called in a file of a plugin there is
  * no need to set the pluginid manually, because the API will normally find
  * it
  *
  * @return int the created visibilityid
  */
 public static function updatePrivacySettingWithTest($test, $name, $id, $parent = null, $category = 1, $user = null, $default = null, $pluginid = null)
 {
     $default = Visibility::removePrivacySetting($id, $user);
     if ($test != "") {
         return Visibility::addPrivacySetting($name, $id, $parent, $category, $user, $default, $pluginid);
     }
     return false;
 }