X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBlock.php;h=569f0552129c9759cef64f2ea8b89bb476b469ca;hb=c503dcf3dc4ec114585dcaa8ffdfdbaab9609da7;hp=92c81a32888fcc248b58a7cc9d9541b20f181258;hpb=d44c681d9105af668449d16d9f53832d7982f47e;p=civicrm-core.git diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index 92c81a3288..569f055212 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -1,7 +1,7 @@ $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') @@ -261,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'], @@ -275,15 +282,14 @@ class CRM_Core_Block { } /** - * set the post action values for the block. + * Set the post action values for the block. * * php is lame and u cannot call functions from static initializers * hence this hack * - * @param $id + * @param int $id * * @return void - * @access private */ private static function setTemplateValues($id) { switch ($id) { @@ -298,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, ); @@ -312,11 +319,18 @@ class CRM_Core_Block { ); break; + 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; @@ -332,10 +346,9 @@ 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 - * @access private */ private static function setTemplateShortcutValues() { $config = CRM_Core_Config::singleton(); @@ -356,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(); @@ -373,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)) { @@ -439,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); @@ -449,19 +469,20 @@ class CRM_Core_Block { } /** - * create the list of dashboard links + * Create the list of dashboard links. * * @return void - * @access private */ private static function setTemplateDashboardValues() { 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)) { @@ -478,24 +499,24 @@ 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 - * @access private */ private static function setTemplateMailValues() { static $shortCuts = NULL; if (!($shortCuts)) { $shortCuts = array( - array('path' => 'civicrm/mailing/send', + array( + 'path' => 'civicrm/mailing/send', 'query' => 'reset=1', 'title' => ts('Send Mailing'), ), @@ -509,19 +530,18 @@ 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 - * @access private */ private static function setTemplateMenuValues() { $config = CRM_Core_Config::singleton(); @@ -534,10 +554,9 @@ class CRM_Core_Block { } /** - * create the event blocks for upcoming events + * Create the event blocks for upcoming events. * * @return void - * @access private */ private static function setTemplateEventValues() { $config = CRM_Core_Config::singleton(); @@ -562,16 +581,16 @@ 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 - * @access public */ - static function getContent($id) { + public static function getContent($id) { // return if upgrade mode $config = CRM_Core_Config::singleton(); if ($config->isUpgradeMode()) { - return; + return NULL; } if (!self::getProperty($id, 'active')) { @@ -588,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) { @@ -623,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')) ); @@ -633,21 +652,22 @@ 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 - * @access public */ - static function fetch($id, $fileName, $properties) { + public static function fetch($id, $fileName, $properties) { $template = CRM_Core_Smarty::singleton(); if ($properties) { @@ -656,5 +676,5 @@ class CRM_Core_Block { return $template->fetch('CRM/Block/' . $fileName); } -} +}