本文整理汇总了PHP中CRM_Utils_Hook::dashboard_defaults方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::dashboard_defaults方法的具体用法?PHP CRM_Utils_Hook::dashboard_defaults怎么用?PHP CRM_Utils_Hook::dashboard_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Hook
的用法示例。
在下文中一共展示了CRM_Utils_Hook::dashboard_defaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeDashlets
/**
* Setup default dashlets for new users.
*
* When a user accesses their dashboard for the first time, set up
* the default dashlets.
*
* @param bool $flatFormat
*
* @return array
* Array of dashboard_id's
* @throws \CiviCRM_API3_Exception
*/
public static function initializeDashlets($flatFormat = FALSE)
{
$dashlets = array();
$getDashlets = civicrm_api3("Dashboard", "get", array('domain_id' => CRM_Core_Config::domainID(), 'option.limit' => 0));
$contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
$allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']);
$defaultDashlets = array();
$defaults = array('blog' => 1, 'getting-started' => '0');
foreach ($defaults as $name => $column) {
if (!empty($allDashlets[$name])) {
$defaultDashlets[$name] = array('dashboard_id' => $allDashlets[$name]['id'], 'is_active' => 1, 'column_no' => $column, 'contact_id' => $contactID);
}
}
CRM_Utils_Hook::dashboard_defaults($allDashlets, $defaultDashlets);
if (is_array($defaultDashlets) && !empty($defaultDashlets)) {
foreach ($defaultDashlets as $id => $defaultDashlet) {
$dashboard_id = $defaultDashlet['dashboard_id'];
if (!self::checkPermission($getDashlets['values'][$dashboard_id]['permission'], CRM_Utils_Array::value('permission_operator', $getDashlets['values'][$dashboard_id]))) {
continue;
} else {
$assignDashlets = civicrm_api3("dashboard_contact", "create", $defaultDashlet);
if (!$flatFormat) {
$values = $assignDashlets['values'][$assignDashlets['id']];
$dashlets[$values['column_no']][$values['weight'] - $values['dashboard_id']] = $values['is_minimized'];
} else {
$dashlets[$dashboard_id] = $defaultDashlet['dashboard_id'];
}
}
}
}
return $dashlets;
}
示例2: initializeDashlets
/**
* @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 && !empty($allDashlets['blog'])) {
$defaultDashlets['blog'] = array('dashboard_id' => $allDashlets['blog']['id'], 'is_active' => 1, 'column_no' => 1, 'contact_id' => $contactID, 'domain_id' => CRM_Core_Config::domainID());
}
CRM_Utils_Hook::dashboard_defaults($allDashlets, $defaultDashlets);
if (is_array($defaultDashlets) && !empty($defaultDashlets)) {
foreach ($defaultDashlets as $defaultDashlet) {
if (!self::checkPermission($getDashlets['values'][$defaultDashlet['dashboard_id']]['permission'], $getDashlets['values'][$defaultDashlet['dashboard_id']]['permission_operator'])) {
unset($defaultDashlets[$defaultDashlet]);
continue;
} else {
$assignDashlets = civicrm_api3("dashboard_contact", "create", $defaultDashlet);
$dashlets[$defaultDashlet['dashboard_id']] = $defaultDashlet['dashboard_id'];
}
}
return $dashlets;
}
return FALSE;
}