I had a need to publish a URL for a reservation and allow a user to join without having to view the dialog box. This was purely a
"join" operation to add the current user that clicks on the URL to the reservation. If the user is not logged in, they will be asked to login.
Here is the process:
* An admin creates or modifies a reservation that they wish to publish on another site or page
* A "URL to Clipboard" button appears in the reservation dialog only for admins, the admin clicks on that button, pastes the URL to the publishing page.
* When a user clicks on the URL they will be prompted to login and then added to the reservation.
* The reservation will still require approval.
Below are the modifications I have made to three files (reserve.php, function.js and reserve.template.php):
Modify \templates\reserve.template.php to include the below in function print_buttons_and_hidden()
after Cancel button and before "Check Availability" botton:
// Add URL to Clipboard Button
$isAdmin = get_Admin_Status(); //new function defined in reserve.php
if ($isAdmin) {
$button_setup = '</td><td align="right"><button type="button" name="check" value="URL to Clipboard" class="button" onclick="';
$button_setup .= 'write_to_the_clipboard(';
$button_setup .= '\'' . $_SESSION['the_target_url'] . '\'';
$button_setup .= ');';
$button_setup .= '">' . 'URL to Clipboard' . '</button></td><td>';
echo $button_setup;
}
Modify \reserve.php to include the below before $timer = new Timer();
//Set URL as session varialble for single click add (AUTOMODIFY)
$the_target_url="http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
$the_target_url = str_replace("type=m", "type=x", $the_target_url);
$_SESSION['the_target_url'] = $the_target_url;
Before line with: if (isset($_POST['btnSubmit']) && strstr($_SERVER['HTTP_REFERER'], $_SERVER['PHP_SELF'])) {
Add:
if ($_GET['type']=='x') {
$fn='modify';
$cur_user = new User(Auth::getCurrentID());
$data = $cur_user->get_user_data();
$users_to_invite[$data['memberid']]=$data['email'];
if (isset($_GET['resid'])) { $res = new $Class($_GET['resid'], false, $is_pending); }
$res->adminMode = true;
$res->mod_res($users_to_invite, $users_to_remove, $unchanged_users, $resources_to_add, $resources_to_remove, isset($_POST['del']), isset($_POST['mod_recur']));
//die;
} else
Before lines with: // End main table
Add: }
After the comment
// Print HTML footer
$t->printHTMLFooter();
function get_Admin_Status() {
$isAdmin = bool;
$user = new User(Auth::getCurrentID());
$is_group_admin = $user->is_group_admin();
$isAdmin = ($is_group_admin || Auth::isAdmin());
return $isAdmin;
}
Modify \functions.js to include the below after function checkAllBoxes():
function write_to_the_clipboard(f) {
window.clipboardData.setData('Text',f);
}