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()
{
$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,29 +7,29 @@
* Zend_Navigation_Page::factory() when constructing
* the navigation container below.
*/
$pages = array(
array(
$pages = array();
$pages[] = array(
'label' => "<i class='icon-music icon-white'></i>"._('My Podcast'),
'module' => 'default',
'controller' => 'podcast',
'action' => 'station',
'resource' => 'podcast'
),
array(
);
$pages[] = array(
'label' => "<i class='icon-globe icon-white'></i>"._('Radio Page'),
'uri' => '/',
'resource' => '',
'pages' => array(
)
),
array(
);
$pages[] = array(
'label' => "<i class='icon-calendar icon-white'></i>"._('Calendar'),
'module' => 'default',
'controller' => 'schedule',
'action' => 'index',
'resource' => 'schedule'
),
array(
);
$pages[] = array(
'label' => "<i class='icon-wrench icon-white'></i>"._('Widgets'),
'module' => 'default',
'controller' => 'embeddablewidgets',
@ -56,8 +56,8 @@ $pages = array(
'action' => 'facebook',
)
)
),
array(
);
$pages[] = array(
'label' => "<i class='icon-cog icon-white'></i>"._("Settings"),
'resource' => 'preference',
'action' => 'index',
@ -90,8 +90,8 @@ $pages = array(
'action' => 'stream-setting'
)
)
),
array(
);
$pages[] = array(
'label' => "<i class='icon-signal icon-white'></i>"._("Analytics"),
'module' => 'default',
'controller' => 'playouthistory',
@ -121,8 +121,9 @@ $pages = array(
'resource' => 'listenerstat'
),
)
),
array(
);
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,8 +152,9 @@ $pages = array(
'resource' => 'billing'
)
)
),
array(
);
}
$pages[] = array(
'label' => "<i class='icon-question-sign icon-white'></i>"._('Help'),
'controller' => 'dashboard',
'action' => 'help',
@ -192,7 +194,6 @@ $pages = array(
'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">