function action(&$object, $action, &$values, &$links, $permission) { // do not expose action link for reverting to default if the template did not diverge or we just reverted it now if (!in_array($object->id, array_keys($this->_revertible)) or $this->_action & CRM_Core_Action::REVERT and $object->id == $this->_revertedId) { $action &= ~CRM_Core_Action::REVERT; $action &= ~CRM_Core_Action::VIEW; } // default workflow templates shouldn’t be deletable if ($object->workflow_id and $object->is_default) { $action &= ~CRM_Core_Action::DELETE; } // workflow templates shouldn’t have disable/enable actions (at least for CiviCRM 3.1) if ($object->workflow_id) { $action &= ~CRM_Core_Action::DISABLE; } parent::action($object, $action, $values, $links, $permission); // rebuild the action links HTML, as we need to handle %%orig_id%% for revertible templates // FIXME: the below somehow hides the Enable/Disable actions even for rows which should have them $values['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $object->id, 'orig_id' => $this->_revertible[$object->id])); }
/** * @param CRM_Core_DAO $object * @param int $action * @param array $values * @param array $links * @param string $permission * @param bool $forceAction */ function action(&$object, $action, &$values, &$links, $permission, $forceAction = FALSE) { if ($object->workflow_id) { // do not expose action link for reverting to default if the template did not diverge or we just reverted it now if (!in_array($object->id, array_keys($this->_revertible)) or $this->_action & CRM_Core_Action::REVERT and $object->id == $this->_revertedId) { $action &= ~CRM_Core_Action::REVERT; $action &= ~CRM_Core_Action::VIEW; } // default workflow templates shouldn’t be deletable // workflow templates shouldn’t have disable/enable actions (at least for CiviCRM 3.1) if ($object->workflow_id) { $action &= ~CRM_Core_Action::DISABLE; $action &= ~CRM_Core_Action::DELETE; } // rebuild the action links HTML, as we need to handle %%orig_id%% for revertible templates $values['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $object->id, 'orig_id' => CRM_Utils_Array::value($object->id, $this->_revertible)), ts('more'), FALSE, 'messageTemplate.manage.action', 'MessageTemplate', $object->id); } else { $action &= ~CRM_Core_Action::REVERT; $action &= ~CRM_Core_Action::VIEW; parent::action($object, $action, $values, $links, $permission); } }
/** * browse all entities. * * @param int $action * * @return void * @access public */ function browse($action = null) { $links =& $this->links(); if ($action == null) { $action = array_sum(array_keys($links)); } if ($action & CRM_CORE_ACTION_DISABLE) { $action -= CRM_CORE_ACTION_DISABLE; } if ($action & CRM_CORE_ACTION_ENABLE) { $action -= CRM_CORE_ACTION_ENABLE; } eval('$object =& new ' . $this->getBAOName() . '( );'); $values = array(); /* * lets make sure we get the stuff sorted by name if it exists */ $fields =& $object->fields(); $key = ''; if (CRM_Utils_Array::value('title', $fields)) { $key = 'title'; } else { if (CRM_Utils_Array::value('label', $fields)) { $key = 'label'; } else { if (CRM_Utils_Array::value('name', $fields)) { $key = 'name'; } } } if ($key) { $object->orderBy($key . ' asc'); } // set the domain_id parameter $config =& CRM_Core_Config::singleton(); $object->domain_id = $config->domainID(); // find all objects $object->find(); while ($object->fetch()) { $permission = CRM_CORE_PERMISSION_EDIT; if ($key) { $permission = $this->checkPermission($object->id, $object->{$key}); } if ($permission) { $values[$object->id] = array(); CRM_Core_DAO::storeValues($object, $values[$object->id]); CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]); // populate action links CRM_Core_Page_Basic::action($object, $action, $values[$object->id], $links, $permission); } } $this->assign('rows', $values); }