예제 #1
0
 /**
  *
  * @return UserModel 
  */
 public static function getLoggedIn()
 {
     $session = new Ajde_Session('user');
     if ($session->has('model')) {
         $user = $session->getModel('model');
         return $user;
     } else {
         return false;
     }
 }
예제 #2
0
파일: User.php 프로젝트: nabble/ajde
 /**
  * @return UserModel
  */
 public static function getLoggedIn()
 {
     if (!isset(self::$_user)) {
         $session = new Ajde_Session('user');
         if ($session->has('model')) {
             $user = $session->getModel('model');
             self::$_user = $user;
         } else {
             self::$_user = false;
         }
     }
     return self::$_user;
 }
예제 #3
0
 private function purgeRevisions($crudId)
 {
     $session = new Ajde_Session('AC.Crud');
     /* @var $crud Ajde_Crud */
     $crud = $session->getModel($crudId);
     /* @var $model Ajde_Model */
     $model = $crud->getModel();
     $success = $model->purgeRevisions();
     return ['operation' => 'purgeRevisions', 'success' => $success, 'message' => 'Revisions purged'];
 }
 public function save($crudId, $id)
 {
     $session = new Ajde_Session('AC.Crud');
     /* @var $crud Ajde_Crud */
     $crud = $session->getModel($crudId);
     /* @var $model Ajde_Model */
     $model = $crud->getModel();
     $model->setOptions($crud->getOptions('model'));
     // Get POST params
     $post = $_POST;
     foreach ($post as $key => $value) {
         // Include empty values, so we can set them to null if the table structure allows us
         //			if (empty($value)) {
         //				unset($post[$key]);
         //			}
     }
     $id = issetor($post["id"]);
     $operation = empty($id) ? 'insert' : 'save';
     if ($operation === 'save') {
         $model->loadByPK($id);
     }
     $model->populate($post);
     if (!$model->validate($crud->getOptions('fields'))) {
         return array('operation' => $operation, 'success' => false, 'errors' => $model->getValidationErrors());
     }
     $success = $model->{$operation}();
     if ($success === true) {
         // Destroy reference to crud instance
         $session->destroy($crudId);
         // Set flash alert
         Ajde_Session_Flash::alert('Record ' . ($operation == 'insert' ? 'added' : 'saved'));
     }
     return array('operation' => $operation, 'id' => $model->getPK(), 'success' => $success);
 }