@@ -271,6 +271,16 @@ private function _setApiCallbacks($apiMethodPrefix)
271
271
$ this ->helpContent [$ apiMethodPrefix .'folder.get ' ] = $ help ;
272
272
$ this ->apicallbacks [$ apiMethodPrefix .'folder.get ' ] = array (&$ this , 'folderGet ' );
273
273
274
+ $ help = array ();
275
+ $ help ['params ' ] = array ();
276
+ $ help ['params ' ]['token ' ] = '(Optional) Authentification token ' ;
277
+ $ help ['params ' ]['id ' ] = 'Id of the folder ' ;
278
+ $ help ['example ' ] = array ();
279
+ $ help ['return ' ] = 'List of children ' ;
280
+ $ help ['description ' ] = 'Get all of the immediate children of a folder ' ;
281
+ $ this ->helpContent [$ apiMethodPrefix .'folder.children ' ] = $ help ;
282
+ $ this ->apicallbacks [$ apiMethodPrefix .'folder.children ' ] = array (&$ this , 'folderChildren ' );
283
+
274
284
$ help = array ();
275
285
$ help ['params ' ] = array ();
276
286
$ help ['params ' ]['token ' ] = '(Optional) Authentification token ' ;
@@ -301,6 +311,7 @@ private function _setApiCallbacks($apiMethodPrefix)
301
311
$ this ->helpContent [$ apiMethodPrefix .'folder.tree ' ] = $ help ;
302
312
$ this ->apicallbacks [$ apiMethodPrefix .'folder.tree ' ] = array (&$ this , 'folderTree ' );
303
313
314
+ /** ----- User -------------*/
304
315
$ help = array ();
305
316
$ help ['params ' ] = array ();
306
317
$ help ['params ' ]['token ' ] = '(Optional) Authentification token ' ;
@@ -310,6 +321,16 @@ private function _setApiCallbacks($apiMethodPrefix)
310
321
$ this ->helpContent [$ apiMethodPrefix .'user.folders ' ] = $ help ;
311
322
$ this ->apicallbacks [$ apiMethodPrefix .'user.folders ' ] = array (&$ this , 'userFolders ' );
312
323
324
+ $ help = array ();
325
+ $ help ['params ' ] = array ();
326
+ $ help ['params ' ]['email ' ] = 'The user \'s email ' ;
327
+ $ help ['params ' ]['password ' ] = 'The user \'s password ' ;
328
+ $ help ['example ' ] = array ();
329
+ $ help ['return ' ] = 'The user \'s default API key ' ;
330
+ $ help ['description ' ] = 'Gets the user \'s default API key. Only call this the first time a new password is used ' ;
331
+ $ this ->helpContent [$ apiMethodPrefix .'user.apikey.default ' ] = $ help ;
332
+ $ this ->apicallbacks [$ apiMethodPrefix .'user.apikey.default ' ] = array (&$ this , 'userApikeyDefault ' );
333
+
313
334
/** ------ ITEM --- */
314
335
$ help = array ();
315
336
$ help ['params ' ] = array ();
@@ -845,6 +866,24 @@ function folderGet($args)
845
866
return $ folder ->toArray ();
846
867
}
847
868
869
+ /** Get the immediate children of a folder */
870
+ function folderChildren ($ args )
871
+ {
872
+ if (!array_key_exists ('id ' , $ args ))
873
+ {
874
+ throw new Exception ('Parameter id is not defined ' , MIDAS_INVALID_PARAMETER );
875
+ }
876
+
877
+ $ id = $ args ['id ' ];
878
+ $ folder = $ this ->Folder ->load ($ id );
879
+
880
+ $ userDao = $ this ->_getUser ($ args );
881
+ $ folders = $ this ->Folder ->getChildrenFoldersFiltered ($ folder , $ userDao );
882
+ $ items = $ this ->Folder ->getItemsFiltered ($ folder , $ userDao );
883
+
884
+ return array ('folders ' => $ folders , 'items ' => $ items );
885
+ }
886
+
848
887
/** Create a folder */
849
888
function folderCreate ($ args )
850
889
{
@@ -1168,13 +1207,13 @@ function resourceGet($args)
1168
1207
}
1169
1208
1170
1209
/** Returns a path of uuids from the root community to the given node */
1171
- function pathFromRoot ($ args )
1210
+ function pathFromRoot ($ args )
1172
1211
{
1173
1212
return array_reverse ($ this ->pathToRoot ($ args ));
1174
1213
}
1175
1214
1176
1215
/** Returns a path of uuids from the given node to the root community */
1177
- function pathToRoot ($ args )
1216
+ function pathToRoot ($ args )
1178
1217
{
1179
1218
if (!array_key_exists ('uuid ' , $ args ))
1180
1219
{
@@ -1334,5 +1373,28 @@ function userFolders($args)
1334
1373
$ userRootFolder = $ userDao ->getFolder ();
1335
1374
return $ this ->Folder ->getChildrenFoldersFiltered ($ userRootFolder , $ userDao , MIDAS_POLICY_READ );
1336
1375
}
1376
+
1377
+ /**
1378
+ * Returns the user's default API key given their username and password
1379
+ */
1380
+ function userApikeyDefault ($ args )
1381
+ {
1382
+ if (!$ this ->_request ->isPost ())
1383
+ {
1384
+ throw new Exception ('POST method required ' , MIDAS_HTTP_ERROR );
1385
+ }
1386
+ if (!array_key_exists ('email ' , $ args ))
1387
+ {
1388
+ throw new Exception ('Parameter email is not defined ' , MIDAS_INVALID_PARAMETER );
1389
+ }
1390
+ if (!array_key_exists ('password ' , $ args ))
1391
+ {
1392
+ throw new Exception ('Parameter password is not defined ' , MIDAS_INVALID_PARAMETER );
1393
+ }
1394
+
1395
+ $ salt = Zend_Registry::get ('configGlobal ' )->password ->prefix ;
1396
+ $ defaultApiKey = $ key = md5 ($ args ['email ' ].md5 ($ salt .$ args ['password ' ]).'Default ' );
1397
+ return array ('apikey ' => $ defaultApiKey );
1398
+ }
1337
1399
} // end class
1338
1400
?>
0 commit comments