Exemple #1
0
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_memberIds = array();
     $values = $this->controller->exportValues('Search');
     $this->_task = $values['task'];
     $memberTasks = CRM_Member_Task::tasks();
     $this->assign('taskName', $memberTasks[$this->_task]);
     $ids = array();
     if ($values['radio_ts'] == 'ts_sel') {
         foreach ($values as $name => $value) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             }
         }
     } else {
         $queryParams = $this->get('queryParams');
         $query =& new CRM_Contact_BAO_Query($queryParams, null, null, false, false, CRM_Contact_BAO_Query::MODE_MEMBER);
         $result = $query->searchQuery(0, 0, null);
         while ($result->fetch()) {
             $ids[] = $result->membership_id;
         }
     }
     if (!empty($ids)) {
         $this->_componentClause = ' civicrm_membership.id IN ( ' . implode(',', $ids) . ' ) ';
         $this->assign('totalSelectedMembers', count($ids));
     }
     $this->_memberIds = $this->_componentIds = $ids;
     //set the context for redirection for any task actions
     $session =& CRM_Core_Session::singleton();
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/member/search', 'force=1'));
 }
 /**
  * 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
     $value = CRM_Utils_Array::value('task', $_POST);
     if (!isset($value)) {
         $value = $this->_controller->get('task');
     }
     $this->_controller->set('task', $value);
     return CRM_Member_Task::getTask($value);
 }
Exemple #3
0
 /**
  * These tasks are the core set of tasks that the user can perform
  * on a contact / group of contacts
  *
  * @return array the set of tasks for a group of contacts
  * @static
  * @access public
  */
 static function &tasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(3 => ts('Export Members'), 1 => ts('Delete Members'), 4 => ts('Send Email to Contacts'), 5 => ts('Batch Update Members Via Profile'));
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete in CiviMember')) {
             unset(self::$_tasks[1]);
         }
     }
     asort(self::$_tasks);
     return self::$_tasks;
 }
 /**
  * These tasks are the core set of tasks that the user can perform
  * on a contact / group of contacts
  *
  * @return array the set of tasks for a group of contacts
  * @static
  * @access public
  */
 static function &tasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(1 => array('title' => ts('Delete Members'), 'class' => 'CRM_Member_Form_Task_Delete', 'result' => FALSE), 2 => array('title' => ts('Print Selected Rows'), 'class' => 'CRM_Member_Form_Task_Print', 'result' => FALSE), 3 => array('title' => ts('Export Members'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), 4 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Member_Form_Task_Email', 'result' => TRUE), 5 => array('title' => ts('Batch Update Members Via Profile'), 'class' => array('CRM_Member_Form_Task_PickProfile', 'CRM_Member_Form_Task_Batch'), 'result' => TRUE), 6 => array('title' => ts('Mailing Labels'), 'class' => array('CRM_Member_Form_Task_Label'), 'result' => TRUE), 7 => array('title' => ts('Print PDF Letters for Memberships'), 'class' => 'CRM_Member_Form_Task_PDFLetter', 'result' => FALSE));
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete in CiviMember')) {
             unset(self::$_tasks[1]);
         }
     }
     CRM_Utils_Hook::searchTasks('membership', self::$_tasks);
     asort(self::$_tasks);
     return self::$_tasks;
 }
Exemple #5
0
 /**
  * These tasks are the core set of tasks that the user can perform
  * on a contact / group of contacts
  *
  * @return array the set of tasks for a group of contacts
  * @static
  * @access public
  */
 static function &tasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(1 => array('title' => ts('Delete Members'), 'class' => 'CRM_Member_Form_Task_Delete', 'result' => false), 2 => array('title' => ts('Print Memberships'), 'class' => 'CRM_Member_Form_Task_Print', 'result' => false), 3 => array('title' => ts('Export Members'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => false), 4 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Member_Form_Task_Email', 'result' => true), 5 => array('title' => ts('Batch Update Members Via Profile'), 'class' => array('CRM_Member_Form_Task_PickProfile', 'CRM_Member_Form_Task_Batch'), 'result' => true));
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete in CiviMember')) {
             unset(self::$_tasks[1]);
         }
     }
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::searchTasks('membership', self::$_tasks);
     asort(self::$_tasks);
     return self::$_tasks;
 }
Exemple #6
0
 /**
  * These tasks are the core set of tasks that the user can perform
  * on a contact / group of contacts
  *
  * @return array
  *   the set of tasks for a group of contacts
  */
 public static function &tasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(1 => array('title' => ts('Delete memberships'), 'class' => 'CRM_Member_Form_Task_Delete', 'result' => FALSE), 2 => array('title' => ts('Print selected rows'), 'class' => 'CRM_Member_Form_Task_Print', 'result' => FALSE), 3 => array('title' => ts('Export members'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), 4 => array('title' => ts('Email - send now'), 'class' => 'CRM_Member_Form_Task_Email', 'result' => TRUE), 5 => array('title' => ts('Update multiple memberships'), 'class' => array('CRM_Member_Form_Task_PickProfile', 'CRM_Member_Form_Task_Batch'), 'result' => TRUE), 6 => array('title' => ts('Mailing labels - print'), 'class' => array('CRM_Member_Form_Task_Label'), 'result' => TRUE), 7 => array('title' => ts('PDF letters - print for memberships'), 'class' => 'CRM_Member_Form_Task_PDFLetter', 'result' => FALSE));
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete in CiviMember')) {
             unset(self::$_tasks[1]);
         }
         //CRM-12920 - check for edit permission
         if (!CRM_Core_Permission::check('edit memberships')) {
             unset(self::$_tasks[5]);
         }
     }
     CRM_Utils_Hook::searchTasks('membership', self::$_tasks);
     asort(self::$_tasks);
     return self::$_tasks;
 }
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addElement('text', 'sort_name', ts('Member Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Member_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $this->addTaskMenu(CRM_Member_Task::permissionedTaskTitles($permission));
     }
 }
Exemple #8
0
 /**
  * @param CRM_Core_Form $form
  * @param bool $useTable
  */
 public static function preProcessCommon(&$form, $useTable = FALSE)
 {
     $form->_memberIds = array();
     $values = $form->controller->exportValues($form->get('searchFormName'));
     $form->_task = $values['task'];
     $memberTasks = CRM_Member_Task::tasks();
     $form->assign('taskName', $memberTasks[$form->_task]);
     $ids = array();
     if ($values['radio_ts'] == 'ts_sel') {
         foreach ($values as $name => $value) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             }
         }
     } else {
         $queryParams = $form->get('queryParams');
         $sortOrder = NULL;
         if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
             $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
         }
         $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_MEMBER);
         $query->_distinctComponentClause = ' civicrm_membership.id';
         $query->_groupByComponentClause = ' GROUP BY civicrm_membership.id ';
         $result = $query->searchQuery(0, 0, $sortOrder);
         while ($result->fetch()) {
             $ids[] = $result->membership_id;
         }
     }
     if (!empty($ids)) {
         $form->_componentClause = ' civicrm_membership.id IN ( ' . implode(',', $ids) . ' ) ';
         $form->assign('totalSelectedMembers', count($ids));
     }
     $form->_memberIds = $form->_componentIds = $ids;
     //set the context for redirection for any task actions
     $session = CRM_Core_Session::singleton();
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $searchFormName = strtolower($form->get('searchFormName'));
     if ($searchFormName == 'search') {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/member/search', $urlParams));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams));
     }
 }
Exemple #9
0
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $this->addElement('text', 'sort_name', ts('Member Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Member_BAO_Query::buildSearchForm($this);
     /*
      * add form checkboxes for each row. This is needed out here to conform to QF protocol
      * of all elements being declared in builQuickForm
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
             foreach ($rows as $row) {
                 $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "');"));
             }
         }
         $total = $cancel = 0;
         $permission = CRM_Core_Permission::getPermission();
         $tasks = array('' => ts('- actions -')) + CRM_Member_Task::permissionedTaskTitles($permission);
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
         $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
         // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
 /**
  * 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_Member_Task::PRINT_MEMBERS;
     } else {
         $value = CRM_Utils_Array::value('task', $_POST);
     }
     if (!isset($value)) {
         $value = $this->_controller->get('task');
     }
     $this->_controller->set('task', $value);
     return CRM_Member_Task::getTask($value);
 }
Exemple #11
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->addSortNameField();
     CRM_Member_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $this->addTaskMenu(CRM_Member_Task::permissionedTaskTitles($permission));
     }
 }
Exemple #12
0
 static function preProcessCommon(&$form, $useTable = false)
 {
     $form->_memberIds = array();
     $values = $form->controller->exportValues('Search');
     $form->_task = $values['task'];
     $memberTasks = CRM_Member_Task::tasks();
     $form->assign('taskName', $memberTasks[$form->_task]);
     $ids = array();
     if ($values['radio_ts'] == 'ts_sel') {
         foreach ($values as $name => $value) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             }
         }
     } else {
         $queryParams = $form->get('queryParams');
         $query = new CRM_Contact_BAO_Query($queryParams, null, null, false, false, CRM_Contact_BAO_Query::MODE_MEMBER);
         $result = $query->searchQuery(0, 0, null);
         while ($result->fetch()) {
             $ids[] = $result->membership_id;
         }
     }
     if (!empty($ids)) {
         $form->_componentClause = ' civicrm_membership.id IN ( ' . implode(',', $ids) . ' ) ';
         $form->assign('totalSelectedMembers', count($ids));
     }
     $form->_memberIds = $form->_componentIds = $ids;
     //set the context for redirection for any task actions
     $session = CRM_Core_Session::singleton();
     $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}";
     }
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/member/search', $urlParams));
 }