/**
  * Verifies whether the post token was set, else dies with error
  * 
  * @return boolean
  */
 public function verifyRequest()
 {
     $checkPost = RequestMethods::issetpost(self::$_tokenname) && $this->isValidToken(RequestMethods::post(self::$_tokenname));
     $checkGet = RequestMethods::issetget(self::$_tokenname) && $this->isValidToken(RequestMethods::get(self::$_tokenname));
     $this->refreshToken();
     if ($checkGet || $checkPost) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * @before _secured, _admin
  */
 public function load()
 {
     $this->willRenderActionView = false;
     $this->willRenderLayoutView = false;
     $page = (int) RequestMethods::post('page', 0);
     $search = RequestMethods::issetpost('sSearch') ? RequestMethods::post('sSearch') : '';
     if ($search != '') {
         $whereCond = "nw.created='?' OR nw.expirationDate='?' " . "OR nw.author LIKE '%%?%%' OR nw.title LIKE '%%?%%'";
         $query = App_Model_News::getQuery(array('nw.id', 'nw.author', 'nw.title', 'nw.expirationDate', 'nw.active', 'nw.created'))->wheresql($whereCond, $search, $search, $search, $search);
         if (RequestMethods::issetpost('iSortCol_0')) {
             $dir = RequestMethods::issetpost('sSortDir_0') ? RequestMethods::post('sSortDir_0') : 'asc';
             $column = RequestMethods::post('iSortCol_0');
             if ($column == 0) {
                 $query->order('nw.id', $dir);
             } elseif ($column == 2) {
                 $query->order('nw.title', $dir);
             } elseif ($column == 3) {
                 $query->order('nw.author', $dir);
             } elseif ($column == 4) {
                 $query->order('nw.expirationDate', $dir);
             } elseif ($column == 5) {
                 $query->order('nw.created', $dir);
             }
         } else {
             $query->order('nw.id', 'desc');
         }
         $limit = (int) RequestMethods::post('iDisplayLength');
         $query->limit($limit, $page + 1);
         $news = App_Model_News::initialize($query);
         $countQuery = App_Model_News::getQuery(array('nw.id'))->wheresql($whereCond, $search, $search, $search, $search);
         $newsCount = App_Model_News::initialize($countQuery);
         unset($countQuery);
         $count = count($newsCount);
         unset($newsCount);
     } else {
         $query = App_Model_News::getQuery(array('nw.id', 'nw.author', 'nw.title', 'nw.expirationDate', 'nw.active', 'nw.created'));
         if (RequestMethods::issetpost('iSortCol_0')) {
             $dir = RequestMethods::issetpost('sSortDir_0') ? RequestMethods::post('sSortDir_0') : 'asc';
             $column = RequestMethods::post('iSortCol_0');
             if ($column == 0) {
                 $query->order('nw.id', $dir);
             } elseif ($column == 2) {
                 $query->order('nw.title', $dir);
             } elseif ($column == 3) {
                 $query->order('nw.author', $dir);
             } elseif ($column == 4) {
                 $query->order('nw.expirationDate', $dir);
             } elseif ($column == 5) {
                 $query->order('nw.created', $dir);
             }
         } else {
             $query->order('nw.id', 'desc');
         }
         $limit = (int) RequestMethods::post('iDisplayLength');
         $query->limit($limit, $page + 1);
         $news = App_Model_News::initialize($query);
         $count = App_Model_News::count();
     }
     $draw = $page + 1 + time();
     $str = '{ "draw": ' . $draw . ', "recordsTotal": ' . $count . ', "recordsFiltered": ' . $count . ', "data": [';
     $returnArr = array();
     if ($news !== null) {
         foreach ($news as $_news) {
             if ($_news->active) {
                 $label = "<span class='labelProduct labelProductGreen'>Aktivní</span>";
             } else {
                 $label = "<span class='labelProduct labelProductRed'>Neaktivní</span>";
             }
             $arr = array();
             $arr[] = "[ \"" . $_news->getId() . "\"";
             $arr[] = "\"" . $_news->getTitle() . "\"";
             $arr[] = "\"" . $_news->getAuthor() . "\"";
             $arr[] = "\"" . $_news->getExpirationDate() . "\"";
             $arr[] = "\"" . $_news->getCreated() . "\"";
             $arr[] = "\"" . $label . "\"";
             $tempStr = "\"<a href='/admin/news/edit/" . $_news->id . "' class='btn btn3 btn_pencil' title='Upravit'></a>";
             if ($this->isAdmin()) {
                 $tempStr .= "<a href='/admin/news/delete/" . $_news->id . "' class='btn btn3 btn_trash ajaxDelete' title='Smazat'></a>";
             }
             $arr[] = $tempStr . "\"]";
             $returnArr[] = join(',', $arr);
         }
         $str .= join(',', $returnArr) . "]}";
         echo $str;
     } else {
         $str .= "[ \"\",\"\",\"\",\"\",\"\",\"\",\"\"]]}";
         echo $str;
     }
 }