Skip to content

Commit

Permalink
Fix link in 'XML phonebook for your device' button
Browse files Browse the repository at this point in the history
Implement new getSystemBaseURL() method to get the current URL of the system
  • Loading branch information
Massi-X committed Dec 21, 2024
1 parent cc447f3 commit a834e51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions Phonemiddleware.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Phonemiddleware extends \DB_Helper implements \BMO
private $WWW_MODULE_DIR_NEW;
private $ASSETS_SYMLINK;

private const numberToCnamPath = '/carddavmiddleware/numbertocnam.php';
private const carddavToXmlPath = '/carddavmiddleware/carddavtoxml.php';
const numberToCnamPath = '/carddavmiddleware/numbertocnam.php';
const carddavToXmlPath = '/carddavmiddleware/carddavtoxml.php';

private static $inPage = false;
private static $forceSSL = null;
Expand Down Expand Up @@ -288,6 +288,22 @@ public static function getForceSSL()
return self::$forceSSL;
}

/**
* Get the system base URL
*
* @return string base URL
*/
public static function getSystemBaseURL()
{
$ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
$port = ':' . $_SERVER['SERVER_PORT'];

if ($ssl && $_SERVER['SERVER_PORT'] == 443) $port = '';
if (!$ssl && $_SERVER['SERVER_PORT'] == 80) $port = '';

return ($ssl ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'] . $port;
}

/**
* Return the resolved email address
*
Expand All @@ -301,7 +317,6 @@ public static function getToAddress()
return self::$emailTo;
}


/**
* Set which ajax requests should be allowed
*
Expand Down
2 changes: 1 addition & 1 deletion page.carddavmiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
<button data-action="close-tip" class="btn fl-right"><?= _('Got it'); ?></button>
</div>
<div class="help-section">
<a target="_blank" href="<?= \FreePBX::PhoneMiddleware()->getXmlPhonebookURL(); ?>" title="<?= _('Open in new page…'); ?>" class="btn-popup"><?= _('XML phonebook for your device'); ?> <i class="fa fa-external-link"></i></a>
<a target="_blank" href="<?= \FreePBX::PhoneMiddleware()->getSystemBaseURL() . \FreePBX::PhoneMiddleware()::carddavToXmlPath; ?>" title="<?= _('Open in new page…'); ?>" class="btn-popup"><?= _('XML phonebook for your device'); ?> <i class="fa fa-external-link"></i></a>
<a href="javascript:;" class="btn-popup" onclick="$('#errorPopup').dialog('open'); return false;"><?= _('Error codes and fixes'); ?></a>
</div>
</div>
Expand Down

0 comments on commit a834e51

Please sign in to comment.