function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $content = '';
     $footer = '';
     $nologin_auths = block_repository_nopasswd_auths();
     if (!empty($USER->auth) && in_array($USER->auth, $nologin_auths)) {
         return '';
     }
     if (isloggedin() && file_exists($CFG->dirroot . '/file/repository/alfresco/repository.php')) {
         require_once $CFG->dirroot . '/file/repository/repository.class.php';
         if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) {
             if ($repo = repository_factory::factory('alfresco')) {
                 if ($repo->alfresco_userdir($USER->username) !== false) {
                     // Fix username
                     $username = repository_plugin_alfresco::fix_username($USER->username);
                     // So that we don't conflict with the default Alfresco admin account.
                     $username = $username == 'admin' ? $CFG->repository_alfresco_admin_username : $username;
                     $hastenant = false;
                     // We must include the tenant portion of the username here.
                     if (($tenantname = strpos($CFG->repository_alfresco_server_username, '@')) > 0) {
                         $username .= substr($CFG->repository_alfresco_server_username, $tenantname);
                         $hastenant = true;
                     }
                     // Display a link to access the Alfresco repository directly.
                     $content .= get_string('webappaccess', 'block_repository', $repo->get_webapp_url()) . '<br /><br />';
                     // Display a link to the configured embedded WebDAV client (if defined).
                     if (!empty($CFG->block_course_repository_webdav_client)) {
                         $content .= get_string('embeddedwebdavlink', 'block_repository', $CFG->block_course_repository_webdav_client) . '<br /><br />';
                     }
                     if ($hastenant || $username != $USER->username) {
                         $content .= get_string('usernametenantinfo', 'block_repository', $username);
                     } else {
                         $content .= get_string('usernameinfo', 'block_repository', $username);
                     }
                     // Display a link to defined help files
                     if (!empty($CFG->block_course_repository_help_link)) {
                         $footer = get_string('helpfileslink', 'block_repository', $CFG->block_course_repository_help_link);
                     }
                 }
             }
         }
     }
     // If there is no content and the current user can actually modify the site settings, display some text
     // in the block explaining what is happening.
     if (empty($content) && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
         if (file_exists($CFG->dirroot . '/admin/file/repositories.php')) {
             $content = get_string('alfresconotconfigured', 'block_repository', $CFG->wwwroot . '/admin/file/' . 'repositories.php');
         } else {
             $content = get_string('norepositorypluginsystem', 'block_repository');
         }
     }
     $this->content = new stdClass();
     $this->content->text = $content;
     $this->content->footer = $footer;
     return $this->content;
 }
 function output_html($data, $query = '')
 {
     global $CFG;
     require_js($CFG->wwwroot . '/file/repository/alfresco/rootfolder.js');
     $default = $this->get_defaultsetting();
     $repoisup = false;
     /// Validate the path, if we can.
     if ($repo = repository_factory::factory('alfresco')) {
         $repoisup = $repo->is_configured() && $repo->verify_setup();
         if ($repoisup) {
             if (empty($CFG->repository_alfresco_root_folder)) {
                 // if alfresco root folder is currently empty, set it to moodle (the default)
                 $root_folder = '/moodle';
             } else {
                 $root_folder = $CFG->repository_alfresco_root_folder;
             }
             if ($root_folder == s($data) && !empty($repo->muuid)) {
                 $valid = '<span class="pathok">&#x2714;</span>';
             } else {
                 $valid = '<span class="patherror">&#x2718;</span>';
             }
         }
     }
     if (!isset($valid)) {
         $valid = '';
     }
     $inputs = '<div class="form-file defaultsnext"><input type="text" size="48" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '" value="' . s($data) . '" /> <input type="button" ' . 'onclick="return chooseRootFolder(document.getElementById(\'adminsettings\'));" value="' . get_string('chooserootfolder', 'repository_alfresco') . '" name="' . $this->get_full_name() . '"' . (!$repoisup ? ' disabled="disabled"' : '') . ' />' . $valid . '</div>';
     return format_admin_setting($this, $this->visiblename, $inputs, $this->description, true, '', $default, $query);
 }
예제 #3
0
    /**
     * Test that info is returned for the root uuid
     */
    public function test_get_folder_response() {
        $this->resetAfterTest(true);
        $this->setup_test_data_xml();

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

        // Look for the Company Home folder
        $uuid = $repo->root->uuid;

        $response = $repo->get_info($uuid);

        // Verify that we get a valid response
        $this->assertNotEquals(false, $response);
        // Verify that response has a uuid
        $this->assertObjectHasAttribute('uuid', $response);
        // Verify that the correct uuid is returned
        $this->assertEquals($repo->root->uuid, $response->uuid);
        // Verify that response has a type
        $this->assertObjectHasAttribute('type', $response);
        // Verify that type is folder
        $this->assertEquals(ELIS_files::$type_folder, $response->type);
        // Verify that title is set
        $this->assertObjectHasAttribute('title', $response);
        // Verify that created is set
        $this->assertObjectHasAttribute('created', $response);
        // Verify that modified is set
        $this->assertObjectHasAttribute('modified', $response);
        // Verify that summary is set
        $this->assertObjectHasAttribute('summary', $response);
        // Verify that Owner is set
        $this->assertObjectHasAttribute('owner', $response);
    }
예제 #4
0
    /**
     * This function loads data into the PHPUnit tables for testing
     */
    protected function setup_test_data_xml() {
        if (!file_exists(__DIR__.'/fixtures/elis_files_config.xml')) {
            $this->markTestSkipped('You must define elis_files_config.xml inside '.__DIR__.
                    '/fixtures/ directory to execute this test.');
        }
        $this->loadDataSet($this->createXMLDataSet(__DIR__.'/fixtures/elis_files_config.xml'));

        // Check if Alfresco is enabled, configured and running first.
        if (!$repo = repository_factory::factory('elisfiles')) {
            $this->markTestSkipped('Could not connect to alfresco with supplied credentials. Please try again.');
        }
    }
 /**
  * Retrieves the repository object used by this assignment type, if applicable
  *
  * @return  mixed  An object representing the repository used to store files, or
  *                 false isf the appropriate configuration is not complete
  */
 function get_repository_object()
 {
     global $CFG;
     //make sure a default repository plugin is selected
     if (empty($CFG->repository)) {
         return false;
     }
     //make sure everything is configured as needed
     if (!isset($CFG->repository_plugins_enabled) || strstr($CFG->repository_plugins_enabled, 'alfresco') === false || !($repo = repository_factory::factory('alfresco')) || !$repo->is_configured() || !$repo->verify_setup()) {
         //accessibility / configuration error
         return false;
     }
     //success
     return $repo;
 }
예제 #6
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);
    }
예제 #7
0
/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2009 Remote-Learner.net Inc (http://www.remote-learner.net)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    elis
 * @subpackage File system
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_repository_alfresco_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007011900) {
        $result = install_from_xmldb_file($CFG->dirroot . '/repository/alfresco/db/install.xml');
    }
    if ($result && $oldversion < 2010030901) {
        $table = new XMLDBTable('alfresco_course_store');
        $table->comment = 'Stores course storage UUID values';
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('uuid', XMLDB_TYPE_CHAR, '36', null, false, null, null, null, null);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
        $table->addIndexInfo('courseid-uuid', XMLDB_INDEX_UNIQUE, array('courseid', 'uuid'));
        $result = $result && create_table($table);
        // Only proceed here if the Alfresco plug-in is actually enabled.
        if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) {
            // Handle upgrading some things on the Alfresco repository.
            require_once $CFG->dirroot . '/file/repository/repository.class.php';
            if (!($repo = repository_factory::factory('alfresco'))) {
                debugging(get_string('couldnotcreaterepositoryobject', 'repository'), DEBUG_DEVELOPER);
                $result = false;
            }
            // Turn off "Inherit parent space permissions" for the special Moodle storage directories.
            $result = $result && $repo->node_inherit($repo->muuid, false);
            $result = $result && $repo->node_inherit($repo->suuid, false);
            $result = $result && $repo->node_inherit($repo->cuuid, false);
            // Make sure that all of the individual course directories are set to not interhit parent space permissions.
            $dir = $repo->read_dir($repo->cuuid);
            if (!empty($dir->folders)) {
                foreach ($dir->folders as $folder) {
                    if ((int) $folder->title != $folder->title || (int) $folder->title <= 1 || !($course = get_record('course', 'id', $folder->title, '', '', '', '', 'id,shortname'))) {
                        continue;
                    }
                    // Check if we need to add this node to the course store table.
                    if ($result && !record_exists('alfresco_course_store', 'courseid', $course->id)) {
                        $coursestore = new stdClass();
                        $coursestore->courseid = $course->id;
                        $coursestore->uuid = $folder->uuid;
                        $coursestore->id = insert_record('alfresco_course_store', $coursestore);
                        $result = !empty($coursestore->id);
                    }
                    $result = $result && $repo->node_inherit($folder->uuid, false);
                    $result = $result && alfresco_node_rename($folder->uuid, $course->shortname);
                }
            }
        }
    }
    if ($result && $oldversion < 2010032900) {
        // Only proceed here if the Alfresco plug-in is actually enabled.
        if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) {
            // Handle upgrading some things on the Alfresco repository.
            require_once $CFG->dirroot . '/file/repository/repository.class.php';
            if (!($repo = repository_factory::factory('alfresco'))) {
                debugging(get_string('couldnotcreaterepositoryobject', 'repository'), DEBUG_DEVELOPER);
                $result = false;
            }
            $root = $repo->get_root();
            if (!empty($root->uuid)) {
                $dir = $repo->read_dir($root->uuid, true);
                if (!empty($dir->folders)) {
                    foreach ($dir->folders as $folder) {
                        // Process each of these directories to make sure that any non-privileged user cannot directly
                        // access them.
                        if ($folder->title == 'Data Dictionary' || $folder->title == 'Guest Home' || $folder->title == 'Sites') {
                            $a = new stdClass();
                            $a->uuid = $folder->uuid;
                            $a->name = $folder->title;
                            echo '<p>' . get_string('lockingdownpermissionson', 'repository_alfresco', $a) . '</p>';
                            if ($permissions = alfresco_get_permissions($folder->uuid, 'GROUP_EVERYONE')) {
                                foreach ($permissions as $permission) {
                                    // Make sure the node isn't inheriting parent node permissions.
                                    $repo->node_inherit($folder->uuid, false);
                                    // Construct the post data
                                    $postdata = array('username' => 'GROUP_EVERYONE', 'name' => $permission, 'capability' => ALFRESCO_CAPABILITY_DENIED);
                                    // We're not going to examine the response (we assume it worked).
                                    $response = alfresco_send('/moodle/setpermissions/' . $folder->uuid, $postdata, 'POST');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($result && $oldversion < 2010090300) {
        // Add the mapping table for organization shared spaces.
        $table = new XMLDBTable('alfresco_organization_store');
        $table->comment = 'Stores organization shared storage UUID values';
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('organizationid', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('uuid', XMLDB_TYPE_CHAR, '36', null, false, null, null, null, null);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('organizationid', XMLDB_KEY_FOREIGN, array('organizationid'), 'crlm_cluster', array('id'));
        $table->addIndexInfo('organization-uuid', XMLDB_INDEX_UNIQUE, array('organizationid', 'uuid'));
        $result = $result && create_table($table);
    }
    return $result;
}
예제 #8
0
파일: lib.php 프로젝트: jamesmcq/elis
    /**
     * Determine whether the root folder is valid
     * @return  string
     */
    private static function root_folder_is_valid($data) {
        $repoisup = false;

    /// Validate the path, if we can.
        if ($repo = repository_factory::factory()) {
            $repoisup = $repo->is_configured() && $repo->verify_setup();
            if ($repoisup) {
                if (elis_files_validate_path($data)) {
                    $valid = '<span class="pathok" style="color:green;">&#x2714;</span>';
                } else {
                    $valid = '<span class="patherror" style="color:red;">&#x2718;</span>';
                }
            }
        }
        if (!isset($valid)) {
            $valid = '';
        }

        return $valid;
    }
예제 #9
0
 *
 * @package    repository_elisfiles
 * @author     Remote-Learner.net Inc
 * @copyright  (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net)
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */


define('CLI_SCRIPT', true);  // This script may only be run from the commandline


require_once(dirname(__FILE__).'/../../config.php');
require_once($CFG->dirroot.'/repository/elisfiles/ELIS_files_factory.class.php');


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

if (!$repo) {
    mtrace(get_string('couldnotinitializerepository', 'repository_elisfiles'));
    exit;
}

set_time_limit(0);  // This may take a long time.

$errors = 0;
$auths = elis_files_nopasswd_auths();

if (empty($auths) || count($auths) === 0) {
    exit;
}
예제 #10
0
파일: lib.php 프로젝트: jamesmcq/elis
function elis_files_get_config() {
    global $CFG;

    require_once($CFG->dirroot . '/repository/elisfiles/ELIS_files_factory.class.php');

    if (!$repo = repository_factory::factory()) {
        return false;
    } else {
        return $repo;
    }

}
예제 #11
0
    /**
     * Test uploading a file to Alfresco explicitly using the web services method.
     */
    public function test_upload_file_via_ftp() {
        global $USER, $SESSION;

        $this->resetAfterTest(true);
        $this->setup_test_data_xml();

        // Check if Alfresco is enabled, configured and running first
        if (!$repo = repository_factory::factory('elisfiles')) {
            $this->markTestSkipped('Repository not configured or enabled');
        }

        // We need to create a user and then force the repository connection to be reinitialized
        $USER->email = '*****@*****.**';
        $this->assertTrue($repo->migrate_user($USER, 'temppass'));
        unset($SESSION->repo);
        $this->testusercreated = true;

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

        // Explicitly set the file transfer method to FTP
        set_config('file_transfer_method', ELIS_FILES_XFER_FTP, 'elisfiles');

        $targets = array(
                $repo->root->uuid,
                $repo->muuid,
                $repo->suuid,
                $repo->cuuid,
                $repo->uuuid,
                $repo->ouuid
        );

        foreach ($targets as $uuid) {
            $filename = $this->generate_temp_file(1);
            $response = $this->call_upload_file($repo, '', $filename, $uuid);
            unlink($filename);
            $this->assertNotEquals(false, $response);
            $this->assertObjectHasAttribute('uuid', $response);
        }
    }
예제 #12
0
    /**
     * Validate duplicate user set creation
     */
    public function test_duplicate_userset_creation() {
        if (!self::$haspm) {
            $this->markTestSkipped('local_elisprogram is required for Userset testing');
        }

        $this->resetAfterTest(true);
        $this->setup_test_data_xml();

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

        $userset = new userset(array('name' => 'testuserset'));
        $userset->save();

        $uuid = $repo->get_userset_store($userset->id);
        $uuidduplicate = $repo->get_userset_store($userset->id);

        $this->assertEquals($uuidduplicate, $uuid);
    }
예제 #13
0
파일: eventlib.php 프로젝트: jamesmcq/elis
/**
 * Handle the event when a user is created in Moodle.
 *
 * @uses $CFG
 * @param object $user Moodle user record object.
 * @return bool True on success, False otherwise.
 */
function elis_files_user_created($user) {
    global $CFG;

    // Only proceed here if the Alfresco plug-in is actually enabled.
    if (!($repo = repository_factory::factory('elisfiles')) || !$repo->is_configured() || !$repo->verify_setup()) {
        //error_log("elis_files_user_created(): Alfresco NOT enabled!");
    } else {
        // create a random password for certain authentications
        $auths = elis_files_nopasswd_auths();
        if (!empty($user->auth) && in_array($user->auth, $auths)) {
            $passwd = random_string(8);
            //$user->password = md5($passwd); // TBD: or reversible encrypt
            //update_record('user', $user);
            //error_log("elis_files_user_created(): generating password for {$user->id} ({$user->auth}) => {$passwd}");
            $repo->migrate_user($user, $passwd);
        }
    }

    return true;
}
예제 #14
0
파일: install.php 프로젝트: jamesmcq/elis
/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2014 onwards Remote-Learner.net Inc (http://www.remote-learner.net)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    repository_elisfiles
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @copyright  (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net)
 *
 */

function xmldb_repository_elisfiles_install() {
    global $CFG, $DB;

    $result = true;
    $dbman = $DB->get_manager();

    // Run upgrade steps from old plugin if applicable
    $oldversion = get_config('repository_elis_files', 'version');
    if ($oldversion !== false) {
        require_once($CFG->dirroot.'/repository/elisfiles/lib/lib.php');

        if ($oldversion < 2011110301) {
            $errors = false;
            $auths = elis_files_nopasswd_auths();
            $authlist = "'". implode("', '", $auths) ."'";
            $users = $DB->get_records_select('user', "auth IN ({$authlist})", array(), 'id, auth');
            if (!empty($users)) {
                foreach ($users as $user) {
                    $user = get_complete_user_data('id', $user->id);
                    $migrate_ok = elis_files_user_created($user);
                    if (!$migrate_ok) {
                        $errors = true;
                        // error_log("xmldb_block_elis_files_upgrade({$oldversion}) - failed migrating user ({$user->id}) to Alfresco.");
                    }
                }
            }
            if (!$errors) {
                set_config('initialized', 1, ELIS_files::$plugin_name);
            }
        }

        if ($result && $oldversion < 2012042300) {
            //check that elis_files_organization_store exists and repository_elisfiles_userset does not exist
            if ($dbman->table_exists('elis_files_organization_store') && !$dbman->table_exists('elis_files_userset_store')) {

                $original_table = new xmldb_table('elis_files_organization_store');

                //rename table
                $dbman->rename_table($original_table, 'elis_files_userset_store');
                $new_table = new xmldb_table('elis_files_userset_store');

                //drop the keys
                $original_uuid_index = new xmldb_index('elisfileorgastor_orguu_uix', XMLDB_INDEX_UNIQUE, array('organizationid', 'uuid'));
                $original_index = new xmldb_index('elisfileorgastor_org_ix', XMLDB_INDEX_NOTUNIQUE, array('organizationid'));
                $dbman->drop_index($new_table, $original_uuid_index);
                $dbman->drop_index($new_table, $original_index);

                //rename field
                $organization = new xmldb_field('organizationid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0);
                $dbman->rename_field($new_table, $organization, 'usersetid');

                //add the keys
                $new_uuid_index = new xmldb_index('elisfileuserstor_useuu_uix', XMLDB_INDEX_UNIQUE, array('usersetid', 'uuid'));
                $new_index = new xmldb_index('elisfileuserstor_use_ix', XMLDB_INDEX_NOTUNIQUE, array('usersetid'));
                $dbman->add_index($new_table, $new_uuid_index);
                $dbman->add_index($new_table, $new_index);
            }
        }

        if ($result && $oldversion < 2012042500) {
            defined('ELIS_FILES_BROWSE_USERSET_FILES') or define('ELIS_FILES_BROWSE_USERSET_FILES',   60);

            // ELIS-4676 ELIS UserSet Files is no longer valid, so change to default of ELIS User Files
            $select = "plugin = 'elis_files' AND name = 'default_browse'";

            if ($record = $DB->get_record_select('config_plugins', $select)) {
                require_once($CFG->dirroot.'/repository/elisfiles/lib/ELIS_files.php');
                $int_value = (int)$record->value;
                $valid_values = array(
                        ELIS_FILES_BROWSE_SITE_FILES,
                        ELIS_FILES_BROWSE_SHARED_FILES,
                        ELIS_FILES_BROWSE_COURSE_FILES,
                        ELIS_FILES_BROWSE_USER_FILES
                );
                if (!in_array($int_value, $valid_values)) {
                    $record->value = ELIS_FILES_BROWSE_USER_FILES;
                    $DB->update_record('config_plugins', $record);
                }
            }
        }

        if ($result && $oldversion < 2012050200)  {
            // Check for any plug-in settings using an incorrect plug-in name "ELIS_files" instead of "elis_files"
            if ($pcfgs = $DB->get_records('config_plugins', array('plugin' => 'ELIS_files'))) {
                foreach ($pcfgs as $pcfg) {
                    $pcfg->plugin = 'elis_files';
                    $DB->update_record('config_plugins', $pcfg);
                }
            }
        }

        /*
         * This upgrade step removes any possible stale data in the repository_elisfiles_userset and
         * repository_elisfiles_course that not longer have relevant courses or user sets
         */
        if ($result && $oldversion < 2012083000)  {
            $haveuserset = false;
            if (file_exists($CFG->dirroot.'/local/elisprogram/lib/data/userset.class.php')) {
                require_once($CFG->dirroot.'/local/elisprogram/lib/data/userset.class.php');
                $haveuserset = $dbman->table_exists(userset::TABLE);
            }

            $sql = 'DELETE FROM {elis_files_userset_store}';
            if ($haveuserset) {
                $sql .= ' WHERE NOT EXISTS (SELECT *
                                              FROM {'.userset::TABLE.'}
                                             WHERE {elis_files_userset_store}.usersetid = {'.userset::TABLE.'}.id)';

            }
            $DB->execute($sql);

            $sql = 'DELETE FROM {elis_files_course_store}
                    WHERE NOT EXISTS (SELECT *
                                        FROM {course}
                                       WHERE {elis_files_course_store}.courseid = {course}.id)';

            $DB->execute($sql);
        }

        /*
         * This upgrade step removes backslashes from category titles in the repository_elisfiles_cats
         */
        if ($result && $oldversion < 2012090400)  {
            require_once($CFG->dirroot.'/repository/elisfiles/ELIS_files_factory.class.php');
            // Initialize the repo object.
            $repo = repository_factory::factory();
            $table = 'elis_files_categories';
            if ($repo && $dbman->table_exists($table) && $categories = elis_files_get_categories()) {
                $DB->delete_records($table);

                // Perform the back-end category refresh
                $categories = elis_files_get_categories();
                $uuids = array();
                $repo->process_categories($uuids, $categories);
            }
        }

        // If the pre-ELIS 2 Alfresco plugin was present and enabled on this site, then we need to automatically
        // enable the ELIS Files plugin
        $select1 = "name = 'repository' AND ".$DB->sql_compare_text('value')." = 'alfresco'";
        $select2 = "name = 'repository_plugins_enabled' AND ".$DB->sql_compare_text('value')." = 'alfresco'";

        if ($DB->record_exists_select('config', $select1) && $DB->record_exists_select('config', $select2)) {
            require_once($CFG->dirroot.'/repository/lib.php');

            $elis_files = new repository_type('elisfiles', array(), true);

            if (!empty($elis_files)) {
                $elis_files->update_visibility(true);
                $elis_files->create();
            }

            $DB->delete_records_select('config', "(name = 'repository' OR name = 'repository_plugins_enabled')");
        }

        // ELIS-3677, ELIS-3802 Moodle files is no longer valid, so change to default of ELIS User Files
        $select = "plugin = 'elis_files' AND name = 'default_browse'";

        if ($record = $DB->get_record_select('config_plugins', $select)) {
            require_once($CFG->dirroot.'/repository/elisfiles/lib/ELIS_files.php');
            $int_value = (int)$record->value;
            $valid_values = array(
                    ELIS_FILES_BROWSE_SITE_FILES,
                    ELIS_FILES_BROWSE_SHARED_FILES,
                    ELIS_FILES_BROWSE_COURSE_FILES,
                    ELIS_FILES_BROWSE_USER_FILES
            );
            if (!in_array($int_value, $valid_values)) {
                $record->value = ELIS_FILES_BROWSE_USER_FILES;
                $DB->update_record('config_plugins', $record);
            }
        }

        $ignoreresult = elis_files_update_references_in_database();
    }

    // Convert old tables to new
    static $tablemap = array(
        'elis_files_categories'    => 'repository_elisfiles_cats',
        'elis_files_course_store'  => 'repository_elisfiles_course',
        'elis_files_userset_store' => 'repository_elisfiles_userset'
    );
    foreach ($tablemap as $oldtable => $newtable) {
        $oldtableobj = new xmldb_table($oldtable);
        if ($dbman->table_exists($oldtableobj)) {
            $newtableobj = new xmldb_table($newtable);
            $dbman->drop_table($newtableobj);
            $dbman->rename_table($oldtableobj, $newtable);
        }
    }

    // Migrate capabilities
    $oldcapprefix = 'repository/elis_files';
    $newcapprefix = 'repository/elisfiles';
    $sql = 'SELECT * FROM {role_capabilities} WHERE capability LIKE ?';
    $params = array($oldcapprefix.'%');
    $rolecaps = $DB->get_recordset_sql($sql, $params);
    foreach ($rolecaps as $rolecaprec) {
        $updaterec = new stdClass;
        $updaterec->id = $rolecaprec->id;
        $updaterec->capability = str_replace($oldcapprefix, $newcapprefix, $rolecaprec->capability);
        $DB->update_record('role_capabilities', $updaterec);
    }
    $sql = 'SELECT * FROM {capabilities} WHERE name LIKE ?';
    $caps = $DB->get_recordset_sql($sql, $params);
    foreach ($caps as $cap) {
        $cap->name = str_replace($oldcapprefix, $newcapprefix, $cap->name);
        $cap->component = str_replace('repository_elis_files', 'repository_elisfiles', $cap->component);
        $DB->update_record('capabilities', $cap);
    }

    // Migrate language strings
    $migrator = new \local_eliscore\install\migration\migrator('repository_elis_files', 'repository_elisfiles');
    $migrator->migrate_language_strings();

    // Copy any settings from old plugin
    $oldconfig = get_config('elis_files');
    foreach ($oldconfig as $name => $value) {
        set_config($name, $value, 'elisfiles');
    }
    unset_all_config_for_plugin('elis_files');
    unset_all_config_for_plugin('repository_elis_files');

    // Update repository table
    $sql = 'UPDATE {repository} SET type = "elisfiles" WHERE type = "elis_files"';
    $DB->execute($sql);

    return $result;
}
예제 #15
0
    /**
     * Validate that the "find_userset_folders" method respect site files
     * capabilities assigned at the system level
     * @uses $USER, $DB
     * @param string $capability The site files capabilility to assign to the test user
     * @param boolean $createonly The "create only" flag, as needed by the method
     * @param array $names The expected set of userset names that should be returned
     * @dataProvider userset_folders_provider
     */
    public function test_find_userset_folders_respects_site_files($capability, $createonly, $names) {
        if (!class_exists('elispm')) {
            $this->markTestSkipped('local_elisprogram needed for test');
            return false;
        }

        $this->resetAfterTest(true);
        $this->setup_test_data_xml();

        global $DB, $USER;
        require_once(elis::lib('data/customfield.class.php'));
        require_once(elispm::lib('data/userset.class.php'));
        require_once(elispm::file('plugins/usetclassify/usersetclassification.class.php'));
        require_once(elispm::file('accesslib.php'));

        // Make sure the test user is not mistaken for a site admin or guest
        set_config('siteadmins', '');
        set_config('siteguest', '');

        $classification = new usersetclassification(array(
            'shortname' => 'testclassification'
        ));
        $classification->param_elis_files_shared_folder = 1;
        $classification->save();

        $userset = new userset(array(
            'name' => 'testusersetname'
        ));
        $userset->save();
        $userset->reset_custom_field_list();
        $userset->load();
        $userset->field__elis_userset_classification = 'testclassification';
        $userset->save();

        $this->setUser(100);

        // Assign the "site files" role to the test user
        $roleid = $this->assign_role_capability($capability);
        $systemcontext = context_system::instance();
        role_assign($roleid, $USER->id, $systemcontext->id);

        // Assign the "view userset content" role to the test user
        $usersetcontext = \local_elisprogram\context\userset::instance($userset->id);
        $roleid = $this->assign_role_capability('repository/elisfiles:viewusersetcontent', 100);
        role_assign($roleid, $USER->id, $usersetcontext->id);

        // Obtain the set of userset folders
        $elisfiles = repository_factory::factory();

        $folders = array();
        $elisfiles->find_userset_folders($folders, $createonly);

        // Validate that the method returned the right number of folders
        $this->assertEquals(count($names), count($folders));

        // Validate the specific names
        foreach ($names as $i => $name) {
            $this->assertEquals($name, $folders[$i]['name']);
        }
    }
예제 #16
0
$file = optional_param('file', '', PARAM_PATH);
$wdir = optional_param('wdir', '/', PARAM_PATH);
$category = optional_param('category', 0, PARAM_INT);
$action = optional_param('action', '', PARAM_ACTION);
$name = optional_param('name', '', PARAM_FILE);
$oldname = optional_param('oldname', '', PARAM_FILE);
$choose = optional_param('choose', '', PARAM_FILE);
//in fact it is always 'formname.inputname'
$userfile = optional_param('userfile', '', PARAM_FILE);
$save = optional_param('save', 0, PARAM_BOOL);
$text = optional_param('text', '', PARAM_RAW);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if (empty($CFG->repository)) {
    print_error('nodefaultrepositoryplugin', 'repository');
}
if (!isset($CFG->repository_plugins_enabled) || strstr($CFG->repository_plugins_enabled, 'alfresco') === false || ($repo = repository_factory::factory($CFG->repository)) === false) {
    print_error('couldnotcreaterepositoryobject', 'repository');
}
if (!alfresco_user_request()) {
    print_error('nopermissions');
}
// If we don't have something explicitly to load and we didn't get here from the drop-down...
if (empty($dd) && empty($uuid)) {
    if ($uuid = $repo->get_repository_location($id, $userid, $shared, $oid)) {
        redirect($CFG->wwwroot . '/file/repository/index.php?id=' . $id . '&amp;choose=' . $choose . '&amp;userid=' . $userid . '&amp;shared=' . $shared . '&amp;oid=' . $oid . '&amp;uuid=' . $uuid, '', 0);
    }
    if ($uuid = $repo->get_default_browsing_location($id, $userid, $shared)) {
        redirect($CFG->wwwroot . '/file/repository/index.php?id=' . $id . '&amp;choose=' . $choose . '&amp;userid=' . $userid . '&amp;shared=' . $shared . '&amp;oid=' . $oid . '&amp;uuid=' . $uuid, '', 0);
    }
}
if ($choose) {
예제 #17
0
파일: upload.php 프로젝트: jamesmcq/elis
    /**
     * Validates that a filename is unique within the specified folder in Alfresco
     *
     * @param string $filename The filename we are checking, without the path included
     * @return mixed true if unique, otherwise a string error message
     */
    function validate_unique_filename($filename) {
        require_once('ELIS_files_factory.class.php');

        $uuid = required_param('uuid', PARAM_TEXT);

        if ($repo = repository_factory::factory()) {
            // look through the files in the current directory
            if ($dir = $repo->read_dir($uuid)) {
                if (!empty($dir->files)) {
                    foreach ($dir->files as $file) {
                        if ($file->title == $filename) {
                            // found an existing file with the same name
                            return get_string('erroruploadduplicatefilename', 'repository_elisfiles', $filename);
                        }
                    }
                }
            }
        } else {
            // this is unlikely but possible
            return get_string('errorupload', 'repository_elisfiles');
        }

        // file not already found, so ok to upload
        return true;
    }
예제 #18
0
 function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     $content = '';
     $footer = '';
     $nologin_auths = elis_files_nopasswd_auths();
     if (!empty($USER->auth) && in_array($USER->auth, $nologin_auths)) {
         return '';
     }
     // Only proceed here if the Alfresco plug-in is actually enabled.
     if (!isloggedin() || !file_exists($CFG->dirroot . '/repository/elisfiles/ELIS_files_factory.class.php')) {
         return $this->content;
     }
     require_once $CFG->dirroot . '/repository/elisfiles/ELIS_files_factory.class.php';
     if (!($repo = repository_factory::factory())) {
         return $this->content;
     }
     // Get the ELIS Files plugin configuration values
     $pcfg = get_config('elisfiles');
     $username = $USER->username == 'admin' ? $pcfg->admin_username : $USER->username;
     $username = $repo->alfresco_username_fix($username);
     $repo->set_alfresco_username($username);
     if ($repo->elis_files_userdir($username) !== false) {
         // So that we don't conflict with the default Alfresco admin account.
         //            $username = $USER->username == 'admin' ? $pcfg->admin_username : $USER->username;
         $hastenant = false;
         // If the Moodle user's user name has an '@' symbol, then replace it with '_AT_' for Alfresco compatibility
         if (($tenantname = strpos($USER->username, '@')) > 0) {
             $username = $repo->get_alfresco_username_fix();
         }
         // We must include the tenant portion of the username here.
         if (($tenantname = strpos(elis::$config->elisfiles->server_username, '@')) > 0) {
             $username .= substr(elis::$config->elisfiles->server_username, $tenantname);
             $hastenant = true;
         }
         // Display a link to access the Alfresco repository directly.
         $content .= get_string('webappaccess', 'block_repository', $repo->get_webapp_url()) . '<br /><br />';
         // Display a link to the configured embedded WebDAV client (if defined).
         if (!empty($CFG->block_course_repository_webdav_client)) {
             $content .= get_string('embeddedwebdavlink', 'block_repository', $CFG->block_course_repository_webdav_client) . '<br /><br />';
         }
         if ($hastenant || $username != $USER->username) {
             $content .= get_string('usernametenantinfo', 'block_repository', $username);
         } else {
             $content .= get_string('usernameinfo', 'block_repository', $username);
         }
         // Display a link to defined help files
         if (!empty($CFG->block_course_repository_help_link)) {
             $footer = get_string('helpfileslink', 'block_repository', $CFG->block_course_repository_help_link);
         }
     }
     // If there is no content and the current user can actually modify the site settings, display some text
     // in the block explaining what is happening.
     if (empty($content) && has_capability('moodle/site:config', context_system::instance())) {
         $url = $CFG->wwwroot . '/admin/repository.php?action=edit&amp;repos=elisfiles&amp;sesskey=' . sesskey();
         $content = get_string('alfresconotconfigured', 'block_repository', $url);
     }
     $this->content->text = $content;
     $this->content->footer = $footer;
     return $this->content;
 }
예제 #19
0
파일: auth.php 프로젝트: jamesmcq/elis
 /**
  * Post authentication hook.
  * This method is called from authenticate_user_login() for all enabled auth plugins.
  *
  * @uses $CFG
  * @param object $user     user object, later used for $USER
  * @param string $username (with system magic quotes)
  * @param string $password plain text password (with system magic quotes)
  */
 function user_authenticated_hook(&$user, $username, $password)
 {
     global $CFG;
     if (!$this->isactive) {
         return;
     }
     require_once $CFG->dirroot . '/repository/elisfiles/ELIS_files_factory.class.php';
     if (!($repo = repository_factory::factory())) {
         return;
     }
     $repoisup = $repo->is_running() && $repo->verify_setup();
     // Perform the proper setup / updating / migration of user information on Alfresco.
     if ($repoisup && $repo->migrate_user($user, $password)) {
         $repo->sync_permissions($user);
     }
 }
예제 #20
0
$action = optional_param('action', '', PARAM_ACTION);
$name = optional_param('name', '', PARAM_FILE);
$oldname = optional_param('oldname', '', PARAM_FILE);
$usecheckboxes = optional_param('usecheckboxes', 1, PARAM_INT);
$save = optional_param('save', 0, PARAM_BOOL);
$text = optional_param('text', '', PARAM_RAW);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if (!($course = get_record('course', 'id', $id))) {
    print_error('invalidcourseid', 'repository_alfresco', '', $id);
}
require_login($course);
//    require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id));
if (empty($CFG->repository)) {
    print_error('nodefaultrepositoryplugin', 'repository');
}
if (!($repo = repository_factory::factory($CFG->repository))) {
    print_error('couldnotcreaterepositoryobject', 'repository');
}
/// Get the context instance for where we originated viewing this browser from.
if (!empty($oid)) {
    $cluster_context = get_context_instance(context_level_base::get_custom_context_level('cluster', 'block_curr_admin'), $oid);
}
if ($id == SITEID) {
    $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
} else {
    $context = get_context_instance(CONTEXT_COURSE, $id);
}
/// Determine whether the current user has editing permissions.
$canedit = false;
if (empty($userid) && empty($shared)) {
    if ($id == SITEID && has_capability('block/repository:createsitecontent', $context, $USER->id) || $id != SITEID && has_capability('block/repository:createcoursecontent', $context, $USER->id) || !empty($oid) && has_capability('block/repository:createorganizationcontent', $cluster_context, $USER->id)) {
예제 #21
0
    /**
     * Test the user migration functionality using an invalid user object
     * @uses $DB
     */
    public function test_migrate_invalid_user_as_object() {
        $this->resetAfterTest(true);
        $this->setup_test_data_xml();

        global $DB;

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

        $this->userstodelete[] = '__phpunit_test1__';

        $user = $DB->get_record('user', array('id' => 100));

        $this->assertTrue($repo->migrate_user($user, 'password'));
    }
예제 #22
0
/**
 * Handle the event when a user is unassigned to a cluster.
 *
 * @uses $CFG
 * @param object $clusterinfo The Moodle role_assignment record object.
 * @return bool True on success or failure (event handlers must always return true).
 */
function block_repository_cluster_deassigned($clusterinfo)
{
    global $CFG;
    // Only proceed here if the Alfresco plug-in is actually enabled.
    if (!isset($CFG->repository_plugins_enabled) || strstr($CFG->repository_plugins_enabled, 'alfresco') === false || !($repo = repository_factory::factory('alfresco'))) {
        return true;
    }
    // Get the Moodle user ID from the CM user ID.
    if (!($muserid = cm_get_moodleuserid($clusterinfo->userid))) {
        return true;
    }
    if (!($username = get_field('user', 'username', 'id', $muserid))) {
        return true;
    }
    if (!($cluster = get_record('crlm_cluster', 'id', $clusterinfo->clusterid))) {
        return true;
    }
    // Does this organization have an Alfresco storage space?
    if (!($uuid = $repo->get_organization_store($cluster->id, false))) {
        return true;
    }
    $context = get_context_instance(context_level_base::get_custom_context_level('cluster', 'block_curr_admin'), $cluster->id);
    $sql = "SELECT rc.*\n            FROM {$CFG->prefix}role_capabilities rc\n            INNER JOIN {$CFG->prefix}role r ON r.id = rc.roleid\n            INNER JOIN {$CFG->prefix}role_assignments ra ON ra.roleid = r.id\n            WHERE ra.contextid = {$context->id}\n            AND ra.userid = {$muserid}\n            AND rc.capability = 'block/repository:createorganizationcontent'\n            AND rc.permission = " . CAP_ALLOW;
    // Check if the user has a specific role assignment on the cluster context with the editing capability
    if (!record_exists_sql($sql)) {
        // Remove all non-editing permissions for this user on the organization shared space.
        if ($permissions = alfresco_get_permissions($uuid, $username)) {
            foreach ($permissions as $permission) {
                // Do not remove editing permissions if this user still actually has a cluster membership.
                if ($permission == ALFRESCO_ROLE_COLLABORATOR) {
                    continue;
                }
                alfresco_set_permission($username, $uuid, $permission, ALFRESCO_CAPABILITY_DENIED);
            }
        }
        // Remove all permissions for this user on the organization shared space.
    } else {
        if ($permissions = alfresco_get_permissions($uuid, $username)) {
            foreach ($permissions as $permission) {
                // Do not remove view permissions if this user still actually has a cluster membership.
                if ($permission == ALFRESCO_ROLE_CONSUMER && record_exists('crlm_usercluster', 'userid', $clusterinfo->userid, 'clusterid', $cluster->id, 'leader', 0)) {
                    continue;
                }
                alfresco_set_permission($username, $uuid, $permission, ALFRESCO_CAPABILITY_DENIED);
            }
        }
    }
    return true;
}
예제 #23
0
<?php

///////////////////////////////////////////////////////////////////////////
//                                                                       //
// NOTICE OF COPYRIGHT                                                   //
//                                                                       //
// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
//          http://moodle.org                                            //
//                                                                       //
// Copyright (C) 2004  Martin Dougiamas  http://moodle.com               //
//                                                                       //
// This program is free software; you can redistribute it and/or modify  //
// it under the terms of the GNU General Public License as published by  //
// the Free Software Foundation; either version 2 of the License, or     //
// (at your option) any later version.                                   //
//                                                                       //
// This program is distributed in the hope that it will be useful,       //
// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
// GNU General Public License for more details:                          //
//                                                                       //
//          http://www.gnu.org/copyleft/gpl.html                         //
//                                                                       //
///////////////////////////////////////////////////////////////////////////
require_once '../../config.php';
require_once $CFG->dirroot . '/repository/repository.php';
$uuid = required_param('uuid', PARAM_CLEAN);
/// Initialize the repository object and 'read' the file by redirecting to the
/// file itself.
$repo = repository_factory::factory('alfresco');
$repo->read_file($uuid);
예제 #24
0
 */
require_once '../../config.php';
require_once $CFG->libdir . '/adminlib.php';
admin_externalpage_setup('repositories');
$repository = required_param('repository', PARAM_ALPHA);
$CFG->pagepath = 'repository/' . $repository;
require_login();
if (!($site = get_site())) {
    redirect("index.php");
}
if (!isadmin()) {
    error("Only the admin can use this page");
}
require_once "{$CFG->dirroot}/file/repository/repository.class.php";
/// Open the factory class
$repositoryobj = repository_factory::factory($repository);
/// If data submitted, then process and store.
if ($frm = data_submitted()) {
    if (!confirm_sesskey()) {
        error(get_string('confirmsesskeybad', 'error'));
    }
    if ($repositoryobj->process_config($frm)) {
        redirect("repository.php?repository={$repository}", get_string("changessaved"), 1);
    }
} else {
    $frm = $CFG;
}
/// Otherwise fill and print the form.
$modules = get_list_of_plugins('repository', '', $CFG->dirroot . '/file');
foreach ($modules as $module) {
    $options[$module] = get_string("repositoryname", "repository_{$module}");
예제 #25
0
 /**
  * Post authentication hook.
  * This method is called from authenticate_user_login() for all enabled auth plugins.
  *
  * @uses $CFG
  * @param object $user user object, later used for $USER
  * @param string $username (with system magic quotes)
  * @param string $password plain text password (with system magic quotes)
  */
 function user_authenticated_hook(&$user, $username, $password)
 {
     global $CFG;
     if (!$this->isactive || !file_exists($CFG->dirroot . '/file/repository/repository.class.php')) {
         return;
     }
     require_once $CFG->dirroot . '/file/repository/repository.class.php';
     if (!($repo = repository_factory::factory('alfresco'))) {
         return;
     }
     if (!$repo->verify_setup() || !$repo->is_configured()) {
         return;
     }
     // Perform the proper setup / updating / migration of user information on Alfresco.
     if ($repo->migrate_user($user, $password)) {
         $repo->sync_permissions($user);
     }
 }
예제 #26
0
    /**
     * Test that uploading a file to a specific folder generates a valid response
     * @dataProvider file_size_provider
     */
    public function test_upload_to_folder_and_get_response($mb) {
        $this->resetAfterTest(true);
        $this->setup_test_data_xml();

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

        // Used data provider to just generate one file
        $filesize = $mb * ONE_MB_BYTES;
        $filename = $this->generate_temp_file($mb);

        // Upload to a folder
        $uploadresponse = elis_files_upload_file('', $filename, $repo->muuid);

        unlink($filename);

        // Verify that we get a valid response
        $this->assertNotEquals(false, $uploadresponse);
        // Verify that response has a uuid
        $this->assertObjectHasAttribute('uuid', $uploadresponse);

        // Get info on the uploaded file's uuid...
        $response = $repo->get_info($uploadresponse->uuid);

        // Cleanup the uploaded file
        $this->cleanup_files($repo->muuid);

        // Verify that response has a type
        $this->assertObjectHasAttribute('type', $response);
        // Verify that type is folder
        $this->assertEquals(ELIS_files::$type_document, $response->type);
        // Verify that title is set
        $this->assertObjectHasAttribute('title', $response);
        // Verify that created is set
        $this->assertObjectHasAttribute('created', $response);
        // Verify that modified is set
        $this->assertObjectHasAttribute('modified', $response);
        // Verify that summary is set
        $this->assertObjectHasAttribute('summary', $response);
        // Verify that Owner is set
        $this->assertObjectHasAttribute('owner', $response);
    }
예제 #27
0
파일: openfile.php 프로젝트: jamesmcq/elis
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    repository_elisfiles
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @copyright  (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net)
 *
 */

require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once('lib/lib.php');
require_once('ELIS_files_factory.class.php');

global $USER;
$uuid = required_param('uuid', PARAM_CLEAN);
$filename = optional_param('filename', '', PARAM_PATH);

if (!$repo = repository_factory::factory()) {
    print_error('couldnotcreaterepositoryobject', 'repository');
}

if (!$repo->permission_check($uuid, $USER->id)) {
    echo '<br>permission check failed for uuid: '.$uuid.' and userid: '.$USER->id.'**';
    print_error('youdonothaveaccesstothisfunctionality', 'repository_alfresco');
}

$repo->read_file($uuid, '', false, true, !empty($filename));

exit;
예제 #28
0
global $DB, $OUTPUT;

if (!$site = get_site()) {
    redirect($CFG->wwwroot . '/');
}

require_login();

$context = context_system::instance();
$PAGE->set_context($context);
require_capability('moodle/site:config', $context);

$strconfigcatfilter = get_string('configurecategoryfilter', 'repository_elisfiles');

// Initialize the repo object.
$repo = repository_factory::factory();

/// Process any form data submission
if (($data = data_submitted($CFG->wwwroot.'/repository/elisfiles/config-categories.php')) && confirm_sesskey()) {

    if (isset($data->reset)) {
        $DB->delete_records('repository_elisfiles_cats');

        // Perform the back-end category refresh
        $categories = elis_files_get_categories();
        $uuids = array();
        $repo->process_categories($uuids, $categories);
    } else if (isset($data->categories)) {
        set_config('catfilter', serialize($data->categories), 'elisfiles');
    } else {
        set_config('catfilter', '', 'elisfiles');
예제 #29
0
 *
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php';
require_once $CFG->dirroot . '/file/repository/repository.class.php';
require_once $CFG->libdir . '/alfresco30/lib.php';
$id = optional_param('id', SITEID, PARAM_INT);
$oid = optional_param('oid', '', PARAM_INT);
$shared = optional_param('shared', '', PARAM_ALPHA);
$userid = optional_param('userid', 0, PARAM_INT);
$uuid = optional_param('uuid', '', PARAM_TEXT);
$dd = optional_param('dd', 0, PARAM_INT);
$upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
require_course_login($id);
// Make sure the plug-in is enabled and setup correctly.
if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) {
    if (!($repo = repository_factory::factory('alfresco'))) {
        debugging('Could not create repository object.', DEBUG_DEVELOPER);
    }
    // If we don't have something explicitly to load and we didn't get here from the drop-down...
    if (empty($uuid) && empty($dd)) {
        if ($uuid = $repo->get_repository_location($id, $userid, $shared, $oid)) {
            redirect($CFG->wwwroot . '/file/repository/alfresco/link.php?id=' . $id . '&amp;userid=' . $userid . '&amp;shared=' . $shared . '&amp;oid=' . $oid . '&amp;uuid=' . $uuid, '', 0);
        }
        if ($uuid = $repo->get_default_browsing_location($id, $userid, $shared)) {
            redirect($CFG->wwwroot . '/file/repository/alfresco/link.php?id=' . $id . '&amp;userid=' . $userid . '&amp;shared=' . $shared . '&amp;oid=' . $oid . '&amp;uuid=' . $uuid, '', 0);
        }
    }
}
@header('Content-Type: text/html; charset=utf-8');
if (!alfresco_user_request()) {
    print_error('nopermissions');
예제 #30
0
print_simple_box(get_string('configrepositoryplugins', 'file'), 'center', '700');
echo '<form target="' . $CFG->framename . '" name="repositorymenu" method="post" action="repositories.php">';
$table = new stdClass();
$table->head = array(get_string('name'), get_string('enable'), get_string('default'), get_string('settings'));
$table->align = array('left', 'center', 'center', 'center');
$table->size = array('60%', '', '', '15%');
$table->width = '700';
$table->data = array();
$modules = get_list_of_plugins('repository', '', $CFG->dirroot . '/file');
foreach ($modules as $module) {
    // skip if directory is empty
    if (!file_exists("{$CFG->dirroot}/file/repository/{$module}/repository.php")) {
        continue;
    }
    $name = get_string('repository', "repository_{$module}");
    $plugin = repository_factory::factory($module);
    $enable = '<input type="checkbox" name="enable[]" value="' . $module . '"';
    if (stristr($CFG->repository_plugins_enabled, $module) !== false) {
        $enable .= ' checked="checked"';
    }
    if ($module == 'manual') {
        $enable .= ' disabled="disabled"';
    }
    $enable .= ' />';
    $default = '<input type="radio" name="default" value="' . $module . '"';
    if ($CFG->repository == $module) {
        $default .= ' checked="checked"';
    }
    $default .= ' />';
    if (file_exists($CFG->dirroot . '/file/repository/' . $module . '/settings.php')) {
        $settings = $CFG->wwwroot . '/admin/settings.php?section=repository' . $module;