<?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. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
* Get the list of dashlets enabled by admin
*
* @param boolean $all all or only active
+ * @param boolean $checkPermission all or only authorized for the current user
*
* @return array $widgets array of dashlets
* @access public
* @static
*/
- static function getDashlets($all = TRUE) {
+ static function getDashlets($all = TRUE, $checkPermission = TRUE) {
$dashlets = array();
$dao = new CRM_Core_DAO_Dashboard();
$dao->find();
while ($dao->fetch()) {
- if (!self::checkPermission($dao->permission, $dao->permission_operator)) {
+ if ($checkPermission && !self::checkPermission($dao->permission, $dao->permission_operator)) {
continue;
}
*
* @param boolean $flatFormat this is true if you want simple associated array of contact dashlets
*
+ * @param null $contactID
+ *
* @return array $dashlets array of dashlets
* @access public
* @static
return $defaultDashlet ? $defaultDashlet : $dashlets;
}
+ /**
+ * @param $hasDashlets
+ *
+ * @return bool
+ * @throws CiviCRM_API3_Exception
+ */
static function initializeDashlets($hasDashlets) {
$getDashlets = civicrm_api3("Dashboard", "get", array('domain_id' => CRM_Core_Config::domainID()));
$contactID = CRM_Core_Session::singleton()->get('userID');
$allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']);
$defaultDashlets = array();
- if (!$hasDashlets && CRM_Utils_Array::value('blog', $allDashlets)) {
+ if (!$hasDashlets && !empty($allDashlets['blog'])) {
$defaultDashlets['blog'] = array(
'dashboard_id' => $allDashlets['blog']['id'],
'is_active' => 1,
/**
* Function to check dashlet permission for current user
*
- * @param string permission string
+ * @param $permission
+ * @param $operator
+ *
+ * @internal param \permission $string string
*
* @return boolean true if use has permission else false
*/
*
* @param array $columns associated array
*
+ * @param null $contactID
+ *
+ * @throws RuntimeException
* @return void
* @access public
* @static
// special case to handle duplicate entires for report instances
$dashboardID = CRM_Utils_Array::value('id', $params);
- if (CRM_Utils_Array::value('instanceURL', $params)) {
+ if (!empty($params['instanceURL'])) {
$query = "SELECT id
FROM `civicrm_dashboard`
WHERE url LIKE '" . CRM_Utils_Array::value('instanceURL', $params) . "&%'";
if (!$dashboardID) {
// check url is same as exiting entries, if yes just update existing
- if (CRM_Utils_Array::value('name', $params)) {
+ if (!empty($params['name'])) {
$dashlet->name = CRM_Utils_Array::value('name', $params);
$dashlet->find(TRUE);
}
return $dashlet;
}
+ /**
+ * @param $url
+ *
+ * @return string
+ */
static function getDashletName($url) {
$urlElements = explode('/', $url);
if ($urlElements[1] == 'dashlet') {
/**
* Delete Dashlet
*
+ * @param $dashletID
+ *
* @return void
* @static
*/