$options = array(ALFRESCO_BROWSE_MOODLE_FILES => get_string('moodlefiles', 'repository'), ALFRESCO_BROWSE_ALFRESCO_SITE_FILES => get_string('repositorysitefiles', 'repository'), ALFRESCO_BROWSE_ALFRESCO_SHARED_FILES => get_string('repositorysharedfiles', 'repository'), ALFRESCO_BROWSE_ALFRESCO_COURSE_FILES => get_string('repositorycoursefiles', 'repository'), ALFRESCO_BROWSE_ALFRESCO_USER_FILES => get_string('repositoryuserfiles', 'repository')); $settings->add(new admin_setting_configselect('repository_alfresco_default_browse', get_string('defaultfilebrowsinglocation', 'repository_alfresco'), get_string('configdefaultfilebrowsinglocation', 'repository_alfresco'), ALFRESCO_BROWSE_MOODLE_FILES, $options)); // Display menu option about overriding the Moodle 'admin' account when creating an Alfresco user account. // Check for the existence of a user that will conflict with the default Alfresco administrator account. $hasadmin = record_exists('user', 'username', 'admin', 'mnethostid', $CFG->mnet_localhost_id); if (empty($CFG->repository_alfresco_admin_username)) { $adminusername = '******'; set_config('repository_alfresco_admin_username', $adminusername); } else { $adminusername = $CFG->repository_alfresco_admin_username; } // Only proceed here if the Alfresco plug-in is actually enabled. if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) { require_once $CFG->dirroot . '/file/repository/repository.class.php'; if ($repo = repository_factory::factory('alfresco')) { if (alfresco_get_home_directory($adminusername) == false) { // If the specified username does not exist in Alfresco yet, allow the value to be changed here. $settings->add(new admin_setting_configtext('repository_alfresco_admin_username', get_string('adminusername', 'repository_alfresco'), get_string('configadminusername', 'repository_alfresco'), 'moodleadmin')); } else { // An Alfresco account with the specified username has been created, check if a Moodle account exists with that // username and display a warning if that is the case. if (($userid = get_field('user', 'id', 'username', $adminusername, 'mnethostid', $CFG->mnet_localhost_id)) !== false) { $a = new stdClass(); $a->username = $adminusername; $a->url = $CFG->wwwroot . '/user/editadvanced.php?id=' . $userid . '&course=' . SITEID; $settings->add(new admin_setting_heading('repository_alfresco_admin_username', get_string('adminusername', 'repository_alfresco'), get_string('configadminusernameconflict', 'repository_alfresco', $a))); } else { $settings->add(new admin_setting_heading('repository_alfresco_admin_username', get_string('adminusername', 'repository_alfresco'), get_string('configadminusernameset', 'repository_alfresco', $adminusername))); } } }
/** * Delete an Alfresco user account, optionally * * @param string $username The Alfresco account username to delete. * @param bool $deletehomedir Set to true to delete the user's home directory. * @return bool True on success, False otherwise. */ function alfresco_delete_user($username, $deletehomedir = false) { $status = true; $username = alfresco_transform_username($username); if ($deletehomedir) { $uuid = alfresco_get_home_directory($username); } $status = alfresco_send('/api/people/' . $username, array(), 'DELETE') !== false; // Actually go through with deleting the home directory if it was requested and we found the UUID. if (!empty($uuid)) { $status = $status && alfresco_delete($uuid, true); } return $status; }
/** * Get an Alfresco user's home directory UUID. * * @param string $username The Alfresco user's username. * @return string|bool The UUID of the home directory or, False. */ function alfresco_userdir($username) { global $CFG; if (ALFRESCO_DEBUG_TRACE) { mtrace('alfresco_userdir(' . $username . ')'); } if (($uuid = alfresco_get_home_directory($username)) === false) { return false; } return $uuid; }