API - OSE Membership 5

From Open Source Excellence Knowledge Base
Jump to: navigation, search

We will add more API codes here, if you would like to know more API codes, please submit a ticket and we will add them here asap.

Content

Get All OSE Controlled Joomla Article IDs

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $oseContent = oseRegistry :: call('content'); $resContentIDs= $oseContent->getRestrictedContent('joomla', 'article'); // Return an array with all Joomla Article IDs that are controlled by OSE and cannot be accessed by the user; </highlightSyntax>

Get All OSE Controlled Joomla Menu IDs

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $oseContent = oseRegistry :: call('content'); $resMenuIDs= $oseContent->getRestrictedContent('joomla', 'menu'); // Return an array with all Joomla Menu IDs that are controlled by OSE and cannot be accessed by the user; </highlightSyntax>

Get All OSE Controlled Joomla Module IDs

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $oseContent = oseRegistry :: call('content'); $resModuleIDs= $oseContent->getRestrictedContent('joomla', 'module'); // Return an array with all Joomla Module IDs that are controlled by OSE and cannot be accessed by the user; </highlightSyntax>

Get All OSE Controlled Joomla Component IDs

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $oseContent = oseRegistry :: call('content'); $resComponentIDs= $oseContent->getRestrictedContent('joomla', 'component'); // Return an array with all Joomla Component IDs that are controlled by OSE and cannot be accessed by the user; </highlightSyntax>

Get All OSE Controlled PhocaDownload Category IDs

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $oseContent = oseRegistry :: call('content'); $resPhocaCatIDs= $oseContent->getRestrictedContent('phoca','category'); // Return an array with all PhocaDownload Category IDs that are controlled by OSE and cannot be accessed by the user; </highlightSyntax>

Payments

Get the currency being used

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $session =& JFactory::getSession(); $osePaymentCurrency = $session->get('osePaymentCurrency',oseRegistry::call('msc')->getConfig('currency','obj')->primary_currency); // Returns a string with the value of the currency that the user currently selects </highlightSyntax>

Get the Payment Information of a membership given a membership plan ID

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $mscID = 1; // Please replace this value for the actual membership plan ID; $paymentInfos = oseRegistry::call('msc')->getExtInfo($mscID,'payment','array'); // Returns an array of the payment information of the membership given the membership plan ID; </highlightSyntax>

Member Information

Get a user's information

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $member= oseRegistry :: call('member'); $member_id = 62; // Please replace the actual member ID that you would like to retrieve the information; $member->instance($member_id); $userInfo= $member->getUserInfo('obj'); // OR $userInfo=$member->getUserInfo('array'); /* Return an Object (if obj is used as data type) or an Array (if array is used as data type) of the following user information: user_id username email block firstname lastname

  • /

</highlightSyntax>

Get a user's billing information information

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $member= oseRegistry :: call('member'); $member_id = 62; // Please replace the actual member ID that you would like to retrieve the information; $member->instance($member_id); $userInfo= $member->getBillingInfo('obj'); // OR $userInfo=$member->getBillingInfo('array'); /* Return an Object (if obj is used as data type) or an Array (if array is used as data type) of the following user information: username user_email firstname lastname company addr1 addr2 city state country postcode telephone

  • /

</highlightSyntax>

Get a user's Membership information given a membership plan id

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $member= oseRegistry :: call('member'); $member_id = 62; // Please replace the actual member ID that you would like to retrieve the information; $membership_id =1; // Please replace the actual membership plan ID; $member->instance($member_id); $membershipInfo= $member->getMemberInfo($membership_id, 'obj'); // OR $membershipInfo=$member->getMemberInfo($membership_id, 'array'); /* Return an Object (if obj is used as data type) or an Array (if array is used as data type) of the following user information: msc_name --> Membership Plan Title msc_id --> Membership Plan ID member_id --> Member's User ID == Member's ID status --> 0 (inactive) OR 1 (active) start_date --> member's membership start date expired_date --> member's membership expiry date username --> member's Joomla! username email --> member's email address

  • /

</highlightSyntax>

Get a user's Membership information given a member id

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $member= oseRegistry :: call('member'); $member_id = 62; // Please replace the actual member ID that you would like to retrieve the information; $member->instance($member_id); $where = array(); $where[] = "member_id = ".$member_id; $membershipPlanList= $member->getMscList( $where, 'obj'); // OR $membershipPlanList= $member->getMscList( $where , 'array'); /* Return an Object (if obj is used as data type) or an Array (if array is used as data type) of the following user information: msc_id --> Membership Plan ID member_id --> Member's User ID == Member's ID status --> 0 (inactive) OR 1 (active) start_date --> member's membership start date expired_date --> member's membership expiry date

  • /

</highlightSyntax>

Membership Information

Get all Membership plans

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $msc = oseRegistry::call('msc'); $items = array(); $items = $msc->retrieveTree(); /* please use the following command:

print_r($ext); exit;

  • /

</highlightSyntax>

Get a Membership plan information given a membership plan id

<highlightSyntax> require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $msc= oseRegistry :: call('msc'); $msc_id = 1; // Please replace this value to the actual membership plan ID; $ext= $msc->getExtInfo($msc_id, 'msc', 'obj'); //OR $ext= $msc->getExtInfo($msc_id, 'msc', 'array'); /* Return an Object (if obj is used as data type) or an Array (if array is used as data type) of the membership plan information; The return values vary in different websites as it depends on how many addons you have on your website, to see the output of the values, please use the following command:

print_r($ext); exit;

  • /

</highlightSyntax>

Events

Joining a membership given a user id and membership plan id

<highlightSyntax> // Replace the XXX with the membership id you would like to add the user to the membership; replace YYY with the user's id; $msc_id = XXX; $user_id = YYY;

require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php');

$member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); $member->joinMsc($msc_id); </highlightSyntax>

Cancelling a membership plan given a user id and membership plan id

<highlightSyntax> // Replace the XXX with the membership id you would like to add the user to the membership; replace YYY with the user's id; $msc_id = XXX; $user_id = YYY;

require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php');

$member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); $member->cancelMsc($msc_id); </highlightSyntax>

Add your customized functions after a user joins a membership

Open this file

/components/com_osemsc/addons/action/join.msc.php

Look for this line

<highlightSyntax> public static function save($params) </highlightSyntax>

Add the functions after the following codes:

<highlightSyntax> if($orderInfo->payment_mode == 'm') { $updated = self::joinInManualMode($msc_id,$member_id,$orderInfo); } else {

       $updated = self::joinInAutomaticMode($msc_id,$member_id,$orderInfo);

}

// $updated returns either true or false here; </highlightSyntax>

Add your customized functions after a user cancels a membership

Open this file

/components/com_osemsc/addons/action/join.msc.php

Look for this line

<highlightSyntax> public static function cancel($params) </highlightSyntax>

Add the functions after the following codes:

<highlightSyntax> if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Cancel Msc Error"); } // $result['success'] returns either true or false here ; </highlightSyntax>

Add your customized functions after a user renews a membership

Open this file

/components/com_osemsc/addons/action/renew.msc.php

Look for this line

<highlightSyntax> public static function renew($params) </highlightSyntax>

Add the functions after the following codes:

<highlightSyntax> if($lastOrder->payment_mode == 'm') // m 2 a {

  $updated = self::renewInAutoMaticMode($msc_id,$member_id,$manual_to_automatic_mode,$curOrder,$ext);

} else // a 2 a extend {

  $updated = self::renewInAutoMaticMode($msc_id,$member_id,'extend',$curOrder,$ext);

}

// $updated returns either true or false here; </highlightSyntax>