/** * Builds server data using a specified ID, Hash, and Root Administrator Status. * * @param string $hash The server hash. * @return mixed Returns an array on success or false on failure. */ private function _buildData($hash) { $query = ORM::forTable('servers')->where(array('hash' => $hash, 'active' => 1)); if (!User::isAdmin()) { $query->where_in('id', Permissions::listServers()); } $this->server = $query->findOne(); if (!$this->server) { $this->found_server = false; $this->found_node = false; return; } else { $this->found_server = true; } $this->node = ORM::forTable('nodes')->where(array('id' => $this->server->node))->findOne(); $this->found_node = !$this->node ? false : true; }
/** * Returns true or false depending on if the user has a specified permission. * * @return bool */ public function has($permission) { if (User::getData('id') == $this->server->owner_id || User::getData('root_admin') == 1) { return true; } return in_array($permission, $this->permission_list); }