/** * Build the form object - it consists of * - displaying the QILL (query in local language) * - displaying elements for saving the search * * * @return void */ public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Smart Group')); // get the qill $query = new CRM_Event_BAO_Query($this->get('formValues')); $qill = $query->qill(); // Values from the search form $formValues = $this->controller->exportValues(); // need to save qill for the smarty template $this->assign('qill', $qill); // the name and description are actually stored with the group and not the saved search $this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE); $this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description')); // get the group id for the saved search $groupId = NULL; if (isset($this->_id)) { $params = array('saved_search_id' => $this->_id); CRM_Contact_BAO_Group::retrieve($params, $values); $groupId = $values['id']; $this->addDefaultButtons(ts('Update Smart Group')); } else { $this->addDefaultButtons(ts('Save Smart Group')); $this->assign('partiallySelected', $formValues['radio_ts'] != 'ts_all'); } $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title')); }
/** * Build the form - it consists of * - displaying the QILL (query in local language) * - displaying elements for saving the search * * @access public * @return void */ function buildQuickForm() { CRM_Utils_System::setTitle(ts('Smart Group')); require_once "CRM/Event/BAO/Query.php"; // get the qill $query = new CRM_Event_BAO_Query($this->get('formValues')); $qill = $query->qill(); // need to save qill for the smarty template $this->assign('qill', $qill); // the name and description are actually stored with the group and not the saved search $this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), true); $this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description')); // get the group id for the saved search $groupId = null; if (isset($this->_id)) { $params = array('saved_search_id' => $this->_id); require_once "CRM/Contact/BAO/Group.php"; CRM_Contact_BAO_Group::retrieve($params, $values); $groupId = $values['id']; $this->addDefaultButtons(ts('Update Smart Group')); } else { $this->addDefaultButtons(ts('Save Smart Group')); } $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title')); }