* @link http://www.techjoomla.com
*/
-jimport('simpleschema.person');
-jimport('simpleschema.category');
+jimport('simpleschema.easyblog.person');
+jimport('simpleschema.easyblog.category');
class PostSimpleSchema {
@@ -36,6 +36,8 @@ class PostSimpleSchema {
public $rating;
+ public $rate = array();
+
public $category;
public function __construct() {
diff --git a/easysocial/easysocial.php b/easysocial/easysocial.php
index b1b1c79..86b39f0 100644
--- a/easysocial/easysocial.php
+++ b/easysocial/easysocial.php
@@ -11,11 +11,21 @@
class plgAPIEasysocial extends ApiPlugin
{
- public function __construct()
+ public function __construct(&$subject, $config = array())
{
- parent::__construct();
+ parent::__construct($subject = 'api' , $config = array());
ApiResource::addIncludePath(dirname(__FILE__).'/easysocial');
+
+ /*load language file for plugin frontend*/
+ $lang = JFactory::getLanguage();
+ $lang->load('plg_api_easysocial', JPATH_ADMINISTRATOR,'',true);
+
+ $this->setResourceAccess('terms', 'public', 'post');
+ $this->setResourceAccess('slogin', 'public', 'post');
+ $this->setResourceAccess('fblogin', 'public', 'post');
+
+
}
}
diff --git a/easysocial/easysocial.xml b/easysocial/easysocial.xml
index 25a1a4f..e1e63b7 100644
--- a/easysocial/easysocial.xml
+++ b/easysocial/easysocial.xml
@@ -1,18 +1,38 @@
- Api - easysocial
- 1.6
+ Api - Easysocial
+ 1.8.4
10/11/2014
Techjoomla
extensions@techjoomla.com
www.techjoomla.com
Techjoomla. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- This plugin use for get data from easysocial.
+ PLG_API_EASYSOCIAL_DESCRIPTION
easysocial.php
- easysocial/friends.php
+ easysocial/friend.php
+ libraries
easysocial
+
+
+ en-GB/en-GB.plg_api_easysocial.ini
+ en-GB/en-GB.plg_api_easysocial.sys.ini
+
+
+
+
+
+
+
+
diff --git a/easysocial/easysocial/album.php b/easysocial/easysocial/album.php
new file mode 100644
index 0000000..ded886a
--- /dev/null
+++ b/easysocial/easysocial/album.php
@@ -0,0 +1,218 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/photos.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/tables/album.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+require_once JPATH_SITE.'/components/com_easysocial/controllers/albums.php';
+
+class EasysocialApiResourceAlbum extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_album_images());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->create_album());
+ }
+ public function delete()
+ {
+ $this->plugin->setResponse($this->delete_check());
+ }
+ //switch case for photo delete or album delete.
+ public function delete_check()
+ {
+ $app = JFactory::getApplication();
+ $flag = $app->input->get('flag',NULL,'STRING');
+
+ switch($flag)
+ {
+ case 'deletephoto': $result1 = $this->delete_photo();
+ return $result1;
+ break;
+ case 'deletealbum': $result = $this->delete_album();
+ return $result;
+ break;
+ }
+ }
+ //this function is use to delete photo from album
+ public function delete_photo()
+ {
+ $user = JFactory::getUser($this->plugin->get('user')->id);
+ $app = JFactory::getApplication();
+ $id = $app->input->get('id',0,'INT');
+ $res = new stdClass();
+ // Load the photo table
+ $photo = FD::table( 'Photo' );
+ $photo->load( $id );
+ $lib = FD::photo( $photo->uid , $photo->type , $photo );
+ if( !$id && !$photo->id )
+ {
+ $res->state = false;
+ $res->message = JText::_( 'COM_EASYSOCIAL_PHOTOS_INVALID_ID_PROVIDED' );
+ return $res;
+ }
+ // Load the photo library
+ // Test if the user is allowed to delete the photo
+ if( !$lib->deleteable() )
+ {
+ $res->state = false;
+ $res->message = JText::_( 'COM_EASYSOCIAL_PHOTOS_NO_PERMISSION_TO_DELETE_PHOTO' );
+ return $res;
+ }
+ // Try to delete the photo
+ $state = $photo->delete();
+ if( !$state )
+ {
+ return false;
+ }
+ else
+ return $state;
+ }
+ //this function is used to get the photos from particular album
+ public function get_album_images()
+ {
+ $mapp = new EasySocialApiMappingHelper();
+ $app = JFactory::getApplication();
+ $album_id = $app->input->get('album_id',0,'INT');
+ $uid = $app->input->get('uid',0,'INT');
+ $state = $app->input->get('state',0,'INT');
+ $mapp = new EasySocialApiMappingHelper();
+ $log_user= $this->plugin->get('user')->id;
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ $limit = $app->input->get('limit',10,'INT');
+
+ $mydata['album_id']=$album_id;
+ $mydata['uid']=$uid;
+ $mydata['start']=$limitstart;
+ $mydata['limit']=$limit;
+
+
+ $ob = new EasySocialModelPhotos();
+ $photos = $ob->getPhotos($mydata);
+ //loading photo table
+ $photo = FD::table( 'Photo' );
+ foreach($photos as $pnode )
+ {
+ $photo->load($pnode->id);
+
+ $pht_lib = FD::photo($pnode->id,'event',$album_id);
+
+ $photo->cluser_user = $pht_lib->creator()->id;
+ $pnode->image_large = $photo->getSource('large');
+ $pnode->image_square = $photo->getSource('square');
+ $pnode->image_thumbnail = $photo->getSource('thumbnail');
+ $pnode->image_featured = $photo->getSource('featured');
+
+ }
+ //mapping function
+ $all_photos = $mapp->mapItem($photos,'photos',$log_user);
+ return $all_photos;
+ // return $photos;
+ }
+ //this function is used to delete photos from album
+ public function delete_album()
+ {
+
+ $app = JFactory::getApplication();
+ $id = $app->input->get('id',0,'INT');
+ $album = FD::table( 'Album' );
+ $album->load( $id );
+ if(!$album->id || !$id)
+ {
+ $result->status=0;
+ $result->message=JText::_( 'PLG_API_EASYSOCIAL_ALBUM_NOT_EXISTS' );
+ return $result;
+ }
+ else
+ {
+ $val =$album->delete();
+ $album->assignPoints( 'photos.albums.delete' , $album->uid );
+ $val->message = JText::_( 'PLG_API_EASYSOCIAL_ALBUM_DELETE_SUCCESS_MESSAGE' );
+ return $val;
+ }
+ }
+ //this function is used to create album
+ public function create_album()
+ {
+ // Get the uid and type
+ $app = JFactory::getApplication();
+ $uid = $app->input->get('uid',0,'INT');
+ $type = $app->input->get('type',0,'USER');
+ $title = $app->input->get('title',0,'USER');
+ // Load the album
+ $album = FD::table( 'Album' );
+ $album->load();
+ $res = new stdClass();
+ // Determine if this item is a new item
+ $isNew = true;
+ if( $album->id )
+ {
+ $isNew = false;
+ }
+ // Load the album's library
+ $lib = FD::albums( $uid , $type );
+ // Check if the person is allowed to create albums
+ if( $isNew && !$lib->canCreateAlbums() )
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'COM_EASYSOCIAL_ALBUMS_ACCESS_NOT_ALLOWED' );
+ return $res;
+ }
+ // Set the album uid and type
+ $album->uid = $uid;
+ $album->type = $type;
+ $album->title = $title;
+ // Determine if the user has already exceeded the album creation
+ if( $isNew && $lib->exceededLimits() )
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'COM_EASYSOCIAL_ALBUMS_EXCEEDED' );
+ return $res;
+ }
+ // Set the album creation alias
+ $album->assigned_date = FD::date()->toMySQL();
+ // Set custom date
+ if( isset( $post['date'] ) )
+ {
+ $album->assigned_date = $post[ 'date' ];
+ unset( $post['date'] );
+ }
+ // Set the user creator
+ $album->user_id = $uid;
+ // Try to store the album
+ $state = $album->store();
+ // Throw error when there's an error saving album
+ if( !$state )
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'COM_EASYSOCIAL_ALBUMS_EXCEEDED' );
+ return $res;
+ }
+ $photo_obj = new EasySocialApiUploadHelper();
+ $photodata = $photo_obj->albumPhotoUpload($uid,$type,$album->id);
+ $album->params=$photodata;
+ if(!$album->cover_id)
+ {
+ $album->cover_id = $photodata->id;
+ // Store the album
+ $album->store();
+ }
+ return $album;
+ }
+
+}
diff --git a/easysocial/easysocial/block.php b/easysocial/easysocial/block.php
new file mode 100644
index 0000000..91b5f9b
--- /dev/null
+++ b/easysocial/easysocial/block.php
@@ -0,0 +1,96 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+
+class EasysocialApiResourceBlock extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse("Use method post");
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->processUser());
+ }
+
+ public function processUser()
+ {
+ $app = JFactory::getApplication();
+ $reason = $app->input->get('reason','','STRING');
+ $target_id = $app->input->get('target_id',0,'INT');
+ $block_this = $app->input->get('block',0,'INT');
+ //print_r($_POST);die();
+ return $res = ($block_this)?$this->block($target_id,$reason):$this->unblock($target_id);
+
+ }
+
+ //block user function
+ public function block($target_id,$reason)
+ {
+
+ //print_r($target_id);die( 'block access' );
+ $res = new stdClass();
+
+ if(!$target_id)
+ {
+ $res->success = 0;
+ $res->message = JText::_('COM_EASYSOCIAL_INVALID_USER_ID_PROVIDED');
+ }
+
+ // Load up the block library
+ $lib = FD::blocks();
+ $result = $lib->block($target_id, $reason);
+
+ if($result->id)
+ {
+ $res->success = 1;
+ $res->message = JText::_('COM_EASYSOCIAL_USER_BLOCKED_SUCCESSFULLY');
+ }
+ else
+ {
+ $res->success = 0;
+ $res->message = JText::_('Unable to block error');
+ }
+ return $res;
+ }
+
+ public function unblock($target_id)
+ {
+ //print_r($target_id);
+ $res = new stdClass();
+
+ if(!$target_id)
+ {
+ $res->success = 0;
+ $res->message = JText::_('COM_EASYSOCIAL_INVALID_USER_ID_PROVIDED');
+ return $res;
+ }
+
+ // Load up the block library
+ $lib = FD::blocks();
+ $result = $lib->unblock($target_id);
+
+ if($result)
+ {
+ $res->success = 1;
+ $res->message = JText::_('COM_EASYSOCIAL_USER_UNBLOCKED_SUCCESSFULLY');
+ }
+ else
+ {
+ $res->success = $result->code;
+ $res->message = $result->message;
+ }
+ return $res;
+ }
+
+}
diff --git a/easysocial/easysocial/comments.php b/easysocial/easysocial/comments.php
new file mode 100644
index 0000000..313f376
--- /dev/null
+++ b/easysocial/easysocial/comments.php
@@ -0,0 +1,177 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceComments extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getComments());
+ }
+
+ public function post()
+ {
+ $app = JFactory::getApplication();
+
+ $element = $app->input->get('element', '', 'string');
+ $group = $app->input->get('group', '', 'string');
+ $verb = $app->input->get('verb', '', 'string');
+ $uid = $app->input->get('uid', 0, 'int');//element id
+
+ $input = $app->input->get( 'comment', "" ,'RAW');
+ $params = $app->input->get( 'params',array(),'ARRAY');//params
+ $streamid = $app->input->get( 'stream_id', '' , 'INT');//whole stream id
+ $parent = $app->input->get( 'parent', 0 ,'INT');//parent comment id
+
+ $result = new stdClass;
+ $valid = 1;
+
+ if(!$uid)
+ {
+ $result->id = 0;
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_ELEMENT_NOT_ALLOWED_MESSAGE' );
+ $valid = 0;
+ }
+
+ // Message should not be empty.
+ if(empty($input))
+ {
+ $result->id = 0;
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_COMMENT_NOT_ALLOWED_MESSAGE' );
+ $valid = 0;
+ }
+ else if($valid)
+ {
+ // Normalize CRLF (\r\n) to just LF (\n)
+ $input = str_ireplace("\r\n", "\n", $input );
+
+ $compositeElement = $element . '.' . $group . '.' . $verb;
+
+ $table = FD::table('comments');
+
+ $table->element = $compositeElement;
+ $table->uid = $uid;
+ $table->comment = $input;
+ $table->created_by = FD::user()->id;
+ $table->created = FD::date()->toSQL();
+ $table->parent = $parent;
+ $table->params = $params;
+ $table->stream_id = $streamid;
+
+ $state = $table->store();
+
+ if ($streamid)
+ {
+ $doUpdate = true;
+ if ($element == 'photos')
+ {
+ $sModel = FD::model('Stream');
+ $totalItem = $sModel->getStreamItemsCount($streamid);
+
+ if ($totalItem > 1) {
+ $doUpdate = false;
+ }
+ }
+
+ if ($doUpdate) {
+ $stream = FD::stream();
+ $stream->updateModified( $streamid, FD::user()->id, SOCIAL_STREAM_LAST_ACTION_COMMENT);
+ }
+ }
+
+ if($state)
+ {
+ $dispatcher = FD::dispatcher();
+
+ $comments = array(&$table);
+ $args = array( &$comments );
+
+ // @trigger: onPrepareComments
+ $dispatcher->trigger($group, 'onPrepareComments', $args);
+
+ //create result obj
+ $result->status = 1;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_COMMENT_SAVE_SUCCESS_MESSAGE' );
+ }
+ else
+ {
+ //create result obj
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_COMMENT_SAVE_UNSUCCESS_MESSAGE' );
+ }
+
+ }
+
+ $this->plugin->setResponse($result);
+ }
+
+ public function getComments()
+ {
+ $app = JFactory::getApplication();
+
+ $row = new stdClass();
+ $row->uid = $app->input->get('uid',0,'INT');
+ $row->element = $app->input->get('element','','STRING');//discussions.group.reply
+ $row->stream_id = $app->input->get('stream_id',0,'INT');
+ $row->group = $app->input->get('group','','STRING');
+ $row->verb = $app->input->get('verb','','STRING');
+
+ $row->limitstart = $app->input->get('limitstart',0,'INT');
+ $row->limit = $app->input->get('limit',10,'INT');
+
+ //$row->deleteable = 1;
+ //$row->parentid = 0;
+
+ $data = array();
+ $mapp = new EasySocialApiMappingHelper();
+ $data['data'] = $mapp->createCommentsObj( $row ,$row->limitstart,$row->limit );
+
+ return $data;
+ }
+
+ public function delete()
+ {
+ $app = JFactory::getApplication();
+
+ $conversion_id = $app->input->get('conversation_id',0,'INT');
+ $valid = 1;
+ $result = new stdClass;
+
+ if( !$conversion_id )
+ {
+
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_INVALID_CONVERSATION_MESSAGE' );
+ $valid = 0;
+ }
+
+ if($valid)
+ {
+ // Try to delete the group
+ $conv_model = FD::model('Conversations');
+ //$my = FD::user($this->plugin->get('user')->id);
+ $result->status = $conv_model->delete( $conversion_id , $this->plugin->get('user')->id );
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_CONVERSATION_DELETED_MESSAGE' );
+ }
+
+ $this->plugin->setResponse($result);
+ }
+}
diff --git a/easysocial/easysocial/discussion.php b/easysocial/easysocial/discussion.php
new file mode 100644
index 0000000..89e0af0
--- /dev/null
+++ b/easysocial/easysocial/discussion.php
@@ -0,0 +1,323 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/apps.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceDiscussion extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getGroupDiscussion());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->createGroupDiscussion());
+ }
+
+ public function delete()
+ {
+ $result = new stdClass;
+ $group_id = $app->input->get('id',0,'INT');
+ $appId = $app->input->get('discussion_id',0,'INT');
+
+ $discussion = FD::table( 'Discussion' );
+ $discussion->load( $appId );
+
+ $my = FD::user();
+ $group = FD::group( $group_id );
+
+ if( !$group->isAdmin() && $discussion->created_by != $this->plugin->get('user')->id)
+ {
+ //error message;
+ return false;
+ }
+
+ // Delete the discussion
+ $res = $discussion->delete();
+ $result->status = ($res)?'Conversation deleted successfully':'Unable to delete converstion.';
+ $this->plugin->setResponse($result);
+ }
+ //function use for get friends data
+ function getGroupDiscussion()
+ {
+ //init variable
+ $mainframe = JFactory::getApplication();
+
+ $group_id = $mainframe->input->get('id',0,'INT');
+ $appId = $mainframe->input->get('discussion_id',0,'INT');
+ //$filter = $mainframe->input->get('filter','all','STRING');
+
+ $limitstart = $mainframe->input->get('limitstart',0,'INT');
+ $limit = $mainframe->input->get('limit',10,'INT');
+
+ $wres = new stdClass;
+ $valid = 0;
+
+ if(!$group_id)
+ {
+ $wres->status = 0;
+ $wres->message[] = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_GROUP_ID_MESSAGE' );
+ return $wres;
+ }
+ else
+ {
+ $group = FD::group( $group_id );
+
+ // Get the current filter type
+ $filter = $mainframe->input->get('filter','all','STRING');
+
+ $options = array();
+
+ if( $filter == 'unanswered' )
+ {
+ $options[ 'unanswered' ] = true;
+ }
+
+ if( $filter == 'locked' )
+ {
+ $options[ 'locked' ] = true;
+ }
+
+ if( $filter == 'resolved' )
+ {
+ $options[ 'resolved' ] = true;
+ }
+
+ //$options[ 'limitstart' ] = $mainframe->input->get('limitstart',0,'INT');
+ //$options[ 'limit' ] = $mainframe->input->get('limit',10,'INT');
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ $model = FD::model( 'Discussions' );
+
+ $discussions_row = $model->getDiscussions( $group->id , SOCIAL_TYPE_GROUP , $options );
+
+ if($limitstart)
+ {
+ $discussions_row = array_slice($discussions_row,$limitstart,$limit);
+ }
+
+
+ $data['data'] = $mapp->mapItem($discussions_row,'discussion',$this->plugin->get('user')->id);
+
+ //
+ return( $data );
+ }
+ }
+
+ //function for create new group
+ function createGroupDiscussion()
+ {
+ //init variable
+ $mainframe = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ // Load the discussion
+ $discuss_id = $mainframe->input->get('discussion_id',0,'INT');
+ $groupId = $mainframe->input->get('group_id',0,'INT');
+
+ $wres = new stdClass;
+
+ $discussion = FD::table( 'Discussion' );
+ $discussion->load( $discuss_id );
+
+
+ // Get the current logged in user.
+ $my = FD::user($log_user);
+
+ // Get the group
+ $group = FD::group( $groupId );
+
+
+ // Check if the user is allowed to create a discussion
+ if( !$group->isMember() )
+ {
+ $wres->status = 0;
+ $wres->message[] = JText::_( 'PLG_API_EASYSOCIAL_CREATE_GD_NOT_ALLOWED_MESSAGE' );
+ return $wres;
+ }
+
+ // Assign discussion properties
+ $discussion->uid = $group->id;
+ $discussion->type = 'group';
+ $discussion->title = $mainframe->input->get('title',0,'STRING');
+ $discussion->content = $mainframe->input->get('content',0,'RAW');
+
+ // If discussion is edited, we don't want to modify the following items
+ if( !$discussion->id )
+ {
+ $discussion->created_by = $my->id;
+ $discussion->parent_id = 0;
+ $discussion->hits = 0;
+ $discussion->state = SOCIAL_STATE_PUBLISHED;
+ $discussion->votes = 0;
+ $discussion->lock = false;
+ }
+
+ //$app = $this->getApp();
+ $app = FD::table('App');
+ $app->load(25);
+
+ // Ensure that the title is valid
+ if (!$discussion->title) {
+
+ $wres->status = 0;
+ $wres->message[] = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_DISCUSSION_TITLE_MESSAGE' );
+ return $wres;
+ }
+
+ // Lock the discussion
+ $state = $discussion->store();
+
+ if( !$state )
+ {
+ $wres->status = 0;
+ $wres->message[] = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_CREATE_DISCUSSION_MESSAGE' );
+ return $wres;
+
+ }
+
+ // Process any files that needs to be created.
+ $discussion->mapFiles();
+
+ // Get the app
+ //$app = $this->getApp();
+
+ // If it is a new discussion, we want to run some other stuffs here.
+ if( !$discuss_id && $state)
+ {
+ // @points: groups.discussion.create
+ // Add points to the user that updated the group
+ $points = FD::points();
+ $points->assign( 'groups.discussion.create' , 'com_easysocial' , $my->id );
+
+ // Create a new stream item for this discussion
+ $stream = FD::stream();
+
+ // Get the stream template
+ $tpl = $stream->getTemplate();
+
+ // Someone just joined the group
+ $tpl->setActor( $my->id , SOCIAL_TYPE_USER );
+
+ // Set the context
+ $tpl->setContext( $discussion->id , 'discussions' );
+
+ // Set the cluster
+ $tpl->setCluster( $group->id , SOCIAL_TYPE_GROUP, $group->type );
+
+ // Set the verb
+ $tpl->setVerb( 'create' );
+
+ // Set the params to cache the group data
+ $registry = FD::registry();
+ $registry->set( 'group' , $group );
+ $registry->set( 'discussion', $discussion );
+
+ $tpl->setParams( $registry );
+
+ $tpl->setAccess('core.view');
+
+ // Add the stream
+ $stream->add( $tpl );
+
+ // Set info message
+ //FD::info()->set(false, JText::_( 'APP_GROUP_DISCUSSIONS_DISCUSSION_CREATED_SUCCESS' ), SOCIAL_MSG_SUCCESS );
+
+ // Send notification to group members only if it is new discussion
+ $options = array();
+ $options[ 'permalink' ] = FRoute::apps( array( 'layout' => 'canvas' , 'customView' => 'item' , 'uid' => $group->getAlias() , 'type' => SOCIAL_TYPE_GROUP , 'id' => $app->getAlias() , 'discussionId' => $discussion->id , 'external' => true ) , false );
+ $options['discussionId'] = $discussion->id;
+ $options[ 'discussionTitle' ] = $discussion->title;
+ $options[ 'discussionContent'] = $discussion->getContent();
+ $options[ 'userId' ] = $discussion->created_by;
+
+ $group->notifyMembers( 'discussion.create' , $options );
+ }
+
+ $wres->id = $discussion->id;
+ $wres->message[] = JText::_( 'PLG_API_EASYSOCIAL_GROUP_DISCUSSION_CREATED_MESSAGE' );
+ return $wres;
+
+ }
+
+/*
+ //format friends object into required object
+ function baseGrpObj($node=null)
+ {
+ if($node==null)
+ return 0;
+
+ $user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $list = array();
+
+ $grp_obj = FD::model('Groups');
+
+ $obj = new stdclass;
+ $obj->id = $node->id;
+ $obj->title = $node->title;
+ $obj->description = $node->description;
+ $obj->hits = $node->hits;
+ $obj->state = $node->state;
+ $obj->created_date = $node->created;
+
+ //get category name
+ $category = FD::table('GroupCategory');
+ $category->load($node->category_id);
+ $obj->category_id = $node->category_id;
+ $obj->category_name = $category->get('title');
+
+ $obj->created_by = $node->creator_uid;
+ $obj->creator_name = JFactory::getUser($node->creator_uid)->username;
+ $obj->type = ($node->type == 1 )?'Private':'Public';
+
+ foreach($node->avatars As $ky=>$avt)
+ {
+ $avt_key = 'avatar_'.$ky;
+ $obj->$avt_key = JURI::root().'media/com_easysocial/avatars/group/'.$node->id.'/'.$avt;
+ }
+
+ //$obj->members = $node->members;
+ $obj->member_count = $grp_obj->getTotalMembers($node->id);
+ //$obj->cover = $grp_obj->getMeta($node->id);
+
+ $alb_model = FD::model('Albums');
+
+ $uid = $node->id.':'.$node->title;
+
+ $filters = array('uid'=>$uid,'type'=>'group');
+ //get total album count
+ $obj->album_count = $alb_model->getTotalAlbums($filters);
+
+ //get group album list
+ //$albums = $alb_model->getAlbums($uid,'group');
+
+ $obj->isowner = ( $node->creator_uid == $userid )?true:false;
+ $obj->ismember = in_array( $log_user->id,$node->members );
+ $obj->approval_pending = in_array( $log_user->id,$node->pending );
+
+ /*$news_obj = new EasySocialModelGroups();
+ $news = $news_obj->getNews($node->id); */
+
+ /*return $obj;
+ }
+*/
+
+}
diff --git a/easysocial/easysocial/event.php b/easysocial/easysocial/event.php
new file mode 100644
index 0000000..5404100
--- /dev/null
+++ b/easysocial/easysocial/event.php
@@ -0,0 +1,392 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceEvent extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_event());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->createEvent());
+ }
+ //get event detail.
+ public function get_event()
+ {
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ $event_id = $app->input->get('event_id',0,'INT');
+ $mapp = new EasySocialApiMappingHelper();
+ //getting all detail of particular event.
+ $data = null;
+ if($event_id)
+ {
+ $event[] = FD::event($event_id);
+ $data = $mapp->mapItem($event,'event',$log_user);
+ }
+ return( $data );
+ }
+ // Create event.
+ public function createEvent()
+ {
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+ $user = FD::user($log_user->id);
+
+ $config = FD::config();
+
+ //create group post structure
+ $ev_data = array();
+ $result = new stdClass;
+ $valid = 1;
+ $mapp = new EasySocialApiMappingHelper();
+
+
+ $post['title'] = $app->input->post->get('title',null,'STRING');
+ $post['parmalink'] = $app->input->post->get('parmalink',null,'STRING');
+ $post['description'] = $app->input->post->get('description',null,'STRING');
+ $post['event_type'] = $app->input->post->get('event_type',0,'INT');
+ $post['startDatetime'] = $app->input->post->get('startDatetime','','string');
+ $post['endDatetime'] = $app->input->post->get('endDatetime','','string');
+ $post['event_allday'] = $app->input->post->get('event_allday',0,'INT');
+ //$post['repeat'] = $app->input->post->get('repeat',null,'RAW');
+ $post['repeat'] = $app->input->post->get('repeat',array('type'=>'none','end'=>null),'ARRAY');
+ $post['website'] = $app->input->post->get('website',0,'INT');
+ $post['allowmaybe'] = $app->input->post->get('allowmaybe',0,'INT');
+ $post['allownotgoingguest'] = $app->input->post->get('allownotgoingguest',0,'INT');
+ $post['guestlimit'] = $app->input->post->get('guestlimit',0,'INT');
+ $post['photo_albums'] = $app->input->post->get('photo_albums',0,'INT');
+ $post['announcement'] = $app->input->post->get('announcement',0,'INT');
+ $post['discussions'] = $app->input->post->get('discussions',0,'INT');
+ $post['location'] = $app->input->post->get('location',null,'STRING');
+
+ $post['categoryId'] = $categoryId = $app->input->post->get('category_id',0,'INT');
+ $post['group_id'] = $app->input->post->get('group_id',null,'INT');
+
+ /*$date = new DateTime($post['startDatetime']);
+ $config = JFactory::getConfig();
+ $date->setTimezone(new DateTimeZone($config->get('offset')));
+ $post['startDatetime'] = $date->format('Y-m-d H:i:s a');*/
+
+ //format date as per server
+ /*$post['startDatetime'] = $mapp->getOffsetServer($post['startDatetime'],$log_user->id);
+
+ if((!empty($post['endDatetime'])) && ($post['endDatetime'] != null) && ($post['endDatetime'] != 'null') )
+ {
+ $post['endDatetime'] = $mapp->getOffsetServer($post['endDatetime'],$log_user->id);
+ }*/
+
+ $category = FD::table('EventCategory');
+ $category->load($categoryId);
+
+ $session = JFactory::getSession();
+ $session->set('category_id', $category->id, SOCIAL_SESSION_NAMESPACE);
+
+ $stepSession = FD::table('StepSession');
+ $stepSession->load(array('session_id' => $session->getId(), 'type' => SOCIAL_TYPE_EVENT));
+
+ $stepSession->session_id = $session->getId();
+ $stepSession->uid = $category->id;
+ $stepSession->type = SOCIAL_TYPE_EVENT;
+
+ $stepSession->set('step', 1);
+
+ $stepSession->addStepAccess(1);
+
+ // Check the group access for event creation
+ if (!empty($post['group_id'])) {
+ $group = FD::group($post['group_id']);
+
+ if (!$group->canCreateEvent()) {
+
+ $result->success = 0;
+ $result->message = JText::_('COM_EASYSOCIAL_EVENTS_NOT_ALLOWED_TO_CREATE_EVENT');
+ return $result;
+ }
+ $stepSession->setValue('group_id', $post['group_id']);
+ }
+ else {
+ // Check if there is a group id set in the session, if yes then remove it
+
+ if (!empty($stepSession->values)) {
+ $value = FD::makeObject($stepSession->values);
+
+ unset($value->group_id);
+
+ $stepSession->values = FD::json()->encode($value);
+ }
+ }
+
+ $stepSession->store();
+
+ //step 2 - create event
+ $session = JFactory::getSession();
+ $stepSession = FD::table('StepSession');
+ $stepSession->load(array('session_id' => $session->getId(), 'type' => SOCIAL_TYPE_EVENT));
+
+ $category = FD::table('EventCategory');
+ $category->load($stepSession->uid);
+ $sequence = $category->getSequenceFromIndex($stepSession->step, SOCIAL_EVENT_VIEW_REGISTRATION);
+ //for api test purpose
+ if (empty($sequence)) {
+
+ $result->success = 0;
+ $result->message = JText::_('COM_EASYSOCIAL_EVENTS_NO_VALID_CREATION_STEP');
+ return $result;
+ }
+
+ // Load the steps and fields
+ $step = FD::table('FieldStep');
+ $step->load(array('uid' => $category->id, 'type' => SOCIAL_TYPE_CLUSTERS, 'sequence' => $sequence));
+
+ $registry = FD::registry();
+ $registry->load($stepSession->values);
+
+ // Get the fields
+ $fieldsModel = FD::model('Fields');
+ $customFields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'visible' => SOCIAL_EVENT_VIEW_REGISTRATION));
+
+ // Get from request
+ //$files = JRequest::get('FILES');
+ //$post = JRequest::get('POST');
+ $token = FD::token();
+ $json = FD::json();
+
+ $data = $this->createData($customFields,$post);
+
+ //add post data in registry
+
+ foreach ($data as $key => $value) {
+ if ($key == $token) {
+ continue;
+ }
+
+ if (is_array($value)) {
+ $value = $json->encode($value);
+ }
+
+ $registry->set($key, $value);
+ }
+
+ $data = $registry->toArray();
+
+ $args = array(&$data, &$stepSession);
+
+ // Load up the fields library so we can trigger the field apps
+ $fieldsLib = FD::fields();
+
+ $callback = array($fieldsLib->getHandler(), 'validate');
+
+ //$errors = $fieldsLib->trigger('onRegisterValidate', SOCIAL_FIELDS_GROUP_EVENT, $customFields, $args, $callback);
+
+ $stepSession->values = $json->encode($data);
+
+ $stepSession->store();
+
+/* if (!empty($errors)) {
+ //error code for
+
+ $stepSession->setErrors($errors);
+
+ $stepSession->store();
+
+ $this->view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
+
+ return $this->view->call(__FUNCTION__, $stepSession);
+
+ }
+*/
+
+ $completed = $step->isFinalStep(SOCIAL_EVENT_VIEW_REGISTRATION);
+
+ $stepSession->created = FD::date()->toSql();
+//~
+ //~ $nextStep = $step->getNextSequence(SOCIAL_EVENT_VIEW_REGISTRATION);
+//~
+ //~ if ($nextStep) {
+ //~ $nextIndex = $stepSession->step + 1;
+ //~ $stepSession->step = $nextIndex;
+ //~ $stepSession->addStepAccess($nextIndex);
+ //~ }
+
+ $stepSession->store();
+
+ // Here we assume that the user completed all the steps
+ $eventsModel = FD::model('Events');
+
+ // Create the new event
+ $event = $eventsModel->createEvent($stepSession);
+
+ if (!$event->id) {
+ $errors = $eventsModel->getError();
+
+ $result->success = 0;
+ $result->message = $errors;
+ return $result;
+ }
+
+ // Assign points to the user for creating event
+ FD::points()->assign('events.create', 'com_easysocial', $log_user->id);
+
+ // If there is recurring data, then we back up the session->values and the recurring data in the the event params first before deleting step session
+ if (!empty($event->recurringData)) {
+ $clusterTable = FD::table('Cluster');
+ $clusterTable->load($event->id);
+ $eventParams = FD::makeObject($clusterTable->params);
+ $eventParams->postdata = FD::makeObject($stepSession->values);
+ $eventParams->recurringData = $event->recurringData;
+ $clusterTable->params = FD::json()->encode($eventParams);
+ $clusterTable->store();
+ }
+
+ $stepSession->delete();
+
+ if ($event->isPublished() && FD::config()->get('events.stream.create')) {
+ $event->createStream('create', $event->creator_uid, $event->creator_type);
+ }
+
+ if($event->id)
+ {
+ $result->success = 1;
+ $result->event_id = $event->id;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_EVENT_CREATE_SUCCESS_MESSAGE' );
+ }
+
+ return $result;
+ }
+
+ /*public function getOffsetServer($date)
+ {
+ $date = new DateTime($date);
+ $config = JFactory::getConfig();
+ $date->setTimezone(new DateTimeZone($config->get('offset')));
+ return $date = $date->format('Y-m-d H:i:s a');
+ }*/
+
+ public function createData($field_ids, $post)
+ {
+ $ev_data = array();
+
+ $avtar_pth = '';
+ $avtar_scr = '';
+ $avtar_typ = '';
+ $phto_obj = null;
+ $avatar_file_name = null;
+
+ if(!empty($_FILES['file']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
+ $phto_obj = $upload_obj->ajax_avatar($_FILES['file']);
+ $avtar_pth = $phto_obj['temp_path'];
+ $avtar_scr = $phto_obj['temp_uri'];
+ $avtar_typ = 'upload';
+ $avatar_file_name = $_FILES['file']['name'];
+ }
+
+ $cover_data = null;
+
+ if(!empty($_FILES['cover_file']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'],'cover_file');
+ //$phtomod = FD::model( 'Photos' );
+ //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
+ //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
+ //
+ }
+
+ foreach($field_ids as $field)
+ {
+ $ev_data['cid'][] = $field->id;
+
+ switch($field->unique_key)
+ {
+ case 'HEADER': break;
+ case 'TITLE': $ev_data['es-fields-'.$field->id] = $post['title'];
+ unset($post['title']);
+ break;
+ case 'PERMALINK': $ev_data['es-fields-'.$field->id] = $post['parmalink'];
+ unset($post['parmalink']);
+ break;
+ case 'DESCRIPTION': $ev_data['es-fields-'.$field->id] = $post['description'];
+ unset($post['description']);
+ break;
+ case 'URL': $ev_data['es-fields-'.$field->id] = $post['website'];
+ unset($post['url']);
+ break;
+ /*case 'TYPE': $ev_data['es-fields-'.$field->id] = $post['event_type'];
+ break;
+ case 'STARTEND':$ev_data['group_type'] = $post['startdate'];
+ break;*/
+ /*case 'ALLDAY': $ev_data['es-fields-'.$field->id] = $post['allday'];
+ break;*/
+ /*case 'CONFIGALLOWMAYBE': $ev_data['es-fields-'.$field->id] = $post['allowmaybe'];
+ break;
+ case 'CONFIGNOTGOINGGUEST': $ev_data['es-fields-'.$field->id] = $post['allownotgoingguest'];
+ break;
+ case 'GUESTLIMIT': $ev_data['es-fields-'.$field->id] = $post['guestlimit'];
+ break;
+ case 'PHOTOS': $ev_data['es-fields-'.$field->id] = $post['photo_albums'];
+ break;*/
+ case 'NEWS': $ev_data['es-fields-'.$field->id] = $post['announcement'];
+ unset($post['announcement']);
+ break;
+ case 'DISCUSSIONS': $ev_data['es-fields-'.$field->id] = $post['discussions'];
+ unset($post['discussions']);
+ break;
+ case 'ADDRESS': $ev_data['es-fields-'.$field->id] = $post['location'];
+ unset($post['location']);
+ break;
+ case 'RECURRING':$post['repeat'] = (array)json_decode($post['repeat']);
+ $ev_data['es-fields-'.$field->id] = $post['repeat'];
+ unset($post['repeat']);
+ break;
+ case 'AVATAR': $ev_data['es-fields-'.$field->id] = Array
+ (
+ 'source' =>$avtar_scr,
+ 'path' =>$avtar_pth,
+ 'data' => '',
+ 'type' => $avtar_typ,
+ 'name' => $avatar_file_name
+ );
+ break;
+ case 'COVER': $ev_data['es-fields-'.$field->id] = Array
+ (
+ 'data' =>$cover_data,
+ 'position' =>'{"x":0.5,"y":0.5}'
+ );
+ break;
+ }
+ }
+
+ $ev_data = array_merge($ev_data,$post);
+
+ return $ev_data;
+
+ }
+
+}
+
diff --git a/easysocial/easysocial/event_category.php b/easysocial/easysocial/event_category.php
new file mode 100644
index 0000000..55e345f
--- /dev/null
+++ b/easysocial/easysocial/event_category.php
@@ -0,0 +1,33 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceEvent_category extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_cat());
+ }
+ //getting all categories of event
+ public function get_cat()
+ {
+ $app = JFactory::getApplication();
+ //getting log_user
+ $log_user = $this->plugin->get('user')->id;
+ //~ $ordering = $this->plugin->get('', '', 'STRING');
+ $cat=FD::model( 'eventcategories' );
+ $res=$cat->getCategories();
+ return $res;
+ }
+}
diff --git a/easysocial/easysocial/event_guest.php b/easysocial/easysocial/event_guest.php
new file mode 100644
index 0000000..554eb68
--- /dev/null
+++ b/easysocial/easysocial/event_guest.php
@@ -0,0 +1,64 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceEvent_guest extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_guests());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_GET_METHOD_MESSAGE' ));
+ }
+ public function get_guests()
+ {
+ $app = JFactory::getApplication();
+ //getting log_user.
+ $log_user = $this->plugin->get('user')->id;
+ //get event id,limit,limitstart.
+ $event_id = $app->input->get('event_id',0,'INT');
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ $limit = $app->input->get('limit',10,'INT');
+ $options = array();
+ $ordering = $this->plugin->get('ordering', 'name', 'STRING');
+ $state = $app->input->get('state','','STRING');
+ $mapp = new EasySocialApiMappingHelper();
+ $eguest = FD::model('Events');
+ //filter with guests state.
+ switch($state)
+ {
+ case 'going':
+ $options['state'] = SOCIAL_EVENT_GUEST_GOING;
+ break;
+ case 'notgoing':
+ $options['state'] = SOCIAL_EVENT_GUEST_NOT_GOING;
+ break;
+ case 'maybe':
+ $options['state'] = SOCIAL_EVENT_GUEST_MAYBE;
+
+ break;
+ case 'admins':
+ $options['admin'] = true;
+ break;
+ }
+ $options['users'] = true;
+ $options['limitstart']=$limitstart;
+ $options['limit']=$limit;
+ $res = $eguest->getGuests($event_id,$options);
+ //map the object to userobject.
+ $eventGuests=$mapp->mapItem($res,'user');
+ return $eventGuests;
+ }
+}
diff --git a/easysocial/easysocial/event_schedule.php b/easysocial/easysocial/event_schedule.php
new file mode 100644
index 0000000..4ed2697
--- /dev/null
+++ b/easysocial/easysocial/event_schedule.php
@@ -0,0 +1,52 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceEvent_schedule extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_schedule());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_GET_METHOD_MESSAGE' ));
+ }
+ //getting schedule of event
+ public function get_schedule()
+ {
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ $event_id = $app->input->get('event_id',0,'INT');
+ $event = FD::event($event_id);
+ $options = array();
+ //getting params for sending array option.
+ $params = $event->getParams();
+ //loading model for getting event schedule.
+ $schedule = FD::model('Events');
+ //required parameters.
+ $options['eventStart'] = $event->getEventStart();
+ $options['end'] = $params->get('recurringData')->end;
+ $options['type'] = $params->get('recurringData')->type;
+ $options['daily'] = $params->get('recurringData')->daily;
+
+ $data = $schedule->getRecurringSchedule($options);
+ //convert date in to require format.
+ foreach($data as $time)
+ {
+ $timings['schedule'][] = gmdate("Y-m-d\ TH:i:s\Z ", $time);
+ }
+ return $timings;
+ }
+}
diff --git a/easysocial/easysocial/eventinvite.php b/easysocial/easysocial/eventinvite.php
new file mode 100644
index 0000000..300a310
--- /dev/null
+++ b/easysocial/easysocial/eventinvite.php
@@ -0,0 +1,80 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+
+class EasysocialApiResourceEventinvite extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_POST_METHOD_MESSAGE' ));
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->invite());
+ }
+ //invite friend to event.
+ public function invite()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+ $result = new stdClass;
+ $event_id = $app->input->get('event_id',0,'INT');
+ $target_users = $app->input->get('target_users',null,'ARRAY');
+ $user = FD::user($log_user->id);
+ $event = FD::event($event_id);
+ $guest = $event->getGuest($log_user->id);
+ if (empty($event) || empty($event->id))
+ {
+ $result->message=JText::_( 'PLG_API_EASYSOCIAL_EVENT_NOT_FOUND_MESSAGE' );
+ $result->status=$state;
+ return $result;
+ }
+ if($event_id)
+ {
+ $not_invi = array();
+ $invited = array();
+ $es_params = FD::config();
+ foreach ($target_users as $id)
+ {
+ $username = JFactory::getUser($id)->name;
+
+ if($es_params->get('users')->displayName == 'username')
+ {
+ $username = $user->username;
+ }
+
+ $guest = $event->getGuest($id);
+ if (!$guest->isGuest() && empty($guest->invited_by)) {
+ //invite friend to event
+ $state = $event->invite($id,$log_user->id);
+ $result->message=JText::_( 'PLG_API_EASYSOCIAL_INVITED_MESSAGE' );
+ $result->status=$state;
+ $invited[] = $username;
+ }
+ else
+ {
+ $result->message=JText::_( 'PLG_API_EASYSOCIAL_GUEST_CANT_INVITED_MESSAGE' );
+ $result->status=$state;
+ $not_invi[] = $username;
+ }
+ }
+ $result->status = 1;
+ $result->invited = $invited;
+ $result->not_invtited = $not_invi;
+ }
+ return $result;
+ }
+}
diff --git a/easysocial/easysocial/events.php b/easysocial/easysocial/events.php
new file mode 100644
index 0000000..001f2cb
--- /dev/null
+++ b/easysocial/easysocial/events.php
@@ -0,0 +1,283 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceEvents extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_events());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->put_status());
+ }
+ public function get_events()
+ {
+ $app = JFactory::getApplication();
+ //getting log_user
+ $log_user = $this->plugin->get('user')->id;
+ $ordering = $this->plugin->get('ordering', 'start', 'STRING');
+ $options = array();
+ $eventResult = array();
+ $res = new stdClass;
+ $options = array('state' => SOCIAL_STATE_PUBLISHED, 'ordering' => $ordering);
+ $event = FD::model( 'events' );
+ $filter = $app->input->get('filter','all','STRING');
+ $dates = $app->input->get('date','','STRING');
+ $cdates = $app->input->get('cdate','','STRING');
+ $start_date = $app->input->get('start_date','','STRING');
+ $end_date = $app->input->get('end_date','','STRING');
+ $start_before = $app->input->get('start_before','','STRING');
+ $includePast = $app->input->get('includePast',0,'INT');
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ $limit = $app->input->get('limit',0,'INT');
+ $categoryid = $app->input->get('categoryid',0,'INT');
+ $mapp = new EasySocialApiMappingHelper();
+ $userObj = FD::user($log_user);
+ $options = array('state' => SOCIAL_STATE_PUBLISHED, 'ordering' => $ordering,'type' => $userObj->isSiteAdmin() ? 'all' : 'user');
+ //if date is given then choose appropriate switch case for that.
+ //for calender date
+ if(!empty($cdates))
+ {
+ $dates=$cdates;
+ }
+
+ if(!empty($dates)){
+ $check = strtotime($dates);
+ if($dates==date('Y-m', $check))
+ {
+ $filter = 'month';
+ }
+ else if($dates==date('Y', $check))
+ {
+ $filter = 'year';
+ }
+ else if($dates==date('Y-m-d', $check))
+ {
+ $filter = 'allDate';
+ }
+ else
+ {
+ $res->message=JText::_( 'PLG_API_EASYSOCIAL_INVALID_DATE_FORMAT_MESSAGE' );
+ $res->status=0;
+ return $res;
+ }
+ }
+ //checking wheather the date is in date range or it is past date.then choose appropriate case.
+ if( !empty($start_date) || !empty($end_date) || !empty($start_before)){
+ if($start_before){
+ $filter = 'past';
+ }
+ else{
+ $filter='range';
+ }
+ }
+
+ //get events with filter.
+ switch($filter)
+ {
+ case 'all': //$options['featured'] = true;
+ // We do not want to include past events here
+ if (!$includePast) {
+ $options['ongoing'] = true;
+ $options['upcoming'] = true;
+ }
+
+
+ break;
+ case 'featured': $options['featured'] = true;
+ break;
+ case 'invited': $options['gueststate'] = SOCIAL_EVENT_GUEST_INVITED;
+ $options['guestuid'] = $log_user;
+ $options['type'] = 'all';
+ // We do not want to include past events here
+ if (!$includePast) {
+ $options['ongoing'] = true;
+ $options['upcoming'] = true;
+ }
+ break;
+ case 'mine': $options['creator_uid'] = $log_user;
+ $options['creator_type'] = SOCIAL_TYPE_USER;
+ $options['type'] = 'all';
+ // We do not want to include past events here
+ if (!$includePast)
+ {
+ $options['ongoing'] = true;
+ $options['upcoming'] = true;
+ }
+ break;
+ case 'range': $options['start-after'] = $start_date;
+ $options['start-before'] = $end_date;
+ break;
+ case 'past': $options['start-before'] = $start_before;
+ $options['ordering'] = 'created';
+ $options['direction'] = 'desc';
+
+ break;
+ case 'allDate':
+ $data = $this->dfilter($dates);
+ $options['start-after']=$data['start-after'];
+ $options['start-before']=$data['start-before'];
+ break;
+ case 'year':
+ $data=$this->dfilter($dates);
+ $options['start-after']=$data['start-after'];
+ $options['start-before']=$data['start-before'];
+ break;
+ case 'month':
+ $data=$this->dfilter($dates);
+ $options['start-after']=$data['start-after'];
+ $options['start-before']=$data['start-before'];
+ break;
+ case 'category':
+ $category = FD::table('EventCategory');
+ $category->load($categoryid);
+ $activeCategory = $category;
+ $options['category'] = $category->id;
+ break;
+ }
+
+ if($limit)
+ {
+ $options['limitstart'] = $limitstart;
+ $options['limit'] = $limit;
+ }
+
+ $eventResult = $event->getEvents($options);
+ if(empty($eventResult)){
+ $res->message=JText::_( 'PLG_API_EASYSOCIAL_EVENT_NOT_FOUND_MESSAGE' );
+ $res->status=0;
+ return $res;
+ }
+ //$eventResult = array_slice($eventResult, $limitstart, $limit);
+ $event_list=$mapp->mapItem( $eventResult,'event',$log_user);
+ return $event_list;
+ }
+ //this common function is for getting dates for month,year,today,tomorrow filters.
+ public function dfilter($dates)
+ {
+ // We need segments to be populated. If no input is passed, then it is today, and we use today as YMD then
+ $segments = explode('-', $dates);
+ $start = $dates;
+ $end = $dates;
+ // Depending on the amount of segments
+ // 1 = filter by year
+ // 2 = filter by month
+ // 3 = filter by day
+ $mode = count($segments);
+
+ switch ($mode)
+ {
+ case 1:
+ $start = $segments[0] . '-01-01';
+ $end = $segments[0] . '-12-31';
+ break;
+
+ case 2:
+ $start = $segments[0] . '-' . $segments[1] . '-01';
+ // Need to get the month's maximum day
+ $monthDate = FD::date($start);
+ $maxDay = $monthDate->format('t');
+
+ $end = $segments[0] . '-' . $segments[1] . '-' . str_pad($maxDay, 2, '0', STR_PAD_LEFT);
+ break;
+
+ default:
+ case 3:
+ $start = $segments[0] . '-' . $segments[1] . '-' . $segments[2];
+ $end = $segments[0] . '-' . $segments[1] . '-' . $segments[2];
+ break;
+ }
+ $options['start-after'] = $start . ' 00:00:00';
+ $options['start-before'] = $end . ' 23:59:59';
+ return $options;
+ }
+
+ //allow user to select join/notgoing/maybe event.
+ public function put_status()
+ {
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ $event_id = $app->input->get('event_id',0,'INT');
+ $state = $app->input->get('state','','STRING');
+ $res = new stdClass;
+ //load the user
+ $user = FD::user($log_user);
+ // Load the event
+ $event = FD::event($event_id);
+ // Determine the guest object
+ $guest = $event->getGuest($log_user);
+
+ if( empty($event) || empty($event->id) || !$event->isPublished() )
+ {
+ $res->message=JText::_( 'PLG_API_EASYSOCIAL_EVENT_NOT_FOUND_MESSAGE' );
+ $res->status=0;
+ return $res;
+ }
+ if ( ($event->isClosed() && ((!$guest->isParticipant() && $state !== 'request') || ($guest->isPending() && $state !== 'withdraw') ) ) || ($event->isInviteOnly() && !$guest->isParticipant()))
+ {
+ $res->message=JText::_( 'PLG_API_EASYSOCIAL_ERROR_MESSAGE' );
+ $res->status=0;
+ return $res;
+ }
+ $guest->cluster_id = $event_id;
+ $access = $user->getAccess();
+ $total = $user->getTotalEvents();
+ if (in_array($state, array('going', 'maybe', 'request')) && $access->exceeded('events.join', $total))
+ {
+ $res->message=JText::_( 'PLG_API_EASYSOCIAL_LIMIT_EXCEEDS_MESSAGE' );
+ $res->status=0;
+ return $res;
+ }
+ switch ($state)
+ {
+ case 'going':
+ $final=$guest->going();
+ break;
+
+ case 'notgoing':
+ // Depending on the event settings
+ // It is possible that if user is not going, then admin doesn't want the user to continue be in the group.
+ // If guest is owner, admin or siteadmin, or this event allows not going guest then allow notgoing state
+ // If guest is just a normal user,then we return state as 'notgoingdialog' so that the JS part can show a dialog to warn user about it.
+ if ($event->getParams()->get('allownotgoingguest', true) || $guest->isOwner()) {
+ $final=$guest->notGoing();
+ } else {
+ $final=$guest->withdraw();
+ }
+ break;
+
+ case 'maybe':
+ $final=$guest->maybe();
+ break;
+
+ case 'request':
+ $final=$guest->request();
+ break;
+
+ case 'withdraw':
+ $final=$guest->withdraw();
+ break;
+
+ default:
+ $final=JText::_( 'PLG_API_EASYSOCIAL_SELECT_VALID_OPTION_MESSAGE' );
+ break;
+ }
+ //$res->message="success";
+ $res->status=$final;
+ return $res;
+ }
+
+}
diff --git a/easysocial/easysocial/fblogin.php b/easysocial/easysocial/fblogin.php
new file mode 100644
index 0000000..8211fa2
--- /dev/null
+++ b/easysocial/easysocial/fblogin.php
@@ -0,0 +1,692 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+jimport('joomla.application.component.controller');
+jimport('joomla.application.component.model');
+jimport('joomla.user.helper');
+jimport('joomla.user.user');
+
+//JModelLegacy::addIncludePath(JPATH_SITE.'components/com_api/models');
+require_once JPATH_SITE.'/components/com_api/libraries/authentication/user.php';
+require_once JPATH_SITE.'/components/com_api/libraries/authentication/login.php';
+require_once JPATH_SITE.'/components/com_api/models/key.php';
+require_once JPATH_SITE.'/components/com_api/models/keys.php';
+
+
+//require_once JPATH_SITE . '/components/com_jfbconnect/controllers/login.php';
+//require_once JPATH_SITE . '/plugins/api/tryitonline/tryitonline/helper/mappingHelper.php';
+
+require_once JPATH_SITE.'/components/com_api/models/keys.php';
+
+class EasysocialApiResourceFblogin extends ApiResource
+{
+
+ public $provider = '';
+ public $accessToken = '';
+ public $socialProfData = '';
+ public $confirmed = '';
+
+ public function get()
+ {
+ //$this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_UNSUPPORTED_METHOD_MESSAGE' ));
+ }
+
+ public function post()
+ {
+ $app = JFactory::getApplication();
+ $this->accessToken = $app->input->get('access_token', '' , 'STR');
+ $this->provider = $app->input->get('provider', 'facebook' , 'STR');
+ $this->confirmed = $app->input->get('confirmed', '0' , 'INT');
+ $obj = new stdClass();
+
+ if( $this->accessToken ) {
+
+ $objFbProfileData = $this->jfbGetUser( $this->accessToken );
+
+ $userId = $this->jfbGetUserFromMap( $objFbProfileData );
+
+ if( $this->confirmed == 0 && !isset($objFbProfileData->birthday) && !( $userId > 0 ) ) {
+ $obj->code = 200;
+ $obj->warning = JText::_( 'PLG_API_FB_CON_DATE_NOT_FOUND' );
+ $this->plugin->setResponse( $obj );
+ return false;
+ }
+
+ if( $userId ) {
+ $this->jfbLogin( $userId );
+ } else {
+
+ if( !isset($objFbProfileData->email) ) {
+
+ $reg_dt = new stdClass();
+
+ $reg_dt->code = 200;
+ $reg_dt->email = 0;
+ $reg_dt->warning = 'Email id not found in Facebook data unable to register user, Do you want to complete registration process';
+ $reg_dt->data = $objFbProfileData;
+
+ $this->plugin->setResponse( $reg_dt );
+ //$this->badRequest( JText::_( 'PLG_API_EMAIL_MANDATORY_REGISTRAION' ), 200 );
+ return false;
+ }
+
+ $this->jfbRegister( $this->accessToken );
+ $userId = $this->jfbGetUserFromMap( $objFbProfileData );
+ if( $userId ) {
+ $this->jfbLogin( $userId );
+ }
+ }
+ } else {
+ $this->badRequest( JText::_( 'PLG_API_EASYSOCIAL_BAD_REQUEST' ) );
+ }
+ }
+
+ function badRequest( $mesage, $code ){
+ $code = $code ? $code : 403;
+ $obj = new stdClass();
+ $obj->code = $code;
+ $obj->message = $mesage;
+ $this->plugin->setResponse( $obj );
+ }
+
+
+ function jfbLogin( $userId ){
+ $this->plugin->setResponse( $this->keygen( $userId ) );
+ }
+
+ function jfbRegister( $accessToken ){
+ $objFbProfileData = $this->jfbGetUser( $accessToken );
+
+ if( $objFbProfileData->id ) {
+ //changed for number login username issue
+ //$username = explode( " ", $objFbProfileData->name );
+ //$username = 'fb_' . $username[0];
+
+ $username = $objFbProfileData->name;
+
+ if( $username ) {
+ $isUserExist = 1;
+ $loopCounter = 0;
+ while( $isUserExist ) {
+ $isUserExist = $this->checkUserNameIsExist( $username );
+ if( $isUserExist ) {
+ $username .= '_' . $loopCounter ++;
+ }
+ };
+
+ $userId = $this->joomlaCreateUser($username, $objFbProfileData->name, $objFbProfileData->email, $objFbProfileData);
+
+ if( $userId ) {
+ $this->jfbCreateUser( $userId, $objFbProfileData);
+ }
+
+ }
+ }
+
+ }
+
+ /*
+ * function to get user from #_jfbconnect_user_map
+ */
+ public function jfbGetUserFromMap( $objFbProfileData )
+ {
+ $db = JFactory::getDBO();
+ $query = $db->getQuery(true);
+
+ $query->select(' j_user_id ');
+ $query->from('#__jfbconnect_user_map');
+ $query->where( " provider_user_id = " . $db->quote( $objFbProfileData->id ) );
+ $db->setQuery($query);
+
+ $userId = $db->loadResult();
+
+ if( !$userId ) {
+ $query = $db->getQuery(true);
+ $query->select(' id ');
+ $query->from('#__users');
+ $query->where( " email = " . $db->quote( $objFbProfileData->email ) );
+ $db->setQuery($query);
+ $userId = $db->loadResult();
+ }
+
+ return $userId;
+ }
+
+ /*
+ * function to get user from #_jfbconnect_user_map
+ */
+ public function jfbGetUser( $accessToken )
+ {
+ $url = 'https://graph.facebook.com/v2.2/me';
+ $token_params = array(
+ "access_token" => $accessToken,
+ "fields" => 'id,name,gender,email,location,website,picture,relationship_status'
+ );
+
+ return $this->makeRequest( $url, $token_params ) ;
+ }
+
+ /*
+ * function to get user from #_jfbconnect_user_map
+ */
+ public function jfbCreateUser( $jUserId, $objFbProfileData )
+ {
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+
+ //manupulate paramteres to save
+ $params = array(
+ 'profile_url' => 'https://www.facebook.com/app_scoped_user_id/' . $objFbProfileData->id,
+ 'avatar_thumb' => $objFbProfileData->picture->data->url
+ );
+
+ $columns = array('j_user_id', 'provider_user_id', 'created_at', 'updated_at', 'access_token', 'authorized', 'params', 'provider');
+
+ // Insert values.
+ $values = array(
+ $jUserId,
+ $objFbProfileData->id,
+ $db->quote( date('Y-m-d H:i:s') ),
+ $db->quote( date('Y-m-d H:i:s') ),
+ $db->quote( '"' . $this->accessToken . '"' ),
+ 1,
+ $db->quote( json_encode( $params ) ),
+ $db->quote( $this->provider )
+ );
+
+ // Prepare the insert query.
+ $query
+ ->insert($db->quoteName('#__jfbconnect_user_map'))
+ ->columns($db->quoteName($columns))
+ ->values(implode(',', $values));
+
+ // Set the query using our newly populated query object and execute it.
+ $db->setQuery($query);
+
+ return $result = $db->execute();
+ }
+
+ public function makeRequest($url, $params){
+ $url .= '?' . http_build_query($params);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
+ curl_setopt($ch, CURLOPT_USERAGENT ,'');
+ $output = curl_exec($ch);
+ $info = curl_getinfo($ch);
+ curl_close($ch);
+ $output = json_decode($output);
+ return $output;
+ }
+
+
+ //public function for genrate key
+ public function keygen( $userId )
+ {
+ $kmodel = new ApiModelKey;
+ $key = null;
+ // Get login user hash
+ $kmodel->setState('user_id', $userId);
+ $log_hash = $kmodel->getList();
+ $log_hash = $log_hash[count($log_hash) - count($log_hash)];
+ $obj = new stdClass();
+
+ if( $log_hash->hash )
+ {
+ $key = $log_hash->hash;
+ }
+ elseif( $key == null || empty($key) )
+ {
+ // Create new key for user
+ $data = array(
+ 'userid' => $userId,
+ 'domain' => '' ,
+ 'state' => 1,
+ 'id' => '',
+ 'task' => 'save',
+ 'c' => 'key',
+ 'ret' => 'index.php?option=com_api&view=keys',
+ 'option' => 'com_api',
+ JSession::getFormToken() => 1
+ );
+
+ $result = $kmodel->save($data);
+ $key = $result->hash;
+
+ }
+
+ if( !empty($key) )
+ {
+ $obj->auth = $key;
+ $obj->code = '200';
+ $obj->id = $userId;
+ }
+ else
+ {
+ $this->badRequest( JText::_( 'PLG_API_EASYSOCIAL_BAD_REQUEST' ) );
+ }
+
+ return( $obj );
+
+ }
+
+ public function checkUserNameIsExist( $username ){
+
+ $db = JFactory::getDBO();
+ $query = $db->getQuery(true);
+
+ $query->select(' id ');
+ $query->from('#__users');
+ $query->where( " username = " . $db->quote( $username ) );
+ $db->setQuery($query);
+
+ return $db->loadResult();
+ }
+
+ /*
+ * function to create new joomla user
+ */
+ public function joomlaCreateUser( $username, $name, $email, $objFbProfileData )
+ {
+
+ $error_messages = array();
+ $fieldname = array();
+ $response = null;
+ $validated = true;
+ $userid = null;
+ $data = array();
+
+ $app = JFactory::getApplication();
+ $data['username'] = $username;
+ $data['password'] = JUserHelper::genRandomPassword(8);
+ $data['name'] = $name;
+ $data['email'] = $email;
+ $data['enabled'] = 0;
+ $data['activation'] = 0;
+
+ 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']);
+ $user->set('block', $data['enabled']);
+ $user->set('activation', $data['activation']);
+
+ // 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->toSql() );
+
+ // True on success, false otherwise
+ if (!$user->save())
+ {
+ $user->getError();
+ return false;
+ }
+ else
+ {
+
+ $mail_sent = $this->sendRegisterEmail($data);
+
+ $userid = $user->id;
+ if( $userid )
+ {
+ $username = explode( " ", $objFbProfileData->name );
+ $firstName = $username[0];
+ $lastName = $username[1];
+
+ $esocialProfData = array(
+ 'BIRTHDAY' => isset($objFbProfileData->birthday) ? $objFbProfileData->birthday : '',
+ 'last_name' => $lastName,
+ 'first_name' => $firstName,
+ 'GENDER' => $objFbProfileData->gender == 'male' ? 1 : 0
+ );
+
+ $easysocial = JPATH_ADMINISTRATOR .'/components/com_easysocial/easysocial.php';
+ //eb version
+ if( JFile::exists( $easysocial ) )
+ {
+ $pobj = $this->createEsprofile( $user->id, $esocialProfData );
+ $message = JText::_('PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE');
+ }
+ else
+ $message = JText::_('PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE');
+
+ // Assign badge for the person.
+ $badge = FD::badges();
+ $badge->log( 'com_easysocial' , 'registration.create' , $user->id , JText::_( 'COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED' ) );
+
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Function create easysocial profile.
+ *
+ * @return user obj
+ */
+ public function createEsprofile( $log_user, $fields )
+ {
+ $obj = new stdClass();
+
+ if (JComponentHelper::isEnabled('com_easysocial', true))
+ {
+ $app = JFactory::getApplication();
+
+ $epost = $fields;
+
+ require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+
+
+ // Get all published fields apps that are available in the current form to perform validations
+ $fieldsModel = FD::model('Fields');
+
+ // Get current user.
+ $my = FD::user($log_user);
+
+ // Only fetch relevant fields for this user.
+ $options = array( 'profile_id' => $my->getProfile()->id, 'data' => true, 'dataId' => $my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_EDIT, 'group' => SOCIAL_FIELDS_GROUP_USER );
+
+ $fields = $fieldsModel->getCustomFields($options);
+
+ $epost = $this->create_field_arr($fields,$epost);
+
+ // Load json library.
+ $json = FD::json();
+
+ // Initialize default registry
+ $registry = FD::registry();
+
+ // Get disallowed keys so we wont get wrong values.
+ $disallowed = array( FD::token() , 'option' , 'task' , 'controller' );
+
+ // Process $_POST vars
+ foreach ($epost as $key => $value) {
+
+ if (!in_array($key, $disallowed)) {
+
+ if (is_array($value) && $key != 'es-fields-11') {
+ $value = $json->encode( $value );
+ }
+
+ $registry->set($key, $value);
+ }
+ }
+
+ // Convert the values into an array.
+ $data = $registry->toArray();
+
+ // Perform field validations here. Validation should only trigger apps that are loaded on the form
+ // @trigger onRegisterValidate
+ $fieldsLib = FD::fields();
+
+ // Get the general field trigger handler
+ $handler = $fieldsLib->getHandler();
+
+ // Build arguments to be passed to the field apps.
+ $args = array( $data , &$my );
+
+ // Ensure that there is no errors.
+ // @trigger onEditValidate
+ //$errors = $fieldsLib->trigger( 'onEditValidate' , SOCIAL_FIELDS_GROUP_USER , $fields , $args, array( $handler, 'validate' ) );
+
+
+ // Bind the my object with appropriate data.
+ $my->bind($data);
+
+ // Save the user object.
+ $sval = $my->save();
+
+ // Reconstruct args
+ $args = array(&$data, &$my);
+
+ // @trigger onEditAfterSave
+ $fieldsLib->trigger( 'onEditAfterSave' , SOCIAL_FIELDS_GROUP_USER , $fields , $args );
+
+ // Bind custom fields for the user.
+ $my->bindCustomFields($data);
+
+ // Reconstruct args
+ $args = array(&$data, &$my);
+
+ // @trigger onEditAfterSaveFields
+ $fieldsLib->trigger( 'onEditAfterSaveFields' , SOCIAL_FIELDS_GROUP_USER , $fields , $args );
+
+
+
+ }
+
+ }
+
+
+ //create field array as per easysocial
+ public function create_field_arr($fields,$post)
+ {
+ $fld_data = array();
+ $app = JFactory::getApplication();
+
+ require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+ //for upload photo
+ if(!empty($_FILES['avatar']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
+ $phto_obj = $upload_obj->ajax_avatar($_FILES['avatar']);
+ $avtar_pth = $phto_obj['temp_path'];
+ $avtar_scr = $phto_obj['temp_uri'];
+ $avtar_typ = 'upload';
+ $avatar_file_name = $_FILES['avatar']['name'];
+ }
+ //for upload cover
+ /*$cover_data = null;
+
+ if(!empty($_FILES['cover_file']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'],'cover_file');
+ //$phtomod = FD::model( 'Photos' );
+ //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
+ //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
+ //
+ }*/
+
+ foreach($fields as $field)
+ {
+ //$fld_data[$field->id] = $field->unique_key;
+ $fobj = new stdClass();
+ $fullname = $post['TITLE']." ".$post['first_name']." ".$post['middle_name']." ".$post['last_name'];
+ $address = $post['STREET_1'].",".$post['STREET_2'].",".$post['CITY'].",".$post['PIN_CODE'].",".$post['STATE'].",".$post['COUNTRY'];
+ // Hari code for address comma remove
+ if($address == ',,,,,'){
+ $address='';
+ }
+
+
+ $fld_data['first_name'] = (!empty($post['first_name']))?$post['first_name']:$app->input->get('name', '', 'STRING');
+ $fld_data['middle_name'] = $post['middle_name'];
+ $fld_data['last_name'] = $post['last_name'];
+
+ $fobj->first = $post['TITLE']." ".$fld_data['first_name'];
+ $fobj->middle = $post['middle_name'];
+ $fobj->last = $post['last_name'];
+ $fobj->name = $fullname;
+
+ switch($field->unique_key)
+ {
+ case 'HEADER': break;
+
+ case 'JOOMLA_FULLNAME': $fld_data['es-fields-'.$field->id] = $fobj;
+ break;
+ case 'JOOMLA_USERNAME': $fld_data['es-fields-'.$field->id] = $app->input->get('username', '', 'STRING');
+ break;
+ case 'JOOMLA_PASSWORD': $fld_data['es-fields-'.$field->id] = $app->input->get('password', '', 'STRING');
+ break;
+ case 'JOOMLA_EMAIL': $fld_data['es-fields-'.$field->id] = $app->input->get('email', '', 'STRING');
+ break;
+ case 'JOOMLA_TIMEZONE': $fld_data['es-fields-'.$field->id] = isset($post['timezone'])?$post['timezone']:null;
+ break;
+ case 'JOOMLA_USER_EDITOR': $fld_data['es-fields-'.$field->id] = isset($post['editor'])?$post['editor']:null;
+ break;
+
+ case 'PERMALINK': $fld_data['es-fields-'.$field->id] = isset($post['permalink'])?$post['permalink']:null;
+ break;
+ case 'BIRTHDAY': $bod =array();
+ if(isset($post['BIRTHDAY']))
+ {
+ $config = JFactory::getConfig();
+ $bod['date'] = $post['BIRTHDAY'];
+ $bod['timezone'] = $config->get('offset');
+ }
+ $fld_data['es-fields-'.$field->id] = isset($post['BIRTHDAY'])?$bod:array();
+ break;
+ case 'GENDER': $fld_data['es-fields-'.$field->id] = isset($post['GENDER'])?$post['GENDER']:'';
+ break;
+ case 'ADDRESS': $fld_data['es-fields-'.$field->id] = $address;
+ break;
+ case 'TEXTBOX': $fld_data['es-fields-'.$field->id] = $post['MOBILE'];
+ break;
+ case 'URL': $fld_data['es-fields-'.$field->id] = (isset($post['WEBSITE']))?$post['WEBSITE']:'';
+ break;
+
+ case 'AVATAR': $fld_data['es-fields-'.$field->id] = Array
+ (
+ 'source' =>$avtar_scr,
+ 'path' =>$avtar_pth,
+ 'data' => '',
+ 'type' => $avtar_typ,
+ 'name' => $avatar_file_name
+ );
+ break;
+ /*
+ case 'COVER': $fld_data['es-fields-'.$field->id] = Array
+ (
+ 'data' =>$cover_data,
+ 'position' =>'{"x":0.5,"y":0.5}'
+ );
+ break;*/
+ }
+ }
+
+ return $fld_data;
+ }
+
+ //send registration mail
+ public function sendRegisterEmail($base_dt)
+ {
+ $config = JFactory::getConfig();
+ $params = JComponentHelper::getParams('com_users');
+ $sendpassword = $params->get('sendpassword', 1);
+
+ $lang = JFactory::getLanguage();
+ $lang->load('com_users', JPATH_SITE, '', true);
+ //$tit=JText::_($emailOptions['title']);
+
+ $data['fromname'] = $config->get('fromname');
+ $data['mailfrom'] = $config->get('mailfrom');
+ $data['sitename'] = $config->get('sitename');
+ $data['siteurl'] = JUri::root();
+ $data['activation'] = $base_dt['activation'];
+
+ // Handle account activation/confirmation emails.
+ if ($data['activation'] == 0)
+ {
+ // Set the link to confirm the user email.
+ $uri = JUri::getInstance();
+ $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
+ $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
+
+ $emailSubject = JText::sprintf(
+ 'COM_USERS_EMAIL_ACCOUNT_DETAILS',
+ $base_dt['name'],
+ $data['sitename']
+ );
+
+
+ if ($sendpassword)
+ {
+ $emailBody = JText::sprintf(
+ 'Hello %s,\n\nThank you for registering at %s. Your account is created and activated.
+ \nYou can login to %s using the following username and password:\n\nUsername: %s\nPassword: %s',
+ $base_dt['name'],
+ $data['sitename'],
+ $base_dt['app'],
+ $base_dt['username'],
+ $base_dt['password']
+ );
+ }
+
+ }
+ elseif ($data['activation'] == 1)
+ {
+ // Set the link to activate the user account.
+ $uri = JUri::getInstance();
+ $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
+ $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
+
+ $emailSubject = JText::sprintf(
+ 'COM_USERS_EMAIL_ACCOUNT_DETAILS',
+ $base_dt['name'],
+ $data['sitename']
+ );
+
+ if ($sendpassword)
+ {
+ $emailBody = JText::sprintf(
+ 'COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY',
+ $base_dt['name'],
+ $data['sitename'],
+ $data['activate'],
+ $base_dt['app'],
+ $base_dt['username'],
+ $base_dt['password']
+ );
+ }
+ }
+
+ // Send the registration email.
+ return $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $base_dt['email'], $emailSubject, $emailBody);
+
+ }
+
+
+}
+
diff --git a/easysocial/easysocial/follower.php b/easysocial/easysocial/follower.php
new file mode 100644
index 0000000..a5fa745
--- /dev/null
+++ b/easysocial/easysocial/follower.php
@@ -0,0 +1,264 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/model.php';
+
+class EasysocialApiResourceFollower extends ApiResource
+{
+
+ public function get()
+ {
+ $this->plugin->setResponse($this->getFollowers());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->follow());
+ }
+
+ /*
+ *Function for follow user
+ */
+ public function follow()
+ {
+ $app = JFactory::getApplication();
+ $target_user = $app->input->get('target_user',0,'INT');
+ $type = $app->input->get('type','user','STRING');
+ $group = $app->input->get('group','user','STRING');
+ $log_user = $this->plugin->get('user')->id;
+ $follow = $app->input->get('follow',1,'INT');
+
+ $target = FD::user( $target_user );
+
+ $res = new stdClass();
+ if( $target_user == $log_user )
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_CANT_FOLLOW_YOURSELF_MESSAGE' );
+ }
+
+ // Load subscription table.
+ $subscription = FD::table('Subscription');
+
+ // Get subscription library
+ $subscriptionLib = FD::get('Subscriptions');
+ // Determine if the current user is already a follower
+ $isFollowing = $subscriptionLib->isFollowing( $target_user , $type , $group , $log_user );
+
+ $subscription->uid = $target_user;
+ $subscription->type = $type . '.' . $group;
+ $subscription->user_id = $log_user;
+ $points = FD::points();
+
+ if(!$isFollowing)
+ {
+ //$state = $subscription->store();
+ if($subscription->store())
+ {
+ $state = $this->addbadges( $target,$log_user,$subscription->id );
+
+ $res->success = 1;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_FOLLOWING_MESSAGE' ).$target->username;
+
+ return $res;
+ }
+ else
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_TO_FOLLOW_MESSAGE' ).$target->username;
+ return $res;
+ }
+
+ }
+ else
+ {
+ if( $subscriptionLib->unfollow( $target_user, $type, $group, $log_user ) )
+ {
+ // @points: profile.unfollow
+ // Assign points when user starts new conversation
+
+ $points->assign( 'profile.unfollow' , 'com_easysocial' , $log_user);
+
+ // @points: profile.unfollowed
+ // Assign points when user starts new conversation
+ $points->assign( 'profile.unfollowed' , 'com_easysocial' , $user->id );
+ $res->success = 1;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_SUCCESSFULLY_UNFOLLW_MESSAGE' ).$target->username;
+
+ return $res;
+ }
+ else
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_TO_UNFOLLW_MESSAGE' ).$target->username;
+
+ return $res;
+ }
+ }
+
+ }
+
+ /*
+ *Function for add badges
+ */
+ public function addbadges( $user,$log_user,$sub_id )
+ {
+ $my = FD::user( $log_user );
+ // @badge: followers.follow
+ $badge = FD::badges();
+ $badge->log( 'com_easysocial' , 'followers.follow' , $my->id , JText::_( 'COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWING_USER' ) );
+
+ // @badge: followers.followed
+ $badge->log( 'com_easysocial' , 'followers.followed' , $user->id , JText::_( 'COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWED' ) );
+
+ // @points: profile.follow
+ // Assign points when user follows another person
+ $points = FD::points();
+ $points->assign( 'profile.follow' , 'com_easysocial' , $my->id );
+
+ // @points: profile.followed
+ // Assign points when user is being followed by another person
+ $points->assign( 'profile.followed' , 'com_easysocial' , $user->id );
+
+ // check if admin want to add stream on following a user or not.
+ $config = FD::config();
+ if ($config->get( 'users.stream.following')) {
+ // Share this on the stream.
+ $stream = FD::stream();
+ $streamTemplate = $stream->getTemplate();
+
+ // Set the actor.
+ $streamTemplate->setActor( $my->id , SOCIAL_TYPE_USER );
+
+ // Set the context.
+ $streamTemplate->setContext( $sub_id , SOCIAL_TYPE_FOLLOWERS );
+
+ // Set the verb.
+ $streamTemplate->setVerb( 'follow' );
+
+ $streamTemplate->setAccess( 'followers.view' );
+
+ // Create the stream data.
+ $stream->add( $streamTemplate );
+ }
+
+ // Set the email options
+ $emailOptions = array(
+ 'title' => 'COM_EASYSOCIAL_EMAILS_NEW_FOLLOWER_SUBJECT',
+ 'template' => 'site/followers/new.followers',
+ 'actor' => $my->getName(),
+ 'actorAvatar' => $my->getAvatar(SOCIAL_AVATAR_SQUARE),
+ 'actorLink' => $my->getPermalink(true, true),
+ 'target' => $user->getName(),
+ 'targetLink' => $user->getPermalink(true, true),
+ 'totalFriends' => $my->getTotalFriends(),
+ 'totalFollowing' => $my->getTotalFollowing(),
+ 'totalFollowers' => $my->getTotalFollowers()
+ );
+
+
+ $state = FD::notify('profile.followed' , array($user->id), $emailOptions, array( 'url' => $my->getPermalink(false, false, false) , 'actor_id' => $my->id , 'uid' => $user->id ));
+
+ return $state;
+ }
+
+ /*
+ *Function for delete friend from list
+ */
+ public function delete()
+ {
+ $app = JFactory::getApplication();
+ $target_user = $app->input->get('target_userid',0,'INT');
+
+ $log_user = $this->plugin->get('user')->id;
+ //$log = FD::user( $frnd_id );
+ // Loads the followers record
+ $follower = FD::table( 'Subscription' );
+ $follower->load( array( 'uid' => $target_user , 'type' => 'user.user' , 'user_id' => $log_user ) );
+
+ $res = new stdClass();
+
+ // Delete the record
+ $res->result = $follower->delete();
+
+ if( $res->result == true )
+ {
+ $res->status = 1;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_USER_REMOVE_MESSAGE' );
+ }
+ else
+ {
+ $res->status = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_TO_REMOVE_USER_MESSAGE' );
+ }
+
+ $this->plugin->setResponse($res);
+ }
+
+ //function use for get friends data
+ function getFollowers()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $user = $this->plugin->get('user')->id;
+ $target_user = $app->input->get('target_user',0,'INT');
+ $type = $app->input->get('type','follower','STRING');
+
+ $options = array();
+ $options['limitstart'] = $app->input->get('limitstart',0,'INT');
+ $options['limit'] = $app->input->get('limit',10,'INT');
+
+ // Load friends model.
+ $foll_model = FD::model( 'Followers' );
+ $frnd_mod = FD::model( 'Friends' );
+
+ $main_mod = new EasySocialModel();
+
+ //set limitstart
+ $main_mod->setUserState( 'limitstart' , $options['limitstart'] );
+ $foll_model->setUserState( 'limitstart' , $options['limitstart'] );
+
+ if(!$target_user)
+ $target_user = $user;
+
+ $data = array();
+ $mapp = new EasySocialApiMappingHelper();
+
+ $raw_followers = array();
+
+ if( $type == 'following' )
+ {
+ $raw_followers = $foll_model->getFollowing( $target_user, $options );
+ }
+ else
+ {
+ $raw_followers = $foll_model->getFollowers( $target_user, $options );
+ }
+
+ //$frnd_list = $this->basefrndObj($ttl_list);
+ $fllowers_list = $mapp->mapItem( $raw_followers,'user',$user );
+
+ //get other data
+ foreach($fllowers_list as $ky=>$lval)
+ {
+ $lval->mutual = $frnd_mod->getMutualFriendCount($user,$lval->id);
+ $lval->isFriend = $frnd_mod->isFriends($users,$lval->id);
+ }
+
+ $data['data'] = $fllowers_list;
+
+ return( $data);
+
+ }
+}
diff --git a/easysocial/easysocial/friend.php b/easysocial/easysocial/friend.php
new file mode 100644
index 0000000..425d200
--- /dev/null
+++ b/easysocial/easysocial/friend.php
@@ -0,0 +1,219 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/friends.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/avatars.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceFriend extends ApiResource
+{
+
+ public function get()
+ {
+ $this->plugin->setResponse($this->getFriends());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->manageFriends());
+ }
+
+ /*
+ *Function for delete friend from list
+ */
+ public function delete()
+ {
+ $this->plugin->setResponse($this->deletefriend());
+
+ /*$app = JFactory::getApplication();
+ $frnd_id = $app->input->get('target_userid',0,'INT');
+
+ $user = FD::user( $frnd_id );
+ $user->approve();
+ $res = new stdClass();
+
+ $res->result = EasySocialModelUsers::deleteFriends($frnd_id);
+
+ if( $res->result == true )
+ {
+ $res->status = 1;
+ //$res->message = 'Freind deleted';
+ }
+ else
+ {
+ $res->status = 0;
+ //$res->message = 'Unable to delete friend';
+ }
+
+ $this->plugin->setResponse($res);*/
+ }
+
+ public function deletefriend()
+ {
+ $app = JFactory::getApplication();
+ //get target user.
+ $frnd_id = $app->input->get('target_userid',0,'INT');
+ //getting log user.
+ $log_user = $this->plugin->get('user')->id;
+ $res = new stdClass();
+ // Try to load up the friend table
+ $friend_table = FD::table( 'Friend' );
+ //load user table.
+ $state=$friend_table->loadByUser($log_user,$frnd_id);
+
+ //API validations.
+ if( !$state )
+ {
+ $res->status = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_DELETE_FRIEND_MESSAGE' );
+ return $res;
+ }
+ // Throw errors when there's a problem removing the friends
+ if( !$friend_table->unfriend( $log_user ) )
+ {
+ $res->status = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_DELETE_FRIEND_MESSAGE' );
+ }
+ else
+ {
+ $res->status = 1;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_FRIEND_DELETED_MESSAGE' );
+ return $res;
+ }
+ }
+
+ //function use for get friends data
+ function getFriends()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $user = JFactory::getUser($this->plugin->get('user')->id);
+ $userid = $app->input->get('target_user',$this->plugin->get('user')->id,'INT');
+
+ $search = $app->input->get('search','','STRING');
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ if($userid == 0)
+ $userid = $user->id;
+
+ $frnd_mod = new EasySocialModelFriends();
+
+ // if search word present then search user as per term and given id
+ if(empty($search))
+ {
+ $ttl_list = $frnd_mod->getFriends($userid);
+ }
+ else
+ {
+ $ttl_list = $frnd_mod->search($userid,$search,'username');
+ }
+
+ //$frnd_list = $this->basefrndObj($ttl_list);
+ $frnd_list = $mapp->mapItem( $ttl_list,'user',$userid);
+
+ //get other data
+ foreach($frnd_list as $ky=>$lval)
+ {
+ //get mutual friends of given user
+ /*if($userid != $user->id)
+ {
+ $lval->mutual = $frnd_mod->getMutualFriendCount($user->id,$lval->id);
+ $lval->isFriend = $frnd_mod->isFriends($user->id,$lval->id);
+ //$lval->mutual_frnds = $frnd_mod->getMutualFriends($userid,$lval->id);
+ }
+ else
+ {
+ $lval->mutual = $frnd_mod->getMutualFriendCount($userid,$lval->id);
+ $lval->isFriend = $frnd_mod->isFriends($user->id,$lval->id);
+ }*/
+
+ $lval->mutual = $frnd_mod->getMutualFriendCount($user->id,$lval->id);
+ $lval->isFriend = $frnd_mod->isFriends($user->id,$lval->id);
+ }
+
+ return( $frnd_list );
+ }
+
+ //format friends object into required object
+ function basefrndObj($data=null)
+ {
+ if($data==null)
+ return 0;
+
+ $list = array();
+ foreach($data as $k=>$node)
+ {
+ $obj = new stdclass;
+ $obj->id = $node->id;
+ $obj->name = $node->name;
+ $obj->username = $node->username;
+ $obj->email = $node->email;
+
+ //$obj->avatar = EasySocialModelAvatars::getPhoto($node->id);
+ foreach($node->avatars As $ky=>$avt)
+ {
+ $avt_key = 'avtar_'.$ky;
+ $obj->$avt_key = JURI::root().'media/com_easysocial/avatars/users/'.$node->id.'/'.$avt;
+ }
+
+ $list[] = $obj;
+ }
+
+ return $list;
+
+ }
+
+ //function use for get friends data
+ function manageFriends()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $db = JFactory::getDbo();
+
+ $frnd_id = $app->input->get('target_userid',0,'INT');
+
+ $userid = $log_user->id;
+
+ $res = new stdClass();
+
+ if(!$frnd_id)
+ {
+ return 'Friend id not found';
+ }
+
+ $frnds_obj = new EasySocialModelFriends();
+
+ $result = $frnds_obj->request($userid,$frnd_id);
+
+ if($result->id)
+ {
+ $res->status = 1;
+ /*$res->frnd_id = $frnd_id;
+ $res->code = 200;
+ $res->message = 'Request send';*/
+ }
+ else
+ {
+ $res->status = 0;
+ /*$res->code = 403;
+ $res->message = $result;*/
+ }
+ return $res;
+
+ }
+
+}
diff --git a/easysocial/easysocial/friends.php b/easysocial/easysocial/friends.php
index 0d8ab58..5e10da8 100644
--- a/easysocial/easysocial/friends.php
+++ b/easysocial/easysocial/friends.php
@@ -11,8 +11,7 @@
jimport('joomla.plugin.plugin');
jimport('joomla.html.html');
-require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/friends.php';
-require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/avatars.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
class EasysocialApiResourceFriends extends ApiResource
{
@@ -20,7 +19,6 @@ public function get()
{
$this->plugin->setResponse($this->getFriends());
}
-
public function post()
{
$this->plugin->setResponse($this->getFriends());
@@ -28,81 +26,183 @@ public function post()
//function use for get friends data
function getFriends()
{
+ $avt_model = FD::model( 'Avatars' );
+ $default = $avt_model->getDefaultAvatars(0,$type = SOCIAL_TYPE_PROFILES);
//init variable
$app = JFactory::getApplication();
$user = JFactory::getUser($this->plugin->get('user')->id);
- $userid = ($app->input->get('userid',0,'INT'))?$app->input->get('userid',0,'INT'):$app->input->post->get('userid',0,'INT');
-
- //$search = (isset($app->input->get('search','','STRING')))?$app->input->get('search','','STRING'):$app->input->post->get('search','','STRING');
+ $userid = $app->input->get('target_user',0,'INT');
+ $filter = $app->input->get('filter',NULL,'STRING');
$search = $app->input->get('search','','STRING');
+ $limit = $app->input->get('limit',10,'INT');
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ //$options['limit']=$limit;
+ //$options['limitstart']=$limitstart;
+ $mssg;
+ $mapp = new EasySocialApiMappingHelper();
if($userid == 0)
$userid = $user->id;
+
+
- $frnd_mod = new EasySocialModelFriends();
+ $frnd_mod = FD::model( 'Friends' );
+ $frnd_mod->setState('limit',$limit);
+ //$frnd_mod->setState('limitstart',$limitstart);
- //if search word present then search user as per term and given id
- if(empty($search))
+ $ttl_list = array();
+ switch($filter)
+ {
+ case 'pending': //get the total pending friends.
+ $options[ 'state' ] = SOCIAL_FRIENDS_STATE_PENDING;
+ $mssg = JText::_( 'PLG_API_EASYSOCIAL_NO_PENDING_REQUESTS' );
+ $flag=0;
+ break;
+ case 'all': //getting all friends
+ $options[ 'state' ] = SOCIAL_FRIENDS_STATE_FRIENDS;
+ $mssg=JText::_( 'PLG_API_EASYSOCIAL_NO_FRIENDS' );
+ $flag=0;
+ break;
+ case 'request': //getting sent requested friends.
+ $options[ 'state' ] = SOCIAL_FRIENDS_STATE_PENDING;
+ $options[ 'isRequest' ] = true;
+ $flag=0;
+ $mssg=JText::_( 'PLG_API_EASYSOCIAL_NOT_SENT_REQUEST' );
+ break;
+
+ case 'suggest': //getting suggested friends
+ $sugg_list = $frnd_mod->getSuggestedFriends($userid);
+
+
+ //$sugg_list = array_slice($sugg_list,$limitstart,$limit);
+ foreach($sugg_list as $sfnd)
+ {
+ $ttl_list[] = $sfnd->friend;
+ }
+
+ if(!empty($ttl_list))
+ {
+ $flag=1;
+ }
+ else
+ {
+ $flag=1;
+ $mssg=JText::_( 'PLG_API_EASYSOCIAL_NO_SUGGESTIONS' );
+ }
+
+
+
+ break;
+ case 'invites': //getiing invited friends
+ $invites['data'] = $frnd_mod->getInvitedUsers($userid);
+ $mssg=JText::_( 'PLG_API_EASYSOCIAL_NO_INVITATION' );
+ if(empty($invites['data']))
+ {
+ $invites['data']['message']=$mssg;
+ $invites['data']['status']=false;
+ }
+ return $invites;
+ break;
+ }
+ // if search word present then search user as per term and given id
+ if(empty($search) && empty($ttl_list) && $flag!=1 )
{
- $ttl_list = $frnd_mod->getFriends($userid);
- }
- else
- {
- $ttl_list = $frnd_mod->search($userid,$search,'username');
+ $ttl_list = $frnd_mod->getFriends($userid,$options);
}
-
- $frnd_list = $this->basefrndObj($ttl_list);
-
+ else if(!empty($search) && empty($filter))
+ {
+ $ttl_list = $frnd_mod->search($userid,$search,'username');
+ }
+
+
+ if(count($ttl_list)>'0')
+ {
+
+ $frnd_list['data'] = $mapp->mapItem( $ttl_list,'user',$userid);
+
+ $frnd_list['data'] = $mapp->frnd_nodes( $frnd_list['data'],$user);
+
+
+
+ $myoptions[ 'state' ] = SOCIAL_FRIENDS_STATE_PENDING;
+ $myoptions[ 'isRequest' ] = true;
+ $req=$frnd_mod->getFriends( $user->id,$myoptions );
+ $myarr=array();
+ if(!empty($req))
+ {
+ foreach($req as $ky=>$row)
+ {
+ $myarr[]= $row->id;
+ }
+ }
+
//get other data
- foreach($frnd_list as $ky=>$lval)
+ foreach($frnd_list['data'] as $ky=>$lval)
{
//get mutual friends of given user
- if($userid != $user->id)
+ if( $lval->id != $user->id)
{
- $lval->mutual = $frnd_mod->getMutualFriendCount($userid,$lval->id);
- $lval->isFriend = $frnd_mod->isFriends($userid,$lval->id);
+ $lval->mutual = $frnd_mod->getMutualFriendCount($user->id,$lval->id);
+
+ //if( $user->id != $lval->id )
+ $lval->isFriend = $frnd_mod->isFriends( $user->id,$lval->id );
+ $lval->isself = false;
+
+
+ if(in_array($lval->id,$myarr))
+ {
+ $lval->isinitiator=true;
+ }
+ else
+ {
+ $lval->isinitiator=false;
+ }
+ //$lval->approval_pending=false;
//$lval->mutual_frnds = $frnd_mod->getMutualFriends($userid,$lval->id);
}
else
{
$lval->mutual = $frnd_mod->getMutualFriendCount($userid,$lval->id);
- $lval->isFriend = true;
- }
+ $lval->isFriend = $frnd_mod->isFriends($userid,$lval->id);
+ $lval->isself = true;
+ }
+
+ //$lval->mutual = $frnd_mod->getMutualFriendCount($user->id,$lval->id);
+ //$lval->isFriend = $frnd_mod->isFriends($user->id,$lval->id);
}
- return( $frnd_list );
}
-
- //format friends object into required object
- function basefrndObj($data=null)
+ else
{
- if($data==null)
- return 0;
-
-
- $list = array();
- foreach($data as $k=>$node)
+ $frnd_list['data'] = $ttl_list;
+ }
+
+ //if data is empty givin respective message and status.
+ if(count($frnd_list['data']))
+ {
+ //as per front developer requirement manage list
+ $frnd_list['data'] = array_slice($frnd_list['data'],$limitstart,$limit);
+ $frnd_list['data_status'] = (count($frnd_list['data']))?true:false;
+
+ }
+ else
{
- $obj = new stdclass;
- $obj->id = $node->id;
- $obj->name = $node->name;
- $obj->username = $node->username;
- $obj->email = $node->email;
-
- //$obj->avatar = EasySocialModelAvatars::getPhoto($node->id);
- foreach($node->avatars As $ky=>$avt)
- {
- $avt_key = 'avtar_'.$ky;
- $obj->$avt_key = JURI::root().'media/com_easysocial/avatars/users/'.$node->id.'/'.$avt;
- }
-
- $list[] = $obj;
+ $frnd_list['data']['message'] = $mssg;
+ //$frnd_list['data']['status'] = false;
+ $frnd_list['data_status'] = false;
+
}
-
- return $list;
-
+ //pending
+ $frnd_list['status']['pending'] = $frnd_mod->getTotalPendingFriends( $userid );
+
+ //all frined
+ $frnd_list['status']['all'] = $frnd_mod->getTotalFriends( $userid );
+ //suggested
+ $frnd_list['status']['suggest'] = $frnd_mod->getSuggestedFriends( $userid, null, true );
+ //request sent
+ $frnd_list['status']['request'] = $frnd_mod->getTotalRequestSent( $userid );
+ //invited
+ $frnd_list['status']['invites'] = $frnd_mod->getTotalInvites( $userid );
+ return( $frnd_list );
}
-
-
-
}
diff --git a/easysocial/easysocial/gcm.php b/easysocial/easysocial/gcm.php
new file mode 100644
index 0000000..31b5577
--- /dev/null
+++ b/easysocial/easysocial/gcm.php
@@ -0,0 +1,174 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceGcm extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->toggleNotify());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->send_notif());
+ }
+ public function delete()
+ {
+ $this->plugin->setResponse($this->delete_notif());
+ }
+ public function toggleNotify()
+ {
+ $result = new stdClass();
+ $state = false;
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ $dev_id = $app->input->get('device_id','','RAW');
+ $nval = $app->input->get('notify_val',1,'INT');
+
+ //DB Create steps
+ $db = FD::db();
+
+ if( $dev_id == "null" || $dev_id == null )
+ {
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_NO_DEVICE_ID' );
+ $result->success = $state;
+ }
+ else
+ {
+
+ $state = $this->tnotify($log_user, $dev_id, $nval);
+ $result->success= $state;
+ $result->message = ( $state && $nval )?JText::_( 'PLG_API_EASYSOCIAL_NOTIFICATION_ON' ):JText::_( 'PLG_API_EASYSOCIAL_NOTIFICATION_OFF' );
+
+ }
+
+ return $result;
+ }
+
+ public function tnotify($log_user, $dev_id , $val)
+ {
+ //DB Create steps
+ $db = FD::db();
+
+ $query1 = "SELECT id FROM #__acpush_users WHERE device_id LIKE '%".$dev_id."%'";
+ $db->setQuery($query1);
+ $db->query();
+ $id = $db->loadResult();
+
+ $query_a = "UPDATE #__acpush_users SET active = ".$val." WHERE id = ".$id;
+
+ $db->setQuery($query_a);
+ return $val = $db->query();
+ }
+
+ //do notification setting
+ public function send_notif()
+ {
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ $user=FD::user($log_user);
+ $reg_id = $app->input->get('device_id','','STRING');
+
+ $type = $app->input->get('type','','STRING');
+ $res = new stdClass;
+
+ //not allow empty device id for registration
+ if( $reg_id == "null" || $reg_id == null )
+ {
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_NO_DEVICE_ID' );
+ $res->status=false;
+ return $res;
+
+ }
+
+ //DB Create steps
+ $db = FD::db();
+ //Create a new query object.
+ $query = $db->getQuery(true);
+ $inserquery = $db->getQuery(true);
+ //Get date.
+ $now = new DateTime();
+ $currentdate=$now->format('Y-m-d H:i:s');
+
+ //Getting database values to check current user is login again or he change his device then only adding device to database
+ $checkval = $db->getQuery(true);
+ $checkval->select($db->quoteName('id'));
+ $checkval->from($db->quoteName('#__acpush_users'));
+ $checkval->where("device_id LIKE '%".$reg_id."%' AND type = "."'".$type."'");
+
+ $db->setQuery($checkval);
+
+ $ids_dev = $db->loadResult();
+
+ /*foreach($results as $notfn)
+ {
+ if($notfn->user_id==$log_user && $notfn->device_id==$reg_id)
+ {
+ $res->message = "Your device is already register to server.";
+ $res->status=false;
+ return $res;
+ }
+ }*/
+
+ if($ids_dev)
+ {
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_DEVICE_ALREADY_REGISTERED_MESSAGE' );
+ $res->status=false;
+ return $res;
+ }
+ else
+ {
+
+ //Insert columns now.
+ $columns = array('device_id','user_id','created_on','type','active');
+ //Insert values.
+ $values = array($db->quote($reg_id),$db->quote($user->id),$db->quote($currentdate),$db->quote($type),1);
+ //Prepare the insert query.
+ $inserquery->insert($db->quoteName('#__acpush_users'))->columns($db->quoteName($columns))->values(implode(',', $values));
+
+ $db->setQuery( $inserquery );
+ $result = $db->query();
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_DEVICE_REGISTER_MESSAGE' );
+ $res->status=$result;
+ return $res;
+ }
+ }
+ public function delete_notif()
+ {
+ $app = JFactory::getApplication();
+ $reg_id = $app->input->get('device_id','','STRING');
+
+ //not allow empty device id for registration
+ if( $reg_id == "null" || $reg_id == null )
+ {
+ return false;
+ }
+
+ //DB steps
+ $db = FD::db();
+ //Getting database values to check current user is login again or he change his device then only adding device to database
+ $query = $db->getQuery(true);
+ // delete all custom keys for user 1001.
+ $conditions = " ".$db->quoteName('device_id') ." LIKE '%".$reg_id."%' ";
+ $query->delete($db->quoteName('#__acpush_users'));
+ $query->where($conditions);
+ $db->setQuery($query);
+
+ $result = $db->execute();
+ return $result;
+ //return true;
+ }
+}
+
+
diff --git a/easysocial/easysocial/getalbums.php b/easysocial/easysocial/getalbums.php
new file mode 100644
index 0000000..17412f7
--- /dev/null
+++ b/easysocial/easysocial/getalbums.php
@@ -0,0 +1,83 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceGetalbums extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_albums());
+ }
+ //get user album as per id / login user
+ public function get_albums()
+ {
+ $app = JFactory::getApplication();
+ //getting log_user
+ $log_user = $this->plugin->get('user')->id;
+ //accepting user details.
+ $uid = $app->input->get('uid',0,'INT');
+ $type = $app->input->get('type',0,'STRING');
+ $mapp = new EasySocialApiMappingHelper();
+ //accepting pagination values.
+ $limitstart = $app->input->get('limitstart',5,'INT');
+ $limit = $app->input->get('limit',10,'INT');
+ // taking values in array for pagination of albums.
+ //$mydata['limitstart']=$limitstart;
+ $mydata['excludeblocked'] = 1;
+ $mydata['pagination'] = 1;
+ //$mydata['limit'] = $limit;
+ $mydata['privacy'] = true;
+ $mydata['order'] = 'a.assigned_date';
+ $mydata['direction'] = 'DESC';
+ //creating object and calling relatvie method for data fetching.
+ $obj = new EasySocialModelAlbums();
+
+ //$obj->setState('limitstart',$limitstart);
+ //$obj->setState('limit',$limit);
+
+ //$obj->limitstart = $limitstart;
+ //$obj->limit= $limit;
+
+ // first param is user id,user type and third contains array for pagination.
+ $albums = $obj->getAlbums($uid,$type,$mydata);
+ //use to load table of album.
+ $album = FD::table( 'Album' );
+
+ foreach($albums as $album )
+ {
+ if($album->cover_id)
+ {
+ $album->load( $album->id );
+ }
+ $album->cover_featured = $album->getCover('featured');
+ $album->cover_large = $album->getCover('large');
+ $album->cover_square = $album->getCover('square');
+ $album->cover_thumbnail = $album->getCover('thumbnail');
+ }
+ //getting count of photos in every albums.
+ foreach($albums as $alb)
+ {
+ $alb->count = $obj->getTotalPhotos($alb->id);
+ }
+ $all_albums = $mapp->mapItem($albums,'albums',$log_user);
+
+ $output = array_slice($all_albums, $limitstart, $limit);
+
+ return $output;
+
+ }
+}
diff --git a/easysocial/easysocial/group.php b/easysocial/easysocial/group.php
new file mode 100644
index 0000000..5ff5a29
--- /dev/null
+++ b/easysocial/easysocial/group.php
@@ -0,0 +1,430 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceGroup extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getGroup());
+ }
+
+ public function post()
+ {
+ //print_r($FILES);die("in post grp api");
+ $this->plugin->setResponse($this->CreateGroup());
+ }
+
+ public function delete()
+ {
+ $app = JFactory::getApplication();
+
+ $group_id = $app->input->get('id',0,'INT');
+ $valid = 1;
+ $result = new stdClass;
+
+ $group = FD::group( $group_id );
+
+ if( !$group->id || !$group_id )
+ {
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_INVALID_GROUP_MESSAGE' );
+ $valid = 0;
+ }
+
+ // Only allow super admins to delete groups
+ $my = FD::user($this->plugin->get('user')->id);
+
+ if( !$my->isSiteAdmin() && !$group->isOwner())
+ {
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_ACCESS_DENIED_MESSAGE' );
+ $valid = 0;
+ }
+
+ if($valid)
+ {
+ // Try to delete the group
+ $group->delete();
+
+ $result->status = 1;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_GROUP_DELETED_MESSAGE' );
+ }
+
+ $this->plugin->setResponse($result);
+ }
+ //function use for get friends data
+ function getGroup()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $group_id = $app->input->get('id',0,'INT');
+ $other_user_id = $app->input->get('user_id',0,'INT');
+
+ $userid = ($other_user_id)?$other_user_id:$log_user->id;
+ $data = array();
+
+ $user = FD::user($userid);
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ $grp_model = FD::model('Groups');
+
+ if($group_id)
+ {
+ $group[] = FD::group($group_id);
+
+ //$pth = FD::photo($group[0]->creator_uid,'',$group[0]->id);
+
+ $data['data'] = $mapp->mapItem($group,'group',$log_user->id);
+ }
+ return( $data );
+ }
+
+ //function for create new group
+ function CreateGroup()
+ {
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+ $user = FD::user($log_user->id);
+
+ $config = FD::config();
+
+ //create group post structure
+ $grp_data = array();
+ $result = new stdClass;
+ $valid = 1;
+
+ $title = $app->input->get('title',null,'STRING');
+ $parmalink = $app->input->get('parmalink',null,'STRING');
+ $description = $app->input->get('description',null,'STRING');
+ $type = $app->input->get('type',0,'INT');
+ $categoryId = $app->input->get('category_id',0,'INT');
+
+ $avtar_pth = '';
+ $avtar_scr = '';
+ $avtar_typ = '';
+ $phto_obj = null;
+
+ if(!empty($_FILES['file']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
+ $phto_obj = $upload_obj->ajax_avatar($_FILES['file']);
+ $avtar_pth = $phto_obj['temp_path'];
+ $avtar_scr = $phto_obj['temp_uri'];
+ $avtar_typ = 'upload';
+ $avatar_file_name = $_FILES['file']['name'];
+ }
+
+ $cover_data = null;
+
+ if(!empty($_FILES['cover_file']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'],'cover_file');
+ //$phtomod = FD::model( 'Photos' );
+ //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
+ //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
+ //
+ }
+
+ //
+
+ //check title
+ if(empty($title) || $title == null)
+ {
+ $valid = 0;
+ $result->status = 0;
+ $result->message[] = JText::_( 'PLG_API_EASYSOCIAL_INVALID_GROUP_NAME' );
+
+ }
+
+ //check parmalink
+ if(empty($parmalink) || $parmalink == null)
+ {
+ $valid = 0;
+ $result->status = 0;
+ $result->message[] = JText::_( 'PLG_API_EASYSOCIAL_INVALID_PARMALINK' );
+ }
+
+ //check description
+ if(empty($description) || $description == null)
+ {
+ $valid = 0;
+ $result->status = 0;
+ $result->message[] = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_DESCRIPTION' );
+ }
+
+ //check group type
+ if(empty($type) || $type == 0)
+ {
+ $valid = 0;
+ $result->status = 0;
+ $result->message[] = JText::_( 'PLG_API_EASYSOCIAL_ADD_GROUP_TYPE_MESSAGE' );
+ }
+
+ if(!$valid)
+ {
+ return $result;
+ }
+ else
+ {
+ // create steps
+ $db = FD::db();
+
+ $group = FD::table('Group');
+ FD::import('admin:/includes/group/group');
+ $group = new SocialGroup();
+
+ // Load front end's language file
+ FD::language()->loadSite();
+
+ $category = FD::table('GroupCategory');
+ $category->load($categoryId);
+
+ // Get the steps
+ $stepsModel = FD::model('Steps');
+ $steps = $stepsModel->getSteps($categoryId, SOCIAL_TYPE_CLUSTERS);
+
+ // Get the fields
+ $lib = FD::fields();
+ $fieldsModel = FD::model('Fields');
+
+ /*$post = $this->input->post->getArray();
+ $args = array(&$post, &$group, &$errors);*/
+
+ // query written due to commented function not working
+ $query = "SELECT a.id,a.unique_key FROM `#__social_fields` AS `a`
+ LEFT JOIN `#__social_apps` AS `b` ON `b`.`id` = `a`.`app_id`
+ LEFT JOIN `#__social_fields_steps` AS `d` ON `a`.`step_id` = `d`.`id`
+ WHERE `a`.`step_id` = '".$steps[0]->id."' ORDER BY `d`.`sequence` ASC,`a`.`ordering` ASC";
+
+ $db->setQuery( $query );
+
+ $field_ids = $db->loadAssocList();
+
+ /*foreach ($steps as $step) {
+
+ if ($group->id) {
+ $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $group->id, 'dataType' => SOCIAL_TYPE_GROUP));
+ }
+ else {
+ $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id));
+ }
+
+
+ }*/
+
+ foreach($field_ids as $field)
+ {
+ $grp_data['cid'][] = $field['id'];
+
+ switch($field['unique_key'])
+ {
+ case 'HEADER': break;
+ case 'TITLE': $grp_data['es-fields-'.$field['id']] = $title;
+ break;
+ case 'PERMALINK': $grp_data['es-fields-'.$field['id']] = $parmalink;
+ break;
+ case 'DESCRIPTION': $grp_data['es-fields-'.$field['id']] = $description;
+ break;
+ case 'TYPE': $grp_data['group_type'] = $type;
+ break;
+ case 'URL': $grp_data['es-fields-'.$field['id']] = $app->input->get('website',null,'STRING');
+ break;
+ case 'PHOTOS': $grp_data['photo_albums'] = $app->input->get('photo_album',0,'INT');
+ break;
+ case 'NEWS': $grp_data['es-fields-'.$field['id']] = $app->input->get('announcements',0,'INT');
+ break;
+ case 'DISCUSSIONS': $grp_data['es-fields-'.$field['id']] = $app->input->get('discussions',0,'INT');
+ break;
+
+ case 'AVATAR': $grp_data['es-fields-'.$field['id']] = Array
+ (
+ 'source' =>$avtar_scr,
+ 'path' =>$avtar_pth,
+ 'data' => '',
+ 'type' => $avtar_typ,
+ 'name' => $avatar_file_name
+ );
+ break;
+ case 'COVER': $grp_data['es-fields-'.$field['id']] = Array
+ (
+ 'data' =>$cover_data,
+ 'position' =>'{"x":0.5,"y":0.5}'
+ );
+ break;
+ }
+ }
+
+ //for check group exceed limit
+ if( !$user->getAccess()->allowed( 'groups.create' ) && !$user->isSiteAdmin() )
+ {
+ $valid = 0;
+ $result->status = 0;
+ $result->message[] = JText::_( 'PLG_API_EASYSOCIAL_CREATE_GROUP_ACCESS_DENIED' );
+ return $result;
+ }
+
+ // Ensure that the user did not exceed their group creation limit
+ if ($user->getAccess()->intervalExceeded('groups.limit', $user->id) && !$user->isSiteAdmin())
+ {
+ $valid = 0;
+ $result->status = 0;
+ $result->message[] = JText::_( 'PLG_API_EASYSOCIAL_GROUP_CREATION_LIMIT_EXCEEDS' );
+ return $result;
+ }
+
+ // Get current user's info
+ $session = JFactory::getSession();
+ // Get necessary info about the current registration process.
+ $stepSession = FD::table( 'StepSession' );
+ $stepSession->load( $session->getId() );
+ $stepSession->uid = $categoryId;
+
+ // Load the group category
+ $category = FD::table( 'GroupCategory' );
+ $category->load( $stepSession->uid );
+
+ $sequence = $category->getSequenceFromIndex($stepSession->step, SOCIAL_GROUPS_VIEW_REGISTRATION);
+
+ // Load the current step.
+ $step = FD::table( 'FieldStep' );
+ $step->load(array('uid' => $category->id, 'type' => SOCIAL_TYPE_CLUSTERS, 'sequence' => $sequence));
+
+ // Merge the post values
+ $registry = FD::get( 'Registry' );
+ $registry->load( $stepSession->values );
+
+ // Load up groups model
+ $groupsModel = FD::model( 'Groups' );
+
+ // Get all published fields apps that are available in the current form to perform validations
+ $fieldsModel = FD::model( 'Fields' );
+ $fields = $fieldsModel->getCustomFields( array( 'step_id' => $step->id, 'visible' => SOCIAL_GROUPS_VIEW_REGISTRATION ) );
+
+ // Load json library.
+ $json = FD::json();
+
+ // Retrieve all file objects if needed
+ //$files = JRequest::get( 'FILES' );
+
+
+ $token = FD::token();
+
+ $disallow = array($token, 'option', 'cid', 'controller', 'task', 'option', 'currentStep');
+
+ foreach( $grp_data as $key => $value )
+ {
+ if (!in_array($key, $disallow))
+ {
+ if( is_array( $value ) )
+ {
+ $value = FD::json()->encode( $value );
+ }
+ $registry->set( $key , $value );
+ }
+ }
+
+ // Convert the values into an array.
+ $data = $registry->toArray();
+
+ $args = array( &$data , &$stepSession );
+
+ // Perform field validations here. Validation should only trigger apps that are loaded on the form
+ // @trigger onRegisterValidate
+ $fieldsLib = FD::fields();
+
+ // Get the trigger handler
+ $handler = $fieldsLib->getHandler();
+
+ // Get error messages
+ $errors = $fieldsLib->trigger( 'onRegisterValidate' , SOCIAL_FIELDS_GROUP_GROUP , $fields , $args, array( $handler, 'validate' ) );
+
+ // The values needs to be stored in a JSON notation.
+ $stepSession->values = $json->encode( $data );
+
+ $stepSession->created = FD::date()->toMySQL();
+
+ $group = $groupsModel->createGroup( $stepSession );
+
+ if($group->id)
+ {
+ $result->status = 1;
+ $result->id = $group->id;
+
+ // @points: groups.create
+ // Assign points to the user when a group is created
+ $points = FD::points();
+ $points->assign( 'groups.create' , 'com_easysocial' , $log_user );
+
+ // If the group is published, we need to perform other activities
+ if( $group->state == SOCIAL_STATE_PUBLISHED )
+ {
+ $this->addTostream($user,$group,$config);
+ }
+ }
+ else
+ {
+ $result->status = 0;
+ $result->id = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_CREATE_GROUP_MESSAGE' );
+ }
+
+ return $result;
+ }
+ }
+
+ public function addTostream($my,$group,$config)
+ {
+ $stream = FD::stream();
+ $streamTemplate = $stream->getTemplate();
+
+ // Set the actor
+ $streamTemplate->setActor( $my->id , SOCIAL_TYPE_USER );
+
+ // Set the context
+ $streamTemplate->setContext( $group->id , SOCIAL_TYPE_GROUPS );
+
+ $streamTemplate->setVerb( 'create' );
+ $streamTemplate->setSiteWide();
+ $streamTemplate->setAccess( 'core.view' );
+ $streamTemplate->setCluster($group->id, SOCIAL_TYPE_GROUP, $group->type );
+
+ // Set the params to cache the group data
+ $registry = FD::registry();
+ $registry->set( 'group' , $group );
+
+ // Set the params to cache the group data
+ $streamTemplate->setParams( $registry );
+
+ // Add stream template.
+ $stream->add( $streamTemplate );
+
+ return true;
+ }
+
+}
diff --git a/easysocial/easysocial/group_category.php b/easysocial/easysocial/group_category.php
new file mode 100644
index 0000000..b985adf
--- /dev/null
+++ b/easysocial/easysocial/group_category.php
@@ -0,0 +1,62 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceGroup_category extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getCategory());
+ }
+
+ public function post()
+ {
+ //print_r($FILES);die("in post grp api");
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_GET_METHOD_MESSAGE' ));
+ }
+
+ //function use for get friends data
+ function getCategory()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+
+ $other_user_id = $app->input->get('user_id',0,'INT');
+
+ $userid = ($other_user_id)?$other_user_id:$log_user;
+
+ $data = array();
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ $user = FD::user($userid);
+
+ // Get a list of group categories
+ $catModel = FD::model('GroupCategories');
+ $cats = $catModel->getCategories(array('state' => SOCIAL_STATE_PUBLISHED, 'ordering' => 'ordering'));
+
+ $data['data'] = $mapp->mapItem($cats,'category',$log_user);
+
+ return( $data );
+ }
+
+}
diff --git a/easysocial/easysocial/group_members.php b/easysocial/easysocial/group_members.php
new file mode 100644
index 0000000..1dacd3f
--- /dev/null
+++ b/easysocial/easysocial/group_members.php
@@ -0,0 +1,250 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groupmembers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/model.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceGroup_members extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getGroup_Members());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->joineGroup());
+ }
+
+ public function getGroup_Members()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ $group_id = $app->input->get('group_id',0,'INT');
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ $limit = $app->input->get('limit',10,'INT');
+ $mapp = new EasySocialApiMappingHelper();
+ $data = array();
+ //hari
+ $filter = $app->input->get('filter','admins','STRING');
+
+ if($limitstart)
+ {
+ $limit = $limit + $limitstart;
+ }
+
+ //for filter user by type
+ $type = $app->input->get('type','group','STRING');
+
+ $state = $app->input->get('state',1,'INT');
+ $getAdmin = $app->input->get('admin',1,'INT');
+
+ if($type == 'group')
+ {
+ /*$options = array( 'groupid' => $group_id );
+ $gruserob = new EasySocialModelGroupMembers();
+
+ $gruserob->setState('limit',$limit);
+
+ $data = $gruserob->getItems($options);
+
+ foreach($data as $val )
+ {
+ $val->id = $val->uid;
+ }*/
+
+ $data = $this->getGroupMembers($group_id,$limit,$log_user,$mapp);
+
+ }
+ else if( $type == 'event' )
+ {
+ $data = $this->getEventMembers($group_id,$filter,$log_user,$mapp);
+ }
+
+ if(empty($data))
+ {
+ $ret_arr = new stdClass;
+ $ret_arr->status = false;
+ $ret_arr->message = JText::_( 'PLG_API_EASYSOCIAL_MEMBER_NOT_FOUND_MESSAGE' );
+ return $ret_arr;
+ }
+
+ //manual pagination code
+ $user_list = array_slice( $data, $limitstart, $limit );
+
+ return $user_list;
+ }
+
+ //get events members
+ public function getEventMembers($group_id,$filter,$log_user,$mapp)
+ {
+
+ //Get event guest with filter.
+ $grp_model = FD::model('Events');
+ if(!empty($filter))
+ {
+ $options['users'] = true;
+ switch($filter)
+ {
+ case 'going':
+ $options['state'] = SOCIAL_EVENT_GUEST_GOING;
+ break;
+ case 'notgoing':
+ $options['state'] = SOCIAL_EVENT_GUEST_NOT_GOING;
+ break;
+ case 'maybe':
+ $options['state'] = SOCIAL_EVENT_GUEST_MAYBE;
+
+ break;
+ case 'pending':
+ $options['state'] = SOCIAL_EVENT_GUEST_PENDING;
+ $options['users'] = true;
+ break;
+ case 'admins':
+ $options['admin'] = true;
+ break;
+ }
+
+ $eguest = FD::model('Events');
+ $data = $eguest->getGuests($group_id,$options);
+
+ $data = $mapp->mapItem( $data,'user',$log_user );
+
+ if($filter == 'pending')
+ {
+ $options['state'] = SOCIAL_EVENT_GUEST_PENDING;
+ $options['users'] = false;
+ $udata = $eguest->getGuests($group_id,$options);
+
+ foreach($udata as $usr )
+ {
+ foreach($data as $dt )
+ {
+ if($usr->uid == $dt->id)
+ {
+ $dt->request_id = $usr->id;
+ $dt->request_state = $usr->state;
+ $dt->isowner = $usr->isOwner();
+ $dt->isStrictlyAdmin = $usr->isStrictlyAdmin();
+ $dt->isGoing = $usr->isGoing();
+ $dt->isMaybe = $usr->isMaybe();
+ $dt->isNotGoing = $usr->isNotGoing();
+ $dt->isPending = $usr->isPending();
+ }
+
+
+ }
+
+ }
+
+ }
+
+ return $data;
+
+
+ }
+
+ }
+
+ //get group members
+ public function getGroupMembers($group_id,$limit,$log_user,$mapp)
+ {
+ $grp_model = FD::model('Groups');
+ $options = array( 'groupid' => $group_id );
+ $gruserob = new EasySocialModelGroupMembers();
+
+ $gruserob->setState('limit',$limit);
+
+ $data = $gruserob->getItems($options);
+
+ foreach($data as $val )
+ {
+ $val->id = $val->uid;
+ }
+
+ $user_list = $mapp->mapItem( $data,'user',$log_user );
+
+ foreach($user_list as $user)
+ {
+ $user->isMember = $grp_model->isMember( $user->id,$group_id );
+ $user->isOwner = $grp_model->isOwner( $user->id,$group_id );
+ $user->isInvited = $grp_model->isInvited( $user->id,$group_id );
+ $user->isPendingMember = $grp_model->isPendingMember( $user->id,$group_id );
+ }
+
+ return $user_list;
+
+ }
+
+ //join group by user
+ public function joineGroup()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ $group_id = $app->input->get('group_id',0,'INT');
+ $obj = new stdClass();
+
+ $group = FD::group( $group_id );
+
+ // Get the user's access as we want to limit the number of groups they can join
+ $user = FD::user($log_user);
+ $access = $user->getAccess();
+ $total = $user->getTotalGroups();
+
+ if ($access->exceeded('groups.join', $total)) {
+ $obj->success = 0;
+ $obj->message = JText::_( 'PLG_API_EASYSOCIAL_GROUP_JOIN_LIMIT_EXCEEDS_MESSAGE' );
+ return $obj;
+ }
+
+ if(!$group->isMember( $log_user ))
+ {
+ // Create a member record for the group
+ if($group->type == 3){
+ $members = $group->createMember($log_user, true);
+ } else {
+ $members = $group->createMember($log_user);
+ }
+ $obj->success = 1;
+ $obj->state = $members->state;
+
+ if($group->type == 1 && $obj->state == 1)
+ {
+ $obj->message = 'Welcome to the group, since this is an open group, you are automatically a member of the group now.';
+ }
+ elseif(($group->type == 3 || $group->type == 2) && $obj->state == 1 )
+ {
+ $obj->message = 'Great! Your joined group.';
+ }
+ else if($obj->state == 2)
+ {
+ $obj->message = 'Great! Your request has been sent successfully and it is pending approval from the group administrator.';
+ }
+
+ }
+ else
+ {
+ $obj->success = 0;
+ $obj->state = $members->state;
+ $obj->message = JText::_( 'PLG_API_EASYSOCIAL_GROUP_ALREADY_JOINED_MESSAGE' );
+ }
+
+ return $obj;
+
+ }
+
+}
diff --git a/easysocial/easysocial/groupinvite.php b/easysocial/easysocial/groupinvite.php
new file mode 100644
index 0000000..6e39fb6
--- /dev/null
+++ b/easysocial/easysocial/groupinvite.php
@@ -0,0 +1,152 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceGroupinvite extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_POST_OR_DELETE_MESSAGE' ));
+ }
+
+ public function post()
+ {
+
+ $this->plugin->setResponse($this->inviteGroup());
+ }
+
+ public function delete()
+ {
+ $app = JFactory::getApplication();
+
+ $group_id = $app->input->get('group_id',0,'INT');
+ $target_user = $app->input->get('target_user',0,'INT');
+ $operation = $app->input->get('operation',0,'STRING');
+
+ $valid = 1;
+ $result = new stdClass;
+
+ $group = FD::group( $group_id );
+
+ if( !$group->id || !$group_id )
+ {
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_INVALID_GROUP_MESSAGE' );
+ $valid = 0;
+ }
+
+ if( !$target_user )
+ {
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_INVALID_USER_MESSAGE' );
+ $valid = 0;
+ }
+
+ // Only allow super admins to delete groups
+ $my = FD::user($this->plugin->get('user')->id);
+
+
+ if($target_user == $my->id && $operation == 'leave' && $group->creator_uid == $my->id )
+ {
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_GROUP_OWNER_NOT_LEAVE_MESSAGE' );
+ $valid = 0;
+ }
+
+ //target user obj
+ $user = FD::user( $target_user );
+
+ if($valid)
+ {
+ switch($operation)
+ {
+ case 'leave': // Remove the user from the group.
+ $group->leave( $user->id );
+ // Notify group members
+ $group->notifyMembers( 'leave' , array( 'userId' => $my->id ) );
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_LEAVE_GROUP_MESSAGE' );
+ break;
+ case 'remove': // Remove the user from the group.
+ $group->deleteMember( $user->id );
+ // Notify group member
+ $group->notifyMembers('user.remove', array('userId' => $user->id));
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_USER_REMOVE_SUCCESS_MESSAGE' );
+ break;
+ }
+
+ $result->status = 1;
+ }
+
+ $this->plugin->setResponse($result);
+ }
+ //function use for get friends data
+ function inviteGroup()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $result = new stdClass;
+
+ $group_id = $app->input->get('group_id',0,'INT');
+ $target_users = $app->input->get('target_users',null,'ARRAY');
+
+ $user = FD::user($log_user->id);
+
+ $grp_model = FD::model('Groups');
+
+ $group = FD::group($group_id);
+
+ if($group_id)
+ {
+ $not_invi = array();
+ $invited = array();
+ $es_params = FD::config();
+ foreach ($target_users as $id) {
+
+ $username = JFactory::getUser($id)->name;
+
+ if($es_params->get('users')->displayName == 'username')
+ {
+ $username = $user->username;
+ }
+ // Ensure that the user is not a member or has been invited already
+ if (!$group->isMember( $id ) && !$grp_model->isInvited($id,$group_id))
+ {
+ $state = $group->invite( $id, $log_user->id );
+ $invited[] = $username;
+ }
+ else
+ {
+ $not_invi[] = $username;
+ }
+
+ }
+
+ $result->status = 1;
+ $result->invited = $invited;
+ $result->not_invtited = $not_invi;
+
+ }
+ return( $result );
+ }
+
+}
diff --git a/easysocial/easysocial/groups.php b/easysocial/easysocial/groups.php
new file mode 100644
index 0000000..371a48c
--- /dev/null
+++ b/easysocial/easysocial/groups.php
@@ -0,0 +1,152 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceGroups extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getGroups());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->getGroups());
+ }
+ //function use for get friends data
+ function getGroups()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+ $db = JFactory::getDbo();
+
+ $nxt_lim = 20;
+
+ $search = $app->input->get('search','','STRING');
+ //$group_id = $app->input->get('id',0,'INT');
+
+ $userid = $log_user->id;
+ $mapp = new EasySocialApiMappingHelper();
+
+ $filters = array();
+ $filters['category'] = $app->input->get('category',0,'INT');
+ $filters['uid'] = $app->input->get('target_user',0,'INT');
+
+ //change target user
+ if( $filters['uid'] !=0 )
+ {
+ $userid = $filters['uid'];
+ }
+
+ $filters['types'] = $app->input->get('type',0,'INT');
+ $filters['state'] = $app->input->get('state',0,'INT');
+
+ $filters['featured'] = $app->input->get('featured',false,'BOOLEAN');
+ $filters['mygroups'] = $app->input->get('mygroups',false,'BOOLEAN');
+ $filters['invited'] = $app->input->get('invited',false,'BOOLEAN');
+
+ //$filters['limit'] = $app->input->get('limit',0,'INT');
+ $limit = $app->input->get('limit',10,'INT');
+ $limitstart = $app->input->get('limitstart',0,'INT');
+
+ $model = FD::model('Groups');
+ $userObj = FD::user($userid);
+ $options = array('state' => SOCIAL_STATE_PUBLISHED,'ordering' => 'latest','types' => $userObj->isSiteAdmin() ? 'all' : 'user');
+ $groups = array();
+
+ if($filters['featured'])
+ {
+ $options['featured'] = true;
+ $featured = $model->getGroups($filters);
+ $featured_grps = $mapp->mapItem($featured,'group',$log_user->id);
+ $featured_grps = array_slice($featured_grps,$limitstart,$limit);
+ if(count($featured_grps) > 0 && $featured_grps != false)
+ {
+ return $featured_grps;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ if($filters['mygroups'])
+ {
+ $options['uid'] = $log_user->id;
+ $options['types'] = 'all';
+ }
+
+ if($filters['invited'])
+ {
+ $options['invited'] = $userid;
+ $options['types'] = 'all';
+ }
+
+ if ($filters['category'])
+ {
+ $options['category'] = $categoryId;
+ }
+
+ if($filters['uid'] == 0)
+ {
+ $groups = $model->getGroups($options);
+ }
+ elseif($search)
+ {
+ // Get exclusion list
+ $exclusion = $app->input->get('exclusion', array(), 'array');
+ $options = array('unpublished' => false, 'exclusion' => $exclusion);
+ $groups = $model->getGroups($search,$options);
+ }
+ else
+ {
+ $groups = $model->getUserGroups($filters['uid']);
+ }
+
+ //$groups = $this->baseGrpObj($groups);
+ if($limit)
+ {
+ $groups = array_slice($groups,$limitstart,$limit);
+ }
+
+ $groups = $mapp->mapItem($groups,'group',$log_user->id);
+ }
+
+ return( $groups );
+ }
+
+ //to get actor object
+ function getActor($id=0)
+ {
+ if($id==0)
+ return 0;
+
+ $user = JFactory::getUser($id);
+
+ $obj = new stdclass;
+
+ $obj->id = $user->id;
+ $obj->username = $user->username;
+ $obj->url = '';
+
+ return $obj;
+ }
+}
diff --git a/easysocial/easysocial/hashsearch.php b/easysocial/easysocial/hashsearch.php
new file mode 100644
index 0000000..03e032e
--- /dev/null
+++ b/easysocial/easysocial/hashsearch.php
@@ -0,0 +1,33 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/hashtags.php';
+
+class EasysocialApiResourceHashsearch extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_hash_list());
+ }
+ public function get_hash_list()
+ {
+ /*search for hashtag */
+ $app = JFactory::getApplication();
+ /*accepting input*/
+ $word = $app->input->get('type',NULL,'STRING');
+ $obj = new EasySocialModelHashtags();
+ /*calling method and return result*/
+ $result = $obj->search($word);
+ return $result;
+ }
+}
diff --git a/easysocial/easysocial/hashtag.php b/easysocial/easysocial/hashtag.php
new file mode 100644
index 0000000..47259f3
--- /dev/null
+++ b/easysocial/easysocial/hashtag.php
@@ -0,0 +1,38 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/stream.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/hashtags.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceHashtag extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_hash_list());
+ }
+ //get hashtag list
+ public function get_hash_list()
+ {
+ /*search for hashtag */
+ $app = JFactory::getApplication();
+ /*accepting input*/
+ $word = $app->input->get('tag',NULL,'STRING');
+ $obj = new EasySocialModelHashtags();
+ /*calling method and return result*/
+ $result = $obj->search($word);
+ return $result;
+ }
+}
diff --git a/easysocial/easysocial/leaderboard.php b/easysocial/easysocial/leaderboard.php
new file mode 100644
index 0000000..ae1749d
--- /dev/null
+++ b/easysocial/easysocial/leaderboard.php
@@ -0,0 +1,52 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceLeaderboard extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_leaderboard());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_GET_METHOD_MESSAGE' ));
+ }
+ //Get leaderboards.
+ public function get_leaderboard()
+ {
+ $app = JFactory::getApplication();
+ //getting log_user
+ $log_user = $this->plugin->get('user')->id;
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ $limit = $app->input->get('limit',10,'INT');
+ $mapp = new EasySocialApiMappingHelper();
+ $model = FD::model( 'Leaderboard' );
+ //$options = array( 'ordering' => 'points' , 'limit' => $limit , 'excludeAdmin' => $excludeAdmin ,'state' => 1);
+ $options = array( 'ordering' => 'points' , 'excludeAdmin' => $excludeAdmin ,'state' => 1);
+ $users = $model->getLadder( $options , false );
+
+ if(empty($users))
+ {
+ $res = new stdClass;
+ $res->status = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_NO_LEADERS' );
+ return $res;
+ }
+
+ $leaderusers=$mapp->mapItem($users,'user');
+ $output = array_slice($leaderusers, $limitstart, $limit);
+ return $output;
+ }
+}
diff --git a/easysocial/easysocial/like.php b/easysocial/easysocial/like.php
new file mode 100644
index 0000000..4d5562d
--- /dev/null
+++ b/easysocial/easysocial/like.php
@@ -0,0 +1,107 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceLike extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_POST_OR_DELETE_MESSAGE' ));
+ }
+
+ public function post()
+ {
+ //print_r($FILES);die("in post grp api");
+ $this->plugin->setResponse($this->toggleLike());
+ }
+ public function delete()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_NOT_SUPPORTED_MESSAGE' ));
+ }
+ //function use for get friends data
+ function toggleLike()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $result = new stdClass;
+
+ $id = $app->input->get('id',0,'INT');
+ $type = $app->input->get('type',null,'STRING');
+ $group = $app->input->get('group','user','STRING');
+ $itemVerb = $app->input->get('verb',null,'STRING');
+ $streamid = $app->input->get('stream_id',0,'INT');
+
+ $my = FD::user($log_user->id);
+
+ // Load likes library.
+ $model = FD::model( 'Likes' );
+
+ // Build the key for likes
+ $key = $type . '.' . $group;
+ if ($itemVerb) {
+ $key = $key . '.' . $itemVerb;
+ }
+
+ // Determine if user has liked this item previously.
+ $hasLiked = $model->hasLiked( $id , $key, $my->id );
+ $useStreamId = ($type == 'albums') ? '' : $streamid;
+
+ // If user had already liked this item, we need to unlike it.
+ if ($hasLiked) {
+
+ $state = $model->unlike( $id , $key , $my->id, $useStreamId );
+
+ } else {
+ $state = $model->like( $id , $key , $my->id, $useStreamId );
+
+ //now we need to update the associated stream id from the liked object
+ if ($streamid) {
+ $doUpdate = true;
+ if ($type == 'photos') {
+ $sModel = FD::model('Stream');
+ $totalItem = $sModel->getStreamItemsCount($streamid);
+
+ if ($totalItem > 1) {
+ $doUpdate = false;
+ }
+ }
+
+ if ($doUpdate) {
+ $stream = FD::stream();
+ $stream->updateModified( $streamid );
+ }
+ }
+ }
+
+ // The current action
+ $verb = $hasLiked ? JText::_( 'PLG_API_EASYSOCIAL_UNLIKE' ) : JText::_( 'PLG_API_EASYSOCIAL_LIKE' );
+
+ $result->status = $state;
+ $result->data = ($state && $verb == 'like')?$model->getLikesCount($id,$type):0;
+ $result->message = ($state)? $verb.JText::_( 'PLG_API_EASYSOCIAL_SUCCESSFULL' ): $verb.JText::_( 'PLG_API_EASYSOCIAL_UNSUCCESSFULL' );
+
+ return( $result );
+ }
+
+}
diff --git a/easysocial/easysocial/manage_friends.php b/easysocial/easysocial/manage_friends.php
new file mode 100644
index 0000000..20fa77a
--- /dev/null
+++ b/easysocial/easysocial/manage_friends.php
@@ -0,0 +1,95 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/friends.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/users.php';
+
+class EasysocialApiResourceManage_friends extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->manageFriends());
+ }
+
+ public function post()
+ {
+
+ $this->plugin->setResponse($this->manageFriends());
+ }
+ //function use for get friends data
+ function manageFriends()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $db = JFactory::getDbo();
+
+ $frnd_id = $app->input->post->get('friend_id',0,'INT');
+ $choice = $app->input->post->get('choice',0,'INT');
+
+ $userid = $log_user->id;
+
+ $res = new stdClass();
+
+ if(!$frnd_id)
+ {
+ return JText::_( 'PLG_API_EASYSOCIAL_FRIEND_ID_NOT_FOUND' );
+ }
+
+ if( $choice )
+ {
+ $frnds_obj = new EasySocialModelFriends();
+
+ $result = $frnds_obj->request($frnd_id,$userid);
+
+ if($result->id)
+ {
+ $res->frnd_id = $frnd_id;
+ $res->code = 200;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_REQUEST_SENT_SUCCESS_MESSAGE' );
+ }
+ else
+ {
+ $res->code = 403;
+ $res->message = $result;
+ }
+
+
+ }
+ else
+ {
+ $user = FD::user( $id );
+ $user->approve();
+
+ $res->result = EasySocialModelUsers::deleteFriends($frnd_id);
+
+ if( $res->result == true )
+ {
+ $res->code = 200;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_FRIEND_DELETED_MESSAGE' );
+ }
+ else
+ {
+ $res->code = 403;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_DELETE_FRIEND_MESSAGE' );
+ }
+
+ }
+
+ return $res;
+
+ }
+}
diff --git a/easysocial/easysocial/message.php b/easysocial/easysocial/message.php
new file mode 100644
index 0000000..80fead8
--- /dev/null
+++ b/easysocial/easysocial/message.php
@@ -0,0 +1,354 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceMessage extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getConversations());
+ }
+
+ public function post()
+ {
+ $app = JFactory::getApplication();
+ $recipients = $app->input->get('recipients',null,'ARRAY');
+ $msg = $app->input->get('message',null,'RAW');
+ //$target_usr = $app->input->get('target_user',0,'INT');
+ $conversion_id = $app->input->get('conversion_id',0,'INT');
+ $log_usr = $this->plugin->get('user')->id;
+ $valid = 1;
+ //setting flag for sending notification to new message or existing message reply.
+ $flag=0;
+ // Normalize CRLF (\r\n) to just LF (\n)
+ $msg = str_ireplace("\r\n", "\n", $msg);
+
+ $result = new stdClass;
+ if(count($recipients)<1)
+ {
+ $result->id = 0;
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_MESSAGE_MESSAGE' );
+ $valid = 0;
+ }
+
+ // Message should not be empty.
+ if (empty($msg))
+ {
+ $result->id = 0;
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_MESSAGE_MESSAGE' );
+ $valid = 0;
+ }
+ else if($valid)
+ {
+
+ if($conversion_id==0)
+ {
+ $flag=1;
+ }
+
+ $conversion_id = ($conversion_id)?$conversion_id:$this->createConversion($recipients,$log_usr);
+
+ if($conversion_id)
+ {
+
+ $message = FD::table('ConversationMessage');
+ // Bind the message data.
+ $post_data = array();
+ $post_data['uid'] = $recipients;
+ $post_data['message'] = $msg;
+ $post_data['upload-id'] = array();
+
+ $message->bind($post_data);
+
+ $message->message = $msg;
+ $message->conversation_id = $conversion_id;
+ $message->type = SOCIAL_CONVERSATION_TYPE_MESSAGE;
+ $message->created = FD::date()->toMySQL();
+ $message->created_by = $log_usr;
+
+ // Try to store the message now.
+ $state = $message->store();
+
+ if($state)
+ {
+ // Add users to the message maps.
+ array_unshift($recipients, $log_usr);
+
+ $model = FD::model('Conversations');
+
+ // Add the recipient as a participant of this conversation.
+ $model->addParticipants($conversion_id, $recipients);
+
+ // Add the message maps so that the recipient can view the message
+ $model->addMessageMaps($conversion_id, $message->id, $recipients, $log_usr);
+
+ //create result obj
+ $result->status = 1;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_MESSAGE_SENT_MESSAGE' );
+
+ if($flag==0)
+ {
+ foreach ($recipients as $recipientId) {
+
+ if ( $recipientId == $log_usr) {
+ // skip sending email notification to itself.
+ continue;
+ }
+ $recipient = FD::user($recipientId);
+ $log_obj = FD::user($log_usr);
+ // Add new notification item
+ $title = 'COM_EASYSOCIAL_EMAILS_NEW_REPLY_RECEIVED_SUBJECT';
+ $conversation = FD::table('Conversation');
+ $conversation->load($conversion_id);
+ $mailParams = array();
+
+ $mailParams['title'] = $title;
+ $mailParams['actor'] = $log_obj->getName();
+ $mailParams['name'] = $recipient->getName();
+ $mailParams['authorName'] = $log_obj->getName();
+ $mailParams['authorAvatar'] = $log_obj->getAvatar();
+ $mailParams['authorLink'] = $log_obj->getPermalink(true, true);
+ $mailParams['message'] = $message->message;
+ $mailParams['messageDate'] = $message->created;
+ $mailParams['conversationLink'] = $conversation->getPermalink(true, true);
+
+ // Send a notification for all participants in this thread.
+ FD::notify('conversations.reply', array($recipient), $mailParams, false);
+ }
+ }
+ else{
+ //next process
+ // Send notification email to recipients
+ foreach ($recipients as $recipientId)
+ {
+ // We should not send a notification to ourself.
+ if ($recipientId == $log_usr) {
+ continue;
+ }
+
+ $recipient = FD::user($recipientId);
+ $log_obj = FD::user($log_usr);
+
+ // Get the conversation table.
+ $conversation = FD::table('Conversation');
+ $conversation->load($conversion_id);
+ // Add new notification item
+ $mailParams = array();
+
+ $mailParams['title'] = 'COM_EASYSOCIAL_EMAILS_NEW_CONVERSATION_SUBJECT';
+ $mailparams['actor'] = $log_obj->getName();
+ $mailParams['authorName'] = $log_obj->getName();
+ $mailParams['authorAvatar'] = $log_obj->getAvatar();
+ $mailParams['authorLink'] = $log_obj->getPermalink(true, true);
+ $mailParams['message'] = $message->getContents();
+ $mailParams['messageDate'] = $message->created;
+ $mailParams['conversationLink'] = $conversation->getPermalink(true, true);
+
+ // Send a notification for all participants in this thread.
+ $state = FD::notify('conversations.new', array($recipientId) , $mailParams, false );
+ }
+ }
+ }
+ else
+ {
+ //create result obj
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_SEND_MESSAGE' );
+ }
+ }
+ }
+
+ $this->plugin->setResponse($result);
+ }
+
+ //function for upload file
+ public function uploadFile()
+ {
+ $config = FD::config();
+ $limit = $config->get( $type . '.attachments.maxsize' );
+
+ // Set uploader options
+ $options = array(
+ 'name' => 'file',
+ 'maxsize' => $limit . 'M'
+ );
+ // Let's get the temporary uploader table.
+ $uploader = FD::table( 'Uploader' );
+ $uploader->user_id = $this->plugin->get('user')->id;
+
+ // Pass uploaded data to the uploader.
+ $uploader->bindFile( $data );
+
+ $state = $uploader->store();
+ }
+
+ //create new conversion
+ public function createConversion($recipients,$log_usr)
+ {
+ // Get the conversation table.
+ $conversation = FD::table('Conversation');
+
+ $type = (count($recipients)>1)?2:1;
+ if($type==1)
+ {
+ $state = $conversation->loadByRelation($log_usr, $recipients[0], 1);
+ }
+ else
+ {
+ $points = FD::points();
+ $points->assign('conversation.create.group', 'com_easysocial', $log_usr);
+ }
+ // Set the conversation creator.
+ $conversation->created_by = $log_usr;
+ $conversation->lastreplied = FD::date()->toMySQL();
+ $conversation->type = $type;
+
+ $state = $conversation->store();
+
+ return $conversation->id;
+
+ }
+
+
+ public function delete()
+ {
+ $app = JFactory::getApplication();
+
+ $conversion_id = $app->input->get('conversation_id',0,'INT');
+ $valid = 1;
+ $result = new stdClass;
+
+ if( !$conversion_id )
+ {
+
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_INVALID_CONVERSATION_MESSAGE' );
+ $valid = 0;
+
+ }
+ else
+ {
+ // Try to delete the group
+ $conv_model = FD::model('Conversations');
+ //$my = FD::user($this->plugin->get('user')->id);
+ $result->status = $conv_model->delete( $conversion_id , $this->plugin->get('user')->id );
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_CONVERSATION_DELETED_MESSAGE' );
+ }
+
+ $this->plugin->setResponse($result);
+ }
+ //function use for get friends data
+ function getConversations()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $conversation_id = $app->input->get('conversation_id',0,'INT');
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ $limit = $app->input->get('limit',20,'INT');
+ $maxlimit = $app->input->get('maxlimit',100,'INT');
+ $filter = $app->input->get('filter',null,'STRING');
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ $data = array();
+
+ $user = FD::user($log_user->id);
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ $conv_model = FD::model('Conversations');
+ $conv_model->setState('limitstart', 0);
+ // set the startlimit
+ $conv_model->setState( 'limitstart' , $limitstart );
+
+ if($conversation_id)
+ {
+ $data['participant'] = $this->getParticipantUsers( $conversation_id );
+ //$msg_data = $conv_model->getMessages($conversation_id,$log_user->id);
+ $msg_data = $conv_model->setLimit( $limit )->getMessages($conversation_id,$log_user->id);
+
+ $data['data'] = $mapp->mapItem($msg_data,'message',$log_user->id);
+ return $data;
+ }
+ else
+ {
+ //sort items by latest first
+ $options = array( 'sorting' => 'lastreplied', 'maxlimit' => $maxlimit );
+
+ if( $filter )
+ {
+ $options['filter'] = $filter;
+ }
+
+ $conversion = $conv_model->getConversations( $log_user->id , $options );
+
+ if(count($conversion)>0)
+ {
+ /*foreach($conversion as $key=>$node)
+ {
+
+ $cobj = new stdClass;
+ $cobj->conversion_id = $node->id;
+ $cobj->created_date = $node->created;
+ $cobj->lastreplied_date = $node->lastreplied;
+ $cobj->isread = $node->isread;
+ $cobj->messages = $node->message;
+ $cobj->participant = $this->getParticipantUsers( $node->id );
+
+ $raw_msg = $conv_model->getMessages($node->id , $log_user->id );
+
+ $cobj->messages = $mapp->mapItem($raw_msg,'message',$log_user->id);
+
+ $data['data'][] = $cobj;
+ }*/
+ $data['data'] = $mapp->mapItem($conversion,'conversion',$log_user->id);
+ }
+
+ //manual pagination code
+ $data['data'] = array_slice( $data['data'], $limitstart, $limit );
+
+ return( $data );
+ }
+ }
+
+ //get conversations particepents
+ public function getParticipantUsers($con_id)
+ {
+ $conv_model = FD::model('Conversations');
+ $mapp = new EasySocialApiMappingHelper();
+
+ $participant_usrs = $conv_model->getParticipants( $con_id );
+
+ $con_usrs = array();
+
+ foreach($participant_usrs as $ky=>$usrs)
+ {
+ if($usrs->id && ($this->plugin->get('user')->id != $usrs->id) )
+ $con_usrs[] = $mapp->createUserObj($usrs->id);
+ }
+ return $con_usrs;
+ }
+
+
+}
+
diff --git a/easysocial/easysocial/newsfeed.php b/easysocial/easysocial/newsfeed.php
new file mode 100644
index 0000000..13d21e4
--- /dev/null
+++ b/easysocial/easysocial/newsfeed.php
@@ -0,0 +1,136 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceNewsfeed extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getStream());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->getGroups());
+ }
+ //function use for get stream data
+ function getStream()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ //code for get non sef urls
+ $jrouter = JFactory::getApplication()->getRouter();
+ $jrouter->setMode(JROUTER_MODE_RAW);
+
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+ $group_id = $app->input->get('group_id', 0, 'INT');
+ $event_id = $app->input->get('event_id', 0, 'INT');
+ $view = $app->input->get('view', 'dashboard', 'STRING');
+
+ $id = $this->plugin->get('user')->id;
+
+ $target_user = $app->input->get('target_user', 0, 'INT');
+
+ $limit = $app->input->get('limit', 10, 'INT');
+ $startlimit = $app->input->get('limitstart', 0, 'INT');
+
+ $filter = $app->input->get('filter', 'everyone', 'STRING');
+ //get tag
+ $tag = $app->input->get('tag', '', 'STRING');
+
+ $config = JFactory::getConfig();
+ $sef = $config->set('sef', 0);
+
+ //map object
+ $mapp = new EasySocialApiMappingHelper();
+
+ // If user id is not passed in, return logged in user
+ if (!$target_user) {
+ $target_user = $id;
+ }
+
+ // Get the stream library
+ $stream = FD::stream();
+
+ $options = array('userId' => $target_user, 'startlimit' => $startlimit, 'limit' => $limit);
+
+ $clusterType = SOCIAL_TYPE_GROUP;
+
+ if($event_id)
+ {
+ $group_id = $event_id;
+ $clusterType = SOCIAL_TYPE_EVENT;
+ }
+
+ if($group_id)
+ {
+ $options = array('clusterId' => $group_id, 'clusterType' => $clusterType, 'startlimit' => $startlimit, 'limit' => $limit);
+ }
+
+ if($target_user == $id )
+ {
+ switch($filter) {
+ case 'everyone':
+ $options['guest'] = true;
+ $options['ignoreUser'] = true;
+ $options['view'] = $view;
+ break;
+
+ case 'following':
+ case 'follow':
+ $options['type'] = 'follow';
+ break;
+ case 'bookmarks':
+ $options['guest'] = true;
+ $options['type'] = 'bookmarks';
+ case 'me':
+ $options['view'] = $view;
+ //$options['userId'] = 0;
+ // nohting to set
+ break;
+ case 'hashtag':
+ //$tag = '';
+ $options['tag'] = $tag;
+ break;
+ case 'sticky':
+ //$options['guest'] = true;
+ $options['type'] = 'sticky';
+ break;
+ default:
+ $options['context'] = $filter;
+ break;
+ }
+ }
+
+ $stream->get($options);
+
+ $result = $stream->toArray();
+
+ $data = array();
+ if(!is_array($result))
+ {
+ return $data;
+ }
+ $data11 = $mapp->mapItem($result,'stream',$target_user);
+ //set back sef
+ $jrouter->setMode(JROUTER_MODE_SEF);
+
+ return $data11;
+ }
+
+}
diff --git a/easysocial/easysocial/notification.php b/easysocial/easysocial/notification.php
new file mode 100644
index 0000000..f949262
--- /dev/null
+++ b/easysocial/easysocial/notification.php
@@ -0,0 +1,260 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/tables/friend.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/friends.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+//this api use for get all notification in app
+class EasysocialApiResourceNotification extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_data());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->friend_add_remove());
+ }
+
+ //forking respective function.
+ public function friend_add_remove()
+ {
+ $app = JFactory::getApplication();
+ $flag = $app->input->get('flag',NULL,'STRING');
+
+ if($flag =='reject')
+ {
+ $result1 = $this->removefriend();
+ return $result1;
+ }
+ else if($flag =='accept')
+ {
+ $result2 = $this->addfriend();
+ return $result2;
+ }
+ else if($flag == 'cancelrequest')
+ {
+ $result3 = $this->requestcancel();
+ return $result3;
+ }
+ else
+ return false;
+ }
+
+ //cancel friend request
+ public function requestcancel()
+ {
+ $app = JFactory::getApplication();
+ //getting target id and user id.
+ $user = $app->input->get('target_id',0,'INT');
+ $target = $app->input->get('user_id',0,'INT');
+ //$log_user = JFactory::getUser($this->plugin->get('user')->id);
+ $friend = FD::table( 'Friend' );
+ $friend->actor_id = $user;
+ $friend->target_id = $target;
+ //loading friend model for getting id.
+ $friendmodel = FD::model( 'Friends' );
+ $result = $friendmodel->getPendingRequests($user);
+ $state = SOCIAL_FRIENDS_STATE_FRIENDS;
+
+ foreach($result as $r)
+ {
+ if( $r->actor_id == $target && $r->target_id == $user)
+ {
+ //$friend->id = $r->id;
+ $friend->load($r->id);
+ break;
+ }
+ else
+ continue;
+ }
+ $status = $friendmodel->isFriends($user,$target,$state);
+
+ if(!$status)
+ {
+ //final call to reject friend request.
+ $final = $friend->reject();
+ }
+ else
+ {
+ return false;
+ }
+ return true;
+ }
+ //reject friend request
+ public function removefriend()
+ {
+ $app = JFactory::getApplication();
+ //getting target id and user id.
+ $user = $app->input->get('user_id',0,'INT');
+ $target = $app->input->get('target_id',0,'INT');
+ //$log_user = JFactory::getUser($this->plugin->get('user')->id);
+ $friend = FD::table( 'Friend' );
+ $friend->actor_id = $user;
+ $friend->target_id = $target;
+ //loading friend model for getting id.
+ $friendmodel = FD::model( 'Friends' );
+ $result = $friendmodel->getPendingRequests($user);
+ $state = SOCIAL_FRIENDS_STATE_FRIENDS;
+ $res = new stdClass;
+ foreach($result as $r)
+ {
+
+ if( $r->actor_id == $target && $r->target_id == $user)
+ {
+ $friend->id = $r->id;
+ break;
+ }
+ else
+ continue;
+ }
+ $status = $friendmodel->isFriends($user,$target,$state);
+ $addstate=$friend->loadByUser($user,$target);
+ if(!$addstate)
+ {
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_REJECT_FRIEND_REQ' );
+ $res->status = false;
+ return $res;
+ }
+ if(!$status)
+ {//final call to reject friend request.
+ $final = $friend->reject();
+ }
+ else
+ {
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNABLE_REJECT_FRIEND_REQ' );
+ $res->status = false;
+ return $res;
+ }
+
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_FRIEND_REQ_CANCEL' );
+ $res->status = true;
+ return $res;
+ }
+
+ public function addfriend()
+ {
+ $app = JFactory::getApplication();
+ $user = $app->input->get('user_id',0,'INT');
+ $target = $app->input->get('target_id',0,'INT');
+ $friend = FD::table( 'Friend' );
+ $res = new stdClass;
+ // Set the state and ensure that the state is both friends.
+ //$friend->state = 'SOCIAL_FRIENDS_STATE_FRIENDS';
+ $friend->actor_id = $user;
+ $friend->target_id = $target;
+ $state = SOCIAL_FRIENDS_STATE_FRIENDS;
+ $friendmodel = FD::model( 'Friends' );
+ $result = $friendmodel->getPendingRequests($user);
+ foreach($result as $r)
+ {
+
+ if( $r->actor_id == $target && $r->target_id == $user)
+ {
+ //$friend->id = $r->id;
+ $friend->load($r->id);
+ break;
+ }
+ else
+ continue;
+ }
+ $status = $friendmodel->isFriends($user,$target,$state);
+ $addstate=$friend->loadByUser($user,$target);
+ if(!$addstate)
+ {
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNBALE_ADD_FRIEND_REQ' );
+ $res->status = false;
+ return $res;
+ }
+ if(!$status )
+ {
+ $final=$friend->approve();
+ }
+ else
+ {
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNBALE_ADD_FRIEND_REQ' );
+ $res->status = false;
+ return $res;
+ }
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_FRIEND_REQ_ACCEPT' );
+ $res->status = true;
+ return $res;
+ }
+ //common function for forking other functions
+ public function get_data()
+ {
+ $app = JFactory::getApplication();
+ $uid = $app->input->get('uid',0,'INT');
+ $data = array();
+ $data['messagecount'] = $this->get_message_count($uid);
+ $data['message'] = $this->get_messages($uid);
+ $data['notificationcount'] = $this->get_notification_count($uid);
+ $data['notifications'] = $this->get_notifications($uid);
+ $data['friendcount'] = $this->get_friend_count($uid);
+ $data['friendreq'] = $this->get_friend_request($uid);
+ return $data;
+ }
+ //function for friend request count
+ public function get_friend_request($uid)
+ {
+ $object = new EasySocialModelFriends();
+ $result = $object->getPendingRequests($uid);
+ return $result;
+ }
+ public function get_friend_count($uid)
+ {
+ $model = FD::model( 'Friends' );
+ $total = $model->getTotalRequests($uid);
+ return $total;
+ }
+ public function get_message_count($uid)
+ {
+ $model = FD::model( 'Conversations' );
+ $total = $model->getNewCount($uid,'user');
+ return $total;
+ }
+ public function get_notification_count($uid)
+ {
+ $options = array(
+ 'unread' => true,
+ 'target' => array('id' => $uid, 'type' => SOCIAL_TYPE_USER)
+ );
+ $model = FD::model( 'Notifications' );
+ $total = $model->getCount($options);
+ return $total;
+ }
+ public function get_messages($uid)
+ {
+ $maxlimit = 0;
+ // Get the conversations model
+ $model = FD::model( 'Conversations' );
+ // We want to sort items by latest first
+ $options = array( 'sorting' => 'lastreplied', 'maxlimit' => $maxlimit );
+ // Get conversation items.
+ $conversations = $model->getConversations( $uid , $options );
+ return $conversations;
+ }
+
+ public function get_notifications($uid)
+ {
+ $notification = FD::notification();
+ $options = array('target_id' => $uid,
+ 'target_type' => SOCIAL_TYPE_USER,
+ 'unread' => true );
+ $items = $notification->getItems($options);
+ return $items;
+ }
+}
+
diff --git a/easysocial/easysocial/photoadd.php b/easysocial/easysocial/photoadd.php
new file mode 100644
index 0000000..c901fb3
--- /dev/null
+++ b/easysocial/easysocial/photoadd.php
@@ -0,0 +1,44 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/photos.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/tables/album.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+require_once JPATH_SITE.'/components/com_easysocial/controllers/albums.php';
+
+
+class EasysocialApiResourcePhotoadd extends ApiResource
+{
+ public function post()
+ {
+ $this->plugin->setResponse($this->add_photo());
+ }
+ public function add_photo()
+ {
+ $app = JFactory::getApplication();
+ $userid = $app->input->get('userid',0,'INT');
+ $album_id = $app->input->get('album_id',0,'INT');
+ // Load the album
+ $album = FD::table( 'Album' );
+ $album->load($album_id);
+ $photo_obj = new EasySocialApiUploadHelper();
+ $addphoto= $photo_obj->addPhotoAlbum($userid,$album_id);
+ $album->params=$addphoto;
+ $album->title = JText::_($album->title);
+ $album->caption = JText::_($album->caption);
+ return $album;
+ }
+}
diff --git a/easysocial/easysocial/profile.php b/easysocial/easysocial/profile.php
new file mode 100644
index 0000000..c79ba49
--- /dev/null
+++ b/easysocial/easysocial/profile.php
@@ -0,0 +1,161 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceProfile extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getProfile());
+ }
+
+ public function post()
+ {
+ //print_r($FILES);die("in post grp api");
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_GET_METHOD_MESSAGE' ));
+ }
+
+ //function use for get friends data
+ function getProfile()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+
+ $other_user_id = $app->input->get('user_id',0,'INT');
+
+ $userid = ($other_user_id)?$other_user_id:$log_user;
+
+ $data = array();
+
+ $user = FD::user($userid);
+
+ //easysocial default profile
+ $profile = $user->getProfile();
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ if($userid)
+ {
+ $user_obj = $mapp->mapItem($userid,'profile',$log_user);
+ //$user_obj = $mapp->createUserObj($userid);
+ /*
+ $user_obj = $mapp->createUserObj($userid);
+ $user_obj->isself = ($log_user == $other_user_id )?true:false;
+ $user_obj->cover = $user->getCover();
+
+ if( $log_user != $other_user_id )
+ {
+ $log_user_obj = FD::user( $log_user );
+ $user_obj->isfriend = $log_user_obj->isFriends( $other_user_id );
+ $user_obj->isfollower = $log_user_obj->isFollowed( $other_user_id );
+ //$user_obj->approval_pending = $user->isPending($other_user_id);
+ }
+ $user_obj->friend_count = $user->getTotalFriends();
+ $user_obj->follower_count = $user->getTotalFollowers();
+ $user_obj->badges = $user->getBadges();
+ $user_obj->points = $user->getPoints();
+ */
+ //code for custom fields
+ // Get the steps model
+ $stepsModel = FD::model('Steps');
+ $steps = $stepsModel->getSteps($profile->id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_DISPLAY);
+
+ // Get custom fields model.
+ $fieldsModel = FD::model('Fields');
+ // Get custom fields library.
+ $fields = FD::fields();
+ $field_arr = array();
+
+ /*$usersModel = ES::model('Users');
+ $asteps = $usersModel->getAbout($user);
+
+ foreach ($asteps as $step)
+ {
+
+ //print_r($step->fields);die("in api");
+
+ foreach($step->fields as $fld)
+ {
+ print_r($fld->output);die("in api");
+ }
+
+ }*/
+
+
+
+ foreach ($steps as $step)
+ {
+
+ $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $userid, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY));
+ $fields = null;
+
+
+ if(count($step->fields))
+ {
+ $fields = $mapp->mapItem($step->fields,'fields',$other_user_id);
+ //die("in fields loop");
+ if(empty($field_arr))
+ {
+ $field_arr = $fields;
+ }
+ else
+ {
+ foreach($fields as $fld)
+ {
+ array_push( $field_arr,$fld );
+ }
+ //array_merge( $field_arr,$fields );
+ }
+ }
+
+ }
+
+ //for change data type
+
+ foreach($field_arr as $ky=>$fld)
+ {
+ if($fld->field_name == 'Password'|| $fld->field_name == 'Timezone' || $fld->field_name == 'Home Church')
+ {
+ unset($field_arr[$ky]);
+ }
+
+ }
+
+ $friendmodel = FD::model( 'Friends' );
+ $result = $friendmodel->getPendingRequests($log_user);
+ $user_obj->isrequestor=false;
+
+ if($result)
+ {
+ foreach($result as $res)
+ {
+ if($res->actor_id == $other_user_id)
+ $user_obj->isrequestor=true;
+ }
+ }
+ $user_obj->more_info = $field_arr;
+
+ }
+ return( $user_obj );
+ }
+
+}
diff --git a/easysocial/easysocial/reply.php b/easysocial/easysocial/reply.php
new file mode 100644
index 0000000..7b72f6b
--- /dev/null
+++ b/easysocial/easysocial/reply.php
@@ -0,0 +1,242 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/router.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/apps.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceReply extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getDiscussionReply());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->postDiscussionReply());
+ }
+
+ public function delete()
+ {
+ /*
+ $result = new stdClass;
+ $group_id = $app->input->get('id',0,'INT');
+ $appId = $app->input->get('discussion_id',0,'INT');
+
+ $discussion = FD::table( 'Discussion' );
+ $discussion->load( $appId );
+
+ $my = FD::user();
+ $group = FD::group( $group_id );
+
+ if( !$group->isAdmin() && $discussion->created_by != $this->plugin->get('user')->id)
+ {
+ //error message;
+ return false;
+ }
+
+ // Delete the discussion
+ $res = $discussion->delete();
+ $result->status = ($res)?'Conversation deleted successfully':'Unable to delete converstion.';
+ $this->plugin->setResponse($result);
+ */
+ }
+ //function use for get friends data
+ function getDiscussionReply()
+ {
+ //init variable
+ $mainframe = JFactory::getApplication();
+
+ $group_id = $mainframe->input->get('group_id',0,'INT');
+ $discussId = $mainframe->input->get('discussion_id',0,'INT');
+ $limit = $mainframe->input->get('limit',10,'INT');
+ $limitstart = $mainframe->input->get('limitstart',0,'INT');
+ $wres = new stdClass;
+ $valid = 0;
+
+ if(!$group_id)
+ {
+ $wres->status = 0;
+ $wres->message[] = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_GROUP_ID_MESSAGE' );
+ return $wres;
+ }
+ else
+ {
+ $group = FD::group( $group_id );
+
+ // Get the current filter type
+ $filter = $mainframe->input->get('filter','all','STRING');
+
+ $options = array();
+
+ if( $filter == 'unanswered' )
+ {
+ $options[ 'unanswered' ] = true;
+ }
+
+ if( $filter == 'locked' )
+ {
+ $options[ 'locked' ] = true;
+ }
+
+ if( $filter == 'resolved' )
+ {
+ $options[ 'resolved' ] = true;
+ }
+
+ //$options[ 'limit' ] = $mainframe->input->get('limit',10,'INT');
+
+ $options[ 'ordering' ] = 'created';
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ $model = FD::model( 'Discussions' );
+ $reply_rows = $model->getReplies( $discussId,$options);
+
+ if($discussId)
+ {
+ $disc_dt = new stdClass();
+ //create discussion details as per request
+ $discussion = FD::table( 'Discussion' );
+ $discussion->load( $discussId );
+ $data_node[] = $discussion;
+ $data['discussion'] = $mapp->mapItem($data_node,'discussion',$this->plugin->get('user')->id);
+ }
+
+ if($limitstart)
+ {
+ $reply_rows = array_slice($reply_rows,$limitstart,$limit);
+ }
+
+ $data['data'] = $mapp->mapItem($reply_rows,'reply',$this->plugin->get('user')->id);
+
+
+ //
+ return( $data );
+ }
+ }
+
+ //function for create new group
+ function postDiscussionReply()
+ {
+ //init variable
+ $mainframe = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ // Load the discussion
+ $discuss_id = $mainframe->input->get('discussion_id',0,'INT');
+ $groupId = $mainframe->input->get('group_id',0,'INT');
+ $content = $mainframe->input->get('content','','RAW');
+
+ $wres = new stdClass;
+
+ $discussion = FD::table( 'Discussion' );
+ $discussion->load( $discuss_id );
+
+ // Get the current logged in user.
+ $my = FD::user($log_user);
+
+ // Get the group
+ $group = FD::group( $groupId );
+
+ $reply = FD::table( 'Discussion' );
+ $reply->uid = $discussion->uid;
+ $reply->type = $discussion->type;
+ $reply->content = $content;
+ $reply->created_by = $log_user;
+ $reply->parent_id = $discussion->id;
+ $reply->state = SOCIAL_STATE_PUBLISHED;
+
+ // Save the reply.
+ $state = $reply->store();
+
+ if($state)
+ {
+ $this->createStream($discussion,$group,$reply,$log_user);
+ $wres->id = $discussion->id;
+ $wres->message[] = JText::_( 'PLG_API_EASYSOCIAL_DISCUSSION_REPLY_MESSAGE' );
+ return $wres;
+ }
+
+ }
+
+ public function createStream($discussion,$group,$reply,$log_user)
+ {
+ // Create a new stream item for this discussion
+ $stream = FD::stream();
+ $my = FD::user($log_user);
+ // Get the stream template
+ $tpl = $stream->getTemplate();
+
+ // Someone just joined the group
+ $tpl->setActor( $log_user , SOCIAL_TYPE_USER );
+
+ // Set the context
+ $tpl->setContext( $discussion->id , 'discussions' );
+
+ // Set the cluster
+ $tpl->setCluster( $group->id , SOCIAL_TYPE_GROUP, $group->type );
+
+ // Set the verb
+ $tpl->setVerb( 'reply' );
+
+ // Set the params to cache the group data
+ $registry = FD::registry();
+ $registry->set( 'group' , $group );
+ $registry->set( 'reply' , $reply );
+ $registry->set( 'discussion' , $discussion );
+
+ $tpl->setParams( $registry );
+
+ $tpl->setAccess('core.view');
+
+ // Add the stream
+ $stream->add( $tpl );
+
+ // Update the parent's reply counter.
+ $discussion->sync( $reply );
+
+ // Before we populate the output, we need to format it according to the theme's specs.
+ $reply->author = $my;
+
+ // Load the contents
+ $theme = FD::themes();
+
+ // Since this reply is new, we don't have an answer for this item.
+ $answer = false;
+
+ $theme->set('question', $discussion);
+ $theme->set('group', $group);
+ $theme->set('answer', $answer);
+ $theme->set('reply', $reply);
+
+// $contents = $theme->output( 'apps/group/discussions/canvas/item.reply' );
+
+ // Send notification to group members
+ $options = array();
+ //$options[ 'permalink' ] = FRoute::apps( array( 'layout' => 'canvas' , 'customView' => 'item' , 'uid' => $group->getAlias() , 'type' => SOCIAL_TYPE_GROUP , 'id' => $this->getApp()->getAlias() , 'discussionId' => $discussion->id , 'external' => true ) , false );
+ $options[ 'permalink' ] = FRoute::apps( array( 'layout' => 'canvas' , 'customView' => 'item' , 'uid' => $group->getAlias() , 'type' => SOCIAL_TYPE_GROUP , 'id' => $group->id , 'discussionId' => $discussion->id , 'external' => true ) , false );
+ $options[ 'title' ] = $discussion->title;
+ $options[ 'content'] = $reply->getContent();
+ $options['discussionId'] = $reply->id;
+ $options[ 'userId' ] = $reply->created_by;
+ $options[ 'targets' ] = $discussion->getParticipants( array( $reply->created_by ) );
+
+ return $group->notifyMembers( 'discussion.reply' , $options );
+ }
+
+}
diff --git a/easysocial/easysocial/report.php b/easysocial/easysocial/report.php
new file mode 100644
index 0000000..e25b4f9
--- /dev/null
+++ b/easysocial/easysocial/report.php
@@ -0,0 +1,132 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/components/com_easysocial/controllers/reports.php';
+
+class EasysocialApiResourceReport extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_POST_METHOD_MESSAGE' ));
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->create_report());
+ }
+ public function create_report()
+ {
+ $app = JFactory::getApplication();
+ $msg = $app->input->get('message','','STRING');
+ $title = $app->input->get('user_title','','STRING');
+ $item_id = $app->input->get('itemId',0,'INT' );
+ $log_user = $this->plugin->get('user')->id;
+
+ $data =array();
+ $data['message']= $msg;
+ $data['uid']= $item_id;
+ $data['type']= $app->input->get('type','stream','STRING');
+ $data['title']= $title;
+ $data['extension']= 'com_easysocial';
+ //build share url use for share post through app
+
+ switch($data['type'])
+ {
+
+ case 'stream':
+ $sharing = FD::get( 'Sharing', array( 'url' => FRoute::stream( array( 'layout' => 'item', 'id' => $item_id, 'external' => true, 'xhtml' => true ) ), 'display' => 'dialog', 'text' => JText::_( 'COM_EASYSOCIAL_STREAM_SOCIAL' ) , 'css' => 'fd-small' ) );
+ $url = $sharing->url;
+ $data['url']= $url;
+ break;
+
+ case 'groups':
+ $group = FD::group( $item_id );
+ $data['url'] = $group->getPermalink( false, true );
+ break;
+
+ case 'events':
+
+ $event = FD::event( $item_id );
+ $data['url'] = $event->getPermalink( false, true );
+ break;
+
+ case 'profile':
+ $user = FD::user( $item_id );
+ $data['url'] = $user->getPermalink( false, true );
+ break;
+
+
+ case 'photos':
+
+ $ptable = FD::table( 'Photo' );
+ $ptable->load( $item_id );
+ $data['url'] = $ptable->getPermalink();
+
+ break;
+
+ case 'albums':
+
+ $atable = FD::table( 'Album' );
+ $atable->load( $item_id );
+ $data['url'] = $atable->getPermalink();
+
+ break;
+
+ }
+
+ // Get the reports model
+ $model = FD::model('Reports');
+ // Determine if this user has the permissions to submit reports.
+ $access = FD::access();
+ // Determine if this user has exceeded the number of reports that they can submit
+ $total = $model->getCount( array( 'created_by' => $log_user ) );
+ if ($access->exceeded( 'reports.limit' , $total)) {
+ $final_result['message'] = JText::_( 'PLG_API_EASYSOCIAL_LIMIT_EXCEEDS_MESSAGE' );
+ $final_result['status'] = true;
+ return $final_result;
+ }
+ // Create the report
+ $report = FD::table( 'Report' );
+ $report->bind($data);
+ // Set the creator id.
+ $report->created_by=$log_user;
+ // Set the default state of the report to new
+ $report->state=0;
+ // Try to store the report.
+ $state = $report->store();
+ // If there's an error, throw it
+ if (!$state) {
+ $final_result['message'] = JText::_( 'PLG_API_EASYSOCIAL_CANT_SAVE_REPORT' );;
+ $final_result['status'] = true;
+ return $final_result;
+ }
+
+ // @badge: reports.create
+ // Add badge for the author when a report is created.
+ $badge = FD::badges();
+ $badge->log( 'com_easysocial' , 'reports.create' , $log_user , JText::_( 'COM_EASYSOCIAL_REPORTS_BADGE_CREATED_REPORT' ) );
+
+ // @points: reports.create
+ // Add points for the author when a report is created.
+ $points = FD::points();
+ $points->assign( 'reports.create' , 'com_easysocial' , $log_user );
+
+ // Determine if we should send an email
+ $config = FD::config();
+ if ($config->get('reports.notifications.moderators')) {
+ $report->notify();
+ }
+ $final_result['message'] = JText::_( 'PLG_API_EASYSOCIAL_REPORT_LOGGED' );;
+ $final_result['status'] = true;
+ return $final_result;
+ }
+}
diff --git a/easysocial/easysocial/request.php b/easysocial/easysocial/request.php
new file mode 100644
index 0000000..4cf8b35
--- /dev/null
+++ b/easysocial/easysocial/request.php
@@ -0,0 +1,149 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+
+class EasysocialApiResourceRequest extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->getGroup());
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->request());
+ }
+
+ public function delete()
+ {
+ //$this->plugin->setResponse($result);
+ }
+ //function use for get friends data
+ function request()
+ {
+ //init variable
+ $app = JFactory::getApplication();
+ $log_user = JFactory::getUser($this->plugin->get('user')->id);
+
+ $group_id = $app->input->get('group_id',0,'INT');
+ $req_val = $app->input->get('request','','STRING');
+ $other_user_id = $app->input->get('target_user',0,'INT');
+ $type = $app->input->get('type','group','STRING');
+
+ //$userid = ($other_user_id)?$other_user_id:$log_user->id;
+ $data = array();
+
+ $user = FD::user($other_user_id);
+ $res = new stdClass();
+
+ //$mapp = new EasySocialApiMappingHelper();
+
+ //$grp_model = FD::model('Groups');
+
+ if(!$group_id || !$other_user_id )
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_INSUFFICIENT_INPUTS_MESSAGE' );
+ return $res;
+ }
+ else
+ {
+ $group = FD::$type($group_id);
+
+ if($group->isAdmin() != $log_user && ($req_val != 'withdraw'))
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_UNAUTHORISED_USER_MESSAGE' );
+ return $res;
+ }
+
+
+ if($type == 'group')
+ {
+ switch($req_val)
+ {
+ case 'Approve':
+ case 'approve': $res->success = $group->approveUser( $other_user_id );
+ $res->message = ($res->success)?JText::_( 'PLG_API_EASYSOCIAL_USER_REQ_GRANTED' ):JText::_( 'PLG_API_EASYSOCIAL_USER_REQ_UNSUCCESS' );
+ break;
+ case 'Reject':
+ case 'reject' : $res->success = $group->rejectUser( $other_user_id );
+ $res->message = ($res->success)?JText::_( 'PLG_API_EASYSOCIAL_USER_APPLICATION_REJECTED' ):JText::_( 'PLG_API_EASYSOCIAL_UNABLE_REJECT_APPLICATION' );
+ break;
+ case 'Withdraw':
+ case 'withdraw' : $res->success = $group->deleteMember( $other_user_id );
+ $res->message = ($res->success)?JText::_( 'PLG_API_EASYSOCIAL_REQUEST_WITHDRAWN' ):JText::_( 'PLG_API_EASYSOCIAL_UNABLE_WITHDRAWN_REQ' );
+ break;
+ }
+ }
+ else
+ {
+
+ $guest = FD::table('EventGuest');
+ $state = $guest->load($other_user_id);
+
+ // Get the event object
+ $event = FD::event($group_id);
+ $my = FD::user($log_user);
+
+ $myGuest = $event->getGuest();
+
+ $res->success = 0;
+ if (!$state || empty($guest->id))
+ {
+ $res->message = JText::_('COM_EASYSOCIAL_EVENTS_INVALID_GUEST_ID');
+ }
+ else if (empty($event) || empty($event->id))
+ {
+ $res->message = JText::_('COM_EASYSOCIAL_EVENTS_INVALID_EVENT_ID');
+ }
+ else if ( $myGuest->isAdmin() && $guest->isPending())
+ {
+
+ switch($req_val)
+ {
+ case 'Approve':
+ case 'approve':
+ $res->success = $guest->approve();
+ $res->message = ($res->success)?JText::_( 'PLG_API_EASYSOCIAL_USER_REQ_GRANTED' ):JText::_( 'PLG_API_EASYSOCIAL_USER_REQ_UNSUCCESS' );
+ break;
+ case 'Reject':
+ case 'reject' : $res->success = $guest->reject();
+ $res->message = ($res->success)?JText::_( 'PLG_API_EASYSOCIAL_USER_APPLICATION_REJECTED' ):JText::_( 'PLG_API_EASYSOCIAL_UNABLE_REJECT_APPLICATION' );
+ break;
+ case 'remove':
+ case 'Remove' : $res->success = $guest->remove();
+ $res->message = ($res->success)?JText::_( 'COM_EASYSOCIAL_EVENTS_GUEST_REMOVAL_SUCCESS' ):JText::_( 'COM_EASYSOCIAL_EVENTS_NO_ACCESS_TO_EVENT' );
+ break;
+ }
+ }
+ else
+ {
+ $res->message = JText::_('COM_EASYSOCIAL_EVENTS_NO_ACCESS_TO_EVENT');
+ }
+ }
+
+ return $res;
+
+ }
+ }
+
+}
diff --git a/easysocial/easysocial/search.php b/easysocial/easysocial/search.php
index c7bff23..a13b7bc 100644
--- a/easysocial/easysocial/search.php
+++ b/easysocial/easysocial/search.php
@@ -16,6 +16,8 @@
require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/friends.php';
require_once JPATH_ROOT . '/components/com_finder/models/search.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
class EasysocialApiResourceSearch extends ApiResource
{
public function get()
@@ -34,10 +36,28 @@ function getSearch()
$app = JFactory::getApplication();
$log_user = JFactory::getUser($this->plugin->get('user')->id);
- $nxt_lim = 20;
-
- $search = $app->input->post->get('search','','STRING');
+ $search = $app->input->get('search','','STRING');
$nxt_lim = $app->input->get('next_limit',0,'INT');
+
+ $limitstart = $app->input->get('limitstart',0,'INT');
+ $limit = $app->input->get('limit',10,'INT');
+ $list = array();
+ $list['data_status'] = true;
+ if($limitstart)
+ {
+ $limit = $limit + $limitstart;
+ }
+
+ $mapp = new EasySocialApiMappingHelper();
+
+ $res = new stdClass;
+
+ if(empty($search))
+ {
+ $res->status = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_SEARCHTEXT_MESSAGE' );
+ return $res;
+ }
$userid = $log_user->id;
@@ -50,60 +70,157 @@ function getSearch()
$query->select($db->quoteName(array('su.user_id')));
$query->from($db->quoteName('#__social_users','su'));
$query->join('LEFT', $db->quoteName('#__users', 'u') . ' ON (' . $db->quoteName('su.user_id') . ' = ' . $db->quoteName('u.id') . ')');
+ //$query->where("su.user_id NOT IN( SELECT bu.user_id FROM #__social_block_users AS bu)");
+
//->where(($db->quoteName('u.username') . ' LIKE '. $db->quote('\'% '.$search.'%\'') ).'OR' .( $db->quoteName('u.name') . ' LIKE '. $db->quote('\'%'.$search.'%\'') ).'OR'.( $db->quoteName('u.email') . ' LIKE '. $db->quote('\'%'.$search.'%\'')))
-
+
if(!empty($search))
{
- $query->where("(u.username LIKE '%".$search."%' ) OR ( u.name LIKE '%".$search."%') OR ( u.email LIKE '%".$search."%')");
+ $query->where("(u.username LIKE '%".$search."%' ) OR ( u.name LIKE '%".$search."%')");
}
$query->order($db->quoteName('u.id') .'ASC');
$db->setQuery($query);
$tdata = $db->loadObjectList();
-
+ $block_model = FD::model('Blocks');
$susers = array();
foreach($tdata as $ky=>$val)
- {
- $susers[] = FD::user($val->user_id);
+ {
+
+ $block = $block_model->isBlocked($val->user_id,$userid);
+ if(!$block)
+ {
+ $susers[] = FD::user($val->user_id);
+ }
+ }
+
+ //manual pagination code
+ $susers = array_slice( $susers, $limitstart, $limit );
+
+ $base_obj = $mapp->mapItem($susers,'user',$log_user->id);
+
+ $list['user'] = $this->createSearchObj( $base_obj );
+
+ if(empty($list['user']))
+ {
+ $ret_arr = new stdClass;
+ $ret_arr->status = false;
+ $ret_arr->message = JText::_( 'PLG_API_EASYSOCIAL_USER_NOT_FOUND' );
+ $list['user']= $ret_arr;
+ }
+
+ //for group
+ $query1 = $db->getQuery(true);
+ $query1->select($db->quoteName(array('cl.id')));
+ $query1->from($db->quoteName('#__social_clusters','cl'));
+
+ if(!empty($search))
+ {
+ $query1->where("(cl.title LIKE '%".$search."%' )");
}
+ $query1->where('cl.state = 1');
- $frnd_list = $this->basefrndObj($susers);
+ $query1->order($db->quoteName('cl.id') .'ASC');
- return( $frnd_list );
+ $db->setQuery($query1);
+ $gdata = $db->loadObjectList();
+
+ $grp_model = FD::model('Groups');
+ $group = array();
+ foreach($gdata as $grp)
+ {
+ $group_load = FD::group($grp->id);
+ $is_inviteonly = $group_load->isInviteOnly();
+ $is_member = $group_load->isMember($log_user);
+ if($is_inviteonly && !$is_member)
+ {
+ if($group_load->creator_uid == $log_user->id)
+ {
+ $group[] = FD::group($grp->id);
+ }
+ else
+ {
+ continue;
+ }
+ }
+ else
+ {
+ $group[] = FD::group($grp->id);
+ }
+ }
+
+ //manual pagination code
+ $group = array_slice( $group, $limitstart, $limit );
+ $list['group'] = $mapp->mapItem($group,'group',$log_user->id);
+
+ if(empty($list['group']))
+ {
+ $ret_arr = new stdClass;
+ $ret_arr->status = false;
+ $ret_arr->message = JText::_( 'PLG_API_EASYSOCIAL_GROUP_NOT_FOUND' );
+ $list['group']= $ret_arr;
+ }
+
+ //give status as per front end requirement
+ if(empty($list['group']) && empty($list['user']))
+ {
+ $list['data_status'] = false;
+ }
+ return( $list );
}
//format friends object into required object
- function basefrndObj($data=null)
+ function createSearchObj($data=null)
{
- if($data==null)
- return 0;
+ if( $data == null )
+ {
+ $ret_arr = new stdClass;
+ $ret_arr->status = false;
+ $ret_arr->message = JText::_( 'PLG_API_EASYSOCIAL_USER_NOT_FOUND' );
+
+ return $ret_arr;
+ }
+
- $user = JFactory::getUser($this->plugin->get('user')->id);
+ $user = JFactory::getUser($this->plugin->get('user')->id);
$frnd_mod = new EasySocialModelFriends();
$list = array();
+
+ $options[ 'state' ] = SOCIAL_FRIENDS_STATE_PENDING;
+ $options[ 'isRequest' ] = true;
+ $req=$frnd_mod->getFriends( $user->id,$options );
+ $myarr=array();
+ if(!empty($req))
+ {
+ foreach($req as $ky=>$row)
+ {
+ $myarr[]= $row->id;
+ }
+ }
+
foreach($data as $k=>$node)
{
- $obj = new stdclass;
- $obj->id = $node->id;
- $obj->name = $node->name;
- $obj->username = $node->username;
- $obj->email = $node->email;
-
- //$obj->avatar = EasySocialModelAvatars::getPhoto($node->id);
- foreach($node->avatars As $ky=>$avt)
+ if($node->id != $user->id)
{
- $avt_key = 'avtar_'.$ky;
- $obj->$avt_key = JURI::root().'media/com_easysocial/avatars/users/'.$node->id.'/'.$avt;
+
+ $node->mutual = $frnd_mod->getMutualFriendCount($user->id,$node->id);
+ $node->isFriend = $frnd_mod->isFriends($user->id,$node->id);
+ $node->approval_pending = $frnd_mod->isPendingFriends($user->id,$node->id);
+ if(in_array($node->id,$myarr))
+ {
+ $node->isinitiator=true;
+ }
+ else
+ {
+ $node->isinitiator=false;
+ }
+
+ $list[] = $node;
}
-
- $obj->mutual = $frnd_mod->getMutualFriendCount($user->id,$node->id);
- $obj->isFriend = $frnd_mod->isFriends($user->id,$node->id);
-
- $list[] = $obj;
}
-
+
return $list;
}
diff --git a/easysocial/easysocial/share.php b/easysocial/easysocial/share.php
new file mode 100644
index 0000000..23588c2
--- /dev/null
+++ b/easysocial/easysocial/share.php
@@ -0,0 +1,394 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/story/story.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/photo/photo.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceShare extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_USE_POST_METHOD_MESSAGE' ));
+ }
+
+ public function post()
+ {
+ $app = JFactory::getApplication();
+
+ //$share_for = $app->input->get('share_for','','CMD');
+
+ $type = $app->input->get('type','story','STRING');
+
+ $content = $app->input->get('content','','RAW');
+
+ //$targetId = $app->input->get('target_user','All','raw');
+ $targetId = $app->input->get('target_user',0,'INT');
+
+ $cluster = $app->input->get('cluster_id',null,'INT');
+ $clusterType = $app->input->get('cluster_type',null,'STRING');
+
+ $friends_tags = $app->input->get('friends_tags',null,'ARRAY');
+
+ // Set the privacy for the album
+ //public,members,friends,only_me
+ $privacy = $app->input->get('privacy', 'public', 'STRING');
+ //specific user id for sharing
+ $customPrivacy = $app->input->get('privacyCustom', '', 'string');
+
+ $log_usr = intval($this->plugin->get('user')->id);
+ //now take login user stream for target
+ $targetId = ( $targetId != $log_usr )?$targetId:$log_usr;
+
+ $valid = 1;
+ $result = new stdClass;
+
+ $story = FD::story(SOCIAL_TYPE_USER);
+
+ // Check whether the user can really post something on the target
+ if ($targetId) {
+ $tuser = FD::user($targetId);
+ $allowed = $tuser->getPrivacy()->validate('profiles.post.status', $targetId, SOCIAL_TYPE_USER);
+
+ if (!$allowed) {
+
+ $result->id = 0;
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_POST_NOT_ALLOW_MESSAGE' );
+ $valid = 0;
+ }
+ }
+
+ if(empty($type))
+ {
+ $result->id = 0;
+ $result->status = 0;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_TYPE' );
+ $valid = 0;
+ }
+ else if($valid)
+ {
+ // Determines if the current posting is for a cluster
+ $cluster = isset($cluster) ? $cluster : 0;
+ //$clusterType = ($cluster) ? 'group' : null;
+ $isCluster = $cluster ? true : false;
+
+ if ($isCluster) {
+
+ $group = FD::group($cluster);
+ $permissions = $group->getParams()->get('stream_permissions', null);
+
+ if($permissions != null)
+ {
+ // If the user is not an admin, ensure that permissions has member
+ if ($group->isMember() && !in_array('member', $permissions) && !$group->isOwner() && !$group->isAdmin()) {
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_MEMBER_ACCESS_DENIED_MESSAGE' );
+ }
+
+ // If the user is an admin, ensure that permissions has admin
+ if ($group->isAdmin() && !in_array('admin', $permissions) && !$group->isOwner()) {
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_ADMIN_ACCESS_DENIED_MESSAGE' );
+ }
+
+ $result->id = 0;
+ $result->status = 0;
+ $this->plugin->setResponse($result);
+ return;
+ }
+ }
+
+ //validate friends
+
+ $friends = array();
+
+ if (!empty( $friends_tags )) {
+
+ // Get the friends model
+ $model = FD::model('Friends');
+
+ // Check if the user is really a friend of him / her.
+ foreach ($friends_tags as $id) {
+
+ if (!$model->isFriends($log_usr, $id)) {
+ continue;
+ }
+
+ $friends[] = $id;
+ }
+ }
+ else
+ {
+ $friends = null;
+ }
+
+ $privacyRule = ( $type == 'photos' ) ? 'photos.view' : 'story.view';
+
+ //for hashtag mentions
+ $mentions = null;
+
+ //if($type == 'hashtag' || !empty($content))
+ if(!empty($content))
+ {
+ //$type = 'story';
+ $start = 0;
+ $posn = array();
+
+ //code adjust for 0 position hashtag
+ $content = 'a '.$content;
+ while($pos = strpos(($content),'#',$start))
+ {
+ //echo 'Found # at position '.$pos."\n";
+ $posn[] = $pos - 2;
+ $start = $pos+1;
+ }
+ $content = substr($content, 2);
+ //
+ //$pos = strpos(($content),'#',$start);
+
+ $has_hash = "#";
+
+ $cont_arr = explode(' ',$content);
+ $indx= 0;
+ foreach($cont_arr as $val)
+ {
+ //if(preg_match('/[\'^#,|=_+¬-]/', $val))
+ if(strpbrk($val, $has_hash))
+ {
+ //$vsl = substr_count($val,'#');
+ $val_arr = array_filter(explode('#',$val));
+
+ foreach($val_arr as $subval)
+ {
+ $subval = '#'.$subval;
+ $mention = new stdClass();
+ $mention->start = $posn[$indx++];
+ $mention->length = strlen($subval) - 0;
+ $mention->value = str_replace('#','',$subval);
+ $mention->type = 'hashtag';
+
+ $mentions[] = $mention;
+ }
+ }
+ }
+
+ }
+
+ $contextIds = 0;
+ if($type == 'photos')
+ {
+ $photo_obj = $this->uploadPhoto($log_usr,'user');
+
+ $photo_ids[] = $photo_obj->id;
+ $contextIds = (count($photo_ids))?$photo_ids:null;
+ }
+ else
+ {
+ $type = 'story';
+ }
+
+ // Process moods here
+ $mood = FD::table('Mood');
+
+ // Options that should be sent to the stream lib
+ $args = array(
+ 'content' => $content,
+ 'actorId' => $log_usr,
+ 'targetId' => $targetId,
+ 'location' => null,
+ 'with' => $friends,
+ 'mentions' => $mentions,
+ 'cluster' => $cluster,
+ 'clusterType' => $clusterType,
+ 'mood' => null,
+ 'privacyRule' => $privacyRule,
+ 'privacyValue' => $privacy,
+ 'privacyCustom' => $customPrivacy
+ );
+
+ $photo_ids = array();
+ $args['actorId'] = $log_usr;
+ $args['contextIds'] = $contextIds;
+ $args['contextType'] = $type;
+
+ // Create the stream item
+ $stream = $story->create($args);
+
+ // Privacy is only applicable to normal postings
+ if (!$isCluster) {
+ $privacyLib = FD::privacy();
+
+ if ($type == 'photos') {
+
+ $photoIds = FD::makeArray($contextIds);
+
+ foreach ($photoIds as $photoId) {
+ $privacyLib->add($privacyRule, $photoId, $type, $privacy, null, $customPrivacy);
+ }
+ } else {
+ $privacyLib->add($privacyRule, $stream->uid, $type, $privacy, null, $customPrivacy);
+ }
+
+ }
+ // Add badge for the author when a report is created.
+ $badge = FD::badges();
+ $badge->log('com_easysocial', 'story.create', $log_usr, JText::_('Posted a new update'));
+
+ // @points: story.create
+ // Add points for the author when a report is created.
+ $points = FD::points();
+ $points->assign('story.create', 'com_easysocial', $log_usr);
+
+ if($stream->id)
+ {
+ $result->id = $stream->id;
+ $result->status =1;
+ $result->message = JText::_( 'PLG_API_EASYSOCIAL_DATA_SHARE_SUCCESS' );
+ }
+
+ }
+
+ $this->plugin->setResponse($result);
+ }
+
+ //function for upload photo
+ public function uploadPhoto($log_usr=0,$type=null)
+ {
+ // Get current logged in user.
+ $my = FD::user($log_usr);
+
+ // Get user access
+ $access = FD::access( $my->id , SOCIAL_TYPE_USER );
+
+ // Load up the photo library
+ $lib = FD::photo($log_usr, $type);
+
+ // Define uploader options
+ $options = array( 'name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit() );
+
+ // Get uploaded file
+ $file = FD::uploader($options)->getFile();
+
+ // Load the iamge object
+ $image = FD::image();
+ $image->load( $file[ 'tmp_name' ] , $file[ 'name' ] );
+
+ // Detect if this is a really valid image file.
+ if( !$image->isValid() )
+ {
+ return JText::_( 'PLG_API_EASYSOCIAL_INVALID_IMAGE' );
+ }
+
+ // Load up the album's model.
+ $albumsModel = FD::model( 'Albums' );
+
+ // Create the default album if necessary
+ $album = $albumsModel->getDefaultAlbum( $log_usr , $type , SOCIAL_ALBUM_STORY_ALBUM );
+
+ // Bind photo data
+ $photo = FD::table( 'Photo' );
+ $photo->uid = $log_usr;
+ $photo->type = $type;
+ $photo->user_id = $my->id;
+ $photo->album_id = $album->id;
+ $photo->title = $file[ 'name' ];
+ $photo->caption = '';
+ $photo->state = 1;
+ $photo->ordering = 0;
+
+ // Set the creation date alias
+ $photo->assigned_date = FD::date()->toMySQL();
+
+ // Trigger rules that should occur before a photo is stored
+ $photo->beforeStore( $file , $image );
+
+ // Try to store the photo.
+ $state = $photo->store();
+
+ // Load the photos model
+ $photosModel = FD::model( 'Photos' );
+
+ // Get the storage path for this photo
+ $storage = FD::call( 'Photos' , 'getStoragePath' , array( $album->id , $photo->id ) );
+
+ // Get the photos library
+ $photoLib = FD::get( 'Photos' , $image );
+ $paths = $photoLib->create($storage);
+
+ // Create metadata about the photos
+ if( $paths )
+ {
+ foreach( $paths as $type => $fileName )
+ {
+ $meta = FD::table( 'PhotoMeta' );
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_PATH;
+ $meta->property = $type;
+ $meta->value = $storage . '/' . $fileName;
+
+ $meta->store();
+
+ // We need to store the photos dimension here
+ list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
+
+ // Set the photo dimensions
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_WIDTH;
+ $meta->property = $type;
+ $meta->value = $width;
+ $meta->store();
+
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_HEIGHT;
+ $meta->property = $type;
+ $meta->value = $height;
+ $meta->store();
+ }
+ }
+
+ // After storing the photo, trigger rules that should occur after a photo is stored
+ //$photo->afterStore( $file , $image );
+
+ //$sphoto = new SocialPhotos($photo_obj->id);
+
+ return $photo;
+ }
+
+ //function for upload file
+ public function uploadFile()
+ {
+ $config = FD::config();
+ $limit = $config->get( $type . '.attachments.maxsize' );
+
+ // Set uploader options
+ $options = array(
+ 'name' => 'file',
+ 'maxsize' => $limit . 'M'
+ );
+ // Let's get the temporary uploader table.
+ $uploader = FD::table( 'Uploader' );
+ $uploader->user_id = $this->plugin->get('user')->id;
+
+ // Pass uploaded data to the uploader.
+ $uploader->bindFile( $data );
+
+ $state = $uploader->store();
+ }
+
+}
diff --git a/easysocial/easysocial/slogin.php b/easysocial/easysocial/slogin.php
new file mode 100644
index 0000000..87d3991
--- /dev/null
+++ b/easysocial/easysocial/slogin.php
@@ -0,0 +1,259 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+jimport('joomla.application.component.controller');
+jimport('joomla.application.component.model');
+jimport('joomla.user.helper');
+jimport('joomla.user.user');
+jimport('joomla.application.component.helper');
+jimport('joomla.database.table.user');
+
+JModelLegacy::addIncludePath(JPATH_SITE.'components/com_api/models');
+require_once JPATH_SITE.'/components/com_api/libraries/authentication/user.php';
+require_once JPATH_SITE.'/components/com_api/libraries/authentication/login.php';
+require_once JPATH_SITE.'/components/com_api/models/key.php';
+require_once JPATH_SITE.'/components/com_api/models/keys.php';
+
+require_once JPATH_SITE . '/libraries/joomla/filesystem/folder.php';
+require_once JPATH_ROOT . '/administrator/components/com_users/models/users.php';
+
+class EasysocialApiResourceSlogin extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse(JText::_( 'PLG_API_EASYSOCIAL_UNSUPPORTED_METHOD_MESSAGE' ));
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->keygen());
+ }
+ //public function for genrate key
+ public function keygen()
+ {
+ $app = JFactory::getApplication();
+ $user_details = 0;
+ //code for social login
+ $slogin = $app->input->get('social_login', 0 , 'INT');
+ if($slogin)
+ {
+ //$provider = $app->input->get('provider', 'facebook' , 'STRING');
+
+ $user_id = $app->input->get('user_id',0,'INT');
+ $tokan = $app->input->get('tokan',0,'STRING');
+ $username = $app->input->get('username','','STRING');
+ $name = $app->input->get('name','','STRING');
+ $email_crp = $app->input->get('email','','STRING');
+
+ //$crpt = base64_encode($email_crp.$tokan);
+
+ $email_crp = base64_decode( $email_crp );
+ $email = str_replace( $tokan,'', $email_crp );
+
+ $reg_usr = 0;
+
+ if($email )
+ {
+ $reg_usr = $this->check_user($email);
+//print_r( $_POST );
+//var_dump( $reg_usr );
+//die("in slogin api");
+ if( $reg_usr == null )
+ {
+ $user_details = $this->createUser($username,$name,$email);
+ $reg_usr = $user_details['user_id'];
+ }
+
+ }
+ $user = JFactory::getUser( $reg_usr );
+ }
+ else
+ {
+ //init variable
+ $obj = new stdclass;
+ $umodel = new JUser;
+ $user = $umodel->getInstance();
+
+ if( !$user->id )
+ {
+ $user = JFactory::getUser($this->plugin->get('user')->id);
+ }
+ }
+
+ if(!$user->id)
+ {
+ $obj->code = 403;
+ $obj->message = JText::_( 'PLG_API_EASYSOCIAL_INVALID_USER' );
+ return $obj;
+ }
+
+ $kmodel = new ApiModelKey;
+ $model = new ApiModelKeys;
+ $key = null;
+ // Get login user hash
+ $kmodel->setState('user_id', $user->id);
+ $log_hash = $kmodel->getList();
+ $log_hash = $log_hash[count($log_hash) - count($log_hash)];
+
+ if( $log_hash->hash )
+ {
+ $key = $log_hash->hash;
+ }
+ elseif( $key == null || empty($key) )
+ {
+ // Create new key for user
+ $data = array(
+ 'userid' => $user->id,
+ 'domain' => '' ,
+ 'state' => 1,
+ 'id' => '',
+ 'task' => 'save',
+ 'c' => 'key',
+ 'ret' => 'index.php?option=com_api&view=keys',
+ 'option' => 'com_api',
+ JSession::getFormToken() => 1
+ );
+
+ $result = $kmodel->save($data);
+ $key = $result->hash;
+
+ //add new key in easysocial table
+ $easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php';
+ if (JFile::exists($easyblog) && JComponentHelper::isEnabled('com_easysocial', true))
+ {
+ $this->updateEauth( $user , $key );
+ }
+ }
+
+ if( !empty($key) )
+ {
+ $obj->auth = $key;
+ $obj->code = '200';
+ $obj->id = $user->id;
+ }
+ else
+ {
+ $obj->code = 403;
+ $obj->message = JText::_( 'PLG_API_EASYSOCIAL_BAD_REQUEST' );
+ }
+ return( $obj );
+
+ }
+
+
+ /*
+ * function to get joomla user id on email
+ */
+ public function check_user( $email )
+ {
+ $db = JFactory::getDBO();
+ $query = $db->getQuery(true);
+
+ $query->select('u.id');
+ $query->from('#__users AS u');
+ $query->where( " u.email ="."'".$email."'");
+ $db->setQuery($query);
+
+ return $user_id = $db->loadResult();
+ }
+
+ /*
+ * function to update Easyblog auth keys
+ */
+ public function updateEauth($user=null,$key=null)
+ {
+ require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+ $model = FD::model('Users');
+ $id = $model->getUserId('username', $user->username);
+ $user = FD::user($id);
+ $user->alias = $user->username;
+ $user->auth = $key;
+ $user->store();
+
+ return $id;
+ }
+ /*
+ * function to create new joomla user
+ */
+ public function createUser($username,$name,$email)
+ {
+
+ $error_messages = array();
+ $fieldname = array();
+ $response = null;
+ $validated = true;
+ $userid = null;
+ $data = array();
+
+ $app = JFactory::getApplication();
+ $data['username'] = $username;
+ $data['password'] = JUserHelper::genRandomPassword(8);
+ $data['name'] = $name;
+ $data['email'] = $email;
+
+ 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->toSql());
+
+ // True on success, false otherwise
+ if (!$user->save())
+ {
+ $message = JText::_( 'PLG_API_EASYSOCIAL_NOT_CREATED' ); . $user->getError();
+
+ return false;
+ }
+ else
+ {
+ $message = JText::_( 'PLG_API_EASYSOCIAL_CREATED_USERNAME' ) . $user->username .JText::_( 'PLG_API_EASYSOCIAL_SEND_MAIL_DETAILS' );
+ }
+
+ // #$this->plugin->setResponse($user->id);
+ $userid = $user->id;
+
+ // Result message
+ $result = array('user id ' => $userid, 'message' => $message);
+ $result = ($userid) ? $result : $message;
+
+ //$this->plugin->setResponse($result);
+ return $result;
+ }
+}
diff --git a/easysocial/easysocial/social_share.php b/easysocial/easysocial/social_share.php
new file mode 100644
index 0000000..0f0fa57
--- /dev/null
+++ b/easysocial/easysocial/social_share.php
@@ -0,0 +1,135 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/sharing/sharing.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+
+class EasysocialApiResourceSocial_share extends ApiResource
+{
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_content());
+ }
+ public function post()
+ {
+ $this->plugin->setResponse($this->put_data());
+ }
+
+ //data for get social share data
+ public function get_content()
+ {
+ $obj = new SocialSharing();
+ $data = $obj->getVendors();
+ return $data;
+ }
+
+ //social share using easysocial method
+ public function put_data()
+ {
+ $app = JFactory::getApplication();
+ $recep = $app->input->get('recipient','','STRING');
+ $stream_id = $app->input->get('stream_uid',0,'INT');
+ $msg = $app->input->get('message','','STRING');
+
+ $res = new stdClass;
+
+ if(!$stream_id)
+ {
+ $res->success = 0;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_EMPTY_STREAM_ID' );
+ }
+
+ //create sharing url
+ $sharing = FD::get( 'Sharing', array( 'url' => FRoute::stream( array( 'layout' => 'item', 'id' => $stream_id, 'external' => true, 'xhtml' => true ) ), 'display' => 'dialog', 'text' => JText::_( 'COM_EASYSOCIAL_STREAM_SOCIAL' ) , 'css' => 'fd-small' ) );
+ $tok = base64_encode($sharing->url);
+
+ if( is_string( $recep ) )
+ {
+ $recep = explode( ',', FD::string()->escape( $recep ) );
+ }
+
+ if( is_array( $recep ) )
+ {
+ foreach( $recep as &$recipient )
+ {
+ $recipient = FD::string()->escape( $recipient );
+
+ if(!JMailHelper::isEmailAddress( $recipient ) )
+ {
+
+ return false;
+ }
+ }
+ }
+ $msg = FD::string()->escape( $msg );
+
+ // Check for valid data
+ if( empty( $recep ) )
+ {
+ return false;
+ }
+
+ if( empty( $tok ) )
+ {
+ return false;
+ }
+ $session = JFactory::getSession();
+
+ $config = FD::config();
+
+ $limit = $config->get( 'sharing.email.limit', 0 );
+
+ $now = FD::date()->toUnix();
+
+ $time = $session->get( 'easysocial.sharing.email.time' );
+
+ $count = $session->get( 'easysocial.sharing.email.count' );
+
+ if( is_null( $time ) )
+ {
+ $session->set( 'easysocial.sharing.email.time', $now );
+ $time = $now;
+ }
+
+ if( is_null( $count ) )
+ {
+ $session->set( 'easysocial.sharing.email.count', 0 );
+ }
+
+ $diff = $now - $time;
+
+ if( $diff <= 3600 )
+ {
+ if( $limit > 0 && $count >= $limit )
+ {
+ return false;
+ }
+ $count++;
+ $session->set( 'easysocial.sharing.email.count', $count );
+ }
+ else
+ {
+ $session->set( 'easysocial.sharing.email.time', $now );
+ $session->set( 'easysocial.sharing.email.count', 1 );
+ }
+ $library = FD::get( 'Sharing' );
+ $result = $library->sendLink( $recep, $tok, $msg );
+
+ $res->success = 1;
+ $res->message = JText::_( 'PLG_API_EASYSOCIAL_SHARE_SUCCESS_MESSAGE' );
+ $res->result = $result;
+
+ return $res;
+ }
+}
diff --git a/easysocial/easysocial/tags.php b/easysocial/easysocial/tags.php
new file mode 100644
index 0000000..33ac73c
--- /dev/null
+++ b/easysocial/easysocial/tags.php
@@ -0,0 +1,72 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/components/com_easysocial/controllers/videos.php';
+
+class EasysocialApiResourceTags extends ApiResource
+{
+ /**
+ * get.
+ *
+ * @see JController
+ * @since 1.0
+ * @return true or null
+ */
+ public function get()
+ {
+ $this->plugin->setResponse($this->getTags());
+ }
+
+ public function getTags()
+ {
+ $app = JFactory::getApplication();
+
+ // Get the video
+ $videoid = $app->input->get('video_id',0,'INT');
+
+ $video = ES::video();
+ $video->load($videoid);
+
+ $tag_peoples = $video->getTags();
+ return $tag_peoples;
+ }
+
+ public function post()
+ {
+ // Check for request forgeries
+ //ES::checkToken();
+
+ $app = JFactory::getApplication();
+
+ // Get the user id's.
+ $friends_tags = $app->input->get('friends_tags',null,'ARRAY');
+
+ // Get the video
+ $cluster = $app->input->get('cluster_id',null,'INT');
+
+ $table = ES::table('Video');
+ $table->load($cluster);
+ $video = ES::video($table->uid, $table->type, $table);
+
+ // Insert the user tags
+ $tags = $video->insertTags($friends_tags);
+
+ $video = ES::video();
+ $video->load($cluster);
+ $tag_peoples=$video->getTags();
+
+ $this->plugin->setResponse($tag_peoples);
+ }
+}
+
diff --git a/easysocial/easysocial/terms.php b/easysocial/easysocial/terms.php
new file mode 100644
index 0000000..1683d0b
--- /dev/null
+++ b/easysocial/easysocial/terms.php
@@ -0,0 +1,48 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+ defined('_JEXEC') or die( 'Restricted access' );
+
+ jimport('joomla.plugin.plugin');
+ jimport('joomla.html.html');
+
+
+ class EasysocialApiResourceTerms extends ApiResource
+ {
+ public function get()
+ {
+ $this->plugin->setResponse("Use method post");
+
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse($this->content());
+ }
+
+ public function content()
+ {
+ $res = new stdClass();
+ //$app = 'Easysocial';
+ //$company = 'Appcarvers';
+ //$day = 30;
+
+ $jinput = JFactory::getApplication();
+
+ $app = $jinput->input->get('appname',null,'STRING');
+
+ $company = $jinput->input->get('company','Appcarvers','STRING');
+ $day = $jinput->input->get('day',30,'INT');
+
+ $res->message = "".JText::sprintf('PLG_API_EASYSOCIAL_APP_TERM_ONE', $company).JText::sprintf('PLG_API_EASYSOCIAL_APP_TERM_TWO', $app, $company).JText::sprintf('PLG_API_EASYSOCIAL_APP_TERM_THREE', $company).JText::sprintf('PLG_API_EASYSOCIAL_APP_TERM_FOUR', $company, $day)."
";
+
+ return $res;
+ }
+ }
+
+
diff --git a/easysocial/easysocial/videos.php b/easysocial/easysocial/videos.php
new file mode 100644
index 0000000..ec1c741
--- /dev/null
+++ b/easysocial/easysocial/videos.php
@@ -0,0 +1,173 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/videos.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/components/com_easysocial/controllers/videos.php';
+
+class EasysocialApiResourceVideos extends ApiResource
+{
+ /**
+ * get.
+ *
+ * @see JController
+ * @since 1.0
+ * @return true or null
+ */
+ public function get()
+ {
+ $this->plugin->setResponse($this->get_videos());
+ }
+
+ public function post()
+ {
+ $app = JFactory::getApplication();
+ $type = $app->input->get('source','upload','STRING');
+ $result = ($type=='link')?$this->processVideo():$this->upload_videos($type);
+ $this->plugin->setResponse($result);
+ }
+
+ public function get_videos()
+ {
+ $log_user= $this->plugin->get('user')->id;
+ $model = FD::model( 'Videos' );
+
+ $result=array();
+ $options=array();
+
+ $app = JFactory::getApplication();
+ $limitstart= $app->input->get('limitstart',0,'INT');
+ $limit= $app->input->get('limit',0,'INT');
+ $filter = $app->input->get('filter','','STRING');
+ $categoryid = $app->input->get('categoryid',0,'INT');
+ $sort = $app->input->get('sort','','STRING');
+
+ $ordering = $this->plugin->get('ordering', '', 'STRING');
+ $userObj = FD::user($log_user);
+
+ $options = array('limitstart'=>$limitstart,'limit'=>$limit,'sort'=>$sort,'filter'=>$filter,'category'=>$categoryid,'state' => SOCIAL_STATE_PUBLISHED, 'ordering' => $ordering); /* ,'type' => $userObj->isSiteAdmin() ? 'all' : 'user' */
+ $data = $model->getVideos($options);
+
+ $mapp = new EasySocialApiMappingHelper();
+ $all_videos = $mapp->mapItem($data,'videos',$log_user);
+
+ $cats = $model->getCategories();
+/*
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+ $query = "SELECT * FROM #__social_videos ";
+
+ $db->setQuery($query);
+ $results = $db->loadObjectList();
+ print_r($results);die("in api");
+*/
+ foreach($cats as $k=>$row)
+ {
+ $row->uid = $row->user_id;
+ }
+
+ $result['video'] = $mapp->mapItem($data,'videos',$log_user);
+ $result['categories'] = $mapp->categorySchema($cats);
+
+ return $result;
+ }
+
+ //upload video in throught api
+ public function upload_videos($type)
+ {
+ $app = JFactory::getApplication();
+ $res = new stdClass;
+ $es_config = ES::config();
+
+ $id = $app->input->get('id', 0, 'int');
+ $action = $app->input->get('action', '', 'STRING');
+ $table = ES::table('Video');
+ $table->load($id);
+
+ $video = ES::video($table->uid, $table->type, $table);
+
+ // Get the callback url
+ $callback = $app->input->get('return', '', 'default');
+
+ if($action=="featured"){
+ $video->setFeatured();
+ } elseif($action=="unfeatured") {
+ $video->removeFeatured();
+ } elseif($action=="delete") {
+ $state = $video->delete();
+ } elseif($action=="edit") {
+ $video = FD::table('Video');
+ $video->load($id);
+ return $video;
+ } elseif($action=="update") {
+ $video = FD::table('Video');
+ $video->load($id);
+ $videoEdit = ES::video($video);
+
+ // Save the video
+ $post['category_id'] = $app->input->get('category_id', 0, 'INT');
+ $post['uid'] = $app->input->get('uid', 0, 'INT');
+ $post['title'] = $app->input->get('title', '', 'STRING');
+ $post['description'] = $app->input->get('description', '', 'STRING');
+ $post['link'] = $app->input->get('path', '', 'STRING');
+ $post['tags'] = $app->input->get('tags', '', 'ARRAY');
+ $post['location'] = $app->input->get('location', '', 'STRING');
+ $post['privacy'] = $app->input->get('privacy', '', 'STRING');
+
+ $state = $videoEdit->save($post);
+
+ $videoEdit->success = 1;
+ $videoEdit->message = JText::_( 'Video updated successfully' );
+ return $videoEdit;
+ }
+ }
+
+ public function delete_videos()
+ {
+ $app = JFactory::getApplication();
+ $res = new stdClass;
+ $es_config = ES::config();
+
+ $id = $app->input->get('id', 0, 'int');
+ $action = $app->input->get('action', '', 'STRING');
+
+ $table = ES::table('Video');
+ $table->load($id);
+
+ $video = ES::video($table->uid, $table->type, $table);
+
+ // Get the callback url
+ $callback = $app->input->get('return', '', 'default');
+
+ // Ensure that the video can be featured
+ //~ if (!$video->canFeature()) {
+ //~ return JError::raiseError(500, JText::_('COM_EASYSOCIAL_VIDEOS_NOT_ALLOWED_TO_FEATURE'));
+ //~ }
+
+ // Feature the video
+
+ if($action=="featured"){
+ $video->setFeatured();
+ } elseif($action=="unfeatured") {
+ $video->removeFeatured();
+ }elseif($action=="delete") {
+ $state = $video->delete();
+ }
+ print_r($video);
+ die("Hi");
+ $res->view->setMessage(JText::_('COM_EASYSOCIAL_VIDEOS_FEATURED_SUCCESS'), SOCIAL_MSG_SUCCESS);
+ return $es_config->view->call(__FUNCTION__, $video, $callback);
+
+ }
+}
+
diff --git a/easysocial/easysocial/videos_link.php b/easysocial/easysocial/videos_link.php
new file mode 100644
index 0000000..59a8fd6
--- /dev/null
+++ b/easysocial/easysocial/videos_link.php
@@ -0,0 +1,204 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/videos.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
+require_once JPATH_SITE.'/components/com_easysocial/controllers/videos.php';
+
+class EasysocialApiResourceVideos_link extends ApiResource
+{
+ public function post()
+ {
+ $this->plugin->setResponse($this->save_video());
+ }
+
+ public function get_videos()
+ {
+ $log_user= $this->plugin->get('user')->id;
+ $model = FD::model( 'Videos' );
+
+ $result=array();
+ $options=array();
+
+ $app = JFactory::getApplication();
+ $limitstart= $app->input->get('limitstart',0,'INT');
+ $limit= $app->input->get('limit',0,'INT');
+ $filter = $app->input->get('filter','','STRING');
+ $categoryid = $app->input->get('categoryid',0,'INT');
+ $sort = $app->input->get('sort','','STRING');
+
+ $ordering = $this->plugin->get('ordering', '', 'STRING');
+ $userObj = FD::user($log_user);
+
+ $options = array('limitstart'=>$limitstart,'limit'=>$limit,'sort'=>$sort,'filter'=>$filter,'category'=>$categoryid,'state' => SOCIAL_STATE_PUBLISHED, 'ordering' => $ordering,'type' => $userObj->isSiteAdmin() ? 'all' : 'user');
+ $data = $model->getVideos($options);
+
+ $mapp = new EasySocialApiMappingHelper();
+ $all_videos = $mapp->mapItem($data,'videos',$log_user);
+
+ $cats = $model->getCategories();
+
+ foreach($cats as $k=>$row)
+ {
+ $row->uid = $row->user_id;
+ }
+ $result['video'] = $mapp->mapItem($data,'videos',$log_user);
+ $result['categories'] = $mapp->categorySchema($cats);
+
+ return $result;
+ }
+
+ public function save_video()
+ {
+ // Check for request forgeries
+ //ES::checkToken();
+
+ $app = JFactory::getApplication();
+ $res = new stdClass;
+ $es_config = ES::config();
+ $log_user = $this->plugin->get('user')->id;
+
+ $post['category_id'] = $app->input->get('category_id', 0, 'INT');
+ $post['uid'] = $app->input->get('uid', $log_user, 'INT');
+ $post['title'] = $app->input->get('title', '', 'STRING');
+ $post['description'] = $app->input->get('description', '', 'STRING');
+ $post['link'] = $app->input->get('path', '', 'STRING');
+ $post['tags'] = $app->input->get('tags', '', 'ARRAY');
+ $post['location'] = $app->input->get('location', '', 'STRING');
+ $post['privacy'] = $app->input->get('privacy', '', 'STRING');
+
+ $video = ES::video();
+ //$video->load($row->id);
+
+ $isNew = $video->isNew();
+
+ // Set the current user id only if this is a new video, otherwise whenever the video is edited,
+ // the owner get's modified as well.
+ if ($isNew) {
+ $video->table->user_id = $video->my->id;
+ }
+
+ // Video links
+ if ($video->table->isLink()) {
+
+ $video->table->path = $post['link'];
+
+ // Grab the video data
+ $crawler = ES::crawler();
+ $crawler->crawl($video->table->path);
+
+ $scrape = (object) $crawler->getData();
+
+ // Set the video params with the scraped data
+ $video->table->params = json_encode($scrape);
+
+ // Set the video's duration
+ $video->table->duration = @$scrape->oembed->duration;
+ $video->processLinkVideo();
+ $video->save($post);
+
+ $video->table->hit();
+ }
+
+ // Save the video
+ $state = $video->table->store();
+
+ if ($id) {
+ $message = 'COM_EASYSOCIAL_VIDEOS_UPDATED_SUCCESS';
+ }
+
+ // Bind the video location
+ if (isset($post['location']) && $post['location'] && isset($post['latitude']) && $post['latitude'] && isset($post['longitude']) && $post['longitude']) {
+
+ // Create a location for this video
+ $location = ES::table('Location');
+
+ $location->uid = $video->table->id;
+ $location->type = SOCIAL_TYPE_VIDEO;
+ $location->user_id = $video->my->id;
+ $location->address = $video['location'];
+ $location->latitude = $video['latitude'];
+ $location->longitude = $video['longitude'];
+ $location->store();
+ }
+
+ // This video could be edited
+ $id = $post["id"];
+ $uid = $log_user;
+ $type = $app->input->get('type', SOCIAL_TYPE_USER, 'word');
+
+ /*
+ // Bind the tags
+ if (isset($post['tags'])) {
+ $video->insertTags($post['tags']);
+ }*/
+
+
+ $privacyData = 'public';
+ if (isset($post['privacy'])) {
+
+ $privacyData = new stdClass();
+ $privacyData->rule = 'videos.view';
+ $privacyData->value = $post['privacy'];
+ $privacyData->custom = $post['privacyCustom'];
+
+ $video->insertPrivacy($privacyData);
+ }
+
+ // check if we should create stream or not.
+ $createStream = ($isNew) ? true : false;
+ if ($createStream) {
+ $video->createStream('create', $privacyData);
+ }
+
+ $video->success = 1;
+ $video->message = JText::_( 'Video uploaded successfully' );
+ return $video;
+ }
+
+ // Determines if the video should be processed immediately or it should be set under pending mode
+ if ($es_config->config->get('video.autoencode')) {
+ // After creating the video, process it
+ $video->process();
+ } else {
+ // Just take a snapshot of the video
+ $video->snapshot();
+ }
+
+ $mapp = new EasySocialApiMappingHelper();
+ $video=$mapp->videoMap($video);
+ return $res;
+ }
+
+ //function for create new group
+ function processVideo($post)
+ {
+ //init variable
+ $mainframe = JFactory::getApplication();
+ $log_user = $this->plugin->get('user')->id;
+ // Load the discussion
+ $link = $mainframe->input->get('link','','STRING');
+ $process = $mainframe->input->get('process','get','STRING');
+ $state = $mainframe->input->get('state',1,'INT');
+
+ $result = new stdClass;
+ if($process == 'get' )
+ {
+ $crawler = ES::crawler();
+ $crawler->crawl($link);
+ $result->data = (object) $crawler->getData();
+ }
+ return $result;
+ }
+}
+
diff --git a/easysocial/language/en-GB/en-GB.plg_api_easysocial.ini b/easysocial/language/en-GB/en-GB.plg_api_easysocial.ini
new file mode 100644
index 0000000..7448a38
--- /dev/null
+++ b/easysocial/language/en-GB/en-GB.plg_api_easysocial.ini
@@ -0,0 +1,164 @@
+PLG_API_EASYSOCIAL="EasySocial APIs"
+PLG_API_EASYSOCIAL_DESCRIPTION="This plugin is used to get data from easysocial."
+PLG_API_EASYSOCIAL_ALBUM_DELETE_SUCCESS_MESSAGE="album deleted successfully"
+PLG_API_EASYSOCIAL_EMPTY_ELEMENT_NOT_ALLOWED_MESSAGE="Empty element id not allowed"
+PLG_API_EASYSOCIAL_EMPTY_COMMENT_NOT_ALLOWED_MESSAGE="Empty comment not allowed"
+PLG_API_EASYSOCIAL_COMMENT_SAVE_SUCCESS_MESSAGE="comment saved successfully"
+PLG_API_EASYSOCIAL_COMMENT_SAVE_UNSUCCESS_MESSAGE="Unable to save comment"
+PLG_API_EASYSOCIAL_INVALID_CONVERSATION_MESSAGE="Invalid Conversation"
+PLG_API_EASYSOCIAL_CONVERSATION_DELETED_MESSAGE="Conversation deleted successfully"
+PLG_API_EASYSOCIAL_EMPTY_GROUP_ID_MESSAGE="Group id is empty"
+PLG_API_EASYSOCIAL_CREATE_GD_NOT_ALLOWED_MESSAGE="Not allowed to create group discussion"
+PLG_API_EASYSOCIAL_EMPTY_DISCUSSION_TITLE_MESSAGE="Discussion title is empty"
+PLG_API_EASYSOCIAL_UNABLE_CREATE_DISCUSSION_MESSAGE="Unable to create discussion,check parameters"
+PLG_API_EASYSOCIAL_GROUP_DISCUSSION_CREATED_MESSAGE="Group discussion created successfully"
+PLG_API_EASYSOCIAL_EVENT_CREATE_SUCCESS_MESSAGE="Event created successfully"
+PLG_API_EASYSOCIAL_USE_GET_METHOD_MESSAGE="Use get method"
+PLG_API_EASYSOCIAL_EVENT_NOT_FOUND_MESSAGE="Event not found"
+PLG_API_EASYSOCIAL_INVITED_MESSAGE="Invited"
+PLG_API_EASYSOCIAL_GUEST_CANT_INVITED_MESSAGE="Guests can not be invited"
+PLG_API_EASYSOCIAL_USE_POST_METHOD_MESSAGE="Use post method"
+PLG_API_EASYSOCIAL_INVALID_DATE_FORMAT_MESSAGE="Date format is invalid"
+PLG_API_EASYSOCIAL_ERROR_MESSAGE="Error"
+PLG_API_EASYSOCIAL_LIMIT_EXCEEDS_MESSAGE="Limit Exceeds"
+PLG_API_EASYSOCIAL_SELECT_VALID_OPTION_MESSAGE="Please select valid option"
+PLG_API_EASYSOCIAL_CANT_FOLLOW_YOURSELF_MESSAGE="You cannot follow yourself"
+PLG_API_EASYSOCIAL_FOLLOWING_MESSAGE="Following "
+PLG_API_EASYSOCIAL_UNABLE_TO_FOLLOW_MESSAGE="unable to follow "
+PLG_API_EASYSOCIAL_SUCCESSFULLY_UNFOLLW_MESSAGE="successfully unfollowed "
+PLG_API_EASYSOCIAL_UNABLE_TO_UNFOLLW_MESSAGE="unable to unfollow "
+PLG_API_EASYSOCIAL_USER_REMOVE_MESSAGE="User removed from followers"
+PLG_API_EASYSOCIAL_UNABLE_TO_REMOVE_USER_MESSAGE="Unable to remove user from followers list"
+PLG_API_EASYSOCIAL_UNABLE_DELETE_FRIEND_MESSAGE="Unable to delete friend"
+PLG_API_EASYSOCIAL_FRIEND_DELETED_MESSAGE="Friend deleted"
+PLG_API_EASYSOCIAL_OLD_PACKAGE_MESSAGE="old package, please update api package"
+PLG_API_EASYSOCIAL_DEVICE_ALREADY_REGISTERED_MESSAGE="Your device is already registered to the server."
+PLG_API_EASYSOCIAL_DEVICE_REGISTER_MESSAGE="Your device is registered to server."
+PLG_API_EASYSOCIAL_INVALID_GROUP_MESSAGE="Invalid Group"
+PLG_API_EASYSOCIAL_ACCESS_DENIED_MESSAGE="You don't have authority to delete this group"
+PLG_API_EASYSOCIAL_GROUP_DELETED_MESSAGE="Group deleted successfully"
+PLG_API_EASYSOCIAL_UNABLE_CREATE_GROUP_MESSAGE="unable to create group"
+PLG_API_EASYSOCIAL_USE_POST_OR_DELETE_MESSAGE="Use post or delete method"
+PLG_API_EASYSOCIAL_INVALID_USER_MESSAGE="Target user is invalid"
+PLG_API_EASYSOCIAL_GROUP_OWNER_NOT_LEAVE_MESSAGE="Group owner cannot leave group"
+PLG_API_EASYSOCIAL_LEAVE_GROUP_MESSAGE="left group successfully"
+PLG_API_EASYSOCIAL_USER_REMOVE_SUCCESS_MESSAGE="User has been removed successfully"
+PLG_API_EASYSOCIAL_MEMBER_NOT_FOUND_MESSAGE="No member found"
+PLG_API_EASYSOCIAL_GROUP_JOIN_LIMIT_EXCEEDS_MESSAGE="Group joining limit exceeded"
+PLG_API_EASYSOCIAL_REQUEST_SENT_MESSAGE="Great! Your request has been sent successfully and the approval is pending from the site administrator"
+PLG_API_EASYSOCIAL_GROUP_ALREADY_JOINED_MESSAGE="Already joined to group"
+PLG_API_EASYSOCIAL_NOT_SUPPORTED_MESSAGE="not supported to this api"
+PLG_API_EASYSOCIAL_REQUEST_SENT_SUCCESS_MESSAGE="Request sent"
+PLG_API_EASYSOCIAL_EMPTY_MESSAGE_MESSAGE="Message cannot be empty"
+PLG_API_EASYSOCIAL_MESSAGE_SENT_MESSAGE="Message has been delivered successfully"
+PLG_API_EASYSOCIAL_UNABLE_SEND_MESSAGE="Unable to send message"
+PLG_API_EASYSOCIAL_DISCUSSION_REPLY_MESSAGE="You have successfully replied to the discussion"
+PLG_API_EASYSOCIAL_INSUFFICIENT_INPUTS_MESSAGE="Insufficient inputs"
+PLG_API_EASYSOCIAL_UNAUTHORISED_USER_MESSAGE="Unauthorised user to approve request"
+PLG_API_EASYSOCIAL_EMPTY_SEARCHTEXT_MESSAGE="Empty searchtext"
+PLG_API_EASYSOCIAL_GROUP_NOT_FOUND="No group found in search"
+PLG_API_EASYSOCIAL_USER_NOT_FOUND="No user found in search"
+PLG_API_EASYSOCIAL_POST_NOT_ALLOW_MESSAGE="User is not allowed to share"
+PLG_API_EASYSOCIAL_EMPTY_TYPE="Empty type not allowed"
+PLG_API_EASYSOCIAL_MEMBER_ACCESS_DENIED_MESSAGE="This group member does not have permission to share data"
+PLG_API_EASYSOCIAL_ADMIN_ACCESS_DENIED_MESSAGE="This group admin does not have permission to share data"
+PLG_API_EASYSOCIAL_UNSUPPORTED_METHOD_MESSAGE="unsupported method,please use post method"
+PLG_API_EASYSOCIAL_EMPTY_STREAM_ID="Empty stream id not allowed"
+PLG_API_EASYSOCIAL_SHARE_SUCCESS_MESSAGE="shared successfully"
+
+PLG_API_EASYSOCIAL_NO_PENDING_REQUESTS="You have no pending requests"
+PLG_API_EASYSOCIAL_NO_FRIENDS="You have no friends"
+PLG_API_EASYSOCIAL_NOT_SENT_REQUEST="You have not sent request"
+PLG_API_EASYSOCIAL_NO_SUGGESTIONS="You have no suggestions"
+PLG_API_EASYSOCIAL_NO_INVITATION="You have no invitations"
+PLG_API_EASYSOCIAL_INVALID_GROUP_NAME="Invalid group name"
+PLG_API_EASYSOCIAL_INVALID_PARMALINK="Invalid parmalink"
+PLG_API_EASYSOCIAL_EMPTY_DESCRIPTION="Empty description is not allowed"
+PLG_API_EASYSOCIAL_ADD_GROUP_TYPE_MESSAGE="Please Add group type"
+PLG_API_EASYSOCIAL_GROUP_CREATION_LIMIT_EXCEEDS="Group creation limit exceeds"
+PLG_API_EASYSOCIAL_CREATE_GROUP_ACCESS_DENIED="You are not allowed to create the group"
+PLG_API_EASYSOCIAL_NO_LEADERS="No Leaders"
+PLG_API_EASYSOCIAL_FRIEND_ID_NOT_FOUND="Friend id not found"
+PLG_API_EASYSOCIAL_UNABLE_REJECT_FRIEND_REQ="Unable to reject friend request"
+PLG_API_EASYSOCIAL_FRIEND_REQ_CANCEL="Friend request cancelled successfully"
+PLG_API_EASYSOCIAL_UNBALE_ADD_FRIEND_REQ="Unable to add friend"
+PLG_API_EASYSOCIAL_FRIEND_REQ_ACCEPT="Friend request accepted successfully"
+PLG_API_EASYSOCIAL_CANT_SAVE_REPORT="Can't save report"
+PLG_API_EASYSOCIAL_REPORT_LOGGED="Report logged successfully"
+PLG_API_EASYSOCIAL_DATA_SHARE_SUCCESS="Post shared successfully"
+PLG_API_EASYSOCIAL_INVALID_IMAGE="Invalid image"
+PLG_API_EASYSOCIAL_INVALID_USER="Invalid User"
+PLG_API_EASYSOCIAL_NOT_CREATED="not created because of "
+PLG_API_EASYSOCIAL_CREATED_USERNAME="created of username-"
+PLG_API_EASYSOCIAL_SEND_MAIL_DETAILS= " and sent email of details. Please check"
+PLG_API_EASYSOCIAL_BAD_REQUEST="Bad request"
+PLG_API_EASYSOCIAL_ALBUM_NOT_EXISTS="album does not exist"
+PLG_API_EASYSOCIAL_SUCCESSFULL=" successful"
+PLG_API_EASYSOCIAL_UNSUCCESSFULL=" unsuccessful"
+PLG_API_EASYSOCIAL_UNLIKE="Unlike"
+PLG_API_EASYSOCIAL_LIKE="Like"
+PLG_API_EASYSOCIAL_USER_REQ_GRANTED="User's request to join the group has been approved successfully"
+PLG_API_EASYSOCIAL_USER_REQ_UNSUCCESS="Sorry! Unable to approve request for joining this group. Please try later!"
+PLG_API_EASYSOCIAL_USER_APPLICATION_REJECTED="User's request has been rejected successfully"
+PLG_API_EASYSOCIAL_UNABLE_REJECT_APPLICATION="Unable to reject request"
+PLG_API_EASYSOCIAL_REQUEST_WITHDRAWN="You have successfully withdrawn your request to join the group"
+PLG_API_EASYSOCIAL_UNABLE_WITHDRAWN_REQ="Unable to withdraw your request to join the group"
+PLG_API_FB_CON_DATE_NOT_FOUND="Permission to access birthdate from facebook has not been provided. Therefore, birthdate has not been updated. This action is irreversible. Do you want to proceed?"
+PLG_API_EMAIL_MANDATORY_REGISTRAION = "Please provide a valid email address, it is mandatory for registration."
+PLG_API_EASYSOCIAL_NO_DEVICE_ID="No device id found, Unable to register device for Notifications"
+PLG_API_EASYSOCIAL_NOTIFICATION_ON="Notification on"
+PLG_API_EASYSOCIAL_NOTIFICATION_OFF="Notification off"
+PLG_API_EASYSOCIAL_NO_DEVICE_ID="No device id found, please check device setting"
+
+PLG_API_EASYSOCIAL_APP_TERM_ONE="End User License Agreement
"
+
+PLG_API_EASYSOCIAL_APP_TERM_TWO="Please read this End User License Agreement carefully before clicking the 'I Agree' button, downloading or using %s.
+By clicking the 'I Agree' button, downloading or using the Application, you are agreeing to be bound by the terms and conditions of this Agreement.
+If you do not agree to the terms of this Agreement, do not click on the 'I Agree' button and do not download or use the Application.
+ %1s grants you a revocable, nonexclusive, nontransferable, limited license to download, install and use the Application solely for your personal, noncommercial purposes strictly in accordance with the terms of this Agreement.
+"
+PLG_API_EASYSOCIAL_APP_TERM_THREE=" Restrictions You agree not to, and you will not permit others to
+
+- License, sell, rent, lease, assign, distribute, transmit, host, outsource, disclose or otherwise commercially exploit the Application or make the Application available to any third party.
+
+
+- The Restrictions section is for applying certain restrictions on the app usage, e.g. user can't sell app, user can't distribute the app.
+
+
+
+- For the full disclosure section, create your own EULA. Modifications to Application %s reserves the right to modify, suspend or discontinue, temporarily or permanently, the Application or any service to which it connects, with or without notice and without liability to you.
+
+
+
+- The Modifications to Application section is for apps that will be updated or regularly maintained. For the full disclosure section, create your own EULA.
+
+
+
+- Term and Termination This Agreement shall remain in effect until terminated by you or %1$s. %1$s may, in its sole discretion, at any time and for any or no reason, suspend or terminate this Agreement with or without prior notice.
+
+
+
+- This Agreement will terminate immediately, without prior notice from %1$s, in the event that you fail to comply with any provision of this Agreement. You may also terminate this Agreement by deleting the Application and all copies thereof from your mobile device or from your desktop.
+
"
+
+PLG_API_EASYSOCIAL_APP_TERM_FOUR="
+
+
+- Upon termination of this Agreement, you shall cease all use of the Application and delete all copies of the Application from your mobile device or from your desktop.
+
+
+
+- Severability If any provision of this Agreement is held to be unenforceable or invalid, such provision will be changed and interpreted to accomplish the objectives of such provision to the greatest extent possible under applicable law and the remaining provisions will continue in full force and effect.
+
+
+
+- Amendments to this Agreement %s reserves the right, at its sole discretion, to modify or replace this Agreement at any time. If a revision is material we will provide at least %1s days' notice prior to any new terms taking effect.
+
+
+
+- What constitutes a material change will be determined at our sole discretion. Contact Information If you have any questions about this Agreement, please contact us
+
"
+
+
+
+
diff --git a/easysocial/language/en-GB/en-GB.plg_api_easysocial.ini~ b/easysocial/language/en-GB/en-GB.plg_api_easysocial.ini~
new file mode 100644
index 0000000..0c736dd
--- /dev/null
+++ b/easysocial/language/en-GB/en-GB.plg_api_easysocial.ini~
@@ -0,0 +1,66 @@
+
+PLG_API_EASYSOCIAL_ALBUM_DELETE_SUCCESS_MESSAGE="album deleted successfully"
+PLG_API_EASYSOCIAL_EMPTY_ELEMENT_NOT_ALLOWED_MESSAGE="Empty element id not allowed"
+PLG_API_EASYSOCIAL_EMPTY_COMMENT_NOT_ALLOWED_MESSAGE="Empty comment not allowed"
+PLG_API_EASYSOCIAL_COMMENT_SAVE_SUCCESS_MESSAGE="comment saved successfully"
+PLG_API_EASYSOCIAL_COMMENT_SAVE_UNSUCCESS_MESSAGE="Unable to save comment"
+PLG_API_EASYSOCIAL_INVALID_CONVERSATION_MESSAGE="Invalid Conversations"
+PLG_API_EASYSOCIAL_CONVERSATION_DELETED_MESSAGE="Conversations deleted successfully"
+PLG_API_EASYSOCIAL_EMPTY_GROUP_ID_MESSAGE="Group id is empty"
+PLG_API_EASYSOCIAL_CREATE_GD_NOT_ALLOWED_MESSAGE="Not allowed to create group discussion"
+PLG_API_EASYSOCIAL_EMPTY_DISCUSSION_TITLE_MESSAGE="Discussion title is empty"
+PLG_API_EASYSOCIAL_UNABLE_CREATE_DISCUSSION_MESSAGE="Unable to create discussion,check params"
+PLG_API_EASYSOCIAL_GROUP_DISCUSSION_CREATED_MESSAGE="Group discussion created"
+PLG_API_EASYSOCIAL_EVENT_CREATE_SUCCESS_MESSAGE="Event created successfully"
+PLG_API_EASYSOCIAL_USE_GET_METHOD_MESSAGE="Use get method."
+PLG_API_EASYSOCIAL_EVENT_NOT_FOUND_MESSAGE="Event not found"
+PLG_API_EASYSOCIAL_INVITED_MESSAGE="Invited"
+PLG_API_EASYSOCIAL_GUEST_CANT_INVITED_MESSAGE="Guests can not be invited"
+PLG_API_EASYSOCIAL_USE_POST_METHOD_MESSAGE="Use post method"
+PLG_API_EASYSOCIAL_INVALID_DATE_FORMAT_MESSAGE="Date format is invalid"
+PLG_API_EASYSOCIAL_ERROR_MESSAGE="Error"
+PLG_API_EASYSOCIAL_LIMIT_EXCEEDS_MESSAGE="Limit Exceeds"
+PLG_API_EASYSOCIAL_SELECT_VALID_OPTION_MESSAGE="Please select valid option."
+PLG_API_EASYSOCIAL_CANT_FOLLOW_YOURSELF_MESSAGE="You can not follow yourself"
+PLG_API_EASYSOCIAL_FOLLOWING_MESSAGE="Following"
+PLG_API_EASYSOCIAL_UNABLE_TO_FOLLOW_MESSAGE="unable to follow "
+PLG_API_EASYSOCIAL_SUCCESSFULLY_UNFOLLW_MESSAGE="successfully unfollow "
+PLG_API_EASYSOCIAL_UNABLE_TO_UNFOLLW_MESSAGE="unable to unfollow "
+PLG_API_EASYSOCIAL_USER_REMOVE_MESSAGE="User remove from followers"
+PLG_API_EASYSOCIAL_UNABLE_TO_REMOVE_USER_MESSAGE="Unable to remove user from follower list"
+PLG_API_EASYSOCIAL_UNABLE_DELETE_FRIEND_MESSAGE="Unable to delete friend"
+PLG_API_EASYSOCIAL_FRIEND_DELETED_MESSAGE="Friend deleted
+PLG_API_EASYSOCIAL_OLD_PACKAGE_MESSAGE="old package, please update api package"
+PLG_API_EASYSOCIAL_DEVICE_ALREADY_REGISTERED_MESSAGE="Your device is already register to server."
+PLG_API_EASYSOCIAL_DEVICE_REGISTER_MESSAGE="Your device is register to server."
+PLG_API_EASYSOCIAL_INVALID_GROUP_MESSAGE="Invalid Group"
+PLG_API_EASYSOCIAL_ACCESS_DENIED_MESSAGE="You are not admin / Owner of group to delete group"
+PLG_API_EASYSOCIAL_GROUP_DELETED_MESSAGE="Group deleted successfully"
+PLG_API_EASYSOCIAL_UNABLE_CREATE_GROUP_MESSAGE="unable to create group"
+PLG_API_EASYSOCIAL_USE_POST_OR_DELETE_MESSAGE="Use post or delete method."
+PLG_API_EASYSOCIAL_INVALID_USER_MESSAGE="Target user not valid"
+PLG_API_EASYSOCIAL_GROUP_OWNER_NOT_LEAVE_MESSAGE="Group owner not leave group"
+PLG_API_EASYSOCIAL_LEAVE_GROUP_MESSAGE="leave group successfully"
+PLG_API_EASYSOCIAL_USER_REMOVE_SUCCESS_MESSAGE="Remove user successfully"
+PLG_API_EASYSOCIAL_MEMBER_NOT_FOUND_MESSAGE="No member found"
+PLG_API_EASYSOCIAL_GROUP_JOIN_LIMIT_EXCEEDS_MESSAGE="Group joining limit exceeded"
+PLG_API_EASYSOCIAL_REQUEST_SENT_MESSAGE="Great! Your request has been sent successfully and it is pending approval from the site administrator."
+PLG_API_EASYSOCIAL_GROUP_ALREADY_JOINED_MESSAGE="Already joined to group"
+PLG_API_EASYSOCIAL_NOT_SUPPORTED_MESSAGE="not supported to this api"
+PLG_API_EASYSOCIAL_REQUEST_SENT_SUCCESS_MESSAGE="Request send"
+PLG_API_EASYSOCIAL_EMPTY_MESSAGE_MESSAGE="Empty message not allowed"
+PLG_API_EASYSOCIAL_MESSAGE_SENT_MESSAGE="Message successfully sent"
+PLG_API_EASYSOCIAL_UNABLE_SEND_MESSAGE="Unable to send message"
+PLG_API_EASYSOCIAL_DISCUSSION_REPLY_MESSAGE="Discussion reply posted successfuly"
+PLG_API_EASYSOCIAL_INSUFFICIENT_INPUTS_MESSAGE="Insufficient inputs"
+PLG_API_EASYSOCIAL_UNAUTHORISED_USER_MESSAGE="Unauthorised user to approve request"
+PLG_API_EASYSOCIAL_EMPTY_SEARCHTEXT_MESSAGE="Empty searchtext"
+PLG_API_EASYSOCIAL_GROUP_NOT_FOUND="No group found in search"
+PLG_API_EASYSOCIAL_USER_NOT_FOUND="No user found in search"
+PLG_API_EASYSOCIAL_POST_NOT_ALLOW_MESSAGE="User not allowed any post in share"
+PLG_API_EASYSOCIAL_EMPTY_TYPE="Empty type not allowed"
+PLG_API_EASYSOCIAL_MEMBER_ACCESS_DENIED_MESSAGE="This group memder do not have share data permission"
+PLG_API_EASYSOCIAL_ADMIN_ACCESS_DENIED_MESSAGE="This group admin do not have share data permission"
+PLG_API_EASYSOCIAL_UNSUPPORTED_METHOD_MESSAGE="unsupported method,please use post method"
+PLG_API_EASYSOCIAL_EMPTY_STREAM_ID="Empty stream id not allowed"
+PLG_API_EASYSOCIAL_SHARE_SUCCESS_MESSAGE="share successful"
diff --git a/easysocial/language/en-GB/en-GB.plg_api_easysocial.sys.ini b/easysocial/language/en-GB/en-GB.plg_api_easysocial.sys.ini
new file mode 100644
index 0000000..709f5c3
--- /dev/null
+++ b/easysocial/language/en-GB/en-GB.plg_api_easysocial.sys.ini
@@ -0,0 +1,2 @@
+PLG_API_EASYSOCIAL="EasySocial APIs"
+PLG_API_EASYSOCIAL_DESCRIPTION="This plugin use for get data from easysocial."
diff --git a/easysocial/libraries/mappingHelper.php b/easysocial/libraries/mappingHelper.php
new file mode 100644
index 0000000..c932eba
--- /dev/null
+++ b/easysocial/libraries/mappingHelper.php
@@ -0,0 +1,1327 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+jimport( 'libraries.schema.group' );
+jimport( 'joomla.filesystem.file' );
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/fields.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/videos.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/video/video.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/group.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/message.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/discussion.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/stream.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/user.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/profile.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/category.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/albums.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/photos.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/createalbum.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/events.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/videos.php';
+
+
+class EasySocialApiMappingHelper
+{
+ public $log_user = 0;
+
+ public function mapItem($rows, $obj_type='', $userid = 0 , $strip_tags='', $text_length=0, $skip=array()) {
+
+ $this->log_user = $userid;
+
+ switch($obj_type)
+ {
+ case 'category':
+ return $this->categorySchema($rows);
+ break;
+ case 'group':
+ return $this->groupSchema($rows,$userid);
+ break;
+ case 'profile':
+ return $this->profileSchema($rows,$userid);
+ break;
+ case 'fields':
+ return $this->fieldsSchema($rows,$userid);
+ break;
+ case 'user':
+ return $this->userSchema($rows);
+ break;
+ case 'comment':
+ return $this->commentSchema($rows);
+ break;
+ case 'message':
+ return $this->messageSchema($rows);
+ break;
+ case 'conversion':
+ return $this->conversionSchema($rows,$userid);
+ break;
+ case 'reply':
+ return $this->replySchema($rows);
+ break;
+ case 'discussion':
+ return $this->discussionSchema($rows);
+ break;
+ case 'stream':
+ return $this->streamSchema($rows,$userid);
+ break;
+ case 'albums':
+ return $this->albumsSchema($rows,$userid);
+ break;
+ case 'photos':
+ return $this->photosSchema($rows,$userid);
+ break;
+ case 'event':
+ return $this->eventsSchema($rows,$userid);
+ break;
+ case 'videos':
+ return $this->videosSchema($rows,$userid);
+ break;
+ case 'polls':
+ return $this->pollsSchema($rows);
+ break;
+ }
+
+ return $item;
+ }
+ //To build photo object
+ public function photosSchema($rows,$userid)
+ {
+ $lang = JFactory::getLanguage();
+ $lang->load('com_easysocial', JPATH_ADMINISTRATOR, '', true);
+ $result = array();
+ foreach($rows as $ky=>$row)
+ {
+
+ if(isset($row->id))
+ {
+ $item = new PhotosSimpleSchema();
+ $pht_lib = FD::photo($row->id,$row->type,$row->album_id);
+
+ $item->isowner= ( $pht_lib->creator()->id == $userid )?true:false;
+ $item->id = $row->id;
+ $item->album_id = $row->album_id;
+ $item->cover_id = $row->cover_id;
+ $item->type = $row->type;
+ $item->uid = $row->id; // for post comment photo id is required.
+ $item->user_id = $row->user_id;
+ $item->title = JText::_($row->title);
+ $item->caption= JText::_($row->caption);
+ $item->created=$row->created;
+ $item->state=$row->state;
+ $item->assigned_date=$row->assigned_date;
+ $item->image_large=$row->image_large;
+ $item->image_square=$row->image_square;
+ $item->image_thumbnail=$row->image_thumbnail;
+ $item->image_featured=$row->image_featured;
+ $like = FD::photo($row->id);
+
+ $like->data->id=$row->id;
+ $data = $like->likes();
+ $item->likes=$this->createlikeObj($data,$userid);
+ $comobj = $like->comments();
+ //$comobj->stream_id=1;
+
+ $item->comment_element = $comobj->element.".".$comobj->group.".".$comobj->verb;
+ $item->comments=$this->createCommentsObj($comobj);
+
+ $result[] = $item;
+ }
+ }
+ return $result;
+ }
+ //to build ablum object
+ public function albumsSchema($rows,$userid)
+ {
+ //To load easysocial language constant
+ $lang = JFactory::getLanguage();
+ $lang->load('com_easysocial', JPATH_ADMINISTRATOR, '', true);
+ $result = array();
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+ $item = new GetalbumsSimpleSchema();
+
+ $item->id = $row->id;
+ $item->cover_id = $row->cover_id;
+ $item->type = $row->type;
+ $item->uid = $row->uid;
+ $item->title = JText::_($row->title);
+ $item->caption= JText::_($row->caption);
+ $item->created=$row->created;
+ $item->assigned_date=$row->assigned_date;
+ $item->cover_featured=$row->cover_featured;
+ $item->cover_large=$row->cover_large;
+ $item->cover_square=$row->cover_square;
+ $item->cover_thumbnail=$row->cover_thumbnail;
+ $item->count=$row->count;
+ $likes = FD::likes($row->id, SOCIAL_TYPE_ALBUM , 'create', SOCIAL_APPS_GROUP_USER );
+ $item->likes = $this->createlikeObj($likes,$userid);
+ //$item->total=$item->likes->total;
+
+ // Get album comments
+ $comments = FD::comments($row->id, SOCIAL_TYPE_ALBUM , 'create', SOCIAL_APPS_GROUP_USER , array('url' => $row->getPermalink()));
+ $item->comment_element = $comments->element.".".$comments->group.".".$comments->verb;
+ if(!$comments->stream_id)
+ $comments->element=$item->comment_element;
+
+
+
+ //$comments->element=$item->comment_element;
+ $item->comments = $this->createCommentsObj($comments);
+ $options = array('uid' => $comments->uid, 'element' => $item->comment_element, 'stream_id' => $comments->stream_id);
+ $item->comments['base_obj']->element="albums";
+ $model = FD::model('Comments');
+ $comcount = $model->getCommentCount($options);
+ //code edit for comment count
+ $item->total=$comcount;
+ $item->comments['total']=$comcount;
+
+ $item->isowner = ( $row->uid == $userid )?true:false;
+ $result[] = $item;
+ }
+ }
+ return $result;
+ }
+
+ //To build field object
+ public function fieldsSchema($rows,$userid)
+ {
+ if(empty($rows))
+ {
+ return array();
+ }
+
+ $lang = JFactory::getLanguage();
+ $lang->load('com_easysocial', JPATH_ADMINISTRATOR, '', true);
+ //$str = JText::_('COM_EASYSOCIAL_FIELDS_PROFILE_DEFAULT_DESIRED_USERNAME');
+
+ $user = FD::user($userid);
+
+ if(count($rows)>0)
+ {
+ $data = array();
+ $fmod_obj = new EasySocialModelFields();
+ foreach($rows as $row)
+ {
+//print_r($row);die("in map");
+ $fobj = new fildsSimpleSchema();
+
+ //$fobj->id = $row->id;
+ $fobj->field_id = $row->id;
+ $fobj->unique_key = $row->unique_key;
+ //$fobj->title = JText($row->title);
+ $fobj->title = JText::_($row->title);
+ $fobj->field_name = JText::_($row->title);
+ $fobj->step = $row->step_id;
+ $fobj->field_value = $fmod_obj->getCustomFieldsValue($row->id,$userid , SOCIAL_FIELDS_GROUP_USER);
+
+ if($fobj->field_name == 'Name' && $fobj->field_value != null )
+ {
+
+ $fobj->field_value = $user->name;
+
+ //$fobj->field_value = $gender->data;
+ //$fobj->field_value = ( $gender->data == 1 )?'male':'female';
+ }
+
+ if($fobj->field_name == 'Gender' && $fobj->field_value != null )
+ {
+
+ $gender = $user->getFieldValue('GENDER');
+ //$fobj->field_value = $gender->data;
+ $fobj->field_value = ( $gender->data == 1 )?'male':'female';
+ }
+
+ /*if($fobj->field_name == 'Birthday')
+ {
+ $birthday = $user->getFieldValue('BIRTHDAY');
+ $date = new DateTime($birthday->data);
+ $fobj->field_value = $date->format('d-m-Y');
+
+ }*/
+
+ // Rework on this work
+ if($fobj->field_name == 'Birthday')
+ {
+ if($fobj->field_value == "Invalid Date")
+ {
+ $fobj->field_value = "";
+ }
+ else
+ {
+ $birthday = $user->getFieldValue('BIRTHDAY');
+ $date = new DateTime($birthday->data);
+ $fobj->field_value = $date->format('d-m-Y');
+ }
+ }
+
+ //to manage address as per site
+ /*if( $fobj->unique_key == 'ADDRESS' )
+ {
+ //$fobj->field_value = $row->data['address'];
+ $fobj->field_value = $row->data['state'].','.$row->data['country'];
+ }*/
+
+ //to manage relationship
+ if( $fobj->unique_key == 'RELATIONSHIP' )
+ {
+ $rs_vl = json_decode($fobj->field_value);
+ $fobj->field_value = $rs_vl->type;
+ }
+ //vishal - runtime solution for issue, need rework
+ if (preg_match('/[\'^[]/', $fobj->field_value))
+ {
+ $fobj->field_value = implode(" ",json_decode($fobj->field_value));
+ }
+
+
+ $fobj->params = json_decode($row->params);
+
+ $data[] = $fobj;
+ }
+
+ return $data;
+ }
+ }
+ //function for stream main obj
+ public function streamSchema($rows,$userid)
+ {
+ $result = array();
+ if(is_array($rows) && empty($rows))
+ {
+ return $result;
+ }
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->uid))
+ {
+
+ $item = new streamSimpleSchema();
+
+ //new code
+ // Set the stream title
+ $item->id = $row->uid;
+
+ //$item->title = strip_tags($row->title);
+ //code changed as request not right way
+ $item->title = $row->title;
+ if($row->type != 'links')
+ {
+ $item->title = str_replace('href="','href="'.JURI::root(),$item->title);
+ }
+
+ if($row->type == 'polls')
+ {
+ continue;
+ }
+
+ $item->type = $row->type;
+ $item->group = $row->cluster_type;
+ $item->element_id = $row->contextId;
+ //
+ $item->content = urldecode(str_replace('href="/index','href="'.JURI::root().'index',$row->content));
+
+ //$item->preview = $row->preview;
+
+ //hari - code for build video iframe
+ //check code optimisation
+ $frame_match= preg_match('/;iframe.*?>/', $row->preview);
+ if($frame_match)
+ {
+ $dom = new DOMDocument;
+ $dom->loadHTML($row->preview);
+ foreach ($dom->getElementsByTagName('a') as $node) {
+ $first = $node->getAttribute( 'href' );
+ break;
+ }
+ if(strstr($first,"youtu.be"))
+ {
+ $first=preg_replace("/\s+/",'',$first);
+ $first=preg_replace("/youtu.be/","youtube.com/embed",$first);
+ $abc=$first."?feature=oembed";
+ $item->preview ='';
+ }
+ else
+ {
+ $df=preg_replace("/\s+/",'',$first);
+ $df=preg_replace("/watch\?v=([a-zA-Z0-9\]+)([a-zA-Z0-9\/\\\\?\&\;\%\=\.])/i","embed/$1 ",$first);
+ $abc=$df."?feature=oembed";
+ $df=preg_replace("/\s+/",'',$abc);
+ $item->preview ='';
+ }
+ }
+ else
+ {
+ $item->preview = $row->preview;
+ }
+ //end
+
+ // Set the stream content
+ if(!empty($item->preview))
+ {
+ $item->raw_content_url = $row->preview;
+ }
+ elseif(!empty($item->content))
+ {
+ $item->raw_content_url = $row->content;
+ }
+
+ if($row->type != 'links')
+ {
+ $item->raw_content_url = str_replace('href="','href="'.JURI::root(),$item->raw_content_url);
+ }
+ // Set the publish date
+ $item->published = $row->created->toMySQL();
+
+ /*
+ // Set the generator
+ $item->generator = new stdClass();
+ $item->generator->url = JURI::root();
+
+ // Set the generator
+ $item->provider = new stdClass();
+ $item->provider->url = JURI::root();
+ */
+ // Set the verb
+ $item->verb = $row->verb;
+
+ //create users object
+ $actors = array();
+ $user_url = array();
+ foreach($row->actors as $actor)
+ {
+ $user_url[$actor->id] = JURI::root().FRoute::profile( array('id' => $actor->id , 'layout' => 'item', 'sef' => false ));
+ $actors[] = $this->createUserObj($actor->id);
+ }
+
+ //with share obj users object
+ //$with_usr = array();
+ $with_user_url = array();
+
+ foreach($row->with as $actor)
+ {
+ $withurl = JURI::root().FRoute::profile( array('id' => $actor->id , 'layout' => 'item', 'sef' => false ));
+ $with_user_url[] = "".$this->createUserObj($actor->id)->username."";
+
+ //$with_url = $with_url." and ".
+
+ //$with_user_url[] = $this->createUserObj($actor->id);
+ }
+ $item->with = null;
+ //to maintain site view for with url
+ if( !empty($with_user_url) )
+ {
+ $cnt = sizeof($with_user_url);
+ $item->with = 'with '.$with_user_url[0];
+
+ for($i=0;$i<$cnt-2;$i++)
+ {
+ $item->with = $item->with.', '.$with_user_url[$i+1];
+ }
+ if($cnt-1 != 0)
+ {
+ $item->with = $item->with.' and '.$with_user_url[$cnt-1];
+ }
+ }
+
+ //
+ $item->actor = $actors;
+ //This node is for Report-flag for the posts.
+ $item->isself = ( $actors[0]->id == $userid )?true:false;
+
+ $item->likes = (!empty($row->likes))?$this->createlikeObj($row->likes,$userid):null;
+
+ if(!empty($row->comments->element))
+ {
+ $item->comment_element = $row->comments->element.".".$row->comments->group.".".$row->comments->verb;
+ $row->comments->stream_id = $row->comments->options['streamid'];
+ }
+ else
+ {
+ $item->comment_element = null;
+ }
+
+ $item->comments = (!empty($row->comments->uid))?$this->createCommentsObj($row->comments):null;
+
+ // These properties onwards are not activity stream specs
+ //$item->icon = $row->fonticon;
+
+ // Set the lapsed time
+ $item->lapsed = $row->lapsed;
+
+ // set the if this stream is mini mode or not.
+ // mini mode should not have any actions such as - likes, comments, share and etc.
+ $item->mini = $row->display == SOCIAL_STREAM_DISPLAY_MINI ? true : false;
+
+ //build share url use for share post through app
+ $sharing = FD::get( 'Sharing', array( 'url' => FRoute::stream( array( 'layout' => 'item', 'id' => $row->uid, 'external' => true, 'xhtml' => true ) ), 'display' => 'dialog', 'text' => JText::_( 'COM_EASYSOCIAL_STREAM_SOCIAL' ) , 'css' => 'fd-small' ) );
+ $item->share_url = $sharing->url;
+
+ // Check if this item has already been bookmarked
+ $sticky = FD::table('StreamSticky');
+ $item->isPinned = null;
+ if($sticky)
+ {
+ $item->isPinned = $sticky->load(array('stream_id' => $row->uid));
+ }
+
+ //create urls for app side mapping
+ //$log_usr = FRoute::profile( array('id' => $row->uid , 'layout' => 'item', 'sef' => false ));
+ $strm_urls = array();
+
+ $strm_urls['actors'] = $user_url;
+
+ $result[] = $item;
+ //$result[] = $row;
+ //end new
+
+ }
+ }
+
+ return $result;
+ }
+
+ //create like object
+ public function createLikeObj($row,$userid)
+ {
+ $likesModel = FD::model('Likes');
+ if (!is_bool($row->uid)) {
+
+ // Like id should contain the exact item id
+ $item = new likesSimpleSchema();
+
+ $key = $row->element.'.'.$row->group.'.'.$row->verb;
+
+ $item->uid = $row->uid;
+ $item->element = $row->element;
+ $item->group = $row->group;
+ $item->verb = $row->verb;
+
+ $item->hasLiked = $likesModel->hasLiked($row->uid,$key,$userid,$row->stream_id);
+ $item->stream_id = $row->stream_id;
+
+ // Get the total likes
+ $item->total = $likesModel->getLikesCount($row->uid, $key);
+ $item->like_obj = $likesModel->getLikes($row->uid,$key);
+
+ return $item;
+ }
+ return null;
+ }
+
+ //server date offset setting
+ public function getOffsetServer($date,$userid)
+ {
+
+ /*$date = new DateTime($date);
+ $config = JFactory::getConfig();
+ $date->setTimezone(new DateTimeZone($config->get('offset')));
+ $date = $date->format('Y-m-d H:i:s a');*/
+
+ $config = JFactory::getConfig();
+ $user = JFactory::getUser($userid);
+ $offset = $user->getParam('timezone', $config->get('offset'));
+
+ if (!empty($date) && $date != '0000-00-00 00:00:00')
+ {
+ $udate = JFactory::getDate($date, $offset);
+ //$date = $udate->toSQL();
+ $date = $udate->format('Y-m-d H:i:s a');
+ }
+
+ return $date;
+
+ }
+
+ //create comments object
+ public function createCommentsObj($row,$limitstart=0,$limit=10)
+ {
+
+ if (!is_bool($row->uid))
+ {
+ $options = array('uid' => $row->uid, 'element' => $row->element, 'stream_id' => $row->stream_id, 'start' => $limitstart, 'limit' => $limit);
+
+ $model = FD::model('Comments');
+
+ $result = $model->getComments($options);
+
+ $data = array();
+ $data['total'] = 0;
+ $data['base_obj'] = $row;
+
+ $likesModel = FD::model('Likes');
+
+ foreach($result As $cdt)
+ {
+ $item = new commentsSimpleSchema();
+
+ $row->group = (isset($row->group))?$row->group:null;
+ $row->verb = (isset($row->group))?$row->verb:null;
+
+ $item->uid = $cdt->id;
+ $item->element = $cdt->element;
+ $item->element_id = $row->uid;
+ $item->stream_id = $cdt->stream_id;
+ $item->comment = $cdt->comment;
+ $item->type = $row->element;
+ $item->verb = $row->verb;
+ $item->group = $row->group;
+ $item->created_by = $this->createUserObj($cdt->created_by);
+ $item->created = $cdt->created;
+
+ $item->likes = new likesSimpleSchema();
+ $item->likes->uid = $cdt->id;
+ $item->likes->element = 'comments';
+ $item->likes->group = 'user';
+ $item->likes->verb = 'like';
+ $item->likes->stream_id = $cdt->stream_id;
+ $item->likes->total = $likesModel->getLikesCount($item->uid, 'comments.' . 'user' . '.like');
+ $item->likes->hasLiked = $likesModel->hasLiked($item->uid,'comments.' . 'user' . '.like',$cdt->created_by);
+ $data['data'][] = $item;
+ }
+
+ //$data['total'] = count($data['data']);
+ $comcount = $model->getCommentCount($options);
+
+ $data['total']=$comcount;
+ return $data;
+ }
+
+ return null;
+ }
+
+ //function for discussion main obj
+ public function discussionSchema($rows)
+ {
+ //$conv_model = FD::model('Conversations');
+ $result = array();
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+
+ $item = new discussionSimpleSchema();
+
+ $item->id = $row->id;
+ $item->title = $row->title;
+ $item->description = $row->content;
+ //$item->attachment = $conv_model->getAttachments($row->id);
+ $item->created_by = $this->createUserObj($row->created_by);
+ $item->created_date = $this->dateCreate($row->created);
+ $item->lapsed = $this->calLaps($row->created);
+ $item->hits = $row->hits;
+ $item->replies_count = $row->total_replies;
+ $item->last_replied = $this->calLaps($row->last_replied);
+
+ //$item->replies = 0;
+ $last_repl = (isset($row->lastreply))?array(0=>$row->lastreply):array();
+
+ $item->replies = $this->discussionReply($last_repl);
+
+ $result[] = $item;
+ }
+ }
+
+ return $result;
+ }
+
+ //function for discussion reply obj
+ public function discussionReply($rows)
+ {
+ if(empty($rows))
+ return 0;
+ //$conv_model = FD::model('Conversations');
+ $result = array();
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+ $item = new discussionReplySimpleSchema();
+
+ $item->id = $row->id;
+ $item->reply = $row->content;
+ $item->created_by = $this->createUserObj($row->created_by);
+ $item->created_date = $this->dateCreate($row->created);
+ $item->lapsed = $this->calLaps($row->created);
+
+ $result[] = $item;
+ }
+ }
+
+ return $result;
+ }
+
+ //function for create category schema
+ public function categorySchema($rows)
+ {
+ $result = array();
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+ $item = new CategorySimpleSchema();
+
+ $item->categoryid = $row->id;
+ $item->title = $row->title;
+ $item->description = $row->description;
+ $item->state = $row->state;
+ //$item->attachment = $conv_model->getAttachments($row->id);
+ $item->created_by = $this->createUserObj($row->uid);
+ $item->created_date = $this->dateCreate($row->created);
+
+ $result[] = $item;
+ }
+ }
+
+ return $result;
+ }
+ //to build event obj.
+ public function eventsSchema($rows,$userid)
+ {
+ $lang = JFactory::getLanguage();
+ $lang->load('com_easysocial', JPATH_ADMINISTRATOR, '', true);
+ $result = array();
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+ $item = new EventsSimpleSchema();
+ $item->id=$row->id;
+ $item->title=$row->title;
+ $item->description=$row->description;
+ //getting all event images
+ foreach($row->avatars As $ky=>$avt)
+ {
+ $avt_key = 'avatar_'.$ky;
+ $item->$avt_key = JURI::root().'media/com_easysocial/avatars/event/'.$row->id.'/'.$avt;
+
+ $fst = JFile::exists('media/com_easysocial/avatars/event/'.$row->id.'/'.$avt);
+ //set default image
+ if(!$fst)
+ {
+ $item->$avt_key = JURI::root().'media/com_easysocial/defaults/avatars/event/'.$ky.'.png';
+ }
+ }
+ //end
+
+ $item->params=json_decode($row->params);
+
+ $item->details=$row->meta;
+ //ios format date
+ if(!empty($item->details->start))
+ {
+ $item->details->ios_start = $this->listDate($item->details->start);
+ $item->start_date = date('D M j Y h:i a',strtotime($row->meta->start));
+ $item->start_date_unix = strtotime($row->meta->start);
+ }
+
+
+ if( $item->details->end == "0000-00-00 00:00:00")
+ {
+ $item->details->ios_end = null;
+ $item->end_date = null;
+ $item->end_date_unix = null;
+
+ /*
+ $item->details->ios_end = $this->listDate($item->details->start);
+ $item->end_date = date('D M j Y h:i a',strtotime($row->meta->start));
+ $item->end_date_unix = strtotime($row->meta->start);
+ */
+
+ }
+ else
+ {
+ $item->details->ios_end = $this->listDate($item->details->end);
+ $item->end_date = date('D M j Y h:i a ',strtotime($row->meta->end));
+ $item->end_date_unix = strtotime($row->meta->end);
+ }
+ //ios format date
+ //$item->start_date_ios = $this->listDate($row->meta->start);
+ //$item->end_date_ios = $this->listDate($row->meta->end);
+
+ $item->start_date_unix = strtotime($row->meta->start);
+ $item->end_date_unix = strtotime($row->meta->end);
+
+ $event = FD::model( 'events' );
+ $item->guests= $event->getTotalAttendees($row->id);
+
+ $item->featured=$row->featured;
+ $item->created=$row->created;
+ $item->categoryId=$row->category_id;
+ $item->type=$row->type;
+
+ //get category name
+ $category = FD::table('EventCategory');
+ $category->load($row->category_id);
+ $item->category_name = $category->get('title');
+
+ //event guest status
+ $eventobj=FD::event($row->id);
+ $item->isAttending=$eventobj->isAttending($userid);
+ $item->isNotAttending=$eventobj->isNotAttending($userid);
+ $item->isOwner=$eventobj->isOwner($userid);
+ $item->isPendingMember = $eventobj->isPendingMember($userid);
+ $item->isMember=$eventobj->isMember($userid);
+ $item->isRecurring=$eventobj->isRecurringEvent();
+ $item->hasRecurring=$eventobj->hasRecurringEvents();
+
+ $event_owner = reset($row->admins);
+ if($event_owner)
+ {
+ $item->owner = $this->createUserObj($event_owner)->username;
+ $item->owner_id = $event_owner;
+ }
+ //$item->owner=$user->username;
+
+ $item->isMaybe=in_array($userid,$row->maybe);
+ $item->total_guest=$eventobj->getTotalGuests();
+ // this node is for past events
+ $item->isoverevent=$eventobj->isOver();
+ if($item->end_date == null){
+ $item->isoverevent = false;
+ }
+
+ $item->location=$row->address;
+ $item->longitude=$row->longitude;
+ $item->latitude=$row->latitude;
+ $NameLocationLabel = $item->location;
+ $item->event_map_url_andr = "geo:".$item->latitude.",".$item->longitude."?q=".$NameLocationLabel;
+ //$item->event_map_url_ios = "geo:".$item->latitude.",".$item->longitude."?q=".$NameLocationLabel;
+ $item->event_map_url_ios = "http://maps.apple.com/?q=".$NameLocationLabel."&sll=".$item->latitude.",".$item->longitude;
+ $item->share_url = JURI::root().$eventobj->getPermalink(true, false, 'item', false);
+ //getting cover image of event
+ $eve = FD::table( 'Cover' );
+ $eve->type='event';
+ $eve->photo_id=$row->cover->photo_id;
+ $item->cover_image=$eve->getSource();
+ //end
+ $item->isInvited = false;
+ $event = FD::event($row->id);
+ $guest = $event->getGuest($userid);
+ if ($guest->invited_by) {
+ $item->isInvited = true;
+ }
+ $result[] = $item;
+ }
+ }
+ return($result);
+ }
+
+ //function for create group schema
+ public function groupSchema($rows=null,$userid=0)
+ {
+ if($rows == null || $userid == 0)
+ {
+ $ret_arr = new stdClass;
+ $ret_arr->status = false;
+ $ret_arr->message = "No group found in search";
+
+ return $ret_arr;
+ }
+
+ $result = array();
+ $user = JFactory::getUser($userid);
+
+ foreach($rows as $ky=>$row)
+ {
+ $fieldsModel = FD::table('FieldData');
+ $fieldsModel->load($row->id);
+
+ if(isset($row->id))
+ {
+ $grpobj = FD::group( $row->id );
+ $item = new GroupSimpleSchema();
+
+ $item->id = $row->id;
+ $item->title = $row->title;
+ $item->alias = $row->alias;
+ $item->description = $row->description;
+ $item->hits = $row->hits;
+ $item->state = $row->state;
+ $item->website = $fieldsModel->raw;
+ $item->created_date = $this->dateCreate($row->created);
+
+ //get category name
+ $category = FD::table('GroupCategory');
+ $category->load($row->category_id);
+ $item->category_id = $row->category_id;
+ $item->category_name = $category->get('title');
+ $item->cover = $grpobj->getCover();
+
+ $item->created_by = $row->creator_uid;
+ $item->creator_name = JFactory::getUser($row->creator_uid)->username;
+ //$item->type = ($row->type == 1 )?'Public':'Public';
+ $item->type = $row->type;
+ $item->params = (!empty($row->params))?$row->params:false;
+
+ foreach($row->avatars As $ky=>$avt)
+ {
+ $avt_key = 'avatar_'.$ky;
+ $item->$avt_key = JURI::root().'media/com_easysocial/avatars/group/'.$row->id.'/'.$avt;
+
+ $fst = JFile::exists('media/com_easysocial/avatars/group/'.$row->id.'/'.$avt);
+ //set default image
+ if(!$fst)
+ {
+ $item->$avt_key = JURI::root().'media/com_easysocial/avatars/group/'.$ky.'.png';
+ }
+ }
+
+ //$obj->members = $row->members;
+ $grp_obj = FD::model('Groups');
+ $item->member_count = $grp_obj->getTotalMembers($row->id);
+ //$obj->cover = $grp_obj->getMeta($row->id);
+
+ $alb_model = FD::model('Albums');
+
+ $uid = $row->id.':'.$row->title;
+
+ $filters = array('uid'=>$uid,'type'=>'group');
+ //get total album count
+ $item->album_count = $alb_model->getTotalAlbums($filters);
+
+ //get group album list
+ //$albums = $alb_model->getAlbums($uid,'group');
+
+ $item->isowner = ( $row->creator_uid == $userid )?true:false;
+ $item->ismember = in_array( $userid,$row->members );
+ $item->approval_pending = in_array( $userid,$row->pending );
+
+ $result[] = $item;
+ }
+ }
+ return $result;
+
+ }
+
+ //function for create profile schema
+ public function profileSchema($other_user_id,$userid)
+ {
+
+ $log_user_obj = FD::user($userid);
+ $other_user_obj = FD::user($other_user_id);
+
+ $user_obj = $this->createUserObj($other_user_id);
+ $user_obj->isself = ($userid == $other_user_id )?true:false;
+ $user_obj->cover = $other_user_obj->getCover();
+
+ $user_obj->isblocked_me = $log_user_obj->isBlockedBy($other_user_id);
+ $user_obj->isblockedby_me = $other_user_obj->isBlockedBy($userid);
+
+ if( $userid != $other_user_id )
+ {
+ $frnd_mod = FD::model( 'Friends' );
+ $trg_obj = FD::user( $other_user_id );
+ $user_obj->isfriend = $trg_obj->isFriends( $userid );
+
+ $user_obj->isfollower = $trg_obj->isFollowed( $userid );
+ $user_obj->approval_pending = $frnd_mod->isPendingFriends($userid,$other_user_id);
+
+ //$user_obj->approval_pending = $user->isPending($other_user_id);
+ }
+
+ //$user_obj->friend_count = $other_user_obj->getTotalFriends();
+ //$user_obj->follower_count = $other_user_obj->getTotalFollowers();
+ //$user_obj->badges = $this->createBadge($other_user_obj->getBadges());
+ $user_obj->points = $other_user_obj->getPoints();
+
+
+ return $user_obj;
+ }
+
+ //create badge object list
+ public function createBadge($rows)
+ {
+ $badges = array();
+
+ foreach( $rows as $row )
+ {
+ $std_obj = new stdClass();
+ $std_obj->id = $row->id;
+ $std_obj->title = JText::_($row->title);
+ $std_obj->description = JText::_($row->description);
+ $std_obj->alias = $row->alias;
+ $std_obj->howto = JText::_($row->howto);
+ $std_obj->avatar = JURI::root().$row->avatar;
+ $std_obj->achieved_date = $row->achieved_date;
+ $std_obj->created = $row->created;
+
+ $badges[] = $std_obj;
+ }
+ return $badges;
+ }
+
+ //function for create user schema
+ public function userSchema($rows)
+ {
+ $data = array();
+ if(empty($rows))
+ return $data;
+
+
+ foreach($rows as $row)
+ {
+ $data[] = $this->createUserObj($row->id);
+ }
+
+ return $data;
+ }
+
+ //function for create message schema
+ public function conversionSchema($rows,$log_user)
+ {
+ $conv_model = FD::model('Conversations');
+ $result = array();
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+ $item = new converastionSimpleSchema();
+ $participant_usrs = $conv_model->getParticipants( $row->id );
+ $con_usrs = array();
+
+ foreach($participant_usrs as $ky=>$usrs)
+ {
+ if($usrs->id && ($log_user != $usrs->id) )
+ $con_usrs[] = $this->createUserObj($usrs->id);
+ }
+
+ $item->conversion_id = $row->id;
+ $item->created_date = $row->created;
+ $item->lastreplied_date = $row->lastreplied;
+ $item->isread = $row->isread;
+ $item->messages = $row->message;
+ $item->lapsed = $this->calLaps($row->created);
+ $item->participant = $con_usrs;
+
+ $result[] = $item;
+ }
+ }
+
+ return $result;
+ }
+
+ //function for create message schema
+ public function messageSchema($rows)
+ {
+ $conv_model = FD::model('Conversations');
+ $result = array();
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+ $item = new MessageSimpleSchema();
+
+ $item->id = $row->id;
+ $item->message = $row->message;
+ $item->attachment = null;
+ //$item->attachment = $conv_model->getAttachments($row->id);
+ $item->created_by = $this->createUserObj($row->created_by);
+ $item->created_date = $this->dateCreate($row->created);
+ $item->lapsed = $this->calLaps($row->created);
+ $item->isself = ($this->log_user == $row->created_by)?1:0;
+
+ $result[] = $item;
+ }
+ }
+
+ return $result;
+ }
+
+ //function for create message schema
+ public function replySchema($rows)
+ {
+ //$conv_model = FD::model('Conversations');
+ $result = array();
+
+ foreach($rows as $ky=>$row)
+ {
+ if(isset($row->id))
+ {
+ $item = new ReplySimpleSchema();
+
+ $item->id = $row->id;
+
+ //format content
+ $row->content = str_replace('[','<',$row->content);
+ $row->content = str_replace(']','>',$row->content);
+
+ $item->reply = $row->content;
+ $item->created_by = $this->createUserObj($row->created_by);
+ $item->created_date = $this->dateCreate($row->created);
+ $item->lapsed = $this->calLaps($row->created);
+ $result[] = $item;
+ }
+ }
+
+ return $result;
+ }
+
+ //calculate laps time
+ function calLaps($date)
+ {
+
+ if( (strtotime($date) == 0) || ($date == NULL) || $date == '0000-00-00 00:00:00' )
+ {
+ return 0;
+ }
+
+ return $lap_date = FD::date($date)->toLapsed();
+
+ }
+
+ //create user object
+ public function createUserObj($id){
+
+ if($id)
+ {
+
+ $user = FD::user($id);
+
+ /*
+ $actor = new stdClass;
+
+ $image = new stdClass;
+
+ $actor->id = $id;
+ $actor->username = $user->username;
+
+ $image->image_small = $user->getAvatar('small');
+ $image->image_medium = $user->getAvatar();
+ $image->image_large = $user->getAvatar('large');
+
+ $image->cover_image = $user->getCover();
+
+ $actor->image = $image;
+
+ return $actor;
+ */
+ $es_params = FD::config();
+ $actor = new userSimpleSchema();
+ $image = new stdClass;
+
+ $actor->id = $id;
+
+ //ES config dependent username
+ if($es_params->get('users')->displayName == 'username')
+ {
+ $actor->username = $user->username;
+ }
+ else
+ {
+ $actor->username = $user->name;
+ }
+
+ $actor->name = $user->name;
+
+ $image->image_small = $user->getAvatar('small');
+ $image->image_medium = $user->getAvatar();
+ $image->image_large = $user->getAvatar('large');
+ $image->image_square = $user->getAvatar('square');
+
+ //set default image
+ /*if(!file_exists($image->image_small))
+ {
+ $image->image_small = JURI::root().'media/com_easysocial/avatars/user/small.png';
+ $image->image_medium = JURI::root().'media/com_easysocial/avatars/user/medium.png';
+ $image->image_large = JURI::root().'media/com_easysocial/avatars/user/large.png';
+ }*/
+
+ $image->cover_image = $user->getCover();
+
+ $actor->image = $image;
+
+ $actor->points = $user->points;
+ $actor->totale_badges = $user->getTotalBadges();
+ $actor->badges = $this->createBadge($user->getBadges());
+
+ $fmodel = FD::model( 'Friends' );
+ //$actor->friend_count = $fmodel->getFriendsCount( $id );
+ $actor->friend_count = $user->getTotalFriends();
+
+
+ $actor->follower_count = $user->getTotalFollowers();
+
+ return $actor;
+ }
+
+ }
+
+ //date formatting for ios 9
+ public function listDate($date)
+ {
+ $datetime = new DateTime($date);
+ /*list($year,$month,$day,$hour,$min,$sec,$msec) = explode('-',$datetime->format('Y-m-d-H-i-s-u'));
+ return $ios9_str_dt = $year.','.$month.','.$day.','.$hour.','.$min.','.$sec.','.$msec;
+ */
+ //alternate code for ios9 sending array
+ $i_dt = array();
+ $i_dt['year'] = $datetime->format('Y');
+ $i_dt['month'] = $datetime->format('m');
+ $i_dt['day'] = $datetime->format('d');
+ $i_dt['hour'] = $datetime->format('H');
+ $i_dt['minutes'] = $datetime->format('i');
+ $i_dt['seconds'] = $datetime->format('s');
+ $i_dt['microsec'] = $datetime->format('u');
+ return $i_dt;
+ }
+
+ //format date for event
+ public function dateCreate($dt) {
+
+ $date=date_create($dt);
+ return $newdta = date_format($date,"l,F j Y");
+ }
+
+ public function sanitize($text) {
+ $text = htmlspecialchars_decode($text);
+ $text = str_ireplace(' ', ' ', $text);
+
+ return $text;
+ }
+ //create user frnd details nod
+ public function frnd_nodes($data,$user)
+ {
+ //$user = JFactory::getUser($this->plugin->get('user')->id);
+ $frnd_mod = FD::model( 'Friends' );
+ $list = array();
+ foreach($data as $k=>$node)
+ {
+
+ if($node->id != $user->id)
+ {
+ $node->mutual = $frnd_mod->getMutualFriendCount($user->id,$node->id);
+ $node->isFriend = $frnd_mod->isFriends($user->id,$node->id);
+ $node->approval_pending = $frnd_mod->isPendingFriends($user->id,$node->id);
+ }
+ }
+ return $data;
+ }
+
+ //function for getting polls
+ public function pollsSchema($rows)
+ {
+ $item=array();
+ foreach($rows as $row)
+ {
+ $item = new pollsSchema();
+
+ $item->id = $row->id;
+ $item->element = $row->element;
+ $item->uid = $row->uid;
+ $item->title = $row->title;
+ $item->multiple = $row->multiple;
+ $item->locked = $row->locked;
+ $item->cluster_id = $row->cluster_id;
+ $item->created_by = $row->created_by;
+ $item->created =$row->created;
+ $item->expiry_date = $row->expiry_date;
+
+ $result[] = $item;
+ }
+ return $result;
+ }
+
+ //function for getting all videos
+ public function videosSchema($rows,$userid)
+ {
+ foreach($rows as $ky=>$row)
+ {
+ $item = new VideoSimpleSchema();
+
+ $category = FD::table('VideoCategory');
+ $category->load($row->category_id);
+
+ //$video = FD::video($row->id);
+ $video = ES::video();
+ $video->load($row->id);
+
+ $user = JFactory::getUser();
+ $isRoot = $user->authorise('core.admin');
+
+ $item->id = $row->id;
+ $item->title = $row->title;
+ $item->description = $row->description;
+ $item->created_by = $this->createUserObj($row->user_id);
+ $item->uid = $row->uid;
+ $item->type = $row->type;
+ $item->created = $video->getCreatedDate();
+ $item->state = $row->state;
+ $item->featured = $row->featured;
+ $item->category_id = $row->category_id;
+ $item->category_name = $category->get('title');
+ $item->hits = $video->getHits(); //$row->hits;
+ $item->duration = $video->getDuration(); //$row->duration;
+ $item->size = $row->size;
+ $item->params = json_decode($row->params,true);
+ $item->storage = $row->storage;
+ $item->path = $row->path;
+ $item->original = $row->original;
+ $item->file_title = $row->file_title;
+ $item->source = $row->source;
+ $item->thumbnail = $row->thumbnail;
+ $item->likes = $video->getLikesCount();
+ $item->comments = $video->getCommentsCount();
+ $item->isAdmin = $isRoot;
+
+ $result[] = $item;
+ }
+ return $result;
+ }
+
+ //function for mapping video object
+ public function videoMap($rows)
+ {
+ foreach($rows as $row)
+ {
+ $item = new VideoSimpleSchema();
+
+ $item->id = $row->id;
+ $item->title = $row->title;
+ $item->description = $row->description;
+ $item->user_id = $row->user_id;
+ $item->uid = $row->uid;
+ $item->type = $row->type;
+ $item->created = $row->created;
+ $item->state = $row->state;
+ $item->featured = $row->featured;
+ $item->category_id = $row->category_id;
+ $item->hits = $row->hits;
+ $item->duration = $row->duration;
+ $item->size = $row->size;
+ $item->params = $row->params;
+ $item->storage = $row->storage;
+ $item->path = $row->path;
+ $item->original = $row->original;
+ $item->file_title = $row->file_title;
+ $item->source = $row->source;
+ $item->thumbnail = $row->thumbnail;
+ $item->message = "Video uploaded successfully";
+
+ $result[] = $item;
+ return $result;
+ }
+ }
+
+}
diff --git a/easysocial/libraries/schema/albums.php b/easysocial/libraries/schema/albums.php
new file mode 100644
index 0000000..8e9a1fd
--- /dev/null
+++ b/easysocial/libraries/schema/albums.php
@@ -0,0 +1,29 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+class GetalbumsSimpleSchema {
+ public $id;
+ public $cover_id;
+ public $uid;
+ public $type;
+ public $title;
+ public $caption;
+ public $created;
+ public $assigned_date;
+ public $cover_featured;
+ public $cover_large;
+ public $cover_square;
+ public $cover_thumbnail;
+ public $count;
+ public $likes;
+ public $total;
+ public $comments;
+ public $comment_element;
+ public $commentcount;
+ public $isowner;
+}
diff --git a/easysocial/libraries/schema/category.php b/easysocial/libraries/schema/category.php
new file mode 100644
index 0000000..720d803
--- /dev/null
+++ b/easysocial/libraries/schema/category.php
@@ -0,0 +1,26 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+
+class CategorySimpleSchema {
+
+ public $categoryid;
+
+ public $title;
+
+ public $description;
+
+ public $state;
+
+ public $created_by;
+
+ public $created_date;
+
+
+}
diff --git a/easysocial/libraries/schema/createalbum.php b/easysocial/libraries/schema/createalbum.php
new file mode 100644
index 0000000..8dcbc7a
--- /dev/null
+++ b/easysocial/libraries/schema/createalbum.php
@@ -0,0 +1,23 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+class CreatealbumSimpleSchema {
+ public $id;
+ public $cover_id;
+ public $uid;
+ public $type;
+ public $user_id;
+ public $title;
+ public $caption;
+ public $created;
+ public $assigned_date;
+ public $cover_featured;
+ public $cover_large;
+ public $cover_square;
+ public $cover_thumbnail;
+}
diff --git a/easysocial/libraries/schema/discussion.php b/easysocial/libraries/schema/discussion.php
new file mode 100644
index 0000000..1183f8f
--- /dev/null
+++ b/easysocial/libraries/schema/discussion.php
@@ -0,0 +1,32 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class discussionSimpleSchema {
+
+ public $id;
+ public $title;
+ public $description;
+ public $created_date;
+ public $created_by;
+ public $replies_count;
+ public $last_replied;
+ public $hits;
+ public $lapsed;
+ public $replies;
+}
+
+class discussionReplySimpleSchema {
+
+ public $id;
+ public $created_by;
+ public $reply;
+ public $created_date;
+ public $lapsed;
+
+}
diff --git a/easysocial/libraries/schema/events.php b/easysocial/libraries/schema/events.php
new file mode 100644
index 0000000..bd0cb1a
--- /dev/null
+++ b/easysocial/libraries/schema/events.php
@@ -0,0 +1,39 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class EventsSimpleSchema {
+public $id;
+public $title;
+public $description;
+public $params;
+public $details;
+public $guests;
+public $featured;
+public $created;
+public $categoryId;
+public $start_date;
+public $end_date;
+public $start_date_unix;
+public $end_date_unix;
+public $category_name;
+public $isAttending;
+public $isOwner;
+public $isMaybe;
+public $location;
+public $longitude;
+public $latitude;
+public $cover_image;
+public $start_date_ios;
+public $end_date_ios;
+public $isoverevent;
+public $share_url;
+public $isPendingMember;
+public $isRecurring;
+public $hasRecurring;
+}
diff --git a/easysocial/libraries/schema/group.php b/easysocial/libraries/schema/group.php
new file mode 100644
index 0000000..8dbebc4
--- /dev/null
+++ b/easysocial/libraries/schema/group.php
@@ -0,0 +1,32 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class GroupSimpleSchema {
+
+public $id;
+public $title;
+public $description;
+public $category_id;
+public $category_name;
+//public $cover;
+public $type;
+public $avatar_large;
+public $member_count;
+public $hits;
+public $created_by;
+public $created_date;
+public $album_count;
+public $isowner;
+public $ismember;
+public $approval_pending;
+public $cover;
+public $more_info;
+public $params;
+
+}
diff --git a/easysocial/libraries/schema/group_members.php b/easysocial/libraries/schema/group_members.php
new file mode 100644
index 0000000..5a8a011
--- /dev/null
+++ b/easysocial/libraries/schema/group_members.php
@@ -0,0 +1,23 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class GroupMembersSimpleSchema {
+
+ public $id;
+ public $username;
+ public $image;
+ public $isself;
+ public $cover;
+ public $friend_count;
+ public $follower_count;
+ public $badges;
+ public $points;
+ public $more_info;
+
+}
diff --git a/easysocial/libraries/schema/message.php b/easysocial/libraries/schema/message.php
new file mode 100644
index 0000000..054e7eb
--- /dev/null
+++ b/easysocial/libraries/schema/message.php
@@ -0,0 +1,42 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class converastionSimpleSchema {
+
+ public $conversion_id;
+ public $created_date;
+ public $lastreplied_date;
+ public $isread;
+ public $messages;
+ public $lapsed;
+ public $participant;
+
+}
+
+class MessageSimpleSchema {
+
+ public $id;
+ public $message;
+ public $attachment;
+ public $created_date;
+ public $created_by;
+ public $lapsed;
+ public $isself;
+
+}
+
+class ReplySimpleSchema {
+
+ public $id;
+ public $created_by;
+ public $reply;
+ public $created_date;
+ public $lapsed;
+
+}
diff --git a/easysocial/libraries/schema/person.php b/easysocial/libraries/schema/person.php
new file mode 100644
index 0000000..14f7042
--- /dev/null
+++ b/easysocial/libraries/schema/person.php
@@ -0,0 +1,22 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class PersonSimpleSchema {
+
+ public $name;
+
+ public $email;
+
+ public $photo;
+
+ public $website;
+
+ public $bio;
+
+}
diff --git a/easysocial/libraries/schema/photos.php b/easysocial/libraries/schema/photos.php
new file mode 100644
index 0000000..414aa5b
--- /dev/null
+++ b/easysocial/libraries/schema/photos.php
@@ -0,0 +1,28 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+class PhotosSimpleSchema {
+ public $id;
+ public $album_id;
+ public $user_id;
+ public $uid;
+ public $type;
+ public $title;
+ public $isowner;
+ public $caption;
+ public $created;
+ public $state;
+ public $assigned_date;
+ public $image_large;
+ public $image_square;
+ public $image_thumbnail;
+ public $image_featured;
+ public $likes;
+ public $comments;
+ public $comment_element;
+}
diff --git a/easysocial/libraries/schema/profile.php b/easysocial/libraries/schema/profile.php
new file mode 100644
index 0000000..d5d85c6
--- /dev/null
+++ b/easysocial/libraries/schema/profile.php
@@ -0,0 +1,34 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+class profileSimpleSchema {
+
+ public $id;
+ public $title;
+ public $raw_content;
+ public $content;
+ public $actor;
+ public $published;
+ public $last_replied;
+ public $likes;
+ public $comment_element;
+ public $comments;
+
+}
+
+class fildsSimpleSchema {
+
+ //public $id;
+ public $title;
+ public $field_id;
+ public $field_name;
+ public $field_value;
+ public $step;
+
+}
+
diff --git a/easysocial/libraries/schema/stream.php b/easysocial/libraries/schema/stream.php
new file mode 100644
index 0000000..cfe9669
--- /dev/null
+++ b/easysocial/libraries/schema/stream.php
@@ -0,0 +1,59 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class streamSimpleSchema {
+
+ public $id;
+ public $title;
+ public $type;
+ public $group;
+ public $element_id;
+ public $preview;
+ public $raw_content_url;
+ public $content;
+ public $actor;
+ public $published;
+ public $last_replied;
+ public $likes;
+ public $comment_element;
+ public $comments;
+ public $share_url;
+ public $stream_url;
+ public $with;
+ public $isPinned;
+
+}
+
+class likesSimpleSchema {
+
+ public $uid;
+ public $type;
+ public $stream_id;
+ public $verb;
+ public $created_by;
+ public $total;
+ //public $hasliked;
+
+}
+
+class commentsSimpleSchema {
+
+ public $uid;
+ public $element;
+ public $element_id;
+ public $comment;
+ public $verb;
+ public $group;
+ public $stream_id;
+ public $created_by;
+ public $created;
+ public $lapsed;
+ public $params;
+
+}
diff --git a/easysocial/libraries/schema/user.php b/easysocial/libraries/schema/user.php
new file mode 100644
index 0000000..81fd8e6
--- /dev/null
+++ b/easysocial/libraries/schema/user.php
@@ -0,0 +1,26 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+class userSimpleSchema {
+
+ public $id;
+ public $username;
+ public $name;
+ public $image;
+ public $isself;
+ public $cover;
+ public $friend_count;
+ public $follower_count;
+ public $badges;
+ public $points;
+ public $more_info;
+ public $isOwner;
+ public $isrequestor;
+
+}
diff --git a/easysocial/libraries/schema/videos.php b/easysocial/libraries/schema/videos.php
new file mode 100644
index 0000000..0ca6f02
--- /dev/null
+++ b/easysocial/libraries/schema/videos.php
@@ -0,0 +1,36 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+class VideoSimpleSchema {
+ public $id;
+ public $title;
+ public $description;
+ public $user_id;
+ public $uid;
+ public $type;
+ public $created;
+ public $state;
+ public $featured;
+ public $category_id;
+ public $hits;
+ public $duration;
+ public $size;
+ public $params;
+ public $storage;
+ public $path;
+ public $original;
+ public $file_title;
+ public $source;
+ public $thumbnail;
+ public $likes;
+ public $comments;
+ public $comment_element;
+ public $message;
+ public $isAdmin;
+}
+?>
diff --git a/easysocial/libraries/uploadHelper.php b/easysocial/libraries/uploadHelper.php
new file mode 100644
index 0000000..8d66c2b
--- /dev/null
+++ b/easysocial/libraries/uploadHelper.php
@@ -0,0 +1,588 @@
+
+ * @link http://www.techjoomla.com
+*/
+defined('_JEXEC') or die('Restricted access');
+
+jimport( 'libraries.schema.group' );
+
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
+require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
+
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/group.php';
+require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/message.php';
+
+require_once JPATH_SITE.'/media/com_easysocial/apps/fields/user/avatar/helper.php';
+require_once JPATH_SITE.'/media/com_easysocial/apps/fields/user/cover/helper.php';
+//require_once JPATH_SITE.'/media/com_easysocial/apps/fields/user/cover/ajax.php';
+
+class EasySocialApiUploadHelper
+{
+ //upload cover photo
+ public function uploadCover($uid = 0,$type=SOCIAL_TYPE_USER)
+ {
+ $result = new stdClass;
+
+ if( !$uid && !$type )
+ {
+ $result->status = 0;
+ $result->message = 'Empty uid / type not allowed for upload';
+ return $result;
+ }
+
+ // Load the photo library now since we have the unique keys
+ $lib = FD::photo( $uid , $type );
+
+ // Check if the user is allowed to upload cover photos
+ if( !$lib->canUploadCovers() )
+ {
+ $result->status = 0;
+ $result->message = 'user not allowed for upload cover';
+ return $result;
+ }
+
+ // Get the current logged in user.
+ $my = FD::user($uid);
+
+ // Set uploader options
+ $options = array( 'name' => 'cover_file' , 'maxsize' => $lib->getUploadFileSizeLimit() );
+
+ // Get uploaded file
+ $file = FD::uploader( $options )->getFile();
+ // Load the image
+ $image = FD::image();
+ $image->load( $file[ 'tmp_name' ] , $file[ 'name' ] );
+
+ // Check if there's a profile photos album that already exists.
+ $model = FD::model( 'Albums' );
+
+ // Retrieve the user's default album
+ $album = $model->getDefaultAlbum( $uid , $type , SOCIAL_ALBUM_PROFILE_COVERS );
+
+ $photo = FD::table( 'Photo' );
+ $photo->uid = $uid;
+ $photo->type = $type;
+ $photo->user_id = $my->id;
+ $photo->album_id = $album->id;
+ $photo->title = $file[ 'name' ];
+ $photo->caption = '';
+ $photo->ordering = 0;
+ $photo->assigned_date = FD::date()->toMySQL();
+
+ // Trigger rules that should occur before a photo is stored
+ $photo->beforeStore( $file , $image );
+
+ // Try to store the photo.
+ $state = $photo->store();
+
+ if( !$state )
+ {
+ $result->status = 0;
+ $result->message = 'unable to create cover file';
+ return $result;
+ }
+
+ // Trigger rules that should occur after a photo is stored
+ //$photo->afterStore( $file , $image );
+
+ // If album doesn't have a cover, set the current photo as the cover.
+ if( !$album->hasCover() )
+ {
+ $album->cover_id = $photo->id;
+
+ // Store the album
+ $album->store();
+ }
+
+ // Render photos library
+ $photoLib = FD::get( 'Photos' , $image );
+ $storage = $photoLib->getStoragePath($album->id, $photo->id);
+ $paths = $photoLib->create($storage);
+
+ // Create metadata about the photos
+ foreach( $paths as $type => $fileName )
+ {
+ $meta = FD::table( 'PhotoMeta' );
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_PATH;
+ $meta->property = $type;
+ $meta->value = $storage . '/' . $fileName;
+
+ $meta->store();
+ }
+
+ // Load the cover
+ $cover = FD::table('Cover');
+ $state = $cover->load(array('uid' => 0, 'type' => $type));
+
+ // Set the cover to pull from photo
+ $cover->setPhotoAsCover($photo->id, 0.5 , 0.5);
+
+ // Save the cover.
+ $cover->store();
+ //return meta data for cover photo object
+ return $photo;
+ }
+ //upload image
+ public function uploadPhoto($log_usr=0,$type=null)
+ {
+ // Get current logged in user.
+ $my = FD::user($log_usr);
+
+ // Get user access
+ $access = FD::access( $my->id , SOCIAL_TYPE_USER );
+
+ // Load up the photo library
+ $lib = FD::photo($log_usr, $type);
+
+ // Define uploader options
+ $options = array( 'name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit() );
+
+ // Get uploaded file
+ $file = FD::uploader($options)->getFile();
+
+ // Load the iamge object
+ $image = FD::image();
+ $image->load( $file[ 'tmp_name' ] , $file[ 'name' ] );
+
+ // Detect if this is a really valid image file.
+ if( !$image->isValid() )
+ {
+ return "invalid image";
+ }
+
+ // Load up the album's model.
+ $albumsModel = FD::model( 'Albums' );
+
+ // Create the default album if necessary
+ $album = $albumsModel->getDefaultAlbum( $log_usr , $type , SOCIAL_ALBUM_STORY_ALBUM );
+
+ // Bind photo data
+ $photo = FD::table( 'Photo' );
+ $photo->uid = '';
+ $photo->type = $type;
+ $photo->user_id = $my->id;
+ $photo->album_id = $album->id;
+ $photo->title = $file[ 'name' ];
+ $photo->caption = '';
+ $photo->ordering = 0;
+
+ // Set the creation date alias
+ $photo->assigned_date = FD::date()->toMySQL();
+
+ // Trigger rules that should occur before a photo is stored
+ $photo->beforeStore( $file , $image );
+
+ // Try to store the photo.
+ $state = $photo->store();
+
+ // Load the photos model
+ $photosModel = FD::model( 'Photos' );
+
+ // Get the storage path for this photo
+ $storage = FD::call( 'Photos' , 'getStoragePath' , array( $album->id , $photo->id ) );
+
+ // Get the photos library
+ $photoLib = FD::get( 'Photos' , $image );
+ $paths = $photoLib->create($storage);
+
+ // Create metadata about the photos
+ if( $paths )
+ {
+ foreach( $paths as $type => $fileName )
+ {
+ $meta = FD::table( 'PhotoMeta' );
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_PATH;
+ $meta->property = $type;
+ $meta->value = $storage . '/' . $fileName;
+
+ $meta->store();
+
+ // We need to store the photos dimension here
+ list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
+
+ // Set the photo dimensions
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_WIDTH;
+ $meta->property = $type;
+ $meta->value = $width;
+ $meta->store();
+
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_HEIGHT;
+ $meta->property = $type;
+ $meta->value = $height;
+ $meta->store();
+ }
+ }
+
+ // After storing the photo, trigger rules that should occur after a photo is stored
+ //$photo->afterStore( $file , $image );
+
+ return $photo;
+ }
+
+ //to create temp group avtar data
+ public function ajax_avatar($file)
+ {
+ // Get the ajax library
+ $ajax = FD::ajax();
+
+ // Load up the image library so we can get the appropriate extension
+ $image = FD::image();
+ $image->load($file['tmp_name']);
+
+ // Copy this to temporary location first
+ $tmpPath = SocialFieldsUserAvatarHelper::getStoragePath( 'file' );
+ $tmpName = md5( $file[ 'name' ] . 'file' . FD::date()->toMySQL()) . $image->getExtension();
+
+ $source = $file['tmp_name'];
+ $target = $tmpPath . '/' . $tmpName;
+ $state = JFile::copy($source, $target);
+
+ $tmpUri = SocialFieldsUserAvatarHelper::getStorageURI('file');
+ $uri = $tmpUri . '/' . $tmpName;
+
+ $ajax->resolve($file, $uri, $target);
+
+ $data = array();
+ $data['temp_path'] = $target;
+ $data['temp_uri'] = $uri;
+
+ return $data;
+ }
+
+ // to create temp group cover data
+ public function ajax_cover($file,$uname='cover_file')
+ {
+ /*
+ $cls_obj = new SocialFieldsUserCover();
+ $cover_obj = $cls_obj->createCover($file,$uname);
+
+ return $cover_obj;
+ */
+
+ // Load our own image library
+ $image = FD::image();
+
+ // Generates a unique name for this image.
+ $name = $file['name'];
+
+ // Load up the file.
+ $image->load($file['tmp_name'], $name);
+
+ // Ensure that the image is valid.
+ if (!$image->isValid()) {
+ return false;
+ //need error code here
+ }
+
+ // Get the storage path
+ $storage = SocialFieldsUserCoverHelper::getStoragePath($uname);
+
+ // Create a new avatar object.
+ $photos = FD::get('Photos', $image);
+
+ // Create avatars
+ $sizes = $photos->create($storage);
+
+ // We want to format the output to get the full absolute url.
+ $base = basename($storage);
+
+ $result = array();
+
+ foreach ($sizes as $size => $value) {
+ $row = new stdClass();
+
+ $row->title = $file['name'];
+ $row->file = $value;
+ $row->path = JPATH_ROOT . '/media/com_easysocial/tmp/' . $base . '/' . $value;
+ $row->uri = rtrim(JURI::root(), '/') . '/media/com_easysocial/tmp/' . $base . '/' . $value;
+
+ $result[$size] = $row;
+ }
+
+ return $result;
+
+ }
+
+ // photo-album image upload function
+ public function albumPhotoUpload($log_usr=0,$type=null,$id)
+ {
+ // Load up the configuration
+ $config = FD::config();
+ // Check if the photos is enabled
+ if (!$config->get('photos.enabled'))
+ {
+ return false;
+ }
+ // Load the album table
+ $album = FD::table( 'Album' );
+ $album->load( $id );
+
+ // Check if the album id provided is valid
+ if (!$album->id || !$album->id)
+ {
+ return false;
+ }
+ // Get the uid and the type
+ $uid = $album->uid;
+ $type = $album->type;
+ // Load the photo library
+ $lib = FD::photo( $uid , $type );
+ // Set uploader options
+ $options = array( 'name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit() );
+ // Get uploaded file
+ $file = FD::uploader( $options )->getFile();
+ // If there was an error getting uploaded file, stop.
+ if ($file instanceof SocialException) {
+ return false;
+ }
+ // Load the image object
+ $image = FD::image();
+ $image->load($file['tmp_name'], $file['name']);
+ // Detect if this is a really valid image file.
+ if (!$image->isValid())
+ {
+ return false;
+ }
+ // Bind the photo data now
+ $photo = FD::table( 'Photo' );
+ $photo->uid = $uid;
+ $photo->type = $type;
+ $photo->user_id = $album->uid;
+ $photo->album_id = $album->id;
+ $photo->title = $file[ 'name' ];
+ $photo->caption = '';
+ $photo->ordering = 0;
+ $photo->state = SOCIAL_STATE_PUBLISHED;
+
+ // Set the creation date alias
+ $photo->assigned_date = FD::date()->toMySQL();
+ // Cleanup photo title.
+ $photo->cleanupTitle();
+ // Trigger rules that should occur before a photo is stored
+ $photo->beforeStore($file , $image);
+
+ // Try to store the photo.
+ $state = $photo->store();
+
+ if (!$state)
+ {
+ return false;
+ }
+ // If album doesn't have a cover, set the current photo as the cover.
+ if (!$album->hasCover())
+ {
+ $album->cover_id = $photo->id;
+ // Store the album
+ $album->store();
+ }
+ // Get the photos library
+ $photoLib = FD::get('Photos', $image);
+ // Get the storage path for this photo
+ $storageContainer = FD::cleanPath($config->get('photos.storage.container'));
+ $storage = $photoLib->getStoragePath($album->id, $photo->id);
+ $paths = $photoLib->create($storage);
+
+ // We need to calculate the total size used in each photo (including all the variants)
+ $totalSize = 0;
+
+ // Create metadata about the photos
+ if($paths) {
+
+ foreach ($paths as $type => $fileName) {
+ $meta = FD::table( 'PhotoMeta' );
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_PATH;
+ $meta->property = $type;
+ // do not store the container path as this path might changed from time to time
+ $tmpStorage = str_replace('/' . $storageContainer . '/', '/', $storage);
+ $meta->value = $tmpStorage . '/' . $fileName;
+ $meta->store();
+
+ // We need to store the photos dimension here
+ list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
+
+ // Set the photo size
+ $totalSize += filesize(JPATH_ROOT . $storage . '/' . $fileName);
+
+ // Set the photo dimensions
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_WIDTH;
+ $meta->property = $type;
+ $meta->value = $width;
+ $meta->store();
+
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_HEIGHT;
+ $meta->property = $type;
+ $meta->value = $height;
+ $meta->store();
+ }
+ }
+
+ // Set the total photo size
+ $photo->total_size = $totalSize;
+ $photo->store();
+
+ // After storing the photo, trigger rules that should occur after a photo is stored
+ $photo->afterStore($file, $image);
+
+ // Determine if we should create a stream item for this upload
+ $createStream = JRequest::getBool( 'createStream' );
+
+ // Add Stream when a new photo is uploaded
+ if ($createStream) {
+ $photo->addPhotosStream( 'create' );
+ }
+ // After storing the photo, trigger rules that should occur after a photo is stored
+ return $photo;
+ }
+
+ //add photos in album.
+
+ public function addPhotoAlbum($log_usr=0,$album_id)
+ {
+ $my = FD::user();
+ // Load up the configuration
+ $config = FD::config();
+
+ // Load the album table
+ $album = FD::table( 'Album' );
+ $album->load( $album_id );
+ // Check if the album id provided is valid
+ if (!$album->id || !$album->id) {
+ return "album not valid";
+ }
+
+ // Get the uid and the type
+ $uid = $album->uid;
+ $type = $album->type;
+
+ // Load the photo library
+ $lib = FD::photo( $uid , $type );
+
+ // Set uploader options
+ $options = array( 'name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit() );
+
+ // Get uploaded file
+ $file = FD::uploader( $options )->getFile();
+ // If there was an error getting uploaded file, stop.
+ if ($file instanceof SocialException) {
+ return false;
+ }
+ // Load the image object
+ $image = FD::image();
+ $image->load($file['tmp_name'], $file['name']);
+ // Detect if this is a really valid image file.
+ if (!$image->isValid()) {
+ return false;
+ }
+ // Bind the photo data now
+ $photo = FD::table( 'Photo' );
+ $photo->uid = $uid;
+ $photo->type = $type;
+ $photo->user_id = $album->uid;
+ $photo->album_id = $album->id;
+ $photo->title = $file[ 'name' ];
+ $photo->caption = '';
+ $photo->ordering = 0;
+ $photo->state = SOCIAL_STATE_PUBLISHED;
+ // Set the creation date alias
+ $photo->assigned_date = FD::date()->toMySQL();
+ // Cleanup photo title.
+ $photo->cleanupTitle();
+
+ // Trigger rules that should occur before a photo is stored
+ $photo->beforeStore($file , $image);
+ // Try to store the photo.
+ $state = $photo->store();
+ if (!$state) {
+ return false;
+ }
+ // If album doesn't have a cover, set the current photo as the cover.
+ //~ if (!$album->hasCover()) {
+ //~ $album->cover_id = $photo->id;
+//~
+ //~ // Store the album
+ //~ $album->store();
+ //~ }
+ // Get the photos library
+ $photoLib = FD::get('Photos', $image);
+
+ // Get the storage path for this photo
+ $storageContainer = FD::cleanPath($config->get('photos.storage.container'));
+ $storage = $photoLib->getStoragePath($album->id, $photo->id);
+ $paths = $photoLib->create($storage);
+
+ // We need to calculate the total size used in each photo (including all the variants)
+ $totalSize = 0;
+ // Create metadata about the photos
+ if($paths) {
+
+ foreach ($paths as $type => $fileName) {
+ $meta = FD::table( 'PhotoMeta' );
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_PATH;
+ $meta->property = $type;
+ // do not store the container path as this path might changed from time to time
+ $tmpStorage = str_replace('/' . $storageContainer . '/', '/', $storage);
+ $meta->value = $tmpStorage . '/' . $fileName;
+ $meta->store();
+
+ // We need to store the photos dimension here
+ list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
+
+ // Set the photo size
+ $totalSize += filesize(JPATH_ROOT . $storage . '/' . $fileName);
+
+ // Set the photo dimensions
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_WIDTH;
+ $meta->property = $type;
+ $meta->value = $width;
+ $meta->store();
+
+ $meta = FD::table('PhotoMeta');
+ $meta->photo_id = $photo->id;
+ $meta->group = SOCIAL_PHOTOS_META_HEIGHT;
+ $meta->property = $type;
+ $meta->value = $height;
+ $meta->store();
+ }
+ }
+ // Set the total photo size
+ $photo->total_size = $totalSize;
+ $photo->store();
+
+ // After storing the photo, trigger rules that should occur after a photo is stored
+ $photo->afterStore($file, $image);
+
+ // Determine if we should create a stream item for this upload
+ $createStream = JRequest::getBool( 'createStream' );
+
+ // Add Stream when a new photo is uploaded
+ if ($createStream) {
+ $photo->addPhotosStream( 'create' );
+ }
+ if ($isAvatar) {
+ return $photo;
+ }
+ // After storing the photo, trigger rules that should occur after a photo is stored
+ return $photo;
+ }
+
+}
diff --git a/jticketing/en-GB/en-GB.plg_api_jticket.ini b/jticketing/en-GB/en-GB.plg_api_jticket.ini
deleted file mode 100644
index ee4273e..0000000
--- a/jticketing/en-GB/en-GB.plg_api_jticket.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-COM_JTICKETING_SELECT_GET_METHOD="Please use GET method."
-COM_JTICKETING_WRONG_METHOD_PUT="Put method not supported to this plugin."
-COM_JTICKETING_WRONG_METHOD_DEL="Delete method not supported to this plugin."
-COM_JTICKETING_INVALID_TICKET="Invalid ticket."
-COM_JTICKETING_INVALID_EVENT="Event not found."
diff --git a/jticketing/jticket.php b/jticketing/jticket.php
index 30d177b..fe66970 100644
--- a/jticketing/jticket.php
+++ b/jticketing/jticket.php
@@ -1,51 +1,67 @@
- * @link http://www.techjoomla.com
-*/
-
-defined('_JEXEC') or die( 'Restricted access' );
-
+ * @version SVN:
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
+defined('_JEXEC') or die( 'Restricted access');
jimport('joomla.plugin.plugin');
-class plgAPIJticket extends ApiPlugin
+/**
+ * Base Class for api plugin
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
+class PlgAPIJticket extends ApiPlugin
{
- public function __construct()
+ /**
+ * Jticketing api plugin to load com_api classes
+ *
+ * @param string $subject originalamount
+ * @param array $config coupon_code
+ *
+ * @since 1.0
+ */
+ public function __construct($subject, $config = array())
{
- parent::__construct();
+ parent::__construct($subject, $config = array());
+
// Load all required helpers.
- $component_path=JPATH_ROOT.DS.'components'.DS.'com_jticketing';
- if(!file_exists($component_path))
+ $component_path = JPATH_ROOT . '/components/com_jticketing';
+
+ if (!file_exists($component_path))
{
return;
}
- $jticketingmainhelperPath = JPATH_ROOT.DS.'components'.DS.'com_jticketing'.DS.'helpers'.DS.'main.php';
+ $jticketingmainhelperPath = JPATH_ROOT . '/components/com_jticketing/helpers/main.php';
if (!class_exists('jticketingmainhelper'))
{
- JLoader::register('jticketingmainhelper', $jticketingmainhelperPath );
+ JLoader::register('jticketingmainhelper', $jticketingmainhelperPath);
JLoader::load('jticketingmainhelper');
}
- $jticketingfrontendhelper = JPATH_ROOT.DS.'components'.DS.'com_jticketing'.DS.'helpers'.DS.'frontendhelper.php';
+ $jticketingfrontendhelper = JPATH_ROOT . '/components/com_jticketing/helpers/frontendhelper.php';
if (!class_exists('jticketingfrontendhelper'))
{
- JLoader::register('jticketingfrontendhelper', $jticketingfrontendhelper );
+ JLoader::register('jticketingfrontendhelper', $jticketingfrontendhelper);
JLoader::load('jticketingfrontendhelper');
}
- $jteventHelperPath = JPATH_ROOT.DS.'components'.DS.'com_jticketing'.DS.'helpers'.DS.'event.php';
+ $jteventHelperPath = JPATH_ROOT . '/components/com_jticketing/helpers/event.php';
if (!class_exists('jteventHelper'))
{
- JLoader::register('jteventHelper', $jteventHelperPath );
+ JLoader::register('jteventHelper', $jteventHelperPath);
JLoader::load('jteventHelper');
}
- ApiResource::addIncludePath(dirname(__FILE__).'/jticket');
+ ApiResource::addIncludePath(dirname(__FILE__) . '/jticket');
}
}
diff --git a/jticketing/jticket.xml b/jticketing/jticket.xml
index 07783bc..8089baf 100644
--- a/jticketing/jticket.xml
+++ b/jticketing/jticket.xml
@@ -1,21 +1,29 @@
-
- Api - Jticketing
- 1.6
- 10/11/2014
- Techjoomla
- extensions@techjoomla.com
- www.techjoomla.com
- Techjoomla. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- API plugins of Jticketing components of the Joomla!
-
-
- jticket.php
- jticket/checkin.php
- jticket
-
-
- en-GB/en-GB.plg_api_jticket.ini
+
+ Api - Jticketing
+ 1.7.2
+ 12th Feb 2016
+ Tekdi
+ support@tekdi.com
+ http://www.tekdi.com
+ 2012 users
+ GNU General Public License v2
+ API plugins of Jticketing components of the Joomla!
+
+ jticket.php
+ jticket/checkin.php
+ jticket
+
+
+ language/en-GB/en-GB.plg_api_jticket.ini
+
+
+
+
+
+
diff --git a/jticketing/jticket/checkin.php b/jticketing/jticket/checkin.php
index e0c6ee7..4ece40a 100644
--- a/jticketing/jticket/checkin.php
+++ b/jticketing/jticket/checkin.php
@@ -1,152 +1,224 @@
- * @link http://www.techjoomla.com
-*/
+ * @version SVN:
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
defined('_JEXEC') or die;
-
jimport('joomla.plugin.plugin');
-
+/**
+ * Class for checkin to tickets for mobile APP
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
class JticketApiResourceCheckin extends ApiResource
{
+ /**
+ * Checkin to tickets for mobile APP
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function get()
{
- jimport( 'joomla.application.component.helper' );
- $send_email_after_checkin=0;
- $com_params=JComponentHelper::getParams('com_jticketing');
- $send_email_after_checkin = $com_params->get('send_email_after_checkin');
- $jticketingmainhelper = new jticketingmainhelper();
- $lang =JFactory::getLanguage();
- $extension = 'com_jticketing';
- $base_dir = JPATH_SITE;
+ $this->plugin->setResponse('Get method not allow, Use post method.');
+ }
+
+ /**
+ * Checkin to tickets for mobile APP
+ *
+ * @return json event details
+ *
+ * @since 1.0
+ */
+ public function post()
+ {
+ jimport('joomla.application.component.helper');
+ $com_params = JComponentHelper::getParams('com_jticketing');
+ $jticketingmainhelper = new jticketingmainhelper;
+ $lang = JFactory::getLanguage();
+ $extension = 'com_jticketing';
+ $base_dir = JPATH_SITE;
$lang->load($extension, $base_dir);
- $ticketidstr = JRequest::getVar('ticketid',0);
- $eventid = JRequest::getVar('eventid',0);
- $eventintegrationid=$jticketingmainhelper->getEventrefid($eventid);
+ $input = JFactory::getApplication()->input;
+ $ticketidstr_arr = $input->get('ticketid', array(), 'ARRAY');
+ $eventid = $input->get('eventid', '0', 'INT');
+ $eventintegrationid = $jticketingmainhelper->getEventrefid($eventid);
+ $obj = new stdClass;
+ $result_arr = array();
+ $attendee_details = array();
+
+ foreach ($ticketidstr_arr as $ky => $ticketidstr)
+ {
+ if (empty($ticketidstr))
+ {
+ $obj->success = 0;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_TICKET");
+ $this->plugin->setResponse($obj);
- if(empty($ticketidstr))
- {
- $obj->success = 0;
- $obj->message =JText::_("COM_JTICKETING_INVALID_TICKET");
- $this->plugin->setResponse($obj);
- return;
+ return;
+ }
+ $ticketidarr = explode('-', $ticketidstr);
+ $oid = $ticketidarr[0];
+ $orderitemsid = $ticketidarr[1];
- }
+ // Vishal -adjustment for random change in ticket id
+ if (count($ticketidarr) > 2)
+ {
+ $oid = $ticketidarr[1];
+ $orderitemsid = $ticketidarr[2];
+ }
- $ticketidarr=explode('-',$ticketidstr);
- $oid=$ticketidarr[0];
- $orderitemsid=$ticketidarr[1];
- $obj = new stdClass();
+ $result = $jticketingmainhelper->GetActualTicketidAPI($oid, $orderitemsid, '');
+ $originalticketid = JText::_("TICKET_PREFIX") . $ticketidstr;
- $result=$jticketingmainhelper->GetActualTicketidAPI($oid,$orderitemsid,'');
- $originalticketid=JText::_("TICKET_PREFIX").$ticketidstr;
+ if (empty($result))
+ {
+ $obj->ticket_id = $ticketidstr;
+ $obj->success = 0;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_TICKET");
+ $result_arr[$ky] = $obj;
+ continue;
+ }
+ elseif ($result[0]->attendee_id)
+ {
+ $field_array = array('first_name', 'last_name');
- if($result[0]->attendee_id)
- {
- $field_array=array('first_name','last_name');
- //Get Attendee Details
- $attendee_details=$jticketingmainhelper->getAttendees_details($result[0]->attendee_id,$field_array);
- }
+ // Get Attendee Details
+ $attendee_details = $jticketingmainhelper->getAttendees_details($result[0]->attendee_id, $field_array);
+ }
- if(!empty($attendee_details['first_name']))
- {
- $attendernm=implode(" ",$attendee_details);
- }
- else
- {
- $attendernm=$result[0]->name;
+ if (!empty($attendee_details['first_name']))
+ {
+ $attendernm = implode(" ", $attendee_details);
+ }
+ else
+ {
+ $attendernm = $result[0]->name;
+ }
+
+ if (empty($result) || ($result[0]->eventid != $eventintegrationid))
+ {
+ $obj->success = 0;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_TICKET_OTHER_EVENT");
+ $result_arr[$ky] = $obj;
+ continue;
+ }
+ else
+ {
+ $result_arr[] = $this->checkTickets($orderitemsid, $attendernm, $originalticketid, $result, $oid, $eventid);
+ }
}
- if(empty($result))
- {
- $obj->success = 0;
- $obj->message =JText::_("COM_JTICKETING_INVALID_TICKET");
+ $this->plugin->setResponse($result_arr);
+ }
- }
- else if($result[0]->eventid!=$eventintegrationid)
- {
- $obj->success = 0;
- $obj->message =JText::_("COM_JTICKETING_INVALID_TICKET");
- }
- else
- {
- $checkindone=$jticketingmainhelper->GetCheckinStatusAPI($orderitemsid);
- if($checkindone)
+ /**
+ * Checkin to tickets for mobile APP
+ *
+ *
+ *
+ * @since 1.0
+ */
+
+ /**
+ * Checkin to tickets for mobile APP
+ *
+ * @param integer $orderitemsid orderitemsid
+ * @param string $attendernm attendernm
+ * @param string $originalticketid originalticketid
+ * @param string $result result
+ * @param string $oid oid
+ * @param integer $eventid eventid
+ *
+ * @return json event details
+ *
+ * @since 1.0
+ */
+ Public function checkTickets($orderitemsid, $attendernm, $originalticketid, $result, $oid, $eventid)
+ {
+ $jticketingmainhelper = new jticketingmainhelper;
+ $obj = new stdClass;
+ $send_email_after_checkin = 0;
+ $com_params = JComponentHelper::getParams('com_jticketing');
+ $send_email_after_checkin = $com_params->get('send_email_after_checkin');
+
+ $checkindone = $jticketingmainhelper->GetCheckinStatusAPI($orderitemsid, $eventid);
+
+ if ($checkindone)
{
- $obj->success = 0;
- if($attendernm)
- $obj->message =sprintf(JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE'),$attendernm);
- else
- $obj->message =JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE');
+ $obj->success = 0;
+ if ($attendernm)
+ {
+ $obj->message = sprintf(JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE'), $attendernm);
+ }
+ else
+ {
+ $obj->message = JText::_('COM_JTICKETING_CHECKIN_FAIL_DUPLICATE');
+ }
}
else
{
+ $items_checkin = array($orderitemsid);
+ $JticketingModelattendee_List = JPATH_ROOT . '/components/com_jticketing/models/attendee_list.php';
- $obj->success = $jticketingmainhelper->DoCheckinAPI($orderitemsid,$result);
+ if (!class_exists('JticketingModelattendee_List'))
+ {
+ JLoader::register('JticketingModelattendee_List', $JticketingModelattendee_List);
+ JLoader::load('JticketingModelattendee_List');
+ }
+
+ $JticketingModelattendee_List = new JticketingModelattendee_List;
+ $obj->success = $JticketingModelattendee_List->setItemState_checkin($items_checkin, 1);
- if($obj->success)
+ if ($obj->success)
{
- $obj->success = 1;
- $ticketTypeData=$jticketingmainhelper->GetTicketTypes('',$result[0]->type_id);
- $app =JFactory::getApplication();
- $mailfrom = $app->getCfg('mailfrom');
- $fromname = $app->getCfg('fromname');
- $sitename = $app->getCfg('sitename');
- $message=JText::_("CHECKIN_MESSAGE");
- $message_subject=JText::_("CHECKIN_SUBJECT");
- $eventnm=$jticketingmainhelper->getEventTitle($oid);
- $message_subject= stripslashes($message_subject);
- $message_subject = str_replace("[EVENTNAME]", $eventnm,$message_subject);
-
- $message_body = stripslashes($message);
- $message_body = str_replace("[EVENTNAME]", $eventnm,$message_body);
- $message_body = str_replace("[NAME]", $attendernm,$message_body);
- $message_body = str_replace("[TICKETID]", $originalticketid,$message_body);
- $message_body = str_replace("[TICKET_TYPE_TITLE]", $ticketTypeData[0]->title,$message_body);
-
-
- if($send_email_after_checkin)
+ $obj->success = 1;
+
+ $ticketTypeData = $jticketingmainhelper->GetTicketTypes('', $result[0]->type_id);
+ $app = JFactory::getApplication();
+ $mailfrom = $app->getCfg('mailfrom');
+ $fromname = $app->getCfg('fromname');
+ $sitename = $app->getCfg('sitename');
+ $message = JText::_("CHECKIN_MESSAGE");
+ $message_subject = JText::_("CHECKIN_SUBJECT");
+ $eventnm = $jticketingmainhelper->getEventTitle($oid);
+ $message_subject = stripslashes($message_subject);
+ $message_subject = str_replace("[EVENTNAME]", $eventnm, $message_subject);
+ $message_body = stripslashes($message);
+ $message_body = str_replace("[EVENTNAME]", $eventnm, $message_body);
+ $message_body = str_replace("[NAME]", $attendernm, $message_body);
+ $message_body = str_replace("[TICKETID]", $originalticketid, $message_body);
+ $message_body = str_replace("[TICKET_TYPE_TITLE]", $ticketTypeData[0]->title, $message_body);
+
+ if ($send_email_after_checkin)
{
- $result=JFactory::getMailer()->sendMail($fromname,$mailfrom,$result[0]->email,$message_subject,$message_body,$html=1,null,null,'');
+ $result = JFactory::getMailer()->sendMail($fromname, $mailfrom, $result[0]->email, $message_subject, $message_body, $html = 1, null, null, '');
}
}
- if($attendernm and $ticketTypeData[0]->title and $originalticketid)
+ if ($attendernm and $ticketTypeData[0]->title and $originalticketid)
{
- $obj->message =sprintf(JText::_('COM_JTICKETING_CHECKIN_SUCCESS'),$attendernm,$ticketTypeData[0]->title,$originalticketid);
+ $obj->ticket_id = $originalticketid;
+ $obj->message = sprintf(JText::_('COM_JTICKETING_CHECKIN_SUCCESS'), $attendernm, $ticketTypeData[0]->title, $originalticketid);
}
else
{
- $obj->message =JText::_('COM_JTICKETING_CHECKIN_SUCCESS');
-
+ $obj->ticket_id = $originalticketid;
+ $obj->message = JText::_('COM_JTICKETING_CHECKIN_SUCCESS');
}
}
- }
- $this->plugin->setResponse($obj);
+ return $obj;
}
-
- /**
- * This is not the best example to follow
- * Please see the category plugin for a better example
- */
- public function post()
- {
-
-
- }
-
- public function put()
- {
-
- }
-
-
}
diff --git a/jticketing/jticket/getattendeelist.php b/jticketing/jticket/getattendeelist.php
index a0f0358..7c050bc 100644
--- a/jticketing/jticket/getattendeelist.php
+++ b/jticketing/jticket/getattendeelist.php
@@ -1,129 +1,172 @@
- * @link http://www.techjoomla.com
-*/
+ * @version SVN:
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
defined('_JEXEC') or die;
-
jimport('joomla.plugin.plugin');
+/**
+ * Class for get attendee list based on event id
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
class JticketApiResourcegetAttendeelist extends ApiResource
{
+ /**
+ * Get Event attendee list based on event id
+ *
+ * @return json event details
+ *
+ * @since 1.0
+ */
public function get()
{
- $this->plugin->setResponse($this->getattendee());
- }
-
- public function post()
- {
- $this->plugin->setResponse($this->getattendee());
- }
-
- public function getattendee()
- {
- $lang =JFactory::getLanguage();
+ $lang = JFactory::getLanguage();
$extension = 'com_jticketing';
- $base_dir = JPATH_SITE;
- $jinput = JFactory::getApplication()->input;
-
+ $base_dir = JPATH_SITE;
$lang->load($extension, $base_dir);
+ $input = JFactory::getApplication()->input;
+ $eventid = $input->get('eventid', '0', 'INT');
+ $var['attendtype'] = $input->get('attendtype', 'all', 'STRING');
+ $var['tickettypeid'] = $input->get('tickettypeid', '0', 'INT');
+ $jticketingmainhelper = new jticketingmainhelper;
- $eventid = $jinput->get('eventid',0,'INT');
- $var['attendtype'] = $jinput->get('attendtype','all','CMD');
- $var['tickettypeid'] = $jinput->get('tickettypeid','0','INT');
-
- $jticketingmainhelper = new jticketingmainhelper();
- if(empty($eventid) OR empty($var))
- {
- $obj->success = 0;
- $obj->message =JText::_("COM_JTICKETING_INVALID_EVENT");
- return $obj;
- }
- $results=$jticketingmainhelper->GetOrderitemsAPI($eventid,$var);
- if(empty($results))
+ if (empty($eventid) OR empty($var))
+ {
+ $obj->success = 0;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
+ $this->plugin->setResponse($obj);
+
+ return;
+ }
+
+ $results = $jticketingmainhelper->GetOrderitemsAPI($eventid, $var);
+
+ if (empty($results))
{
$obj->success = "0";
- $obj->data = JText::_("COM_JTICKETING_INVALID_TICKET");;
- return $obj;
+ $obj->data = JText::_("COM_JTICKETING_INVALID_TICKET");
+ $this->plugin->setResponse($obj);
+
+ return;
}
- if($eventid)
+ if ($eventid)
{
$data = array();
- foreach($results as &$orderitem)
+
+ foreach ($results as &$orderitem)
{
- $obj = new stdClass();
- if($orderitem->attendee_id)
+ $obj = new stdClass;
+
+ if ($orderitem->attendee_id)
{
- $field_array=array('first_name','last_name');
- //Get Attendee Details
- $attendee_details=$jticketingmainhelper->getAttendees_details($orderitem->attendee_id,$field_array);
+ $field_array = array(
+ 'first_name',
+ 'last_name'
+ );
+
+ // Get Attendee Details
+ $attendee_details = $jticketingmainhelper->getAttendees_details($orderitem->attendee_id, $field_array);
}
- if(!empty($attendee_details['first_name']))
+
+ if (!empty($attendee_details['first_name']))
{
- $buyername=implode(" ",$attendee_details);
+ $buyername = implode(" ", $attendee_details);
}
else
{
- $buyername=$orderitem->name;
+ $buyername = $orderitem->name;
}
- $obj->checkin = $jticketingmainhelper->GetCheckinStatusAPI($orderitem->order_items_id);
- $obj->ticketid = $orderitem->oid.'-'.$orderitem->order_items_id;
+ $obj->checkin = $jticketingmainhelper->GetCheckinStatusAPI($orderitem->order_items_id);
+ $obj->ticketid = $orderitem->oid . '-' . $orderitem->order_items_id;
+ $obj->attendee_nm = strtolower($buyername);
+ $obj->tickettypeid = $orderitem->tickettypeid;
+ $obj->ticket_type_title = $orderitem->ticket_type_title;
+ $obj->event_title = $orderitem->event_title;
+ $obj->ticket_prefix = JText::_("TICKET_PREFIX");
- $obj->attendee_nm =strtolower($buyername);
- $obj->tickettypeid=$orderitem->tickettypeid;
- $obj->ticket_type_title =$orderitem->ticket_type_title;
- $obj->event_title = $orderitem->event_title;
- $obj->ticket_prefix=JText::_("TICKET_PREFIX");
-
- /*if($var['attendtype']=="all")
+ if ($var['attendtype'] == "all")
{
$data[] = $obj;
}
- else if($var['attendtype']=="attended" && $obj->checkin==1)
+ elseif ($var['attendtype'] == "attended" && $obj->checkin == 1)
{
$data[] = $obj;
}
- else if($var['attendtype']=="notattended" && $obj->checkin==0)
+ elseif ($var['attendtype'] == "notattended" && $obj->checkin == 0)
{
$data[] = $obj;
- }*/
- $data[] = $obj;
+ }
}
- $fobj = new stdClass();
+ $fobj = new stdClass;
$fobj->success = "1";
- $fobj->total = count($data);
- $fobj->data = $data;
- }
+ $fobj->total = count($data);
+ $fobj->data = $data;
+ }
else
{
$fobj->success = "0";
- $fobj->data = JText::_("COM_JTICKETING_INVALID_TICKET");
+ $fobj->data = JText::_("COM_JTICKETING_INVALID_TICKET");
}
- return $fobj;
+ $this->plugin->setResponse($fobj);
}
+ /**
+ * Post Method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
+ public function post()
+ {
+ $obj = new stdClass;
+ $obj->success = 0;
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
+ $this->plugin->setResponse($obj);
+ }
+
+ /**
+ * Put method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function put()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_PUT");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
+
+ /**
+ * Delete method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function delete()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_DEL");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
-
}
diff --git a/jticketing/jticket/geteventdetails.php b/jticketing/jticket/geteventdetails.php
index c0347f4..896b83a 100644
--- a/jticketing/jticket/geteventdetails.php
+++ b/jticketing/jticket/geteventdetails.php
@@ -1,154 +1,193 @@
- * @link http://www.techjoomla.com
-*/
+ * @version SVN:
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
defined('_JEXEC') or die;
-
jimport('joomla.plugin.plugin');
-
+/**
+ * Class for getting ticket list which are chekin or not checkin
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
class JticketApiResourceGeteventdetails extends ApiResource
{
+ /**
+ * Get Event details based on event id
+ *
+ * @return json event details
+ *
+ * @since 1.0
+ */
public function get()
{
- $this->plugin->setResponse($this->getEvents());
- }
-
- public function post()
- {
- $this->plugin->setResponse($this->getEvents());
- }
-
- public function getEvents()
- {
- $jinput = JFactory::getApplication()->input;
- $com_params=JComponentHelper::getParams('com_jticketing');
- //0 Jomsocial 1/Native 3 JEvents
- $integration = $com_params->get('integration');
- $extension = 'com_jticketing';
- $base_dir = JPATH_SITE;
-
- $jticketingmainhelper = new jticketingmainhelper();
- $lang = JFactory::getLanguage();
+ $com_params = JComponentHelper::getParams('com_jticketing');
+ $integration = $com_params->get('integration');
+ $lang = JFactory::getLanguage();
+ $extension = 'com_jticketing';
+ $base_dir = JPATH_SITE;
+ $jticketingmainhelper = new jticketingmainhelper;
$lang->load($extension, $base_dir);
-
- $eventid = $jinput->get('eventid',0,'INT');
+ $input = JFactory::getApplication()->input;
+ $eventid = $input->get('eventid', '0', 'INT');
+ $userid = $input->get('userid', '', 'INT');
- if(empty($eventid))
- {
+ if (empty($eventid))
+ {
$obj->success = 0;
- $obj->message =JText::_("COM_JTICKETING_INVALID_EVENT");
- return $obj;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
+ $this->plugin->setResponse($obj);
+
+ return;
}
- $eventdatapaid = $jticketingmainhelper->GetUserEventsAPI('',$eventid);
- $eveidarr=array();
+ $eventdatapaid = $jticketingmainhelper->GetUserEventsAPI('', $eventid);
+ $eveidarr = array();
- if($eventdatapaid)
+ if ($eventdatapaid)
{
- foreach($eventdatapaid as &$eventdata)
+ foreach ($eventdatapaid as &$eventdata)
{
- $eveidarr[]=$eventdata->id;
- $eventdata->totaltickets= $jticketingmainhelper->GetTicketcount($eventdata->id);
+ $eveidarr[] = $eventdata->id;
+ $eventdata->totaltickets = $jticketingmainhelper->GetTicketcount($eventdata->id);
}
}
- $eventdataunpaid= $jticketingmainhelper->GetUser_unpaidEventsAPI($userid,$eveidarr,$eventid);
+ $eventdataunpaid = $jticketingmainhelper->GetUser_unpaidEventsAPI($eventid, $userid, $eveidarr);
- if($eventdataunpaid )
+ if ($eventdataunpaid)
{
- foreach($eventdataunpaid as &$eventdata3)
+ foreach ($eventdataunpaid as &$eventdata3)
{
- $eventdata3->totaltickets= $jticketingmainhelper->GetTicketcount($eventdata3->id);
- $eventdata3->soldtickets=0;
- $eventdata3->checkin=0;
+ $eventdata3->totaltickets = $jticketingmainhelper->GetTicketcount($eventdata3->id);
+ $eventdata3->soldtickets = 0;
+ $eventdata3->checkin = 0;
}
}
- if($eventdatapaid and $eventdataunpaid)
+ if ($eventdatapaid and $eventdataunpaid)
{
- $obj_merged =array_merge((array) $eventdatapaid, (array) $eventdataunpaid);
+ $obj_merged = array_merge((array) $eventdatapaid, (array) $eventdataunpaid);
}
- else if($eventdatapaid and empty($eventdataunpaid))
+ elseif ($eventdatapaid and empty($eventdataunpaid))
{
- $obj_merged=(array)$eventdatapaid;
+ $obj_merged = (array) $eventdatapaid;
}
- else if($eventdataunpaid and empty($eventdatapaid))
+ elseif ($eventdataunpaid and empty($eventdatapaid))
{
- $obj_merged=(array)$eventdataunpaid;
+ $obj_merged = (array) $eventdataunpaid;
}
- $obj = new stdClass();
- if($obj_merged)
+ $obj = new stdClass;
+
+ if ($obj_merged)
{
- $config = JFactory::getConfig();
- $return=$jticketingmainhelper->getTimezoneString($eventdata->id);
- $obj_merged[0]->startdate=$return['startdate'];
- $obj_merged[0]->enddate=$return['enddate'];
- $datetoshow=$return['startdate'].'-'.$return['enddate'];
- if(!empty($return['eventshowtimezone']))
- $datetoshow.='
'.$return['eventshowtimezone'];
-
- if($obj_merged[0]->avatar)
+ $config = JFactory::getConfig();
+ $return = $jticketingmainhelper->getTimezoneString($eventdata->id);
+ $obj_merged[0]->startdate = $return['startdate'];
+ $obj_merged[0]->enddate = $return['enddate'];
+ $datetoshow = $return['startdate'] . '-' . $return['enddate'];
+
+ if (!empty($return['eventshowtimezone']))
+ {
+ $datetoshow .= '
' . $return['eventshowtimezone'];
+ }
+
+ if (isset($obj_merged[0]->avatar))
+ {
+ if ($integration == 2)
{
- if($integration==2)
- {
- $obj_merged[0]->avatar=JURI::base().'media/com_jticketing/images/'.$obj_merged[0]->avatar;
- }
- else
- {
- $obj_merged[0]->avatar=JURI::base().$obj_merged[0]->avatar;
- }
+ $obj_merged[0]->avatar = JUri::base() . 'media/com_jticketing/images/' . $obj_merged[0]->avatar;
}
+ else
+ {
+ $obj_merged[0]->avatar = JUri::base() . $obj_merged[0]->avatar;
+ }
+ }
else
- $obj_merged[0]->avatar='';
- if(empty($obj_merged[0]->soldtickets))
{
- $obj_merged[0]->soldtickets=0;
+ $obj_merged[0]->avatar = '';
}
- if(empty($obj_merged[0]->totaltickets))
+ if (empty($obj_merged[0]->soldtickets))
{
- $obj_merged[0]->totaltickets=0;
+ $obj_merged[0]->soldtickets = 0;
}
- if(empty($obj_merged[0]->checkin))
+ if (empty($obj_merged[0]->totaltickets))
{
- $obj_merged[0]->checkin=0;
+ $obj_merged[0]->totaltickets = 0;
}
- $obj->success = "1";
- $obj->data =$obj_merged;
+ if (empty($obj_merged[0]->checkin))
+ {
+ $obj_merged[0]->checkin = 0;
+ }
+ $obj->success = "1";
+ $obj->data = $obj_merged;
}
else
{
$obj->success = "0";
- $obj->data = JText::_("COM_JTICKETING_NO_EVENT_DATA");
+ $obj->data = JText::_("COM_JTICKETING_NO_EVENT_DATA");
}
- return $obj;
+ $this->plugin->setResponse($obj);
+ }
+
+ /**
+ * Post Method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
+ public function post()
+ {
+ $obj = new stdClass;
+ $obj->success = 0;
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
+ $this->plugin->setResponse($obj);
}
+ /**
+ * Put method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function put()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_PUT");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
+
+ /**
+ * Delete method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function delete()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_DEL");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
-
}
diff --git a/jticketing/jticket/getticketlist.php b/jticketing/jticket/getticketlist.php
index dc553d5..f186e0c 100644
--- a/jticketing/jticket/getticketlist.php
+++ b/jticketing/jticket/getticketlist.php
@@ -1,123 +1,163 @@
- * @link http://www.techjoomla.com
-*/
+ * @version SVN:
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
defined('_JEXEC') or die;
-
jimport('joomla.plugin.plugin');
+/**
+ * Class for getting ticket list which are chekin or not checkin
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
class JticketApiResourceGetticketlist extends ApiResource
{
+ /**
+ * Get Ticket list
+ *
+ * @return json ticket list list
+ *
+ * @since 1.0
+ */
public function get()
{
- $this->plugin->setResponse($this->getTicket());
- }
-
- public function post()
- {
- $this->plugin->setResponse($this->getTicket());
- }
-
- public function getTicket()
- {
- $lang =JFactory::getLanguage();
+ $lang = JFactory::getLanguage();
$extension = 'com_jticketing';
- $base_dir = JPATH_SITE;
- $jinput = JFactory::getApplication()->input;
-
+ $base_dir = JPATH_SITE;
+ $input = JFactory::getApplication()->input;
$lang->load($extension, $base_dir);
- $eventid = $jinput->get('eventid',0,'INT');
- $var['attendtype'] = $jinput->get('attendtype','all','CMD');
- $var['tickettypeid'] = $jinput->get('tickettypeid','0','INT');
-
- $jticketingmainhelper = new jticketingmainhelper();
- $results= $jticketingmainhelper->GetOrderitemsAPI($eventid,$var);
-
- if(empty($results))
+ $eventid = $input->get('eventid', '0', 'INT');
+ $var['attendtype'] = $input->get('attendtype', 'all', 'STRING');
+ $var['tickettypeid'] = $input->get('tickettypeid', '0', 'INT');
+ $jticketingmainhelper = new jticketingmainhelper;
+ $results = $jticketingmainhelper->GetOrderitemsAPI($eventid, $var);
+
+ if (empty($results))
{
$obj->success = "0";
- $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");;
- return $obj;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
+ $this->plugin->setResponse($obj);
+
+ return;
}
- if($eventid)
+ if ($eventid)
{
$data = array();
- foreach($results as &$orderitem)
+ foreach ($results as &$orderitem)
{
- $obj = new stdClass();
- $obj->checkin = $jticketingmainhelper->GetCheckinStatusAPI($orderitem->order_items_id);
- if($orderitem->attendee_id)
+ $obj = new stdClass;
+ $obj->checkin = $jticketingmainhelper->GetCheckinStatusAPI($orderitem->order_items_id, $eventid);
+
+ if ($orderitem->attendee_id)
{
- $field_array=array('first_name','last_name');
- //Get Attendee Details
- $attendee_details=$jticketingmainhelper->getAttendees_details($orderitem->attendee_id,$field_array);
+ $field_array = array(
+ 'first_name',
+ 'last_name'
+ );
+
+ // Get Attendee Details
+ $attendee_details = $jticketingmainhelper->getAttendees_details($orderitem->attendee_id, $field_array);
}
- if(!empty($attendee_details['first_name']))
+
+ if (!empty($attendee_details['first_name']))
{
- $attendee_nm=implode(" ",$attendee_details);
+ $attendee_nm = implode(" ", $attendee_details);
}
else
{
- $attendee_nm=$orderitem->name;
+ $attendee_nm = $orderitem->name;
}
- $obj->ticketid = $orderitem->oid.'-'.$orderitem->order_items_id;
- $obj->attendee_nm =$attendee_nm;
- $obj->tickettypeid=$orderitem->tickettypeid;
- $obj->ticket_type_title =$orderitem->ticket_type_title;
- $obj->event_title = $orderitem->event_title;
- $obj->ticket_prefix=JText::_("TICKET_PREFIX");
-
- /*if($var['attendtype']=="all")
+
+ $obj->ticketid = $orderitem->oid . '-' . $orderitem->order_items_id;
+ $obj->attendee_nm = $attendee_nm;
+ $obj->tickettypeid = $orderitem->tickettypeid;
+ $obj->ticket_type_title = $orderitem->ticket_type_title;
+ $obj->event_title = $orderitem->event_title;
+ $obj->ticket_prefix = JText::_("TICKET_PREFIX");
+
+ if ($var['attendtype'] == "all")
{
$data[] = $obj;
}
- else if($var['attendtype']=="attended" && $obj->checkin==1)
+ elseif ($var['attendtype'] == "attended" && $obj->checkin == 1)
{
$data[] = $obj;
}
- else if($var['attendtype']=="notattended" && $obj->checkin==0)
+ elseif ($var['attendtype'] == "notattended" && $obj->checkin == 0)
{
$data[] = $obj;
- }*/
- $data[] = $obj;
+ }
}
- $fobj = new stdClass();
+ $fobj = new stdClass;
$fobj->success = "1";
- $fobj->total = count($data);
- $fobj->data = $data;
- }
+ $fobj->total = count($data);
+ $fobj->data = $data;
+ }
else
{
$fobj->success = "0";
$fobj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
}
- return $fobj;
+ $this->plugin->setResponse($fobj);
+ }
+
+ /**
+ * Post Method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
+ public function post()
+ {
+ $obj = new stdClass;
+ $obj->success = 0;
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
+ $this->plugin->setResponse($obj);
}
+ /**
+ * Put method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function put()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_PUT");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
+
+ /**
+ * Delete method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function delete()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_DEL");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
-
}
diff --git a/jticketing/jticket/gettickettypes.php b/jticketing/jticket/gettickettypes.php
index 0302aa3..f224ad4 100644
--- a/jticketing/jticket/gettickettypes.php
+++ b/jticketing/jticket/gettickettypes.php
@@ -1,75 +1,84 @@
- * @link http://www.techjoomla.com
-*/
+ * @version SVN:
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
defined('_JEXEC') or die;
-
jimport('joomla.plugin.plugin');
-
+/**
+ * Class for getting ticket types based on event id
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
class JticketApiResourceGettickettypes extends ApiResource
{
+ /**
+ * Get ticket types based on event id
+ *
+ * @return json user list
+ *
+ * @since 1.0
+ */
public function get()
{
- $this->plugin->setResponse($this->getTickettype());
- }
-
- public function post()
- {
- $this->plugin->setResponse($this->getTickettype());
- }
-
- public function getTickettype()
- {
- $lang =& JFactory::getLanguage();
+ $lang = JFactory::getLanguage();
$extension = 'com_jticketing';
- $base_dir = JPATH_SITE;
- $jinput = JFactory::getApplication()->input;
-
+ $base_dir = JPATH_SITE;
+ $input = JFactory::getApplication()->input;
$lang->load($extension, $base_dir);
- $eventid = $jinput->get('eventid',0,'INT');
-
- if(empty($eventid))
- {
+ $eventid = $input->get('eventid', '0', 'INT');
+
+ if (empty($eventid))
+ {
$obj->success = 0;
- $obj->message =JText::_("COM_JTICKETING_INVALID_EVENT");
- return $obj;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_EVENT");
+ $this->plugin->setResponse($obj);
+
+ return;
}
- $jticketingmainhelper = new jticketingmainhelper();
- $tickettypes= $jticketingmainhelper->GetTicketTypes($eventid,'');
+ $jticketingmainhelper = new jticketingmainhelper;
+ $tickettypes = $jticketingmainhelper->GetTicketTypes($eventid, '');
+
+ if ($tickettypes)
+ {
+ foreach ($tickettypes as &$tickettype)
+ {
+ if ($tickettype->available == 0 || $tickettype->unlimited_seats == 1)
+ {
+ $tickettype->available = JText::_('COM_JTICKETING_UNLIMITED_SEATS');
+ }
+
+ $tickettype->soldticket = (int) $jticketingmainhelper->GetTicketTypessold($tickettype->id);
- if($tickettypes)
+ if (empty($tickettype->soldticket) or $tickettype->soldticket < 0)
{
- foreach($tickettypes as &$tickettype)
- {
- $tickettype->available=(int)$tickettype->available;
- $tickettype->count=(int)$tickettype->count;
- $tickettype->soldticket=$tickettype->available-$tickettype->count;
-
- if(empty($tickettype->soldticket) or $tickettype->soldticket<0)
- {
- $tickettype->soldticket=0;
- }
-
- $tickettype->checkins=(int) $jticketingmainhelper->GetTicketTypescheckin($tickettype->id);
- if(empty($tickettype->checkins) or $tickettype->checkins<0)
- {
- $tickettype->checkins=0;
- }
- }
+ $tickettype->soldticket = 0;
+ }
+
+ $tickettype->checkins = (int) $jticketingmainhelper->GetTicketTypescheckin($tickettype->id);
+ if (empty($tickettype->checkins) or $tickettype->checkins < 0)
+ {
+ $tickettype->checkins = 0;
}
+ }
+ }
- if($tickettypes)
+ $obj = new Stdclass;
+
+ if (isset($tickettypes))
{
$obj->success = "1";
- $obj->data =$tickettypes;
- }
+ $obj->data = $tickettypes;
+ }
else
{
$obj->success = "0";
@@ -79,21 +88,51 @@ public function getTickettype()
$this->plugin->setResponse($obj);
}
+ /**
+ * Post Method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
+ public function post()
+ {
+ $obj = new stdClass;
+ $obj->success = 0;
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
+ $this->plugin->setResponse($obj);
+ }
+
+ /**
+ * Put method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function put()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_PUT");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
+
+ /**
+ * Delete method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function delete()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_DEL");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
-
}
diff --git a/jticketing/jticket/getuserevents.php b/jticketing/jticket/getuserevents.php
index 0bdfb79..f17d1bd 100644
--- a/jticketing/jticket/getuserevents.php
+++ b/jticketing/jticket/getuserevents.php
@@ -1,124 +1,184 @@
- * @link http://www.techjoomla.com
-*/
+ * @version SVN:
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
defined('_JEXEC') or die;
-
jimport('joomla.plugin.plugin');
-
+/**
+ * Class for getting user events based on user id
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
class JticketApiResourceGetuserevents extends ApiResource
{
+ /**
+ * Get Event data
+ *
+ * @return json user list
+ *
+ * @since 1.0
+ */
public function get()
{
- $this->plugin->setResponse($this->getUserEvent());
- }
-
- public function post()
- {
- $this->plugin->setResponse($this->getUserEvent());
- }
-
- public function getUserEvent()
- {
- $com_params=JComponentHelper::getParams('com_jticketing');
- //0 Jomsocial 1/Native 3 JEvents
+ $com_params = JComponentHelper::getParams('com_jticketing');
$integration = $com_params->get('integration');
-
- $lang =& JFactory::getLanguage();
+ $input = JFactory::getApplication()->input;
+ $lang = JFactory::getLanguage();
$extension = 'com_jticketing';
- $base_dir = JPATH_SITE;
- $jinput = JFactory::getApplication()->input;
-
+ $base_dir = JPATH_SITE;
$lang->load($extension, $base_dir);
- $userid = $jinput->get('userid',0,'INT');
-
- if(empty($userid))
+
+ $userid = $input->get('userid', '', 'INT');
+
+ // $userid = $this->plugin->get('user')->id;
+
+ if (empty($userid))
{
$obj->success = 0;
- $obj->message =JText::_("COM_JTICKETING_INVALID_USER");
- return $obj;
+ $obj->message = JText::_("COM_JTICKETING_INVALID_USER");
+ $this->plugin->setResponse($obj);
+
+ return;
+ }
+
+ $jticketingmainhelper = new jticketingmainhelper;
+ $plugin = JPluginHelper::getPlugin('api', 'jticket');
+
+ // Check if plugin is enabled
+ if ($plugin)
+ {
+ // Get plugin params
+ $pluginParams = new JRegistry($plugin->params);
+ $users_allow_access_app = $pluginParams->get('users_allow_access_app');
}
- $jticketingmainhelper = new jticketingmainhelper();
- $eventdatapaid= $jticketingmainhelper->GetUserEventsAPI($userid,'');
- $eveidarr=array();
- if($eventdatapaid)
+ // If user is in allowed user to access APP show all events to that user
+ if (is_array($users_allow_access_app) and in_array($userid, $users_allow_access_app))
{
- foreach($eventdatapaid as &$eventdata1)
+ $eventdatapaid = $jticketingmainhelper->GetUserEventsAPI();
+ }
+ else
+ {
+ $eventdatapaid = $jticketingmainhelper->GetUserEventsAPI($userid, '');
+ }
+
+ $eveidarr = array();
+
+ if ($eventdatapaid)
+ {
+ foreach ($eventdatapaid as &$eventdata1)
{
- $eveidarr[]=$eventdata1->id;
- if($eventdata1->avatar)
- $eventdata1->avatar=$eventdata1->avatar;
+ $eveidarr[] = $eventdata1->id;
+
+ if (isset($eventdata1->avatar))
+ {
+ $eventdata1->avatar = $eventdata1->avatar;
+ }
else
- $eventdata1->avatar='';
-
- $eventdata1->totaltickets= $jticketingmainhelper->GetTicketcount($eventdata1->id);
-
- if(empty($eventdata1->totaltickets))
- $eventdata1->totaltickets=0;
- $return=$jticketingmainhelper->getTimezoneString($eventdata1->id);
- $eventdata1->startdate=$return['startdate'];
- $eventdata1->enddate=$return['enddate'];
- $datetoshow=$return['startdate'].'-'.$return['enddate'];
- if(!empty($return['eventshowtimezone']))
- $datetoshow.='
'.$return['eventshowtimezone'];
+ {
+ $eventdata1->avatar = '';
+ }
+
+ $eventdata1->totaltickets = $jticketingmainhelper->GetTicketcount($eventdata1->id);
+
+ if (empty($eventdata1->totaltickets))
+ {
+ $eventdata1->totaltickets = 0;
+ }
+
+ $return = $jticketingmainhelper->getTimezoneString($eventdata1->id);
+ $eventdata1->startdate = $return['startdate'];
+ $eventdata1->enddate = $return['enddate'];
+ $datetoshow = $return['startdate'] . '-' . $return['enddate'];
+
+ if (!empty($return['eventshowtimezone']))
+ {
+ $datetoshow .= $return['eventshowtimezone'];
+ }
}
}
- $eventdataunpaid= $jticketingmainhelper->GetUser_unpaidEventsAPI($userid,$eveidarr,'');
- if($eventdataunpaid)
+ $eventdataunpaid = $jticketingmainhelper->GetUser_unpaidEventsAPI('', $userid, $eveidarr);
+
+ if ($eventdataunpaid)
{
- foreach($eventdataunpaid as &$eventdata3)
+ foreach ($eventdataunpaid as &$eventdata3)
{
- $eventdata3->totaltickets= $jticketingmainhelper->GetTicketcount($eventdata3->id);
- if(empty($eventdata3->totaltickets))
- $eventdata3->totaltickets=0;
- $eventdata3->startdate= $jticketingmainhelper->getLocaletime($userid,$eventdata3->startdate);
- $eventdata3->enddate= $jticketingmainhelper->getLocaletime($userid,$eventdata3->enddate);
- $eventdata3->soldtickets=0;
- $eventdata3->checkin=0;
+ $eventdata3->totaltickets = $jticketingmainhelper->GetTicketcount($eventdata3->id);
+
+ if (empty($eventdata3->totaltickets))
+ {
+ $eventdata3->totaltickets = 0;
+ }
+
+ $eventdata3->startdate = $jticketingmainhelper->getLocaletime($userid, $eventdata3->startdate);
+ $eventdata3->enddate = $jticketingmainhelper->getLocaletime($userid, $eventdata3->enddate);
+ $eventdata3->soldtickets = 0;
+ $eventdata3->checkin = 0;
}
}
- if($eventdatapaid and $eventdataunpaid)
- $obj_merged = array_merge((array) $eventdatapaid, (array) $eventdataunpaid);
- else if($eventdatapaid and empty($eventdataunpaid))
- $obj_merged=$eventdatapaid;
- else if($eventdataunpaid and empty($eventdatapaid))
- $obj_merged=$eventdataunpaid;
-
- $obj = new stdClass();
- if($obj_merged)
+
+ if ($eventdatapaid and $eventdataunpaid)
+ {
+ $obj_merged = array_merge((array) $eventdatapaid, (array) $eventdataunpaid);
+ }
+ elseif ($eventdatapaid and empty($eventdataunpaid))
+ {
+ $obj_merged = $eventdatapaid;
+ }
+ elseif ($eventdataunpaid and empty($eventdatapaid))
{
- foreach($obj_merged as &$objmerged)
+ $obj_merged = $eventdataunpaid;
+ }
+
+ $obj = new stdClass;
+
+ if ($obj_merged)
+ {
+ foreach ($obj_merged as &$objmerged)
{
- if(empty($objmerged->soldtickets))
- $objmerged->soldtickets=0;
+ if (empty($objmerged->soldtickets))
+ {
+ $objmerged->soldtickets = 0;
+ }
- if(empty($objmerged->totaltickets))
- $objmerged->totaltickets=0;
- if($objmerged->avatar)
+ if (empty($objmerged->totaltickets))
{
- if($integration==2)
+ $objmerged->totaltickets = 0;
+ }
+
+ if (isset($objmerged->avatar))
+ {
+ if ($integration == 2)
{
- $objmerged->avatar=JURI::base().'media/com_jticketing/images/'.$objmerged->avatar;
+ $objmerged->avatar = JUri::base() . 'media/com_jticketing/images/' . $objmerged->avatar;
}
else
{
- $objmerged->avatar=JURI::base().$objmerged->avatar;
+ $objmerged->avatar = JUri::base() . $objmerged->avatar;
}
}
else
- $eventdata3->avatar='';
- if(empty($objmerged->checkin))
- $objmerged->checkin=0;
+ {
+ $eventdata3->avatar = '';
+ }
+
+ if (empty($objmerged->checkin))
+ {
+ $objmerged->checkin = 0;
+ }
}
+
$obj->success = "1";
- $obj->data = $obj_merged;
+ $obj->data = $obj_merged;
}
else
{
@@ -126,24 +186,54 @@ public function getUserEvent()
$obj->message = JText::_("COM_JTICKETING_NO_EVENT_DATA_USER");
}
- return $obj;
+ $this->plugin->setResponse($obj);
}
+ /**
+ * Post Method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
+ public function post()
+ {
+ $obj = new stdClass;
+ $obj->success = 0;
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
+ $this->plugin->setResponse($obj);
+ }
+
+ /**
+ * Put method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function put()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_PUT");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
+
+ /**
+ * Delete method
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
public function delete()
{
- $obj = new stdClass();
+ $obj = new stdClass;
$obj->success = 0;
- $obj->code = 403;
- $obj->message = JText::_("COM_JTICKETING_WRONG_METHOD_DEL");
+ $obj->code = 20;
+ $obj->message = JText::_("COM_JTICKETING_SELECT_GET_METHOD");
$this->plugin->setResponse($obj);
}
-
}
diff --git a/jticketing/jticket/index.html b/jticketing/jticket/index.html
new file mode 100644
index 0000000..e69de29
diff --git a/jticketing/jticket/login.php b/jticketing/jticket/login.php
new file mode 100644
index 0000000..994b058
--- /dev/null
+++ b/jticketing/jticket/login.php
@@ -0,0 +1,169 @@
+
+ * @package JTicketing
+ * @author Techjoomla
+ * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
+
+defined('_JEXEC') or die('Restricted access');
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+jimport('joomla.application.component.controller');
+jimport('joomla.application.component.model');
+jimport('joomla.user.helper');
+jimport('joomla.user.user');
+JModelLegacy::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_api' . DS . 'models');
+require_once JPATH_SITE . DS . 'components' . DS . 'com_api' . DS . 'libraries' . DS . 'authentication' . DS . 'login.php';
+require_once JPATH_SITE . DS . 'components' . DS . 'com_api' . DS . 'models' . DS . 'key.php';
+require_once JPATH_SITE . DS . 'components' . DS . 'com_api' . DS . 'models' . DS . 'keys.php';
+
+/**
+ * Class for login API
+ *
+ * @package JTicketing
+ * @subpackage component
+ * @since 1.0
+ */
+class JticketApiResourceLogin extends ApiResource
+{
+ /**
+ * Get Event data
+ *
+ * @return json user list
+ *
+ * @since 1.0
+ */
+ public function get()
+ {
+ $lang = JFactory::getLanguage();
+ $extension = 'com_jticketing';
+ $base_dir = JPATH_SITE;
+ $lang->load($extension, $base_dir);
+ $result = $this->keygen();
+ $success = $result->success;
+
+ if (empty($success))
+ {
+ $result = JText::_("COM_JTICKETING_INVALID_USER_PASSWORD");
+ }
+
+ unset($result->success);
+
+ if ($success)
+ {
+ $data1 = array(
+ "data" => $result,
+ "success" => $success
+ );
+ }
+ else
+ {
+ $data1 = array(
+ "message" => $result,
+ "success" => $success
+ );
+ }
+
+ $this->plugin->setResponse($data1);
+ }
+
+ /**
+ * Post Event data
+ *
+ * @return json user list
+ *
+ * @since 1.0
+ */
+ public function post()
+ {
+ $this->plugin->setResponse($this->keygen());
+ }
+
+ /**
+ * keygen
+ *
+ * @return json user list
+ *
+ * @since 1.0
+ */
+ public function keygen()
+ {
+ $umodel = new JUser;
+ $user = $umodel->getInstance();
+ $group = JRequest::getVar('group');
+
+ if (!$user->id)
+ {
+ $user = JFactory::getUser($this->getUserId(JRequest::getVar("username")));
+ }
+
+ $kmodel = new ApiModelKey;
+ $model = new ApiModelKeys;
+ $key = null;
+ $keys_data = $model->getList();
+
+ foreach ($keys_data as $val)
+ {
+ if (!empty($user->id) and $val->user_id == $user->id)
+ {
+ $key = $val->hash;
+ }
+ }
+
+ // Create new key for user
+ if (!empty($user->id) and $key == null)
+ {
+ $data = array(
+ 'user_id' => $user->id,
+ 'domain' => '',
+ 'published' => 1,
+ 'id' => '',
+ 'task' => 'save',
+ 'c' => 'key',
+ 'ret' => 'index.php?option=com_api&view=keys',
+ 'option' => 'com_api',
+ JSession::getFormToken() => 1
+ );
+ $result = $kmodel->save($data);
+ $key = $result->hash;
+ $userid = $result->user_id;
+ }
+
+ $obj = new stdclass;
+
+ if (!empty($user->id))
+ {
+ $obj->success = 1;
+ $obj->userid = $user->id;
+ $obj->key = $key;
+ $obj->url = JURI::base() . 'index.php';
+ }
+ else
+ {
+ $obj->success = 0;
+ $obj->data = JText::_("COM_JTICKETING_INVALID_USER_PASSWORD");
+ }
+
+ return ($obj);
+ }
+
+ /**
+ * function to get user name
+ *
+ * @param object $username name of user
+ *
+ * @return void
+ *
+ * @since 1.0
+ */
+ public function getUserId($username)
+ {
+ $db = JFactory::getDBO();
+ $query = "SELECT u.id FROM #__users AS u WHERE u.username = '{$username}'";
+ $db->setQuery($query);
+
+ return $id = $db->loadResult();
+ }
+}
diff --git a/jticketing/language/en-GB/en-GB.plg_api_jticket.ini b/jticketing/language/en-GB/en-GB.plg_api_jticket.ini
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/jticketing/language/en-GB/en-GB.plg_api_jticket.ini
@@ -0,0 +1 @@
+
diff --git a/users/language/en-GB/en-GB.plg_api_users.ini b/users/language/en-GB/en-GB.plg_api_users.ini
new file mode 100755
index 0000000..1e75e9c
--- /dev/null
+++ b/users/language/en-GB/en-GB.plg_api_users.ini
@@ -0,0 +1,17 @@
+PLG_API_USERS="API - Users"
+PLG_API_USERS_DESCRIPTION="This plugin exposes users to the Joomla! API. Supports creation, listing and login for users."
+PLG_API_USERS_BAD_REQUEST_MESSAGE="Bad request"
+PLG_API_USERS_REQUIRED_DATA_EMPTY_MESSAGE="Required data is empty"
+PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE="Congratulations! Your account has been created successfully"
+PLG_API_USERS_PROFILE_CREATED_SUCCESSFULLY_MESSAGE="profile created successfully"
+PLG_API_USERS_UNABLE_CREATE_PROFILE_MESSAGE="Unable to create profile"
+PLG_API_USERS_EASYSOCIAL_NOT_INSTALL_MESSAGE="Easysocial is not installed properly"
+PLG_API_USERS_GET_METHOD_NOT_ALLOWED_MESSAGE="Get method not allowed, Use post method"
+PLG_API_USERS_USER_NOT_FOUND_MESSAGE="User not found"
+PLG_API_USERS_IN_DELETE_FUNCTION_MESSAGE="in delete function"
+
+PLG_API_USERS_UNSUPPORTED_METHOD="unsupported method,please use post method"
+PLG_API_USERS_UNSUPPORTED_METHOD_POST="unsupported method,please use get method"
+PLG_API_USERS_USERS="users/"
+PLG_API_USERS_IN_DELETE="in delete"
+PLG_API_USERS_IN_POST="in post"
diff --git a/users/language/en-GB/en-GB.plg_api_users.sys.ini b/users/language/en-GB/en-GB.plg_api_users.sys.ini
new file mode 100755
index 0000000..4e664ee
--- /dev/null
+++ b/users/language/en-GB/en-GB.plg_api_users.sys.ini
@@ -0,0 +1,8 @@
+; Joomla! Project
+; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
+; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
+; Note : All ini files need to be saved as UTF-8
+
+PLG_API_USERS="API - Users"
+PLG_API_USERS_DESCRIPTION="This plugin exposes users to the Joomla! API. Supports creation, listing and login for users."
+
diff --git a/users/users.php b/users/users.php
old mode 100755
new mode 100644
index 4cb60de..a46af06
--- a/users/users.php
+++ b/users/users.php
@@ -18,7 +18,13 @@ public function __construct(&$subject, $config = array())
ApiResource::addIncludePath(dirname(__FILE__).'/users');
+ /*load language file for plugin frontend*/
+ $lang = JFactory::getLanguage();
+ $lang->load('plg_api_users', JPATH_ADMINISTRATOR,'',true);
+
// Set the login resource to be public
- $this->setResourceAccess('login', 'public');
+ $this->setResourceAccess('login', 'public','get');
+ $this->setResourceAccess('users', 'public', 'post');
+ $this->setResourceAccess('config', 'public', 'get');
}
}
diff --git a/users/users.xml b/users/users.xml
old mode 100755
new mode 100644
index 24592e4..3cc4b03
--- a/users/users.xml
+++ b/users/users.xml
@@ -1,17 +1,31 @@
-
- Api - Users
- 1.6
+
+ PLG_API_USERS
+ 1.8.4
10/11/2014
Techjoomla
extensions@techjoomla.com
www.techjoomla.com
Techjoomla. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- This plugin exposes users to the Joomla! API. Supports creation, listing and login for users.
-
+ PLG_API_USERS_DESCRIPTION
users.php
users
+
+ en-GB/en-GB.plg_api_users.ini
+ en-GB/en-GB.plg_api_users.sys.ini
+
+
+
+
+
+
diff --git a/users/users/config.php b/users/users/config.php
new file mode 100644
index 0000000..cbba3b1
--- /dev/null
+++ b/users/users/config.php
@@ -0,0 +1,152 @@
+
+ * @link http://www.techjoomla.com
+*/
+
+defined('_JEXEC') or die( 'Restricted access' );
+
+jimport('joomla.plugin.plugin');
+jimport('joomla.html.html');
+jimport('joomla.application.component.controller');
+jimport('joomla.application.component.model');
+jimport('joomla.user.helper');
+jimport('joomla.user.user');
+jimport('joomla.application.component.helper');
+
+JModelLegacy::addIncludePath(JPATH_SITE.'components/com_api/models');
+require_once JPATH_SITE.'/components/com_api/libraries/authentication/user.php';
+require_once JPATH_SITE.'/components/com_api/libraries/authentication/login.php';
+
+class UsersApiResourceConfig extends ApiResource
+{
+ public function get()
+ {
+ $obj = new stdClass;
+ //get joomla,easyblog and easysocial configuration
+ //get version of easysocial and easyblog
+ $easyblog = JPATH_ADMINISTRATOR .'/components/com_easyblog/easyblog.php';
+ $easysocial = JPATH_ADMINISTRATOR .'/components/com_easysocial/easysocial.php';
+ //eb version
+ if( JFile::exists( $easyblog ) )
+ {
+ $obj->easyblog = $this->getCompParams('com_easyblog','easyblog');
+ }
+ //es version
+ if( JFile::exists( $easysocial ) )
+ {
+ /*$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_easysocial/easyblog.xml');
+ $obj->easysocial_version = (string)$xml->version;*/
+ $obj->easysocial = $this->getCompParams( 'com_easysocial','easysocial' );
+ }
+
+ $obj->global_config = $this->getJoomlaConfig();
+ $obj->plugin_config = $this->getpluginConfig();
+
+
+ $this->plugin->setResponse($obj);
+ }
+
+ public function post()
+ {
+ $this->plugin->setResponse( JText::_( 'PLG_API_USERS_UNSUPPORTED_METHOD_POST' ));
+ }
+
+
+ //get component params
+ public function getCompParams($cname=null,$name=null)
+ {
+ jimport('joomla.application.component.helper');
+ $app = JFactory::getApplication();
+ $cdata = array();
+
+ $xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/'.$cname.'/'.$name.'.xml');
+ $cdata['version'] = (string)$xml->version;
+ $jconfig = JFactory::getConfig();
+
+ if( $cname == 'com_easyblog' )
+ {
+ /*$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_easyblog/easyblog.xml');
+ $version = (string)$xml->version;*/
+
+ if($cdata['version']<5)
+ {
+ require_once( JPATH_ROOT . '/components/com_easyblog/helpers/helper.php' );
+ $eb_params = EasyBlogHelper::getConfig();
+ }
+ else
+ {
+ require_once JPATH_ADMINISTRATOR.'/components/com_easyblog/includes/easyblog.php';
+ $eb_params = EB::config();
+ }
+
+ $cdata['main_max_relatedpost'] = $eb_params->get('main_max_relatedpost');
+ $cdata['layout_pagination_bloggers'] = $eb_params->get('layout_pagination_bloggers');
+ $cdata['layout_pagination_categories'] = $eb_params->get('layout_pagination_categories');
+ $cdata['layout_pagination_categories_per_page'] = $eb_params->get('layout_pagination_categories_per_page');
+ $cdata['layout_pagination_bloggers_per_page'] = $eb_params->get('layout_pagination_bloggers_per_page');
+ $cdata['layout_pagination_archive'] = $eb_params->get('layout_pagination_archive');
+ $cdata['layout_pagination_teamblogs'] = $eb_params->get('layout_pagination_teamblogs');
+
+ }
+ else
+ {
+ require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+ $es_params = FD::config();
+
+ $cdata['conversations_limit'] = $es_params->get('conversations')->limit;
+ $cdata['activity_limit'] = $es_params->get('activity')->pagination;
+ $cdata['lists_limit'] = $es_params->get('lists')->display->limit;
+ $cdata['comments_limit'] = $es_params->get('comments')->limit;
+ $cdata['stream_pagination_limit'] = $es_params->get('stream')->pagination->pagelimit;
+ $cdata['photos_pagination_limit'] = $es_params->get('photos')->pagination->photo;
+ $cdata['album_pagination_limit'] = $es_params->get('photos')->pagination->album;
+ $cdata['emailasusername'] = $es_params->get('registrations')->emailasusername;
+ $cdata['displayName'] = $es_params->get('users')->displayName;
+ $cdata['groups']['enabled'] = $es_params->get('groups')->enabled;
+
+ }
+ return $cdata;
+ }
+
+ // get fb plugin config
+ public function getpluginConfig()
+ {
+ $data = array();
+ $plugin = JPluginHelper::getPlugin('api', 'users');
+ $pluginParams = new JRegistry($plugin->params);
+ $data['fb_login'] = $pluginParams->get('fb_login');
+
+ return $data;
+ }
+
+ //get joomla config changes
+ public function getJoomlaConfig()
+ {
+ $jconfig = JFactory::getConfig();
+ $jarray = array();
+ $jarray['global_list_limit'] = $jconfig->get('list_limit');
+ $jarray['offset'] = $jconfig->get('offset');
+ $jarray['offset_user'] = $jconfig->get('offset_user');
+
+ return $jarray;
+ }
+
+ /*
+ * function to update Easyblog auth keys
+ */
+ public function updateEauth($user=null,$key=null)
+ {
+ require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+ $model = FD::model('Users');
+ $id = $model->getUserId('username', $user->username);
+ $user = FD::user($id);
+ $user->alias = $user->username;
+ $user->auth = $key;
+ $user->store();
+
+ return $id;
+ }
+}
diff --git a/users/users/login.php b/users/users/login.php
index fa3caf9..9659e40 100644
--- a/users/users/login.php
+++ b/users/users/login.php
@@ -26,7 +26,8 @@ class UsersApiResourceLogin extends ApiResource
{
public function get()
{
- $this->plugin->setResponse("unsupported method,please use post method");
+
+ $this->plugin->setResponse( JText::_( 'PLG_API_USERS_GET_METHOD_NOT_ALLOWED_MESSAGE' ));
}
public function post()
@@ -34,7 +35,7 @@ public function post()
$this->plugin->setResponse($this->keygen());
}
- function keygen()
+ public function keygen()
{
//init variable
$obj = new stdclass;
@@ -60,30 +61,30 @@ function keygen()
}
elseif( $key == null || empty($key) )
{
- // Create new key for user
- $data = array(
- 'userid' => $user->id,
- 'domain' => '' ,
- 'state' => 1,
- 'id' => '',
- 'task' => 'save',
- 'c' => 'key',
- 'ret' => 'index.php?option=com_api&view=keys',
- 'option' => 'com_api',
- JSession::getFormToken() => 1
- );
+ // Create new key for user
+ $data = array(
+ 'userid' => $user->id,
+ 'domain' => '' ,
+ 'state' => 1,
+ 'id' => '',
+ 'task' => 'save',
+ 'c' => 'key',
+ 'ret' => 'index.php?option=com_api&view=keys',
+ 'option' => 'com_api',
+ JSession::getFormToken() => 1
+ );
- $result = $kmodel->save($data);
- $key = $result->hash;
-
- //add new key in easysocial table
- $easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php';
- if (JFile::exists($easyblog) && JComponentHelper::isEnabled('com_easysocial', true))
- {
- $this->updateEauth( $user , $key );
- }
+ $result = $kmodel->save($data);
+ $key = $result->hash;
+
+ //add new key in easysocial table
+ $easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php';
+ if (JFile::exists($easyblog) && JComponentHelper::isEnabled('com_easysocial', true))
+ {
+ $this->updateEauth( $user , $key );
+ }
}
-
+
if( !empty($key) )
{
$obj->auth = $key;
@@ -93,9 +94,10 @@ function keygen()
else
{
$obj->code = 403;
- $obj->message = 'Bad request';
+ $obj->message = JText::_('PLG_API_USERS_BAD_REQUEST_MESSAGE');
}
return( $obj );
+
}
/*
@@ -110,6 +112,7 @@ public function updateEauth($user=null,$key=null)
$user->alias = $user->username;
$user->auth = $key;
$user->store();
+
return $id;
}
}
diff --git a/users/users/users.php b/users/users/users.php
old mode 100755
new mode 100644
index fe52934..21f6f2b
--- a/users/users/users.php
+++ b/users/users/users.php
@@ -1,52 +1,530 @@
- * @link http://www.techjoomla.com
-*/
-
-defined('_JEXEC') or die( 'Restricted access' );
+ * @package Joomla.Administrator
+ * @subpackage com_trading
+ *
+ * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+// No direct access.
+defined('_JEXEC') or die;
+
jimport('joomla.user.user');
+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 . '/libraries/joomla/filesystem/folder.php';
require_once JPATH_ROOT . '/administrator/components/com_users/models/users.php';
+/**
+ * User Api.
+ *
+ * @package Joomla.Administrator
+ * @subpackage com_api
+ *
+ * @since 1.0
+ */
class UsersApiResourceUsers extends ApiResource
{
-
+ /**
+ * Function delete for user record.
+ *
+ * @return void
+ */
public function delete()
- {
- $this->plugin->setResponse( 'in delete' );
+ {
+ $this->plugin->setResponse( JText::_( 'PLG_API_USERS_IN_DELETE_FUNCTION_MESSAGE' ));
}
+ /**
+ * Function post for create user record.
+ *
+ * @return void
+ */
public function post()
- {
- $this->plugin->setResponse( 'in post' );
- }
+ {
+ $error_messages = array();
+ $fieldname = array();
+ $response = null;
+ $validated = true;
+ $userid = null;
+ $data = array();
+
+ //$log_user = $this->plugin->get('user')->id;
+
+ $app = JFactory::getApplication();
+ $data['username'] = $app->input->get('username', '', 'STRING');
+ $data['password'] = $app->input->get('password', '', 'STRING');
+ $data['name'] = $app->input->get('name', '', 'STRING');
+ $data['email'] = $app->input->get('email', '', 'STRING');
+ $data['enabled'] = $app->input->get('enabled', 1, 'INT');
+ $data['activation'] = $app->input->get('activation', 0, 'INT');
+ $data['app'] = $app->input->get('app_name', 'Easysocial App', 'STRING');
+
+ global $message;
+
+ $eobj = new stdClass();
+
+ if( $data['username']=='' || $data['password'] =='' || $data['name'] == '' || $data['email']== '')
+ {
+ $eobj->status = false;
+ $eobj->id = 0;
+ $eobj->code = '403';
+ $eobj->message = JText::_( 'PLG_API_USERS_REQUIRED_DATA_EMPTY_MESSAGE' );
+
+ $this->plugin->setResponse($eobj);
+ return;
+
+ }
+
+ 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']);
+ $user->set('block', $data['enabled']);
+ $user->set('activation', $data['activation']);
+
+ // 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->toSql());
+
+ // True on success, false otherwise
+ if (!$user->save())
+ {
+ //$message = "not created because of " . $user->getError();
+ $message = $user->getError();
+
+ $eobj->status = false;
+ $eobj->id = 0;
+ $eobj->code = '403';
+ $eobj->message = $message;
+ $this->plugin->setResponse($eobj);
+ return;
+ }
+ else
+ {
+
+ /*
+ // Auto registration
+ if( $data['activation'] == 0)
+ {
+ $emailSubject = 'Email Subject for registration successfully';
+ $emailBody = 'Email body for registration successfully';
+ $return = JFactory::getMailer()->sendMail('sender email', 'sender name', $user->email, $emailSubject, $emailBody);
+
+ }
+ else if( $data['activation'] == 1)
+ {
+ $emailSubject = 'Email Subject for activate the account';
+ $emailBody = 'Email body for for activate the account';
+ $user_activation_url = JURI::base().JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $user->activation, false); // Append this URL in your email body
+ $return = JFactory::getMailer()->sendMail('sender email', 'sender name', $user->email, $emailSubject, $emailBody);
+
+ }
+ */
+ $mail_sent = $this->sendRegisterEmail($data);
+
+ $easysocial = JPATH_ADMINISTRATOR .'/components/com_easysocial/easysocial.php';
+ //eb version
+ if( JFile::exists( $easysocial ) )
+ {
+ $pobj = $this->createEsprofile($user->id);
+ //$message = "created of username-" . $user->username .",send mail of details please check";
+ $message = JText::_('PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE');
+ }
+ else
+ $message = JText::_('PLG_API_USERS_ACCOUNT_CREATED_SUCCESSFULLY_MESSAGE');
+
+ // Assign badge for the person.
+ $badge = FD::badges();
+ $badge->log( 'com_easysocial' , 'registration.create' , $user->id , JText::_( 'COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED' ) );
+
+ }
+
+ // #$this->plugin->setResponse($user->id);
+ $userid = $user->id;
+
+ // Result message
+ //$result = array('user id ' => $userid, 'message' => $message);
+ //$result = ($userid) ? $result : $message;
+ $eobj->status = true;
+ $eobj->id = $userid;
+ $eobj->code = '200';
+ $eobj->message = $message;
- public function get() {
+ $this->plugin->setResponse($eobj);
+ return;
+ }
+
+ /**
+ * Function get for users record.
+ *
+ * @return void
+ */
+ public function get()
+ {
+
$input = JFactory::getApplication()->input;
// If we have an id try to fetch the user
- if ($id = $input->get('id')) {
+ if ($id = $input->get('id'))
+ {
$user = JUser::getInstance($id);
-
- if (!$user->id) {
- $this->plugin->setResponse( $this->getErrorResponse(404, 'User not found') );
+
+ if (!$user->id)
+ {
+ $this->plugin->setResponse($this->getErrorResponse(JText::_( 'PLG_API_USERS_USER_NOT_FOUND_MESSAGE' )));
+
return;
}
-
- $this->plugin->setResponse( $user );
- } else {
+
+ $this->plugin->setResponse($user);
+ }
+ else
+ {
$model = new UsersModelUsers;
$users = $model->getItems();
-
- foreach ($users as $k => $v) {
+
+ foreach ($users as $k => $v)
+ {
unset($users[$k]->password);
}
+
+ $this->plugin->setResponse($users);
+ }
+ }
+
+ /**
+ * Function create easysocial profile.
+ *
+ * @return user obj
+ */
+ public function createEsprofile($log_user)
+ {
+ $obj = new stdClass();
+
+ if (JComponentHelper::isEnabled('com_easysocial', true))
+ {
+ $app = JFactory::getApplication();
+
+ $epost = $app->input->get('fields', '', 'ARRAY');
+
+ require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
+
+
+ // Get all published fields apps that are available in the current form to perform validations
+ $fieldsModel = FD::model('Fields');
+
+ // Get current user.
+ $my = FD::user($log_user);
+
+ // Only fetch relevant fields for this user.
+ $options = array( 'profile_id' => $my->getProfile()->id, 'data' => true, 'dataId' => $my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_EDIT, 'group' => SOCIAL_FIELDS_GROUP_USER );
+
+ $fields = $fieldsModel->getCustomFields($options);
+
+ $epost = $this->create_field_arr($fields,$epost);
+
+ // Load json library.
+ $json = FD::json();
+
+ // Initialize default registry
+ $registry = FD::registry();
+
+ // Get disallowed keys so we wont get wrong values.
+ $disallowed = array( FD::token() , 'option' , 'task' , 'controller' );
+
+ // Process $_POST vars
+ foreach ($epost as $key => $value) {
+
+ if (!in_array($key, $disallowed)) {
+
+ if (is_array($value) && $key != 'es-fields-11') {
+ $value = $json->encode( $value );
+ }
+
+ $registry->set($key, $value);
+ }
+ }
+
+ // Convert the values into an array.
+ $data = $registry->toArray();
+
+ // Perform field validations here. Validation should only trigger apps that are loaded on the form
+ // @trigger onRegisterValidate
+ $fieldsLib = FD::fields();
+
+ // Get the general field trigger handler
+ $handler = $fieldsLib->getHandler();
+
+ // Build arguments to be passed to the field apps.
+ $args = array( $data , &$my );
+
+ // Ensure that there is no errors.
+ // @trigger onEditValidate
+ //$errors = $fieldsLib->trigger( 'onEditValidate' , SOCIAL_FIELDS_GROUP_USER , $fields , $args, array( $handler, 'validate' ) );
+
+ // Bind the my object with appropriate data.
+ $my->bind($data);
+
+ // Save the user object.
+ $sval = $my->save();
+
+ // Reconstruct args
+ $args = array(&$data, &$my);
+
+ // @trigger onEditAfterSave
+ $fieldsLib->trigger( 'onEditAfterSave' , SOCIAL_FIELDS_GROUP_USER , $fields , $args );
+
+ // Bind custom fields for the user.
+ $my->bindCustomFields($data);
+
+ // Reconstruct args
+ $args = array(&$data, &$my);
+
+ // @trigger onEditAfterSaveFields
+ $fieldsLib->trigger( 'onEditAfterSaveFields' , SOCIAL_FIELDS_GROUP_USER , $fields , $args );
+
+ if($sval)
+ {
+ $obj->success = 1;
+ $obj->message = JText::_('PLG_API_USERS_PROFILE_CREATED_SUCCESSFULLY_MESSAGE');
+ }
+ else
+ {
+ $obj->success = 0;
+ $obj->message = JText::_( 'PLG_API_USERS_UNABLE_CREATE_PROFILE_MESSAGE' );
+ }
- $this->plugin->setResponse( $users );
}
+ else
+ {
+ $obj->success = 0;
+ $obj->message = JText::_( 'PLG_API_USERS_EASYSOCIAL_NOT_INSTALL_MESSAGE');
+ }
+
+ return $obj;
+
+ }
+
+ //create field array as per easysocial
+ public function create_field_arr($fields,$post)
+ {
+ $fld_data = array();
+ $app = JFactory::getApplication();
+
+ require_once JPATH_SITE.'/plugins/api/easysocial/libraries/uploadHelper.php';
+ //for upload photo
+ if(!empty($_FILES['avatar']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
+ $phto_obj = $upload_obj->ajax_avatar($_FILES['avatar']);
+ $avtar_pth = $phto_obj['temp_path'];
+ $avtar_scr = $phto_obj['temp_uri'];
+ $avtar_typ = 'upload';
+ $avatar_file_name = $_FILES['avatar']['name'];
+ }
+ //for upload cover
+ /*$cover_data = null;
+
+ if(!empty($_FILES['cover_file']['name']))
+ {
+ $upload_obj = new EasySocialApiUploadHelper();
+ //ckecking upload cover
+ $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'],'cover_file');
+ //$phtomod = FD::model( 'Photos' );
+ //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
+ //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
+ //
+ }*/
+
+ foreach($fields as $field)
+ {
+ //$fld_data[$field->id] = $field->unique_key;
+ $fobj = new stdClass();
+ $fullname = $post['TITLE']." ".$post['first_name']." ".$post['middle_name']." ".$post['last_name'];
+ $address = $post['STREET_1'].",".$post['STREET_2'].",".$post['CITY'].",".$post['PIN_CODE'].",".$post['STATE'].",".$post['COUNTRY'];
+ // Hari code for address comma remove
+ if($address == ',,,,,'){
+ $address='';
+ }
+
+
+ $fld_data['first_name'] = (!empty($post['first_name']))?$post['first_name']:$app->input->get('name', '', 'STRING');
+ $fld_data['middle_name'] = $post['middle_name'];
+ $fld_data['last_name'] = $post['last_name'];
+
+ $fobj->first = $post['TITLE']." ".$fld_data['first_name'];
+ $fobj->middle = $post['middle_name'];
+ $fobj->last = $post['last_name'];
+ $fobj->name = $fullname;
+
+ switch($field->unique_key)
+ {
+ case 'HEADER': break;
+
+ case 'JOOMLA_FULLNAME': $fld_data['es-fields-'.$field->id] = $fobj;
+ break;
+ case 'JOOMLA_USERNAME': $fld_data['es-fields-'.$field->id] = $app->input->get('username', '', 'STRING');
+ break;
+ case 'JOOMLA_PASSWORD': $fld_data['es-fields-'.$field->id] = $app->input->get('password', '', 'STRING');
+ break;
+ case 'JOOMLA_EMAIL': $fld_data['es-fields-'.$field->id] = $app->input->get('email', '', 'STRING');
+ break;
+ case 'JOOMLA_TIMEZONE': $fld_data['es-fields-'.$field->id] = isset($post['timezone'])?$post['timezone']:null;
+ break;
+ case 'JOOMLA_USER_EDITOR': $fld_data['es-fields-'.$field->id] = isset($post['editor'])?$post['editor']:null;
+ break;
+
+ case 'PERMALINK': $fld_data['es-fields-'.$field->id] = isset($post['permalink'])?$post['permalink']:null;
+ break;
+ case 'BIRTHDAY': $bod =array();
+ if(isset($post['BIRTHDAY']))
+ {
+ $config = JFactory::getConfig();
+ $bod['date'] = $post['BIRTHDAY'];
+ $bod['timezone'] = $config->get('offset');
+ }
+ $fld_data['es-fields-'.$field->id] = isset($post['BIRTHDAY'])?$bod:array();
+ break;
+ case 'GENDER': $fld_data['es-fields-'.$field->id] = isset($post['GENDER'])?$post['GENDER']:'';
+ break;
+ case 'ADDRESS': $fld_data['es-fields-'.$field->id] = $address;
+ break;
+ case 'TEXTBOX': $fld_data['es-fields-'.$field->id] = $post['MOBILE'];
+ break;
+ case 'URL': $fld_data['es-fields-'.$field->id] = (isset($post['WEBSITE']))?$post['WEBSITE']:'';
+ break;
+
+ case 'AVATAR': $fld_data['es-fields-'.$field->id] = Array
+ (
+ 'source' =>$avtar_scr,
+ 'path' =>$avtar_pth,
+ 'data' => '',
+ 'type' => $avtar_typ,
+ 'name' => $avatar_file_name
+ );
+ break;
+ /*
+ case 'COVER': $fld_data['es-fields-'.$field->id] = Array
+ (
+ 'data' =>$cover_data,
+ 'position' =>'{"x":0.5,"y":0.5}'
+ );
+ break;*/
+ }
+ }
+
+ return $fld_data;
}
+ //send registration mail
+ public function sendRegisterEmail($base_dt)
+ {
+ $config = JFactory::getConfig();
+ $params = JComponentHelper::getParams('com_users');
+ $sendpassword = $params->get('sendpassword', 1);
+
+ $lang = JFactory::getLanguage();
+ $lang->load('com_users', JPATH_SITE, '', true);
+ //$tit=JText::_($emailOptions['title']);
+
+ $data['fromname'] = $config->get('fromname');
+ $data['mailfrom'] = $config->get('mailfrom');
+ $data['sitename'] = $config->get('sitename');
+ $data['siteurl'] = JUri::root();
+ $data['activation'] = $base_dt['activation'];
+
+ // Handle account activation/confirmation emails.
+ if ($data['activation'] == 0)
+ {
+ // Set the link to confirm the user email.
+ $uri = JUri::getInstance();
+ $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
+ $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
+
+ $emailSubject = JText::sprintf(
+ 'COM_USERS_EMAIL_ACCOUNT_DETAILS',
+ $base_dt['name'],
+ $data['sitename']
+ );
+
+
+ if ($sendpassword)
+ {
+ $emailBody = JText::sprintf(
+ 'Hello %s,\n\nThank you for registering at %s. Your account is created and activated.
+ \nYou can login to %s using the following username and password:\n\nUsername: %s\nPassword: %s',
+ $base_dt['name'],
+ $data['sitename'],
+ $base_dt['app'],
+ $base_dt['username'],
+ $base_dt['password']
+ );
+ }
+
+ }
+ elseif ($data['activation'] == 1)
+ {
+ // Set the link to activate the user account.
+ $uri = JUri::getInstance();
+ $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
+ $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
+
+ $emailSubject = JText::sprintf(
+ 'COM_USERS_EMAIL_ACCOUNT_DETAILS',
+ $base_dt['name'],
+ $data['sitename']
+ );
+
+ if ($sendpassword)
+ {
+ $emailBody = JText::sprintf(
+ 'COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY',
+ $base_dt['name'],
+ $data['sitename'],
+ $data['activate'],
+ $base_dt['app'],
+ $base_dt['username'],
+ $base_dt['password']
+ );
+ }
+ }
+
+ // Send the registration email.
+ $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $base_dt['email'], $emailSubject, $emailBody);
+ return $return;
+
+ }
}
+