function get_content() { global $CFG, $COURSE, $USER, $DB, $OUTPUT; if (!($CONSUMER_KEY = get_config('morsle', 'consumer_key'))) { $this->content = null; return $this->content; } $MORSLE_EXPIRES = is_null(get_config('morsle', 'morsle_expiration')) ? 30 * 24 * 60 * 60 : get_config('morsle', 'morsle_expiration') * 24 * 60 * 60; $curtime = time(); $this->content = new stdClass(); $morslerec = new stdClass(); $mhelp = get_string('morsle_help_string', 'block_morsle'); if ($COURSE->startdate + $MORSLE_EXPIRES < $curtime || $COURSE->startdate == 0) { $this->content = null; return $this->content; } $context = get_context_instance(CONTEXT_COURSE, $COURSE->id); // create morslerec if needed EVEN IF course is invisible to students // only if user has editingteacher role and not admin // admin entering unused course will not create the morsle record $conditions = array('courseid' => $COURSE->id); if (!($morslerec = $DB->get_record('morsle_active', $conditions))) { if (has_capability('moodle/course:update', $context) && !is_siteadmin($USER)) { $newrec->created = time(); $newrec->status = 'Full'; $newrec->courseid = $COURSE->id; $newrec->shortname = strtolower($COURSE->shortname); // gotta have some sort of course enrolenddate to know when to remove course -- set 120 days /* am commenting out this part cuz I really want to be able to disable the morsle repo and a 0 course startdate would do that if ($COURSE->enrolenddate == 0) { $COURSE->enrolenddate = time() + (120 * 24 * 60 * 60); $success = update_record('course','id',$COURSE->id); } */ if ($morslerec = $DB->insert_record('morsle_active', $newrec)) { add_to_log($COURSE->id, 'morsle', "morsle FULL record created for {$COURSE->shortname}"); } else { add_to_log($COURSE->id, 'morsle', "morsle FULL record NOT CREATED for {$COURSE->shortname}"); } } else { $morslerec = new stdClass(); } } $username = $COURSE->shortname . '@' . $CONSUMER_KEY; $urlshortname = str_replace('@', '%40', strtolower($username)); $returnurl = curPageURL2(); // if a password has been created that means either resources have been requested or an event is active // that causes the causes the calendar to be active /* if (!isset($morslerec)) { $coursecalendar = '  No Calendar Information Available<br />'; } elseif(!isset($morslerec->password)){ $coursecalendar = '  Morsle Calendar Not Yet Available<br />'; } else { // $coursecalendar = '<object data="https://www.google.com/calendar/b/0/embed?showTitle=0&showNav=0&showDate=0&showPrint=0&showTabs=0&showCalendars=0&showTz=0&mode=AGENDA&height=120&wkst=1&bgcolor=%23ffffff&src=' // . $urlshortname . '&color=%23856508&ctz=America%2FChicago" type="text/html" id="embeddedhtml" style=" border-width:0 " width="195" height="120"></object>'; $coursecalendar = '<iframe src="https://www.google.com/calendar/embed?showTitle=0&showNav=0&showDate=0&showPrint=0&showTabs=0&showTz=0&mode=AGENDA&height=400&wkst=1&bgcolor=%23FFFFFF&src=' . $urlshortname . '&color=%236B3304&ctz=America%2FChicago" style=" border-width:0 " width="200" height="300" frameborder="0" scrolling="no"></iframe>'; } * */ $coursecalendar = ''; $this->content->text .= '<table class="morslefull">'; // morsle logo $this->content->text .= '<tr><td class="morslefiles morsletop" colspan = "2"><img class="logo" src="' . $CFG->wwwroot . '/blocks/morsle/images/morslelogobackground.png" alt=\\"Norse Docs for Moodle" />'; $this->content->text .= '</td></tr>'; // google calendar for course $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; $this->content->text .= '</td></tr>'; // folders if (!isset($morslerec->password)) { $this->content->text .= '<tr><td colspan = "2">'; // $this->content->text .= $OUTPUT->help_icon('morsle', $this->title, 'block_morsle', true); $this->content->text .= 'Norse Apps resources for this course not yet available</td></tr></table>'; // TODO: should be checking all values to make sure all resources are available } else { $this->content->text .= '<tr><td class="morslefiles"><a href="' . $CFG->wwwroot . '/blocks/morsle/morslefiles.php?courseid=' . $COURSE->id . '&wdir="> <img src="' . $CFG->wwwroot . '/blocks/morsle/images/morslefiles.png" /></a></td>'; $this->content->text .= '<td><a target="_blank" href="mailto:' . $morslerec->shortname . '-group@' . $CONSUMER_KEY . '"> <img src="' . $CFG->wwwroot . '/blocks/morsle/images/mailAllCourseMembersCell.png" /></a></td></tr>'; /* $this->content->text .= '<td><a href="' . $CFG->wwwroot . '/blocks/morsle/morslefiles.php?courseid=' . $COURSE->id . '&wdir=/"> <img src="' . $CFG->wwwroot . '/blocks/morsle/images/studentWriteableFolderCell.png" /></a></td></tr>'; */ $this->content->text .= '<tr><td class="morslefiles"><a href="' . $CFG->wwwroot . '/blocks/morsle/lang/help/morsle/morsle.html" target="_blank"> <img src="' . $CFG->wwwroot . '/blocks/morsle/images/helpWithMorsleCell.png" /></a></td>'; $this->content->text .= '<td class="morslebottom"><a href="' . $morslerec->siteid . '"> <img src="' . $CFG->wwwroot . '/blocks/morsle/images/morsleSitesCell.png" /></a></td></tr>'; // $this->content->text .= '<td></td></tr>'; $this->content->text .= '</table>'; } $this->content->footer = ''; return $this->content; }
public function get_content() { if ($this->content !== null) { return $this->content; } global $COURSE, $CFG, $USER, $DB, $OUTPUT; $MORSLE_EXPIRES = is_null(get_config('morsle', 'morsle_expiration')) ? 30 * 24 * 60 * 60 : get_config('morsle', 'morsle_expiration') * 24 * 60 * 60; $curtime = time(); $this->content = new stdClass(); $morslerec = new stdClass(); $mhelp = get_string('morsle_help_string', 'block_morsle'); // get_config('assignment','duedate'); if ($COURSE->startdate + $MORSLE_EXPIRES < $curtime || $COURSE->startdate == 0) { $this->content = null; return $this->content; } $context = context_course::instance($COURSE->id); $conditions = array('courseid' => $COURSE->id); // create morslerec if needed EVEN IF course is invisible to students // only if user has editingteacher role and not admin // admin entering unused course will not create the morsle record if (!($morslerec = $DB->get_record('morsle_active', $conditions))) { if (has_capability('moodle/course:update', $context) && !is_siteadmin($USER)) { $newrec->created = time(); $newrec->status = 'Full'; $newrec->courseid = $COURSE->id; $newrec->shortname = strtolower($COURSE->shortname); if ($morslerec = $DB->insert_record('morsle_active', $newrec)) { add_to_log($COURSE->id, 'morsle', "morsle FULL record created for {$COURSE->shortname}"); } else { add_to_log($COURSE->id, 'morsle', "morsle FULL record NOT CREATED for {$COURSE->shortname}"); } } else { $morslerec = new stdClass(); } } $username = $COURSE->shortname . '@luther.edu'; $urlshortname = str_replace('@', '%40', strtolower($username)); $morslecalendar_auth = new block_morsle_auth($username); $morslecalendar_list = $morslecalendar_auth->morsle_calendar->calendarList->listCalendarList(); $morslecalendar_id = $username; /* or 'primary', depending on your preference*/ $morslecalendar_optionalParams = array('maxResults' => 10, 'orderBy' => 'startTime', 'singleEvents' => TRUE, 'timeMin' => date('c')); $results = $morslecalendar_auth->morsle_calendar->events->listEvents($morslecalendar_id, $morslecalendar_optionalParams); $morslecalendarTimeZone = $results->timeZone; //get calendar's timezone date_default_timezone_set($morslecalendarTimeZone); $returnurl = curPageURL2(); $this->content->text = ''; $this->content->text .= '<table class="morslefull" style="width: 100%;">'; $imsrc = $CFG->wwwroot . '/blocks/morsle/images/morslelogobackground.png'; // $this->content->text .= '<tr><td class="morslelogo morsletop" colspan = "2" style="background-image:url('.$imsrc.');background-repeat:no-repeat;background-size:100%;background-position:center;">'; $this->content->text .= '<tr><td class="morslelogo morsletop" colspan = "2"><img class="logo" src="' . $imsrc . '" alt=\\"Norse Docs for Moodle" />'; $this->content->text .= '</td></tr>'; if (!isset($morslerec)) { $coursecalendar = '  No Calendar Information Available<br/>'; $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; } elseif (!isset($morslerec->password)) { $coursecalendar = '  Morsle Calendar Not Yet Available<br/>'; $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; } else { //morsle block is available if (count($results->getItems()) == 0) { $coursecalendar .= "<div id='calendardiv'><p>No Upcoming Events</p>"; $coursecalendar .= "<div class='calendarlink'>"; // $coursecalendar = '  No Upcoming Events<br/>'; $coursecalendar .= '<iframe src="https://www.google.com/calendar/b/0/embed?showTitle=0&showNav=0&showDate=0&showPrint=0&showTabs=0&showCalendars=0&showTz=0&mode=AGENDA&height=120&wkst=1&bgcolor=%23e3e9ff&src=' . $urlshortname . '&color=%23856508&ctz=America%2FChicago" type="text/html" id="embeddedhtml" style=" border-width:0" width="250" height="120" frameborder=0 ></iframe>'; $coursecalendar .= "</div></div>"; $coursecalendar .= "<div id='usernotloggedin' style='padding-top:5px;padding-left:5px;display:none;'><p><a href='https://accounts.google.com/ServiceLogin?hl=en&continue=https://www.google.com/#identifier'>Log into Google</a> to use Morsle.</p></div>"; //<div class='g-signin2' data-onsuccess='onSignIn'></div></div>"; $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; } else { $coursecalendar = "<div id='calendardiv'><p>Upcoming Events</p>"; $coursecalendar .= "<div class='calendarlink'>"; /* foreach ($results->getItems() as $results) { $courseevents = $results->start->dateTime; if (empty($courseevents)) { $courseevents = $results->start->date; } $temp_timezone = $results->start->timeZone; if (!empty($temp_timezone)) { $timezone = new DateTimeZone($temp_timezone); //GET THE TIME ZONE } else { $timezone = new DateTimeZone($morslecalendarTimeZone); //set it to local timezone } $eventdate = new DateTime($courseevents,$timezone); $link = $results->htmlLink; $TZlink = $link . "&ctz=" . $morslecalendarTimeZone; $newmonth = $eventdate->format("M"); $newday = $eventdate->format("j"); $coursecalendar .="<li><a href=". $TZlink .">"; $coursecalendar.= $results->summary."</a></li>"; }*/ $coursecalendar .= '<object data="https://www.google.com/calendar/b/0/embed?showTitle=0&showNav=0&showDate=0&showPrint=0&showTabs=0&showCalendars=0&showTz=0&mode=AGENDA&height=120&wkst=1&bgcolor=%23e3e9ff&src=' . $urlshortname . '&color=%23856508&ctz=America%2FChicago" type="text/html" id="embeddedhtml" style ="border-radius: none;" width="255" height="200"></object>'; $coursecalendar .= "</div></div>"; $coursecalendar .= "<div id='usernotloggedin' style='padding-top:5px;padding-left:5px;display:none;'><p><a href='https://accounts.google.com/ServiceLogin?hl=en&continue=https://www.google.com/#identifier'>Log into Google</a> to use Morsle.</p></div>"; //<div class='g-signin2' data-onsuccess='onSignIn'></div></div>"; $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; } } $this->content->text .= '</td></tr>'; if (!isset($morslerec->password)) { $this->content->text .= '<tr><td colspan = "2">'; $this->content->text .= 'Norse Apps resources for this course not yet available</td></tr></table>'; } else { // $this->content->text .= '<tr><td class="morslefiles"><a href="' . $CFG->wwwroot . '/blocks/morsle/morslefiles.php?courseid=' . $COURSE->id . $this->content->text .= '<tr><td class="morslefiles"><a href="https://www.luther.edu/lis/blog/?story_id=621182"> <img src="' . $CFG->wwwroot . '/blocks/morsle/images/morslefiles.png" /></a></td>'; $this->content->text .= '<td class="morslemail"><a target="_blank" href="mailto:' . $morslerec->shortname . '*****@*****.**"><img src="' . $CFG->wwwroot . '/blocks/morsle/images/mailAllCourseMembersCell.png" /></a></td></tr>'; $this->content->text .= '<tr class="bottomrows"><td class="morslehelp"><a href="' . $CFG->wwwroot . '/blocks/morsle/lang/help/morsle/morsle.html" target="_blank"><img src="' . $CFG->wwwroot . '/blocks/morsle/images/helpWithMorsleCell.png" /></a></td>'; $this->content->text .= '<td class="morslebottom morslesites"><a href="' . $morslerec->siteid . '"> <img src="' . $CFG->wwwroot . '/blocks/morsle/images/morsleSitesCell.png" /></a></td></tr>'; $this->content->text .= '</table>'; } $this->content->footer = ''; return $this->content; }
public function get_content() { if ($this->content !== null) { return $this->content; } global $COURSE, $CFG, $USER, $DB, $OUTPUT; $this->content = new stdClass(); $morslerec = new stdClass(); $mhelp = get_string('morsle_help_string', 'block_morsle'); // expiration of block $MORSLE_EXPIRES = is_null(get_config('morsle', 'morsle_expiration')) ? 30 * 24 * 60 * 60 : get_config('morsle', 'morsle_expiration') * 24 * 60 * 60; $curtime = time(); if ($COURSE->startdate + $MORSLE_EXPIRES < $curtime || $COURSE->startdate == 0) { $this->content = null; return $this->content; } $context = context_course::instance($COURSE->id); $conditions = array('courseid' => $COURSE->id); // create morslerec if needed EVEN IF course is invisible to students // only if user has editingteacher role and not admin // admin entering unused course will not create the morsle record if (!($morslerec = $DB->get_record('morsle_active', $conditions))) { if (has_capability('moodle/course:update', $context) && !is_siteadmin($USER)) { $newrec->created = time(); $newrec->status = 'Full'; $newrec->courseid = $COURSE->id; $newrec->shortname = strtolower($COURSE->shortname); if ($morslerec = $DB->insert_record('morsle_active', $newrec)) { add_to_log($COURSE->id, 'morsle', "morsle FULL record created for {$COURSE->shortname}"); } else { add_to_log($COURSE->id, 'morsle', "morsle FULL record NOT CREATED for {$COURSE->shortname}"); } } else { $morslerec = new stdClass(); } } $username = $COURSE->shortname . '@luther.edu'; $urlshortname = str_replace('@', '%40', strtolower($username)); $returnurl = curPageURL2(); $this->content->text = ''; $this->content->text .= '<table class="morslefull" style="width: 100%;">'; $imsrc = $CFG->wwwroot . '/blocks/morsle/images/morslelogobackground.png'; // $this->content->text .= '<tr><td class="morslelogo morsletop" colspan = "2" style="background-image:url('.$imsrc.');background-repeat:no-repeat;background-size:100%;background-position:center;">'; $this->content->text .= '<tr><td class="morslelogo morsletop" colspan = "2"><img class="logo" src="' . $imsrc . '" alt=\\"Norse Docs for Moodle" />'; $this->content->text .= '</td></tr>'; if (!isset($morslerec)) { $coursecalendar = '  No Calendar Information Available<br/>'; $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; } elseif (!isset($morslerec->password)) { $coursecalendar = '  Morsle Calendar Not Yet Available<br/>'; $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; } else { //morsle block is available $coursecalendar = '<object data="https://www.google.com/calendar/b/0/embed?showTitle=0&showNav=0&showDate=0&showPrint=0&showTabs=0&showCalendars=0&showTz=0&mode=AGENDA&height=120&wkst=1&bgcolor=%23e3e9ff&src=' . $urlshortname . '&color=%23856508&ctz=America%2FChicago" type="text/html" id="embeddedhtml" style ="border-radius: none;" width="255" height="200"></object>'; $coursecalendar .= "</div></div>"; $coursecalendar .= "<div id='usernotloggedin' style='padding-top:5px;padding-left:5px;display:none;'><p><a href='https://accounts.google.com/ServiceLogin?hl=en&continue=https://www.google.com/#identifier'>Log into Google</a> to use Morsle.</p></div>"; $this->content->text .= '<tr><td colspan = "2" class="calendar">' . $coursecalendar; } $this->content->text .= '</td></tr>'; if (!isset($morslerec->password)) { $this->content->text .= '<tr><td colspan = "2">'; $this->content->text .= 'Norse Apps resources for this course not yet available</td></tr></table>'; } else { $this->content->text .= '<tr><td class="morsleleft"><a target="_blank" href="mailto:' . $morslerec->shortname . '*****@*****.**"><img src="' . $CFG->wwwroot . '/blocks/morsle/images/mailAllCourseMembersCell.png" /></a></td>'; $this->content->text .= '<td class="morsleright"><a href="' . $CFG->wwwroot . '/blocks/morsle/lang/help/morsle/morsle.html" target="_blank"><img src="' . $CFG->wwwroot . '/blocks/morsle/images/helpWithMorsleCell.png" /></a></td></tr>'; $this->content->text .= '</table>'; } $this->content->footer = ''; return $this->content; }