Beispiel #1
0
 public static function get($level)
 {
     Platal::assert(array_key_exists($level, self::$view_levels), "Invalid visibility access level {$level}.");
     if (!array_key_exists($level, self::$vis_list)) {
         self::$vis_list[$level] = new Visibility($level);
     }
     return self::$vis_list[$level];
 }
Beispiel #2
0
 /** Format of the emails sent by the site
  */
 public function setEmailFormat($format)
 {
     Platal::assert($format == self::FORMAT_HTML || $format == self::FORMAT_TEXT, "Invalid email format \"{$format}\"");
     XDB::execute("UPDATE  accounts\n                         SET  email_format = {?}\n                       WHERE  uid = {?}", $format, $this->uid);
     $this->email_format = $format;
 }
Beispiel #3
0
 public function child($qid)
 {
     $prev = null;
     foreach ($this->children as $question) {
         if ($qid == $question->qid) {
             return $question;
         } else {
             if ($qid < $question->qid) {
                 Platal::assert($prev instanceof SurveyQuestionGroup);
                 return $prev->child($qid);
             }
         }
         $prev = $question;
     }
     Platal::assert($prev instanceof SurveyQuestionGroup);
     return $prev->child($qid);
 }
Beispiel #4
0
 public function isDeltaTenEnabled($role)
 {
     global $globals;
     switch ($role) {
         case self::DELTATEN_YOUNG:
             return $this->mainGrade() == UserFilter::GRADE_ING && $this->yearpromo() >= $globals->deltaten->first_promo_young;
         case self::DELTATEN_OLD:
             // Roughly compute the current promo in second year on the campus:
             // Promo 2010 is in second year between 09/2011 and 08/2012 => use 2012.
             // DeltaTen program begins around January of the second year.
             $promo_on_platal = (int) date('Y') - 2;
             return $this->mainGrade() == UserFilter::GRADE_ING && $this->yearpromo() >= $globals->deltaten->first_promo_young - 10 && $this->yearpromo() <= $promo_on_platal - 10;
         default:
             Platal::assert(false, "Invalid DeltaTen role {$role}");
     }
 }
Beispiel #5
0
 public static function activate_storage(User $user, $storage, $action = null)
 {
     Platal::assert(in_array($storage, self::get_allowed_storages($user)), 'Unknown storage.');
     // We first need to retrieve the value for the antispam filter if not
     // provided: it is either the user's redirections common value, or if
     // they differ, our default value.
     if (is_null($action)) {
         $bogo = new Bogo($user);
         $action = $bogo->single_state ? Bogo::$states[$bogo->state] : Bogo::MAIN_DEFAULT;
     }
     if (!self::is_active_storage($user, $storage)) {
         XDB::execute('INSERT INTO  email_redirect_account (uid, type, action, redirect, flags)
                            VALUES  ({?}, {?}, {?}, {?}, \'active\')', $user->id(), $storage, $action, self::make_storage_redirection($user, $storage));
     }
 }