public function getActivities($ids, $appId, $sortBy, $filterBy, $filterOp, $filterValue, $startIndex, $count, $fields, $activityIds) {
// public function getActivities($ids, $appId, $sortBy, $filterBy, $filterOp, $filterValue, $startIndex, $count, $fields) {
- global $db;
//TODO add support for filterBy, filterOp and filterValue
$this->checkDb();
$activities = array();
}
/**
- * I didn't implement this yet
+ * I haven't implement this yet
*/
private function getMediaItems($activity_id) {
$media = array();
return $media;
}
+ /**
+ * Retrieve all the groups of this person.
+ * reference: http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/restful-protocol.html Section 2.3
+ * Group ID, and Title.
+ * @param Array member ids
+ */
+ public function getPersonGroups($ids){
+ $this->checkDb();
+ $ret = array();
+
+ foreach ($ids as $k=>$v){
+ $ids[$k] = intval($v);
+ }
+ $ids = implode(', ', $ids);
+ $sql = "SELECT m.member_id, g.id, g.name FROM ".TABLE_PREFIX."social_groups_members m LEFT JOIN ".TABLE_PREFIX."social_groups g ON m.group_id=g.id WHERE m.member_id IN ($ids)";
+ $result = mysql_query($sql, $this->db);
+ if ($result){
+ while(list($member_id, $group_id, $group_name) = mysql_fetch_row($result)){
+ $ret[$member_id][] = array($group_id, $group_name);
+ }
+ }
+ return $ret;
+ }
+
/**
* @param Int Sender's member id
* @param appId application id
* @return null
*/
public function createMessage($member_id, $appId, $message){
- global $db;
$this->checkDb();
$app_id = intval($app_id);
$member_id = intval($member_id);
}
public function getFriendIds($member_id) {
- global $db;
$this->checkDb();
$ret = array();
- $person_id = intval($person_id);
- $sql = "select member_id, friend_id from ".TABLE_PREFIX."social_friends where member_id = $member_id or friend_id = $member_id";
+ $member_id = intval($member_id);
+ $sql = "SELECT member_id, friend_id from ".TABLE_PREFIX."social_friends WHERE member_id = $member_id or friend_id = $member_id";
$res = mysql_query($sql, $this->db);
while (list($mid, $fid) = mysql_fetch_row($res)) {
$id = ($mid == $member_id) ? $fid : $mid;
}
public function deleteAppData($member_id, $key, $app_id) {
- global $db;
$this->checkDb();
$person_id = intval($member_id);
$app_id = intval($app_id);
--- /dev/null
+<?php
+/***********************************************************************/
+/* ATutor */
+/***********************************************************************/
+/* Copyright (c) 2002-2010 */
+/* Inclusive Design Institute */
+/* http://atutor.ca */
+/* */
+/* This program is free software. You can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation. */
+/***********************************************************************/
+// $Id$
+
+class ATutorGroupService extends ATutorService implements GroupService {
+ /**
+ * Fetch groups for a list of ids.
+ * @param UserId The user id to perform the action for
+ * @param GroupId optional grouping ID
+ * @param token The SecurityToken for this request
+ * @return ResponseItem a response item with the error code set if
+ * there was a problem
+ */
+ function getPersonGroups($userId, GroupId $groupId, SecurityToken $token){
+ $ids = $this->getIdSet($userId, $groupId, $token);
+ $data = ATutorDbFetcher::get()->getPersonGroups($ids);
+ // If the data array is empty, return empty DataCollection.
+ return new DataCollection($data);
+ }
+}
+?>
\ No newline at end of file