本文整理汇总了PHP中CRM_Utils_System::docURL2方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::docURL2方法的具体用法?PHP CRM_Utils_System::docURL2怎么用?PHP CRM_Utils_System::docURL2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::docURL2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
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: preProcess
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: preProcess
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: com_install
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: preProcess
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: com_install
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: preProcess
/**
* 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.'));
}
}
}
示例8: install
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: authenticateKey
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: upgrade
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);
//.........这里部分代码省略.........
示例11: civimailchimp_civicrm_validateForm
/**
* 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: authenticateKey
/**
* @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: handle
/**
* @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: formRule
//.........这里部分代码省略.........
$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: install
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;
}