Beispiel #1
0
function move_contact_to_group($contact_id, $group_id, $uid)
{
    if (!is_numeric($contact_id) || !is_numeric($group_id)) {
        return false;
    }
    $contact = get_contact_by_id($contact_id);
    if ($contact == null || $contact['uid'] != $uid) {
        return false;
    }
    if ($group_id != $contact['group_id'] && $group_id != 0) {
        $group = get_group_by_id($group_id);
        if ($group == null || $group['uid'] != $uid) {
            return false;
        }
    }
    $sql = 'UPDATE `contact` SET `group_id` = ? WHERE `contact_id` = ?';
    $params = array($group_id, $contact_id);
    $affected_rows = (new MysqlPDO())->execute($sql, $params);
    return $affected_rows == 1;
}
Beispiel #2
0
 $arrObj = array();
 switch ($method) {
     case 'get_all_account':
         $resp = get_all_account($param1, $pgIndex, $recordPerPage);
         break;
     case 'get_account_by_id':
         $resp = get_account_by_id($param1);
         break;
     case 'get_all_contact':
         $resp = get_all_contact($param1, $param2, $param3, $pgIndex, $recordPerPage);
         break;
     case 'get_contact_by_account':
         $resp = get_contact_by_account($param1, $param2, $param3, $pgIndex, $recordPerPage);
         break;
     case 'get_contact_by_id':
         $resp = get_contact_by_id($param1);
         break;
     case 'get_person_by_account':
         $resp = get_person_by_account($param1, $param2, $param3);
         break;
     case 'get_all_supplier':
         $resp = get_all_suppliers($param1, $pgIndex, $recordPerPage);
         break;
     case 'get_supplier_by_id':
         $resp = get_supplier_by_id($param1);
         break;
     case 'get_contact_by_supplier_id':
         $resp = get_contact_by_supplier_id($param1, $param2, $param3, $pgIndex, $recordPerPage);
         break;
     case 'get_supplier_contact_by_id':
         $resp = get_supplier_contact_by_id($param1);
Beispiel #3
0
function update_contact($id_contact, $new_value)
{
    if (!$id_contact) {
        lcm_panic("update_contact: no id_contact was provided");
    }
    $old_info = get_contact_by_id($id_contact);
    $kw = get_kwg_from_id($old_info['type_contact']);
    $type_contact = $kw['name'];
    $validator_file = 'contact';
    $validator_func = 'LcmCustomValidateContact';
    // This way, we can validate 'phone_home' or 'phone_mobile' using validate_contact_phone.php
    if (preg_match("/^\\+?([A-Za-z0-9]+)_/", $type_contact, $regs)) {
        $validator_file .= '_' . $regs[1];
        $validator_func .= ucfirst($regs[1]);
        lcm_debug("*********** MATCHES: " . $type_contact . ":" . $validator_file);
    }
    if (include_validator_exists($validator_file)) {
        include_validator($validator_file);
        $foo = new $validator_func();
        if ($err = $foo->validate($old_info['type_person'], $old_info['id_of_person'], $type_contact, $new_value)) {
            return $err;
        }
    }
    if ($old_info['value'] != $new_value) {
        $query = "UPDATE lcm_contact\n\t\t\tSET value = '" . clean_input($new_value) . "', \n\t\t\t\tdate_update = NOW()\n\t\t\t\t\tWHERE id_contact = " . intval($id_contact);
        lcm_query($query);
    }
    return '';
}
Beispiel #4
0
                        $update_endpoint[$parameter] = $vars['contact_endpoint_' . $parameter];
                    }
                }
                $update_endpoint = json_encode($update_endpoint);
                if ($update_endpoint != $contact['contact_endpoint']) {
                    //r($update_endpoint);
                    //r($contact['contact_endpoint']);
                    $update_state['contact_endpoint'] = $update_endpoint;
                }
                $rows_updated = dbUpdate($update_state, 'alert_contacts', 'contact_id = ?', array($vars['contact_id']));
                break;
        }
    }
}
include $config['html_dir'] . '/includes/contacts-navbar.inc.php';
if ($contact = get_contact_by_id($vars['contact_id'])) {
    ?>

<div class="row">
  <div class="col-sm-6">
<?php 
    foreach (json_decode($contact['contact_endpoint']) as $field => $value) {
        $contact['endpoint_parameters'][$field] = $value;
    }
    $data = $config['alerts']['transports'][$contact['contact_method']];
    if (!count($data['parameters']['global'])) {
        $data['parameters']['global'] = array();
    }
    // Temporary until we separate "global" out.
    // Plan: add defaults for transport types to global settings, which we use by default, then be able to override the settings via this GUI
    // This needs supporting code in the transport to check for set variable and if not, use the global default