コード例 #1
0
ファイル: Admin.php プロジェクト: prashantgajare/civicrm-core
 /**
  * @return string
  */
 function run()
 {
     $errorMessage = '';
     // ensure that all CiviCRM tables are InnoDB, else abort
     // this is not a very fast operation, so we do it randomly 10% of the times
     // but we do it for most / all tables
     // http://bugs.mysql.com/bug.php?id=43664
     if (rand(1, 10) == 3 && CRM_Core_DAO::isDBMyISAM(150)) {
         $errorMessage = ts('Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues.');
         CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert");
     }
     if (!CRM_Utils_System::isDBVersionValid($errorMessage)) {
         CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert", array('expires' => 0));
     }
     $groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array('CiviMember', $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array('CiviEvent', $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array('CiviMail', $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array('CiviCase', $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array('CiviReport', $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array('CiviCampaign', $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     $values = CRM_Core_Menu::getAdminLinks();
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $groupId = str_replace(' ', '_', $group);
         $this->_showHide->addShow("id_{$groupId}_show");
         $this->_showHide->addHide("id_{$groupId}");
         $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
         if (isset($values[$group])) {
             $adminPanel[$groupId] = $values[$group];
             $adminPanel[$groupId]['show'] = $v['show'];
             $adminPanel[$groupId]['hide'] = $v['hide'];
             $adminPanel[$groupId]['title'] = $title;
         } else {
             $adminPanel[$groupId] = array();
             $adminPanel[$groupId]['show'] = '';
             $adminPanel[$groupId]['hide'] = '';
             $adminPanel[$groupId]['title'] = $title;
         }
     }
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
コード例 #2
0
ファイル: Admin.php プロジェクト: hampelm/Ginsberg-CiviDemo
 function run()
 {
     // ensure that all CiviCRM tables are InnoDB, else abort
     if (CRM_Core_DAO::isDBMyISAM()) {
         $errorMessage = 'Your database is configured to use the MyISAM database engine. CiviCRM  requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues. This will be a fatal error in CiviCRM v2.1.';
         require_once 'CRM/Core/Session.php';
         CRM_Core_Session::setStatus($errorMessage);
     }
     if (!CRM_Utils_System::isDBVersionValid($errorMessage)) {
         CRM_Core_Session::setStatus($errorMessage);
     }
     $groups = array('Customize' => ts('Customize'), 'Configure' => ts('Configure'), 'Manage' => ts('Manage'), 'Option Lists' => ts('Option Lists'));
     $config = CRM_Core_Config::singleton();
     if (in_array("CiviContribute", $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array("CiviMember", $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array("CiviEvent", $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array("CiviMail", $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array("CiviCase", $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array("CiviReport", $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array("CiviCampaign", $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     require_once 'CRM/Core/Menu.php';
     $values =& CRM_Core_Menu::getAdminLinks();
     require_once 'CRM/Core/ShowHideBlocks.php';
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $this->_showHide->addShow("id_{$group}_show");
         $this->_showHide->addHide("id_{$group}");
         $v = CRM_Core_ShowHideBlocks::links($this, $group, '', '', false);
         $adminPanel[$group] = $values[$group];
         $adminPanel[$group]['show'] = $v['show'];
         $adminPanel[$group]['hide'] = $v['hide'];
         $adminPanel[$group]['title'] = $title;
     }
     require_once 'CRM/Utils/VersionCheck.php';
     $versionCheck =& CRM_Utils_VersionCheck::singleton();
     $this->assign('newVersion', $versionCheck->newerVersion());
     $this->assign('localVersion', $versionCheck->localVersion);
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
コード例 #3
0
ファイル: Admin.php プロジェクト: kcristiano/civicrm-core
 /**
  * Run page.
  *
  * @return string
  */
 public function run()
 {
     Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
     $this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
     $groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array('CiviMember', $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array('CiviEvent', $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array('CiviMail', $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array('CiviCase', $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array('CiviReport', $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array('CiviCampaign', $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     $values = CRM_Core_Menu::getAdminLinks();
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $groupId = str_replace(' ', '_', $group);
         $this->_showHide->addShow("id_{$groupId}_show");
         $this->_showHide->addHide("id_{$groupId}");
         $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
         if (isset($values[$group])) {
             $adminPanel[$groupId] = $values[$group];
             $adminPanel[$groupId]['show'] = $v['show'];
             $adminPanel[$groupId]['hide'] = $v['hide'];
             $adminPanel[$groupId]['title'] = $title;
         } else {
             $adminPanel[$groupId] = array();
             $adminPanel[$groupId]['show'] = '';
             $adminPanel[$groupId]['hide'] = '';
             $adminPanel[$groupId]['title'] = $title;
         }
     }
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
コード例 #4
0
 /**
  * @return string
  */
 public function run()
 {
     $groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array('CiviMember', $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array('CiviEvent', $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array('CiviMail', $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array('CiviCase', $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array('CiviReport', $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array('CiviCampaign', $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     $values = CRM_Core_Menu::getAdminLinks();
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $groupId = str_replace(' ', '_', $group);
         $this->_showHide->addShow("id_{$groupId}_show");
         $this->_showHide->addHide("id_{$groupId}");
         $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
         if (isset($values[$group])) {
             $adminPanel[$groupId] = $values[$group];
             $adminPanel[$groupId]['show'] = $v['show'];
             $adminPanel[$groupId]['hide'] = $v['hide'];
             $adminPanel[$groupId]['title'] = $title;
         } else {
             $adminPanel[$groupId] = array();
             $adminPanel[$groupId]['show'] = '';
             $adminPanel[$groupId]['hide'] = '';
             $adminPanel[$groupId]['title'] = $title;
         }
     }
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
コード例 #5
0
 /**
  * Generate the custom Data Fields based
  * on the is_searchable
  *
  *
  * @param $form
  *
  * @return void
  */
 public static function custom(&$form)
 {
     $form->add('hidden', 'hidden_custom', 1);
     $extends = array('Relationship');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     $form->assign('groupTree', $groupDetails);
     foreach ($groupDetails as $key => $group) {
         $_groupTitle[$key] = $group['name'];
         CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
         $groupId = $group['id'];
         foreach ($group['fields'] as $field) {
             $fieldId = $field['id'];
             $elementName = 'custom_' . $fieldId;
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
         }
     }
 }
コード例 #6
0
 /**
  * This function provides the HTML form elements that are specific to the Individual Contact Type
  * 
  * @access public
  * @return None 
  */
 function buildQuickForm(&$form)
 {
     $form->applyFilter('__ALL__', 'trim');
     // prefix
     $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::individualPrefix());
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Individual');
     // first_name
     $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
     //middle_name
     $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
     // last_name
     $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
     // suffix
     $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::individualSuffix());
     // nick_name
     $form->addElement('text', 'nick_name', ts('Nick Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
     // greeting type
     $form->addElement('select', 'greeting_type', ts('Greeting'), CRM_Core_SelectValues::greeting());
     // job title
     $form->addElement('text', 'job_title', ts('Job title'), $attributes['job_title']);
     // radio button for gender
     $genderOptions = array();
     $gender = CRM_Core_PseudoConstant::gender();
     foreach ($gender as $key => $var) {
         $genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key);
     }
     $form->addGroup($genderOptions, 'gender_id', ts('Gender'));
     $form->addElement('checkbox', 'is_deceased', null, ts('Contact is deceased'));
     $form->addElement('date', 'birth_date', ts('Date of birth'), CRM_Core_SelectValues::date('birth'));
     $form->addRule('birth_date', ts('Select a valid date.'), 'qfDate');
     $form->addElement('text', 'home_URL', ts('Website'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'home_URL'));
     $form->addRule('home_URL', ts('Enter a valid Website.'), 'url');
     $config =& CRM_Core_Config::singleton();
     CRM_Core_ShowHideBlocks::links($this, 'demographics', '', '');
 }
コード例 #7
0
 /**
  * Generic function to build all the form elements for a specific group tree.
  *
  * @param CRM_Core_Form $form
  *   The form object.
  * @param array $groupTree
  *   The group tree object.
  * @param bool $inactiveNeeded
  *   Return inactive custom groups.
  * @param string $prefix
  *   Prefix for custom grouptree assigned to template.
  */
 public static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '')
 {
     $form->assign_by_ref("{$prefix}groupTree", $groupTree);
     foreach ($groupTree as $id => $group) {
         CRM_Core_ShowHideBlocks::links($form, $group['title'], '', '');
         foreach ($group['fields'] as $field) {
             $required = CRM_Utils_Array::value('is_required', $field);
             //fix for CRM-1620
             if ($field['data_type'] == 'File') {
                 if (!empty($field['element_value']['data'])) {
                     $required = 0;
                 }
             }
             $fieldId = $field['id'];
             $elementName = $field['element_name'];
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, $required);
         }
     }
 }
コード例 #8
0
 /**
  * generic function to build all the form elements for a specific group tree
  *
  * @param CRM_Core_Form $form      the form object
  * @param array         $groupTree the group tree object
  * @param string        $showName  
  * @param string        $hideName
  *
  * @return void
  * @access public
  * @static
  */
 function buildQuickForm(&$form, &$groupTree, $showName = 'showBlocks', $hideName = 'hideBlocks')
 {
     //this is fix for calendar for date field
     foreach ($groupTree as $key1 => $group) {
         foreach ($group['fields'] as $key2 => $field) {
             if ($field['data_type'] == 'Date' && $field['date_parts']) {
                 $datePart = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $field['date_parts']);
                 if (count($datePart) < 3) {
                     $groupTree[$key1]['fields'][$key2]['skip_calendar'] = true;
                 }
             }
         }
     }
     $form->assign_by_ref('groupTree', $groupTree);
     $sBlocks = array();
     $hBlocks = array();
     // this is fix for date field
     $form->assign('currentYear', date('Y'));
     require_once 'CRM/Core/ShowHideBlocks.php';
     foreach ($groupTree as $group) {
         CRM_Core_ShowHideBlocks::links($form, $group['title'], '', '');
         $groupId = $group['id'];
         foreach ($group['fields'] as $field) {
             $fieldId = $field['id'];
             $elementName = 'custom_' . $fieldId;
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, $inactiveNeeded, $group['is_required']);
         }
         if ($group['collapse_display']) {
             $sBlocks[] = "'" . $group['title'] . "[show]'";
             $hBlocks[] = "'" . $group['title'] . "'";
         } else {
             $hBlocks[] = "'" . $group['title'] . "[show]'";
             $sBlocks[] = "'" . $group['title'] . "'";
         }
     }
     $showBlocks = implode(",", $sBlocks);
     $hideBlocks = implode(",", $hBlocks);
     $form->assign($showName, $showBlocks);
     $form->assign($hideName, $hideBlocks);
 }
コード例 #9
0
 /**
  * generic function to build all the form elements for a specific group tree
  *
  * @param CRM_Core_Form $form      the form object
  * @param array         $groupTree the group tree object
  * @param string        $showName  
  * @param string        $hideName
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = false, $groupCount = 1, $prefix = '')
 {
     require_once 'CRM/Core/BAO/CustomField.php';
     require_once 'CRM/Core/BAO/CustomOption.php';
     $form->assign_by_ref("{$prefix}groupTree", $groupTree);
     $sBlocks = array();
     $hBlocks = array();
     // this is fix for date field
     $form->assign('currentYear', date('Y'));
     require_once 'CRM/Core/ShowHideBlocks.php';
     foreach ($groupTree as $id => $group) {
         CRM_Core_ShowHideBlocks::links($form, $group['title'], '', '');
         $groupId = CRM_Utils_Array::value('id', $group);
         foreach ($group['fields'] as $field) {
             // skip all view fields
             if (CRM_Utils_Array::value('is_view', $field)) {
                 continue;
             }
             $required = CRM_Utils_Array::value('is_required', $field);
             //fix for CRM-1620
             if ($field['data_type'] == 'File') {
                 if (isset($field['customValue']['data'])) {
                     $required = 0;
                 }
             }
             $fieldId = $field['id'];
             $elementName = $field['element_name'];
             require_once "CRM/Core/BAO/CustomField.php";
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, $inactiveNeeded, $required);
         }
     }
 }
コード例 #10
0
 /**
  * This function provides the HTML form elements that are specific to the Individual Contact Type
  * 
  * @access public
  * @return None 
  */
 public function buildQuickForm(&$form, $action = null)
 {
     $form->applyFilter('__ALL__', 'trim');
     //prefix
     $prefix = CRM_Core_PseudoConstant::individualPrefix();
     if (!empty($prefix)) {
         $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => '') + $prefix);
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
     // first_name
     $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
     //middle_name
     $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
     // last_name
     $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
     // suffix
     $suffix = CRM_Core_PseudoConstant::individualSuffix();
     if ($suffix) {
         $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => '') + $suffix);
     }
     // nick_name
     $form->addElement('text', 'nick_name', ts('Nick Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
     // job title
     // override the size for UI to look better
     $attributes['job_title']['size'] = 30;
     $form->addElement('text', 'job_title', ts('Job title'), $attributes['job_title'], 'size="30"');
     //Current Employer Element
     $employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1', false, null, false);
     $form->assign('employerDataURL', $employerDataURL);
     $form->addElement('text', 'current_employer', ts('Current Employer'), '');
     $form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id'));
     $form->addElement('text', 'contact_source', ts('Source'));
     $checkSimilar = defined('CIVICRM_CONTACT_AJAX_CHECK_SIMILAR') ? CIVICRM_CONTACT_AJAX_CHECK_SIMILAR : true;
     $form->assign('checkSimilar', $checkSimilar);
     //External Identifier Element
     $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), false);
     $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
     $config = CRM_Core_Config::singleton();
     CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
 }
コード例 #11
0
ファイル: Criteria.php プロジェクト: kidaa30/yes
 /**
  * Generate the custom Data Fields based
  * on the is_searchable
  *
  *
  * @param $form
  *
  * @return void
  */
 public static function custom(&$form)
 {
     $form->add('hidden', 'hidden_custom', 1);
     $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     $form->assign('groupTree', $groupDetails);
     foreach ($groupDetails as $key => $group) {
         $_groupTitle[$key] = $group['name'];
         CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
         $groupId = $group['id'];
         foreach ($group['fields'] as $field) {
             $fieldId = $field['id'];
             $elementName = 'custom_' . $fieldId;
             if ($field['data_type'] == 'Date' && $field['is_search_range']) {
                 CRM_Core_Form_Date::buildDateRange($form, $elementName, 1, '_from', '_to', ts('From:'), FALSE);
             } else {
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
             }
         }
     }
     //TODO: validate for only one state if prox_distance isset
 }
コード例 #12
0
ファイル: Criteria.php プロジェクト: bhirsch/civicrm
 /**
  * Generate the custom Data Fields based
  * on the is_searchable
  *
  * @access private
  * @return void
  */
 static function custom(&$form)
 {
     $form->add('hidden', 'hidden_custom', 1);
     $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $extends);
     $form->assign('groupTree', $groupDetails);
     foreach ($groupDetails as $key => $group) {
         $_groupTitle[$key] = $group['name'];
         CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
         $groupId = $group['id'];
         foreach ($group['fields'] as $field) {
             $fieldId = $field['id'];
             $elementName = 'custom_' . $fieldId;
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true);
         }
     }
 }
コード例 #13
0
 /**
  * This function provides the HTML form elements that are specific to the Individual Contact Type.
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param int $inlineEditMode
  *   ( 1 for contact summary.
  * top bar form and 2 for display name edit )
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         // Fixme: dear god why? these come out in a format that is NOT the name of the fields.
         foreach ($nameFields as &$fix) {
             $fix = str_replace(' ', '_', strtolower($fix));
             if ($fix == 'prefix' || $fix == 'suffix') {
                 // God, why god?
                 $fix .= '_id';
             }
         }
         foreach ($nameFields as $name) {
             $props = array();
             if ($name == 'prefix_id' || $name == 'suffix_id') {
                 $options = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name);
                 // Skip if we have no options available
                 if (!CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name)) {
                     //continue;
                 }
                 $props = array('class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix'));
             }
             $form->addField($name, $props);
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addField('nick_name');
         // job title
         // override the size for UI to look better
         $form->addField('job_title', array('size' => '30'));
         //Current Employer Element
         $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
         $form->addField('employer_id', $props);
         $form->addField('contact_source', array('class' => 'big'));
     }
     if (!$inlineEditMode) {
         $checkSimilar = Civi::settings()->get('contact_ajax_check_similar');
         if ($checkSimilar == NULL) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //External Identifier Element
         $form->addField('external_identifier', array('label' => 'External ID'));
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
         CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
     }
 }
コード例 #14
0
ファイル: Edit.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 function buildQuickForm()
 {
     // assign a few constants used by all display elements
     // we can obsolete this when smarty can access class constans directly
     $this->assign('locationCount', CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS + 1);
     $this->assign('blockCount', CRM_CONTACT_FORM_LOCATION_BLOCKS + 1);
     $this->assign('contact_type', $this->_contactType);
     require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_" . $this->_contactType) . ".php";
     eval('CRM_Contact_Form_' . $this->_contactType . '::buildQuickForm( $this );');
     // add the communications block
     CRM_Contact_Form_Edit::buildCommunicationBlock($this);
     /* Entering the compact location engine */
     $location =& CRM_Contact_Form_Location::buildLocationBlock($this, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS);
     /* End of locations */
     // add note block
     if ($this->_action & CRM_CORE_ACTION_ADD) {
         $note =& CRM_Contact_Form_Note::buildNoteBlock($this);
     }
     //add tags and groups block
     $groupTag =& CRM_Contact_Form_GroupTag::buildGroupTagBlock($this, $this->_contactId, CRM_CONTACT_FORM_GROUPTAG_ALL);
     //Custom Group Inline Edit form
     $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this->_contactId);
     CRM_Core_BAO_CustomGroup::buildQuickForm($this, $this->_groupTree, 'showBlocks1', 'hideBlocks1');
     $config =& CRM_Core_Config::singleton();
     CRM_Core_ShowHideBlocks::links($this, 'notes', '', '');
     // add the dedupe button
     $this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)'));
     $this->addElement('submit', $this->_duplicateButtonName, ts('Save Duplicate Contact'));
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
コード例 #15
0
 /**
  * Generate the custom Data Fields based
  * on the is_searchable
  *
  * @access private
  * @return void
  */
 function customDataSearch()
 {
     // expand on search result if criteria entered
     $customDataSearch = $this->get('customDataSearch');
     if (!empty($customDataSearch)) {
         $customAssignHide = array();
         $customAssignShow = array();
         foreach (array_unique($customDataSearch) as $v) {
             $customAssignHide[] = $v . '[show]';
             $customAssignShow[] = $v;
         }
         $customShow = '"' . implode("\",\"", $customAssignShow) . '"';
         $customHide = '"' . implode("\",\"", $customAssignHide) . '"';
         $this->assign('customShow', $customShow);
         $this->assign('customHide', $customHide);
     }
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, array('Contact', 'Individual', 'Household', 'Organization'));
     $this->assign('groupTree', $groupDetails);
     foreach ($groupDetails as $group) {
         $_groupTitle[] = $group['title'];
         CRM_Core_ShowHideBlocks::links($this, $group['title'], '', '');
         $groupId = $group['id'];
         foreach ($group['fields'] as $field) {
             $fieldId = $field['id'];
             $elementName = 'custom_' . $fieldId;
             CRM_Core_BAO_CustomField::addQuickFormElement($this, $elementName, $fieldId, false, false, true);
         }
     }
     $this->setShowHide($_groupTitle);
 }
コード例 #16
0
 /**
  * This function provides the HTML form elements that are specific
  * to the Individual Contact Type
  *
  * @param CRM_Core_Form $form form object
  * @param int $inlineEditMode ( 1 for contact summary
  * top bar form and 2 for display name edit )
  *
  * @access public
  * @return void
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         //prefix
         $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
         if (isset($nameFields['Prefix']) && !empty($prefix)) {
             $form->addSelect('prefix_id', array('class' => 'four', 'placeholder' => ' '));
         }
         $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
         if (isset($nameFields['Formal Title'])) {
             $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
         }
         // first_name
         if (isset($nameFields['First Name'])) {
             $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
         }
         //middle_name
         if (isset($nameFields['Middle Name'])) {
             $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
         }
         // last_name
         if (isset($nameFields['Last Name'])) {
             $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
         }
         // suffix
         $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
         if (isset($nameFields['Suffix']) && $suffix) {
             $form->addSelect('suffix_id', array('class' => 'four', 'placeholder' => ' '));
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
         // job title
         // override the size for UI to look better
         $attributes['job_title']['size'] = 30;
         $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
         //Current Employer Element
         $employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $form->_contactId, FALSE, NULL, FALSE);
         $form->assign('employerDataURL', $employerDataURL);
         $form->addElement('text', 'current_employer', ts('Current Employer'), '');
         $form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id'));
         $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     }
     if (!$inlineEditMode) {
         $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
         if ($checkSimilar == null) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //External Identifier Element
         $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
         $config = CRM_Core_Config::singleton();
         CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
     }
 }
コード例 #17
0
ファイル: Individual.php プロジェクト: kidaa30/yes
 /**
  * This function provides the HTML form elements that are specific
  * to the Individual Contact Type
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param int $inlineEditMode
  *   ( 1 for contact summary.
  * top bar form and 2 for display name edit )
  *
  * @return void
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         //prefix
         $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
         if (isset($nameFields['Prefix']) && !empty($prefix)) {
             $form->addSelect('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix')));
         }
         $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
         if (isset($nameFields['Formal Title'])) {
             $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
         }
         // first_name
         if (isset($nameFields['First Name'])) {
             $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
         }
         //middle_name
         if (isset($nameFields['Middle Name'])) {
             $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
         }
         // last_name
         if (isset($nameFields['Last Name'])) {
             $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
         }
         // suffix
         $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
         if (isset($nameFields['Suffix']) && $suffix) {
             $form->addSelect('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix')));
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
         // job title
         // override the size for UI to look better
         $attributes['job_title']['size'] = 30;
         $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
         //Current Employer Element
         $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
         $form->addEntityRef('employer_id', ts('Current Employer'), $props);
         $attributes['source']['class'] = 'big';
         $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     }
     if (!$inlineEditMode) {
         $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
         if ($checkSimilar == NULL) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //External Identifier Element
         $form->add('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
         $config = CRM_Core_Config::singleton();
         CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
     }
 }
コード例 #18
0
ファイル: Individual.php プロジェクト: ksecor/civicrm
 /**
  * This function provides the HTML form elements that are specific to the Individual Contact Type
  * 
  * @access public
  * @return None 
  */
 public function buildQuickForm(&$form, $action = null)
 {
     $form->applyFilter('__ALL__', 'trim');
     //prefix
     $prefix = CRM_Core_PseudoConstant::individualPrefix();
     if (!empty($prefix)) {
         $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => '') + $prefix);
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
     // first_name
     $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
     //middle_name
     $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
     // last_name
     $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
     // suffix
     $suffix = CRM_Core_PseudoConstant::individualSuffix();
     if ($suffix) {
         $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => '') + $suffix);
     }
     // nick_name
     $form->addElement('text', 'nick_name', ts('Nick Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
     // job title
     // override the size for UI to look better
     $attributes['job_title']['size'] = 30;
     $form->addElement('text', 'job_title', ts('Job title'), $attributes['job_title'], 'size="30"');
     if ($action & CRM_Core_Action::UPDATE) {
         $mailToHouseholdID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $form->_contactId, 'mail_to_household_id', 'id');
         $form->assign('mailToHouseholdID', $mailToHouseholdID);
     }
     //Shared Address Element
     $form->addElement('checkbox', 'use_household_address', null, ts('Use Household Address'));
     $housholdDataURL = CRM_Utils_System::url('civicrm/ajax/search', "hh=1", false, null, false);
     $form->assign('housholdDataURL', $housholdDataURL);
     $form->add('text', 'shared_household', ts('Select Household'));
     $form->add('hidden', 'shared_household_id', '', array('id' => 'shared_household_id'));
     //Home Url Element
     $form->addElement('text', 'home_URL', ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'home_URL'), array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false")));
     $form->addRule('home_URL', ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url');
     //Current Employer Element
     $employerDataURL = CRM_Utils_System::url('civicrm/ajax/search', 'org=1', false, null, false);
     $form->assign('employerDataURL', $employerDataURL);
     $form->addElement('text', 'current_employer', ts('Current Employer'), '');
     $form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id'));
     $form->addElement('text', 'contact_source', ts('Source'));
     //External Identifier Element
     $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), false);
     $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
     $config =& CRM_Core_Config::singleton();
     CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
 }
コード例 #19
0
 /**
  * generic function to build all the form elements for a specific group tree
  *
  * @param object    $form             the form object
  * @param array     $groupTree        the group tree object
  * @param boolean   $inactiveNeeded   return inactive custom groups
  * @param string    $prefix           prefix for custom grouptree assigned to template
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '')
 {
     $form->assign_by_ref("{$prefix}groupTree", $groupTree);
     // this is fix for date field
     $form->assign('currentYear', date('Y'));
     foreach ($groupTree as $id => $group) {
         CRM_Core_ShowHideBlocks::links($form, $group['title'], '', '');
         foreach ($group['fields'] as $field) {
             $required = CRM_Utils_Array::value('is_required', $field);
             //fix for CRM-1620
             if ($field['data_type'] == 'File') {
                 if (!empty($field['element_value']['data'])) {
                     $required = 0;
                 }
             }
             $fieldId = $field['id'];
             $elementName = $field['element_name'];
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, $inactiveNeeded, $required);
         }
     }
     if (!empty($form->_stateCountryMap['state_province']) && !empty($form->_stateCountryMap['country'])) {
         foreach ($form->_stateCountryMap['state_province'] as $key => $value) {
             $stateCountryMap[$key]['state_province'] = $value;
             $stateCountryMap[$key]['country'] = $form->_stateCountryMap['country'][$key];
         }
         CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
     }
 }