:::
7-5 根據不同身份顯示不同內容
- 目前活動列表的顯示是山選出有啟動,且截止日期還沒到的活動。
- 但是,這樣有一個缺點,就是已經被關閉的,或者已經超過截止日的,那麼管理員永遠管理不到!(因為不會出現)
- 如何解決?當然可以在後台列出所有未篩選活動,不過,這樣又要多做一些東西!所以,最簡單的方式就是,針對不同身份來顯示不同內容。
//顯示活動列表 function list_action() { global $xoopsDB, $xoopsTpl, $isAdmin; $tbl = $xoopsDB->prefix('actions'); $where = $isAdmin ? '' : "WHERE `enable` ='1' AND `end_date` > now() "; $sql = "SELECT * FROM `{$tbl}` $where ORDER BY `end_date` DESC"; $result = $xoopsDB->query($sql) or web_error($sql); $myts = MyTextSanitizer::getInstance(); while ($action = $xoopsDB->fetchArray($result)) { $action['title'] = $myts->htmlSpecialChars($action['title']); $action['content'] = $myts->displayTarea($action['content'], 1, 1, 1, 1, 0); $actions[] = $action; } $xoopsTpl->assign('actions', $actions); include_once XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php"; $sweet_alert = new sweet_alert(); $sweet_alert->render("delete_action", "admin/main.php?op=delete_action&action_id=", 'action_id'); }
7-4 加入刪除功能