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


PHP CRM_Core_BAO_PrevNextCache::getSelection方法代码示例

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


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

示例1: addSearchContactIdsToSession

 /**
  * @return $this
  */
 private function addSearchContactIdsToSession()
 {
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
     $cacheKey = "civicrm search {$qfKey}";
     $selectedCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey);
     $contactIds = array();
     // Set contact IDs to the IDs of contacts selected (ticked) on the search result
     foreach ($selectedCids[$cacheKey] as $selectedCid => $ignore) {
         $contactIds[$selectedCid] = $selectedCid;
     }
     // So a bit of magic happens here
     // When you instantiate a CRM_Contract_Controller_Search object, it checks to see if a qfKey is passed in the $_REQUEST
     // in our case you should see it in the GET
     // If this is passed in, the controller tries to create itself using data from the SESSION
     // that means your controller is automatically populated with search data from a previous page
     $searchController = new CRM_Contact_Controller_Search();
     $totalContacts = count($contactIds);
     if ($totalContacts <= 0) {
         $totalContacts = $searchController->get('rowCount');
     }
     // CS: This needs to be commented out because the contact IDs are irrelevant at this point.
     // If the user hasn't ticked any users then this code would just give you back the first 50 contacts
     // Better to leave the contactIds empty which tells us that nothing is actually selected
     if (!$contactIds) {
         foreach ($this->get('rows') as $contact) {
             $contactIds[$contact['contact_id']] = $contact['contact_id'];
         }
     }
     simplemail_civicrm_addToSessionScope('contactCountFromSearch', $totalContacts);
     simplemail_civicrm_addToSessionScope('contactIds', $contactIds);
     return $this;
 }
开发者ID:jaapjansma,项目名称:uk.co.compucorp.civicrm.simplemail,代码行数:35,代码来源:SimpleMailRecipientsFromSearch.php

示例2: selectUnselectRelationships

 /**
  * Used to store selected contacts across multiple pages in advanced search.
  */
 public static function selectUnselectRelationships()
 {
     $name = CRM_Utils_Array::value('name', $_REQUEST);
     $cacheKey = CRM_Utils_Array::value('qfKey', $_REQUEST);
     $state = CRM_Utils_Array::value('state', $_REQUEST, 'checked');
     $variableType = CRM_Utils_Array::value('variableType', $_REQUEST, 'single');
     $actionToPerform = CRM_Utils_Array::value('action', $_REQUEST, 'select');
     if ($variableType == 'multiple') {
         // action post value only works with multiple type variable
         if ($name) {
             //multiple names like mark_x_1-mark_x_2 where 1,2 are cids
             $elements = explode('-', $name);
             foreach ($elements as $key => $element) {
                 $elements[$key] = self::_convertToId($element);
             }
             CRM_Core_BAO_PrevNextCache::markSelection($cacheKey, $actionToPerform, $elements, 'civicrm_relationship');
         } else {
             CRM_Core_BAO_PrevNextCache::markSelection($cacheKey, $actionToPerform, NULL, 'civicrm_relationship');
         }
     } elseif ($variableType == 'single') {
         $cId = self::_convertToId($name);
         $action = $state == 'checked' ? 'select' : 'unselect';
         CRM_Core_BAO_PrevNextCache::markSelection($cacheKey, $action, $cId, 'civicrm_relationship');
     }
     $contactIds = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey, 'get', 'civicrm_relationship');
     $countSelectionCids = count($contactIds[$cacheKey]);
     $arrRet = array('getCount' => $countSelectionCids);
     CRM_Utils_JSON::output($arrRet);
 }
开发者ID:Chirojeugd-Vlaanderen,项目名称:civicrm-relationship-entity,代码行数:32,代码来源:AJAX.php

示例3: buildQuickForm

 /**
  * Build the common elements between the search/advanced form.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
     $permission = CRM_Core_Permission::getPermission();
     // some tasks.. what do we want to do with the selected contacts ?
     $tasks = array();
     if ($this->_componentMode == 1 || $this->_componentMode == 7) {
         $tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
     } else {
         $className = $this->_modeValue['taskClassName'];
         $tasks += $className::permissionedTaskTitles($permission, FALSE);
     }
     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') {
         // CRM-11788, we might want to do this for all of search where force=1
         $formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues);
         $getQFKey = CRM_Utils_Array::value('qfKey', $_GET);
         $postQFKey = CRM_Utils_Array::value('qfKey', $_POST);
         if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
             $url = CRM_Utils_System::makeURL('qfKey') . $formQFKey;
             CRM_Utils_System::redirect($url);
         }
         $permissionForGroup = FALSE;
         if (!empty($this->_groupID)) {
             // check if user has permission to edit members of this group
             $permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID);
             if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
                 $permissionForGroup = TRUE;
             }
             // check if _groupID exists, it might not if
             // we are displaying a hidden group
             if (!isset($this->_group[$this->_groupID])) {
                 $this->_group[$this->_groupID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'title');
             }
             // 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);
             }
             // Set dynamic page title for 'Show Members of Group'
             CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
         }
         $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', $permissionForGroup);
     }
     // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
     if ($this->_context === 'amtg') {
         // check if _groupID exists, it might not if
         // we are displaying a hidden group
         if (!isset($this->_group[$this->_amtgID])) {
             $this->assign('permissionedForGroup', FALSE);
             $this->_group[$this->_amtgID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID, 'title');
         }
         // 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' => 'crm-form-submit'));
         $this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
         $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
         $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
         $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
         $this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
     }
     $selectedContactIds = array();
     $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues);
     // We use ajax to handle selections only if the search results component_mode is set to "contacts"
     if ($qfKeyParam && ($this->get('component_mode') <= 1 || $this->get('component_mode') == 7)) {
         $this->addClass('crm-ajax-selection-form');
         $qfKeyParam = "civicrm search {$qfKeyParam}";
         $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
         $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
     }
     $this->assign_by_ref('selectedContactIds', $selectedContactIds);
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Search.php

示例4: preProcess

 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $values = $this->controller->exportValues('Search');
     $this->_task = $values['task'];
     $campaignTasks = CRM_Campaign_Task::tasks();
     $taskName = CRM_Utils_Array::value($this->_task, $campaignTasks);
     $this->assign('taskName', $taskName);
     $ids = array();
     if ($values['radio_ts'] == 'ts_sel') {
         foreach ($values as $name => $value) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             }
         }
     } else {
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
         $cacheKey = "civicrm search {$qfKey}";
         $allCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey, "getall");
         $ids = array_keys($allCids[$cacheKey]);
         $this->assign('totalSelectedVoters', count($ids));
     }
     if (!empty($ids)) {
         $this->_componentClause = 'contact_a.id IN ( ' . implode(',', $ids) . ' ) ';
         $this->assign('totalSelectedVoters', count($ids));
     }
     $this->_voterIds = $this->_contactIds = $this->_componentIds = $ids;
     $this->assign('totalSelectedContacts', count($this->_contactIds));
     //set the context for redirection for any task actions
     $session = CRM_Core_Session::singleton();
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= '&qfKey=' . $qfKey;
     }
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/survey/search', $urlParams));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:39,代码来源:Task.php

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

示例6: preProcessCommon

 /**
  * Common pre-processing function.
  *
  * @param CRM_Core_Form $form
  * @param bool $useTable
  */
 public static function preProcessCommon(&$form, $useTable = FALSE)
 {
     $form->_contactIds = array();
     $form->_contactTypes = array();
     // get the submitted values of the search form
     // we'll need to get fv from either search or adv search in the future
     $fragment = 'search';
     if ($form->_action == CRM_Core_Action::ADVANCED) {
         self::$_searchFormValues = $form->controller->exportValues('Advanced');
         $fragment .= '/advanced';
     } elseif ($form->_action == CRM_Core_Action::PROFILE) {
         self::$_searchFormValues = $form->controller->exportValues('Builder');
         $fragment .= '/builder';
     } elseif ($form->_action == CRM_Core_Action::COPY) {
         self::$_searchFormValues = $form->controller->exportValues('Custom');
         $fragment .= '/custom';
     } else {
         self::$_searchFormValues = $form->controller->exportValues('Basic');
     }
     //set the user context for redirection of task actions
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $cacheKey = "civicrm search {$qfKey}";
     $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
     $session = CRM_Core_Session::singleton();
     $session->replaceUserContext($url);
     $form->_task = CRM_Utils_Array::value('task', self::$_searchFormValues);
     $crmContactTaskTasks = CRM_Contact_Task::taskTitles();
     $form->assign('taskName', CRM_Utils_Array::value($form->_task, $crmContactTaskTasks));
     if ($useTable) {
         $form->_componentTable = CRM_Core_DAO::createTempTableName('civicrm_task_action', TRUE, $qfKey);
         $sql = " DROP TABLE IF EXISTS {$form->_componentTable}";
         CRM_Core_DAO::executeQuery($sql);
         $sql = "CREATE TABLE {$form->_componentTable} ( contact_id int primary key) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
         CRM_Core_DAO::executeQuery($sql);
     }
     // all contacts or action = save a search
     if (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_all' || $form->_task == CRM_Contact_Task::SAVE_SEARCH) {
         $sortByCharacter = $form->get('sortByCharacter');
         $cacheKey = $sortByCharacter && $sortByCharacter != 'all' ? "{$cacheKey}_alphabet" : $cacheKey;
         // since we don't store all contacts in prevnextcache, when user selects "all" use query to retrieve contacts
         // rather than prevnext cache table for most of the task actions except export where we rebuild query to fetch
         // final result set
         if ($useTable) {
             $allCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey, "getall");
         } else {
             $allCids[$cacheKey] = $form->getContactIds();
         }
         $form->_contactIds = array();
         if ($useTable) {
             $count = 0;
             $insertString = array();
             foreach ($allCids[$cacheKey] as $cid => $ignore) {
                 $count++;
                 $insertString[] = " ( {$cid} ) ";
                 if ($count % 200 == 0) {
                     $string = implode(',', $insertString);
                     $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}";
                     CRM_Core_DAO::executeQuery($sql);
                     $insertString = array();
                 }
             }
             if (!empty($insertString)) {
                 $string = implode(',', $insertString);
                 $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}";
                 CRM_Core_DAO::executeQuery($sql);
             }
         } else {
             // filter duplicates here
             // CRM-7058
             // might be better to do this in the query, but that logic is a bit complex
             // and it decides when to use distinct based on input criteria, which needs
             // to be fixed and optimized.
             foreach ($allCids[$cacheKey] as $cid => $ignore) {
                 $form->_contactIds[] = $cid;
             }
         }
     } elseif (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_sel') {
         // selected contacts only
         // need to perform action on only selected contacts
         $insertString = array();
         // refire sql in case of custom seach
         if ($form->_action == CRM_Core_Action::COPY) {
             // selected contacts only
             // need to perform action on only selected contacts
             foreach (self::$_searchFormValues as $name => $value) {
                 if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                     $contactID = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
                     if ($useTable) {
                         $insertString[] = " ( {$contactID} ) ";
                     } else {
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:Task.php

示例7: selectUnselectContacts

 static function selectUnselectContacts()
 {
     $name = CRM_Utils_Array::value('name', $_POST);
     $cacheKey = CRM_Utils_Array::value('qfKey', $_POST);
     $state = CRM_Utils_Array::value('state', $_POST, 'checked');
     $variableType = CRM_Utils_Array::value('variableType', $_POST, 'single');
     $actionToPerform = CRM_Utils_Array::value('action', $_POST, 'select');
     if ($actionToPerform == 'countSelection') {
         $contactIds = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey);
         $countSelectionCids = count($contactIds[$cacheKey]);
         $arrRet = array('getCount' => $countSelectionCids);
         echo json_encode($arrRet);
         CRM_Utils_System::civiExit();
     } elseif ($variableType == 'multiple') {
         // action post value only works with multiple type variable
         if ($name) {
             //multiple names like mark_x_1-mark_x_2 where 1,2 are cids
             $elements = explode('-', $name);
             foreach ($elements as $key => $element) {
                 $elements[$key] = self::_convertToId($element);
             }
             CRM_Core_BAO_PrevNextCache::markSelection($cacheKey, $actionToPerform, $elements);
         } else {
             CRM_Core_BAO_PrevNextCache::markSelection($cacheKey, $actionToPerform);
         }
     } elseif ($variableType == 'single') {
         $cId = self::_convertToId($name);
         $action = $state == 'checked' ? 'select' : 'unselect';
         CRM_Core_BAO_PrevNextCache::markSelection($cacheKey, $action, $cId);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:31,代码来源:AJAX.php

示例8: buildQuickForm

 /**
  * Build the common elements between the search/advanced form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
     $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 {
         $className = $this->_modeValue['taskClassName'];
         $tasks += $className::permissionedTaskTitles($permission, false);
     }
     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') {
         // CRM-11788, we might want to do this for all of search where force=1
         $formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues);
         $getQFKey = CRM_Utils_Array::value('qfKey', $_GET);
         $postQFKey = CRM_Utils_Array::value('qfKey', $_POST);
         if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
             $url = CRM_Utils_System::makeURL('qfKey') . $formQFKey;
             CRM_Utils_System::redirect($url);
         }
         if (!empty($this->_groupID)) {
             $permissionForGroup = FALSE;
             // check if user has permission to edit members of this group
             $permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID);
             if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
                 $permissionForGroup = TRUE;
             }
             // check if _groupID exists, it might not if
             // we are displaying a hidden group
             if (!isset($this->_group[$this->_groupID])) {
                 $permissionForGroup = FALSE;
                 $this->_group[$this->_groupID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'title');
             }
             $this->assign('permissionedForGroup', $permissionForGroup);
             // 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);
             }
             // Set dynamic page title for 'Show Members of Group'
             CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
         }
         $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);
     }
     // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
     if ($this->_context === 'amtg') {
         // check if _groupID exists, it might not if
         // we are displaying a hidden group
         if (!isset($this->_group[$this->_amtgID])) {
             $this->assign('permissionedForGroup', FALSE);
             $this->_group[$this->_amtgID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID, 'title');
         }
         // 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, 1);"));
     }
     // 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);
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Search.php

示例9: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $this->_searchPane = CRM_Utils_Array::value('searchPane', $_GET);
     if (!$this->_searchPane || $this->_searchPane == 'basic') {
         CRM_Relationship_Form_Search_Criteria::basic($this);
     }
     $allPanes = array();
     $paneNames = array(ts('Custom Fields') => 'custom', ts('Contact A') => 'contact_a', ts('Contact B') => 'contact_b');
     //check if there are any custom data searchable fields
     $extends = array('Relationship');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     // if no searchable fields unset panel
     if (empty($groupDetails)) {
         unset($paneNames[ts('Custom Fields')]);
     }
     //TODO: allow hook injected panes
     //$hookPanes = array();
     //CRM_Contact_BAO_Query_Hook::singleton()->registerAdvancedSearchPane($hookPanes);
     //$paneNames = array_merge($paneNames, $hookPanes);
     $this->_paneTemplatePath = array();
     foreach ($paneNames as $name => $type) {
         $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/rel/search', "snippet=1&searchPane={$type}&qfKey={$this->controller->_key}"), 'open' => 'false', 'id' => $type);
         // see if we need to include this paneName in the current form
         if ($this->_searchPane == $type || !empty($_POST["hidden_{$type}"]) || CRM_Utils_Array::value("hidden_{$type}", $this->_formValues)) {
             $allPanes[$name]['open'] = 'true';
             CRM_Relationship_Form_Search_Criteria::$type($this);
             $template = ucfirst($type);
             $this->_paneTemplatePath[$type] = "CRM/Relationship/Form/Search/Criteria/{$template}.tpl";
         }
     }
     $this->assign('allPanes', $allPanes);
     if (!$this->_searchPane) {
         parent::buildQuickForm();
         $resources = CRM_Core_Resources::singleton();
         $resources->addScriptFile('be.chiro.civi.relationship', 'js/markrelationselector.js', 1, 'html-header');
         //remove original js file
         $searchformjspath = $resources->getUrl('civicrm', 'js/crm.searchForm.js', TRUE);
         unset(CRM_Core_Region::instance('html-header')->_snippets[$searchformjspath]);
         $permission = CRM_Core_Permission::getPermission();
         // some tasks.. what do we want to do with the selected contacts ?
         $tasks = CRM_Relationship_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
         $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
         $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
         $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
         $this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
         $selectedRelationshipIds = array();
         $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues);
         // We use ajax to handle selections only if the search results component_mode is set to "relationships"
         if ($qfKeyParam && $this->get('component_mode') <= 1) {
             $this->addClass('crm-ajax-selection-form');
             $qfKeyParam = "civicrm search {$qfKeyParam}";
             $selectedRelationshipIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
             $selectedRelationshipIds = array_keys($selectedRelationshipIdsArr[$qfKeyParam]);
         }
         $this->assign_by_ref('selectedRelationshipIds', $selectedRelationshipIds);
         $rows = $this->get('rows');
         if (is_array($rows)) {
             $this->addRowSelectors($rows);
         }
     } else {
         $this->assign('suppressForm', TRUE);
     }
 }
开发者ID:Chirojeugd-Vlaanderen,项目名称:civicrm-relationship-entity,代码行数:66,代码来源:Search.php


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