コード例 #1
0
 /**
  * Process the uploaded file.
  *
  * @return void
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $exportParams = $this->controller->exportValues('Select');
     $currentPath = CRM_Utils_System::currentPath();
     $urlParams = NULL;
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams = "&qfKey={$qfKey}";
     }
     //get the button name
     $buttonName = $this->controller->getButtonName('done');
     $buttonName1 = $this->controller->getButtonName('next');
     if ($buttonName == '_qf_Map_done') {
         $this->set('exportColumnCount', NULL);
         $this->controller->resetPage($this->_name);
         return CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, 'force=1' . $urlParams));
     }
     if ($this->controller->exportValue($this->_name, 'addMore')) {
         $this->set('exportColumnCount', $this->_exportColumnCount);
         return;
     }
     $mapperKeys = $params['mapper'][1];
     $checkEmpty = 0;
     foreach ($mapperKeys as $value) {
         if ($value[0]) {
             $checkEmpty++;
         }
     }
     if (!$checkEmpty) {
         $this->set('mappingId', NULL);
         CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, '_qf_Map_display=true' . $urlParams));
     }
     if ($buttonName1 == '_qf_Map_next') {
         if (!empty($params['updateMapping'])) {
             //save mapping fields
             CRM_Core_BAO_Mapping::saveMappingFields($params, $params['mappingId']);
         }
         if (!empty($params['saveMapping'])) {
             $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => $this->get('mappingTypeId'));
             $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
             //save mapping fields
             CRM_Core_BAO_Mapping::saveMappingFields($params, $saveMapping->id);
         }
     }
     //get the csv file
     CRM_Export_BAO_Export_Relationship::exportComponents($this->get('selectAll'), $this->get('componentIds'), $this->get('queryParams'), $this->get(CRM_Utils_Sort::SORT_ORDER), $mapperKeys, $this->get('returnProperties'), $this->get('exportMode'), $this->get('componentClause'), $this->get('componentTable'), $this->get('mergeSameAddress'), $this->get('mergeSameHousehold'), $exportParams);
 }
コード例 #2
0
ファイル: Group.php プロジェクト: ksecor/civicrm
 /**
  * This function create the hidden smart group when user perform
  * contact seach and want to send mailing to search contacts.
  *
  * @param  array $params ( reference ) an assoc array of name/value pairs
  * @return array ( smartGroupId, ssId ) smart group id and saved search id
  * @access public
  * @static
  */
 static function createHiddenSmartGroup($params)
 {
     $ssId = CRM_Utils_Array::value('saved_search_id', $params);
     //add mapping record only for search builder saved search
     $mappingId = null;
     if ($params['is_advanced'] == '2' && $params['is_searchBuilder'] == '1') {
         //save the mapping for search builder
         require_once "CRM/Core/BAO/Mapping.php";
         if (!$ssId) {
             //save record in mapping table
             $temp = array();
             $mappingParams = array('mapping_type' => 'Search Builder');
             $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp);
             $mappingId = $mapping->id;
         } else {
             //get the mapping id from saved search
             require_once "CRM/Contact/BAO/SavedSearch.php";
             $savedSearch =& new CRM_Contact_BAO_SavedSearch();
             $savedSearch->id = $ssId;
             $savedSearch->find(true);
             $mappingId = $savedSearch->mapping_id;
         }
         //save mapping fields
         CRM_Core_BAO_Mapping::saveMappingFields($params['form_values'], $mappingId);
     }
     //create/update saved search record.
     $savedSearch =& new CRM_Contact_BAO_SavedSearch();
     $savedSearch->id = $ssId;
     $savedSearch->form_values = serialize($params['form_values']);
     $savedSearch->mapping_id = $mappingId;
     $savedSearch->search_custom_id = CRM_Utils_Array::value('search_custom_id', $params);
     $savedSearch->save();
     $ssId = $savedSearch->id;
     if (!$ssId) {
         return null;
     }
     $smartGroupId = null;
     if (CRM_Utils_Array::value('saved_search_id', $params)) {
         $smartGroupId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $ssId, 'id', 'saved_search_id');
     } else {
         //create group only when new saved search.
         $groupParams = array('title' => "Hidden Smart Group {$ssId}", 'is_active' => CRM_Utils_Array::value('is_active', $params, 1), 'is_hidden' => CRM_Utils_Array::value('is_hidden', $params, 1), 'group_type' => CRM_Utils_Array::value('group_type', $params), 'visibility' => CRM_Utils_Array::value('visibility', $params), 'saved_search_id' => $ssId);
         require_once 'CRM/Contact/BAO/Group.php';
         $smartGroup = self::create($groupParams);
         $smartGroupId = $smartGroup->id;
     }
     return array($smartGroupId, $ssId);
 }
コード例 #3
0
ファイル: SaveSearch.php プロジェクト: nganivet/civicrm-core
 /**
  * Process the form after the input has been submitted and validated.
  */
 public function postProcess()
 {
     // saved search form values
     // get form values of all the forms in this controller
     $formValues = $this->controller->exportValues();
     $isAdvanced = $this->get('isAdvanced');
     $isSearchBuilder = $this->get('isSearchBuilder');
     // add mapping record only for search builder saved search
     $mappingId = NULL;
     if ($isAdvanced == '2' && $isSearchBuilder == '1') {
         //save the mapping for search builder
         if (!$this->_id) {
             //save record in mapping table
             $mappingParams = array('mapping_type' => 'Search Builder');
             $temp = array();
             $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp);
             $mappingId = $mapping->id;
         } else {
             //get the mapping id from saved search
             $savedSearch = new CRM_Contact_BAO_SavedSearch();
             $savedSearch->id = $this->_id;
             $savedSearch->find(TRUE);
             $mappingId = $savedSearch->mapping_id;
         }
         //save mapping fields
         CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId);
     }
     //save the search
     $savedSearch = new CRM_Contact_BAO_SavedSearch();
     $savedSearch->id = $this->_id;
     $savedSearch->form_values = serialize($this->get('formValues'));
     $savedSearch->mapping_id = $mappingId;
     $savedSearch->search_custom_id = $this->get('customSearchID');
     $savedSearch->save();
     $this->set('ssID', $savedSearch->id);
     CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success');
     // also create a group that is associated with this saved search only if new saved search
     $params = array();
     $params['title'] = $formValues['title'];
     $params['description'] = $formValues['description'];
     if (isset($formValues['group_type']) && is_array($formValues['group_type'])) {
         $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
     } else {
         $params['group_type'] = '';
     }
     $params['visibility'] = 'User and User Admin Only';
     $params['saved_search_id'] = $savedSearch->id;
     $params['is_active'] = 1;
     //CRM-14190
     $params['parents'] = $formValues['parents'];
     if ($this->_id) {
         $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id');
     }
     $group = CRM_Contact_BAO_Group::create($params);
     // CRM-9464
     $this->_id = $savedSearch->id;
     //CRM-14190
     if (!empty($formValues['parents'])) {
         CRM_Contact_BAO_GroupNestingCache::update();
     }
 }
コード例 #4
0
 /**
  * Process the form after the input has been submitted and validated.
  */
 public function postProcess()
 {
     // saved search form values
     // get form values of all the forms in this controller
     $formValues = $this->controller->exportValues();
     $isAdvanced = $this->get('isAdvanced');
     $isSearchBuilder = $this->get('isSearchBuilder');
     // add mapping record only for search builder saved search
     $mappingId = NULL;
     if ($isAdvanced == '2' && $isSearchBuilder == '1') {
         //save the mapping for search builder
         if (!$this->_id) {
             //save record in mapping table
             $mappingParams = array('mapping_type' => 'Search Builder');
             $temp = array();
             $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp);
             $mappingId = $mapping->id;
         } else {
             //get the mapping id from saved search
             $savedSearch = new CRM_Contact_BAO_SavedSearch();
             $savedSearch->id = $this->_id;
             $savedSearch->find(TRUE);
             $mappingId = $savedSearch->mapping_id;
         }
         //save mapping fields
         CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId);
     }
     //save the search
     $savedSearch = new CRM_Contact_BAO_SavedSearch();
     $savedSearch->id = $this->_id;
     // Use the query parameters rather than the form values - these have already been assessed / converted
     // with the extra knowledge that the form has.
     // Note that we want to move towards a standardised way of saving the query that is not
     // an exact match for the form requirements & task the form layer with converting backwards and forwards.
     // Ideally per CRM-17075 we will use entity reference fields heavily in the form layer & convert to the
     // sql operator syntax at the query layer.
     $savedSearch->form_values = serialize($this->get('queryParams'));
     $savedSearch->mapping_id = $mappingId;
     $savedSearch->search_custom_id = $this->get('customSearchID');
     $savedSearch->save();
     $this->set('ssID', $savedSearch->id);
     CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success');
     // also create a group that is associated with this saved search only if new saved search
     $params = array();
     $params['title'] = $formValues['title'];
     $params['description'] = $formValues['description'];
     if (isset($formValues['group_type']) && is_array($formValues['group_type'])) {
         $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
     } else {
         $params['group_type'] = '';
     }
     $params['visibility'] = 'User and User Admin Only';
     $params['saved_search_id'] = $savedSearch->id;
     $params['is_active'] = 1;
     //CRM-14190
     $params['parents'] = $formValues['parents'];
     if ($this->_id) {
         $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id');
     }
     $group = CRM_Contact_BAO_Group::create($params);
     // CRM-9464
     $this->_id = $savedSearch->id;
     //CRM-14190
     if (!empty($formValues['parents'])) {
         CRM_Contact_BAO_GroupNestingCache::update();
     }
 }
コード例 #5
0
 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return void
  */
 public function postProcess()
 {
     // saved search form values
     // get form values of all the forms in this controller
     $formValues = $this->controller->exportValues();
     $isAdvanced = $this->get('isAdvanced');
     $isSearchBuilder = $this->get('isSearchBuilder');
     // add mapping record only for search builder saved search
     $mappingId = null;
     if ($isAdvanced == '2' && $isSearchBuilder == '1') {
         //save the mapping for search builder
         require_once "CRM/Core/BAO/Mapping.php";
         if (!$this->_id) {
             //save record in mapping table
             $mappingParams = array('mapping_type' => 'Search Builder');
             $temp = array();
             $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp);
             $mappingId = $mapping->id;
         } else {
             //get the mapping id from saved search
             require_once "CRM/Contact/BAO/SavedSearch.php";
             $savedSearch = new CRM_Contact_BAO_SavedSearch();
             $savedSearch->id = $this->_id;
             $savedSearch->find(true);
             $mappingId = $savedSearch->mapping_id;
         }
         //save mapping fields
         CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId);
     }
     //save the search
     $savedSearch = new CRM_Contact_BAO_SavedSearch();
     $savedSearch->id = $this->_id;
     $savedSearch->form_values = serialize($this->get('formValues'));
     $savedSearch->mapping_id = $mappingId;
     $savedSearch->search_custom_id = $this->get('customSearchID');
     $savedSearch->save();
     $this->set('ssID', $savedSearch->id);
     CRM_Core_Session::setStatus(ts('Your smart group has been saved as \'%1\'.', array(1 => $formValues['title'])));
     // also create a group that is associated with this saved search only if new saved search
     $params = array();
     $params['title'] = $formValues['title'];
     $params['description'] = $formValues['description'];
     if (is_array($formValues['group_type'])) {
         $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR;
     } else {
         $params['group_type'] = '';
     }
     $params['visibility'] = 'User and User Admin Only';
     $params['saved_search_id'] = $savedSearch->id;
     $params['is_active'] = 1;
     if ($this->_id) {
         $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id');
     }
     require_once 'CRM/Contact/BAO/Group.php';
     $group =& CRM_Contact_BAO_Group::create($params);
 }
コード例 #6
0
ファイル: Map.php プロジェクト: bhirsch/voipdev
 /**
  * Process the uploaded file
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $currentPath = CRM_Utils_System::currentPath();
     //get the button name
     $buttonName = $this->controller->getButtonName('done');
     $buttonName1 = $this->controller->getButtonName('next');
     if ($buttonName == '_qf_Map_done') {
         $this->set('exportColumnCount', null);
         $this->controller->resetPage($this->_name);
         return CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, 'force=1'));
     }
     if ($this->controller->exportValue($this->_name, 'addMore')) {
         $this->set('exportColumnCount', $this->_exportColumnCount);
         return;
     }
     $mapperKeys = $params['mapper'][1];
     $checkEmpty = 0;
     foreach ($mapperKeys as $value) {
         if ($value[0]) {
             $checkEmpty++;
         }
     }
     if (!$checkEmpty) {
         $this->set('mappingId', null);
         require_once 'CRM/Utils/System.php';
         CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, '_qf_Map_display=true'));
     }
     if ($buttonName1 == '_qf_Map_next') {
         if (CRM_Utils_Array::value('updateMapping', $params)) {
             //save mapping fields
             CRM_Core_BAO_Mapping::saveMappingFields($params, $params['mappingId']);
         }
         if (CRM_Utils_Array::value('saveMapping', $params)) {
             $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => $this->get('mappingTypeId'));
             $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
             //save mapping fields
             CRM_Core_BAO_Mapping::saveMappingFields($params, $saveMapping->id);
         }
     }
     //get the csv file
     require_once "CRM/Export/BAO/Export.php";
     CRM_Export_BAO_Export::exportComponents($this->get('selectAll'), $this->get('componentIds'), $this->get('queryParams'), $this->get(CRM_Utils_Sort::SORT_ORDER), $mapperKeys, $this->get('returnProperties'), $this->get('exportMode'), $this->get('componentClause'));
 }