1<?php
2/**
3* This file provides common output functions thar are used by other templates
4* No data manipulation is done in this file
5*
6* Following functions were borrowed from phpScheduleIt Project:
7*	- showQuickLinks()
8*	- printCpanelBr()
9*	- getShowHide()
10*	- getShowHideHeaders()
11*	- startQuickLinksCol()
12*	- startDataDisplayCol()
13*	- endDataDisplayCol()
14* @author Nick Korbel <lqqkout13@users.sourceforge.net>
15* @author Adam Moore
16* @author David Poole <David.Poole@fccc.edu>
17* @version 04-03-07
18* @package Templates
19* Copyright (C) 2003 - 2005 phpScheduleIt
20*
21* New functions added for MailZu
22* @author Samuel Tran <stran2005@users.sourceforge.net>
23* @author Brian Wong <bwsource@users.sourceforge.net>
24* @author Nicolas Peyrussie <peyrouz@users.sourceforge.net>
25* @author Jeremy Fowler <jfowler06@users.sourceforge.net>
26* Copyright (C) 2005 - 2007 MailZu
27* License: GPL, see LICENSE
28*/
29
30// Get Link object
31$link = CmnFns::getNewLink();
32
33/**
34* Print out a table of links for user or administrator
35* This function prints out a table of links to
36* other parts of the system.  If the user is an admin,
37* it will print out links to administrative pages, also
38* @param none
39*/
40function showQuickLinks() {
41	global $conf;
42	global $link;
43?>
44<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
45  <tr>
46    <td>
47      <table width="100%" border="0" cellspacing="0" cellpadding="0">
48        <tr>
49          <td class="tableTitle" style="background-color:#0F93DF;">
50		    <?php echo translate('My Quick Links')?>
51		  </td>
52          <td class="tableTitle" style="background-color:#0F93DF;"><div align="right">
53              <?php $link->doLink("javascript: help('quick_links');", '?', '', 'color: #FFFFFF', translate('Help') . ' - ' . translate('My Quick Links')) ?>
54            </div>
55          </td>
56        </tr>
57      </table>
58      <table width="100%" border="0" cellspacing="0" cellpadding="0">
59        <tr style="padding: 5px;" class="cellColor">
60          <td colspan="2">
61		<?php echo "Quarantine Summary" == $_SESSION['sessionNav'] ?
62			' <p class="selectedLink"><b>&raquo;</b>':
63			" <p><b>&#8250;</b>\t";
64              	$link->doLink('summary.php', translate('Quarantine Summary')) ?>
65            	</p>
66		<?php echo "My Quarantine" == $_SESSION['sessionNav'] ?
67			' <p class="selectedLink"><b>&raquo;</b>':
68			" <p><b>&#8250;</b>\t";
69              	$link->doLink('messagesIndex.php?ctype=A', translate('My Quarantine'));
70            	echo '</p>';
71		if (! Auth::isMailAdmin()) {
72		  echo "My Pending Requests" == $_SESSION['sessionNav'] ?
73                      ' <p class="selectedLink"><b>&raquo;</b>':
74                      " <p><b>&#8250;</b>\t";
75                  $link->doLink('messagesPending.php?ctype=A', translate('My Pending Requests'));
76		  echo '</p>';
77		}
78		?>
79            	</p>
80		<br>
81		<?php if (Auth::isMailAdmin()) {
82		     if ($conf['app']['siteSummary']) {
83  		       echo "Site Quarantine Summary" == $_SESSION['sessionNav'] ?
84		  	  ' <p class="selectedLink"><b>&raquo;</b>':
85			  " <p><b>&#8250;</b>\t";
86        	      	  $link->doLink('messagesSummary.php', translate('Site Quarantine Summary'));
87            	       echo '</p>';
88                     }
89
90		  echo "Site Quarantine" == $_SESSION['sessionNav'] ?
91                        ' <p class="selectedLink"><b>&raquo;</b>':
92                        " <p><b>&#8250;</b>\t";
93                  $link->doLink('messagesAdmin.php?ctype=A&searchOnly='.$conf['app']['searchOnly'], translate('Site Quarantine'));
94		  echo '</p>';
95		  echo "Site Pending Requests" == $_SESSION['sessionNav'] ?
96                        ' <p class="selectedLink"><b>&raquo;</b>':
97                        " <p><b>&#8250;</b>\t";
98                  $link->doLink('messagesPendingAdmin.php?ctype=A', translate('Site Pending Requests'));
99		  echo '</p>';
100		  echo '<br>';
101		}
102    if ((! Auth::isMailAdmin()) && ($conf['app']['showEmailAdmin'])) {
103		  echo "Email Administrator" == $_SESSION['sessionNav'] ?
104			' <p class="selectedLink"><b>&raquo;</b>':
105			" <p><b>&#8250;</b>\t";
106              	  $link->doLink('send_mail.php', translate('Email Administrator'));
107            	  echo ' </p>';
108		}
109		?>
110            	<p><b>&#8250;</b>
111              	<?php $link->doLink('javascript: help();', translate('Help')) ?>
112            	</p>
113		<br>
114            	<p><b>&#8250;</b>
115              	<?php $link->doLink('index.php?logout=true', translate('Log Out')) ?>
116            	</p>
117          </td>
118        </tr>
119      </table>
120    </td>
121  </tr>
122</table>
123<?php
124}
125
126/**
127* Print out break to be used between tables
128* @param none
129*/
130function printCpanelBr() {
131	echo '<p>&nbsp;</p>';
132}
133
134/**
135* Returns the proper expansion type for this table
136*  based on cookie settings
137* @param string table name of table to check
138* @return either 'block' or 'none'
139*/
140function getShowHide($table) {
141	if (isset($_COOKIE[$table]) && $_COOKIE[$table] == 'show') {
142		return 'block';
143	}
144	else
145		return 'none';
146}
147
148/**
149* Returns the proper className for the rows of this table
150*  based on cookie settings
151* @param string table name of table to check
152* @return 'visible' or 'hidden'
153*/
154function getShowHideHeaders($table) {
155        if (isset($_COOKIE[$table]) && $_COOKIE[$table] == 'visible') {
156                return 'visible';
157        } else {
158                return 'hidden';
159	}
160}
161
162function startQuickLinksCol() {
163?>
164<table width="100%" border="0" cellpadding="0" cellspacing="0">
165<tr>
166<td style="vertical-align:top; width:16%; border:solid 2px #0F93DF; background-color:#FFFFFF;">
167<?php
168}
169
170function startDataDisplayCol() {
171?>
172</td>
173<td style="padding-left:5px; vertical-align:top;">
174<?php
175}
176
177function endDataDisplayCol() {
178?>
179</td>
180</tr>
181</table>
182<?php
183}
184
185/**
186* Print 'Release', 'Delete' and 'Delete All' buttons
187* @param string $content_type: 'S' (default), 'B', ...
188* @param bool $printDeleteAll: if true (default) print 'Delete All' button
189*/
190function printActionButtons( $printDeleteAll = true ) {
191?>
192<table width="100%" border="0" cellspacing="1" cellpadding="0">
193<tr>
194<?php
195	echo "<td align=\"left\"><input type=\"submit\" class=\"button\" name=\"action\" value=\"";
196	if ($_SESSION['sessionNav'] == "My Pending Requests") {
197		echo ( Auth::isMailAdmin() ? translate('Release') : translate('Cancel Request') );
198
199	} else {
200		echo ( Auth::isMailAdmin() ? translate('Release') : translate('Release/Request release') );
201	}
202	echo "\"></td>";
203?>
204	<td align="right"><input type="submit" class="button" name="action" value="<?php echo translate('Delete'); ?>">
205<?php 	if ( $printDeleteAll )
206		echo "<input type=\"submit\" class=\"button\" name=\"action\" value=\"".translate('Delete All')."\">";
207?>
208	</td>
209</tr>
210</table>
211<?php
212}
213
214/**
215* Print 'Send Error Report' buttons
216* @param string $query_string
217* @param array $error_array
218*/
219function printReportButtons( $query_string, $error_array, $process_action ) {
220
221	$serialized_error_array = urlencode(serialize($error_array));
222?>
223<form name="error_report_form" action="sendErrorReport.php" method="POST">
224<table width="100%" border="0" cellspacing="1" cellpadding="0">
225<tr>
226	<input type="hidden" name="query_string" value="<?php echo $query_string; ?> ">
227	<input type="hidden" name="serialized_error_array" value="<?php echo $serialized_error_array; ?>">
228	<input type="hidden" name="process_action" value="<?php echo $process_action ;?>">
229	<td><center>
230		<input type="submit" class="button" name="action" value="<?php echo translate('Send report and go back'); ?>">&nbsp;
231		<input type="submit" class="button" name="action" value="<?php echo translate('Go back'); ?>">
232	</center></td>
233</tr>
234</table>
235</form>
236<?php
237}
238
239/**
240* Print Message and flushes the output buffer.
241*/
242
243function printMessage($message) {
244	$id = urlencode($message);
245?>
246	<div align="center" id="<?php echo $id; ?>" style="display:block;">
247		<H4><?php echo $message; ?></H4>
248	</div>
249<?php
250	ob_flush();
251	flush();
252}
253
254/**
255* Hides Message crested with printMessage and flushes the output buffer.
256*/
257function hideMessage($message) {
258	$id = urlencode($message);
259	echo "<script> document.getElementById('$id').style.display='none'; </script>";
260	ob_flush();
261	flush();
262}
263?>
264