Example #1
0
/**
 * Delete a node from the repository, optionally recursing into sub-directories (only
 * relevant when the node being deleted is a folder).
 *
 * @uses $CFG
 * @uses $USER
 * @param string $uuid      The node UUID.
 * @param bool   $recursive Whether to recursively delete child content.
 * @return mixed
 */
function alfresco_delete($uuid, $recursive = false, $repo = NULL)
{
    global $CFG, $USER;
    if (ALFRESCO_DEBUG_TRACE) {
        print_object('alfresco_delete(' . $uuid . ', ' . $recursive . ')');
    }
    // Ensure that we set the configured admin user to be the owner of the deleted file before deleting.
    // This is to prevent the user's Alfresco account from having space incorrectly attributed to it.
    // ELIS-1102
    alfresco_request('/moodle/nodeowner/' . $uuid . '?username='******'3.2')) {
        return true === alfresco_send(alfresco_get_uri($uuid, 'delete'), array(), 'DELETE');
    } else {
        if (repository_plugin_alfresco::is_version('3.4')) {
            // Get node type and use descendants delete for folders
            $node_type = alfresco_get_type($uuid);
            if (!(strstr($node_type, $repo->type_folder) === FALSE)) {
                if (alfresco_send('/cmis/i/' . $uuid . '/descendants', array(), 'DELETE') === false) {
                    return false;
                }
            } else {
                if (alfresco_send('/cmis/i/' . $uuid, array(), 'DELETE') === false) {
                    return false;
                }
            }
            return true;
        }
    }
}
 /**
  * Delete a node from the repository, optionally recursing into sub-directories (only
  * relevant when the node being deleted is a folder).
  *
  * @uses $CFG
  * @uses $USER
  * @param string $uuid      The node UUID.
  * @param bool   $recursive Whether to recursively delete child content.
  * @return mixed
  */
 function delete($uuid, $recursive = false)
 {
     global $CFG, $USER;
     if (ALFRESCO_DEBUG_TRACE) {
         print_object('repo alfresco_delete(' . $uuid . ', ' . $recursive . ')');
     }
     // Ensure that we set the configured admin user to be the owner of the deleted file before deleting.
     // This is to prevent the user's Alfresco account from having space incorrectly attributed to it.
     // ELIS-1102
     // Ensure that we set the configured admin user to be the owner of the deleted file before deleting.
     alfresco_request('/moodle/nodeowner/' . $uuid . '?username='******'3.2')) {
         return true === alfresco_send(alfresco_get_uri($uuid, 'delete'), array(), 'DELETE');
     } else {
         if (self::is_version('3.4')) {
             if ($this->is_dir($uuid)) {
                 if (alfresco_send('/cmis/i/' . $uuid . '/descendants', array(), 'DELETE') === false) {
                     return false;
                 }
             } else {
                 if ($this->cmis->deleteObject('workspace://SpacesStore/' . $uuid) === false) {
                     return false;
                 }
             }
             return true;
         }
     }
 }