Пример #1
0
if ($a == 'update') {
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.update.first') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_block($usr['isadmin'] || $usr['auth_write'] && $usr['id'] == $item['item_userid']);
    $ritem = cot_market_import('POST', $item, $usr);
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $rdelete = cot_import('rdelete', 'P', 'BOL');
    } else {
        $rdelete = cot_import('delete', 'G', 'BOL');
        cot_check_xg();
    }
    if ($rdelete) {
        cot_market_delete($id, $item);
        cot_redirect(cot_url('market', "c=" . $item['item_cat'], '', true));
    }
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.update.import') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_market_validate($ritem);
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.update.error') as $pl) {
        include $pl;
    }
    /* ===== */
    if (!cot_error_found()) {
        cot_market_update($id, $ritem, $usr);
    cot_mail($item['user_email'], $L['market_added_mail_subj'], $rbody);
    /* === Hook: Part 2 === */
    foreach ($extpl1 as $pl) {
        include $pl;
    }
    /* ===== */
    cot_redirect(cot_url('admin', 'm=market&p=default'));
}
if ($a == 'delete') {
    cot_market_delete($id);
}
if (count($prd_arr) > 0 && in_array($mass_act, array('delete', 'validate'))) {
    switch ($mass_act) {
        case 'delete':
            foreach ($prd_arr as $prd_id) {
                cot_market_delete($prd_id);
            }
            cot_redirect(cot_url('admin', 'm=market&p=default', '', true));
            break;
        case 'validate':
            foreach ($prd_arr as $prd_id) {
                /* === Hook: Part 1 === */
                foreach ($extpl as $pl) {
                    include $pl;
                }
                /* ===== */
                $sql = $db->query("SELECT * FROM {$db_market} AS m LEFT JOIN {$db_users} AS u ON u.user_id=m.item_userid WHERE item_id='{$prd_id}' LIMIT 1");
                cot_die($sql->rowCount() == 0);
                $item = $sql->fetch();
                $db->update($db_market, array('item_state' => 0), "item_id=?", array($prd_id));
                cot_market_sync($item['item_cat']);