function definition() { global $CFG, $USER, $DB, $COURSE; $mform =& $this->_form; // Don't forget the underscore! $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } $alertunit = $DB->get_record('block_timetracker_alertunits', array('id' => $this->alertid)); $userinfo = $DB->get_record('block_timetracker_workerinfo', array('id' => $alertunit->userid)); $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', array('id' => $alertunit->courseid, 'userid' => $alertunit->userid)); if (get_referer(false)) { $nextpage = get_referer(false); } else { $nextpage = $index; } if (!$canmanage && $USER->id != $userinfo->mdluserid) { redirect($nextpage, 'You do not have permission to change this alert.', 1); } else { $mform->addElement('hidden', 'userid', $alertunit->userid); $mform->addElement('hidden', 'courseid', $alertunit->courseid); $mform->addElement('hidden', 'payrate', $alertunit->payrate); $mform->addElement('hidden', 'lasteditedby', $USER->id); $mform->addElement('hidden', 'alertid', $alertunit->id); $mform->addElement('hidden', 'action', $alertunit->id); $mform->addElement('header', 'general', get_string('changealert', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); $mform->addElement('html', get_string('emessage2', 'block_timetracker')); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage3', 'block_timetracker', userdate($alertunit->origtimein))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage4', 'block_timetracker', userdate($alertunit->origtimeout))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessageduration', 'block_timetracker', format_elapsed_time($alertunit->origtimeout - $alertunit->origtimein, $alertunit->courseid))); $mform->addElement('html', get_string('br2', 'block_timetracker')); $mform->addElement('html', get_string('emessage5', 'block_timetracker')); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage3', 'block_timetracker', userdate($alertunit->timein))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage4', 'block_timetracker', userdate($alertunit->timeout))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessageduration', 'block_timetracker', format_elapsed_time($alertunit->timeout - $alertunit->timein, $alertunit->courseid))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage6', 'block_timetracker', $alertunit->message)); $mform->addElement('html', get_string('br2', 'block_timetracker')); $mform->addElement('html', get_string('changeto', 'block_timetracker')); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('date_time_selector', 'timein', get_string('timeinerror', 'block_timetracker'), array('optional' => false, 'step' => 1)); $mform->setDefault('timein', $alertunit->timein); $mform->addHelpButton('timein', 'timein', 'block_timetracker'); $mform->addElement('date_time_selector', 'timeout', get_string('timeouterror', 'block_timetracker'), array('optional' => false, 'step' => 1)); $mform->setDefault('timeout', $alertunit->timeout); $mform->addHelpButton('timeout', 'timeout', 'block_timetracker'); $mform->addElement('checkbox', 'deleteunit', get_string('deleteunit', 'block_timetracker')); $mform->addHelpButton('deleteunit', 'deleteunit', 'block_timetracker'); $this->add_action_buttons(true, get_string('savebutton', 'block_timetracker')); } }
} echo ">>> [" . date("H:i:s") . "] Finished building {$build} {$message_32}- Elapsed time: " . format_elapsed_time(time() - $port_start_time) . "\n"; } else { echo ">>> [" . date("H:i:s") . "] Skipping {$build} for {$main_build_arch}\n"; } if ($host_arch == "amd64" && $options['a'] == 'all') { if (empty($pbi_options['only_for_archs']) || in_array("i386", $pbi_options['only_for_archs'])) { echo ">>> [" . date("H:i:s") . "] Processing {$build} 32-bit ({$j}/{$total_to_build})\n"; echo ">>> [" . date("H:i:s") . "] Executing /usr/local/sbin/pbi_makeport -o /usr/ports/packages/All/ -c {$pbi_confdir} -32 {$sign}{$category}/{$port}\n"; system("/usr/local/sbin/pbi_makeport -o /usr/ports/packages/All/ -c {$pbi_confdir} -32 {$sign}{$category}/{$port}{$redirbg}"); if (!isset($options['v'])) { wait_for_procs_finish(); } echo ">>> [" . date("H:i:s") . "] Finished building {$build} 32-bit - Elapsed time: " . format_elapsed_time(time() - $port_start_time) . "\n"; } else { echo ">>> [" . date("H:i:s") . "] Skipping {$build} for i386\n"; } } if ($copy_packages_to_folder_ssh && isset($options['u']) && !isset($options['U'])) { copy_packages($copy_packages_to_host_ssh, $copy_packages_to_host_ssh_port, $file_system_root, $copy_packages_to_folder_ssh); } } echo ">>> {$file_system_root}/usr/ports/packages/All now contains:\n"; system("ls {$file_system_root}/usr/ports/packages/All"); // Copy created packages to the package server via rsync if ($copy_packages_to_folder_ssh && !isset($options['U'])) { copy_packages($copy_packages_to_host_ssh, $copy_packages_to_host_ssh_port, $file_system_root, $copy_packages_to_folder_ssh); } echo ">>> Package binary build run ended at " . date(DATE_RFC822) . ".\n"; echo ">>> Total time: " . format_elapsed_time(time() - $port_start_time) . "\n";
$messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessage4', 'block_timetracker', userdate($formdata->origtimeout)); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessageduration', 'block_timetracker', format_elapsed_time($formdata->origtimeout - $formdata->origtimein, $course->id)); } $messagehtml .= get_string('br2', 'block_timetracker'); $messagehtml .= get_string('emessage5', 'block_timetracker'); $messagehtml .= get_string('br1', 'block_timetracker'); if ($delete == 1) { $messagehtml .= get_string('emessagedelete', 'block_timetracker'); } else { $messagehtml .= get_string('emessage3', 'block_timetracker', userdate($formdata->timeinerror)); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessage4', 'block_timetracker', userdate($formdata->timeouterror)); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessageduration', 'block_timetracker', format_elapsed_time($formdata->timeouterror - $formdata->timeinerror, $course->id)); } $messagehtml .= get_string('br2', 'block_timetracker'); $messagehtml .= get_string('emessage6', 'block_timetracker', $formdata->message); $messagehtml .= get_string('br2', 'block_timetracker'); //$messagehtml .= get_string('hr','block_timetracker'); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessageavailable', 'block_timetracker'); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessagedisclaimer', 'block_timetracker'); $messagehtml .= get_string('br2', 'block_timetracker'); // Get data from 'pending' or 'workunit' table to put into the 'alertunits' table if ($ispending) { // Pending Work Unit $alertunit = $DB->get_record('block_timetracker_pending', array('id' => $unitid)); } else {
function definition() { global $CFG, $USER, $DB, $COURSE; $mform =& $this->_form; // Don't forget the underscore! //check to make sure that if $this->userid != $USER->id that they have //the correct capability TODO if (!has_capability('block/timetracker:manageworkers', $this->context)) { print_error('Insufficient permission to edit this workunit'); return; } $canmanagepayrate = false; if (has_capability('block/timetracker:managepayrate', $this->context)) { $canmanagepayrate = true; } $userinfo = $DB->get_record('block_timetracker_workerinfo', array('id' => $this->userid)); if (!$userinfo) { print_error('Worker info does not exist for workerinfo id of ' . $this->userid); return; } if ($this->ispending) { //error_log("getting a pending unit # $this->unitid"); $unit = $DB->get_record('block_timetracker_pending', array('id' => $this->unitid)); //print_object($unit); } else { $unit = $DB->get_record('block_timetracker_workunit', array('id' => $this->unitid)); } if (!$unit) { print_error('Unit does not exist: ' . $this->unitid); return; } $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', array('id' => $this->courseid, 'userid' => $this->userid)); if (isset($_SERVER['HTTP_REFERER'])) { $nextpage = $_SERVER['HTTP_REFERER']; } else { $nextpage = $index; } $mform->addElement('header', 'general', get_string('editunittitle', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); /** HIDDEN FIELDS **/ $mform->addElement('hidden', 'userid', $this->userid); $mform->addElement('hidden', 'unitid', $this->unitid); $mform->addElement('hidden', 'id', $this->courseid); $mform->addElement('hidden', 'ispending', $this->ispending); $mform->addElement('hidden', 'next', '#'); $mform->addElement('hidden', 'eunitid', '#'); $mform->addElement('hidden', 'astart', '#'); $mform->addElement('hidden', 'aend', '#'); //edited by supervisor $mform->addElement('hidden', 'editedby', $USER->id); /** END HIDDEN FIELDS **/ /** EXISTING DATA **/ $mform->addElement('html', get_string('existingunit', 'block_timetracker')); $mform->addElement('html', '<blockquote>'); $mform->addElement('html', get_string('existingtimein', 'block_timetracker', userdate($unit->timein, get_string('datetimeformat', 'block_timetracker')))); if (!$this->ispending) { $mform->addElement('html', '<br />'); $mform->addElement('html', get_string('existingtimeout', 'block_timetracker', userdate($unit->timeout, get_string('datetimeformat', 'block_timetracker')))); $mform->addElement('html', '<br /><b>'); $mform->addElement('html', get_string('existingduration', 'block_timetracker', format_elapsed_time($unit->timeout - $unit->timein, $unit->courseid))); } $mform->addElement('html', '</blockquote>'); /** END EXISTING DATA **/ $mform->addElement('date_time_selector', 'timein', 'Time In: ', array('optional' => false, 'step' => 1)); $mform->addHelpButton('timein', 'timein', 'block_timetracker'); if ($this->start != 0) { $mform->setDefault('timein', $this->start); } else { $mform->setDefault('timein', $unit->timein); } if (!$this->ispending) { $mform->addElement('date_time_selector', 'timeout', 'Time Out: ', array('optional' => false, 'step' => 1)); $mform->addHelpButton('timeout', 'timeout', 'block_timetracker'); if ($this->end != 0) { $mform->setDefault('timeout', $this->end); } else { $mform->setDefault('timeout', $unit->timeout); } $opstring = 'readonly="readonly"'; if ($canmanagepayrate) { $opstring = ''; } $mform->addElement('text', 'payrate', 'Payrate $', $opstring); $mform->setDefault('payrate', $unit->payrate); $mform->addRule('payrate', 'Numeric values only', 'numeric', null, 'server', false, false); } $this->add_action_buttons(true, get_string('savebutton', 'block_timetracker')); }
function definition() { global $CFG, $USER, $DB, $COURSE; $mform =& $this->_form; // Don't forget the underscore! //check to make sure that if $this->userid != $USER->id that they have //the correct capability TODO $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } if ($this->ispending) { //Get from pending table $unit = $DB->get_record('block_timetracker_pending', array('id' => $this->unitid)); } else { //Get from workunit $unit = $DB->get_record('block_timetracker_workunit', array('id' => $this->unitid)); } if (!$unit) { print_error('Unit does not exist for unit id of ' . $this->unitid); return; } $userinfo = $DB->get_record('block_timetracker_workerinfo', array('id' => $this->userid)); if (!$userinfo) { print_error('Worker info does not exist for workerinfo id of ' . $this->userid); return; } $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', array('id' => $this->courseid, 'userid' => $this->userid)); if (get_referer(false)) { $nextpage = get_referer(false); } else { $nextpage = $index; } if (!$canmanage && $USER->id != $userinfo->mdluserid) { redirect($nextpage, 'No permission to add hours', 1); } $mform->addElement('header', 'general', get_string('errortitle', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); $mform->addElement('hidden', 'userid', $this->userid); $mform->addElement('hidden', 'id', $this->courseid); $mform->addElement('hidden', 'unitid', $this->unitid); $mform->addElement('hidden', 'ispending', $this->ispending); if ($canmanage) { } else { $mform->addElement('hidden', 'editedby', $this->userid); $mform->addElement('html', '<b>'); $mform->addElement('html', get_string('to', 'block_timetracker')); $mform->addElement('html', '</b>'); $teachers = get_users_by_capability($this->context, 'block/timetracker:manageworkers'); if (!$teachers) { print_error('No supervisor is enrolled in this course. Please alert your Administrator.'); } foreach ($teachers as $teacher) { if (is_enrolled($this->context, $teacher->id)) { //!has_capability('moodle/category:manage',$this->context,$teacher) && //is_enrolled($this->context, $teacher->id)){ $mform->addElement('advcheckbox', 'teacherid[' . $teacher->id . ']', $teacher->firstname . ' ' . $teacher->lastname, null, array('group' => 1)); } } $this->add_checkbox_controller(1, null, null, 1); $mform->addElement('html', '<b>'); $mform->addElement('html', get_string('subject', 'block_timetracker')); $mform->addElement('html', '</b>'); $mform->addElement('html', get_string('subjecttext', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); $mform->addElement('html', '<br /><br />'); $mform->addElement('html', get_string('existingunit', 'block_timetracker')); $mform->addElement('html', '<blockquote>'); $mform->addElement('html', get_string('existingtimein', 'block_timetracker', userdate($unit->timein, get_string('datetimeformat', 'block_timetracker')))); if (!$this->ispending) { //Time out and elapsed time $mform->addElement('html', '<br />'); $mform->addElement('html', get_string('existingtimeout', 'block_timetracker', userdate($unit->timeout, get_string('datetimeformat', 'block_timetracker')))); $mform->addElement('html', '<br />'); $mform->addElement('html', get_string('existingduration', 'block_timetracker', format_elapsed_time($unit->timeout - $unit->timein, $unit->courseid))); } $mform->addElement('html', '</blockquote><b>'); $mform->addElement('html', get_string('data', 'block_timetracker')); $mform->addElement('date_time_selector', 'timeinerror', 'Time In: ', array('optional' => false, 'step' => 1)); $mform->setDefault('timeinerror', $unit->timein); $mform->addHelpButton('timeinerror', 'timein', 'block_timetracker'); $mform->addElement('date_time_selector', 'timeouterror', 'Time Out: ', array('optional' => false, 'step' => 1)); $mform->addHelpButton('timeouterror', 'timeout', 'block_timetracker'); $mform->addElement('hidden', 'origtimein', $unit->timein); if (!$this->ispending) { $mform->setDefault('timeouterror', $unit->timeout); $mform->addElement('hidden', 'origtimeout', $unit->timeout); } else { $mform->setDefault('timeouterror', $unit->timein + 60 * 60 * 2); } if (!$this->ispending) { $mform->addElement('checkbox', 'deleteunit', get_string('deleteunit', 'block_timetracker')); $mform->addHelpButton('deleteunit', 'deleteunit', 'block_timetracker'); } $mform->addElement('textarea', 'message', get_string('messageforerror', 'block_timetracker'), 'wrap="virtual" rows="6" cols="75"'); $mform->addHelpButton('message', 'messageforerror', 'block_timetracker'); $mform->addRule('message', null, 'required', null, 'client', 'false'); $mform->addElement('html', '</b>'); $this->add_action_buttons(true, get_string('sendbutton', 'block_timetracker')); } }
$messagehtml .= get_string('emessage3', 'block_timetracker', userdate($alertunit->origtimein)); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessage4', 'block_timetracker', userdate($alertunit->origtimeout)); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessageduration', 'block_timetracker', format_elapsed_time($alertunit->origtimeout - $alertunit->origtimein, $course->id)); $messagehtml .= get_string('br2', 'block_timetracker'); $messagehtml .= get_string('approveddata', 'block_timetracker'); $messagehtml .= get_string('br1', 'block_timetracker'); if ($alertunit->todelete == 1) { $messagehtml .= get_string('unitdeleted', 'block_timetracker'); } else { $messagehtml .= get_string('emessage3', 'block_timetracker', userdate($alertunit->timein)); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessage4', 'block_timetracker', userdate($alertunit->timeout)); $messagehtml .= get_string('br1', 'block_timetracker'); $messagehtml .= get_string('emessageduration', 'block_timetracker', format_elapsed_time($alertunit->timeout - $alertunit->timein, $course->id)); } foreach ($alertcom as $alertcomentry) { if ($USER->id != $alertcomentry->mdluserid) { // Get email address from each in moodle table $emailto = $DB->get_record('user', array('id' => $alertcomentry->mdluserid)); if ($emailto) { email_to_user($emailto, $from, $subject, $messagetext, $messagehtml); } } // Remove record(s) from the 'alert_com' table $DB->delete_records('block_timetracker_alert_com', array('alertid' => $alertcomentry->alertid, 'mdluserid' => $alertcomentry->mdluserid)); } // Remove record(s) from the 'alert_com' table $DB->delete_records('block_timetracker_alertunits', array('id' => $alertunit->id)); }
function definition() { global $CFG, $USER, $DB, $COURSE, $OUTPUT; $mform =& $this->_form; // Don't forget the underscore! $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } $canview = false; if (has_capability('block/timetracker:viewonly', $this->context)) { $canview = true; } if ($canview && !$canmanage) { $urlparams['id'] = $COURSE->id; $nextpage = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', $urlparams); redirect($nextpage, 'You do not have permission to view alerts for this course. <br /> Redirecting you now.', 2); } $mform->addElement('header', 'general', get_string('managealerts', 'block_timetracker')); $mform->addHelpButton('general', 'managealerts', 'block_timetracker'); $strname = get_string('workername', 'block_timetracker'); $strprev = get_string('previous', 'block_timetracker'); $strproposed = get_string('proposed', 'block_timetracker'); $strmsg = get_string('message', 'block_timetracker'); if (!has_course_alerts($COURSE->id)) { $mform->addElement('html', '<div style="text-align:center">'); $mform->addElement('html', get_string('noalerts', 'block_timetracker')); $mform->addElement('html', '</div>'); return; } else { $mform->addElement('html', '<table align="center" border="1" cellspacing="10px" ' . 'cellpadding="5px" width="95%">'); $tblheaders = '<tr> <td><span style="font-weight: bold">' . $strname . '</span></td> <td><span style="font-weight: bold">' . $strprev . '</span></td> <td><span style="font-weight: bold">' . $strproposed . '</span></td> <td><span style="font-weight: bold">' . $strmsg . '</span></td>'; if ($canmanage) { $tblheaders .= '<td style="text-align: center">' . '<span style="font-weight: bold">' . get_string('action') . '</span></td>'; } $tblheaders .= '</tr>'; $mform->addElement('html', $tblheaders); $alertlinks = get_course_alert_links($COURSE->id); //print_object($alertlinks); if ($canmanage) { $alerts = $DB->get_records('block_timetracker_alertunits', array('courseid' => $COURSE->id), 'alerttime'); } else { $ttuserid = $DB->get_field('block_timetracker_workerinfo', 'id', array('mdluserid' => $USER->id, 'courseid' => $COURSE->id)); if (!$ttuserid) { print_error('Error obtaining mdluserid from workerinfo for ' . $USER->id); } $alerts = $DB->get_records('block_timetracker_alertunits', array('courseid' => $COURSE->id, 'userid' => $ttuserid)); } } foreach ($alerts as $alert) { $worker = $DB->get_record('block_timetracker_workerinfo', array('id' => $alert->userid)); $mform->addElement('html', '<tr>'); $row = '<td>' . $worker->lastname . ', ' . $worker->firstname . '<br />Submitted: ' . userdate($alert->alerttime, get_string('datetimeformat', 'block_timetracker')) . '</td>'; $row .= '<td>In: ' . userdate($alert->origtimein, get_string('datetimeformat', 'block_timetracker')); if ($alert->origtimeout > 0) { $row .= '<br />Out: ' . userdate($alert->origtimeout, get_string('datetimeformat', 'block_timetracker')); $row .= '<br />Elapsed: ' . format_elapsed_time($alert->origtimeout - $alert->origtimein, $alert->courseid); } else { $row .= ''; } $row .= '</td>'; if ($alert->todelete == 0) { $row .= '<td>In: ' . userdate($alert->timein, get_string('datetimeformat', 'block_timetracker')); $row .= '<br />Out: ' . userdate($alert->timeout, get_string('datetimeformat', 'block_timetracker')); $row .= '<br />Elapsed: ' . format_elapsed_time($alert->timeout - $alert->timein, $alert->courseid); $row .= '</td>'; } else { $row .= '<td><span style="color: red">User requests removal</span></td>'; } $row .= '<td>' . nl2br($alert->message) . '</td>'; if ($canmanage) { $editurl = new moodle_url($alertlinks[$worker->id][$alert->id]['change']); $editaction = $OUTPUT->action_icon($editurl, new pix_icon('clock_edit', 'Edit proposed work unit', 'block_timetracker')); $approveurl = new moodle_url($alertlinks[$worker->id][$alert->id]['approve']); $checkicon = new pix_icon('approve', 'Approve the proposed work unit', 'block_timetracker'); if ($alert->todelete) { $approveaction = $OUTPUT->action_icon($approveurl, $checkicon, new confirm_action('Are you sure you want to delete this work unit as requested by the worker?')); } else { $approveaction = $OUTPUT->action_icon($approveurl, $checkicon); } $deleteurl = new moodle_url($alertlinks[$worker->id][$alert->id]['delete']); $deleteicon = new pix_icon('delete', 'Delete this alert', 'block_timetracker'); $deleteaction = $OUTPUT->action_icon($deleteurl, $deleteicon, new confirm_action('Are you sure you want to delete this alert?')); $denyurl = new moodle_url($alertlinks[$worker->id][$alert->id]['deny']); $denyicon = new pix_icon('clock_delete', 'Deny and restore original work unit', 'block_timetracker'); $denyaction = $OUTPUT->action_icon($denyurl, $denyicon, new confirm_action('Are you sure you want to deny this alert unit?<br />The work unit will be re-inserted into the worker\'s record as it originally appeared.')); $row .= '<td style="text-align: center">' . $approveaction . ' ' . $deleteaction . ' ' . $editaction . ' ' . $denyaction . '</td>'; } $row .= '</tr>'; $mform->addElement('html', $row); } $mform->addElement('html', '</table>'); //$this->add_action_buttons(true, 'Save Changes'); if ($canmanage) { $mform->addElement('header', 'general', 'Alert Action Legend'); $legend = ' <img src="' . $CFG->wwwroot . '/blocks/timetracker/pix/approve.png" /> Approve the proposed work unit <br /> <img src="' . $CFG->wwwroot . '/blocks/timetracker/pix/delete.png" /> Delete the alert and the original/proposed work units <br /> <img src="' . $CFG->wwwroot . '/blocks/timetracker/pix/clock_edit.png" /> Edit the proposed work unit before approval<br /> <img src="' . $CFG->wwwroot . '/blocks/timetracker/pix/clock_delete.png" /> Deny the proposed work unit and re-add the original work unit'; $mform->addElement('html', $legend); } }