Пример #1
0
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_contactIds = array();
     $this->_selectAll = false;
     // 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');
     } else {
         $values = $this->controller->exportValues('Search');
     }
     $this->_task = $values['task'];
     $crmContactTaskTasks = CRM_Contact_Task::tasks();
     $this->assign('taskName', $crmContactTaskTasks[$this->_task]);
     // all contacts or action = save a search
     if ($values['radio_ts'] == 'ts_all' || $this->_task == CRM_CONTACT_TASK_SAVE_SEARCH) {
         $this->_selectAll = true;
         $this->assign('totalSelectedContacts', $this->get('rowCount'));
     } else {
         if ($values['radio_ts'] == '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);
                 }
             }
             $this->assign('totalSelectedContacts', count($this->_contactIds));
         }
     }
     $this->set('contactIds', $this->_contactIds);
     $this->set('selectAll', $this->_selectAll);
 }
Пример #2
0
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_contactIds = array();
     // 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');
     } else {
         $values = $this->controller->exportValues('Search');
     }
     $this->_task = $values['task'];
     $crmContactTaskTasks = CRM_Contact_Task::tasks();
     $this->assign('taskName', $crmContactTaskTasks[$this->_task]);
     // all contacts or action = save a search
     if ($values['radio_ts'] == '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
         $contact =& new CRM_Contact_BAO_Contact();
         $fv = $this->get('formValues');
         $query =& new CRM_Contact_BAO_Query($fv);
         $ids = $query->searchQuery(0, 0, null, false, false, false, true, false);
         $this->_contactIds = explode(',', $ids);
     } else {
         if ($values['radio_ts'] == '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);
                 }
             }
         }
     }
     $this->assign('totalSelectedContacts', count($this->_contactIds));
 }
Пример #3
0
 static function initTasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(1 => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup', 'result' => true), 2 => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup', 'result' => true), 3 => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag', 'result' => true), 4 => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag', 'result' => true), 5 => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => false), 6 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => false), 7 => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => true), 8 => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => false), 11 => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity', 'result' => true), 13 => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => true), 14 => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => true), 15 => array('title' => ts('Print Contacts'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => false), 16 => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => true), 17 => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => true), 19 => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => true), 21 => array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => true));
         if (CRM_Contact_BAO_ContactType::isActive('Household')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('Household');
             self::$_tasks[9] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold', 'result' => true);
         }
         if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('Organization');
             self::$_tasks[10] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization', 'result' => true);
         }
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete contacts')) {
             unset(self::$_tasks[8]);
         }
         //show map action only if map provider and key is set
         $config =& CRM_Core_Config::singleton();
         if ($config->mapProvider && $config->mapAPIKey) {
             self::$_tasks[12] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => false);
         }
         if (CRM_Core_Permission::access('CiviEvent')) {
             self::$_tasks[18] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant', 'result' => true);
         }
         if (CRM_Core_Permission::access('CiviMail')) {
             self::$_tasks[20] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => false);
         }
         self::$_tasks += CRM_Core_Component::taskList();
         require_once 'CRM/Utils/Hook.php';
         CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
         asort(self::$_tasks);
     }
 }
Пример #4
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access 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');
     } else {
         $values = $this->controller->exportValues('Search');
     }
     $this->_task = $values['task'];
     $crmContactTaskTasks = CRM_Contact_Task::tasks();
     $this->assign('taskName', $crmContactTaskTasks[$this->_task]);
 }
Пример #5
0
 public static function initTasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(self::GROUP_CONTACTS => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), self::REMOVE_CONTACTS => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), self::TAG_CONTACTS => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), self::REMOVE_TAGS => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), self::EXPORT_CONTACTS => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), self::EMAIL_CONTACTS => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), self::DELETE_CONTACTS => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::RECORD_CONTACTS => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity'), self::SAVE_SEARCH => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), self::SAVE_SEARCH_UPDATE => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), self::PRINT_CONTACTS => array('title' => ts('Print Selected Rows'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), self::LABEL_CONTACTS => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), self::BATCH_UPDATE => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), self::PRINT_FOR_CONTACTS => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), self::EMAIL_UNHOLD => array('title' => ts('Unhold Emails'), 'class' => 'CRM_Contact_Form_Task_Unhold'), self::COMMUNICATION_PREFS => array('title' => ts('Alter Contact Communication Preferences'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete Permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE));
         //CRM-16329, if SMS provider is configured show sms action.
         $providersCount = CRM_SMS_BAO_Provider::activeProviderCount();
         if ($providersCount) {
             self::$_tasks[self::SMS_CONTACTS] = array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE);
         }
         if (CRM_Contact_BAO_ContactType::isActive('Household')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('Household');
             self::$_tasks[self::HOUSEHOLD_CONTACTS] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold');
         }
         if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('Organization');
             self::$_tasks[self::ORGANIZATION_CONTACTS] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization');
         }
         if (CRM_Core_Permission::check('merge duplicate contacts')) {
             self::$_tasks[self::MERGE_CONTACTS] = array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE);
         }
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete contacts')) {
             unset(self::$_tasks[self::DELETE_CONTACTS]);
         }
         //show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
         // should fix this to be more flexible as providers are added ??
         $config = CRM_Core_Config::singleton();
         if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) {
             self::$_tasks[self::MAP_CONTACTS] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE);
         }
         if (CRM_Core_Permission::access('CiviEvent')) {
             self::$_tasks[self::ADD_EVENT] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant');
         }
         if (defined('CIVICRM_CIVIMAIL_UI_LEGACY')) {
             if (CRM_Core_Permission::access('CiviMail')) {
                 self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => FALSE);
             } elseif (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
                 self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Create a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test'), 'result' => FALSE);
             }
         } else {
             if (CRM_Core_Permission::access('CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
                 self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => 'CRM_Mailing_Form_Task_AdhocMailing', 'result' => FALSE);
             }
         }
         self::$_tasks += CRM_Core_Component::taskList();
         CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
         asort(self::$_tasks);
     }
 }
Пример #6
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));
 }
Пример #7
0
 public static function initTasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(self::GROUP_CONTACTS => array('title' => ts('Group - add contacts'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), self::REMOVE_CONTACTS => array('title' => ts('Group - remove contacts'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), self::TAG_CONTACTS => array('title' => ts('Tag - add to contacts'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), self::REMOVE_TAGS => array('title' => ts('Tag - remove from contacts'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), self::EXPORT_CONTACTS => array('title' => ts('Export contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), self::EMAIL_CONTACTS => array('title' => ts('Email - send now (to 50 or less)'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), self::DELETE_CONTACTS => array('title' => ts('Delete contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::RECORD_CONTACTS => array('title' => ts('Add activity'), 'class' => 'CRM_Activity_Form_Activity'), self::SAVE_SEARCH => array('title' => ts('Smart group - create'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), self::SAVE_SEARCH_UPDATE => array('title' => ts('Smart group - update'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), self::PRINT_CONTACTS => array('title' => ts('Print selected rows'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), self::LABEL_CONTACTS => array('title' => ts('Mailing labels - print'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), self::BATCH_UPDATE => array('title' => ts('Batch update contacts via profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), self::PRINT_FOR_CONTACTS => array('title' => ts('PDF letters - print'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), self::EMAIL_UNHOLD => array('title' => ts('Email - unhold addresses'), 'class' => 'CRM_Contact_Form_Task_Unhold'), self::COMMUNICATION_PREFS => array('title' => ts('Communication preferences - alter'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore contacts from trash'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE));
         //CRM-16329, if SMS provider is configured show sms action.
         $providersCount = CRM_SMS_BAO_Provider::activeProviderCount();
         if ($providersCount) {
             self::$_tasks[self::SMS_CONTACTS] = array('title' => ts('SMS - schedule/send'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE);
         }
         if (CRM_Contact_BAO_ContactType::isActive('Household')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('household');
             self::$_tasks[self::HOUSEHOLD_CONTACTS] = array('title' => ts('Add relationship - to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold');
         }
         if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('organization');
             self::$_tasks[self::ORGANIZATION_CONTACTS] = array('title' => ts('Add relationship - to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization');
         }
         if (CRM_Core_Permission::check('merge duplicate contacts')) {
             self::$_tasks[self::MERGE_CONTACTS] = array('title' => ts('Merge contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE);
         }
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete contacts')) {
             unset(self::$_tasks[self::DELETE_CONTACTS]);
         }
         //show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
         // should fix this to be more flexible as providers are added ??
         $config = CRM_Core_Config::singleton();
         if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) {
             self::$_tasks[self::MAP_CONTACTS] = array('title' => ts('Map contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE);
         }
         if (CRM_Core_Permission::access('CiviEvent')) {
             self::$_tasks[self::ADD_EVENT] = array('title' => ts('Register participants for event'), 'class' => 'CRM_Event_Form_Participant');
         }
         if (CRM_Core_Permission::access('CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
             self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Email - schedule/send via CiviMail'), 'class' => 'CRM_Mailing_Form_Task_AdhocMailing', 'result' => FALSE);
         }
         self::$_tasks += CRM_Core_Component::taskList();
         CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
         asort(self::$_tasks);
     }
 }
Пример #8
0
 static function initTasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(1 => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), 2 => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), 3 => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), 4 => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), 5 => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), 6 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), 7 => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE), 8 => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), 11 => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity'), 13 => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), 14 => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), 15 => array('title' => ts('Print Contacts'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), 16 => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), 17 => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), 19 => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), 22 => array('title' => ts('Unhold Emails'), 'class' => 'CRM_Contact_Form_Task_Unhold'), 25 => array('title' => ts('Alter Contact Communication Preferences'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete Permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE));
         if (CRM_Contact_BAO_ContactType::isActive('Household')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('Household');
             self::$_tasks[9] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold');
         }
         if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
             $label = CRM_Contact_BAO_ContactType::getLabel('Organization');
             self::$_tasks[10] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization');
         }
         if (CRM_Core_Permission::check('merge duplicate contacts')) {
             self::$_tasks[21] = array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE);
         }
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete contacts')) {
             unset(self::$_tasks[8]);
         }
         //show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
         // should fix this to be more flexible as providers are added ??
         $config = CRM_Core_Config::singleton();
         if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) {
             self::$_tasks[12] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE);
         }
         if (CRM_Core_Permission::access('CiviEvent')) {
             self::$_tasks[18] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant');
         }
         if (CRM_Core_Permission::access('CiviMail')) {
             self::$_tasks[20] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => FALSE);
         } elseif (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
             self::$_tasks[20] = array('title' => ts('Create a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test'), 'result' => FALSE);
         }
         self::$_tasks += CRM_Core_Component::taskList();
         CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
         asort(self::$_tasks);
     }
 }
Пример #9
0
 /**
  * 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('- more actions -')) + CRM_Contact_Task::permissionedTaskTitles($permission);
     if (isset($this->_ssID)) {
         if ($permission == CRM_Core_Permission::EDIT) {
             $tasks = $tasks + CRM_Contact_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);
     }
     if ($this->_context === 'smog') {
         // need to figure out how to freeze a bunch of checkboxes, hack for now
         if ($this->_action != CRM_Core_Action::ADVANCED) {
             //Fix ME
             //$this->_groupElement->freeze( );
         }
         // also 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) {
             $ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
         }
         if (isset($ssMappingId)) {
             $this->assign('ssMappingID', $ssMappingId);
         }
         $group_contact_status = array();
         foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
             if (!empty($k)) {
                 $group_contact_status[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
             }
         }
         $this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
         /* 
          * commented out to fix CRM-4268
          *
          * $this->addGroupRule( 'group_contact_status',
          *                  ts( 'Please select at least Group Status value.' ), 'required', null, 1 );
          */
         // Set dynamic page title for 'Show Members of Group'
         CRM_Utils_System::setTitle(ts('Group Members: %1', array(1 => $this->_group[$this->_groupID])));
         // check if user has permission to edit members of this group
         require_once 'CRM/Contact/BAO/Group.php';
         $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);
         } else {
             $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') {
         // Set dynamic page title for 'Add Members Group'
         CRM_Utils_System::setTitle(ts('Add Members: %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);"));
     }
     // 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', 'onclick' => 'toggleTaskAction( true );'));
     $this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);toggleTaskAction( true );"));
     /*
      * 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 ); return toggleCheckboxVals('mark_x_',this);"));
         foreach ($rows as $row) {
             $this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
         }
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
     $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'id' => 'Print', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
     $this->setDefaultAction('refresh');
 }
Пример #10
0
 /**
  * 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);
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
     $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'id' => 'Print', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1, 1);"));
     $this->setDefaultAction('refresh');
 }
Пример #11
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;
     }
 }
Пример #12
0
 /**
  * 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;
     }
 }
Пример #13
0
 /**
  * Determine the form name based on the action. This allows us
  * to avoid using  conditional state machine, much more efficient
  * and simpler
  *
  * @param CRM_Core_Controller $controller the controller object
  *
  * @return string the name of the form that will handle the task
  * @access protected
  */
 function taskName($controller, $formName = 'Search')
 {
     // total hack, check POST vars and then session to determine stuff
     // fix value if print button is pressed
     if (CRM_Utils_Array::value('_qf_' . $formName . '_next_print', $_POST)) {
         $value = CRM_Contact_Task::PRINT_CONTACTS;
     } else {
         $value = CRM_Utils_Array::value('task', $_POST);
     }
     if (!isset($value)) {
         $value = $this->_controller->get('task');
     }
     $this->_controller->set('task', $value);
     if ($value) {
         $componentMode = $this->_controller->get('component_mode');
         $modeValue = CRM_Contact_Form_Search::getModeValue($componentMode);
         $taskClassName = $modeValue['taskClassName'];
         return $taskClassName::getTask($value);
     } else {
         return CRM_Contact_Task::getTask($value);
     }
 }
Пример #14
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;
     }
 }
Пример #15
0
 /**
  * Determine the form name based on the action. This allows us
  * to avoid using  conditional state machine, much more efficient
  * and simpler
  *
  * @param CRM_Core_Controller $controller the controller object
  *
  * @return string the name of the form that will handle the task
  * @access protected
  */
 function taskName($controller, $formName = 'Search')
 {
     // total hack, check POST vars and then session to determine stuff
     // fix value if print button is pressed
     if (CRM_Utils_Array::value('_qf_' . $formName . '_next_print', $_POST)) {
         $value = CRM_Contact_Task::PRINT_CONTACTS;
     } else {
         $value = CRM_Utils_Array::value('task', $_POST);
     }
     if (!isset($value)) {
         $value = $this->_controller->get('task');
     }
     $this->_controller->set('task', $value);
     if ($value) {
         $componentMode = $this->_controller->get('component_mode');
         require_once 'CRM/Contact/Form/Search.php';
         $modeValue = CRM_Contact_Form_Search::getModeValue($componentMode);
         require_once str_replace('_', DIRECTORY_SEPARATOR, $modeValue['taskClassName']) . '.php';
         return eval("return {$modeValue['taskClassName']}::getTask( {$value} );");
     } else {
         return CRM_Contact_Task::getTask($value);
     }
 }
Пример #16
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);
 }
Пример #17
0
 /**
  * show tasks selectively based on the permission level
  * of the user
  *
  * @param int $permission
  *
  * @return array set of tasks that are valid for the user
  * @access public
  */
 function &permissionedTasks($permission)
 {
     if ($permission == CRM_CORE_PERMISSION_EDIT) {
         return CRM_Contact_Task::tasks();
     } else {
         $tasks = array(4096 => ts('Export Contacts'), 2048 => ts('Map Contacts using Google Maps'));
         return $tasks;
     }
 }
Пример #18
0
 /**
  * Determine the form name based on the action. This allows us
  * to avoid using  conditional state machine, much more efficient
  * and simpler
  *
  * @param CRM_Core_Controller $controller
  *   The controller object.
  *
  * @param string $formName
  *
  * @return string
  *   the name of the form that will handle the task
  */
 public function taskName($controller, $formName = 'Search')
 {
     // total hack, check POST vars and then session to determine stuff
     $value = CRM_Utils_Array::value('task', $_POST);
     if (!isset($value)) {
         $value = $this->_controller->get('task');
     }
     $this->_controller->set('task', $value);
     if ($value) {
         $componentMode = $this->_controller->get('component_mode');
         $modeValue = CRM_Contact_Form_Search::getModeValue($componentMode);
         $taskClassName = $modeValue['taskClassName'];
         return $taskClassName::getTask($value);
     } else {
         return CRM_Contact_Task::getTask($value);
     }
 }
Пример #19
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);
 }
Пример #20
0
 /**
  * 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);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $this->addRowSelectors($rows);
     }
 }
Пример #21
0
 /**
  * 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);
         $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
     }
     $this->assign_by_ref('selectedContactIds', $selectedContactIds);
     $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; 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('class' => 'select-rows', 'onclick' => "toggleTaskAction( true ); 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 );", 'class' => 'select-row'));
             if (!in_array($row['contact_id'], $selectedContactIds)) {
                 $unselectedContactIds[] = $row['contact_id'];
             }
         }
         $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
     $this->setDefaultAction('refresh');
 }