:::

3-2-1 加入刪除功能

您沒有觀看影片的權限

您沒有觀看影片的權限

請先登入,登入後,確認您的權限後,即可觀看影片。

  1. 先修改 templates\op_tad_signup_actions_show.tpl,加入刪除活動的按鈕
    <{if $smarty.session.tad_signup_adm}>
        <div class="bar">
            <a href="index.php?op=tad_signup_actions_destroy&id=<{$id}>" class="btn btn-danger">
                <i class="fa fa-times" aria-hidden="true"></i> 刪除活動
            </a>
            <a href="index.php?op=tad_signup_actions_edit&id=<{$id}>" class="btn btn-warning">
                <i class="fa fa-pencil" aria-hidden="true"></i> 編輯活動
            </a>
        </div>
    <{/if}>

     

  2. 按下時, index.php 中的 switch() 必須有下面這段:
    //刪除資料
    case 'tad_signup_actions_destroy':
        Tad_signup_actions::destroy($id);
        // header("location: {$_SERVER['PHP_SELF']}");
        redirect_header($_SERVER['PHP_SELF'], 3, "成功刪除活動!");
        exit;
    

     

  3. 編輯 class/Tad_signup_actions.php 中的 Tad_signup_actions 類別,編輯 destroy() 方法
    //刪除某筆資料資料
    public static function destroy($id = '')
    {
        global $xoopsDB;
    
        if (!$_SESSION['tad_signup_adm']) {
            redirect_header($_SERVER['PHP_SELF'], 3, "您沒有權限使用此功能");
        }
    
        if (empty($id)) {
            return;
        }
    
        $sql = "delete from `" . $xoopsDB->prefix("tad_signup_actions") . "`
        where `id` = '{$id}'";
        $xoopsDB->queryF($sql) or Utility::web_error($sql, __FILE__, __LINE__);
    }

link to https://github.com/tadlearn/tad_signup/commit/c9610fc78474a25d2dbc3b1f7fe6264d595b5b96 \


:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D48%26tbdsn%3D1616

書籍目錄

展開 | 闔起

線上使用者

22人線上 (4人在瀏覽線上書籍)

會員: 0

訪客: 22

更多…