diff options
-rwxr-xr-x | boot.php | 5 | ||||
-rw-r--r-- | doc/bbcode.html | 3 | ||||
-rw-r--r-- | include/RedDAV/RedBrowser.php | 9 | ||||
-rw-r--r-- | include/bbcode.php | 4 | ||||
-rwxr-xr-x | include/items.php | 87 | ||||
-rw-r--r-- | include/text.php | 12 | ||||
-rw-r--r-- | library/tableofcontents/jquery.toc.js | 96 | ||||
-rw-r--r-- | mod/channel.php | 1 | ||||
-rw-r--r-- | mod/cloud.php | 58 | ||||
-rw-r--r-- | mod/connedit.php | 11 | ||||
-rw-r--r-- | mod/dav.php | 9 | ||||
-rw-r--r-- | mod/display.php | 1 | ||||
-rw-r--r-- | mod/home.php | 6 | ||||
-rw-r--r-- | mod/impel.php | 4 | ||||
-rw-r--r-- | mod/item.php | 40 | ||||
-rw-r--r-- | mod/network.php | 9 | ||||
-rw-r--r-- | mod/photos.php | 2 | ||||
-rw-r--r-- | mod/profiles.php | 5 | ||||
-rw-r--r-- | mod/search.php | 1 | ||||
-rw-r--r-- | mod/settings.php | 5 | ||||
-rw-r--r-- | version.inc | 2 | ||||
-rw-r--r-- | view/js/main.js | 2 | ||||
-rw-r--r-- | view/php/theme_init.php | 1 | ||||
-rwxr-xr-x | view/tpl/build_query.tpl | 2 |
24 files changed, 253 insertions, 122 deletions
@@ -221,7 +221,7 @@ define ( 'PAGE_NORMAL', 0x0000 ); define ( 'PAGE_HIDDEN', 0x0001 ); define ( 'PAGE_AUTOCONNECT', 0x0002 ); define ( 'PAGE_APPLICATION', 0x0004 ); - +define ( 'PAGE_ALLOWCODE', 0x0008 ); define ( 'PAGE_PREMIUM', 0x0010 ); define ( 'PAGE_ADULT', 0x0020 ); define ( 'PAGE_CENSORED', 0x0040 ); // Site admin has blocked this channel from appearing in casual search results and site feeds @@ -514,6 +514,7 @@ define ( 'ACTIVITY_OBJ_GROUP', NAMESPACE_ACTIVITY_SCHEMA . 'group' ); define ( 'ACTIVITY_OBJ_TAGTERM', NAMESPACE_ZOT . '/activity/tagterm' ); define ( 'ACTIVITY_OBJ_PROFILE', NAMESPACE_ZOT . '/activity/profile' ); define ( 'ACTIVITY_OBJ_THING', NAMESPACE_ZOT . '/activity/thing' ); +define ( 'ACTIVITY_OBJ_LOCATION',NAMESPACE_ZOT . '/activity/location' ); /** * item weight for query ordering @@ -569,7 +570,7 @@ define ( 'ITEM_ORIGIN', 0x0001); define ( 'ITEM_UNSEEN', 0x0002); define ( 'ITEM_STARRED', 0x0004); define ( 'ITEM_UPLINK', 0x0008); -define ( 'ITEM_UPLINK_PRV', 0x0010); +define ( 'ITEM_CONSENSUS', 0x0010); // an item which may present agree/disagree/abstain options define ( 'ITEM_WALL', 0x0020); define ( 'ITEM_THREAD_TOP', 0x0040); define ( 'ITEM_NOTSHOWN', 0x0080); // technically visible but not normally shown (e.g. like/dislike) diff --git a/doc/bbcode.html b/doc/bbcode.html index fac768879..f0b61b33c 100644 --- a/doc/bbcode.html +++ b/doc/bbcode.html @@ -65,7 +65,8 @@ <li>[rpost=title]Text to post[/rpost] The observer will be returned to their home hub to enter a post with the specified title and body. Both are optional <br /> <li>[qr]text to post[/qr] - create a QR code.<br /> -<br /> +<li>[toc] - create a table of content in a webpage (level h1,...,h4).<br /> +<br /><br /> </ul> <p>These require a suitable map plugin/addon such as openstreetmap or else the result will be blank</p> diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index 709f6339b..9ea2b9808 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -267,6 +267,15 @@ class RedBrowser extends DAV\Browser\Plugin { get_app()->page['content'] = $html; load_pdl(get_app()); + + $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php"; + if (file_exists($theme_info_file)){ + require_once($theme_info_file); + if (function_exists(str_replace('-', '_', current_theme()) . '_init')) { + $func = str_replace('-', '_', current_theme()) . '_init'; + $func(get_app()); + } + } construct_page(get_app()); } diff --git a/include/bbcode.php b/include/bbcode.php index 030a1fb49..33017c011 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -575,6 +575,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { if (strpos($Text,'[h6]') !== false) { $Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text); } + // Check for table of content + if (strpos($Text,'[toc]') !== false) { + $Text = preg_replace("/\[toc\]/ism",'<ul id="toc"></ul>',$Text); + } // Check for centered text if (strpos($Text,'[/center]') !== false) { $Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text); diff --git a/include/items.php b/include/items.php index 4c533aedc..fb2f2586a 100755 --- a/include/items.php +++ b/include/items.php @@ -419,6 +419,9 @@ function post_activity_item($arr) { $arr['verb'] = ((x($arr,'verb')) ? $arr['verb'] : ACTIVITY_POST); $arr['obj_type'] = ((x($arr,'obj_type')) ? $arr['obj_type'] : ACTIVITY_OBJ_NOTE); + if($is_comment) + $arr['obj_type'] = ACTIVITY_OBJ_COMMENT; + $arr['allow_cid'] = ((x($arr,'allow_cid')) ? $arr['allow_cid'] : $channel['channel_allow_cid']); $arr['allow_gid'] = ((x($arr,'allow_gid')) ? $arr['allow_gid'] : $channel['channel_allow_gid']); @@ -834,6 +837,11 @@ function get_item_elements($x) { $arr['item_flags'] = 0; + if(array_key_exists('flags',$x) && in_array('consensus',$x['flags'])) + $arr['item_flags'] |= ITEM_CONSENSUS; + + + if(array_key_exists('flags',$x) && in_array('deleted',$x['flags'])) $arr['item_restrict'] = ITEM_DELETED; if(array_key_exists('flags',$x) && in_array('hidden',$x['flags'])) @@ -1314,6 +1322,8 @@ function encode_item_flags($item) { $ret[] = 'thread_parent'; if($item['item_flags'] & ITEM_NSFW) $ret[] = 'nsfw'; + if($item['item_flags'] & ITEM_CONSENSUS) + $ret[] = 'consensus'; if($item['item_private']) $ret[] = 'private'; @@ -2019,8 +2029,8 @@ function item_store($arr,$allow_exec = false) { $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : ''); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : ''); $arr['thr_parent'] = ((x($arr,'thr_parent')) ? notags(trim($arr['thr_parent'])) : $arr['parent_mid']); - $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ''); - $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ''); + $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ACTIVITY_POST); + $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ACTIVITY_OBJ_NOTE); $arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : ''); $arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : ''); $arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : ''); @@ -2084,6 +2094,8 @@ function item_store($arr,$allow_exec = false) { return $ret; } + if($arr['obj_type'] == ACTIVITY_OBJ_NOTE) + $arr['obj_type'] = ACTIVITY_OBJ_COMMENT; // is the new message multi-level threaded? // even though we don't support it now, preserve the info @@ -2673,7 +2685,7 @@ function tag_deliver($uid,$item_id) { * Fetch stuff we need - a channel and an item */ - $u = q("select * from channel where channel_id = %d limit 1", + $u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($uid) ); if(! $u) @@ -2811,7 +2823,7 @@ function tag_deliver($uid,$item_id) { if($terms) logger('tag_deliver: post mentions: ' . print_r($terms,true), LOGGER_DATA); - $link = normalise_link($a->get_baseurl() . '/channel/' . $u[0]['channel_address']); + $link = normalise_link($u[0]['xchan_url']); if($terms) { foreach($terms as $term) { @@ -2952,7 +2964,7 @@ function tgroup_check($uid,$item) { if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) return false; - $u = q("select * from channel where channel_id = %d limit 1", + $u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($uid) ); @@ -2964,7 +2976,7 @@ function tgroup_check($uid,$item) { if($terms) logger('tgroup_check: post mentions: ' . print_r($terms,true), LOGGER_DATA); - $link = normalise_link($a->get_baseurl() . '/channel/' . $u[0]['channel_address']); + $link = normalise_link($u[0]['xchan_url']); if($terms) { foreach($terms as $term) { @@ -3939,7 +3951,7 @@ function drop_items($items) { // $stage = 1 => set deleted flag on the item and perform intial notifications // $stage = 2 => perform low level delete at a later stage -function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { +function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) { $a = get_app(); @@ -3959,6 +3971,8 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { $item = $r[0]; + $linked_item = (($item['resource_id']) ? true : false); + $ok_to_delete = false; // system deletion @@ -3980,10 +3994,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { // hook calls a remote process which loops. We'll delete it properly in a second. $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ) WHERE id = %d", - intval(ITEM_DELETED), + intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), intval($item['id']) ); + $arr = array('item' => $item, 'interactive' => $interactive, 'stage' => $stage); call_hooks('drop_item', $arr ); @@ -3995,10 +4010,10 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { ); if($items) { foreach($items as $i) - delete_item_lowlevel($i,$stage); + delete_item_lowlevel($i,$stage,$force); } else - delete_item_lowlevel($item,$stage); + delete_item_lowlevel($item,$stage,$force); if(! $interactive) return 1; @@ -4030,8 +4045,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { // It merely destroys all resources associated with an item. // Please do not use without a suitable wrapper. -function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { +function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) { + $linked_item = (($item['resource_id']) ? true : false); switch($stage) { case DROPITEM_PHASE2: @@ -4047,7 +4063,7 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { case DROPITEM_PHASE1: $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), changed = '%s', edited = '%s' WHERE id = %d", - intval(ITEM_DELETED), + intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($item['id']) @@ -4056,13 +4072,24 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { case DROPITEM_NORMAL: default: - $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', - changed = '%s', edited = '%s' WHERE id = %d", - intval(ITEM_DELETED), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item['id']) - ); + if($linked_item && ! $force) { + $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), + changed = '%s', edited = '%s' WHERE id = %d", + intval(ITEM_HIDDEN), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + } + else { + $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', + changed = '%s', edited = '%s' WHERE id = %d", + intval(ITEM_DELETED), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + } break; } @@ -4074,25 +4101,6 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { intval($item['uid']) ); - // If item is a link to a photo/event resource, nuke all the associated photos/events - // This only applies to photos uploaded from the photos page. Photos inserted into a post do not - // generate a resource_id and therefore aren't intimately linked to the item. - - if(strlen($item['resource_id'])) { - if($item['resource_type'] === 'event') { - q("delete from event where event_hash = '%s' and uid = %d", - dbesc($item['resource_id']), - intval($item['uid']) - ); - } - elseif($item['resource_type'] === 'photo') { - q("DELETE FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ", - dbesc($item['resource_id']), - intval($item['uid']) - ); - } - } - // network deletion request. Keep the message structure so that we can deliver delete notifications. // Come back after several days (or perhaps a month) to do the lowlevel delete (DROPITEM_PHASE2). @@ -4115,8 +4123,7 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { intval(TERM_OBJ_POST) ); -// FIXME remove notifications for this item - + // FIXME remove notifications for this item return true; } diff --git a/include/text.php b/include/text.php index 6b579e35c..c130a9b8a 100644 --- a/include/text.php +++ b/include/text.php @@ -92,10 +92,10 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') { return escape_tags($s); if($type == 'text/plain') return escape_tags($s); - $r = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", + $r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval($channel_id) ); - if($r && ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) { + if($r && (($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { if(local_user() && (get_account_id() == $r[0]['account_id'])) { return $s; } @@ -620,7 +620,7 @@ function get_tags($s) { // Match full names against @tags including the space between first and last // We will look these up afterward to see if they are full names or not recognisable. - if(preg_match_all('/(@[^ \x0D\x0A,:?]+ [^ \x0D\x0A@,:?]+)([ \x0D\x0A@,:?]|$)/',$s,$match)) { + if(preg_match_all('/(@[^ \x0D\x0A,:?\[]+ [^ \x0D\x0A@,:?\[]+)([ \x0D\x0A@,:?\[]|$)/',$s,$match)) { foreach($match[1] as $mtch) { if(strstr($mtch,"]")) { // we might be inside a bbcode color tag - leave it alone @@ -636,7 +636,7 @@ function get_tags($s) { // Otherwise pull out single word tags. These can be @nickname, @first_last // and #hash tags. - if(preg_match_all('/([@#][^ \x0D\x0A,;:?]+)([ \x0D\x0A,;:?]|$)/',$s,$match)) { + if(preg_match_all('/([@#][^ \x0D\x0A,;:?\[]+)([ \x0D\x0A,;:?\[]|$)/',$s,$match)) { foreach($match[1] as $mtch) { if(strstr($mtch,"]")) { // we might be inside a bbcode color tag - leave it alone @@ -1584,13 +1584,13 @@ function mimetype_select($channel_id, $current = 'text/bbcode') { 'text/plain' ); - $r = q("select account_id, account_roles from account left join channel on account_id = channel_account_id where + $r = q("select account_id, account_roles, channel_pageflags from account left join channel on account_id = channel_account_id where channel_id = %d limit 1", intval($channel_id) ); if($r) { - if($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) { + if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) { if(local_user() && get_account_id() == $r[0]['account_id']) $x[] = 'application/x-php'; } diff --git a/library/tableofcontents/jquery.toc.js b/library/tableofcontents/jquery.toc.js new file mode 100644 index 000000000..d136f5aab --- /dev/null +++ b/library/tableofcontents/jquery.toc.js @@ -0,0 +1,96 @@ +/* + * Table of Contents jQuery Plugin - jquery.toc + * + * Copyright 2013 Nikhil Dabas + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations + * under the License. + * + * The original script was modified to work within the red#martrix (added var pathname). + */ + +(function ($) { + "use strict"; + + // Builds a list with the table of contents in the current selector. + // options: + // content: where to look for headings + // headings: string with a comma-separated list of selectors to be used as headings, ordered + // by their relative hierarchy level + var toc = function (options) { + return this.each(function () { + var root = $(this), + data = root.data(), + thisOptions, + stack = [root], // The upside-down stack keeps track of list elements + listTag = this.tagName, + currentLevel = 0, + headingSelectors; + + // Defaults: plugin parameters override data attributes, which override our defaults + thisOptions = $.extend( + {content: "body", headings: "h1,h2,h3"}, + {content: data.toc || undefined, headings: data.tocHeadings || undefined}, + options + ); + headingSelectors = thisOptions.headings.split(","); + + // Set up some automatic IDs if we do not already have them + $(thisOptions.content).find(thisOptions.headings).attr("id", function (index, attr) { + // Generate a valid ID: must start with a letter, and contain only letters and + // numbers. All other characters are replaced with underscores. + return attr || + $(this).text().replace(/^[^A-Za-z]*/, "").replace(/[^A-Za-z0-9]+/g, "_"); + }).each(function () { + // What level is the current heading? + var elem = $(this), level = $.map(headingSelectors, function (selector, index) { + return elem.is(selector) ? index : undefined; + })[0]; + + if (level > currentLevel) { + // If the heading is at a deeper level than where we are, start a new nested + // list, but only if we already have some list items in the parent. If we do + // not, that means that we're skipping levels, so we can just add new list items + // at the current level. + // In the upside-down stack, unshift = push, and stack[0] = the top. + var parentItem = stack[0].children("li:last")[0]; + if (parentItem) { + stack.unshift($("<" + listTag + "/>").appendTo(parentItem)); + } + } else { + // Truncate the stack to the current level by chopping off the 'top' of the + // stack. We also need to preserve at least one element in the stack - that is + // the containing element. + stack.splice(0, Math.min(currentLevel - level, Math.max(stack.length - 1, 0))); + } + // the variable pathname was added to the original script. + var pathname = window.location.pathname; + // Add the list item + $("<li/>").appendTo(stack[0]).append( + $("<a/>").text(elem.text()).attr("href", pathname + "#" + elem.attr("id")) + ); + + currentLevel = level; + }); + }); + }, old = $.fn.toc; + + $.fn.toc = toc; + + $.fn.toc.noConflict = function () { + $.fn.toc = old; + return this; + }; + + // Data API + $(function () { + toc.call($("[data-toc]")); + }); +}(window.jQuery)); diff --git a/mod/channel.php b/mod/channel.php index e819de0e0..c8ac83baf 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -286,6 +286,7 @@ function channel_content(&$a, $update = 0, $load = false) { '$cats' => (($category) ? $category : ''), '$tags' => (($hashtags) ? $hashtags : ''), '$mid' => $mid, + '$verb' => '', '$dend' => $datequery, '$dbegin' => $datequery2 )); diff --git a/mod/cloud.php b/mod/cloud.php index abeae88eb..ad85eba34 100644 --- a/mod/cloud.php +++ b/mod/cloud.php @@ -3,7 +3,7 @@ * @file mod/cloud.php * @brief Initialize RedMatrix's cloud (SabreDAV). * - * Module for accessing the DAV storage area from a web client. + * Module for accessing the DAV storage area. */ use Sabre\DAV; @@ -12,45 +12,31 @@ use RedMatrix\RedDAV; // composer autoloader for SabreDAV require_once('vendor/autoload.php'); -if(! defined('TRINIDAD')) { - // workaround for HTTP-auth in CGI mode - if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { - $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } +// workaround for HTTP-auth in CGI mode +if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { + $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } +} - if (x($_SERVER, 'HTTP_AUTHORIZATION')) { - $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } +if (x($_SERVER, 'HTTP_AUTHORIZATION')) { + $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } } - - /** * @brief Fires up the SabreDAV server. * * @param App &$a */ function cloud_init(&$a) { - // call ($currenttheme)_init since we're operating outside of index.php - $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php"; - if (file_exists($theme_info_file)){ - require_once($theme_info_file); - if (function_exists(str_replace('-', '_', current_theme()) . '_init')) { - $func = str_replace('-', '_', current_theme()) . '_init'; - $func($a); - } - } - require_once('include/reddav.php'); if (! is_dir('store')) @@ -130,19 +116,13 @@ function cloud_init(&$a) { } if ((! $auth->observer) && (! $isapublic_file) && (! $davguest)) { - if(defined('TRINIDAD')) { + try { + $auth->Authenticate($server, t('RedMatrix - Guests: Username: {your email address}, Password: +++')); + } + catch (Exception $e) { logger('mod_cloud: auth exception' . $e->getMessage()); http_status_exit($e->getHTTPCode(), $e->getMessage()); } - else { - try { - $auth->Authenticate($server, t('RedMatrix channel')); - } - catch (Exception $e) { - logger('mod_cloud: auth exception' . $e->getMessage()); - http_status_exit($e->getHTTPCode(), $e->getMessage()); - } - } } require_once('include/RedDAV/RedBrowser.php'); diff --git a/mod/connedit.php b/mod/connedit.php index 49aae6684..5c36c3184 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -55,6 +55,15 @@ function connedit_post(&$a) { if(! $contact_id) return; + // TODO if configured for hassle-free permissions, we'll post the form with ajax as soon as the + // connection enable is toggled to a special autopost url and set permissions immediately, leaving + // the other form elements alone pending a manual submit of the form. The downside is that there + // will be a window of opportunity when the permissions have been set but before you've had a chance + // to review and possibly restrict them. The upside is we won't have to warn you that your connection + // can't do anything until you save the bloody form. + + $autopost = (((argc() > 2) && (argv(2) === 'auto')) ? true : false); + $orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($contact_id), intval(local_user()) @@ -287,7 +296,7 @@ function connedit_content(&$a) { $o .= "\$('#me_id_perms_" . $p . "').attr('checked','checked'); \n"; } } - $o .= "abook_perms_msg(); }\n</script>\n"; + $o .= " }\n</script>\n"; } if(argc() == 3) { diff --git a/mod/dav.php b/mod/dav.php index 1bff5ffbc..e3719cb93 100644 --- a/mod/dav.php +++ b/mod/dav.php @@ -37,15 +37,6 @@ if (x($_SERVER, 'HTTP_AUTHORIZATION')) { * @param App &$a */ function dav_init(&$a) { - // call ($currenttheme)_init since we're operating outside of index.php - $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php"; - if (file_exists($theme_info_file)){ - require_once($theme_info_file); - if (function_exists(str_replace('-', '_', current_theme()) . '_init')) { - $func = str_replace('-', '_', current_theme()) . '_init'; - $func($a); - } - } require_once('include/reddav.php'); diff --git a/mod/display.php b/mod/display.php index 7d7f4ca13..f14aca6da 100644 --- a/mod/display.php +++ b/mod/display.php @@ -136,6 +136,7 @@ function display_content(&$a, $update = 0, $load = false) { '$tags' => '', '$dend' => '', '$dbegin' => '', + '$verb' => '', '$mid' => $item_hash )); diff --git a/mod/home.php b/mod/home.php index b2538795f..2e57a2ab9 100644 --- a/mod/home.php +++ b/mod/home.php @@ -109,6 +109,11 @@ function home_content(&$a, $update = 0, $load = false) { } else { + if(get_config('system','disable_discover_tab')) { + call_hooks('home_content',$o); + return $o; + } + if(! $update) { $maxheight = get_config('system','home_divmore_height'); @@ -144,6 +149,7 @@ function home_content(&$a, $update = 0, $load = false) { '$tags' => '', '$dend' => '', '$mid' => '', + '$verb' => '', '$dbegin' => '' )); } diff --git a/mod/impel.php b/mod/impel.php index 1c7541bef..60e80ff9f 100644 --- a/mod/impel.php +++ b/mod/impel.php @@ -75,11 +75,11 @@ function impel_init(&$a) { $execflag = false; if($arr['mimetype'] === 'application/x-php') { - $z = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", + $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval(local_user()) ); - if($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) { + if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { $execflag = true; } } diff --git a/mod/item.php b/mod/item.php index e1855732e..b3370fecf 100644 --- a/mod/item.php +++ b/mod/item.php @@ -88,6 +88,7 @@ function item_post(&$a) { $pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags(urlencode($_REQUEST['pagetitle'])) : ''); $layout_mid = ((x($_REQUEST,'layout_mid')) ? escape_tags($_REQUEST['layout_mid']): ''); $plink = ((x($_REQUEST,'permalink')) ? escape_tags($_REQUEST['permalink']) : ''); + $obj_type = ((x($_REQUEST,'obj_type')) ? escape_tags($_REQUEST['obj_type']) : ACTIVITY_OBJ_NOTE); // allow API to bulk load a bunch of imported items with sending out a bunch of posts. $nopush = ((x($_REQUEST,'nopush')) ? intval($_REQUEST['nopush']) : 0); @@ -132,6 +133,9 @@ function item_post(&$a) { if(! x($_REQUEST,'type')) $_REQUEST['type'] = 'net-comment'; + if($obj_type == ACTIVITY_OBJ_POST) + $obj_type = ACTIVITY_OBJ_COMMENT; + if($parent) { $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($parent) @@ -449,10 +453,10 @@ function item_post(&$a) { $execflag = false; if($mimetype === 'application/x-php') { - $z = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", + $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval($profile_uid) ); - if($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) { + if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { if($uid && (get_account_id() == $z[0]['account_id'])) { $execflag = true; } @@ -578,20 +582,23 @@ function item_post(&$a) { // Look for tags and linkify them $results = linkify_tags($a, $body, ($uid) ? $uid : $profile_uid); - // Set permissions based on tag replacements - set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item); - - $post_tags = array(); - foreach($results as $result) { - $success = $result['success']; - if($success['replaced']) { - $post_tags[] = array( - 'uid' => $profile_uid, - 'type' => $success['termtype'], - 'otype' => TERM_OBJ_POST, - 'term' => $success['term'], - 'url' => $success['url'] - ); + if($results) { + + // Set permissions based on tag replacements + set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item); + + $post_tags = array(); + foreach($results as $result) { + $success = $result['success']; + if($success['replaced']) { + $post_tags[] = array( + 'uid' => $profile_uid, + 'type' => $success['termtype'], + 'otype' => TERM_OBJ_POST, + 'term' => $success['term'], + 'url' => $success['url'] + ); + } } } @@ -699,6 +706,7 @@ function item_post(&$a) { $datarray['location'] = $location; $datarray['coord'] = $coord; $datarray['verb'] = $verb; + $datarray['obj_type'] = $obj_type; $datarray['allow_cid'] = $str_contact_allow; $datarray['allow_gid'] = $str_group_allow; $datarray['deny_cid'] = $str_contact_deny; diff --git a/mod/network.php b/mod/network.php index d444dbd59..65332e3f6 100644 --- a/mod/network.php +++ b/mod/network.php @@ -47,7 +47,7 @@ function network_content(&$a, $update = 0, $load = false) { $gid = ((x($_GET,'gid')) ? intval($_GET['gid']) : 0); $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); - + $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); $search = (($_GET['search']) ? $_GET['search'] : ''); if($search) { @@ -251,6 +251,7 @@ function network_content(&$a, $update = 0, $load = false) { '$tags' => $hashtags, '$dend' => $datequery, '$mid' => '', + '$verb' => $verb, '$dbegin' => $datequery2 )); } @@ -279,6 +280,12 @@ function network_content(&$a, $update = 0, $load = false) { } } + if($verb) { + $sql_extra .= sprintf(" AND item.verb like '%s' ", + dbesc(protect_sprintf('%' . $verb . '%')) + ); + } + if(strlen($file)) { $sql_extra .= term_query('item',$file,TERM_FILE); } diff --git a/mod/photos.php b/mod/photos.php index 3a7ef2d71..b2eb2847f 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -140,7 +140,7 @@ function photos_post(&$a) { ); if($r) { foreach($r as $i) { - drop_item($i['id'],false); + drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */); if(! $item_restrict) proc_run('php','include/notifier.php','drop',$i['id']); } diff --git a/mod/profiles.php b/mod/profiles.php index 11cd86645..ef5f6b379 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -296,6 +296,8 @@ function profiles_post(&$a) { $work = fix_mce_lf(escape_tags(trim($_POST['work']))); $education = fix_mce_lf(escape_tags(trim($_POST['education']))); + $hide_friends = ((intval($_POST['hide_friends'])) ? 1: 0); + require_once('include/text.php'); linkify_tags($a, $likes, local_user()); linkify_tags($a, $dislikes, local_user()); @@ -312,7 +314,6 @@ function profiles_post(&$a) { linkify_tags($a, $work, local_user()); linkify_tags($a, $education, local_user()); - $hide_friends = (($_POST['hide_friends'] == 1) ? 1: 0); $with = ((x($_POST,'with')) ? escape_tags(trim($_POST['with'])) : ''); @@ -621,7 +622,7 @@ function profiles_content(&$a) { $opt_tpl = get_markup_template("profile_hide_friends.tpl"); $hide_friends = replace_macros($opt_tpl,array('$field' => array( - 'hide-friends', + 'hide_friends', t('Hide your contact/friend list from viewers of this profile?'), $r[0]['hide_friends'], '', diff --git a/mod/search.php b/mod/search.php index 6df9d631a..2ea6ad86f 100644 --- a/mod/search.php +++ b/mod/search.php @@ -109,6 +109,7 @@ function search_content(&$a,$update = 0, $load = false) { '$cats' => '', '$tags' => '', '$mid' => '', + '$verb' => '', '$dend' => '', '$dbegin' => '' )); diff --git a/mod/settings.php b/mod/settings.php index 59ce98a2a..902213446 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -1004,7 +1004,10 @@ function settings_content(&$a) { $evdays = 3; $permissions_role = get_pconfig(local_user(),'system','permissions_role'); - $permissions_set = (($permissions_role && $permissions_role != 'custom') ? true : false); + if(! $permissions_role) + $permissions_role = 'custom'; + + $permissions_set = (($permissions_role != 'custom') ? true : false); $vnotify = get_pconfig(local_user(),'system','vnotify'); $always_show_in_notices = get_pconfig(local_user(),'system','always_show_in_notices'); if($vnotify === false) diff --git a/version.inc b/version.inc index 117991bf8..7eb391e00 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-01-11.916 +2015-01-14.918 diff --git a/view/js/main.js b/view/js/main.js index 9d5136c34..0c56c8d41 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1125,6 +1125,8 @@ $(document).ready(function() { $(".autotime").timeago(); + $("#toc").toc({content: "div.page-body", headings: "h1,h2,h3,h4"}); + }); diff --git a/view/php/theme_init.php b/view/php/theme_init.php index d43a87046..b3580b81f 100644 --- a/view/php/theme_init.php +++ b/view/php/theme_init.php @@ -43,6 +43,7 @@ head_add_js('library/colorbox/jquery.colorbox-min.js'); head_add_js('library/bootstrap-tagsinput/bootstrap-tagsinput.js'); head_add_js('library/jquery.AreYouSure/jquery.are-you-sure.js'); +head_add_js('library/tableofcontents/jquery.toc.js'); /** * Those who require this feature will know what to do with it. * Those who don't, won't. diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl index 8110b70b1..62f81b618 100755 --- a/view/tpl/build_query.tpl +++ b/view/tpl/build_query.tpl @@ -26,6 +26,7 @@ var bParam_dend = "{{$dend}}"; var bParam_dbegin = "{{$dbegin}}"; var bParam_mid = "{{$mid}}"; + var bParam_verb = "{{$verb}}"; function buildCmd() { var udargs = ((page_load) ? "/load" : ""); @@ -51,6 +52,7 @@ if(bParam_dend != "") bCmd = bCmd + "&dend=" + bParam_dend; if(bParam_dbegin != "") bCmd = bCmd + "&dbegin=" + bParam_dbegin; if(bParam_mid != "") bCmd = bCmd + "&mid=" + bParam_mid; + if(bParam_verb != "") bCmd = bCmd + "&verb=" + bParam_verb; if(bParam_page != 1) bCmd = bCmd + "&page=" + bParam_page; return(bCmd); } |