示例#1
0
 static function get_profile()
 {
     $profile = MObject::get('user', MAuth::user_id());
     if ($profile->get_id()) {
         return $profile;
     }
     return null;
 }
示例#2
0
 public function update()
 {
     if (!MAuth::user_id()) {
         return null;
     }
     $user = null;
     if ($this->id && MValidate::id($this->id)) {
         $user = ORM::for_table('users')->find_one($this->id);
     }
     if (!$user || !$this->setup_object($user, true)) {
         return null;
     }
     $user->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     if (MAuth::user_id()) {
         $user->modifiedby = MAuth::user_id();
     } else {
         $user->modifiedby = 1;
     }
     if ($user->save()) {
         mapi_report_message('User data sucessfully updated.', 'success');
     }
 }
示例#3
0
 public function update($report = true)
 {
     if (!MAuth::user_id()) {
         return null;
     }
     $page = null;
     if ($this->id && MValidate::id($this->id)) {
         $page = ORM::for_table('pages')->find_one(intval($this->id));
     }
     if (!$page || !$this->setup_object($page)) {
         return null;
     }
     $page->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     $page->modifiedby = MAuth::user_id();
     if ($page->save() && $report) {
         mapi_report_message('Sucessfully updated.', 'success');
     }
 }
 protected function update_record()
 {
     if (!$this->permission()) {
         return mapi_report('No permission to edit this content');
     }
     $record = null;
     if ($this->id && MValidate::id($this->id)) {
         $record = ORM::for_table('contents')->find_one($this->id);
     }
     if (!$record || !$this->setup_object($record)) {
         return null;
     }
     $record->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     $record->modifiedby = MAuth::user_id();
     return $record;
 }
示例#5
0
 private static function check_auth()
 {
     if (!sizeof($_COOKIE) > 0) {
         return null;
     }
     if (!isset($_COOKIE['mpmi_r'])) {
         return null;
     }
     if (!isset($_COOKIE['mpmi_t'])) {
         return null;
     }
     if (!isset($_COOKIE['mpmi_b'])) {
         return null;
     }
     $cookie_of_rand = MCrypt::decrypt($_COOKIE['mpmi_r']);
     $cookie_of_time = MCrypt::decrypt($_COOKIE['mpmi_t']);
     $cookie_of_browser = MCrypt::decrypt($_COOKIE['mpmi_b']);
     $rand_array = explode(' ', $cookie_of_rand);
     $user = new M_User($rand_array[0], true);
     if ($user) {
         if ($user->compare_lastlogin($cookie_of_rand, $cookie_of_time, $cookie_of_browser)) {
             self::$auth = true;
             self::$user = $user->get_username();
             self::$user_id = $user->get_id();
             self::$group_id = $user->get_group_id();
         }
     }
 }
示例#6
0
 public function update($report = true)
 {
     if (!$this->permission()) {
         return mapi_report('No permission to edit this category');
     }
     if (!MAuth::user_id()) {
         return null;
     }
     $category = null;
     if ($this->id && MValidate::id($this->id)) {
         $category = ORM::for_table('categories')->find_one(intval($this->id));
     }
     if (!$category || !$this->setup_object($category)) {
         return null;
     }
     $category->modified = date_format(new DateTime('now'), 'Y-m-d H:i:s');
     $category->modifiedby = MAuth::user_id();
     if ($category->save() && $report) {
         mapi_report_message('Your category was sucessfully updated.', 'success');
     }
 }