Exemplo n.º 1
0
function gnavi_update_desc($mode, $lid, $cid, $title, $submitter, $valid, $ext, $ext1, $ext2, $resx, $resy, $resx1, $resy1, $resx2, $resy2, $caption, $caption1, $caption2, $desc, $arrowhtml, $addinfo)
{
    global $xoopsDB, $gnavi_addposts;
    global $table_photos, $table_text, $table_cat, $mod_url, $isadmin;
    $myts =& GNaviTextSanitizer::getInstance();
    $caption = $ext == '' ? '' : $caption;
    $caption1 = $ext1 == '' ? '' : $caption1;
    $caption2 = $ext2 == '' ? '' : $caption2;
    $sql = "UPDATE {$table_photos} SET caption='" . addSlashes($caption) . "',caption1='" . addSlashes($caption1) . "',caption2='" . addSlashes($caption2) . "',ext='{$ext}',ext1='{$ext1}',ext2='{$ext2}',res_x={$resx},res_y={$resy},res_x1={$resx1},res_y1={$resy1},res_x2={$resx2},res_y2={$resy2} WHERE lid='{$lid}'";
    $xoopsDB->query($sql) or die("DB error: UPDATE text table");
    if ($mode == G_INSERT) {
        $sql = "INSERT INTO {$table_text} (lid, description,arrowhtml,addinfo) VALUES ({$lid},'" . addSlashes($desc) . "',{$arrowhtml},'" . addSlashes($addinfo) . "')";
        $xoopsDB->query($sql) or die("DB error: INSERT desc table");
        // Update User's Posts (Should be modified when need admission.)
        $user_handler =& xoops_gethandler('user');
        $submitter_obj =& $user_handler->get($submitter);
        if (is_object($submitter_obj)) {
            for ($i = 0; $i < $gnavi_addposts; $i++) {
                $submitter_obj->incrementPost();
            }
        }
    } else {
        // not admin can only touch photos status>0
        $whr_status = $isadmin ? '' : 'AND status>0';
        $sql = "UPDATE {$table_text} SET description='" . addSlashes($desc) . "',arrowhtml={$arrowhtml},addinfo='" . addSlashes($addinfo) . "' WHERE lid='{$lid}'";
        $xoopsDB->query($sql) or die("DB error: UPDATE text table");
    }
    // Trigger Notification if Change Or submit
    if ($valid == 1) {
        $notification_handler =& xoops_gethandler('notification');
        $tags = array();
        $tags['PHOTO_TITLE'] = $title;
        $tags['PHOTO_URI'] = $mod_url . "/index.php?lid=" . $lid;
        // Global Notification
        gnavi_trigger_event('global', 0, 'new_item', $tags);
        // Category Notification
        $rs = $xoopsDB->query("SELECT title FROM {$table_cat} WHERE cid={$cid}");
        list($cat_title) = $xoopsDB->fetchRow($rs);
        $tags['CATEGORY_TITLE'] = $cat_title;
        $tags['PHOTO_URI'] = $mod_url . "/index.php?lid=" . $lid . "&cid=" . $cid;
        gnavi_trigger_event('category', $cid, 'new_item', $tags);
    }
}
Exemplo n.º 2
0
        $whr .= "lid={$id} OR ";
    }
    $xoopsDB->query("UPDATE {$table_photos} SET status=1 WHERE {$whr} 0");
    // Trigger Notification
    $notification_handler =& xoops_gethandler('notification');
    $rs = $xoopsDB->query("SELECT l.lid,l.cid,l.submitter,l.title,c.title FROM {$table_photos} l LEFT JOIN {$table_cat} c ON l.cid=c.cid WHERE {$whr} 0");
    while (list($lid, $cid, $submitter, $title, $cat_title) = $xoopsDB->fetchRow($rs)) {
        $tags = array();
        $tags['PHOTO_TITLE'] = $title;
        $tags['PHOTO_URI'] = $mod_url . "/index.php?lid=" . $lid;
        // Global Notification
        gnavi_trigger_event('global', 0, 'new_item', $tags);
        // Category Notification
        $tags['CATEGORY_TITLE'] = $cat_title;
        $tags['PHOTO_URI'] = $mod_url . "/index.php?lid=" . $lid . "&cid=" . $cid;
        gnavi_trigger_event('category', $cid, 'new_item', $tags);
    }
    redirect_header('index.php?page=admission', 2, _MD_A_GNAVI_ADMITTING);
    exit;
} else {
    if (!empty($_POST['action']) && $_POST['action'] == 'delete' && isset($_POST['ids']) && is_array($_POST['ids'])) {
        // remove records
        // Ticket Check
        if (!$xoopsGTicket->check()) {
            redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors());
        }
        foreach ($_POST['ids'] as $lid) {
            gnavi_delete_photos("lid=" . intval($lid));
        }
        redirect_header("index.php?page=admission", 2, _MD_GNAV_SMT_DELETINGITEM);
        exit;