Exemple #1
0
function manage_review_s($option, $sorting)
{
    global $database, $mainframe, $mosConfig_list_limit;
    global $table_prefix;
    // for J 1.6
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0);
    $database->setQuery("SELECT count(*) FROM #__booklibrary_review;");
    $total = $database->loadResult();
    echo $database->getErrorMsg();
    $pageNav = new JPagination($total, $limitstart, $limit);
    // for J 1.6
    //********************   begin request for reviews manager   **********************/
    //if for sorting
    if (isset($_COOKIE['TestCookie']) and $_COOKIE['TestCookie'] == $sorting) {
        $sorting .= ' DESC';
        setcookie("TestCookie", $sorting, time() - 3600);
    } else {
        setcookie("TestCookie", $sorting, time() + 3600);
    }
    if ($sorting != "") {
        $request_string = "SELECT b.id as fk_bookid, a.id as review_id, b.isbn, b.title as title_book,\n                GROUP_CONCAT(c.title  SEPARATOR ', ') as title_catigory, a.title as title_review,\n                a.comment, e.user_name, a.date, a.rating, a.published" . "\nFROM\n\t\t{$table_prefix}booklibrary_review as a,\n\t\t{$table_prefix}booklibrary as b,\n\t\t{$table_prefix}booklibrary_main_categories as c,\n\t\t{$table_prefix}booklibrary_categories AS w,\n      (SELECT DISTINCT d.name as user_name, a.fk_userid\n\t  FROM {$table_prefix}booklibrary_review as a,\n\t  {$table_prefix}users as d\n\t  WHERE d.id = a.fk_userid" . "\nunion all" . "\nSELECT DISTINCT 'anonymous' as user_name, a.fk_userid\n\t\tFROM {$table_prefix}booklibrary_review as a\n\t\tWHERE a.fk_userid = 0) as e" . "\nWHERE a.fk_bookid = b.id AND b.id = w.bookid AND w.catid = c.id AND a.fk_userid = e.fk_userid\n      GROUP BY review_id\n      ORDER by {$sorting}" . "\nLIMIT {$pageNav->limitstart},{$pageNav->limit};";
    } else {
        $request_string = "\n\t\t\tSELECT\n\t\t\t\tb.id AS fk_bookid, a.id AS review_id, b.isbn, b.title AS title_book,\n\t\t\t\tGROUP_CONCAT(c.title  SEPARATOR ', ') AS title_catigory,\n\t\t\t\ta.title AS title_review, a.comment, e.user_name, a.date, a.rating, a.published" . "\n FROM\n\t\t\t\t#__booklibrary_review AS a,\n\t\t\t\t#__booklibrary AS b,\n\t\t\t\t#__booklibrary_main_categories AS c,\n\t\t\t\t#__booklibrary_categories AS w,\n\t\t\t  ( SELECT DISTINCT d.name AS user_name, a.fk_userid\n\t\t\t\tFROM #__booklibrary_review AS a,\n\t\t\t\t\t #__users AS d\n\t\t\t\tWHERE d.id = a.fk_userid" . "\n UNION all \n" . "SELECT DISTINCT 'anonymous' AS user_name, a.fk_userid\n\t\t\t\tFROM #__booklibrary_review AS a\n\t\t\t\tWHERE a.fk_userid = 0) AS e" . "\n WHERE a.fk_bookid = b.id\n\t\t\tAND b.id = w.bookid AND w.catid = c.id AND a.fk_userid = e.fk_userid\n\n\t\t\tGROUP BY review_id\n\t\t\tORDER by date" . "\n LIMIT {$pageNav->limitstart},{$pageNav->limit};";
    }
    $database->setQuery($request_string);
    $reviews = $database->loadObjectList();
    //**************   end request for reviews manager   ***************************/
    HTML_booklibrary::showManageReviews($option, $pageNav, $reviews);
}