Exemple #1
0
 * @package Contact
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('contact', 'plug');
$a = cot_import('a', 'G', 'TXT');
$id = (int) cot_import('id', 'G', 'INT');
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg['maxrowsperpage']);
$rtext = cot_import('rtext', 'P', 'TXT');
if ($a == 'del') {
    $sql_contact_delete = $db->query("SELECT * FROM {$db_contact} WHERE contact_id={$id} LIMIT 1");
    if ($row_contact_delete = $sql_contact_delete->fetch()) {
        $db->delete($db_contact, "contact_id = {$id}");
        foreach ($cot_extrafields[$db_contact] as $exfld) {
            cot_extrafield_unlinkfiles($row_contact_delete['contact_' . $exfld['field_name']], $exfld);
        }
        cot_message('Deleted');
    }
} elseif ($a == 'val') {
    $db->update($db_contact, array('contact_val' => 1), "contact_id = {$id}");
    cot_message('Updated');
} elseif ($a == 'unval') {
    $db->update($db_contact, array('contact_val' => 0), "contact_id = {$id}");
    cot_message('Updated');
} elseif ($a == 'send' && $rtext != '') {
    $row = $db->query("SELECT contact_email FROM {$db_contact} WHERE contact_id = {$id}")->fetch();
    cot_mail($row['contact_email'], $cfg['mainurl'], $rtext);
    $db->update($db_contact, array('contact_reply' => $rtext), "contact_id = {$id}");
    cot_message('Done');
}
Exemple #2
0
             $sql = $db->update($db_users, array('user_maingrp' => 4), "user_id='" . $row['user_id'] . "' AND user_lostpass='******'");
             $sql = $db->update($db_groups_users, array('gru_groupid' => 4), "gru_groupid=2 AND gru_userid='" . $row['user_id'] . "'");
             /* === Hook for the plugins === */
             foreach (cot_getextplugins('users.register.validate.done') as $pl) {
                 include $pl;
             }
             /* ===== */
             cot_auth_clear($row['user_id']);
             if (!empty($token) && $token == $row['user_token'] && $sys['now'] < $row['user_regdate'] + 172800) {
                 cot_redirect(cot_url('login', 'a=check&v=' . $v . '&token=' . $token, '', true));
             } else {
                 cot_redirect(cot_url('message', 'msg=106', '', true));
             }
         } elseif ($y == 0) {
             foreach ($cot_extrafields[$db_users] as $exfld) {
                 cot_extrafield_unlinkfiles($row['user_' . $exfld['field_name']], $exfld);
             }
             $sql = $db->delete($db_users, "user_id=" . (int) $row['user_id']);
             $sql = $db->delete($db_groups_users, "gru_userid='" . $row['user_id'] . "'");
             /* === Hook for the plugins === */
             foreach (cot_getextplugins('users.register.validate.rejected') as $pl) {
                 include $pl;
             }
             /* ===== */
             cot_redirect(cot_url('message', 'msg=109', '', true));
         }
     } elseif ($row['user_maingrp'] == -1) {
         $sql = $db->update($db_users, array('user_maingrp' => $row['user_sid']), "user_id='" . $row['user_id'] . "' AND user_lostpass='******'");
         cot_redirect(cot_url('message', 'msg=106', '', true));
     }
 } else {
/**
 * Removes a page from the CMS.
 * @param  int     $id    Page ID
 * @param  array   $rpage Page data
 * @return boolean        TRUE on success, FALSE on error
 */
function cot_page_delete($id, $rpage = array())
{
    global $db, $db_pages, $db_structure, $cache, $cfg, $cot_extrafields, $structure, $L;
    if (!is_numeric($id) || $id <= 0) {
        return false;
    }
    $id = (int) $id;
    if (count($rpage) == 0) {
        $rpage = $db->query("SELECT * FROM {$db_pages} WHERE page_id = ?", $id)->fetch();
        if (!$rpage) {
            return false;
        }
    }
    if ($rpage['page_state'] == 0) {
        $db->query("UPDATE {$db_structure} SET structure_count=structure_count-1 WHERE  structure_area='page' AND structure_code = ?", $rpage['page_cat']);
    }
    foreach ($cot_extrafields[$db_pages] as $exfld) {
        cot_extrafield_unlinkfiles($rpage['page_' . $exfld['field_name']], $exfld);
    }
    $db->delete($db_pages, "page_id = ?", $id);
    cot_log("Deleted page #" . $id, 'adm');
    /* === Hook === */
    foreach (cot_getextplugins('page.edit.delete.done') as $pl) {
        include $pl;
    }
    /* ===== */
    if ($cache) {
        if ($cfg['cache_page']) {
            $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$rpage['page_cat']]['path']));
        }
        if ($cfg['cache_index']) {
            $cache->page->clear('index');
        }
    }
    return true;
}
/**
 * Removes a product from the CMS.
 * @param  int     $id    Product ID
 * @param  array   $rpage Product data
 * @return boolean        TRUE on success, FALSE on error
 */
function cot_market_delete($id, $ritem = array())
{
    global $db, $db_market, $db_structure, $cache, $cfg, $cot_extrafields, $structure, $L;
    if (!is_numeric($id) || $id <= 0) {
        return false;
    }
    $id = (int) $id;
    if (count($ritem) == 0) {
        $ritem = $db->query("SELECT * FROM {$db_market} WHERE item_id = ?", $id)->fetch();
        if (!$ritem) {
            return false;
        }
    }
    foreach ($cot_extrafields[$db_market] as $exfld) {
        cot_extrafield_unlinkfiles($ritem['item_' . $exfld['field_name']], $exfld);
    }
    $db->delete($db_market, "item_id = ?", $id);
    cot_log("Deleted product #" . $id, 'adm');
    cot_market_sync($ritem['item_cat']);
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.delete.done') as $pl) {
        include $pl;
    }
    /* ===== */
    return true;
}
/**
 * Removes a project from the CMS.
 * @param  int     $id    Project ID
 * @param  array   $rpage Project data
 * @return boolean        TRUE on success, FALSE on error
 */
function cot_projects_delete($id, $ritem = array())
{
    global $db, $db_projects, $db_projects_offers, $db_projects_posts, $cot_extrafields;
    if (!is_numeric($id) || $id <= 0) {
        return false;
    }
    $id = (int) $id;
    if (count($ritem) == 0) {
        $ritem = $db->query("SELECT * FROM {$db_projects} WHERE item_id = ?", $id)->fetch();
        if (!$ritem) {
            return false;
        }
    }
    foreach ($cot_extrafields[$db_projects] as $exfld) {
        cot_extrafield_unlinkfiles($ritem['item_' . $exfld['field_name']], $exfld);
    }
    $db->delete($db_projects, "item_id = ?", $id);
    $db->delete($db_projects_offers, "offer_pid = ?", $id);
    $db->delete($db_projects_posts, "post_pid = ?", $id);
    cot_log("Deleted project #" . $id, 'adm');
    cot_projects_sync($ritem['item_cat']);
    /* === Hook === */
    foreach (cot_getextplugins('projects.edit.delete.done') as $pl) {
        include $pl;
    }
    /* ===== */
    return true;
}