/* CONTACTS $Id: do_contact_aed.php 5872 2009-04-25 00:09:56Z merlinyoda $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$obj = new CContact();
$msg = '';
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
$del = dPgetParam($_POST, 'del', 0);
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Contact');
if ($del) {
    if ($msg = $obj->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg("deleted", UI_MSG_ALERT, true);
        $AppUI->redirect("m=contacts");
    }
} else {
    $isNotNew = @$_POST['contact_id'];
    if ($msg = $obj->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true);
    }
    $AppUI->redirect();
}
<?php

/* $Id: do_contact_aed.php 1940 2011-05-31 05:20:41Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/contacts/do_contact_aed.php $ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$del = (int) w2PgetParam($_POST, 'del', 0);
$obj = new CContact();
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
$action = $del ? 'deleted' : 'stored';
$result = $del ? $obj->delete($AppUI) : $obj->store($AppUI);
$redirect = $del ? 'm=contacts' : 'm=contacts&a=view&contact_id=' . $obj->contact_id;
if (is_array($result)) {
    $AppUI->setMsg($result, UI_MSG_ERROR, true);
    $AppUI->holdObject($obj);
    $AppUI->redirect('m=contacts&a=addedit');
}
if ($result) {
    $AppUI->setMsg('Contact ' . $action, UI_MSG_OK, true);
    if (!$del) {
        $updatekey = $obj->getUpdateKey();
        $notifyasked = w2PgetParam($_POST, 'contact_updateask', 0);
        if ($notifyasked && !$updatekey) {
            $rnow = new w2p_Utilities_Date();
            $obj->contact_updatekey = MD5($rnow->format(FMT_DATEISO));
            $obj->contact_updateasked = $rnow->format(FMT_DATETIME_MYSQL);
            $obj->contact_lastupdate = '';
            $obj->store($AppUI);
示例#3
0
 /**
  * Delete Request Handler
  *
  * This method is called when a request is a DELETE
  *
  * @return array
  */
 public function executeDelete()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     $contact_id = $this->getParam('contact_id', self::TYPE_INT);
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = '******';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $contact = new CContact();
     $contact->load($contact_id);
     if (!$contact->delete($AppUI)) {
         throw new Frapi_Error('PERMISSION_ERROR');
     }
     $this->data['success'] = true;
     return $this->toArray();
 }
示例#4
0
    if (!$perms->checkModule('contacts', 'add')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
}
$notifyasked = w2PgetParam($_POST, 'contact_updateask', 0);
if ($notifyasked != 0) {
    $notifyasked = 1;
}
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Contact');
if ($del) {
    if ($msg = $obj->delete($AppUI)) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
        $AppUI->redirect('m=contacts');
    }
} else {
    if ($result = $obj->store($AppUI)) {
        if (is_array($result)) {
            $AppUI->setMsg($result, UI_MSG_ERROR, true);
            $AppUI->holdObject($obj);
            $AppUI->redirect('m=contacts&a=addedit');
        }
    } else {
        $custom_fields = new CustomFields($m, 'addedit', $obj->contact_id, 'edit');