Exemplo n.º 1
0
 static function read($name, &$menu)
 {
     $config =& CRM_Core_Config::singleton();
     $xml = simplexml_load_file($name);
     foreach ($xml->item as $item) {
         //do not expose 'Access Control' link for Joomla, CRM-3550
         if ($item->path == 'civicrm/admin/access' && $config->userFramework == 'Joomla') {
             continue;
         }
         if (!(string) $item->path) {
             CRM_Core_Error::debug('i', $item);
             CRM_Core_Error::fatal();
         }
         $path = (string) $item->path;
         $menu[$path] = array();
         unset($item->path);
         foreach ($item as $key => $value) {
             $key = (string) $key;
             $value = (string) $value;
             if (strpos($key, '_callback') && strpos($value, '::')) {
                 $value = explode('::', $value);
             } else {
                 if ($key == 'access_arguments') {
                     if (strpos($value, ',') || strpos($value, ';')) {
                         if (strpos($value, ',')) {
                             $elements = explode(',', $value);
                             $op = 'and';
                         } else {
                             $elements = explode(';', $element);
                             $op = 'or';
                         }
                         $items = array();
                         foreach ($elements as $element) {
                             $items[] = $element;
                         }
                         $value = array($items, $op);
                     } else {
                         $value = array(array($value), 'and');
                     }
                 } else {
                     if ($key == 'is_public' || $key == 'is_ssl') {
                         $value = $value == 'true' || $value == 1 ? 1 : 0;
                     }
                 }
             }
             $menu[$path][$key] = $value;
         }
     }
 }
 /**
  * Method to determine if the condition is valid
  *
  * @param CRM_Civirules_TriggerData_TriggerData $triggerData
  * @return bool
  */
 public function isConditionValid(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     $isConditionValid = FALSE;
     $membership = $triggerData->getEntityData('Membership');
     CRM_Core_Error::debug('membership', $membership);
     switch ($this->conditionParams['operator']) {
         case 0:
             if ($membership['status_id'] == $this->conditionParams['membership_status_id']) {
                 $isConditionValid = TRUE;
             }
             break;
         case 1:
             if ($membership['status_id'] != $this->conditionParams['membership_status_id']) {
                 $isConditionValid = TRUE;
             }
             break;
     }
     return $isConditionValid;
 }
Exemplo n.º 3
0
 static function read($name, &$menu)
 {
     $config = CRM_Core_Config::singleton();
     $xml = simplexml_load_file($name);
     foreach ($xml->item as $item) {
         if (!(string) $item->path) {
             CRM_Core_Error::debug('i', $item);
             CRM_Core_Error::fatal();
         }
         $path = (string) $item->path;
         $menu[$path] = array();
         unset($item->path);
         foreach ($item as $key => $value) {
             $key = (string) $key;
             $value = (string) $value;
             if (strpos($key, '_callback') && strpos($value, '::')) {
                 $value = explode('::', $value);
             } elseif ($key == 'access_arguments') {
                 if (strpos($value, ',') || strpos($value, ';')) {
                     if (strpos($value, ',')) {
                         $elements = explode(',', $value);
                         $op = 'and';
                     } else {
                         $elements = explode(';', $value);
                         $op = 'or';
                     }
                     $items = array();
                     foreach ($elements as $element) {
                         $items[] = $element;
                     }
                     $value = array($items, $op);
                 } else {
                     $value = array(array($value), 'and');
                 }
             } elseif ($key == 'is_public' || $key == 'is_ssl') {
                 $value = $value == 'true' || $value == 1 ? 1 : 0;
             }
             $menu[$path][$key] = $value;
         }
     }
 }
 /**
  * This function checks to see if we have the right config values
  *
  * @return string the error message if any
  * @public
  */
 function checkConfig()
 {
     $config = CRM_Core_Config::singleton();
     $error = array();
     //Create database tables if they haven't been.
     if (!CRM_Core_DAO::checkTableExists('civicrm_stripe_customers')) {
         CRM_Core_DAO::executeQuery("\r\n\t\tCREATE TABLE IF NOT EXISTS `civicrm_stripe_customers` (\r\n  \t\t\t`email` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,\r\n  \t\t\t`id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\r\n  \t\t\tUNIQUE KEY `email` (`email`)\r\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\r\n\t\t\t");
         CRM_Core_DAO::executeQuery("\r\n\t\tCREATE TABLE IF NOT EXISTS `civicrm_stripe_plans` (\r\n  \t\t\t`plan_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\r\n  \t\t\tUNIQUE KEY `plan_id` (`plan_id`)\r\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\r\n\t\t");
         CRM_Core_DAO::executeQuery("\r\n\t\tCREATE TABLE IF NOT EXISTS `civicrm_stripe_subscriptions` (\r\n\t\t\t`customer_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t\t`invoice_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t\t`end_time` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t`is_live` tinyint(4) NOT NULL COMMENT 'Whether this is a live or test transaction',\r\n\t\t\tKEY `end_time` (`end_time`)\r\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\r\n\t\t");
         CRM_Core_Error::debug('Stripe Database tables created.  <br />This is the only time this message will be displayed.  You do not need to take any further actions.');
     }
     if (empty($this->_paymentProcessor['user_name'])) {
         $error[] = ts('The "Secret Key" is not set in the Stripe Payment Processor settings.');
     }
     if (empty($this->_paymentProcessor['password'])) {
         $error[] = ts('The "Publishable Key" is not set in the Stripe Payment Processor settings.');
     }
     if (!empty($error)) {
         return implode('<p>', $error);
     } else {
         return NULL;
     }
 }
Exemplo n.º 5
0
<?php

require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
require_once 'CRM/Core/Error.php';
$config = CRM_Core_Config::singleton();
require_once 'CRM/Case/XMLProcessor/Report.php';
$xmlProcessor = new CRM_Case_XMLProcessor_Report();
$report = $xmlProcessor->getActivityInfo(102, 552);
CRM_Core_Error::debug($report);
exit;
$xmlProcessor->run(104, 1, 'Substance Abuse', '15 Day Review');
$params = array('clientID' => 104, 'creatorID' => 108, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'dueDateTime' => time(), 'caseID' => 1);
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$result = $xmlProcessor->get('Substance Abuse', 'CaseRoles');
CRM_Core_Error::debug('Case Roles', $result);
$result = $xmlProcessor->get('Substance Abuse', 'ActivityTypes');
CRM_Core_Error::debug('Activity Types', $result);
$result = $xmlProcessor->get('Substance Abuse', 'ActivitySets');
CRM_Core_Error::debug('Activity Sets', $result);
$xmlProcessor->run('Substance Abuse', $params);
exit;
Exemplo n.º 6
0
 protected static function _invoke($args)
 {
     if ($args[0] !== 'civicrm') {
         return;
     }
     require_once 'CRM/Core/I18n.php';
     $config = CRM_Core_Config::singleton();
     if (isset($args[1]) and $args[1] == 'menu' and isset($args[2]) and $args[2] == 'rebuild') {
         // ensure that the user has a good privilege level
         if (CRM_Core_Permission::check('administer CiviCRM')) {
             self::rebuildMenuAndCaches();
             CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
             return CRM_Utils_System::redirect();
         } else {
             CRM_Core_Error::fatal('You do not have permission to execute this url');
         }
     }
     // first fire up IDS and check for bad stuff
     if ($config->useIDS) {
         $ids = new CRM_Core_IDS();
         $ids->check($args);
     }
     // also initialize the i18n framework
     $i18n = CRM_Core_I18n::singleton();
     if ($config->userFramework == 'Standalone') {
         $session = CRM_Core_Session::singleton();
         if ($session->get('new_install') !== TRUE) {
             CRM_Core_Standalone::sidebarLeft();
         } elseif ($args[1] == 'standalone' && $args[2] == 'register') {
             CRM_Core_Menu::store();
         }
     }
     // get the menu items
     $path = implode('/', $args);
     $item = CRM_Core_Menu::get($path);
     // we should try to compute menus, if item is empty and stay on the same page,
     // rather than compute and redirect to dashboard.
     if (!$item) {
         CRM_Core_Menu::store(FALSE);
         $item = CRM_Core_Menu::get($path);
     }
     if ($config->userFramework == 'Joomla' && $item) {
         $config->userFrameworkURLVar = 'task';
         // joomla 1.5RC1 seems to push this in the POST variable, which messes
         // QF and checkboxes
         unset($_POST['option']);
         CRM_Core_Joomla::sidebarLeft();
     }
     // set active Component
     $template = CRM_Core_Smarty::singleton();
     $template->assign('activeComponent', 'CiviCRM');
     $template->assign('formTpl', 'default');
     if ($item) {
         // CRM-7656 - make sure we send a clean sanitized path to create printer friendly url
         $printerFriendly = CRM_Utils_System::makeURL('snippet', FALSE, FALSE, CRM_Utils_Array::value('path', $item)) . '2';
         $template->assign('printerFriendly', $printerFriendly);
         if (!array_key_exists('page_callback', $item)) {
             CRM_Core_Error::debug('Bad item', $item);
             CRM_Core_Error::fatal(ts('Bad menu record in database'));
         }
         // check that we are permissioned to access this page
         if (!CRM_Core_Permission::checkMenuItem($item)) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         // check if ssl is set
         if (CRM_Utils_Array::value('is_ssl', $item)) {
             CRM_Utils_System::redirectToSSL();
         }
         if (isset($item['title'])) {
             CRM_Utils_System::setTitle($item['title']);
         }
         if (isset($item['breadcrumb']) && !isset($item['is_public'])) {
             CRM_Utils_System::appendBreadCrumb($item['breadcrumb']);
         }
         $pageArgs = NULL;
         if (CRM_Utils_Array::value('page_arguments', $item)) {
             $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']);
         }
         $template = CRM_Core_Smarty::singleton();
         if (isset($item['is_public']) && $item['is_public']) {
             $template->assign('urlIsPublic', TRUE);
         } else {
             $template->assign('urlIsPublic', FALSE);
         }
         if (isset($item['return_url'])) {
             $session = CRM_Core_Session::singleton();
             $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1');
             $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
         }
         // CRM_Core_Error::debug( $item ); exit( );
         $result = NULL;
         if (is_array($item['page_callback'])) {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php';
             $result = call_user_func($item['page_callback'], $newArgs);
         } elseif (strstr($item['page_callback'], '_Form')) {
             $wrapper = new CRM_Utils_Wrapper();
             $result = $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : NULL);
         } else {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php';
             $mode = 'null';
             if (isset($pageArgs['mode'])) {
                 $mode = $pageArgs['mode'];
                 unset($pageArgs['mode']);
             }
             $title = CRM_Utils_Array::value('title', $item);
             if (strstr($item['page_callback'], '_Page')) {
                 eval("\$object = new {$item['page_callback']}( \$title, \$mode );");
             } elseif (strstr($item['page_callback'], '_Controller')) {
                 $addSequence = 'false';
                 if (isset($pageArgs['addSequence'])) {
                     $addSequence = $pageArgs['addSequence'];
                     $addSequence = $addSequence ? 'true' : 'false';
                     unset($pageArgs['addSequence']);
                 }
                 eval("\$object = new {$item['page_callback']}( \$title, true, \$mode, null, \$addSequence );");
             } else {
                 CRM_Core_Error::fatal();
             }
             $result = $object->run($newArgs, $pageArgs);
         }
         CRM_Core_Session::storeSessionObjects();
         return $result;
     }
     CRM_Core_Menu::store();
     CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
     return CRM_Utils_System::redirect();
 }
Exemplo n.º 7
0
 /**
  * @param $key
  * @param $value
  *
  * @return bool
  * @throws Exception
  */
 public function set($key, &$value)
 {
     if (!$this->_cache->set($this->_prefix . $key, serialize($value), $this->_timeout)) {
         CRM_Core_Error::debug('Result Code: ', $this->_cache->getResultMessage());
         CRM_Core_Error::fatal("Redis set failed, wondering why?, {$key}", $value);
         return FALSE;
     }
     return TRUE;
 }
Exemplo n.º 8
0
<?php

require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
require_once 'CRM/Utils/Cache.php';
define('CIVICRM_USE_MEMCACHE', 1);
$config =& CRM_Core_Config::singleton();
$cache =& CRM_Utils_Cache::singleton();
$cache->set('CRM_Core_Config' . CRM_Core_Config::domainID(), $config);
CRM_Core_Error::debug('get', $cache->get('CRM_Core_Config' . CRM_Core_Config::domainID()));
Exemplo n.º 9
0
 /**
  * @param string $name
  * @param $menu
  *
  * @throws Exception
  */
 public static function read($name, &$menu)
 {
     $config = CRM_Core_Config::singleton();
     $xml = simplexml_load_file($name);
     foreach ($xml->item as $item) {
         if (!(string) $item->path) {
             CRM_Core_Error::debug('i', $item);
             CRM_Core_Error::fatal();
         }
         $path = (string) $item->path;
         $menu[$path] = array();
         unset($item->path);
         foreach ($item as $key => $value) {
             $key = (string) $key;
             $value = (string) $value;
             if (strpos($key, '_callback') && strpos($value, '::')) {
                 // FIXME Remove the rewrite at this level. Instead, change downstream call_user_func*($value)
                 // to call_user_func*(Civi\Core\Resolver::singleton()->get($value)).
                 $value = explode('::', $value);
             } elseif ($key == 'access_arguments') {
                 // FIXME Move the permission parser to its own class (or *maybe* CRM_Core_Permission).
                 if (strpos($value, ',') || strpos($value, ';')) {
                     if (strpos($value, ',')) {
                         $elements = explode(',', $value);
                         $op = 'and';
                     } else {
                         $elements = explode(';', $value);
                         $op = 'or';
                     }
                     $items = array();
                     foreach ($elements as $element) {
                         $items[] = $element;
                     }
                     $value = array($items, $op);
                 } else {
                     $value = array(array($value), 'and');
                 }
             } elseif ($key == 'is_public' || $key == 'is_ssl') {
                 $value = $value == 'true' || $value == 1 ? 1 : 0;
             }
             $menu[$path][$key] = $value;
         }
     }
 }
Exemplo n.º 10
0
 /**
  * This is the main function that is called on every click action and based on the argument
  * respective functions are called
  *
  * @param $args array this array contains the arguments of the url 
  * 
  * @static
  * @access public
  */
 static function invoke($args)
 {
     require_once 'CRM/Core/I18n.php';
     require_once 'CRM/Utils/Wrapper.php';
     require_once 'CRM/Core/Action.php';
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/Menu.php';
     require_once 'CRM/Core/Component.php';
     require_once 'CRM/Core/Permission.php';
     if ($args[0] !== 'civicrm') {
         return;
     }
     if (isset($args[1]) and $args[1] == 'menu' and isset($args[2]) and $args[2] == 'rebuild') {
         CRM_Core_Menu::store();
         CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
         // also reset navigation
         require_once 'CRM/Core/BAO/Navigation.php';
         CRM_Core_BAO_Navigation::resetNavigation();
         return CRM_Utils_System::redirect();
     }
     // first fire up IDS and check for bad stuff
     require_once 'CRM/Core/IDS.php';
     $ids = new CRM_Core_IDS();
     $ids->check($args);
     $config =& CRM_Core_Config::singleton();
     // also initialize the i18n framework
     $i18n =& CRM_Core_I18n::singleton();
     if ($config->userFramework == 'Standalone') {
         require_once 'CRM/Core/Session.php';
         $session =& CRM_Core_Session::singleton();
         if ($session->get('new_install') !== true) {
             require_once 'CRM/Core/Standalone.php';
             CRM_Core_Standalone::sidebarLeft();
         } else {
             if ($args[1] == 'standalone' && $args[2] == 'register') {
                 CRM_Core_Menu::store();
             }
         }
     }
     // get the menu items
     $path = implode('/', $args);
     $item =& CRM_Core_Menu::get($path);
     // we should try to compute menus, if item is empty and stay on the same page,
     // rather than compute and redirect to dashboard.
     if (!$item) {
         CRM_Core_Menu::store(false);
         $item =& CRM_Core_Menu::get($path);
     }
     if ($config->userFramework == 'Joomla' && $item) {
         $config->userFrameworkURLVar = 'task';
         require_once 'CRM/Core/Joomla.php';
         // joomla 1.5RC1 seems to push this in the POST variable, which messes
         // QF and checkboxes
         unset($_POST['option']);
         CRM_Core_Joomla::sidebarLeft();
     }
     // set active Component
     $template =& CRM_Core_Smarty::singleton();
     $template->assign('activeComponent', 'CiviCRM');
     $template->assign('formTpl', 'default');
     if ($item) {
         if (!array_key_exists('page_callback', $item)) {
             CRM_Core_Error::debug('Bad item', $item);
             CRM_Core_Error::fatal(ts('Bad menu record in database'));
         }
         // check that we are permissioned to access this page
         if (!CRM_Core_Permission::checkMenuItem($item)) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         // check if ssl is set
         if (CRM_Utils_Array::value('is_ssl', $item)) {
             CRM_Utils_System::redirectToSSL();
         }
         if (isset($item['title'])) {
             CRM_Utils_System::setTitle($item['title']);
         }
         if (isset($item['breadcrumb']) && !isset($item['is_public'])) {
             CRM_Utils_System::appendBreadCrumb($item['breadcrumb']);
         }
         $pageArgs = null;
         if (CRM_Utils_Array::value('page_arguments', $item)) {
             $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']);
         }
         $template =& CRM_Core_Smarty::singleton();
         if (isset($item['is_public']) && $item['is_public']) {
             $template->assign('urlIsPublic', true);
         } else {
             $template->assign('urlIsPublic', false);
         }
         if (isset($item['return_url'])) {
             $session =& CRM_Core_Session::singleton();
             $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1');
             $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
         }
         if (is_array($item['page_callback'])) {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php';
             return call_user_func($item['page_callback'], $newArgs);
         } else {
             if (strstr($item['page_callback'], '_Form')) {
                 $wrapper =& new CRM_Utils_Wrapper();
                 return $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : null);
             } else {
                 $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php';
                 $mode = 'null';
                 if (isset($pageArgs['mode'])) {
                     $mode = $pageArgs['mode'];
                     unset($pageArgs['mode']);
                 }
                 $title = CRM_Utils_Array::value('title', $item);
                 if (strstr($item['page_callback'], '_Page')) {
                     eval('$object =& ' . "new {$item['page_callback']}( \$title, \$mode );");
                 } else {
                     if (strstr($item['page_callback'], '_Controller')) {
                         $addSequence = 'false';
                         if (isset($pageArgs['addSequence'])) {
                             $addSequence = $pageArgs['addSequence'];
                             $addSequence = $addSequence ? 'true' : 'false';
                             unset($pageArgs['addSequence']);
                         }
                         eval('$object =& ' . "new {$item['page_callback']} ( \$title, true, \$mode, null, \$addSequence );");
                     } else {
                         CRM_Core_Error::fatal();
                     }
                 }
                 return $object->run($newArgs, $pageArgs);
             }
         }
     }
     CRM_Core_Menu::store();
     CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
     return CRM_Utils_System::redirect();
 }
Exemplo n.º 11
0
 /**
  * @param string $msg
  * @param bool $log
  */
 public static function backtrace($msg = 'backTrace', $log = FALSE)
 {
     $backTrace = debug_backtrace();
     $message = self::formatBacktrace($backTrace);
     if (!$log) {
         CRM_Core_Error::debug($msg, $message);
     } else {
         CRM_Core_Error::debug_var($msg, $message);
     }
 }
Exemplo n.º 12
0
  /**
   * Mostly overriding this for ease of adding in debug.
   */
  function postProcess() {

    try {
      if (!empty($this->_aclTable) && CRM_Utils_Array::value($this->_aclTable, $this->_aliases)) {
        $this->buildACLClause($this->_aliases[$this->_aclTable]);
      }
      $this->beginPostProcess();

      $sql = $this->buildQuery();
      $this->reOrderColumnHeaders();
      // build array of result based on column headers. This method also allows
      // modifying column headers before using it to build result set i.e $rows.
      $rows = array();
      $this->buildRows($sql, $rows);
      $this->addDeveloperTab($sql);
      $this->addAggregatePercentRow($rows);

      // format result set.
      $this->formatDisplay($rows);

      // assign variables to templates
      $this->doTemplateAssignment($rows);

      // do print / pdf / instance stuff if needed
      $this->endPostProcess($rows);
    } catch (Exception $e) {
      $err['message'] = $e->getMessage();
      $err['trace'] = $e->getTrace();

      foreach ($err['trace'] as $fn) {
        if ($fn['function'] == 'raiseError') {
          foreach ($fn['args'] as $arg) {
            $err['sql_error'] = $arg;
          }
        }
        if ($fn['function'] == 'simpleQuery') {
          foreach ($fn['args'] as $arg) {
            $err['sql_query'] = $arg;
          }
        }
      }

      if (function_exists('dpm')) {
        dpm($err);
        dpm($this->_columns);;
      }
      else {
        CRM_Core_Error::debug($err);
      }

    }
  }
 /**
  * Download the remote zipfile.
  *
  * @return boolean Whether the download was successful.
  */
 public function download()
 {
     require_once 'CA/Config/Curl.php';
     $config = CRM_Core_Config::singleton();
     $path = $config->extensionsDir . DIRECTORY_SEPARATOR . 'tmp';
     $filename = $path . DIRECTORY_SEPARATOR . $this->key . '.zip';
     if (!$this->downloadUrl) {
         CRM_Core_Error::fatal('Cannot install this extension - downloadUrl is not set!');
     }
     // Download extension zip file ...
     if (!function_exists('curl_init')) {
         CRM_Core_Error::fatal('Cannot install this extension - curl is not installed!');
     }
     if (preg_match('/^https:/', $this->downloadUrl) && !CA_Config_Curl::singleton()->isEnableSSL()) {
         CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
     }
     //setting the curl parameters.
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->downloadUrl);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_VERBOSE, 1);
     if (preg_match('/^https:/', $this->downloadUrl)) {
         curl_setopt_array($ch, CA_Config_Curl::singleton()->toCurlOptions());
     }
     //follow redirects
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
     $fp = fopen($filename, "w");
     if (!$fp) {
         CRM_Core_Session::setStatus(ts('Unable to write to %1.<br />Is the location writable?', array(1 => $filename)));
         return;
     }
     curl_setopt($ch, CURLOPT_FILE, $fp);
     curl_exec($ch);
     if (curl_errno($ch)) {
         CRM_Core_Error::debug(curl_error($ch));
         CRM_Core_Error::debug(curl_errno($ch));
         exit;
         CRM_Core_Session::setStatus(ts('Unable to download extension from %1. Error Message: %2', array(1 => $this->downloadUrl, 2 => curl_error($ch))));
         return;
     } else {
         curl_close($ch);
     }
     fclose($fp);
     $this->tmpFile = $filename;
     return TRUE;
 }
Exemplo n.º 14
0
 /**
  * dumps the session to the log
  */
 function debug($all = 1)
 {
     if ($all != 1) {
         CRM_Core_Error::debug('CRM Session', $this->_session);
     } else {
         CRM_Core_Error::debug('CRM Session', $this->_session[$this->_key]);
     }
 }
Exemplo n.º 15
0
 public function postProcess()
 {
     $this->_params = $this->controller->exportValues($this->_name);
     CRM_Core_Error::debug($this->_params);
     CRM_Utils_System::civiExit();
 }
 public function handlePaymentNotification()
 {
     CRM_Core_Error::debug_log_message('uk_co_vedaconsulting_payment_smartdebitdd handlePaymentNotification');
     CRM_Core_Error::debug_log_message('$_GET[]:' . print_r($_GET, true));
     CRM_Core_Error::debug_log_message('$_POST[]:' . print_r($_POST, true));
     CRM_Core_Error::debug('Smart Debit handlePaymentNotification');
     require_once 'CRM/Utils/Array.php';
     require_once 'CRM/Core/Payment/SmartDebitIPN.php';
     $module = CRM_Utils_Array::value('module', $_GET);
     if (empty($_GET)) {
         $rpInvoiceArray = array();
         $rpInvoiceArray = explode('&', $_POST['rp_invoice_id']);
         foreach ($rpInvoiceArray as $rpInvoiceValue) {
             $rpValueArray = explode('=', $rpInvoiceValue);
             if ($rpValueArray[0] == 'm') {
                 $value = $rpValueArray[1];
             }
         }
         CRM_Core_Error::debug_log_message('uk_co_vedaconsulting_payment_smartdebitdd handlePaymentNotification #2');
         $SmartDebitIPN = new CRM_Core_Payment_SmartDebitIPN();
     } else {
         CRM_Core_Error::debug_log_message('uk_co_vedaconsulting_payment_smartdebitdd handlePaymentNotification #3');
         $value = CRM_Utils_Array::value('module', $_GET);
         $SmartDebitIPN = new CRM_Core_Payment_SmartDebitIPN();
     }
     CRM_Core_Error::debug_log_message('uk_co_vedaconsulting_payment_smartdebitdd handlePaymentNotification value=' . $value);
     switch (strtolower($value)) {
         case 'contribute':
             $SmartDebitIPN->main('contribute');
             break;
         case 'event':
             $SmartDebitIPN->main('event');
             break;
         default:
             require_once 'CRM/Core/Error.php';
             CRM_Core_Error::debug_log_message("Could not get module name from request url");
             echo "Could not get module name from request url<p>";
             break;
     }
 }
Exemplo n.º 17
0
 /**
  * Send an SMS Message via the Clickatell API Server
  *
  * @param array the message with a to/from/text
  *
  * @return mixed true on sucess or PEAR_Error object
  * @access public
  * @since 1.2
  */
 function sendMessage(&$message)
 {
     list($url, $postData) = $this->formURLPostData("/http/sendmsg");
     $postData .= "&from=" . $message['From'];
     $postData .= "&to=" . $message['To'];
     $postData .= "&text=" . $message['Body'];
     $postData .= "&climsgid=" . $message['id'];
     $postData .= "&callback=3&deliv_ack=1";
     if (!in_array($message['Type'], $this->messageType)) {
         return PEAR::raiseError("Invalid message type. Message ID is " . $message['id']);
     }
     if ($message['Type'] != "SMS_TEXT") {
         $postData .= "&msg_type=" . $message['Type'];
     }
     /**
      * Check if we are using a queue when sending as each account
      * with Clickatell is assigned three queues namely 1, 2 and 3.
      */
     if (isset($message['queue']) && is_numeric($message['queue'])) {
         if (in_array($message['queue'], range(1, 3))) {
             $postData .= "&queue=" . $message['queue'];
         }
     }
     $reqFeat = 0;
     /**
      * Normal text message
      */
     if ($message['Type'] == 'SMS_TEXT') {
         $reqFeat += 1;
     }
     /**
      * We set the sender id is alpha numeric or numeric
      * then we change the sender from data.
      */
     if (is_numeric($message['From'])) {
         $reqFeat += 32;
     } elseif (is_string($message['From'])) {
         $reqFeat += 16;
     }
     /**
      * Flash Messaging
      */
     if ($message['msg_type'] == 'SMS_FLASH') {
         $reqFeat += 512;
     }
     /**
      * Delivery Acknowledgments
      */
     $reqFeat += 8192;
     if (!empty($reqFeat)) {
         $postData .= "&req_feat=" . $reqFeat;
     }
     /**
      * Must we escalate message delivery if message is stuck in
      * the queue at Clickatell?
      */
     if (isset($message['escalate']) && !empty($message['escalate'])) {
         if (is_numeric($message['escalate'])) {
             if (in_array($message['escalate'], range(1, 2))) {
                 $postData .= "&escalate=" . $message['escalate'];
             }
         }
     }
     $response = $this->curl($url, $postData);
     if (PEAR::isError($response)) {
         return $response;
     }
     $send = split(":", $response['data']);
     CRM_Core_Error::debug('s', $send);
     if ($send[0] == "ID") {
         return true;
     } else {
         return PEAR::raiseError($response['data']);
     }
 }
Exemplo n.º 18
0
 /**
  * Given the key, retrieves the info XML from a remote server
  * and stores locally, returning the contents.
  *
  * @access public
  *
  * @param string $key extension key
  * @param boolean $cached whether to use cached data
  *
  * @return contents of info.xml, or null if info.xml cannot be retrieved or parsed
  */
 private function grabRemoteInfoFile($key, $cached = FALSE)
 {
     $filename = $this->cacheDir . DIRECTORY_SEPARATOR . $key . '.xml';
     $url = $this->getRepositoryUrl() . '/' . $key . '.xml';
     if (!$cached || !file_exists($filename)) {
         $fetchStatus = CRM_Utils_HttpClient::singleton()->fetch($url, $filename);
         if ($fetchStatus != CRM_Utils_HttpClient::STATUS_OK) {
             return NULL;
         }
     }
     if (file_exists($filename)) {
         $contents = file_get_contents($filename);
         //parse just in case
         $check = simplexml_load_string($contents);
         if (!$check) {
             foreach (libxml_get_errors() as $error) {
                 CRM_Core_Error::debug('xmlError', $error);
             }
             return;
         }
         return $contents;
     }
 }
Exemplo n.º 19
0
 /**
  * Dumps the session to the log.
  * @param int $all
  */
 public function debug($all = 1)
 {
     $this->initialize();
     if ($all != 1) {
         CRM_Core_Error::debug('CRM Session', $this->_session);
     } else {
         CRM_Core_Error::debug('CRM Session', $this->_session[$this->_key]);
     }
 }
Exemplo n.º 20
0
 /**
  * @param $key
  * @param $value
  *
  * @return bool
  * @throws Exception
  */
 function set($key, &$value)
 {
     $key = $this->cleanKey($key);
     if (!$this->_cache->set($key, $value, $this->_timeout)) {
         CRM_Core_Error::debug('Result Code: ', $this->_cache->getResultMessage());
         CRM_Core_Error::fatal("memcached set failed, wondering why?, {$key}", $value);
         return FALSE;
     }
     return TRUE;
 }
 /**
  * @param $tree
  * @param $id
  *
  * @return bool
  */
 static function isCyclic(&$tree, $id)
 {
     $parents = $children = array();
     self::getAll($parent, $tree, $id, 'parents');
     self::getAll($child, $tree, $id, 'children');
     $one = array_intersect($parents, $children);
     $two = array_intersect($children, $parents);
     if (!empty($one) || !empty($two)) {
         CRM_Core_Error::debug($id, $tree);
         CRM_Core_Error::debug($id, $one);
         CRM_Core_Error::debug($id, $two);
         return TRUE;
     }
     return FALSE;
 }
Exemplo n.º 22
0
 static function backtrace($msg = 'backTrace', $log = false)
 {
     $backTrace = debug_backtrace();
     $msgs = array();
     require_once 'CRM/Utils/Array.php';
     foreach ($backTrace as $trace) {
         $msgs[] = implode(', ', array(CRM_Utils_Array::value('file', $trace), CRM_Utils_Array::value('function', $trace), CRM_Utils_Array::value('line', $trace)));
     }
     $message = implode("\n", $msgs);
     if (!$log) {
         CRM_Core_Error::debug($msg, $message);
     } else {
         CRM_Core_Error::debug_var($msg, $message);
     }
 }
Exemplo n.º 23
0
 /**
  * @param null $message
  * @param bool $printDAO
  */
 public static function debugPrint($message = NULL, $printDAO = TRUE)
 {
     CRM_Utils_System::xMemory("{$message}: ");
     if ($printDAO) {
         global $_DB_DATAOBJECT;
         $q = array();
         foreach (array_keys($_DB_DATAOBJECT['RESULTS']) as $id) {
             $q[] = $_DB_DATAOBJECT['RESULTS'][$id]->query;
         }
         CRM_Core_Error::debug('_DB_DATAOBJECT', $q);
     }
 }
Exemplo n.º 24
0
 public function postProcess()
 {
     $this->_params = $this->controller->exportValues($this->_name);
     CRM_Core_Error::debug($this->_params);
     exit;
 }
Exemplo n.º 25
0
        $errors['mem'][] = $rows[0];
        continue;
    }
    if (!empty($rows[18])) {
        $membershipParams['end_date'] = date('Y-m-d', strtotime($rows[18]));
    }
    if (!empty($membershipResult['id'])) {
        $membershipParams['id'] = $membershipResult['id'];
    }
    $membership = civicrm_api3('Membership', 'create', $membershipParams);
    if (empty($membership['id'])) {
        CRM_Core_Error::debug_var('$membershipFailed', $membership);
    } else {
        $totalImported++;
    }
    CRM_Core_Error::debug('$totalImported', $totalImported);
}
// print details in log
$logFile = 'Sync-' . date('Y-m-d-h-i-s');
if (!empty($errors['org'])) {
    CRM_Core_Error::debug_log_message('Organization already found in db for CFRA ID:', FALSE, $logFile);
    CRM_Core_Error::debug_var('', $errors['org'], TRUE, TRUE, $logFile);
}
if (!empty($errors['ind'])) {
    CRM_Core_Error::debug_log_message('Individual Contacts already found in db for CFRA ID:', FALSE, $logFile);
    CRM_Core_Error::debug_var('', $errors['ind'], TRUE, TRUE, $logFile);
}
if (!empty($errors['mem'])) {
    CRM_Core_Error::debug_log_message('Ignored membership for CFRA ID:', FALSE, $logFile);
    CRM_Core_Error::debug_var('', $errors['mem'], TRUE, TRUE, $logFile);
}
 /**
  * The function gets called when a new order takes place.
  *
  * @param array $post_data_exp
  *   Response from DataTrans
  * @param decimal $formatted_amount
  *   The native display of amount (e.g. in USD: 10.50).
  *
  * @return void
  *
  */
 function newOrderNotify($post_data_exp, $formatted_amount)
 {
     $ids = $input = $params = array();
     $input['component'] = $post_data_exp['component'];
     $ids['contact'] = self::retrieve('contactID', 'Integer', $post_data_exp, TRUE);
     $ids['contribution'] = self::retrieve('contributionID', 'Integer', $post_data_exp, TRUE);
     if ($input['component'] == "event") {
         $ids['event'] = self::retrieve('eventID', 'Integer', $post_data_exp, TRUE);
         $ids['participant'] = self::retrieve('participantID', 'Integer', $post_data_exp, TRUE);
         $ids['membership'] = NULL;
     } else {
         $ids['membership'] = self::retrieve('membershipID', 'Integer', $post_data_exp, FALSE);
     }
     $ids['contributionRecur'] = $ids['contributionPage'] = NULL;
     if (!$this->validateData($input, $ids, $objects, TRUE, $post_data_exp['payment_processor_id'])) {
         return FALSE;
     }
     // Make sure the invoice is valid and matches what we have in the contribution record.
     $input['invoice'] = $post_data_exp['refno'];
     $input['newInvoice'] = $post_data_exp['uppTransactionId'];
     $contribution =& $objects['contribution'];
     $input['trxn_id'] = $post_data_exp['uppTransactionId'];
     if ($contribution->invoice_id != $input['invoice']) {
         CRM_Core_Error::debug_log_message("Invoice values dont match between database and IPN request");
         print "Failure: Invoice values dont match between database and IPN request<p>";
         return;
     }
     // Replace invoice-id with Payment Processor trxn_id.
     $contribution->invoice_id = $input['newInvoice'];
     $input['amount'] = $formatted_amount;
     if ($contribution->total_amount != $input['amount']) {
         CRM_Core_Error::debug_log_message("Amount values dont match between database and IPN request");
         print "Failure: Amount values dont match between database and IPN request. " . $contribution->total_amount . "/" . $input['amount'] . "<p>";
         return;
     }
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     // Check if contribution is already completed, if so we ignore this ipn.
     if ($contribution->contribution_status_id == 1) {
         CRM_Core_Error::debug("Returning since contribution has already been handled");
         print "Success: Contribution has already been handled<p>";
         return TRUE;
     }
     $this->completeTransaction($input, $ids, $objects, $transaction);
     return TRUE;
 }
Exemplo n.º 27
0
 function debugPrint()
 {
     CRM_Core_Error::debug("{$this->_name}, {$this->_type}", "{$this->_back}, {$this->_next}");
 }
Exemplo n.º 28
0
function run()
{
    SFS_bin_Utils_auth();
    require_once '../SFS/Utils/Conference.php';
    // first cache all the contacts who have created a login
    $sql = "\nSELECT c.id\nFROM   civicrm_contact c,\n       civicrm_uf_match uf,\n       drupal_sfs.users u\nWHERE  uf.contact_id = c.id\nAND    uf.uf_id = u.uid\nAND    u.created != u.access\n";
    $dao = CRM_Core_DAO::executeQuery($sql);
    $accountsCreted = array();
    while ($dao->fetch()) {
        $accountsCreated[$dao->id] = 1;
    }
    // now fetch all the student parent information
    $sql = "\nSELECT      c.id as c_id, c.display_name as c_name, s.grade_sis as c_grade, p.id as p_id, p.display_name as p_name, ep.email as p_email\nFROM        civicrm_contact c\nINNER JOIN  civicrm_value_school_information s ON s.entity_id = c.id\nINNER JOIN  civicrm_relationship r ON r.contact_id_a = c.id\nINNER JOIN  civicrm_contact p      ON r.contact_id_b = p.id\nLEFT  JOIN  civicrm_email   ep     ON ep.contact_id  = p.id\nWHERE s.subtype = 'Student'\nAND   s.grade_sis >= 1\nAND   r.relationship_type_id = 1\nORDER BY p_id\n";
    $parentsDoNotHaveLogin = array();
    $parentsDoHaveLogin = array();
    $dao = CRM_Core_DAO::executeQuery($sql);
    while ($dao->fetch()) {
        if (array_key_exists($dao->p_id, $accountsCreated)) {
            unset($parentsDoNotHaveLogin[$dao->c_id]);
            if (!array_key_exists($dao->c_id, $parentsDoHaveLogin)) {
                $parentsDoHaveLogin[$dao->c_id] = array();
            }
            $parentsDoHaveLogin[$dao->c_id][] = array($dao->c_name, $dao->c_grade, $dao->p_id, $dao->p_name, $dao->p_email);
        } else {
            if (array_key_exists($dao->c_id, $parentsDoHaveLogin)) {
                unset($parentsDoNotHaveLogin[$dao->c_id]);
                $parentsDoHaveLogin[$dao->c_id][] = array($dao->c_name, $dao->c_grade, $dao->p_id, $dao->p_name, $dao->p_email);
            } else {
                if (!array_key_exists($dao->c_id, $parentsDoNotHaveLogin)) {
                    $parentsDoNotHaveLogin[$dao->c_id] = array();
                }
                $parentsDoNotHaveLogin[$dao->c_id][] = array($dao->c_name, $dao->c_grade, $dao->p_id, $dao->p_name, $dao->p_email);
            }
        }
    }
    $families = array();
    $emailAddress = array();
    foreach ($parentsDoNotHaveLogin as $cid => $pValues) {
        $familyKey = $familyValue = array();
        foreach ($pValues as $pValue) {
            $familyKey[] = $pValue[2];
            if (!empty($pValue[4])) {
                $familyValue[] = "{$pValue[3]} <{$pValue[4]}>";
                $emailAddress[$pValue[4]] = "{$pValue[3]} <{$pValue[4]}>";
            } else {
                $familyValue[] = $pValue[3];
            }
        }
        $families[implode('_', $familyKey)] = implode(', ', $familyValue);
    }
    CRM_Core_Error::debug(count($emailAddress), implode(', ', $emailAddress));
    CRM_Core_Error::debug(count($families), $families);
    $familiesLoggedIn = array();
    foreach ($parentsDoHaveLogin as $cid => $pValues) {
        $familyKey = $familyValue = array();
        foreach ($pValues as $pValue) {
            $familyKey[] = $pValue[2];
            $familyValue[] = "{$pValue[3]} <{$pValue[4]}>";
        }
        $familiesLoggedIn[implode('_', $familyKey)] = implode(', ', $familyValue);
    }
    CRM_Core_Error::debug(count($familiesLoggedIn), $familiesLoggedIn);
}
Exemplo n.º 29
0
 /**
  * Given a menu item, call the appropriate controller and return the response
  *
  * @param array $item see CRM_Core_Menu
  * @return string, HTML
  */
 public static function runItem($item)
 {
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'Joomla' && $item) {
         $config->userFrameworkURLVar = 'task';
         // joomla 1.5RC1 seems to push this in the POST variable, which messes
         // QF and checkboxes
         unset($_POST['option']);
         CRM_Core_Joomla::sidebarLeft();
     }
     // set active Component
     $template = CRM_Core_Smarty::singleton();
     $template->assign('activeComponent', 'CiviCRM');
     $template->assign('formTpl', 'default');
     if ($item) {
         // CRM-7656 - make sure we send a clean sanitized path to create printer friendly url
         $printerFriendly = CRM_Utils_System::makeURL('snippet', FALSE, FALSE, CRM_Utils_Array::value('path', $item)) . '2';
         $template->assign('printerFriendly', $printerFriendly);
         if (!array_key_exists('page_callback', $item)) {
             CRM_Core_Error::debug('Bad item', $item);
             CRM_Core_Error::fatal(ts('Bad menu record in database'));
         }
         // check that we are permissioned to access this page
         if (!CRM_Core_Permission::checkMenuItem($item)) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         // check if ssl is set
         if (CRM_Utils_Array::value('is_ssl', $item)) {
             CRM_Utils_System::redirectToSSL();
         }
         if (isset($item['title'])) {
             CRM_Utils_System::setTitle($item['title']);
         }
         if (isset($item['breadcrumb']) && !isset($item['is_public'])) {
             CRM_Utils_System::appendBreadCrumb($item['breadcrumb']);
         }
         $pageArgs = NULL;
         if (CRM_Utils_Array::value('page_arguments', $item)) {
             $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']);
         }
         $template = CRM_Core_Smarty::singleton();
         if (!empty($item['is_public'])) {
             $template->assign('urlIsPublic', TRUE);
         } else {
             $template->assign('urlIsPublic', FALSE);
             self::versionCheck($template);
         }
         if (isset($item['return_url'])) {
             $session = CRM_Core_Session::singleton();
             $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1');
             $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
         }
         $result = NULL;
         if (is_array($item['page_callback'])) {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php';
             $result = call_user_func($item['page_callback'], $newArgs);
         } elseif (strstr($item['page_callback'], '_Form')) {
             $wrapper = new CRM_Utils_Wrapper();
             $result = $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : NULL);
         } else {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php';
             $mode = 'null';
             if (isset($pageArgs['mode'])) {
                 $mode = $pageArgs['mode'];
                 unset($pageArgs['mode']);
             }
             $title = CRM_Utils_Array::value('title', $item);
             if (strstr($item['page_callback'], '_Page')) {
                 $object = new $item['page_callback']($title, $mode);
             } elseif (strstr($item['page_callback'], '_Controller')) {
                 $addSequence = 'false';
                 if (isset($pageArgs['addSequence'])) {
                     $addSequence = $pageArgs['addSequence'];
                     $addSequence = $addSequence ? 'true' : 'false';
                     unset($pageArgs['addSequence']);
                 }
                 $object = new $item['page_callback']($title, true, $mode, null, $addSequence);
             } else {
                 CRM_Core_Error::fatal();
             }
             $result = $object->run($newArgs, $pageArgs);
         }
         CRM_Core_Session::storeSessionObjects();
         return $result;
     }
     CRM_Core_Menu::store();
     CRM_Core_Session::setStatus(ts('Menu has been rebuilt'), ts('Complete'), 'success');
     return CRM_Utils_System::redirect();
 }
 /**
  * Given the key, retrieves the info XML from a remote server
  * and stores locally, returning the contents.
  *
  * @access public
  *
  * @param string $key extension key
  * @param boolean $cached whether to use cached data
  *
  * @return contents of info.xml, or null if info.xml cannot be retrieved or parsed
  */
 public function grabRemoteInfoFile($key, $cached = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $path = $config->extensionsDir . DIRECTORY_SEPARATOR . 'cache';
     $filename = $path . DIRECTORY_SEPARATOR . $key . '.xml';
     $url = $this->getRepositoryUrl() . '/' . $key . '.xml';
     if (!$cached || !file_exists($filename)) {
         file_put_contents($filename, file_get_contents($url));
     }
     if (file_exists($filename)) {
         $contents = file_get_contents($filename);
         //parse just in case
         $check = simplexml_load_string($contents);
         if (!$check) {
             foreach (libxml_get_errors() as $error) {
                 CRM_Core_Error::debug('xmlError', $error);
             }
             return;
         }
         return $contents;
     }
 }