示例#1
0
    /**
     * Validate that the "migrate_all_users" method correctly deletes legacy
     * @uses $CFG, $DB
     * numeric user directories
     */
    public function test_migrate_all_users_handles_deleted_users() {
        $this->resetAfterTest(true);
        $this->setup_test_data_xml();

        global $CFG, $DB;

        $repo = repository_factory::factory('elisfiles');

        // Our test username
        $username = '******';

        // Set up the user in Alfresco
        $elisfiles = new ELIS_files();
        $elisfiles->migrate_user($username);

        // Validate that the user exists and that their home directory was set up
        // (for sanity reasons only)
        $userexists = elis_files_request('/api/people/'.$username);
        $this->assertNotEquals(false, $userexists);

        $initialuserhome = elis_files_get_home_directory($username);
        $this->assertNotEquals(false, $initialuserhome);

        // Change the node name to the "old" style
        $test = elis_files_node_rename($initialuserhome, '100');

        // Run the migration method
        $usr = new stdClass();
        $usr->id = 100;
        $usr->deleted = 1;
        $DB->update_record('user', $usr);

        $elisfiles->migrate_all_users();

        // Validate cleanup for the legacy folder
        $legacyuuid = false;
        $dir = elis_files_read_dir($elisfiles->uhomesuid, true);
        foreach ($dir->folders as $folder) {
            if ($folder->title == '100') {
                $legacyuuid = $folder->uuid;
            }
        }

        // Clean up the non-legacy data before final validation
        $elisfiles->delete_user($username);

        $this->assertEquals(false, $legacyuuid);
    }
示例#2
0
文件: lib.php 项目: jamesmcq/elis
/**
 * 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 $CFG
 * @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 elis_files_quota_info($username = '') {
    global $CFG, $USER;

    if (empty($username)) {
        $username = $USER->username;
    }

    $username = elis_files_transform_username($username);

    // Get the JSON response containing user data for the given account.
    if (($json = elis_files_request('/api/people/' . $username)) === false) {
        return false;
    }

    $userdata = elis_files_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;
}
示例#3
0
/**
 * 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 (ELIS_FILES_DEBUG_TRACE) mtrace('/moodle/nodeinherit/' . $uuid . '?enabled=' . ($inherit ? 'true' : 'false'));

        $response = elis_files_request('/moodle/nodeinherit/' . $uuid . '?enabled=' . ($inherit ? 'true' : 'false'));

        try {
            $sxml = new SimpleXMLElement($response);
        } catch (Exception $e) {
            debugging(get_string('badxmlreturn', 'repository_elisfiles') . "\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'));
    }