/** * construct the dismiss action in a new dialog * * @param int $id message Id * @param array $extrabuttons extra dialog buttons * @param string $messagetype message type */ function message_alert_popup($id, $extrabuttons=array(), $messagetype) { global $CFG, $FULLME, $PAGE, $DB; $clean_fullme = clean_param($FULLME, PARAM_LOCALURL); // Button Lang Strings $PAGE->requires->string_for_js('cancel', 'moodle'); $PAGE->requires->string_for_js('dismiss', 'local_message'); $PAGE->requires->string_for_js('reviewitems', 'block_alerts'); $metadata = $DB->get_record('message_metadata', array('messageid' => $id)); $eventdata = message_eventdata($id, 'onaccept', $metadata); if ($eventdata && $eventdata->action == 'facetoface') { require_once($CFG->dirroot . '/mod/facetoface/lib.php'); $canbook = facetoface_task_check_capacity($eventdata->data); if (!$canbook) { // Remove accept / reject buttons $extrabuttons = array(); } } $extrabuttonjson = ''; if ($extrabuttons) { $extrabuttonjson .= '{'; $count = sizeof($extrabuttons); for ($i = 0; $i < $count; $i++) { $clean_redirect = clean_param($extrabuttons[$i]->redirect, PARAM_LOCALURL); $extrabuttonjson .= '"'.$extrabuttons[$i]->text.'":{"action":"'.$extrabuttons[$i]->action.'&sesskey='.sesskey().'", "clean_redirect":"'.$clean_redirect.'"}'; $extrabuttonjson .= ( $i < $count-1 )? ',' : ''; } $extrabuttonjson .= '}'; } $args = array('id'=>$id, 'selector'=>$messagetype, 'clean_fullme'=>$clean_fullme, 'sesskey'=>sesskey(), 'extrabuttonjson'=>$extrabuttonjson); $PAGE->requires->js_init_call('M.message.create_dialog', $args); }
$id = required_param('id', PARAM_INT); $msg = $DB->get_record('message', array('id' => $id)); if (!$msg || $msg->useridto != $USER->id || !confirm_sesskey()) { print_error('notyours', 'local_message', $id); } $canbook = false; $isfacetoface = false; $metadata = $DB->get_record('message_metadata', array('messageid' => $id)); $eventdata = local_message_eventdata($id, 'onaccept', $metadata); if ($eventdata && $eventdata->action == 'facetoface') { require_once($CFG->dirroot . '/mod/facetoface/lib.php'); $isfacetoface = true; $canbook = facetoface_task_check_capacity($eventdata->data); } if ($msg->useridfrom == 0) { $from = generate_email_supportuser(); } else { $from = $DB->get_record('user', array('id' => $msg->useridfrom)); } $fromname = fullname($from) . " ({$from->email})"; $subject = format_string($msg->subject); if ($isfacetoface && !$DB->record_exists('facetoface_sessions', array('id' => $eventdata->data['session']->id))) { $subject .= ' (' . html_writer::tag('b', get_string('f2fsessiondeleted', 'block_tasks')) . ')'; } else if ($isfacetoface && !$canbook) { $subject .= ' (' . html_writer::tag('b', get_string('f2fsessionfull', 'block_tasks')) . ')';