-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AEC APIs as part of Gyre Consulting
- Loading branch information
Ashwin Date
committed
Feb 1, 2013
1 parent
6440786
commit c1d6f05
Showing
8 changed files
with
707 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* @package API | ||
* @version 1.5 | ||
* @author Brian Edgerton | ||
* @link http://www.edgewebworks.com | ||
* @copyright Copyright (C) 2011 Edge Web Works, LLC. All rights reserved. | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||
*/ | ||
|
||
defined('_JEXEC') or die( 'Restricted access' ); | ||
|
||
jimport('joomla.plugin.plugin'); | ||
|
||
class plgAPIAec extends ApiPlugin | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
ApiResource::addIncludePath(dirname(__FILE__).'/aec'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<install version="1.7" type="plugin" group="api" method="upgrade"> | ||
<name>Api - aec</name> | ||
<version>1.0</version> | ||
<creationDate>Jan 2013</creationDate> | ||
<author>Tekdi</author> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>http://www.tekdi.com</authorUrl> | ||
<copyright>2012 users</copyright> | ||
<license>GNU General Public License v2</license> | ||
<description>API plugins of AEC components of the Joomla! </description> | ||
|
||
<files> | ||
<filename plugin="aec">aec.php</filename> | ||
<filename >aec/userlist.php</filename> | ||
<filename >aec/createuser.php</filename> | ||
<folder>aec</folder> | ||
</files> | ||
</install> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
/** | ||
* @package API | ||
* @version 1.5 | ||
* @author Brian Edgerton | ||
* @link http://www.edgewebworks.com | ||
* @copyright Copyright (C) 2011 Edge Web Works, LLC. All rights reserved. | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||
*/ | ||
|
||
defined('_JEXEC') or die( 'Restricted access' ); | ||
|
||
jimport('joomla.plugin.plugin'); | ||
jimport('joomla.html.html'); | ||
jimport('joomla.user.helper'); | ||
jimport( 'joomla.application.component.helper' ); | ||
jimport( 'joomla.application.component.model' ); | ||
jimport( 'joomla.database.table.user' ); | ||
|
||
require_once( JPATH_SITE .DS.'libraries'.DS.'joomla'.DS.'filesystem'.DS.'folder.php'); | ||
|
||
/*if(JFolder::exists(JPATH_BASE.DS.'components'.DS.'com_xipt')) | ||
{ | ||
require_once( JPATH_SITE .DS.'components'.DS.'com_xipt'.DS.'api.xipt.php'); | ||
}*/ | ||
|
||
class AecApiResourceCreateuser extends ApiResource | ||
{ | ||
|
||
public function post() | ||
{ | ||
|
||
$error_messages = array(); | ||
$fieldname = array(); | ||
$response = NULL; | ||
$validated = true; | ||
$userid = NULL; | ||
$data = JRequest::get('post'); | ||
|
||
//for rest api only | ||
unset($data['format']); | ||
unset($data['resource']); | ||
unset($data['app']); | ||
unset($data['key']); | ||
// | ||
//$userid = $data['userid']; | ||
//$fields = $data['field']; | ||
//print_r($_POST); die; | ||
//chk data | ||
if($data['email']=="" ) | ||
{ | ||
$validated = false; | ||
$error_messages[] = array("success"=>0,"id"=>16,"fieldname"=>"email","message"=>"Email cannot be blank"); | ||
} elseif( false == $this->isValidEmail( $data['email'] ) ) { | ||
$validated = false; | ||
$error_messages[] = array("success"=>0,"id"=>16,"fieldname"=>"email","message"=>"Please set valid email id eg.([email protected]). Check 'email' field in request"); | ||
|
||
} | ||
if( $data['password']=="" ) | ||
{ | ||
$validated = false; | ||
$error_messages[] = array("success"=>0,"id"=>15,"fieldname"=>"password","message"=>"Password cannot be blank"); | ||
} | ||
|
||
if( $data['name']=="" or $data['username']=="" ) | ||
{ | ||
$validated = false; | ||
$error_messages[] = array("success"=>0,"id"=>14,"fieldname"=>"name/username","message"=>"Name cannot be blank"); | ||
} | ||
|
||
if( true == $validated) | ||
{ //to create new user for joomla | ||
|
||
global $message; | ||
jimport('joomla.user.helper'); | ||
$authorize = & JFactory::getACL(); | ||
$user = clone(JFactory::getUser()); | ||
$user->set('username', $data['username']); | ||
$user->set('password', $data['password'] ); | ||
$user->set('name', $data['name']); | ||
$user->set('email', $data['email']); | ||
|
||
// password encryption | ||
$salt = JUserHelper::genRandomPassword(32); | ||
$crypt = JUserHelper::getCryptedPassword($user->password, $salt); | ||
$user->password = "$crypt:$salt"; | ||
|
||
// user group/type | ||
$user->set('id', ''); | ||
$user->set('usertype', 'Registered'); | ||
if(JVERSION >= '1.6.0') | ||
{ | ||
$userConfig = JComponentHelper::getParams('com_users'); | ||
// Default to Registered. | ||
$defaultUserGroup = $userConfig->get('new_usertype', 2); | ||
$user->set('groups', array($defaultUserGroup)); | ||
} | ||
else | ||
$user->set('gid', $authorize->get_group_id( '', 'Registered', 'ARO' )); | ||
|
||
$date =& JFactory::getDate(); | ||
$user->set('registerDate', $date->toMySQL()); | ||
|
||
// true on success, false otherwise | ||
if(!$user->save()) | ||
{ | ||
$message="not created because of ".$user->getError(); | ||
return false; | ||
} | ||
else | ||
{ | ||
$message="created of username-".$user->username." and send mail of details please check"; | ||
|
||
} | ||
//$this->plugin->setResponse($user->id); | ||
$userid = $user->id; | ||
|
||
//result message | ||
$result = array('success'=>1,'user id '=>$userid,'username'=>$user->username,'message'=>$message); | ||
$result =($userid) ? $result : $message; | ||
|
||
$this->plugin->setResponse($result); | ||
|
||
|
||
} | ||
else | ||
{ | ||
|
||
$this->plugin->setResponse($error_messages);//print_r($error_messages); die("validate mail2222"); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
function isValidEmail( $email ) | ||
{ | ||
$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"; | ||
|
||
if ( preg_match( $pattern, $email ) ) | ||
{ | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
/** | ||
* @package K2 API plugin | ||
* @version 1.0 | ||
* @author Rafael Corral | ||
* @link http://www.rafaelcorral.com | ||
* @copyright Copyright (C) 2011 Rafael Corral. All rights reserved. | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
jimport('joomla.plugin.plugin'); | ||
//function in file - /var/www/mppronline/administrator/components/com_acctexp/admin.acctexp.php | ||
|
||
|
||
class AecApiResourcePlanslist extends ApiResource | ||
{ | ||
public function get() | ||
{ | ||
require_once JPATH_SITE .'/components/com_acctexp/acctexp.class.php'; | ||
$limitstart = JRequest::getInt('limitstart',0); | ||
$limit = JRequest::getInt('limit',20); | ||
$active = JRequest::getInt('active',0); | ||
$visible = JRequest::getInt('visible',0); | ||
$name = JRequest::getVar('name',''); | ||
$pattern = '/' . preg_quote($name, '/') . '/'; | ||
|
||
$limit = ($limit>100)?100:$limit; | ||
|
||
$t_plans = SubscriptionPlanHandler::getFullPlanList(); | ||
$plans = SubscriptionPlanHandler::getFullPlanList($limitstart,$limit); | ||
$data = array(); | ||
$data["total"] = count($t_plans); | ||
$sel_plan = array(); | ||
foreach($plans as $k=>$val) | ||
{ | ||
|
||
//$val->group_id = ItemGroupHandler::getItemListItem($val); | ||
unset($val->params); | ||
unset($val->custom_params); | ||
unset($val->restrictions); | ||
unset($val->micro_integrations); | ||
unset($val->lifetime); | ||
unset($val->email_desc); | ||
|
||
if($active && $visible && $val->active == 1 && $val->visible == 1 ) | ||
{ | ||
$sel_plan[$val->id] = $val; | ||
} | ||
elseif($active && $val->active == $active && $val->visible != 0 ) | ||
{ | ||
|
||
$sel_plan[$val->id] = $val; | ||
} | ||
elseif($visible && $val->visible == $visible && $val->active != 0) | ||
{ | ||
|
||
$sel_plan[$val->id] = $val; | ||
} | ||
elseif($visible ==0 && $active == 0 && $name == '' ) | ||
{ | ||
$sel_plan[$val->id] = $val; | ||
} | ||
|
||
} | ||
//$match = preg_match($pattern, $val->name); | ||
$name_arr = array(); | ||
foreach($sel_plan as $k=>$v) | ||
{ | ||
|
||
if(preg_match($pattern, $v->name)) | ||
{ | ||
|
||
$name_arr[$v->id] = $v; | ||
} | ||
$sel_plan =$name_arr; | ||
} | ||
|
||
|
||
|
||
$data['count']=count($sel_plan); | ||
$data['users']=$sel_plan; | ||
$this->plugin->setResponse($data); | ||
|
||
|
||
} | ||
|
||
/** | ||
* This is not the best example to follow | ||
* Please see the category plugin for a better example | ||
*/ | ||
public function post() | ||
{ | ||
|
||
$this->plugin->setResponse( "this is post data" ); | ||
} | ||
|
||
public function put() | ||
{ | ||
// Simply call post as K2 will just save an item with an id | ||
/*$this->post(); | ||
$response = $this->plugin->get( 'response' ); | ||
if ( isset( $response->success ) && $response->success ) { | ||
JResponse::setHeader( 'status', 200, true ); | ||
$response->code = 200; | ||
$this->plugin->setResponse( $response ); | ||
}*/ | ||
} | ||
|
||
function qry() | ||
{ | ||
$db = &JFactory::getDBO(); | ||
$qry = "SELECT count(*) FROM #__acctexp_subscr AS a INNER JOIN #__users AS b ON a.userid = b.id WHERE ((a.status = 'Active' || a.status = 'Trial'))"; | ||
$db->setQuery( $query ); | ||
$total = $db->loadResult(); | ||
} | ||
|
||
} |
Oops, something went wrong.