Skip to content

Commit

Permalink
Add account stuff and bump script versions.
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Prosser <[email protected]>
  • Loading branch information
Simon Prosser committed Jul 9, 2013
1 parent 853c658 commit 2367cfa
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 16 deletions.
46 changes: 37 additions & 9 deletions editor/editor.account.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function toolbar( $toolbar ){
'icon' => 'icon-star',
'call' => array(&$this, 'pagelines_welcome'),
),
'account' => array(
'pl_account' => array(
'name' => 'Your Account',
'icon' => 'icon-user',
'call' => array(&$this, 'pagelines_account'),
Expand Down Expand Up @@ -58,20 +58,48 @@ function pagelines_welcome(){
}

function pagelines_account(){

$disabled = '';
$email = '';
$key = '';
$activate_text = 'Activate';
if( pl_is_pro() ) {
$disabled = ' disabled';
$data = get_option( 'dms_activation' );
$email = sprintf( 'value="%s"', $data['email'] );
$key = sprintf( 'value="%s"', $data['key'] );
printf( '<div class="account-description"><div class="alert alert-info">%s</div></div>', $data['message'] );
$activate_text = 'Deactivate';
}

if( ! pl_is_pro() ){
?>
<h3><i class="icon-user"></i> Enter your PageLines user account information</h3>
<p>
This will be used to authenticate purchases and membership level. If you are a Pro member, it will unlock pro features.
<h3><i class="icon-user"></i> Enter your PageLines DMS Activation key</h3>
<p class="account-description">
If you are a Pro member, it will unlock pro features.
</p>
<label>PageLines Username</label>
<input type="text" class="pl-text-input" />
<?php }
?>
<label for="pl_activation">User email</label>
<input type="text" class="pl-text-input" name="pl_email" id="pl_email" <?php echo $email . $disabled ?> />

<label for="pl_activation">Activation key</label>
<input type="text" class="pl-text-input" name="pl_activation" id="pl_activation" <?php echo $key . $disabled ?>/>


<?php
if( pl_is_pro() ) {
echo '<input type="hidden" name="pl_revoke" id="pl_revoke" value="true" />';
}

<label>PageLines Password</label>
<input type="password" class="pl-text-input" />
?>
<div class="submit-area">
<button class="btn btn-primary" >Submit</button>
<button class="btn btn-primary settings-action" data-action="pagelines-account"><?php echo $activate_text; ?></button>
</div>
<?php



}

function pagelines_support(){
Expand Down
57 changes: 55 additions & 2 deletions editor/editor.actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,63 @@ function pl_up_image (){
echo json_encode(array('url' => $uploaded_file['url'], 'success' => TRUE));

}
die(); // don't forget this, always returns 0 w/o
}

add_action( 'wp_ajax_pl_account_actions', 'pl_account_actions' );

function pl_account_actions() {
$postdata = $_POST;
$response = array();

$response['key'] = $postdata['key'];
$response['email'] = $postdata['email'];
$response['active'] = false;
$response['refresh'] = false;

$activated = array( 'active' => false, 'key' => '', 'message' => '', 'email' => '' );

if( $postdata['key'] && $postdata['email'] ) {
$state = 'activation';

if( true == $postdata['revoke'] )
$state = 'deactivation';

$url = sprintf( 'http://www.pagelines.com/?wc-api=software-api&request=%s&product_id=dmspro&licence_key=%s&email=%s&instance=%s', $state, $response['key'], $response['email'], site_url() );

$response['url'] = $url;
// $response['postdata'] = $postdata;
$data = wp_remote_get( $url );



$rsp = json_decode( $data['body'] );

if( isset( $rsp->activated ) ) {
$response['active'] = $rsp->activated;
}
$response['message'] = ( isset( $rsp->error ) ) ? $rsp->error : $rsp->message;

die(); // don't forget this, always returns 0 w/o

} else {
$response['message'] = 'There was an error!';
}
if( true == $rsp->activated ) {
$activated['message'] = $rsp->message;
$activated['instance'] = $rsp->instance;
$activated['active'] = true;
$activated['key'] = $response['key'];
$activated['email'] = $response['email'];
$response['refresh'] = true;
}

if( isset( $rsp->reset ) && true == $rsp->reset ){
$response['message'] = 'Deactivated activation for ' . site_url();
$response['refresh'] = true;
}

// $response['rsp'] = $rsp;
update_option( 'dms_activation', $activated );
echo json_encode( pl_arrays_to_objects( $response ) );

exit();
}
6 changes: 5 additions & 1 deletion editor/editor.premium.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

function pl_is_pro(){

return false;
$status = get_option( 'dms_activation', array( 'active' => false, 'key' => '', 'message' => '', 'email' => '' ) );

$pro = (true === $status['active']) ? true : false;

return $pro;

}

Expand Down
37 changes: 37 additions & 0 deletions editor/js/pl.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,43 @@

that.tabLink(tabLink, tabSubLink)
}

$('[data-action="pagelines-account"]').on('click', function() {


var key = $('#pl_activation').val()
, email = $('#pl_email').val()
, revoke = $('#pl_revoke').val()
, theData = {
action: 'pl_account_actions'
, key: key
, email: email
, revoke: revoke
}

$.ajax({
type: 'POST'
, url: ajaxurl
, data: theData
, beforeSend: function(){

}
, success: function( response ){

var rsp = $.parseJSON( response )
, textRsp = sprintf('<div class="alert alert-info">%s</div>', rsp.message)
$('.account-description').html( textRsp )

var url = sprintf( '%s?tablink=account&tabsublink=pl_account', $.pl.config.siteURL)
if( true == rsp.refresh )
pl_url_refresh(url,1000)

console.log(response)
}
})


})
}

, tabLink: function(tabLink, tabSubLink){
Expand Down
6 changes: 2 additions & 4 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Theme Name: PageLines Framework
Description: !!!MASTER BRANCH!!! A responsive drag-and-drop platform for professional websites based on HTML5 and CSS3. PageLines will help you do amazing things faster & easier than ever before. Designed by <a href="http://pagelines.com/">PageLines</a> in California. Twitter @pagelines
Version: 2.5_alpha5
Version: 2.5_alpha6
Author: PageLines
Expand Down Expand Up @@ -47,6 +47,4 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
* The license for this software can also likely be found here:
* http://www.gnu.org/licenses/gpl-2.0.html
*
********************************************************************************************************************************/


********************************************************************************************************************************/

0 comments on commit 2367cfa

Please sign in to comment.