Пример #1
0
 function entrycan($what, &$entry, $cache = true)
 {
     // Do something for a bit more performance:
     // Cache the last request because we often query
     // just one entry per page
     static $lastentry;
     static $lastcat;
     if (is_null($entry)) {
         return false;
     }
     if (is_object($entry)) {
         $id = $entry->id();
     } else {
         $id = $entry;
     }
     if ($cache && $id == $lastentry) {
         $array = $lastcat;
     } else {
         $db = new CodeKBDatabase();
         $db->dosql("SELECT cat " . "FROM entry_cat " . "WHERE entry = {$db->number($id)}");
         $lastentry = $id;
         $array = $db->all();
         $lastcat = $array;
     }
     $succ = false;
     while (is_array($array) && ($val = array_pop($array))) {
         if ($this->can($what, $val['cat'], $cache)) {
             $succ = true;
             break;
         }
     }
     if ($succ) {
         return true;
     }
     return false;
 }
Пример #2
0
 public function listfiles($sort = null)
 {
     $db = new CodeKBDatabase();
     $db->dosql("SELECT id, " . "name, " . "fs_name, " . "size, " . "symbol, " . "highlight " . "FROM files " . "WHERE entry = {$db->number($this->_id)}" . "ORDER BY " . ($sort ? $db->string($sort) : "name"));
     return $db->all();
 }
Пример #3
0
 public function listusers()
 {
     $db = new CodeKBDatabase();
     $db->dosql("SELECT id, " . "name " . "FROM users " . "ORDER BY name");
     return $db->all();
 }