Example #1
0
 public function delete($args)
 {
     $users_id = get($args, 'users_id');
     if ($users_id) {
         if ($user = DBTable::get('users')->loadRow($users_id)) {
             DBTable::deleteRow($user);
             return data::success($user->export());
         }
         return data::error('invalid user id');
     }
     return data::error('user id required');
 }
Example #2
0
 public function create($args)
 {
     //load data into the currnt scope - $data is always extracted into the current scope so no need to worry about undefined
     extract(extractable(array('data'), $args));
     //for a single value you would probably realistically use
     //$data = get($args,'data');
     if ($data) {
         file_put_contents(self::$example_file, $data);
         return data::success(array('file' => self::$example_file, 'data' => $data));
     }
     return data::error("data required");
 }
Example #3
0
 public function logout($args)
 {
     extract(extractable(array('users_id', 'key'), $args));
     $users_id = intval($users_id);
     if ($users_id) {
         if ($session = DBTable::get('session')->loadRowsWhere(array('key' => $key))) {
             $session = $session[0];
             $session->logged_in = 0;
             $session->save();
             return data::success($session->export());
         }
         return data::error('unable to locate session');
     }
     return data::error('user_id required');
 }