Ejemplo n.º 1
0
                 }
             }
         }
     }
     notify(get_string('linkedfile', 'block_morsle'));
     // get ready to display the list of resources again
     clearfilelist();
     $files = morsle_get_files($morsle, $wdir, $collectionid);
     displaydir($wdir, $files);
     break;
 case "makedir":
     if ($name != '' && confirm_sesskey()) {
         $collections = explode("\r\n", $_POST['name']);
         foreach ($collections as $name) {
             if ($name !== '') {
                 createcollection($morsle, $name, $collectionid);
             }
         }
         // go get folder contents from Google and display
         //	            html_header($course, $wdir);
         $files = morsle_get_files($wdir, $collectionid, $owner);
         displaydir($wdir, $files);
     } else {
         // display the input form for the new collection name
         $strcreate = get_string("create");
         $strcancel = get_string("cancel");
         $strcreatefolder = get_string("createfolder", "block_morsle", $wdir);
         //                html_header($course, $wdir, "form.name");
         echo "<p>{$strcreatefolder}:</p>";
         //TODO: replace with mform
         echo "<table><tr><td>";
Ejemplo n.º 2
0
 public function morsle_digest($record)
 {
     global $success, $CFG, $DB;
     $this->shortname = strtolower($record->shortname);
     $this->courseid = $record->courseid;
     $groupname = $this->shortname . '-group';
     $groupfullname = $groupname . '@' . $this->domain;
     $this->sitename = urlencode('Course Site for ' . strtoupper($this->shortname));
     $stats = array('password' => $record->password, 'groupname' => $record->groupname, 'readfolderid' => $record->readfolderid, 'writefolderid' => $record->writefolderid, 'siteid' => $record->siteid);
     foreach ($stats as $key => $stat) {
         if (is_null($stat)) {
             switch ($key) {
                 case 'password':
                     // create user account
                     $this->useremail = $this->admin;
                     $this->get_token('user');
                     $this->revoke_token();
                     $this->get_token('user');
                     $returnval = $this->useradd();
                     // either password coming back or $response->response
                     break;
                 case 'groupname':
                     // add group
                     $this->useremail = $this->admin;
                     $this->get_token('user');
                     $this->revoke_token();
                     $this->get_token('group');
                     $returnval = $this->groupadd($groupname);
                     break;
                 case 'readfolderid':
                     // create readonly folder
                     $this->useremail = $this->shortname . '@luther.edu';
                     $this->get_token('user');
                     $this->revoke_token();
                     $this->get_token('drive');
                     $returnval = createcollection($this, $this->shortname . '-read');
                     break;
                 case 'writefolderid':
                     // create writeable folder
                     $this->useremail = $this->shortname . '@luther.edu';
                     $this->get_token('user');
                     $this->revoke_token();
                     $this->get_token('drive');
                     $returnval = createcollection($this, $this->shortname . '-write');
                     break;
                 case 'siteid':
                     // create site
                     //                                $returnval = $this->createsite();
                     break;
             }
             if ($returnval !== null) {
                 $this->log('added ' . $key . " SUCCESS", $record->courseid, null, s($returnval));
                 $record->{$key} = s($returnval);
                 $updaterec = $DB->update_record('morsle_active', $record);
             } else {
                 $this->log('added ' . $key . " FAILURE", $record->courseid, null, s($returnval));
                 if ($key == 'password') {
                     //                            break;
                 }
             }
         }
     }
     return $returnval;
 }
Ejemplo n.º 3
0
            break;
        case 'department':
            $useremail = $deptemail;
            // get read-only collectionid for course
            $readcollectionid = get_collection($deptaccount . '-read', $deptemail);
            break;
        case 'own':
            $useremail = $USER->email;
            $readcollectionid = null;
            break;
    }
    // check to see if collection exists for course, if not create collection on google user's account named after the shortname + term of course
    $rootcollectionname = 'Migration from ' . strtolower($course->shortname);
    if (!($collectionid = get_collection($rootcollectionname, $useremail, $readcollectionid))) {
        // create collection
        $collectionid = createcollection($rootcollectionname, $useremail, $readcollectionid);
    }
    /*
    	    // recursive function for uploading folder contents (and subfolders) to collection (and subcollections)
    		$rel = 'http://schemas.google.com/g/2005#resumable-create-media';
    		if ($feed = get_doc_feed($useremail, $collectionid,1)) {
    			$links = explode('?',get_href_noentry($feed, $rel));
    			$res_med_link = $links[0];
    		}
    */
    html_header($course, 'Migrating Files', 'Morsle File Migration');
    echo '<div align="center" font-size="18px" font-color="#ff0000"><image src="' . $CFG->wwwroot . '/blocks/morsle/images/spinner.gif" /><br />Files Uploading To Norse Docs<br />This May Take Some Time<br />You Should
			Close This Tab on Your Browser, or <br />you may shut down this computer (files will continue to upload)</div>';
    html_footer();
    //		flush();
    //		ob_flush();