function run() { require_once 'CRM/Utils/Request.php'; $contact_id = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject); $hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject); $activity_id = CRM_Utils_Request::retrieve('a', 'String', CRM_Core_DAO::$_nullObject); $petition_id = CRM_Utils_Request::retrieve('p', 'String', CRM_Core_DAO::$_nullObject); if (!$contact_id || !$subscribe_id || !$hash) { CRM_Core_Error::fatal(ts("Missing input parameters")); } require_once 'CRM/Mailing/Event/BAO/Confirm.php'; $result = $this->confirm($contact_id, $subscribe_id, $hash, $activity_id, $petition_id); if ($result === false) { $this->assign('success', $result); } else { $this->assign('success', true); // $this->assign( 'group' , $result ); } require_once 'CRM/Contact/BAO/Contact/Location.php'; list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id); $this->assign('display_name', $displayName); $this->assign('email', $email); $this->assign('petition_id', $petition_id); $this->assign('survey_id', $petition_id); // send thank you email require_once 'CRM/Campaign/Form/Petition/Signature.php'; $params['contactId'] = $contact_id; $params['email-Primary'] = $email; $params['sid'] = $petition_id; $params['activityId'] = $activity_id; CRM_Campaign_BAO_Petition::sendEmail($params, CRM_Campaign_Form_Petition_Signature::EMAIL_THANK); parent::run(); }
public function preProcess() { $this->_type = 'unsubscribe'; $this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this); $this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this); $this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this); if (!$job_id || !$queue_id || !$hash) { CRM_Core_Error::fatal(ts("Missing Parameters")); } // verify that the three numbers above match $q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash); if (!$q) { CRM_Core_Error::fatal(ts("There was an error in your request")); } list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id); $this->assign('display_name', $displayName); $emailMasked = CRM_Utils_String::maskEmail($email); $this->assign('email_masked', $emailMasked); $this->assign('email', $email); $this->_email = $email; $groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE); $this->assign('groups', $groups); $groupExist = NULL; foreach ($groups as $key => $value) { if ($value) { $groupExist = TRUE; } } if (!$groupExist) { $statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.', array(1 => $email)); CRM_Core_Session::setStatus($statusMsg, '', 'fail'); } $this->assign('groupExist', $groupExist); }
/** * For pre-processing * * @return void */ public function preProcess() { parent::preProcess(); $this->_key = CRM_Utils_Request::retrieve('key', 'String', $this, FALSE, 0); $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1&action=browse'); $session->pushUserContext($url); $this->assign('id', $this->_id); $this->assign('key', $this->_key); switch ($this->_action) { case CRM_Core_Action::ADD: case CRM_Core_Action::DELETE: case CRM_Core_Action::ENABLE: case CRM_Core_Action::DISABLE: $info = CRM_Extension_System::singleton()->getMapper()->keyToInfo($this->_key); $extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info); $this->assign('extension', $extInfo); break; case CRM_Core_Action::UPDATE: if (!CRM_Extension_System::singleton()->getBrowser()->isEnabled()) { CRM_Core_Error::fatal(ts('The system administrator has disabled this feature.')); } $info = CRM_Extension_System::singleton()->getBrowser()->getExtension($this->_key); $extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info); $this->assign('extension', $extInfo); break; default: CRM_Core_Error::fatal(ts('Unsupported action')); } }
/** * Set variables up before form is built. * * * @return void */ public function preProcess() { // current set id $this->_id = $this->get('id'); if ($this->_id && ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_id, 'is_reserved', 'id'))) { CRM_Core_Error::fatal("You cannot edit the settings of a reserved custom field-set."); } // setting title for html page if ($this->_action == CRM_Core_Action::UPDATE) { $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id); CRM_Utils_System::setTitle(ts('Edit %1', array(1 => $title))); } elseif ($this->_action == CRM_Core_Action::VIEW) { $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id); CRM_Utils_System::setTitle(ts('Preview %1', array(1 => $title))); } else { CRM_Utils_System::setTitle(ts('New Custom Field Set')); } if (isset($this->_id)) { $params = array('id' => $this->_id); CRM_Core_BAO_CustomGroup::retrieve($params, $this->_defaults); $subExtends = CRM_Utils_Array::value('extends_entity_column_value', $this->_defaults); if (!empty($subExtends)) { $this->_subtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subExtends, 1, -1)); } } }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('action', $this->_action); $this->assign('context', $this->_context); //check permission for action. if (!CRM_Core_Permission::checkActionPermission('CiviGrant', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page')); } if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->_noteId = null; if ($this->_id) { require_once 'CRM/Core/BAO/Note.php'; $noteDAO = new CRM_Core_BAO_Note(); $noteDAO->entity_table = 'civicrm_grant'; $noteDAO->entity_id = $this->_id; if ($noteDAO->find(true)) { $this->_noteId = $noteDAO->id; } } //build custom data CRM_Custom_Form_Customdata::preProcess($this, null, null, 1, 'Grant', $this->_id); }
/** * Get the next item * * @param $lease_time seconds * * @return object with key 'data' that matches the inputted data */ function claimItem($lease_time = 3600) { $sql = "\n SELECT id, queue_name, submit_time, release_time, data\n FROM civicrm_queue_item\n WHERE queue_name = %1\n and (release_time is null OR release_time <= NOW())\n ORDER BY weight ASC, release_time ASC, id ASC\n LIMIT 1\n "; $params = array(1 => array($this->getName(), 'String')); $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem'); if (is_a($dao, 'DB_Error')) { // FIXME - Adding code to allow tests to pass CRM_Core_Error::fatal(); } if ($dao->fetch()) { $nowEpoch = CRM_Utils_Time::getTimeRaw(); if ($dao->release_time === NULL || strtotime($dao->release_time) < $nowEpoch) { CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1 WHERE id = %2", array('1' => array(date('YmdHis', $nowEpoch + $lease_time), 'String'), '2' => array($dao->id, 'Integer'))); // work-around: inconsistent date-formatting causes unintentional breakage # $dao->submit_time = date('YmdHis', strtotime($dao->submit_time)); # $dao->release_time = date('YmdHis', $nowEpoch + $lease_time); # $dao->save(); $dao->data = unserialize($dao->data); return $dao; } else { CRM_Core_Error::debug_var('not ready for release', $dao); return FALSE; } } else { CRM_Core_Error::debug_var('no items found'); return FALSE; } }
/** * create or update a Volunteer Commendation * * This function is invoked from within the web form layer * * @param array $params An assoc array of name/value pairs * - aid: activity id of an existing commendation to update * - cid: id of contact to be commended * - vid: id of project for which contact is to be commended * - details: text about the contact's exceptional volunteerism * @see self::requiredParamsArePresent for rules re required params * @return array Result of api.activity.create * @access public * @static */ public static function create(array $params) { // check required params if (!self::requiredParamsArePresent($params)) { CRM_Core_Error::fatal('Not enough data to create commendation object.'); } $activity_statuses = CRM_Activity_BAO_Activity::buildOptions('status_id', 'create'); $api_params = array('activity_type_id' => self::getActivityTypeId(), 'status_id' => CRM_Utils_Array::key('Completed', $activity_statuses)); $aid = CRM_Utils_Array::value('aid', $params); if ($aid) { $api_params['id'] = $aid; } $cid = CRM_Utils_Array::value('cid', $params); if ($cid) { $api_params['target_contact_id'] = $cid; } $vid = CRM_Utils_Array::value('vid', $params); if ($vid) { $project = CRM_Volunteer_BAO_Project::retrieveByID($vid); $api_params['subject'] = ts('Volunteer Commendation for %1', array('1' => $project->title, 'domain' => 'org.civicrm.volunteer')); $customFieldSpec = self::getCustomFields(); $volunteer_project_id_field_name = $customFieldSpec['volunteer_project_id']['custom_n']; $api_params[$volunteer_project_id_field_name] = $vid; } if (array_key_exists('details', $params)) { $api_params['details'] = CRM_Utils_Array::value('details', $params); } return civicrm_api3('Activity', 'create', $api_params); }
/** * Function to set variables up before form is built * * @param null * * @return void * @access public */ public function preProcess() { if ($this->_action & CRM_Core_Action::DELETE) { //check permission for action. if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page')); } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'title'); $this->assign('title', $this->_title); parent::preProcess(); } if (!$this->_action) { $action = CRM_Utils_Array::value('action', $_GET); $id = CRM_Utils_Array::value('id', $_GET); switch ($action) { case 'delete': require_once 'CRM/Contribute/BAO/PCP.php'; $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $id, 'title'); CRM_Contribute_BAO_PCP::delete($id); CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $title))); break; case 'disable': require_once 'CRM/Contribute/BAO/PCP.php'; CRM_Contribute_BAO_PCP::setDisable($id, '0'); break; case 'enable': require_once 'CRM/Contribute/BAO/PCP.php'; CRM_Contribute_BAO_PCP::setDisable($id, '1'); break; } $session =& CRM_Core_Session::singleton(); CRM_Utils_System::redirect($session->popUserContext()); } }
/** * Function to pre-process * * @return None * @access public */ public function preProcess() { parent::preProcess(); $session =& CRM_Core_Session::singleton(); if (!$this->_gName) { $this->_gName = CRM_Utils_Request::retrieve('group', 'String', $this, false, 0); $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gName, 'id', 'name'); } if ($this->_gName) { $this->set('gName', $this->_gName); } else { $this->_gName = $this->get('gName'); } $this->_GName = ucwords(str_replace('_', ' ', $this->_gName)); $url = "civicrm/admin/options/{$this->_gName}"; $params = "group={$this->_gName}&reset=1"; $session->pushUserContext(CRM_Utils_System::url($url, $params)); $this->assign('id', $this->_id); require_once 'CRM/Core/OptionGroup.php'; if ($this->_id && in_array($this->_gName, CRM_Core_OptionGroup::$_domainIDGroups)) { $domainID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'domain_id', 'id'); if (CRM_Core_Config::domainID() != $domainID) { CRM_Core_Error::fatal(ts('You do not have permission to access this page')); } } }
/** * Checks whether the logged in user has permission to perform an action * against a specified project. * * @param int $op * See the constants in CRM_Core_Action. * @param int $projectId * Required for some but not all operations. * @return boolean * TRUE is the action is allowed; else FALSE. */ public static function checkProjectPerms($op, $projectId = NULL) { $opsRequiringProjectId = array(CRM_Core_Action::UPDATE, CRM_Core_Action::DELETE); if (in_array($op, $opsRequiringProjectId) && empty($projectId)) { CRM_Core_Error::fatal('Missing required parameter Project ID'); } $contactId = CRM_Core_Session::getLoggedInContactID(); switch ($op) { case CRM_Core_Action::ADD: return self::check('create volunteer projects'); case CRM_Core_Action::UPDATE: if (self::check('edit all volunteer projects')) { return TRUE; } $projectOwners = CRM_Volunteer_BAO_Project::getContactsByRelationship($projectId, 'volunteer_owner'); if (self::check('edit own volunteer projects') && in_array($contactId, $projectOwners)) { return TRUE; } break; case CRM_Core_Action::DELETE: if (self::check('delete all volunteer projects')) { return TRUE; } $projectOwners = CRM_Volunteer_BAO_Project::getContactsByRelationship($projectId, 'volunteer_owner'); if (self::check('delete own volunteer projects') && in_array($contactId, $projectOwners)) { return TRUE; } break; case CRM_Core_Action::VIEW: if (self::check('register to volunteer') || self::check('edit all volunteer projects')) { return TRUE; } } return FALSE; }
/** * Constructor * * @param string $mode the mode of operation: live or test * * @return void */ function __construct($mode, &$paymentProcessor) { if (empty($paymentProcessor)) { CRM_Core_Error::fatal(ts('Could not find user name for payment processor')); } if ($paymentProcessor['name'] == 'Worldpay') { return; } //select the key depending on the mode from the payment processor type into the DB $sql = "select user_name,password,url_site from civicrm_payment_processor Where name = '" . $paymentProcessor['name'] . "'"; if ($mode == 'test') { $sql .= " and is_test = 0"; } else { $sql .= " and is_test = 1"; } $dao = CRM_Core_DAO::executeQuery($sql); if ($dao->fetch()) { //variable declaration $this->_service_key = $dao->user_name; $this->_client_key = $dao->password; $this->_endpoint = $dao->url_site; } $this->_timeout = 65; $this->_disable_ssl = false; $this->_use_external_JSON = false; $this->_order_types = array('ECOM', 'MOTO', 'RECURRING'); $this->_mode = $mode; $this->_paymentProcessor = $paymentProcessor; $this->_processorName = ts('world pay payment processor'); }
public function run() { /** * @var \Civi\Angular\Manager $angular */ //Use our manager instead of the one provided by core $angular = new Civi\Angular\VolunteerManager(\CRM_Core_Resources::singleton()); $moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular); switch (\CRM_Utils_Request::retrieve('format', 'String')) { case 'json': case '': $this->send('application/javascript', json_encode($this->getMetadata($moduleNames, $angular))); break; case 'js': $digest = $this->digestJs($angular->getResources($moduleNames, 'js', 'path')); //Tell crmResource to use our ajax end-point $digest = str_replace("ajax/angular-modules", "ajax/volunteer-angular-modules", $digest); $this->send('application/javascript', $digest); break; case 'css': $this->send('text/css', \CRM_Utils_File::concat($angular->getResources($moduleNames, 'css', 'path'), "\n")); break; default: \CRM_Core_Error::fatal("Unrecognized format"); } \CRM_Utils_System::civiExit(); }
function preProcess() { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE); if ($oid) { $this->_id = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE); } else { $this->assign('hide_contact', TRUE); $this->_id = $cid; } if (!CRM_Utils_Rule::positiveInteger($this->_id)) { CRM_Core_Error::fatal('We need a valid discount ID for view'); } $this->assign('id', $this->_id); $defaults = array(); $params = array('id' => $this->_id); require_once 'CRM/CiviDiscount/BAO/Item.php'; CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults); require_once 'CRM/CiviDiscount/BAO/Track.php'; if ($cid) { $rows = CRM_CiviDiscount_BAO_Track::getUsageByContact($this->_id); } else { $rows = CRM_CiviDiscount_BAO_Track::getUsageByOrg($this->_id); } $this->assign('rows', $rows); $this->assign('code_details', $defaults); $this->ajaxResponse['tabCount'] = count($rows); if (!empty($defaults['code'])) { CRM_Utils_System::setTitle($defaults['code']); } }
function preProcess() { // Make sure case types have been configured for the component require_once 'CRM/Core/OptionGroup.php'; $caseType = CRM_Core_OptionGroup::values('case_type'); if (empty($caseType)) { $this->assign('notConfigured', 1); return; } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); // contact id is not mandatory for case form. If not found, don't call // parent's pre-process and proceed further. if ($this->_contactId) { parent::preProcess(); } else { // we would need action to proceed further. $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add'); if ($this->_action & CRM_Core_Action::VIEW) { CRM_Core_Error::fatal('Contact Id is required for view action.'); } $this->assign('action', $this->_action); } $activityTypes = CRM_Case_PseudoConstant::activityType(); $this->assign('openCaseId', $activityTypes['Open Case']['id']); $this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']); $this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']); $this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']); }
/** * @param $formValues * * @throws Exception */ public function __construct(&$formValues) { parent::__construct($formValues); // unset search profile and other search params if set unset($this->_formValues['uf_group_id']); unset($this->_formValues['component_mode']); unset($this->_formValues['operator']); if (!empty($this->_formValues)) { // add the country and state if (!empty($this->_formValues['country_id'])) { $this->_formValues['country'] = CRM_Core_PseudoConstant::country($this->_formValues['country_id']); } if (!empty($this->_formValues['state_province_id'])) { $this->_formValues['state_province'] = CRM_Core_PseudoConstant::stateProvince($this->_formValues['state_province_id']); } // use the address to get the latitude and longitude CRM_Utils_Geocode_Google::format($this->_formValues); if (!is_numeric(CRM_Utils_Array::value('geo_code_1', $this->_formValues)) || !is_numeric(CRM_Utils_Array::value('geo_code_2', $this->_formValues)) || !isset($this->_formValues['distance'])) { CRM_Core_Error::fatal(ts('Could not geocode input')); } $this->_latitude = $this->_formValues['geo_code_1']; $this->_longitude = $this->_formValues['geo_code_2']; if ($this->_formValues['prox_distance_unit'] == "miles") { $conversionFactor = 1609.344; } else { $conversionFactor = 1000; } $this->_distance = $this->_formValues['distance'] * $conversionFactor; } $this->_group = CRM_Utils_Array::value('group', $this->_formValues); $this->_tag = CRM_Utils_Array::value('tag', $this->_formValues); $this->_columns = array(ts('Name') => 'sort_name', ts('Street Address') => 'street_address', ts('City') => 'city', ts('Postal Code') => 'postal_code', ts('State') => 'state_province', ts('Country') => 'country'); }
/** * Build all the data structures needed to build the form. */ public function preProcess() { if (!CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } parent::preProcess(); }
/** * Download the remote zipfile. * * @param string $remoteFile URL of a .zip file * @param string $localFile path at which to store the .zip file * @return STATUS_OK|STATUS_WRITE_ERROR|STATUS_DL_ERROR */ public function fetch($remoteFile, $localFile) { // Download extension zip file ... if (!function_exists('curl_init')) { CRM_Core_Error::fatal('Cannot install this extension - curl is not installed!'); } list($ch, $caConfig) = $this->createCurl($remoteFile); if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) { CRM_Core_Error::fatal('Cannot install this extension - does not support SSL'); } $fp = @fopen($localFile, "w"); if (!$fp) { CRM_Core_Session::setStatus(ts('Unable to write to %1.<br />Is the location writable?', array(1 => $localFile)), ts('Write Error'), 'error'); return self::STATUS_WRITE_ERROR; } curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec($ch); if (curl_errno($ch)) { CRM_Core_Session::setStatus(ts('Unable to download extension from %1. Error Message: %2', array(1 => $remoteFile, 2 => curl_error($ch))), ts('Download Error'), 'error'); return self::STATUS_DL_ERROR; } else { curl_close($ch); } fclose($fp); return self::STATUS_OK; }
function preProcess() { // Make sure case types have been configured for the component require_once 'CRM/Core/OptionGroup.php'; $caseType = CRM_Core_OptionGroup::values('case_type'); if (empty($caseType)) { $this->assign('notConfigured', 1); return; } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse'); if ($this->_contactId) { $this->assign('contactId', $this->_contactId); // check logged in url permission require_once 'CRM/Contact/Page/View.php'; CRM_Contact_Page_View::checkUserPermission($this); } else { if ($this->_action & CRM_Core_Action::VIEW) { CRM_Core_Error::fatal('Contact Id is required for view action.'); } } $activityTypes = CRM_Case_PseudoConstant::activityType(); $this->assign('openCaseId', $activityTypes['Open Case']['id']); $this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']); $this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']); $this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']); }
static function preProcess(&$form) { if (!$form->get('page_id')) { CRM_Core_Error::fatal(ts("Can't determine pcp id.")); } $form->assign('component_page_id', $form->get('component_page_id')); }
function run() { $sql = "\nSELECT distinct(g.id), g.*\nFROM civicrm_option_group g,\n civicrm_custom_field f,\n civicrm_custom_group cg\nWHERE f.option_group_id = g.id\nAND f.custom_group_id = cg.id\nAND cg.is_active = 1\n"; $this->fetch('optionGroup', 'CRM_Core_DAO_OptionGroup', $sql, array('id', 'label')); $sql = "\nSELECT v.*\nFROM civicrm_option_value v,\n civicrm_option_group g,\n civicrm_custom_field f,\n civicrm_custom_group cg\nWHERE v.option_group_id = g.id\nAND f.option_group_id = g.id\nAND f.custom_group_id = cg.id\nAND cg.is_active = 1\n"; $this->fetch('optionValue', 'CRM_Core_DAO_OptionValue', $sql, null, array(array('optionGroup', 'option_group_id', 'option_group_label'))); $sql = "\nSELECT cg.*\nFROM civicrm_custom_group cg\nWHERE cg.is_active = 1\n"; $this->fetch('customGroup', 'CRM_Core_DAO_CustomGroup', $sql, array('id', 'title')); $sql = "\nSELECT f.*\nFROM civicrm_custom_field f,\n civicrm_custom_group cg\nWHERE f.custom_group_id = cg.id\nAND cg.is_active = 1\n"; $this->fetch('customField', 'CRM_Core_DAO_CustomField', $sql, null, array(array('optionGroup', 'option_group_id', 'option_group_label'), array('customGroup', 'custom_group_id', 'custom_group_title'))); $this->fetch('profileGroup', 'CRM_Core_DAO_UFGroup', null, array('id', 'title'), null); $this->fetch('profileField', 'CRM_Core_DAO_UFField', null, null, array(array('profileGroup', 'uf_group_id', 'profile_group_title'))); $buffer = '<?xml version="1.0" encoding="iso-8859-1" ?>'; $buffer .= "\n\n<CustomData>\n"; foreach (array_keys($this->_xml) as $key) { if (!empty($this->_xml[$key]['data'])) { $buffer .= " <{$this->_xml[$key]['scope']}>\n{$this->_xml[$key]['data']} </{$this->_xml[$key]['scope']}>\n"; } else { if ($this->_xml[$key]['required']) { CRM_Core_Error::fatal("No records in DB for {$key}"); } } } $buffer .= "</CustomData>\n"; CRM_Utils_System::download('CustomGroupData.xml', 'text/plain', $buffer); }
public function preProcess() { require_once 'CRM/Contact/BAO/SearchCustom.php'; $csID = CRM_Utils_Request::retrieve('csid', 'Integer', $this); $ssID = CRM_Utils_Request::retrieve('ssID', 'Integer', $this); $gID = CRM_Utils_Request::retrieve('gid', 'Integer', $this); list($this->_customSearchID, $this->_customSearchClass, $formValues) = CRM_Contact_BAO_SearchCustom::details($csID, $ssID, $gID); if (!$this->_customSearchID) { CRM_Core_Error::fatal('Could not get details for custom search.'); } if (!empty($formValues)) { $this->_formValues = $formValues; } // set breadcrumb to return to Custom Search listings page $breadCrumb = array(array('title' => ts('Custom Searches'), 'url' => CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'))); CRM_Utils_System::appendBreadCrumb($breadCrumb); // use the custom selector require_once 'CRM/Contact/Selector/Custom.php'; $this->_selectorName = 'CRM_Contact_Selector_Custom'; $this->set('customSearchID', $this->_customSearchID); $this->set('customSearchClass', $this->_customSearchClass); parent::preProcess(); // instantiate the new class eval('$this->_customClass = new ' . $this->_customSearchClass . '( $this->_formValues );'); }
/** * Pre processing work done here. * * gets session variables for group or field id * * @param * * @return void */ public function preProcess() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { // CRM_Core_Controller validates qfKey for POST requests, but not necessarily // for GET requests. Allowing GET would therefore be CSRF vulnerability. CRM_Core_Error::fatal(ts('Preview only supports HTTP POST')); } // Inline forms don't get menu-level permission checks $checkPermission = array(array('administer CiviCRM', 'manage event profiles')); if (!CRM_Core_Permission::check($checkPermission)) { CRM_Core_Error::fatal(ts('Permission Denied')); } $content = json_decode($_REQUEST['ufData'], TRUE); foreach (array('ufGroup', 'ufFieldCollection') as $key) { if (!is_array($content[$key])) { CRM_Core_Error::fatal("Missing JSON parameter, {$key}"); } } //echo '<pre>'.htmlentities(var_export($content, TRUE)) .'</pre>'; //CRM_Utils_System::civiExit(); $fields = CRM_Core_BAO_UFGroup::formatUFFields($content['ufGroup'], $content['ufFieldCollection']); //$fields = CRM_Core_BAO_UFGroup::getFields(1); $this->setProfile($fields); //echo '<pre>'.htmlentities(var_export($fields, TRUE)) .'</pre>';CRM_Utils_System::civiExit(); }
function __construct(&$formValues) { parent::__construct($formValues); $this->_earthFlattening = 1.0 / 298.257223563; $this->_earthRadiusSemiMajor = 6378137.0; $this->_earthRadiusSemiMinor = $this->_earthRadiusSemiMajor * (1.0 - $this->_earthFlattening); $this->_earthEccentricitySQ = 2 * $this->_earthFlattening - pow($this->_earthFlattening, 2); // unset search profile if set unset($this->_formValues['uf_group_id']); if (!empty($this->_formValues)) { // add the country and state if (CRM_Utils_Array::value('country_id', $this->_formValues)) { $this->_formValues['country'] = CRM_Core_PseudoConstant::country($this->_formValues['country_id']); } if (CRM_Utils_Array::value('state_province_id', $this->_formValues)) { $this->_formValues['state_province'] = CRM_Core_PseudoConstant::stateProvince($this->_formValues['state_province_id']); } // use the address to get the latitude and longitude require_once 'CRM/Utils/Geocode/Google.php'; CRM_Utils_Geocode_Google::format($this->_formValues); if (!isset($this->_formValues['geo_code_1']) || !isset($this->_formValues['geo_code_2']) || !isset($this->_formValues['distance'])) { CRM_Core_Error::fatal(ts('Could not geocode input')); } $this->_latitude = $this->_formValues['geo_code_1']; $this->_longitude = $this->_formValues['geo_code_2']; $this->_distance = $this->_formValues['distance'] * 1000; } $this->_earthDistanceSQL = $this->earthDistanceSQL($this->_latitude, $this->_longitude); $this->_tag = CRM_Utils_Array::value('tag', $this->_formValues); $this->_columns = array(ts('Name') => 'sort_name', ts('Street Address') => 'street_address', ts('City') => 'city', ts('Postal Code') => 'postal_code', ts('State') => 'state_province', ts('Country') => 'country'); }
/** * @param CRM_Core_Form $form * @param null $type * @param null $mode * * @throws Exception */ public static function preProcess(&$form, $type = NULL, $mode = NULL) { if ($type) { $form->_type = $type; } else { $form->_type = CRM_Utils_Request::retrieve('type', 'String', $form); } if ($form->_type) { $form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode); } $form->set('paymentProcessor', $form->_paymentProcessor); // also set cancel subscription url if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) { $form->_paymentObject = CRM_Core_Payment::singleton($mode, $form->_paymentProcessor, $form); $form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(); } //checks after setting $form->_paymentProcessor // we do this outside of the above conditional to avoid // saving the country/state list in the session (which could be huge) CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor); $form->assign_by_ref('paymentProcessor', $form->_paymentProcessor); // check if this is a paypal auto return and redirect accordingly //@todo - determine if this is legacy and remove if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) { $url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}"); CRM_Utils_System::redirect($url); } // make sure we have a valid payment class, else abort if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) { CRM_Core_Error::fatal(ts('Payment processor is not set for this page')); } if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !(CRM_Utils_Array::value('billing_mode', $form->_paymentProcessor) & CRM_Core_Payment::BILLING_MODE_FORM))) { CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type']))); } }
public function preProcess() { $this->set('searchFormName', 'Custom'); $this->set('context', 'custom'); $csID = CRM_Utils_Request::retrieve('csid', 'Integer', $this); $ssID = CRM_Utils_Request::retrieve('ssID', 'Integer', $this); $gID = CRM_Utils_Request::retrieve('gid', 'Integer', $this); list($this->_customSearchID, $this->_customSearchClass, $formValues) = CRM_Contact_BAO_SearchCustom::details($csID, $ssID, $gID); if (!$this->_customSearchID) { CRM_Core_Error::fatal('Could not get details for custom search.'); } // stash this as a hidden element so we can potentially go there if the session // is reset but this is available in the POST $this->addElement('hidden', 'csid', $csID); if (!empty($formValues)) { $this->_formValues = $formValues; } // set breadcrumb to return to Custom Search listings page $breadCrumb = array(array('title' => ts('Custom Searches'), 'url' => CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'))); CRM_Utils_System::appendBreadCrumb($breadCrumb); // use the custom selector self::$_selectorName = 'CRM_Contact_Selector_Custom'; $this->set('customSearchID', $this->_customSearchID); $this->set('customSearchClass', $this->_customSearchClass); parent::preProcess(); // instantiate the new class $this->_customClass = new $this->_customSearchClass($this->_formValues); // CRM-12747 if (isset($this->_customClass->_permissionedComponent) && !self::isPermissioned($this->_customClass->_permissionedComponent)) { CRM_Utils_System::permissionDenied(); } }
public static function update() { // lets build the tree in memory first $sql = "\nSELECT n.child_group_id as child ,\n n.parent_group_id as parent\nFROM civicrm_group_nesting n,\n civicrm_group gc,\n civicrm_group gp\nWHERE n.child_group_id = gc.id\n AND n.parent_group_id = gp.id\n"; $dao = CRM_Core_DAO::executeQuery($sql); $tree = array(); while ($dao->fetch()) { if (!array_key_exists($dao->child, $tree)) { $tree[$dao->child] = array('children' => array(), 'parents' => array()); } if (!array_key_exists($dao->parent, $tree)) { $tree[$dao->parent] = array('children' => array(), 'parents' => array()); } $tree[$dao->child]['parents'][] = $dao->parent; $tree[$dao->parent]['children'][] = $dao->child; } if (self::checkCyclicGraph($tree)) { CRM_Core_Error::fatal(ts('We detected a cycle which we cant handle. aborting')); } // first reset the current cache entries $sql = "\nUPDATE civicrm_group\nSET parents = null,\n children = null\n"; CRM_Core_DAO::executeQuery($sql); $values = array(); foreach (array_keys($tree) as $id) { $parents = implode(',', $tree[$id]['parents']); $children = implode(',', $tree[$id]['children']); $parents = $parents == NULL ? 'null' : "'{$parents}'"; $children = $children == NULL ? 'null' : "'{$children}'"; $sql = "\nUPDATE civicrm_group\nSET parents = {$parents} ,\n children = {$children}\nWHERE id = {$id}\n"; CRM_Core_DAO::executeQuery($sql); } // this tree stuff is quite useful, so lets store it in the cache CRM_Core_BAO_Cache::setItem($tree, 'contact groups', 'nestable tree hierarchy'); }
/** * Given the list of params in the params array, fetch the object * and store the values in the values array * * @param Object $block typically a Phone|Email|IM|OpenID object * @param string $blockName name of the above object * @param array $params input parameters to find object * @param array $values output values of the object * * @return array of $block objects. * @access public * @static */ static function &getValues($blockName, $params) { if (empty($params)) { return NULL; } $BAOString = 'CRM_Core_BAO_' . $blockName; $block = new $BAOString(); $blocks = array(); if (!isset($params['entity_table'])) { $block->contact_id = $params['contact_id']; if (!$block->contact_id) { CRM_Core_Error::fatal(); } $blocks = self::retrieveBlock($block, $blockName); } else { $blockIds = self::getBlockIds($blockName, NULL, $params); if (empty($blockIds)) { return $blocks; } $count = 1; foreach ($blockIds as $blockId) { $block = new $BAOString(); $block->id = $blockId['id']; $getBlocks = self::retrieveBlock($block, $blockName); $blocks[$count++] = array_pop($getBlocks); } } return $blocks; }
/** * TODO: How many checks do we need to do? Should we check to make sure the * activity is the right type? That the cid and aid are associated? Seems like * if you are messing with URL params you are kind of asking for trouble... */ function preProcess() { $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE); $this->_cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $this->_vid = CRM_Utils_Request::retrieve('vid', 'Positive', $this, FALSE); if (!CRM_Volunteer_Permission::checkProjectPerms(CRM_Core_Action::UPDATE, $this->_vid)) { CRM_Utils_System::permissionDenied(); } if (!$this->_aid && !($this->_cid && $this->_vid)) { CRM_Core_Error::fatal("Form expects an activity ID or both a contact and a volunteer project ID."); } $check = array('Activity' => $this->_aid, 'Contact' => $this->_cid, 'VolunteerProject' => $this->_vid); $errors = array(); foreach ($check as $entityType => $entityID) { if (!$this->entityExists($entityType, $entityID)) { $errors[] = "No {$entityType} with ID {$entityID} exists."; } } if (count($errors)) { CRM_Core_Error::fatal("Invalid parameter(s) passed to commendation form: " . implode(' ', $errors)); } $contact_display_name = civicrm_api3('Contact', 'getvalue', array('id' => $this->_cid, 'return' => 'display_name')); CRM_Utils_System::setTitle(ts('Commend %1', array(1 => $contact_display_name, 'domain' => 'org.civicrm.volunteer'))); parent::preProcess(); }
/** * Singleton function used to manage this object. * * @param array $providerParams * @param bool $force * * @return object */ public static function &singleton($providerParams = array(), $force = FALSE) { $mailingID = CRM_Utils_Array::value('mailing_id', $providerParams); $providerID = CRM_Utils_Array::value('provider_id', $providerParams); $providerName = CRM_Utils_Array::value('provider', $providerParams); if (!$providerID && $mailingID) { $providerID = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $mailingID, 'sms_provider_id', 'id'); $providerParams['provider_id'] = $providerID; } if ($providerID) { $providerName = CRM_SMS_BAO_Provider::getProviderInfo($providerID, 'name'); } if (!$providerName) { CRM_Core_Error::fatal('Provider not known or not provided.'); } $providerName = CRM_Utils_Type::escape($providerName, 'String'); $cacheKey = "{$providerName}_" . (int) $providerID . "_" . (int) $mailingID; if (!isset(self::$_singleton[$cacheKey]) || $force) { $ext = CRM_Extension_System::singleton()->getMapper(); if ($ext->isExtensionKey($providerName)) { $paymentClass = $ext->keyToClass($providerName); require_once "{$paymentClass}.php"; } else { CRM_Core_Error::fatal("Could not locate extension for {$providerName}."); } self::$_singleton[$cacheKey] = $paymentClass::singleton($providerParams, $force); } return self::$_singleton[$cacheKey]; }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { //check for permission to edit contributions if (!CRM_Core_Permission::check('issue cdn tax receipts')) { CRM_Core_Error::fatal(ts('You do not have permission to access this page', array('domain' => 'org.civicrm.cdntaxreceipts'))); } parent::preProcess(); $thisYear = date("Y"); $this->_years = array($thisYear, $thisYear - 1, $thisYear - 2); $receipts = array(); foreach ($this->_years as $year) { $receipts[$year] = array('email' => 0, 'print' => 0, 'total' => 0, 'contrib' => 0); } // count and categorize contributions foreach ($this->_contactIds as $id) { foreach ($this->_years as $year) { list($issuedOn, $receiptId) = cdntaxreceipts_annual_issued_on($id, $year); $eligible = count(cdntaxreceipts_contributions_not_receipted($id, $year)); if ($eligible > 0) { list($method, $email) = cdntaxreceipts_sendMethodForContact($id); $receipts[$year][$method]++; $receipts[$year]['total']++; $receipts[$year]['contrib'] += $eligible; } } } $this->_receipts = $receipts; }