/** * undocumented function * * @return void **/ public function uninstall() { if (!array_key_exists($this->ext->key, $this->paymentProcessorTypes)) { CRM_Core_Error::fatal('This payment processor type is not registered.'); } require_once 'CRM/Core/PseudoConstant.php'; $paymentProcessors = CRM_Core_PseudoConstant::paymentProcessor(TRUE); require_once "CRM/Core/DAO/PaymentProcessor.php"; foreach ($paymentProcessors as $id => $name) { $dao = new CRM_Core_DAO_PaymentProcessor(); $dao->id = $id; $dao->find(); while ($dao->fetch()) { if ($dao->payment_processor_type == $this->ext->name) { CRM_Core_Error::fatal('Cannot uninstall this extension - there is at least one payment processor using payment processor type provided by it.'); } } } require_once "CRM/Core/BAO/PaymentProcessorType.php"; CRM_Core_BAO_PaymentProcessorType::del($this->paymentProcessorTypes[$this->ext->key]); }
/** * Class constructor * * @access private */ function __construct() { global $civicrm_root; $config = CRM_Core_Config::singleton(); $localfile = $civicrm_root . DIRECTORY_SEPARATOR . self::LOCALFILE_NAME; $cachefile = $config->uploadDir . self::CACHEFILE_NAME; if ($config->versionCheck && file_exists($localfile)) { require_once $localfile; if (function_exists('civicrmVersion')) { $info = civicrmVersion(); $this->localVersion = $info['version']; } $expiryTime = time() - self::CACHEFILE_EXPIRE; // if there's a cachefile and it's not stale use it to // read the latestVersion, else read it from the Internet if (file_exists($cachefile) and filemtime($cachefile) > $expiryTime) { $this->latestVersion = file_get_contents($cachefile); } else { // we have to set the error handling to a dummy function, otherwise // if the URL is not working (e.g., due to our server being down) // the users would be presented with an unsuppressable warning ini_set('default_socket_timeout', self::CHECK_TIMEOUT); set_error_handler(array('CRM_Utils_VersionCheck', 'downloadError')); $hash = md5($config->userFrameworkBaseURL); $url = self::LATEST_VERSION_AT . "?version={$this->localVersion}&uf={$config->userFramework}&hash={$hash}&lang={$config->lcMessages}&ufv={$config->userFrameworkVersion}"; // add PHP and MySQL versions $dao = new CRM_Core_DAO(); $dao->query('SELECT VERSION() AS version'); $dao->fetch(); $url .= '&MySQL=' . $dao->version . '&PHP=' . phpversion(); $tables = array('CRM_Activity_DAO_Activity' => 'is_test = 0', 'CRM_Case_DAO_Case' => NULL, 'CRM_Contact_DAO_Contact' => NULL, 'CRM_Contact_DAO_Relationship' => NULL, 'CRM_Contribute_DAO_Contribution' => 'is_test = 0', 'CRM_Contribute_DAO_ContributionPage' => 'is_active = 1', 'CRM_Contribute_DAO_ContributionProduct' => NULL, 'CRM_Contribute_DAO_Widget' => 'is_active = 1', 'CRM_Core_DAO_Discount' => NULL, 'CRM_Price_DAO_SetEntity' => NULL, 'CRM_Core_DAO_UFGroup' => 'is_active = 1', 'CRM_Event_DAO_Event' => 'is_active = 1', 'CRM_Event_DAO_Participant' => 'is_test = 0', 'CRM_Friend_DAO_Friend' => 'is_active = 1', 'CRM_Grant_DAO_Grant' => NULL, 'CRM_Mailing_DAO_Mailing' => 'is_completed = 1', 'CRM_Member_DAO_Membership' => 'is_test = 0', 'CRM_Member_DAO_MembershipBlock' => 'is_active = 1', 'CRM_Pledge_DAO_Pledge' => 'is_test = 0', 'CRM_Pledge_DAO_PledgeBlock' => NULL); // add &key=count pairs to $url, where key is the last part of the DAO foreach ($tables as $daoName => $where) { require_once str_replace('_', '/', $daoName) . '.php'; eval("\$dao = new {$daoName};"); if ($where) { $dao->whereAdd($where); } $url .= '&' . array_pop(explode('_', $daoName)) . "={$dao->count()}"; } // get active payment processor types $dao = new CRM_Core_DAO_PaymentProcessor(); $dao->is_active = 1; $dao->find(); $ppTypes = array(); while ($dao->fetch()) { $ppTypes[] = $dao->payment_processor_type; } // add the .-separated list of the processor types (urlencoded just in case) $url .= '&PPTypes=' . urlencode(implode('.', array_unique($ppTypes))); // get the latest version using the stats-carrying $url $this->latestVersion = file_get_contents($url); ini_restore('default_socket_timeout'); restore_error_handler(); if (!preg_match('/^\\d+\\.\\d+\\.\\d+$/', $this->latestVersion)) { $this->latestVersion = NULL; } if (!$this->latestVersion) { return; } $fp = @fopen($cachefile, 'w'); if (!$fp) { $message = ts('Do not have permission to write to file: %1', array(1 => $cachefile)); CRM_Core_Session::setStatus($message); return; } fwrite($fp, $this->latestVersion); fclose($fp); } } }
/** * Browse all payment processors. * * @return void * @access public * @static */ function browse($action = NULL) { // get all custom groups sorted by weight $paymentProcessor = array(); $dao = new CRM_Core_DAO_PaymentProcessor(); $dao->is_test = 0; $dao->domain_id = CRM_Core_Config::domainID(); $dao->orderBy('name'); $dao->find(); while ($dao->fetch()) { $paymentProcessor[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $paymentProcessor[$dao->id]); // form all action links $action = array_sum(array_keys($this->links())); // update enable/disable links. if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $paymentProcessor[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id)); } $this->assign('rows', $paymentProcessor); }