From 7b4d0168c0f4b24f8fdc7ee47fff7fc3142b36c0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Feb 2017 11:09:02 -0800 Subject: [PATCH 001/366] parse bbcode events which use the "new" vcalendar format. work in progress. --- include/event.php | 147 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 3 deletions(-) diff --git a/include/event.php b/include/event.php index cf1cc331d..d4b81a25f 100644 --- a/include/event.php +++ b/include/event.php @@ -249,6 +249,15 @@ function bbtoevent($s) { $ev = array(); + + $match = ''; + if(preg_match("/\[event\](.*?)\[\/event\]/is",$s,$match)) { + // only parse one object per event tag + $x = ical_to_ev($match[1]); + if($x) + $ev = $x[0]; + } + $match = ''; if(preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is",$s,$match)) $ev['summary'] = $match[1]; @@ -283,6 +292,8 @@ function bbtoevent($s) { $ev['nofinish'] = 1; } + logger('bbtoevent: ' . print_r($ev,true)); + return $ev; } @@ -555,6 +566,136 @@ function event_addtocal($item_id, $uid) { } +function ical_to_ev($s) { + require_once('vendor/autoload.php'); + + $saved_timezone = date_default_timezone_get(); + date_default_timezone_set('Australia/Sydney'); + + $ical = VObject\Reader::read($s); + + $ev = []; + + if($ical) { + if($ical->VEVENT) { + foreach($ical->VEVENT as $event) { + $ev[] = parse_vobject($event,'event'); + } + } + if($ical->VTODO) { + foreach($ical->VTODO as $event) { + $ev[] = parse_vobject($event,'task'); + } + } + } + + date_default_timezone_set($saved_timezone); + + return $ev; + +} + + + +function parse_vobject($ical, $type) { + + + $ev = []; + + if(! isset($ical->DTSTART)) { + logger('no event start'); + return $ev; + } + + $ev['etype'] = $type; + + $dtstart = $ical->DTSTART->getDateTime(); + $ev['adjust'] = (($ical->DTSTART->isFloating()) ? 1 : 0); + + $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $dtstart->format(\DateTime::W3C)); + + + if(isset($ical->DUE)) { + $dtend = $ical->DUE->getDateTime(); + $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $dtend->format(\DateTime::W3C)); + } + elseif(isset($ical->DTEND)) { + $dtend = $ical->DTEND->getDateTime(); + $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $dtend->format(\DateTime::W3C)); + } + else + $ev['nofinish'] = 1; + + + if($ev['dtstart'] === $ev['dtend']) + $ev['nofinish'] = 1; + + if(isset($ical->CREATED)) { + $created = $ical->CREATED->getDateTime(); + $ev['created'] = datetime_convert('UTC','UTC',$created->format(\DateTime::W3C)); + } + + if(isset($ical->{'DTSTAMP'})) { + $edited = $ical->{'DTSTAMP'}->getDateTime(); + $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C)); + } + if(isset($ical->{'LAST-MODIFIED'})) { + $edited = $ical->{'LAST-MODIFIED'}->getDateTime(); + $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C)); + } + + if(isset($ical->{'X-ZOT-LOCATION'})) + $ev['location'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-LOCATION'}); + elseif(isset($ical->LOCATION)) + $ev['location'] = (string) $ical->LOCATION; + + if(isset($ical->{'X-ZOT-DESCRIPTION'})) + $ev['description'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-DESCRIPTION'}); + elseif(isset($ical->DESCRIPTION)) + $ev['description'] = (string) $ical->DESCRIPTION; + + if(isset($ical->{'X-ZOT-SUMMARY'})) + $ev['summary'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-SUMMARY'}); + elseif(isset($ical->SUMMARY)) + $ev['summary'] = (string) $ical->SUMMARY; + + if(isset($ical->PRIORITY)) + $ev['event_priority'] = intval((string) $ical->PRIORITY); + + if(isset($ical->UID)) { + $evuid = (string) $ical->UID; + $ev['event_hash'] = $evuid; + } + + if(isset($ical->SEQUENCE)) { + $ev['event_sequence'] = (string) $ical->SEQUENCE; + } + + if(isset($ical->STATUS)) { + $ev['event_status'] = (string) $ical->STATUS; + } + + if(isset($ical->{'COMPLETED'})) { + $completed = $ical->{'COMPLETED'}->getDateTime(); + $ev['event_status_date'] = datetime_convert('UTC','UTC',$completed->format(\DateTime::W3C)); + } + + if(isset($ical->{'PERCENT-COMPLETE'})) { + $ev['event_percent'] = (string) $ical->{'PERCENT-COMPLETE'} ; + } + + $ev['event_vdata'] = $ical->serialize(); + + return $ev; +} + + + + + function parse_ical_file($f,$uid) { require_once('vendor/autoload.php'); @@ -617,15 +758,14 @@ function event_import_ical($ical, $uid) { $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', $dtstart->format(\DateTime::W3C)); - if(isset($ical->DTEND)) { $dtend = $ical->DTEND->getDateTime(); $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', $dtend->format(\DateTime::W3C)); } - else + else { $ev['nofinish'] = 1; - + } if($ev['dtstart'] === $ev['dtend']) $ev['nofinish'] = 1; @@ -635,6 +775,7 @@ function event_import_ical($ical, $uid) { $ev['created'] = datetime_convert('UTC','UTC',$created->format(\DateTime::W3C)); } + if(isset($ical->{'LAST-MODIFIED'})) { $edited = $ical->{'LAST-MODIFIED'}->getDateTime(); $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C)); From c866c482520e786b23e870f4548dd944921ed43e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Feb 2017 11:26:22 -0800 Subject: [PATCH 002/366] minor edits --- CHANGELOG | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0ea4bdacb..5b29b875d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,21 +3,21 @@ Hubzilla 2.2 (2017-??-??) - Use head_add_link() for feed discovery - Provide HTTP header parser which honours continuation lines - Numerous doco improvements - - Implement virtual profile groups + - Implement virtual privacy groups from restricted profile access list - Implement permission roles - Implement app-tray - Default to manual conversation updates - - Implement channel move + - Implement channel move for all server roles - Implement nav login modal - Rename bb2diaspora.php to markdown.php - - Remove module match + - Remove obsolete module 'match' - Move firefox social api configuration to plugin - Move rsd service to twitter_api plugin - Add build_pagehead hook - Move opensearch to plugins - Move dreamhost hack to plugin - Add wiki permissions - - Introduce hubloc_store_lowlevel() and xchan_store_lowlevel( + - Introduce hubloc_store_lowlevel() and xchan_store_lowlevel() - Move diaspora account import to the diaspora plugin - Allow export of single data sets instead of always exporting everything we know about in channel export - Queue optimisations for sites that have lingered in the queue for more than a couple of days @@ -25,15 +25,17 @@ Hubzilla 2.2 (2017-??-??) - Provide lowlevel xchan storage function to ensure that all non-null rows are initialised - Implement native wiki - Block well-known from oembed - - Implement oberver.language bbcode + - Implement observer.language bbcode and observer.language comanche conditional - Implement daemon_addon hook to let plugins create custom background processes - Implement profile vcards + - Implement connection vcards + - Implement 'click to call' in address book - Default cover photo - Remove fullscreen functionality in photo album view - Update fontawesome lib to version 4.7.0 - Implement a menu to select a section to be open by default in connedit - Improve comanche conditionals - - Add enclosures and categories to atom feed + - Add enclosures and categories to atom feed parsing - Allow the atom_entry hook to change the results - Set 'adjust for viewer timezone' as the default for new events - Allow event creation in other timezones than your own From 3e992604c711b64232075215e2fec734f7084377 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Feb 2017 14:52:36 -0800 Subject: [PATCH 003/366] move some functions to more appropriate places --- boot.php | 18 +++ include/channel.php | 207 +++++++++++++++++++++++++++++++++- include/connections.php | 244 ++-------------------------------------- 3 files changed, 233 insertions(+), 236 deletions(-) diff --git a/boot.php b/boot.php index 7120632f4..9338bc5b2 100755 --- a/boot.php +++ b/boot.php @@ -1384,6 +1384,24 @@ function os_mkdir($path, $mode = 0777, $recursive = false) { return $result; } + +// recursively delete a directory +function rrmdir($path) { + if(is_dir($path) === true) { + $files = array_diff(scandir($path), array('.', '..')); + foreach($files as $file) { + rrmdir(realpath($path) . '/' . $file); + } + return rmdir($path); + } + elseif(is_file($path) === true) { + return unlink($path); + } + + return false; +} + + /** * @brief Function to check if request was an AJAX (xmlhttprequest) request. * diff --git a/include/channel.php b/include/channel.php index 71ba2476f..755bfc5d6 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2046,4 +2046,209 @@ function profile_store_lowlevel($arr) { ]; return create_table_from_array('profile',$store); -} \ No newline at end of file +} + + +// Included here for completeness, but this is a very dangerous operation. +// It is the caller's responsibility to confirm the requestor's intent and +// authorisation to do this. + +function account_remove($account_id,$local = true,$unset_session=true) { + + logger('account_remove: ' . $account_id); + + if(! intval($account_id)) { + logger('account_remove: no account.'); + return false; + } + + // Don't let anybody nuke the only admin account. + + $r = q("select account_id from account where (account_roles & %d) > 0", + intval(ACCOUNT_ROLE_ADMIN) + ); + + if($r !== false && count($r) == 1 && $r[0]['account_id'] == $account_id) { + logger("Unable to remove the only remaining admin account"); + return false; + } + + $r = q("select * from account where account_id = %d limit 1", + intval($account_id) + ); + $account_email=$r[0]['account_email']; + + if(! $r) { + logger('account_remove: No account with id: ' . $account_id); + return false; + } + + $x = q("select channel_id from channel where channel_account_id = %d", + intval($account_id) + ); + if($x) { + foreach($x as $xx) { + channel_remove($xx['channel_id'],$local,false); + } + } + + $r = q("delete from account where account_id = %d", + intval($account_id) + ); + + + if ($unset_session) { + unset($_SESSION['authenticated']); + unset($_SESSION['uid']); + notice( sprintf(t("User '%s' deleted"),$account_email) . EOL); + goaway(z_root()); + } + return $r; + +} + +function channel_remove($channel_id, $local = true, $unset_session=false) { + + if(! $channel_id) + return; + + logger('Removing channel: ' . $channel_id); + logger('channel_remove: local only: ' . intval($local)); + + $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id)); + if(! $r) { + logger('channel_remove: channel not found: ' . $channel_id); + return; + } + + $channel = $r[0]; + + call_hooks('channel_remove',$r[0]); + + if(! $local) { + + $r = q("update channel set channel_deleted = '%s', channel_removed = 1 where channel_id = %d", + dbesc(datetime_convert()), + intval($channel_id) + ); + + q("delete from pconfig where uid = %d", + intval($channel_id) + ); + + logger('deleting hublocs',LOGGER_DEBUG); + + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", + dbesc($channel['channel_hash']) + ); + + + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", + dbesc($channel['channel_hash']) + ); + + Zotlabs\Daemon\Master::Summon(array('Notifier','purge_all',$channel_id)); + } + + + $r = q("select * from iconfig left join item on item.id = iconfig.iid + where item.uid = %d", + intval($channel_id) + ); + if($r) { + foreach($r as $rr) { + q("delete from iconfig where iid = %d", + intval($rr['iid']) + ); + } + } + + + q("DELETE FROM groups WHERE uid = %d", intval($channel_id)); + q("DELETE FROM group_member WHERE uid = %d", intval($channel_id)); + q("DELETE FROM event WHERE uid = %d", intval($channel_id)); + q("DELETE FROM item WHERE uid = %d", intval($channel_id)); + q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id)); + q("DELETE FROM notify WHERE uid = %d", intval($channel_id)); + q("DELETE FROM photo WHERE uid = %d", intval($channel_id)); + q("DELETE FROM attach WHERE uid = %d", intval($channel_id)); + q("DELETE FROM profile WHERE uid = %d", intval($channel_id)); + q("DELETE FROM pconfig WHERE uid = %d", intval($channel_id)); + + // @FIXME At this stage we need to remove the file resources located under /store/$nickname + + + q("delete from abook where abook_xchan = '%s' and abook_self = 1 ", + dbesc($channel['channel_hash']) + ); + + $r = q("update channel set channel_deleted = '%s', channel_removed = 1 where channel_id = %d", + dbesc(datetime_convert()), + intval($channel_id) + ); + + // if this was the default channel, set another one as default + if(App::$account['account_default_channel'] == $channel_id) { + $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", + intval(App::$account['account_id']), + intval(PAGE_REMOVED)); + if ($r) { + $rr = q("update account set account_default_channel = %d where account_id = %d", + intval($r[0]['channel_id']), + intval(App::$account['account_id'])); + logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']); + } + else { + $rr = q("update account set account_default_channel = 0 where account_id = %d", + intval(App::$account['account_id']) + ); + } + } + + logger('deleting hublocs',LOGGER_DEBUG); + + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", + dbesc($channel['channel_hash']), + dbesc(z_root()) + ); + + // Do we have any valid hublocs remaining? + + $hublocs = 0; + + $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", + dbesc($channel['channel_hash']) + ); + if($r) + $hublocs = count($r); + + if(! $hublocs) { + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s' ", + dbesc($channel['channel_hash']) + ); + } + + //remove from file system + $r = q("select channel_address from channel where channel_id = %d limit 1", + intval($channel_id) + ); + + if($r) { + $channel_address = $r[0]['channel_address'] ; + } + if($channel_address) { + $f = 'store/' . $channel_address.'/'; + logger('delete '. $f); + if(is_dir($f)) { + @rrmdir($f); + } + } + + Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id)); + + if($channel_id == local_channel() && $unset_session) { + App::$session->nuke(); + goaway(z_root()); + } + +} diff --git a/include/connections.php b/include/connections.php index e26943b68..a8d7d8483 100644 --- a/include/connections.php +++ b/include/connections.php @@ -188,232 +188,6 @@ function abook_toggle_flag($abook,$flag) { } -// Included here for completeness, but this is a very dangerous operation. -// It is the caller's responsibility to confirm the requestor's intent and -// authorisation to do this. - -function user_remove($uid) { - -} - -function account_remove($account_id,$local = true,$unset_session=true) { - - logger('account_remove: ' . $account_id); - - if(! intval($account_id)) { - logger('account_remove: no account.'); - return false; - } - - // Don't let anybody nuke the only admin account. - - $r = q("select account_id from account where (account_roles & %d) > 0", - intval(ACCOUNT_ROLE_ADMIN) - ); - - if($r !== false && count($r) == 1 && $r[0]['account_id'] == $account_id) { - logger("Unable to remove the only remaining admin account"); - return false; - } - - $r = q("select * from account where account_id = %d limit 1", - intval($account_id) - ); - $account_email=$r[0]['account_email']; - - if(! $r) { - logger('account_remove: No account with id: ' . $account_id); - return false; - } - - $x = q("select channel_id from channel where channel_account_id = %d", - intval($account_id) - ); - if($x) { - foreach($x as $xx) { - channel_remove($xx['channel_id'],$local,false); - } - } - - $r = q("delete from account where account_id = %d", - intval($account_id) - ); - - - if ($unset_session) { - unset($_SESSION['authenticated']); - unset($_SESSION['uid']); - notice( sprintf(t("User '%s' deleted"),$account_email) . EOL); - goaway(z_root()); - } - return $r; - -} -// recursively delete a directory -function rrmdir($path) -{ - if (is_dir($path) === true) - { - $files = array_diff(scandir($path), array('.', '..')); - - foreach ($files as $file) - { - rrmdir(realpath($path) . '/' . $file); - } - - return rmdir($path); - } - - else if (is_file($path) === true) - { - return unlink($path); - } - - return false; -} - -function channel_remove($channel_id, $local = true, $unset_session=false) { - - if(! $channel_id) - return; - - logger('Removing channel: ' . $channel_id); - logger('channel_remove: local only: ' . intval($local)); - - $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id)); - if(! $r) { - logger('channel_remove: channel not found: ' . $channel_id); - return; - } - - $channel = $r[0]; - - call_hooks('channel_remove',$r[0]); - - if(! $local) { - - $r = q("update channel set channel_deleted = '%s', channel_removed = 1 where channel_id = %d", - dbesc(datetime_convert()), - intval($channel_id) - ); - - q("delete from pconfig where uid = %d", - intval($channel_id) - ); - - logger('deleting hublocs',LOGGER_DEBUG); - - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", - dbesc($channel['channel_hash']) - ); - - - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", - dbesc($channel['channel_hash']) - ); - - Zotlabs\Daemon\Master::Summon(array('Notifier','purge_all',$channel_id)); - } - - - $r = q("select * from iconfig left join item on item.id = iconfig.iid - where item.uid = %d", - intval($channel_id) - ); - if($r) { - foreach($r as $rr) { - q("delete from iconfig where iid = %d", - intval($rr['iid']) - ); - } - } - - - q("DELETE FROM groups WHERE uid = %d", intval($channel_id)); - q("DELETE FROM group_member WHERE uid = %d", intval($channel_id)); - q("DELETE FROM event WHERE uid = %d", intval($channel_id)); - q("DELETE FROM item WHERE uid = %d", intval($channel_id)); - q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id)); - q("DELETE FROM notify WHERE uid = %d", intval($channel_id)); - q("DELETE FROM photo WHERE uid = %d", intval($channel_id)); - q("DELETE FROM attach WHERE uid = %d", intval($channel_id)); - q("DELETE FROM profile WHERE uid = %d", intval($channel_id)); - q("DELETE FROM pconfig WHERE uid = %d", intval($channel_id)); - - // @FIXME At this stage we need to remove the file resources located under /store/$nickname - - - q("delete from abook where abook_xchan = '%s' and abook_self = 1 ", - dbesc($channel['channel_hash']) - ); - - $r = q("update channel set channel_deleted = '%s', channel_removed = 1 where channel_id = %d", - dbesc(datetime_convert()), - intval($channel_id) - ); - - // if this was the default channel, set another one as default - if(App::$account['account_default_channel'] == $channel_id) { - $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", - intval(App::$account['account_id']), - intval(PAGE_REMOVED)); - if ($r) { - $rr = q("update account set account_default_channel = %d where account_id = %d", - intval($r[0]['channel_id']), - intval(App::$account['account_id'])); - logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']); - } - else { - $rr = q("update account set account_default_channel = 0 where account_id = %d", - intval(App::$account['account_id']) - ); - } - } - - logger('deleting hublocs',LOGGER_DEBUG); - - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", - dbesc($channel['channel_hash']), - dbesc(z_root()) - ); - - // Do we have any valid hublocs remaining? - - $hublocs = 0; - - $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", - dbesc($channel['channel_hash']) - ); - if($r) - $hublocs = count($r); - - if(! $hublocs) { - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s' ", - dbesc($channel['channel_hash']) - ); - } - - //remove from file system - $r = q("select channel_address from channel where channel_id = %d limit 1", - intval($channel_id) - ); - if($r) - $channel_address = $r[0]['channel_address'] ; - if ($channel_address !== '') { - $f = 'store/' . $channel_address.'/'; - logger ('delete '. $f); - if(is_dir($f)) - @rrmdir($f); - } - - Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id)); - - if($channel_id == local_channel() && $unset_session) { - App::$session->nuke(); - goaway(z_root()); - } - -} /** * mark any hubs "offline" that haven't been heard from in more than 30 days @@ -430,10 +204,10 @@ function mark_orphan_hubsxchans() { if($dirmode == DIRECTORY_MODE_NORMAL) return; - $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0 + $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0 and hubloc_network = 'zot' and hubloc_connected < %s - interval %s", - db_utcnow(), db_quoteinterval('36 day') - ); + db_utcnow(), db_quoteinterval('36 day') + ); // $realm = get_directory_realm(); // if($realm == DIRECTORY_REALM) { @@ -547,13 +321,13 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) { // directory servers need to keep the record around for sync purposes - mark it deleted - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", - dbesc($xchan) - ); + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", + dbesc($xchan) + ); - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", - dbesc($xchan) - ); + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", + dbesc($xchan) + ); } } } From 96fdb88690fcb572b5bc4948a7df71b3c257a97d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Feb 2017 15:15:19 -0800 Subject: [PATCH 004/366] nativewiki: only apply markdown filter to markdown input --- Zotlabs/Lib/NativeWikiPage.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index cdb2a5134..af0286997 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -333,18 +333,26 @@ class NativeWikiPage { static public function save_page($arr) { - $pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : ''); - $content = ((array_key_exists('content',$arr)) ? purify_html(Zlib\NativeWikiPage::prepare_content($arr['content'])) : ''); - $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : ''); + $pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : ''); + $content = ((array_key_exists('content',$arr)) ? $arr['content'] : ''); + $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : ''); $observer_hash = ((array_key_exists('observer_hash',$arr)) ? $arr['observer_hash'] : ''); $channel_id = ((array_key_exists('channel_id',$arr)) ? $arr['channel_id'] : 0); - $revision = ((array_key_exists('revision',$arr)) ? $arr['revision'] : 0); + $revision = ((array_key_exists('revision',$arr)) ? $arr['revision'] : 0); $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id); if (!$w['wiki']) { return array('message' => t('Error reading wiki'), 'success' => false); } + + $mimetype = $w['mimeType']; + if($mimetype === 'text/markdown') { + $content = purify_html(Zlib\NativeWikiPage::prepare_content($content)); + } + else { + $content = escape_tags($content); + } // fetch the most recently saved revision. From b1ff5367e7e853d7e0e24c91aecc3a8f80d0ba87 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Feb 2017 19:07:01 -0800 Subject: [PATCH 005/366] more work on profile vcards - still a lot of work to go --- Zotlabs/Module/Profiles.php | 36 +++++++--- include/channel.php | 2 +- view/js/mod_connedit.js | 2 +- view/js/mod_profiles.js | 4 +- view/tpl/profile_advanced.tpl | 22 ++++++ view/tpl/profile_edit.tpl | 126 +++++++++++++++++++++++++++++++++- 6 files changed, 178 insertions(+), 14 deletions(-) diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 32e888f14..da8b16b00 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -330,13 +330,7 @@ class Profiles extends \Zotlabs\Web\Controller { 'photo' => $channel['xchan_photo_l'], 'adr' => [], 'adr_type' => [ $default_vcard_cat ], - 'tel' => [], - 'tel_type' => [ $default_vcard_cat ], - 'email' => [], - 'email_type' => [ $default_vcard_cat ], - 'impp' => [], - 'impp_type' => [ $default_vcard_cat ], - 'url' => [], + 'url' => [ $homepage ], 'url_type' => [ $default_vcard_cat ] ]; @@ -350,9 +344,12 @@ class Profiles extends \Zotlabs\Web\Controller { 6 => $country_name ]; - $profile_vcard = update_vcard($defcard,$orig_vcard); + $orig_vcard = \Sabre\VObject\Reader::read($profile_vcard); + + $profile_vcard = update_vcard($_REQUEST,$orig_vcard); + require_once('include/text.php'); linkify_tags($a, $likes, local_channel()); @@ -700,6 +697,10 @@ class Profiles extends \Zotlabs\Web\Controller { } //logger('extra_fields: ' . print_r($extra_fields,true)); + + $vc = $r[0]['profile_vcard']; + $vctmp = (($vc) ? \Sabre\VObject\Reader::read($vc) : null); + $vcard = (($vctmp) ? get_vcard_array($vctmp,$contact['abook_id']) : [] ); $f = get_config('system','birthday_input_format'); if(! $f) @@ -717,6 +718,7 @@ class Profiles extends \Zotlabs\Web\Controller { . get_form_security_token("profile_drop"), '$fields' => $fields, + '$vcard' => $vcard, '$guid' => $r[0]['profile_guid'], '$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), @@ -776,11 +778,27 @@ class Profiles extends \Zotlabs\Web\Controller { '$film' => array('film', t('Film/Dance/Culture/Entertainment'), $r[0]['film']), '$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']), '$romance' => array('romance',t('Love/Romance'), $r[0]['romance']), - '$work' => array('work', t('Work/Employment'), $r[0]['employment']), + '$employ' => array('work', t('Work/Employment'), $r[0]['employment']), '$education' => array('education', t('School/Education'), $r[0]['education']), '$contact' => array('contact', t('Contact information and social networks'), $r[0]['contact']), '$channels' => array('channels', t('My other channels'), $r[0]['channels']), '$extra_fields' => $extra_fields, + '$tel_label' => t('Phone'), + '$email_label' => t('Email'), + '$impp_label' => t('Instant messenger'), + '$url_label' => t('Website'), + '$adr_label' => t('Address'), + '$note_label' => t('Note'), + '$mobile' => t('Mobile'), + '$home' => t('Home'), + '$work' => t('Work'), + '$other' => t('Other'), + '$add_card' => t('Add Contact'), + '$add_field' => t('Add Field'), + '$create' => t('Create'), + '$update' => t('Update'), + '$delete' => t('Delete'), + '$cancel' => t('Cancel'), )); $arr = array('profile' => $r[0], 'entry' => $o); diff --git a/include/channel.php b/include/channel.php index 755bfc5d6..b838f8393 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1608,7 +1608,7 @@ function get_profile_fields_basic($filter = 0) { $profile_fields_basic = (($filter == 0) ? get_config('system','profile_fields_basic') : null); if(! $profile_fields_basic) - $profile_fields_basic = array('fullname','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact'); + $profile_fields_basic = array('fullname','pdesc','chandesc','comms','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact'); $x = array(); if($profile_fields_basic) diff --git a/view/js/mod_connedit.js b/view/js/mod_connedit.js index 4739c490c..7100e0d07 100644 --- a/view/js/mod_connedit.js +++ b/view/js/mod_connedit.js @@ -82,7 +82,7 @@ $(document).ready(function() { function doRemove() { var what = $(this).data('remove'); var element = $(this).parents('div.form-' + what); - var where = '#abook_edit_form' + $(this).data('id'); + var where = '#abook-edit-form' + $(this).data('id'); if(what === 'vcard-org' || what === 'vcard-title' || what === 'vcard-note') { $(where + ' .add-' + what).show() diff --git a/view/js/mod_profiles.js b/view/js/mod_profiles.js index acc9f9953..784f64458 100644 --- a/view/js/mod_profiles.js +++ b/view/js/mod_profiles.js @@ -38,7 +38,7 @@ $(document).ready(function() { var what = $(this).data('add'); var id = $(this).data('id'); var element = '#template-form-' + what; - var where = '#abook-edit-form'; + var where = '#profile-edit-form'; $(element + ' .remove-field').attr('data-id', id) @@ -58,7 +58,7 @@ $(document).ready(function() { function doRemove() { var what = $(this).data('remove'); var element = $(this).parents('div.form-' + what); - var where = '#abook_edit_form' + $(this).data('id'); + var where = '#profile-edit-form' + $(this).data('id'); if(what === 'vcard-org' || what === 'vcard-title' || what === 'vcard-note') { $(where + ' .add-' + what).show() diff --git a/view/tpl/profile_advanced.tpl b/view/tpl/profile_advanced.tpl index 4000f39d6..ba0efe999 100755 --- a/view/tpl/profile_advanced.tpl +++ b/view/tpl/profile_advanced.tpl @@ -47,6 +47,28 @@ {{foreach $fields as $f}} + + + + + + + + + + + + + + + + + + + + + + {{if $f == 'name'}}
{{$profile.fullname.0}}
diff --git a/view/tpl/profile_edit.tpl b/view/tpl/profile_edit.tpl index b0211d697..a50d11136 100755 --- a/view/tpl/profile_edit.tpl +++ b/view/tpl/profile_edit.tpl @@ -108,6 +108,128 @@ + + {{if $fields.comms }} + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+
+ +
+ + + {{if $vcard.fn}}{{$vcard.fn}}{{/if}} + {{if $vcard.emails.0.address}}{{/if}} + {{if $vcard.tels.0}}{{/if}} + + +
+
+
+ +
+
+ {{if $vcard.tels}} + {{foreach $vcard.tels as $tel}} +
+ + + +
+ {{/foreach}} + {{/if}} +
+
+ + +
+
+ {{if $vcard.emails}} + {{foreach $vcard.emails as $email}} +
+ + + +
+ {{/foreach}} + {{/if}} +
+
+ +
+
+ {{if $vcard.impps}} + {{foreach $vcard.impps as $impp}} +
+ + + +
+ {{/foreach}} + {{/if}} +
+
+ +
+ +
+
+ {{/if}} + + {{if $fields.address || $fields.locality || $fields.postal_code || $fields.region || $fields.country_name || $fields.hometown}}
+ {{/if}} + {{if $fields.marital || $fields.sexual}}
@@ -266,7 +266,7 @@ @@ -289,7 +289,7 @@
diff --git a/view/tpl/layoutlist.tpl b/view/tpl/layoutlist.tpl index d0b81af0c..96c795a3b 100644 --- a/view/tpl/layoutlist.tpl +++ b/view/tpl/layoutlist.tpl @@ -2,8 +2,8 @@
{{if $editor}}
- -  {{$help.text}} + +  {{$help.text}}
{{/if}}

{{$title}}

diff --git a/view/tpl/like_noshare.tpl b/view/tpl/like_noshare.tpl index 67f5868cb..e83b885fe 100755 --- a/view/tpl/like_noshare.tpl +++ b/view/tpl/like_noshare.tpl @@ -1,5 +1,5 @@ diff --git a/view/tpl/locmanage.tpl b/view/tpl/locmanage.tpl index fe2d5ec84..fe24ac460 100644 --- a/view/tpl/locmanage.tpl +++ b/view/tpl/locmanage.tpl @@ -8,7 +8,7 @@ $.post(baseurl + '/locs','drop='+id,function(data) { window.location.href=window.location.href; }); } - +

{{$header}}

diff --git a/view/tpl/mail_conv.tpl b/view/tpl/mail_conv.tpl index 249e13a04..a0904ea6c 100755 --- a/view/tpl/mail_conv.tpl +++ b/view/tpl/mail_conv.tpl @@ -15,12 +15,12 @@
{{if $mail.attachments}} {{/if}} diff --git a/view/tpl/profile_advanced.tpl b/view/tpl/profile_advanced.tpl index ba0efe999..c176f678d 100755 --- a/view/tpl/profile_advanced.tpl +++ b/view/tpl/profile_advanced.tpl @@ -3,7 +3,7 @@
{{if $profile.like_count}}
- + {{if $profile.likers}} {{/if}} @@ -11,14 +11,14 @@ {{/if}} {{if $profile.canlike}}
-
{{/if}} {{if $editmenu.multi}}
-  {{$editmenu.edit.3}} +  {{$editmenu.edit.3}}
{{elseif $editmenu}} {{/if}} {{if $exportlink}} {{/if}}
@@ -319,13 +319,13 @@
  • {{if $item.img}}{{$item.term}}{{/if}} {{$item.term}} {{if $profile.canlike}}
    - {{/if}} {{if $item.like_count}}
    - + {{if $item.likes}} {{/if}} diff --git a/view/tpl/profile_edit.tpl b/view/tpl/profile_edit.tpl index a50d11136..9c16b734f 100755 --- a/view/tpl/profile_edit.tpl +++ b/view/tpl/profile_edit.tpl @@ -1,7 +1,7 @@
    diff --git a/view/tpl/wiki_page_history.tpl b/view/tpl/wiki_page_history.tpl index ca16e8333..9e5ba0f9c 100644 --- a/view/tpl/wiki_page_history.tpl +++ b/view/tpl/wiki_page_history.tpl @@ -46,10 +46,10 @@ Date{{$commit.date}} {{if $permsWrite}} - +

    {{/if}} - + Name{{$commit.name}} <{{$commit.email}}> Message{{$commit.title}} diff --git a/view/tpl/wikilist.tpl b/view/tpl/wikilist.tpl index 916552e03..15d6eff0d 100644 --- a/view/tpl/wikilist.tpl +++ b/view/tpl/wikilist.tpl @@ -1,7 +1,7 @@
    {{if $owner}} - + {{/if}}

    {{$header}}

    @@ -13,7 +13,7 @@ {{include file="field_checkbox.tpl" field=$notify}}
    - From 0f9ddbf3b2509ef4651a9b58d008330d6bc8cfd9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 10 Mar 2017 17:02:55 +0100 Subject: [PATCH 068/366] fixing classes --- view/css/bootstrap-red.css | 9 ++++----- view/css/widgets.css | 21 +------------------- view/theme/redbasic/css/style.css | 26 ++++++++++++------------- view/theme/redbasic/php/style.php | 2 +- view/tpl/abook_edit.tpl | 2 +- view/tpl/conv_item.tpl | 2 +- view/tpl/conv_list.tpl | 2 +- view/tpl/events-js.tpl | 2 +- view/tpl/generic_links_widget.tpl | 4 ++-- view/tpl/group_side.tpl | 14 +++++++------- view/tpl/help.tpl | 4 ++-- view/tpl/jot.tpl | 2 +- view/tpl/mail_conv.tpl | 2 +- view/tpl/mail_head.tpl | 2 +- view/tpl/mail_list.tpl | 4 ++-- view/tpl/message_side.tpl | 10 +++++----- view/tpl/nav.tpl | 32 +++++++++++++++---------------- view/tpl/peoplefind.tpl | 10 +++++----- view/tpl/photo_view.tpl | 2 +- view/tpl/posted_date_widget.tpl | 6 +++--- view/tpl/profile_edit.tpl | 2 +- view/tpl/prv_message.tpl | 2 +- view/tpl/search_item.tpl | 2 +- view/tpl/wiki.tpl | 2 +- 24 files changed, 73 insertions(+), 93 deletions(-) diff --git a/view/css/bootstrap-red.css b/view/css/bootstrap-red.css index 1369ea5c8..4f855ce39 100644 --- a/view/css/bootstrap-red.css +++ b/view/css/bootstrap-red.css @@ -10,6 +10,10 @@ nav .badge { } +.nav-item.nav-item-hack { + height: 1.9rem; +} + #navbar-collapse-1 i { font-size: 1rem; } @@ -17,11 +21,6 @@ nav .badge { /* nav overrides end */ -aside .nav-pills > li > a, -.response-list .nav-pills > li > a { - padding: 6px 10px; -} - nav .dropdown-menu { max-height: 70vh; overflow: auto; diff --git a/view/css/widgets.css b/view/css/widgets.css index 9b97d8bf7..8fb4ab377 100644 --- a/view/css/widgets.css +++ b/view/css/widgets.css @@ -20,34 +20,15 @@ .widget-nav-pills-icons { opacity: 0; - padding: 6px 10px; float: right; - position: relative; - z-index:1; } - .widget-nav-pills-checkbox { - padding: 6px 10px; + padding: 0.6rem 1.4rem; float: right; - position: relative; - z-index:1; cursor: pointer; } -i.widget-nav-pills-icons, -i.widget-nav-pills-checkbox { - margin-top: 2px; -} - -.widget-nav-pills-icons:hover + a { - background-color: #eee; -} - -.widget-nav-pills-checkbox:hover + a { - background-color: #eee; -} - li:hover .widget-nav-pills-icons { opacity: 1; } diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 7250ff961..33dcfedc9 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -1169,9 +1169,15 @@ margin-right: 50px; } .generic-icons { - font-size: 1.2em; + font-size: 1rem; color: $toolicon_colour; - margin-right: 7px; + margin-right: 0.5rem; +} + +.generic-icons-right { + font-size: 1rem; + color: $toolicon_colour; + margin-left: 0.5rem; } .generic-icons:hover { @@ -1476,6 +1482,11 @@ img.mail-conv-sender-photo { color: $toolicon_colour; } +.widget .nav-item:hover { + background-color: #eee; + border-radius: $radiuspx; +} + #note-text { border: 1px solid #ccc; border-radius: $radiuspx; @@ -2063,17 +2074,6 @@ dl.bb-dl > dd > li { border-left: 3px solid #eee; } -.nav-pills-stacked-icons { - padding: 6px 10px; - float: right; - position: relative; - z-index:1; -} - -.nav-pills-stacked-icons:hover + a { - background-color: #eee; -} - .app-icon { font-size: 80px; color: $toolicon_colour; diff --git a/view/theme/redbasic/php/style.php b/view/theme/redbasic/php/style.php index 85b495792..43a973da1 100644 --- a/view/theme/redbasic/php/style.php +++ b/view/theme/redbasic/php/style.php @@ -102,7 +102,7 @@ if (! $nav_icon_colour) if (! $nav_active_icon_colour) $nav_active_icon_colour = "#fff"; if (! $link_colour) - $link_colour = "#337AB7"; + $link_colour = "#0275d8"; if (! $banner_colour) $banner_colour = "#fff"; if (! $bgcolour) diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl index 76d52f699..be9fcc2a3 100755 --- a/view/tpl/abook_edit.tpl +++ b/view/tpl/abook_edit.tpl @@ -4,7 +4,7 @@
    {{/if}}