From d074c538897532a4ff7945c1e725c64ac264d5c2 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 23 Feb 2016 16:34:53 -0800 Subject: function to process atom stream without actually storing anything --- include/items.php | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++---- version.inc | 2 +- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/include/items.php b/include/items.php index 363563278..1b8824793 100755 --- a/include/items.php +++ b/include/items.php @@ -3724,10 +3724,6 @@ function mail_store($arr) { /** * @brief Process atom feed and update anything/everything we might need to update. * - * $hub = should we find a hub declation in the feed, pass it back to our calling process, who might (or - * might not) try and subscribe to it. - * $datedir sorts in reverse order - * * @param array $xml * The (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds. * @param $importer @@ -3766,7 +3762,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { if(($chn_expire != 0) && ($chn_expire < $sys_expire)) $expire_days = $chn_expire; -logger('expire_days: ' . $expire_days); + // logger('expire_days: ' . $expire_days); $feed = new SimplePie(); $feed->set_raw_data($xml); @@ -3987,6 +3983,72 @@ logger('expire_days: ' . $expire_days); } } + +/** + * @brief Process atom feed and return the first post and structure + * + * @param array $xml + * The (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds. + * @param $importer + * The contact_record (joined to user_record) of the local user who owns this + * relationship. It is this person's stuff that is going to be updated. + */ + +function process_salmon_feed($xml, $importer) { + + $ret = array(); + + require_once('library/simplepie/simplepie.inc'); + + if(! strlen($xml)) { + logger('process_feed: empty input'); + return; + } + + $feed = new SimplePie(); + $feed->set_raw_data($xml); + $feed->init(); + + if($feed->error()) + logger('Error parsing XML: ' . $feed->error()); + + $permalink = $feed->get_permalink(); + + if($feed->get_item_quantity()) { + + // this should be exactly one + + logger('feed item count = ' . $feed->get_item_quantity(), LOGGER_DEBUG); + + $items = $feed->get_items(); + + foreach($items as $item) { + + $item_id = base64url_encode($item->get_id()); + + logger('processing ' . $item_id, LOGGER_DEBUG); + + $rawthread = $item->get_item_tags( NAMESPACE_THREAD,'in-reply-to'); + if(isset($rawthread[0]['attribs']['']['ref'])) { + $is_reply = true; + $parent_mid = base64url_encode($rawthread[0]['attribs']['']['ref']); + } + + if($is_reply) + $ret['is_reply'] = true; + + $ret['author'] = array(); + + $datarray = get_atom_elements($feed,$item,$ret['author']); + + $ret['item'] = $datarray; + } + } + + return $ret; +} + + function update_feed_item($uid,$datarray) { logger('update_feed_item: not implemented! ' . $uid . ' ' . print_r($datarray,true), LOGGER_DATA); } diff --git a/version.inc b/version.inc index 06b5d04b1..b794d33a4 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2016-02-22.1315H +2016-02-23.1316H -- cgit v1.2.3 From b101a8f6fb3fd3ec0d5466ba1bb7bc9dc9480fba Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 24 Feb 2016 11:20:46 -0800 Subject: missing function --- Zotlabs/Web/Router.php | 1 - include/items.php | 2 +- include/session.php | 23 +++++++++++++++++++---- index.php | 20 +++----------------- mod/webpages.php | 2 ++ version.inc | 2 +- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index 4ae96b5da..af171437d 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -196,5 +196,4 @@ class Router { } } } - } \ No newline at end of file diff --git a/include/items.php b/include/items.php index 1b8824793..bb4d1108e 100755 --- a/include/items.php +++ b/include/items.php @@ -4132,7 +4132,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $o .= '' . "\r\n"; } - if(activity_compare($item['obj_type'],ACTIVITY_OBJ_EVENT) && activity_compare($item['verb'],ACTIVITY_POST)) { + if(activity_match($item['obj_type'],ACTIVITY_OBJ_EVENT) && activity_match($item['verb'],ACTIVITY_POST)) { $obj = ((is_array($item['obj'])) ? $item['object'] : json_decode($item['object'],true)); $o .= '' . xmlify($item['title']) . '' . "\r\n"; diff --git a/include/session.php b/include/session.php index 92004bc18..182805980 100644 --- a/include/session.php +++ b/include/session.php @@ -1,4 +1,5 @@ config['system']['ssl_cookie_protection'])) { + $arr = session_get_cookie_params(); + session_set_cookie_params( + ((isset($arr['lifetime'])) ? $arr['lifetime'] : 0), + ((isset($arr['path'])) ? $arr['path'] : '/'), + ((isset($arr['domain'])) ? $arr['domain'] : $a->get_hostname()), + ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false), + ((isset($arr['httponly'])) ? $arr['httponly'] : true)); + } \ No newline at end of file diff --git a/index.php b/index.php index 4ae2ebe36..bccb270d8 100755 --- a/index.php +++ b/index.php @@ -61,25 +61,11 @@ if(! $a->install) { load_hooks(); call_hooks('init_1'); - $a->language = get_best_language(); - load_translation_table($a->language); - // Force the cookie to be secure (https only) if this site is SSL enabled. Must be done before session_start(). - - if(intval($a->config['system']['ssl_cookie_protection'])) { - $arr = session_get_cookie_params(); - session_set_cookie_params( - ((isset($arr['lifetime'])) ? $arr['lifetime'] : 0), - ((isset($arr['path'])) ? $arr['path'] : '/'), - ((isset($arr['domain'])) ? $arr['domain'] : $a->get_hostname()), - ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false), - ((isset($arr['httponly'])) ? $arr['httponly'] : true)); - } } -else { - // load translations but do not check plugins as we have no database + + $a->language = get_best_language(); - load_translation_table($a->language,true); -} + load_translation_table($a->language,$a->install); /** diff --git a/mod/webpages.php b/mod/webpages.php index 8e12b5910..6b157073e 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -128,6 +128,8 @@ function webpages_content(&$a) { // Get a list of webpages. We can't display all them because endless scroll makes that unusable, // so just list titles and an edit link. + + /** @TODO - this should be replaced with pagelist_widget */ $sql_extra = item_permissions_sql($owner); diff --git a/version.inc b/version.inc index b794d33a4..2d59eb514 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2016-02-23.1316H +2016-02-24.1317H -- cgit v1.2.3 From e73df9ed1d076c19aca384d9967f9257ac020b4e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 24 Feb 2016 23:16:42 +0100 Subject: give nav dropdowns a fixed width to preventtext-overflow: ellipsis cut of to much of the text in some situations --- view/css/bootstrap-red.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/css/bootstrap-red.css b/view/css/bootstrap-red.css index 29164c7ad..777bf69eb 100644 --- a/view/css/bootstrap-red.css +++ b/view/css/bootstrap-red.css @@ -37,7 +37,7 @@ nav .navbar-header img { nav .dropdown-menu { max-height: 450px; - max-width: 300px; + width: 270px; overflow-y: auto; margin-top: 0px; } -- cgit v1.2.3 From 7e6febe2a6609457eca1f1caf650375534780048 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 24 Feb 2016 15:19:28 -0800 Subject: add 'requires' field to plugin info to list other dependent plugins/addons and disable if dependencies are not installed/enabled --- include/plugin.php | 19 ++++++++++++++++++- mod/admin.php | 2 +- mod/xrd.php | 4 +--- view/tpl/admin_plugins_details.tpl | 3 +++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/plugin.php b/include/plugin.php index 5afded542..bd844442f 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -325,7 +325,8 @@ function get_plugin_info($plugin){ 'description' => '', 'author' => array(), 'maintainer' => array(), - 'version' => '' + 'version' => '', + 'requires' => '' ); if (!is_file("addon/$plugin/$plugin.php")) @@ -383,6 +384,22 @@ function check_plugin_versions($info) { } } + if(array_key_exists('requires',$info)) { + $arr = explode(',',$info['requires']); + $found = true; + if($arr) { + foreach($arr as $test) { + $test = trim($test); + if(! $test) + continue; + if(! in_array($test,get_app()->plugins)) + $found = false; + } + } + if(! $found) + return false; + } + return true; } diff --git a/mod/admin.php b/mod/admin.php index 5195db320..292a4e66a 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1275,7 +1275,7 @@ function admin_page_plugins(&$a){ '$str_minversion' => t('Minimum project version: '), '$str_maxversion' => t('Maximum project version: '), '$str_minphpversion' => t('Minimum PHP version: '), - + '$str_requires' => t('Requires: '), '$disabled' => t('Disabled - version incompatibility'), '$admin_form' => $admin_form, diff --git a/mod/xrd.php b/mod/xrd.php index 34ed47149..da4ab51a4 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -35,8 +35,6 @@ function xrd_init(&$a) { header("Content-type: application/xrd+xml"); - $tpl = get_markup_template('view/xrd_person.tpl'); - $o = replace_macros(get_markup_template('xrd_person.tpl'), array( '$nick' => $r[0]['channel_address'], '$accturi' => $uri, @@ -51,7 +49,7 @@ function xrd_init(&$a) { // '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['channel_address'] . '/mention', '$modexp' => 'data:application/magic-public-key,' . $salmon_key, '$subscribe' => $a->get_baseurl() . '/follow?url={uri}', -// '$bigkey' => salmon_key($r[0]['pubkey']) + '$bigkey' => salmon_key($r[0]['channel_pubkey']) )); diff --git a/view/tpl/admin_plugins_details.tpl b/view/tpl/admin_plugins_details.tpl index 721bd3573..5d9e233f9 100755 --- a/view/tpl/admin_plugins_details.tpl +++ b/view/tpl/admin_plugins_details.tpl @@ -24,6 +24,9 @@ {{if $info.minphpversion}}

{{$str_minphpversion}}{{$info.minphpversion}}

{{/if}} + {{if $info.requires}} +

{{$str_requires}}{{$info.requires}}

+ {{/if}} {{foreach $info.maintainer as $a}} -- cgit v1.2.3 From 9d3ce5597863e90fc3d28ceb500d1ce0a7023e5b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 25 Feb 2016 00:24:58 +0100 Subject: fix boxy scheme --- view/theme/redbasic/schema/boxy.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/view/theme/redbasic/schema/boxy.css b/view/theme/redbasic/schema/boxy.css index ad3e587f0..43ef3e34e 100644 --- a/view/theme/redbasic/schema/boxy.css +++ b/view/theme/redbasic/schema/boxy.css @@ -3,9 +3,5 @@ } .wall-item-content-wrapper.comment { - border-width: 0px 0px 1px 0px; -} - -.hide-comments-outer { - border-width: 1px 0px 1px 0px; + border-bottom: 1px solid #ccc; } -- cgit v1.2.3 From 01a8292d653205f7ab0288176af878804039941f Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Thu, 25 Feb 2016 01:04:37 +0100 Subject: fix TOS --- mod/register.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/register.php b/mod/register.php index 2de13feae..b533483f7 100644 --- a/mod/register.php +++ b/mod/register.php @@ -250,6 +250,7 @@ function register_content(&$a) { '$role' => $role, '$default_role' => $default_role, '$nickname' => $nickname, + '$enable_tos' => $enable_tos, '$tos' => $tos, '$email' => $email, '$pass1' => $password, -- cgit v1.2.3 From 93b84f1262bbbf467bab266288e6676d896ac2c8 Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Thu, 25 Feb 2016 01:39:50 +0100 Subject: interim dutch string update --- view/nl/hstrings.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/nl/hstrings.php b/view/nl/hstrings.php index 6bac66a1e..37212e1ab 100644 --- a/view/nl/hstrings.php +++ b/view/nl/hstrings.php @@ -1847,8 +1847,8 @@ $a->strings["Public Sites"] = "Openbare hubs"; $a->strings["The listed sites allow public registration for the \$Projectname network. All sites in the network are interlinked so membership on any of them conveys membership in the network as a whole. Some sites may require subscription or provide tiered service plans. The provider links may provide additional details."] = "Op de hier weergegeven hubs kan iedereen zich voor het \$Projectname-netwerk aanmelden. Alle hubs in het \$Projectname-netwerk zijn met elkaar verbonden, dus maakt het qua lidmaatschap niet uit waar je je aanmeldt. Op sommige hubs heb je eerst goedkeuring nodig en sommige hubs vereisen betaalde abonnementen voor uitbreidingen. Mogelijk wordt hierover op de hub zelf meer informatie gegeven."; $a->strings["Rate this hub"] = "Beoordeel deze hub"; $a->strings["Site URL"] = "URL hub"; -$a->strings["Access Type"] = "Toegangstype"; -$a->strings["Registration Policy"] = "Registratiebeleid"; +$a->strings["Access Type"] = "Toegangs-
 type"; +$a->strings["Registration Policy"] = "Registratie-
 beleid"; $a->strings["Project"] = "Project"; $a->strings["View hub ratings"] = "Beoordelingen"; $a->strings["Rate"] = "Beoordeel"; @@ -1877,7 +1877,7 @@ $a->strings["Register at another affiliated site/hub"] $a->strings["This site has exceeded the number of allowed daily account registrations. Please try again tomorrow."] = "Deze \$Projectname-hub heeft het maximum aantal dagelijks toegestane registraties bereikt. Probeer het morgen (UTC) nogmaals."; $a->strings["Terms of Service"] = "Gebruiksvoorwaarden"; $a->strings["I accept the %s for this website"] = "Ik accepteer de %s van deze \$Projectname-hub"; -$a->strings["I am over 13 years of age and accept the %s for this website"] = "Ik accepteer de %s van deze \$Projectname-hub"; +$a->strings["I am over 13 years of age and accept the %s for this website"] = "Ik ben 13 jaar of ouder en accepteer de %s van deze \$Projectname-hub"; $a->strings["Membership on this site is by invitation only."] = "Registreren op deze \$Projectname-hub kan alleen op uitnodiging."; $a->strings["Please enter your invitation code"] = "Vul jouw uitnodigingscode in"; $a->strings["Enter your name"] = "Vul jouw naam in"; -- cgit v1.2.3 From 6300f47cdcd921141b8f98b71d373d53aa3d80f2 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 24 Feb 2016 16:59:50 -0800 Subject: schema change to support channel move (a completely different operation than channel clone) --- boot.php | 2 +- install/schema_mysql.sql | 4 +++- install/schema_postgres.sql | 2 ++ install/update.php | 17 ++++++++++++++++- view/en-au/update_fail_eml.tpl | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/boot.php b/boot.php index f1c7d8951..7610f16d8 100755 --- a/boot.php +++ b/boot.php @@ -50,7 +50,7 @@ define ( 'RED_VERSION', trim(file_get_contents('version.inc'))); define ( 'STD_VERSION', '1.2.4' ); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1163 ); +define ( 'DB_UPDATE_VERSION', 1164 ); /** diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 161c174e5..07a88cf0a 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -230,6 +230,7 @@ CREATE TABLE IF NOT EXISTS `channel` ( `channel_w_like` int(10) unsigned NOT NULL DEFAULT '0', `channel_removed` tinyint(1) NOT NULL DEFAULT '0', `channel_system` tinyint(1) NOT NULL DEFAULT '0', + `channel_moved` char(255) NOT NULL DEFAULT '', PRIMARY KEY (`channel_id`), UNIQUE KEY `channel_address_unique` (`channel_address`), KEY `channel_account_id` (`channel_account_id`), @@ -268,7 +269,8 @@ CREATE TABLE IF NOT EXISTS `channel` ( KEY `channel_w_like` (`channel_w_like`), KEY `channel_removed` (`channel_removed`), KEY `channel_system` (`channel_system`), - KEY `channel_lastpost` (`channel_lastpost`) + KEY `channel_lastpost` (`channel_lastpost`), + KEY `channel_moved` (`channel_moved`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `chat` ( diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index 964ca5966..3302ef6c0 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -225,6 +225,7 @@ CREATE TABLE "channel" ( "channel_w_like" bigint NOT NULL DEFAULT '128', "channel_removed" smallint NOT NULL DEFAULT '0', "channel_system" smallint NOT NULL DEFAULT '0', + "channel_moved" text NOT NULL DEFAULT '', PRIMARY KEY ("channel_id"), UNIQUE ("channel_address") ); @@ -265,6 +266,7 @@ create index "channel_dirdate" on channel ("channel_dirdate"); create index "channel_lastpost" on channel ("channel_lastpost"); create index "channel_removed" on channel ("channel_removed"); create index "channel_system" on channel ("channel_system"); +create index "channel_moved" on channel ("channel_moved"); CREATE TABLE "chat" ( "chat_id" serial NOT NULL, "chat_room" bigint NOT NULL DEFAULT '0', diff --git a/install/update.php b/install/update.php index d21295be7..0f9b3ab28 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ Date: Thu, 25 Feb 2016 02:03:58 +0100 Subject: another dutch update --- view/nl/register_open_eml.tpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/view/nl/register_open_eml.tpl b/view/nl/register_open_eml.tpl index 411bd00be..4ee6756ef 100644 --- a/view/nl/register_open_eml.tpl +++ b/view/nl/register_open_eml.tpl @@ -1,19 +1,19 @@ - -Er is met dit e-mailadres een account aangemaakt op {{$sitename}}. +s met dit e-mailadres een account aangemaakt op {{$sitename}}. De inloggegevens zijn als volgt: Hub: {{$siteurl}} Inlognaam: {{$email}} Wachtwoord: (het wachtwoord dat je tijdens de registratie hebt opgegeven) -Wanneer dit account was aangemaakt zonder jouw medeweten en tevens niet gewenst, dan kan je {{$siteurl}} -bezoeken en een nieuwe wachtwoord aanvragen. Je kan daarna inloggen, een kanaal aanmaken en -meteen via 'instellingen > account' (linksboven) het account verwijderen (onderaan). +Wanneer dit account was aangemaakt zonder jouw medeweten en tevens niet gewenst, dan kan je {{$siteurl +}}/lostpass bezoeken en het wachtwoord opnieuw instellen. Je kan daarna inloggen, een kanaal aanmaken en meteen via 'instellingen > account' (linksboven) het account verwijderen (rechtsboven). Excuses voor het eventuele ongemak. -Wanneer dit account wel door jou is aangemaakt: Dank je en welkom op {{$sitename}}. +Wanneer dit account wel door jou is aangemaakt: Dank je en van harte welkom op {{$sitename}}. Vriendelijke groet, + Beheerder {{$sitename}} ({{$siteurl}}) + -- cgit v1.2.3 From c95d7c69eb3135f137390323a09eb105776ce29c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 24 Feb 2016 18:54:52 -0800 Subject: issue #216 - calendar sharing --- include/conversation.php | 20 +++ include/security.php | 18 ++- mod/cal.php | 343 +++++++++++++++++++++++++++++++++++++++++++++ mod/events.php | 7 + view/pdl/mod_cal.pdl | 3 + view/tpl/event_cal.tpl | 14 ++ view/tpl/event_head.tpl | 13 +- view/tpl/events_cal-js.tpl | 17 +++ 8 files changed, 425 insertions(+), 10 deletions(-) create mode 100755 mod/cal.php create mode 100644 view/pdl/mod_cal.pdl create mode 100755 view/tpl/event_cal.tpl create mode 100755 view/tpl/events_cal-js.tpl diff --git a/include/conversation.php b/include/conversation.php index 1ade8ed3a..e2dfccac9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1595,8 +1595,17 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if (is_null($nickname)) $nickname = $channel['channel_address']; + $uid = (($a->profile['profile_uid']) ? $a->profile['profile_uid'] : local_channel()); + if($uid == local_channel()) { + $cal_link = '/events'; + } + else { + $cal_link = '/cal/' . $nickname; + } + + if (get_pconfig($uid, 'system', 'noprofiletabs')) return; @@ -1644,6 +1653,17 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ ); } + if($p['view_stream']) { + $tabs[] = array( + 'label' => t('Events'), + 'url' => $a->get_baseurl() . $cal_link, + 'sel' => ((argv(0) == 'cal' || argv(0) == 'events') ? 'active' : ''), + 'title' => t('Events'), + 'id' => 'event-tab', + ); + } + + if ($p['chat']) { require_once('include/chat.php'); $has_chats = chatroom_list_count($uid); diff --git a/include/security.php b/include/security.php index ee94dba82..215cc92cb 100644 --- a/include/security.php +++ b/include/security.php @@ -148,7 +148,7 @@ function change_channel($change_channel) { * @return string additional SQL where statement */ -function permissions_sql($owner_id, $remote_observer = null) { +function permissions_sql($owner_id, $remote_observer = null, $table = '') { $local_channel = local_channel(); @@ -158,10 +158,14 @@ function permissions_sql($owner_id, $remote_observer = null) { * default permissions - anonymous user */ - $sql = " AND allow_cid = '' - AND allow_gid = '' - AND deny_cid = '' - AND deny_gid = '' + if($table) + $table .= '.'; + + + $sql = " AND {$table}allow_cid = '' + AND {$table}allow_gid = '' + AND {$table}deny_cid = '' + AND {$table}deny_gid = '' "; /** @@ -193,8 +197,8 @@ function permissions_sql($owner_id, $remote_observer = null) { } $regexop = db_getfunc('REGEXP'); $sql = sprintf( - " AND ( NOT (deny_cid like '%s' OR deny_gid $regexop '%s') - AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '') ) + " AND ( NOT ({$table}deny_cid like '%s' OR {$table}deny_gid $regexop '%s') + AND ( {$table}allow_cid like '%s' OR {$table}allow_gid $regexop '%s' OR ( {$table}allow_cid = '' AND {$table}allow_gid = '') ) ) ", dbesc(protect_sprintf( '%<' . $observer . '>%')), diff --git a/mod/cal.php b/mod/cal.php new file mode 100755 index 000000000..9899b33b0 --- /dev/null +++ b/mod/cal.php @@ -0,0 +1,343 @@ + 1) { + $nick = argv(1); + + profile_load($a,$nick); + + $channelx = channelx_by_nick($nick); + + if(! $channelx) + return; + + $a->data['channel'] = $channelx; + + $observer = $a->get_observer(); + $a->data['observer'] = $observer; + + $observer_xchan = (($observer) ? $observer['xchan_hash'] : ''); + + head_set_icon($a->data['channel']['xchan_photo_s']); + + $a->page['htmlhead'] .= "" ; + + } + + return; +} + + + +function cal_content(&$a) { + + $channel = null; + + if(argc() > 1) { + $channel = channelx_by_nick(argv(1)); + } + + + if(! $channel) { + notice( t('Channel not found.') . EOL); + return; + } + + // since we don't currently have an event permission - use the stream permission + + if(! perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_stream')) { + notice( t('Permissions denied.') . EOL); + return; + } + + $sql_extra = permissions_sql($channel['channel_id'],get_observer_hash(),'event'); + + $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(), + '$module_url' => '/cal/' . $channel['channel_address'], + '$modparams' => 2, + '$lang' => $a->language, + '$first_day' => $first_day + )); + + $o = ''; + + $mode = 'view'; + $y = 0; + $m = 0; + $ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : ''); + +logger('args: ' . print_r($a->argv,true)); + + if(argc() > 3 && intval(argv(2)) && intval(argv(3))) { + $mode = 'view'; + $y = intval(argv(2)); + $m = intval(argv(3)); + } + if(argc() <= 3) { + $mode = 'view'; + $event_id = argv(2); + } + + 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($channel['channel_id']) + ); + if(count($r)) + $orig_event = $r[0]; + } + + + // Passed parameters overrides anything found in the DB + if(!x($orig_event)) + $orig_event = array(); + + + + $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 = 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 = datetime_convert('UTC', $tz, $fdt, 'Y'); + $fmonth = datetime_convert('UTC', $tz, $fdt, 'm'); + $fday = datetime_convert('UTC', $tz, $fdt, 'd'); + $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($channel['channel_id'],'categories'); + + + $show_bd = perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts'); + if(! $show_bd) { + $sql_extra .= " and event.type != 'birthday' "; + } + + + $category = ''; + + $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); + $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); + if(! $y) + $y = intval($thisyear); + if(! $m) + $m = intval($thismonth); + + // 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. + + if($y < 1901) + $y = 1900; + if($y > 2099) + $y = 2100; + + $nextyear = $y; + $nextmonth = $m + 1; + if($nextmonth > 12) { + $nextmonth = 1; + $nextyear ++; + } + + $prevyear = $y; + if($m > 1) + $prevmonth = $m - 1; + else { + $prevmonth = 12; + $prevyear --; + } + + $dim = get_dim($y,$m); + $start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0); + $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59); + + + if (argv(2) === 'json'){ + 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); + + $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start); + $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); + + if (x($_GET,'id')){ + $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan + from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1", + intval($channel['channel_id']), + intval($_GET['id']) + ); + } + 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. + // Ultimately the finish date shouldn't be involved in the query. + + $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' )) $sql_extra ", + intval($channel['channel_id']), + dbesc($start), + dbesc($finish), + dbesc($adjust_start), + dbesc($adjust_finish) + ); + + } + + $links = array(); + + if($r) { + 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)) + $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j; + } + } + + $events=array(); + + $last_date = ''; + $fmt = t('l, F j'); + + 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')); + $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt)); + $d = day_translate($d); + + $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c')); + if ($rr['nofinish']){ + $end = null; + } else { + $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c')); + } + + + $is_first = ($d !== $last_date); + + $last_date = $d; + + $edit = false; + + $drop = false; + + $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); + if(! $title) { + list($title, $_trash) = explode("$rr['id'], + 'hash' => $rr['event_hash'], + 'start'=> $start, + 'end' => $end, + 'drop' => $drop, + 'allDay' => false, + 'title' => $title, + + 'j' => $j, + 'd' => $d, + 'edit' => $edit, + 'is_first'=>$is_first, + 'item'=>$rr, + 'html'=>$html, + 'plink' => array($rr['plink'],t('Link to Source'),'',''), + ); + + + } + } + + if (argv(2) === 'json'){ + echo json_encode($events); killme(); + } + + // links: array('href', 'text', 'extra css classes', 'title') + if (x($_GET,'id')){ + $tpl = get_markup_template("event_cal.tpl"); + } + else { + $tpl = get_markup_template("events_cal-js.tpl"); + } + + $nick = $channel['channel_address']; + + $o = replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(), + '$new_event' => array($a->get_baseurl().'/cal',(($event_id) ? t('Edit Event') : t('Create Event')),'',''), + '$previus' => array($a->get_baseurl()."/cal/$nick/$prevyear/$prevmonth",t('Previous'),'',''), + '$next' => array($a->get_baseurl()."/cal/$nick/$nextyear/$nextmonth",t('Next'),'',''), + '$export' => array($a->get_baseurl()."/cal/$nick/$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'), + '$form' => $form, + '$expandform' => ((x($_GET,'expandform')) ? true : false), + )); + + if (x($_GET,'id')){ echo $o; killme(); } + + return $o; + } + +} diff --git a/mod/events.php b/mod/events.php index b07ffa184..be39902aa 100755 --- a/mod/events.php +++ b/mod/events.php @@ -283,6 +283,8 @@ function events_content(&$a) { $htpl = get_markup_template('event_head.tpl'); $a->page['htmlhead'] .= replace_macros($htpl,array( '$baseurl' => $a->get_baseurl(), + '$module_url' => '/events', + '$modparams' => 1, '$lang' => $a->language, '$first_day' => $first_day )); @@ -296,6 +298,11 @@ function events_content(&$a) { $m = 0; $ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : ''); + +logger('args: ' . print_r($a->argv,true)); + + + if(argc() > 1) { if(argc() > 2 && argv(1) === 'add') { $mode = 'add'; diff --git a/view/pdl/mod_cal.pdl b/view/pdl/mod_cal.pdl new file mode 100644 index 000000000..f12bf39c3 --- /dev/null +++ b/view/pdl/mod_cal.pdl @@ -0,0 +1,3 @@ +[region=aside] +[widget=fullprofile][/widget] +[/region] diff --git a/view/tpl/event_cal.tpl b/view/tpl/event_cal.tpl new file mode 100755 index 000000000..61458b263 --- /dev/null +++ b/view/tpl/event_cal.tpl @@ -0,0 +1,14 @@ +{{foreach $events as $event}} +
+
+
+ {{if $event.item.author.xchan_name}}{{$event.item.author.xchan_name}}{{/if}} +
+ {{$event.html}} +
+ {{if $event.item.plink}}{{/if}} +
+
+
+
+{{/foreach}} diff --git a/view/tpl/event_head.tpl b/view/tpl/event_head.tpl index dc98d14b3..5083c5835 100755 --- a/view/tpl/event_head.tpl +++ b/view/tpl/event_head.tpl @@ -6,7 +6,7 @@