本文整理汇总了PHP中CRM_Core_Component::getComponents方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Component::getComponents方法的具体用法?PHP CRM_Core_Component::getComponents怎么用?PHP CRM_Core_Component::getComponents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Component
的用法示例。
在下文中一共展示了CRM_Core_Component::getComponents方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
public function buildQuickForm()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
$this->add('text', 'label', ts('Title'), array('size' => 40), true);
$this->add('text', 'value', ts('URL'), array('size' => 40), true);
$this->add('text', 'name', ts('Class'), array('size' => 40), true);
$element = $this->add('text', 'weight', ts('Weight'), array('size' => 4), true);
// $element->freeze( );
$this->add('text', 'description', ts('Description'), array('size' => 40), true);
$this->add('checkbox', 'is_active', ts('Enabled?'));
require_once 'CRM/Core/Component.php';
$this->_components = CRM_Core_Component::getComponents();
//unset the report component
unset($this->_components['CiviReport']);
$components = array();
foreach ($this->_components as $name => $object) {
$components[$object->componentID] = $object->info['translatedName'];
}
$this->add('select', 'component_id', ts('Component'), array('' => ts('Contact')) + $components);
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->addFormRule(array('CRM_Report_Form_Register', 'formRule'), $this);
}
示例2: _getComponentSelectValues
/**
* @return array
*/
private function _getComponentSelectValues()
{
$ret = array();
$this->_components = CRM_Core_Component::getComponents();
foreach ($this->_components as $name => $object) {
$ret[$name] = $object->info['translatedName'];
}
return $ret;
}
示例3: getComponentName
/**
* Function to get component name from given permission.
*
* @param string $permission
*
* return string $componentName the name of component.
* @static
*/
static function getComponentName($permission)
{
$componentName = NULL;
$permission = trim($permission);
if (empty($permission)) {
return $componentName;
}
static $allCompPermissions;
if (!is_array($allCompPermissions)) {
$components = CRM_Core_Component::getComponents();
foreach ($components as $name => $comp) {
$allCompPermissions[$name] = $comp->getPermissions();
}
}
if (is_array($allCompPermissions)) {
foreach ($allCompPermissions as $name => $permissions) {
if (in_array($permission, $permissions)) {
$componentName = $name;
break;
}
}
}
return $componentName;
}
示例4: setEnabledComponents
/**
* Set enabled components.
*
* @param array $enabledComponents
*/
public static function setEnabledComponents($enabledComponents)
{
$config = CRM_Core_Config::singleton();
$components = CRM_Core_Component::getComponents();
$enabledComponentIDs = array();
foreach ($enabledComponents as $name) {
$enabledComponentIDs[] = $components[$name]->componentID;
}
// fix the config object
$config->enableComponents = $enabledComponents;
$config->enableComponentIDs = $enabledComponentIDs;
// also force reset of component array
CRM_Core_Component::getEnabledComponents(TRUE);
// update DB
CRM_Core_BAO_Setting::setItem($enabledComponents, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components');
}
示例5: getComponentName
/**
* Get component name from given permission.
*
* @param string $permission
*
* @return null|string
* the name of component.
*/
public static function getComponentName($permission)
{
$componentName = NULL;
$permission = trim($permission);
if (empty($permission)) {
return $componentName;
}
static $allCompPermissions = array();
if (empty($allCompPermissions)) {
$components = CRM_Core_Component::getComponents();
foreach ($components as $name => $comp) {
//get all permissions of each components unconditionally
$allCompPermissions[$name] = $comp->getPermissions(TRUE);
}
}
if (is_array($allCompPermissions)) {
foreach ($allCompPermissions as $name => $permissions) {
if (array_key_exists($permission, $permissions)) {
$componentName = $name;
break;
}
}
}
return $componentName;
}
示例6: enableComponent
/**
* takes a componentName and enables it in the config
* Primarily used during unit testing
*
* @param string $componentName name of the component to be enabled, needs to be valid
*
* @return boolean - true if valid component name and enabling succeeds, else false
* @static
*/
static function enableComponent($componentName)
{
$config = CRM_Core_Config::singleton();
if (in_array($componentName, $config->enableComponents)) {
// component is already enabled
return TRUE;
}
$components = CRM_Core_Component::getComponents();
// return if component does not exist
if (!array_key_exists($componentName, $components)) {
return FALSE;
}
// get enabled-components from DB and add to the list
$enabledComponents = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
$enabledComponents[] = $componentName;
$enabledComponentIDs = array();
foreach ($enabledComponents as $name) {
$enabledComponentIDs[] = $components[$name]->componentID;
}
// fix the config object
$config->enableComponents = $enabledComponents;
$config->enableComponentIDs = $enabledComponentIDs;
// also force reset of component array
CRM_Core_Component::getEnabledComponents(TRUE);
// update DB
CRM_Core_BAO_Setting::setItem($enabledComponents, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components');
return TRUE;
}
示例7: disableComponent
/**
* Disable specified component.
*
* @param string $componentName
*
* @return bool
*/
public static function disableComponent($componentName)
{
$config = CRM_Core_Config::singleton();
if (!in_array($componentName, $config->enableComponents) || !array_key_exists($componentName, CRM_Core_Component::getComponents())) {
// Post-condition is satisfied.
return TRUE;
}
// get enabled-components from DB and add to the list
$enabledComponents = Civi::settings()->get('enable_components');
$enabledComponents = array_diff($enabledComponents, array($componentName));
self::setEnabledComponents($enabledComponents);
return TRUE;
}
示例8: enableComponent
/**
* takes a componentName and enables it in the config
* Primarily used during unit testing
*
* @param string $componentName name of the component to be enabled, needs to be valid
*
* @return boolean - true if valid component name and enabling succeeds, else false
* @static
*/
static function enableComponent($componentName)
{
$config = CRM_Core_Config::singleton();
if (in_array($componentName, $config->enableComponents)) {
// component is already enabled
return TRUE;
}
$components = CRM_Core_Component::getComponents();
// return if component does not exist
if (!array_key_exists($componentName, $components)) {
return FALSE;
}
// get config_backend value
$sql = "\nSELECT config_backend\nFROM civicrm_domain\nWHERE id = %1\n";
$params = array(1 => array(CRM_Core_Config::domainID(), 'Integer'));
$configBackend = CRM_Core_DAO::singleValueQuery($sql, $params);
if (!$configBackend) {
static $alreadyVisited = FALSE;
if ($alreadyVisited) {
CRM_Core_Error::fatal(ts('Returning early due to unexpected error - civicrm_domain.config_backend column value is NULL. Try visiting CiviCRM Home page.'));
}
$alreadyVisited = TRUE;
// try to recreate the config backend
$config = CRM_Core_Config::singleton(TRUE, TRUE);
return self::enableComponent($componentName);
}
$configBackend = unserialize($configBackend);
$configBackend['enableComponents'][] = $componentName;
$configBackend['enableComponentIDs'][] = $components[$componentName]->componentID;
// fix the config object
$config->enableComponents = $configBackend['enableComponents'];
$config->enableComponentIDs = $configBackend['enableComponentIDs'];
// also force reset of component array
CRM_Core_Component::getEnabledComponents(TRUE);
// check if component is already there, is so return
$configBackend = serialize($configBackend);
$sql = "\nUPDATE civicrm_domain\nSET config_backend = %2\nWHERE id = %1\n";
$params[2] = array($configBackend, 'String');
CRM_Core_DAO::executeQuery($sql, $params);
return TRUE;
}
示例9: array
static function &basicPermissions($all = false)
{
static $permissions = null;
if (!$permissions) {
$permissions = array('add contacts' => ts('add contacts'), 'view all contacts' => ts('view all contacts'), 'edit all contacts' => ts('edit all contacts'), 'delete contacts' => ts('delete contacts'), 'import contacts' => ts('import contacts'), 'edit groups' => ts('edit groups'), 'administer CiviCRM' => ts('administer CiviCRM'), 'access uploaded files' => ts('access uploaded files'), 'profile listings and forms' => ts('profile listings and forms'), 'profile listings' => ts('profile listings'), 'profile create' => ts('profile create'), 'profile edit' => ts('profile edit'), 'profile view' => ts('profile view'), 'access all custom data' => ts('access all custom data'), 'view all activities' => ts('view all activities'), 'delete activities' => ts('delete activities'), 'access CiviCRM' => ts('access CiviCRM'), 'access Contact Dashboard' => ts('access Contact Dashboard'), 'translate CiviCRM' => ts('translate CiviCRM'));
if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE) {
$permissions['administer Multiple Organizations'] = ts('administer Multiple Organizations');
}
$config = CRM_Core_Config::singleton();
require_once 'CRM/Core/Component.php';
if (!$all) {
$components = CRM_Core_Component::getEnabledComponents();
} else {
$components = CRM_Core_Component::getComponents();
}
foreach ($components as $comp) {
$perm = $comp->getPermissions();
if ($perm) {
sort($perm);
foreach ($perm as $p) {
$permissions[$p] = $p;
}
}
}
asort($permissions);
}
return $permissions;
}