Ejemplo n.º 1
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     // get categories for the contact id
     $entityTag =& CRM_Core_BAO_EntityTag::getTag($this->_contactId);
     $this->assign('tagged', $entityTag);
     // get the list of all the categories
     $allTag =& CRM_Core_PseudoConstant::tag();
     // need to append the array with the " checked " if contact is tagged with the tag
     foreach ($allTag as $tagID => $varValue) {
         if (in_array($tagID, $entityTag)) {
             $tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'checked' => 'checked', 'id' => "tag_{$tagID}");
         } else {
             $tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'id' => "tag_{$tagID}");
         }
         $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
     }
     $this->addGroup($tagChk, 'tagList', null, null, true);
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree();
     $this->assign('tree', $tags->getTree());
     $this->assign('tag', $allTag);
     if ($this->_action & CRM_Core_Action::BROWSE) {
         $this->freeze();
     } else {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
Ejemplo n.º 2
0
Archivo: Tag.php Proyecto: kidaa30/yes
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // get categories for the contact id
     $entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
     $this->assign('tagged', $entityTag);
     // get the list of all the categories
     $allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
     // need to append the array with the " checked " if contact is tagged with the tag
     foreach ($allTag as $tagID => $varValue) {
         if (in_array($tagID, $entityTag)) {
             $tagAttribute = array('checked' => 'checked', 'id' => "tag_{$tagID}");
         } else {
             $tagAttribute = array('id' => "tag_{$tagID}");
         }
         $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
     }
     $this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree($this->_entityTable, TRUE);
     // let's not load jstree if there are not children. This also fixes blank
     // display at the beginning of checkboxes
     $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
     $this->assign('loadjsTree', FALSE);
     if (!empty($loadJsTree)) {
         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');
         $this->assign('loadjsTree', TRUE);
     }
     $this->assign('tree', $tree);
     $this->assign('tag', $allTag);
     //build tag widget
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
 }
 /**
  * build form elements.
  * params object $form object of the form
  *
  * @param CRM_Core_Form $form
  *   The form object that we are operating on.
  * @param int $contactId
  *   Contact id.
  * @param int $type
  *   What components are we interested in.
  * @param bool $visibility
  *   Visibility of the field.
  * @param null $isRequired
  * @param string $groupName
  *   If used for building group block.
  * @param string $tagName
  *   If used for building tag block.
  * @param string $fieldName
  *   This is used in batch profile(i.e to build multiple blocks).
  *
  * @param string $groupElementType
  *
  */
 public static function buildQuickForm(&$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL, $groupElementType = 'checkbox')
 {
     if (!isset($form->_tagGroup)) {
         $form->_tagGroup = array();
     }
     // NYSS 5670
     if (!$contactId && !empty($form->_contactId)) {
         $contactId = $form->_contactId;
     }
     $type = (int) $type;
     if ($type & self::GROUP) {
         $fName = 'group';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $groupID = isset($form->_grid) ? $form->_grid : NULL;
         if ($groupID && $visibility) {
             $ids = array($groupID => $groupID);
         } else {
             if ($visibility) {
                 $group = CRM_Core_PseudoConstant::allGroup();
             } else {
                 $group = CRM_Core_PseudoConstant::group();
             }
             $ids = $group;
         }
         if ($groupID || !empty($group)) {
             $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids);
             $attributes['skiplabel'] = TRUE;
             $elements = array();
             $groupsOptions = array();
             foreach ($groups as $id => $group) {
                 // make sure that this group has public visibility
                 if ($visibility && $group['visibility'] == 'User and User Admin Only') {
                     continue;
                 }
                 if ($groupElementType == 'select') {
                     $groupsOptions[$id] = $group['title'];
                 } else {
                     $form->_tagGroup[$fName][$id]['description'] = $group['description'];
                     $elements[] =& $form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes);
                 }
             }
             if ($groupElementType == 'select' && !empty($groupsOptions)) {
                 $form->add('select', $fName, $groupName, $groupsOptions, FALSE, array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2'));
                 $form->assign('groupCount', count($groupsOptions));
             }
             if ($groupElementType == 'checkbox' && !empty($elements)) {
                 $form->addGroup($elements, $fName, $groupName, '&nbsp;<br />');
                 $form->assign('groupCount', count($elements));
                 if ($isRequired) {
                     $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required');
                 }
             }
             $form->assign('groupElementType', $groupElementType);
         }
     }
     if ($type & self::TAG) {
         $fName = 'tag';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $form->_tagGroup[$fName] = 1;
         // get the list of all the categories
         $tags = new CRM_Core_BAO_Tag();
         $tree = $tags->getTree('civicrm_contact', TRUE);
         // let's not load jstree if there are not children. This also fixes blank
         // display at the beginning of checkboxes
         $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
         $form->assign('loadjsTree', FALSE);
         if (!empty($loadJsTree)) {
             // CODE FROM CRM/Tag/Form/Tag.php //
             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');
             $form->assign('loadjsTree', TRUE);
         }
         $elements = array();
         self::climbtree($form, $tree, $elements);
         $form->addGroup($elements, $fName, $tagName, '<br />');
         $form->assign('tagCount', count($elements));
         $form->assign('tree', $tree);
         $form->assign('tag', $tree);
         $form->assign('entityID', $contactId);
         $form->assign('entityTable', 'civicrm_contact');
         if ($isRequired) {
             $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required');
         }
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
         CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE);
     }
     $form->assign('tagGroup', $form->_tagGroup);
 }
Ejemplo n.º 4
0
 static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     if ($form->_searchOptions['contactType']) {
         // add checkboxes for contact type
         $contact_type = array();
         require_once 'CRM/Contact/BAO/ContactType.php';
         $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
         foreach ($contactTypes as $k => $v) {
             if (!empty($k)) {
                 $contact_type[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
             }
         }
         $form->addGroup($contact_type, 'contact_type', ts('Contact Type(s)'), '<br />');
     }
     if ($form->_searchOptions['groups']) {
         // checkboxes for groups
         foreach ($form->_group as $groupID => $group) {
             $form->_groupElement =& $form->addElement('checkbox', "group[{$groupID}]", null, $group);
         }
     }
     if ($form->_searchOptions['tags']) {
         // checkboxes for categories
         require_once 'CRM/Core/BAO/Tag.php';
         $tags = new CRM_Core_BAO_Tag();
         $tree = $tags->getTree();
         $form->assign('tree', $tags->getTree());
         foreach ($form->_tag as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "tag[{$tagID}]", null, $tagName);
         }
     }
     // add text box for last name, first name, street name, city
     $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     // add text box for last name, first name, street name, city
     $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     //added contact source
     $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
     // add checkbox for cms users only
     if (CIVICRM_UF != 'Standalone') {
         $form->addYesNo('uf_user', ts('CMS User?'));
     }
     // add search profiles
     require_once 'CRM/Core/BAO/UFGroup.php';
     // FIXME: This is probably a part of profiles - need to be
     // FIXME: eradicated from here when profiles are reworked.
     $types = array('Participant', 'Contribution', 'Membership');
     // get component profiles
     $componentProfiles = array();
     $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
     $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
     $searchProfiles = array();
     foreach ($ufGroups as $key => $var) {
         if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
             $searchProfiles[$key] = $var['title'];
         }
     }
     $form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
     // checkboxes for DO NOT phone, email, mail
     // we take labels from SelectValues
     $t = CRM_Core_SelectValues::privacy();
     $t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).');
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
     $privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']);
     $form->addGroup($privacy, 'privacy', ts('Privacy'), array('&nbsp;', '&nbsp;', '&nbsp;', '<br/>'));
     // preferred communication method
     require_once 'CRM/Core/PseudoConstant.php';
     $comm = CRM_Core_PseudoConstant::pcm();
     $commPreff = array();
     foreach ($comm as $k => $v) {
         $commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
     }
     $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
 }
Ejemplo n.º 5
0
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function 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');
     // get categories for the contact id
     $entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
     $this->assign('tagged', $entityTag);
     // get the list of all the categories
     $allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
     // need to append the array with the " checked " if contact is tagged with the tag
     foreach ($allTag as $tagID => $varValue) {
         if (in_array($tagID, $entityTag)) {
             $tagAttribute = array('checked' => 'checked', 'id' => "tag_{$tagID}");
         } else {
             $tagAttribute = array('id' => "tag_{$tagID}");
         }
         $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
     }
     $this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree($this->_entityTable, TRUE);
     $this->assign('tree', $tree);
     $this->assign('tag', $allTag);
     //build tag widget
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
     CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
     if ($this->_action & CRM_Core_Action::BROWSE) {
         $this->freeze();
     } else {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }