Beispiel #1
0
function format_time($d, $t)
{
    global $time_names;
    if ($d === null || $t === null) {
        return "";
    } elseif (is_valid_day($d) && is_valid_time($t)) {
        return "{$d} at {$time_names[$t]}";
    } else {
        return '<invalid time>';
    }
}
Beispiel #2
0
        $errors[] = "end time must be in HH:MM format";
    }
}
// Defaults
$Day = "";
$STime = "";
$ETime = "";
$Members = array();
$event = array();
$event['Location'] = "";
$event['Summary'] = "Study Group Event";
$event['Description'] = "Meet to study for classes";
if (isset($_GET['group_id'])) {
    $group = get_group($db, $_GET['group_id']);
    $event['Summary'] = "Meeting for " . $group['name'];
    if (is_valid_day($group['day'])) {
        $Day = next_weekday($group['day'])->format("Y-m-d");
    }
    if (is_valid_time($group['time'])) {
        $STime = sprintf("%02d:00", $group['time']);
        $ETime = sprintf("%02d:00", ($group['time'] + 1) % 24);
    }
    $Members = get_group_members($db, $_GET['group_id']);
    $event['Location'] = $group['place'];
}
if (isset($_POST['Day'])) {
    $Day = $_POST['Day'];
}
if (isset($_POST['STime'])) {
    $STime = $_POST['STime'];
}
Beispiel #3
0
         if ($course['id'] === $form['course']) {
             $have_course = true;
         }
     }
     if (!$have_course) {
         $errors['course'] = "choose a course you are registered for";
     }
 }
 // Fill in a useful default name
 if ($form['name'] === '' && !isset($errors['course'])) {
     $course = get_course($db, $form['course']);
     $form['name'] = "{$course['department']} {$course['number']} study group";
 }
 // Check that the day and time are valid
 if (isset($_POST['day']) && $_POST['day'] !== "" || isset($_POST['time']) && $_POST['time'] !== "") {
     if (empty($_POST['day']) || !is_valid_day($_POST['day'])) {
         $errors['day'] = "please choose a valid day";
     } else {
         $form['day'] = $_POST['day'];
     }
     if (!isset($_POST['time']) || $_POST['time'] === "" || !is_valid_time($_POST['time'])) {
         $errors['time'] = 'please choose a valid time';
     } else {
         $form['time'] = $_POST['time'];
     }
 }
 // Check if all the user ids are numeric
 if (isset($_POST['members']) && is_array($_POST['members'])) {
     foreach ($_POST['members'] as $member_id) {
         if (is_numeric($member_id)) {
             $form['members'][] = $member_id;
Beispiel #4
0
     $q->execute();
     $campus = $q->fetch();
     $place = $campus['name'];
     $stmt = $db->prepare("UPDATE groups SET campus=:campus WHERE id=:group_id");
     $stmt->bindValue(":group_id", $group['id']);
     $stmt->bindValue(":campus", $place);
     $stmt->execute();
 }
 if (!empty($_POST['building'])) {
     $place = $_POST['building'];
     $stmt = $db->prepare("UPDATE groups SET place=:place WHERE id=:group_id");
     $stmt->bindValue(":group_id", $group['id']);
     $stmt->bindValue(":place", $place);
     $stmt->execute();
 }
 if (isset($_POST['day']) && isset($_POST['time']) && is_valid_day($_POST['day']) && is_valid_time($_POST['time'])) {
     $stmt = $db->prepare("UPDATE groups SET day=:day, time=:time WHERE id=:group_id");
     $stmt->bindValue(":group_id", $group['id']);
     $stmt->bindValue(":day", $_POST['day']);
     $stmt->bindValue(":time", $_POST['time']);
     $stmt->execute();
 }
 $private = !empty($_POST['private']);
 if ($group['is_private'] != $private) {
     $stmt = $db->prepare("UPDATE groups SET is_private=:private WHERE id=:group_id");
     $stmt->bindValue(":group_id", $group['id']);
     $stmt->bindValue(":private", $private);
     $stmt->execute();
 }
 header("Location: group.php?id=" . urlencode($group['id']));
 exit(0);