Ejemplo n.º 1
0
 public function do_auth()
 {
     $email = $this->request->post('email');
     $password = $this->request->post('password');
     $remember = $this->request->post('remember');
     $return = $this->request->post('return') ? $this->request->post('return') : '/ariol-admin';
     Auth::instance()->login($email, $password, $remember);
     if (Auth::instance()->logged_in() && Auth::instance()->get_user()->roles == 1) {
         Json::response(array('status' => 1, 'return' => $return));
     } else {
         $this->do_logout();
         Json::response(array('status' => 2));
     }
 }
Ejemplo n.º 2
0
 public function action_get_grid_data()
 {
     $model = ORM::factory($this->_model);
     $this->template->unSortableFields = $model->getUnSortableSortableFields();
     $offset = Arr::get($_REQUEST, 'iDisplayStart');
     $limit = Arr::get($_REQUEST, 'iDisplayLength');
     $draw = intval(Arr::get($_REQUEST, 'sEcho'));
     $sorting = Arr::get($_REQUEST, 'sSortDir_0');
     $sortingColumn = $model->getColumnByNumber(arr::get($_REQUEST, 'iSortCol_0'));
     $model = $this->before_fetch($model);
     $clone = clone $model;
     if ($sorting && $sortingColumn) {
         $model = $model->order_by($sortingColumn, $sorting);
     } else {
         $model = $model->order_by('id', 'DESC');
     }
     $data = $model->offset($offset)->limit($limit)->find_all()->as_array();
     $json_data = array('aaData' => array(), 'sEcho' => $draw, 'iTotalRecords' => count($data), 'iTotalDisplayRecords' => $clone->count_all());
     foreach ($data as $index => $item) {
         $json_data['aaData'][$index][] = '<input name="ids[]" value="' . $item->id . '" type="checkbox" class="checkbox" />';
         foreach ($item->grid_fields() as $field => $attributes) {
             $json_data['aaData'][$index][] = $item->grid_value($field);
         }
     }
     Json::response($json_data);
 }