bulk comment fixes
[civicrm-core.git] / CRM / Core / Block.php
index f4bdcb3ce0f2080bd2d250fc07bd2be104b687ac..f2a71281bedb57c8fba2c54847dc726f131c52e4 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -280,6 +280,8 @@ class CRM_Core_Block {
    * php is lame and u cannot call functions from static initializers
    * hence this hack
    *
+   * @param $id
+   *
    * @return void
    * @access private
    */
@@ -401,17 +403,8 @@ class CRM_Core_Block {
     }
 
     $values = array();
-    foreach ($shortCuts as $short) {
-      $value = array();
-      if (isset($short['url'])) {
-        $value['url'] = $short['url'];
-      }
-      else {
-        $value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE);
-      }
-      $value['title'] = $short['title'];
-      $value['ref']   = $short['ref'];
-      $values[]       = $value;
+    foreach ($shortCuts as $key => $short) {
+      $values[$key] = self::setShortCutValues($short);
     }
 
     // call links hook to add user defined links
@@ -419,12 +412,37 @@ class CRM_Core_Block {
       NULL,
       CRM_Core_DAO::$_nullObject,
       $values,
+      CRM_Core_DAO::$_nullObject,
       CRM_Core_DAO::$_nullObject
     );
 
+    foreach ($values as $key => $val) {
+      if (!empty($val['title'])) {
+        $values[$key]['name'] = CRM_Utils_Array::value('name', $val, $val['title']);
+      }
+    }
+
     self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values));
   }
 
+  private static function setShortcutValues($short) {
+    $value = array();
+    if (isset($short['url'])) {
+      $value['url'] = $short['url'];
+    }
+    elseif (isset($short['path'])) {
+      $value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE);
+    }
+    $value['title'] = $short['title'];
+    $value['ref']   = $short['ref'];
+    if (!empty($short['shortCuts'])) {
+      foreach ($short['shortCuts'] as $shortCut) {
+        $value['shortCuts'][] = self::setShortcutValues($shortCut);
+      }
+    }
+    return $value;
+  }
+
   /**
    * create the list of dashboard links
    *