Problem: Billing is always on

Solution: Make billing configurable through LIBRETIME_ENABLE_BILLING and deactivate it

This should catch all the changes needed to deactive billing in LibreTime.

* [x] only call billing when it is enabled
* [x] let super admins edit their info
* [x] dont link to billing if it is disabled
This commit is contained in:
Lucas Bickel 2017-02-23 12:03:25 +01:00
parent 4557395a86
commit 6e03863fa1
11 changed files with 176 additions and 164 deletions

View file

@ -118,8 +118,14 @@ class Amazon_S3StorageBackend extends StorageBackend
public function getFilePrefix()
{
$hostingId = Billing::getClientInstanceId();
$filePrefix = substr($hostingId, -2)."/".$hostingId;
$filePrefix = '';
// only prefix files on S3 when billing is active since saas customers share a s3 bucket
// I'm not sure why the choice was made to put everything into one bucket
// We might refactor this to use a bucket per customer if we revisit S3
if (LIBRETIME_ENABLE_BILLING === true) {
$hostingId = Billing::getClientInstanceId();
$filePrefix = substr($hostingId, -2)."/".$hostingId;
}
return $filePrefix;
}
}

View file

@ -103,7 +103,7 @@ class Application_Common_UsabilityHints
"<a href=\"/schedule\">",
"</a>");
}
} else if ($userIsOnShowbuilderPage && $userIsSuperAdmin) {
} else if (LIBRETIME_ENABLE_BILLING === true && $userIsOnShowbuilderPage && $userIsSuperAdmin) {
$unpaidInvoice = Billing::checkForUnpaidInvoice();
if ($unpaidInvoice != null) {
$invoiceUrl = "/billing/invoice?invoiceid=" . $unpaidInvoice['id'];

View file

@ -141,3 +141,6 @@ define('STATION_PODCAST_SERVICE_NAME', 'station_podcast');
//define('IMPORTED_PODCAST', 1);
define('ITUNES_XML_NAMESPACE_URL', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
// Billing configuration
define('LIBRETIME_ENABLE_BILLING', false);

View file

@ -7,122 +7,123 @@
* Zend_Navigation_Page::factory() when constructing
* the navigation container below.
*/
$pages = array(
array(
'label' => "<i class='icon-music icon-white'></i>"._('My Podcast'),
'module' => 'default',
'controller' => 'podcast',
'action' => 'station',
'resource' => 'podcast'
),
array(
'label' => "<i class='icon-globe icon-white'></i>"._('Radio Page'),
'uri' => '/',
'resource' => '',
'pages' => array(
$pages = array();
$pages[] = array(
'label' => "<i class='icon-music icon-white'></i>"._('My Podcast'),
'module' => 'default',
'controller' => 'podcast',
'action' => 'station',
'resource' => 'podcast'
);
$pages[] = array(
'label' => "<i class='icon-globe icon-white'></i>"._('Radio Page'),
'uri' => '/',
'resource' => '',
'pages' => array(
)
);
$pages[] = array(
'label' => "<i class='icon-calendar icon-white'></i>"._('Calendar'),
'module' => 'default',
'controller' => 'schedule',
'action' => 'index',
'resource' => 'schedule'
);
$pages[] = array(
'label' => "<i class='icon-wrench icon-white'></i>"._('Widgets'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'player',
'resource' => 'embeddablewidgets',
'title' => 'Widgets',
'pages' => array(
array(
'label' => _('Player'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'player',
),
array(
'label' => _('Weekly Schedule'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'schedule',
),
array(
'label' => _('Facebook'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'facebook',
)
),
array(
'label' => "<i class='icon-calendar icon-white'></i>"._('Calendar'),
'module' => 'default',
'controller' => 'schedule',
'action' => 'index',
'resource' => 'schedule'
),
array(
'label' => "<i class='icon-wrench icon-white'></i>"._('Widgets'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'player',
'resource' => 'embeddablewidgets',
'title' => 'Widgets',
'pages' => array(
array(
'label' => _('Player'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'player',
),
array(
'label' => _('Weekly Schedule'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'schedule',
),
array(
'label' => _('Facebook'),
'module' => 'default',
'controller' => 'embeddablewidgets',
'action' => 'facebook',
)
)
);
$pages[] = array(
'label' => "<i class='icon-cog icon-white'></i>"._("Settings"),
'resource' => 'preference',
'action' => 'index',
'module' => 'default',
'controller' => 'preference',
'title' => 'Settings',
'pages' => array(
array(
'label' => _('General'),
'module' => 'default',
'controller' => 'preference'
),
array(
'label' => _('My Profile'),
'controller' => 'user',
'action' => 'edit-user',
'resource' => 'user'
),
array(
'label' => _('Users'),
'module' => 'default',
'controller' => 'user',
'action' => 'add-user',
'resource' => 'user'
),
array(
'label' => _('Streams'),
'module' => 'default',
'controller' => 'preference',
'action' => 'stream-setting'
)
),
array(
'label' => "<i class='icon-cog icon-white'></i>"._("Settings"),
'resource' => 'preference',
'action' => 'index',
'module' => 'default',
'controller' => 'preference',
'title' => 'Settings',
'pages' => array(
array(
'label' => _('General'),
'module' => 'default',
'controller' => 'preference'
),
array(
'label' => _('My Profile'),
'controller' => 'user',
'action' => 'edit-user',
'resource' => 'user'
),
array(
'label' => _('Users'),
'module' => 'default',
'controller' => 'user',
'action' => 'add-user',
'resource' => 'user'
),
array(
'label' => _('Streams'),
'module' => 'default',
'controller' => 'preference',
'action' => 'stream-setting'
)
)
),
array(
'label' => "<i class='icon-signal icon-white'></i>"._("Analytics"),
'module' => 'default',
'controller' => 'playouthistory',
'action' => 'index',
'resource' => 'playouthistory',
'title' => 'Analytics',
'pages' => array(
array(
'label' => _('Playout History'),
'module' => 'default',
'controller' => 'playouthistory',
'action' => 'index',
'resource' => 'playouthistory'
),
array(
'label' => _('History Templates'),
'module' => 'default',
'controller' => 'playouthistorytemplate',
'action' => 'index',
'resource' => 'playouthistorytemplate'
),
array(
'label' => _('Listener Stats'),
'module' => 'default',
'controller' => 'listenerstat',
'action' => 'index',
'resource' => 'listenerstat'
),
)
),
array(
)
);
$pages[] = array(
'label' => "<i class='icon-signal icon-white'></i>"._("Analytics"),
'module' => 'default',
'controller' => 'playouthistory',
'action' => 'index',
'resource' => 'playouthistory',
'title' => 'Analytics',
'pages' => array(
array(
'label' => _('Playout History'),
'module' => 'default',
'controller' => 'playouthistory',
'action' => 'index',
'resource' => 'playouthistory'
),
array(
'label' => _('History Templates'),
'module' => 'default',
'controller' => 'playouthistorytemplate',
'action' => 'index',
'resource' => 'playouthistorytemplate'
),
array(
'label' => _('Listener Stats'),
'module' => 'default',
'controller' => 'listenerstat',
'action' => 'index',
'resource' => 'listenerstat'
),
)
);
if (LIBRETIME_ENABLE_BILLING === true) {
$pages[] = array(
'label' => (Application_Model_Preference::GetPlanLevel()=="trial") ? "<i class='icon-star icon-orange'></i><span style='color: #ff5d1a'>"._('Upgrade')."</span>" : "<i class='icon-briefcase icon-white'></i>"._('Billing'),
'controller' => 'billing',
'action' => 'upgrade',
@ -151,48 +152,48 @@ $pages = array(
'resource' => 'billing'
)
)
),
array(
'label' => "<i class='icon-question-sign icon-white'></i>"._('Help'),
'controller' => 'dashboard',
'action' => 'help',
'resource' => 'dashboard',
'title' => 'Help',
'pages' => array(
array(
'label' => _('Getting Started'),
'module' => 'default',
'controller' => 'dashboard',
'action' => 'help',
'resource' => 'dashboard'
),
array(
'label' => _('FAQ'),
'uri' => FAQ_URL,
'target' => "_blank"
),
array(
'label' => _('User Manual'),
'uri' => USER_MANUAL_URL,
'target' => "_blank"
),
array(
'label' => _('File a Support Ticket'),
'uri' => SUPPORT_TICKET_URL,
'target' => "_blank"
),
array(
'label' => _(sprintf("Help Translate %s", PRODUCT_NAME)),
'uri' => AIRTIME_TRANSIFEX_URL,
'target' => "_blank"
),
array(
'label' => _('What\'s New?'),
'uri' => UI_REVAMP_YOUTUBE_URL,
'target' => "_blank"
)
);
}
$pages[] = array(
'label' => "<i class='icon-question-sign icon-white'></i>"._('Help'),
'controller' => 'dashboard',
'action' => 'help',
'resource' => 'dashboard',
'title' => 'Help',
'pages' => array(
array(
'label' => _('Getting Started'),
'module' => 'default',
'controller' => 'dashboard',
'action' => 'help',
'resource' => 'dashboard'
),
array(
'label' => _('FAQ'),
'uri' => FAQ_URL,
'target' => "_blank"
),
array(
'label' => _('User Manual'),
'uri' => USER_MANUAL_URL,
'target' => "_blank"
),
array(
'label' => _('File a Support Ticket'),
'uri' => SUPPORT_TICKET_URL,
'target' => "_blank"
),
array(
'label' => _(sprintf("Help Translate %s", PRODUCT_NAME)),
'uri' => AIRTIME_TRANSIFEX_URL,
'target' => "_blank"
),
array(
'label' => _('What\'s New?'),
'uri' => UI_REVAMP_YOUTUBE_URL,
'target' => "_blank"
)
),
)
);

View file

@ -443,7 +443,7 @@ class LibraryController extends Zend_Controller_Action
$this->_helper->layout->disableLayout();
if (!Billing::isStationPodcastAllowed()) {
if (LIBRETIME_ENABLE_BILLING === true && !Billing::isStationPodcastAllowed()) {
$this->renderScript("podcast/featureupgrade-pane.phtml");
}

View file

@ -27,7 +27,7 @@ class PodcastController extends Zend_Controller_Action {
*/
public function stationAction() {
if (!Billing::isStationPodcastAllowed()) {
if (LIBRETIME_ENABLE_BILLING === true && !Billing::isStationPodcastAllowed()) {
$this->render("featureupgrade-page");
return;
}

View file

@ -131,7 +131,7 @@ class Application_Form_EditUser extends Zend_Form
$timezone->setDecorators(array('ViewHelper'));
$this->addElement($timezone);
if (Application_Model_User::getCurrentUser()->isSuperAdmin()) {
if (LIBRETIME_ENABLE_BILLING === true && Application_Model_User::getCurrentUser()->isSuperAdmin()) {
$elemsToDisable = array($password, $passwordVerify, $email, $firstName, $lastName,
$cellPhone, $skype, $jabber);
foreach ($elemsToDisable as $element) {

View file

@ -1573,7 +1573,7 @@ class Application_Model_Preference
* @return int either 0 (public) or 1 (private)
*/
public static function getStationPodcastPrivacy() {
if (!Billing::isStationPodcastAllowed()) {
if (LIBRETIME_ENABLE_BILLING === true && !Billing::isStationPodcastAllowed()) {
// return private setting
return 1;
}

View file

@ -1,7 +1,7 @@
<h2><?php echo _("My Profile") ?></h2>
<div id="current-user-container">
<?php if(Application_Model_User::getCurrentUser()->isSuperAdmin()) : ?>
<?php if(LIBRETIME_ENABLE_BILLING === true && Application_Model_User::getCurrentUser()->isSuperAdmin()) : ?>
<div id="user_details_superadmin_message">
<p class="alert alert-error">
<?=sprintf(_("<b>Note:</b> Since you're the station owner, your account information can be edited in <a href=\"%s\">Billing Settings</a> instead."), "/billing/client");?>

View file

@ -9,7 +9,7 @@
</div>
<?php
if (Billing::isStationPodcastAllowed()) { ?>
if (LIBRETIME_ENABLE_BILLING === true && Billing::isStationPodcastAllowed()) { ?>
<h3 class="collapsible-header" id="soundcloud-heading"><span class="arrow-icon"></span><?php echo _("SoundCloud Settings") ?></h3>
<div class="collapsible-content" id="soundcloud-settings">
<?php echo $this->element->getSubform('preferences_soundcloud') ?>

View file

@ -26,9 +26,11 @@
</table>
</div>
</div>
<?php if (LIBRETIME_ENABLE_BILLING === true) { ?>
<div class="user-data" id="user_details_superadmin_message" style="display: none; margin-top: 105px; text-align: center;">
<?=sprintf(_("Super Admin details can be changed in your <a href=\"%s\">Billing Settings</a>."), "/billing/client");?>
</div>
<?php } ?>
<div class="user-data simple-formblock" id="user_details">
<?php echo $this->successMessage ?>
<fieldset class="padded">