diff options
author | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2015-08-23 15:54:46 +0200 |
---|---|---|
committer | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2015-08-23 15:54:46 +0200 |
commit | 092e7378cdaeefaa7b4a954bd865bba1960f01aa (patch) | |
tree | 43a01ef991aae0e394d6c0645f84cbc7b856f972 /mod | |
parent | e50e68719155c7d35e30bb203a403854f789d5a1 (diff) | |
parent | 2a59392ba8be974a5deec2e6f15959fde21186ea (diff) | |
download | volse-hubzilla-092e7378cdaeefaa7b4a954bd865bba1960f01aa.tar.gz volse-hubzilla-092e7378cdaeefaa7b4a954bd865bba1960f01aa.tar.bz2 volse-hubzilla-092e7378cdaeefaa7b4a954bd865bba1960f01aa.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mod')
-rw-r--r-- | mod/editpost.php | 6 | ||||
-rwxr-xr-x | mod/events.php | 61 | ||||
-rw-r--r-- | mod/oexchange.php | 2 | ||||
-rw-r--r-- | mod/ping.php | 2 | ||||
-rw-r--r-- | mod/rpost.php | 2 | ||||
-rw-r--r-- | mod/tasks.php | 107 | ||||
-rw-r--r-- | mod/urlinfo.php (renamed from mod/parse_url.php) | 10 | ||||
-rw-r--r-- | mod/wall_attach.php | 1 |
8 files changed, 171 insertions, 20 deletions
diff --git a/mod/editpost.php b/mod/editpost.php index 235ae9def..daca7c154 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -32,6 +32,12 @@ function editpost_content(&$a) { return; } + if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) { + goaway(z_root() . '/events/event/' . $itm[0]['resource_id']); + } + + + $plaintext = true; // if(feature_enabled(local_channel(),'richtext')) // $plaintext = false; diff --git a/mod/events.php b/mod/events.php index c2bacfe44..15fed9df2 100755 --- a/mod/events.php +++ b/mod/events.php @@ -8,7 +8,7 @@ require_once('include/items.php'); function events_post(&$a) { - logger('post: ' . print_r($_REQUEST,true)); + logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA); if(! local_channel()) return; @@ -89,14 +89,14 @@ function events_post(&$a) { $summary = escape_tags(trim($_POST['summary'])); $desc = escape_tags(trim($_POST['desc'])); $location = escape_tags(trim($_POST['location'])); - $type = 'event'; + $type = escape_tags(trim($_POST['type'])); require_once('include/text.php'); linkify_tags($a, $desc, local_channel()); 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"; + $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"; if(strcmp($finish,$start) < 0 && !$nofinish) { notice( t('Event can not end before it has started.') . EOL); if(intval($_REQUEST['preview'])) { @@ -228,6 +228,27 @@ function events_post(&$a) { function events_content(&$a) { + if(argc() > 2 && argv(1) == 'ical') { + $event_id = argv(2); + + require_once('include/security.php'); + $sql_extra = permissions_sql(local_channel()); + + $r = q("select * from event where event_hash = '%s' $sql_extra limit 1", + dbesc($event_id) + ); + if($r) { + header('Content-type: text/calendar'); + header('content-disposition: attachment; filename="' . t('event') . '-' . $event_id . '.ics"' ); + echo ical_wrapper($r); + killme(); + } + else { + notice( t('Event not found.') . EOL ); + return; + } + } + if(! local_channel()) { notice( t('Permission denied.') . EOL); return; @@ -306,6 +327,10 @@ function events_content(&$a) { killme(); } + + + + if($mode == 'view') { @@ -366,8 +391,18 @@ function events_content(&$a) { intval(local_channel()), intval($_GET['id']) ); - } else { - + } elseif($export) { + $r = q("SELECT * from event where uid = %d + AND (( `adjust` = 0 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' ) + OR ( `adjust` = 1 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' )) ", + intval(local_channel()), + dbesc($start), + dbesc($finish), + dbesc($adjust_start), + dbesc($adjust_finish) + ); + } + else { // fixed an issue with "nofinish" events not showing up in the calendar. // There's still an issue if the finish date crosses the end of month. // Noting this for now - it will need to be fixed here and in Friendica. @@ -384,17 +419,19 @@ function events_content(&$a) { dbesc($adjust_start), dbesc($adjust_finish) ); - } + $links = array(); - if($r) { + if($r && ! $export) { xchan_query($r); $r = fetch_post_tags($r,true); $r = sort_by_date($r); + } + if($r) { foreach($r as $rr) { $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); if(! x($links,$j)) @@ -402,7 +439,6 @@ function events_content(&$a) { } } - $events=array(); $last_date = ''; @@ -547,9 +583,7 @@ function events_content(&$a) { 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') { + 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" ' : ''); @@ -568,9 +602,6 @@ function events_content(&$a) { 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'); @@ -596,6 +627,7 @@ function events_content(&$a) { $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) @@ -635,6 +667,7 @@ function events_content(&$a) { $o .= replace_macros($tpl,array( '$post' => $a->get_baseurl() . '/events', '$eid' => $eid, + '$type' => $type, '$xchan' => $event_xchan, '$mid' => $mid, '$event_hash' => $event_id, diff --git a/mod/oexchange.php b/mod/oexchange.php index a684bd5d8..867cea6f2 100644 --- a/mod/oexchange.php +++ b/mod/oexchange.php @@ -47,7 +47,7 @@ function oexchange_content(&$a) { $tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags'])) ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : ''); - $ret = z_fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags); + $ret = z_fetch_url($a->get_baseurl() . '/urlinfo?f=&url=' . $url . $title . $description . $tags); if($ret['success']) $s = $ret['body']; diff --git a/mod/ping.php b/mod/ping.php index 719183388..394dbf089 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -321,6 +321,7 @@ function ping_init(&$a) { $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 + and type in ( 'event', 'birthday' ) ORDER BY `start` DESC LIMIT 1000", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), @@ -439,6 +440,7 @@ function ping_init(&$a) { if($vnotify & (VNOTIFY_EVENT|VNOTIFY_EVENTTODAY|VNOTIFY_BIRTHDAY)) { $events = q("SELECT type, start, adjust FROM `event` WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 + and type in ( 'event', 'birthday' ) ORDER BY `start` ASC ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), diff --git a/mod/rpost.php b/mod/rpost.php index 0c0916646..4a6b87cc6 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -102,7 +102,7 @@ function rpost_content(&$a) { ); if($_REQUEST['url']) { - $x = z_fetch_url(z_root() . '/parse_url?f=&url=' . urlencode($_REQUEST['url'])); + $x = z_fetch_url(z_root() . '/urlinfo?f=&url=' . urlencode($_REQUEST['url'])); if($x['success']) $_REQUEST['body'] = $_REQUEST['body'] . $x['body']; } diff --git a/mod/tasks.php b/mod/tasks.php new file mode 100644 index 000000000..ed267cc92 --- /dev/null +++ b/mod/tasks.php @@ -0,0 +1,107 @@ +<?php + +require_once('include/event.php'); + + +function tasks_init(&$a) { + + +// logger('request: ' . print_r($_REQUEST,true)); + + $arr = array(); + + if(argc() > 1 && argv(1) === 'fetch') { + if(argc() > 2 && argv(2) === 'all') + $arr['all'] = 1; + + $x = tasks_fetch($arr); + if($x['tasks']) { + $x['html'] = ''; + foreach($x['tasks'] as $y) { + $x['html'] .= '<div class="tasklist-item"><input type="checkbox" onchange="taskComplete(' . $y['id'] . '); return false;" /> ' . $y['summary'] . '</div>'; + } + } + json_return_and_die($x); + } + +} + + + +function tasks_post(&$a) { + + +// logger('post: ' . print_r($_POST,true)); + + + if(! local_channel()) + return; + + $channel = $a->get_channel(); + + if((argc() > 2) && (argv(1) === 'complete') && intval(argv(2))) { + $ret = array('success' => false); + $r = q("select * from event where `type` = 'task' and uid = %d and id = %d limit 1", + intval(local_channel()), + intval(argv(2)) + ); + if($r) { + $event = $r[0]; + if($event['event_status'] === 'COMPLETED') { + $event['event_status'] = 'IN-PROCESS'; + $event['event_status_date'] = NULL_DATE; + $event['event_percent'] = 0; + $event['event_sequence'] = $event['event_sequence'] + 1; + $event['edited'] = datetime_convert(); + } + else { + $event['event_status'] = 'COMPLETED'; + $event['event_status_date'] = datetime_convert(); + $event['event_percent'] = 100; + $event['event_sequence'] = $event['event_sequence'] + 1; + $event['edited'] = datetime_convert(); + } + $x = event_store_event($event); + if($x) + $ret['success'] = true; + } + json_return_and_die($ret); + } + + if(argc() == 2 && argv(1) === 'new') { + $text = escape_tags(trim($_REQUEST['summary'])); + if(! $text) + return array('success' => false); + $event = array(); + $event['aid'] = $channel['channel_account_id']; + $event['uid'] = $channel['channel_id']; + $event['event_xchan'] = $channel['channel_hash']; + $event['type'] = 'task'; + $event['nofinish'] = true; + $event['created'] = $event['edited'] = $event['start'] = datetime_convert(); + $event['adjust'] = 1; + $event['allow_cid'] = '<' . $channel['channel_hash'] . '>'; + $event['summary'] = escape_tags($_REQUEST['summary']); + $x = event_store_event($event); + if($x) + $x['success'] = true; + else + $x = array('success' => false); + json_return_and_die($x); + } + + +} + + + + + +function tasks_content(&$a) { + + if(! local_channel()) + return; + + + return ''; +}
\ No newline at end of file diff --git a/mod/parse_url.php b/mod/urlinfo.php index 2a6f7663e..6b9be3f6f 100644 --- a/mod/parse_url.php +++ b/mod/urlinfo.php @@ -220,7 +220,9 @@ function arr_add_hashes(&$item,$k) { $item = '#' . $item; } -function parse_url_content(&$a) { +function urlinfo_content(&$a) { + + logger('urlinfo: ' . print_r($_REQUEST,true)); $text = null; $str_tags = ''; @@ -251,7 +253,7 @@ function parse_url_content(&$a) { } } - logger('parse_url: ' . $url); + logger('urlinfo: ' . $url); $result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true)); if($result['success']) { @@ -315,7 +317,7 @@ function parse_url_content(&$a) { $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags; - logger('parse_url (unparsed): returns: ' . $result); + logger('urlinfo (unparsed): returns: ' . $result); echo $result; killme(); @@ -374,7 +376,7 @@ function parse_url_content(&$a) { $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags; - logger('parse_url: returns: ' . $result, LOGGER_DEBUG); + logger('urlinfo: returns: ' . $result, LOGGER_DEBUG); echo trim($result); killme(); diff --git a/mod/wall_attach.php b/mod/wall_attach.php index f08f931c2..8677c2b83 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -52,6 +52,7 @@ function wall_attach_post(&$a) { echo "\n\n" . $r['body'] . "\n\n"; if($using_api) return; + killme(); } echo "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n"; killme(); |