Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
zottel 2016-07-14 20:49:26 +02:00
commit a2461d9816
32 changed files with 126 additions and 97 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
if(class_exists('PermissionDescription')) return; namespace Zotlabs\Lib;
require_once("include/permissions.php"); require_once("include/permissions.php");
require_once("include/language.php"); require_once("include/language.php");

View File

@ -1,7 +1,18 @@
<?php <?php
namespace Zotlabs\Module; namespace Zotlabs\Module;
/* ACL selector json backend */ /*
* ACL selector json backend
* This module provides JSON lists of connections and local/remote channels
* (xchans) to populate various tools such as the ACL (AccessControlList) popup
* and various auto-complete functions (such as email recipients, search, and
* mention targets.
* There are two primary output structural formats. One for the ACL widget and
* the other for auto-completion.
* Many of the behaviour variations are triggered on the use of single character keys
* however this functionality has grown in an ad-hoc manner and has gotten quite messy over time.
*/
require_once("include/acl_selectors.php"); require_once("include/acl_selectors.php");
require_once("include/group.php"); require_once("include/group.php");
@ -10,40 +21,63 @@ class Acl extends \Zotlabs\Web\Controller {
function init(){ function init(){
// logger('mod_acl: ' . print_r($_REQUEST,true)); // logger('mod_acl: ' . print_r($_REQUEST,true));
$start = (x($_REQUEST,'start')?$_REQUEST['start']:0); $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0);
$count = (x($_REQUEST,'count')?$_REQUEST['count']:100); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 500);
$search = (x($_REQUEST,'search')?$_REQUEST['search']:""); $search = (x($_REQUEST,'search') ? $_REQUEST['search'] : '');
$type = (x($_REQUEST,'type')?$_REQUEST['type']:""); $type = (x($_REQUEST,'type') ? $_REQUEST['type'] : '');
$noforums = (x($_REQUEST,'n') ? $_REQUEST['n'] : false); $noforums = (x($_REQUEST,'n') ? $_REQUEST['n'] : false);
// $type =
// '' => standard ACL request
// 'g' => Groups only ACL request
// 'c' => Connections only ACL request or editor (textarea) mention request
// $_REQUEST['search'] contains ACL search text.
// $type =
// 'm' => autocomplete private mail recipient (checks post_mail permission)
// 'a' => autocomplete connections (mod_connections, mod_poke, mod_sources, mod_photos)
// 'x' => nav search bar autocomplete (match any xchan)
// $_REQUEST['query'] contains autocomplete search text.
// List of channels whose connections to also suggest, e.g. currently viewed channel or channels mentioned in a post // 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()); $extra_channels = (x($_REQUEST,'extra_channels') ? $_REQUEST['extra_channels'] : array());
// For use with jquery.autocomplete for private mail completion // The different autocomplete libraries use different names for the search text
// parameter. Internaly we'll use $search to represent the search text no matter
// what request variable it was attached to.
if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) { if(array_key_exists('query',$_REQUEST)) {
if(! $type)
$type = 'm';
$search = $_REQUEST['query']; $search = $_REQUEST['query'];
} }
if(!(local_channel())) if( (! local_channel()) && (! ($type == 'x' || $type == 'c')))
if(!($type == 'x' || $type == 'c')) killme();
killme();
if ($search != "") { if($search) {
$sql_extra = " AND `name` LIKE " . protect_sprintf( "'%" . dbesc($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) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") "; $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 // This horrible mess is needed because position also returns 0 if nothing is found.
// Otherwise we could just order by LEAST(POSITION($search IN xchan_name),POSITION($search IN xchan_addr)). // Would be MUCH easier if it instead returned a very large value
$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, "; // Otherwise we could just
// order by LEAST(POSITION($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' ); $col = ((strpos($search,'@') !== false) ? 'xchan_addr' : 'xchan_name' );
$sql_extra3 = "AND $col like " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " "; $sql_extra3 = "AND $col like " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " ";
} else { }
else {
$sql_extra = $sql_extra2 = $sql_extra3 = ""; $sql_extra = $sql_extra2 = $sql_extra3 = "";
} }
@ -51,7 +85,7 @@ class Acl extends \Zotlabs\Web\Controller {
$groups = array(); $groups = array();
$contacts = array(); $contacts = array();
if ($type=='' || $type=='g'){ if($type == '' || $type == 'g') {
$r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`gname` $r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`gname`
FROM `groups`,`group_member` FROM `groups`,`group_member`
@ -82,7 +116,7 @@ class Acl extends \Zotlabs\Web\Controller {
} }
} }
if ($type=='' || $type=='c') { if($type == '' || $type == 'c') {
$extra_channels_sql = ''; $extra_channels_sql = '';
// Only include channels who allow the observer to view their permissions // Only include channels who allow the observer to view their permissions
foreach($extra_channels as $channel) { foreach($extra_channels as $channel) {
@ -171,7 +205,7 @@ class Acl extends \Zotlabs\Web\Controller {
intval(PERMS_W_MAIL) intval(PERMS_W_MAIL)
); );
} }
elseif(($type == 'a') || ($type == 'p')) { elseif($type == 'a') {
$r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash $r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d WHERE abook_channel = %d
@ -296,7 +330,7 @@ class Acl extends \Zotlabs\Web\Controller {
$url = $directory['url'] . '/dirsearch'; $url = $directory['url'] . '/dirsearch';
} }
$count = (x($_REQUEST,'count')?$_REQUEST['count']:100); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
if($url) { if($url) {
$query = $url . '?f=' ; $query = $url . '?f=' ;
$query .= '&name=' . urlencode($search) . "&limit=$count" . (($address) ? '&address=' . urlencode($search) : ''); $query .= '&name=' . urlencode($search) . "&limit=$count" . (($address) ? '&address=' . urlencode($search) : '');

View File

@ -9,7 +9,6 @@ require_once('include/security.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
require_once('include/permissions.php'); require_once('include/permissions.php');
require_once('include/PermissionDescription.php');
class Channel extends \Zotlabs\Web\Controller { class Channel extends \Zotlabs\Web\Controller {
@ -133,7 +132,7 @@ class Channel extends \Zotlabs\Web\Controller {
'default_location' => (($is_owner) ? \App::$profile['channel_location'] : ''), 'default_location' => (($is_owner) ? \App::$profile['channel_location'] : ''),
'nickname' => \App::$profile['channel_address'], 'nickname' => \App::$profile['channel_address'],
'lockstate' => (((strlen(\App::$profile['channel_allow_cid'])) || (strlen(\App::$profile['channel_allow_gid'])) || (strlen(\App::$profile['channel_deny_cid'])) || (strlen(\App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'), 'lockstate' => (((strlen(\App::$profile['channel_allow_cid'])) || (strlen(\App::$profile['channel_allow_gid'])) || (strlen(\App::$profile['channel_deny_cid'])) || (strlen(\App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'),
'acl' => (($is_owner) ? populate_acl($channel_acl,true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : ''), 'acl' => (($is_owner) ? populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : ''),
'showacl' => (($is_owner) ? 'yes' : ''), 'showacl' => (($is_owner) ? 'yes' : ''),
'bang' => '', 'bang' => '',
'visitor' => (($is_owner || $observer) ? true : false), 'visitor' => (($is_owner || $observer) ? true : false),

View File

@ -4,7 +4,6 @@ namespace Zotlabs\Module;
require_once('include/channel.php'); require_once('include/channel.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
require_once('include/PermissionDescription.php');
class Editwebpage extends \Zotlabs\Web\Controller { class Editwebpage extends \Zotlabs\Web\Controller {
@ -151,7 +150,7 @@ class Editwebpage extends \Zotlabs\Web\Controller {
'body' => undo_post_tagging($itm[0]['body']), 'body' => undo_post_tagging($itm[0]['body']),
'post_id' => $post_id, 'post_id' => $post_id,
'visitor' => ($is_owner) ? true : false, 'visitor' => ($is_owner) ? true : false,
'acl' => populate_acl($itm[0],false,\PermissionDescription::fromGlobalPermission('view_pages')), 'acl' => populate_acl($itm[0],false,\Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')),
'showacl' => ($is_owner) ? true : false, 'showacl' => ($is_owner) ? true : false,
'mimetype' => $mimetype, 'mimetype' => $mimetype,
'mimeselect' => true, 'mimeselect' => true,

View File

@ -6,7 +6,6 @@ require_once('include/bbcode.php');
require_once('include/datetime.php'); require_once('include/datetime.php');
require_once('include/event.php'); require_once('include/event.php');
require_once('include/items.php'); require_once('include/items.php');
require_once('include/PermissionDescription.php');
class Events extends \Zotlabs\Web\Controller { class Events extends \Zotlabs\Web\Controller {
@ -471,7 +470,7 @@ class Events extends \Zotlabs\Web\Controller {
'$permissions' => t('Permission settings'), '$permissions' => t('Permission settings'),
// populating the acl dialog was a permission description from view_stream because Cal.php, which // populating the acl dialog was a permission description from view_stream because Cal.php, which
// displays events, says "since we don't currently have an event permission - use the stream permission" // displays events, says "since we don't currently have an event permission - use the stream permission"
'$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults), false, \PermissionDescription::fromGlobalPermission('view_stream'))), '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults), false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'))),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$advanced' => t('Advanced Options') '$advanced' => t('Advanced Options')

View File

@ -6,7 +6,6 @@ namespace Zotlabs\Module;
*/ */
require_once('include/attach.php'); require_once('include/attach.php');
require_once('include/PermissionDescription.php');
/** /**
@ -134,7 +133,7 @@ class Filestorage extends \Zotlabs\Web\Controller {
$cloudpath = get_cloudpath($f) . (intval($f['is_dir']) ? '?f=&davguest=1' : ''); $cloudpath = get_cloudpath($f) . (intval($f['is_dir']) ? '?f=&davguest=1' : '');
$parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']); $parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']);
$aclselect_e = populate_acl($f, false, \PermissionDescription::fromGlobalPermission('view_storage')); $aclselect_e = populate_acl($f, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage'));
$is_a_dir = (intval($f['is_dir']) ? true : false); $is_a_dir = (intval($f['is_dir']) ? true : false);
$lockstate = (($f['allow_cid'] || $f['allow_gid'] || $f['deny_cid'] || $f['deny_gid']) ? 'lock' : 'unlock'); $lockstate = (($f['allow_cid'] || $f['allow_gid'] || $f['deny_cid'] || $f['deny_gid']) ? 'lock' : 'unlock');

View File

@ -905,7 +905,7 @@ class Item extends \Zotlabs\Web\Controller {
if($r) { if($r) {
xchan_query($r); xchan_query($r);
$sync_item = fetch_post_tags($r); $sync_item = fetch_post_tags($r);
build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true)))); build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true))));
} }
} }
if(! $nopush) if(! $nopush)
@ -1000,7 +1000,7 @@ class Item extends \Zotlabs\Web\Controller {
if($r) { if($r) {
xchan_query($r); xchan_query($r);
$sync_item = fetch_post_tags($r); $sync_item = fetch_post_tags($r);
build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true)))); build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true))));
} }
} }
@ -1014,11 +1014,6 @@ class Item extends \Zotlabs\Web\Controller {
logger('post_complete'); logger('post_complete');
// figure out how to return, depending on from whence we came // figure out how to return, depending on from whence we came
if($api_source) if($api_source)

View File

@ -6,8 +6,6 @@ require_once('include/group.php');
require_once('include/contact_widgets.php'); require_once('include/contact_widgets.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
require_once('include/PermissionDescription.php');
class Network extends \Zotlabs\Web\Controller { class Network extends \Zotlabs\Web\Controller {
@ -171,7 +169,7 @@ class Network extends \Zotlabs\Web\Controller {
'default_location' => $channel['channel_location'], 'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'], 'nickname' => $channel['channel_address'],
'lockstate' => (($private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'lockstate' => (($private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'bang' => (($private_editing) ? '!' : ''), 'bang' => (($private_editing) ? '!' : ''),
'visitor' => true, 'visitor' => true,
'profile_uid' => local_channel(), 'profile_uid' => local_channel(),

View File

@ -9,8 +9,6 @@ require_once('include/bbcode.php');
require_once('include/security.php'); require_once('include/security.php');
require_once('include/attach.php'); require_once('include/attach.php');
require_once('include/text.php'); require_once('include/text.php');
require_once('include/PermissionDescription.php');
class Photos extends \Zotlabs\Web\Controller { class Photos extends \Zotlabs\Web\Controller {
@ -633,7 +631,7 @@ class Photos extends \Zotlabs\Web\Controller {
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock'); $lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
} }
$aclselect = (($_is_owner) ? populate_acl($channel_acl,false, \PermissionDescription::fromGlobalPermission('view_storage')) : ''); $aclselect = (($_is_owner) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
// this is wrong but is to work around an issue with js_upload wherein it chokes if these variables // this is wrong but is to work around an issue with js_upload wherein it chokes if these variables
// don't exist. They really should be set to a parseable representation of the channel's default permissions // don't exist. They really should be set to a parseable representation of the channel's default permissions
@ -1023,7 +1021,7 @@ class Photos extends \Zotlabs\Web\Controller {
if($can_post) { if($can_post) {
$album_e = $ph[0]['album']; $album_e = $ph[0]['album'];
$caption_e = $ph[0]['description']; $caption_e = $ph[0]['description'];
$aclselect_e = (($_is_owner) ? populate_acl($ph[0], true, \PermissionDescription::fromGlobalPermission('view_storage')) : ''); $aclselect_e = (($_is_owner) ? populate_acl($ph[0], true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
$albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer'])); $albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer']));
$_SESSION['album_return'] = bin2hex($ph[0]['album']); $_SESSION['album_return'] = bin2hex($ph[0]['album']);

View File

@ -7,7 +7,6 @@ require_once('include/items.php');
require_once('include/taxonomy.php'); require_once('include/taxonomy.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
require_once('include/zot.php'); require_once('include/zot.php');
require_once('include/PermissionDescription.php');
/** /**
* remote post * remote post
@ -116,7 +115,7 @@ class Rpost extends \Zotlabs\Web\Controller {
'default_location' => $channel['channel_location'], 'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'], 'nickname' => $channel['channel_address'],
'lockstate' => (($acl->is_private()) ? 'lock' : 'unlock'), 'lockstate' => (($acl->is_private()) ? 'lock' : 'unlock'),
'acl' => populate_acl($channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'acl' => populate_acl($channel_acl, true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'bang' => '', 'bang' => '',
'visitor' => true, 'visitor' => true,
'profile_uid' => local_channel(), 'profile_uid' => local_channel(),

View File

@ -2,8 +2,6 @@
namespace Zotlabs\Module; /** @file */ namespace Zotlabs\Module; /** @file */
require_once('include/zot.php'); require_once('include/zot.php');
require_once('include/PermissionDescription.php');
class Settings extends \Zotlabs\Web\Controller { class Settings extends \Zotlabs\Web\Controller {
@ -1066,7 +1064,7 @@ class Settings extends \Zotlabs\Web\Controller {
'$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')),
'$permissions' => t('Default Post and Publish Permissions'), '$permissions' => t('Default Post and Publish Permissions'),
'$permdesc' => t("\x28click to open/close\x29"), '$permdesc' => t("\x28click to open/close\x29"),
'$aclselect' => populate_acl($perm_defaults, false, \PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), '$aclselect' => populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))),
'$suggestme' => $suggestme, '$suggestme' => $suggestme,
'$group_select' => $group_select, '$group_select' => $group_select,
'$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()), '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()),

View File

@ -4,7 +4,6 @@ namespace Zotlabs\Module;
require_once('include/channel.php'); require_once('include/channel.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
require_once('include/PermissionDescription.php');
class Webpages extends \Zotlabs\Web\Controller { class Webpages extends \Zotlabs\Web\Controller {
@ -105,7 +104,7 @@ class Webpages extends \Zotlabs\Web\Controller {
'is_owner' => true, 'is_owner' => true,
'nickname' => \App::$profile['channel_address'], 'nickname' => \App::$profile['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'acl' => (($is_owner) ? populate_acl($channel_acl,false, \PermissionDescription::fromGlobalPermission('view_pages')) : ''), 'acl' => (($is_owner) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''),
'showacl' => (($is_owner) ? true : false), 'showacl' => (($is_owner) ? true : false),
'visitor' => true, 'visitor' => true,
'hide_location' => true, 'hide_location' => true,

View File

@ -24,7 +24,8 @@ class SessionHandler implements \SessionHandlerInterface {
return $r[0]['sess_data']; return $r[0]['sess_data'];
} }
else { else {
q("INSERT INTO `session` (sid, expire) values ('%s', '%s')", q("INSERT INTO `session` (sess_data, sid, expire) values ('%s', '%s', '%s')",
dbesc(''),
dbesc($id), dbesc($id),
dbesc(time() + 300) dbesc(time() + 300)
); );

View File

@ -0,0 +1,11 @@
[h2]change_channel[/h2]
Called when entering a logged in state in a channel context (as opposed to an account context).
The hook array provides two arguments, 'channel_id' and 'chanx'. 'chanx' is a union of the channel
and xchan records for the now active channel.
Use this to capture what would traditionally be known as 'login events'. In this platform, login is
a separate authentication activity and doesn't necessarily require "connecting to an identity", which
is what the change_channel activity represents.

View File

@ -73,6 +73,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/bb_translate_video]bb_translate_video[/zrl] [zrl=[baseurl]/help/hook/bb_translate_video]bb_translate_video[/zrl]
Called when extracting embedded services from bbcode video elements (rarely used) Called when extracting embedded services from bbcode video elements (rarely used)
[zrl=[baseurl]/help/hook/change_channel]change_channel[/zrl]
Called when logging in to a channel (either during login or afterward through the channel manager)
[zrl=[baseurl]/help/hook/channel_remove]channel_remove[/zrl] [zrl=[baseurl]/help/hook/channel_remove]channel_remove[/zrl]
Called when removing a channel Called when removing a channel

View File

@ -7,8 +7,6 @@
* @package acl_selectors * @package acl_selectors
*/ */
require_once("include/PermissionDescription.php");
function group_select($selname,$selclass,$preselected = false,$size = 4) { function group_select($selname,$selclass,$preselected = false,$size = 4) {
$o = ''; $o = '';
@ -231,7 +229,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
if(! $emptyACL_description) { if(! $emptyACL_description) {
$showall_caption = t('Visible to your default audience'); $showall_caption = t('Visible to your default audience');
} else if (is_a($emptyACL_description, 'PermissionDescription')) { } else if (is_a($emptyACL_description, '\\Zotlabs\\Lib\\PermissionDescription')) {
$showall_caption = $emptyACL_description->get_permission_description(); $showall_caption = $emptyACL_description->get_permission_description();
$showall_origin = (($role === 'custom') ? $emptyACL_description->get_permission_origin_description() : ''); $showall_origin = (($role === 'custom') ? $emptyACL_description->get_permission_origin_description() : '');
$showall_icon = $emptyACL_description->get_permission_icon(); $showall_icon = $emptyACL_description->get_permission_icon();

View File

@ -4154,32 +4154,19 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
} }
if($page_type) { if($page_type) {
// store page info as an alternate message_id so we can access it via // store page info as an alternate message_id so we can access it via
// https://sitename/page/$channelname/$pagetitle // https://sitename/page/$channelname/$pagetitle
// if no pagetitle was given or it couldn't be transliterated into a url, use the first // if no pagetitle was given or it couldn't be transliterated into a url, use the first
// sixteen bytes of the mid - which makes the link portable and not quite as daunting // sixteen bytes of the mid - which makes the link portable and not quite as daunting
// as the entire mid. If it were the post_id the link would be less portable. // as the entire mid. If it were the post_id the link would be less portable.
$r = q("select * from item_id where iid = %d and uid = %d and service = '%s' limit 1", \Zotlabs\Lib\IConfig::Set(
intval($post_id), intval($post_id),
intval($channel['channel_id']), 'system',
dbesc($page_type) $page_type,
($pagetitle) ? $pagetitle : substr($mid,0,16),
false
); );
if($r) {
q("update item_id set sid = '%s' where id = %d",
dbesc(($pagetitle) ? $pagetitle : substr($mid,0,16)),
intval($r[0]['id'])
);
}
else {
q("insert into item_id ( iid, uid, sid, service ) values ( %d, %d, '%s','%s' )",
intval($post_id),
intval($channel['channel_id']),
dbesc(($pagetitle) ? $pagetitle : substr($mid,0,16)),
dbesc($page_type)
);
}
} }
} }

View File

@ -125,13 +125,17 @@ function change_channel($change_channel) {
); );
if($x) { if($x) {
$_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_url'] = $x[0]['xchan_url'];
$_SESSION['my_address'] = $r[0]['channel_address'] . '@' . substr(z_root(), strpos(z_root(), '://') + 3); $_SESSION['my_address'] = $r[0]['channel_address'] . '@' . App::get_hostname();
App::set_observer($x[0]); App::set_observer($x[0]);
App::set_perms(get_all_perms(local_channel(), $hash)); App::set_perms(get_all_perms(local_channel(), $hash));
} }
if(! is_dir('store/' . $r[0]['channel_address'])) if(! is_dir('store/' . $r[0]['channel_address']))
@os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS,true); @os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS,true);
$arr = [ 'channel_id' => $change_channel, 'chanx' => $ret ];
call_hooks('change_channel', $arr);
} }
return $ret; return $ret;

View File

@ -296,7 +296,7 @@ function widget_filer($arr) {
$selected = ((x($_REQUEST,'file')) ? $_REQUEST['file'] : ''); $selected = ((x($_REQUEST,'file')) ? $_REQUEST['file'] : '');
$terms = array(); $terms = array();
$r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc", $r = q("select distinct term from term where uid = %d and ttype = %d order by term asc",
intval(local_channel()), intval(local_channel()),
intval(TERM_FILE) intval(TERM_FILE)
); );

View File

@ -3014,7 +3014,12 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
if($x['hubloc_host'] == App::get_hostname()) if($x['hubloc_host'] == App::get_hostname())
continue; continue;
$synchubs[] = $x; $y = q("select site_dead from site where site_url = '%s' limit 1",
dbesc($x['hubloc_url'])
);
if((! $y) || ($y[0]['site_dead'] == 0))
$synchubs[] = $x;
} }
if(! $synchubs) if(! $synchubs)

View File

@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS `abconfig` ( CREATE TABLE IF NOT EXISTS `abconfig` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`chan` int(10) unsigned NOT NULL DEFAULT '', `chan` int(10) unsigned NOT NULL DEFAULT '0',
`xchan` char(255) NOT NULL DEFAULT '', `xchan` char(255) NOT NULL DEFAULT '',
`cat` char(255) NOT NULL DEFAULT '', `cat` char(255) NOT NULL DEFAULT '',
`k` char(255) NOT NULL DEFAULT '', `k` char(255) NOT NULL DEFAULT '',

View File

@ -1,6 +1,6 @@
CREATE TABLE "abconfig" ( CREATE TABLE "abconfig" (
"id" serial NOT NULL, "id" serial NOT NULL,
"chan" bigint NOT NULL, "chan" bigint NOT NULL DEFAULT '0',
"xchan" text NOT NULL, "xchan" text NOT NULL,
"cat" text NOT NULL, "cat" text NOT NULL,
"k" text NOT NULL, "k" text NOT NULL,

View File

@ -59,7 +59,8 @@ aside .nav-pills > li > a,
padding: 6px 10px; padding: 6px 10px;
} }
.wall-item-tools .dropdown-menu { .wall-item-tools .dropdown-menu,
.section-title-wrapper .dropdown-menu {
min-width: auto; min-width: auto;
} }

View File

@ -1,5 +1,5 @@
/** /**
* Red people autocomplete * general autocomplete support
* *
* require jQuery, jquery.textcomplete * require jQuery, jquery.textcomplete
*/ */

View File

@ -1,5 +1,5 @@
$(document).ready(function() { $(document).ready(function() {
$("#recip").name_autocomplete(baseurl + '/acl', '', false, function(data) { $("#recip").name_autocomplete(baseurl + '/acl', 'm', false, function(data) {
$("#recip-complete").val(data.xid); $("#recip-complete").val(data.xid);
}); });
$(".autotime").timeago() $(".autotime").timeago()

View File

@ -3,7 +3,7 @@
*/ */
$(document).ready(function() { $(document).ready(function() {
$("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', false, function(data) { $("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) {
$("#photo-edit-newtag").val('@' + data.name); $("#photo-edit-newtag").val('@' + data.name);
}); });

View File

@ -56,14 +56,16 @@ $(document).ready(function() {
function makeFullScreen(full) { function makeFullScreen(full) {
if(typeof full=='undefined' || full == true) { if(typeof full=='undefined' || full == true) {
$('main').css({'transition': 'none'}).addClass('fullscreen'); $('main').css({'transition': 'none'}).addClass('fullscreen');
$('#fullscreen-btn, header, nav, aside, #tabs-collapse-1').css({'visibility': 'hidden'}); $('header, nav, aside, #tabs-collapse-1').css({'visibility': 'hidden'});
$('#fullscreen-btn').hide();
$('#inline-btn').show(); $('#inline-btn').show();
} }
else { else {
$('main').removeClass('fullscreen'); $('main').removeClass('fullscreen');
$('#fullscreen-btn, header, nav, aside, #tabs-collapse-1').css({'visibility': ''}); $('header, nav, aside, #tabs-collapse-1').css({'visibility': ''});
$('#inline-btn').hide(); $('#inline-btn').hide();
$('#fullscreen-btn').show();
$('main').css({'transition': ''}); $('main').css({'transition': ''});
} }
} }

View File

@ -1,8 +1,6 @@
<div class="generic-content-wrapper"> <div class="generic-content-wrapper">
<div class="section-title-wrapper"> <div class="section-title-wrapper">
<div class="pull-right"> <div class="pull-right">
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(); adjustFullscreenTopBarHeight();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false); adjustInlineTopBarHeight();"><i class="fa fa-compress"></i></button>
{{if $is_owner}} {{if $is_owner}}
<form id="chat-destroy" method="post" action="chat"> <form id="chat-destroy" method="post" action="chat">
<input type="hidden" name="room_name" value="{{$room_name}}" /> <input type="hidden" name="room_name" value="{{$room_name}}" />
@ -10,6 +8,8 @@
<button class="btn btn-danger btn-xs" type="submit" name="submit" value="{{$drop}}" onclick="return confirmDelete();"><i class="fa fa-trash-o"></i>&nbsp;{{$drop}}</button> <button class="btn btn-danger btn-xs" type="submit" name="submit" value="{{$drop}}" onclick="return confirmDelete();"><i class="fa fa-trash-o"></i>&nbsp;{{$drop}}</button>
</form> </form>
{{/if}} {{/if}}
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(); adjustFullscreenTopBarHeight();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false); adjustInlineTopBarHeight();"><i class="fa fa-compress"></i></button>
</div> </div>
<h2>{{$room_name}}</h2> <h2>{{$room_name}}</h2>
<div class="clear"></div> <div class="clear"></div>

View File

@ -2,8 +2,6 @@
<div class="section-title-wrapper"> <div class="section-title-wrapper">
<div class="pull-right"> <div class="pull-right">
<div class="dropdown"> <div class="dropdown">
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><i class="fa fa-caret-down"></i>&nbsp;{{$view_label}}</button> <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><i class="fa fa-caret-down"></i>&nbsp;{{$view_label}}</button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#" onclick="changeView('changeView', 'month'); return false;">{{$month}}</a></li> <li><a href="#" onclick="changeView('changeView', 'month'); return false;">{{$month}}</a></li>
@ -16,6 +14,8 @@
<button id="events-spinner" class="btn btn-default btn-xs" onclick="changeView('today', false);" title="{{$today}}"><i class="fa fa-bullseye"></i></button> <button id="events-spinner" class="btn btn-default btn-xs" onclick="changeView('today', false);" title="{{$today}}"><i class="fa fa-bullseye"></i></button>
<button class="btn btn-default btn-xs" onclick="changeView('next', false);" title="{{$next}}"><i class="fa fa-forward"></i></button> <button class="btn btn-default btn-xs" onclick="changeView('next', false);" title="{{$next}}"><i class="fa fa-forward"></i></button>
</div> </div>
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
</div> </div>
</div> </div>
<h2 id="title"></h2> <h2 id="title"></h2>

View File

@ -2,13 +2,13 @@
<div class="generic-content-wrapper"> <div class="generic-content-wrapper">
<div class="section-title-wrapper"> <div class="section-title-wrapper">
<div class="pull-right"> <div class="pull-right">
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-default btn-xs" onclick="changeView('prev', false);" title="{{$prev}}"><i class="fa fa-backward"></i></button> <button class="btn btn-default btn-xs" onclick="changeView('prev', false);" title="{{$prev}}"><i class="fa fa-backward"></i></button>
<button id="events-spinner" class="btn btn-default btn-xs" onclick="changeView('today', false);" title="{{$today}}"><i class="fa fa-bullseye"></i></button> <button id="events-spinner" class="btn btn-default btn-xs" onclick="changeView('today', false);" title="{{$today}}"><i class="fa fa-bullseye"></i></button>
<button class="btn btn-default btn-xs" onclick="changeView('next', false);" title="{{$next}}"><i class="fa fa-forward"></i></button> <button class="btn btn-default btn-xs" onclick="changeView('next', false);" title="{{$next}}"><i class="fa fa-forward"></i></button>
</div> </div>
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
</div> </div>
<h2 id="title"></h2> <h2 id="title"></h2>
<div class="clear"></div> <div class="clear"></div>

View File

@ -1,8 +1,6 @@
<div class="generic-content-wrapper"> <div class="generic-content-wrapper">
<div class="section-title-wrapper"> <div class="section-title-wrapper">
<div class="pull-right"> <div class="pull-right">
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
{{if $order}} {{if $order}}
<a class="btn btn-default btn-xs" href="{{$order.1}}" title="{{$order.0}}"><i class="fa fa-sort"></i></a> <a class="btn btn-default btn-xs" href="{{$order.1}}" title="{{$order.0}}"><i class="fa fa-sort"></i></a>
{{/if}} {{/if}}
@ -14,6 +12,8 @@
<button class="btn btn-xs btn-success btn-xs" title="{{$usage}}" onclick="openClose('photo-upload-form'); closeMenu('photo-album-edit-wrapper');"><i class="fa fa-arrow-circle-o-up"></i>&nbsp;{{$upload.0}}</button> <button class="btn btn-xs btn-success btn-xs" title="{{$usage}}" onclick="openClose('photo-upload-form'); closeMenu('photo-album-edit-wrapper');"><i class="fa fa-arrow-circle-o-up"></i>&nbsp;{{$upload.0}}</button>
{{/if}} {{/if}}
</div> </div>
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
</div> </div>
<h2>{{$album}}</h2> <h2>{{$album}}</h2>
<div class="clear"></div> <div class="clear"></div>

View File

@ -1,11 +1,11 @@
<div class="generic-content-wrapper"> <div class="generic-content-wrapper">
<div class="section-title-wrapper"> <div class="section-title-wrapper">
<div class="pull-right"> <div class="pull-right">
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
{{if $can_post}} {{if $can_post}}
<button class="btn btn-xs btn-success" title="{{$usage}}" onclick="openClose('photo-upload-form');"><i class="fa fa-arrow-circle-o-up"></i>&nbsp;{{$upload.0}}</button> <button class="btn btn-xs btn-success" title="{{$usage}}" onclick="openClose('photo-upload-form');"><i class="fa fa-arrow-circle-o-up"></i>&nbsp;{{$upload.0}}</button>
{{/if}} {{/if}}
<button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
</div> </div>
<h2>{{$title}}</h2> <h2>{{$title}}</h2>
<div class="clear"></div> <div class="clear"></div>