Skip to content

Commit

Permalink
Massive update to licensing
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Chatfield <[email protected]>
  • Loading branch information
danielchatfield committed Apr 5, 2012
1 parent 5a41f28 commit 6608a77
Show file tree
Hide file tree
Showing 46 changed files with 2,695 additions and 393 deletions.
6 changes: 6 additions & 0 deletions _classes/lavaPrivateBlogAccessLogsPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
class lavaPrivateBlogAccessLogsPage extends lavaTablePage
{

}
?>
30 changes: 30 additions & 0 deletions _classes/lavaVolcanicPixelsLicensingAjax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* The Volcanic Pixels licensing ajax class
*
*
* @package Lava
* @subpackage lavaVolcanicPixelsLicensingAjax
*
* @author Daniel Chatfield
* @copyright 2012
* @version 1.0.0
*/
class lavaVolcanicPixelsLicensingAjax extends lavaAjax {
public $targetAction = "licensing";

function doAjax() {
$private_key = $_REQUEST['private_key'];
$public_key = $_REQUEST['public_key'];
$this->_settings()->fetchSetting('license_public', 'vendor')->updateValue( $public_key );
$this->_settings()->fetchSetting('license_private', 'vendor')->updateValue( $private_key );

$return = array(
"status" => "complete"
);

$this->returnData( $return );
$this->doReturn();
}
}
?>
Binary file added _static/images/Thumbs.db
Binary file not shown.
Binary file added _static/images/logout-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions _static/scripts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var passwordFieldAnimationSpeed = 0;
jQuery( document ).ready( function(){
makeLabels();
bindLogoutLink();
jQuery('#private_blog-settings-multiple_passwords').change( function(){
if( jQuery(this).hasAttr( 'checked' ) )
{
Expand Down Expand Up @@ -120,14 +119,3 @@ function makeLabels()
//jQuery(this).find( '.custom-password-label' ).css({marginLeft: -(labelWidth + 50 ),opacity:0,display: 'none'});
});
}

function bindLogoutLink() {
jQuery('#private_blog-settings-logout_link').change(function(){

if( jQuery(this).hasAttr( "checked" ) ) {console.log(2);
jQuery( '#setting-cntr_private_blog-settings-logout_link_menu.tag-options-available' ).slideDown();
} else {
jQuery( '#setting-cntr_private_blog-settings-logout_link_menu' ).slideUp();
}
}).change();
}
24 changes: 24 additions & 0 deletions _static/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* This beautiful CSS-File has been crafted with LESS (lesscss.org) and compiled by simpLESS (wearekiss.com/simpless) */
.setting.tag-multi-password {
margin-top: -10px;
}
Expand Down Expand Up @@ -76,3 +77,26 @@
cursor: pointer;
min-width: 28px;
}
.lava-table-viewer[data-data-source="access_logs"] .cell-id,
.lava-table-viewer[data-data-source="access_logs"] .cell-password,
.lava-table-viewer[data-data-source="access_logs"] .cell-password_color,
.lava-table-viewer[data-data-source="access_logs"] .cell-user_agent {
display: none;
}
.lava-table-viewer[data-data-source="access_logs"] .cell-timestamp {
text-align: center;
}
.lava-table-viewer[data-data-source="access_logs"] .cell-action.value-loginAccepted, .lava-table-viewer[data-data-source="access_logs"] .cell-action.value-doLogout, .lava-table-viewer[data-data-source="access_logs"] .cell-action.value-loginRejected {
text-align: center;
color: white;
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.5);
}
.lava-table-viewer[data-data-source="access_logs"] .cell-action.value-doLogout {
background: #69AEB4;
}
.lava-table-viewer[data-data-source="access_logs"] .cell-action.value-loginAccepted {
background-color: #7cd05b;
}
.lava-table-viewer[data-data-source="access_logs"] .cell-action.value-loginRejected {
background: red;
}
42 changes: 36 additions & 6 deletions _static/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
//background: rgba(255,255,255,0.25);
border-radius: 15px;
background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.01) 2%, rgba(0,0,0,0.14) 49%, rgba(0,0,0,0.18) 51%, rgba(0,0,0,0.2) 52%, rgba(0,0,0,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0)), color-stop(2%,rgba(0,0,0,0.01)), color-stop(49%,rgba(0,0,0,0.14)), color-stop(51%,rgba(0,0,0,0.18)), color-stop(52%,rgba(0,0,0,0.2)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* IE10+ */
background: linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* W3C */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0)), color-stop(2%,rgba(0,0,0,0.01)), color-stop(49%,rgba(0,0,0,0.14)), color-stop(51%,rgba(0,0,0,0.18)), color-stop(52%,rgba(0,0,0,0.2)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* IE10+ */
background: linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0,0.14) 49%,rgba(0,0,0,0.18) 51%,rgba(0,0,0,0.2) 52%,rgba(0,0,0,0) 100%); /* W3C */
}
}
}
Expand Down Expand Up @@ -105,4 +105,34 @@ background: linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.01) 2%,rgba(0,0,0
}
}
}
}
}

.lava-table-viewer[data-data-source="access_logs"] {
.cell-id, .cell-password, .cell-password_color, .cell-user_agent {
display: none;
}

.cell-timestamp {
text-align: center;
}

.cell-action {
&.value-loginAccepted, &.value-doLogout, &.value-loginRejected {
text-align: center;
color: white;
text-shadow: 0px -1px 0px rgba(0,0,0,0.5);
}

&.value-doLogout {
background: #69AEB4;
}

&.value-loginAccepted {
background-color: #7cd05b;
}

&.value-loginRejected {
background: red;
}
}
}
2 changes: 2 additions & 0 deletions _static/vendor.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

172 changes: 172 additions & 0 deletions _static/vendor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
var lava_api_version = 1;
var lava_vendor_uri = "http://www.volcanicpixels.com/api/" + lava_api_version;

if( location.href.indexOf('localhost') != -1 ){
lava_vendor_uri = "http://localhost:8082/api/" + lava_api_version;
}
var install_id = "DEVELOPMENTINSTALL2";
var install_url = encodeURIComponent('http://localhost:31786/');
var install_name = "WordPress Beta";
var install_version = "4.0 beta";
var package_slug = "private_blog";
//lava_vendor_uri = 'http://localhost:8082/api/' + lava_api_version;

jQuery(document).ready(function(){
//do register


var the_url = lava_vendor_uri + '/register/'
+ '?install_id=' + install_id
+ '&installed_version=' + install_version
+ '&package_slug=' + package_slug
+ '&install_name='+ install_name
+ '&install_url=' + install_url
;
jQuery.getJSON( the_url, function(data){
if( data.status == "complete" ) {
jQuery('.ajax-check.type-register').removeClass( "loading" ).addClass( "complete" ).attr("title", "Registered").tipTip({'delay':0});
} else {
jQuery('.ajax-check.type-register').removeClass( "loading" ).addClass( "error" ).attr("title", "An error occured").tipTip({'delay':0});
}
});



showPremiumUI()
})

function showPremiumUI() {
jQuery('.setting.tag-is-premium .premium-notice').attr("title", "This is a premium feature, either enter trial mode or purchase a license to use.").tipTip({'delay':0});

jQuery('.start-trial').click(function(){
enterTrialMode();
})


jQuery('.get-premium-link').attr("href", "#unlock").click(function(){
showUnderground( "get-premium" );
var the_url = lava_vendor_uri + '/get_license_options/'
+ '?package_slug=' + package_slug
;
jQuery.getJSON( the_url, function(data){
jQuery('.underground-context-get-premium').removeClass('loading');
var license_types = data.licenses;
jQuery('.underground-context-get-premium .license-options').html('');
for( license_type in license_types) {
the_license = license_types[license_type];
var the_license = '<div class="license-option " data-price="' + the_license.price + '" data-product="' + license_type + '"><h3>' + the_license.name + '</h3><div class="description">' + the_license.description + '</div></div>';
jQuery('.underground-context-get-premium .license-options').append(the_license)
}
jQuery('.underground-context-get-premium .license-options .license-option:first-child').addClass('selected');
jQuery('.license-option').click(function(){
jQuery('.license-option').removeClass('selected');
jQuery(this).addClass( 'selected');
});
});

});


jQuery('.redeem-code-link').attr("href", "#verify").click(function(){
current_key = jQuery('.vendor-input.license-public').val();
userInput = prompt('Enter License key', current_key );
if (userInput != null) {
jQuery('.vendor-input.license-public').val(userInput);
checkLicense(false);
}
})


checkLicense(true);


jQuery('.lava-btn.purchase-premium-button').click(function(){
jQuery(this).html(jQuery(this).attr("data-clicked-text") );

the_url = lava_vendor_uri + '/setup_payment/'
+ '?package_slug=' + package_slug
+ '&purchase_id=' + jQuery('.license-option.selected').attr('data-product');
jQuery.getJSON( the_url, function(data){
location.href = data.checkout_url;
});
});
}

function enterTrialMode() {
jQuery('.remove-for-trial').remove()
jQuery('.setting.tag-is-premium').removeClass( 'tag-is-premium' );
jQuery('.started-trial').removeClass('hidden');
jQuery('.lava-form-purpose').val('trial');
}

function checkLicense( routine ) {
var license_pub = jQuery('.vendor-input.license-public').val();
jQuery('.ajax-check.type-licensing').show().removeClass( "complete" ).removeClass( "error" ).addClass('loading').attr("title", "Checking License...").tipTip({'delay':0});
if( license_pub.length == 0 ) {
jQuery('.ajax-check.type-licensing').hide();
if( routine ) {
console.log('just routine')
return;//no license
}
}
var installation_to_unlicense = jQuery(this).attr('data-installation_to_unlicense');
the_url = lava_vendor_uri + '/is_licensed/'
+ '?install_id=' + install_id
+ '&license_public=' + license_pub
+ '&installation_to_unlicense=' + installation_to_unlicense
;

if(routine){
//this is a routine license check (no changes were made) - if the license is alive then that is fine
jQuery.getJSON( the_url, function(data){
if( data.license_status == "alive" ) {
jQuery('.ajax-check.type-licensing').removeClass( "loading" ).addClass( "complete" ).attr("title", "License approved").tipTip({'delay':0});
} else if(data.license_status == "dead") {
jQuery('.ajax-check.type-licensing').removeClass( "loading" ).addClass( "error" ).attr("title", "License rejected").tipTip({'delay':0});
var action = jQuery('.vendor-input.ajax-action').val();
var nonce = jQuery('.vendor-input.ajax-nonce').val();
var the_url = ajaxurl + '?action=' + action + '&nonce=' + nonce
+ '?private_key=' + ''
+ '&public_key=' + jQuery('.vendor-input.license-public').val();
;
alert( data.license_error_message );
var private_key = jQuery('.vendor-input.license-private').val();

if( private_key.length != 0 ) {//don't need to remove it if it isn't there
jQuery.getJSON( the_url, function(data){
location.reload();
});
}
}
});
} else {
jQuery('body').addClass( 'lava-loading' );
jQuery.getJSON( the_url, function(data){
if( data.license_status == "alive" ) {
jQuery('.ajax-check.type-licensing').removeClass( "loading" ).addClass( "complete" ).attr("title", "License approved").tipTip({'delay':0});
action = jQuery('.vendor-input.ajax-action').val();
nonce = jQuery('.vendor-input.ajax-nonce').val();
the_url = ajaxurl + '?action=' + action + '&nonce=' + nonce
+ '&private_key=' + data.license_private
+ '&public_key=' + data.license_public
;

jQuery.getJSON( the_url, function(data){
location.reload();
});
} else if(data.license_status == "dead") {
jQuery('.ajax-check.type-licensing').removeClass( "loading" ).addClass( "error" ).attr("title", "License rejected").tipTip({'delay':0});
action = jQuery('.vendor-input.ajax-action').val();
nonce = jQuery('.vendor-input.ajax-nonce').val();
the_url = ajaxurl + '?action=' + action + '&nonce=' + nonce
+ '&private_key=' + ''
+ '&public_key=' + jQuery('.vendor-input.license-public').val();
;
alert( data.license_error_message );
jQuery.getJSON( the_url, function(data){
location.reload();
});
}
});
}
}
Loading

0 comments on commit 6608a77

Please sign in to comment.