navigation['users'] = array('title'=>_('Users'), 'url'=>"users/view"); }*/ function getItemTypes() { $item_types = array( array("type" => "multipleChoice", "name" => _("Multiple Choice")), array("type" => "multipleResponse", "name" => _("Multiple Response")), ); return $item_types; } function getUserItems($order='modified') { $user_id = get_logged_in_user()->getId(); $res = query_rows("SELECT * FROM ". DB_PREFIX . "base_item WHERE creator=". $user_id ." AND locked=false ORDER BY {$order} DESC"); return $res; } function getItems($order='modified', $limit=20, $offset=0) { $query = "SELECT * FROM ". DB_PREFIX . "base_item"; $query .= $this->getWhereQuery(); $query .= " ORDER BY {$order} DESC"; if ($limit != "all") { $query .= " LIMIT {$limit} OFFSET {$offset}"; } $res = query_rows($query); return $res; } function getFinishedItems($order='modified', $limit=20, $offset=0) { $query = "SELECT * FROM ". DB_PREFIX . "base_item"; $query .= $this->getWhereQuery() . " AND status='final'"; $query .= " ORDER BY {$order} DESC"; if ($limit != "all") { $query .= " LIMIT {$limit} OFFSET {$offset}"; } $res = query_rows($query); return $res; } function getSearchWord() { if (isset($_SESSION["item"]["searchword"])) { return $_SESSION["item"]["searchword"]; } return ""; } function getSearchLanguage() { if (isset($_SESSION["item"]["searchlanguage"])) { return $_SESSION["item"]["searchlanguage"]; } return ""; } function getSearchDifficulty() { if (isset($_SESSION["item"]["searchdifficulty"])) { return $_SESSION["item"]["searchdifficulty"]; } return ""; } function getSearchCategory() { if (isset($_SESSION["item"]["searchcategory"])) { return $_SESSION["item"]["searchcategory"]; } return ""; } function getItemsPerPage() { if (isset($_SESSION["item"]["itemsperpage"])) { return $_SESSION["item"]["itemsperpage"]; } return 20; } function getWhereQuery() { global $TeKe; $query = " WHERE"; $query .= " locked=false"; if ($this->getSearchWord()) { $query .= " AND title LIKE '%". $this->getSearchWord() ."%'"; } if ($this->getSearchLanguage()) { $query .= " AND language LIKE '%". $this->getSearchLanguage() ."%'"; } if ($this->getSearchDifficulty()) { $query .= " AND difficulty LIKE '%". $this->getSearchDifficulty() ."%'"; } if ($this->getSearchCategory()) { $query .= " AND category='". $this->getSearchCategory() ."'"; } if (!$TeKe->is_admin()) { $user_id = get_logged_in_user()->getId(); $query .= " AND (security='public' OR (security='private' AND creator=${user_id}))"; } return $query; } function getPageCount($limit=20) { $limit = $this->getItemsPerPage(); if ($limit == "all") { return 1; } $query = "SELECT * FROM ". DB_PREFIX ."base_item"; $query .= $this->getWhereQuery(); $total_count = mysql_num_rows(query($query)); $last_page = ceil($total_count/$limit); return $last_page; } function getFinishedItemsPageCount($limit=20) { $limit = $this->getItemsPerPage(); if ($limit == "all") { return 1; } $query = "SELECT * FROM ". DB_PREFIX ."base_item"; $query .= $this->getWhereQuery() . " AND status='final'"; $total_count = mysql_num_rows(query($query)); $last_page = ceil($total_count/$limit); return $last_page; } } ?>