Ejemplo n.º 1
0
 /**
  * This is not the best example to follow
  * Please see the category plugin for a better example
  */
 public function post()
 {
     require_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $db =& JFactory::getDBO();
     $app = JFactory::getApplication();
     $userid = JRequest::getInt('user_id', 0);
     $planid = JRequest::getInt('plan_id', 0);
     //$new_expiry = JRequest::getString('date',0);
     $obj = new stdClass();
     //validate plan
     $plans = SubscriptionPlanHandler::getPlanList();
     $muser = metaUserDB::getIDbyUserid($userid);
     //$pplan = metaUserDB::getPreviousPlan($muser);
     //$uplan = metaUserDB::getUsedPlans($muser);
     //print_r($new_expiry);die;
     if (!$userid) {
         $obj->success = 0;
         $obj->code = 21;
         $obj->message = "invalid user id";
     } elseif (!$plans[array_search($planid, $plans)]) {
         $obj->success = 0;
         $obj->code = 22;
         $obj->message = "invalid plan id";
     } else {
         $plan = new SubscriptionPlan($db);
         $plan->load($planid);
         //print_r($plan->params['full_period']);die;
         //check user is metauser
         /*if ( is_a( $user, 'metaUser' ) ) {
         			$metaUser = $user;
         			} elseif( is_a( $user, 'Subscription' ) ) {
         			$metaUser = new metaUser( $user->userid );
         
         			$metaUser->focusSubscription = $user;
         			}*/
         $metaUser = new metaUser($userid);
         $renew = $metaUser->is_renewing();
         //$metaUser->focusSubscription->lifetime;
         $metaUser->focusSubscription->plan = $planid;
         $metaUser->focusSubscription->status = 'Active';
         $metaUser->temporaryRFIX();
         //$metaUser->focusSubscription->lifetime = 1;
         //set expiration
         $now = (int) gmdate('U');
         //$current = strtotime($new_expiry);
         //$metaUser->focusSubscription->expiration = $new_expiry;
         //$metaUser->objSubscription->expiration = $new_expiry;
         $reply = $metaUser->focusSubscription->storeload();
         if ($reply && $planid) {
             $history = new logHistory($db);
             $obj->success = 1;
             $obj->message = "User added to plan";
         }
     }
     $this->plugin->setResponse($obj);
 }
Ejemplo n.º 2
0
 /**
  * This is not the best example to follow
  * Please see the category plugin for a better example
  */
 public function post()
 {
     require_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $db =& JFactory::getDBO();
     $app = JFactory::getApplication();
     $userid = JRequest::getInt('user_id', 0);
     $planid = JRequest::getInt('plan_id', 0);
     $new_expiry = JRequest::getString('date', 0);
     //convert date in format
     $new_expiry = date("Y-m-d h:i:s", strtotime($new_expiry));
     $obj = new stdClass();
     //validate plan
     $plans = SubscriptionPlanHandler::getPlanList();
     $muser = metaUserDB::getIDbyUserid($userid);
     $plnuser = SubscriptionPlanHandler::getPlanUserlist($planid);
     if (!$userid) {
         $obj->success = 0;
         $obj->code = 21;
         $obj->message = "invalid user id";
     } elseif (!$plans[array_search($planid, $plans)]) {
         $obj->success = 0;
         $obj->code = 22;
         $obj->message = "invalid plan id";
     } elseif ($userid == $plnuser[array_search($userid, $plnuser)]) {
         $plan = new SubscriptionPlan($db);
         $plan->load($planid);
         $metaUser = new metaUser($userid);
         $renew = $metaUser->is_renewing();
         $lifetime = $metaUser->focusSubscription->lifetime;
         $metaUser->focusSubscription->plan = $planid;
         $metaUser->focusSubscription->status = 'Active';
         $metaUser->temporaryRFIX();
         $metaUser->focusSubscription->lifetime = 0;
         //set expiration
         //$now = (int) gmdate('U');
         $metaUser->focusSubscription->expiration = $new_expiry;
         //$metaUser->objSubscription->expiration = $new_expiry;
         $reply = $metaUser->focusSubscription->storeload();
         if ($reply && $planid) {
             $obj->success = 1;
             $obj->message = "Expiry updated";
         }
     } else {
         $obj->success = 0;
         $obj->code = 31;
         $obj->message = "Plan not assigned to user";
     }
     $this->plugin->setResponse($obj);
 }
Ejemplo n.º 3
0
 public function Settings()
 {
     $db = JFactory::getDBO();
     $settings = array();
     if (!empty($_POST['type']) && !empty($_POST['id']) && empty($_POST['edit'])) {
         $db = JFactory::getDBO();
         $settings['edit'] = array('hidden', 1);
         $settings['type'] = array('hidden', $_POST['type']);
         $fixed = array();
         switch ($_POST['type']) {
             case 'metauser':
                 $fixed = array('userid');
                 $object = new metaUserDB();
                 $s = AECToolbox::searchUser($_POST['id']);
                 if (!empty($s)) {
                     $_POST['id'] = $object->getIDbyUserid($s[0]);
                 } else {
                     $_POST['id'] = $object->getIDbyUserid((int) $_POST['id']);
                 }
                 break;
             case 'processor':
                 if (!is_numeric($_POST['id'])) {
                     $query = 'SELECT `id`' . ' FROM #__acctexp_config_processors' . ' WHERE `name` = \'' . (int) $_POST['id'] . '\'';
                     $db->setQuery($query);
                     $_POST['id'] = $db->loadResult();
                 }
                 $object = new processor();
                 break;
             case 'invoice':
                 if (!is_numeric($_POST['id'])) {
                     $_POST['id'] = aecInvoiceHelper::InvoiceIDfromNumber($_POST['id']);
                 }
                 $object = new Invoice();
                 break;
         }
         $object->load($_POST['id']);
         $vars = get_object_vars($object);
         $encoded = $object->declareParamFields();
         foreach ($vars as $k => $v) {
             if (is_null($k)) {
                 $k = "";
             }
             if ($k == 'id') {
                 $settings['id'] = array('hidden', $v);
             } elseif (in_array($k, $fixed)) {
                 $settings[$k] = array('p', $k, $k, $v);
             } elseif (in_array($k, $encoded)) {
                 $v = jsoonHandler::encode($v);
                 if ($v === "null") {
                     $v = "";
                 }
                 $settings[$k] = array('inputD', $k, $k, $v);
             } elseif (strpos($k, '_') !== 0) {
                 $settings[$k] = array('inputD', $k, $k, $v);
             }
         }
     } else {
         $settings['type'] = array('list', 'Item Type', 'The type of Item you want to edit');
         $settings['id'] = array('inputC', 'Item ID', 'Identification for your Item');
         $types = array('metauser' => 'MetaUser Information', 'processor' => 'Payment Processor', 'invoice' => 'Invoice');
         $typelist = array();
         foreach ($types as $type => $typename) {
             $typelist[] = JHTML::_('select.option', $type, $typename);
         }
         $settings['lists']['type'] = JHTML::_('select.genericlist', $typelist, 'type', 'size="3"', 'value', 'text', array());
     }
     return $settings;
 }
Ejemplo n.º 4
0
 * @author David Deutsch <*****@*****.**> & Team AEC - http://www.valanx.org
 * @license GNU/GPL v.3 http://www.gnu.org/licenses/gpl.html or, at your option, any later version
 */
// Dont allow direct linking
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
$query = 'SELECT `id`' . ' FROM #__acctexp_metauser';
$db->setQuery($query);
$entries = xJ::getDBArray($db);
/*
 * This may seem odd, but due to unforseen consequences, json encoding and decoding
 * actually fixes some numeric properties so that we can switch them over to arrays,
 * which is done with get_object_vars as its the quickest AND, uhm, dirtiest method.
 * without the encoding and decoding, get_object_vars just purrs out an empty array.
 */
foreach ($entries as $eid) {
    $meta = new metaUserDB();
    $meta->load($eid);
    if (!empty($meta->params)) {
        if (is_object($meta->params)) {
            if (is_object($meta->params->mi)) {
                $new = get_object_vars(json_decode(json_encode($meta->params->mi)));
                $meta->params->mi = $new;
            }
        }
    }
    if (!empty($meta->plan_params)) {
        if (is_object($meta->plan_params)) {
            $temp = get_object_vars(json_decode(json_encode($meta->plan_params)));
            $new = array();
            foreach ($temp as $pid => $param) {
                $new[$pid] = get_object_vars(json_decode(json_encode($param)));
Ejemplo n.º 5
0
             $temp = explode(';', $object->{$fieldname});
             array_walk($temp, 'trim');
         } else {
             foreach ($temp as $key => $value) {
                 if (in_array($key, $ucontent[2][$fieldname])) {
                     $temp[$key] = explode(';', $value);
                     array_walk($temp[$key], 'trim');
                 }
             }
         }
     }
 }
 // Make sure to capture exceptions
 if ($dbtable == 'subscr' && $fieldname == 'params') {
     if (isset($object->userid)) {
         $metaUserDB = new metaUserDB();
         $metaUserDB->loadUserid($object->userid);
         if (!empty($temp)) {
             $vs = new stdClass();
             $vsmi = new stdClass();
             foreach ($temp as $key => $value) {
                 if (strpos($key, 'MI_FLAG') !== false) {
                     $ks = explode('_', $key);
                     $vname = array();
                     foreach ($ks as $n => $k) {
                         if (in_array($n, array(0, 1, 2, 4))) {
                             // And nothing of value was lost
                         } elseif ($n == 3) {
                             // Set usage
                             $usage = $k;
                         } elseif ($n == 5) {