当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_Hook::summaryActions方法代码示例

本文整理汇总了PHP中CRM_Utils_Hook::summaryActions方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::summaryActions方法的具体用法?PHP CRM_Utils_Hook::summaryActions怎么用?PHP CRM_Utils_Hook::summaryActions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Hook的用法示例。


在下文中一共展示了CRM_Utils_Hook::summaryActions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: contextMenu

 /**
  * Build context menu items.
  *
  * @param int $contactId
  *
  * @return array
  *   Array of context menu for logged in user.
  */
 public static function contextMenu($contactId = NULL)
 {
     $menu = array('view' => array('title' => ts('View Contact'), 'weight' => 0, 'ref' => 'view-contact', 'class' => 'no-popup', 'key' => 'view', 'permissions' => array('view all contacts')), 'add' => array('title' => ts('Edit Contact'), 'weight' => 0, 'ref' => 'edit-contact', 'class' => 'no-popup', 'key' => 'add', 'permissions' => array('edit all contacts')), 'delete' => array('title' => ts('Delete Contact'), 'weight' => 0, 'ref' => 'delete-contact', 'key' => 'delete', 'permissions' => array('access deleted contacts', 'delete contacts')), 'contribution' => array('title' => ts('Add Contribution'), 'weight' => 5, 'ref' => 'new-contribution', 'key' => 'contribution', 'tab' => 'contribute', 'component' => 'CiviContribute', 'href' => CRM_Utils_System::url('civicrm/contact/view/contribution', 'reset=1&action=add&context=contribution'), 'permissions' => array('access CiviContribute', 'edit contributions')), 'participant' => array('title' => ts('Register for Event'), 'weight' => 10, 'ref' => 'new-participant', 'key' => 'participant', 'tab' => 'participant', 'component' => 'CiviEvent', 'href' => CRM_Utils_System::url('civicrm/contact/view/participant', 'reset=1&action=add&context=participant'), 'permissions' => array('access CiviEvent', 'edit event participants')), 'activity' => array('title' => ts('Record Activity'), 'weight' => 35, 'ref' => 'new-activity', 'key' => 'activity', 'permissions' => array('edit all contacts')), 'pledge' => array('title' => ts('Add Pledge'), 'weight' => 15, 'ref' => 'new-pledge', 'key' => 'pledge', 'tab' => 'pledge', 'href' => CRM_Utils_System::url('civicrm/contact/view/pledge', 'reset=1&action=add&context=pledge'), 'component' => 'CiviPledge', 'permissions' => array('access CiviPledge', 'edit pledges')), 'membership' => array('title' => ts('Add Membership'), 'weight' => 20, 'ref' => 'new-membership', 'key' => 'membership', 'tab' => 'member', 'component' => 'CiviMember', 'href' => CRM_Utils_System::url('civicrm/contact/view/membership', 'reset=1&action=add&context=membership'), 'permissions' => array('access CiviMember', 'edit memberships')), 'case' => array('title' => ts('Add Case'), 'weight' => 25, 'ref' => 'new-case', 'key' => 'case', 'tab' => 'case', 'component' => 'CiviCase', 'href' => CRM_Utils_System::url('civicrm/case/add', 'reset=1&action=add&context=case'), 'permissions' => array('add cases')), 'grant' => array('title' => ts('Add Grant'), 'weight' => 26, 'ref' => 'new-grant', 'key' => 'grant', 'tab' => 'grant', 'component' => 'CiviGrant', 'href' => CRM_Utils_System::url('civicrm/contact/view/grant', 'reset=1&action=add&context=grant'), 'permissions' => array('edit grants')), 'rel' => array('title' => ts('Add Relationship'), 'weight' => 30, 'ref' => 'new-relationship', 'key' => 'rel', 'tab' => 'rel', 'href' => CRM_Utils_System::url('civicrm/contact/view/rel', 'reset=1&action=add'), 'permissions' => array('edit all contacts')), 'note' => array('title' => ts('Add Note'), 'weight' => 40, 'ref' => 'new-note', 'key' => 'note', 'tab' => 'note', 'class' => 'medium-popup', 'href' => CRM_Utils_System::url('civicrm/contact/view/note', 'reset=1&action=add'), 'permissions' => array('edit all contacts')), 'email' => array('title' => ts('Send an Email'), 'weight' => 45, 'ref' => 'new-email', 'key' => 'email', 'permissions' => array('view all contacts')), 'group' => array('title' => ts('Add to Group'), 'weight' => 50, 'ref' => 'group-add-contact', 'key' => 'group', 'tab' => 'group', 'permissions' => array('edit groups')), 'tag' => array('title' => ts('Tag Contact'), 'weight' => 55, 'ref' => 'tag-contact', 'key' => 'tag', 'tab' => 'tag', 'permissions' => array('edit all contacts')));
     CRM_Utils_Hook::summaryActions($menu, $contactId);
     //1. check for component is active.
     //2. check for user permissions.
     //3. check for acls.
     //3. edit and view contact are directly accessible to user.
     $aclPermissionedTasks = array('view-contact', 'edit-contact', 'new-activity', 'new-email', 'group-add-contact', 'tag-contact', 'delete-contact');
     $corePermission = CRM_Core_Permission::getPermission();
     $config = CRM_Core_Config::singleton();
     $contextMenu = array();
     foreach ($menu as $key => $values) {
         $componentName = CRM_Utils_Array::value('component', $values);
         // if component action - make sure component is enable.
         if ($componentName && !in_array($componentName, $config->enableComponents)) {
             continue;
         }
         // make sure user has all required permissions.
         $hasAllPermissions = FALSE;
         $permissions = CRM_Utils_Array::value('permissions', $values);
         if (!is_array($permissions) || empty($permissions)) {
             $hasAllPermissions = TRUE;
         }
         // iterate for required permissions in given permissions array.
         if (!$hasAllPermissions) {
             $hasPermissions = 0;
             foreach ($permissions as $permission) {
                 if (CRM_Core_Permission::check($permission)) {
                     $hasPermissions++;
                 }
             }
             if (count($permissions) == $hasPermissions) {
                 $hasAllPermissions = TRUE;
             }
             // if still user does not have required permissions, check acl.
             if (!$hasAllPermissions && $values['ref'] != 'delete-contact') {
                 if (in_array($values['ref'], $aclPermissionedTasks) && $corePermission == CRM_Core_Permission::EDIT) {
                     $hasAllPermissions = TRUE;
                 } elseif (in_array($values['ref'], array('new-email'))) {
                     // grant permissions for these tasks.
                     $hasAllPermissions = TRUE;
                 }
             }
         }
         // user does not have necessary permissions.
         if (!$hasAllPermissions) {
             continue;
         }
         // build directly accessible action menu.
         if (in_array($values['ref'], array('view-contact', 'edit-contact'))) {
             $contextMenu['primaryActions'][$key] = array('title' => $values['title'], 'ref' => $values['ref'], 'class' => CRM_Utils_Array::value('class', $values), 'key' => $values['key']);
             continue;
         }
         // finally get menu item for -more- action widget.
         $contextMenu['moreActions'][$values['weight']] = array('title' => $values['title'], 'ref' => $values['ref'], 'href' => CRM_Utils_Array::value('href', $values), 'tab' => CRM_Utils_Array::value('tab', $values), 'class' => CRM_Utils_Array::value('class', $values), 'key' => $values['key']);
     }
     ksort($contextMenu['moreActions']);
     return $contextMenu;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:68,代码来源:Contact.php


注:本文中的CRM_Utils_Hook::summaryActions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。