[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/companies/ -> do_company_aed.php (source)

   1  <?php /* $Id: do_company_aed.php 102 2008-03-18 19:52:59Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/companies/do_company_aed.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $del = w2PgetParam($_POST, 'del', 0);
   7  $obj = new CCompany();
   8  $msg = '';
   9  
  10  $isNotNew = $_POST['company_id'];
  11  $company_id = intval(w2PgetParam($_POST, 'company_id', 0));
  12  $perms = &$AppUI->acl();
  13  if ($del) {
  14      if (!$perms->checkModuleItem('companies', 'delete', $company_id)) {
  15          $AppUI->redirect('m=public&a=access_denied');
  16      }
  17  } elseif ($isNotNew) {
  18      if (!$perms->checkModuleItem('companies', 'edit', $company_id)) {
  19          $AppUI->redirect('m=public&a=access_denied');
  20      }
  21  } else {
  22      if (!$perms->checkModule('companies', 'add')) {
  23          $AppUI->redirect('m=public&a=access_denied');
  24      }
  25  }
  26  
  27  if (!$obj->bind($_POST)) {
  28      $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
  29      $AppUI->redirect();
  30  }
  31  
  32  require_once ($AppUI->getSystemClass('CustomFields'));
  33  
  34  // prepare (and translate) the module name ready for the suffix
  35  $AppUI->setMsg('Company');
  36  if ($del) {
  37      if (!$obj->canDelete($msg)) {
  38          $AppUI->setMsg($msg, UI_MSG_ERROR);
  39          $AppUI->redirect();
  40      }
  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=companies');
  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->company_id, 'edit');
  53          $custom_fields->bind($_POST);
  54          $sql = $custom_fields->store($obj->company_id); // Store Custom Fields
  55          $AppUI->setMsg($_POST['company_id'] ? 'updated' : 'added', UI_MSG_OK, true);
  56      }
  57      $AppUI->redirect();
  58  }
  59  ?>


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