Location: PHPKode > projects > Meeting Request Scheduling and Booking System > mrsbs/php/admin/meetings.php
<?PHP

   // Meetings list
   //
   // Version: $Revision: 1.6 $
   // Date: $Date: 2008/06/20 01:22:08 $
   //
   // Copyright (c) 2006 - 2008 Benjamin Oshrin
   // License restrictions apply, see LICENSE for details.
   
// We might get called via admin/ or via schedule/.  Both required
// authn, but each requires different authz.
$auth_required = 1;
include "../lib/mrsbs.inc";
$pgtitle = $tx['mt.mtgs.list'];
$pgtype = "admin";

$op = "all";

if(isset($rvar_op))
{
  if($rvar_op == "asearch")
    $op = "asearch";
  elseif($rvar_op == "own")
  {
    $pgtype = "search";
    $op = "own";
  }
  elseif($rvar_op == "search")
  {
    $pgtype = "search";
    $op = "search";
  }
}

if($op != "all" && $op != "asearch")
{
  if(!authorize("schedule", "meetings", $op))
    mexit($tx['op.err.perm'], 1);
}
elseif(!authorize("admin", "meetings", -1))
  mexit($tx['op.err.perm'], 1);

$sortby = "replyby";
$sortdir = "desc";

?>
<HTML>
<HEAD>
<TITLE><?PHP print $pgtitle;?></TITLE>
</HEAD>

<BODY>
<TABLE CLASS="main">
 <?PHP include "../lib/titlebar.php";?>
 <TR>
  <TD CLASS="main">
   <TABLE CLASS="form">
    <TR>
     <TD CLASS="infofield">
      <?PHP
       $search_fields = array();

       // We'll track the last search in the session state for rerendering
       // the search form.

       $_SESSION['lastsearchtype'] = "unknown";

       if($op == "search" || $op == "asearch")
       {
	 // If advanced search fields were specified, use that instead of
	 // $rvar_text.  We also map the field names here, since we don't
	 // want the web page to be specifying arbitrary database fields
	 // to look at.

	 $_SESSION['lastsearchtype'] = "advanced";
	 $_SESSION['lastsearchtext'] = array();  // Blank out previous values
	 
	 if(isset($rvar_ss)) {
	   $_SESSION['lastsearchtext']['ss'] =
	     $search_fields['summary'] = $rvar_ss;
	 }
	 if(isset($rvar_sd)) {
	   $_SESSION['lastsearchtext']['sd'] =
	     $search_fields['description'] = $rvar_sd;
	 }
	 if(isset($rvar_so)) {
	   $_SESSION['lastsearchtext']['so'] =
	     $search_fields['owner'] = $rvar_so;
	 }
	 if(isset($rvar_sh)) {
	   $_SESSION['lastsearchtext']['sh'] =
	     $search_fields['host'] = $rvar_sh;
	 }
	 if(isset($rvar_si)) {
	   $_SESSION['lastsearchtext']['si'] =
	     $search_fields['invitees'] = $rvar_si;
	 }
	 if(isset($rvar_sl)) {
	   $_SESSION['lastsearchtext']['sl'] =
	     $search_fields['location'] = $rvar_sl;
	 }
	 if(isset($rvar_st)) {
	   $_SESSION['lastsearchtext']['st'] =
	     $search_fields['status'] = $rvar_st;
	 }
	 if(isset($rvar_sdc) && $rvar_sdc != "" &&
	    isset($rvar_sdv) && $rvar_sdv >= 0 &&
	    isset($rvar_sdu) && $rvar_sdu != "") {
	   // Multiple variables make up duration

	   $_SESSION['lastsearchtext']['sdc'] =
	     $search_fields['duration']['comp'] = $rvar_sdc;
	   $_SESSION['lastsearchtext']['sdv'] =
	     $search_fields['duration']['val'] = $rvar_sdv;
	   $_SESSION['lastsearchtext']['sdu'] =
	     $search_fields['duration']['unit'] = $rvar_sdu;
	 }
	 if(isset($rvar_src) && $rvar_src != "") {
	   // Multiple variables make up replyby

	   $_SESSION['lastsearchtext']['src'] =
	     $search_fields['replyby']['comp'] = $rvar_src;
	   
	   $hmsrt = preg_split('/-/', $rvar_hmsrt);
	   // is_dst (the -1 parameter) is deprecated in php5
	   $srtv = mktime($hmsrt[0], $hmsrt[1], 0, $rvar_msrt, $rvar_dsrt,
			  $rvar_ysrt, -1);
	   
	   // Store the calculated time, not the components
	   $_SESSION['lastsearchtext']['srtv'] =
	     $search_fields['replyby']['val'] = $srtv;
	 }
	 if(isset($rvar_ssc) && $rvar_ssc != "") {
	   // Multiple variables make up start

	   $_SESSION['lastsearchtext']['src'] =
	     $search_fields['start']['comp'] = $rvar_ssc;
	   
	   $hmsst = preg_split('/-/', $rvar_hmsst);
	   // is_dst (the -1 parameter) is deprecated in php5
	   $sstv = mktime($hmsst[0], $hmsst[1], 0, $rvar_msst, $rvar_dsst,
			  $rvar_ysst, -1);

	   // Store the calculated time, not the components
	   $_SESSION['lastsearchtext']['sstv'] =
	     $search_fields['start']['val'] = $sstv;
	 }
	 if(isset($rvar_sns)) {
	   $_SESSION['lastsearchtext']['sns'] =
	     $search_fields['scheduled'] = $rvar_sns;
	 }
       }

       if(count($search_fields) < 1)
       {
	 // No advanced search keys, so drop the array to perform a simple
	 // search.
	 
	 $search_fields = false;

	 if(isset($rvar_text))
	 {
	   $_SESSION['lastsearchtype'] = "simple";
	   $_SESSION['lastsearchtext'] = $rvar_text;
	 }
       }
  
       if($op == "own")
         $mtgs = get_meetings($_SESSION['contactid']);
       elseif($op == "search" ||
	      ($op == "asearch" && (!isset($rvar_all) || $rvar_all != 'Y')))
         $mtgs = get_meetings($_SESSION['contactid'],
			      (isset($rvar_text) ? $rvar_text : ""),
			      $search_fields);
       elseif($op == "asearch")
         $mtgs = get_meetings(-1,
			      (isset($rvar_text) ? $rvar_text : ""),
			      $search_fields);
       else
	 $mtgs = get_meetings();

       // Build a list of meetings to be rendered

       $l = array();
       $l['column']['count'] = 6;
       $l['column'][0]['title'] = $tx['sd.mtgid'];
       $l['column'][0]['sortable'] = 'A';
       $l['column'][1]['title'] = $tx['sd.role'];
       $l['column'][1]['sortable'] = 'D';
       $l['column'][2]['title'] = $tx['sd.summary'];
       $l['column'][2]['sortable'] = 'A';
       $l['column'][3]['title'] = $tx['sd.host'];
       $l['column'][3]['sortable'] = 'A';
       $l['column'][4]['title'] = $tx['sd.time.replyby'];
       $l['column'][4]['sortable'] = 'D';
       $l['column'][5]['title'] = $tx['sd.time.start'];
       $l['column'][5]['sortable'] = 'D';
       $l['row']['count'] = $mtgs['count'];

       if($op == "search" || $op == "asearch")
       {
	 // For search results, add another column, the search ranking

	 $l['column']['count']++;
	 $l['column'][6]['title'] = $tx['sd.search.rank'];
	 $l['column'][6]['sortable'] = 'A';
       }

       for($i = 0;$i < $mtgs['count'];$i++)
       {
	 // Generate a link according to privileges.  For admins, owners,
	 // and hosts, link to mtg.  For invitees, link to invite.
	 
	 $ilink = '../schedule/review.php?mtgid=' . $mtgs[$i]['mtgid'];

	 if($mtgs[$i]['contactid'] == $_SESSION['contactid'])
	   $istat = $tx['sd.owner'];
	 elseif($mtgs[$i]['hostid'] == $_SESSION['contactid'])
	   $istat = $tx['sd.host'];
	 elseif($op != "own" && authorize("admin", "admin"))
	   $istat = "-";
	 else // Assume invitee
	 {
	   $istat = $tx['sd.invitee'];
	   $ilink = '../reply/reply.php?inviteid=' .
	     get_inviteid($mtgs[$i]['mtgid'], $_SESSION['contactid']);
	 }

	 $l['row'][$i][0]['value'] = $mtgs[$i]['mtgid'];
	 $l['row'][$i][0]['sortval'] = $mtgs[$i]['mtgid'];
	 
	 $l['row'][$i][1]['value'] = $istat;
	 $l['row'][$i][1]['sortval'] = $istat;
	 
	 $l['row'][$i][2]['value'] = '<A HREF="' . $ilink . '">' .
	     ($mtgs[$i]['summary'] != "" ? $mtgs[$i]['summary'] : "-") .
	     '</A>';
	 $l['row'][$i][2]['sortval'] = $mtgs[$i]['summary'];
	 
	 $l['row'][$i][3]['value'] = render_name("compact",
						 $mtgs[$i]['hostgivenname'],
						 $mtgs[$i]['hostsn'],
						 $mtgs[$i]['hostmail']);
	 $l['row'][$i][3]['sortval'] = $mtgs[$i]['hostsn'];
	 
	 $l['row'][$i][4]['value'] = ($mtgs[$i]['replyby'] > 0 ?
				      strftime('%c %Z', $mtgs[$i]['replyby']) :
				      "");
	 $l['row'][$i][4]['sortval'] = $mtgs[$i]['replyby'];
	 
	 $l['row'][$i][5]['value'] = ($mtgs[$i]['scheduledfor'] > 0 ?
				      strftime('%c %Z',
					       $mtgs[$i]['scheduledfor']) :
				      "");
	 $l['row'][$i][5]['sortval'] = $mtgs[$i]['scheduledfor'];
	 
	 if($op == "search" || $op == "asearch")
	 {
	   // The search rank is simply the order returned by get_meetings,
	   // offset to start at 1 instead of 0.

	   $l['row'][$i][6]['value'] = $i+1;
	   $l['row'][$i][6]['sortval'] = $i+1;
	 }
       }

       // Prep standard values to render the list

       if($op == "search" || $op == "asearch")
       {
	 $sortkey = 6;
	 $sortorder = 'asc';
       }
       else
       {
	 $sortkey = 4;
	 $sortorder = 'desc';
       }
       $showpage = 1;
       $perpage = -1;

       if(isset($rvar_sortkey) && $rvar_sortkey > -1)
       {
	 $sortkey = $rvar_sortkey;
	 $sortorder = $rvar_sortorder;
       }

       if(isset($rvar_showpage) && $rvar_showpage > -1)
	 $showpage = $rvar_showpage;

       if(isset($rvar_perpage) && $rvar_perpage > -1)
	 $perpage = $rvar_perpage;

       if($mtgs['count'] > 0)
	 print $mtgs['count'] . $tx['mt.mtgs.founds'] . '<P>';
	 
       render_list($l, $tx['mt.mtgs.none'], $sortkey, $sortorder, $showpage,
		   $perpage);
      ?>
     </TD>
    </TR>
   </TABLE>
  </TD>
 </TR>
</TABLE>
</BODY>
</HTML>
Return current item: Meeting Request Scheduling and Booking System