/**
  * 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()
 {
     // get the qill
     $query = new CRM_Contact_BAO_Query($this->get('queryParams'));
     $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('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
     $groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
     unset($groupTypes['Access Control']);
     if (!CRM_Core_Permission::access('CiviMail')) {
         $isWorkFlowEnabled = CRM_Mailing_Info::workflowEnabled();
         if ($isWorkFlowEnabled && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
             unset($groupTypes['Mailing List']);
         }
     }
     if (!empty($groupTypes)) {
         $this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, '   ');
     }
     //CRM-14190
     CRM_Group_Form_Edit::buildParentGroups($this);
     // get the group id for the saved search
     $groupID = NULL;
     if (isset($this->_id)) {
         $groupID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_id, 'id', 'saved_search_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'));
 }
Exemple #2
0
 /**
  * Browse all saved searches.
  *
  * @return content of the parents run method
  *
  */
 function browse()
 {
     $rows = array();
     $savedSearch = new CRM_Contact_DAO_SavedSearch();
     $savedSearch->is_active = 1;
     $savedSearch->selectAdd();
     $savedSearch->selectAdd('id, form_values');
     $savedSearch->find();
     $properties = array('id', 'name', 'description');
     while ($savedSearch->fetch()) {
         // get name and description from group object
         $group = new CRM_Contact_DAO_Group();
         $group->saved_search_id = $savedSearch->id;
         if ($group->find(TRUE)) {
             $permissions = CRM_Group_Page_Group::checkPermission($group->id, $group->title);
             if (!CRM_Utils_System::isNull($permissions)) {
                 $row = array();
                 $row['name'] = $group->title;
                 $row['description'] = $group->description;
                 $row['id'] = $savedSearch->id;
                 $formValues = unserialize($savedSearch->form_values);
                 $query = new CRM_Contact_BAO_Query($formValues);
                 $row['query_detail'] = $query->qill();
                 $action = array_sum(array_keys(self::links()));
                 $action = $action & CRM_Core_Action::mask($permissions);
                 $row['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $row['id']));
                 $rows[] = $row;
             }
         }
     }
     $this->assign('rows', $rows);
     return parent::run();
 }
 /**
  * @inheritDoc
  */
 public function getQILL()
 {
     return $this->_query->qill();
 }
 /**
  * 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()
 {
     // get the qill
     $query = new CRM_Contact_BAO_Query($this->get('queryParams'));
     $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('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
     require_once 'CRM/Core/OptionGroup.php';
     $groupTypes = CRM_Core_OptionGroup::values('group_type', true);
     unset($groupTypes['Access Control']);
     if (!CRM_Core_Permission::access('CiviMail')) {
         unset($groupTypes['Mailing List']);
     }
     if (!empty($groupTypes)) {
         $this->addCheckBox('group_type', ts('Group Type'), $groupTypes, null, null, null, null, '   ');
     }
     // get the group id for the saved search
     $groupID = null;
     if (isset($this->_id)) {
         $groupID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_id, 'id', 'saved_search_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'));
 }