aboutsummaryrefslogtreecommitdiffstats
path: root/mod/events.php
diff options
context:
space:
mode:
authorhabeascodice <habeascodice@federated.social>2014-11-01 03:04:11 -0700
committerhabeascodice <habeascodice@federated.social>2014-11-01 03:04:11 -0700
commit31376de0665091f2dba04755562ccd238d57a13c (patch)
treeae59c8697b9fd20c33aeaf8acb3a698b63e9657b /mod/events.php
parentc854f8c238da2df08b52249142ad24ef66e422d1 (diff)
parent50c16c394fe2d966c62d30930600212a4e33303e (diff)
downloadvolse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.tar.gz
volse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.tar.bz2
volse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'mod/events.php')
-rwxr-xr-xmod/events.php53
1 files changed, 27 insertions, 26 deletions
diff --git a/mod/events.php b/mod/events.php
index c80d1dd39..513899308 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -12,24 +12,14 @@ function events_post(&$a) {
return;
$event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
+ $event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : '');
+
$xchan = ((x($_POST,'xchan')) ? dbesc($_POST['xchan']) : '');
$uid = local_user();
$start_text = escape_tags($_REQUEST['start_text']);
$finish_text = escape_tags($_REQUEST['finish_text']);
- $startyear = intval($_POST['startyear']);
- $startmonth = intval($_POST['startmonth']);
- $startday = intval($_POST['startday']);
- $starthour = intval($_POST['starthour']);
- $startminute = intval($_POST['startminute']);
-
- $finishyear = intval($_POST['finishyear']);
- $finishmonth = intval($_POST['finishmonth']);
- $finishday = intval($_POST['finishday']);
- $finishhour = intval($_POST['finishhour']);
- $finishminute = intval($_POST['finishminute']);
-
$adjust = intval($_POST['adjust']);
$nofinish = intval($_POST['nofinish']);
@@ -79,17 +69,22 @@ function events_post(&$a) {
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
- if(strcmp($finish,$start) < 0)
- $finish = $start;
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
$location = escape_tags(trim($_POST['location']));
$type = 'event';
+ $action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
+ $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
+ if(strcmp($finish,$start) < 0 && !$nofinish) {
+ notice( t('Event can not end before it has started.') . EOL);
+ goaway($onerror_url);
+ }
+
if((! $summary) || (! $start)) {
notice( t('Event title and start time are required.') . EOL);
- goaway($a->get_baseurl() . '/events/new');
+ goaway($onerror_url);
}
$share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0);
@@ -460,6 +455,19 @@ function events_content(&$a) {
$channel = $a->get_channel();
+ // Passed parameters overrides anything found in the DB
+ if($mode === 'edit' || $mode === 'new') {
+ if(!x($orig_event)) $orig_event = array();
+ // In case of an error the browser is redirected back here, with these parameters filled in with the previous values
+ if(x($_REQUEST,'nofinish')) $orig_event['nofinish'] = $_REQUEST['nofinish'];
+ if(x($_REQUEST,'adjust')) $orig_event['adjust'] = $_REQUEST['adjust'];
+ if(x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary'];
+ if(x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description'];
+ if(x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location'];
+ if(x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start'];
+ if(x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish'];
+ }
+
if($mode === 'edit' || $mode === 'new') {
$n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
@@ -530,11 +538,6 @@ function events_content(&$a) {
}
}
-
-
- $dateformat = datesel_format($f);
- $timeformat = t('hour:minute');
-
require_once('include/acl_selectors.php');
$perm_defaults = array(
@@ -552,26 +555,23 @@ function events_content(&$a) {
'$eid' => $eid,
'$xchan' => $event_xchan,
'$mid' => $mid,
+ '$event_hash' => $event_id,
'$title' => t('Event details'),
- '$format_desc' => sprintf( t('Format is %s %s.'),$dateformat,$timeformat),
'$desc' => t('Starting date and Title are required.'),
'$catsenabled' => $catsenabled,
'$placeholdercategory' => t('Categories (comma-separated list)'),
'$category' => $category,
'$s_text' => t('Event Starts:') . ' <span class="required" title="' . t('Required') . '">*</span>',
- '$bootstrap' => 1,
'$stext' => $stext,
'$ftext' => $ftext,
'$ModalCANCEL' => t('Cancel'),
'$ModalOK' => t('OK'),
- '$s_dsel' => datesel($f,'start',$syear+5,$syear,false,$syear,$smonth,$sday),
- '$s_tsel' => timesel('start',$shour,$sminute),
+ '$s_dsel' => datetimesel($f,mktime(),mktime(0,0,0,0,0,$syear+5),mktime($shour,$sminute,$ssecond,$smonth,$sday,$syear),'start_text'),
'$n_text' => t('Finish date/time is not known or not relevant'),
'$n_checked' => $n_checked,
'$f_text' => t('Event Finishes:'),
- '$f_dsel' => datesel($f,'finish',$fyear+5,$fyear,false,$fyear,$fmonth,$fday),
- '$f_tsel' => timesel('finish',$fhour,$fminute),
+ '$f_dsel' => datetimesel($f,mktime(),mktime(0,0,0,0,0,$fyear+5),mktime($fhour,$fminute,$fsecond,$fmonth,$fday,$fyear),'finish_text',true,true,'start_text'),
'$a_text' => t('Adjust for viewer timezone'),
'$a_checked' => $a_checked,
'$d_text' => t('Description:'),
@@ -582,6 +582,7 @@ function events_content(&$a) {
'$t_orig' => $t_orig,
'$sh_text' => t('Share this event'),
'$sh_checked' => $sh_checked,
+ '$permissions' => t('Permissions'),
'$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults),false)),
'$submit' => t('Submit')