public function do_validate()
 {
     parent::do_validate();
     $user = new _cms_user();
     $user->do_retrieve([], ['where_equals' => ['title' => $this->username, 'password' => md5($this->password)]]);
     if ($user->get_primary_key()) {
         $user->last_login = time();
         $user->last_login_ip = ip;
     } else {
         $this->validation_errors['username'] = '******';
     }
     return !count($this->validation_errors);
 }
Exemple #2
0
 /** Add user level management
  * ---CMS User
  * ---CMS User level
  * ---CMS User --> CMS Module
  * */
 public function patch_v4()
 {
     if (!db::table_exists('_cms_user')) {
         self::create_from_structure('_cms_user');
         table::reload_table_definitions();
         $user_level = new _cms_user_level();
         $user_level->title = 'User';
         $user_level->do_save();
         $user_level->ulid = 0;
         $user_level->title = 'Webmaster';
         $user_level->do_save();
         $user_level->ulid = 0;
         $user_level->title = 'Admin';
         $user_level->do_save();
         $cms_user = new _cms_user();
         $cms_user->title = 'admin';
         $cms_user->password = '******';
         $cms_user->ulid = 3;
         $cms_user->do_save();
         $_module = new _cms_module();
         $_module->do_retrieve([], ['where_equals' => ['table_name' => '_cms_module']]);
         $_field = new _cms_field();
         $_field->do_retrieve([], ['where_equals' => ['mid' => $_module->get_primary_key(), 'field_name' => 'user_level_view']]);
         static::modify_link_field($_field, '_cms_user_level', 'title');
         $_field = new _cms_field();
         $_field->do_retrieve([], ['where_equals' => ['mid' => $_module->get_primary_key(), 'field_name' => 'user_level_add']]);
         static::modify_link_field($_field, '_cms_user_level', 'title');
         $_field = new _cms_field();
         $_field->do_retrieve([], ['where_equals' => ['mid' => $_module->get_primary_key(), 'field_name' => 'user_level_delete']]);
         static::modify_link_field($_field, '_cms_user_level', 'title');
     }
 }