Commit 3138816b authored by lindonb's avatar lindonb

[FIX] Implement 12--24 hour clock choice on admin calendars. Also, page wasn't...

[FIX] Implement 12--24 hour clock choice on admin calendars. Also, page wasn't refreshing with updated data after save. Improved navigation to expected cookie tabs.
parent 0c856b79
......@@ -99,8 +99,12 @@ function smarty_function_html_select_time($params, &$smarty)
$hours[$i] = sprintf('%02d', $hours[$i]);
if ($prefix == 'end_' && ($time_hr24 == '000000')) {
$selected = $latest;
} elseif ($prefix == 'duration_') {
$selected = floor($time / (60*60));
} elseif ($prefix == 'duration_' || $prefix == 'startday_' || $prefix == 'endday_') {
if ($use_24_hours) {
$selected = floor($time / (60*60));
} else {
$selected = date('h', strtotime(floor($time / (60*60)) . ':00 '));
}
} else {
$selected = $time == '--' ? $hour_empty : TikiLib::date_format($hour_fmt, $time);
}
......
......@@ -82,7 +82,7 @@
<a title="{tr}Permissions{/tr}" class="link" href="tiki-objectpermissions.php?objectName={$cal.name|escape:"url"}&amp;objectType=calendar&amp;permType=calendar&amp;objectId={$id}">{if $cal.individual gt 0}{icon _id='key_active' alt="{tr}Permissions{/tr}"}</a>&nbsp;{$cal.individual}{else}{icon _id='key' alt="{tr}Permissions{/tr}"}</a>{/if}
</td>
<td class="action">
<a title="{tr}Edit{/tr}" class="link" href="tiki-admin_calendars.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;calendarId={$id}">{icon _id='page_edit'}</a>
<a title="{tr}Edit{/tr}" class="link" href="tiki-admin_calendars.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;calendarId={$id}&cookietab=2">{icon _id='page_edit'}</a>
<a title="{tr}View Calendar{/tr}" class="link" href="tiki-calendar.php?calIds[]={$id}">{icon _id='magnifier' alt="{tr}View{/tr}"}</a>
<a title="{tr}Delete{/tr}" class="link" href="tiki-admin_calendars.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;drop={$id}&amp;calendarId={$id}" title="{tr}Delete{/tr}">{icon _id='cross' alt="{tr}Delete{/tr}"}</a>
<a title="{tr}Add Event{/tr}" class="link" href="tiki-calendar_edit_item.php?calendarId={$id}">{icon _id='add' alt="{tr}Add Event{/tr}"}</a>
......@@ -209,21 +209,13 @@
<tr>
<td>{tr}Start of day:{/tr}</td>
<td>
<select name="startday_Hour">
{foreach key=h item=d from=$hours}
<option value="{$h}"{if $h eq $startday} selected="selected"{/if}>{$d}</option>
{/foreach}
</select>
{html_select_time prefix="startday_" time=$info.startday display_minutes=false display_seconds=false use_24_hours=$use_24hr_clock}
</td>
</tr>
<tr>
<td>{tr}End of day:{/tr}</td>
<td>
<select name="endday_Hour">
{foreach key=h item=d from=$hours}
<option value="{$h}"{if $h eq $endday} selected="selected"{/if}>{$d}</option>
{/foreach}
</select>
{html_select_time prefix="endday_" time=$info.endday display_minutes=false display_seconds=false use_24_hours=$use_24hr_clock}
</td>
</tr>
<tr>
......@@ -303,7 +295,7 @@
</tr>
</table>
<br />
{if $calendarId}{$name|escape} : {/if}
{if $calendarId ne 0}{$name|escape} : {/if}
{tr}Delete events older than:{/tr} <input type="text" name="days" value="0"/> {tr}days{/tr} <input type="submit" name="clean" value="{tr}Delete{/tr}" />
</form>
{/tab}
......
......@@ -26,7 +26,7 @@
{if $displayedcals|@count eq 1}
{button href="tiki-admin_calendars.php?calendarId=$displayedcals[0]" _text="{tr}Edit Calendar{/tr}"}
{/if}
{button href="tiki-admin_calendars.php" _text="{tr}Admin Calendars{/tr}"}
{button href="tiki-admin_calendars.php?cookietab=1" _text="{tr}Admin Calendars{/tr}"}
{/if}
{* avoid Add Event being shown if no calendar is displayed *}
{if $tiki_p_add_events eq 'y'}
......
......@@ -53,8 +53,15 @@ if (isset($_REQUEST["save"])) {
}
if (!preg_match('/^[0-9a-fA-F]{3,6}$/', $options['customfgcolor'])) $options['customfgcolor'] = '';
if (!preg_match('/^[0-9a-fA-F]{3,6}$/', $options['custombgcolor'])) $options['custombgcolor'] = '';
//Convert 12-hour clock hours to 24-hour scale to compute time
if (!empty($_REQUEST['startday_Meridian'])) {
$_REQUEST['startday_Hour'] = date('H', strtotime($_REQUEST['startday_Hour'] . ':00 ' . $_REQUEST['startday_Meridian']));
}
if (!empty($_REQUEST['endday_Meridian'])) {
$_REQUEST['endday_Hour'] = date('H', strtotime($_REQUEST['endday_Hour'] . ':00 ' . $_REQUEST['endday_Meridian']));
}
$options['startday'] = $_REQUEST['startday_Hour'] * 60 * 60;
$options['endday'] = $_REQUEST['endday_Hour'] == 0 ? (24 * 60 * 60) - 1 : ($_REQUEST['endday_Hour'] * 60 * 60) - 1;
$options['endday'] = $_REQUEST['endday_Hour'] == 0 ? (24 * 60 * 60) - 1 : ($_REQUEST['endday_Hour'] * 60 * 60);
$extra = array(
'calname',
'description',
......@@ -76,6 +83,7 @@ if (isset($_REQUEST["save"])) {
}
if (isset($_REQUEST['viewdays'])) $options['viewdays'] = $_REQUEST['viewdays'];
$_REQUEST["calendarId"] = $calendarlib->set_calendar($_REQUEST["calendarId"], $user, $_REQUEST["name"], $_REQUEST["description"], $customflags, $options);
$info = $calendarlib->get_calendar($_REQUEST['calendarId']);
if ($prefs['feature_groupalert'] == 'y') {
$groupalertlib->AddGroup('calendar', $_REQUEST["calendarId"], $_REQUEST['groupforAlert'], !empty($_REQUEST['showeachuser']) ? $_REQUEST['showeachuser'] : 'n');
}
......@@ -111,7 +119,7 @@ if ($prefs['feature_categories'] == 'y') {
}
}
}
if ($_REQUEST["calendarId"]) {
if ($_REQUEST['calendarId'] != 0) {
$cookietab = 2;
} else {
$info = array();
......@@ -142,9 +150,9 @@ if ($_REQUEST["calendarId"]) {
$info["defaulteventstatus"] = 1;
$info['viedays'] = $prefs['calendar_view_days'];
if (!empty($_REQUEST['show']) && $_REQUEST['show'] == 'mod') {
$cookietab = '2';
$cookietab = 2;
} else {
if (!isset($cookietab)) { $cookietab = '1'; }
if (!isset($cookietab)) { $cookietab = 1; }
}
}
if ($prefs['feature_groupalert'] == 'y') {
......@@ -185,34 +193,11 @@ $smarty->assign('show_participants', $info["show_participants"]);
$smarty->assign('show_url', $info["show_url"]);
$smarty->assign('calendarId', $_REQUEST["calendarId"]);
$smarty->assign('personal', $info["personal"]);
$smarty->assign('startday', $info["startday"] < 0 ? 0 : round($info['startday'] / (60 * 60)));
$smarty->assign('endday', $info["endday"] < 0 ? 0 : round($info['endday'] / (60 * 60)));
$smarty->assign('hours', array(
'0' => '12:00 midnight',
'1' => '1:00 am',
'2' => '2:00 am',
'3' => '3:00 am',
'4' => '4:00 am',
'5' => '5:00 am',
'6' => '6:00 am',
'7' => '7:00 am',
'8' => '8:00 am',
'9' => '9:00 am',
'10' => '10:00 am',
'11' => '11:00 am',
'12' => '12:00 noon',
'13' => '1:00 pm',
'14' => '2:00 pm',
'15' => '3:00 pm',
'16' => '4:00 pm',
'17' => '5:00 pm',
'18' => '6:00 pm',
'19' => '7:00 pm',
'20' => '8:00 pm',
'21' => '9:00 pm',
'22' => '10:00 pm',
'23' => '11:00 pm'
));
$smarty->assign('startday', $info["startday"] < 0 ? 0 : $info['startday']);
$smarty->assign('endday', $info["endday"] < 0 ? 0 : $info['endday']);
//Use 12- or 24-hour clock for $publishDate time selector based on admin and user preferences
include_once ('lib/userprefs/userprefslib.php');
$smarty->assign('use_24hr_clock', $userprefslib->get_user_clock_pref($user));
$smarty->assign('defaulteventstatus', $info['defaulteventstatus']);
$smarty->assign('eventstatus', array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment