Exemplo n.º 1
0
function morsle_get_files($morsle, $wdir, &$collectionid)
{
    global $USER, $COURSE;
    global $userstr, $deptstr;
    $collections = explode('/', $wdir);
    if ($wdir === '') {
        // root of morsle files, user and department are prepended in display_dir
        $files = get_doc_feed($morsle, $collectionid);
        // go get folder contents from Google
    } elseif (strpos($wdir, $deptstr) === false && strpos($wdir, $userstr) === false) {
        // course collection
        $basecollectionid = sizeof($collections) > 2 ? get_collection($morsle, $collections[sizeof($collections) - 2]) : null;
        // $basecollectionid = second to last collection in path that is passed
        $collectionid = get_collection($morsle, $collections[sizeof($collections) - 1], $basecollectionid);
        // $collectionid = last collection in path that is passed
        // TODO: send a path to be used to get the doc feed from a nested collection
        $files = get_doc_feed($morsle, $collectionid);
        // go get folder contents from Google
    } else {
        // departmental or user account collection
        $basecollectionid = sizeof($collections) > 3 ? get_collection($morsle, $collections[sizeof($collections) - 2]) : null;
        // $basecollectionid = second to last collection in path that is passed
        $collectionid = sizeof($collections) > 2 ? get_collection($morsle, $collections[sizeof($collections) - 1], $basecollectionid) : null;
        // $collectionid = last collection in path that is passed
        // go get folder contents from Google
        if ($collectionid == null || $collectionid === '') {
            $collectionid = 'root';
        }
        // TODO: send a path to be used to get the doc feed from a nested collection
        $files = get_doc_feed($morsle, $collectionid);
        // go get folder contents from Google
    }
    return $files;
}
Exemplo n.º 2
0
    $collectionid = 'root';
    $basecollectionid = null;
    $files = get_doc_feed($morsle, $collectionid);
    $collection = $wdir;
} else {
    $collections = explode('/', $wdir);
    $basecollectionid = null;
    foreach ($collections as $collection) {
        // cycle through the path so our ultimate collection is a subcollection of its parent
        if ($collection !== '') {
            $collectionid = get_collection($morsle, $collection, $basecollectionid);
            $basecollectionid = $collectionid;
            // just for cycling through the collections, not used again
        }
    }
    $files = get_doc_feed($morsle, $collectionid);
}
$PAGE->navbar->ignore_active();
if ($wdir === '') {
    $PAGE->navbar->add($morslefilestr, $returnurl);
} else {
    //    	$PAGE->navbar->add($wdir, $returnurl);
    $PAGE->navbar->add($collection, $returnurl);
}
echo $OUTPUT->header();
// get read-only folderid because we'll use this a lot and its easier than trying to keep getting it from Google
$readfolderid = $DB->get_field('morsle_active', 'readfolderid', array('courseid' => $COURSE->id));
$pagetitle = strip_tags($course->shortname . ': ' . $wdir);
//  End of configuration and access control
switch ($action) {
    case 'upload and link':
Exemplo n.º 3
0
    $deptaccount = strtolower(CONSTANT($dept[0]) . '-Departmental-Morsle-Account');
    $deptemail = strtolower($deptaccount . '@' . $CONSUMER_KEY);
    if (!$checkaccounts) {
        $deptfeed = get_doc_feed($deptemail);
    }
}
// identify various accounts
$strcourseuser = get_string("strcourseuser", "block_morsle", $course->shortname);
$strdepartmentuser = get_string("strdepartmentuser", 'block_morsle', $deptaccount);
$strownuser = get_string("strownuser", 'block_morsle', $user->email);
$struploadtargetchoice = get_string('struploadtarget', 'block_morsle');
// find out if a course morsle account exists for this course
$courseaccount = strtolower($course->shortname);
$courseemail = $courseaccount . '@' . $CONSUMER_KEY;
if (!$checkaccounts) {
    $coursefeed = get_doc_feed($courseemail);
}
// check to see if any file resources exist for course, if not, exit with message
// establish base dataroot path for course resources
$currdir = $CFG->dataroot . '/' . $id;
if (!file_exists($currdir)) {
    echo '<div class="notifyproblem" align="center">You Have No File Resources to Migrate</div>' . "<br />\n";
    return false;
}
// get term (or category) of course
// TODO: see if this query actually works
$sql = "SELECT path\n    \t\t\t \t FROM {$CFG->prefix}course_categories cat\n    \t\t\t\t WHERE cat.id = {$course->category}";
$path = get_field_sql($sql);
$paths = explode('/', $path);
$path = is_null($paths[2]) ? $paths[1] : $paths[2];
$sql = "SELECT cc.name FROM {$CFG->prefix}course_categories cc\n    \t\t\t WHERE cc.id = {$path}";