durana
Full Member
 
Karma: 1
Posts: 101
|
 |
« Reply #11 on: December 22, 2008, 03:07:17 PM » |
|
First of all check the manual phpScheduleIt developer guide, made by Nick, This is what I have done to make it work easy for 1.2.8.
Just an extract of the manual. all the credits go to Nick ofcourse ======================================
Step 1 :
ALTER TABLE reservations ADD COLUMN environment CHAR(50);
======================================
Step 2 : phpScheduleIt\lib\db\ResDB.class.php
function add_res($res, $is_parent, $users_to_invite, $resources_to_add, $accept_code) { $id = $this->get_new_id();
// Insert the main reservation data $values = array ( $id, $res->get_machid(), $res->get_scheduleid(), $res->get_start_date(), $res->get_end_date(), $res->get_start(), $res->get_end(), mktime(), null, ($is_parent ? $id : $res->get_parentid()), intval($res->is_blackout), $res->get_pending(), $res->get_summary(), $res->get_allow_participation(), $res->get_allow_anon_participation() ); $query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATIONS) . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $q = $this->db->prepare($query); $result = $this->db->execute($q, $values); $this->check_for_error($result);
should be :
function add_res($res, $is_parent, $users_to_invite, $resources_to_add, $accept_code) { $id = $this->get_new_id();
// Insert the main reservation data $values = array ( $id, $res->get_machid(), $res->get_scheduleid(), $res->get_start_date(), $res->get_end_date(), $res->get_start(), $res->get_end(), mktime(), null, ($is_parent ? $id : $res->get_parentid()), intval($res->is_blackout), $res->get_pending(), $res->get_summary(), $res->get_allow_participation(), $res->get_allow_anon_participation(), $res->get_environment() ); $query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATIONS) . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $q = $this->db->prepare($query); $result = $this->db->execute($q, $values); $this->check_for_error($result); ---------------------------------------------------------------------- Step 3 phpScheduleIt\lib\db\ResDB.class.php
function mod_res($res, $users_to_invite, $users_to_remove, $resources_to_add, $resources_to_remove, $accept_code) { $t = new Timer("mod_res()"); $t->start(); $id = $res->get_id(); // Update the main reservation data $values = array ( $res->get_start_date(), $res->get_end_date(), $res->get_start(), $res->get_end(), mktime(), $res->get_summary(), $res->get_pending(), $res->get_allow_participation(), $res->get_allow_anon_participation(), $id );
$query = 'UPDATE ' . $this->get_table(TBL_RESERVATIONS) . ' SET ' . ' start_date=?,' . ' end_date=?,' . ' starttime=?,' . ' endtime=?,' . ' modified=?,' . ' summary=?,' . ' is_pending=?,' . ' allow_participation=?,' . ' allow_anon_participation=?' . ' WHERE resid=?';
Should be : function mod_res($res, $users_to_invite, $users_to_remove, $resources_to_add, $resources_to_remove, $accept_code) { $t = new Timer("mod_res()"); $t->start(); $id = $res->get_id(); // Update the main reservation data $values = array ( $res->get_start_date(), $res->get_end_date(), $res->get_start(), $res->get_end(), mktime(), $res->get_summary(), $res->get_pending(), $res->get_allow_participation(), $res->get_allow_anon_participation(), $res->get_environment(), $id );
$query = 'UPDATE ' . $this->get_table(TBL_RESERVATIONS) . ' SET ' . ' start_date=?,' . ' end_date=?,' . ' starttime=?,' . ' endtime=?,' . ' modified=?,' . ' summary=?,' . ' is_pending=?,' . ' allow_participation=?,' . ' allow_anon_participation=?,' . ' environment=?' . ' WHERE resid=?';
------------------------------------------------------------------------------- Step 4 phpScheduleIt\lib\Reservation.class.php class Reservation { var $id = null; // Properties var $start_date = null; // var $end_date = null; // var $start = null; // var $end = null; // var $resource = null; // var $user = null; // var $resources = array(); // var $created = null;
Should be: class Reservation { var $id = null; // Properties var $start_date = null; // var $end_date = null; // var $start = null; // var $end = null; // var $resource = null; // var $user = null; // var $environment = null; var $resources = array(); // var $created = null;
------------------------------------------------------- Step 5 phpScheduleIt\lib\Reservation.class.php
Add this after the reservation class
/** * Returns the environment for this reservation * @param none * @return string environment */ function get_environment () { return $this->environment; } ---------------------------------------------------------------------- Step 6 phpScheduleIt\lib\Reservation.class.php
function load_by_id() { $res = $this->db->get_reservation($this->id, Auth::getCurrentID()); // Get values from DB
if (!$res) { // Quit if reservation doesnt exist CmnFns::do_error_box($this->db->get_err()); }
$this->start_date = $res['start_date']; $this->end_date = $res['end_date']; $this->start = $res['starttime']; $this->end = $res['endtime']; $this->resource = new Resource($res['machid']); $this->created = $res['created']; $this->modified = $res['modified']; $this->parentid = $res['parentid']; $this->summary = htmlspecialchars($res['summary']); $this->scheduleid = $res['scheduleid']; $this->is_blackout = $res['is_blackout']; $this->is_pending = $res['is_pending']; $this->allow_participation = $res['allow_participation']; $this->allow_anon_participation = $res['allow_anon_participation']; $this->is_participant = $res['participantid'] != null; $reminder = new Reminder($res['reminderid']); $reminder->set_reminder_time($res['reminder_time']); $this->reminderid = $res['reminderid']; $this->reminder_minutes_prior = $reminder->getMinutuesPrior($this);
$this->users = $this->db->get_res_users($this->id);
Should be:
function load_by_id() { $res = $this->db->get_reservation($this->id, Auth::getCurrentID()); // Get values from DB
if (!$res) { // Quit if reservation doesnt exist CmnFns::do_error_box($this->db->get_err()); }
$this->start_date = $res['start_date']; $this->end_date = $res['end_date']; $this->start = $res['starttime']; $this->end = $res['endtime']; $this->resource = new Resource($res['machid']); $this->created = $res['created']; $this->modified = $res['modified']; $this->parentid = $res['parentid']; $this->summary = htmlspecialchars($res['summary']); $this->scheduleid = $res['scheduleid']; $this->is_blackout = $res['is_blackout']; $this->is_pending = $res['is_pending']; $this->allow_participation = $res['allow_participation']; $this->allow_anon_participation = $res['allow_anon_participation']; $this->environment = $res['environment']; $this->is_participant = $res['participantid'] != null; $reminder = new Reminder($res['reminderid']); $reminder->set_reminder_time($res['reminder_time']); $this->reminderid = $res['reminderid']; $this->reminder_minutes_prior = $reminder->getMinutuesPrior($this);
$this->users = $this->db->get_res_users($this->id);
-------------------------------------------------- Step 7 phpScheduleIt\reserve.php
function process_reservation($fn) { $success = false; global $Class; $is_pending = (isset($_POST['pending']) && $_POST['pending']);
if (isset($_POST['start_date'])) { // Parse the POST-ed starting and ending dates $start_date = eval('return mktime(0,0,0, \'' . str_replace(INTERNAL_DATE_SEPERATOR, '\',\'', $_POST['start_date']) . '\');'); $end_date = eval('return mktime(0,0,0, \'' . str_replace(INTERNAL_DATE_SEPERATOR, '\',\'', $_POST['end_date']) . '\');'); }
if (isset($_POST['resid'])) $res = new $Class($_POST['resid'], false, $is_pending); else if (isset($_GET['resid'])) $res = new $Class($_GET['resid'], false, $is_pending); else { // New reservation $res = new $Class(null, false, $is_pending); if ($_POST['interval'] != 'none') { // Check for reservation repeation if ($start_date == $end_date) { $res->is_repeat = true; $days = isset($_POST['repeat_day']) ? $_POST['repeat_day'] : NULL; $week_num = isset($_POST['week_number']) ? $_POST['week_number'] : NULL; $repeat = CmnFns::get_repeat_dates($start_date, $_POST['interval'], $days, $_POST['repeat_until'], $_POST['frequency'], $week_num); } else { // Cannot repeat multi-day reservations $repeat = array($start_date); $res->is_repeat = false; } } else { $repeat = array($start_date); $res->is_repeat = false; } }
$cur_user = new User(Auth::getCurrentID()); $res->adminMode = Auth::isAdmin() || $cur_user->get_isadmin() || ($fn != 'create' && $cur_user->is_group_admin($res->user->get_groupids()));
if (Auth::isAdmin() || $cur_user->get_isadmin()) { $res->is_pending = false; } // ... $environment = isset($_POST['environment']) ? stripslashes(htmlspecialchars($_POST['environment'])) : ''; // ... if ($fn == 'create' || $fn == 'modify') { $helper = new ReservationHelper(); $util = new Utility();
$orig = (isset($_POST['orig_invited_users']) && count($_POST['orig_invited_users']) > 0) ? $_POST['orig_invited_users'] : array(); $invited = (isset($_POST['invited_users'])) ? $_POST['invited_users'] : array(); $removed = (isset($_POST['removed_users'])) ? $_POST['removed_users'] : array();
$users_to_remove = $helper->getRowsForRemoval($orig, $removed, $invited); $users_to_invite = $helper->getRowsForInvitation($orig, $invited); $unchanged_users = $helper->getUnchangedUsers($orig, $invited);
$orig_resources = (isset($_POST['orig_resources']) && count($_POST['orig_resources']) > 0) ? $_POST['orig_resources'] : array(); $selected_resources = (isset($_POST['selected_resources']) && count($_POST['selected_resources']) > 0) ? $_POST['selected_resources'] : array();
$resources_to_add = $util->getAddedItems($orig_resources, $selected_resources); $resources_to_remove = $util->getRemovedItems($orig_resources, $selected_resources);
$res->user = new User($_POST['memberid']); $res->start_date= $start_date; $res->end_date = $end_date; $res->start = $_POST['starttime']; $res->end = $_POST['endtime'];
$res->summary = stripslashes($_POST['summary']); $res->allow_participation = (int)isset($_POST['allow_participation']); $res->allow_anon_participation = (int)isset($_POST['allow_anon_participation']); $res->reminderid = isset($_POST['reminderid']) ? $_POST['reminderid'] : null; $res->environment = $environment; $res->reminder_minutes_prior = isset($_POST['reminder_minutes_prior']) ? intval($_POST['reminder_minutes_prior']) : 0; }
if ($fn == 'create') { $res->resource = new Resource($_POST['machid']); $res->scheduleid= $_POST['scheduleid']; $res->repeat = $repeat; $res->add_res($users_to_invite, $resources_to_add); } else if ($fn == 'modify') { $res->summary = str_replace("\n", '', $_POST['summary']); $res->mod_res($users_to_invite, $users_to_remove, $unchanged_users, $resources_to_add, $resources_to_remove, isset($_POST['del']), isset($_POST['mod_recur']), $environment); } else if ($fn == 'delete') { $res->del_res(isset($_POST['mod_recur'])); } else if ($fn == 'approve') { $res->approve_res(isset($_POST['mod_recur'])); }
------------------------------------------------- Step 8 \phpScheduleIt\templates\reserve.template.php
if (!$is_private) { print_summary($res->summary, $res->type); }
should be
if (!$is_private) { print_summary($res->summary, $res->type); print_environment($res->get_environment(), $res->type); }
====================================== Step 9 \phpScheduleIt\templates\reserve.template.php
Add this afther the function print_summary($summary, $type) {
/** * Print out the reservation summary or a box to add/edit one * @param string $environment environment to edit * @param string $type type of reservation */ function print_environment($environment, $type) { ?> <table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr class="tableBorder"> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td class="cellColor"><?=translate('Environment')?></td> <td class="cellColor" style="text-align: left;"> <? if ($type == RES_TYPE_ADD || $type == RES_TYPE_MODIFY) echo '<input type="text" name="environment" class="textbox" value="' . $environment . '"/>'; else echo (!empty($environment) ? $environment : ''); ?> </td> </tr> </table> </td> </tr> </table> <? }
|