示例#1
0
/**
 * Get the UUID value of the web scripts extension directory.
 *
 * The path is as follows /Data Dictionary/Web Scripts Extensions/
 *
 * @param bool $moodle Whether to get the UUID of the Moodle web scripts folder (optional)
 * @return string|bool The node UUID value on succes, False otherwise.
 */
function alfresco_get_web_scripts_dir($moodle = false)
{
    $dir = alfresco_read_dir();
    if (empty($dir->folders)) {
        return false;
    }
    foreach ($dir->folders as $folder) {
        if ($folder->title == 'Data Dictionary') {
            $dir = alfresco_read_dir($folder->uuid);
            if (empty($dir->folders)) {
                return false;
            }
            foreach ($dir->folders as $folder) {
                if ($folder->title == 'Web Scripts Extensions') {
                    if (!$moodle) {
                        return $folder->uuid;
                    }
                    $dir = alfresco_read_dir($folder->uuid);
                    if (empty($dir->folders)) {
                        return false;
                    }
                    foreach ($dir->folders as $folder) {
                        if ($folder->title == 'org') {
                            $dir = alfresco_read_dir($folder->uuid);
                            if (empty($dir->folders)) {
                                return false;
                            }
                            foreach ($dir->folders as $folder) {
                                if ($folder->title == 'alfresco') {
                                    $dir = alfresco_read_dir($folder->uuid);
                                    if (empty($dir->folders)) {
                                        return false;
                                    }
                                    foreach ($dir->folders as $folder) {
                                        if ($folder->title == 'moodle') {
                                            debugging('Returning UUID for ' . $folder->title . ': ' . $folder->uuid);
                                            return $folder->uuid;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
 /**
  * Read a directory from the repository server.
  *
  * @param string $uuid     Unique identifier for a node.
  * @param bool   $useadmin Set to false to make sure that the administrative user configured in
  *                         the plug-in is not used for this operation (default: true).
  * @return object|bool An object representing the layout of the directory or
  *                     False on failure.
  */
 function read_dir($uuid = '', $useadmin = true)
 {
     if (ALFRESCO_DEBUG_TRACE) {
         mtrace('read_dir(' . $uuid . ', ' . ($useadmin !== true ? 'false' : 'true') . ')');
     }
     if (!$this->get_defaults()) {
         return false;
     }
     if (self::is_version('3.2')) {
         return alfresco_read_dir($uuid, $useadmin);
     } else {
         if (self::is_version('3.4')) {
             if (empty($uuid)) {
                 if ($root = $this->get_root()) {
                     $uuid = $root->uuid;
                 }
             }
             if (!($result = $this->cmis->getChildren('workspace://SpacesStore/' . $uuid))) {
                 return false;
             }
             $return = new stdClass();
             $return->folders = array();
             $return->files = array();
             foreach ($result->objectsById as $child) {
                 $type = '';
                 $node = alfresco_process_node_new($child, $type);
                 if ($type == ALFRESCO_TYPE_FOLDER) {
                     $return->folders[] = $node;
                     // Only include a file in the list if it's title does not start with a period '.'
                 } else {
                     if ($type == ALFRESCO_TYPE_DOCUMENT && !empty($node->title) && $node->title[0] !== '.') {
                         $return->files[] = $node;
                     }
                 }
             }
             return $return;
         }
     }
 }