Example #1
0
/**
 * Get the current quota information for a user from the Alfresco server.
 *
 * The return object contains two properties as follows:
 *  quota   - The maximum amount of data the user can have in the system (in bytes)
 *  current - The current amount of data that this user has allocated (in bytes)
 *
 * NOTE: no quota is represented by a value of -1 for the 'quota' property.
 *
 * @uses $USER
 * @param string $username A Moodle username.
 * @return object|bool An object containing the quota values for this user or, False on error.
 */
function alfresco_quota_info($username = '')
{
    global $USER;
    if (empty($username)) {
        $username = $USER->username;
    }
    $username = alfresco_transform_username($username);
    // Get the JSON response containing user data for the given account.
    if (($json = alfresco_request('/api/people/' . $username)) === false) {
        return false;
    }
    $userdata = alfresco_json_parse($json);
    if (!isset($userdata->quota) || !isset($userdata->sizeCurrent)) {
        return false;
    }
    $userquota = new stdClass();
    $userquota->quota = $userdata->quota;
    $userquota->current = $userdata->sizeCurrent;
    return $userquota;
}
 /**
  * Toggle the setting for "Inherit Parent Space Permissions" on a specific node.
  *
  * @param string $uuid    Unique identifier for a node.
  * @param bool   $inherit Flag to indicate whether to set inheritance on or off.
  * @return bool True on success, False otherwise.
  */
 function node_inherit($uuid, $inherit)
 {
     if (ALFRESCO_DEBUG_TRACE) {
         mtrace('/moodle/nodeinherit/' . $uuid . '?enabled=' . ($inherit ? 'true' : 'false'));
     }
     $response = alfresco_request('/moodle/nodeinherit/' . $uuid . '?enabled=' . ($inherit ? 'true' : 'false'));
     try {
         $sxml = new SimpleXMLElement($response);
     } catch (Exception $e) {
         debugging(get_string('badxmlreturn', 'repository_alfresco') . "\n\n{$response}", DEBUG_DEVELOPER);
         return false;
     }
     if (empty($sxml->uuid) || empty($sxml->enabled)) {
         return false;
     }
     return $sxml->uuid == $uuid && ($inherit && $sxml->enabled == 'true' || !$inherit && $sxml->enabled == 'false');
 }