function show_assignments() { global $m, $uid, $group_id, $langSubmit, $langDays, $langNoAssign, $tool_content, $langWorks, $course_id, $course_code, $themeimg; $res = Database::get()->queryArray("SELECT *, (TO_DAYS(deadline) - TO_DAYS(NOW())) AS days\n\t\t FROM assignment WHERE course_id = ?d", $course_id); if (count($res) == 0) { $tool_content .= $langNoAssign; return; } $tool_content .= "<form action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' method='post'>\n <input type='hidden' name='file' value='" . q($_GET['submit']) . "'>\n <input type='hidden' name='group_id' value='{$group_id}'>\n <table class='tbl' width='99%'>\n <tr>\n <th class='left' width='170'> </th>\n <td> </td>\n </tr>\n <tr>\n <th class='left'>{$langWorks} ({$m['select']}):</th>\n <td>\n <table width='99%' align='left'>\n <tr>\n\t\t<th class='left' colspan='2'>{$m['title']}</th>\n\t\t<th align='center' width='30%'>{$m['deadline']}</th>\n\t\t<th align='center' width='10%'>{$m['submitted']}</th>\n\t\t<th align='center' width='10%'>{$m['select']}</th>\n\t\t</tr>"; foreach ($res as $row) { if (!$row->active) { continue; } $tool_content .= "<tr><td width=\"1%\">\n\t\t\t<img style='padding-top:2px;' src='{$themeimg}/arrow.png' alt=''></td>\n\t\t\t<td><div align='left'><a href='index.php?course={$course_code}&id={$row->id}'>" . q($row->title) . "</a></td>\n\t\t\t<td align='center'>" . nice_format($row->deadline); if ($row->days > 1) { $tool_content .= " ({$m['in']} {$row->days} {$langDays}"; } elseif ($row->days < 0) { $tool_content .= " ({$m['expired']})"; } elseif ($row->days == 1) { $tool_content .= " ({$m['tomorrow']})"; } else { $tool_content .= " ({$m['today']})"; } $tool_content .= "</div></td>\n <td align=\"center\">"; $subm = was_submitted($uid, $group_id, $row->id); if ($subm == 'user') { $tool_content .= $m['yes']; } elseif ($subm == 'group') { $tool_content .= $m['by_groupmate']; } else { $tool_content .= $m['no']; } $tool_content .= "</td><td align=\"center\">"; if ($row->days >= 0 and !was_graded($uid, $row->id) and is_group_assignment($row->id)) { $tool_content .= "<input type='radio' name='assign' value='{$row->id}'>"; } else { $tool_content .= '-'; } $tool_content .= "</td>\n </tr>"; } $tool_content .= "\n </table>"; $tool_content .= "</td></tr>\n\t<tr>\n\t <th class='left'>" . $m['comments'] . ":</th>\n\t <td><textarea name='comments' rows='4' cols='60'>" . "</textarea></td>\n\t</tr>\n\t<tr>\n\t <th> </th>\n\t <td><input class='btn btn-primary' type='submit' name='submit' value='{$langSubmit}'></td>\n\t</tr>\n\t</table>\n\t</form>"; }
function show_assignments() { global $m, $uid, $group_id, $langSubmit, $langDays, $langNoAssign, $tool_content, $langWorks, $course_id, $course_code, $themeimg, $langCancel, $urlServer; $gids = user_group_info($uid, $course_id); if (!empty($gids)) { $gids_sql_ready = implode(',',array_keys($gids)); } else { $gids_sql_ready = "''"; } $res = Database::get()->queryArray("SELECT *, CAST(UNIX_TIMESTAMP(deadline)-UNIX_TIMESTAMP(NOW()) AS SIGNED) AS time FROM assignment WHERE course_id = ?d AND active = '1' AND (assign_to_specific = '0' OR assign_to_specific = '1' AND id IN (SELECT assignment_id FROM assignment_to_specific WHERE user_id = ?d UNION SELECT assignment_id FROM assignment_to_specific WHERE group_id IN ($gids_sql_ready)) ) ORDER BY CASE WHEN CAST(deadline AS UNSIGNED) = '0' THEN 1 ELSE 0 END, deadline", $course_id, $uid); if (count($res) == 0) { $tool_content .= $langNoAssign; return; } $table_content = ''; foreach ($res as $row) { if (!$row->active) { continue; } $table_content .= "<tr><td width=\"1%\"> <img style='padding-top:2px;' src='$themeimg/arrow.png' alt=''></td> <td><div align='left'><a href='index.php?course=$course_code&id=$row->id'>" . q($row->title) . "</a></td> <td align='center'>" . nice_format($row->deadline); if ($row->time > 0) { $table_content .= "<br>(<small>$langDaysLeft" . format_time_duration($row->time) . "</small>)"; } else if($row->deadline){ $table_content .= "<br> (<small><span class='expired'>$m[expired]</span></small>)"; } $table_content .= "</div></td>\n <td align=\"center\">"; $subm = was_submitted($uid, $group_id, $row->id); if ($subm == 'user') { $table_content .= $m['yes']; } elseif ($subm == 'group') { $table_content .= $m['by_groupmate']; } else { $table_content .= $m['no']; } $table_content .= "</td><td align=\"center\">"; if ($row->time >= 0 and !was_graded($uid, $row->id) and is_group_assignment($row->id)) { $table_content .= "<input type='radio' name='assign' value='$row->id'>"; } else { $table_content .= '-'; } $table_content .= "</td>\n </tr>"; } $tool_content .= " <div class='form-wrapper'> <form class='form-horizontal' action='$_SERVER[SCRIPT_NAME]?course=$course_code' method='post'> <fieldset> <input type='hidden' name='file' value='" . q($_GET['submit']) . "'> <input type='hidden' name='group_id' value='$group_id'> <div class='form-group'> <label for='title' class='col-sm-2 control-label'>$langWorks ($m[select]):</label> <div class='col-sm-10'> <table class='table-default'> <tr> <th class='left' colspan='2'>$m[title]</th> <th align='center' width='30%'>$m[deadline]</th> <th align='center' width='10%'>$m[submitted]</th> <th align='center' width='10%'>$m[select]</th> </tr> $table_content </table> </div> </div> <div class='form-group'> <label for='title' class='col-sm-2 control-label'>$m[comments]:</label> <div class='col-sm-10'> <textarea name='comments' rows='4' cols='60' class='form-control'></textarea> </div> </div> <div class='form-group'> <div class='col-sm-10 col-sm-offset-2'> <input class='btn btn-primary' type='submit' name='submit' value='$langSubmit'> <a class='btn btn-default' href='$urlServer/modules/group/document.php?course=$course_code&group_id=$group_id'>$langCancel</a> </div> </div> </fieldset> </form> </div>"; }
<?php require_once __DIR__ . '/../cif-media-config.php'; require_once __DIR__ . '/../lib/media-uploader.php'; require_once __DIR__ . '/../lib/media.php'; // If no media id was given, redirect to the new upload page if (!isset($_GET['id'])) { header('Location: ' . UPLOAD_URL, true, 303); die; } $media = new Media($_GET['id']); $status = false; $title = isset($_POST['title']) ? $_POST['title'] : $media->title; $desc = isset($_POST['desc']) ? $_POST['desc'] : $media->description; $tags = isset($_POST['tags']) ? $_POST['tags'] : join(',', $media->tags); if (was_submitted('upload_revision')) { if (isset($_FILES['new_media'])) { // Revise the media (true to allow duplicates) $status = MediaUploader::upload_revision($media->id, $_FILES['new_media'], $title, $desc, $tags, true); // Redirect to the revised media's page on success if ($status['status'] == STATUS_OK) { // Redirect with HTTP status code 303: See Other $view_url = sprintf(VIEW_URL, $media->id); header("Location: {$view_url}", true, 303); } } else { $status = array('status' => STATUS_UPLOAD_ERROR, 'response' => 'You forgot to upload your revision!'); } } echo $twig->render('upload.html', array('heading' => 'Revise "' . $media->title . '"', 'action' => 'upload_revision', 'title' => $title, 'description' => $desc, 'tags' => $tags, 'media' => $media, 'status' => $status));
<?php require_once __DIR__ . '/../cif-media-config.php'; require_once __DIR__ . '/../lib/media-uploader.php'; $status = false; $similar_media = null; $title = isset($_POST['title']) ? $_POST['title'] : ''; $desc = isset($_POST['desc']) ? $_POST['desc'] : ''; $tags = isset($_POST['tags']) ? $_POST['tags'] : ''; $allow_dupes = isset($_POST['allow_dupes']) ? $_POST['allow_dupes'] == '1' : false; if (was_submitted('upload_new')) { if (isset($_FILES['new_media'])) { // Upload the new media $status = MediaUploader::upload($_FILES['new_media'], $title, $desc, $tags, $allow_dupes); // Redirect to the new media's page on success if ($status['status'] == STATUS_OK) { // Redirect with HTTP status code 303: See Other $view_url = sprintf(VIEW_URL, $status['response']); header("Location: {$view_url}", true, 303); } else { if ($status['status'] == STATUS_SIMILAR_EXISTS) { // Let the user consciously submit a duplicate $allow_dupes = true; $similar_media = new Media($status['response']); // Display an actual status response message to the user $status['response'] = "It looks like that file has already been uploaded!"; } } } else { $status = array('status' => STATUS_UPLOAD_ERROR, 'response' => 'You forgot to upload your file!'); }
<?php /** * Account creation page. Renders the account creation form or a * success or error page if the form has been submitted. */ require_once 'panel-config.php'; require_once 'lib/utility.php'; // Render the account form if all required fields were not filled out if (!was_submitted('create_account') || !isset($_POST['netid']) || !isset($_POST['password']) || !isset($_POST['aup']) || $_POST['aup'] != 'yes') { $errors = array(); // Give error messages if the form was submitted if (was_submitted('create_account')) { if (!isset($_POST['netid']) || trim($_POST['netid']) == '') { $errors[] = "Please enter your NetID."; } if (!isset($_POST['password']) || trim($_POST['password']) == '') { $errors[] = "Please enter your NetID password."; } if (!isset($_POST['aup']) || $_POST['aup'] != 'yes') { $errors[] = "You need to read and accept our Acceptable Use Policy."; } } echo $twig->render('join.html', array('form_fields' => array('netid' => isset($_POST['netid']) ? $_POST['netid'] : '', 'lcc' => isset($_POST['lcc']) ? $_POST['lcc'] : '', 'aup' => isset($_POST['aup']) && $_POST['aup'] == 'yes'), 'error_messages' => $errors, 'show_subfooter' => false)); } else { require_once 'lib/create-account.php'; $result = create_account($_POST['netid'], $_POST['password'], $_POST['lcc']); if ($result['status'] == STATUS_AUTH_ERROR) { // Password or NetID were incorrect, render the creation form again echo $twig->render('join.html', array('form_fields' => array('netid' => $_POST['netid'], 'lcc' => $_POST['lcc'], 'aup' => true), 'error_messages' => array($result['message']), 'show_subfooter' => false)); } else {
$forms['password']['reasons'] = $result['reasons']; } // Determine database status $database_data = array(); $database_data['available'] = $cif_user->database_available; if ($cif_user->database_available) { $database_data['exists'] = $cif_user->has_database; // If a database form was submitted, handle it $forms['database'] = array('submitted' => false); if ((was_submitted('update_database_password') || was_submitted('create_database')) && isset($_POST['database_password']) && isset($_POST['database_password_again'])) { $result = $cif_user->change_database_password($_POST['database_password'], $_POST['database_password_again']); $forms['database']['submitted'] = true; $forms['database']['status'] = $result['status']; $forms['database']['message'] = $result['message']; $forms['database']['reasons'] = $result['reasons']; } elseif (was_submitted('delete_database') && isset($_POST['database_delete_confirmation'])) { $result = $cif_user->delete_database($_POST['database_delete_confirmation']); $forms['database']['submitted'] = true; $forms['database']['status'] = $result['status']; $forms['database']['message'] = $result['message']; $forms['database']['reasons'] = $result['reasons']; } } // Gather AFS data $afs_data = array(); $afs_data['available'] = $cif_user->afs_available; if ($cif_user->afs_available) { $afs_data['used'] = $cif_user->get_storage_used(); $afs_data['quota'] = $cif_user->get_storage_size(); $afs_data['free'] = $cif_user->get_storage_free(); $afs_data['used_percent'] = $cif_user->get_storage_percent_used();