示例#1
0
文件: Manager.php 项目: johnstyle/sjo
 public function delete()
 {
     if (Request::env('REQUEST')->{Admin::getInstance()->getPrimaryKey()}->val() == 1) {
         Alert::set(I18n::__('Vous ne pouvez pas supprimer cet administrateur.'));
         Http::redirect(Router::linkBack(Router::$controller));
     }
     parent::delete(new Admin());
 }
示例#2
0
文件: Auth.php 项目: johnstyle/sjo
 public static function secure()
 {
     $rc = new \ReflectionClass(self::model());
     $modelName = $rc->getShortName();
     if (Router::$controller !== $modelName . '\\Auth') {
         if (!self::model()->isLogged()) {
             http_response_code(401);
             Http::redirect(Router::link(Router::$interface, $modelName . '\\Auth', array('redirect' => Request::env('SERVER')->REQUEST_URI->val())));
         }
     } elseif (self::model()->isLogged() && !Router::$method) {
         Http::redirect(Router::link());
     }
 }
示例#3
0
文件: Auth.php 项目: johnstyle/sjo
 public function signin()
 {
     if (Request::env('POST')->email->exists()) {
         if (Request::env('POST')->password->exists()) {
             if ($id = self::model()->exists(Request::env('POST')->email->val(), Request::env('POST')->password->val())) {
                 Logger::getInstance()->info('Signin {admin}', array('admin' => Request::env('POST')->email->val()));
                 self::model()->session()->id = $id;
                 self::model()->session()->token = Token::get($id);
                 $url = SJO_BASEHREF;
                 if (preg_match('#^(\\./|/)#', Request::env('GET')->redirect->val())) {
                     $url = Request::env('GET')->redirect->val();
                 }
                 Http::redirect($url);
             } else {
                 Alert::set(Lib\I18n::__('Les informations de connexion sont incorrects'));
             }
         } else {
             Alert::set(Lib\I18n::__('Veuillez renseigner votre mot de passe'));
         }
     } else {
         Alert::set(Lib\I18n::__('Veuillez renseigner votre identifiant'));
     }
 }
示例#4
0
文件: Form.php 项目: johnstyle/sjo
 /**
  *
  */
 public function redirectForm()
 {
     $next = 'back';
     if (Request::env('REQUEST')->__saveAndStay->exists()) {
         $next = 'stay';
     } elseif (Request::env('REQUEST')->__saveAndCreate->exists()) {
         $next = 'create';
     }
     switch ($next) {
         default:
             Http::redirect(Router::link(null, Router::$controller));
             break;
         case 'stay':
             Http::redirect(Router::link(null, null, array($this->getPrimaryKey() => $this->getPrimaryValue())));
             break;
         case 'create':
             Http::redirect(Router::link());
             break;
     }
 }