There is still some work needed for the calendar block, but now it is possible to add events and delete them

This commit is contained in:
Marc Alexander
2010-10-15 20:35:16 +00:00
parent 1350827f0e
commit 8521b1d5e0
4 changed files with 451 additions and 43 deletions

View File

@@ -0,0 +1,158 @@
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_TITLE}</h1>
<p>{L_TITLE_EXPLAIN}</p>
<!-- IF S_ERROR -->
<div class="errorbox">
<h3>{L_WARNING}</h3>
<p>{ERROR_MSG}</p>
</div>
<!-- ENDIF -->
<!-- IF S_EDIT -->
<form id="acp_portal_links" method="post" action="{U_ACTION}">
<fieldset>
<legend>{L_ACP_PORTAL_MENU_LINK}</legend>
<dl>
<dt><label for="event_title">{L_EVENT_TITLE}:</label></dt>
<dd><input name="event_title" type="text" id="event_title" value="{EVENT_TITLE}" maxlength="255" /></dd>
</dl>
<dl>
<dt><label for="event_desc">{L_EVENT_DESC}:</label></dt>
<dd><input name="event_desc" type="text" id="event_desc" value="{EVENT_TITLE}" maxlength="255" /></dd>
</dl>
<dl>
<dt>
<label for="event_start_day">{L_ACP_PORTAL_EVENT_START_DAY}:</label><br />
<span>{L_ACP_PORTAL_EVENT_START_DAY_EXP}</span>
</dt>
<dd><input name="event_start_day" type="text" id="event_start_day" value="{EVENT_START_DAY}" maxlength="255" /></dd>
</dl>
<dl>
<dt>
<label for="event_start_time">{L_ACP_PORTAL_EVENT_START_TIME}:</label><br />
<span>{L_ACP_PORTAL_EVENT_START_TIME_EXP}</span>
</dt>
<dd><input name="event_start_time" type="text" id="event_start_time" value="{EVENT_START_TIME}" maxlength="255" /></dd>
</dl>
<dl>
<dt><label for="event_all_day">{L_EVENT_ALL_DAY}:</label></dt>
<dd>
<label><input onchange="dE('end', -1)" type="radio" class="radio" name="event_all_day" value="1" id="event_all_day"<!-- IF EVENT_ALL_DAY --> checked="checked"<!-- ENDIF --> />{L_YES}</label>
<label><input onchange="dE('end', 1)" type="radio" class="radio" name="event_all_day" value="0"<!-- IF not EVENT_ALL_DAY --> checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd>
</dl>
<div id="end"<!-- IF EVENT_ALL_DAY -->style="display: none;"<!-- ENDIF -->>
<dl>
<dt>
<label for="event_end_day">{L_ACP_PORTAL_EVENT_END_DAY}:</label><br />
<span>{L_ACP_PORTAL_EVENT_END_DAY_EXP}</span>
</dt>
<dd><input name="event_end_day" type="text" id="event_end_day" value="{EVENT_END_DAY}" maxlength="255" /></dd>
</dl>
<dl>
<dt>
<label for="event_end_time">{L_ACP_PORTAL_EVENT_END_TIME}:</label><br />
<span>{L_ACP_PORTAL_EVENT_END_TIME_EXP}</span>
</dt>
<dd><input name="event_end_time" type="text" id="event_end_time" value="{EVENT_END_TIME}" maxlength="255" /></dd>
</dl>
</div>
<dl>
<dt>
<label for="event_url">{L_EVENT_LINK}:</label><br />
<span>{L_EVENT_LINK_EXP}</span>
</dt>
<dd><input name="event_url" type="text" id="event_url" value="{EVENT_URL}" maxlength="255" /></dd>
</dl>
<dl>
<dt>
<label for="permission-setting">{L_ACP_PORTAL_MENU_PERMISSION}:</label><br />
<span>{L_ACP_PORTAL_MENU_PERMISSION_EXP}</span>
</dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
</select>
</dd>
</dl>
<p class="submit-buttons">
<input type="hidden" name="action" value="save" />
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
{S_FORM_TOKEN}
</p>
</fieldset>
</form>
<!-- ELSE -->
<form id="acp_portal_calendar" method="post" action="{U_ACTION}">
<!-- IF SHOW_MODULE_OPTIONS -->
<fieldset>
<legend>{L_MODULE_OPTIONS}</legend>
<dl>
<dt><label for="module_name">{L_MODULE_NAME}:</label><br /><span>{L_MODULE_NAME_EXP}</span></dt>
<dd><input id="module_name" type="text" value="{MODULE_NAME}" name="module_name" maxlength="255" size="64" /></dd>
</dl>
<dl>
<dt><label for="module_image">{L_MODULE_IMAGE}:</label><br /><span>{L_MODULE_IMAGE_EXP}</span></dt>
<dd><input id="module_image" type="text" value="{MODULE_IMAGE}" name="module_image" maxlength="255" size="64" /></dd>
<!-- IF MODULE_IMAGE_SRC --><dd><img src="{MODULE_IMAGE_SRC}" alt="{L_MODULE_IMAGE}" /></dd><!-- ENDIF -->
</dl>
</fieldset>
<!-- ENDIF -->
<fieldset class="tabulated">
<legend>{L_ACP_PORTAL_CALENDAR}</legend>
<p class="quick">
<input class="button2" name="add" type="submit" value="{L_ADD_LINK}" />
</p>
<table cellspacing="1">
<thead>
<tr>
<th>{L_EVENT_TITLE}</th>
<th>{L_EVENT_DESC}</th>
<th>{L_EVENT_TIME}</th>
<th>{L_EVENT_LINK}</th>
<th>{L_ACTION}</th>
</tr>
</thead>
<tbody>
<!-- BEGIN events -->
<!-- IF events.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
<td style="text-align: center;">{events.EVENT_TITLE}</td>
<td style="text-align: center;">{events.EVENT_DESC}</td>
<td style="text-align: center;"><!-- IF events.EVENT_END -->{L_EVENT_START}:&nbsp;{events.EVENT_START}&nbsp;&#124;&nbsp;{L_EVENT_END}:&nbsp;{events.EVENT_END}<!-- ELSE -->{L_EVENT_TIME}:&nbsp;{events.EVENT_START}<!-- ENDIF --></td>
<td style="text-align: center;">{events.LINK_URL}</td>
<td style="text-align: center;">
<a href="{events.U_EDIT}">{ICON_EDIT}</a> <a href="{events.U_DELETE}">{ICON_DELETE}</a>
</td>
</tr>
<!-- BEGINELSE -->
<tr class="row1">
<td style="text-align: center;" colspan="5">{L_NO_EVENTS}</td>
</tr>
<!-- END events -->
</tbody>
</table>
<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
</p>
{S_FORM_TOKEN}
</fieldset>
</form>
<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->

View File

@@ -84,6 +84,49 @@ $lang = array_merge($lang, array(
'12'=> 'December', '12'=> 'December',
), ),
), ),
// ACP
'ACP_PORTAL_CALENDAR' => 'Calendar settings',
'ACP_PORTAL_CALENDAR_EXP' => 'This is where you customize the calendar block.',
'PORTAL_CALENDAR_TODAY_COLOR' => 'Active day color',
'PORTAL_CALENDAR_TODAY_COLOR_EXPLAIN' => 'HEX or named colors are allowed such as #FFFFFF for white, or color names like violet.',
'PORTAL_CALENDAR_SUNDAY_COLOR' => 'Color for sunday',
'PORTAL_CALENDAR_SUNDAY_COLOR_EXPLAIN' => 'HEX or named colors are allowed such as #FFFFFF for white, or color names like violet.',
'PORTAL_LONG_MONTH' => 'Show full month names',
'PORTAL_LONG_MONTH_EXPLAIN' => 'If disabled the months will be shortened e.g. Aug. instead of August.',
'PORTAL_SUNDAY_FIRST' => 'First day of the week',
'PORTAL_SUNDAY_FIRST_EXPLAIN' => 'If disabled the calendar will show Mo. --> Su., else Su. --> Sa.',
'PORTAL_DISPLAY_EVENTS' => 'Display events',
'PORTAL_DISPLAY_EVENTS_EXP' => 'Display events that have been created in the calendar block',
'PORTAL_EVENTS_MANAGE' => 'Manage events',
'NO_EVENT_TITLE' => 'You havent specified a title for the event.',
'NO_EVENT_START' => 'You havent specified a start time for the event.',
'EVENT_UPDATED' => 'Event updated successfully.',
'EVENT_ADDED' => 'Event added successfully.',
'NO_EVENT' => 'No event specified.',
'EVENT_TITLE' => 'Event title',
'EVENT_DESC' => 'Event description',
'EVENT_LINK' => 'Event link',
'EVENT_LINK_EXP' => 'Enter the link to a topic or website with the announcement or discussion topic of the event.',
'NO_EVENTS' => 'No events',
'ACP_PORTAL_CALENDAR_START_INCORRECT' => 'The start time you entered was incorrect. Please follow the instructions carefully.',
'ACP_PORTAL_CALENDAR_END_INCORRECT' => 'The end time you entered was incorrect. Please follow the instructions carefully.',
'ACP_PORTAL_CALENDAR_EVENT_PAST' => 'The event start time needs to be in the future.',
'ACP_PORTAL_EVENT_START_DAY' => 'Event start date',
'ACP_PORTAL_EVENT_START_DAY_EXP' => 'Enter the date when the event starts. The date has to be in this format: YYYY-MM-DD',
'ACP_PORTAL_EVENT_START_TIME' => 'Event start time',
'ACP_PORTAL_EVENT_START_TIME_EXP' => 'Enter the time when the event starts. The time has to be in a 24 hour format, i.e. 23:12',
'ACP_PORTAL_EVENT_END_DAY' => 'Event end date',
'ACP_PORTAL_EVENT_END_DAY_EXP' => 'Enter the date when the event starts. The date has to be in this format: YYYY-MM-DD',
'ACP_PORTAL_EVENT_END_TIME' => 'Event end time',
'ACP_PORTAL_EVENT_END_TIME_EXP' => 'Enter the time when the event starts. The time has to be in a 24 hour format, i.e. 23:12',
'ACP_PORTAL_CALENDAR_EVENT_START_FIRST' => 'The end of the event has to be after the start of the event.',
// Logs
'LOG_PORTAL_EVENT_UPDATED' => '<strong>Updated Event</strong><br />&raquo; %s',
'LOG_PORTAL_EVENT_ADDED' => '<strong>Added Event</strong><br />&raquo; %s',
'LOG_PORTAL_EVENT_REMOVED' => '<strong>Removed Event</strong><br />&raquo; %s',
)); ));
?> ?>

View File

@@ -50,7 +50,7 @@ class portal_calendar_module
* custom acp template * custom acp template
* file must be in "adm/style/portal/" * file must be in "adm/style/portal/"
*/ */
//var $custom_acp_tpl = ''; var $custom_acp_tpl = 'acp_portal_calendar';
function get_template_center($module_id) function get_template_center($module_id)
{ {
@@ -174,7 +174,7 @@ class portal_calendar_module
'desc' => '', 'desc' => '',
'start_time' => '', 'start_time' => '',
'end_time' => '', 'end_time' => '',
'url' => '', 'url' => '', // optional
);*/ );*/
if(!empty($events)) if(!empty($events))
{ {
@@ -195,9 +195,10 @@ class portal_calendar_module
$template->assign_block_vars('cur_events', array( $template->assign_block_vars('cur_events', array(
'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '', 'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '',
'EVENT_TITLE' => $cur_event['title'], 'EVENT_TITLE' => $cur_event['title'],
'START_TIME' => $user->format_date($cur_event['start_time'], 'y-m-d'), 'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'),
'END_TIME' => $user->format_date($cur_event['end_time'], 'y-m-d'), 'END_TIME' => $user->format_date($cur_event['end_time'], 'j. M Y, H:i'),
'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '', 'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '',
'ALL_DAY' => (($cur_event['start_time'] - $cur_event['end_time']) == 1) ? true : false,
)); ));
} }
else else
@@ -206,61 +207,33 @@ class portal_calendar_module
'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '', 'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '',
'EVENT_TITLE' => $cur_event['title'], 'EVENT_TITLE' => $cur_event['title'],
'CUR_EVENT' => ($cur_event['start_time'] <= $today_timestamp && $cur_event['end_time'] >= $today_timestamp) ? true : false, 'CUR_EVENT' => ($cur_event['start_time'] <= $today_timestamp && $cur_event['end_time'] >= $today_timestamp) ? true : false,
'START_TIME' => $user->format_date($cur_event['start_time'], 'y-m-d'), 'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'),
'END_TIME' => $user->format_date($cur_event['end_time'], 'y-m-d'), 'END_TIME' => $user->format_date($cur_event['end_time'], 'j. M Y, H:i'),
'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '', 'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '',
'ALL_DAY' => (($cur_event['start_time'] - $cur_event['end_time']) == 1) ? true : false,
)); ));
} }
} }
else
{
// mark the events that should be deleted
$delete_id_ary[] = $key;
}
}
// now delete old events
if(isset($delete_id_ary) && !empty($delete_id_ary))
{
foreach($delete_id_ary as $cur_id)
{
array_splice($events, $cur_id, 1);
}
// afterwards reset the array numbering and insert the data into the database
$events = array_merge($events);
$events = serialize($events);
set_portal_config('board3_calendar_events_' . $module_id, $events);
} }
} }
//print_r($events); // no output needed, seems to work correctly
/*
if (!isset($template->filename['mini_cal_block']))
{
$template->set_filenames(array(
'mini_cal_block' => 'portal/block/mini_calendar.html')
);
}
*/
return 'calendar_side.html'; return 'calendar_side.html';
} }
function get_template_acp($module_id) function get_template_acp($module_id)
{ {
return array( return array(
'title' => 'ACP_CONFIG_MODULENAME', 'title' => 'ACP_PORTAL_CALENDAR',
'vars' => array( 'vars' => array(
'legend1' => 'ACP_MODULENAME_CONFIGLEGEND', 'legend1' => 'ACP_PORTAL_CALENDAR',
'portal_' . $module_id . '_configname' => array('lang' => 'MODULENAME_CONFIGNAME', 'validate' => 'string', 'type' => 'text:10:200', 'explain' => false), 'board3_calendar_today_color_' . $module_id => array('lang' => 'PORTAL_CALENDAR_TODAY_COLOR' , 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true),
'portal_' . $module_id . '_configname2' => array('lang' => 'MODULENAME_CONFIGNAME2', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), 'board3_calendar_sunday_color_' . $module_id => array('lang' => 'PORTAL_CALENDAR_SUNDAY_COLOR' , 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true),
'board3_long_month_' . $module_id => array('lang' => 'PORTAL_LONG_MONTH' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_sunday_first_' . $module_id => array('lang' => 'PORTAL_SUNDAY_FIRST' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_display_events_' . $module_id => array('lang' => 'PORTAL_DISPLAY_EVENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_events_' . $module_id => array('lang' => 'PORTAL_EVENTS_MANAGE', 'validate' => 'string', 'type' => 'custom', 'explain' => false, 'method' => 'manage_events', 'submit' => 'update_events'),
), ),
); );
return array();
} }
/** /**
@@ -272,6 +245,8 @@ class portal_calendar_module
set_config('board3_calendar_today_color_' . $module_id, '#000000'); set_config('board3_calendar_today_color_' . $module_id, '#000000');
set_config('board3_calendar_sunday_color_' . $module_id, '#FF0000'); set_config('board3_calendar_sunday_color_' . $module_id, '#FF0000');
set_config('board3_long_month_' . $module_id, 0); set_config('board3_long_month_' . $module_id, 0);
set_config('board3_display_events_' . $module_id, 0);
set_config('board3_events_' . $module_id, '');
set_portal_config('board3_calendar_events_' . $module_id, ''); set_portal_config('board3_calendar_events_' . $module_id, '');
return true; return true;
@@ -294,12 +269,243 @@ class portal_calendar_module
'board3_calendar_today_color_' . $module_id, 'board3_calendar_today_color_' . $module_id,
'board3_calendar_sunday_color_' . $module_id, 'board3_calendar_sunday_color_' . $module_id,
'board3_long_month_' . $module_id, 'board3_long_month_' . $module_id,
'board3_display_events_' . $module_id,
'board3_events_' . $module_id,
); );
$sql = 'DELETE FROM ' . CONFIG_TABLE . ' $sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config); WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql); return $db->sql_query($sql);
} }
function manage_events($value, $key, $module_id)
{
global $db, $portal_config, $config, $template, $user, $phpEx, $phpbb_admin_path;
$action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action;
$link_id = request_var('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach
$portal_config = obtain_portal_config();
$events = (strlen($portal_config['board3_calendar_events_' . $module_id]) >= 1) ? $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]) : array();
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
switch($action)
{
// Save changes
case 'save':
if (!check_form_key('acp_portal'))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$event_title = utf8_normalize_nfc(request_var('event_title', ' ', true));
$event_desc = utf8_normalize_nfc(request_var('event_desc', ' ', true));
$event_start_day = trim(request_var('event_start_day', ''));
$event_start_time = trim(request_var('event_start_time', ''));
$event_end_day = trim(request_var('event_end_day', ''));
$event_end_time = trim(request_var('event_end_time', ''));
$event_all_day = request_var('event_all_day', false); // default to false
$event_url = str_replace('&amp;', '&', request_var('event_url', ' ')); // @todo: check if we need the str_replace when using serialize
$event_permission = request_var('permission-setting', array(0 => ''));
$groups_ary = array();
/*
* parse the event time
* first check for obvious errors, we don't want to waste server resources
*/
if(strlen($event_start_day) < 9 || strlen($event_start_day) > 10 || strlen($event_start_time) < 4 || strlen($event_start_time) > 5)
{
echo 'what';
trigger_error($user->lang['ACP_PORTAL_CALENDAR_START_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
}
elseif((strlen($event_end_day) < 9 || strlen($event_end_day) > 10 || strlen($event_end_time) < 4 || strlen($event_end_time) > 5) && !$event_all_day)
{
trigger_error($user->lang['ACP_PORTAL_CALENDAR_END_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
}
$start_year = (int) substr($event_start_day, 0, 4);
$start_month = (int) substr($event_start_day, 5, 2);
$start_day = (int) substr($event_start_day, 8, 2);
$start_hour = (int) substr($event_start_time, 0, 2);
$start_minute = (int) substr($event_start_time, 3, 2);
$end_year = (int) substr($event_end_day, 0, 4);
$end_month = (int) substr($event_end_day, 5, 2);
$end_day = (int) substr($event_end_day, 8, 2);
$end_hour = (int) substr($event_end_time, 0, 2);
$end_minute = (int) substr($event_end_time, 3, 2);
// UNIX timestamps
$start_time = mktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year);
$end_time = (!$event_all_day) ? mktime($end_hour, $end_minute, 0, $end_month, $end_day, $end_year) : ($start_time - 1);
if($start_time <= time())
{
trigger_error($user->lang['ACP_PORTAL_CALENDAR_EVENT_PAST']. adm_back_link($u_action), E_USER_WARNING);
}
elseif($end_time < $start_time && !$event_all_day)
{
trigger_error($user->lang['ACP_PORTAL_CALENDAR_EVENT_START_FIRST']. adm_back_link($u_action), E_USER_WARNING);
}
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$event_permission = array_intersect($event_permission, $groups_ary);
$event_permission = implode(',', $event_permission);
// Check for errors
if (!$event_title)
{
trigger_error($user->lang['NO_EVENT_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
}
if (!$start_time || $start_time == 0)
{
trigger_error($user->lang['NO_EVENT_START'] . adm_back_link($u_action), E_USER_WARNING);
}
// overwrite already existing events and make sure we don't try to save an event outside of the normal array size of $events
if (isset($link_id) && $link_id < sizeof($events))
{
$message = $user->lang['EVENT_UPDATED'];
$events[$link_id] = array(
'title' => $event_title,
'desc' => $event_desc,
'start_time' => $event_start,
'end_time' => $event_end,
'permission' => $event_permission,
'url' => htmlspecialchars_decode($event_url),
);
/*
* this is what the events array should look like
$events[0] = array(
'title' => '',
'desc' => '',
'start_time' => '',
'end_time' => '',
'permission' => '',
'url' => '', // optional
);*/
add_log('admin', 'LOG_PORTAL_EVENT_UPDATED', $link_title);
}
else
{
$message = $user->lang['EVENT_ADDED'];
$events[] = array(
'title' => $event_title,
'desc' => $event_desc,
'start_time' => $start_time,
'end_time' => $end_time,
'permission' => $event_permission,
'url' => $event_url, // optional
);
add_log('admin', 'LOG_PORTAL_EVENT_ADDED', $event_title);
}
$board3_events_array = serialize($events);
set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array);
trigger_error($message . adm_back_link($u_action));
break;
// Delete link
case 'delete':
if (!isset($link_id) && $link_id >= sizeof($events))
{
trigger_error($user->lang['NO_EVENT'] . adm_back_link($u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$cur_event_title = $events[$link_id]['title'];
// delete the selected link and reset the array numbering afterwards
array_splice($events, $link_id, 1);
$events = array_merge($events);
$board3_events_array = serialize($events);
set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array);
add_log('admin', 'LOG_PORTAL_EVENT_REMOVED', $cur_event_title);
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'link_id' => $link_id,
'action' => 'delete',
)));
}
break;
// Edit or add menu item
case 'edit':
case 'add':
$template->assign_vars(array(
'EVENT_TITLE' => (isset($events[$link_id]['title']) && $action != 'add') ? $events[$link_id]['title'] : '',
'LINK_URL' => (isset($events[$link_id]['url']) && $action != 'add') ? str_replace('&', '&amp;', $events[$link_id]['url']) : '',
//'U_BACK' => $u_action,
'U_ACTION' => $u_action . '&amp;id=' . $link_id,
'S_EDIT' => true,
));
$groups_ary = (isset($events[$link_id]['permission'])) ? explode(',', $events[$link_id]['permission']) : array();
// get group info from database and assign the block vars
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('permission_setting', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'],
));
}
$db->sql_freeresult($result);
return;
break;
}
for ($i = 0; $i < sizeof($events); $i++)
{
$template->assign_block_vars('events', array(
'EVENT_TITLE' => ($action != 'add') ? ((isset($user->lang[$events[$i]['title']])) ? $user->lang[$events[$i]['title']] : $events[$i]['title']) : '',
'EVENT_DESC' => ($action != 'add') ? $events[$i]['desc'] : '',
'EVENT_URL' => ($action != 'add') ? str_replace('&', '&amp;', $events[$i]['url']) : '',
'EVENT_START' => ($action != 'add') ? $user->format_date($events[$i]['start_time'], 'j. M Y, H:i') : '',
'EVENT_END' => ($action != 'add' && ($events[$i]['end_time'] - $events[$i]['start_time']) != 1) ? $user->format_date($events[$i]['end_time'], 'j. M Y, H:i') : '',
'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i,
'U_DELETE' => $u_action . '&amp;action=delete&amp;id=' . $i,
'EVENT_ALL_DAY' => ($events[$i]['end_time'] - $events[$i]['start_time']) ? true : false,
));
}
}
function update_events($key, $module_id)
{
$this->manage_events('', $key, $module_id);
}
var $dateYYY; // year in numeric format (YYYY) var $dateYYY; // year in numeric format (YYYY)
var $dateMM; // month in numeric format (MM) var $dateMM; // month in numeric format (MM)
var $dateDD; // day in numeric format (DD) var $dateDD; // day in numeric format (DD)

View File

@@ -51,6 +51,7 @@
<li><span style="float:left;" class="gensmall"><strong>{L_NO_CUR_EVENTS}</strong></span><br /></li> <li><span style="float:left;" class="gensmall"><strong>{L_NO_CUR_EVENTS}</strong></span><br /></li>
<!-- END cur_events --> <!-- END cur_events -->
</ul> </ul>
<hr style="margin: 10px 0; border-top: 0;" />
<div class="menutitle" style="font: bold 12px 'Trebuchet MS','Lucida Grande',Arial,sans-serif; text-decoration: underline;">{L_UPCOMING_EVENTS}:</div> <div class="menutitle" style="font: bold 12px 'Trebuchet MS','Lucida Grande',Arial,sans-serif; text-decoration: underline;">{L_UPCOMING_EVENTS}:</div>
<ul> <ul>
<!-- BEGIN upcoming_events --> <!-- BEGIN upcoming_events -->