[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/system/ -> do_custom_field_aed.php (source)

   1  <?php /* $Id: do_custom_field_aed.php 40 2008-02-11 12:11:44Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/do_custom_field_aed.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $perms = &$AppUI->acl();
   7  if (!$perms->checkModule('system', 'edit')) {
   8      $AppUI->redirect('m=public&a=access_denied');
   9  }
  10  
  11  /*
  12  *    do_custom_field_aed.php
  13  *
  14  */
  15  require_once ($AppUI->getSystemClass('CustomFields'));
  16  
  17  $edit_field_id = w2PgetParam($_POST, 'field_id', null);
  18  
  19  if ($edit_field_id != null) {
  20      $edit_module = w2PgetParam($_POST, 'module', null);
  21      $field_name = w2PgetParam($_POST, 'field_name', null);
  22      $field_description = db_escape(strip_tags(w2PgetParam($_POST, 'field_description', null)));
  23      $field_htmltype = w2PgetParam($_POST, 'field_htmltype', null);
  24      $field_datatype = w2PgetParam($_POST, 'field_datatype', 'alpha');
  25      $field_published = w2PGetParam($_POST, 'field_published', 0);
  26      $field_order = w2PGetParam($_POST, 'field_order', 0);
  27      $field_extratags = db_escape(w2PgetParam($_POST, 'field_extratags', null));
  28  
  29      $list_select_items = w2PgetParam($_POST, 'select_items', null);
  30  
  31      $custom_fields = new CustomFields(strtolower($edit_module), 'addedit', null, null);
  32  
  33      if ($edit_field_id == 0) {
  34          $fid = $custom_fields->add($field_name, $field_description, $field_htmltype, $field_datatype, $field_extratags, $field_order, $field_published, $msg);
  35      } else {
  36          $fid = $custom_fields->update($edit_field_id, $field_name, $field_description, $field_htmltype, $field_datatype, $field_extratags, $field_order, $field_published, $msg);
  37      }
  38  
  39      // Add or Update a Custom Field
  40      if ($msg) {
  41          $AppUI->setMsg($AppUI->_('Error adding custom field:') . $msg, UI_MSG_ALERT, true);
  42      } else {
  43          if ($field_htmltype == 'select') {
  44              $opts = new CustomOptionList($fid);
  45              $opts->setOptions($list_select_items);
  46  
  47              if ($edit_field_id == 0) {
  48                  $o_msg = $opts->store();
  49              } else {
  50                  // To update each list would be a lot more complex than rewriting it
  51                  // So it is, but it is needed in order for it to work properly. (Pedro A. Bug 1163)
  52                  $o_msg = $opts->store();
  53              }
  54  
  55              if ($o_msg) {
  56                  // Select List Failed - Delete CustomField also
  57              }
  58  
  59          }
  60          $AppUI->setMsg($AppUI->_('Custom field added successfully'), UI_MSG_OK, true);
  61      }
  62  }
  63  ?>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7