[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/contacts/ -> do_contact_aed.php (source)

   1  <?php /* $Id: do_contact_aed.php 137 2008-04-04 16:12:02Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/contacts/do_contact_aed.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $obj = new CContact();
   7  $msg = '';
   8  
   9  $isNotNew = $_POST['contact_id'];
  10  $perms = &$AppUI->acl();
  11  if ($del) {
  12      if (!$perms->checkModule('contacts', 'delete')) {
  13          $AppUI->redirect('m=public&a=access_denied');
  14      }
  15  } elseif ($isNotNew) {
  16      if (!$perms->checkModule('contacts', 'edit')) {
  17          $AppUI->redirect('m=public&a=access_denied');
  18      }
  19  } else {
  20      if (!$perms->checkModule('contacts', 'add')) {
  21          $AppUI->redirect('m=public&a=access_denied');
  22      }
  23  }
  24  
  25  $notifyasked = w2PgetParam($_POST, 'contact_updateask', 0);
  26  if ($notifyasked != 0) {
  27      $notifyasked = 1;
  28  }
  29  
  30  if (!$obj->bind($_POST)) {
  31      $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
  32      $AppUI->redirect();
  33  }
  34  
  35  require_once ($AppUI->getSystemClass('CustomFields'));
  36  $del = w2PgetParam($_POST, 'del', 0);
  37  
  38  // prepare (and translate) the module name ready for the suffix
  39  $AppUI->setMsg('Contact');
  40  if ($del) {
  41      if (($msg = $obj->delete())) {
  42          $AppUI->setMsg($msg, UI_MSG_ERROR);
  43          $AppUI->redirect();
  44      } else {
  45          $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
  46          $AppUI->redirect('m=contacts');
  47      }
  48  } else {
  49      if (($msg = $obj->store())) {
  50          $AppUI->setMsg($msg, UI_MSG_ERROR);
  51      } else {
  52          $custom_fields = new CustomFields($m, 'addedit', $obj->contact_id, 'edit');
  53          $custom_fields->bind($_POST);
  54          $sql = $custom_fields->store($obj->contact_id); // Store Custom Fields
  55  
  56          $updatekey = $obj->getUpdateKey();
  57          if ($notifyasked && !$updatekey) {
  58              $rnow = new CDate();
  59              $obj->contact_updatekey = MD5($rnow->format(FMT_DATEISO));
  60              $obj->contact_updateasked = $rnow->format(FMT_DATETIME_MYSQL);
  61              $obj->contact_lastupdate = '';
  62              $obj->updateNotify();
  63              //            } elseif (!$notifyasked && $obj->contact_updatekey) {
  64          } elseif ($notifyasked && $updatekey) {
  65          } else {
  66              $obj->contact_updatekey = '';
  67          }
  68          $obj->store();
  69  
  70          $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true);
  71      }
  72      $AppUI->redirect();
  73  }
  74  ?>


Generated: Wed Jan 7 03:00:01 2009 Cross-referenced by PHPXref 0.7