/** * making sure all variables ar mysql safe */ function load($id) { parent::load($id); if (function_exists('base64_unserialize')) { $this->submission = base64_unserialize($this->submission); } }
function base64_unserialize($str) { $ary = unserialize($str); if (is_array($ary)) { foreach ($ary as $k => $v) { if (is_array(unserialize($v))) { $ritorno[$k] = base64_unserialize($v); } else { $ritorno[$k] = base64_decode($v); } } } else { return false; } return $ritorno; }
/** * this is for the omnigrid table management * * @access public * @return boolean True on success */ function getPageList() { if ($page = bRequest::getVar("page", 0)) { $page = true; $page = intval(bRequest::getVar("page")); $perpage = intval(bRequest::getVar("perpage")); $n = ($page - 1) * $perpage; } //setting pagination query $limit = ""; if ($page) { $limit = " LIMIT {$n}, {$perpage}"; } // this variables Omnigrid will send only if serverSort option is true $sorton = bRequest::getVar("sorton", false); $sortby = bRequest::getVar("sortby"); //setting pagination query $where = ""; if ($sorton) { $where = " ORDER BY {$sorton} {$sortby} "; } //set the query $query = "SELECT * FROM " . $this->_tbl . $where . $limit; //set and run the query $this->_db->setQuery($query); $this->_db->query(); $results = $this->_db->loadAssocList(); foreach ($results as $key => $val) { $results[$key]['capabilities'] = base64_unserialize($val['capabilities']); $this->setCapabilities($results[$key]['capabilities']); $results[$key]['capabilities'] = $this->getCapabilities(); } //set the query $query = "SELECT * FROM " . $this->_tbl; //set and run the query $this->_db->setQuery($query); $this->_db->query(); $total = $this->_db->getNumRows(); // return the json results $return = array("page" => $page, "total" => $total, "data" => $results); echo json_encode($return); return; }