Example #1
0
function view_suggestion($option, $id)
{
    global $database;
    if (count($id) > 1) {
        echo "<script> alert('Please select one suggestion for view!!!'); window.history.go(-1); </script>\n";
    } else {
        $request_suggestions = "select b.email, d.*  from (SELECT a.id, a.title, a.comment, e.user_name, a.date, a.fk_userid\n        FROM #__booklibrary_suggestion AS a, (SELECT DISTINCT d.name AS user_name, a.fk_userid FROM #__booklibrary_suggestion AS a, #__users AS d WHERE d.id = a.fk_userid union all SELECT DISTINCT 'anonymous' AS user_name, a.fk_userid FROM #__booklibrary_suggestion AS a WHERE a.fk_userid = 0) as e" . "\n WHERE  a.fk_userid = e.fk_userid ORDER by date) as d left join #__users AS b on  d.fk_userid = b.id;";
        $database->setQuery($request_suggestions);
        $suggestions = $database->loadObjectList();
        $suggestion = "";
        //select one item suggestion
        for ($i = 0; $i < count($suggestions); $i++) {
            if ($suggestions[$i]->id == $id[0]) {
                $suggestion = $suggestions[$i];
            }
        }
        if ($suggestion != "") {
            HTML_booklibrary::showViewSuggestion($option, $suggestion);
        } else {
            mosRedirect('index.php?option=com_booklibrary&task=manage_suggestion');
        }
    }
    //end else
}