本文整理汇总了PHP中Paginator::getPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getPage方法的具体用法?PHP Paginator::getPage怎么用?PHP Paginator::getPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paginator
的用法示例。
在下文中一共展示了Paginator::getPage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run method with main page logic
*
* Read in list of albums and the latest photos for each album. Pagination enabled.
* Populate template with data and display results in the page.
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
$albumDAO = AlbumDAO::getInstance();
$photoDAO = PhotoDAO::getInstance();
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
if ($page < 1) {
$page = 1;
}
$count = $paginator = $paginator_page = null;
$album = $photo_info_array = null;
$title = "";
$count = $albumDAO->count();
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$album_array = $albumDAO->all(array("limit" => $paginator_page));
$photo_info_array = array();
foreach ($album_array as $album) {
$count = $photoDAO->countByAlbum($album);
if ($count > 0) {
$tmp_paginator = new Paginator($count, 1);
$tmp_paginator_page = $paginator->getPage($page);
// Only get latest item
list($latest_photo) = $photoDAO->allByAlbum($album, array("order" => "id DESC", "limit" => $tmp_paginator_page));
$photo_info_array[] = array($count, $latest_photo);
}
}
$this->template->render(array("title" => "Album List", "main_page" => "album_list_tpl.php", "session" => $session, "album_array" => $album_array, "photo_info_array" => $photo_info_array, "paginator_page" => $paginator_page));
}
示例2: run
/**
* Run method with main page logic
*
* Read in list of the latest published articles. Pagination enabled.
* Populate template and display results in the page.
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
/*
if ($user == null || !$user->validUser ()) {
header ("Location: " . BASE_URL);
return;
}
*/
$articleDAO = ArticleDAO::getInstance();
$tagDAO = ArticleTagDAO::getInstance();
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
if ($page < 1) {
$page = 1;
}
$count = $paginator = $paginator_page = null;
$article = $articletags_array = null;
$title = "";
$count = $articleDAO->countPublished(true);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$article_array = $articleDAO->allPublished(true, array("order" => "{$articleDAO->getTableName()}.postDate DESC, {$articleDAO->getTableName()}.id DESC", "limit" => $paginator_page, "joins" => true));
foreach ($article_array as $article) {
$articletags_array[] = $tagDAO->allArticleTags($article, array("order" => "name"));
}
$this->template->render(array("title" => "Latests Articles", "main_page" => "article_list_tpl.php", "session" => $session, "article_array" => $article_array, "articletags_array" => $articletags_array, "paginator_page" => $paginator_page));
}
示例3: getDataFromDb
public function getDataFromDb($pageNumber)
{
//new database connection
$db = new Database();
// $start = 0;
// $limit = 5;
//execute query
// $db->executeQuery("INSERT INTO cars(id,name,price) VALUES('9','maruti','5400')");
//$db->executeQuery("INSERT INTO test_table(name,email) VALUES('kumaran','kumaran@gmail.com')");
// $db->executeQuery("INSERT INTO fruits(name,color) VALUES('mango','orange')");
// $db->executeQuery("DELETE FROM fruits WHERE color='violet'");
$db->executeQuery("SELECT * FROM first_names");
// $db->executeQuery("DELETE FROM test_table WHERE name='gfdg' OR name='tty' ");
// $db->executeQuery("DELETE FROM test_table WHERE name='kumaran'");
//return result array
// $db->getAllRows(); // ok
$page = new Paginator($db->getAllRows(), 10);
//array , limit, pages count [optional. default is 10]
$rows = $page->getPage($pageNumber);
$this->navLinks = $page->pageCount();
return $rows;
// print_r ($db->getRows(1,3)); //ok
// print_r($db->getRowAt(1)); // ok
// print_r ($db->getRow()); // return first row
// print_r($db->affectedRows()); // ok
// print_r($db->count()); // ok
// print_r($db->lastInsertId()); //ok
/*
* to escape string
* $email="kumaran@gmail.com";
* $db->escapeString($email);
*/
}
示例4: run
/**
* Run method with main page logic
*
* Read in album information and photos associated with an album from the database.
* Populate template and display results in the page. Pagination possible
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
$albumDAO = AlbumDAO::getInstance();
$photoDAO = PhotoDAO::getInstance();
$album = $photo_array = $photo_count = $paginator_page = $queryVars = null;
$title = "";
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
if ($page < 1) {
$page = 1;
}
$id = isset($_GET["id"]) && is_numeric($_GET["id"]) ? intval($_GET["id"]) : 0;
if ($id <= 0) {
header("Location: " . BASE_URL);
return;
}
$album = $albumDAO->load($id, array("joins" => true));
if ($album) {
$title = $album->getTitle();
$count = $photoDAO->countByAlbum($album);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$photo_array = $photoDAO->allByAlbum($album, array("limit" => $paginator_page));
$queryVars = array("id" => $id);
}
$this->template->render(array("title" => "View Album - {$title}", "session" => $session, "album" => $album, "photo_array" => $photo_array, "paginator_page" => $paginator_page, "queryVars" => $queryVars, "main_page" => "view_album_tpl.php"));
}
示例5: run
/**
* Run method with main page logic
*
* Read in list of the latest published events and populate template with results.
* Display results in the page. Pagination enabled
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
$eventDAO = EventDAO::getInstance();
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
$platform_id = isset($_GET["platform"]) && is_numeric($_GET["platform"]) ? intval($_GET["platform"]) : 0;
if ($page < 1) {
$page = 1;
}
$count = $paginator = $paginator_page = $queryVars = $current_platform = null;
if ($platform_id <= 0) {
$count = $eventDAO->countStatus(Event::APPROVED_STATUS);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$event_array = $eventDAO->allByStatus(Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
} else {
$count = $eventDAO->countPlatformStatus($platform_id, Event::APPROVED_STATUS);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$event_array = $eventDAO->allByPlatformStatus($platform_id, Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
$queryVars = array("platform" => $platform_id);
}
$platformDAO = PlatformDAO::getInstance();
$platform_array = $platformDAO->all();
//print_r ($event_array);
if ($platform_id > 0) {
$current_platform = $platformDAO->load($platform_id);
}
$this->template->render(array("title" => "Event List", "main_page" => "event_list_tpl.php", "event_array" => $event_array, "session" => $session, "paginator_page" => $paginator_page, "sidebar_extra" => joinPath("fragments", "event_sidebar_tpl.php"), "platform_array" => $platform_array, "queryVars" => $queryVars, "current_platform" => $current_platform));
}
示例6: getPage
public function getPage()
{
$this->current_page = isset($_GET['page']) ? $_GET['page'] : 1;
$this->limit = isset($_GET['limit']) ? $_GET['limit'] : 5;
$page_nav = new Paginator($this->current_page, $this->limit);
$res = $page_nav->getPage();
$this->num_entries = $res['num_entries'];
return ['items' => $res['items'], 'page' => $this->current_page];
}
示例7: run
/**
* Run method with main page logic
*
* Populate template and read in list of users in the database. Allow filtering by online identity
* and by the first letter of a user name. Display list in the page.
* Available to members only
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
if (!$user || !$user->validUser()) {
$session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
header("Location: " . BASE_URL);
return;
}
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
if ($page < 1) {
$page = 1;
}
$userDAO = UserDAO::getInstance();
$user_array = $paginator_page = null;
$form_values = array("identity" => "", "startswith" => "");
$form_values["identity"] = $identity = isset($_GET["identity"]) ? trim($_GET["identity"]) : "";
$form_values["startswith"] = isset($_GET["startswith"]) ? trim($_GET["startswith"]) : "";
$identity_array = array("steam", "xbox", "psn", "wii");
$queryVars = array();
if ($identity) {
$found = false;
for ($i = 0; $i < count($identity_array) && !$found; $i++) {
if (strcmp($identity, $identity_array[$i]) == 0) {
$paginator = new Paginator($userDAO->countIdentity($identity), $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$user_array = $userDAO->allByIdentity($identity, array("limit" => $paginator_page, "order" => "userName ASC"));
$found = true;
}
}
$queryVars["identity"] = $form_values["identity"];
} else {
if (!empty($form_values["startswith"]) && preg_match("/^[a-z]/", $form_values["startswith"])) {
$paginator = new Paginator($userDAO->countLetter($form_values["startswith"]), $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$user_array = $userDAO->allByLetter($form_values["startswith"], array("limit" => $paginator_page, "order" => "userName ASC"));
$queryVars["startswith"] = $form_values["startswith"];
} else {
$paginator = new Paginator($userDAO->count(), $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$user_array = $userDAO->all(array("limit" => $paginator_page, "order" => "userName ASC"));
}
}
$this->template->render(array("title" => "View Userlist", "main_page" => "user_list_tpl.php", "user_array" => $user_array, "session" => $session, "paginator_page" => $paginator_page, "form_values" => $form_values, "queryVars" => $queryVars));
}
示例8: run
/**
* Run method with main page logic
*
* Read latest approved event data from database. Alter output header so
* client interprets sent text as RSS/XML. Send feed text
* to client
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 20;
$eventDAO = EventDAO::getInstance();
$platform = isset($_GET["platform"]) && is_numeric($_GET["platform"]) ? intval($_GET["platform"]) : 0;
$count = $paginator = $paginator_page = null;
// Platform choice was made. Retrieve only events with platform id
if ($platform <= 0) {
$count = $eventDAO->countStatus(Event::APPROVED_STATUS);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage(1);
$event_array = $eventDAO->allByStatus(Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
} else {
$count = $eventDAO->countPlatformStatus($platform, Event::APPROVED_STATUS);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage(1);
$event_array = $eventDAO->allByPlatformStatus($platform, Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
}
//print_r ($event_array);
// Alter header so client does not interpret output as HTML
header("Content-Type: text/xml");
$this->template->render(array("title" => "Latest Events Feed", "event_array" => $event_array, "paginator_page" => $paginator_page));
}
示例9: run
/**
* Run method with main page logic
*
* Read in events from the database. Populate template and display an interface to administer event data
* for allowing bulk deletion of events, deletion of a single
* event, links to editing and viewing each event entry.
* Available to admins only
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
// Check for admin user
if (!$user || !$user->isAdmin()) {
$session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
header("Location: " . BASE_URL);
return;
}
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
if ($page < 1) {
$page = 1;
}
$action = isset($_GET["action"]) ? trim($_GET["action"]) : "";
$eventDAO = EventDAO::getInstance();
$event_array = $paginator_page = null;
$content_title = "";
// Check for POST request and necessary variable for deletion
if (!empty($_POST) && !empty($_POST["ids"]) && !empty($_POST["action"]) && empty($_POST["domodstatus"])) {
$action = isset($_POST["action"]) ? trim($_POST["action"]) : "";
if (!strcmp($action, "delete") == 0) {
header("Location: " . BASE_URL);
return;
}
$status = $eventDAO->deleteByIds($_POST["ids"]);
if ($status) {
$session->setMessage("Selected events deleted");
header("Location: {$_SERVER["PHP_SELF"]}");
return;
} else {
$session->setMessage("Deletion failed", Session::MESSAGE_ERROR);
header("Location: {$_SERVER["PHP_SELF"]}");
return;
}
} else {
if (!empty($_GET) && !empty($_GET["ids"]) && !empty($_GET["domodstatus"])) {
$status = isset($_GET["status"]) ? trim($_GET["status"]) : "";
if (!empty($status)) {
$status = intval($status);
$tmp = new Event();
try {
$tmp->setStatus($status);
} catch (Exception $e) {
$session->setMessage("Invalid status choice");
header("Location: {$_SERVER["PHP_SELF"]}");
return;
}
}
$status = $eventDAO->saveStatusByIds($status, $_GET["ids"]);
if ($status) {
$session->setMessage("Selected events updated");
header("Location: {$_SERVER["PHP_SELF"]}");
return;
} else {
$session->setMessage("Update failed", Session::MESSAGE_ERROR);
header("Location: {$_SERVER["PHP_SELF"]}");
return;
}
} else {
if (strcmp($action, "delete") == 0 && !empty($_GET["ids"])) {
$content_title = "Delete Events";
$event_array = $eventDAO->allByIds($_GET["ids"]);
} else {
if (strcmp($action, "delete") == 0) {
} else {
$count = $eventDAO->count();
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$event_array = $eventDAO->all(array("limit" => $paginator_page, "joins" => true));
}
}
}
}
$this->template->render(array("title" => "Admin - Event Options", "main_page" => "event_options_tpl.php", "session" => $session, "event_array" => $event_array, "paginator_page" => $paginator_page, "action" => $action, "content_title" => $content_title));
}
示例10: testGetPage
/**
* @covers Hermes\Resource\Paginator::getPage
* @covers Hermes\Resource\Paginator::setPage
*/
public function testGetPage()
{
$this->assertSame($this->object, $this->object->setPage(15));
$this->assertSame(15, $this->object->getPage());
}
示例11: run
/**
* Run method with main page logic
*
* Read in albums from the database. Displays an interface to administer album data
* for allowing bulk deletion of albums, deletion of a single
* album and links to edit and view each album entry. Pagination enabled.
* Available to admins only
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
if (!$user || !$user->isAdmin()) {
$session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
header("Location: " . BASE_URL);
return;
}
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? $_GET["page"] : 1;
if ($page < 1) {
$page = 1;
}
$action = isset($_GET["action"]) ? trim($_GET["action"]) : "";
$albumDAO = AlbumDAO::getInstance();
$album_array = $paginator_page = null;
$content_title = "";
// Check for POST request and necessary data for deletion
if (!empty($_POST) && !empty($_POST["ids"]) && !empty($_POST["action"])) {
$action = isset($_POST["action"]) ? trim($_POST["action"]) : "";
if (!strcmp($action, "delete") == 0) {
header("Location: " . BASE_URL);
return;
}
$status = $albumDAO->deleteByIds($_POST["ids"]);
if ($status) {
$session->setMessage("Selected pages deleted");
header("Location: {$_SERVER["PHP_SELF"]}");
return;
} else {
$session->setMessage("Deletion failed", Session::MESSAGE_ERROR);
header("Location: {$_SERVER["PHP_SELF"]}");
return;
}
} else {
if (strcmp($action, "delete") == 0 && !empty($_GET["ids"])) {
$content_title = "Delete Album";
$album_array = $albumDAO->allByIds($_GET["ids"]);
} else {
if (strcmp($action, "delete") == 0) {
} else {
$count = $albumDAO->count();
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$album_array = $albumDAO->all(array("limit" => $paginator_page));
}
}
}
$this->template->render(array("title" => "Admin - Album Options", "main_page" => "album_options_tpl.php", "session" => $session, "album_array" => $album_array, "paginator_page" => $paginator_page, "action" => $action, "content_title" => $content_title));
}
示例12: run
/**
* Run method with main page logic
*
* Reads in events for a given day or current day if no parameters are passed.
* Allow filtering by platform id. Populate template and display event data on page.
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
$eventDAO = EventDAO::getInstance();
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
$platform_id = isset($_GET["platform"]) && is_numeric($_GET["platform"]) ? intval($_GET["platform"]) : 0;
$month = isset($_GET["month"]) && is_numeric($_GET["month"]) ? intval($_GET["month"]) : 0;
$day = isset($_GET["day"]) && is_numeric($_GET["day"]) ? intval($_GET["day"]) : 0;
$year = isset($_GET["year"]) && is_numeric($_GET["year"]) ? intval($_GET["year"]) : 0;
if ($page < 1) {
$page = 1;
}
$count = $paginator = $paginator_page = $event_array = $next_eventday = $prev_eventday = $queryVars = $current_platform = null;
if ($platform_id > 0 && checkdate($month, $day, $year)) {
$start = mktime(0, 0, 0, $month, $day, $year);
$end = strtotime("+1 day", $start) - 1;
$count = $eventDAO->countPlatformStatusAndRange($platform_id, Event::APPROVED_STATUS, $start, $end);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$event_array = $eventDAO->allByPlatformStatusAndRange($platform_id, Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
$queryVars = array("platform" => $platform_id);
} else {
if ($platform_id > 0) {
$start = mktime(0, 0, 0);
$end = strtotime("+1 day", $start) - 1;
$count = $eventDAO->countPlatformStatusAndRange($platform_id, Event::APPROVED_STATUS, $start, $end);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$event_array = $eventDAO->allByPlatformStatusAndRange($platform_id, Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
$queryVars = array("platform" => $platform_id);
} else {
if (checkdate($month, $day, $year)) {
$start = mktime(0, 0, 0, $month, $day, $year);
$end = strtotime("+1 day", $start) - 1;
$count = $eventDAO->countStatusAndRange(Event::APPROVED_STATUS, $start, $end);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$event_array = $eventDAO->allByStatusAndRange(Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
} else {
$start = mktime(0, 0, 0);
$end = strtotime("+1 day", $start) - 1;
$count = $eventDAO->countStatusAndRange(Event::APPROVED_STATUS, $start, $end);
$paginator = new Paginator($count, $PAGINATION_LIMIT);
$paginator_page = $paginator->getPage($page);
$event_array = $eventDAO->allByStatusAndRange(Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
}
}
}
$platformDAO = PlatformDAO::getInstance();
$platform_array = $platformDAO->all();
if ($platform_id > 0) {
$current_platform = $platformDAO->load($platform_id);
$next_eventday = $eventDAO->loadByNextDayPlatform($platform_id, $end, Event::APPROVED_STATUS);
$prev_eventday = $eventDAO->loadByPreviousDayPlatform($platform_id, $start, Event::APPROVED_STATUS);
} else {
$next_eventday = $eventDAO->loadByNextDay($end, Event::APPROVED_STATUS);
$prev_eventday = $eventDAO->loadByPreviousDay($start, Event::APPROVED_STATUS);
}
$this->template->render(array("title" => "Event List for day " . strftime(strftime("%B %d, %Y", $start)), "main_page" => "events_day_tpl.php", "event_array" => $event_array, "session" => $session, "paginator_page" => $paginator_page, "start" => $start, "end" => $end, "next_eventday" => $next_eventday, "prev_eventday" => $prev_eventday, "sidebar_extra" => joinPath("fragments", "event_sidebar_tpl.php"), "platform_array" => $platform_array, "queryVars" => $queryVars, "current_platform" => $current_platform));
}
示例13: run
/**
* Run method with main page logic
*
* Populate template and read in list of users in the database. Populate template and
* display an interface to administer user data for allowing bulk deletion of users, deletion of a single
* user, links to editing and viewing each user entry. Available to admins only
* Available to members only
* @access public
*/
public function run()
{
$PAGINATION_LIMIT = 10;
$session = Session::getInstance();
$user = $session->getUser();
if ($user == null || !$user->isAdmin()) {
$session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
header("Location: " . BASE_URL);
return;
}
$userDAO = UserDAO::getInstance();
$method = isset($_GET["users"]) ? trim($_GET["users"]) : "";
$page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
if ($page < 1) {
$page = 1;
}
$action = isset($_GET["action"]) ? trim($_GET["action"]) : "";
$page = is_numeric($page) ? $page : 1;
$paginator_page = $queryVars = null;
// POST request for bulk deletion of users
if (!empty($_POST) && !empty($_POST["userids"]) && !empty($_POST["action"]) && empty($_POST["domodstatus"])) {
$action = isset($_POST["action"]) ? trim($_POST["action"]) : "";
if (!strcmp($action, "delete") == 0) {
header("Location: " . BASE_URL);
return;
}
$status = $userDAO->deleteByIds($_POST["userids"]);
if ($status) {
$session->setMessage("Selected users deleted");
header("Location: {$_SERVER["PHP_SELF"]}?users=all");
return;
} else {
$session->setMessage("Deletion failed", Session::MESSAGE_ERROR);
header("Location: {$_SERVER["PHP_SELF"]}?users=all");
return;
}
} else {
if (!empty($_GET) && !empty($_GET["userids"]) && !empty($_GET["domodstatus"])) {
$status = isset($_GET["status"]) ? trim($_GET["status"]) : "";
if (!empty($status)) {
$status = intval($status);
$tmp = new User();
try {
$tmp->setUserType($status);
} catch (InvalidUserTypeException $e) {
$session->setMessage("Invalid status choice");
header("Location: {$_SERVER["PHP_SELF"]}?users=all");
return;
}
}
$status = $userDAO->saveStatusByIds($status, $_GET["userids"]);
if ($status) {
$session->setMessage("Selected users updated");
header("Location: {$_SERVER["PHP_SELF"]}?users=all");
return;
} else {
$session->setMessage("Update failed", Session::MESSAGE_ERROR);
header("Location: {$_SERVER["PHP_SELF"]}?users=all");
return;
}
} else {
if (strcmp($action, "delete") == 0 && !empty($_GET["userids"])) {
$content_title = "Delete Users";
$user_array = $userDAO->allByIds($_GET["userids"]);
} else {
if (strcmp($method, "all") == 0) {
$count = $userDAO->count();
$paginator = new Paginator($count, $PAGINATION_LIMIT);
if ($page < 0) {
$page = 1;
}
$paginator_page = $paginator->getPage($page);
$user_array = $userDAO->all(array("limit" => $paginator_page, "order" => "userName"));
$content_title = "All Users Options";
$queryVars = array("users" => "all");
} else {
$user_array = $userDAO->allPendingUsers();
$content_title = "Pending Users Options";
}
}
}
}
$this->template->render(array("title" => "Admin - User Options", "main_page" => "user_options_tpl.php", "user" => $user, "session" => $session, "user_array" => $user_array, "content_title" => $content_title, "paginator_page" => $paginator_page, "queryVars" => $queryVars, "action" => $action));
}