Skip to content

Commit a616ad5

Browse files
committed
Beta release easysocial api
1 parent aa913ef commit a616ad5

File tree

16 files changed

+974
-247
lines changed

16 files changed

+974
-247
lines changed

easysocial/easysocial/.giosaveRPEFWX

Whitespace-only changes.

easysocial/easysocial/comments.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
/**
3+
* @package K2 API plugin
4+
* @version 1.0
5+
* @author Rafael Corral
6+
* @link http://www.rafaelcorral.com
7+
* @copyright Copyright (C) 2011 Rafael Corral. All rights reserved.
8+
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
9+
*/
10+
11+
defined('_JEXEC') or die( 'Restricted access' );
12+
13+
jimport('joomla.plugin.plugin');
14+
jimport('joomla.html.html');
15+
16+
require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/includes/foundry.php';
17+
require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/groups.php';
18+
require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/covers.php';
19+
require_once JPATH_ADMINISTRATOR.'/components/com_easysocial/models/albums.php';
20+
21+
require_once JPATH_SITE.'/plugins/api/easysocial/libraries/mappingHelper.php';
22+
23+
class EasysocialApiResourceComments extends ApiResource
24+
{
25+
public function get()
26+
{
27+
$this->plugin->setResponse($this->getComments());
28+
}
29+
30+
public function post()
31+
{
32+
$app = JFactory::getApplication();
33+
34+
$element = $app->input->get('element', '', 'string');
35+
$group = $app->input->get('group', '', 'string');
36+
$verb = $app->input->get('verb', '', 'string');
37+
$uid = $app->input->get('uid', 0, 'int');//element id
38+
39+
$input = $app->input->get( 'comment', '' ,'STRING');
40+
$params = $app->input->get( 'params',array(),'ARRAY');//params
41+
$streamid = $app->input->get( 'stream_id', '' , 'INT');//whole stream id
42+
$parent = $app->input->get( 'parent', 0 ,'INT');//parent comment id
43+
44+
$result = new stdClass;
45+
$valid = 1;
46+
47+
if(!$uid)
48+
{
49+
$result->id = 0;
50+
$result->status = 0;
51+
$result->message = 'Empty element id not allowed';
52+
$valid = 0;
53+
}
54+
55+
// Message should not be empty.
56+
if(!$streamid)
57+
{
58+
$result->id = 0;
59+
$result->status = 0;
60+
$result->message = 'Empty stream id not allowed';
61+
$valid = 0;
62+
}
63+
else if($valid)
64+
{
65+
66+
$compositeElement = $element . '.' . $group . '.' . $verb;
67+
68+
$table = FD::table('comments');
69+
70+
$table->element = $compositeElement;
71+
$table->uid = $uid;
72+
$table->comment = $input;
73+
$table->created_by = FD::user()->id;
74+
$table->created = FD::date()->toSQL();
75+
$table->parent = $parent;
76+
$table->params = $params;
77+
$table->stream_id = $streamid;
78+
79+
$state = $table->store();
80+
81+
if($state)
82+
{
83+
//create result obj
84+
$result->status = 1;
85+
$result->message = 'comment saved successfully';
86+
}
87+
else
88+
{
89+
//create result obj
90+
$result->status = 0;
91+
$result->message = 'Unable to save comment';
92+
}
93+
94+
}
95+
96+
$this->plugin->setResponse($result);
97+
}
98+
99+
public function getComments()
100+
{
101+
$app = JFactory::getApplication();
102+
103+
$row = new stdClass();
104+
$row->uid = $app->input->get('uid',0,'INT');
105+
$row->element = $app->input->get('element','','STRING');//discussions.group.reply
106+
$row->stream_id = $app->input->get('stream_id',0,'INT');
107+
108+
$row->limitstart = $app->input->get('limitstart',0,'INT');
109+
$row->limit = $app->input->get('limit',10,'INT');
110+
111+
$data = array();
112+
$mapp = new EasySocialApiMappingHelper();
113+
$data['data'] = $mapp->createCommentsObj( $row ,$row->limitstart,$row->limit );
114+
115+
return $data;
116+
}
117+
118+
public function delete()
119+
{
120+
$app = JFactory::getApplication();
121+
122+
$conversion_id = $app->input->get('conversation_id',0,'INT');
123+
$valid = 1;
124+
$result = new stdClass;
125+
126+
if( !$conversion_id )
127+
{
128+
129+
$result->status = 0;
130+
$result->message = 'Invalid Conversations';
131+
$valid = 0;
132+
}
133+
134+
if($valid)
135+
{
136+
// Try to delete the group
137+
$conv_model = FD::model('Conversations');
138+
//$my = FD::user($this->plugin->get('user')->id);
139+
$result->status = $conv_model->delete( $conversion_id , $this->plugin->get('user')->id );
140+
$result->message = 'Conversations deleted successfully';
141+
}
142+
143+
$this->plugin->setResponse($result);
144+
}
145+
}

easysocial/easysocial/discussion.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function getGroupDiscussion()
6464

6565
$group_id = $mainframe->input->get('id',0,'INT');
6666
$appId = $mainframe->input->get('discussion_id',0,'INT');
67+
//$filter = $mainframe->input->get('filter','all','STRING');
6768
$wres = new stdClass;
6869
$valid = 0;
6970

@@ -97,6 +98,7 @@ function getGroupDiscussion()
9798
$options[ 'resolved' ] = true;
9899
}
99100

101+
$options[ 'limitstart' ] = $mainframe->input->get('limitstart',0,'INT');
100102
$options[ 'limit' ] = $mainframe->input->get('limit',10,'INT');
101103

102104
$mapp = new EasySocialApiMappingHelper();

easysocial/easysocial/group.php

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,32 @@ function CreateGroup()
123123
$type = $app->input->get('type',0,'INT');
124124
$categoryId = $app->input->get('category_id',0,'INT');
125125

126-
/*
127-
//ckecking upload cover
128-
$upload_obj = new EasySocialApiUploadHelper();
126+
$phtomod = FD::model( 'Photos' );
127+
$metdata = $phtomod->getMeta(108,'path');
129128

130-
$udata = $upload_obj->uploadCover($log_user->id,$type='group');
131-
print_r($upload_obj);die("in create grp");
129+
$upload_obj = new EasySocialApiUploadHelper();
130+
/*
131+
//ckecking upload cover
132+
$cover_obj = $upload_obj->uploadCover($log_user->id,$type='group');
133+
//
134+
*/
135+
136+
$avtar_pth = '';
137+
$avtar_scr = '';
138+
$avtar_typ = '';
139+
$phto_obj = null;
140+
/*
141+
if($_FILES['file']['name'])
142+
{
143+
//ckecking upload cover
144+
$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
145+
$avtar_pth = $phto_obj->getPath();
146+
$avtar_scr = $phto_obj->getSource();
147+
$avtar_typ = 'upload';
148+
}
149+
print_r($avtar_pth);die("in grp api");
150+
*/
132151
//
133-
*/
134152

135153
//check title
136154
if(empty($title) || $title == null)
@@ -172,7 +190,7 @@ function CreateGroup()
172190
else
173191
{
174192
// create steps
175-
$db = FD::db();
193+
$db = FD::db();
176194

177195
$group = FD::table('Group');
178196
FD::import('admin:/includes/group/group');
@@ -243,10 +261,10 @@ function CreateGroup()
243261

244262
case 'AVATAR': $grp_data['es-fields-'.$field['id']] = Array
245263
(
246-
'source' =>'',
247-
'path' => '',
264+
'source' =>$avtar_scr,
265+
'path' =>$avtar_pth,
248266
'data' => '',
249-
'type' => '',
267+
'type' => $avtar_typ,
250268
'name' => ''
251269
);
252270
break;
@@ -297,7 +315,7 @@ function CreateGroup()
297315
$token = FD::token();
298316

299317
$disallow = array($token, 'option', 'cid', 'controller', 'task', 'option', 'currentStep');
300-
318+
301319
foreach( $grp_data as $key => $value )
302320
{
303321
if (!in_array($key, $disallow))
@@ -344,8 +362,6 @@ function CreateGroup()
344362
$result->message = 'unable to create group';
345363
}
346364

347-
//print_r($group);die("in group post api");
348-
349365
return $result;
350366
}
351367
}

easysocial/easysocial/groups.php

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -104,60 +104,7 @@ function getGroups()
104104

105105
return( $groups );
106106
}
107-
108-
/*
109-
//format friends object into required object
110-
function baseGrpObj($data=null)
111-
{
112-
if($data==null)
113-
return 0;
114-
115-
$user = JFactory::getUser($this->plugin->get('user')->id);
116-
117-
$list = array();
118-
119-
$grp_obj = FD::model('Groups');
120-
121-
foreach($data as $k=>$node)
122-
{
123107

124-
$obj = new stdclass;
125-
$obj->id = $node->id;
126-
$obj->title = $node->title;
127-
$obj->description = $node->description;
128-
$obj->hits = $node->hits;
129-
$obj->state = $node->state;
130-
$obj->created_date = $node->created;
131-
132-
//get category name
133-
$category = FD::table('GroupCategory');
134-
$category->load($node->category_id);
135-
$obj->category_id = $node->category_id;
136-
$obj->category_name = $category->get('title');
137-
138-
$obj->created_by = $this->getActor($node->creator_uid);
139-
$obj->creator_name = JFactory::getUser($node->creator_uid)->username;
140-
$obj->type = ($node->type == 1 )?'Private':'Public';
141-
142-
foreach($node->avatars As $ky=>$avt)
143-
{
144-
$avt_key = 'avtar_'.$ky;
145-
$obj->$avt_key = JURI::root().'media/com_easysocial/avatars/group/'.$node->id.'/'.$avt;
146-
}
147-
148-
//$obj->members = $node->members;
149-
$obj->members = $grp_obj->getTotalMembers($node->id);
150-
//$obj->cover = $grp_obj->getMeta($node->id);
151-
152-
$news_obj = new EasySocialModelGroups();
153-
$news = $news_obj->getNews($node->id);
154-
155-
$list[] = $obj;
156-
}
157-
return $list;
158-
}
159-
*/
160-
161108
//to get actor object
162109
function getActor($id=0)
163110
{

0 commit comments

Comments
 (0)