X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBlock.php;h=569f0552129c9759cef64f2ea8b89bb476b469ca;hb=c503dcf3dc4ec114585dcaa8ffdfdbaab9609da7;hp=b59591ced2a57ac779b31238dcd95402d64c55df;hpb=397d0aec7771968e6ad649229f9a72c9c0e9b12c;p=civicrm-core.git diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index b59591ced2..569f055212 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -41,7 +41,7 @@ class CRM_Core_Block { /** - * The following blocks are supported + * The following blocks are supported. * * @var int */ @@ -55,15 +55,15 @@ class CRM_Core_Block { FULLTEXT_SEARCH = 7; /** - * Template file names for the above blocks + * Template file names for the above blocks. */ static $_properties = NULL; /** - * Class constructor - * + * Class constructor. */ - public function __construct() {} + public function __construct() { + } /** * Initialises the $_properties array @@ -182,10 +182,13 @@ class CRM_Core_Block { /** * Returns the desired property from the $_properties array * - * @param int $id one of the class constants (ADD, SEARCH, etc.) - * @param string $property the desired property + * @param int $id + * One of the class constants (ADD, SEARCH, etc.). + * @param string $property + * The desired property. * - * @return string the value of the desired property + * @return string + * the value of the desired property */ public static function getProperty($id, $property) { if (!(self::$_properties)) { @@ -197,9 +200,12 @@ class CRM_Core_Block { /** * Sets the desired property in the $_properties array * - * @param int $id one of the class constants (ADD, SEARCH, etc.) - * @param string $property the desired property - * @param string $value the value of the desired property + * @param int $id + * One of the class constants (ADD, SEARCH, etc.). + * @param string $property + * The desired property. + * @param string $value + * The value of the desired property. * * @return void */ @@ -213,7 +219,8 @@ class CRM_Core_Block { /** * Returns the whole $_properties array * - * @return array the $_properties array + * @return array + * the $_properties array */ public static function properties() { if (!(self::$_properties)) { @@ -223,7 +230,7 @@ class CRM_Core_Block { } /** - * Creates the info block for drupal + * Creates the info block for drupal. * * @return array */ @@ -233,7 +240,9 @@ class CRM_Core_Block { foreach (self::properties() as $id => $value) { if ($value['active']) { if (in_array($id, array( - self::ADD, self::CREATE_NEW))) { + self::ADD, + self::CREATE_NEW, + ))) { $hasAccess = TRUE; if (!CRM_Core_Permission::check('add contacts') && !CRM_Core_Permission::check('edit groups') @@ -260,7 +269,6 @@ class CRM_Core_Block { $block[$id] = array( 'info' => $value['info'], 'cache' => $value['cache'], - 'status' => $value['active'], 'region' => $value['region'], 'visibility' => $value['visibility'], 'pages' => $value['pages'], @@ -296,7 +304,8 @@ class CRM_Core_Block { case self::ADD: $defaultLocation = CRM_Core_BAO_LocationType::getDefault(); $defaultPrimaryLocationId = $defaultLocation->id; - $values = array('postURL' => CRM_Utils_System::url('civicrm/contact/add', 'reset=1&ct=Individual'), + $values = array( + 'postURL' => CRM_Utils_System::url('civicrm/contact/add', 'reset=1&ct=Individual'), 'primaryLocationType' => $defaultPrimaryLocationId, ); @@ -310,16 +319,18 @@ class CRM_Core_Block { ); break; - case self::LANGSWITCH: + case self::LANGSWITCH: // gives the currentPath without trailing empty lcMessages to be completed $values = array('queryString' => CRM_Utils_System::getLinksUrl('lcMessages', TRUE, FALSE, FALSE)); self::setProperty(self::LANGSWITCH, 'templateValues', $values); break; + case self::FULLTEXT_SEARCH: $urlArray = array( 'fullTextSearchID' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'CRM_Contact_Form_Search_Custom_FullText', 'value', 'name' - )); + ), + ); self::setProperty(self::FULLTEXT_SEARCH, 'templateValues', $urlArray); break; @@ -335,7 +346,7 @@ class CRM_Core_Block { } /** - * Create the list of options to create New objects for the application and format is as a block + * Create the list of options to create New objects for the application and format is as a block. * * @return void */ @@ -358,7 +369,8 @@ class CRM_Core_Block { 'query' => 'action=add&reset=1&context=standalone', 'ref' => 'new-activity', 'title' => ts('Activity'), - ))); + ), + )); $components = CRM_Core_Component::getEnabledComponents(); @@ -375,28 +387,34 @@ class CRM_Core_Block { // new email (select recipients) $shortCuts = array_merge($shortCuts, array( - array('path' => 'civicrm/activity/email/add', - 'query' => 'atype=3&action=add&reset=1&context=standalone', - 'ref' => 'new-email', - 'title' => ts('Email'), - ))); + array( + 'path' => 'civicrm/activity/email/add', + 'query' => 'atype=3&action=add&reset=1&context=standalone', + 'ref' => 'new-email', + 'title' => ts('Email'), + ), + )); if (CRM_Core_Permission::check('edit groups')) { $shortCuts = array_merge($shortCuts, array( - array('path' => 'civicrm/group/add', - 'query' => 'reset=1', - 'ref' => 'new-group', - 'title' => ts('Group'), - ))); + array( + 'path' => 'civicrm/group/add', + 'query' => 'reset=1', + 'ref' => 'new-group', + 'title' => ts('Group'), + ), + )); } if (CRM_Core_Permission::check('administer CiviCRM')) { $shortCuts = array_merge($shortCuts, array( - array('path' => 'civicrm/admin/tag', - 'query' => 'reset=1&action=add', - 'ref' => 'new-tag', - 'title' => ts('Tag'), - ))); + array( + 'path' => 'civicrm/admin/tag', + 'query' => 'reset=1&action=add', + 'ref' => 'new-tag', + 'title' => ts('Tag'), + ), + )); } if (empty($shortCuts)) { @@ -441,7 +459,7 @@ class CRM_Core_Block { $value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE); } $value['title'] = $short['title']; - $value['ref'] = $short['ref']; + $value['ref'] = $short['ref']; if (!empty($short['shortCuts'])) { foreach ($short['shortCuts'] as $shortCut) { $value['shortCuts'][] = self::setShortcutValues($shortCut); @@ -451,7 +469,7 @@ class CRM_Core_Block { } /** - * Create the list of dashboard links + * Create the list of dashboard links. * * @return void */ @@ -459,10 +477,12 @@ class CRM_Core_Block { static $dashboardLinks = array(); if (CRM_Core_Permission::check('access Contact Dashboard')) { $dashboardLinks = array( - array('path' => 'civicrm/user', + array( + 'path' => 'civicrm/user', 'query' => 'reset=1', 'title' => ts('My Contact Dashboard'), - )); + ), + ); } if (empty($dashboardLinks)) { @@ -479,14 +499,14 @@ class CRM_Core_Block { $value['url'] = CRM_Utils_System::url($dash['path'], $dash['query'], FALSE); } $value['title'] = $dash['title']; - $value['key'] = CRM_Utils_Array::value('key', $dash); - $values[] = $value; + $value['key'] = CRM_Utils_Array::value('key', $dash); + $values[] = $value; } self::setProperty(self::DASHBOARD, 'templateValues', array('dashboardLinks' => $values)); } /** - * Create the list of mail urls for the application and format is as a block + * Create the list of mail urls for the application and format is as a block. * * @return void */ @@ -495,7 +515,8 @@ class CRM_Core_Block { if (!($shortCuts)) { $shortCuts = array( - array('path' => 'civicrm/mailing/send', + array( + 'path' => 'civicrm/mailing/send', 'query' => 'reset=1', 'title' => ts('Send Mailing'), ), @@ -509,16 +530,16 @@ class CRM_Core_Block { $values = array(); foreach ($shortCuts as $short) { - $value = array(); - $value['url'] = CRM_Utils_System::url($short['path'], $short['query']); + $value = array(); + $value['url'] = CRM_Utils_System::url($short['path'], $short['query']); $value['title'] = $short['title']; - $values[] = $value; + $values[] = $value; } self::setProperty(self::MAIL, 'templateValues', array('shortCuts' => $values)); } /** - * Create the list of shortcuts for the application and format is as a block + * Create the list of shortcuts for the application and format is as a block. * * @return void */ @@ -533,7 +554,7 @@ class CRM_Core_Block { } /** - * Create the event blocks for upcoming events + * Create the event blocks for upcoming events. * * @return void */ @@ -560,7 +581,8 @@ class CRM_Core_Block { /** * Given an id creates a subject/content array * - * @param int $id id of the block + * @param int $id + * Id of the block. * * @return array */ @@ -568,7 +590,7 @@ class CRM_Core_Block { // return if upgrade mode $config = CRM_Core_Config::singleton(); if ($config->isUpgradeMode()) { - return; + return NULL; } if (!self::getProperty($id, 'active')) { @@ -585,7 +607,7 @@ class CRM_Core_Block { // do nothing } // require 'access CiviCRM' permissons, except for the language switch block - elseif (!CRM_Core_Permission::check('access CiviCRM') && $id!=self::LANGSWITCH) { + elseif (!CRM_Core_Permission::check('access CiviCRM') && $id != self::LANGSWITCH) { return NULL; } elseif ($id == self::ADD) { @@ -620,9 +642,9 @@ class CRM_Core_Block { return NULL; } - $block = array(); - $block['name'] = 'block-civicrm'; - $block['id'] = $block['name'] . '_' . $id; + $block = array(); + $block['name'] = 'block-civicrm'; + $block['id'] = $block['name'] . '_' . $id; $block['subject'] = self::fetch($id, 'Subject.tpl', array('subject' => self::getProperty($id, 'subject')) ); @@ -630,16 +652,18 @@ class CRM_Core_Block { self::getProperty($id, 'templateValues') ); - return $block; } /** * Given an id and a template, fetch the contents * - * @param int $id id of the block - * @param string $fileName name of the template file - * @param array $properties template variables + * @param int $id + * Id of the block. + * @param string $fileName + * Name of the template file. + * @param array $properties + * Template variables. * * @return array */ @@ -652,4 +676,5 @@ class CRM_Core_Block { return $template->fetch('CRM/Block/' . $fileName); } + }