Skip to content

Commit

Permalink
more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
amin0_000 committed Sep 29, 2014
1 parent ed348a2 commit b16d379
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 7 additions & 2 deletions software-license-manager/includes/slm-api-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ function activation_api_listener() {

$sql_prep2 = $wpdb->prepare("SELECT * FROM $reg_table WHERE lic_key = %s", $key);
$reg_domains = $wpdb->get_results($sql_prep2, OBJECT);

if ($retLic) {
if ($retLic->lic_status == 'blocked') {
$args = (array('result' => 'error', 'message' => 'Your License key is blocked'));
Expand All @@ -103,7 +102,7 @@ function activation_api_listener() {
SLM_API_Utility::output_api_response($args);
}

if (floor($retLic->max_allowed_domains) > count($reg_domains)) {
if (count($reg_domains) < floor($retLic->max_allowed_domains)) {
foreach ($reg_domains as $reg_domain) {
if (isset($_REQUEST['migrate_from']) && (trim($_REQUEST['migrate_from']) == $reg_domain->registered_domain)) {
$wpdb->update($reg_table, array('registered_domain' => $fields['registered_domain']), array('registered_domain' => trim(strip_tags($_REQUEST['migrate_from']))));
Expand All @@ -117,6 +116,12 @@ function activation_api_listener() {
}
$fields['lic_key_id'] = $retLic->id;
$wpdb->insert($reg_table, $fields);

$slm_debug_logger->log_debug("Updating license key status to active.");
$data = array('lic_status' => 'active');
$where = array('id' => $retLic->id);
$updated = $wpdb->update($tbl_name, $data, $where);

$args = (array('result' => 'success', 'message' => 'License key activated'));
SLM_API_Utility::output_api_response($args);
} else {
Expand Down
4 changes: 2 additions & 2 deletions software-license-manager/menu/lic_add_licenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function wp_lic_mgr_add_licenses_menu() {
<?php
if ($id != '') {
global $wpdb;
$reg_table = WP_LICENSE_MANAGER_REG_DOMAIN_TABLE_NAME;
$reg_table = SLM_TBL_LIC_DOMAIN;
$sql_prep = $wpdb->prepare("SELECT * FROM $reg_table WHERE lic_key_id = %s", $id);
$reg_domains = $wpdb->get_results($sql_prep, OBJECT);
?>
Expand Down Expand Up @@ -272,7 +272,7 @@ function wp_lic_mgr_add_licenses_menu() {
jQuery('.del').click(function() {
var $this = this;
jQuery('#reg_del_msg').html('Loading ...');
jQuery.get('<?php echo get_bloginfo('wpurl') ?>' + '/wp-admin/admin-ajax.php?action=del_dom&id=' + jQuery(this).attr('id'), function(data) {
jQuery.get('<?php echo get_bloginfo('wpurl') ?>' + '/wp-admin/admin-ajax.php?action=del_reistered_domain&id=' + jQuery(this).attr('id'), function(data) {
if (data == 'success') {
jQuery('#reg_del_msg').html('Deleted');
jQuery($this).parent().parent().remove();
Expand Down
11 changes: 5 additions & 6 deletions software-license-manager/slm_plugin_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ function slm_plugins_loaded_handler() {
}

//TODO - need to move this to an ajax handler file
add_action('wp_ajax_del_dom', 'del_reg_dom');

function del_reg_dom() {
$reg_table = WP_LICENSE_MANAGER_REG_DOMAIN_TABLE_NAME;
add_action('wp_ajax_del_reistered_domain', 'slm_del_reg_dom');
function slm_del_reg_dom() {
global $wpdb;
$sql_prep = $wpdb->prepare("DELETE FROM $reg_table WHERE id=%s", $_GET['id']);
$ret = $wpdb->query($sql_prep);
$reg_table = SLM_TBL_LIC_DOMAIN;
$id = strip_tags($_GET['id']);
$ret = $wpdb->query("DELETE FROM $reg_table WHERE id='$id'");
echo ($ret) ? 'success' : 'failed';
exit(0);
}

0 comments on commit b16d379

Please sign in to comment.