/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { if (!CRM_Core_Permission::check('administer Reports')) { return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', "reset=1")); } $optionVal = CRM_Report_Utils_Report::getValueFromUrl(); $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value', 'String', FALSE); $extKey = strpos($templateInfo['name'], '.'); $reportClass = NULL; if ($extKey !== FALSE) { $ext = new CRM_Core_Extensions(); $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); $templateInfo['name'] = $reportClass; } if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) { CRM_Utils_System::setTitle($templateInfo['label'] . ' - Template'); $this->assign('reportTitle', $templateInfo['label']); $session = CRM_Core_Session::singleton(); $session->set('reportDescription', $templateInfo['description']); $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run($templateInfo['name'], NULL, NULL); } if ($optionVal) { CRM_Core_Session::setStatus(ts('Could not find the report template. Make sure the report template is registered and / or url is correct.')); } return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', "reset=1")); }
/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { $instanceId = CRM_Report_Utils_Report::getInstanceID(); if (!$instanceId) { $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath(); } $action = CRM_Utils_Request::retrieve('action', 'String', $this); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('administer Reports')) { $statusMessage = ts('You do not have permission to Delete Report.'); CRM_Core_Error::statusBounce($statusMessage, $reportUrl); } $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_Instance', $instanceId, 'navigation_id', 'id'); CRM_Report_BAO_Instance::delete($instanceId); //delete navigation if exists if ($navId) { CRM_Core_BAO_Navigation::processDelete($navId); CRM_Core_BAO_Navigation::resetNavigation(); } CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.')); } else { $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); if (empty($templateInfo)) { CRM_Core_Session::setStatus(ts('Could not find template for the instance.')); return; } $extKey = strpos($templateInfo['name'], '.'); $reportClass = NULL; if ($extKey !== FALSE) { $ext = new CRM_Core_Extensions(); $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); $templateInfo['name'] = $reportClass; } if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) { $instanceInfo = array(); CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { CRM_Utils_System::setTitle($instanceInfo['title']); $this->assign('reportTitle', $instanceInfo['title']); } else { CRM_Utils_System::setTitle($templateInfo['label']); $this->assign('reportTitle', $templateInfo['label']); } $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run($templateInfo['name'], NULL, NULL); } CRM_Core_Session::setStatus(ts('Could not find template for the instance.')); } return CRM_Utils_System::redirect($reportUrl); }
static function details($csID, $ssID = null, $gID = null) { $error = array(null, null, null); if (!$csID && !$ssID && !$gID) { return $error; } $customSearchID = $csID; $formValues = array(); if ($ssID || $gID) { if ($gID) { $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $gID, 'saved_search_id'); } $formValues = CRM_Contact_BAO_SavedSearch::getFormValues($ssID); $customSearchID = CRM_Utils_Array::value('customSearchID', $formValues); } if (!$customSearchID) { return $error; } // check that the csid exists in the db along with the right file // and implements the right interface require_once 'CRM/Core/OptionGroup.php'; $customSearchClass = CRM_Core_OptionGroup::getLabel('custom_search', $customSearchID); if (!$customSearchClass) { return $error; } require_once 'CRM/Core/Extensions.php'; $ext = new CRM_Core_Extensions(); if (!$ext->isExtensionKey($customSearchClass)) { $customSearchFile = str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php'; } else { $customSearchFile = $ext->keyToPath($customSearchClass); $customSearchClass = $ext->keyToClass($customSearchClass); } $error = (include_once $customSearchFile); if ($error == false) { CRM_Core_Error::fatal('Custom search file: ' . $customSearchFile . ' does not exist. Please verify your custom search settings in CiviCRM administrative panel.'); } return array($customSearchID, $customSearchClass, $formValues); }
/** * singleton function used to manage this object * * @param string $mode the mode of operation: live or test * * @return object * @static * */ static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = null, $force = false) { $cacheKey = "{$mode}_{$paymentProcessor['id']}_" . (int) isset($paymentForm); if (!isset(self::$_singleton[$cacheKey]) || $force) { $config = CRM_Core_Config::singleton(); require_once 'CRM/Core/Extensions.php'; $ext = new CRM_Core_Extensions(); if ($ext->isExtensionKey($paymentProcessor['class_name'])) { $paymentClass = $ext->keyToClass($paymentProcessor['class_name'], 'payment'); require_once $ext->classToPath($paymentClass); } else { $paymentClass = "CRM_Core_" . $paymentProcessor['class_name']; require_once str_replace('_', DIRECTORY_SEPARATOR, $paymentClass) . '.php'; } //load the object. self::$_singleton[$cacheKey] = eval('return ' . $paymentClass . '::singleton( $mode, $paymentProcessor );'); //load the payment form for required processor. if ($paymentForm !== null) { self::$_singleton[$cacheKey]->setForm($paymentForm); } } return self::$_singleton[$cacheKey]; }
/** * Class constructor * * @param array $formValues array of form values imported * @param array $params array of parameters for query * @param int $action - action of search basic or advanced. * * @return CRM_Contact_Selector * @access public */ function __construct($customSearchClass, $formValues = null, $params = null, $returnProperties = null, $action = CRM_Core_Action::NONE, $includeContactIds = false, $searchChildGroups = true, $searchContext = 'search') { $this->_customSearchClass = $customSearchClass; $this->_formValues = $formValues; $this->_includeContactIds = $includeContactIds; require_once 'CRM/Core/Extensions.php'; $ext = new CRM_Core_Extensions(); if (!$ext->isExtensionKey($customSearchClass)) { if ($ext->isExtensionClass($customSearchClass)) { $customSearchFile = $ext->classToPath($customSearchClass); require_once $customSearchFile; } else { require_once str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php'; } eval('$this->_search = new ' . $customSearchClass . '( $formValues );'); } else { $customSearchFile = $ext->keyToPath($customSearchClass, 'search'); require_once $customSearchFile; eval('$this->_search = new ' . $ext->keyToClass($customSearchClass, 'search') . '( $formValues );'); } }
/** * Payment callback handler * Load requested payment processor and call that processor's handle<$method> method * * @public */ static function handlePaymentMethod($method, $params = array()) { if (!isset($params['processor_name'])) { CRM_Core_Error::fatal("Missing 'processor_name' param for payment callback"); } // Query db for processor .. $mode = @$params['mode']; $dao = CRM_Core_DAO::executeQuery("\n SELECT ppt.class_name, ppt.name as processor_name, pp.id AS processor_id\n FROM civicrm_payment_processor_type ppt\n INNER JOIN civicrm_payment_processor pp\n ON pp.payment_processor_type = ppt.name\n AND pp.is_active\n AND pp.is_test = %1\n WHERE ppt.name = %2 \n ", array(1 => array($mode == 'test' ? 1 : 0, 'Integer'), 2 => array($params['processor_name'], 'String'))); // Check whether we found anything at all .. if (!$dao->N) { CRM_Core_Error::fatal("No active instances of the '{$params['processor_name']}' payment processor were found."); } $method = 'handle' . $method; $extension_instance_found = FALSE; // In all likelihood, we'll just end up with the one instance returned here. But it's // possible we may get more. Hence, iterate through all instances .. while ($dao->fetch()) { // Check pp is extension $ext = new CRM_Core_Extensions(); if ($ext->isExtensionKey($dao->class_name)) { $extension_instance_found = TRUE; $paymentClass = $ext->keyToClass($dao->class_name, 'payment'); require_once $ext->classToPath($paymentClass); } else { // Legacy instance - but there may also be an extension instance, so // continue on to the next instance and check that one. We'll raise an // error later on if none are found. continue; } $paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($dao->processor_id, $mode); // Should never be empty - we already established this processor_id exists and is active. if (empty($paymentProcessor)) { continue; } // Instantiate PP eval('$processorInstance = ' . $paymentClass . '::singleton( $mode, $paymentProcessor );'); // Does PP implement this method, and can we call it? if (!method_exists($processorInstance, $method) || !is_callable(array($processorInstance, $method))) { // No? This will be the case in all instances, so let's just die now // and not prolong the agony. CRM_Core_Error::fatal("Payment processor does not implement a '{$method}' method"); } // Everything, it seems, is ok - execute pp callback handler $processorInstance->{$method}(); } if (!$extension_instance_found) { CRM_Core_Error::fatal("No extension instances of the '{$params['processor_name']}' payment processor were found.<br />" . "{$method} method is unsupported in legacy payment processors."); } // Exit here on web requests, allowing just the plain text response to be echoed if ($method == 'handlePaymentNotification') { CRM_Utils_System::civiExit(); } }
/** * Function to run hooks in the payment processor class * Load requested payment processor and call the method specified. * * @param string $method - the method to call in the payment processor class * @private */ private function _runPaymentHook($method) { // Not concerned about performance at this stage, as these are seldomly performed tasks // (payment processor enable/disable/install/uninstall). May wish to implement some // kind of registry/caching system if more hooks are added. if (!isset($this->id) || empty($this->id)) { $this->id = 0; } $ext = new CRM_Core_Extensions(); $paymentClass = $ext->keyToClass($this->key, 'payment'); require_once $ext->classToPath($paymentClass); // See if we have any instances of this PP defined .. if ($this->id && ($processor_id = CRM_Core_DAO::singleValueQuery("\n SELECT pp.id\n FROM civicrm_extension ext\n INNER JOIN civicrm_payment_processor pp\n ON pp.payment_processor_type = ext.name\n WHERE ext.type = 'payment'\n AND ext.id = %1\n\n ", array(1 => array($this->id, 'Integer'))))) { // If so, load params in the usual way .. $paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($processor_id, NULL); } else { // Otherwise, do the best we can to construct some .. $dao = CRM_Core_DAO::executeQuery("\n SELECT ppt.*\n FROM civicrm_extension ext\n INNER JOIN civicrm_payment_processor_type ppt\n ON ppt.name = ext.name\n WHERE ext.name = %1\n AND ext.type = 'payment'\n ", array(1 => array($this->name, 'String'))); if ($dao->fetch()) { $paymentProcessor = array('id' => -1, 'name' => $dao->title, 'payment_processor_type' => $dao->name, 'user_name' => 'nothing', 'password' => 'nothing', 'signature' => '', 'url_site' => $dao->url_site_default, 'url_api' => $dao->url_api_default, 'url_recur' => $dao->url_recur_default, 'url_button' => $dao->url_button_default, 'subject' => '', 'class_name' => $dao->class_name, 'is_recur' => $dao->is_recur, 'billing_mode' => $dao->billing_mode, 'payment_type' => $dao->payment_type); } else { CRM_Core_Error::fatal("Unable to find payment processor in " . __CLASS__ . '::' . __METHOD__); } } // In the case of uninstall, check for instances of PP first. // Don't run hook if any are found. if ($method == 'uninstall' && $paymentProcessor['id'] > 0) { return; } switch ($method) { case 'install': case 'uninstall': case 'enable': case 'disable': // Instantiate PP eval('$processorInstance = ' . $paymentClass . '::singleton( null, $paymentProcessor );'); // Does PP implement this method, and can we call it? if (method_exists($processorInstance, $method) && is_callable(array($processorInstance, $method))) { // If so, call it ... $processorInstance->{$method}(); } break; default: CRM_Core_Session::setStatus("Unrecognized payment hook ({$method}) in " . __CLASS__ . '::' . __METHOD__); } }