if (!$perms->checkModule('system', 'edit')) { $AppUI->redirect('m=public&a=access_denied'); } /* * do_custom_field_aed.php * */ $edit_field_id = w2PgetParam($_POST, 'field_id', null); if ($edit_field_id != null) { $edit_module = w2PgetParam($_POST, 'module', null); $field_name = w2PgetParam($_POST, 'field_name', null); $field_description = db_escape(strip_tags(w2PgetParam($_POST, 'field_description', null))); $field_htmltype = w2PgetParam($_POST, 'field_htmltype', null); $field_datatype = w2PgetParam($_POST, 'field_datatype', 'alpha'); $field_published = w2PGetParam($_POST, 'field_published', 0); $field_order = w2PGetParam($_POST, 'field_order', 0); $field_extratags = db_escape(w2PgetParam($_POST, 'field_extratags', null)); $list_select_items = w2PgetParam($_POST, 'select_items', null); $custom_fields = new CustomFields(strtolower($edit_module), 'addedit', null, null); if ($edit_field_id == 0) { $fid = $custom_fields->add($field_name, $field_description, $field_htmltype, $field_datatype, $field_extratags, $field_order, $field_published, $msg); } else { $fid = $custom_fields->update($edit_field_id, $field_name, $field_description, $field_htmltype, $field_datatype, $field_extratags, $field_order, $field_published, $msg); } // Add or Update a Custom Field if ($msg) { $AppUI->setMsg($AppUI->_('Error adding custom field:') . $msg, UI_MSG_ALERT, true); } else { if ($field_htmltype == 'select') { $opts = new CustomOptionList($fid); $opts->setOptions($list_select_items);
} /* * Custom Field Editor (NEW) * */ // check permissions $perms =& $AppUI->acl(); if (!$perms->checkModule('system', 'edit')) { $AppUI->redirect('m=public&a=access_denied'); } $AppUI->savePlace(); $yesno = w2PgetSysVal('GlobalYesNo'); $html_types = array('textinput' => $AppUI->_('Text Input'), 'textarea' => $AppUI->_('Text Area'), 'checkbox' => $AppUI->_('Checkbox'), 'select' => $AppUI->_('Select List'), 'label' => $AppUI->_('Label'), 'separator' => $AppUI->_('Separator'), 'href' => $AppUI->_('Weblink')); $titleBlock = new CTitleBlock('Custom field editor', 'customfields.png', 'admin', 'admin.custom_field_editor'); $titleBlock->addCrumb('?m=system', 'system admin'); $edit_field_id = w2PGetParam($_POST, 'field_id', null); $titleBlock->show(); $q = new DBQuery(); $q->addTable('modules'); $q->addOrder('mod_ui_order'); $q->addWhere('mod_name IN (\'Companies\', \'Projects\', \'Tasks\', \'Calendar\', \'Contacts\')'); $modules = $q->loadList(); $q->clear(); $s = '<table width="100%" class="std" cellpadding="2">'; foreach ($modules as $module) { $s .= '<tr valign="bottom"><td colspan="4">'; $s .= '<h3><span title="' . $AppUI->_('Add Custom Field') . '::' . $AppUI->_('Click this icon to Add a new Custom Field to this Module.') . '"><a href="?m=system&a=custom_field_addedit&module=' . $module['mod_name'] . '"><img src="' . w2PfindImage('icons/edit_add.png') . '" align="center" width="16" height="16" border="0"></a></span>'; $s .= $AppUI->_($module['mod_name']) . '</h3>'; $s .= '</td></tr>'; $q = new DBQuery(); $q->addTable('custom_fields_struct');
$select_items = $select_options->getOptions(); } } else { //No such field exists with this ID $AppUI->setMsg('Couldnt load the Custom Field, It might have been deleted somehow.'); $AppUI->redirect(); } $edit_title = $AppUI->_('Edit Custom Field In'); } else { $edit_title = $AppUI->_('New Custom Field In'); $field_name = w2PgetParam($_POST, 'field_name', null); $field_description = w2PgetParam($_POST, 'field_description', null); $field_htmltype = w2PgetParam($_POST, 'field_htmltype', 'textinput'); $field_extratags = w2PgetParam($_POST, 'field_extratags', null); $field_order = w2PgetParam($_POST, 'field_order', null); $field_published = w2PGetParam($_POST, 'field_published', 0); } $html_types = array('textinput' => $AppUI->_('Text Input'), 'textarea' => $AppUI->_('Text Area'), 'checkbox' => $AppUI->_('Checkbox'), 'select' => $AppUI->_('Select List'), 'label' => $AppUI->_('Label'), 'separator' => $AppUI->_('Separator'), 'href' => $AppUI->_('Weblink')); $visible_state = array(); foreach ($html_types as $k => $ht) { if ($k == $field_htmltype) { $visible_state['div_' . $k] = 'display : block'; } else { $visible_state['div_' . $k] = 'display : none'; } } ?> <script> function hideAll() { var selobj = document.getElementById('htmltype'); for (i = 0, i_cmp = selobj.options.length; i < i_cmp; i++) {