From 2fa9645dfc4dc640d7460f069fc9536cce1e4fd2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 11 Apr 2018 17:40:04 -0700 Subject: channel delegation: push current identity and pop it on logout from the delegated channel. This fixes the known issue of being forced to log back in after leaving the delegated channel. --- Zotlabs/Module/Logout.php | 7 ++++++- Zotlabs/Module/Magic.php | 2 ++ include/auth.php | 13 +++++++++++-- include/bbcode.php | 4 ++-- include/html2bbcode.php | 1 + view/js/main.js | 1 - 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Zotlabs/Module/Logout.php b/Zotlabs/Module/Logout.php index f06e7278b..d11ce54ac 100644 --- a/Zotlabs/Module/Logout.php +++ b/Zotlabs/Module/Logout.php @@ -5,7 +5,12 @@ namespace Zotlabs\Module; class Logout extends \Zotlabs\Web\Controller { function init() { - \App::$session->nuke(); + if($_SESSION['delegate'] && $_SESSION['delegate_push']) { + $_SESSION = $_SESSION['delegate_push']; + } + else { + \App::$session->nuke(); + } goaway(z_root()); } diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 15e5cedcf..4b3a223ba 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -112,6 +112,8 @@ class Magic extends \Zotlabs\Web\Controller { if($r && intval($r[0]['channel_id'])) { $allowed = perm_is_allowed($r[0]['channel_id'],get_observer_hash(),'delegate'); if($allowed) { + $tmp = $_SESSION; + $_SESSION['delegate_push'] = $tmp; $_SESSION['delegate_channel'] = $r[0]['channel_id']; $_SESSION['delegate'] = get_observer_hash(); $_SESSION['account_id'] = intval($r[0]['channel_account_id']); diff --git a/include/auth.php b/include/auth.php index 844566919..c44eeb8fc 100644 --- a/include/auth.php +++ b/include/auth.php @@ -145,8 +145,17 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && // process logout request $args = array('channel_id' => local_channel()); call_hooks('logging_out', $args); - App::$session->nuke(); - info( t('Logged out.') . EOL); + + + if($_SESSION['delegate'] && $_SESSION['delegate_push']) { + $_SESSION = $_SESSION['delegate_push']; + info( t('Delegation session ended.') . EOL); + } + else { + App::$session->nuke(); + info( t('Logged out.') . EOL); + } + goaway(z_root()); } diff --git a/include/bbcode.php b/include/bbcode.php index 152e4888f..340fe6b25 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1001,11 +1001,11 @@ function bbcode($Text, $options = []) { } // Check for strike-through text if (strpos($Text,'[s]') !== false) { - $Text = preg_replace("(\[s\](.*?)\[\/s\])ism", '$1', $Text); + $Text = preg_replace("(\[s\](.*?)\[\/s\])ism", '$1', $Text); } // Check for over-line text if (strpos($Text,'[o]') !== false) { - $Text = preg_replace("(\[o\](.*?)\[\/o\])ism", '$1', $Text); + $Text = preg_replace("(\[o\](.*?)\[\/o\])ism", '$1', $Text); } if (strpos($Text,'[sup]') !== false) { $Text = preg_replace("(\[sup\](.*?)\[\/sup\])ism", '$1', $Text); diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 4166299db..1a03fbdaf 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -164,6 +164,7 @@ function html2bbcode($message) node2bbcode($doc, 'b', array(), '[b]', '[/b]'); node2bbcode($doc, 'i', array(), '[i]', '[/i]'); node2bbcode($doc, 'u', array(), '[u]', '[/u]'); + node2bbcode($doc, 's', array(), '[s]', '[/s]'); node2bbcode($doc, 'big', array(), "[size=large]", "[/size]"); node2bbcode($doc, 'small', array(), "[size=small]", "[/size]"); diff --git a/view/js/main.js b/view/js/main.js index c3c2c850f..dd7b81ad4 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1465,7 +1465,6 @@ function b2h(s) { rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,""); rep(/\[img\](.*?)\[\/img\]/gi,""); - // FIXME - add zid() rep(/\[zrl=([^\]]+)\](.*?)\[\/zrl\]/gi,"$2"); rep(/\[zrl\](.*?)\[\/zrl\]/gi,"$1"); rep(/\[zmg=(.*?)x(.*?)\](.*?)\[\/zmg\]/gi,""); -- cgit v1.2.3 From 739a6128247d55cdab9a6432e28f5710310951b3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 11 Apr 2018 21:51:57 -0700 Subject: poll responses: start treating them as hidden activities now so that when this feature gets finished it will work flawlessly for versions greater than today. --- boot.php | 1 + include/conversation.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index b5de3a544..33302a71c 100755 --- a/boot.php +++ b/boot.php @@ -481,6 +481,7 @@ define ( 'ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain' ); define ( 'ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes' ); define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' ); define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' ); +define ( 'ACTIVITY_POLLRESPONSE', NAMESPACE_ZOT . '/activity/pollresponse' ); define ( 'ACTIVITY_OBJ_HEART', NAMESPACE_ZOT . '/activity/heart' ); diff --git a/include/conversation.php b/include/conversation.php index 3834d9866..82317ae95 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -404,7 +404,7 @@ function count_descendants($item) { * @return boolean */ function visible_activity($item) { - $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ]; + $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE ]; if(intval($item['item_notshown'])) return false; -- cgit v1.2.3 From 549f7a53b11d014993fbb550de97b6cdf45e0843 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 11 Apr 2018 22:27:59 -0700 Subject: util/dcp (server to cloud file copy) better handling when destination directory is the channel root --- util/dcp | 64 ++++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/util/dcp b/util/dcp index 677882193..ecef67804 100755 --- a/util/dcp +++ b/util/dcp @@ -28,9 +28,14 @@ if($argc < 3) { if(strpos($dstfile,'store/') === 0) $dstfile = substr($dstfile,6); - $nick = substr($dstfile,0,strpos($dstfile,'/')); - - $dstfile = substr($dstfile,strlen($nick)+1); + if(strpos($dstfile,'/')) + $nick = substr($dstfile,0,strpos($dstfile,'/')); + $dstfile = substr($dstfile,strlen($nick)+1); + } + else { + $nick = $dstfile; + $dstfile = ''; + } $channel = channelx_by_nick($nick); if(! $channel) @@ -43,38 +48,45 @@ if($argc < 3) { } } - + $rootdir = ((strlen(trim($dstfile,'/'))) ? false : true); + $isadir = false; if(($recursive) || ($argc > 3)) $isadir = true; - $r = q("select * from attach where display_path = '%s' and uid = %d limit 1", - dbesc($dstfile), - intval($channel['channel_id']) - ); - - if($r && $r[0]['is_dir']) { - $isadir = true; - $basepath = $dstfile; - $folder = $r[0]['hash']; + if($rootdir) { + $folder = ''; } else { - $pathname = (($isadir) ? $dstfile : dirname($dstfile)); - $arr = [ - 'pathname' => $pathname, - 'allow_cid' => $channel['channel_allow_cid'], - 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'], - ]; - $folder = ''; - if($pathname && $isadir) { - $x = attach_mkdirp($channel,$channel['channel_hash'],$arr); - if($x['success']) - $folder = $x['data']['hash']; + $r = q("select * from attach where display_path = '%s' and uid = %d limit 1", + dbesc($dstfile), + intval($channel['channel_id']) + ); + + if($r && $r[0]['is_dir']) { + $isadir = true; + $basepath = $dstfile; + $folder = $r[0]['hash']; + } + else { + $pathname = (($isadir) ? $dstfile : dirname($dstfile)); + $arr = [ + 'pathname' => $pathname, + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'], + ]; + + $folder = ''; + if($pathname && $isadir) { + $x = attach_mkdirp($channel,$channel['channel_hash'],$arr); + if($x['success']) + $folder = $x['data']['hash']; + } } } -- cgit v1.2.3