diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/account.php | 18 | ||||
-rw-r--r-- | include/attach.php | 4 | ||||
-rw-r--r-- | include/bb2diaspora.php | 4 | ||||
-rw-r--r-- | include/channel.php | 38 | ||||
-rw-r--r-- | include/conversation.php | 16 | ||||
-rw-r--r-- | include/features.php | 1 | ||||
-rw-r--r-- | include/import.php | 29 | ||||
-rwxr-xr-x | include/items.php | 6 | ||||
-rw-r--r-- | include/js_strings.php | 8 | ||||
-rw-r--r-- | include/nav.php | 19 | ||||
-rw-r--r-- | include/network.php | 7 | ||||
-rw-r--r-- | include/widgets.php | 15 | ||||
-rw-r--r-- | include/wiki.php | 77 |
13 files changed, 186 insertions, 56 deletions
diff --git a/include/account.php b/include/account.php index caf12878e..c02a74928 100644 --- a/include/account.php +++ b/include/account.php @@ -499,11 +499,27 @@ function account_approve($hash) { intval($register[0]['uid']) ); + // get a fresh copy after we've modified it. + + $account = q("SELECT * FROM account WHERE account_id = %d LIMIT 1", + intval($register[0]['uid']) + ); + + if(! $account) + return $ret; + + + if(get_config('system','auto_channel_create') || UNO) auto_channel_create($register[0]['uid']); + else { + $_SESSION['login_return_url'] = 'new_channel'; + authenticate_success($account[0],true,true,false,true); + } + - info( t('Account verified. Please login.') . EOL ); + // info( t('Account verified. Please login.') . EOL ); return true; } diff --git a/include/attach.php b/include/attach.php index 4961d7f91..b3ddfee88 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1468,7 +1468,7 @@ function find_filename_by_hash($channel_id, $attachHash) { function pipe_streams($in, $out) { $size = 0; while (!feof($in)) - $size += fwrite($out, fread($in, 8192)); + $size += fwrite($out, fread($in, 16384)); return $size; } @@ -1909,4 +1909,4 @@ function get_attach_binname($s) { $p = substr($p,strpos($p,'/')+1); } return $p; -}
\ No newline at end of file +} diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index c7d0e56b1..16f67dc4a 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -302,11 +302,11 @@ function bb2diaspora_itemwallwall(&$item) { } } - if(($wallwall) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { + if(($wallwall) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_s']) { logger('bb2diaspora_itemwallwall: wall to wall post',LOGGER_DEBUG); // post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author. $item['body'] = "\n\n" - . '[img]' . $item['author']['xchan_photo_m'] . '[/img]' + . '[img]' . $item['author']['xchan_photo_s'] . '[/img]' . '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n" . $item['body']; } diff --git a/include/channel.php b/include/channel.php index 913768017..95506ed78 100644 --- a/include/channel.php +++ b/include/channel.php @@ -747,6 +747,44 @@ function identity_export_year($channel_id,$year,$month = 0) { return $ret; } +// export items within an arbitrary date range. Date/time is in UTC. + +function channel_export_items($channel_id,$start,$finish) { + + if(! $start) + return array(); + else + $start = datetime_convert('UTC','UTC',$start); + + $finish = datetime_convert('UTC','UTC',(($finish) ? $finish : 'now')); + if($finish < $start) + return array(); + + $ret = array(); + + $ch = channelx_by_n($channel_id); + if($ch) { + $ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()]; + } + + $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created", + intval(ITEM_TYPE_POST), + intval($channel_id), + dbesc($start), + dbesc($finish) + ); + + if($r) { + $ret['item'] = array(); + xchan_query($r); + $r = fetch_post_tags($r,true); + foreach($r as $rr) + $ret['item'][] = encode_item($rr,true); + } + + return $ret; +} + /** * @brief Loads a profile into the App structure. diff --git a/include/conversation.php b/include/conversation.php index d2d4ffca0..957dbf8e9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1703,13 +1703,19 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'title' => t('Manage Webpages'), 'id' => 'webpages-tab', ); - } else { - /** - * @FIXME we probably need a listing of events that were created by - * this channel and are visible to the observer - */ + } + + if(feature_enabled($uid,'wiki') && (! UNO)) { + $tabs[] = array( + 'label' => t('Wiki'), + 'url' => z_root() . '/wiki/' . $nickname, + 'sel' => ((argv(0) == 'wiki') ? 'active' : ''), + 'title' => t('Wiki'), + 'id' => 'wiki-tab', + ); } + $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs); call_hooks('profile_tabs', $arr); diff --git a/include/features.php b/include/features.php index 6d38bcfb4..2d71aa9be 100644 --- a/include/features.php +++ b/include/features.php @@ -52,6 +52,7 @@ function get_features($filtered = true) { array('advanced_profiles', t('Advanced Profiles'), t('Additional profile sections and selections'),false,get_config('feature_lock','advanced_profiles')), array('profile_export', t('Profile Import/Export'), t('Save and load profile details across sites/channels'),false,get_config('feature_lock','profile_export')), array('webpages', t('Web Pages'), t('Provide managed web pages on your channel'),false,get_config('feature_lock','webpages')), + array('wiki', t('Wiki'), t('Provide a wiki for your channel'),((UNO) ? false : true),get_config('feature_lock','wiki')), array('hide_rating', t('Hide Rating'), t('Hide the rating buttons on your channel and profile pages. Note: People can still rate you somewhere else.'),false,get_config('feature_lock','hide_rating')), array('private_notes', t('Private Notes'), t('Enables a tool to store notes and reminders (note: not encrypted)'),false,get_config('feature_lock','private_notes')), array('nav_channel_select', t('Navigation Channel Select'), t('Change channels directly from within the navigation dropdown menu'),false,get_config('feature_lock','nav_channel_select')), diff --git a/include/import.php b/include/import.php index 982eeb138..00ecef07d 100644 --- a/include/import.php +++ b/include/import.php @@ -575,12 +575,20 @@ function import_items($channel,$items,$sync = false,$relocate = null) { if(! $item) continue; + if($relocate && $item['mid'] === $item['parent_mid']) { + item_url_replace($channel,$item,$relocate['url'],z_root(),$relocate['channel_address']); + } + $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($channel['channel_id']) ); if($r) { - if($item['edited'] > $r[0]['edited']) { + + // flags may have changed and we are probably relocating the post, + // so force an update even if we have the same timestamp + + if($item['edited'] >= $r[0]['edited']) { $item['id'] = $r[0]['id']; $item['uid'] = $channel['channel_id']; $item_result = item_store_update($item,$allow_code,$deliver); @@ -595,24 +603,7 @@ function import_items($channel,$items,$sync = false,$relocate = null) { if($sync && $item['item_wall']) { // deliver singletons if we have any if($item_result && $item_result['success']) { - Zotlabs\Daemon\Master::Summon(array('Notifier','single_activity',$item_result['item_id'])); - } - } - if($relocate && $item_result['item_id']) { - $item = $item_result['item']; - if($item['mid'] === $item['parent_mid']) { - item_url_replace($channel,$item,$relocate['url'],z_root(),$relocate['channel_address']); - dbesc_array($item); - $item_id = $item_result['item_id']; - unset($item['id']); - $str = ''; - foreach($item as $k => $v) { - if($str) - $str .= ","; - $str .= " `" . $k . "` = '" . $v . "' "; - } - - $r = dbq("update `item` set " . $str . " where id = " . $item_id ); + Zotlabs\Daemon\Master::Summon( [ 'Notifier','single_activity',$item_result['item_id'] ]); } } } diff --git a/include/items.php b/include/items.php index 84683273d..48358c0e4 100755 --- a/include/items.php +++ b/include/items.php @@ -449,11 +449,7 @@ function post_activity_item($arr) { call_hooks('post_local_end', $arr); Zotlabs\Daemon\Master::Summon(array('Notifier','activity',$post_id)); $ret['success'] = true; - $r = q("select * from item where id = %d limit 1", - intval($post_id) - ); - if($r) - $ret['activity'] = $r[0]; + $ret['activity'] = $post['item']; } return $ret; diff --git a/include/js_strings.php b/include/js_strings.php index b1817f373..1b4668061 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -4,10 +4,10 @@ function js_strings() { return replace_macros(get_markup_template('js_strings.tpl'), array( '$delitem' => t('Delete this item?'), '$comment' => t('Comment'), - '$showmore' => t('[+] show all'), - '$showfewer' => t('[-] show less'), - '$divgrowmore' => t('[+] expand'), - '$divgrowless' => t('[-] collapse'), + '$showmore' => sprintf( t('%s show all'), '<i class=\'fa fa-chevron-down\'></i>'), + '$showfewer' => sprintf( t('%s show less'), '<i class=\'fa fa-chevron-up\'></i>'), + '$divgrowmore' => sprintf( t('%s expand'), '<i class=\'fa fa-chevron-down\'></i>'), + '$divgrowless' => sprintf( t('%s collapse'),'<i class=\'fa fa-chevron-up\'></i>'), '$pwshort' => t("Password too short"), '$pwnomatch' => t("Passwords do not match"), '$everybody' => t('everybody'), diff --git a/include/nav.php b/include/nav.php index 70faec598..1fb0e98dc 100644 --- a/include/nav.php +++ b/include/nav.php @@ -104,6 +104,8 @@ EOT; if(feature_enabled($channel['channel_id'],'webpages') && (! UNO)) $nav['usermenu'][] = Array('webpages/' . $channel['channel_address'],t('Webpages'),"",t('Your webpages'),'webpages_nav_btn'); + if(feature_enabled($channel['channel_id'],'wiki') && (! UNO)) + $nav['usermenu'][] = Array('wiki/' . $channel['channel_address'],t('Wiki'),"",t('Your wiki'),'wiki_nav_btn'); } else { if(! get_account_id()) { @@ -126,7 +128,7 @@ EOT; $nav['lock'] = array('logout','','lock', sprintf( t('%s - click to logout'), $observer['xchan_addr'])); } - else { + elseif(! $_SESSION['authenticated']) { $nav['loginmenu'][] = Array('rmagic',t('Remote authentication'),'',t('Click to authenticate to your home hub'),'rmagic_nav_btn'); } @@ -143,7 +145,7 @@ EOT; if((App::$module != 'home') && (! (local_channel()))) $nav['home'] = array($homelink, t('Home'), "", t('Home Page'),'home_nav_btn'); - if((App::$config['system']['register_policy'] == REGISTER_OPEN) && (! local_channel()) && (! remote_channel())) + if((App::$config['system']['register_policy'] == REGISTER_OPEN) && (! $_SESSION['authenticated'])) $nav['register'] = array('register',t('Register'), "", t('Create an account'),'register_nav_btn'); if(! get_config('system','hide_help')) { @@ -253,6 +255,19 @@ $powered_by = ''; '$pleasewait' => t('Please wait...') )); + + if(x($_SESSION, 'reload_avatar') && $observer) { + // The avatar has been changed on the server but the browser doesn't know that, + // force the browser to reload the image from the server instead of its cache. + $tpl = get_markup_template('force_image_reload.tpl'); + + App::$page['nav'] .= replace_macros($tpl, array( + '$imgUrl' => $observer['xchan_photo_m'] + )); + unset($_SESSION['reload_avatar']); + } + + call_hooks('page_header', App::$page['nav']); } diff --git a/include/network.php b/include/network.php index 96bf714f6..47863b680 100644 --- a/include/network.php +++ b/include/network.php @@ -101,6 +101,9 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { if(x($opts,'cookiefile')) @curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']); + if(x($opts,'cookie')) + @curl_setopt($ch, CURLOPT_COOKIE, $opts['cookie']); + @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, ((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true)); @@ -258,6 +261,10 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) { if(x($opts,'cookiefile')) @curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']); + + if(x($opts,'cookie')) + @curl_setopt($ch, CURLOPT_COOKIE, $opts['cookie']); + @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, ((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true)); diff --git a/include/widgets.php b/include/widgets.php index 8a7f4b69f..7fc3f1aeb 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -743,21 +743,6 @@ function widget_conversations($arr) { return $o; } -function widget_eventsmenu($arr) { - if (! local_channel()) - return; - - return replace_macros(get_markup_template('events_menu_side.tpl'), array( - '$title' => t('Events Menu'), - '$day' => t('Day View'), - '$week' => t('Week View'), - '$month' => t('Month View'), - '$export' => t('Export'), - '$upload' => t('Import'), - '$submit' => t('Submit') - )); -} - function widget_eventstools($arr) { if (! local_channel()) return; diff --git a/include/wiki.php b/include/wiki.php index 63cf70f3c..424b2d9a0 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -493,4 +493,79 @@ function wiki_convert_links($s, $wikiURL) { } } return $s; -}
\ No newline at end of file +} + +function wiki_generate_toc($s) { + + if (strpos($s,'[toc]') !== false) { + //$toc_md = wiki_toc($s); // Generate Markdown-formatted list prior to HTML render + $toc_md = '<ul id="wiki-toc"></ul>'; // use the available jQuery plugin http://ndabas.github.io/toc/ + $s = preg_replace("/\[toc\]/", $toc_md, $s, -1); + } + return $s; +} + +// This function is derived from +// http://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php +function wiki_toc($content) { + // ensure using only "\n" as line-break + $source = str_replace(["\r\n", "\r"], "\n", $content); + + // look for markdown TOC items + preg_match_all( + '/^(?:=|-|#).*$/m', + $source, + $matches, + PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE + ); + + // preprocess: iterate matched lines to create an array of items + // where each item is an array(level, text) + $file_size = strlen($source); + foreach ($matches[0] as $item) { + $found_mark = substr($item[0], 0, 1); + if ($found_mark == '#') { + // text is the found item + $item_text = $item[0]; + $item_level = strrpos($item_text, '#') + 1; + $item_text = substr($item_text, $item_level); + } else { + // text is the previous line (empty if <hr>) + $item_offset = $item[1]; + $prev_line_offset = strrpos($source, "\n", -($file_size - $item_offset + 2)); + $item_text = + substr($source, $prev_line_offset, $item_offset - $prev_line_offset - 1); + $item_text = trim($item_text); + $item_level = $found_mark == '=' ? 1 : 2; + } + if (!trim($item_text) OR strpos($item_text, '|') !== FALSE) { + // item is an horizontal separator or a table header, don't mind + continue; + } + $raw_toc[] = ['level' => $item_level, 'text' => trim($item_text)]; + } + $o = ''; + foreach($raw_toc as $t) { + $level = intval($t['level']); + $text = $t['text']; + switch ($level) { + case 1: + $li = '* '; + break; + case 2: + $li = ' * '; + break; + case 3: + $li = ' * '; + break; + case 4: + $li = ' * '; + break; + default: + $li = '* '; + break; + } + $o .= $li . $text . "\n"; + } + return $o; +} |