/**
 * Updates a product in the CMS.
 * @param  integer $id    Product ID
 * @param  array   $ritem Product data
 * @param  array   $auth  Permissions array
 * @return boolean        TRUE on success, FALSE on error
 */
function cot_market_update($id, &$ritem, $auth = array())
{
    global $cache, $cfg, $db, $db_market, $db_structure, $structure, $L;
    if (cot_error_found()) {
        return false;
    }
    if (count($auth) == 0) {
        $auth = cot_market_auth($ritem['item_cat']);
    }
    if (!empty($ritem['item_alias'])) {
        $prd_count = $db->query("SELECT COUNT(*) FROM {$db_market} WHERE item_alias = ? AND item_id != ?", array($ritem['item_alias'], $id))->fetchColumn();
        if ($prd_count > 0) {
            $ritem['item_alias'] = $ritem['item_alias'] . rand(1000, 9999);
        }
    }
    $item = $db->query("SELECT * FROM {$db_market} WHERE item_id = ?", $id)->fetch();
    if (!$cfg['market']['preview']) {
        $ritem['item_state'] = !$cfg['market']['prevalidate'] || $auth['isadmin'] ? 0 : 2;
    } else {
        $ritem['item_state'] = 1;
    }
    if (!$db->update($db_market, $ritem, 'item_id = ?', $id)) {
        return false;
    }
    cot_market_sync($item['item_cat']);
    cot_market_sync($ritem['item_cat']);
    cot_extrafield_movefiles();
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.update.done') as $pl) {
        include $pl;
    }
    /* ===== */
    return true;
}
Example #2
0
    }
    $db->update($db_market, $ritem, 'item_id = ?', $id);
    cot_market_sync($item['item_cat']);
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.public') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_redirect($r_url);
    exit;
}
if ($a == 'hide') {
    $ritem = array();
    $ritem['item_state'] = 1;
    $db->update($db_market, $ritem, 'item_id = ?', $id);
    cot_market_sync($item['item_cat']);
    $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $id) : array('c' => $item['item_cat'], 'al' => $item['item_alias']);
    $r_url = cot_url('market', $urlparams, '', true);
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.hide') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_redirect($r_url);
    exit;
}
$out['subtitle'] = $L['market_edit_product_title'];
$out['head'] .= $R['code_noindex'];
$sys['sublocation'] = $structure['market'][$item['item_cat']]['title'];
$mskin = cot_tplfile(array('market', 'edit', $structure['market'][$item['item_cat']]['tpl']));
/* === Hook === */