');
+ $this->plugin->setResponse( $item );
+
+ }
+
+ public function get() {
+ $input = JFactory::getApplication()->input;
+ $model = EasyBlogHelper::getModel( 'Blog' );
+ $config = EasyBlogHelper::getConfig();
+ $id = $input->get('id', null, 'INT');
+
+ // If we have an id try to fetch the user
+ $blog = EasyBlogHelper::getTable( 'Blog' );
+ $blog->load( $id );
+
+ if (!$id) {
+ $this->plugin->setResponse( $this->getErrorResponse(404, 'Blog id cannot be blank') );
+ return;
+ }
+
+ if (!$blog->id) {
+ $this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') );
+ return;
+ }
+
+ $item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, '
- ');
+ $this->plugin->setResponse( $config->get('comment_disqus_code') );
+ }
+
+}
diff --git a/easyblog/easyblog/category.php b/easyblog/easyblog/category.php
new file mode 100644
index 0000000..bb4d082
--- /dev/null
+++ b/easyblog/easyblog/category.php
@@ -0,0 +1,75 @@
+plugin->setResponse( $this->getErrorResponse(404, 'Easyblog not installed') );
+ return;
+ }
+ require_once( JPATH_ROOT . '/components/com_easyblog/helpers/helper.php' );
+ }
+ public function delete()
+ {
+ $this->plugin->setResponse( 'in delete' );
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse( 'in post' );
+ }
+
+ public function get() {
+ $input = JFactory::getApplication()->input;
+ $model = EasyBlogHelper::getModel( 'Blog' );
+ $category = EasyBlogHelper::getTable( 'Category', 'Table' );
+ $id = $input->get('id', null, 'INT');
+ $search = $input->get('search', null, 'STRING');
+ $posts = array();
+
+ $category->load($id);
+
+ // private category shouldn't allow to access.
+ $privacy = $category->checkPrivacy();
+
+ if(! $privacy->allowed )
+ {
+ $this->plugin->setResponse( $this->getErrorResponse(404, 'Category not found') );
+ return;
+ }
+
+ $catIds = array();
+ $catIds[] = $category->id;
+ EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
+
+ $sorting = $this->plugin->params->get( 'sorting' , 'latest' );
+ $total = (int) $this->plugin->params->get( 'total' , 20 );
+ $rows = $model->getBlogsBy( 'category' , $catIds , $sorting , $total, EBLOG_FILTER_PUBLISHED, $search );
+
+ foreach ($rows as $k => $v) {
+ $item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text'));
+ $posts[] = $item;
+ }
+
+ $this->plugin->setResponse( $posts );
+ }
+
+}
diff --git a/easyblog/easyblog/latest.php b/easyblog/easyblog/latest.php
new file mode 100644
index 0000000..87af64b
--- /dev/null
+++ b/easyblog/easyblog/latest.php
@@ -0,0 +1,73 @@
+plugin->setResponse( $this->getErrorResponse(404, 'Easyblog not installed') );
+ return;
+ }
+ require_once( JPATH_ROOT . '/components/com_easyblog/helpers/helper.php' );
+ }
+ public function delete()
+ {
+ $this->plugin->setResponse( 'in delete' );
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse( 'in post' );
+ }
+
+ public function get() {
+ $input = JFactory::getApplication()->input;
+ $model = EasyBlogHelper::getModel( 'Blog' );
+ $id = $input->get('id', null, 'INT');
+ $search = $input->get('search', null, 'STRING');
+ $posts = array();
+
+ // If we have an id try to fetch the user
+ $blog = EasyBlogHelper::getTable( 'Blog' );
+ $blog->load( $id );
+
+ if ($id) {
+ if(!$blog->id) {
+ $this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') );
+ return;
+ }
+
+ $this->plugin->setResponse( $blog );
+ } else {
+
+ $sorting = $this->plugin->params->get( 'sorting' , 'latest' );
+ $total = (int) $this->plugin->params->get( 'total' , 20 );
+ $rows = $model->getBlogsBy( $sorting , '' , $sorting , $total, EBLOG_FILTER_PUBLISHED, $search );
+
+ foreach ($rows as $k => $v) {
+ $item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text'));
+ $posts[] = $item;
+ }
+
+ $this->plugin->setResponse( $posts );
+ }
+ }
+
+}
diff --git a/users/users.php b/users/users.php
index 157fb04..68615c7 100755
--- a/users/users.php
+++ b/users/users.php
@@ -14,10 +14,13 @@
class plgAPIUsers extends ApiPlugin
{
- public function __construct()
+ public function __construct(&$subject, $config = array())
{
- parent::__construct();
+ parent::__construct($subject, $config = array());
ApiResource::addIncludePath(dirname(__FILE__).'/users');
+
+ // Set the login resource to be public
+ $this->setResourceAccess('login', 'public');
}
}
diff --git a/users/users/users_delete.php b/users/users/users_delete.php
deleted file mode 100755
index c955ba1..0000000
--- a/users/users/users_delete.php
+++ /dev/null
@@ -1,73 +0,0 @@
-setQuery($query);
- //$data1 = $db->loadResult();
- if (!$db->query())
- {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
- else
- {
- $this->plugin->setResponse( "User of id = ".$userid." deleted" );
- }
-
-
- }
-
-
-}
diff --git a/users/users/users_update.php b/users/users/users_update.php
deleted file mode 100755
index 5f319e4..0000000
--- a/users/users/users_update.php
+++ /dev/null
@@ -1,143 +0,0 @@
-1,"fieldname"=>"email","message"=>"Email cannot be blank");
- } elseif( false == $this->isValidEmail( $data['email'] ) ) {
- $validated = false;
- $error_messages[] = array("id"=>1,"fieldname"=>"email","message"=>"Please set valid email id eg.(example@gmail.com). Check 'email' field in request");
-
- }
-
- if( $data['pass_word']=="" )
- {
- $validated = false;
- $error_messages[] = array("id"=>1,"fieldname"=>"password","message"=>"Password cannot be blank");
- }
-
- if( $data['name']=="" or $data['username1']=="" )
- {
- $validated = false;
- $error_messages[] = array("id"=>1,"fieldname"=>"name","message"=>"Name cannot be blank");
- }
-
- if( true == $validated)
- {
- //to update user for joomla
- global $message;
- jimport('joomla.user.helper');
- $authorize = & JFactory::getACL();
- $user = clone(JFactory::getUser());
-
- $user->set('id', $data['userid']);
- $user->set('username', $data['username1']);
- $user->set('password', $data['pass_word'] );
- $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";
-
- // true on success, false otherwise
- if(!$user->save())
- {
- $message="not created because of ".$user->getError();
- return false;
- }
- else
- {
- $message="username-".$user->username." is updated";
-
- }
-
- if(isset($data['field']))
- {
- $fields = $data['field'];
- //to access model function
- $profileModel =& CFactory::getModel('profile');
- //using update function
- foreach($fields as $id=>$value)
- {
- //to get fieldcode
- $fieldcode = $profileModel->getFieldCode($id);
- $profileModel->updateUserData( $fieldcode , $userid , $value );
-
- }
- //using saveprofile function
- //$val = $profileModel->saveProfile($userid, $fields);
- //$userid = $user->id;
- }
- $result = array('user id '=>$userid,'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})$";
-
- if ( eregi( $pattern, $email )) {
- return true;
- } else {
- return false;
- }
- }
-
-}