[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/ -> do_updatecontact.php (source)

   1  <?php /* $Id: do_updatecontact.php 102 2008-03-18 19:52:59Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/do_updatecontact.php $ */
   2  require_once  'base.php';
   3  require_once W2P_BASE_DIR . '/includes/config.php';
   4  
   5  if (!isset($GLOBALS['OS_WIN'])) {
   6      $GLOBALS['OS_WIN'] = (stristr(PHP_OS, "WIN") !== false);
   7  }
   8  
   9  // tweak for pathname consistence on windows machines

  10  require_once  W2P_BASE_DIR . '/includes/main_functions.php';
  11  require_once  W2P_BASE_DIR . '/includes/db_adodb.php';
  12  require_once  W2P_BASE_DIR . '/classes/query.class.php';
  13  require_once  W2P_BASE_DIR . '/classes/ui.class.php';
  14  $AppUI = new CAppUI();
  15  require_once  W2P_BASE_DIR . '/classes/date.class.php';
  16  require_once  W2P_BASE_DIR . '/modules/contacts/contacts.class.php';
  17  
  18  $obj = new CContact();
  19  $msg = '';
  20  
  21  $updatekey = w2PgetParam($_POST, 'updatekey', 0);
  22  $q = new DBQuery;
  23  $q->addTable('contacts');
  24  $q->addQuery('contact_id');
  25  $q->addWhere('contact_updatekey = \'' . $updatekey . '\'');
  26  $contactkey = $q->loadList();
  27  $q->clear();
  28  
  29  $contact_id = $contactkey[0]['contact_id'] ? $contactkey[0]['contact_id'] : 0;
  30  
  31  // check permissions for this record

  32  
  33  if (!$contact_id) {
  34      echo ($AppUI->_('You are not authorized to use this page. If you should be authorized please contact Bruce Bodger to give you another valid link, thank you.'));
  35      exit;
  36  }
  37  
  38  if (!$obj->bind($_POST)) {
  39      $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
  40      $AppUI->redirect();
  41  }
  42  require_once  W2P_BASE_DIR . '/classes/CustomFields.class.php';
  43  
  44  // prepare (and translate) the module name ready for the suffix

  45  $AppUI->setMsg('Contact');
  46  
  47  $isNotNew = $_POST['contact_id'];
  48  
  49  if (($msg = $obj->store())) {
  50      $AppUI->setMsg($msg, UI_MSG_ERROR);
  51      echo $AppUI->_('There was an error recording your contact data, please contact the system administrator. Thank you very much.');
  52  } else {
  53      $custom_fields = new CustomFields('contacts', 'addedit', $obj->contact_id, 'edit', 1);
  54      $custom_fields->bind($_POST);
  55      $sql = $custom_fields->store($obj->contact_id); // Store Custom Fields

  56  
  57      $rnow = new CDate();
  58      $obj->contact_updatekey = '';
  59      $obj->contact_lastupdate = $rnow->format(FMT_DATETIME_MYSQL);
  60      $obj->store();
  61  
  62      $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true);
  63      //            echo $AppUI->_('Your contact data has been recorded sucessfully. Thank you very much.');

  64      //            echo "<script>if(confirm('".$AppUI->_('Your contact data has  been recorded sucessfully. Thank you very much.')."')){self.close();} else {self.close();};</script>";

  65      echo ('Your contact data has been recorded successfully. Your may now close your browser window<br></br>Thank you very much, ' . $obj->contact_first_name);
  66  }
  67  ?>


Generated: Thu Aug 21 03:00:13 2008 Cross-referenced by PHPXref 0.7