function _soc_boxauth_diagnostics() { if (!BoxFolderOperations::isSessionActive()) { return 'Box not active'; } $content = '<pre>'; $content .= print_r($_SESSION['box'], true); $folder = new BoxFolder(0, $_SESSION['box']['access_token']); $content .= print_r($folder->getItems(), true); $content .= '</pre>'; return $content; }
function soc_boxgroup_test($gid) { if (!BoxFolderOperations::isSessionActive()) { return 'Box session not active'; } $box_id = BoxFolderOperations::getBoxFolderID($gid); if (!$box_id) { $folder = new BoxFolder($box_id, BoxFolderOperations::getCurrentAccessToken()); } $to_return[] = 'TESTING:'; $to_return[] = $box_id; //$to_return[] = '<pre>' . print_r(json_decode($folder->getCollaborations()), TRUE) . '</pre>'; $to_return[] = '<h2>Collaborators Object</h2><pre>' . print_r($folder->getCollabortiorNames(), TRUE) . '</pre>'; return '<p>' . implode('</p><p>', $to_return) . '</p>'; }
/** * * Imports the tree structure and allows us to provide some extended functionality * at some point. Don't run import manually. It expects certain things that are * delivered through the API. Instead, if you need a tree structure of something, * simply call Client->folder(folder_id); and it will automatically return * the right stuff. * * Due to an inconsistency with the Box.net ReST API, this section invovles a few * more checks than normal to ensure that all the necessary values are available * when doing the import. * @param array $tree * @return null */ public function import(array $tree) { foreach ($tree['@attributes'] as $key => $val) { $this->attributes[$key] = $val; } if (array_key_exists('folders', $tree)) { if (array_key_exists('folder', $tree['folders'])) { if (array_key_exists('@attributes', $tree['folders']['folder'])) { // this is the case when there is a single folder within the root $boxFolder = new BoxFolder(); $boxFolder->import($tree['folders']['folder']); $this->folders[] = $boxFolder; } else { // this is the case when there are multiple folders within the root foreach ($tree['folders']['folder'] as $folder) { $boxFolder = new BoxFolder(); $boxFolder->import($folder); $this->folders[] = $boxFolder; } } } } if (array_key_exists('files', $tree)) { if (array_key_exists('file', $tree['files'])) { if (array_key_exists('@attributes', $tree['files']['file'])) { // this is the case when there is a single file within a directory $boxFile = new BoxFile(); $boxFile->import($tree['files']['file']); $this->files[] = $boxFile; } else { // this is the case when there are multiple files in a directory foreach ($tree['files']['file'] as $file) { $boxFile = new BoxFile(); $boxFile->import($file); $this->files[] = $boxFile; } } } } }