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; }
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(); }
public function listusers() { $db = new CodeKBDatabase(); $db->dosql("SELECT id, " . "name " . "FROM users " . "ORDER BY name"); return $db->all(); }