/** * Get the action links for this page. * * @return array * array of action links that we need to display for the browse screen */ public function &actionLinks() { if (!isset(self::$_actionLinks)) { self::$_actionLinks = array(CRM_Core_Action::UPDATE => array('name' => ts('Edit Field'), 'url' => 'civicrm/admin/custom/group/field/update', 'qs' => 'action=update&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Edit Custom Field')), CRM_Core_Action::BROWSE => array('name' => ts('Edit Multiple Choice Options'), 'url' => 'civicrm/admin/custom/group/field/option', 'qs' => 'reset=1&action=browse&gid=%%gid%%&fid=%%id%%', 'title' => ts('List Custom Options')), CRM_Core_Action::PREVIEW => array('name' => ts('Preview Field Display'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=preview&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Preview Custom Field')), CRM_Core_Action::DISABLE => array('name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Custom Field')), CRM_Core_Action::ENABLE => array('name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Custom Field')), CRM_Core_Action::EXPORT => array('name' => ts('Move'), 'url' => 'civicrm/admin/custom/group/field/move', 'class' => 'small-popup', 'qs' => 'reset=1&fid=%%id%%', 'title' => ts('Move Custom Field')), CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=delete&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Delete Custom Field'))); } return self::$_actionLinks; }
/** * Get the action links for this page. * * @param null * * @return array array of action links that we need to display for the browse screen * @access public */ function &actionLinks() { if (!isset(self::$_actionLinks)) { $deleteExtra = ts('Are you sure you want to delete this custom data field?'); self::$_actionLinks = array(CRM_Core_Action::UPDATE => array('name' => ts('Edit Field'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=update&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Edit Custom Field')), CRM_Core_Action::BROWSE => array('name' => ts('Edit Multiple Choice Options'), 'url' => 'civicrm/admin/custom/group/field/option', 'qs' => 'reset=1&action=browse&gid=%%gid%%&fid=%%id%%', 'title' => ts('List Custom Options')), CRM_Core_Action::PREVIEW => array('name' => ts('Preview Field Display'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=preview&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Preview Custom Field')), CRM_Core_Action::DISABLE => array('name' => ts('Disable'), 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Core_BAO_CustomField' . '\',\'' . 'enable-disable' . '\' );"', 'ref' => 'disable-action', 'title' => ts('Disable Custom Field')), CRM_Core_Action::ENABLE => array('name' => ts('Enable'), 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Core_BAO_CustomField' . '\',\'' . 'disable-enable' . '\' );"', 'ref' => 'enable-action', 'title' => ts('Enable Custom Field')), CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=delete&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Delete Custom Field'), 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"')); } return self::$_actionLinks; }
/** * Browse all custom group fields. * * @param null * * @return void * @access public */ function browse() { require_once 'CRM/Core/BAO/CustomField.php'; $customField = array(); $customFieldBAO =& new CRM_Core_BAO_CustomField(); // fkey is gid $customFieldBAO->custom_group_id = $this->_gid; $customFieldBAO->orderBy('weight, label'); $customFieldBAO->find(); while ($customFieldBAO->fetch()) { $customField[$customFieldBAO->id] = array(); CRM_Core_DAO::storeValues($customFieldBAO, $customField[$customFieldBAO->id]); $action = array_sum(array_keys($this->actionLinks())); if ($customFieldBAO->is_active) { $action -= CRM_CORE_ACTION_ENABLE; } else { $action -= CRM_CORE_ACTION_DISABLE; } // if Multi Select field is selected in custom field if ($customFieldBAO->data_type == 'String' || $customFieldBAO->data_type == 'Int' || $customFieldBAO->data_type == 'Float' || $customFieldBAO->data_type == 'Money') { if ($customFieldBAO->html_type == 'Text') { $action -= CRM_CORE_ACTION_BROWSE; } } switch ($customFieldBAO->data_type) { case "Memo": $action -= CRM_CORE_ACTION_BROWSE; break; case "Date": $action -= CRM_CORE_ACTION_BROWSE; break; case "Boolean": $action -= CRM_CORE_ACTION_BROWSE; break; case "StateProvince": $action -= CRM_CORE_ACTION_BROWSE; break; case "Country": $action -= CRM_CORE_ACTION_BROWSE; break; } $customFieldDataType = CRM_Core_BAO_CustomField::dataType(); $customField[$customFieldBAO->id]['data_type'] = $customFieldDataType[$customField[$customFieldBAO->id]['data_type']]; $customField[$customFieldBAO->id]['action'] = CRM_Core_Action::formLink(CRM_Custom_Page_Field::actionLinks(), $action, array('id' => $customFieldBAO->id, 'gid' => $this->_gid)); } $this->assign('customField', $customField); }