Author: chabotc
Date: Tue Jun 17 06:43:09 2008
New Revision: 668666

URL: http://svn.apache.org/viewvc?rev=668666&view=rev
Log:
SHINDIG-390 BasicAppDataService:getPersonData() sample code didn't honor the 
GroupId token. Added group id parsing to it

Modified:
    
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicAppDataService.php

Modified: 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicAppDataService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicAppDataService.php?rev=668666&r1=668665&r2=668666&view=diff
==============================================================================
--- 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicAppDataService.php
 (original)
+++ 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicAppDataService.php
 Tue Jun 17 06:43:09 2008
@@ -44,16 +44,33 @@
        {
                $allData = XmlStateFileFetcher::get()->getAppData();
                $data = array();
-               $id = $userId->getUserId($token);
-               if (isset($allData[$id])) {
-                       $allPersonData = $allData[$id];
-                       $personData = array();
-                       foreach (array_keys($allPersonData) as $key) {
-                               if (in_array($key, $fields) || $fields[0] == 
"*") {
-                                       $personData[$key] = 
$allPersonData[$key];
+               $ids = array();
+               switch($groupId->getType()) {
+                       case 'self':
+                               $ids[] = $userId->getUserId($token);
+                               break;
+                       case 'all':
+                       case 'friends':
+                               $friendIds = 
XmlStateFileFetcher::get()->getFriendIds();
+                               if (is_array($friendIds) && count($friendIds) 
&& isset($friendIds[$userId->getUserId($token)])) {
+                                       $ids = 
$friendIds[$userId->getUserId($token)];
+                               }
+                               break;
+                       default:
+                               return new ResponseItem(NOT_IMPLEMENTED, "We 
don't support fetching data in batches yet", null);                
+                               break;
+               }
+               foreach ($ids as $id) {
+                       if (isset($allData[$id])) {
+                               $allPersonData = $allData[$id];
+                               $personData = array();
+                               foreach (array_keys($allPersonData) as $key) {
+                                       if (in_array($key, $fields) || 
$fields[0] == "*") {
+                                               $personData[$key] = 
$allPersonData[$key];
+                                       }
                                }
+                               $data[$id] = $personData;
                        }
-                       $data[$id] = $personData;
                }
                return new ResponseItem(null, null, 
RestFulCollection::createFromEntry($data));
        }


Reply via email to