phpScheduleIt
June 19, 2013, 04:39:47 AM *
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: Limit Login to approved booking  (Read 991 times)
phlsi
Newbie
*

Karma: 0
Posts: 5


« on: August 18, 2010, 08:28:03 AM »

I have been testing scheduleIt for a project and am very impressed with the application and the support on the forums but i am a newbie:

I am hoping that someone can help me with the following:

I am creating schedules wich have dedicated user accounts; for example a Monday morning schedule and user and a Monday afternoon schedule and user, when the user logs on successfully he is redirected to a web page.
Idealy what i am trying to achieve is some kind of check If the Monday morning schedule is approved then allow the user to logon, if the shedule is not approved deny the logon with a message.

Any thoughts or help greatly appreciated
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5506


WWW
« Reply #1 on: August 30, 2010, 01:31:57 PM »

Just so I understand, you want to not allow the user to log on at all based on some additional check?

If so, you can implement this in the login method of lib/auth.class.php.
Logged
phlsi
Newbie
*

Karma: 0
Posts: 5


« Reply #2 on: September 06, 2010, 11:54:51 AM »

Thanks for your reply.
i have had a good look at the lib/auth.class.php page.
i am afraid i do not know how to tie the login values in with the field "is_pending" from the reservations table to do a check.
Just inexperience  Angry
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5506


WWW
« Reply #3 on: September 07, 2010, 01:46:45 PM »

You'd need to write a query to pull the information our of the database, then return an error message from doLogin() if the user should not be able to log in.
Logged
phlsi
Newbie
*

Karma: 0
Posts: 5


« Reply #4 on: September 08, 2010, 12:34:37 PM »

Nick i dont know where you get the time, but i do appreciate the help.
i thought i was getting close.....
I am able to limit access to the web page based on the value in is_pending but cant seem to lock it down to the current user only.
this is what i have done.........................
i have a cron job which runs a query to check if there are any sessions awaiting aproval, this job is indescriminate it runs every hour and auto approves any record in is pending;

update reservations set is_pending=0 where (start_date + (60 * starttime)) < unix_timestamp() +3600 and is_pending = 1;

the effect of the is pending being set to 0 (approved) is to display an image with a link to another web page in the users control pannel view. to do this i have edited the cpannel.template.php.....

function showReservationTable($res, $err) {
   global $link;
   global $conf;
   $order = array('start_date', 'end_date', 'name', 'starttime', 'endtime', 'created', 'modified','is_pending',);
   $util = new Utility();
   $qs = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
?>
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td class="tableBorder">
      <table width="100%" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <td class="tableTitle" width="120">
           <a href="javascript: void(0);" onclick="showHideCpanelTable('reservation');">&#8250; <?php echo translate('My Reservations')?></a></div>
        </td>
        <td class="tableTitle" width="300">
           <?php $link->doImageLink('export.php', 'img/export.gif', 'Export Reservations');
$today=date("m.d.y");
for ($i = 0; is_array($res) && $i < count($res); $i++) {
      
      if ($res[$i]['is_pending']) { print("Demo sessions links will be available 1 hour before the sart time <br />");
               }
else{$link->doImageLink('../lsi/ctrlpnl.php', 'img/launch.jpg', 'Launch Demo');
}
}
?>
then on the new ctrlpnl.php web page i have inserted before the html code.......
<?php
/**
* This file is the control panel, or "home page" for logged in users.
* It provides a listing of all upcoming reservations
*  and functionality to modify or delete them. It also
*  provides links to all other parts of the system.
* @author Nick Korbel <lqqkout13@users.sourceforge.net>
* @version 03-30-06
* @package phpScheduleIt
*
* Copyright (C) 2003 - 2007 phpScheduleIt
* License: GPL, see LICENSE
*/

include_once('../remote/lib/Template.class.php');
include_once('../remote/lib/Utility.class.php');
include_once('../remote/templates/cpanel.template.php');

if (!Auth::is_logged_in()) {
    Auth::print_login_msg();   // Check if user is logged in
}

$db = new DBEngine();
$user = new User(Auth::getCurrentID());

// Valid order values in reservation retreival
$order = array('start_date', 'name', 'starttime', 'endtime', 'created', 'modified','is_pending');
$res = $db->get_user_reservations(Auth::getCurrentID(), CmnFns::get_value_order($order), CmnFns::get_vert_order());

//check if the reservation has been approved if yes continue to HTML code below if no  send error
if($res ['is_pending']==1){
   print("sorry you do not have an approved session, please contact the administrator!!!!");die;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo</title>
<style type="text/css"> ................>>>>>>>>>>>>>>>>>>>>>>>>>>>
any ideas will be greatfully recieved, i will now investigate the login option you mentioned
many thanks again
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!