本文整理汇总了PHP中CRM_Utils_System::baseURL方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::baseURL方法的具体用法?PHP CRM_Utils_System::baseURL怎么用?PHP CRM_Utils_System::baseURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::baseURL方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: track
/**
* Track a click-through and return the URL to redirect. If the numbers
* don't match up, return the base url.
*
* @param int $queue_id
* The Queue Event ID of the clicker.
* @param int $url_id
* The ID of the trackable URL.
*
* @return string
* The redirection url, or base url on failure.
*/
public static function track($queue_id, $url_id)
{
$search = new CRM_Mailing_BAO_TrackableURL();
/* To find the url, we also join on the queue and job tables. This
* prevents foreign key violations. */
$job = CRM_Mailing_BAO_MailingJob::getTableName();
$eq = CRM_Mailing_Event_BAO_Queue::getTableName();
$turl = CRM_Mailing_BAO_TrackableURL::getTableName();
if (!$queue_id) {
$search->query("SELECT {$turl}.url as url from {$turl}\n WHERE {$turl}.id = " . CRM_Utils_Type::escape($url_id, 'Integer'));
if (!$search->fetch()) {
return CRM_Utils_System::baseURL();
}
return $search->url;
}
$search->query("SELECT {$turl}.url as url from {$turl}\n INNER JOIN {$job} ON {$turl}.mailing_id = {$job}.mailing_id\n INNER JOIN {$eq} ON {$job}.id = {$eq}.job_id\n WHERE {$eq}.id = " . CRM_Utils_Type::escape($queue_id, 'Integer') . " AND {$turl}.id = " . CRM_Utils_Type::escape($url_id, 'Integer'));
if (!$search->fetch()) {
/* Whoops, error, don't track it. Return the base url. */
return CRM_Utils_System::baseURL();
}
$open = new CRM_Mailing_Event_BAO_TrackableURLOpen();
$open->event_queue_id = $queue_id;
$open->trackable_url_id = $url_id;
$open->time_stamp = date('YmdHis');
$open->save();
return $search->url;
}
示例2: track
/**
* Track a click-through and return the URL to redirect.
*
* If the numbers don't match up, return the base url.
*
* @param int $queue_id
* The Queue Event ID of the clicker.
* @param int $url_id
* The ID of the trackable URL.
*
* @return string
* The redirection url, or base url on failure.
*/
public static function track($queue_id, $url_id)
{
// To find the url, we also join on the queue and job tables. This
// prevents foreign key violations.
$job = CRM_Utils_Type::escape(CRM_Mailing_BAO_MailingJob::getTableName(), 'MysqlColumnNameOrAlias');
$eq = CRM_Utils_Type::escape(CRM_Mailing_Event_BAO_Queue::getTableName(), 'MysqlColumnNameOrAlias');
$turl = CRM_Utils_Type::escape(CRM_Mailing_BAO_TrackableURL::getTableName(), 'MysqlColumnNameOrAlias');
if (!$queue_id) {
$search = CRM_Core_DAO::executeQuery("SELECT url\n FROM {$turl}\n WHERE {$turl}.id = %1", array(1 => array($url_id, 'Integer')));
if (!$search->fetch()) {
return CRM_Utils_System::baseURL();
}
return $search->url;
}
$search = CRM_Core_DAO::executeQuery("SELECT {$turl}.url as url\n FROM {$turl}\n INNER JOIN {$job} ON {$turl}.mailing_id = {$job}.mailing_id\n INNER JOIN {$eq} ON {$job}.id = {$eq}.job_id\n WHERE {$eq}.id = %1 AND {$turl}.id = %2", array(1 => array($queue_id, 'Integer'), 2 => array($url_id, 'Integer')));
if (!$search->fetch()) {
// Can't find either the URL or the queue. If we can find the URL then
// return the URL without tracking. Otherwise return the base URL.
$search = CRM_Core_DAO::executeQuery("SELECT {$turl}.url as url\n FROM {$turl}\n WHERE {$turl}.id = %1", array(1 => array($url_id, 'Integer')));
if (!$search->fetch()) {
return CRM_Utils_System::baseURL();
}
return $search->url;
}
$open = new CRM_Mailing_Event_BAO_TrackableURLOpen();
$open->event_queue_id = $queue_id;
$open->trackable_url_id = $url_id;
$open->time_stamp = date('YmdHis');
$open->save();
return $search->url;
}
示例3: getSiteCallbackUrl
/**
* Determine the current site's callback URL.
*
* @return string
*/
public static function getSiteCallbackUrl()
{
$config = CRM_Core_Config::singleton();
if (preg_match('/^(http|https):/', $config->resourceBase)) {
$civiUrl = $config->resourceBase;
} else {
$civiUrl = rtrim(CRM_Utils_System::baseURL(), '/') . '/' . ltrim($config->resourceBase, '/');
}
// In practice, this may not be necessary, but we want to prevent
// edge-cases that downgrade security-level below system policy.
if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL')) {
$civiUrl = preg_replace('/^http:/', 'https:', $civiUrl);
}
return rtrim($civiUrl, '/') . '/extern/cxn.php';
}
示例4: run
function run()
{
// title
CRM_Utils_System::setTitle(ts('SuperStyler'));
// variables
$url = CRM_Utils_System::baseURL() . 'civicrm/ctrl/superstyler';
$this->assign('url', $url);
// get settings
$settings = CRM_Core_BAO_Setting::getItem('superstyler', 'settings');
$decode = json_decode(utf8_decode($settings), true);
// on form action
if (isset($_REQUEST['color'])) {
// clear
foreach ($decode['superstyler'] as $key => $value) {
if ($value['name'] == $_REQUEST['color']) {
$decode['superstyler'][$key]['active'] = 1;
} else {
$decode['superstyler'][$key]['active'] = 0;
}
}
// set
$encode = json_encode($decode);
CRM_Core_BAO_Setting::setItem($encode, 'superstyler', 'settings');
// notice
CRM_Core_Session::setStatus(ts('Superstyler settings changed'), ts('Saved'), 'success');
}
// form
$form = "";
$form .= "<form action=" . $url . " method='post'>";
$form .= "<label>Select stylesheet</label>";
$form .= "<div class='listing-box'>";
// loop
foreach ($decode['superstyler'] as $key => $value) {
$v = $value['name'];
if ($value['active'] == 1) {
$form .= "<input type='radio' id='css_{$v}' name='color' value='{$v}' checked><label for='css_{$v}' >{$v}</label><br>";
} else {
$form .= "<input type='radio' id='css_{$v}' name='color' value='{$v}'><label for='css_{$v}' >{$v}</label><br>";
}
}
$form .= "</div>";
$form .= "<div class='crm-submit-buttons'><span class='crm-button'><input class='crm-form-submit default' type='submit' value='Submit'></span></div>";
$form .= "</form>";
// assign form
$this->assign('content', $form);
// render
parent::run();
}
示例5: tryEnable
/**
* Attempt to enable the extension on the linked CiviCRM site
*
* @return bool TRUE on success; FALSE if there's no site or if there's an error
*/
protected function tryEnable(InputInterface $input, OutputInterface $output, $key)
{
$civicrm_api3 = $this->getContainer()->get('civicrm_api3');
if ($civicrm_api3 && $civicrm_api3->local && version_compare(\CRM_Utils_System::version(), '4.3.dev', '>=')) {
$siteName = \CRM_Utils_System::baseURL();
// \CRM_Core_Config::singleton()->userSystem->cmsRootPath();
$output->writeln("<info>Refresh extension list for \"{$siteName}\"</info>");
if (!$civicrm_api3->Extension->refresh(array('local' => TRUE, 'remote' => FALSE))) {
$output->writeln("<error>Refresh error: " . $civicrm_api3->errorMsg() . "</error>");
return FALSE;
}
if ($this->confirm($input, $output, "Enable extension ({$key}) in \"{$siteName}\"? [Y/n] ")) {
$output->writeln("<info>Enable extension ({$key}) in \"{$siteName}\"</info>");
if (!$civicrm_api3->Extension->install(array('key' => $key))) {
$output->writeln("<error>Install error: " . $civicrm_api3->errorMsg() . "</error>");
}
}
return TRUE;
}
// fallback
$output->writeln("NOTE: This might be a good time to refresh the extension list and install \"{$key}\".");
return FALSE;
}
示例6: while
/**
* Replace unsubscribe tokens.
*
* @param string $str
* The string with tokens to be replaced.
* @param object $domain
* The domain BAO.
* @param array $groups
* The groups (if any) being unsubscribed.
* @param bool $html
* Replace tokens with html or plain text.
* @param int $contact_id
* The contact ID.
* @param string $hash The security hash of the unsub event
*
* @return string
* The processed string
*/
public static function &replaceUnsubscribeTokens($str, &$domain, &$groups, $html, $contact_id, $hash)
{
if (self::token_match('unsubscribe', 'group', $str)) {
if (!empty($groups)) {
$config = CRM_Core_Config::singleton();
$base = CRM_Utils_System::baseURL();
// FIXME: an ugly hack for CRM-2035, to be dropped once CRM-1799 is implemented
$dao = new CRM_Contact_DAO_Group();
$dao->find();
while ($dao->fetch()) {
if (substr($dao->visibility, 0, 6) == 'Public') {
$visibleGroups[] = $dao->id;
}
}
$value = implode(', ', $groups);
self::token_replace('unsubscribe', 'group', $value, $str);
}
}
return $str;
}
示例7: foreach
/**
* Replace unsubscribe tokens
*
* @param string $str the string with tokens to be replaced
* @param object $domain The domain BAO
* @param array $groups The groups (if any) being unsubscribed
* @param boolean $html Replace tokens with html or plain text
* @param int $contact_id The contact ID
* @param string hash The security hash of the unsub event
* @return string The processed string
* @access public
* @static
*/
function &replaceUnsubscribeTokens($str, &$domain, &$groups, $html, $contact_id, $hash)
{
if (CRM_Utils_Token::token_match('unsubscribe', 'group', $str)) {
if (!empty($groups)) {
$config =& CRM_Core_Config::singleton();
$base = CRM_Utils_System::baseURL();
if ($html) {
$value = '<ul>';
foreach ($groups as $gid => $name) {
$verpAddress = implode($config->verpSeparator, array('subscribe', $domain->id, $gid)) . "@{$domain->email_domain}";
$value .= "<li>{$name} (<a href=\"mailto:{$verpAddress}\">" . ts("re-subscribe") . "</a>)</li>\n";
}
$value .= '</ul>';
} else {
$value = "\n";
foreach ($groups as $gid => $name) {
$verpAddress = implode($config->verpSeparator, array('subscribe', $domain->id, $gid)) . "@{$domain->email_domain}";
$value .= "\t* {$name} " . ts("(re-subscribe: %1)", array(1 => "{$verpAddress}")) . "\n";
}
$value .= "\n";
}
CRM_Utils_Token::token_replace('unsubscribe', 'group', $value, $str);
}
}
return $str;
}
示例8: main
function main(&$args)
{
if ($args[1] !== 'mailing') {
return;
}
require_once 'CRM/Mailing/Controller/Send.php';
require_once 'CRM/Mailing/Page/Browse.php';
require_once 'CRM/Mailing/BAO/Job.php';
if ($args[2] == 'forward') {
$session =& CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::baseURL());
$wrapper =& new CRM_Utils_Wrapper();
return $wrapper->run('CRM_Profile_Form_ForwardMailing', ts('Forward Mailing'), null);
}
if ($args[2] == 'retry') {
$session =& CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse'));
CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/browse') . '">' . ts('Mailings') . '</a>');
CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/report') . '">' . ts('Report') . '</a>');
$wrapper =& new CRM_Utils_Wrapper();
return $wrapper->run('CRM_Mailing_Form_Retry', ts('Retry Mailing'), null);
}
if ($args[2] == 'component') {
require_once 'CRM/Mailing/Page/Component.php';
$view =& new CRM_Mailing_Page_Component();
return $view->run();
}
if ($args[2] == 'browse') {
require_once 'CRM/Mailing/Page/Browse.php';
$view =& new CRM_Mailing_Page_Browse();
return $view->run();
}
if ($args[2] == 'event') {
CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/browse') . '">' . ts('Mailings') . '</a>');
CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/report') . '">' . ts('Report') . '</a>');
require_once 'CRM/Mailing/Page/Event.php';
$view =& new CRM_Mailing_Page_Event();
return $view->run();
}
if ($args[2] == 'report') {
CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/browse') . '">' . ts('Mailings') . '</a>');
require_once 'CRM/Mailing/Page/Report.php';
$view =& new CRM_Mailing_Page_Report();
return $view->run();
}
if ($args[2] == 'send') {
$session =& CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse', 'reset=1'));
require_once 'CRM/Mailing/Controller/Send.php';
$controller =& new CRM_Mailing_Controller_Send(ts('Send Mailing'));
return $controller->run();
}
if ($args[2] == 'queue') {
$session =& CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse', 'reset=1'));
require_once 'CRM/Mailing/BAO/Job.php';
CRM_Mailing_BAO_Job::runJobs();
CRM_Core_Session::setStatus(ts('The mailing queue has been processed.'));
}
require_once 'CRM/Mailing/Page/Browse.php';
$view =& new CRM_Mailing_Page_Browse();
return $view->run();
}