Beispiel #1
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 #2
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 #3
0
 /**
  * Deletes a given category.
  *
  * @param String $id Id of the category to be deleted
  * @param bool $verified Indicates whether the delete action has been
  *                       verfified
  */
 public function delete_action($id, $verified = false)
 {
     $category = Kategorie::find($id);
     $name = $category->name;
     if ($category->range_id !== $GLOBALS['user']->user_id) {
         $this->reportError(_('Sie haben leider nicht die notwendige Berechtigung für diese Aktion.'))->redirect('settings/categories');
         return;
     }
     if (!$verified) {
         $this->redirect($this->url_for('settings/categories/verify', 'delete', $id));
         return;
     }
     if ($category->delete()) {
         $this->reportSuccess(_('Kategorie "%s" gelöscht!'), $name);
         Visibility::removePrivacySetting('kat_' . $id);
     } else {
         $this->reportError(_('Kategorie "%s" konnte nicht gelöscht werden!'), $name);
     }
     $this->redirect('settings/categories');
 }
Beispiel #4
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;
 }