aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorChristian Vogeley <christian.vogeley@hotmail.de>2015-01-11 16:22:59 +0100
committerChristian Vogeley <christian.vogeley@hotmail.de>2015-01-11 16:22:59 +0100
commitf0c7612bcd49d32e408e67ac1829ee891c677f7e (patch)
treed4cff4aa2d728524b631776ffffee71f42056421 /mod
parent43f143a211c75138d09ceb89acc48ea7d5c31ca9 (diff)
parent10102ac2ac4d5b02012a9794e23656717ab05556 (diff)
downloadvolse-hubzilla-f0c7612bcd49d32e408e67ac1829ee891c677f7e.tar.gz
volse-hubzilla-f0c7612bcd49d32e408e67ac1829ee891c677f7e.tar.bz2
volse-hubzilla-f0c7612bcd49d32e408e67ac1829ee891c677f7e.zip
Merge remote-tracking branch 'upstream/master'
Conflicts: doc/html/classRedmatrix_1_1Import_1_1Import-members.html doc/html/classRedmatrix_1_1Import_1_1Import.js
Diffstat (limited to 'mod')
-rw-r--r--mod/acl.php205
-rw-r--r--mod/admin.php4
-rw-r--r--mod/connections.php3
-rw-r--r--mod/connedit.php27
-rw-r--r--mod/filestorage.php12
-rw-r--r--mod/item.php11
-rw-r--r--mod/manage.php18
-rwxr-xr-xmod/mood.php2
-rw-r--r--mod/new_channel.php7
-rw-r--r--mod/parse_url.php9
-rw-r--r--mod/photo.php18
-rw-r--r--mod/photos.php2
-rw-r--r--mod/ping.php15
-rw-r--r--mod/profile_photo.php1
-rw-r--r--mod/profiles.php41
-rw-r--r--mod/search_ac.php48
-rw-r--r--mod/settings.php33
-rwxr-xr-xmod/setup.php2
18 files changed, 253 insertions, 205 deletions
diff --git a/mod/acl.php b/mod/acl.php
index 797a3633b..d406942c3 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -13,6 +13,9 @@ function acl_init(&$a){
$type = (x($_REQUEST,'type')?$_REQUEST['type']:"");
$noforums = (x($_REQUEST,'n') ? $_REQUEST['n'] : false);
+ // List of channels whose connections to also suggest, e.g. currently viewed channel or channels mentioned in a post
+ $extra_channels = (x($_REQUEST,'extra_channels') ? $_REQUEST['extra_channels'] : array());
+
// For use with jquery.autocomplete for private mail completion
if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) {
@@ -21,15 +24,17 @@ function acl_init(&$a){
$search = $_REQUEST['query'];
}
-
if(!(local_user()))
- if($type != 'x')
+ if(!($type == 'x' || $type == 'c'))
killme();
if ($search != "") {
$sql_extra = " AND `name` LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " ";
- $sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . ") ";
+ $sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc($search) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") ";
+ // This horrible mess is needed because position also returns 0 if nothing is found. W/ould be MUCH easier if it instead returned a very large value
+ // Otherwise we could just order by LEAST(POSTION($search IN xchan_name),POSITION($search IN xchan_addr)).
+ $order_extra2 = "CASE WHEN xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) ." then POSITION('".dbesc($search)."' IN xchan_name) else position('".dbesc($search)."' IN xchan_addr) end, ";
$col = ((strpos($search,'@') !== false) ? 'xchan_addr' : 'xchan_name' );
$sql_extra3 = "AND $col like " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " ";
@@ -37,72 +42,6 @@ function acl_init(&$a){
$sql_extra = $sql_extra2 = $sql_extra3 = "";
}
- // count groups and contacts
- if ($type=='' || $type=='g'){
- $r = q("SELECT COUNT(`id`) AS g FROM `groups` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
- intval(local_user())
- );
- $group_count = (int)$r[0]['g'];
- } else {
- $group_count = 0;
- }
-
- if ($type=='' || $type=='c'){
- $r = q("SELECT COUNT(abook_id) AS c FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d AND not ( abook_flags & %d )>0 and not (xchan_flags & %d )>0 $sql_extra2" ,
- intval(local_user()),
- intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED),
- intval(XCHAN_FLAGS_DELETED)
- );
- $contact_count = (int)$r[0]['c'];
-
- if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_user(),'system','taganyone'))) {
- if(((! $r) || (! $r[0]['total'])) && $type == 'c') {
- $r = q("SELECT COUNT(xchan_hash) AS c FROM xchan
- WHERE not (xchan_flags & %d )>0 $sql_extra2" ,
- intval(XCHAN_FLAGS_DELETED)
- );
- $contact_count = (int)$r[0]['c'];
- }
- }
-
- }
-
- elseif ($type == 'm') {
-
- // autocomplete for Private Messages
-
-
- $r = q("SELECT count(xchan_hash) as c
- FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d and ( (abook_their_perms = null) or (abook_their_perms & %d )>0)
- and not ( xchan_flags & %d )>0
- $sql_extra2 ",
- intval(local_user()),
- intval(PERMS_W_MAIL),
- intval(XCHAN_FLAGS_DELETED)
- );
-
- if($r)
- $contact_count = (int)$r[0]['c'];
-
- }
- elseif (($type == 'a')||($type == 'p')) {
-
- // autocomplete for Contacts
-
- $r = q("SELECT COUNT(abook_id) AS c FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d and not ( xchan_flags & %d )>0 $sql_extra2" ,
- intval(local_user()),
- intval(XCHAN_FLAGS_DELETED)
- );
- $contact_count = (int)$r[0]['c'];
-
- } else {
- $contact_count = 0;
- }
-
- $tot = $group_count+$contact_count;
$groups = array();
$contacts = array();
@@ -139,18 +78,80 @@ function acl_init(&$a){
}
if ($type=='' || $type=='c') {
- $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags
+ $extra_channels_sql = '';
+ // Only include channels who allow the observer to view their permissions
+ foreach($extra_channels as $channel) {
+ if(perm_is_allowed(intval($channel), get_observer_hash(),'view_contacts'))
+ $extra_channels_sql .= "," . intval($channel);
+ }
+
+ $extra_channels_sql = substr($extra_channels_sql,1); // Remove initial comma
+
+ // Getting info from the abook is better for local users because it contains info about permissions
+ if(local_user()) {
+ if($extra_channels_sql != '')
+ $extra_channels_sql = " OR (abook_channel IN ($extra_channels_sql)) and not (abook_flags & ". intval(ABOOK_FLAG_HIDDEN) . ') > 0';
+
+ $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags
FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d AND not ( abook_flags & %d )>0 and not (xchan_flags & %d )>0 $sql_extra2 order by xchan_name asc" ,
- intval(local_user()),
- intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED),
- intval(XCHAN_FLAGS_DELETED)
- );
+ WHERE (abook_channel = %d $extra_channels_sql) AND not ( abook_flags & %d )>0 and not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
+ intval(local_user()),
+ intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED),
+ intval(XCHAN_FLAGS_DELETED)
+ );
+ }
+ else { // Visitors
+ $r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags
+ FROM xchan left join xlink on xlink_link = xchan_hash
+ WHERE xlink_xchan = '%s' AND NOT (xchan_flags & %d) > 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
+ dbesc(get_observer_hash()),
+ intval(XCHAN_FLAGS_DELETED));
+
+ // Find contacts of extra channels
+ // This is probably more complicated than it needs to be
+ if($extra_channels_sql) {
+ // Build a list of hashes that we got previously so we don't get them again
+ $known_hashes = array("'".get_observer_hash()."'");
+ if($r)
+ foreach($r as $rr)
+ $known_hashes[] = "'".$rr['hash']."'";
+ $known_hashes_sql = 'AND xchan_hash not in ('.join(',',$known_hashes).')';
+
+ $r2 = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel IN ($extra_channels_sql) $known_hashes_sql AND not ( abook_flags & %d )>0 and not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
+ intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_HIDDEN),
+ intval(XCHAN_FLAGS_DELETED)
+ );
+ if($r2)
+ $r = array_merge($r,$r2);
+
+ // Sort accoring to match position, then alphabetically. This could be avoided if the above two SQL queries could be combined into one, and the sorting could be done on the SQl server (like in the case of a local user)
+ $matchpos = function($x) use($search) {
+ $namepos = strpos($x['name'],$search);
+ $nickpos = strpos($x['nick'],$search);
+ // Use a large position if not found
+ return min($namepos === false ? 9999 : $namepos, $nickpos === false ? 9999 : $nickpos);
+ };
+ // This could be made simpler if PHP supported stable sorting
+ usort($r,function($a,$b) use($matchpos) {
+ $pos1 = $matchpos($a);
+ $pos2 = $matchpos($b);
+ if($pos1 == $pos2) { // Order alphabetically if match position is the same
+ if($a['name'] == $b['name'])
+ return 0;
+ else
+ return ($a['name'] < $b['name']) ? -1 : 1;
+ }
+ return ($pos1 < $pos2) ? -1 : 1;
+ });
+ }
+ }
if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_user(),'system','taganyone'))) {
if((! $r) && $type == 'c') {
$r = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags
FROM xchan
- WHERE not (xchan_flags & %d )>0 $sql_extra2 order by xchan_name asc" ,
+ WHERE not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
intval(XCHAN_FLAGS_DELETED)
);
}
@@ -181,49 +182,29 @@ function acl_init(&$a){
);
}
elseif($type == 'x') {
-
$r = navbar_complete($a);
- $x = array();
- $x['query'] = $search;
- $x['photos'] = array();
- $x['links'] = array();
- $x['suggestions'] = array();
- $x['data'] = array();
+ $contacts = array();
if($r) {
foreach($r as $g) {
- $x['photos'][] = $g['photo'];
- $x['links'][] = $g['url'];
- $x['suggestions'][] = '@' . $g['name'];
- $x['data'][] = $g['name'];
+ $contacts[] = array(
+ "photo" => $g['photo'],
+ "name" => $g['name'],
+ "nick" => $g['address'],
+ );
}
}
- echo json_encode($x);
- killme();
+ $o = array(
+ 'start' => $start,
+ 'count' => $count,
+ 'items' => $contacts,
+ );
+ echo json_encode($o);
+ killme();
}
else
$r = array();
-
- if($type == 'm' || $type == 'a' || $type == 'p') {
- $x = array();
- $x['query'] = $search;
- $x['photos'] = array();
- $x['links'] = array();
- $x['suggestions'] = array();
- $x['data'] = array();
- if(count($r)) {
- foreach($r as $g) {
- $x['photos'][] = $g['micro'];
- $x['links'][] = $g['url'];
- $x['suggestions'][] = $g['name'];
- $x['data'][] = (($type === 'p') ? '@' . str_replace(' ','_',$g['name']) : $g['id']);
- }
- }
- echo json_encode($x);
- killme();
- }
-
if(count($r)) {
foreach($r as $g){
@@ -263,7 +244,6 @@ function acl_init(&$a){
$items = array_merge($groups, $contacts);
$o = array(
- 'tot' => $tot,
'start' => $start,
'count' => $count,
'items' => $items,
@@ -284,7 +264,7 @@ function navbar_complete(&$a) {
}
$dirmode = intval(get_config('system','directory_mode'));
- $search = ((x($_REQUEST,'query')) ? htmlentities($_REQUEST['query'],ENT_COMPAT,'UTF-8',false) : '');
+ $search = ((x($_REQUEST,'search')) ? htmlentities($_REQUEST['search'],ENT_COMPAT,'UTF-8',false) : '');
if(! $search || mb_strlen($search) < 2)
return array();
@@ -313,9 +293,10 @@ function navbar_complete(&$a) {
$url = $directory['url'] . '/dirsearch';
}
+ $count = (x($_REQUEST,'count')?$_REQUEST['count']:100);
if($url) {
$query = $url . '?f=' ;
- $query .= '&name=' . urlencode($search) . '&limit=50' . (($address) ? '&address=' . urlencode($search) : '');
+ $query .= '&name=' . urlencode($search) . "&limit=$count" . (($address) ? '&address=' . urlencode($search) : '');
$x = z_fetch_url($query);
if($x['success']) {
diff --git a/mod/admin.php b/mod/admin.php
index 0e580960a..74a373738 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -827,7 +827,7 @@ function admin_page_channels(&$a){
/* get channels */
$total = q("SELECT count(*) as total FROM channel where not (channel_pageflags & %d)>0",
- intval(PAGE_REMOVED)
+ intval(PAGE_REMOVED|PAGE_SYSTEM)
);
if($total) {
$a->set_pager_total($total[0]['total']);
@@ -837,7 +837,7 @@ function admin_page_channels(&$a){
$order = " order by channel_name asc ";
$channels = q("SELECT * from channel where not ( channel_pageflags & %d )>0 $order limit %d offset %d ",
- intval(PAGE_REMOVED),
+ intval(PAGE_REMOVED|PAGE_SYSTEM),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
diff --git a/mod/connections.php b/mod/connections.php
index 70e28913a..d36734ccb 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -179,7 +179,8 @@ function connections_content(&$a) {
$unconnected = false;
$all = false;
- $_SESSION['return_url'] = $a->query_string;
+ if(! $_REQUEST['aj'])
+ $_SESSION['return_url'] = $a->query_string;
$search_flags = 0;
$head = '';
diff --git a/mod/connedit.php b/mod/connedit.php
index 5bf9c130b..7a38187dd 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -216,10 +216,9 @@ function connedit_post(&$a) {
$arr = array('channel_id' => local_user(), 'abook' => $a->poi);
call_hooks('accept_follow', $arr);
}
-dbg(1);
+
if(! is_null($autoperms))
set_pconfig(local_user(),'system','autoperms',(($autoperms) ? $abook_my_perms : 0));
-dbg(0);
connedit_clone($a);
@@ -403,9 +402,9 @@ function connedit_content(&$a) {
contact_remove(local_user(), $orig_record[0]['abook_id']);
build_sync_packet(0 /* use the current local_user */,
- array('abook' => array(
+ array('abook' => array(array(
'abook_xchan' => $orig_record[0]['abook_xchan'],
- 'entry_deleted' => true)
+ 'entry_deleted' => true))
)
);
@@ -444,32 +443,34 @@ function connedit_content(&$a) {
'url' => $a->get_baseurl(true) . '/network/?f=&cid=' . $contact['abook_id'],
'sel' => '',
'title' => t('View recent posts and comments'),
- ),
+ )
+ );
+ $buttons = array(
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/block',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''),
- 'title' => t('Block or Unblock this connection'),
+ 'title' => t('Block (or Unblock) all communications with this connection'),
),
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/ignore',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''),
- 'title' => t('Ignore or Unignore this connection'),
+ 'title' => t('Ignore (or Unignore) all inbound communications from this connection'),
),
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/archive',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''),
- 'title' => t('Archive or Unarchive this connection'),
+ 'title' => t('Archive (or Unarchive) this connection - mark channel dead but keep content'),
),
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/hide',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''),
- 'title' => t('Hide or Unhide this connection'),
+ 'title' => t('Hide or Unhide this connection from your other connections'),
),
array(
@@ -542,11 +543,15 @@ function connedit_content(&$a) {
'$notself' => (($self) ? '' : '1'),
'$self' => (($self) ? '1' : ''),
'$autolbl' => t('Apply the permissions indicated on this page to all new connections.'),
+ '$buttons' => (($self) ? '' : $buttons),
'$viewprof' => t('View Profile'),
'$lbl_slider' => t('Slide to adjust your degree of friendship'),
'$slide' => $slide,
'$tabs' => $t,
'$tab_str' => $tab_str,
+ '$perms_step1' => t('<p>Step #1. (Completed).</p><p>Create connection with minimal or no permissions.</p>'),
+ '$perms_step2' => t('<p>Step #2. (Incomplete).</p><p>Review and/or edit the default individual permissions on this page, if desired.</p>'),
+ '$perms_step3' => t('<p>Step #3. (Incomplete).</p><p>Submit this page to apply the selected permissions.</p><p>Until this is complete, this connection may have insufficient permission to communicate with you.</p>'),
'$is_pending' => (($contact['abook_flags'] & ABOOK_FLAG_PENDING) ? 1 : ''),
'$unapproved' => $unapproved,
'$inherited' => t('inherited'),
@@ -598,12 +603,8 @@ function connedit_content(&$a) {
'$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
'$archived' => (($contact['archive']) ? t('Currently archived') : ''),
'$pending' => (($contact['archive']) ? t('Currently pending') : ''),
- '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
- '$photo' => $contact['photo'],
'$name' => $contact['name'],
- '$dir_icon' => $dir_icon,
'$alt_text' => $alt_text,
- '$sparkle' => $sparkle,
'$url' => $url
));
diff --git a/mod/filestorage.php b/mod/filestorage.php
index 1767ea6bf..0a25617f0 100644
--- a/mod/filestorage.php
+++ b/mod/filestorage.php
@@ -32,7 +32,7 @@ function filestorage_post(&$a) {
$str_group_deny = perms2str($_REQUEST['group_deny']);
$str_contact_deny = perms2str($_REQUEST['contact_deny']);
- attach_change_permissions($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny,$str_group_deny, $recurse = false);
+ attach_change_permissions($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, $recurse);
//Build directory tree and redirect
$channel = $a->get_channel();
@@ -127,10 +127,14 @@ function filestorage_content(&$a) {
$lockstate = (($f['allow_cid'] || $f['allow_gid'] || $f['deny_cid'] || $f['deny_gid']) ? 'lock' : 'unlock');
+ // Encode path that is used for link so it's a valid URL
+ // Keep slashes as slashes, otherwise mod_rewrite doesn't work correctly
+ $encoded_path = str_replace('%2F', '/', rawurlencode($cloudpath));
+
$o = replace_macros(get_markup_template('attach_edit.tpl'), array(
'$header' => t('Edit file permissions'),
'$file' => $f,
- '$cloudpath' => z_root() . '/' . $cloudpath,
+ '$cloudpath' => z_root() . '/' . $encoded_path,
'$parentpath' => $parentpath,
'$uid' => $channel['channel_id'],
'$channelnick' => $channel['channel_address'],
@@ -143,7 +147,9 @@ function filestorage_content(&$a) {
'$isadir' => $is_a_dir,
'$cpdesc' => t('Copy/paste this code to attach file to a post'),
'$cpldesc' => t('Copy/paste this URL to link file from a web page'),
- '$submit' => t('Submit')
+ '$submit' => t('Submit'),
+ '$attach_btn_title' => t('Attach this file to a new post'),
+ '$link_btn_title' => t('Show URL to this file'),
));
echo $o;
diff --git a/mod/item.php b/mod/item.php
index 9ffcc7de2..894e23a0f 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -470,11 +470,13 @@ function item_post(&$a) {
require_once('include/text.php');
if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) {
- require_once('include/bb2diaspora.php');
- $body = diaspora2bb(escape_tags($body),true);
+ require_once('include/bb2diaspora.php');
+ $body = escape_tags($body);
+ $body = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$body);
+ $body = diaspora2bb($body,true);
+ $body = preg_replace_callback('/\[share(.*?)\]/ism','share_unshield',$body);
}
-
// BBCODE alert: the following functions assume bbcode input
// and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.)
// we may need virtual or template classes to implement the possible alternatives
@@ -683,7 +685,8 @@ function item_post(&$a) {
}
}
- $item_flags |= ITEM_UNSEEN;
+ if(local_user() != $profile_uid)
+ $item_flags |= ITEM_UNSEEN;
if($post_type === 'wall' || $post_type === 'wall-comment')
$item_flags = $item_flags | ITEM_WALL;
diff --git a/mod/manage.php b/mod/manage.php
index 6fb835696..b6e10bf46 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -28,8 +28,13 @@ function manage_content(&$a) {
if($change_channel) {
$r = change_channel($change_channel);
- if($r && $r['channel_startpage'])
- goaway(z_root() . '/' . $r['channel_startpage']);
+ if((argc() > 2) && !(argv(2) === 'default')) {
+ goaway(z_root() . '/' . implode('/',array_slice($a->argv,2))); // Go to whatever is after /manage/, but with the new channel
+ }
+ else {
+ if($r && $r['channel_startpage'])
+ goaway(z_root() . '/' . $r['channel_startpage']); // If nothing extra is specified, go to the default page
+ }
goaway(z_root());
}
@@ -41,15 +46,12 @@ function manage_content(&$a) {
intval(PAGE_REMOVED)
);
- $selected_channel = null;
$account = get_app()->get_account();
if($r && count($r)) {
$channels = $r;
for($x = 0; $x < count($channels); $x ++) {
$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
- if($channels[$x]['channel_id'] == local_user())
- $selected_channel = $channels[$x];
$channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
$channels[$x]['default_links'] = '1';
@@ -147,12 +149,14 @@ function manage_content(&$a) {
$o = replace_macros(get_markup_template('channels.tpl'), array(
'$header' => t('Channel Manager'),
'$msg_selected' => t('Current Channel'),
- '$selected' => $selected_channel,
- '$desc' => t('Attach to one of your channels by selecting it.'),
+ '$selected' => local_user(),
+ '$desc' => t('Switch to one of your channels by selecting it.'),
'$msg_default' => t('Default Channel'),
'$msg_make_default' => t('Make Default'),
'$links' => $links,
'$all_channels' => $channels,
+ '$mail_format' => t('%d new messages'),
+ '$intros_format' => t('%d new introductions'),
'$channel_usage_message' => $channel_usage_message,
));
diff --git a/mod/mood.php b/mod/mood.php
index ff765fcac..e6f4760e0 100755
--- a/mod/mood.php
+++ b/mod/mood.php
@@ -137,4 +137,4 @@ function mood_content(&$a) {
return $o;
-} \ No newline at end of file
+}
diff --git a/mod/new_channel.php b/mod/new_channel.php
index 185fc7c28..047048f0a 100644
--- a/mod/new_channel.php
+++ b/mod/new_channel.php
@@ -115,11 +115,8 @@ function new_channel_content(&$a) {
'$nick_desc' => t('Your nickname will be used to create an easily remembered channel address (like an email address) which you can share with others.'),
'$label_import' => t('Or <a href="import">import an existing channel</a> from another location'),
'$name' => $name,
- '$label_role' => t('Channel Type'),
- '$questionmark' => t('?'),
- '$what_is_role' => t('What is this?'),
- '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'),
- '$role_select' => role_selector(($privacy_role) ? $privacy_role : 'social'),
+ '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'),
+ '$role' => array('permissions_role' , t('Channel Type'), ($privacy_role) ? $privacy_role : 'social', '<a href="help/roles" target="_blank">'.t('Read more about roles').'</a>',get_roles()),
'$nickname' => $nickname,
'$submit' => t('Create')
));
diff --git a/mod/parse_url.php b/mod/parse_url.php
index 340e1a67e..23d608411 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -307,7 +307,14 @@ function parse_url_content(&$a) {
$max_images = intval($max_images);
foreach ($siteinfo["images"] as $imagedata) {
- $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]' . "\n";
+ if ($url) {
+ $image .= sprintf('[url=%s]', $url);
+ }
+ $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
+ if ($url) {
+ $image .= '[/url]';
+ }
+ $image .= "\n";
$total_images ++;
if($max_images && $max_images >= $total_images)
break;
diff --git a/mod/photo.php b/mod/photo.php
index 8cb82e8ff..66280cb76 100644
--- a/mod/photo.php
+++ b/mod/photo.php
@@ -224,9 +224,21 @@ function photo_init(&$a) {
}
else {
-
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
- header("Cache-Control: max-age=" . (3600*24));
+ // The photo cache default is 1 day to provide a privacy trade-off,
+ // as somebody reducing photo permissions on a photo that is already
+ // "in the wild" won't be able to stop the photo from being viewed
+ // for this amount amount of time once it is in the browser cache.
+ // The privacy expectations of your site members and their perception
+ // of privacy where it affects the entire project may be affected.
+ // This has performance considerations but we highly recommend you
+ // leave it alone.
+
+ $cache = get_config('system','photo_cache_time');
+ if(! $cache)
+ $cache = (3600 * 24); // 1 day
+
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cache) . " GMT");
+ header("Cache-Control: max-age=" . $cache);
}
echo $data;
diff --git a/mod/photos.php b/mod/photos.php
index f4e770ec0..8a54eca4f 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -370,7 +370,7 @@ function photos_post(&$a) {
if($fullnametagged)
continue;
- require_once('mod/item.php');
+ require_once('include/text.php');
$body = $access_tag = '';
$success = handle_tag($a, $body, $access_tag, $str_tags, (local_user()) ? local_user() : $a->profile['profile_uid'] , $tag);
diff --git a/mod/ping.php b/mod/ping.php
index ef8afd91c..593ae21f8 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -46,6 +46,7 @@ function ping_init(&$a) {
if(local_user()) {
$vnotify = get_pconfig(local_user(),'system','vnotify');
$evdays = intval(get_pconfig(local_user(),'system','evdays'));
+ $ob_hash = get_observer_hash();
}
// if unset show all visual notification types
@@ -275,10 +276,12 @@ function ping_init(&$a) {
$result = array();
$r = q("SELECT * FROM item
- WHERE item_restrict = %d and ( item_flags & %d ) > 0 and uid = %d",
+ WHERE item_restrict = %d and ( item_flags & %d ) > 0 and uid = %d
+ and author_xchan != '%s' ORDER BY created DESC",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
- intval(local_user())
+ intval(local_user()),
+ dbesc($ob_hash)
);
if($r) {
@@ -297,7 +300,7 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'intros')) {
$result = array();
- $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0)",
+ $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC",
intval(local_user()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
@@ -381,10 +384,12 @@ function ping_init(&$a) {
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
$r = q("SELECT id, item_restrict, item_flags FROM item
- WHERE (item_restrict = %d) and ( item_flags & %d ) > 0 and uid = %d",
+ WHERE (item_restrict = %d) and ( item_flags & %d ) > 0 and uid = %d
+ and author_xchan != '%s'",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
- intval(local_user())
+ intval(local_user()),
+ dbesc($ob_hash)
);
if($r) {
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index e9dad6f51..13d3cd756 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -130,6 +130,7 @@ function profile_photo_post(&$a) {
if($r) {
$base_image = $r[0];
+ $base_image['data'] = dbunescbin($base_image['data']);
$im = photo_factory($base_image['data'], $base_image['type']);
if($im->is_valid()) {
diff --git a/mod/profiles.php b/mod/profiles.php
index 1d784c506..fa6a6e35c 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -11,7 +11,7 @@ function profiles_init(&$a) {
if((argc() > 2) && (argv(1) === "drop") && intval(argv(2))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1",
- intval($a->argv[2]),
+ intval(argv(2)),
intval(local_user())
);
if(! count($r)) {
@@ -156,9 +156,18 @@ function profiles_init(&$a) {
// Run profile_load() here to make sure the theme is set before
// we start loading content
- if((argc() > 1) && (intval(argv(1)))) {
+ if(((argc() > 1) && (intval(argv(1)))) || !feature_enabled(local_user(),'multi_profiles')) {
+ if(feature_enabled(local_user(),'multi_profiles'))
+ $id = $a->argv[1];
+ else {
+ $x = q("select id from profile where uid = %d and is_default = 1",
+ intval(local_user())
+ );
+ if($x)
+ $id = $x[0]['id'];
+ }
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($a->argv[1]),
+ intval($id),
intval(local_user())
);
if(! count($r)) {
@@ -556,9 +565,18 @@ function profiles_content(&$a) {
$profile_fields_basic = get_profile_fields_basic();
$profile_fields_advanced = get_profile_fields_advanced();
- if((argc() > 1) && (intval(argv(1)))) {
+ if(((argc() > 1) && (intval(argv(1)))) || !feature_enabled(local_user(),'multi_profiles')) {
+ if(feature_enabled(local_user(),'multi_profiles'))
+ $id = $a->argv[1];
+ else {
+ $x = q("select id from profile where uid = %d and is_default = 1",
+ intval(local_user())
+ );
+ if($x)
+ $id = $x[0]['id'];
+ }
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($a->argv[1]),
+ intval($id),
intval(local_user())
);
if(! count($r)) {
@@ -586,13 +604,12 @@ function profiles_content(&$a) {
$opt_tpl = get_markup_template("profile_hide_friends.tpl");
- $hide_friends = replace_macros($opt_tpl,array(
- '$desc' => t('Hide your contact/friend list from viewers of this profile?'),
- '$yes_str' => t('Yes'),
- '$no_str' => t('No'),
- '$yes_selected' => (($r[0]['hide_friends']) ? " checked=\"checked\" " : ""),
- '$no_selected' => (($r[0]['hide_friends'] == 0) ? " checked=\"checked\" " : "")
- ));
+ $hide_friends = replace_macros($opt_tpl,array('$field' => array(
+ 'hide-friends',
+ t('Hide your contact/friend list from viewers of this profile?'),
+ $r[0]['hide_friends'],
+ '',
+ )));
$q = q("select * from profdef where true");
if($q) {
diff --git a/mod/search_ac.php b/mod/search_ac.php
index 36da21376..b4f5c9600 100644
--- a/mod/search_ac.php
+++ b/mod/search_ac.php
@@ -1,8 +1,9 @@
<?php
+// Autocomplete for saved searches. Should probably be put in the same place as the other autocompletes
function search_ac_init(&$a){
if(!local_user())
- return "";
+ killme();
$start = (x($_REQUEST,'start')?$_REQUEST['start']:0);
@@ -13,17 +14,6 @@ function search_ac_init(&$a){
$search = $_REQUEST['query'];
}
-
- $sql_extra = '';
-
- $x = array();
- $x['query'] = $search;
- $x['photos'] = array();
- $x['links'] = array();
- $x['suggestions'] = array();
- $x['data'] = array();
-
-
// Priority to people searches
if ($search) {
@@ -32,18 +22,23 @@ function search_ac_init(&$a){
}
- $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
+ $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
$people_sql_extra
ORDER BY `xchan_name` ASC ",
intval(local_user())
);
+ $results = array();
if($r) {
foreach($r as $g) {
- $x['photos'][] = $g['xchan_photo_s'];
- $x['links'][] = $g['xchan_url'];
- $x['suggestions'][] = '@' . $g['xchan_name'];
- $x['data'][] = 'cid=' . intval($g['abook_id']);
+ $results[] = array(
+ "photo" => $g['xchan_photo_s'],
+ "name" => '@'.$g['xchan_name'],
+ "id" => $g['abook_id'],
+ "link" => $g['xchan_url'],
+ "label" => '',
+ "nick" => '',
+ );
}
}
@@ -53,15 +48,24 @@ function search_ac_init(&$a){
if(count($r)) {
foreach($r as $g) {
- $x['photos'][] = $a->get_baseurl() . '/images/hashtag.png';
- $x['links'][] = $g['url'];
- $x['suggestions'][] = '#' . $g['term'];
- $x['data'][] = intval($g['tid']);
+ $results[] = array(
+ "photo" => $a->get_baseurl() . '/images/hashtag.png',
+ "name" => '#'.$g['term'],
+ "id" => $g['tid'],
+ "link" => $g['url'],
+ "label" => '',
+ "nick" => '',
+ );
}
}
header("content-type: application/json");
- echo json_encode($x);
+ $o = array(
+ 'start' => $start,
+ 'count' => $count,
+ 'items' => $results,
+ );
+ echo json_encode($o);
logger('search_ac: ' . print_r($x,true));
diff --git a/mod/settings.php b/mod/settings.php
index ea7b2ba06..59ce98a2a 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -122,10 +122,19 @@ function settings_post(&$a) {
if((argc() > 1) && (argv(1) === 'features')) {
check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
- foreach($_POST as $k => $v) {
- if(strpos($k,'feature_') === 0) {
- set_pconfig(local_user(),'feature',substr($k,8),((intval($v)) ? 1 : 0));
- }
+
+ // Build list of features and check which are set
+ $features = get_features();
+ $all_features = array();
+ foreach($features as $k => $v) {
+ foreach($v as $f)
+ $all_features[] = $f[0];
+ }
+ foreach($all_features as $k) {
+ if(x($_POST,"feature_$k"))
+ set_pconfig(local_user(),'feature',$k, 1);
+ else
+ set_pconfig(local_user(),'feature',$k, 0);
}
build_sync_packet();
return;
@@ -449,6 +458,8 @@ function settings_post(&$a) {
if(x($_POST,'vnotify11'))
$vnotify += intval($_POST['vnotify11']);
+ $always_show_in_notices = x($_POST,'always_show_in_notices') ? 1 : 0;
+
$channel = $a->get_channel();
$err = '';
@@ -478,6 +489,7 @@ function settings_post(&$a) {
set_pconfig(local_user(),'system','blocktags',$blocktags);
set_pconfig(local_user(),'system','channel_menu',$channel_menu);
set_pconfig(local_user(),'system','vnotify',$vnotify);
+ set_pconfig(local_user(),'system','always_show_in_notices',$always_show_in_notices);
set_pconfig(local_user(),'system','evdays',$evdays);
$r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d",
@@ -704,7 +716,6 @@ function settings_content(&$a) {
'$title' => t('Additional Features'),
'$features' => $arr,
'$submit' => t('Submit'),
- '$field_yesno' => 'field_yesno.tpl',
));
return $o;
@@ -935,7 +946,7 @@ function settings_content(&$a) {
$timezone = date_default_timezone_get();
- $opt_tpl = get_markup_template("field_yesno.tpl");
+ $opt_tpl = get_markup_template("field_checkbox.tpl");
if(get_config('system','publish_all')) {
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
}
@@ -995,6 +1006,7 @@ function settings_content(&$a) {
$permissions_role = get_pconfig(local_user(),'system','permissions_role');
$permissions_set = (($permissions_role && $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)
$vnotify = (-1);
@@ -1006,12 +1018,10 @@ function settings_content(&$a) {
'$uid' => local_user(),
'$form_security_token' => get_form_security_token("settings"),
'$nickname_block' => $prof_addr,
-
-
'$h_basic' => t('Basic Settings'),
'$username' => array('username', t('Full Name:'), $username,''),
'$email' => array('email', t('Email Address:'), $email, ''),
- '$timezone' => array('timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''),
+ '$timezone' => array('timezone_select' , t('Your Timezone:'), $timezone, '', get_timezones()),
'$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')),
'$allowloc' => array('allow_location', t('Use Browser Location:'), ((get_pconfig(local_user(),'system','use_browser_location')) ? 1 : ''), ''),
@@ -1040,9 +1050,7 @@ function settings_content(&$a) {
'$aclselect' => populate_acl($perm_defaults,false),
'$suggestme' => $suggestme,
'$group_select' => $group_select,
- '$role_lbl' => t('Channel permissions category:'),
-
- '$role_select' => role_selector($permissions_role),
+ '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()),
'$profile_in_dir' => $profile_in_dir,
'$hide_friends' => $hide_friends,
@@ -1080,6 +1088,7 @@ function settings_content(&$a) {
'$vnotify9' => array('vnotify9', t('System critical alerts'), ($vnotify & VNOTIFY_ALERT), VNOTIFY_ALERT, t('Recommended')),
'$vnotify10' => array('vnotify10', t('New connections'), ($vnotify & VNOTIFY_INTRO), VNOTIFY_INTRO, t('Recommended')),
'$vnotify11' => array('vnotify11', t('System Registrations'), ($vnotify & VNOTIFY_REGISTER), VNOTIFY_REGISTER, ''),
+ '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, ''),
'$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')),
diff --git a/mod/setup.php b/mod/setup.php
index 044def15a..6f2c7c074 100755
--- a/mod/setup.php
+++ b/mod/setup.php
@@ -349,7 +349,7 @@ function setup_content(&$a) {
'$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')),
- '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''),
+ '$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()),
'$baseurl' => $a->get_baseurl(),