function run() { // Add our template CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported()); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl')); parent::run(); }
function __construct() { $ext = CRM_Core_Extensions::singleton(); self::$_extensions = $ext->getExtensions(); $config = CRM_Core_Config::singleton(); $this->extDir = $config->extensionsDir; }
/** */ public function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array_merge(array('sort_name_linked' => array('title' => ts('Participant Name'), 'required' => TRUE, 'no_repeat' => TRUE, 'dbAlias' => 'contact_civireport.sort_name')), $this->getBasicContactFields(), array('age_at_event' => array('title' => ts('Age at Event'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, event_civireport.start_date)'))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('name' => 'first_name', 'title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'age_at_event' => array('name' => 'age_at_event', 'title' => ts('Age at Event')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('sort_name' => array('title' => ts('Participant Name'), 'operator' => 'like'), 'gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'birth_date' => array('title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields', 'filters' => array('email' => array('title' => ts('Participant E-mail'), 'operator' => 'like'))), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_address' => NULL, 'supplemental_address_1' => NULL, 'supplemental_address_2' => NULL, 'city' => NULL, 'postal_code' => NULL, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'))), 'grouping' => 'contact-fields'), 'civicrm_participant' => array('dao' => 'CRM_Event_DAO_Participant', 'fields' => array('participant_id' => array('title' => 'Participant ID'), 'participant_record' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE), 'event_id' => array('default' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'status_id' => array('title' => ts('Status'), 'default' => TRUE), 'role_id' => array('title' => ts('Role'), 'default' => TRUE), 'fee_currency' => array('required' => TRUE, 'no_display' => TRUE), 'registered_by_id' => array('title' => ts('Registered by Participant ID')), 'participant_fee_level' => NULL, 'participant_fee_amount' => array('title' => ts('Participant Fee')), 'participant_register_date' => array('title' => ts('Registration Date')), 'total_paid' => array('title' => ts('Total Paid'), 'dbAlias' => 'SUM(ft.total_amount)', 'type' => 1024), 'balance' => array('title' => ts('Balance'), 'dbAlias' => 'participant_civireport.fee_amount - SUM(ft.total_amount)', 'type' => 1024)), 'grouping' => 'event-fields', 'filters' => array('event_id' => array('name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, 'attributes' => array('entity' => 'event', 'select' => array('minimumInputLength' => 0))), 'sid' => array('name' => 'status_id', 'title' => ts('Participant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label')), 'rid' => array('name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole()), 'participant_register_date' => array('title' => 'Registration Date', 'operatorType' => CRM_Report_Form::OP_DATE), 'fee_currency' => array('title' => ts('Fee Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'registered_by_id' => array('title' => ts('Registered by Participant ID'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like')), 'order_bys' => array('participant_register_date' => array('title' => ts('Registration Date'), 'default_weight' => '1', 'default_order' => 'ASC'), 'event_id' => array('title' => ts('Event'), 'default_weight' => '1', 'default_order' => 'ASC'))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_event' => array('dao' => 'CRM_Event_DAO_Event', 'fields' => array('event_type_id' => array('title' => ts('Event Type')), 'event_start_date' => array('title' => ts('Event Start Date'))), 'grouping' => 'event-fields', 'filters' => array('eid' => array('name' => 'event_type_id', 'title' => ts('Event Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type')), 'event_start_date' => array('title' => ts('Event Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE)), 'order_bys' => array('event_type_id' => array('title' => ts('Event Type'), 'default_weight' => '2', 'default_order' => 'ASC'), 'event_start_date' => array('title' => ts('Event Start Date')))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_id' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contribution ID')), 'financial_type_id' => array('title' => ts('Financial Type')), 'receive_date' => array('title' => ts('Payment Date')), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'payment_instrument_id' => array('title' => ts('Payment Type')), 'contribution_source' => array('name' => 'source', 'title' => ts('Contribution Source')), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_id' => NULL, 'fee_amount' => array('title' => ts('Transaction Fee')), 'net_amount' => NULL), 'grouping' => 'contrib-fields', 'filters' => array('receive_date' => array('title' => 'Payment Date', 'operatorType' => CRM_Report_Form::OP_DATE), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), 'currency' => array('title' => ts('Contribution Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'payment_instrument_id' => array('title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => NULL))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem', 'grouping' => 'priceset-fields', 'filters' => array('price_field_value_id' => array('name' => 'price_field_value_id', 'title' => ts('Fee Level'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->getPriceLevels())))); $this->_options = array('blank_column_begin' => array('title' => ts('Blank column at the Begining'), 'type' => 'checkbox'), 'blank_column_end' => array('title' => ts('Blank column at the End'), 'type' => 'select', 'options' => array('' => '-select-', 1 => ts('One'), 2 => ts('Two'), 3 => ts('Three')))); // CRM-17115 avoid duplication of sort_name - would be better to standardise name // & behaviour across reports but trying for no change at this point. $this->_columns['civicrm_contact']['fields']['sort_name']['no_display'] = TRUE; // If we have active campaigns add those elements to both the fields and filters if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_participant']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_participant']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); $this->_columns['civicrm_participant']['order_bys']['campaign_id'] = array('title' => ts('Campaign')); } $this->_currencyColumn = 'civicrm_participant_fee_currency'; parent::__construct(); }
function run() { session_start(); require_once '../civicrm.config.php'; require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); require_once 'Console/Getopt.php'; $shortOptions = "n:p:k:pre"; $longOptions = array('name=', 'pass='******'key=', 'prefix='); $getopt = new Console_Getopt(); $args = $getopt->readPHPArgv(); array_shift($args); list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions); $vars = array('name' => 'n', 'pass' => 'p', 'key' => 'k', 'prefix' => 'pre'); foreach ($vars as $var => $short) { ${$var} = NULL; foreach ($valid as $v) { if ($v[0] == $short || $v[0] == "--{$var}") { ${$var} = $v[1]; break; } } if (!${$var}) { ${$var} = CRM_Utils_Array::value($var, $_REQUEST); } $_REQUEST[$var] = ${$var}; } // this does not return on failure // require_once 'CRM/Utils/System.php'; CRM_Utils_System::authenticateScript(TRUE, $name, $pass); //log the execution of script CRM_Core_Error::debug_log_message('NormalizePhone.php'); // process all phones processPhones($config, $prefix); }
/** */ public function __construct() { $this->_rollup = 'WITH ROLLUP'; $this->_autoIncludeIndexedFieldsAsOrderBys = 1; $yearsInPast = 10; $yearsInFuture = 1; $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture); $count = $date['maxYear']; while ($date['minYear'] <= $count) { $optionYear[$date['minYear']] = $date['minYear']; $date['minYear']++; } // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-field', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => TRUE), 'first_name' => array('title' => ts('First Name')), 'middle_name' => array('title' => ts('Middle Name')), 'last_name' => array('title' => ts('Last Name')), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'gender_id' => array('title' => ts('Gender')), 'birth_date' => array('title' => ts('Birth Date')), 'age' => array('title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())'), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('name' => 'first_name', 'title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'age_at_event' => array('name' => 'age_at_event', 'title' => ts('Age at Event')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE), 'gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'birth_date' => array('title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-field', 'fields' => array('email' => array('title' => ts('Email'), 'default' => TRUE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE)))); $this->_columns += $this->addAddressFields(); $this->_columns += array('civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contact_id' => array('title' => ts('contactId'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE), 'total_amount' => array('title' => ts('Total Amount'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE), 'receive_date' => array('title' => ts('Year'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('yid' => array('name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y'), 'type' => CRM_Utils_Type::T_INT), 'financial_type_id' => array('title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1'))))); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, 'type' => CRM_Utils_Type::T_INT); } $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; parent::__construct(); }
/** * Takes an associative array and creates a contribution object. * * the function extract all the params it needs to initialize the create a * contribution object. the params array could contain additional unused name/value * pairs * * @param array $params * (reference ) an assoc array of name/value pairs. * * @return CRM_Contribute_BAO_Contribution * @todo move hook calls / extended logic to create - requires changing calls to call create not add */ public static function add(&$params) { if (!empty($params['id'])) { CRM_Utils_Hook::pre('edit', 'ContributionRecur', $params['id'], $params); } else { CRM_Utils_Hook::pre('create', 'ContributionRecur', NULL, $params); } // make sure we're not creating a new recurring contribution with the same transaction ID // or invoice ID as an existing recurring contribution $duplicates = array(); if (self::checkDuplicate($params, $duplicates)) { $error = CRM_Core_Error::singleton(); $d = implode(', ', $duplicates); $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching recurring contribution(s): {$d}"); return $error; } $recurring = new CRM_Contribute_BAO_ContributionRecur(); $recurring->copyValues($params); $recurring->id = CRM_Utils_Array::value('id', $params); // set currency for CRM-1496 if (empty($params['id']) && !isset($recurring->currency)) { $config = CRM_Core_Config::singleton(); $recurring->currency = $config->defaultCurrency; } $result = $recurring->save(); if (!empty($params['id'])) { CRM_Utils_Hook::post('edit', 'ContributionRecur', $recurring->id, $recurring); } else { CRM_Utils_Hook::post('create', 'ContributionRecur', $recurring->id, $recurring); } if (!empty($params['custom']) && is_array($params['custom'])) { CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution_recur', $recurring->id); } return $result; }
/** * Constructor. * * @param null $path * The class Path of the form being implemented * @param bool $title * @param string $mode * @param bool $imageUpload * @param bool $addSequence * Should we add a unique sequence number to the end of the key. * @param bool $ignoreKey * Should we not set a qfKey for this controller (for standalone forms). * @param bool $attachUpload * * @return \CRM_Core_Controller_Simple */ public function __construct($path, $title, $mode = NULL, $imageUpload = FALSE, $addSequence = FALSE, $ignoreKey = FALSE, $attachUpload = FALSE) { // by definition a single page is modal :). We use the form name as the scope for this controller parent::__construct($title, TRUE, $mode, $path, $addSequence, $ignoreKey); $this->_stateMachine = new CRM_Core_StateMachine($this); $params = array($path => NULL); $savedAction = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, NULL); if (!empty($savedAction) && $savedAction != $mode) { $mode = $savedAction; } $this->_stateMachine->addSequentialPages($params, $mode); $this->addPages($this->_stateMachine, $mode); //changes for custom data type File $uploadNames = $this->get('uploadNames'); $config = CRM_Core_Config::singleton(); if (is_array($uploadNames) && !empty($uploadNames)) { $uploadArray = $uploadNames; $this->addActions($config->customFileUploadDir, $uploadArray); $this->set('uploadNames', NULL); } else { // always allow a single upload file with same name if ($attachUpload) { $this->addActions($config->uploadDir, CRM_Core_BAO_File::uploadNames()); } elseif ($imageUpload) { $this->addActions($config->imageUploadDir, array('uploadFile')); } else { $this->addActions(); } } }
/** * @return string */ public function run() { $config = CRM_Core_Config::singleton(); switch ($config->userFramework) { case 'Drupal': $this->assign('ufAccessURL', url('admin/people/permissions')); break; case 'Drupal6': $this->assign('ufAccessURL', url('admin/user/permissions')); break; case 'Joomla': //condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value if (version_compare(JVERSION, '3.0', 'lt')) { JHTML::_('behavior.modal'); $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component'; $jparams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"'; $this->assign('ufAccessURL', $url); $this->assign('jAccessParams', $jparams); } else { $uri = (string) JUri::getInstance(); $return = urlencode(base64_encode($uri)); $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return; $this->assign('ufAccessURL', $url); $this->assign('jAccessParams', ''); } break; case 'WordPress': $this->assign('ufAccessURL', CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1')); break; } return parent::run(); }
/** */ public function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => TRUE), 'first_name' => array('title' => ts('First Name')), 'middle_name' => array('title' => ts('Middle Name')), 'last_name' => array('title' => ts('Last Name')), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'gender_id' => array('title' => ts('Gender')), 'birth_date' => array('title' => ts('Birth Date')), 'age' => array('title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())'), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'type' => CRM_Utils_Type::T_INT), 'gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'birth_date' => array('title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('name' => 'first_name', 'title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Donor Email'), 'default' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Donor Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_id' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE), 'list_contri_id' => array('name' => 'id', 'title' => ts('Contribution ID')), 'financial_type_id' => array('title' => ts('Financial Type'), 'default' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'contribution_page_id' => array('title' => ts('Contribution Page')), 'source' => array('title' => ts('Source')), 'payment_instrument_id' => array('title' => ts('Payment Type')), 'check_number' => array('title' => ts('Check Number')), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_id' => NULL, 'receive_date' => array('default' => TRUE), 'receipt_date' => NULL, 'total_amount' => array('title' => ts('Amount'), 'required' => TRUE, 'statistics' => array('sum' => ts('Amount'))), 'fee_amount' => NULL, 'net_amount' => NULL, 'contribution_or_soft' => array('title' => ts('Contribution OR Soft Credit?'), 'dbAlias' => "'Contribution'"), 'soft_credits' => array('title' => ts('Soft Credits'), 'dbAlias' => "NULL"), 'soft_credit_for' => array('title' => ts('Soft Credit For'), 'dbAlias' => "NULL")), 'filters' => array('contribution_or_soft' => array('title' => ts('Contribution OR Soft Credit?'), 'clause' => "(1)", 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_STRING, 'options' => array('both' => ts('Both'), 'contributions_only' => ts('Contributions Only'), 'soft_credits_only' => ts('Soft Credits Only'))), 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), 'type' => CRM_Utils_Type::T_INT), 'contribution_page_id' => array('title' => ts('Contribution Page'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionPage(), 'type' => CRM_Utils_Type::T_INT), 'payment_instrument_id' => array('title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), 'type' => CRM_Utils_Type::T_INT), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1), 'type' => CRM_Utils_Type::T_INT), 'total_amount' => array('title' => ts('Contribution Amount'))), 'order_bys' => array('financial_type_id' => array('title' => ts('Financial Type')), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'payment_instrument_id' => array('title' => ts('Payment Instrument')), 'receive_date' => array('title' => ts('Receive Date'))), 'grouping' => 'contri-fields'), 'civicrm_contribution_soft' => array('dao' => 'CRM_Contribute_DAO_ContributionSoft', 'fields' => array('soft_credit_type_id' => array('title' => ts('Soft Credit Type'))), 'filters' => array('soft_credit_type_id' => array('title' => 'Soft Credit Type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING))), 'civicrm_contribution_ordinality' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'alias' => 'cordinality', 'filters' => array('ordinality' => array('title' => ts('Contribution Ordinality'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => array(0 => 'First by Contributor', 1 => 'Second or Later by Contributor'), 'type' => CRM_Utils_Type::T_INT))), 'civicrm_note' => array('dao' => 'CRM_Core_DAO_Note', 'fields' => array('contribution_note' => array('name' => 'note', 'title' => ts('Contribution Note'))), 'filters' => array('note' => array('name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING)))) + $this->addAddressFields(FALSE); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; // Don't show Batch display column and filter unless batches are being used $this->_allBatches = CRM_Batch_BAO_Batch::getBatches(); if (!empty($this->_allBatches)) { $this->_columns['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch'; $this->_columns['civicrm_batch']['fields']['batch_id'] = array('name' => 'id', 'title' => ts('Batch Name')); $this->_columns['civicrm_batch']['filters']['bid'] = array('name' => 'id', 'title' => ts('Batch Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_allBatches); $this->_columns['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch'; $this->_columns['civicrm_entity_batch']['fields']['entity_batch_id'] = array('name' => 'batch_id', 'default' => TRUE, 'no_display' => TRUE); } // If we have active campaigns add those elements to both the fields and filters if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign')); } $this->_currencyColumn = 'civicrm_contribution_currency'; parent::__construct(); }
/** * Class constructor. */ public function __construct() { // There could be multiple contacts. We not clear on which contact id to display. // Lets hide it for now. $this->_exposeContactID = FALSE; $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); $this->engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel(); } $this->activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'label', TRUE); asort($this->activityTypes); $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('contact_source' => array('name' => 'sort_name', 'title' => ts('Source Contact Name'), 'alias' => 'civicrm_contact_source', 'no_repeat' => TRUE), 'contact_assignee' => array('name' => 'sort_name', 'title' => ts('Assignee Contact Name'), 'alias' => 'civicrm_contact_assignee', 'dbAlias' => "civicrm_contact_assignee.sort_name", 'default' => TRUE), 'contact_target' => array('name' => 'sort_name', 'title' => ts('Target Contact Name'), 'alias' => 'civicrm_contact_target', 'dbAlias' => "civicrm_contact_target.sort_name", 'default' => TRUE), 'contact_source_id' => array('name' => 'id', 'alias' => 'civicrm_contact_source', 'dbAlias' => "civicrm_contact_source.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE), 'contact_assignee_id' => array('name' => 'id', 'alias' => 'civicrm_contact_assignee', 'dbAlias' => "civicrm_contact_assignee.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE), 'contact_target_id' => array('name' => 'id', 'alias' => 'civicrm_contact_target', 'dbAlias' => "civicrm_contact_target.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE)), 'filters' => array('contact_source' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_source', 'title' => ts('Source Contact Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_assignee' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_assignee', 'title' => ts('Assignee Contact Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_target' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_target', 'title' => ts('Target Contact Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'current_user' => array('name' => 'current_user', 'title' => ts('Limit To Current User'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('0' => ts('No'), '1' => ts('Yes')))), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('contact_source_email' => array('name' => 'email', 'title' => ts('Source Contact Email'), 'alias' => 'civicrm_email_source'), 'contact_assignee_email' => array('name' => 'email', 'title' => ts('Assignee Contact Email'), 'alias' => 'civicrm_email_assignee'), 'contact_target_email' => array('name' => 'email', 'title' => ts('Target Contact Email'), 'alias' => 'civicrm_email_target')), 'order_bys' => array('source_contact_email' => array('name' => 'email', 'title' => ts('Source Contact Email'), 'dbAlias' => 'civicrm_email_contact_source_email'))), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('no_display' => TRUE, 'title' => ts('Activity ID'), 'required' => TRUE), 'source_record_id' => array('no_display' => TRUE, 'required' => TRUE), 'activity_type_id' => array('title' => ts('Activity Type'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'activity_subject' => array('title' => ts('Subject'), 'default' => TRUE), 'activity_date_time' => array('title' => ts('Activity Date'), 'required' => TRUE), 'status_id' => array('title' => ts('Activity Status'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'duration' => array('title' => ts('Duration'), 'type' => CRM_Utils_Type::T_INT), 'details' => array('title' => ts('Activity Details'))), 'filters' => array('activity_date_time' => array('default' => 'this.month', 'operatorType' => CRM_Report_Form::OP_DATE), 'activity_subject' => array('title' => ts('Activity Subject')), 'activity_type_id' => array('title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityTypes), 'status_id' => array('title' => ts('Activity Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus()), 'details' => array('title' => ts('Activity Details'), 'type' => CRM_Utils_Type::T_TEXT)), 'order_bys' => array('activity_date_time' => array('title' => ts('Activity Date'), 'default_weight' => '1', 'dbAlias' => 'civicrm_activity_activity_date_time'), 'activity_type_id' => array('title' => ts('Activity Type'), 'default_weight' => '2', 'dbAlias' => "option_value_civireport")), 'grouping' => 'activity-fields', 'alias' => 'activity'), 'civicrm_activity_contact' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array()), 'civicrm_option_value' => array('dao' => 'CRM_Core_DAO_OptionValue', 'fields' => array(), 'status_id' => array('title' => ts('Activity Status'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'duration' => array('title' => ts('Duration'), 'type' => CRM_Utils_Type::T_INT), 'location' => array('title' => ts('Location'), 'type' => CRM_Utils_Type::T_STRING), 'details' => array('title' => ts('Activity Details'))), 'filters' => array('activity_date_time' => array('default' => 'this.month', 'operatorType' => CRM_Report_Form::OP_DATE), 'activity_subject' => array('title' => ts('Activity Subject')), 'location' => array('title' => ts('Location'), 'type' => CRM_Utils_Type::T_TEXT), 'activity_type_id' => array('title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityTypes), 'status_id' => array('title' => ts('Activity Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus()), 'details' => array('title' => ts('Activity Details'), 'type' => CRM_Utils_Type::T_TEXT))) + $this->addressFields(TRUE); if ($campaignEnabled) { // Add display column and filter for Survey Results, Campaign and Engagement Index if CiviCampaign is enabled $this->_columns['civicrm_activity']['fields']['result'] = array('title' => 'Survey Result', 'default' => 'false'); $this->_columns['civicrm_activity']['filters']['result'] = array('title' => ts('Survey Result'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING); if (!empty($this->activeCampaigns)) { $this->_columns['civicrm_activity']['fields']['campaign_id'] = array('title' => 'Campaign', 'default' => 'false'); $this->_columns['civicrm_activity']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); } if (!empty($this->engagementLevels)) { $this->_columns['civicrm_activity']['fields']['engagement_level'] = array('title' => 'Engagement Index', 'default' => 'false'); $this->_columns['civicrm_activity']['filters']['engagement_level'] = array('title' => ts('Engagement Index'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->engagementLevels); } } $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; $this->_tagFilterTable = 'civicrm_activity'; parent::__construct(); }
/** * Given a url, mailing id and queue event id, find or construct a * trackable url and redirect url. * * @param string $url The target url to track * @param int $mailing_id The id of the mailing * @param int $queue_id The queue event id (contact clicking through) * @return string $redirect The redirect/tracking url * @static */ public static function getTrackerURL($url, $mailing_id, $queue_id) { static $urlCache = array(); if (array_key_exists($url, $urlCache)) { return $urlCache[$url] . "&qid={$queue_id}"; } // hack for basic CRM-1014 and CRM-1151 and CRM-3492 compliance: // let's not replace possible image URLs and CiviMail ones if (preg_match('/\\.(png|jpg|jpeg|gif|css)[\'"]?$/i', $url) or substr_count($url, 'civicrm/extern/') or substr_count($url, 'civicrm/mailing/')) { // let's not cache these, so they don't get &qid= appended to them return $url; } else { $hrefExists = false; $config = CRM_Core_Config::singleton(); $tracker = new CRM_Mailing_BAO_TrackableURL(); if (preg_match('/^href/i', $url)) { $url = preg_replace('/^href[ ]*=[ ]*[\'"](.*?)[\'"]$/i', '$1', $url); $hrefExists = true; } $tracker->url = $url; $tracker->mailing_id = $mailing_id; if (!$tracker->find(true)) { $tracker->save(); } $id = $tracker->id; $tracker->free(); $redirect = $config->userFrameworkResourceURL . "extern/url.php?u={$id}"; $urlCache[$url] = $redirect; } $returnUrl = "{$urlCache[$url]}&qid={$queue_id}"; if ($hrefExists) { $returnUrl = "href='{$returnUrl}'"; } return $returnUrl; }
/** * @param array $cxn * @param string $entity * @param string $action * @param array $params * @return mixed */ public static function route($cxn, $entity, $action, $params) { $SUPER_PERM = array('administer CiviCRM'); require_once 'api/v3/utils.php'; // FIXME: Shouldn't the X-Forwarded-Proto check be part of CRM_Utils_System::isSSL()? if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL') && !CRM_Utils_System::isSSL() && strtolower(CRM_Utils_Array::value('X_FORWARDED_PROTO', CRM_Utils_System::getRequestHeaders())) != 'https') { return civicrm_api3_create_error('System policy requires HTTPS.'); } // Note: $cxn and cxnId are authenticated before router is called. $dao = new CRM_Cxn_DAO_Cxn(); $dao->cxn_id = $cxn['cxnId']; if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) { return civicrm_api3_create_error('Failed to lookup connection authorizations.'); } if (!$dao->is_active) { return civicrm_api3_create_error('Connection is inactive.'); } if (!is_string($entity) || !is_string($action) || !is_array($params)) { return civicrm_api3_create_error('API parameters are malformed.'); } if (empty($cxn['perm']['api']) || !is_array($cxn['perm']['api']) || empty($cxn['perm']['grant']) || !(is_array($cxn['perm']['grant']) || is_string($cxn['perm']['grant']))) { return civicrm_api3_create_error('Connection has no permissions.'); } $whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']); \Civi::service('dispatcher')->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist)); CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp(); if ($cxn['perm']['grant'] === '*') { CRM_Core_Config::singleton()->userPermissionTemp->grant($SUPER_PERM); } else { CRM_Core_Config::singleton()->userPermissionTemp->grant($cxn['perm']['grant']); } $params['check_permissions'] = 'whitelist'; return civicrm_api($entity, $action, $params); }
/** * Common form elements. */ public function buildQuickForm() { $config = CRM_Core_Config::singleton(); $uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE); $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE); $this->setDefaults(array('fieldSeparator' => $config->fieldSeparator)); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import ' . static::IMPORT_ENTITY, 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadedMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadedMapping); $this->setDefaults(array('savedMapping' => $loadedMapping)); } //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** */ public function __construct() { $this->_pledgeStatuses = CRM_Contribute_PseudoConstant::contributionStatus(); // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Contact Name')), 'id' => array('no_display' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_pledge' => array('dao' => 'CRM_Pledge_DAO_Pledge', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_id' => array('no_display' => TRUE, 'required' => TRUE), 'financial_type_id' => array('title' => ts('Financial Type')), 'amount' => array('title' => ts('Pledge Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'frequency_unit' => array('title' => ts('Frequency Unit')), 'installments' => array('title' => ts('Installments')), 'pledge_create_date' => array('title' => ts('Pledge Made Date')), 'start_date' => array('title' => ts('Pledge Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('Pledge End Date'), 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Pledge Status'), 'required' => TRUE)), 'filters' => array('pledge_create_date' => array('title' => 'Pledge Made Date', 'operatorType' => CRM_Report_Form::OP_DATE), 'pledge_amount' => array('title' => ts('Pledged Amount'), 'operatorType' => CRM_Report_Form::OP_INT), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'sid' => array('name' => 'status_id', 'title' => ts('Pledge Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('contribution_status')), 'financial_type_id' => array('title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()))), 'civicrm_pledge_payment' => array('dao' => 'CRM_Pledge_DAO_PledgePayment', 'fields' => array('total_paid' => array('title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_MONEY), 'balance_due' => array('title' => ts('Balance Due'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY)))); $this->_columns += $this->getAddressColumns(array('group_by' => FALSE)) + $this->getPhoneColumns(); // If we have a campaign, build out the relevant elements $this->_tagFilter = TRUE; if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_pledge']['fields']['campaign_id'] = array('title' => 'Campaign', 'default' => 'false'); $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); $this->_columns['civicrm_pledge']['group_bys']['campaign_id'] = array('title' => ts('Campaign')); } $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; $this->_currencyColumn = 'civicrm_pledge_currency'; parent::__construct(); }
public static function &info($ovID = null, &$title = null) { $report = ''; if ($ovID) { $report = " AND v.id = {$ovID} "; } $sql = "\n SELECT inst.id, inst.title, inst.report_id, inst.description, v.label, \n ifnull( SUBSTRING(comp.name, 5), 'Contact' ) as compName\n FROM civicrm_option_group g\n LEFT JOIN civicrm_option_value v\n ON v.option_group_id = g.id AND\n g.name = 'report_template'\n LEFT JOIN civicrm_report_instance inst\n ON v.value = inst.report_id\n LEFT JOIN civicrm_component comp \n ON v.component_id = comp.id\n \n WHERE v.is_active = 1 {$report}\n\n ORDER BY v.weight\n "; $dao = CRM_Core_DAO::executeQuery($sql); $config = CRM_Core_Config::singleton(); $rows = array(); $url = 'civicrm/report/instance'; while ($dao->fetch()) { $enabled = in_array("Civi{$dao->compName}", $config->enableComponents); if ($dao->compName == 'Contact') { $enabled = true; } //filter report listings by permissions if (!($enabled && CRM_Report_Utils_Report::isInstancePermissioned($dao->id))) { continue; } if (trim($dao->title)) { if ($ovID) { $title = ts("Report(s) created from the template: %1", array(1 => $dao->label)); } $rows[$dao->compName][$dao->id]['title'] = $dao->title; $rows[$dao->compName][$dao->id]['label'] = $dao->label; $rows[$dao->compName][$dao->id]['description'] = $dao->description; $rows[$dao->compName][$dao->id]['url'] = CRM_Utils_System::url("{$url}/{$dao->id}", "reset=1"); if (CRM_Core_Permission::check('administer Reports')) { $rows[$dao->compName][$dao->id]['deleteUrl'] = CRM_Utils_System::url("{$url}/{$dao->id}", 'action=delete&reset=1'); } } } return $rows; }
function run() { $config =& CRM_Core_Config::singleton(); $ufAccessURL = CRM_Utils_System::url('admin/user/permissions'); $this->assign('ufAccessURL', $ufAccessURL); return parent::run(); }
/** * Starting from the processor as an array retrieve the processor as an object. * * If there is no valid configuration it will not be retrieved. * * @param array $processor * * @return CRM_Core_Payment|NULL * * @throws \CRM_Core_Exception */ public function getByProcessor($processor) { $id = $processor['id']; if (!isset($this->cache[$id])) { if (!isset($this->cache[$id])) { //does this config need to be called? $config = \CRM_Core_Config::singleton(); $ext = \CRM_Extension_System::singleton()->getMapper(); if ($ext->isExtensionKey($processor['class_name'])) { $paymentClass = $ext->keyToClass($processor['class_name'], 'payment'); require_once $ext->classToPath($paymentClass); } else { $paymentClass = 'CRM_Core_' . $processor['class_name']; if (empty($paymentClass)) { throw new \CRM_Core_Exception('no class provided'); } require_once str_replace('_', DIRECTORY_SEPARATOR, $paymentClass) . '.php'; } $processorObject = new $paymentClass(!empty($processor['is_test']) ? 'test' : 'live', $processor); if ($processorObject->checkConfig()) { $processorObject = NULL; } else { $processorObject->setPaymentProcessor($processor); } } $this->cache[$id] = $processorObject; } return $this->cache[$id]; }
/** * takes an associative array and creates an instance object * * the function extract all the params it needs to initialize the create a * instance object. the params array could contain additional unused name/value * pairs * * @param array $params (reference ) an assoc array of name/value pairs * * @return object CRM_Report_DAO_ReportInstance object * @access public * @static */ static function add(&$params) { $instance = new CRM_Report_DAO_ReportInstance(); if (empty($params)) { return NULL; } $config = CRM_Core_Config::singleton(); $params['domain_id'] = CRM_Core_Config::domainID(); // convert roles array to string if (isset($params['grouprole']) && is_array($params['grouprole'])) { $grouprole_array = array(); foreach ($params['grouprole'] as $key => $value) { $grouprole_array[$value] = $value; } $params['grouprole'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($grouprole_array)); } if (!isset($params['id'])) { $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE); } $instanceID = CRM_Utils_Array::value('id', $params); if (!empty($params['instance_id'])) { $instanceID = CRM_Utils_Array::value('instance_id', $params); } if ($instanceID) { CRM_Utils_Hook::pre('edit', 'ReportInstance', $instanceID, $params); } else { CRM_Utils_Hook::pre('create', 'ReportInstance', NULL, $params); } $instance = new CRM_Report_DAO_ReportInstance(); $instance->copyValues($params); if ($config->userFramework == 'Joomla') { $instance->permission = 'null'; } // explicitly set to null if params value is empty if (!$instanceID && empty($params['grouprole'])) { $instance->grouprole = 'null'; } if ($instanceID) { $instance->id = $instanceID; } if (!$instanceID) { if ($reportID = CRM_Utils_Array::value('report_id', $params)) { $instance->report_id = $reportID; } else { if ($instanceID) { $instance->report_id = CRM_Report_Utils_Report::getValueFromUrl($instanceID); } else { // just take it from current url $instance->report_id = CRM_Report_Utils_Report::getValueFromUrl(); } } } $instance->save(); if ($instanceID) { CRM_Utils_Hook::pre('edit', 'ReportInstance', $instance->id, $instance); } else { CRM_Utils_Hook::pre('create', 'ReportInstance', $instance->id, $instance); } return $instance; }
/** * format a monetary string * * Format a monetary string basing on the amount provided, * ISO currency code provided and a format string consisting of: * * %a - the formatted amount * %C - the currency ISO code (e.g., 'USD') if provided * %c - the currency symbol (e.g., '$') if available * * @param float $amount the monetary amount to display (1234.56) * @param string $currency the three-letter ISO currency code ('USD') * @param string $format the desired currency format * * @return string formatted monetary string * * @static */ static function format($amount, $currency = null, $format = null) { if (CRM_Utils_System::isNull($amount)) { return ''; } $config =& CRM_Core_Config::singleton(); if (!self::$_currencySymbols) { require_once "CRM/Core/PseudoConstant.php"; $currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name'); $currencySymbol = CRM_Core_PseudoConstant::currencySymbols(); self::$_currencySymbols = array_combine($currencySymbolName, $currencySymbol); } if (!$currency) { $currency = $config->defaultCurrency; } if (!$format) { $format = $config->moneyformat; } // money_format() exists only in certain PHP install (CRM-650) if (is_numeric($amount) and function_exists('money_format')) { $amount = money_format($config->moneyvalueformat, $amount); } $replacements = array('%a' => $amount, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, self::$_currencySymbols, $currency)); return strtr($format, $replacements); }
/** */ public function __construct() { $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array('CiviCampaign', $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'first_name' => array('title' => ts('First Name'), 'no_repeat' => TRUE), 'last_name' => array('title' => ts('Last Name'), 'no_repeat' => TRUE), 'contact_type' => array('title' => ts('Contact Type'), 'no_repeat' => TRUE), 'contact_sub_type' => array('title' => ts('Contact Subtype'), 'no_repeat' => TRUE), 'do_not_email' => array('title' => ts('Do Not Email'), 'no_repeat' => TRUE), 'is_opt_out' => array('title' => ts('No Bulk Email(Is Opt Out)'), 'no_repeat' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contact ID'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Donor Email'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Donor Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'first_donation' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('first_donation_date' => array('title' => ts('First Contribution Date'), 'base_field' => 'receive_date', 'no_repeat' => TRUE), 'first_donation_amount' => array('title' => ts('First Contribution Amount'), 'base_field' => 'total_amount', 'no_repeat' => TRUE))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_id' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contribution ID')), 'financial_type_id' => array('title' => ts('Financial Type'), 'default' => TRUE), 'contribution_recur_id' => array('title' => ts('Recurring Contribution Id'), 'name' => 'contribution_recur_id', 'required' => TRUE, 'no_display' => TRUE, 'csv_display' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'payment_instrument_id' => array('title' => ts('Payment Type')), 'contribution_source' => array('name' => 'source', 'title' => ts('Contribution Source')), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_id' => NULL, 'receive_date' => array('default' => TRUE), 'receipt_date' => NULL, 'fee_amount' => NULL, 'net_amount' => NULL, 'total_amount' => array('title' => ts('Amount'), 'required' => TRUE)), 'filters' => array('receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'payment_instrument_id' => array('title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1)), 'total_amount' => array('title' => ts('Contribution Amount'))), 'grouping' => 'contri-fields'), 'civicrm_product' => array('dao' => 'CRM_Contribute_DAO_Product', 'fields' => array('product_name' => array('name' => 'name', 'title' => ts('Premium')))), 'civicrm_contribution_product' => array('dao' => 'CRM_Contribute_DAO_ContributionProduct', 'fields' => array('product_id' => array('no_display' => TRUE), 'product_option' => array('title' => ts('Premium Option')), 'fulfilled_date' => array('title' => ts('Premium Fulfilled Date')), 'contribution_id' => array('no_display' => TRUE))), 'civicrm_contribution_ordinality' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'alias' => 'cordinality', 'filters' => array('ordinality' => array('title' => ts('Contribution Ordinality'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => array(0 => 'First by Contributor', 1 => 'Second or Later by Contributor')))), 'civicrm_membership' => array('dao' => 'CRM_Member_DAO_Membership', 'fields' => array('membership_type_id' => array('title' => ts('Membership Type'), 'required' => TRUE, 'no_repeat' => TRUE), 'membership_start_date' => array('title' => ts('Start Date'), 'default' => TRUE), 'membership_end_date' => array('title' => ts('End Date'), 'default' => TRUE), 'join_date' => array('title' => ts('Join Date'), 'default' => TRUE), 'source' => array('title' => ts('Membership Source'))), 'filters' => array('join_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'membership_start_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'membership_end_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'owner_membership_id' => array('title' => ts('Membership Owner ID'), 'operatorType' => CRM_Report_Form::OP_INT), 'tid' => array('name' => 'membership_type_id', 'title' => ts('Membership Types'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType())), 'grouping' => 'member-fields'), 'civicrm_membership_status' => array('dao' => 'CRM_Member_DAO_MembershipStatus', 'alias' => 'mem_status', 'fields' => array('membership_status_name' => array('name' => 'name', 'title' => ts('Membership Status'), 'default' => TRUE)), 'filters' => array('sid' => array('name' => 'id', 'title' => ts('Membership Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'))), 'grouping' => 'member-fields'), 'civicrm_note' => array('dao' => 'CRM_Core_DAO_Note', 'fields' => array('contribution_note' => array('name' => 'note', 'title' => ts('Contribution Note'))), 'filters' => array('note' => array('name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING)))) + $this->addAddressFields(FALSE); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; // Don't show Batch display column and filter unless batches are being used $this->_allBatches = CRM_Batch_BAO_Batch::getBatches(); if (!empty($this->_allBatches)) { $this->_columns['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch'; $this->_columns['civicrm_batch']['fields']['batch_id'] = array('name' => 'id', 'title' => ts('Batch Name')); $this->_columns['civicrm_batch']['filters']['bid'] = array('name' => 'id', 'title' => ts('Batch Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_allBatches); $this->_columns['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch'; $this->_columns['civicrm_entity_batch']['fields']['entity_batch_id'] = array('name' => 'batch_id', 'default' => TRUE, 'no_display' => TRUE); } if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign')); } $this->_currencyColumn = 'civicrm_contribution_currency'; parent::__construct(); }
/** * Compute any messages which should be displayed after upgrade. * * @param string $postUpgradeMessage * alterable. * @param string $rev * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs. * @return void */ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { if ($rev == '4.7.alpha1') { $config = CRM_Core_Config::singleton(); // FIXME: Performing an upgrade step during postUpgrade message phase is probably bad $editor_id = self::updateWysiwyg(); $msg = NULL; $ext_href = 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1') . '"'; $dsp_href = 'href="' . CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1') . '"'; $blog_href = 'href="https://civicrm.org/blogs/colemanw/big-changes-wysiwyg-editing-47"'; switch ($editor_id) { // TinyMCE case 1: $msg = ts('Your configured editor "TinyMCE" is no longer part of the main CiviCRM download. To continue using it, visit the <a %1>Manage Extensions</a> page to download and install the TinyMCE extension.', array(1 => $ext_href)); break; // Drupal/Joomla editor // Drupal/Joomla editor case 3: case 4: $msg = ts('CiviCRM no longer integrates with the "%1 Default Editor." Your wysiwyg setting has been reset to the built-in CKEditor. <a %2>Learn more...</a>', array(1 => $config->userFramework, 2 => $blog_href)); break; } if ($msg) { $postUpgradeMessage .= '<p>' . $msg . '</p>'; } $postUpgradeMessage .= '<p>' . ts('CiviCRM now includes the easy-to-use CKEditor Configurator. To customize the features and display of your wysiwyg editor, visit the <a %1>Display Preferences</a> page. <a %2>Learn more...</a>', array(1 => $dsp_href, 2 => $blog_href)) . '</p>'; $postUpgradeMessage .= '<br /><br />' . ts('Default version of the following System Workflow Message Templates have been modified: <ul><li>Personal Campaign Pages - Owner Notification</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).'); $postUpgradeMessage .= '<p>' . ts('The custom fatal error template setting has been removed.') . '</p>'; } }
/** * FIXME: we should make this method like getLocBlock() OR use the same method and * remove this one. * * Function to obtain the location of given contact-id. * This method is used by on-behalf-of form to dynamically generate poulate the * location field values for selected permissioned contact. */ function getPermissionedLocation() { $cid = CRM_Utils_Type::escape($_GET['cid'], 'Integer'); require_once 'CRM/Core/BAO/Location.php'; $entityBlock = array('contact_id' => $cid); $location =& CRM_Core_BAO_Location::getValues($entityBlock); $config =& CRM_Core_Config::singleton(); $addressSequence = array_flip($config->addressSequence()); $elements = array("phone_1_phone" => $location['phone'][1]['phone'], "email_1_email" => $location['email'][1]['email']); if (array_key_exists('street_address', $addressSequence)) { $elements["address_1_street_address"] = $location['address'][1]['street_address']; } if (array_key_exists('supplemental_address_1', $addressSequence)) { $elements['address_1_supplemental_address_1'] = $location['address'][1]['supplemental_address_1']; } if (array_key_exists('supplemental_address_2', $addressSequence)) { $elements['address_1_supplemental_address_2'] = $location['address'][1]['supplemental_address_2']; } if (array_key_exists('city', $addressSequence)) { $elements['address_1_city'] = $location['address'][1]['city']; } if (array_key_exists('postal_code', $addressSequence)) { $elements['address_1_postal_code'] = $location['address'][1]['postal_code']; $elements['address_1_postal_code_suffix'] = $location['address'][1]['postal_code_suffix']; } if (array_key_exists('country', $addressSequence)) { $elements['address_1_country_id'] = $location['address'][1]['country_id']; } if (array_key_exists('state_province', $addressSequence)) { $elements['address_1_state_province_id'] = $location['address'][1]['state_province_id']; } echo json_encode($elements); exit; }
function run() { $upgrade = new CRM_Upgrade_Form(); $message = ts('CiviCRM upgrade successful'); if ($upgrade->checkVersion($upgrade->latestVersion)) { $message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $upgrade->latestVersion)); } elseif ($upgrade->checkVersion('2.1.2') || $upgrade->checkVersion('2.1.3') || $upgrade->checkVersion('2.1.4') || $upgrade->checkVersion('2.1.5')) { // do nothing, db version is changed for all upgrades } elseif ($upgrade->checkVersion('2.1.0') || $upgrade->checkVersion('2.1') || $upgrade->checkVersion('2.1.1')) { // 2.1 to 2.1.2 $this->runTwoOneTwo(); } else { // 2.0 to 2.1 for ($i = 1; $i <= 4; $i++) { $this->runForm($i); } // 2.1 to 2.1.2 $this->runTwoOneTwo(); } // just change the ver in the db, since nothing to upgrade $upgrade->setVersion($upgrade->latestVersion); // also cleanup the templates_c directory $config = CRM_Core_Config::singleton(); $config->cleanup(1); $template = CRM_Core_Smarty::singleton(); $template->assign('message', $message); $template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $upgrade->latestVersion))); $template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1')); $contents = $template->fetch('CRM/common/success.tpl'); echo $contents; }
function __construct() { $yearsInPast = 10; $yearsInFuture = 1; $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture); $count = $date['maxYear']; while ($date['minYear'] <= $count) { $optionYear[$date['minYear']] = $date['minYear']; $date['minYear']++; } // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-field', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => TRUE), 'first_name' => array('title' => ts('First Name')), 'last_name' => array('title' => ts('Last Name')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-field', 'fields' => array('email' => array('title' => ts('Email'), 'default' => TRUE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE)))) + $this->addAddressFields() + array('civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contact_id' => array('title' => ts('contactId'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE), 'total_amount' => array('title' => ts('Total Amount'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE), 'receive_date' => array('title' => ts('Year'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('yid' => array('name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y')), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1')))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group())))); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); } $this->_tagFilter = TRUE; parent::__construct(); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this); $this->_cc = CRM_Utils_Request::retrieve('cc', 'String', $this); //get the contact and event id and assing to session. $values = array(); $csContactID = NULL; if ($this->_participantId) { $params = array('id' => $this->_participantId); CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Participant', $params, $values, array('contact_id', 'event_id', 'status_id')); } $this->_participantStatusId = CRM_Utils_Array::value('status_id', $values); $this->_eventId = CRM_Utils_Array::value('event_id', $values); $csContactId = CRM_Utils_Array::value('contact_id', $values); // make sure we have right permission to edit this user $this->_csContactID = NULL; if ($csContactId && $this->_eventId) { $session = CRM_Core_Session::singleton(); if ($csContactId == $session->get('userID')) { $this->_csContactID = $csContactId; } else { if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactId, $this)) { //since we have landing page so get this contact //id in session if user really want to walk wizard. $this->_csContactID = $csContactId; } } } if (!$this->_csContactID) { $config = CRM_Core_Config::singleton(); CRM_Core_Error::statusBounce(ts('You do not have permission to access this event registration. Contact the site administrator if you need assistance.'), $config->userFrameworkBaseURL); } }
/** * 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', '', ''); }
/** * Display daily system status alerts (admin only). */ public function showPeriodicAlerts() { if (CRM_Core_Permission::check('administer CiviCRM')) { $session = CRM_Core_Session::singleton(); if ($session->timer('check_' . __CLASS__, self::CHECK_TIMER)) { // Best attempt at re-securing folders $config = CRM_Core_Config::singleton(); $config->cleanup(0, FALSE); $statusMessages = array(); $maxSeverity = 0; foreach ($this->checkAll() as $message) { if (!$message->isVisible()) { continue; } if ($message->getLevel() >= 3) { $maxSeverity = max($maxSeverity, $message->getLevel()); $statusMessage = $message->getMessage(); $statusMessages[] = $statusTitle = $message->getTitle(); } } if ($statusMessages) { if (count($statusMessages) > 1) { $statusTitle = self::toStatusLabel($maxSeverity); $statusMessage = '<ul><li>' . implode('</li><li>', $statusMessages) . '</li></ul>'; } $statusMessage .= '<p><a href="' . CRM_Utils_System::url('civicrm/a/#/status') . '">' . ts('View details and manage alerts') . '</a></p>'; $statusType = $maxSeverity >= 4 ? 'error' : 'alert'; CRM_Core_Session::setStatus($statusMessage, $statusTitle, $statusType); } } } }
function add_participant_to_cart() { require 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); $cart_id = $_GET['cart_id']; $event_id = $_GET['event_id']; $cart = CRM_Event_Cart_BAO_Cart::find_by_id($_GET['cart_id']); $params_array = array('cart_id' => $cart->id, 'contact_id' => CRM_Event_Cart_Form_Cart::find_or_create_contact(), 'event_id' => $event_id); //XXX security? $participant = CRM_Event_Cart_BAO_MerParticipant::create($params_array); $participant->save(); $form = new CRM_Core_Form(); $pform = new CRM_Event_Cart_Form_MerParticipant($participant); $pform->appendQuickForm($form); $renderer = $form->getRenderer(); $config = CRM_Core_Config::singleton(); $templateDir = $config->templateDir; if (is_array($templateDir)) { $templateDir = array_pop($templateDir); } $requiredTemplate = file_get_contents($templateDir . '/CRM/Form/label.tpl'); $renderer->setRequiredTemplate($requiredTemplate); $form->accept($renderer); $template = CRM_Core_Smarty::singleton(); $template->assign('form', $renderer->toArray()); $template->assign('participant', $participant); $output = $template->fetch("CRM/Event/Cart/Form/Checkout/Participant.tpl"); $transaction->commit(); echo $output; CRM_Utils_System::civiExit(); }
/** * constructor * * @param string path the class Path of the form being implemented * @param string title the descriptive name for the page * @param int mode the mode that the form will operate on * @param boolean addSequence should we add a unique sequence number to the end of the key * @param boolean ignoreKey should we not set a qfKey for this controller (for standalone forms) * * @return object * @access public */ function __construct($path, $title, $mode = null, $imageUpload = false, $addSequence = false, $ignoreKey = false, $attachUpload = false) { // by definition a single page is modal :). We use the form name as the scope for this controller parent::__construct($title, true, $mode, $path, $addSequence, $ignoreKey); $this->_stateMachine =& new CRM_Core_StateMachine($this); $params = array($path => null); $this->_stateMachine->addSequentialPages($params, $mode); $this->addPages($this->_stateMachine, $mode); //changes for custom data type File $uploadNames = $this->get('uploadNames'); $config =& CRM_Core_Config::singleton(); if (is_array($uploadNames) && !empty($uploadNames)) { $uploadArray = $uploadNames; $this->addActions($config->customFileUploadDir, $uploadArray); $this->set('uploadNames', null); } else { // always allow a single upload file with same name if ($attachUpload) { require_once 'CRM/Core/BAO/File.php'; $this->addActions($config->uploadDir, CRM_Core_BAO_File::uploadNames()); } else { if ($imageUpload) { $this->addActions($config->imageUploadDir, array('uploadFile')); } else { $this->addActions(); } } } }
function run() { // Prepares variables for being sent to Smarty //Only show countries with attached information $countries = null; $stats = civicrm_api3('Bic', 'stats'); foreach ($stats['values'] as $country => $count) { $countries[] = $country; } // Get country names $country_names = null; if ($countries) { $config = CRM_Core_Config::singleton(); $country_names = array(); $id2code = CRM_Core_PseudoConstant::countryIsoCode(); $default_country = $id2code[$config->defaultContactCountry]; $code2id = array_flip($id2code); $id2country = CRM_Core_PseudoConstant::country(false, false); foreach ($countries as $code) { $country_id = $code2id[$code]; $country_name = $id2country[$country_id]; $country_names[$code] = $country_name; } } // Sends variables to Smarty $this->assign('countries', $countries); $this->assign('country_names', $country_names); $this->assign('default_country', $default_country); $this->assign('show_message', true); parent::run(); }