コード例 #1
0
ファイル: controller.endo.php プロジェクト: nemoDreamer/endo
 public function __construct()
 {
     // Data
     $this->data = $_POST;
     // TODO clean up data for SQL here?
     // View
     $this->View = new AppView();
     // Model
     if ($this->has_model) {
         // load Model class
         if (Globe::Load(Url::$data['model'], 'model')) {
             $this->Model = $this->{Url::$data['modelName']} = AppModel::Create(Url::$data['modelName']);
             // reference for ease
         }
     }
 }
コード例 #2
0
ファイル: controller.users.php プロジェクト: nemoDreamer/endo
 public function signup()
 {
     if ($this->data) {
         if (!$this->data('email') || !$this->data('password')) {
             Error::Set("Fields blank!", 'validation');
             return false;
         }
         // create
         $this->Model = AppModel::Create(CLASS_USER_MEMBER, $this->data);
         // valid?
         if ($this->Model->save()) {
             $this->redirect('/users/login');
         }
     } else {
         $this->assign(array('redirect_to' => null, 'email' => null));
     }
 }
コード例 #3
0
ファイル: class.globe.php プロジェクト: nemoDreamer/endo
 static function Init($name, $type = 'class', $show_errors = true)
 {
     if (self::Load($name, $type, $show_errors)) {
         $class_name = AppInflector::classify($name, $type);
         return $type == 'model' ? AppModel::Create($class_name) : new $class_name();
     } else {
         return new stdClass();
     }
 }
コード例 #4
0
ファイル: model.user.php プロジェクト: nemoDreamer/endo
 /**
  * This is basically the 'Login' function.
  * It cycles through different possible locations for the user,
  * lastly checking if a login is occurring.
  *
  * @return User object. FALSE on fail.
  */
 static function GetCurrent()
 {
     // session?
     if ($session = AppUser::GetSession()) {
         if ($user = AppUser::FetchFromString($session)) {
             return $user;
         }
     } elseif ($cookie = AppUser::GetCookie()) {
         if ($user = AppUser::FetchFromString($cookie)) {
             return $user;
         }
     } elseif (Url::GetRequest('check_data', false) && ($email = Url::GetRequest('email', false)) && ($password = Url::GetRequest('password', false))) {
         // valid?
         if (($user = AppUser::FetchUser($email)) && $user->validate($password)) {
             return AppUser::SetCurrent($user);
         } else {
             Error::Set("Invalid Email and/or Password", 'validation');
         }
     }
     // create Guest...
     return AppModel::Create(AppUser::$levels[0]);
 }
コード例 #5
0
ファイル: model.endo.php プロジェクト: nemoDreamer/endo
 static function FindAllAssoc($strClass, $extend = FALSE, $mxdWhere = NULL, $strIndexBy = 'id', $strOrderBy = null, $intLimit = 10000, $intOffset = 0)
 {
     if (!AppModel::_smartLoadModel($strClass)) {
         return false;
     }
     $model = AppModel::Create($strClass);
     // TODO replace by ::singleton
     $strOrderBy = get_default($strOrderBy, $model->order_by);
     // get collection
     $collection = AppModel::FindAll($strClass, $extend, $mxdWhere, $strOrderBy, $intLimit, $intOffset);
     // associate label
     $output = array();
     foreach ($collection as $key => $object) {
         $output[$object->{$strIndexBy}] = $object;
     }
     return $output;
 }