X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FRecent.php;h=55ccf47b4b5c65447ae7e4be95bbb5b5465d9fda;hb=a6491ceec03e64e45e127222ae268187c652f5b7;hp=f3baf09271927f078747cb57930c96411460b359;hpb=d880d1db343ce51a575d446d2748e3e1e5468277;p=civicrm-core.git diff --git a/CRM/Utils/Recent.php b/CRM/Utils/Recent.php index f3baf09271..55ccf47b4b 100644 --- a/CRM/Utils/Recent.php +++ b/CRM/Utils/Recent.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -27,7 +27,7 @@ /** * @package CRM - * @copyright CiviCRM LLC (c) 2004-2018 + * @copyright CiviCRM LLC (c) 2004-2019 */ /** @@ -67,7 +67,7 @@ class CRM_Utils_Recent { $session = CRM_Core_Session::singleton(); self::$_recent = $session->get(self::STORE_NAME); if (!self::$_recent) { - self::$_recent = array(); + self::$_recent = []; } } } @@ -104,7 +104,7 @@ class CRM_Utils_Recent { $type, $contactId, $contactName, - $others = array() + $others = [] ) { self::initialize(); @@ -116,7 +116,7 @@ class CRM_Utils_Recent { // make sure item is not already present in list for ($i = 0; $i < count(self::$_recent); $i++) { - if (self::$_recent[$i]['type'] === $type && self::$_recent[$i]['id'] === $id) { + if (self::$_recent[$i]['type'] === $type && self::$_recent[$i]['id'] == $id) { // delete item from array array_splice(self::$_recent, $i, 1); break; @@ -124,11 +124,11 @@ class CRM_Utils_Recent { } if (!is_array($others)) { - $others = array(); + $others = []; } array_unshift(self::$_recent, - array( + [ 'title' => $title, 'url' => $url, 'id' => $id, @@ -140,7 +140,7 @@ class CRM_Utils_Recent { 'image_url' => CRM_Utils_Array::value('imageUrl', $others), 'edit_url' => CRM_Utils_Array::value('editUrl', $others), 'delete_url' => CRM_Utils_Array::value('deleteUrl', $others), - ) + ] ); if (count(self::$_recent) > self::$_maxItems) { @@ -162,7 +162,7 @@ class CRM_Utils_Recent { self::initialize(); $tempRecent = self::$_recent; - self::$_recent = array(); + self::$_recent = []; // make sure item is not already present in list for ($i = 0; $i < count($tempRecent); $i++) { @@ -174,6 +174,7 @@ class CRM_Utils_Recent { } } + CRM_Utils_Hook::recent(self::$_recent); $session = CRM_Core_Session::singleton(); $session->set(self::STORE_NAME, self::$_recent); } @@ -189,7 +190,7 @@ class CRM_Utils_Recent { $tempRecent = self::$_recent; - self::$_recent = array(); + self::$_recent = []; // rebuild recent. for ($i = 0; $i < count($tempRecent); $i++) { @@ -200,15 +201,17 @@ class CRM_Utils_Recent { self::$_recent[] = $tempRecent[$i]; } + CRM_Utils_Hook::recent(self::$_recent); $session = CRM_Core_Session::singleton(); $session->set(self::STORE_NAME, self::$_recent); } /** * Check if a provider is allowed to add stuff. - * If correspondig setting is empty, all are allowed + * If corresponding setting is empty, all are allowed * * @param string $providerName + * @return bool */ public static function isProviderEnabled($providerName) { @@ -230,9 +233,11 @@ class CRM_Utils_Recent { /** * Gets the list of available providers to civi's recent items stack + * + * @return array */ public static function getProviders() { - $providers = array( + $providers = [ 'Contact' => ts('Contacts'), 'Relationship' => ts('Relationships'), 'Activity' => ts('Activities'), @@ -246,7 +251,7 @@ class CRM_Utils_Recent { 'Pledge' => ts('Pledges'), 'Event' => ts('Events'), 'Campaign' => ts('Campaigns'), - ); + ]; return $providers; }