Ejemplo n.º 1
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $this->_id = NULL;
     // get the submitted values of the search form
     // we'll need to get fv from either search or adv search in the future
     if ($this->_action == CRM_Core_Action::ADVANCED) {
         $values = $this->controller->exportValues('Advanced');
     } elseif ($this->_action == CRM_Core_Action::PROFILE) {
         $values = $this->controller->exportValues('Builder');
     } elseif ($this->_action == CRM_Core_Action::COPY) {
         $values = $this->controller->exportValues('Custom');
     } else {
         $values = $this->controller->exportValues('Basic');
     }
     $this->_task = CRM_Utils_Array::value('task', $values);
     $crmContactTaskTasks = CRM_Contact_Task::taskTitles();
     $this->assign('taskName', CRM_Utils_Array::value($this->_task, $crmContactTaskTasks));
 }
Ejemplo n.º 2
0
 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) {
         $values = $form->controller->exportValues('Advanced');
         $fragment .= '/advanced';
     } else {
         if ($form->_action == CRM_Core_Action::PROFILE) {
             $values = $form->controller->exportValues('Builder');
             $fragment .= '/builder';
         } else {
             if ($form->_action == CRM_Core_Action::COPY) {
                 $values = $form->controller->exportValues('Custom');
                 $fragment .= '/custom';
             } else {
                 $values = $form->controller->exportValues('Basic');
             }
         }
     }
     //set the user context for redirection of task actions
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
     require_once 'CRM/Utils/Rule.php';
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
     $session = CRM_Core_Session::singleton();
     $session->replaceUserContext($url);
     require_once 'CRM/Contact/Task.php';
     $form->_task = CRM_Utils_Array::value('task', $values);
     $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', false);
         $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', $values) == 'ts_all' || $form->_task == CRM_Contact_Task::SAVE_SEARCH) {
         // need to perform action on all contacts
         // fire the query again and get the contact id's + display name
         $sortID = null;
         if ($form->get(CRM_Utils_Sort::SORT_ID)) {
             $sortID = CRM_Utils_Sort::sortIDValue($form->get(CRM_Utils_Sort::SORT_ID), $form->get(CRM_Utils_Sort::SORT_DIRECTION));
         }
         $selectorName = $form->controller->selectorName();
         require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php';
         $fv = $form->get('formValues');
         $customClass = $form->get('customSearchClass');
         require_once "CRM/Core/BAO/Mapping.php";
         $returnProperties = CRM_Core_BAO_Mapping::returnProperties($values);
         eval('$selector   = new ' . $selectorName . '( $customClass, $fv, null, $returnProperties ); ');
         $params = $form->get('queryParams');
         // fix for CRM-5165
         $sortByCharacter = $form->get('sortByCharacter');
         if ($sortByCharacter && $sortByCharacter != 1) {
             $params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0);
         }
         $dao =& $selector->contactIDQuery($params, $form->_action, $sortID);
         $form->_contactIds = array();
         if ($useTable) {
             $count = 0;
             $insertString = array();
             while ($dao->fetch()) {
                 $count++;
                 $insertString[] = " ( {$dao->contact_id} ) ";
                 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);
             }
             $dao->free();
         } 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.
             $alreadySeen = array();
             while ($dao->fetch()) {
                 if (!array_key_exists($dao->contact_id, $alreadySeen)) {
                     $form->_contactIds[] = $dao->contact_id;
                     $alreadySeen[$dao->contact_id] = 1;
                 }
             }
             unset($alreadySeen);
             $dao->free();
         }
     } else {
         if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') {
             // selected contacts only
             // need to perform action on only selected contacts
             $insertString = array();
             foreach ($values 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 {
                         $form->_contactIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
                     }
                 }
             }
             if (!empty($insertString)) {
                 $string = implode(',', $insertString);
                 $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}";
                 CRM_Core_DAO::executeQuery($sql);
             }
         }
     }
     //contact type for pick up profiles as per selected contact types with subtypes
     //CRM-5521
     if ($selectedTypes = CRM_Utils_Array::value('contact_type', $values)) {
         if (!is_array($selectedTypes)) {
             $selectedTypes = explode(" ", $selectedTypes);
         }
         foreach ($selectedTypes as $ct => $dontcare) {
             if (strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR) === false) {
                 $form->_contactTypes[] = $ct;
             } else {
                 $separator = strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR);
                 $form->_contactTypes[] = substr($ct, $separator + 1);
             }
         }
     }
     if (!empty($form->_contactIds)) {
         $form->_componentClause = ' contact_a.id IN ( ' . implode(',', $form->_contactIds) . ' ) ';
         $form->assign('totalSelectedContacts', count($form->_contactIds));
         $form->_componentIds = $form->_contactIds;
     }
 }
Ejemplo n.º 3
0
Archivo: Task.php Proyecto: kidaa30/yes
 /**
  * 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 {
                         $form->_contactIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
                     }
                 }
             }
         } else {
             // fetching selected contact ids of passed cache key
             $selectedCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey);
             foreach ($selectedCids[$cacheKey] as $selectedCid => $ignore) {
                 if ($useTable) {
                     $insertString[] = " ( {$selectedCid} ) ";
                 } else {
                     $form->_contactIds[] = $selectedCid;
                 }
             }
         }
         if (!empty($insertString)) {
             $string = implode(',', $insertString);
             $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}";
             CRM_Core_DAO::executeQuery($sql);
         }
     }
     //contact type for pick up profiles as per selected contact types with subtypes
     //CRM-5521
     if ($selectedTypes = CRM_Utils_Array::value('contact_type', self::$_searchFormValues)) {
         if (!is_array($selectedTypes)) {
             $selectedTypes = explode(' ', $selectedTypes);
         }
         foreach ($selectedTypes as $ct => $dontcare) {
             if (strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR) === FALSE) {
                 $form->_contactTypes[] = $ct;
             } else {
                 $separator = strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR);
                 $form->_contactTypes[] = substr($ct, $separator + 1);
             }
         }
     }
     if (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_sel' && $form->_action != CRM_Core_Action::COPY) {
         $sel = CRM_Utils_Array::value('radio_ts', self::$_searchFormValues);
         $form->assign('searchtype', $sel);
         $result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
         $form->assign("value", $result);
     }
     if (!empty($form->_contactIds)) {
         $form->_componentClause = ' contact_a.id IN ( ' . implode(',', $form->_contactIds) . ' ) ';
         $form->assign('totalSelectedContacts', count($form->_contactIds));
         $form->_componentIds = $form->_contactIds;
     }
 }
Ejemplo n.º 4
0
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     //special case for custom search, directly give option to download csv file
     $customSearchID = $this->get('customSearchID');
     if ($customSearchID) {
         require_once 'CRM/Export/BAO/Export.php';
         CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'), $this->get('formValues'), $this->get(CRM_Utils_Sort::SORT_ORDER));
     }
     $this->_selectAll = false;
     $this->_exportMode = self::CONTACT_EXPORT;
     // get the submitted values based on search
     if ($this->_action == CRM_Core_Action::ADVANCED) {
         $values = $this->controller->exportValues('Advanced');
     } else {
         if ($this->_action == CRM_Core_Action::PROFILE) {
             $values = $this->controller->exportValues('Builder');
         } else {
             if ($this->_action == CRM_Core_Action::COPY) {
                 $values = $this->controller->exportValues('Custom');
             } else {
                 // we need to determine component export
                 $stateMachine =& $this->controller->getStateMachine();
                 $formName = CRM_Utils_System::getClassName($stateMachine);
                 $componentName = explode('_', $formName);
                 $components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');
                 if (in_array($componentName[1], $components)) {
                     eval('$this->_exportMode = self::' . strtoupper($componentName[1]) . '_EXPORT;');
                     require_once "CRM/{$componentName[1]}/Form/Task.php";
                     eval('CRM_' . $componentName[1] . '_Form_Task::preProcessCommon( $this, true );');
                     $values = $this->controller->exportValues('Search');
                 } else {
                     $values = $this->controller->exportValues('Basic');
                 }
             }
         }
     }
     $componentMode = $this->get('component_mode');
     switch ($componentMode) {
         case 2:
             require_once "CRM/Contribute/Form/Task.php";
             CRM_Contribute_Form_Task::preProcessCommon($this, true);
             $this->_exportMode = self::CONTRIBUTE_EXPORT;
             $componentName = array('', 'Contribute');
             break;
         case 3:
             require_once "CRM/Event/Form/Task.php";
             CRM_Event_Form_Task::preProcessCommon($this, true);
             $this->_exportMode = self::EVENT_EXPORT;
             $componentName = array('', 'Event');
             break;
         case 4:
             require_once "CRM/Activity/Form/Task.php";
             CRM_Activity_Form_Task::preProcessCommon($this, true);
             $this->_exportMode = self::ACTIVITY_EXPORT;
             $componentName = array('', 'Activity');
             break;
     }
     require_once 'CRM/Contact/Task.php';
     $this->_task = $values['task'];
     if ($this->_exportMode == self::CONTACT_EXPORT) {
         $contactTasks = CRM_Contact_Task::taskTitles();
         $taskName = $contactTasks[$this->_task];
         require_once "CRM/Contact/Form/Task.php";
         CRM_Contact_Form_Task::preProcessCommon($this, true);
     } else {
         $this->assign('taskName', "Export {$componentName['1']}");
         eval('$componentTasks = CRM_' . $componentName[1] . '_Task::tasks();');
         $taskName = $componentTasks[$this->_task];
     }
     if ($this->_componentTable) {
         $query = "\nSELECT count(*)\nFROM   {$this->_componentTable}\n";
         $totalSelectedRecords = CRM_Core_DAO::singleValueQuery($query);
     } else {
         $totalSelectedRecords = count($this->_componentIds);
     }
     $this->assign('totalSelectedRecords', $totalSelectedRecords);
     $this->assign('taskName', $taskName);
     // all records actions = save a search
     if ($values['radio_ts'] == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) {
         $this->_selectAll = true;
         $this->assign('totalSelectedRecords', $this->get('rowCount'));
     }
     $this->set('componentIds', $this->_componentIds);
     $this->set('selectAll', $this->_selectAll);
     $this->set('exportMode', $this->_exportMode);
     $this->set('componentClause', $this->_componentClause);
     $this->set('componentTable', $this->_componentTable);
 }
Ejemplo n.º 5
0
 /**
  * Build all the data structures needed to build the form.
  *
  * @param
  *
  * @return void
  */
 public function preProcess()
 {
     //special case for custom search, directly give option to download csv file
     $customSearchID = $this->get('customSearchID');
     if ($customSearchID) {
         CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'), $this->get('formValues'), $this->get(CRM_Utils_Sort::SORT_ORDER));
     }
     $this->_selectAll = FALSE;
     $this->_exportMode = self::CONTACT_EXPORT;
     $this->_componentIds = array();
     $this->_componentClause = NULL;
     // get the submitted values based on search
     if ($this->_action == CRM_Core_Action::ADVANCED) {
         $values = $this->controller->exportValues('Advanced');
     } elseif ($this->_action == CRM_Core_Action::PROFILE) {
         $values = $this->controller->exportValues('Builder');
     } elseif ($this->_action == CRM_Core_Action::COPY) {
         $values = $this->controller->exportValues('Custom');
     } else {
         // we need to determine component export
         $stateMachine = $this->controller->getStateMachine();
         $formName = CRM_Utils_System::getClassName($stateMachine);
         $componentName = explode('_', $formName);
         $components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');
         if (in_array($componentName[1], $components)) {
             switch ($componentName[1]) {
                 case 'Contribute':
                     $this->_exportMode = self::CONTRIBUTE_EXPORT;
                     break;
                 case 'Member':
                     $this->_exportMode = self::MEMBER_EXPORT;
                     break;
                 case 'Event':
                     $this->_exportMode = self::EVENT_EXPORT;
                     break;
                 case 'Pledge':
                     $this->_exportMode = self::PLEDGE_EXPORT;
                     break;
                 case 'Case':
                     $this->_exportMode = self::CASE_EXPORT;
                     break;
                 case 'Grant':
                     $this->_exportMode = self::GRANT_EXPORT;
                     break;
                 case 'Activity':
                     $this->_exportMode = self::ACTIVITY_EXPORT;
                     break;
             }
             $className = "CRM_{$componentName[1]}_Form_Task";
             $className::preProcessCommon($this, TRUE);
             $values = $this->controller->exportValues('Search');
         } else {
             $values = $this->controller->exportValues('Basic');
         }
     }
     $count = 0;
     $this->_matchingContacts = FALSE;
     if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') {
         foreach ($values as $key => $value) {
             if (strstr($key, 'mark_x')) {
                 $count++;
             }
             if ($count > 2) {
                 $this->_matchingContacts = TRUE;
                 break;
             }
         }
     }
     $componentMode = $this->get('component_mode');
     switch ($componentMode) {
         case 2:
             CRM_Contribute_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::CONTRIBUTE_EXPORT;
             $componentName = array('', 'Contribute');
             break;
         case 3:
             CRM_Event_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::EVENT_EXPORT;
             $componentName = array('', 'Event');
             break;
         case 4:
             CRM_Activity_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::ACTIVITY_EXPORT;
             $componentName = array('', 'Activity');
             break;
         case 5:
             CRM_Member_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::MEMBER_EXPORT;
             $componentName = array('', 'Member');
             break;
         case 6:
             CRM_Case_Form_Task::preProcessCommon($this, TRUE);
             $this->_exportMode = self::CASE_EXPORT;
             $componentName = array('', 'Case');
             break;
     }
     $this->_task = $values['task'];
     if ($this->_exportMode == self::CONTACT_EXPORT) {
         $contactTasks = CRM_Contact_Task::taskTitles();
         $taskName = $contactTasks[$this->_task];
         $component = FALSE;
         CRM_Contact_Form_Task::preProcessCommon($this, TRUE);
     } else {
         $this->assign('taskName', "Export {$componentName['1']}");
         $className = "CRM_{$componentName[1]}_Task";
         $componentTasks = $className::tasks();
         $taskName = $componentTasks[$this->_task];
         $component = TRUE;
     }
     if ($this->_componentTable) {
         $query = "\nSELECT count(*)\nFROM   {$this->_componentTable}\n";
         $totalSelectedRecords = CRM_Core_DAO::singleValueQuery($query);
     } else {
         $totalSelectedRecords = count($this->_componentIds);
     }
     $this->assign('totalSelectedRecords', $totalSelectedRecords);
     $this->assign('taskName', $taskName);
     $this->assign('component', $component);
     // all records actions = save a search
     if ($values['radio_ts'] == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) {
         $this->_selectAll = TRUE;
         $rowCount = $this->get('rowCount');
         if ($rowCount > 2) {
             $this->_matchingContacts = TRUE;
         }
         $this->assign('totalSelectedRecords', $rowCount);
     }
     $this->assign('matchingContacts', $this->_matchingContacts);
     $this->set('componentIds', $this->_componentIds);
     $this->set('selectAll', $this->_selectAll);
     $this->set('exportMode', $this->_exportMode);
     $this->set('componentClause', $this->_componentClause);
     $this->set('componentTable', $this->_componentTable);
 }
Ejemplo n.º 6
0
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_contactIds = array();
     $this->_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 ($this->_action == CRM_Core_Action::ADVANCED) {
         $values = $this->controller->exportValues('Advanced');
         $fragment .= '/advanced';
     } else {
         if ($this->_action == CRM_Core_Action::PROFILE) {
             $values = $this->controller->exportValues('Builder');
             $fragment .= '/builder';
         } else {
             if ($this->_action == CRM_Core_Action::COPY) {
                 $values = $this->controller->exportValues('Custom');
                 $fragment .= '/custom';
             } else {
                 $values = $this->controller->exportValues('Basic');
             }
         }
     }
     //set the user context for redirection of task actions
     $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, 'force=1');
     $session =& CRM_Core_Session::singleton();
     $session->replaceUserContext($url);
     require_once 'CRM/Contact/Task.php';
     $this->_task = $values['task'];
     $crmContactTaskTasks = CRM_Contact_Task::taskTitles();
     $this->assign('taskName', $crmContactTaskTasks[$this->_task]);
     // all contacts or action = save a search
     if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) {
         // need to perform action on all contacts
         // fire the query again and get the contact id's + display name
         $sortID = null;
         if ($this->get(CRM_Utils_Sort::SORT_ID)) {
             $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
         }
         $selectorName = $this->controller->selectorName();
         require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php';
         $fv = $this->get('formValues');
         $customClass = $this->get('customSearchClass');
         require_once "CRM/Core/BAO/Mapping.php";
         $returnProperties = CRM_Core_BAO_Mapping::returnProperties($values);
         eval('$selector   =& new ' . $selectorName . '( $customClass, $fv, null, $returnProperties ); ');
         $params = $this->get('queryParams');
         // fix for CRM-5165
         $sortByCharacter = $this->get('sortByCharacter');
         if ($sortByCharacter && $sortByCharacter != 1) {
             $params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0);
         }
         $dao =& $selector->contactIDQuery($params, $this->_action, $sortID);
         while ($dao->fetch()) {
             $this->_contactIds[] = $dao->contact_id;
         }
     } else {
         if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') {
             // selected contacts only
             // need to perform action on only selected contacts
             foreach ($values as $name => $value) {
                 if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                     $this->_contactIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
                 }
             }
         }
     }
     //contact type for pick up profiles as per selected contact types with subtypes
     //CRM-5521
     if ($selectedTypes = CRM_Utils_Array::value('contact_type', $values)) {
         $selectedTypes = explode(" ", $selectedTypes);
         foreach ($selectedTypes as $ct => $dontcare) {
             if (strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR) === false) {
                 $this->_contactTypes[] = $ct;
             } else {
                 $separator = strpos($ct, CRM_Core_DAO::VALUE_SEPARATOR);
                 $this->_contactTypes[] = substr($ct, $separator + 1);
             }
         }
     }
     if (!empty($this->_contactIds)) {
         $this->_componentClause = ' contact_a.id IN ( ' . implode(',', $this->_contactIds) . ' ) ';
         $this->assign('totalSelectedContacts', count($this->_contactIds));
         $this->_componentIds = $this->_contactIds;
     }
 }