2013-08-12 09:52:50 +02:00
|
|
|
<?php
|
|
|
|
function getNotice() {
|
|
|
|
if(!file_exists('data/notice')) {
|
|
|
|
file_put_contents('data/notice');
|
|
|
|
}
|
|
|
|
|
|
|
|
return file_get_contents('data/notice');
|
|
|
|
}
|
|
|
|
|
|
|
|
function setNotice($notice) {
|
|
|
|
return file_put_contents('data/notice', $notice);
|
|
|
|
}
|
2013-08-26 21:21:52 +02:00
|
|
|
|
|
|
|
function secureDisplay($unsecured) {
|
|
|
|
$return = NULL;
|
|
|
|
if(is_array($unsecured)) {
|
|
|
|
$return = array();
|
|
|
|
foreach($unsecured as $key=>$unsecured_item) {
|
|
|
|
$return[$key] = secureDisplay($unsecured_item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif(is_object($unsecured)) {
|
|
|
|
$return = $unsecured->secureDisplay();
|
|
|
|
}
|
|
|
|
elseif(is_numeric($unsecured)) {
|
|
|
|
if(intval($unsecured) == floatval($unsecured))
|
|
|
|
$return = (int) $unsecured;
|
|
|
|
else
|
|
|
|
$return = (float) $unsecured;
|
|
|
|
}
|
|
|
|
elseif(is_bool($unsecured)) {
|
|
|
|
$return = (bool) $unsecured;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$return = htmlspecialchars($unsecured);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
2013-08-30 20:07:52 +02:00
|
|
|
|
|
|
|
function ampm2int($date) {
|
|
|
|
if($date == 'am')
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function int2ampm($hour) {
|
|
|
|
if($hour == 0)
|
|
|
|
return 6;
|
|
|
|
else
|
|
|
|
return 18;
|
|
|
|
}
|
2013-09-05 20:09:03 +02:00
|
|
|
|
2013-09-05 23:46:51 +02:00
|
|
|
function listTemplates($dir) {
|
2013-09-05 20:09:03 +02:00
|
|
|
if(strrpos($dir, '/') !== strlen($dir) - 1) {
|
|
|
|
$dir .= '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
$return = array();
|
|
|
|
|
|
|
|
if ($handle = opendir($dir)) {
|
|
|
|
while (false !== ($entry = readdir($handle))) {
|
2013-09-06 20:07:28 +02:00
|
|
|
if ($entry != "." && $entry != ".." && $entry != 'json' && is_dir($dir.$entry)) {
|
2013-09-05 23:57:47 +02:00
|
|
|
$return[] = array('value'=>$entry, 'option'=>str_replace(array('_en', '_fr'), array(' (English)', ' (French)'), $entry));
|
2013-09-05 20:09:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($handle);
|
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
2013-09-06 23:07:35 +02:00
|
|
|
|
|
|
|
function TwoDArrayToOneD($array, $key) {
|
|
|
|
$return = array();
|
|
|
|
|
|
|
|
foreach($array as $value) {
|
|
|
|
$return[] = $value[$key];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
2013-09-08 16:12:30 +02:00
|
|
|
|
|
|
|
function formatUsersIn($users_in, $all_users) {
|
2013-09-08 18:36:59 +02:00
|
|
|
global $localized;
|
2013-09-08 16:12:30 +02:00
|
|
|
// TODO : Move this function to somewhere else ?
|
|
|
|
$return = '';
|
|
|
|
$users_in = $users_in->get();
|
|
|
|
|
|
|
|
$i = false;
|
|
|
|
foreach($users_in as $user_in=>$guests) {
|
|
|
|
if($i) { $return .= '<br/>'; } else { $i = true; }
|
|
|
|
|
|
|
|
$return .= $all_users[$user_in]->getDisplayName();
|
|
|
|
if($guests != 0) {
|
2013-09-08 18:36:59 +02:00
|
|
|
if($guests > 1)
|
|
|
|
$return .= ' ('.$guests.' '.$localized['guest'][LANG].'s)';
|
2013-09-08 16:12:30 +02:00
|
|
|
else
|
2013-09-08 18:36:59 +02:00
|
|
|
$return .= ' ('.$guests.' '.$localized['guest'][LANG].')';
|
2013-09-08 16:12:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|