diff --git a/doc/roadmapv4.bb b/doc/roadmapv4.bb
index 4670c73b3..33a3384c5 100644
--- a/doc/roadmapv4.bb
+++ b/doc/roadmapv4.bb
@@ -24,4 +24,6 @@ Abstraction of nomadic identity so that sending/receiving to/from singleton netw
CalDAV/CardDAV
-E-Commerce
\ No newline at end of file
+E-Commerce
+
+Auto Updater
\ No newline at end of file
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 512e12838..8be99d91e 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -346,6 +346,7 @@ class Item extends BaseObject {
'owner_photo' => $this->get_owner_photo(),
'owner_name' => $this->get_owner_name(),
'photo' => $body['photo'],
+ 'event' => $body['event'],
'has_tags' => $has_tags,
// Item toolbar buttons
diff --git a/include/conversation.php b/include/conversation.php
index 2c447acbc..3b534dc69 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -697,6 +697,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
'thumb' => $profile_avatar,
'title' => $item['title'],
'body' => $body['html'],
+ 'event' => $body['event'],
'photo' => $body['photo'],
'tags' => $body['tags'],
'categories' => $body['categories'],
diff --git a/include/datetime.php b/include/datetime.php
index 63287d023..f7df70a36 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -153,7 +153,7 @@ function dob($dob) {
* id and name of datetimepicker (defaults to "datetimepicker")
*/
function datesel($format, $min, $max, $default, $id = 'datepicker') {
- return datetimesel($format, $min, $max, $default, $id,true, false, '', '');
+ return datetimesel($format, $min, $max, $default, '', $id,true, false, '', '');
}
/**
@@ -168,7 +168,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') {
* id and name of datetimepicker (defaults to "timepicker")
*/
function timesel($format, $h, $m, $id='timepicker') {
- return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),$id,false,true);
+ return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),'', $id,false,true);
}
/**
@@ -198,7 +198,7 @@ function timesel($format, $h, $m, $id='timepicker') {
* @todo Once browser support is better this could probably be replaced with
* native HTML5 date picker.
*/
-function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) {
+function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) {
$o = '';
$dateformat = '';
@@ -207,11 +207,11 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
if($pickdate && $picktime) $dateformat .= ' ';
if($picktime) $dateformat .= 'H:i';
- $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : '';
- $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : '';
+ $minjs = $min->getTimestamp() ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : '';
+ $maxjs = $max->getTimestamp() ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : '';
- $input_text = $default ? 'value="' . date($dateformat, $default->getTimestamp()) . '"' : '';
- $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : '';
+ $input_text = $default->getTimestamp() ? date($dateformat, $default->getTimestamp()) : '';
+ $defaultdatejs = $default->getTimestamp() ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : '';
$pickers = '';
if(!$pickdate) $pickers .= ',datepicker: false';
@@ -219,10 +219,10 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$extra_js = '';
if($minfrom != '')
- $extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
+ $extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
if($maxfrom != '')
- $extra_js .= "\$('#$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
+ $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
$readable_format = $dateformat;
$readable_format = str_replace('Y','yyyy',$readable_format);
@@ -231,10 +231,11 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$readable_format = str_replace('H','HH',$readable_format);
$readable_format = str_replace('i','MM',$readable_format);
- $o .= "
";
- $o .= (($required) ? '*' : '');
- $o .= '
';
- $o .= "";
+ $tpl = get_markup_template('field_input.tpl');
+ $o .= replace_macros($tpl,array(
+ '$field' => array($id, $label, $input_text, (($required) ? t('Required') : ''), (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'),
+ ));
+ $o .= "";
return $o;
}
diff --git a/include/event.php b/include/event.php
index e303ad232..539bfe484 100644
--- a/include/event.php
+++ b/include/event.php
@@ -21,35 +21,37 @@ function format_event_html($ev) {
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM
+ //todo: move this to template
+
$o = '' . "\r\n";
- $o .= '
' . bbcode($ev['summary']) . '
' . "\r\n";
+ $o .= '
' . bbcode($ev['summary']) . '
' . "\r\n";
- $o .= '
' . bbcode($ev['description']) . '
' . "\r\n";
-
- $o .= '
' . t('Starts:') . ' ' . t('Starts:') . ' '
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)))
- . '
' . "\r\n";
+ . '
' . "\r\n";
if(! $ev['nofinish'])
- $o .= '' . t('Finishes:') . ' ' . t('Finishes:') . ' '
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )))
- . '
' . "\r\n";
+ . '' . "\r\n";
+
+ $o .= '' . bbcode($ev['description']) . '
' . "\r\n";
if(strlen($ev['location']))
- $o .= ' ' . t('Location:') . ' '
+ $o .= ' ' . t('Location:') . ' '
. bbcode($ev['location'])
- . '' . "\r\n";
+ . '
' . "\r\n";
$o .= '' . "\r\n";
@@ -785,6 +787,12 @@ function event_store_item($arr, $event) {
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $r[0]['resource_id'],
'title' => $arr['summary'],
+ 'start' => $arr['start'],
+ 'finish' => $arr['finish'],
+ 'nofinish' => $arr['nofinish'],
+ 'description' => $arr['description'],
+ 'location' => $arr['location'],
+ 'adjust' => $arr['adjust'],
'content' => format_event_bbcode($arr),
'author' => array(
'name' => $r[0]['xchan_name'],
@@ -887,7 +895,7 @@ function event_store_item($arr, $event) {
$item_arr['verb'] = ACTIVITY_POST;
$item_arr['item_wall'] = $item_wall;
$item_arr['item_origin'] = $item_origin;
- $item_arr['item_thread_top'] = $item_thread_top;;
+ $item_arr['item_thread_top'] = $item_thread_top;
$attach = array(array(
'href' => z_root() . '/events/ical/' . urlencode($event['event_hash']),
@@ -924,6 +932,12 @@ function event_store_item($arr, $event) {
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $event['event_hash'],
'title' => $arr['summary'],
+ 'start' => $arr['start'],
+ 'finish' => $arr['finish'],
+ 'nofinish' => $arr['nofinish'],
+ 'description' => $arr['description'],
+ 'location' => $arr['location'],
+ 'adjust' => $arr['adjust'],
'content' => format_event_bbcode($arr),
'author' => array(
'name' => $x[0]['xchan_name'],
diff --git a/include/text.php b/include/text.php
index eb9171b40..f40d67f23 100644
--- a/include/text.php
+++ b/include/text.php
@@ -5,6 +5,7 @@
require_once("include/template_processor.php");
require_once("include/smarty.php");
+require_once("include/bbcode.php");
// random string, there are 86 characters max in text mode, 128 for hex
// output is urlsafe
@@ -1413,9 +1414,55 @@ function prepare_body(&$item,$attach = false) {
}
}
+ $event = array();
+ $is_event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? true : false);
+
+ if($is_event) {
+ $object = json_decode($item['object'],true);
+
+ //ensure compatibility with older items
+ if(array_key_exists('description', $object)) {
+
+ $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM
+
+ $event['header'] = ' ' . bbcode($object['title']) . '
' . "\r\n";
+
+ $event['header'] .= '' . t('Starts:') . ' '
+ . (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
+ $object['start'] , $bd_format ))
+ : day_translate(datetime_convert('UTC', 'UTC',
+ $object['start'] , $bd_format)))
+ . '
' . "\r\n";
+
+ if(! $object['nofinish'])
+ $event['header'] .= '' . t('Finishes:') . ' '
+ . (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
+ $object['finish'] , $bd_format ))
+ : day_translate(datetime_convert('UTC', 'UTC',
+ $object['finish'] , $bd_format )))
+ . '
' . "\r\n";
+
+
+ $event['content'] = '' . bbcode($object['description']) . '
' . "\r\n";
+
+ if(strlen($object['location']))
+ $event['content'] .= ' ' . t('Location:') . ' '
+ . bbcode($object['location'])
+ . '
' . "\r\n";
+ }
+ else {
+ $is_event = false;
+ }
+ }
+
$prep_arr = array(
'item' => $item,
- 'html' => $s,
+ 'html' => $is_event ? $event['content'] : $s,
+ 'event' => $event['header'],
'photo' => $photo
);
@@ -1423,6 +1470,7 @@ function prepare_body(&$item,$attach = false) {
$s = $prep_arr['html'];
$photo = $prep_arr['photo'];
+ $event = $prep_arr['event'];
// q("update item set html = '%s' where id = %d",
// dbesc($s),
@@ -1489,6 +1537,7 @@ function prepare_body(&$item,$attach = false) {
'item' => $item,
'photo' => $photo,
'html' => $s,
+ 'event' => $event,
'categories' => $categories,
'folders' => $filer,
'tags' => $tags,
diff --git a/mod/editpost.php b/mod/editpost.php
index bd46ac14a..030d8d671 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -33,7 +33,7 @@ function editpost_content(&$a) {
}
if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) {
- goaway(z_root() . '/events/event/' . $itm[0]['resource_id']);
+ goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1');
}
diff --git a/mod/events.php b/mod/events.php
index 7220a3d42..64d7dfb93 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -91,7 +91,11 @@ function events_post(&$a) {
linkify_tags($a, $location, local_channel());
$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&type=$type";
+
+ //fixme: this url gives a wsod if there is a linebreak detected in one of the variables ($desc or $location)
+ //$onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish&type=$type";
+ $onerror_url = $a->get_baseurl() . "/events";
+
if(strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
if(intval($_REQUEST['preview'])) {
@@ -166,7 +170,7 @@ function events_post(&$a) {
'otype' => TERM_OBJ_POST,
'term' => trim($cat),
'url' => $channel['xchan_url'] . '?f=&cat=' . urlencode(trim($cat))
- );
+ );
}
}
@@ -273,25 +277,17 @@ function events_content(&$a) {
);
}
-
- $plaintext = true;
-
-// if(feature_enabled(local_channel(),'richtext'))
-// $plaintext = false;
-
-
$first_day = get_pconfig(local_channel(),'system','cal_first_day');
$first_day = (($first_day) ? $first_day : 0);
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array(
'$baseurl' => $a->get_baseurl(),
- '$editselect' => (($plaintext) ? 'none' : 'textareas'),
'$lang' => $a->language,
'$first_day' => $first_day
));
- $o ="";
+ $o = '';
$channel = $a->get_channel();
@@ -301,10 +297,6 @@ function events_content(&$a) {
$ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : '');
if(argc() > 1) {
- if(argc() > 2 && argv(1) == 'event') {
- $mode = 'edit';
- $event_id = argv(2);
- }
if(argc() > 2 && argv(1) === 'add') {
$mode = 'add';
$item_id = intval(argv(2));
@@ -313,15 +305,15 @@ function events_content(&$a) {
$mode = 'drop';
$event_id = argv(2);
}
- if(argv(1) === 'new') {
- $mode = 'new';
- $event_id = '';
- }
if(argc() > 2 && intval(argv(1)) && intval(argv(2))) {
$mode = 'view';
$y = intval(argv(1));
$m = intval(argv(2));
}
+ if(argc() <= 2) {
+ $mode = 'view';
+ $event_id = argv(1);
+ }
}
if($mode === 'add') {
@@ -329,13 +321,164 @@ function events_content(&$a) {
killme();
}
-
-
-
-
if($mode == 'view') {
-
-
+
+ /* edit/create form */
+ if($event_id) {
+ $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($event_id),
+ intval(local_channel())
+ );
+ if(count($r))
+ $orig_event = $r[0];
+ }
+
+ $channel = $a->get_channel();
+
+ // Passed parameters overrides anything found in the DB
+ 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(x($_REQUEST,'type')) $orig_event['type'] = $_REQUEST['type'];
+ */
+
+ $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
+ $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : '');
+ $t_orig = ((x($orig_event)) ? $orig_event['summary'] : '');
+ $d_orig = ((x($orig_event)) ? $orig_event['description'] : '');
+ $l_orig = ((x($orig_event)) ? $orig_event['location'] : '');
+ $eid = ((x($orig_event)) ? $orig_event['id'] : 0);
+ $event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']);
+ $mid = ((x($orig_event)) ? $orig_event['mid'] : '');
+
+ if(! x($orig_event))
+ $sh_checked = '';
+ else
+ $sh_checked = ((($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' || (! $orig_event['allow_cid'])) && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
+
+ if($orig_event['event_xchan'])
+ $sh_checked .= ' disabled="disabled" ';
+
+ $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
+
+ $fdt = ((x($orig_event)) ? $orig_event['finish'] : '+1 hour');
+
+ $tz = date_default_timezone_get();
+ if(x($orig_event))
+ $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
+
+// $syear = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'Y') : '0000');
+// $smonth = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'm') : '00');
+// $sday = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'd') : '00');
+
+ $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
+ $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
+ $sday = datetime_convert('UTC', $tz, $sdt, 'd');
+
+// $shour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'H') : '00');
+// $sminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'i') : '00');
+
+ $shour = datetime_convert('UTC', $tz, $sdt, 'H');
+ $sminute = datetime_convert('UTC', $tz, $sdt, 'i');
+
+ $stext = datetime_convert('UTC',$tz,$sdt);
+ $stext = substr($stext,0,14) . "00:00";
+
+// $fyear = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'Y') : '0000');
+// $fmonth = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'm') : '00');
+// $fday = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'd') : '00');
+
+ $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
+ $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
+ $fday = datetime_convert('UTC', $tz, $fdt, 'd');
+
+// $fhour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'H') : '00');
+// $fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : '00');
+
+ $fhour = datetime_convert('UTC', $tz, $fdt, 'H');
+ $fminute = datetime_convert('UTC', $tz, $fdt, 'i');
+
+ $ftext = datetime_convert('UTC',$tz,$fdt);
+ $ftext = substr($ftext,0,14) . "00:00";
+ $type = ((x($orig_event)) ? $orig_event['type'] : 'event');
+
+ $f = get_config('system','event_input_format');
+ if(! $f)
+ $f = 'ymd';
+
+ $catsenabled = feature_enabled(local_channel(),'categories');
+
+ $category = '';
+
+ if($catsenabled && x($orig_event)){
+ $itm = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d limit 1",
+ dbesc($orig_event['event_hash']),
+ intval(local_channel())
+ );
+ $itm = fetch_post_tags($itm);
+ if($itm) {
+ $cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
+ foreach ($cats as $cat) {
+ if(strlen($category))
+ $category .= ', ';
+ $category .= $cat['term'];
+ }
+ }
+ }
+
+ require_once('include/acl_selectors.php');
+
+ $acl = new AccessList($channel);
+ $perm_defaults = $acl->get();
+
+ $tpl = get_markup_template('event_form.tpl');
+
+ $form = replace_macros($tpl,array(
+ '$post' => $a->get_baseurl() . '/events',
+ '$eid' => $eid,
+ '$type' => $type,
+ '$xchan' => $event_xchan,
+ '$mid' => $mid,
+ '$event_hash' => $event_id,
+ '$summary' => array('summary', t('Event Title'), $t_orig, t('Required'), '*'),
+ '$catsenabled' => $catsenabled,
+ '$placeholdercategory' => t('Categories (comma-separated list)'),
+ '$c_text' => t('Category'),
+ '$category' => $category,
+ '$required' => '*',
+ '$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"), t('Start date and time'), 'start_text',true,true,'','',true,$first_day),
+ '$n_text' => t('Finish date and time are not known or not relevant'),
+ '$n_checked' => $n_checked,
+ '$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"), t('Finish date and time'),'finish_text',true,true,'start_text','',false,$first_day),
+ '$nofinish' => array('nofinish', t('Finish date and time are not known or not relevant'), $n_checked, '', array(t('No'),t('Yes')), 'onclick="enableDisableFinishDate();"'),
+ '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked, t('Important for events that happen in a particular place. Not practical for global holidays.'), array(t('No'),t('Yes'))),
+ '$a_text' => t('Adjust for viewer timezone'),
+ '$d_text' => t('Description'),
+ '$d_orig' => $d_orig,
+ '$l_text' => t('Location'),
+ '$l_orig' => $l_orig,
+ '$t_orig' => $t_orig,
+ '$sh_text' => t('Share this event'),
+ '$sh_checked' => $sh_checked,
+ '$share' => array('share', t('Share this event'), $sh_checked, '', array(t('No'),t('Yes'))),
+ '$preview' => t('Preview'),
+ '$permissions' => t('Permission settings'),
+ '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults),false)),
+ '$submit' => t('Submit'),
+ '$advanced' => t('Advanced Options')
+
+ ));
+ /* end edit/create form */
+
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
if(! $y)
@@ -347,7 +490,6 @@ function events_content(&$a) {
if(argc() === 4 && argv(3) === 'export')
$export = true;
-
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
@@ -424,9 +566,6 @@ function events_content(&$a) {
}
-
-
-
$links = array();
if($r && ! $export) {
@@ -469,7 +608,7 @@ function events_content(&$a) {
$last_date = $d;
- $edit = (intval($rr['item_wall']) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null);
+ $edit = array($a->get_baseurl().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','');
$drop = array($a->get_baseurl().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
@@ -524,24 +663,24 @@ function events_content(&$a) {
$o = replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(),
- '$title' => t('Events'),
- '$new_event'=> array($a->get_baseurl().'/events/new',t('New Event'),'',''),
+ '$new_event' => array($a->get_baseurl().'/events/new',t('New Event'),'',''),
'$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
'$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
- '$export' => array($a->get_baseurl()."/events/$y/$m/export",t('Export'),'',''),
- '$calendar' => cal($y,$m,$links, ' eventcal'),
+ '$export' => array($a->get_baseurl()."/events/$y/$m/export",t('Export'),'',''),
+ '$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
- '$upload' => t('Import'),
- '$submit' => t('Submit'),
- '$prev' => t('Previous'),
- '$next' => t('Next'),
- '$today' => t('Today')
+ '$upload' => t('Import'),
+ '$submit' => t('Submit'),
+ '$prev' => t('Previous'),
+ '$next' => t('Next'),
+ '$today' => t('Today'),
+ '$form' => $form,
+ '$expandform' => ((x($_GET,'expandform')) ? true : false),
));
if (x($_GET,'id')){ echo $o; killme(); }
return $o;
-
}
if($mode === 'drop' && $event_id) {
@@ -574,147 +713,4 @@ function events_content(&$a) {
}
}
- if($mode === 'edit' && $event_id) {
- $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1",
- dbesc($event_id),
- intval(local_channel())
- );
- if(count($r))
- $orig_event = $r[0];
- }
-
- $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(x($_REQUEST,'type')) $orig_event['type'] = $_REQUEST['type'];
-
- $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
- $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : '');
- $t_orig = ((x($orig_event)) ? $orig_event['summary'] : '');
- $d_orig = ((x($orig_event)) ? $orig_event['description'] : '');
- $l_orig = ((x($orig_event)) ? $orig_event['location'] : '');
- $eid = ((x($orig_event)) ? $orig_event['id'] : 0);
- $event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']);
- $mid = ((x($orig_event)) ? $orig_event['mid'] : '');
-
- if(! x($orig_event))
- $sh_checked = '';
- else
- $sh_checked = ((($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' || (! $orig_event['allow_cid'])) && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
-
- if($orig_event['event_xchan'])
- $sh_checked .= ' disabled="disabled" ';
-
- $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
- $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
-
- $tz = date_default_timezone_get();
- if(x($orig_event))
- $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
-
- $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
- $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
- $sday = datetime_convert('UTC', $tz, $sdt, 'd');
-
-
- $shour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'H') : 0);
- $sminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'i') : 0);
- $stext = datetime_convert('UTC',$tz,$sdt);
- $stext = substr($stext,0,14) . "00:00";
-
- $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
- $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
- $fday = datetime_convert('UTC', $tz, $fdt, 'd');
-
- $fhour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'H') : 0);
- $fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0);
- $ftext = datetime_convert('UTC',$tz,$fdt);
- $ftext = substr($ftext,0,14) . "00:00";
- $type = ((x($orig_event)) ? $orig_event['type'] : 'event');
-
- $f = get_config('system','event_input_format');
- if(! $f)
- $f = 'ymd';
-
- $catsenabled = feature_enabled(local_channel(),'categories');
-
- $category = '';
-
- if($catsenabled && x($orig_event)){
- $itm = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d limit 1",
- dbesc($orig_event['event_hash']),
- intval(local_channel())
- );
- $itm = fetch_post_tags($itm);
- if($itm) {
- $cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
- foreach ($cats as $cat) {
- if(strlen($category))
- $category .= ', ';
- $category .= $cat['term'];
- }
- }
- }
-
- require_once('include/acl_selectors.php');
-
- $acl = new AccessList($channel);
- $perm_defaults = $acl->get();
-
-
- $tpl = get_markup_template('event_form.tpl');
-
- $o .= replace_macros($tpl,array(
- '$post' => $a->get_baseurl() . '/events',
- '$eid' => $eid,
- '$type' => $type,
- '$xchan' => $event_xchan,
- '$mid' => $mid,
- '$event_hash' => $event_id,
-
- '$title' => t('Event details'),
- '$desc' => t('Starting date and Title are required.'),
- '$catsenabled' => $catsenabled,
- '$placeholdercategory' => t('Categories (comma-separated list)'),
- '$category' => $category,
- '$s_text' => t('Event Starts:'),
- '$stext' => $stext,
- '$ftext' => $ftext,
- '$required' => '*',
- '$ModalCANCEL' => t('Cancel'),
- '$ModalOK' => t('OK'),
- '$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"),'start_text',true,true,'','',true,$first_day),
- '$n_text' => t('Finish date/time is not known or not relevant'),
- '$n_checked' => $n_checked,
- '$f_text' => t('Event Finishes:'),
- '$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"),'finish_text',true,true,'start_text','',false,$first_day),
- '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked, t('Important for events that happen in a particular place. Not practical for global holidays.'),),
- '$a_text' => t('Adjust for viewer timezone'),
- '$d_text' => t('Description:'),
- '$d_orig' => $d_orig,
- '$l_text' => t('Location:'),
- '$l_orig' => $l_orig,
- '$t_text' => t('Title:'),
- '$t_orig' => $t_orig,
- '$sh_text' => t('Share this event'),
- '$sh_checked' => $sh_checked,
- '$preview' => t('Preview'),
- '$permissions' => t('Permissions'),
- '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults),false)),
- '$submit' => t('Submit')
-
- ));
-
- return $o;
- }
}
diff --git a/mod/update_channel.php b/mod/update_channel.php
index 5f4436d59..63a3735ea 100644
--- a/mod/update_channel.php
+++ b/mod/update_channel.php
@@ -39,6 +39,7 @@ function update_channel_content(&$a) {
$replace = "
' . t('[Embedded content - reload page to view]') . '
';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
@@ -50,6 +51,7 @@ function update_channel_content(&$a) {
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
+*/
/**
* reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
diff --git a/mod/update_display.php b/mod/update_display.php
index d41e2e5cb..b448c76ee 100644
--- a/mod/update_display.php
+++ b/mod/update_display.php
@@ -20,7 +20,7 @@ function update_display_content(&$a) {
$pattern = "/
]*) src=\"([^\"]*)\"/";
$replace = "
' . t('[Embedded content - reload page to view]') . '
';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
@@ -32,7 +32,7 @@ function update_display_content(&$a) {
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
-
+*/
echo str_replace("\t",' ',$text);
echo (($_GET['msie'] == 1) ? '' : '');
echo "