コード例 #1
0
function retrieve_dbMonths($id)
{
    connect();
    $query = 'SELECT * FROM dbMonths WHERE id = "' . $id . '"';
    $result = mysql_query($query);
    // can't find month with id
    if (mysql_num_rows($result) != 1) {
        mysql_close();
        return newMonth($id);
    }
    $result_row = mysql_fetch_assoc($result);
    $theMonth = new Month($result_row['id'], $result_row['status']);
    return $theMonth;
}
コード例 #2
0
 function testdbMonthsModule()
 {
     //creates an empty dbMonths table
     //$this->assertTrue(create_dbMonths());
     // create a month to add to the table
     $m1 = new Month("13-10-foodbank", "unpublished");
     // test the insert function
     $this->assertTrue(insert_dbMonths($m1));
     // test the retrieve function
     $this->assertEqual(retrieve_dbMonths($m1->get_id())->get_id(), "13-10-foodbank");
     $this->assertEqual(retrieve_dbMonths($m1->get_id())->get_status(), "unpublished");
     $this->assertEqual(retrieve_dbMonths($m1->get_id())->get_group(), "foodbank");
     $this->assertEqual(retrieve_dbMonths($m1->get_id())->get_end_of_month_timestamp(), mktime(0, 0, 0, 10, 31, 2013));
     // testing generation of a new calendar month from the master schedule
     $this->assertTrue(newMonth("13-10-foodbank"));
     // test the update function
     $m1->set_status("published");
     $this->assertTrue(update_dbMonths($m1));
     $this->assertEqual(retrieve_dbMonths($m1->get_id())->get_status(), "published");
     // tests the delete function
     $this->assertTrue(delete_dbMonths($m1));
     echo "\ntestdbMonths complete\n";
 }
コード例 #3
0
        $id = $_GET['monthid'];
        $month = retrieve_dbMonths($id);
        if ($month) {
            if ($month->get_status() == "unpublished" || $month->get_status() == "archived") {
                delete_dbMonths($month);
                add_log_entry('<a href=\\"personEdit.php?id=' . $_SESSION['_id'] . '\\">' . $_SESSION['f_name'] . ' ' . $_SESSION['l_name'] . '</a> removed the month of <a href=\\"calendar.php?id=' . $month->get_id() . '&edit=true&group=' . $_SESSION['mygroup'] . '\\">' . $month->get_name() . '</a>.');
                echo "<p>Month \"" . $month->get_name() . "\" removed.<br>";
            } else {
                echo "<p>Month \"" . $month->get_name() . "\" is published, so it cannot be removed.<br>";
            }
            include 'addMonth.inc';
        }
    } else {
        if (!array_key_exists('_submit_check_newmonth', $_POST)) {
            include 'addMonth.inc';
        } else {
            $month_id = $_POST['_new_month_timestamp'];
            // add the newe month to the database and refresh the view
            newMonth($month_id);
            include 'addMonth.inc';
        }
    }
}
?>
                <?php 
include 'footer.inc';
?>
            </div>
        </div>
    </body>
</html>