Пример #1
0
 function preProcess()
 {
     $msDoc = CRM_Utils_System::docURL2('Multi Site Installation', NULL, NULL, NULL, NULL, "wiki");
     CRM_Utils_System::setTitle(ts('Multi Site Settings'));
     $this->_varNames = array(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array('is_enabled' => array('html_type' => 'checkbox', 'title' => ts('Enable Multi Site Configuration'), 'weight' => 1, 'description' => ts('Multi Site provides support for sharing a single CiviCRM database among multiple sites.') . ' ' . $msDoc), 'uniq_email_per_site' => array('html_type' => 'checkbox', 'title' => ts('Ensure multi sites have a unique email per site'), 'weight' => 2, 'description' => NULL), 'domain_group_id' => array('html_type' => 'text', 'title' => ts('Parent group for this domain'), 'weight' => 3, 'description' => ts('Enter the group ID (civicrm_group.id).')), 'event_price_set_domain_id' => array('html_type' => 'text', 'title' => ts('Domain for event price sets'), 'weight' => 4, 'description' => NULL)));
     parent::preProcess();
 }
Пример #2
0
 function preProcess()
 {
     $msDoc = CRM_Utils_System::docURL2('Multi Site Installation', NULL, NULL, NULL, NULL, "wiki");
     CRM_Utils_System::setTitle(ts('Multi Site Settings'));
     $this->_varNames = array(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array('is_enabled' => array('html_type' => 'checkbox', 'title' => ts('Enable Multi Site Configuration'), 'weight' => 1, 'description' => ts('Make CiviCRM aware of multiple domains. You should configure a domain group if enabled') . ' ' . $msDoc), 'domain_group_id' => array('html_type' => 'entity_reference', 'title' => ts('Domain Group'), 'weight' => 3, 'options' => array('entity' => 'group', 'select' => array('minimumInputLength' => 0)), 'description' => ts('Contacts created on this site are added to this group'))));
     parent::preProcess();
 }
Пример #3
0
 function preProcess()
 {
     CRM_Utils_System::setTitle(ts('CiviEvent Component Settings'));
     // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
     $docLink = CRM_Utils_System::docURL2("CiviEvent Cart Checkout", NULL, NULL, NULL, NULL, "wiki");
     $this->_varNames = array(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array('enable_cart' => array('html_type' => 'checkbox', 'title' => ts('Use Shopping Cart Style Event Registration'), 'weight' => 1, 'description' => ts('This feature allows users to register for more than one event at a time. When enabled, users will add event(s) to a "cart" and then pay for them all at once. Enabling this setting will affect online registration for all active events. The code is an alpha state, and you will potentially need to have developer resources to debug and fix sections of the codebase while testing and deploying it. %1', array(1 => $docLink)))));
     parent::preProcess();
 }
Пример #4
0
function com_install()
{
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'configure.php';
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Utils' . DIRECTORY_SEPARATOR . 'System.php';
    global $civicrmUpgrade;
    $liveSite = substr_replace(JURI::root(), '', -1, 1);
    $configTaskUrl = $liveSite . '/administrator/index2.php?option=com_civicrm&task=civicrm/admin/configtask&reset=1';
    $upgradeUrl = $liveSite . '/administrator/index2.php?option=com_civicrm&task=civicrm/upgrade&reset=1';
    $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
    if ($civicrmUpgrade) {
        $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', true, 'Upgrade Guide');
        // UPGRADE successful status and links
        $content = '
  <center>
  <table width="100%" border="0">
    <tr>
        <td>
            <strong>CiviCRM component files have been UPGRADED <font color="green">succesfully</font></strong>.
            <p><strong>Please run the <a href="' . $upgradeUrl . '">CiviCRM Database Upgrade Utility</a> now. This utility will check your database and perform any needed upgrades.</strong></p>
            <p>Also review the <a href="' . $docLink . '">Upgrade Guide</a> for any additional steps required to complete this upgrade.</p>
        </td>
    </tr>
  </table>
  </center>';
    } else {
        $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', false, 'Installation Guide');
        $frontEnd = CRM_Utils_System::docURL2('Configuring Front-end Profile Listings and Forms in Joomla! Sites', false, 'Create front-end forms and searchable directories using Profiles');
        $contri = CRM_Utils_System::docURL2('Displaying Online Contribution Pages in Joomla! Frontend Sites', false, 'Create online contribution pages');
        $event = CRM_Utils_System::docURL2('Configuring Front-end Event Info and Registration in Joomla! Sites', false, 'Create events with online event registration');
        // INSTALL successful status and links
        $content = '
  <center>
  <table width="100%" border="0">
    <tr>
        <td>
            <strong>CiviCRM component files and database tables have been INSTALLED <font color="green">succesfully</font></strong>.
            <p><strong>Please review the ' . $docLink . ' for any additional steps required to complete the installation.</strong></p>
            <p><strong>Then use the <a href="' . $configTaskUrl . '">Configuration Checklist</a> to review and configure CiviCRM settings for your new site.</strong></p>
            <p><strong>Additional Resources:</strong>
                <ul>
                    <li>' . $frontEnd . '</li>
                    <li>' . $contri . '</li>
                    <li>' . $event . '</li>
                </ul>
            </p>
           <p><strong>Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href="' . $registerSiteURL . '" target="_blank">fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</strong></p>
        </td>
    </tr>
  </table>
  </center>';
    }
    echo $content;
}
Пример #5
0
 public function preProcess()
 {
     CRM_Utils_System::setTitle(ts('CiviEvent Component Settings'));
     // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
     $docLink = CRM_Utils_System::docURL2("CiviEvent Cart Checkout", NULL, NULL, NULL, NULL, "wiki");
     // build an array containing all selectable option values for show_events
     $optionValues = array();
     for ($i = 10; $i <= 100; $i += 10) {
         $optionValues[$i] = $i;
     }
     $this->_varNames = array(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array('enable_cart' => array('html_type' => 'checkbox', 'title' => ts('Use Shopping Cart Style Event Registration'), 'weight' => 1, 'description' => ts('This feature allows users to register for more than one event at a time. When enabled, users will add event(s) to a "cart" and then pay for them all at once. Enabling this setting will affect online registration for all active events. The code is an alpha state, and you will potentially need to have developer resources to debug and fix sections of the codebase while testing and deploying it. %1', array(1 => $docLink))), 'show_events' => array('html_type' => 'select', 'title' => ts('Dashboard entries'), 'weight' => 2, 'description' => ts('Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.'), 'option_values' => array('' => ts('- select -')) + $optionValues + array(-1 => ts('show all')))));
     parent::preProcess();
 }
Пример #6
0
function com_install()
{
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'configure.php';
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Utils' . DIRECTORY_SEPARATOR . 'System.php';
    global $civicrmUpgrade;
    $liveSite = substr_replace(JURI::root(), '', -1, 1);
    $configTaskUrl = $liveSite . '/administrator/index2.php?option=com_civicrm&task=civicrm/admin/configtask&reset=1';
    $upgradeUrl = $liveSite . '/administrator/index2.php?option=com_civicrm&task=civicrm/upgrade&reset=1';
    if ($civicrmUpgrade) {
        $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', true, 'Upgrade Guide');
        // UPGRADE successful status and links
        $content = '
  <center>
  <table width="100%" border="0">
    <tr>
        <td>
            <strong>CiviCRM component files have been UPGRADED <font color="green">succesfully</font></strong>.
            <p><strong>Please run the <a href="' . $upgradeUrl . '">CiviCRM Database Upgrade Utility</a> now. This utility will check your database and perform any needed upgrades.</strong></p>
            <p>Also review the <a href="' . $docLink . '">Upgrade Guide</a> for any additional steps required to complete this upgrade.</p>
        </td>
    </tr>
  </table>
  </center>';
    } else {
        $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', false, 'Installation Guide');
        $frontEnd = CRM_Utils_System::docURL2('Configuring Front-end Profile Listings and Forms in Joomla! Sites', false, 'Create front-end forms and searchable directories using Profiles');
        $contri = CRM_Utils_System::docURL2('Displaying Online Contribution Pages in Joomla! Frontend Sites', false, 'Create online contribution pages');
        $event = CRM_Utils_System::docURL2('Configuring Front-end Event Info and Registration in Joomla! Sites', false, 'Create events with online event registration');
        // INSTALL successful status and links
        $content = '
  <center>
  <table width="100%" border="0">
    <tr>
        <td>
            <strong>CiviCRM component files and database tables have been INSTALLED <font color="green">succesfully</font></strong>.
            <p><strong>Please review the ' . $docLink . ' for any additional steps required to complete the installation.</strong></p>
            <p><strong>Then use the <a href="' . $configTaskUrl . '">Configuration Checklist</a> to review and configure CiviCRM settings for your new site.</strong></p>
            <p><strong>Additional Resources:</strong>
                <ul>
                    <li>' . $frontEnd . '</li>
                    <li>' . $contri . '</li>
                    <li>' . $event . '</li>
                </ul>
            </p>
        </td>
    </tr>
  </table>
  </center>';
    }
    echo $content;
}
Пример #7
0
 /**
  * Pre-process
  */
 public function preProcess()
 {
     parent::preProcess();
     $session = CRM_Core_Session::singleton();
     if (!$this->_gName && !empty($this->urlPath[3])) {
         $this->_gName = $this->urlPath[3];
     }
     if (!$this->_gName && !empty($_GET['gid'])) {
         $this->_gName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', (int) $_GET['gid'], 'name');
     }
     if ($this->_gName) {
         $this->set('gName', $this->_gName);
     } else {
         $this->_gName = $this->get('gName');
     }
     $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gName, 'id', 'name');
     $this->_gLabel = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gid, 'title');
     $url = "civicrm/admin/options/{$this->_gName}";
     $params = "reset=1";
     if ($this->_action & CRM_Core_Action::DELETE && in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee'))) {
         // Don't allow delete if the option value belongs to addressee, postal or email greetings and is in use.
         $findValue = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'value');
         $queryParam = array(1 => array($findValue, 'Integer'));
         $columnName = $this->_gName . "_id";
         $sql = "SELECT count(id) FROM civicrm_contact WHERE " . $columnName . " = %1";
         $isInUse = CRM_Core_DAO::singleValueQuery($sql, $queryParam);
         if ($isInUse) {
             $scriptURL = "<a href='" . CRM_Utils_System::docURL2('Update Greetings and Address Data for Contacts', TRUE, NULL, NULL, NULL, "wiki") . "'>" . ts('Learn more about a script that can automatically update contact addressee and greeting options.') . "</a>";
             CRM_Core_Session::setStatus(ts('The selected %1 option has <strong>not been deleted</strong> because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', array(1 => $this->_gLabel, 2 => $scriptURL)), ts('Sorry'), 'error');
             $redirect = CRM_Utils_System::url($url, $params);
             CRM_Utils_System::redirect($redirect);
         }
     }
     $session->pushUserContext(CRM_Utils_System::url($url, $params));
     $this->assign('id', $this->_id);
     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.'));
         }
     }
 }
   function install($parent)
   {
       require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'configure.php';
       global $civicrmUpgrade;
       $script = 'index.php';
       $liveSite = substr_replace(JURI::root(), '', -1, 1);
       $configTaskUrl = $liveSite . "/administrator/?option=com_civicrm&task=civicrm/admin/configtask&reset=1";
       $upgradeUrl = $liveSite . "/administrator/?option=com_civicrm&task=civicrm/upgrade&reset=1";
       $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
       require_once 'CRM/Utils/System.php';
       require_once 'CRM/Utils/Array.php';
       if ($civicrmUpgrade) {
           $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', TRUE, 'Upgrade Guide', NULL, NULL, "wiki");
           // UPGRADE successful status and links
           $content = '
 <center>
 <table width="100%" border="0">
   <tr>
       <td>
           <strong>CiviCRM component files have been UPGRADED <font color="green">succesfully</font></strong>.
           <p><strong>Please run the <a href="' . $upgradeUrl . '">CiviCRM Database Upgrade Utility</a> now. This utility will check your database and perform any needed upgrades.</strong></p>
           <p>Also review the <a href="' . $docLink . '">Upgrade Guide</a> for any additional steps required to complete this upgrade.</p>
       </td>
   </tr>
 </table>
 </center>';
       } else {
           $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, 'Installation Guide', NULL, NULL, "wiki");
           $frontEnd = CRM_Utils_System::docURL2('Configuring Front-end Profile Listings and Forms in Joomla! Sites', FALSE, 'Create front-end forms and searchable directories using Profiles', NULL, NULL, "wiki");
           $contri = CRM_Utils_System::docURL2('Displaying Online Contribution Pages in Joomla! Frontend Sites', FALSE, 'Create online contribution pages', NULL, NULL, "wiki");
           $event = CRM_Utils_System::docURL2('Configuring Front-end Event Info and Registration in Joomla! Sites', FALSE, 'Create events with online event registration', NULL, NULL, "wiki");
           // INSTALL successful status and links
           $content = '
 <center>
 <table width="100%" border="0">
   <tr>
       <td>
           <strong>CiviCRM component files and database tables have been INSTALLED <font color="green">succesfully</font></strong>.
           <p><strong>Please review the ' . $docLink . ' for any additional steps required to complete the installation.</strong></p>
           <p><strong>Then use the <a href="' . $configTaskUrl . '">Configuration Checklist</a> to review and configure CiviCRM settings for your new site.</strong></p>
           <p><strong>Additional Resources:</strong>
               <ul>
                   <li>' . $frontEnd . '</li>
                   <li>' . $contri . '</li>
                   <li>' . $event . '</li>
               </ul>
           </p>
          <p><strong>We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.</strong>
           </p>
          <p><strong>Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href="' . $registerSiteURL . '" target="_blank">fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</strong></p>
       </td>
   </tr>
 </table>
 </center>';
       }
       //install and enable plugins
       $manifest = $parent->get("manifest");
       $parent = $parent->getParent();
       $source = $parent->getPath("source");
       $installer = new JInstaller();
       $plgArray = array();
       foreach ($manifest->plugins->plugin as $plugin) {
           $attributes = $plugin->attributes();
           $plg = $source . DS . $attributes['folder'] . DS . $attributes['plugin'];
           $installer->install($plg);
           $plgArray[] = "'" . $attributes['plugin'] . "'";
       }
       $db = JFactory::getDbo();
       $tableExtensions = $db->nameQuote("#__extensions");
       $columnElement = $db->nameQuote("element");
       $columnType = $db->nameQuote("type");
       $columnEnabled = $db->nameQuote("enabled");
       $plgList = implode(',', $plgArray);
       // Enable plugins
       $db->setQuery("UPDATE {$tableExtensions}\n                        SET {$columnEnabled} = 1\n                        WHERE {$columnElement} IN ({$plgList})\n                        AND {$columnType} = 'plugin'");
       $db->query();
       echo $content;
   }
Пример #9
0
 static function authenticateKey($abort = true)
 {
     // also make sure the key is sent and is valid
     $key = trim(CRM_Utils_Array::value('key', $_REQUEST));
     $docAdd = "More info at:" . CRM_Utils_System::docURL2("Command-line Script Configuration", true);
     if (!$key) {
         return self::authenticateAbort("ERROR: You need to send a valid key to execute this file. " . $docAdd . "\n", $abort);
     }
     $siteKey = defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : null;
     if (!$siteKey || empty($siteKey)) {
         return self::authenticateAbort("ERROR: You need to set a valid site key in civicrm.settings.php. " . $docAdd . "\n", $abort);
     }
     if (strlen($siteKey) < 8) {
         return self::authenticateAbort("ERROR: Site key needs to be greater than 7 characters in civicrm.settings.php. " . $docAdd . "\n", $abort);
     }
     if ($key !== $siteKey) {
         return self::authenticateAbort("ERROR: Invalid key value sent. " . $docAdd . "\n", $abort);
     }
     return true;
 }
Пример #10
0
 function upgrade($rev)
 {
     // fix CRM-5270: if civicrm_report_instance.description is localised,
     // recreate it based on the first locale’s description_xx_YY contents
     // and drop all the description_xx_YY columns
     if (!CRM_Core_DAO::checkFieldExists('civicrm_report_instance', 'description')) {
         require_once 'CRM/Core/DAO/Domain.php';
         $domain = new CRM_Core_DAO_Domain();
         $domain->find(true);
         $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
         CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance ADD description VARCHAR(255)");
         CRM_Core_DAO::executeQuery("UPDATE civicrm_report_instance SET description = description_{$locales[0]}");
         CRM_Core_DAO::executeQuery("DROP TRIGGER civicrm_report_instance_before_insert");
         foreach ($locales as $locale) {
             CRM_Core_DAO::executeQuery("DROP VIEW civicrm_report_instance_{$locale}");
             CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance DROP description_{$locale}");
         }
     }
     //We execute some part of php after sql and then again sql
     //So using conditions for skipping some part of sql CRM-4575
     $upgrade =& new CRM_Upgrade_Form();
     //Run the SQL file (1)
     $upgrade->processSQL($rev);
     //replace  with ; in report instance
     $sql = "UPDATE civicrm_report_instance \n                       SET form_values = REPLACE(form_values,'#',';') ";
     CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
     //delete unnecessary activities
     $bulkEmailID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
     if ($bulkEmailID) {
         $mailingActivityIds = array();
         $query = " \n            SELECT max( ca.id ) as aid, \n                   ca.source_record_id sid\n            FROM civicrm_activity ca\n            WHERE ca.activity_type_id = %1 \n            GROUP BY ca.source_record_id";
         $params = array(1 => array($bulkEmailID, 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($query, $params);
         while ($dao->fetch()) {
             $updateQuery = "\n                UPDATE civicrm_activity_target cat, civicrm_activity ca \n                    SET cat.activity_id = {$dao->aid}  \n                WHERE ca.source_record_id IS NOT NULL   AND\n                      ca.activity_type_id = %1          AND \n                      ca.id <> {$dao->aid}              AND \n                      ca.source_record_id = {$dao->sid} AND \n                      ca.id = cat.activity_id";
             $updateParams = array(1 => array($bulkEmailID, 'Integer'));
             CRM_Core_DAO::executeQuery($updateQuery, $updateParams);
             $deleteQuery = " \n                DELETE ca.* \n                FROM civicrm_activity ca \n                WHERE ca.source_record_id IS NOT NULL  AND \n                      ca.activity_type_id = %1         AND \n                      ca.id <> {$dao->aid}             AND \n                      ca.source_record_id = {$dao->sid}";
             $deleteParams = array(1 => array($bulkEmailID, 'Integer'));
             CRM_Core_DAO::executeQuery($deleteQuery, $deleteParams);
         }
     }
     //CRM-4453
     //lets insert column in civicrm_aprticipant table
     $query = "\n        ALTER TABLE `civicrm_participant` \n            ADD `fee_currency` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '3 character string, value derived from config setting.' AFTER `discount_id`";
     CRM_Core_DAO::executeQuery($query);
     //get currency from contribution table if exists/default
     //insert currency when fee_amount != NULL or event is paid.
     $query = "\n        SELECT  civicrm_participant.id \n        FROM    civicrm_participant\n            LEFT JOIN  civicrm_event \n                   ON ( civicrm_participant.event_id = civicrm_event.id )\n        WHERE  civicrm_participant.fee_amount IS NOT NULL OR \n               civicrm_event.is_monetary = 1";
     $participant = CRM_Core_DAO::executeQuery($query);
     while ($participant->fetch()) {
         $query = "\n            SELECT civicrm_contribution.currency \n            FROM   civicrm_contribution, \n                   civicrm_participant_payment\n            WHERE  civicrm_contribution.id = civicrm_participant_payment.contribution_id AND  \n                   civicrm_participant_payment.participant_id = {$participant->id}";
         $currencyID = CRM_Core_DAO::singleValueQuery($query);
         if (!$currencyID) {
             $config =& CRM_Core_Config::singleton();
             $currencyID = $config->defaultCurrency;
         }
         //finally update participant record.
         CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $participant->id, 'fee_currency', $currencyID);
     }
     //CRM-4575
     //check whether {contact.name} is set in mailing labels
     require_once 'CRM/Core/BAO/Preferences.php';
     $mailingFormat = CRM_Core_BAO_Preferences::value('mailing_format');
     $addNewAddressee = true;
     if (strpos($mailingFormat, '{contact.contact_name}') === false) {
         $addNewAddressee = false;
     } else {
         //else compare individual name format with default individual addressee.
         $individualNameFormat = CRM_Core_BAO_Preferences::value('individual_name_format');
         $defaultAddressee = CRM_Core_OptionGroup::values('addressee', false, false, false, " AND v.filter = 1 AND v.is_default =  1", 'label');
         if (array_search($individualNameFormat, $defaultAddressee) !== false) {
             $addNewAddressee = false;
         }
     }
     require_once 'CRM/Utils/System.php';
     $docURL = CRM_Utils_System::docURL2('Update Greetings and Address Data for Contacts', false, null, null, 'color: white; text-decoration: underline;');
     if ($addNewAddressee) {
         //otherwise insert new token in addressee and set as a default
         $addresseeGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'addressee', 'id', 'name');
         $optionValueParams = array('label' => $individualNameFormat, 'is_active' => 1, 'contactOptions' => 1, 'filter' => 1, 'is_default' => 1, 'reset_default_for' => array('filter' => "0, 1"));
         $action = CRM_Core_Action::ADD;
         $addresseeGroupParams = array('name' => 'addressee');
         $fieldValues = array('option_group_id' => $addresseeGroupId);
         $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
         $optionValueParams['weight'] = $weight;
         $addresseeToken = CRM_Core_OptionValue::addOptionValue($optionValueParams, $addresseeGroupParams, $action, $optionId = null);
         $afterUpgradeMessage = ts("During this upgrade, Postal Addressee values have been stored for each contact record using the system default format - %2.You will need to run the included command-line script to update your Individual contact records to use the \"Individual Name Format\" previously specified for your site %1", array(1 => $docURL, 2 => array_pop($defaultAddressee)));
     } else {
         $afterUpgradeMessage = ts("Email Greeting, Postal Greeting and Postal Addressee values have been stored for all contact records based on the system default formats. If you want to use a different format for any of these contact fields - you can run the provided command line script to update contacts to a different format %1 ", array(1 => $docURL));
     }
     //replace contact.contact_name with contact.addressee in civicrm_preference.mailing_format
     $updateQuery = "\n        UPDATE civicrm_preferences \n               SET `mailing_format` = \n                    replace(`mailing_format`, '{contact.contact_name}','{contact.addressee}')";
     CRM_Core_DAO::executeQuery($updateQuery);
     //drop column individual_name_format
     $alterQuery = "\n        ALTER TABLE `civicrm_preferences`\n              DROP `individual_name_format`";
     CRM_Core_DAO::executeQuery($alterQuery);
     //set status message for default greetings
     $template =& CRM_Core_Smarty::singleton();
     $template->assign('afterUpgradeMessage', $afterUpgradeMessage);
 }
/**
 * Implementation of hook_civicrm_validateForm
 */
function civimailchimp_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors)
{
    if ($formName === "CRM_Group_Form_Edit") {
        if (!empty($fields['mailchimp_list'])) {
            $site_key = defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : NULL;
            if (!$site_key) {
                $doc_link = CRM_Utils_System::docURL2("Managing Scheduled Jobs", TRUE, NULL, NULL, NULL, "wiki");
                $errors['mailchimp_list'] = ts("A valid CiviCRM site key in civicrm.settings.php is required to configure a Group to sync with Mailchimp. More info on generating a site key at %1.", array(1 => $doc_link));
            }
            $mailchimp_sync_setting = CRM_CiviMailchimp_BAO_SyncSettings::findByListId($fields['mailchimp_list'], FALSE);
            if ($mailchimp_sync_setting) {
                $group_id = $form->getVar('_id');
                if ($mailchimp_sync_setting->civicrm_group_id != $group_id) {
                    $errors['mailchimp_list'] = ts("Another CiviCRM Group is already configured to sync to this Mailchimp list. Please select another list.");
                }
            }
        }
    }
}
Пример #12
0
 /**
  * @param bool $abort
  *   (optional) Whether to exit; defaults to true.
  *
  * @return bool
  */
 public static function authenticateKey($abort = TRUE)
 {
     // also make sure the key is sent and is valid
     $key = trim(CRM_Utils_Array::value('key', $_REQUEST));
     $docAdd = "More info at:" . CRM_Utils_System::docURL2("Managing Scheduled Jobs", TRUE, NULL, NULL, NULL, "wiki");
     if (!$key) {
         return self::authenticateAbort("ERROR: You need to send a valid key to execute this file. " . $docAdd . "\n", $abort);
     }
     $siteKey = defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : NULL;
     if (!$siteKey || empty($siteKey)) {
         return self::authenticateAbort("ERROR: You need to set a valid site key in civicrm.settings.php. " . $docAdd . "\n", $abort);
     }
     if (strlen($siteKey) < 8) {
         return self::authenticateAbort("ERROR: Site key needs to be greater than 7 characters in civicrm.settings.php. " . $docAdd . "\n", $abort);
     }
     if ($key !== $siteKey) {
         return self::authenticateAbort("ERROR: Invalid key value sent. " . $docAdd . "\n", $abort);
     }
     return TRUE;
 }
Пример #13
0
 /**
  * @return array|int
  */
 public static function handle()
 {
     $requestParams = CRM_Utils_Request::exportValues();
     // Get the function name being called from the q parameter in the query string
     $q = CRM_Utils_array::value('q', $requestParams);
     // or for the rest interface, from fnName
     $r = CRM_Utils_array::value('fnName', $requestParams);
     if (!empty($r)) {
         $q = $r;
     }
     $entity = CRM_Utils_array::value('entity', $requestParams);
     if (empty($entity) && !empty($q)) {
         $args = explode('/', $q);
         // If the function isn't in the civicrm namespace, reject the request.
         if ($args[0] != 'civicrm') {
             return self::error('Unknown function invocation.');
         }
         // If the query string is malformed, reject the request.
         // Does this mean it will reject it
         if (count($args) != 3 && $args[1] != 'ping') {
             return self::error('Unknown function invocation.');
         }
         $store = NULL;
         if ($args[1] == 'ping') {
             return self::ping();
         }
     } else {
         // or the new format (entity+action)
         $args = array();
         $args[0] = 'civicrm';
         $args[1] = CRM_Utils_array::value('entity', $requestParams);
         $args[2] = CRM_Utils_array::value('action', $requestParams);
     }
     // Everyone should be required to provide the server key, so the whole
     //  interface can be disabled in more change to the configuration file.
     // first check for civicrm site key
     if (!CRM_Utils_System::authenticateKey(FALSE)) {
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", TRUE, NULL, NULL, NULL, "wiki");
         $key = CRM_Utils_array::value('key', $requestParams);
         if (empty($key)) {
             return self::error("FATAL: mandatory param 'key' missing. More info at: " . $docLink);
         }
         return self::error("FATAL: 'key' is incorrect. More info at: " . $docLink);
     }
     // At this point we know we are not calling ping which does not require authentication.
     //  Therefore, at this point we need to make sure we're working with a trusted user.
     //  Valid users are those who provide a valid server key and API key
     $valid_user = FALSE;
     // Check and see if a valid secret API key is provided.
     $api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
     if (!$api_key || strtolower($api_key) == 'null') {
         return self::error("FATAL: mandatory param 'api_key' (user key) missing");
     }
     $valid_user = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
     // If we didn't find a valid user, die
     if (empty($valid_user)) {
         return self::error("User API key invalid");
     }
     return self::process($args, self::buildParamList());
 }
Пример #14
0
 /**
  * Validation.
  *
  * @param array $params
  *   (ref.) an assoc array of name/value pairs.
  *
  * @param $files
  * @param $self
  *
  * @return bool|array
  *   mixed true or array of errors
  */
 public static function formRule($params, $files, $self)
 {
     if (!empty($_POST['_qf_Import_refresh'])) {
         return TRUE;
     }
     $errors = array();
     $template = CRM_Core_Smarty::singleton();
     if (isset($params['html_message'])) {
         $htmlMessage = str_replace(array("\n", "\r"), ' ', $params['html_message']);
         $htmlMessage = str_replace("'", "\\'", $htmlMessage);
         $template->assign('htmlContent', $htmlMessage);
     }
     $domain = CRM_Core_BAO_Domain::getDomain();
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $self->_mailingID;
     $mailing->find(TRUE);
     $session = CRM_Core_Session::singleton();
     $values = array('contact_id' => $session->get('userID'), 'version' => 3);
     require_once 'api/api.php';
     $contact = civicrm_api('contact', 'get', $values);
     //CRM-4524
     $contact = reset($contact['values']);
     $verp = array_flip(array('optOut', 'reply', 'unsubscribe', 'resubscribe', 'owner'));
     foreach ($verp as $key => $value) {
         $verp[$key]++;
     }
     $urls = array_flip(array('forward', 'optOutUrl', 'unsubscribeUrl', 'resubscribeUrl'));
     foreach ($urls as $key => $value) {
         $urls[$key]++;
     }
     // set $header and $footer
     foreach (array('header', 'footer') as $part) {
         ${$part} = array();
         if ($params["{$part}_id"]) {
             //echo "found<p>";
             $component = new CRM_Mailing_BAO_Component();
             $component->id = $params["{$part}_id"];
             $component->find(TRUE);
             ${$part}['textFile'] = $component->body_text;
             ${$part}['htmlFile'] = $component->body_html;
             $component->free();
         } else {
             ${$part}['htmlFile'] = ${$part}['textFile'] = '';
         }
     }
     $skipTextFile = $self->get('skipTextFile');
     $skipHtmlFile = $self->get('skipHtmlFile');
     if (!$params['upload_type']) {
         if ((!isset($files['textFile']) || !file_exists($files['textFile']['tmp_name'])) && (!isset($files['htmlFile']) || !file_exists($files['htmlFile']['tmp_name']))) {
             if (!($skipTextFile || $skipHtmlFile)) {
                 $errors['textFile'] = ts('Please provide either a Text or HTML formatted message - or both.');
             }
         }
     } else {
         if (empty($params['text_message']) && empty($params['html_message'])) {
             $errors['html_message'] = ts('Please provide either a Text or HTML formatted message - or both.');
         }
         if (!empty($params['saveTemplate']) && empty($params['saveTemplateName'])) {
             $errors['saveTemplateName'] = ts('Please provide a Template Name.');
         }
     }
     foreach (array('text', 'html') as $file) {
         if (!$params['upload_type'] && !file_exists(CRM_Utils_Array::value('tmp_name', $files[$file . 'File']))) {
             continue;
         }
         if ($params['upload_type'] && !$params[$file . '_message']) {
             continue;
         }
         if (!$params['upload_type']) {
             $str = file_get_contents($files[$file . 'File']['tmp_name']);
             $name = $files[$file . 'File']['name'];
         } else {
             $str = $params[$file . '_message'];
             $str = $file == 'html' ? str_replace('%7B', '{', str_replace('%7D', '}', $str)) : $str;
             $name = $file . ' message';
         }
         /* append header/footer */
         $str = $header[$file . 'File'] . $str . $footer[$file . 'File'];
         $dataErrors = array();
         /* First look for missing tokens */
         if (!CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check')) {
             $err = CRM_Utils_Token::requiredTokens($str);
             if ($err !== TRUE) {
                 foreach ($err as $token => $desc) {
                     $dataErrors[] = '<li>' . ts('This message is missing a required token - {%1}: %2', array(1 => $token, 2 => $desc)) . '</li>';
                 }
             }
         }
         /* Do a full token replacement on a dummy verp, the current
          * contact and domain, and the first organization. */
         // here we make a dummy mailing object so that we
         // can retrieve the tokens that we need to replace
         // so that we do get an invalid token error
         // this is qute hacky and I hope that there might
         // be a suggestion from someone on how to
         // make it a bit more elegant
         $dummy_mail = new CRM_Mailing_BAO_Mailing();
         $mess = "body_{$file}";
         $dummy_mail->{$mess} = $str;
         $tokens = $dummy_mail->getTokens();
         $str = CRM_Utils_Token::replaceSubscribeInviteTokens($str);
         $str = CRM_Utils_Token::replaceDomainTokens($str, $domain, NULL, $tokens[$file]);
         $str = CRM_Utils_Token::replaceMailingTokens($str, $mailing, NULL, $tokens[$file]);
         $str = CRM_Utils_Token::replaceOrgTokens($str, $org);
         $str = CRM_Utils_Token::replaceActionTokens($str, $verp, $urls, NULL, $tokens[$file]);
         $str = CRM_Utils_Token::replaceContactTokens($str, $contact, NULL, $tokens[$file]);
         $unmatched = CRM_Utils_Token::unmatchedTokens($str);
         if (!empty($unmatched) && 0) {
             foreach ($unmatched as $token) {
                 $dataErrors[] = '<li>' . ts('Invalid token code') . ' {' . $token . '}</li>';
             }
         }
         if (!empty($dataErrors)) {
             $errors[$file . 'File'] = ts('The following errors were detected in %1:', array(1 => $name)) . ' <ul>' . implode('', $dataErrors) . '</ul><br /><a href="' . CRM_Utils_System::docURL2('Sample CiviMail Messages', TRUE, NULL, NULL, NULL, "wiki") . '" target="_blank">' . ts('More information on required tokens...') . '</a>';
         }
     }
     $templateName = CRM_Core_BAO_MessageTemplate::getMessageTemplates();
     if (!empty($params['saveTemplate']) && in_array(CRM_Utils_Array::value('saveTemplateName', $params), $templateName)) {
         $errors['saveTemplate'] = ts('Duplicate Template Name.');
     }
     return empty($errors) ? TRUE : $errors;
 }
Пример #15
0
 function install($config)
 {
     echo '<link rel="stylesheet" type="text/css" href="template.css" />';
     echo '<div style="padding: 1em;"><h1>Installing CiviCRM...</h1>
           <p>I am now running through the installation steps (this should take a few minutes)<p/>
           <p>If you receive a fatal error, refresh this page to continue the installation</p>';
     flush();
     // Load the sapphire runtime
     echo '<br/>Building database schema and setup files...</div>';
     flush();
     // create database if does not exists
     $this->createDatabaseIfNotExists($config['mysql']['server'], $config['mysql']['username'], $config['mysql']['password'], $config['mysql']['database']);
     // Build database
     require_once 'civicrm.php';
     civicrm_main($config);
     // clean output
     @ob_clean();
     if (!$this->errors) {
         global $installType;
         echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
         echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
         echo '<head>';
         echo '<title>CiviCRM Installed</title>';
         echo '<link rel="stylesheet" type="text/css" href="template.css" />';
         echo '</head>';
         echo '<body>';
         echo '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
         echo '<ul>';
         $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', false, 'here');
         if (!function_exists('ts')) {
             $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
         }
         if ($installType == 'drupal') {
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/user/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             echo "<li>Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a target='_blank' href={$drupalPermissionsURL}>review these permissions</a> to ensure that they are appropriate for your requirements (<a target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'>learn more...</a>)</li>\n                      <li>Use the <a target='_blank' href=\"{$drupalURL}\">Configuration Checklist</a> to review and configure settings for your new site</li>";
             // explicitly setting error reporting, since we cannot handle drupal related notices
             error_reporting(1);
             // automatically enable CiviCRM module once it is installed successfully.
             // so we need to Bootstrap Drupal, so that we can call drupal hooks.
             global $cmsPath, $crmPath;
             // relative / abosolute paths are not working for drupal, hence using chdir()
             chdir($cmsPath);
             include_once "./includes/bootstrap.inc";
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             // rebuild modules, so that civicrm is added
             module_rebuild_cache();
             // now enable civicrm module.
             module_enable(array('civicrm'));
             // clear block and page cache, to make sure civicrm link is present in navigation block
             cache_clear_all();
             //add basic drupal permissions
             db_query('UPDATE {permission} SET perm = CONCAT( perm, \', access CiviMail subscribe/unsubscribe pages, access all custom data, access uploaded files, make online contributions, profile listings and forms, register for events, view event info, view event participants\') WHERE rid IN (1, 2)');
         } elseif ($installType == 'standalone') {
             $standaloneURL = civicrm_cms_base() . 'standalone/index.php';
             $checkListURL = $standaloneURL . "?q=civicrm/admin/configtask&reset=1";
             echo "<li>Click <a target=\"_blank\" href=\"{$standaloneURL}\">here</a> to go to your CiviCRM Standalone home page.</li>";
         }
         echo '</ul>';
         echo '</div>';
         echo '</body>';
         echo '</html>';
     }
     return $this->errors;
 }
Пример #16
0
 static function errorMessage($mailer, $result)
 {
     $message = '<p>' . ts('An error occurred when CiviCRM attempted to send an email (via %1). If you received this error after submitting on online contribution or event registration - the transaction was completed, but we were unable to send the email receipt.', array(1 => 'SMTP')) . '</p>' . '<p>' . ts('The mail library returned the following error message:') . '<br /><span class="font-red"><strong>' . $result->getMessage() . '</strong></span></p>' . '<p>' . ts('This is probably related to a problem in your Outbound Email Settings (Administer CiviCRM &raquo; System Settings &raquo; Outbound Email), OR the FROM email address specifically configured for your contribution page or event. Possible causes are:') . '</p>';
     if (is_a($mailer, 'Mail_smtp')) {
         $message .= '<ul>' . '<li>' . ts('Your SMTP Username or Password are incorrect.') . '</li>' . '<li>' . ts('Your SMTP Server (machine) name is incorrect.') . '</li>' . '<li>' . ts('You need to use a Port other than the default port 25 in your environment.') . '</li>' . '<li>' . ts('Your SMTP server is just not responding right now (it is down for some reason).') . '</li>';
     } else {
         $message .= '<ul>' . '<li>' . ts('Your Sendmail path is incorrect.') . '</li>' . '<li>' . ts('Your Sendmail argument is incorrect.') . '</li>';
     }
     $message .= '<li>' . ts('The FROM Email Address configured for this feature may not be a valid sender based on your email service provider rules.') . '</li>' . '</ul>' . '<p>' . ts('Check <a href="%1">this page</a> for more information.', array(1 => CRM_Utils_System::docURL2('user/initial-set-up/email-system-configuration', TRUE))) . '</p>';
     return $message;
 }
Пример #17
0
    function handle( $config ) {
        
        // Get the function name being called from the q parameter in the query string
        $q = CRM_Utils_array::value( 'q', $_REQUEST );
        $args = explode( '/', $q );
        // If the function isn't in the civicrm namespace, reject the request.
        if ( $args[0] != 'civicrm' ) {
            return self::error( 'Unknown function invocation.' );
        }

        // If the query string is malformed, reject the request.
        if ( ( count( $args ) != 3 ) && ( $args[1] != 'login' ) && ( $args[1] != 'ping') ) {
            return self::error( 'Unknown function invocation.' );
        }

        // Everyone should be required to provide the server key, so the whole 
        //  interface can be disabled in more change to the configuration file.
        //  This used to be done in the authenticate function, but that was bad...trust me
        // first check for civicrm site key
        if ( ! CRM_Utils_System::authenticateKey( false ) ) {
            $docLink = CRM_Utils_System::docURL2( "Command-line Script Configuration", true );
            return self::error( 'Could not authenticate user, invalid site key. More info at: ' . $docLink );
        }
	
        require_once 'CRM/Utils/Request.php';

        $store = null;
        if ( $args[1] == 'login' ) {
            $name = CRM_Utils_Request::retrieve( 'name', 'String', $store, false, null, 'REQUEST' );
            $pass = CRM_Utils_Request::retrieve( 'pass', 'String', $store, false, null, 'REQUEST' );
            if ( empty( $name ) ||
                 empty( $pass ) ) {
                return self::error( 'Invalid name / password.' );
            }
            return self::authenticate( $name, $pass );
        } else if ($args[1] == 'ping' ) {
            return self::ping();
        }
	
        // At this point we know we are not calling either login or ping (neither of which 
        //  require authentication prior to being called.  Therefore, at this point we need
        //  to make sure we're working with a trusted user.
	
        // There are two ways to check for a trusted user:
        //  First: they can be someone that has a valid session currently
        //  Second: they can be someone that has provided an API_Key
	
        $valid_user = false;

        // Check for valid session.  Session ID's only appear here if you have
        // run the rest_api login function.  That might be a problem for the 
        // AJAX methods.  
        $session = CRM_Core_Session::singleton();
        if ($session->get('PHPSESSID') ) {
            $valid_user = true;
        }
	
        // If the user does not have a valid session (most likely to be used by people using
        // an ajax interface), we need to check to see if they are carring a valid user's 
        // secret key.
        if ( !$valid_user ) {
            require_once 'CRM/Core/DAO.php';
            $api_key = CRM_Utils_Request::retrieve( 'api_key', 'String', $store, false, null, 'REQUEST' );
            $valid_user = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
        }
	
        // If we didn't find a valid user either way, then die.
        if ( empty($valid_user) ) {
            return self::error("Valid session, or user api_key required");
        }

        return self::process( $args );
    }
Пример #18
0
 function run()
 {
     // lets get around the time limit issue if possible for upgrades
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
     }
     $latestVer = CRM_Utils_System::version();
     $currentVer = CRM_Core_BAO_Domain::version();
     if (!$currentVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
     } else {
         if (stripos($currentVer, 'upgrade')) {
             CRM_Core_Error::fatal(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
         }
     }
     if (!$latestVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm codebase.'));
     }
     // hack to make past ver compatible /w new incremental upgrade process
     $convertVer = array('2.1' => '2.1.0', '2.2' => '2.2.alpha1', '2.2.alph' => '2.2.alpha3', '3.1.0' => '3.1.1');
     if (isset($convertVer[$currentVer])) {
         $currentVer = $convertVer[$currentVer];
     }
     // since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
     // lets do a pattern check -
     if (!CRM_Utils_System::isVersionFormatValid($currentVer)) {
         CRM_Core_Error::fatal(ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.'));
     }
     // This could be removed in later rev
     if ($currentVer == '2.1.6') {
         $config = CRM_Core_Config::singleton();
         // also cleanup the templates_c directory
         $config->cleanup(1, false);
         if ($config->userFramework !== 'Standalone') {
             // clean the session
             $session = CRM_Core_Session::singleton();
             $session->reset(2);
         }
     }
     // end of hack
     CRM_Utils_System::setTitle(ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $upgrade = new CRM_Upgrade_Form();
     $template = CRM_Core_Smarty::singleton();
     $template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1'));
     $template->assign('cancelURL', CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     if (version_compare($currentVer, $latestVer) > 0) {
         // DB version number is higher than codebase being upgraded to. This is unexpected condition-fatal error.
         $dbToolsLink = CRM_Utils_System::docURL2("Database Troubleshooting Tools", true);
         $error = ts('Your database is marked with an unexpected version number: %1. The automated upgrade to version %2 can not be run - and the %2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. The database tools utility at %3 may be helpful. You may want to revert to the codebase you were using prior to beginning this upgrade until you resolve this problem.', array(1 => $currentVer, 2 => $latestVer, 3 => $dbToolsLink));
         CRM_Core_Error::fatal($error);
     } else {
         if (version_compare($currentVer, $latestVer) == 0) {
             $message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $latestVer));
             $template->assign('upgraded', true);
         } else {
             $message = ts('CiviCRM upgrade was successful.');
             if ($latestVer == '3.2.alpha1') {
                 $message .= '<br />' . ts("We have reset the COUNTED flag to false for the event participant status 'Pending from incomplete transaction'. This change ensures that people who have a problem during registration can try again.");
             } else {
                 if ($latestVer == '3.2.beta3' && version_compare($currentVer, '3.1.alpha1') >= 0) {
                     require_once 'CRM/Contact/BAO/ContactType.php';
                     $subTypes = CRM_Contact_BAO_ContactType::subTypes();
                     if (is_array($subTypes) && !empty($subTypes)) {
                         $config = CRM_Core_Config::singleton();
                         $subTypeTemplates = array();
                         if (isset($config->customTemplateDir)) {
                             foreach ($subTypes as $key => $subTypeName) {
                                 $customContactSubTypeEdit = $config->customTemplateDir . "CRM/Contact/Form/Edit/" . $subTypeName . ".tpl";
                                 $customContactSubTypeView = $config->customTemplateDir . "CRM/Contact/Page/View/" . $subTypeName . ".tpl";
                                 if (file_exists($customContactSubTypeEdit) || file_exists($customContactSubTypeView)) {
                                     $subTypeTemplates[$subTypeName] = $subTypeName;
                                 }
                             }
                         }
                         foreach ($subTypes as $key => $subTypeName) {
                             $customContactSubTypeEdit = $config->templateDir . "CRM/Contact/Form/Edit/" . $subTypeName . ".tpl";
                             $customContactSubTypeView = $config->templateDir . "CRM/Contact/Page/View/" . $subTypeName . ".tpl";
                             if (file_exists($customContactSubTypeEdit) || file_exists($customContactSubTypeView)) {
                                 $subTypeTemplates[$subTypeName] = $subTypeName;
                             }
                         }
                         if (!empty($subTypeTemplates)) {
                             $subTypeTemplates = implode(',', $subTypeTemplates);
                             $message .= '<br />' . ts('You are using custom template for contact subtypes: %1.', array(1 => $subTypeTemplates)) . '<br />' . ts('You need to move these subtype templates to the SubType directory in %1 and %2 respectively.', array(1 => 'CRM/Contact/Form/Edit', 2 => 'CRM/Contact/Page/View'));
                         }
                     }
                 } else {
                     if ($latestVer == '3.2.beta4') {
                         $statuses = array('New', 'Current', 'Grace', 'Expired', 'Pending', 'Cancelled', 'Deceased');
                         $sql = "\nSELECT  count( id ) as statusCount \n  FROM  civicrm_membership_status \n WHERE  name IN ( '" . implode("' , '", $statuses) . "' ) ";
                         $count = CRM_Core_DAO::singleValueQuery($sql);
                         if ($count < count($statuses)) {
                             $message .= '<br />' . ts("One or more Membership Status Rules was disabled during the upgrade because it did not match a recognized status name. if custom membership status rules were added to this site - review the disabled statuses and re-enable any that are still needed (Administer > CiviMember > Membership Status Rules).");
                         }
                     }
                 }
             }
             $template->assign('currentVersion', $currentVer);
             $template->assign('newVersion', $latestVer);
             $template->assign('upgradeTitle', ts('Upgrade CiviCRM from v %1 To v %2', array(1 => $currentVer, 2 => $latestVer)));
             $template->assign('upgraded', false);
             if (CRM_Utils_Array::value('upgrade', $_POST)) {
                 $revisions = $upgrade->getRevisionSequence();
                 foreach ($revisions as $rev) {
                     // proceed only if $currentVer < $rev
                     if (version_compare($currentVer, $rev) < 0) {
                         // as soon as we start doing anything we append ".upgrade" to version.
                         // this also helps detect any partial upgrade issues
                         $upgrade->setVersion($rev . '.upgrade');
                         $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev);
                         // follow old upgrade process for all version
                         // below 3.2.alpha1
                         if (version_compare($rev, '3.2.alpha1') < 0) {
                             if (is_callable(array($this, $phpFunctionName))) {
                                 eval("\$this->{$phpFunctionName}('{$rev}');");
                             } else {
                                 $upgrade->processSQL($rev);
                             }
                         } else {
                             // new upgrade process from version
                             // 3.2.alpha1
                             $versionObject = $upgrade->incrementalPhpObject($rev);
                             // predb check for major release.
                             if ($upgrade->checkVersionRelease($rev, 'alpha1')) {
                                 if (!is_callable(array($versionObject, 'verifyPreDBstate'))) {
                                     CRM_Core_Error::fatal("verifyPreDBstate method was not found for {$rev}");
                                 }
                                 $error = null;
                                 if (!$versionObject->verifyPreDBstate($error)) {
                                     if (!isset($error)) {
                                         $error = "post-condition failed for current upgrade for {$rev}";
                                     }
                                     CRM_Core_Error::fatal($error);
                                 }
                             }
                             if (is_callable(array($versionObject, $phpFunctionName))) {
                                 $versionObject->{$phpFunctionName}($rev);
                             } else {
                                 $upgrade->processSQL($rev);
                             }
                         }
                         // after an successful intermediate upgrade, set the complete version
                         $upgrade->setVersion($rev);
                     }
                 }
                 $upgrade->setVersion($latestVer);
                 $template->assign('upgraded', true);
                 // also cleanup the templates_c directory
                 $config = CRM_Core_Config::singleton();
                 $config->cleanup(1, false);
                 // clear db caching
                 $config->clearDBCache();
                 // clear temporary tables
                 $config->clearTempTables();
                 // clean the session. Note: In case of standalone this makes the user logout.
                 // So skip this step for standalone.
                 if ($config->userFramework !== 'Standalone') {
                     $session = CRM_Core_Session::singleton();
                     $session->reset(2);
                 }
             }
         }
     }
     $template->assign('message', $message);
     $content = $template->fetch('CRM/common/success.tpl');
     echo CRM_Utils_System::theme('page', $content, true, $this->_print, false, true);
 }
Пример #19
0
 /**
  * create a directory given a path name, creates parent directories
  * if needed
  * 
  * @param string $path  the path name
  * @param boolean $abort should we abort or just return an invalid code
  *
  * @return void
  * @access public
  * @static
  */
 function createDir($path, $abort = true)
 {
     if (is_dir($path) || empty($path)) {
         return;
     }
     CRM_Utils_File::createDir(dirname($path), $abort);
     if (@mkdir($path, 0777) == false) {
         if ($abort) {
             $docLink = CRM_Utils_System::docURL2('Moving an Existing Installation to a New Server or Location', false, 'Moving an Existing Installation to a New Server or Location');
             echo "Error: Could not create directory: {$path}.<p>If you have moved an existing CiviCRM installation from one location or server to another there are several steps you will need to follow. They are detailed on this CiviCRM wiki page - {$docLink}. A fix for the specific problem that caused this error message to be displayed is to set the value of the config_backend column in the civicrm_domain table to NULL. However we strongly recommend that you review and follow all the steps in that document.</p>";
             exit;
         } else {
             return false;
         }
     }
     return true;
 }
 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($fields)
 {
     $errors = array();
     // Validate include/exclude groups, mailings
     // Start
     if (isset($fields['includeGroups']) && isset($fields['excludeGroups']) && is_array($fields['excludeGroups'])) {
         $checkGroups = array();
         $checkGroups = in_array($fields['includeGroups'], $fields['excludeGroups']);
         if (!empty($checkGroups)) {
             $errors['excludeGroups'] = ts('Cannot have same groups in Include Group(s) and Exclude Group(s).');
         }
     }
     if (isset($fields['includeMailings']) && is_array($fields['includeMailings']) && isset($fields['excludeMailings']) && is_array($fields['excludeMailings'])) {
         $checkMailings = array();
         $checkMailings = array_intersect($fields['includeMailings'], $fields['excludeMailings']);
         if (!empty($checkMailings)) {
             $errors['excludeMailings'] = ts('Cannot have same mail in Include mailing(s) and Exclude mailing(s).');
         }
     }
     if (!empty($fields['search_id']) && empty($fields['group_id'])) {
         $errors['group_id'] = ts('You must select a group to filter on');
     }
     if (empty($fields['search_id']) && !empty($fields['group_id'])) {
         $errors['search_id'] = ts('You must select a search to filter');
     }
     // End
     // Validate message template html/text
     // Start
     $errors = array();
     $template = CRM_Core_Smarty::singleton();
     if (isset($fields['html_message'])) {
         $htmlMessage = str_replace(array("\n", "\r"), ' ', $fields['html_message']);
         $htmlMessage = str_replace("'", "\\'", $htmlMessage);
         $template->assign('htmlContent', $htmlMessage);
     }
     $domain = CRM_Core_BAO_Domain::getDomain();
     $session = CRM_Core_Session::singleton();
     $values = array('contact_id' => $session->get('userID'), 'version' => 3);
     require_once 'api/api.php';
     $contact = civicrm_api('contact', 'get', $values);
     //CRM-4524
     $contact = reset($contact['values']);
     $verp = array_flip(array('optOut', 'reply', 'unsubscribe', 'resubscribe', 'owner'));
     foreach ($verp as $key => $value) {
         $verp[$key]++;
     }
     $urls = array_flip(array('forward', 'optOutUrl', 'unsubscribeUrl', 'resubscribeUrl'));
     foreach ($urls as $key => $value) {
         $urls[$key]++;
     }
     // set $header and $footer
     foreach (array('header', 'footer') as $part) {
         ${$part} = array();
         if ($fields["{$part}_id"]) {
             //echo "found<p>";
             $component = new CRM_Mailing_BAO_Component();
             $component->id = $fields["{$part}_id"];
             $component->find(TRUE);
             ${$part}['textFile'] = $component->body_text;
             ${$part}['htmlFile'] = $component->body_html;
             $component->free();
         } else {
             ${$part}['htmlFile'] = ${$part}['textFile'] = '';
         }
     }
     if (!CRM_Utils_Array::value('text_message', $fields) && !CRM_Utils_Array::value('html_message', $fields)) {
         $errors['html_message'] = ts('Please provide either a Text or HTML formatted message - or both.');
     }
     foreach (array('text', 'html') as $file) {
         $str = $fields[$file . '_message'];
         $str = $file == 'html' ? str_replace('%7B', '{', str_replace('%7D', '}', $str)) : $str;
         $name = $file . ' message';
         /* append header/footer */
         $str = $header[$file . 'File'] . $str . $footer[$file . 'File'];
         $dataErrors = array();
         /* First look for missing tokens */
         $err = CRM_Utils_Token::requiredTokens($str);
         if ($err !== TRUE) {
             foreach ($err as $token => $desc) {
                 $dataErrors[] = '<li>' . ts('This message is missing a required token - {%1}: %2', array(1 => $token, 2 => $desc)) . '</li>';
             }
         }
         /* Do a full token replacement on a dummy verp, the current
          * contact and domain, and the first organization. */
         // here we make a dummy mailing object so that we
         // can retrieve the tokens that we need to replace
         // so that we do get an invalid token error
         // this is qute hacky and I hope that there might
         // be a suggestion from someone on how to
         // make it a bit more elegant
         $dummy_mail = new CRM_Mailing_BAO_Mailing();
         $mess = "body_{$file}";
         $dummy_mail->{$mess} = $str;
         $tokens = $dummy_mail->getTokens();
         $str = CRM_Utils_Token::replaceSubscribeInviteTokens($str);
         $str = CRM_Utils_Token::replaceDomainTokens($str, $domain, NULL, $tokens[$file]);
         $str = CRM_Utils_Token::replaceMailingTokens($str, $mailing, NULL, $tokens[$file]);
         $str = CRM_Utils_Token::replaceOrgTokens($str, $org);
         $str = CRM_Utils_Token::replaceActionTokens($str, $verp, $urls, NULL, $tokens[$file]);
         $str = CRM_Utils_Token::replaceContactTokens($str, $contact, NULL, $tokens[$file]);
         $unmatched = CRM_Utils_Token::unmatchedTokens($str);
         if (!empty($unmatched) && 0) {
             foreach ($unmatched as $token) {
                 $dataErrors[] = '<li>' . ts('Invalid token code') . ' {' . $token . '}</li>';
             }
         }
         if (!empty($dataErrors)) {
             $errors[$file . '_message'] = ts('The following errors were detected in %1:', array(1 => $name)) . ' <ul>' . implode('', $dataErrors) . '</ul><br /><a href="' . CRM_Utils_System::docURL2('Sample CiviMail Messages', TRUE, NULL, NULL, NULL, "wiki") . '" target="_blank">' . ts('More information on required tokens...') . '</a>';
         }
     }
     // End
     return empty($errors) ? TRUE : $errors;
 }
Пример #21
0
 /**
  * Validation.
  *
  * @param array $params
  *   (ref.) an assoc array of name/value pairs.
  *
  * @param $files
  * @param $options
  *
  * @return bool|array
  *   mixed true or array of errors
  */
 public static function dataRule($params, $files, $options)
 {
     if ($params['component_type'] == 'Header' || $params['component_type'] == 'Footer') {
         $InvalidTokens = array();
     } else {
         $InvalidTokens = array('action.forward' => ts("This token can only be used in send mailing context (body, header, footer).."));
     }
     $errors = array();
     foreach (array('text', 'html') as $type) {
         $dataErrors = array();
         foreach ($InvalidTokens as $token => $desc) {
             if ($params['body_' . $type]) {
                 if (preg_match('/' . preg_quote('{' . $token . '}') . '/', $params['body_' . $type])) {
                     $dataErrors[] = '<li>' . ts('This message is having a invalid token - %1: %2', array(1 => $token, 2 => $desc)) . '</li>';
                 }
             }
         }
         if (!empty($dataErrors)) {
             $errors['body_' . $type] = ts('The following errors were detected in %1 message:', array(1 => $type)) . '<ul>' . implode('', $dataErrors) . '</ul><br /><a href="' . CRM_Utils_System::docURL2('Tokens', TRUE, NULL, NULL, NULL, "wiki") . '">' . ts('More information on tokens...') . '</a>';
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
Пример #22
0
 /**
  * @param $activityTypeXML
  * @param array $params
  *
  * @return bool
  * @throws CRM_Core_Exception
  * @throws Exception
  */
 public function createActivity($activityTypeXML, &$params)
 {
     $activityTypeName = (string) $activityTypeXML->name;
     $activityTypes =& $this->allActivityTypes(TRUE, TRUE);
     $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $activityTypes);
     if (!$activityTypeInfo) {
         $docLink = CRM_Utils_System::docURL2("user/case-management/setup");
         CRM_Core_Error::fatal(ts('Activity type %1, found in case configuration file, is not present in the database %2', array(1 => $activityTypeName, 2 => $docLink)));
         return FALSE;
     }
     $activityTypeID = $activityTypeInfo['id'];
     if (isset($activityTypeXML->status)) {
         $statusName = (string) $activityTypeXML->status;
     } else {
         $statusName = 'Scheduled';
     }
     if ($this->_isMultiClient) {
         $client = $params['clientID'];
     } else {
         $client = array(1 => $params['clientID']);
     }
     //set order
     $orderVal = '';
     if (isset($activityTypeXML->order)) {
         $orderVal = (string) $activityTypeXML->order;
     }
     if ($activityTypeName == 'Open Case') {
         $activityParams = array('activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => FALSE, 'is_current_revision' => 1, 'subject' => CRM_Utils_Array::value('subject', $params) ? $params['subject'] : $activityTypeName, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', $statusName, 'name'), 'target_contact_id' => $client, 'medium_id' => CRM_Utils_Array::value('medium_id', $params), 'location' => CRM_Utils_Array::value('location', $params), 'details' => CRM_Utils_Array::value('details', $params), 'duration' => CRM_Utils_Array::value('duration', $params), 'weight' => $orderVal);
     } else {
         $activityParams = array('activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => TRUE, 'is_current_revision' => 1, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', $statusName, 'name'), 'target_contact_id' => $client, 'weight' => $orderVal);
     }
     //parsing date to default preference format
     $params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time']);
     if ($activityTypeName == 'Open Case') {
         // we don't set activity_date_time for auto generated
         // activities, but we want it to be set for open case.
         $activityParams['activity_date_time'] = $params['activity_date_time'];
         if (array_key_exists('custom', $params) && is_array($params['custom'])) {
             $activityParams['custom'] = $params['custom'];
         }
         // Add parameters for attachments
         $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
         for ($i = 1; $i <= $numAttachments; $i++) {
             $attachName = "attachFile_{$i}";
             if (isset($params[$attachName]) && !empty($params[$attachName])) {
                 $activityParams[$attachName] = $params[$attachName];
             }
         }
     } else {
         $activityDate = NULL;
         //get date of reference activity if set.
         if ($referenceActivityName = (string) $activityTypeXML->reference_activity) {
             //we skip open case as reference activity.CRM-4374.
             if (!empty($params['resetTimeline']) && $referenceActivityName == 'Open Case') {
                 $activityDate = $params['activity_date_time'];
             } else {
                 $referenceActivityInfo = CRM_Utils_Array::value($referenceActivityName, $activityTypes);
                 if ($referenceActivityInfo['id']) {
                     $caseActivityParams = array('activity_type_id' => $referenceActivityInfo['id']);
                     //if reference_select is set take according activity.
                     if ($referenceSelect = (string) $activityTypeXML->reference_select) {
                         $caseActivityParams[$referenceSelect] = 1;
                     }
                     $referenceActivity = CRM_Case_BAO_Case::getCaseActivityDates($params['caseID'], $caseActivityParams, TRUE);
                     if (is_array($referenceActivity)) {
                         foreach ($referenceActivity as $aId => $details) {
                             $activityDate = CRM_Utils_Array::value('activity_date', $details);
                             break;
                         }
                     }
                 }
             }
         }
         if (!$activityDate) {
             $activityDate = $params['activity_date_time'];
         }
         list($activity_date, $activity_time) = CRM_Utils_Date::setDateDefaults($activityDate);
         $activityDateTime = CRM_Utils_Date::processDate($activity_date, $activity_time);
         //add reference offset to date.
         if ((int) $activityTypeXML->reference_offset) {
             $activityDateTime = CRM_Utils_Date::intervalAdd('day', (int) $activityTypeXML->reference_offset, $activityDateTime);
         }
         $activityParams['activity_date_time'] = CRM_Utils_Date::format($activityDateTime);
     }
     // if same activity is already there, skip and dont touch
     $params['activityTypeID'] = $activityTypeID;
     $params['activityTypeName'] = $activityTypeName;
     if ($this->isActivityPresent($params)) {
         return TRUE;
     }
     $activityParams['case_id'] = $params['caseID'];
     if (!empty($activityParams['is_auto'])) {
         $activityParams['skipRecentView'] = TRUE;
     }
     $activity = CRM_Activity_BAO_Activity::create($activityParams);
     if (!$activity) {
         CRM_Core_Error::fatal();
         return FALSE;
     }
     // create case activity record
     $caseParams = array('activity_id' => $activity->id, 'case_id' => $params['caseID']);
     CRM_Case_BAO_Case::processCaseActivity($caseParams);
     return TRUE;
 }
Пример #23
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_Job');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_Job::del($this->_id);
         CRM_Core_Session::setStatus("", ts('Scheduled Job Deleted.'), "success");
         return;
     }
     $values = $this->controller->exportValues($this->_name);
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     $dao->run_frequency = $values['run_frequency'];
     $dao->parameters = $values['parameters'];
     $dao->name = $values['name'];
     $dao->api_entity = $values['api_entity'];
     $dao->api_action = $values['api_action'];
     $dao->description = $values['description'];
     $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
     $dao->save();
     /************************************
      * begin com.klangsoft.flexiblejobs *
      ************************************/
     $ts = strtotime(trim("{$values['schedule_at']} {$values['schedule_at_time']}"));
     if ($ts < time()) {
         $ts = NULL;
     } else {
         // warn about monthly/quarterly scheduling, if applicable
         if ($dao->run_frequency == 'Monthly' || $dao->run_frequency == 'Quarter') {
             $info = getdate($ts);
             if ($info['mday'] > 28) {
                 CRM_Core_Session::setStatus(ts('Relative month values are calculated based on the length of month(s) that they pass through.
           The result will land on the same day of the month except for days 29-31 when the target month contains fewer days than the previous month.
           For example, if a job is scheduled to run on August 31st, the following invocation will occur on October 1st, and then the 1st of every month thereafter.
           To avoid this issue, please schedule Monthly and Quarterly jobs to run within the first 28 days of the month.'), ts('Warning'), 'info', array('expires' => 0));
             }
         }
     }
     CRM_Core_BAO_Setting::setItem($ts ?: NULL, 'com.klangsoft.flexiblejobs', 'job_' . $dao->id);
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
     // CRM-11143 - Give warning message if update_greetings is Enabled (is_active) since it generally should not be run automatically via execute action or runjobs url.
     if ($values['api_action'] == 'update_greeting' && CRM_Utils_Array::value('is_active', $values) == 1) {
         // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
         $msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', array(1 => $docLink));
         CRM_Core_Session::setStatus($msg, ts('Warning: Update Greeting job enabled'), 'alert');
     }
 }
Пример #24
0
 static function formRule($fields)
 {
     $errors = array();
     require_once 'api/api.php';
     $apiRequest = array();
     $apiRequest['entity'] = CRM_Utils_String::munge($fields['api_entity']);
     $apiRequest['action'] = CRM_Utils_String::munge($fields['api_action']);
     $apiRequest['version'] = substr($fields['api_prefix'], -1);
     // ie. civicrm_api3
     $apiRequest += _civicrm_api_resolve($apiRequest);
     // look up function, file, is_generic
     if (!$apiRequest['function']) {
         $errors['api_action'] = ts('Given API command is not defined.');
     }
     // CRM-9868- don't allow Enabled (is_active) for jobs that should never be run automatically via execute action or runjobs url
     if (($fields['api_action'] == 'process_membership_reminder_date' || $fields['api_action'] == 'update_greeting') && CRM_Utils_Array::value('is_active', $fields) == 1) {
         // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
         $errors['is_active'] = ts('You can not save this Scheduled Job as Active with the specified api action (%2). That action should not be run regularly - it should only be run manually for special conditions. %1', array(1 => $docLink, 2 => $fields['api_action']));
     }
     if (!empty($errors)) {
         return $errors;
     }
     return empty($errors) ? TRUE : $errors;
 }
Пример #25
0
 function install($config)
 {
     global $installDirPath;
     // create database if does not exists
     $this->createDatabaseIfNotExists($config['mysql']['server'], $config['mysql']['username'], $config['mysql']['password'], $config['mysql']['database']);
     global $installDirPath;
     // Build database
     require_once $installDirPath . 'civicrm.php';
     civicrm_main($config);
     if (!$this->errors) {
         global $installType, $installURLPath;
         $output = NULL;
         if ($installType == 'drupal' && version_compare(VERSION, '7.0-rc1') >= 0) {
             // clean output
             @ob_clean();
             $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
             $output .= '<head>';
             $output .= '<title>CiviCRM Installed</title>';
             $output .= '<link rel="stylesheet" type="text/css" href="template.css" />';
             $output .= '</head>';
             $output .= '<body>';
             $output .= '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
             $output .= '<ul>';
             $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
             if (!function_exists('ts')) {
                 $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
             }
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/people/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
             $output .= "<li>Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a target='_blank' href={$drupalPermissionsURL}>review these permissions</a> to ensure that they are appropriate for your requirements (<a target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'>learn more...</a>)</li>\n                      <li>Use the <a target='_blank' href=\"{$drupalURL}\">Configuration Checklist</a> to review and configure settings for your new site</li>\n                      <li> Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='{$registerSiteURL}' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>\n                      <li>We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.</li>";
             // automatically enable CiviCRM module once it is installed successfully.
             // so we need to Bootstrap Drupal, so that we can call drupal hooks.
             global $cmsPath, $crmPath;
             // relative / abosolute paths are not working for drupal, hence using chdir()
             chdir($cmsPath);
             include_once "./includes/bootstrap.inc";
             include_once "./includes/unicode.inc";
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             // prevent session information from being saved.
             drupal_save_session(FALSE);
             // Force the current user to anonymous.
             $original_user = $GLOBALS['user'];
             $GLOBALS['user'] = drupal_anonymous_user();
             // explicitly setting error reporting, since we cannot handle drupal related notices
             error_reporting(1);
             // rebuild modules, so that civicrm is added
             system_rebuild_module_data();
             // now enable civicrm module.
             module_enable(array('civicrm', 'civicrmtheme'));
             // clear block and page cache, to make sure civicrm link is present in navigation block
             cache_clear_all();
             //add basic drupal permissions
             civicrm_install_set_drupal_perms();
             // restore the user.
             $GLOBALS['user'] = $original_user;
             drupal_save_session(TRUE);
             $output .= '</ul>';
             $output .= '</div>';
             $output .= '</body>';
             $output .= '</html>';
             echo $output;
         } elseif ($installType == 'drupal' && version_compare(VERSION, '6.0') >= 0) {
             // clean output
             @ob_clean();
             $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
             $output .= '<head>';
             $output .= '<title>CiviCRM Installed</title>';
             $output .= '<link rel="stylesheet" type="text/css" href="template.css" />';
             $output .= '</head>';
             $output .= '<body>';
             $output .= '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
             $output .= '<ul>';
             $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
             if (!function_exists('ts')) {
                 $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
             }
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/user/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
             $output .= "<li>Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a target='_blank' href={$drupalPermissionsURL}>review these permissions</a> to ensure that they are appropriate for your requirements (<a target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'>learn more...</a>)</li>\n                      <li>Use the <a target='_blank' href=\"{$drupalURL}\">Configuration Checklist</a> to review and configure settings for your new site</li>\n                      <li> Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='{$registerSiteURL}' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>\n                      <li>We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.</li>";
             // explicitly setting error reporting, since we cannot handle drupal related notices
             error_reporting(1);
             // automatically enable CiviCRM module once it is installed successfully.
             // so we need to Bootstrap Drupal, so that we can call drupal hooks.
             global $cmsPath, $crmPath;
             // relative / abosolute paths are not working for drupal, hence using chdir()
             chdir($cmsPath);
             include_once "./includes/bootstrap.inc";
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             // rebuild modules, so that civicrm is added
             module_rebuild_cache();
             // now enable civicrm module.
             module_enable(array('civicrm'));
             // clear block and page cache, to make sure civicrm link is present in navigation block
             cache_clear_all();
             //add basic drupal permissions
             db_query('UPDATE {permission} SET perm = CONCAT( perm, \', access CiviMail subscribe/unsubscribe pages, access all custom data, access uploaded files, make online contributions, profile create, profile edit, profile view, register for events, view event info\') WHERE rid IN (1, 2)');
             echo $output;
         } elseif ($installType == 'wordpress') {
             echo '<h1>CiviCRM Installed</h1>';
             echo '<div style="padding: 1em;"><p style="background-color: #0C0; border: 1px #070 solid; color: white;">CiviCRM has been successfully installed</p>';
             echo '<ul>';
             $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
             if (!function_exists('ts')) {
                 $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
             }
             $cmsURL = civicrm_cms_base();
             $cmsURL .= "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/configtask&reset=1";
             $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
             echo "<li>Use the <a target='_blank' href=\"{$cmsURL}\">Configuration Checklist</a> to review and configure settings for your new site</li>\n                    <li> Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='{$registerSiteURL}' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>\n                    <li>We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.</li>";
             echo '</ul>';
             echo '</div>';
         }
     }
     return $this->errors;
 }
Пример #26
0
 /**
  * Compute any messages which should be displayed beforeupgrade.
  *
  * Note: This function is called iteratively for each upcoming
  * revision to the database.
  *
  * @param $preUpgradeMessage
  * @param string $rev
  *   a version number, e.g. '4.2.alpha1', '4.2.beta3', '4.2.0'.
  * @param null $currentVer
  *
  * @return void
  */
 public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL)
 {
     if ($rev == '4.2.alpha1') {
         $tables = array('civicrm_contribution_page', 'civicrm_event', 'civicrm_group', 'civicrm_contact');
         if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)) {
             $errors = ts("The upgrade has identified some schema integrity issues in the database. It seems some of your constraints are missing. You will have to rebuild your schema before re-trying the upgrade. Please refer to %1.", array(1 => CRM_Utils_System::docURL2("Ensuring Schema Integrity on Upgrades", FALSE, "Ensuring Schema Integrity on Upgrades", NULL, NULL, "wiki")));
             CRM_Core_Error::fatal($errors);
             return FALSE;
         }
         // CRM-10613, CRM-11120
         $query = "\nSELECT mp.contribution_id, mp.membership_id, mem.membership_type_id, mem.start_date, mem.end_date, mem.status_id, mem.contact_id\nFROM civicrm_membership_payment mp\nINNER JOIN ( SELECT cmp.contribution_id\n              FROM civicrm_membership_payment cmp\n              LEFT JOIN civicrm_line_item cli ON cmp.contribution_id=cli.entity_id and cli.entity_table = 'civicrm_contribution'\n              WHERE cli.entity_id IS NULL\n              GROUP BY cmp.contribution_id\n              HAVING COUNT(cmp.membership_id) > 1) submp ON submp.contribution_id = mp.contribution_id\nINNER JOIN civicrm_membership mem ON mem.id = mp.membership_id\nORDER BY mp.contribution_id, mp.membership_id";
         $invalidData = CRM_Core_DAO::executeQuery($query);
         if ($invalidData->N) {
             $invalidDataMessage = "<br /><strong>" . ts('The upgrade is being aborted due to data integrity issues in your database. There are multiple membership records linked to the same contribution record. This is unexpected, and some of the membership records may be duplicates. The problem record sets are listed below. Refer to <a href="%1">this wiki page for instructions on repairing your database</a> so that you can run the upgrade successfully.
     ', array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC42/Repair+database+script+for+4.2+upgrades')) . "</strong>";
             $membershipType = CRM_Member_PseudoConstant::membershipType();
             $membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
             $invalidDataMessage .= "<table border=1><tr><th>Contact-ID</th><th>Contribution-ID</th><th>Membership-ID</th><th>Membership Type</th><th>Start Date</th><th>End Date</th><th>Membership Status</th></tr>";
             while ($invalidData->fetch()) {
                 $invalidDataMessage .= "<tr>";
                 $invalidDataMessage .= "<td>{$invalidData->contact_id}</td>";
                 $invalidDataMessage .= "<td>{$invalidData->contribution_id}</td>";
                 $invalidDataMessage .= "<td>{$invalidData->membership_id}</td>";
                 $invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->membership_type_id, $membershipType) . "</td>";
                 $invalidDataMessage .= "<td>{$invalidData->start_date}</td>";
                 $invalidDataMessage .= "<td>{$invalidData->end_date}</td>";
                 $invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->status_id, $membershipStatus) . "</td>";
                 $invalidDataMessage .= "</tr>";
             }
             $invalidDataMessage .= "</table><p>" . ts('If you have reviewed the cleanup script documentation on the wiki and you are ready to run the cleanup now - <a href="%1">click here</a>.', array(1 => CRM_Utils_System::url('civicrm/upgrade/cleanup425', 'reset=1'))) . "</p>";
             CRM_Core_Error::fatal($invalidDataMessage);
             return FALSE;
         }
     }
     if ($rev == '4.2.beta2') {
         // note: error conditions are also checked in upgrade_4_2_beta2()
         if (!defined('CIVICRM_SETTINGS_PATH')) {
             $preUpgradeMessage .= '<br />' . ts('Could not determine path to civicrm.settings.php. Please manually locate it and add these lines at the bottom: <pre>%1</pre>', array(1 => self::SETTINGS_SNIPPET));
         } elseif (preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
             // OK, nothing to do
         } elseif (!is_writable(CIVICRM_SETTINGS_PATH)) {
             $preUpgradeMessage .= '<br />' . ts('The settings file (%1) must be updated. Please make it writable or manually add these lines:<pre>%2</pre>', array(1 => CIVICRM_SETTINGS_PATH, 2 => self::SETTINGS_SNIPPET));
         }
     }
     if ($rev == '4.2.2' && version_compare($currentVer, '3.3.alpha1') >= 0) {
         $query = " SELECT cli.id\nFROM `civicrm_line_item` cli\nINNER JOIN civicrm_membership_payment cmp ON cmp.contribution_id = cli.entity_id AND cli.entity_table = 'civicrm_contribution'\nINNER JOIN civicrm_price_field_value cpfv ON cpfv.id = cli.price_field_value_id\nINNER JOIN civicrm_price_field cpf ON cpf.id = cpfv.price_field_id and cpf.id != cli.price_field_id\nINNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'default_membership_type_amount' ";
         $dao = CRM_Core_DAO::executeQuery($query);
         if ($dao->N) {
             $preUpgradeMessage .= "<br /><strong>" . ts('We have identified extraneous data in your database that a previous upgrade likely introduced. We STRONGLY recommend making a backup of your site before continuing. We also STRONGLY suggest fixing this issue with unneeded records BEFORE you upgrade. You can find more information about this issue and the way to fix it by visiting <a href="http://forum.civicrm.org/index.php/topic,26181.0.html">http://forum.civicrm.org/index.php/topic,26181.0.html</a>.') . "</strong>";
         }
     }
     if (version_compare($rev, '4.2.9') >= 0) {
         //CRM-11980
         $sql = "SELECT id FROM civicrm_option_group WHERE name LIKE 'civicrm_price_field.amount.%' LIMIT 1";
         $dao = CRM_Core_DAO::executeQuery($sql);
         if ($dao->fetch()) {
             $errors = ts("We found unexpected data values from an older version of CiviCRM in your database. The upgrade can not be run until this condition is corrected.<br /><br />Details: One or more rows are present in the civicrm_option_group with name like 'civicrm_price_field.amount.%'. <a href='%1'>Check here for information on diagnosing and correcting this problem.</a>", array(1 => 'http://forum.civicrm.org/index.php/topic,27744.msg118748.html#msg118748'));
             CRM_Core_Error::fatal($errors);
             return FALSE;
         }
     }
 }
Пример #27
0
/**
 * @param $errorTitle
 * @param $errorMsg
 * @param $showRefer
 */
function errorDisplayPage($errorTitle, $errorMsg, $showRefer = TRUE)
{
    if ($showRefer) {
        $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, 'Installation Guide', NULL, NULL, "wiki");
        if (function_exists('ts')) {
            $errorMsg .= '<p>' . ts("<a %1>Refer to the online documentation for more information</a>", array(1 => "href='{$docLink}'")) . '</p>';
        } else {
            $errorMsg .= '<p>' . sprintf("<a %s>Refer to the online documentation for more information</a>", "href='{$docLink}'") . '</p>';
        }
    }
    include 'error.html';
    exit;
}
Пример #28
0
 function upgrade_3_1_4()
 {
     $query = "SELECT id FROM civicrm_payment_processor WHERE payment_processor_type = 'Moneris' LIMIT 1";
     $isMoneris = CRM_Core_DAO::singleValueQuery($query);
     if ($isMoneris) {
         $template =& CRM_Core_Smarty::singleton();
         $afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage');
         $docURL = CRM_Utils_System::docURL2('Moneris Configuration Guide', false, 'download and install', null, 'color: white; text-decoration: underline;');
         $afterUpgradeMessage .= "<br/>" . ts("Please %1 mpgClasses.php in packages/Services in order to continue using Moneris payment processor. That file is no longer included in the CiviCRM distribution.", array(1 => $docURL));
         $template->assign('afterUpgradeMessage', $afterUpgradeMessage);
     }
 }
Пример #29
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_Job');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_Job::del($this->_id);
         CRM_Core_Session::setStatus("", ts('Scheduled Job Deleted.'), "success");
         return;
     }
     $values = $this->controller->exportValues($this->_name);
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     $dao->run_frequency = $values['run_frequency'];
     $dao->parameters = $values['parameters'];
     $dao->name = $values['name'];
     $dao->api_entity = $values['api_entity'];
     $dao->api_action = $values['api_action'];
     $dao->description = $values['description'];
     $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
     $dao->save();
     /************************************
      * begin com.klangsoft.flexiblejobs *
      ************************************/
     $ts = strtotime($values['schedule_at']);
     if ($ts < time()) {
         $ts = null;
     }
     CRM_Core_BAO_Setting::setItem($ts ?: null, 'com.klangsoft.flexiblejobs', 'job_' . $dao->id);
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
     // CRM-11143 - Give warning message if update_greetings is Enabled (is_active) since it generally should not be run automatically via execute action or runjobs url.
     if ($values['api_action'] == 'update_greeting' && CRM_Utils_Array::value('is_active', $values) == 1) {
         // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
         $msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', array(1 => $docLink));
         CRM_Core_Session::setStatus($msg, ts('Warning: Update Greeting job enabled'), 'alert');
     }
 }
Пример #30
0
 function run()
 {
     // lets get around the time limit issue if possible for upgrades
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
     }
     $latestVer = CRM_Utils_System::version();
     $currentVer = CRM_Core_BAO_Domain::version();
     if (!$currentVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
     } else {
         if (stripos($currentVer, 'upgrade')) {
             CRM_Core_Error::fatal(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
         }
     }
     if (!$latestVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm codebase.'));
     }
     // hack to make past ver compatible /w new incremental upgrade process
     $convertVer = array('2.1' => '2.1.0', '2.2' => '2.2.alpha1', '2.2.alph' => '2.2.alpha3', '3.1.0' => '3.1.1');
     if (isset($convertVer[$currentVer])) {
         $currentVer = $convertVer[$currentVer];
     }
     // since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
     // lets do a pattern check -
     if (!CRM_Utils_System::isVersionFormatValid($currentVer)) {
         CRM_Core_Error::fatal(ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.'));
     }
     // This could be removed in later rev
     if ($currentVer == '2.1.6') {
         $config =& CRM_Core_Config::singleton();
         // also cleanup the templates_c directory
         $config->cleanup(1, false);
         if ($config->userFramework !== 'Standalone') {
             // clean the session
             $session =& CRM_Core_Session::singleton();
             $session->reset(2);
         }
     }
     // end of hack
     CRM_Utils_System::setTitle(ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $upgrade =& new CRM_Upgrade_Form();
     $template =& CRM_Core_Smarty::singleton();
     $template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1'));
     $template->assign('cancelURL', CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     if (version_compare($currentVer, $latestVer) > 0) {
         // DB version number is higher than codebase being upgraded to. This is unexpected condition-fatal error.
         $dbToolsLink = CRM_Utils_System::docURL2("Database Troubleshooting Tools", true);
         $error = ts('Your database is marked with an unexpected version number: %1. The automated upgrade to version %2 can not be run - and the %2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. The database tools utility at %3 may be helpful. You may want to revert to the codebase you were using prior to beginning this upgrade until you resolve this problem.', array(1 => $currentVer, 2 => $latestVer, 3 => $dbToolsLink));
         CRM_Core_Error::fatal($error);
     } else {
         if (version_compare($currentVer, $latestVer) == 0) {
             $message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $latestVer));
             $template->assign('upgraded', true);
         } else {
             $message = ts('CiviCRM upgrade was successful.');
             $template->assign('currentVersion', $currentVer);
             $template->assign('newVersion', $latestVer);
             $template->assign('upgradeTitle', ts('Upgrade CiviCRM from v %1 To v %2', array(1 => $currentVer, 2 => $latestVer)));
             $template->assign('upgraded', false);
             if (CRM_Utils_Array::value('upgrade', $_POST)) {
                 $revisions = $upgrade->getRevisionSequence();
                 foreach ($revisions as $rev) {
                     // proceed only if $currentVer < $rev
                     if (version_compare($currentVer, $rev) < 0) {
                         // as soon as we start doing anything we append ".upgrade" to version.
                         // this also helps detect any partial upgrade issues
                         $upgrade->setVersion($rev . '.upgrade');
                         $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev);
                         if (is_callable(array($this, $phpFunctionName))) {
                             eval("\$this->{$phpFunctionName}('{$rev}');");
                         } else {
                             $upgrade->processSQL($rev);
                         }
                         // after an successful intermediate upgrade, set the complete version
                         $upgrade->setVersion($rev);
                     }
                 }
                 $upgrade->setVersion($latestVer);
                 $template->assign('upgraded', true);
                 // also cleanup the templates_c directory
                 $config =& CRM_Core_Config::singleton();
                 $config->cleanup(1, false);
                 // clear db caching
                 $config->clearDBCache();
                 // clean the session. Note: In case of standalone this makes the user logout.
                 // So skip this step for standalone.
                 if ($config->userFramework !== 'Standalone') {
                     $session =& CRM_Core_Session::singleton();
                     $session->reset(2);
                 }
             }
         }
     }
     $template->assign('message', $message);
     $content = $template->fetch('CRM/common/success.tpl');
     echo CRM_Utils_System::theme('page', $content, true, $this->_print, false, true);
 }