Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
kenno
Worker
Worker



Joined: Jul 26, 2009
Posts: 117
Location: Scunthorpe, UK

PostPosted: Sat Aug 06, 2011 8:15 am Reply with quote

Does anyone on here use the WS Subscription module on there sites, I have been using this for the past 6 months or so and although it is a vast improvement on what was there before it does not fully work the way I need it to.

I know your going to say go back to the author and believe me I have with numerous issues and he has helped a lot, for which I am great full, but with nearly 6 months of promises of a fix for this I thought I would ask on here.

The main problem lies where users who are subscribed already and already in there connected NSN group with there expiry time, these users if they renew EARLY without there subscription lapsing there NSN expiry time does not get updated automatically so that stays at there previous time and they get removed even though they still show as being subscribed in the WS Subscription admin.

I don`t think the problem will be that a hard fix as the plugin works and they get added in the assigned NSN group with the correct expiry time, if the users are not already in the NSN group

I think this lies somewhere in the NSN plugin file but I don`t have the ability or knowledge to fix this myself.

Here is that plugins file, if anyone can see anything that stands out can you let me know or maybe point me in the right direction.

Code:
<?php


if(!defined('WS_COPYRIGHT') && !defined('WS_ADMINCOPYRIGHT')){
die('You do not have direct access to this file.');
}

class wsNsngroups extends ws_Core{


function newSubscr($uid, $pid, $customid){
global $db, $prefix, $user_prefix;

ws_Core::GetPlanConfig($pid, 'wsNsngrps');

if(defined('NSN_OPT_GROUPS')){
   
   #get plan
   $plan = ws_Core::GetPlan($pid);
      #subscription expire time mod
      if($plan['records']['ws_plan_expire'] !='' && $plan['records']['ws_plan_expire'] != '0000-00-00 00:00:00'):
         #get time to expire
         $expire_val = strtotime($plan['records']['ws_plan_expire']);
         $subtime = $expire_val-time();
      else:
         $subtime = ws_Core::subtime_ws($plan['records']['wsn'], $plan['records']['wsp']);
      endif;
   
   #get username
   $uname = ws_Core::GetUname($uid);
      
//add member number if not available
$this->GetUserInfo(array('user_member_membernumber'), $uid);
$usernum = $this->getuserinfo[0]['user_member_membernumber'];

if($usernum >0 or $usernum !='99999')
{
   //number exists so do nothing
}else{
   //get the max member number
   $sql_unum = "SELECT MAX(user_member_membernumber) AS maxnum FROM ".$user_prefix."_users";
   $result_unum = $db->sql_query($sql_unum);
   $row_unum = $db->sql_fetchrow($result_unum);
   
   $new_mem_num = $row_unum['maxnum']+1;
   //update user table with member id
   $sql_update_num = "UPDATE ".$user_prefix."_users SET user_member_membernumber='".$new_mem_num."' WHERE user_id='".$uid."' AND (user_member_membernumber ='' OR user_member_membernumber='99999')";
   $db->sql_query($sql_update_num);
   
}
//end add member number



$nsngrps = explode(".", NSN_OPT_GROUPS);
      foreach ($nsngrps as $wsgid) {
       
      $sql = sprintf("SELECT COUNT(gid) as wsct FROM %s_nsngr_users WHERE gid='%d' AND uid ='%d'",
                       $prefix, (int)$wsgid, (int)$uid);
      if(!$result = $db->sql_query($sql)):
          ws_Core::ws_debug(__FILE__, __LINE__, $sql);
         return false;
          exit;
      endif;   
      list($wsct)=$db->sql_fetchrow($result);
         
         if($wsct <=0){//add new entry
         $stime2 = $subtime+time();
         $ntime = time();
         $sql2 = sprintf("INSERT INTO %s_nsngr_users (gid, uid, sdate, edate) VALUES('%d', '%d', '%s', '%s')",
                            $prefix, (int)$wsgid, (int)$uid, $ntime, $stime2);
                     if(!$result2 = $db->sql_query($sql2)):
                     ws_Core::ws_debug(__FILE__, __LINE__, $sql2.mysql_error());
                    return false;
                     exit;
                     endif;   
         }else{//update time
         
         $sql6 = sprintf("UPDATE %s_nsngr_users SET edate+%s WHERE gid='%d' AND uid='%d'",
                     $prefix,
                     $subtime,
                     (int)$wsgid,
                     (int)$uid
                     );   
                     if(!$result6 = $db->sql_query($sql6)):
                     ws_Core::ws_debug(__FILE__, __LINE__, $sql6);
                    return false;
                     exit;
                     endif;   
         }
      }
  }
 return true;
}//EOF

function recurSubscr($uid, $pid, $orderid){//subscription has recurred
global $db, $prefix, $user_prefix;

ws_Core::GetPlanConfig($pid, 'wsNsngrps');

if(defined('NSN_OPT_GROUPS')){
   
   #get plan
   $plan = ws_Core::GetPlan($pid);
      #subscription expire time mod
      if($plan['records']['ws_plan_expire'] !='' && $plan['records']['ws_plan_expire'] != '0000-00-00 00:00:00'):
         #get time to expire
         $expire_val = strtotime($plan['records']['ws_plan_expire']);
         $subtime = $expire_val-time();
      else:
         $subtime = ws_Core::subtime_ws($plan['records']['wsn'], $plan['records']['wsp']);
      endif;
   
   #get username
   $uname = ws_Core::GetUname($uid);
      
      
$nsngrps = explode(".", NSN_OPT_GROUPS);
      foreach ($nsngrps as $wsgid) {
       
      $sql = sprintf("SELECT COUNT(gid) as wsct FROM %s_nsngr_users WHERE gid='%d' AND uid ='%d'",
                       $prefix, (int)$wsgid, (int)$uid);
      if(!$result = $db->sql_query($sql)):
          ws_Core::ws_debug(__FILE__, __LINE__, $sql);
         return false;
          exit;
      endif;   
      list($wsct)=$db->sql_fetchrow($result);
         
         if($wsct <=0){//add new entry
         $stime2 = $subtime+time();
         $ntime = time();
         $sql2 = sprintf("INSERT INTO %s_nsngr_users (gid, uid, sdate, edate) VALUES ('%d', '%d', '%s', '%s')",
                            $prefix, (int)$wsgid, (int)$uid, $ntime, $stime2);
                     if(!$result2 = $db->sql_query($sql2)):
                     ws_Core::ws_debug(__FILE__, __LINE__, $sql2);
                    return false;
                     exit;
                     endif;   
         }else{//update time
         
         $sql6 = sprintf("UPDATE %s_nsngr_users SET edate+%s WHERE gid='%d' AND uid='%d'",
                     $prefix,
                     $subtime,
                     (int)$wsgid,
                     (int)$uid
                     );   
                     if(!$result6 = $db->sql_query($sql6)):
                     ws_Core::ws_debug(__FILE__, __LINE__, $sql6);
                    return false;
                     exit;
                     endif;   
         }
      }
  }
 return true;

}//EOF

function expireNSNGRSubscr($uid, $pid, $orderid){//subscription expire --wsgroups
global $db, $prefix, $user_prefix;

ws_Core::GetPlanConfig($pid, 'wsNsngrps');

if(NSN_OPT_GROUPS >0){

$ws_Grps = explode(".",NSN_OPT_GROUPS);
foreach ($ws_Grps as $wsgid) {
$db->sql_query("DELETE FROM ".$prefix."_nsngr_users WHERE  uid='".$uid."' AND gid='".wsgid."'");
       }

}

return true;

}//EOF




}//EOC


?>


Its also supposed to add a new member number on new sign up but it does not do that either but that is not the main issue I am wanting fixing.

But if someone could fix them both I would be willing to pay a small fee !

Thanks Mark
 
View user's profile Send private message
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Sat Aug 06, 2011 10:03 am Reply with quote

I will look into it. Not sure when that will be.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
kenno







PostPosted: Sat Aug 06, 2011 10:21 am Reply with quote

Palbin

That would be spot on, Like I say I will pay you for your time / make a donation to your site if you can fix the issues.

I appreciate you considering taking a look at this

Thanks Mark
 
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm



Joined: Aug 13, 2009
Posts: 1123

PostPosted: Sun Aug 07, 2011 7:41 am Reply with quote

Hi kenno

Long time ago I had the same problem but I fixed it with a simple mod and when the subscription expired automatically users are gone.

Open your header.php in the root where mainfile.php is

at the end before ?> you should copy and paste these codes

Code:
//remove subscribers mod

require 'modules/Subscription/includes/remove_subscr.php';
//DELETE SUBSCRIBERS MOD
global $prefix, $db;
$db->sql_query("DELETE FROM ".$prefix."_subscriptions WHERE subscription_expire <= '".time()."'");


Wink I hope it helps

Remember to use a DECENT EDITOR

http://www.flos-freeware.ch/notepad2.html
 
View user's profile Send private message
kenno







PostPosted: Sun Aug 07, 2011 8:05 am Reply with quote

Hi Unicornio

Thanks for the advice, but my problem with the module does is not an issue with removing expired users from the NSN group this works fine.

The problem is when the users who are already subscribed to a plan (membership) and they renew that membership before it runs out, the NSN expiry time does not get updated.
I am hoping it is a quick fix for someone in the know as the time does get added on the user originally taking the membership out.

Thanks Mark
 
kenno







PostPosted: Tue Aug 23, 2011 7:51 am Reply with quote

Palbin wrote:
I will look into it. Not sure when that will be.


Hi Palbin

Would you know when you would be able to give this sometime, I do not mind paying you or donating to your site for the time taken to fix this issue.

It is quite an annoying problem when I have to go through all expiring users and check to see if they have renewed early and then add them back to the correct NSN group.

If you do not have the time yet no problem

Thanks Mark
 
kenno







PostPosted: Mon Sep 05, 2011 1:46 pm Reply with quote

bump anyone

Should I add this in the for hire forum as I really need a fix for this as it is really starting to cause a lot of issues due to the manual checking of all expiring members
 
Palbin







PostPosted: Mon Sep 05, 2011 7:16 pm Reply with quote

Do you have version 4.0?
 
kenno







PostPosted: Thu Sep 08, 2011 10:55 am Reply with quote

Hi

Yes I have version 4.0, I can give you access to all the files if you require them Palbin
 
Palbin







PostPosted: Sun Sep 11, 2011 8:02 am Reply with quote

I need access to everything because there is not enough in the file you posted.
 
kenno







PostPosted: Sun Nov 06, 2011 4:20 am Reply with quote

Can anyone else help with this one ?
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Sun Nov 06, 2011 1:28 pm Reply with quote

Yes, but the problem is that this module is a commercial product and diving into the code whilst it is in use on a production environment could cause problems. There may be more than one file that needs tweaking.
 
View user's profile Send private message Send e-mail
kenno







PostPosted: Tue Nov 08, 2011 2:39 am Reply with quote

Yes I can understand that, I can set this up on a test site, Palbin has already taken a copy of the module to I guess set up somewhere for testing, but I think he is busy delving into other issues so I thought I would ask again, incase anyone else could spare some time to help
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©