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


PHP CRM_Core_Permission::getPermission方法代码示例

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


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

示例1: addActions

 function addActions(&$rows)
 {
     $links = self::links();
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     foreach ($rows as $id => &$row) {
         $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $row['contact_id']));
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:12,代码来源:Custom.php

示例2: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addElement('text', 'sort_name', ts('Member Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Member_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $this->addTaskMenu(CRM_Member_Task::permissionedTaskTitles($permission));
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:21,代码来源:Search.php

示例3: addActions

 /**
  * @param $rows
  */
 function addActions(&$rows)
 {
     $config = CRM_Core_Config::singleton();
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     // mask value to hide map link if there are not lat/long
     $mapMask = $mask & 4095;
     // mask value to hide map link if there are not lat/long
     $mapMask = $mask & 4095;
     $links = self::links($this->_context, $this->_contextMenu, $this->_key);
     foreach ($rows as $id => &$row) {
         if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts')) {
             $links = array(array('name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%id%%', 'class' => 'no-popup', 'title' => ts('View Contact Details')), array('name' => ts('Restore'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&restore=1', 'title' => ts('Restore Contact')));
             if (CRM_Core_Permission::check('delete contacts')) {
                 $links[] = array('name' => ts('Delete Permanently'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&skip_undelete=1', 'title' => ts('Permanently Delete Contact'));
             }
             $row['action'] = CRM_Core_Action::formLink($links, null, array('id' => $row['contact_id']), ts('more'), FALSE, 'contact.selector.actions', 'Contact', $row['contact_id']);
         } elseif (is_numeric(CRM_Utils_Array::value('geo_code_1', $row)) || $config->mapGeoCoding && !empty($row['city']) && CRM_Utils_Array::value('state_province', $row)) {
             $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $row['contact_id']), ts('more'), FALSE, 'contact.selector.actions', 'Contact', $row['contact_id']);
         } else {
             $row['action'] = CRM_Core_Action::formLink($links, $mapMask, array('id' => $row['contact_id']), ts('more'), FALSE, 'contact.selector.actions', 'Contact', $row['contact_id']);
         }
         // allow components to add more actions
         CRM_Core_Component::searchAction($row, $row['contact_id']);
         if (!empty($row['contact_type_orig'])) {
             $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($row['contact_type_orig'], FALSE, $row['contact_id']);
         }
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:35,代码来源:Selector.php

示例4: buildInstanceAndButtons

 /**
  * This adds the tab referred to as Title and Format, rendered through Instance.tpl.
  *
  * @todo call this tab into the report template in the same way as OrderBy etc, ie
  * by adding a description of the tab to $this->tabs, causing the tab to be added in
  * Criteria.tpl.
  */
 public function buildInstanceAndButtons()
 {
     CRM_Report_Form_Instance::buildForm($this);
     $label = $this->_id ? ts('Update Report') : ts('Create Report');
     $this->addElement('submit', $this->_instanceButtonName, $label);
     $this->addElement('submit', $this->_printButtonName, ts('Print Report'));
     $this->addElement('submit', $this->_pdfButtonName, ts('PDF'));
     if ($this->_id) {
         $this->addElement('submit', $this->_createNewButtonName, ts('Save a Copy') . '...');
     }
     $this->assign('instanceForm', $this->_instanceForm);
     $label = $this->_id ? ts('Print Report') : ts('Print Preview');
     $this->addElement('submit', $this->_printButtonName, $label);
     $label = $this->_id ? ts('PDF') : ts('Preview PDF');
     $this->addElement('submit', $this->_pdfButtonName, $label);
     $label = $this->_id ? ts('Export to CSV') : ts('Preview CSV');
     if ($this->_csvSupported) {
         $this->addElement('submit', $this->_csvButtonName, $label);
     }
     // CRM-16274 Determine if user has 'edit all contacts' or equivalent
     $permission = CRM_Core_Permission::getPermission();
     if ($permission == CRM_Core_Permission::EDIT && $this->_add2groupSupported) {
         $this->addElement('select', 'groups', ts('Group'), array('' => ts('Add Contacts to Group')) + CRM_Core_PseudoConstant::nestedGroup(), array('class' => 'crm-select2 crm-action-menu fa-plus huge'));
         $this->assign('group', TRUE);
     }
     $this->addElement('submit', $this->_groupButtonName, '', array('style' => 'display: none;'));
     $this->addChartOptions();
     $this->addButtons(array(array('type' => 'submit', 'name' => ts('Preview Report'), 'isDefault' => TRUE)));
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:36,代码来源:Form.php

示例5: array_values

 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = null)
 {
     $includeContactIDs = false;
     if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
         $includeContactIDs = true;
     }
     $sql = $this->_search->all($offset, $rowCount, $sort, $includeContactIDs);
     $dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
     $columns = $this->_search->columns();
     $columnNames = array_values($columns);
     $links = self::links();
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     $alterRow = false;
     if (method_exists($this->_customSearchClass, 'alterRow')) {
         $alterRow = true;
     }
     $image = false;
     if (is_a($this->_search, 'CRM_Contact_Form_Search_Custom_Basic')) {
         $image = true;
     }
     // process the result of the query
     $rows = array();
     while ($dao->fetch()) {
         $row = array();
         $empty = true;
         // the columns we are interested in
         foreach ($columnNames as $property) {
             $row[$property] = $dao->{$property};
             if (!empty($dao->{$property})) {
                 $empty = false;
             }
         }
         if (!$empty) {
             $contactID = isset($dao->contact_id) ? $dao->contact_id : NULL;
             $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $contactID;
             $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $contactID));
             $row['contact_id'] = $contactID;
             if ($alterRow) {
                 $this->_search->alterRow($row);
             }
             if ($image) {
                 require_once 'CRM/Contact/BAO/Contact/Utils.php';
                 $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($dao->contact_sub_type ? $dao->contact_sub_type : $dao->contact_type, false, $contactID);
             }
             $rows[] = $row;
         }
     }
     return $rows;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:64,代码来源:Custom.php

示例6: buildQuickForm

 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addElement('text', 'sort_name', ts('Client Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Case_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $tasks = CRM_Case_Task::permissionedTaskTitles($permission);
         if (!empty($this->_formValues['case_deleted'])) {
             unset($tasks[1]);
         } else {
             unset($tasks[4]);
         }
         $this->addTaskMenu($tasks);
     }
 }
开发者ID:sugan2111,项目名称:Drupal_code,代码行数:26,代码来源:Search.php

示例7: 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

示例8: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     $this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     require_once 'CRM/Event/BAO/Query.php';
     CRM_Event_BAO_Query::buildSearchForm($this);
     /* 
      * add form checkboxes for each row. This is needed out here to conform to QF protocol 
      * of all elements being declared in builQuickForm 
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $lineItems = array();
         require_once 'CRM/Event/BAO/Event.php';
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
         }
         foreach ($rows as $row) {
             if (!$this->_single) {
                 $this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
             }
             if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
                 // add line item details if applicable
                 require_once 'CRM/Price/BAO/LineItem.php';
                 $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
             }
         }
         $this->assign('lineItems', $lineItems);
         $total = $cancel = 0;
         require_once "CRM/Core/Permission.php";
         $permission = CRM_Core_Permission::getPermission();
         require_once 'CRM/Event/Task.php';
         $tasks = array('' => ts('- more actions -')) + CRM_Event_Task::permissionedTaskTitles($permission);
         if (isset($this->_ssID)) {
             if ($permission == CRM_Core_Permission::EDIT) {
                 require_once "CRM/Contact/Task.php";
                 $tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
             }
             $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
             $this->assign_by_ref('savedSearch', $savedSearchValues);
             $this->assign('ssID', $this->_ssID);
         }
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
         $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
         // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
         $this->addElement('radio', 'radio_ts', null, '', 'ts_sel', array('checked' => 'checked'));
         $this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:57,代码来源:Search.php

示例9: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addSortNameField();
     CRM_Pledge_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $this->addTaskMenu(CRM_Pledge_Task::permissionedTaskTitles($permission));
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:17,代码来源:Search.php

示例10: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     //build the search form.
     CRM_Campaign_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $allTasks = CRM_Campaign_Task::permissionedTaskTitles($permission);
         //hack to serve right page to state machine.
         $taskMapping = array('interview' => 1, 'reserve' => 2, 'release' => 3);
         $currentTaskValue = CRM_Utils_Array::value($this->_operation, $taskMapping);
         $taskValue = array($currentTaskValue => $allTasks[$currentTaskValue]);
         if ($this->_operation == 'interview' && !empty($this->_formValues['campaign_survey_id'])) {
             $activityTypes = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
             $surveyTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_formValues['campaign_survey_id'], 'activity_type_id');
             $taskValue = array($currentTaskValue => ts('Record %1 Responses', array(1 => $activityTypes[$surveyTypeId])));
         }
         $this->addTaskMenu($taskValue);
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:27,代码来源:Search.php

示例11: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     // text for sort_name
     $this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $this->_group = CRM_Core_PseudoConstant::group();
     // multiselect for groups
     if ($this->_group) {
         $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
     }
     // multiselect for tags
     $contactTags = CRM_Core_BAO_Tag::getTags();
     if ($contactTags) {
         $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2'));
     }
     CRM_Contribute_BAO_Query::buildSearchForm($this);
     /*
      * add form checkboxes for each row. This is needed out here to conform to QF protocol
      * of all elements being declared in builQuickForm
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows'));
             foreach ($rows as $row) {
                 $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-row'));
             }
         }
         $total = $cancel = 0;
         $permission = CRM_Core_Permission::getPermission();
         $tasks = array('' => ts('- actions -')) + CRM_Contribute_Task::permissionedTaskTitles($permission);
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
         // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:46,代码来源:Search.php

示例12: array

 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = null)
 {
     $config =& CRM_Core_Config::singleton();
     if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
         $includeContactIds = true;
     } else {
         $includeContactIds = false;
     }
     // note the formvalues were given by CRM_Contact_Form_Search to us
     // and contain the search criteria (parameters)
     // note that the default action is basic
     $result = $this->_query->searchQuery($offset, $rowCount, $sort, false, $includeContactIds);
     // process the result of the query
     $rows = array();
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     $mapMask = $mask & 4095;
     // mask value to hide map link if there are not lat/long
     $gc = CRM_Core_SelectValues::groupContactStatus();
     if ($this->_ufGroupID) {
         require_once 'CRM/Core/PseudoConstant.php';
         $locationTypes = CRM_Core_PseudoConstant::locationType();
         $names = array();
         static $skipFields = array('group', 'tag');
         foreach ($this->_fields as $key => $field) {
             if (CRM_Utils_Array::value('in_selector', $field) && !in_array($key, $skipFields)) {
                 if (strpos($key, '-') !== false) {
                     list($fieldName, $id, $type) = explode('-', $key);
                     if ($id == 'Primary') {
                         $locationTypeName = 1;
                     } else {
                         $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
                         if (!$locationTypeName) {
                             continue;
                         }
                     }
                     $locationTypeName = str_replace(' ', '_', $locationTypeName);
                     if (in_array($fieldName, array('phone', 'im', 'email'))) {
                         if ($type) {
                             $names[] = "{$locationTypeName}-{$fieldName}-{$type}";
                         } else {
                             $names[] = "{$locationTypeName}-{$fieldName}";
                         }
                     } else {
                         $names[] = "{$locationTypeName}-{$fieldName}";
                     }
                 } else {
                     $names[] = $field['name'];
                 }
             }
         }
         $names[] = "status";
     } else {
         if (!empty($this->_returnProperties)) {
             $names =& self::makeProperties($this->_returnProperties);
         } else {
             $names = self::$_properties;
         }
     }
     //hack for student data (checkboxs)
     $multipleSelectFields = array('preferred_communication_method' => 1);
     if (CRM_Core_Permission::access('Quest')) {
         require_once 'CRM/Quest/BAO/Student.php';
         $multipleSelectFields = CRM_Quest_BAO_Student::$multipleSelectFields;
     }
     $searchType = null;
     if ($this->_action == CRM_Core_Action::BASIC) {
         $searchType = 'basic';
     } elseif ($this->_action == CRM_Core_Action::ADVANCED) {
         $searchType = 'advance';
     }
     require_once 'CRM/Core/OptionGroup.php';
     $links =& self::links($searchType, $this->_contextMenu);
     //check explicitly added contact to a Smart Group.
     $groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
     while ($result->fetch()) {
         $row = array();
         // the columns we are interested in
         foreach ($names as $property) {
             if ($property == 'status') {
                 continue;
             }
             if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
                 $row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
             } else {
                 if ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Selector.php

示例13: array

 /**
  * Returns all the rows in the given offset and rowCount.
  *
  * @param string $action
  *   The action being performed.
  * @param int $offset
  *   The row number to start from.
  * @param int $rowCount
  *   The number of rows to return.
  * @param string $sort
  *   The sql string that describes the sort order.
  * @param string $output
  *   What should the result set include (web/email/csv).
  *
  * @return int
  *   the total number of rows for this action
  */
 public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
 {
     $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_mailingClause);
     // process the result of the query
     $rows = array();
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     $qfKey = $this->_key;
     while ($result->fetch()) {
         $row = array();
         // the columns we are interested in
         foreach (self::$_properties as $property) {
             if (property_exists($result, $property)) {
                 $row[$property] = $result->{$property};
             }
         }
         $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->mailing_recipients_id;
         $actions = array('cid' => $result->contact_id, 'cxt' => $this->_context);
         $row['action'] = CRM_Core_Action::formLink(self::links($qfKey, $this->_context), $mask, $actions, ts('more'), FALSE, 'contact.mailing.row', 'Contact', $result->contact_id);
         $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
         $rows[] = $row;
     }
     return $rows;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:44,代码来源:Search.php

示例14: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $this->addElement('text', 'sort_name', ts('Pledger Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Pledge_BAO_Query::buildSearchForm($this);
     /*
      * add form checkboxes for each row. This is needed out here to conform to QF protocol
      * of all elements being declared in builQuickForm
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows'));
             foreach ($rows as $row) {
                 $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-row'));
             }
         }
         $total = $cancel = 0;
         $permission = CRM_Core_Permission::getPermission();
         $tasks = array('' => ts('- actions -')) + CRM_Pledge_Task::permissionedTaskTitles($permission);
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
         // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:36,代码来源:Search.php

示例15: buildQuickForm

 /**
  * Build the common elements between the search/advanced form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $permission = CRM_Core_Permission::getPermission();
     // some tasks.. what do we want to do with the selected contacts ?
     $tasks = array('' => ts('- actions -'));
     if ($this->_componentMode == 1 || $this->_componentMode == 7) {
         $tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
     } else {
         require_once str_replace('_', DIRECTORY_SEPARATOR, $this->_modeValue['taskClassName']) . '.php';
         eval('$tasks += ' . $this->_modeValue['taskClassName'] . '::permissionedTaskTitles( $permission );');
     }
     if (isset($this->_ssID)) {
         if ($permission == CRM_Core_Permission::EDIT) {
             $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
         }
         $search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
         $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
         $this->assign_by_ref('savedSearch', $savedSearchValues);
         $this->assign('ssID', $this->_ssID);
     }
     if ($this->_context === 'smog') {
         if (!empty($this->_groupID)) {
             // set the group title
             $groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
             $this->assign_by_ref('group', $groupValues);
             // also set ssID if this is a saved search
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
             $this->assign('ssID', $ssID);
             //get the saved search mapping id
             if ($ssID) {
                 $this->_ssID = $ssID;
                 $ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
                 $this->assign('ssMappingID', $ssMappingId);
             }
         }
         $group_contact_status = array();
         foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
             if (!empty($k)) {
                 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
             }
         }
         $this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
         $this->assign('permissionedForGroup', FALSE);
         if (!empty($this->_groupID)) {
             // Set dynamic page title for 'Show Members of Group'
             CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
             // check if user has permission to edit members of this group
             $permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID, $this->_group[$this->_groupID]);
             if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
                 $this->assign('permissionedForGroup', TRUE);
             }
         }
     }
     // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
     if ($this->_context === 'amtg') {
         // Set dynamic page title for 'Add Members Group'
         CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
         // also set the group title and freeze the action task with Add Members to Group
         $groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
         $this->assign_by_ref('group', $groupValues);
         $this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
         $this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
     } else {
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0, " . (int) empty($this->_customSearchClass) . ");"));
     }
     // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
     $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked', 'onclick' => 'toggleTaskAction( true );'));
     $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
     if ($qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues)) {
         $qfKeyParam = "civicrm search {$qfKeyParam}";
         $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
         $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
     }
     $this->assign_by_ref('selectedContactIds', $selectedContactIds);
     $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);toggleTaskAction( true );toggleContactSelection( 'resetSel', '{$qfKeyParam}', 'reset' );"));
     $this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
     /*
      * add form checkboxes for each row. This is needed out here to conform to QF protocol
      * of all elements being declared in builQuickForm
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );  toggleCheckboxVals('mark_x_',this);return toggleContactSelection( 'toggleSelect', '" . $qfKeyParam . "' , 'multiple' );"));
         $unselectedContactIds = array();
         foreach ($rows as $row) {
             $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleContactSelection( '" . $row['checkbox'] . "', '" . $qfKeyParam . "' , 'single' );toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "');"));
             if (!in_array($row['contact_id'], $selectedContactIds)) {
                 $unselectedContactIds[] = $row['contact_id'];
             }
         }
         $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
     }
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Search.php


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