From bd3d32384956f8c5c7ca2624c96f47bb66d8958c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 11 Nov 2015 15:09:22 -0800 Subject: run markdown through html purifier for those who insist on mixing html with markdown. --- mod/item.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 5f45a248b..5bf59de26 100644 --- a/mod/item.php +++ b/mod/item.php @@ -473,8 +473,9 @@ function item_post(&$a) { require_once('include/text.php'); if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { require_once('include/bb2diaspora.php'); - $body = escape_tags($body); $body = str_replace("\n",'
', $body); + $body = purify_html($body); + $body = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$body); $body = diaspora2bb($body,true); $body = preg_replace_callback('/\[share(.*?)\]/ism','share_unshield',$body); -- cgit v1.2.3 From 5afe8e5aa116fb288b2ef87c7af3c7e74565d50b Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Thu, 12 Nov 2015 22:10:20 +0100 Subject: Small update to Bluegrid and generic-content-wrapper-styled to dreport --- mod/dreport.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/dreport.php b/mod/dreport.php index c320bf0e6..1ad1eca7c 100644 --- a/mod/dreport.php +++ b/mod/dreport.php @@ -56,7 +56,7 @@ function dreport_content(&$a) { return; } - + $o .= '
'; $o .= '

' . sprintf( t('Delivery report for %1$s'),substr($mid,0,32)) . '...' . '

'; $o .= ''; @@ -121,6 +121,7 @@ function dreport_content(&$a) { $o .= ''; } $o .= '
' . $rr['name'] . '' . escape_tags($rr['dreport_result']) . '' . escape_tags($rr['dreport_time']) . '
'; + $o .= '
'; return $o; @@ -135,4 +136,4 @@ function dreport_gravity_sort($a,$b) { return strcmp($a['name'],$b['name']); } return (($a['gravity'] > $b['gravity']) ? 1 : (-1)); -} \ No newline at end of file +} -- cgit v1.2.3 From 391807b46c3f54eb94b88c253d89d09bc7139989 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 12 Nov 2015 16:45:38 -0800 Subject: small fixes, removed old unused database row, and log more prominently a missing directory server URL --- mod/directory.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 3c230e173..4ab118b17 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -121,6 +121,8 @@ function directory_content(&$a) { } if(! $url) { $directory = find_upstream_directory($dirmode); + if((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url'])) + logger('CRITICAL: No directory server URL'); $url = $directory['url'] . '/dirsearch'; } -- cgit v1.2.3 From 888bf76e4b4c2d4285c0bb28334df6e9af884e16 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 12 Nov 2015 17:47:38 -0800 Subject: allow pdl content --- mod/page.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mod') diff --git a/mod/page.php b/mod/page.php index b635a60f2..ae572ca1e 100644 --- a/mod/page.php +++ b/mod/page.php @@ -131,6 +131,10 @@ function page_content(&$a) { xchan_query($r); $r = fetch_post_tags($r,true); + + if($r[0]['mimetype'] === 'application/x-pdl') + $a->page['pdl_content'] = true; + $o .= prepare_page($r[0]); return $o; -- cgit v1.2.3 From dba38821bc5f3ad9b3a8f4f614d651e98f0b5ec5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 13 Nov 2015 15:28:34 -0800 Subject: superblock enhancements --- mod/siteinfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 2fffccc73..231427290 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -81,8 +81,8 @@ function siteinfo_init(&$a) { 'commit' => $commit, 'url' => z_root(), 'plugins' => $visible_plugins, - 'register_policy' => $register_policy[$a->config['system']['register_policy']], - 'directory_mode' => $directory_mode[$a->config['system']['directory_mode']], + 'register_policy' => $register_policy[get_config('system','register_policy')], + 'directory_mode' => $directory_mode[get_config('system','directory_mode')], 'language' => get_config('system','language'), 'rss_connections' => get_config('system','feed_contacts'), 'expiration' => $site_expire, -- cgit v1.2.3 From 3d80073a0e1e0847cad2e2fbe86aa66a1fbec983 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 18:03:37 -0800 Subject: revert html in markdown for posts, but trim the input before processing the markdown --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 5bf59de26..b66d71797 100644 --- a/mod/item.php +++ b/mod/item.php @@ -473,8 +473,8 @@ function item_post(&$a) { require_once('include/text.php'); if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { require_once('include/bb2diaspora.php'); + $body = escape_tags(trim($body)); $body = str_replace("\n",'
', $body); - $body = purify_html($body); $body = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$body); $body = diaspora2bb($body,true); -- cgit v1.2.3 From fff30b1c3d7030ff63c880c13bcb47e2932cd1b8 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 19:36:17 -0800 Subject: permission issues editing wall-to-wall posts --- mod/editpost.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/editpost.php b/mod/editpost.php index 2f999858f..bd46ac14a 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -21,9 +21,9 @@ function editpost_content(&$a) { return; } - $itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d and author_xchan = '%s' LIMIT 1", + $itm = q("SELECT * FROM `item` WHERE `id` = %d AND ( owner_xchan = '%s' OR author_xchan = '%s' ) LIMIT 1", intval($post_id), - intval(local_channel()), + dbesc(get_observer_hash()), dbesc(get_observer_hash()) ); @@ -37,6 +37,8 @@ function editpost_content(&$a) { } + $owner_uid = $itm[0]['uid']; + $plaintext = true; // if(feature_enabled(local_channel(),'richtext')) @@ -71,14 +73,12 @@ function editpost_content(&$a) { call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); - $channel = $a->get_channel(); - //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); - $voting = feature_enabled(local_channel(),'consensus_tools'); + $voting = feature_enabled($owner_uid,'consensus_tools'); $category = ''; - $catsenabled = ((feature_enabled(local_channel(),'categories')) ? 'categories' : ''); + $catsenabled = ((feature_enabled($owner_uid,'categories')) ? 'categories' : ''); if ($catsenabled){ $itm = fetch_post_tags($itm); @@ -145,7 +145,7 @@ function editpost_content(&$a) { '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', - '$profile_uid' => local_channel(), + '$profile_uid' => $owner_uid, '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), -- cgit v1.2.3 From 6df98f080ba0c9a0309158c1ea5d48f95aae71ee Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 16 Nov 2015 19:17:39 -0800 Subject: fix api/direct_messages/new at least for the json case. We seem to have a missing template for XML --- mod/acl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/acl.php b/mod/acl.php index dc29e3eff..aaf056b60 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -1,6 +1,6 @@ Date: Tue, 17 Nov 2015 20:44:57 -0800 Subject: fix admin plugin hooks --- mod/admin.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index a884b7658..3f1a69ca6 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1042,7 +1042,12 @@ function admin_page_plugins(&$a){ } $admin_form = ''; - if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){ + + $r = q("select * from addon where plugin_admin = 1 and name = '%s' limit 1", + dbesc($plugin) + ); + + if($r) { @require_once("addon/$plugin/$plugin.php"); if(function_exists($plugin.'_plugin_admin')) { $func = $plugin.'_plugin_admin'; -- cgit v1.2.3 From 1f2a408be0310c7f70df2c916424dec1a2e25d6c Mon Sep 17 00:00:00 2001 From: ken restivo Date: Wed, 18 Nov 2015 00:03:59 -0800 Subject: Use provided account_id instead of user's logged in account_id. Necessary for bulk importer. --- mod/import.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/import.php b/mod/import.php index a33cf339b..1b8bc3098 100644 --- a/mod/import.php +++ b/mod/import.php @@ -128,7 +128,7 @@ function import_account(&$a, $account_id) { } else { $r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1", - intval(get_account_id()), + intval($account_id), dbesc($channel['channel_guid']) ); if($r) @@ -166,7 +166,7 @@ function import_account(&$a, $account_id) { if($data['photo']) { require_once('include/photo/photo_driver.php'); - import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],get_account_id(),$channel['channel_id']); + import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],$account_id,$channel['channel_id']); } if(is_array($data['profile'])) @@ -335,7 +335,7 @@ function import_account(&$a, $account_id) { unset($abook['abook_id']); unset($abook['abook_rating']); unset($abook['abook_rating_text']); - $abook['abook_account'] = get_account_id(); + $abook['abook_account'] = $account_id; $abook['abook_channel'] = $channel['channel_id']; if(! array_key_exists('abook_blocked',$abook)) { $abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001 ) ? 1 : 0); -- cgit v1.2.3 From 312cc415cec39f3b7a45f268acda5f0dd2500e3e Mon Sep 17 00:00:00 2001 From: ken restivo Date: Wed, 18 Nov 2015 00:26:18 -0800 Subject: Pass in account_id. Required for bulk identity importer. --- mod/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/import.php b/mod/import.php index 1b8bc3098..02e71233a 100644 --- a/mod/import.php +++ b/mod/import.php @@ -123,7 +123,7 @@ function import_account(&$a, $account_id) { if(array_key_exists('channel',$data)) { if($completed < 1) { - $channel = import_channel($data['channel']); + $channel = import_channel($data['channel'], $account_id); } else { -- cgit v1.2.3 From e4145deeb7a72ac321113fde672e1b499ecb0d2d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 18 Nov 2015 23:50:42 +0100 Subject: some events refacturing --- mod/events.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index d76602a33..230e386ce 100755 --- a/mod/events.php +++ b/mod/events.php @@ -288,14 +288,9 @@ function events_content(&$a) { )); $o =""; - // tabs $channel = $a->get_channel(); - $tabs = profile_tabs($a, True, $channel['channel_address']); - - - $mode = 'view'; $y = 0; $m = 0; @@ -378,10 +373,10 @@ function events_content(&$a) { if (argv(1) === 'json'){ - if (x($_GET,'start')) $start = date("Y-m-d h:i:s", $_GET['start']); - if (x($_GET,'end')) $finish = date("Y-m-d h:i:s", $_GET['end']); + if (x($_GET,'start')) $start = $_GET['start']; + if (x($_GET,'end')) $finish = $_GET['end']; } - + $start = datetime_convert('UTC','UTC',$start); $finish = datetime_convert('UTC','UTC',$finish); @@ -413,18 +408,21 @@ function events_content(&$a) { $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan from event left join item on event_hash = resource_id - where resource_type = 'event' and event.uid = %d $ignored - AND (( `adjust` = 0 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' ) - OR ( `adjust` = 1 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' )) ", + where resource_type = 'event' and event.uid = %d $ignored + 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) ); + } + + $links = array(); if($r && ! $export) { @@ -500,7 +498,7 @@ function events_content(&$a) { } } - + if($export) { header('Content-type: text/calendar'); header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"' ); @@ -522,16 +520,17 @@ function events_content(&$a) { $o = replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), - '$tabs' => $tabs, '$title' => t('Events'), - '$new_event'=> array($a->get_baseurl().'/events/new',t('Create 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'), '$events' => $events, '$upload' => t('Import'), - '$submit' => t('Submit') + '$submit' => t('Submit'), + '$prev' => t('Previous'), + '$next' => t('Next'), )); if (x($_GET,'id')){ echo $o; killme(); } -- cgit v1.2.3 From ba52af786e0e2f27c36e82df9086dfb8d33d9062 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 19 Nov 2015 11:38:34 +0100 Subject: move today button from aside to section title --- mod/events.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 230e386ce..53284e7a9 100755 --- a/mod/events.php +++ b/mod/events.php @@ -530,7 +530,8 @@ function events_content(&$a) { '$upload' => t('Import'), '$submit' => t('Submit'), '$prev' => t('Previous'), - '$next' => t('Next'), + '$next' => t('Next'), + '$today' => t('Today') )); if (x($_GET,'id')){ echo $o; killme(); } -- cgit v1.2.3 From ed87dbc1414b7da2f58213671539c5570a416809 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 19 Nov 2015 11:46:29 -0800 Subject: issue #173 --- mod/subthread.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/subthread.php b/mod/subthread.php index 162545a2f..74d742b6a 100755 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -11,18 +11,24 @@ function subthread_content(&$a) { return; } + $item_id = ((argc() > 2) ? notags(trim(argv(2))) : 0); + if(argv(1) === 'sub') $activity = ACTIVITY_FOLLOW; elseif(argv(1) === 'unsub') $activity = ACTIVITY_UNFOLLOW; - $item_id = ((argc() > 2) ? notags(trim(argv(2))) : 0); - $r = q("SELECT * FROM `item` WHERE `parent` = '%s' OR `parent_mid` = '%s' and parent = id LIMIT 1", - dbesc($item_id), + $r = q("SELECT parent FROM item WHERE id = '%s'", dbesc($item_id) ); + if($r) { + $r = q("select * from item where id = parent and id = %d limit 1", + dbesc($r[0]['parent']) + ); + } + if((! $item_id) || (! $r)) { logger('subthread: no item ' . $item_id); return; -- cgit v1.2.3 From a890ee6864f5a3b727ac558b64f9a208345d9fb7 Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Fri, 20 Nov 2015 00:39:47 +0100 Subject: Some bits --- mod/invite.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/invite.php b/mod/invite.php index 46fa7b413..1af5fc1f8 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -51,7 +51,7 @@ function invite_post(&$a) { } if($invonly && ($x || is_site_admin())) { - $code = autoname(8) . srand(1000,9999); + $code = autoname(8) . rand(1000,9999); $nmessage = str_replace('$invite_code',$code,$message); $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", @@ -143,4 +143,4 @@ function invite_content(&$a) { )); return $o; -} \ No newline at end of file +} -- cgit v1.2.3 From c7652fc29ce2d69a6d71d6d8a928709cbf6ebbb0 Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Fri, 20 Nov 2015 00:50:54 +0100 Subject: Had to switch these 2. Sorry. --- mod/invite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/invite.php b/mod/invite.php index 1af5fc1f8..bda808142 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -51,7 +51,7 @@ function invite_post(&$a) { } if($invonly && ($x || is_site_admin())) { - $code = autoname(8) . rand(1000,9999); + $code = autoname(8) . srand(1000,9999); $nmessage = str_replace('$invite_code',$code,$message); $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", -- cgit v1.2.3 From 8f94c721bffab9f2ee4aeb045fb81a9840013211 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 19 Nov 2015 16:05:47 -0800 Subject: new feature: 'suppress_duplicates' issue #146 triggered with less than two minutes between posts having identical content. --- mod/admin.php | 5 +++-- mod/item.php | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 3f1a69ca6..4b7cb3cd9 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -395,9 +395,10 @@ function admin_page_site(&$a) { } /* Banner */ + $banner = get_config('system', 'banner'); - if($banner == false) - $banner = 'red'; + if($banner === false) + $banner = get_config('system','sitename'); $banner = htmlspecialchars($banner); diff --git a/mod/item.php b/mod/item.php index b66d71797..1e39ca9c9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -703,6 +703,10 @@ function item_post(&$a) { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid; } + + + + $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; @@ -781,6 +785,22 @@ function item_post(&$a) { if($orig_post) $datarray['edit'] = true; + + + if(feature_enabled($profile_uid,'suppress_duplicates')) { + + $z = q("select created from item where uid = %d and body = '%s'", + intval($profile_uid), + dbesc($body) + ); + + if($z && $z[0]['created'] > datetime_convert('UTC','UTC', 'now - 2 minutes')) { + $datarray['cancel'] = 1; + notice( t('Duplicate post suppressed.') . EOL); + logger('Duplicate post. Faking plugin cancel.'); + } + } + call_hooks('post_local',$datarray); if(x($datarray,'cancel')) { -- cgit v1.2.3 From 5805a540973e6110f148d5be7b68c102382a4e12 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 19 Nov 2015 16:44:12 -0800 Subject: directory search for pubforums using hubzilla directory servers using redmatrix flag value --- mod/dirsearch.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 937564a79..548acbd08 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -124,8 +124,6 @@ function dirsearch_content(&$a) { if($keywords) $sql_extra .= dir_query_build($joiner,'xprof_keywords',$keywords); - if($forums) - $safesql .= dir_flag_build(' AND ','xchan_flags',XCHAN_FLAGS_PUBFORUM, $forums); // we only support an age range currently. You must set both agege // (greater than or equal) and agele (less than or equal) @@ -173,6 +171,9 @@ function dirsearch_content(&$a) { if($safe < 0) $safesql = " and ( xchan_censored = 1 OR xchan_selfcensored = 1 ) "; + if($forums) + $safesql .= " and xchan_pubforum = " . ((intval($forums)) ? '1 ' : '0 '); + if($limit) $qlimit = " LIMIT $limit "; else { @@ -185,7 +186,6 @@ function dirsearch_content(&$a) { } } - if($sort_order == 'normal') { $order = " order by xchan_name asc "; @@ -202,6 +202,7 @@ function dirsearch_content(&$a) { else $order = " order by xchan_name_date desc "; + if($sync) { $spkt = array('transactions' => array()); $r = q("select * from updates where ud_date >= '%s' and ud_guid != '' order by ud_date desc", @@ -245,15 +246,20 @@ function dirsearch_content(&$a) { json_return_and_die($spkt); } else { + $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql $order $qlimit " ); + + + $ret['page'] = $page + 1; $ret['records'] = count($r); } + if($r) { $entries = array(); -- cgit v1.2.3 From 301072a86cacd2620a08cf07f2cef55dffac3c2f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 20 Nov 2015 00:15:48 -0800 Subject: issue #85, community tags and file tags lost during edits. This required splitting off communitytags as a separate tag type and is not backward compatible. Community tags on older posts or those federated from redmatrix clones will not be preserved during edits. --- mod/channel.php | 2 +- mod/item.php | 23 +++++++++++++++++++++++ mod/network.php | 4 ++-- mod/search.php | 3 ++- mod/search_ac.php | 5 +++-- mod/tagger.php | 2 +- 6 files changed, 32 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 0af2666cc..2b9d0ed89 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -189,7 +189,7 @@ function channel_content(&$a, $update = 0, $load = false) { $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); } if(x($hashtags)) { - $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG)); + $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); } if($datequery) { diff --git a/mod/item.php b/mod/item.php index 1e39ca9c9..34484eff7 100644 --- a/mod/item.php +++ b/mod/item.php @@ -651,6 +651,29 @@ function item_post(&$a) { } } + if($orig_post) { + // preserve original tags + $t = q("select * from term where oid = %d and otype = %d and uid = %d and type in ( %d, %d, %d )", + intval($orig_post['id']), + intval(TERM_OBJ_POST), + intval($profile_uid), + intval(TERM_UNKNOWN), + intval(TERM_FILE), + intval(TERM_COMMUNITYTAG) + ); + if($t) { + foreach($t as $t1) { + $post_tags[] = array( + 'uid' => $profile_uid, + 'type' => $t1['type'], + 'otype' => TERM_OBJ_POST, + 'term' => $t1['term'], + 'url' => $t1['url'], + ); + } + } + } + $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0); $item_wall = (($post_type === 'wall' || $post_type === 'wall-comment') ? 1 : 0); diff --git a/mod/network.php b/mod/network.php index 53de975a4..9f0604296 100644 --- a/mod/network.php +++ b/mod/network.php @@ -248,7 +248,7 @@ function network_content(&$a, $update = 0, $load = false) { $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); } if(x($hashtags)) { - $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG)); + $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); } if(! $update) { @@ -313,7 +313,7 @@ function network_content(&$a, $update = 0, $load = false) { if(x($_GET,'search')) { $search = escape_tags($_GET['search']); if(strpos($search,'#') === 0) { - $sql_extra .= term_query('item',substr($search,1),TERM_HASHTAG); + $sql_extra .= term_query('item',substr($search,1),TERM_HASHTAG,TERM_COMMUNITYTAG); } else { $sql_extra .= sprintf(" AND item.body like '%s' ", diff --git a/mod/search.php b/mod/search.php index a0085fca9..555d46f6a 100644 --- a/mod/search.php +++ b/mod/search.php @@ -75,9 +75,10 @@ function search_content(&$a,$update = 0, $load = false) { return $o; if($tag) { - $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type = %d and term = '%s') ", + $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type in ( %d , %d) and term = '%s') ", intval(TERM_OBJ_POST), intval(TERM_HASHTAG), + intval(TERM_COMMUNITYTAG), dbesc(protect_sprintf($search)) ); } diff --git a/mod/search_ac.php b/mod/search_ac.php index e42945d43..19c1dc940 100644 --- a/mod/search_ac.php +++ b/mod/search_ac.php @@ -42,8 +42,9 @@ function search_ac_init(&$a){ } } - $r = q("select distinct term, tid, url from term where type = %d $tag_sql_extra group by term order by term asc", - intval(TERM_HASHTAG) + $r = q("select distinct term, tid, url from term where type in ( %d, %d ) $tag_sql_extra group by term order by term asc", + intval(TERM_HASHTAG), + intval(TERM_COMMUNITYTAG) ); if(count($r)) { diff --git a/mod/tagger.php b/mod/tagger.php index 9f9855ed8..27a8a15ea 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -123,7 +123,7 @@ function tagger_content(&$a) { $arr['object'] = $obj; $arr['parent_mid'] = $item['mid']; - store_item_tag($item['uid'],$item['id'],TERM_OBJ_POST,TERM_HASHTAG,$term,$tagid); + store_item_tag($item['uid'],$item['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$term,$tagid); $ret = post_activity_item($arr); if($ret['success']) -- cgit v1.2.3 From a3e47d26f617f06b3f9c8221a5240b3387131ddd Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 20 Nov 2015 16:39:55 +0100 Subject: make calendar language aware --- mod/events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 53284e7a9..c3731bf1c 100755 --- a/mod/events.php +++ b/mod/events.php @@ -280,11 +280,11 @@ function events_content(&$a) { // $plaintext = false; - $htpl = get_markup_template('event_head.tpl'); $a->page['htmlhead'] .= replace_macros($htpl,array( '$baseurl' => $a->get_baseurl(), - '$editselect' => (($plaintext) ? 'none' : 'textareas') + '$editselect' => (($plaintext) ? 'none' : 'textareas'), + '$lang' => $a->language )); $o =""; -- cgit v1.2.3 From 106b4fdd2d4b0cf893d27df7d60085b441f37b9a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 20 Nov 2015 14:38:32 -0800 Subject: add v4 project roadmap, partial fix for cloning of profile photos on alternate profiles --- mod/profile_photo.php | 3 +++ mod/profiles.php | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 7067a9f76..2884505f0 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -6,6 +6,7 @@ */ require_once('include/photo/photo_driver.php'); +require_once('include/identity.php'); /* @brief Function for sync'ing permissions of profile-photos and their profile * @@ -195,6 +196,8 @@ function profile_photo_post(&$a) { ); } + profiles_build_sync(local_channel()); + // We'll set the updated profile-photo timestamp even if it isn't the default profile, // so that browsers will do a cache update unconditionally diff --git a/mod/profiles.php b/mod/profiles.php index 19e5ffc50..282d741ac 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -1,5 +1,6 @@ get_baseurl(true) . '/profiles'); return; // NOTREACHED } @@ -118,7 +125,10 @@ function profiles_init(&$a) { dbesc($name) ); info( t('New profile created.') . EOL); - if(count($r3) == 1) + + profiles_build_sync(local_channel()); + + if(($r3) && (count($r3) == 1)) goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']); goaway($a->get_baseurl(true) . '/profiles'); @@ -193,7 +203,6 @@ function profiles_post(&$a) { $namechanged = false; - call_hooks('profile_post', $_POST); // import from json export file. // Only import fields that are allowed on this hub @@ -220,6 +229,7 @@ function profiles_post(&$a) { } } + call_hooks('profile_post', $_POST); if((argc() > 1) && (argv(1) !== "new") && intval(argv(1))) { @@ -564,8 +574,6 @@ function profiles_post(&$a) { } - - function profiles_content(&$a) { $o = ''; -- cgit v1.2.3 From d726c921eb5902483dfeb82383829e9309f6b65c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 21 Nov 2015 15:33:57 +0100 Subject: make calendar week start (sun or mon) configurable --- mod/events.php | 5 ++++- mod/settings.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index c3731bf1c..af5a9fc66 100755 --- a/mod/events.php +++ b/mod/events.php @@ -280,11 +280,14 @@ function events_content(&$a) { // $plaintext = false; + $first_day = get_pconfig(local_channel(),'system','cal_first_day'); + $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 + '$lang' => $a->language, + '$first_day' => (($first_day) ? $first_day : 0) )); $o =""; diff --git a/mod/settings.php b/mod/settings.php index 9a18d8e48..339f83cfe 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -405,7 +405,6 @@ function settings_post(&$a) { $allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0); - $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted! $unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0); $cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0); @@ -416,6 +415,8 @@ function settings_post(&$a) { $post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0); $adult = (($_POST['adult'] == 1) ? 1 : 0); + $cal_first_day = (((x($_POST,'first_day')) && (intval($_POST['first_day']) == 1)) ? 1: 0); + $channel = $a->get_channel(); $pageflags = $channel['channel_pageflags']; $existing_adult = (($pageflags & PAGE_ADULT) ? 1 : 0); @@ -503,6 +504,7 @@ function settings_post(&$a) { set_pconfig(local_channel(),'system','evdays',$evdays); set_pconfig(local_channel(),'system','photo_path',$photo_path); set_pconfig(local_channel(),'system','attach_path',$attach_path); + set_pconfig(local_channel(),'system','cal_first_day',$cal_first_day); $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d", dbesc($username), @@ -1110,6 +1112,7 @@ function settings_content(&$a) { '$removeme' => t('Remove Channel'), '$removechannel' => t('Remove this channel.'), '$firefoxshare' => t('Firefox Share $Projectname provider'), + '$cal_first_day' => array('first_day', t('Start calendar week on monday'), ((get_pconfig(local_channel(),'system','cal_first_day')) ? 1 : ''), '', $yes_no), )); call_hooks('settings_form',$o); -- cgit v1.2.3 From 74b574d0b1874b0811837d9ac4472f1084800aeb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 21 Nov 2015 23:49:29 +0100 Subject: datetimepicker should also respect first day of week setting --- mod/events.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index af5a9fc66..e07abbf46 100755 --- a/mod/events.php +++ b/mod/events.php @@ -281,13 +281,14 @@ function events_content(&$a) { $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) ? $first_day : 0) + '$first_day' => $first_day )); $o =""; @@ -692,11 +693,11 @@ function events_content(&$a) { '$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), + '$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'), + '$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',$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:'), -- cgit v1.2.3 From 4c84a2ce615be12adfbeb1067b5c6652330027bb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 22 Nov 2015 00:13:33 +0100 Subject: update datetimepicker and fix it for finish date --- mod/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index e07abbf46..7220a3d42 100755 --- a/mod/events.php +++ b/mod/events.php @@ -697,7 +697,7 @@ function events_content(&$a) { '$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',$first_day), + '$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:'), -- cgit v1.2.3 From dfaf1a1075acdeccea5c730611c13db3d61d6277 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 23 Nov 2015 15:27:57 -0800 Subject: issue #183 --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 34484eff7..f32ff8844 100644 --- a/mod/item.php +++ b/mod/item.php @@ -810,7 +810,7 @@ function item_post(&$a) { - if(feature_enabled($profile_uid,'suppress_duplicates')) { + if(feature_enabled($profile_uid,'suppress_duplicates') && (! $orig_post)) { $z = q("select created from item where uid = %d and body = '%s'", intval($profile_uid), -- cgit v1.2.3 From 987619130b99bf4548d5d31ac453cdf48c818eff Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 24 Nov 2015 14:15:28 +0100 Subject: some event heavy lifting - please test and report issues --- mod/editpost.php | 2 +- mod/events.php | 334 ++++++++++++++++++++++++++----------------------------- 2 files changed, 156 insertions(+), 180 deletions(-) (limited to 'mod') 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..fcacacd6f 100755 --- a/mod/events.php +++ b/mod/events.php @@ -166,7 +166,7 @@ function events_post(&$a) { 'otype' => TERM_OBJ_POST, 'term' => trim($cat), 'url' => $channel['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)) - ); + ); } } @@ -273,25 +273,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 +293,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 +301,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() > 1) { + $mode = 'view'; + $event_id = argv(1); + } } if($mode === 'add') { @@ -329,13 +317,148 @@ 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'] : 'now'); + + $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') : '00'); + $smonth = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'm') : '00'); + $sday = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'd') : '00'); + + $shour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'H') : '00'); + $sminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'i') : '00'); + $stext = datetime_convert('UTC',$tz,$sdt); + $stext = substr($stext,0,14) . "00:00"; + + $fyear = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'Y') : '00'); + $fmonth = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'm') : '00'); + $fday = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'd') : '00'); + + $fhour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'H') : '00'); + $fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : '00'); + $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 */ - if($mode == 'view') { - - $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); if(! $y) @@ -347,7 +470,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 +546,6 @@ function events_content(&$a) { } - - - $links = array(); if($r && ! $export) { @@ -469,7 +588,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 +643,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 +693,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; - } } -- cgit v1.2.3 From eb6fd311df6fabd0cc2f97560f3672a5b8e1abf6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 24 Nov 2015 14:25:16 +0100 Subject: fix event droping --- mod/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index fcacacd6f..36527d6c7 100755 --- a/mod/events.php +++ b/mod/events.php @@ -306,7 +306,7 @@ function events_content(&$a) { $y = intval(argv(1)); $m = intval(argv(2)); } - if(argc() > 1) { + if(argc() <= 2) { $mode = 'view'; $event_id = argv(1); } -- cgit v1.2.3 From 0559db9cf81267c34ca014fef1aebe1cf31de2ab Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 24 Nov 2015 15:37:33 -0800 Subject: fix event form initial values --- mod/events.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 36527d6c7..d55d22f44 100755 --- a/mod/events.php +++ b/mod/events.php @@ -372,18 +372,26 @@ function events_content(&$a) { if(x($orig_event)) $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC'); - $syear = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'Y') : '00'); - $smonth = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'm') : '00'); - $sday = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'd') : '00'); +// $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'); $stext = datetime_convert('UTC',$tz,$sdt); $stext = substr($stext,0,14) . "00:00"; - $fyear = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'Y') : '00'); - $fmonth = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'm') : '00'); - $fday = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'd') : '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'); -- cgit v1.2.3 From fe57e7059bc6ef1942a6b054a4da8edfb5a07578 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 25 Nov 2015 15:05:21 +0100 Subject: events: make sure default finish date is one hour after start date and shift the finishdate if startdate is shifted --- mod/events.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index d55d22f44..0366c9b02 100755 --- a/mod/events.php +++ b/mod/events.php @@ -366,7 +366,7 @@ function events_content(&$a) { $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); - $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now'); + $fdt = ((x($orig_event)) ? $orig_event['finish'] : '+1 hour'); $tz = date_default_timezone_get(); if(x($orig_event)) @@ -380,8 +380,12 @@ function events_content(&$a) { $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 = ((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"; @@ -393,8 +397,12 @@ function events_content(&$a) { $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 = ((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'); -- cgit v1.2.3 From 3ea84d7eab20947ac52dc7e6c205252f0a76c047 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 25 Nov 2015 22:55:07 +0100 Subject: some basic event styling --- mod/events.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 0366c9b02..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'])) { -- cgit v1.2.3 From a039869ba0410a35368e978ddfd638b344b17b40 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 25 Nov 2015 17:30:11 -0800 Subject: issue #185 --- mod/update_channel.php | 2 ++ mod/update_display.php | 4 ++-- mod/update_home.php | 4 ++-- mod/update_network.php | 4 ++-- mod/update_public.php | 4 ++-- mod/update_search.php | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) (limited to 'mod') 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 = "'; $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 = "'; $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 "\r\n"; diff --git a/mod/update_home.php b/mod/update_home.php index 80ae2438f..4a8000bdb 100644 --- a/mod/update_home.php +++ b/mod/update_home.php @@ -16,7 +16,7 @@ function update_home_content(&$a) { $pattern = "/]*) src=\"([^\"]*)\"/"; $replace = "'; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; @@ -28,7 +28,7 @@ function update_home_content(&$a) { $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $text = preg_replace($pattern, $replace, $text); } - +*/ echo str_replace("\t",' ',$text); echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '' : ''); echo "\r\n"; diff --git a/mod/update_network.php b/mod/update_network.php index acd5ccdc8..03c12312c 100644 --- a/mod/update_network.php +++ b/mod/update_network.php @@ -18,7 +18,7 @@ function update_network_content(&$a) { $pattern = "/]*) src=\"([^\"]*)\"/"; $replace = "'; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; @@ -30,7 +30,7 @@ function update_network_content(&$a) { $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $text = preg_replace($pattern, $replace, $text); } - +*/ echo str_replace("\t",' ',$text); echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '' : ''); echo "\r\n"; diff --git a/mod/update_public.php b/mod/update_public.php index bac1ccf15..fcec792f6 100644 --- a/mod/update_public.php +++ b/mod/update_public.php @@ -16,7 +16,7 @@ function update_public_content(&$a) { $pattern = "/]*) src=\"([^\"]*)\"/"; $replace = "'; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; @@ -28,7 +28,7 @@ function update_public_content(&$a) { $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $text = preg_replace($pattern, $replace, $text); } - +*/ echo str_replace("\t",' ',$text); echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '' : ''); echo "\r\n"; diff --git a/mod/update_search.php b/mod/update_search.php index de29e89bd..25bcffcb6 100644 --- a/mod/update_search.php +++ b/mod/update_search.php @@ -41,7 +41,7 @@ function update_search_content(&$a) { $pattern = "/]*) src=\"([^\"]*)\"/"; $replace = "'; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; @@ -53,7 +53,7 @@ function update_search_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 */ -- cgit v1.2.3 From 61a5e81bc62d8517a1c7a86249c0a1e9a42fe1d8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 27 Nov 2015 13:55:02 +0100 Subject: only show edit icon for your own events and minoe cleanup --- mod/events.php | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 64d7dfb93..080c39911 100755 --- a/mod/events.php +++ b/mod/events.php @@ -90,7 +90,7 @@ function events_post(&$a) { linkify_tags($a, $desc, local_channel()); linkify_tags($a, $location, local_channel()); - $action = ($event_hash == '') ? 'new' : "event/" . $event_hash; + //$action = ($event_hash == '') ? 'new' : "event/" . $event_hash; //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"; @@ -376,39 +376,24 @@ function events_content(&$a) { 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'); @@ -608,7 +593,7 @@ function events_content(&$a) { $last_date = $d; - $edit = array($a->get_baseurl().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'',''); + $edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array($a->get_baseurl().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false); $drop = array($a->get_baseurl().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); -- cgit v1.2.3 From 4e223f816a15c6faec14ddb4f3aa4e4f122167d9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 28 Nov 2015 17:05:37 +0100 Subject: reflect in form if we are editing or creating --- mod/events.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 080c39911..74b44906c 100755 --- a/mod/events.php +++ b/mod/events.php @@ -434,22 +434,22 @@ function events_content(&$a) { '$xchan' => $event_xchan, '$mid' => $mid, '$event_hash' => $event_id, - '$summary' => array('summary', t('Event Title'), $t_orig, t('Required'), '*'), + '$summary' => array('summary', (($event_id) ? t('Edit event titel') : t('Event titel')), $t_orig, t('Required'), '*'), '$catsenabled' => $catsenabled, '$placeholdercategory' => t('Categories (comma-separated list)'), - '$c_text' => t('Category'), + '$c_text' => (($event_id) ? t('Edit Category') : 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), + '$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"), (($event_id) ? t('Edit start date and time') : 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), + '$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"), (($event_id) ? t('Edit finish date and time') : 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_text' => (($event_id) ? t('Edit Description') : t('Description')), '$d_orig' => $d_orig, - '$l_text' => t('Location'), + '$l_text' => (($event_id) ? t('Edit Location') : t('Location')), '$l_orig' => $l_orig, '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), @@ -648,7 +648,7 @@ function events_content(&$a) { $o = replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), - '$new_event' => array($a->get_baseurl().'/events/new',t('New Event'),'',''), + '$new_event' => array($a->get_baseurl().'/events',(($event_id) ? t('Edit Event') : t('Create 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'),'',''), -- cgit v1.2.3 From 29877963be2f13607976df84e1c88a161714a4a6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 29 Nov 2015 18:07:59 -0800 Subject: issue #189 --- mod/feed.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod') diff --git a/mod/feed.php b/mod/feed.php index 3b622fc17..eb72af9cf 100644 --- a/mod/feed.php +++ b/mod/feed.php @@ -15,6 +15,7 @@ function feed_init(&$a) { $params['start'] = ((x($params,'start')) ? intval($params['start']) : 0); $params['records'] = ((x($params,'records')) ? intval($params['records']) : 40); $params['direction'] = ((x($params,'direction')) ? dbesc($params['direction']) : 'desc'); + $params['cat'] = ((x($_REQUEST,'cat')) ? escape_tags($_REQUEST['cat']) : ''); $channel = ''; if(argc() > 1) { -- cgit v1.2.3 From 3f9412add27ecc225df0e5c23f5c15a4bf4e8971 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 29 Nov 2015 19:37:03 -0800 Subject: create get_site_info() function so we can have a siteinfo.json module instead of or actually in addition to siteinfo/json --- mod/siteinfo.php | 100 ++------------------------------------------------ mod/siteinfo_json.php | 8 ++++ 2 files changed, 11 insertions(+), 97 deletions(-) create mode 100644 mod/siteinfo_json.php (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 231427290..4c5782abe 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -1,104 +1,10 @@ argv[1]=="json"){ - $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'); - $directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_SECONDARY','DIRECTORY_MODE_PRIMARY', 'DIRECTORY_MODE_STANDALONE'); - - $sql_extra = ''; - - $r = q("select * from channel left join account on account_id = channel_account_id where ( account_roles & 4096 )>0 and account_default_channel = channel_id"); - - - if($r) { - $admin = array(); - foreach($r as $rr) { - if($rr['channel_pageflags'] & PAGE_HUBADMIN) - $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']); - } - if(! $admin) { - foreach($r as $rr) { - $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']); - } - } - } - else { - $admin = false; - } - $def_service_class = get_config('system','default_service_class'); - if($def_service_class) - $service_class = get_config('service_class',$def_service_class); - else - $service_class = false; - - $visible_plugins = array(); - if(is_array($a->plugins) && count($a->plugins)) { - $r = q("select * from addon where hidden = 0"); - if(count($r)) - foreach($r as $rr) - $visible_plugins[] = $rr['name']; - } - sort($visible_plugins); - - if(@is_dir('.git') && function_exists('shell_exec')) - $commit = trim(@shell_exec('git log -1 --format="%h"')); - if(! isset($commit) || strlen($commit) > 16) - $commit = ''; - - $site_info = get_config('system','info'); - $site_name = get_config('system','sitename'); - if(! get_config('system','hidden_version_siteinfo')) { - $version = RED_VERSION; - if(@is_dir('.git') && function_exists('shell_exec')) { - $commit = trim( @shell_exec('git log -1 --format="%h"')); - if(! get_config('system','hidden_tag_siteinfo')) - $tag = trim( @shell_exec('git describe --tags --abbrev=0')); - else - $tag = ''; - } - if(! isset($commit) || strlen($commit) > 16) - $commit = ''; - } - else { - $version = $commit = ''; - } - - //Statistics - $channels_total_stat = intval(get_config('system','channels_total_stat')); - $channels_active_halfyear_stat = intval(get_config('system','channels_active_halfyear_stat')); - $channels_active_monthly_stat = intval(get_config('system','channels_active_monthly_stat')); - $local_posts_stat = intval(get_config('system','local_posts_stat')); - $hide_in_statistics = intval(get_config('system','hide_in_statistics')); - $site_expire = intval(get_config('system', 'default_expire_days')); - - - $data = Array( - 'version' => $version, - 'version_tag' => $tag, - 'commit' => $commit, - 'url' => z_root(), - 'plugins' => $visible_plugins, - 'register_policy' => $register_policy[get_config('system','register_policy')], - 'directory_mode' => $directory_mode[get_config('system','directory_mode')], - 'language' => get_config('system','language'), - 'rss_connections' => get_config('system','feed_contacts'), - 'expiration' => $site_expire, - 'default_service_restrictions' => $service_class, - 'admin' => $admin, - 'site_name' => (($site_name) ? $site_name : ''), - 'platform' => PLATFORM_NAME, - 'dbdriver' => $db->getdriver(), - 'lastpoll' => get_config('system','lastpoll'), - 'info' => (($site_info) ? $site_info : ''), - 'channels_total' => $channels_total_stat, - 'channels_active_halfyear' => $channels_active_halfyear_stat, - 'channels_active_monthly' => $channels_active_monthly_stat, - 'local_posts' => $local_posts_stat, - 'hide_in_statistics' => $hide_in_statistics - ); + + if (argv(1) === 'json') { + $data = get_site_info(); json_return_and_die($data); } } diff --git a/mod/siteinfo_json.php b/mod/siteinfo_json.php new file mode 100644 index 000000000..35697917c --- /dev/null +++ b/mod/siteinfo_json.php @@ -0,0 +1,8 @@ + Date: Sun, 29 Nov 2015 20:26:00 -0800 Subject: generalise the site black|white allow lists, also add a channel black|white list for future use --- mod/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/setup.php b/mod/setup.php index e5ac25965..5c9e988d9 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -14,7 +14,7 @@ $install_wizard_pass = 1; * * @param[in,out] App &$a */ -function setup_init(&$a){ +function setup_init(&$a) { // Ensure that if somebody hasn't read the install documentation and doesn't have all // the required modules or has a totally borked shared hosting provider and they can't -- cgit v1.2.3 From 593423434c0c0e8d1ebb43d97b2dda7e6b4d67bd Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 2 Dec 2015 09:44:25 +0100 Subject: fix attachment rendering for mail --- mod/mail.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/mail.php b/mod/mail.php index 536149a28..44c4b479d 100644 --- a/mod/mail.php +++ b/mod/mail.php @@ -329,7 +329,8 @@ function mail_content(&$a) { 'to_url' => chanlink_hash($message['to_xchan']), 'to_photo' => $message['to']['xchan_photo_s'], 'subject' => $message['title'], - 'body' => smilies(bbcode($message['body']) . $s), + 'body' => smilies(bbcode($message['body'])), + 'attachments' => $s, 'delete' => t('Delete message'), 'dreport' => t('Delivery report'), 'recall' => t('Recall message'), -- cgit v1.2.3 From 75058e54b8dc9625ac009781388789cff713e456 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 2 Dec 2015 18:37:22 -0800 Subject: provide correct error if a directory server requires a realm_token and one wasn't provided --- mod/dirsearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 548acbd08..388e5f3ac 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -26,8 +26,8 @@ function dirsearch_content(&$a) { $token = get_config('system','realm_token'); if($token && $access_token != $token) { - $result['message'] = t('This directory server requires an access token'); - return; + $ret['message'] = t('This directory server requires an access token'); + json_return_and_die($ret); } -- cgit v1.2.3 From ca55bbdaed8c361fe9203c9823b67dd91f3b7741 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 3 Dec 2015 17:09:05 -0800 Subject: use the std_version where applicable instead of matching to the git. --- mod/siteinfo.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 4c5782abe..52d014de1 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -1,8 +1,6 @@ 16) $commit = ''; -- cgit v1.2.3 From 5217d89543912aec870f27282b99d8e5e7920c57 Mon Sep 17 00:00:00 2001 From: ken restivo Date: Thu, 3 Dec 2015 18:21:25 -0800 Subject: srand() is for seeding the PRNG. You want rand() here. --- mod/invite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/invite.php b/mod/invite.php index bda808142..1af5fc1f8 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -51,7 +51,7 @@ function invite_post(&$a) { } if($invonly && ($x || is_site_admin())) { - $code = autoname(8) . srand(1000,9999); + $code = autoname(8) . rand(1000,9999); $nmessage = str_replace('$invite_code',$code,$message); $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", -- cgit v1.2.3