phpScheduleIt
May 19, 2013, 02:10:05 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Publish a one click reservation URL (w/no dialog box req)  (Read 1508 times)
aj
Newbie
*

Karma: 0
Posts: 23


« on: April 10, 2011, 12:05:13 PM »

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:

Code:
       // 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();

Code:
//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:

Code:
  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();
        
Code:
       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():

Code:
function write_to_the_clipboard(f) {
 window.clipboardData.setData('Text',f);
}
« Last Edit: April 10, 2011, 12:14:19 PM by aj » Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5403


WWW
« Reply #1 on: April 11, 2011, 01:28:55 PM »

Fancy!  Thanks for posting!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!