Skip to content

Commit 6c1f8f9

Browse files
committed
api changeds at 10 apr EOD
1 parent f67f693 commit 6c1f8f9

File tree

7 files changed

+166
-80
lines changed

7 files changed

+166
-80
lines changed

easyblog/easyblog/easyblog_users.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
JModelLegacy::addIncludePath(JPATH_SITE.'components/com_api/models');
2525
require_once JPATH_SITE.'/components/com_easyblog/models/users.php';
2626
require_once JPATH_SITE.'/components/com_easyblog/models/blogger.php';
27+
require_once JPATH_SITE.'/components/com_easyblog/helpers/helper.php';
2728
//~ require_once JPATH_SITE.'/plugins/api/easyblog/libraries/simpleschema/bloggers.php';
2829

2930
class EasyblogApiResourceEasyblog_users extends ApiResource
@@ -38,8 +39,23 @@ public function post()
3839
}
3940
public function getEasyBlog_user()
4041
{
42+
$app = JFactory::getApplication();
43+
$limitstart = $app->input->get('limitstart',0,'INT');
44+
$limit = $app->input->get('limit',0,'INT');
45+
$search = $app->input->get('search','','STRING');
4146
$ob1 = new EasyBlogModelBlogger();
42-
$var1 = $ob1->getAllBloggers();
43-
return $var1;
47+
$ob1->setState('limitstart',$limitstart);
48+
$bloggers = $ob1->getAllBloggers('latest',$limit, $filter='showallblogger' , $search );
49+
50+
$blogger = EasyBlogHelper::getTable( 'Profile', 'Table' );
51+
52+
foreach($bloggers as $usr )
53+
{
54+
$blogger->load($usr->id);
55+
//$avatar = $blogger->getAvatar();
56+
$usr->avatar = $blogger->getAvatar();
57+
}
58+
59+
return $bloggers;
4460
}
4561
}

easysocial/easysocial.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
<files>
1414
<filename plugin="easysocial">easysocial.php</filename>
15-
<filename >easysocial/friends.php</filename>
15+
<filename >easysocial/friend.php</filename>
16+
<folder>libraries</folder>
1617
<folder>easysocial</folder>
1718
</files>
1819
</extension>

easysocial/easysocial/group.php

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

126-
$phtomod = FD::model( 'Photos' );
127-
128-
$upload_obj = new EasySocialApiUploadHelper();
129-
130126
$avtar_pth = '';
131127
$avtar_scr = '';
132128
$avtar_typ = '';
133129
$phto_obj = null;
134130

135-
if($_FILES['file']['name'])
131+
if(!empty($_FILES['file']['name']))
136132
{
133+
$upload_obj = new EasySocialApiUploadHelper();
137134
//ckecking upload cover
138-
$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
139-
//$avtar_pth = $phto_obj->getImageObject($phto_obj->type);
140-
$avtar_scr = $phto_obj->getSource();
135+
//$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
136+
$phto_obj = $upload_obj->ajax_avatar($_FILES['file']);
137+
$avtar_pth = $phto_obj['temp_path'];
138+
$avtar_scr = $phto_obj['temp_uri'];
141139
$avtar_typ = 'upload';
140+
$avatar_file_name = $_FILES['file']['name'];
142141
}
143-
142+
144143
$cover_data = null;
145144

146-
if($_FILES['cover_file']['name'])
145+
if(!empty($_FILES['cover_file']['name']))
147146
{
147+
$upload_obj = new EasySocialApiUploadHelper();
148148
//ckecking upload cover
149-
$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
150-
$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
149+
$cover_data = $upload_obj->ajax_cover($_FILES['cover_file'],'cover_file');
150+
//$phtomod = FD::model( 'Photos' );
151+
//$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
152+
//$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
151153
//
152154
}
153-
155+
154156
//
155157

156158
//check title
@@ -268,13 +270,13 @@ function CreateGroup()
268270
'path' =>$avtar_pth,
269271
'data' => '',
270272
'type' => $avtar_typ,
271-
'name' => ''
273+
'name' => $avatar_file_name
272274
);
273275
break;
274276
case 'COVER': $grp_data['es-fields-'.$field['id']] = Array
275277
(
276278
'data' =>$cover_data,
277-
'position' =>''
279+
'position' =>'{"x":0.5,"y":0.5}'
278280
);
279281
break;
280282
}
@@ -357,6 +359,7 @@ function CreateGroup()
357359
{
358360
$result->status = 1;
359361
$result->id = $group->id;
362+
$this->addTostream($user,$group);
360363
}
361364
else
362365
{
@@ -369,4 +372,33 @@ function CreateGroup()
369372
}
370373
}
371374

375+
public function addTostream($my,$group,$registry)
376+
{
377+
$stream = FD::stream();
378+
$streamTemplate = $stream->getTemplate();
379+
380+
// Set the actor
381+
$streamTemplate->setActor( $my->id , SOCIAL_TYPE_USER );
382+
383+
// Set the context
384+
$streamTemplate->setContext( $group->id , SOCIAL_TYPE_GROUPS );
385+
386+
$streamTemplate->setVerb( 'create' );
387+
$streamTemplate->setSiteWide();
388+
$streamTemplate->setAccess( 'core.view' );
389+
$streamTemplate->setCluster($group->id, SOCIAL_TYPE_GROUP, $group->type );
390+
391+
// Set the params to cache the group data
392+
$registry = FD::registry();
393+
$registry->set( 'group' , $group );
394+
395+
// Set the params to cache the group data
396+
$streamTemplate->setParams( $registry );
397+
398+
// Add stream template.
399+
$stream->add( $streamTemplate );
400+
401+
return true;
402+
}
403+
372404
}

easysocial/easysocial/users.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

easysocial/libraries/mappingHelper.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ public function streamSchema($rows=array(),$userid)
108108
//new code
109109
// Set the stream title
110110
$item->id = $row->uid;
111-
$item->title = strip_tags($row->title);
112-
111+
//$item->title = strip_tags($row->title);
112+
//code changed as request not right way
113+
$item->title = $row->title;
114+
$item->title = str_replace('href="','href="'.JURI::root(),$item->title);
115+
//
113116
$item->content = $row->content;
114117

115118
$item->preview = $row->preview;
@@ -122,7 +125,8 @@ public function streamSchema($rows=array(),$userid)
122125
{
123126
$item->raw_content_url = $row->content;
124127
}
125-
$item->raw_content_url = str_replace('href="/j/','href="'.JURI::root(),$item->raw_content_url);
128+
129+
$item->raw_content_url = str_replace('href="','href="'.JURI::root(),$item->raw_content_url);
126130

127131
// Set the publish date
128132
$item->published = $row->created->toMySQL();
@@ -357,6 +361,7 @@ public function groupSchema($rows=null,$userid=0)
357361
{
358362
if(isset($row->id))
359363
{
364+
$grpobj = FD::group( $row->id );
360365
$item = new GroupSimpleSchema();
361366

362367
$item->id = $row->id;
@@ -372,7 +377,7 @@ public function groupSchema($rows=null,$userid=0)
372377
$category->load($row->category_id);
373378
$item->category_id = $row->category_id;
374379
$item->category_name = $category->get('title');
375-
//$item->cover = $row->cover->('title');
380+
$item->cover = $grpobj->getCover();
376381

377382
$item->created_by = $row->creator_uid;
378383
$item->creator_name = JFactory::getUser($row->creator_uid)->username;
@@ -415,6 +420,7 @@ public function groupSchema($rows=null,$userid=0)
415420
//function for create profile schema
416421
public function profileSchema($other_user_id,$userid)
417422
{
423+
418424
$log_user_obj = FD::user($userid);
419425
$other_user_obj = FD::user($other_user_id);
420426

easysocial/libraries/schema/stream.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class streamSimpleSchema {
1212
public $title;
1313
public $preview;
1414
public $raw_content_url;
15-
public $raw_content;
1615
public $content;
1716
public $actor;
1817
public $published;

easysocial/libraries/uploadHelper.php

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/group.php';
1212
require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/message.php';
13-
require_once JPATH_SITE.'/plugins/api/easysocial/libraries/schema/discussion.php';
13+
14+
require_once JPATH_SITE.'/media/com_easysocial/apps/fields/user/avatar/helper.php';
15+
require_once JPATH_SITE.'/media/com_easysocial/apps/fields/user/cover/helper.php';
16+
//require_once JPATH_SITE.'/media/com_easysocial/apps/fields/user/cover/ajax.php';
1417

1518
class EasySocialApiUploadHelper
1619
{
@@ -220,4 +223,89 @@ public function uploadPhoto($log_usr=0,$type=null)
220223

221224
return $photo;
222225
}
226+
227+
//to create temp group avtar data
228+
public function ajax_avatar($file)
229+
{
230+
// Get the ajax library
231+
$ajax = FD::ajax();
232+
233+
// Load up the image library so we can get the appropriate extension
234+
$image = FD::image();
235+
$image->load($file['tmp_name']);
236+
237+
// Copy this to temporary location first
238+
$tmpPath = SocialFieldsUserAvatarHelper::getStoragePath( 'file' );
239+
$tmpName = md5( $file[ 'name' ] . 'file' . FD::date()->toMySQL()) . $image->getExtension();
240+
241+
$source = $file['tmp_name'];
242+
$target = $tmpPath . '/' . $tmpName;
243+
$state = JFile::copy($source, $target);
244+
245+
$tmpUri = SocialFieldsUserAvatarHelper::getStorageURI('file');
246+
$uri = $tmpUri . '/' . $tmpName;
247+
248+
$ajax->resolve($file, $uri, $target);
249+
250+
$data = array();
251+
$data['temp_path'] = $target;
252+
$data['temp_uri'] = $uri;
253+
254+
return $data;
255+
}
256+
257+
// to create temp group cover data
258+
public function ajax_cover($file,$uname='cover_file')
259+
{
260+
/*
261+
$cls_obj = new SocialFieldsUserCover();
262+
$cover_obj = $cls_obj->createCover($file,$uname);
263+
264+
return $cover_obj;
265+
*/
266+
267+
// Load our own image library
268+
$image = FD::image();
269+
270+
// Generates a unique name for this image.
271+
$name = $file['name'];
272+
273+
// Load up the file.
274+
$image->load($file['tmp_name'], $name);
275+
276+
// Ensure that the image is valid.
277+
if (!$image->isValid()) {
278+
return false;
279+
//need error code here
280+
}
281+
282+
// Get the storage path
283+
$storage = SocialFieldsUserCoverHelper::getStoragePath($uname);
284+
285+
// Create a new avatar object.
286+
$photos = FD::get('Photos', $image);
287+
288+
// Create avatars
289+
$sizes = $photos->create($storage);
290+
291+
// We want to format the output to get the full absolute url.
292+
$base = basename($storage);
293+
294+
$result = array();
295+
296+
foreach ($sizes as $size => $value) {
297+
$row = new stdClass();
298+
299+
$row->title = $file['name'];
300+
$row->file = $value;
301+
$row->path = JPATH_ROOT . '/media/com_easysocial/tmp/' . $base . '/' . $value;
302+
$row->uri = rtrim(JURI::root(), '/') . '/media/com_easysocial/tmp/' . $base . '/' . $value;
303+
304+
$result[$size] = $row;
305+
}
306+
307+
return $result;
308+
309+
}
310+
223311
}

0 commit comments

Comments
 (0)