/** * Function to be run periodically according to the moodle cron * This function searches for things that need to be done, such * as sending out mail, toggling flags etc ... * * @return boolean */ function udutu_cron() { global $CFG; require_once 'locallib.php'; $sitetimezone = $CFG->timezone; /// Now see if there are any digest mails waiting to be sent, and if we should send them if (!isset($CFG->udutu_updatetimelast)) { // To catch the first time set_config('udutu_updatetimelast', 0); } $timenow = time(); $updatetime = usergetmidnight($timenow, $sitetimezone) + $CFG->udutu_updatetime * 3600; if ($CFG->udutu_updatetimelast < $updatetime and $timenow > $updatetime) { set_config('udutu_updatetimelast', $timenow); mtrace('Updating udutu packages which require daily update'); //We are updating $udutusupdate = get_records('udutu', 'updatefreq', UPDATE_EVERYDAY); if (!empty($udutusupdate)) { foreach ($udutusupdate as $udutuupdate) { $udutuupdate->instance = $udutuupdate->id; $id = udutu_update_instance($udutuupdate); } } } return true; }
function udutu_view_display($user, $udutu, $action, $cm, $boxwidth = '') { global $CFG; if ($udutu->updatefreq == UDUTU_UPDATE_EVERYTIME) { $udutu->instance = $udutu->id; udutu_update_instance($udutu); } $organization = optional_param('organization', '', PARAM_INT); print_simple_box_start('center', $boxwidth); ?> <div class="structurehead"><?php print_string('contents', 'udutu'); ?> </div> <?php if (empty($organization)) { $organization = $udutu->launch; } if ($orgs = get_records_select_menu('udutu_scoes', "udutu='{$udutu->id}' AND organization='' AND launch=''", 'id', 'id,title')) { if (count($orgs) > 1) { ?> <div class='center'> <?php print_string('organizations', 'udutu'); ?> <form id='changeorg' method='post' action='<?php echo $action; ?> '> <?php choose_from_menu($orgs, 'organization', "{$organization}", '', 'submit()'); ?> </form> </div> <?php } } $orgidentifier = ''; if ($sco = udutu_get_sco($organization, UDUTU_SCO_ONLY)) { if ($sco->organization == '' && $sco->launch == '') { $orgidentifier = $sco->identifier; } else { $orgidentifier = $sco->organization; } } /* $orgidentifier = ''; if ($org = get_record('udutu_scoes','id',$organization)) { if (($org->organization == '') && ($org->launch == '')) { $orgidentifier = $org->identifier; } else { $orgidentifier = $org->organization; } }*/ $udutu->version = strtolower(clean_param($udutu->version, PARAM_SAFEDIR)); // Just to be safe if (!file_exists($CFG->dirroot . '/mod/udutu/datamodels/' . $udutu->version . 'lib.php')) { $udutu->version = 'udutu_12'; } require_once $CFG->dirroot . '/mod/udutu/datamodels/' . $udutu->version . 'lib.php'; $result = udutu_get_toc($user, $udutu, 'structlist', $orgidentifier); $incomplete = $result->incomplete; echo $result->toc; print_simple_box_end(); ?> <div class="center"> <form id="theform" method="post" action="<?php echo $CFG->wwwroot; ?> /mod/udutu/player.php?scoid=<?php echo $sco->id; ?> &id=<?php echo $cm->id; ?> "<?php echo $udutu->popup == 1 ? ' target="newwin"' : ''; ?> > <?php if ($udutu->hidebrowse == 0) { print_string('mode', 'udutu'); echo '<input type="hidden" name="scoid" value="$sco->id" />' . "\n"; echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">' . get_string('browse', 'udutu') . '</label>' . "\n"; echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">' . get_string('normal', 'udutu') . "</label>\n"; } else { echo '<input type="hidden" name="mode" value="normal" />' . "\n"; } if ($incomplete === false && ($result->attemptleft > 0 || $udutu->maxattempt == 0)) { ?> <br /> <input type="checkbox" id="a" name="newattempt" /> <label for="a"><?php print_string('newattempt', 'udutu'); ?> </label> <?php } ?> <br /> <input type="hidden" name="scoid"/> <input type="hidden" name="currentorg" value="<?php echo $orgidentifier; ?> " /> <input type="submit" value="<?php print_string('entercourse', 'udutu'); ?> " /> </form> </div> <?php }