aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ItemObject.php15
-rw-r--r--include/bbcode.php42
-rw-r--r--include/chat.php44
-rw-r--r--include/comanche.php25
-rw-r--r--include/conversation.php5
-rw-r--r--include/dir_fns.php27
-rw-r--r--include/directory.php8
-rw-r--r--include/identity.php15
-rwxr-xr-xinclude/items.php148
-rw-r--r--include/notifier.php8
-rw-r--r--include/page_widgets.php54
-rw-r--r--include/permissions.php2
-rw-r--r--include/reddav.php16
-rw-r--r--include/security.php20
-rw-r--r--include/socgraph.php8
-rwxr-xr-xinclude/text.php22
-rw-r--r--include/widgets.php2
-rw-r--r--include/zot.php6
18 files changed, 341 insertions, 126 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 2922ee473..36070335d 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -123,6 +123,14 @@ class Item extends BaseObject {
$location = format_location($item);
+ $like_count = ((x($alike,$item['mid'])) ? $alike[$item['mid']] : '');
+ $like_list = ((x($alike,$item['mid'])) ? $alike[$item['mid'] . '-l'] : '');
+ $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('like') : t('likes'));
+ if (feature_enabled($conv->get_profile_owner(),'dislike')) {
+ $dislike_count = ((x($dlike,$item['mid'])) ? $dlike[$item['mid']] : '');
+ $dislike_list = ((x($dlike,$item['mid'])) ? $dlike[$item['mid'] . '-l'] : '');
+ $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('dislike') : t('dislikes'));
+ }
$showlike = ((x($alike,$item['mid'])) ? format_like($alike[$item['mid']],$alike[$item['mid'] . '-l'],'like',$item['mid']) : '');
$showdislike = ((x($dlike,$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike'))
@@ -251,7 +259,12 @@ class Item extends BaseObject {
'drop' => $drop,
'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''),
// end toolbar buttons
-
+ 'like_count' => $like_count,
+ 'like_list' => $like_list,
+ 'like_button_label' => $like_button_label,
+ 'dislike_count' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_count : ''),
+ 'dislike_list' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list : ''),
+ 'dislike_button_label' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_button_label : ''),
'showlike' => $showlike,
'showdislike' => $showdislike,
'comment' => $this->get_comment_box($indent),
diff --git a/include/bbcode.php b/include/bbcode.php
index 526007306..a4e7560d6 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -200,6 +200,12 @@ function bb_ShareAttributes($match) {
if ($matches[1] != "")
$posted = $matches[1];
+ $message_id = "";
+ preg_match("/message_id='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $message_id = $matches[1];
+
+
// FIXME - this should really be a wall-item-ago so it will get updated on the client
$reldate = (($posted) ? relative_date($posted) : '');
@@ -501,6 +507,30 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1px;\">$2</span>",$Text);
$Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1;\">$2</span>",$Text);
}
+ // Check for h1
+ if (strpos($Text,'[h1]') !== false) {
+ $Text = preg_replace("(\[h1\](.*?)\[\/h1\])ism",'<h1>$1</h1>',$Text);
+ }
+ // Check for h2
+ if (strpos($Text,'[h2]') !== false) {
+ $Text = preg_replace("(\[h2\](.*?)\[\/h2\])ism",'<h2>$1</h2>',$Text);
+ }
+ // Check for h3
+ if (strpos($Text,'[h3]') !== false) {
+ $Text = preg_replace("(\[h3\](.*?)\[\/h3\])ism",'<h3>$1</h3>',$Text);
+ }
+ // Check for h4
+ if (strpos($Text,'[h4]') !== false) {
+ $Text = preg_replace("(\[h4\](.*?)\[\/h4\])ism",'<h4>$1</h4>',$Text);
+ }
+ // Check for h5
+ if (strpos($Text,'[h5]') !== false) {
+ $Text = preg_replace("(\[h5\](.*?)\[\/h5\])ism",'<h5>$1</h5>',$Text);
+ }
+ // Check for h6
+ if (strpos($Text,'[h6]') !== false) {
+ $Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text);
+ }
// Check for centered text
if (strpos($Text,'[/center]') !== false) {
$Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text);
@@ -600,24 +630,24 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Images
// [img]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) {
- $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
- $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" style="max-width=100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text);
}
// [img float={left, right}]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) {
- $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '<img src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/img]') !== false) {
- $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '<img src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
- $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '<img style="max-width=100%;" class="zrl" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
- $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '<img style="max-width=100%;" class="zrl" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
}
// [img=widthxheight]pathtoimage[/img]
diff --git a/include/chat.php b/include/chat.php
index 5a17230e0..4c79319ee 100644
--- a/include/chat.php
+++ b/include/chat.php
@@ -84,6 +84,9 @@ function chatroom_destroy($channel,$arr) {
q("delete from chatpresence where cp_room = %d",
intval($r[0]['cr_id'])
);
+ q("delete from chat where chat_room = %d",
+ intval($r[0]['cr_id'])
+ );
}
$ret['success'] = true;
return $ret;
@@ -182,3 +185,44 @@ function chatroom_list($uid) {
return $r;
}
+
+/**
+ * create a chat message via API.
+ * It is the caller's responsibility to enter the room.
+ */
+
+function chat_message($uid,$room_id,$xchan,$text) {
+
+ $ret = array('success' => false);
+
+ if(! $text)
+ return;
+
+ $sql_extra = permissions_sql($uid);
+
+ $r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra",
+ intval($uid),
+ intval($room_id)
+ );
+ if(! $r)
+ return $ret;
+
+ $arr = array(
+ 'chat_room' => $room_id,
+ 'chat_xchan' => $xchan,
+ 'chat_text' => $text
+ );
+
+ call_hooks('chat_message',$arr);
+
+ $x = q("insert into chat ( chat_room, chat_xchan, created, chat_text )
+ values( %d, '%s', '%s', '%s' )",
+ intval($room_id),
+ dbesc($xchan),
+ dbesc(datetime_convert()),
+ dbesc($arr['chat_text'])
+ );
+
+ $ret['success'] = true;
+ return $ret;
+}
diff --git a/include/comanche.php b/include/comanche.php
index 13146ded4..b0eac475d 100644
--- a/include/comanche.php
+++ b/include/comanche.php
@@ -223,3 +223,28 @@ function comanche_region(&$a,$s) {
return $s;
}
+
+/*
+ * @function register_page_template($arr)
+ * Registers a page template/variant for use by Comanche selectors
+ * @param array $arr
+ * 'template' => template name
+ * 'variant' => array(
+ * 'name' => variant name
+ * 'desc' => text description
+ * 'regions' => array(
+ * 'name' => name
+ * 'desc' => text description
+ * )
+ * )
+ */
+
+
+function register_page_template($arr) {
+ get_app()->page_layouts[$arr['template']] = array($arr['variant']);
+ return;
+}
+
+
+
+
diff --git a/include/conversation.php b/include/conversation.php
index 541da1d9b..2d72f3489 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1303,11 +1303,9 @@ function render_location_default($item) {
function prepare_page($item) {
-
$a = get_app();
$naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0);
$observer = $a->get_observer();
- $zid = ($observer['xchan_addr']);
//240 chars is the longest we can have before we start hitting problems with suhosin sites
$preview = substr(urlencode($item['body']), 0, 240);
$link = z_root() . '/' . $a->cmd;
@@ -1318,8 +1316,7 @@ function prepare_page($item) {
}
return replace_macros(get_markup_template('page_display.tpl'),array(
'$author' => (($naked) ? '' : $item['author']['xchan_name']),
- '$auth_url' => (($naked) ? '' : $item['author']['xchan_url']),
- '$zid' => $zid,
+ '$auth_url' => (($naked) ? '' : zid($item['author']['xchan_url'])),
'$date' => (($naked) ? '' : datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i')),
'$title' => smilies(bbcode($item['title'])),
'$body' => prepare_body($item,true),
diff --git a/include/dir_fns.php b/include/dir_fns.php
index aeee8492f..a96e7821f 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -3,10 +3,31 @@
require_once('include/permissions.php');
function find_upstream_directory($dirmode) {
+ global $DIRECTORY_FALLBACK_SERVERS;
+
$preferred = get_config('system','directory_server');
- if($preferred)
- return array('url' => $preferred);
- return '';
+ if(! $preferred) {
+
+ /**
+ * No directory has yet been set. For most sites, pick one at random
+ * from our list of directory servers. However, if we're a directory
+ * server ourself, point at the local instance
+ * We will then set this value so this should only ever happen once.
+ * Ideally there will be an admin setting to change to a different
+ * directory server if you don't like our choice or if circumstances change.
+ */
+
+ $dirmode = intval(get_config('system','directory_mode'));
+ if($dirmode == DIRECTORY_MODE_NORMAL) {
+ $toss = mt_rand(0,count($DIRECTORY_FALLBACK_SERVERS));
+ $preferred = $DIRECTORY_FALLBACK_SERVERS[$toss];
+ set_config('system','directory_server',$preferred);
+ }
+ else{
+ set_config('system','directory_server',z_root());
+ }
+ }
+ return array('url' => $preferred);
}
function dir_sort_links() {
diff --git a/include/directory.php b/include/directory.php
index c69fb1f4b..c51fe765f 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -48,13 +48,7 @@ function directory_run($argv, $argc){
}
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/post';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/post';
- }
+ $url = $directory['url'] . '/post';
// ensure the upstream directory is updated
diff --git a/include/identity.php b/include/identity.php
index b66eaad51..4352f026a 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -953,15 +953,20 @@ function advanced_profile(&$a) {
if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
+
+ $val = '';
+
+ if((substr($a->profile['dob'],5,2) === '00') || (substr($a->profile['dob'],8,2) === '00'))
+ $val = substr($a->profile['dob'],0,4);
$year_bd_format = t('j F, Y');
$short_bd_format = t('j F');
-
- $val = ((intval($a->profile['dob']))
- ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format))
- : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format)));
-
+ if(! $val) {
+ $val = ((intval($a->profile['dob']))
+ ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format))
+ : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format)));
+ }
$profile['birthday'] = array( t('Birthday:'), $val);
}
diff --git a/include/items.php b/include/items.php
index f6efea58c..7a94336be 100755
--- a/include/items.php
+++ b/include/items.php
@@ -9,13 +9,6 @@ require_once('include/permissions.php');
function collect_recipients($item,&$private) {
-// FIXME - this needs a revision to handle public scope (this site, this network, etc.)
-// We'll be changing this to return an array of
-// - recipients
-// - private
-// - scope if message is public ('global', 'network: red', 'site: $sitename', 'connections')
-// The receiving site will need to check the scope before creating a list of local recipients
-
require_once('include/group.php');
$private = ((intval($item['item_private'])) ? true : false);
@@ -113,6 +106,7 @@ function collect_recipients($item,&$private) {
* If it is, you should be able to use perm_is_allowed( ... 'post_comments'), and if it isn't you need to call
* can_comment_on_post()
*/
+
function can_comment_on_post($observer_xchan,$item) {
// logger('can_comment_on_post: comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG);
@@ -153,6 +147,21 @@ function can_comment_on_post($observer_xchan,$item) {
return false;
}
+/**
+ * @function add_source_route($iid,$hash)
+ * Adds $hash to the item source route specified by $iid
+ * @param integer $iid
+ * item['id'] of target item
+ * @param string $hash
+ * xchan_hash of the channel that sent the item
+ * Modifies item pointed to by $iid
+ *
+ * $item['route'] contains a comma-separated list of xchans that sent the current message,
+ * somewhat analogous to the * Received: header line in email. We can use this to perform
+ * loop detection and to avoid sending a particular item to any "upstream" sender (they
+ * already have a copy because they sent it to us).
+ *
+ */
function add_source_route($iid,$hash) {
// logger('add_source_route ' . $iid . ' ' . $hash, LOGGER_DEBUG);
@@ -352,6 +361,10 @@ function post_activity_item($arr) {
}
+/**
+ * @function get_public_feed($channel,$params)
+ * generate an Atom feed
+ */
function get_public_feed($channel,$params) {
@@ -388,6 +401,9 @@ function get_public_feed($channel,$params) {
return get_feed_for($channel,get_observer_hash(),$params);
}
+
+
+
function get_feed_for($channel, $observer_hash, $params) {
if(! channel)
@@ -1822,6 +1838,9 @@ function item_store($arr,$allow_exec = false) {
return $ret;
}
+ call_hooks('item_store',$arr);
+
+ // This hook remains for backward compatibility.
call_hooks('post_remote',$arr);
if(x($arr,'cancel')) {
@@ -1952,8 +1971,6 @@ function item_store($arr,$allow_exec = false) {
function item_store_update($arr,$allow_exec = false) {
-
-
$d = array('item' => $arr, 'allow_exec' => $allow_exec);
call_hooks('item_store_update', $d );
$arr = $d['item'];
@@ -2100,7 +2117,7 @@ function item_store_update($arr,$allow_exec = false) {
// $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] );
$arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
- $arr['layout_mid'] = ((x($arr,'layout_mid')) ? dbesc($arr['layout_mid']) : $orig[0]['layout_mid'] );
+ $arr['layout_mid'] = ((array_key_exists('layout_mid',$arr)) ? dbesc($arr['layout_mid']) : $orig[0]['layout_mid'] );
call_hooks('post_remote_update',$arr);
@@ -2284,27 +2301,6 @@ function tag_deliver($uid,$item_id) {
$item = $i[0];
-
- $terms = get_terms_oftype($item['term'],TERM_BOOKMARK);
-
- if($terms && (! $item['item_restrict'])) {
- logger('tag_deliver: found bookmark');
- $bookmark_self = intval(get_pconfig($uid,'system','bookmark_self'));
- if(perm_is_allowed($u[0]['channel_id'],$item['author_xchan'],'bookmark') && (($item['author_xchan'] != $u[0]['channel_hash']) || ($bookmark_self))) {
- require_once('include/bookmarks.php');
- require_once('include/Contact.php');
-
- $s = q("select * from xchan where xchan_hash = '%s' limit 1",
- dbesc($item['author_xchan'])
- );
- if($s) {
- foreach($terms as $t) {
- bookmark_add($u[0],$s[0],$t,$item['item_private']);
- }
- }
- }
- }
-
if(($item['source_xchan']) && ($item['item_flags'] & ITEM_UPLINK) && ($item['item_flags'] & ITEM_THREAD_TOP) && ($item['edited'] != $item['created'])) {
// this is an update to a post which was already processed by us and has a second delivery chain
// Just start the second delivery chain to deliver the updated post
@@ -2450,16 +2446,26 @@ function tag_deliver($uid,$item_id) {
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
+ $tagged = false;
+ $plustagged = false;
+
+ $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'],'/') . '\[\/zrl\]/';
+ if(preg_match($pattern,$body,$matches))
+ $tagged = true;
+
$pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'] . '+','/') . '\[\/zrl\]/';
+ if(preg_match($pattern,$body,$matches))
+ $plustagged = true;
- if(! preg_match($pattern,$body,$matches)) {
+ if(! ($tagged || $plustagged)) {
logger('tag_deliver: mention was in a reshare - ignoring');
return;
}
-
- // All good.
- // Send a notification
+ $arr = array('channel_id' => $uid, 'item' => $item, 'body' => $body);
+ call_hooks('tagged',$arr);
+
+ // Valid tag. Send a notification
require_once('include/enotify.php');
notification(array(
@@ -2472,6 +2478,14 @@ function tag_deliver($uid,$item_id) {
'otype' => 'item'
));
+ // Just a normal tag?
+
+ if(! $plustagged) {
+ logger('tag_deliver: not a plus tag', LOGGER_DEBUG);
+ return;
+ }
+
+ // plustagged - keep going, next check permissions
if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) {
logger('tag_delivery denied for uid ' . $uid . ' and xchan ' . $item['author_xchan']);
@@ -3707,13 +3721,53 @@ function first_post_date($uid,$wall = false) {
intval($uid)
);
- if(count($r)) {
+ if($r) {
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
}
return false;
}
+/**
+ * modified posted_dates() {below} to arrange the list in years, which we'll eventually
+ * use to make a menu of years with collapsible sub-menus for the months instead of the
+ * current flat list of all representative dates.
+ */
+
+function list_post_dates($uid,$wall) {
+ $dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d');
+
+ $dthen = first_post_date($uid,$wall);
+ if(! $dthen)
+ return array();
+
+ // If it's near the end of a long month, backup to the 28th so that in
+ // consecutive loops we'll always get a whole month difference.
+
+ if(intval(substr($dnow,8)) > 28)
+ $dnow = substr($dnow,0,8) . '28';
+ if(intval(substr($dthen,8)) > 28)
+ $dnow = substr($dthen,0,8) . '28';
+
+ $ret = array();
+ // Starting with the current month, get the first and last days of every
+ // month down to and including the month of the first post
+ while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+ $dyear = intval(substr($dnow,0,4));
+ $dstart = substr($dnow,0,8) . '01';
+ $dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5)));
+ $start_month = datetime_convert('','',$dstart,'Y-m-d');
+ $end_month = datetime_convert('','',$dend,'Y-m-d');
+ $str = day_translate(datetime_convert('','',$dnow,'F'));
+ if(! $ret[$dyear])
+ $ret[$dyear] = array();
+ $ret[$dyear][] = array($str,$end_month,$start_month);
+ $dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d');
+ }
+ return $ret;
+}
+
+
function posted_dates($uid,$wall) {
$dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d');
@@ -3833,18 +3887,19 @@ function zot_feed($uid,$observer_xchan,$mindate) {
$items = array();
if(is_sys_channel($uid)) {
-
require_once('include/security.php');
- $r = q("SELECT item.*, item.id as item_id from item
- WHERE uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0 and id = parent
+ $r = q("SELECT distinct parent from item
+ WHERE uid != %d
+ and uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0
AND (item_flags & %d)
and item_private = 0 $sql_extra ORDER BY created ASC $limit",
+ intval($uid),
intval(ITEM_WALL)
);
}
else {
- $r = q("SELECT item.*, item.id as item_id from item
- WHERE uid = %d AND item_restrict = 0 and id = parent
+ $r = q("SELECT distinct parent from item
+ WHERE uid = %d AND item_restrict = 0
AND (item_flags & %d)
$sql_extra ORDER BY created ASC $limit",
intval($uid),
@@ -3853,11 +3908,12 @@ function zot_feed($uid,$observer_xchan,$mindate) {
}
if($r) {
- $parents_str = ids_to_querystr($r,'id');
-
+ $parents_str = ids_to_querystr($r,'parent');
+ $sys_query = ((is_sys_channel($uid)) ? $sql_extra : '');
+
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`
WHERE `item`.`item_restrict` = 0
- AND `item`.`parent` IN ( %s ) ",
+ AND `item`.`parent` IN ( %s ) $sys_query ",
dbesc($parents_str)
);
}
@@ -3872,11 +3928,13 @@ function zot_feed($uid,$observer_xchan,$mindate) {
else
$items = array();
+
+ logger('zot_feed: number items: ' . count($items),LOGGER_DEBUG);
+
foreach($items as $item)
$result[] = encode_item($item);
return $result;
-
}
diff --git a/include/notifier.php b/include/notifier.php
index dbae6211c..59f472539 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -476,6 +476,14 @@ function notifier_run($argv, $argc){
$deliver = array();
foreach($hubs as $hub) {
+
+ if(defined('DIASPORA_RELIABILITY_EMULATION')) {
+ $cointoss = mt_rand(0,2);
+ if($cointoss == 2) {
+ continue;
+ }
+ }
+
$hash = random_string();
if($packet_type === 'refresh' || $packet_type === 'purge') {
$n = zot_build_packet($channel,$packet_type);
diff --git a/include/page_widgets.php b/include/page_widgets.php
index d70281afc..49d1439be 100644
--- a/include/page_widgets.php
+++ b/include/page_widgets.php
@@ -3,37 +3,47 @@
// A basic toolbar for observers with write_pages permissions
function writepages_widget ($who,$which){
return replace_macros(get_markup_template('write_pages.tpl'), array(
- '$new' => t('New Page'),
- '$newurl' => "webpages/$who",
- '$edit' => t('Edit'),
- '$editurl' => "editwebpage/$who/$which"
- ));
+ '$new' => t('New Page'),
+ '$newurl' => "webpages/$who",
+ '$edit' => t('Edit'),
+ '$editurl' => "editwebpage/$who/$which"
+ ));
}
-// Chan is channel_id, $who is channel_address - we'll need to pass observer later too.
-function pagelist_widget ($chan,$who){
- $r = q("select * from item_id where uid = %d and service = 'WEBPAGE' order by sid asc",
- intval($chan)
+// Chan is channel_id, $which is channel_address - we'll need to pass observer later too.
+function pagelist_widget ($owner,$which){
+
+ $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc",
+ intval($owner)
);
- $pages = null;
-// TODO - only list public pages. Doesn't matter for now, since we don't have ACL anyway.
-
- if($r) {
- $pages = array();
- foreach($r as $rr) {
- $pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']);
- }
+
+ $pages = null;
+
+ if($r) {
+ $pages = array();
+ foreach($r as $rr) {
+ $pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['sid'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']));
}
+ }
- return replace_macros(get_markup_template('webpagelist.tpl'), array(
+ //Build the base URL for edit links
+ $url = z_root() . "/editwebpage/" . $which;
+ // This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM).
+ return $o . replace_macros(get_markup_template("webpagelist.tpl"), array(
'$baseurl' => $url,
- '$edit' => '',
+ '$edit' => t('Edit'),
'$pages' => $pages,
- '$channel' => $who,
- '$preview' => '',
- '$widget' => 1,
+ '$channel' => $which,
+ '$view' => t('View'),
+ '$preview' => t('Preview'),
+ '$actions_txt' => t('Actions'),
+ '$pagelink_txt' => t('Page Link'),
+ '$title_txt' => t('Title'),
+ '$created_txt' => t('Created'),
+ '$edited_txt' => t('Edited')
+
));
}
diff --git a/include/permissions.php b/include/permissions.php
index 01dd18f8d..029bc1288 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -29,7 +29,7 @@ function get_perms() {
'write_pages' => array('channel_w_pages', intval(PERMS_W_PAGES), false, t('Can edit my "public" pages'), ''),
'republish' => array('channel_a_republish', intval(PERMS_A_REPUBLISH), false, t('Can source my "public" posts in derived channels'), t('Somewhat advanced - very useful in open communities')),
- 'bookmark' => array('channel_a_bookmark', intval(PERMS_A_BOOKMARK), false, t('Can send me bookmarks'), 'Bookmarks from this person will automatically be saved'),
+
'delegate' => array('channel_a_delegate', intval(PERMS_A_DELEGATE), false, t('Can administer my channel resources'), t('Extremely advanced. Leave this alone unless you know what you are doing')),
);
$ret = array('global_permissions' => $global_perms);
diff --git a/include/reddav.php b/include/reddav.php
index 03cfe1aab..0650531dd 100644
--- a/include/reddav.php
+++ b/include/reddav.php
@@ -1038,6 +1038,14 @@ class RedBrowser extends DAV\Browser\Plugin {
public function htmlActionsPanel(DAV\INode $node, &$output) {
+
+ if($this->auth->owner_id && $this->auth->owner_id == $this->auth->channel_id) {
+ $channel = get_app()->get_channel();
+ if($channel) {
+ $output .= '<tr><td colspan="2"><a href="filestorage/' . $channel['channel_address'] . '" >' . t('Edit File properties') . '</a></td></tr><tr><td>&nbsp;</td></tr>';
+ }
+ }
+
if (!$node instanceof DAV\ICollection)
return;
@@ -1062,14 +1070,6 @@ class RedBrowser extends DAV\Browser\Plugin {
</form>
</td></tr>';
-
- if($this->auth->owner_id && $this->auth->owner_id == $this->auth->channel_id) {
- $channel = get_app()->get_channel();
- if($channel) {
- $output .= '<tr><td>&nbsp;</td></tr><tr><td colspan="2"><a href="filestorage/' . $channel['channel_address'] . '" >' . t('Edit File properties') . '</a></td></tr>';
- }
- }
-
}
/**
diff --git a/include/security.php b/include/security.php
index 0edbf854d..53161e427 100644
--- a/include/security.php
+++ b/include/security.php
@@ -108,6 +108,9 @@ function change_channel($change_channel) {
function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
+ if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
+ return '';
+
$local_user = local_user();
$remote_user = remote_user();
@@ -170,6 +173,9 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) {
+ if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
+ return '';
+
$local_user = local_user();
$remote_user = remote_user();
@@ -347,10 +353,9 @@ function stream_perms_api_uids($perms_min = PERMS_SITE) {
$ret = array();
if(local_user())
$ret[] = local_user();
- $r = q("select channel_id from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d) and not (channel_pageflags & %d)",
+ $r = q("select channel_id from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d)",
intval($perms_min),
- intval(PAGE_CENSORED),
- intval(PAGE_SYSTEM)
+ intval(PAGE_CENSORED|PAGE_SYSTEM|PAGE_REMOVED)
);
if($r)
foreach($r as $rr)
@@ -364,7 +369,7 @@ function stream_perms_api_uids($perms_min = PERMS_SITE) {
$str .= ',';
$str .= intval($rr);
}
-logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG);
+ logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG);
return $str;
}
@@ -373,10 +378,9 @@ function stream_perms_xchans($perms_min = PERMS_SITE) {
if(local_user())
$ret[] = get_observer_hash();
- $r = q("select channel_hash from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d) and not (channel_pageflags & %d)",
+ $r = q("select channel_hash from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d)",
intval($perms_min),
- intval(PAGE_CENSORED),
- intval(PAGE_SYSTEM)
+ intval(PAGE_CENSORED|PAGE_SYETEM|PAGE_REMOVED)
);
if($r)
foreach($r as $rr)
@@ -390,6 +394,6 @@ function stream_perms_xchans($perms_min = PERMS_SITE) {
$str .= ',';
$str .= "'" . dbesc($rr) . "'";
}
-logger('stream_perms_xchans: ' . $str, LOGGER_DEBUG);
+ logger('stream_perms_xchans: ' . $str, LOGGER_DEBUG);
return $str;
}
diff --git a/include/socgraph.php b/include/socgraph.php
index 65e23f9df..e12da5862 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -370,13 +370,7 @@ function update_suggestions() {
}
else {
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/sitelist';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/sitelist';
- }
+ $url = $directory['url'] . '/sitelist';
}
if(! $url)
return;
diff --git a/include/text.php b/include/text.php
index 68542005b..0e136fe8e 100755
--- a/include/text.php
+++ b/include/text.php
@@ -705,12 +705,22 @@ function contact_block() {
if($shown == 0)
return;
+
+ $is_owner = ((local_user() && local_user() == $a->profile['uid']) ? true : false);
+
+ $abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF;
+ $xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED;
+ if(! $is_owner) {
+ $abook_flags = $abook_flags | ABOOK_FLAGS_HIDDEN;
+ $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN;
+ }
+
if((! is_array($a->profile)) || ($a->profile['hide_friends']))
return $o;
$r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not ( abook_flags & %d ) and not (xchan_flags & %d)",
intval($a->profile['uid']),
- intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF),
- intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED)
+ intval($abook_flags),
+ intval($xchan_flags)
);
if(count($r)) {
$total = intval($r[0]['total']);
@@ -723,8 +733,8 @@ function contact_block() {
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND not ( abook_flags & %d) and not (xchan_flags & %d ) ORDER BY RAND() LIMIT %d",
intval($a->profile['uid']),
- intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF),
- intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED),
+ intval($abook_flags),
+ intval($xchan_flags),
intval($shown)
);
@@ -895,9 +905,6 @@ function get_poke_verbs() {
function get_mood_verbs() {
- // index is present tense verb
- // value is array containing past tense verb, translation of present, translation of past
-
$arr = array(
'happy' => t('happy'),
'sad' => t('sad'),
@@ -916,6 +923,7 @@ function get_mood_verbs() {
'cranky' => t('cranky'),
'disturbed' => t('disturbed'),
'frustrated' => t('frustrated'),
+ 'depressed' => t('depressed'),
'motivated' => t('motivated'),
'relaxed' => t('relaxed'),
'surprised' => t('surprised'),
diff --git a/include/widgets.php b/include/widgets.php
index 678fed833..1b0e140c0 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -313,7 +313,7 @@ function widget_archive($arr) {
$url = z_root() . '/' . $a->cmd;
- $ret = posted_dates($uid,$wall);
+ $ret = list_post_dates($uid,$wall);
if(! count($ret))
return '';
diff --git a/include/zot.php b/include/zot.php
index c919b0981..9e69aea96 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -171,6 +171,10 @@ function zot_finger($webbie,$channel,$autofallback = true) {
return array('success' => false);
}
+ // potential issue here; the xchan_addr points to the primary hub.
+ // The webbie we were called with may not, so it might not be found
+ // unless we query for hubloc_addr instead of xchan_addr
+
$r = q("select xchan.*, hubloc.* from xchan
left join hubloc on xchan_hash = hubloc_hash
where xchan_addr = '%s' and (hubloc_flags & %d) limit 1",
@@ -1453,7 +1457,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false) {
if((x($arr,'obj_type')) && (activity_match($arr['obj_type'],ACTIVITY_OBJ_EVENT))) {
require_once('include/event.php');
$ev = bbtoevent($arr['body']);
- if(x($ev,'desc') && x($ev,'start')) {
+ if(x($ev,'description') && x($ev,'start')) {
$ev['event_xchan'] = $arr['author_xchan'];
$ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id'];