Merge pull request #3 from friendica/master

Merge from upstream
This commit is contained in:
Paolo T 2014-09-18 08:41:41 +02:00
commit 7da97c1981
41 changed files with 5638 additions and 205 deletions

View File

@ -44,7 +44,7 @@ require_once('include/Contact.php');
require_once('include/account.php');
define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_PLATFORM', 'redmatrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );

View File

@ -1,60 +0,0 @@
Project Code To-Do List
=======================
We need much more than this, but here are areas where developers can help. Please edit this page when items are finished. Another place for developers to start is with the issues list.
* Documentation - see [Red Documentation Project To-Do List](help/To-Do)
* Finish the anti-spam bayesian engine
* Integrate the "open site" list with the register page
* implement oembed provider interface
* implement openid server interface
* Write more webpage layouts
* Write more webpage widgets
* (Advanced) create a UI for building Comanche pages
* External post connectors - create standard interface
* External post connectors, add popular services
* templatise and translate the Web interface to webDAV
* Extend WebDAV to provide desktop access to photo albums
* service classes - provide a pluggable subscription payment gateway for premium accounts
* service classes - account overview page showing resources consumed by channel. With special consideration this page can also be accessed at a meta level by the site admin to drill down on problematic accounts/channels.
* Events module - fix permissions on events, and provide JS translation support for the calendar overview; integrate with calDAV
* Events module - event followups and RSVP
* Uploads - integrate https://github.com/blueimp/jQuery-File-Upload
* App taxonomy
* replace the tinymce visual editor and/or make the visual editor pluggable and responsive to different output formats. We probably want library/bbedit for bbcode. This needs a fair bit of work to catch up with our "enhanced bbcode", but start with images, links, bold and highlight and work from there.
* Photos module - turn photos into normal conversations and fix tagging
* Provide RSS feed support which look like channels (in matrix only - copyright issues)
* Create mobile clients for the top platforms - which involves extending the API so that we can do stuff far beyond the current crop of Twitter/Statusnet clients. Ditto for mobile themes. We can probably use something like the Friendica Android app as a base to start from.
* Implement owned and exchangeable "things".
* Family Account creation - using service classes (an account holder can create a certain number of sub-accounts which are all tied to their subscription - if the subscription lapses they all go away).
* Put mod_admin under Comanche
In many cases some of the work has already been started and code exists so that you needn't start from scratch. Please contact one of the developer channels like Channel One (one@zothub.com) before embarking and we can tell you what we already have and provide some insights on how we envision these features fitting together.

View File

@ -1,23 +0,0 @@
Documentation we need to write
==============================
* Database schema detailed descriptions
* Complete plugin hook documentation
* API documentation
* Function and code documentation (doxygen)
* New Member guide
* "Extra Feature" reference, description of each
* Detailed Personal Settings Documentation
* Administration Guide (post-install)
* Administration Guide (pre-install)

View File

@ -2,13 +2,16 @@
[ul]
[*][b]I am able to edit a post's text after I saved it, but is there a way to change the permissions?[/b]
Short anser: No, there isn't. This has got some resons. You are able to change permissons to your files, photos and the likes, but not to posts after you have saved them. The reason is: Once you have saved a post it is being distributed either to the public channel and from there to other Red Matrix servers or to those you intended it to go. Just like you cannot reclaim a few after you have sold them off to some people, you cannot change permissions to Red Matrix posts. We would need to track everywhere your posting goes, keep track of everyone you allowed to see it and then keep track of from whom to delete it.
If a posting is public this is even harder, as the Red Matrix is a global network and there is no way to follow a post, let alone reclaim it reliably.
Once you have sent out an email there too is no way to take it back. So think wisely and keep alert when posting. :)
[*][b]I downloaded my channel and uploaded it to another site but there is no content, no posts, no photos. What is wrong???[/b]
To be honest: Nothing. That's the way it is right now. Technically it is surely possible to take at least your own posts and maybe even files with you, but this has simply put not implemented yet. When creating this feature we thought that keeping all your contacts was more important. Once we find someone willing to implement this, it will be done. :)
Short anser: No, there isn't. There are reasons. You are able to change permissons to your files, photos and the likes, but not to posts after you have saved them. The main reason is: Once you have saved a post it is being distributed either to the public channel and from there to other Red Matrix servers or to those you intended it to go. Just like you cannot reclaim something you gave to another person, you cannot change permissions to Red Matrix posts. We would need to track everywhere your posting goes, keep track of everyone you allowed to see it and then keep track of from whom to delete it.
If a posting is public this is even harder, as the Red Matrix is a global network and there is no way to follow a post, let alone reclaim it reliably. Other networks that may receive your post have no reliable way to delete or reclaim the post.
[*][b]I downloaded my channel and imported it (cloned my identity) to another site but there is no content, no posts, no photos. What is wrong???[/b]
To be honest: Nothing. That's the way it is right now. Technically it is surely possible to take at least your own posts and maybe even files with you, but this has simply put not implemented yet. When creating this feature we thought that keeping all your contacts was more important. Your friends have already seen your old content. Once we find someone willing to implement this, it will be done. :)
[*][b]I can't see private resources[/b]
You have probably disabled third party cookies. You need to enable them for remote authentication to work.
[*][b]There are a lot of foreign language posts. Let's auto-translate them.[/b]
There are also a lot of [b]private[/b] foreign language posts and auto-translation services would require us to transmit these private messages to the translation service; and we don't know what they will do with them on their servers. Actually we do know thanks to Edward Snowden. Our best bet is a project called [b][i]Apertium[/i][/b] which is an open source translator we can install locally. It is currently missing German translations - which are the most requested translation in the matrix. Once again, this will be implemented when we find somebody who really wants to make it happen.
[/ul]
Return to the [zrl=[baseurl]/help/main]Main documentation page[/zrl]

View File

@ -16,14 +16,10 @@
[install] Installation and upgrade files and DB schema
[js] core required javascript
[library] Third party modules (must be license compatible)
[mod] Controller modules based on URL pathname (e.g. #^[url=http://sitename/foo]http://sitename/foo[/url] loads mod/foo.php)
[spec] protocol specifications
[util] translation tools, main English string database and other miscellaneous utilities
[version.inc] contains current version (auto-updated via cron for the master repository and distributed via git)
@ -44,15 +40,14 @@
[li]app - peronal app data[/li]
[li]attach - file attachments[/li]
[li]auth_codes - OAuth usage[/li]
[li]cache - TBD[/li]
[li]challenge - old DFRN structure, may re-use or may deprecate[/li]
[li]cache - OEmbed cache[/li]
[li]channel - replaces Friendica 'user'[/li]
[li]chat - chat room content[/li]
[li]chatpresence - channel presence information for chat[/li]
[li]chatroom - data for the actual chat room[/li]
[li]clients - OAuth usage[/li]
[li]config - main configuration storage[/li]
[li]conv - [/li]
[li]conv - Diaspora private messages[/li]
[li]event - Events[/li]
[li]fcontact - friend suggestion stuff[/li]
[li]ffinder - friend suggestion stuff[/li]
@ -62,7 +57,6 @@
[li]group_member - privacy groups[/li]
[li]hook - plugin hook registry[/li]
[li]hubloc - Red location storage, ties a location to an xchan[/li]
[li]intro - DFRN introductions, may be obsolete[/li]
[li]item - posts[/li]
[li]item_id - other identifiers on other services for posts[/li]
[li]likes - likes of 'things'[/li]

View File

@ -49,8 +49,8 @@ Zot is the great new communicaton protocol invented especially for the Red Matri
[zrl=[baseurl]/help/faq_admins]FAQ For Admins[/zrl]
[size=large][b]Technical Documentation[/b][/size]
[zrl=[baseurl]/help/Zot---A-High-Level-Overview.md[/zrl]A high level overview of Zot[/zrl]
[zrl=[baseurl]/help/zot]An introduction to Zot/zrl]
[zrl=[baseurl]/help/Zot---A-High-Level-Overview]A high level overview of Zot[/zrl]
[zrl=[baseurl]/help/zot]An introduction to Zot[/zrl]
[zrl=[baseurl]/help/zot_structures]Zot Stuctures[/zrl]
[zrl=[baseurl]/help/comanche]Comanche Page Descriptions[/zrl]
[zrl=[baseurl]/help/Creating-Templates]Creating Comanche Templates[/zrl]

View File

@ -4,6 +4,8 @@ We need much more than this, but here are areas where developers can help. Pleas
[li]Documentation - see Red Documentation Project To-Do List[/li]
[li]Include TOS link in registration/verification email[/li]
[li]Finish the anti-spam bayesian engine[/li]
[li]If DAV folders exist, add an option to the Settings page to set a default folder for attachment uploads.[/li]
@ -12,6 +14,8 @@ We need much more than this, but here are areas where developers can help. Pleas
[li]implement oembed provider interface[/li]
[li]refactor the oembed client interface so that we can safely sandbox remote content[/li]
[li]implement openid server interface[/li]
[li]Write more webpage layouts[/li]
@ -38,8 +42,22 @@ We need much more than this, but here are areas where developers can help. Pleas
[li]Uploads - integrate #^[url=https://github.com/blueimp/jQuery-File-Upload]https://github.com/blueimp/jQuery-File-Upload[/url][/li]
[li]Import/export - include items, events, things, etc.[/li]
[li]Import channel from Diaspora/Friendica[/li]
[li]MediaGoblin photo "crosspost" connector[/li]
[li]Create management page/UI for extensible profile fields[/li]
[li]Create interface to include/exclude and re-order standard profile fields[/li]
[li]Provide a mechanism to share page design elements in posts (just like apps)[/li]
[li]App taxonomy[/li]
[li]Customisable App collection pages[/li]
[li]replace the tinymce visual editor and/or make the visual editor pluggable and responsive to different output formats. We probably want library/bbedit for bbcode. This needs a fair bit of work to catch up with our "enhanced bbcode", but start with images, links, bold and highlight and work from there.[/li]
[li]Photos module - turn photos into normal conversations and fix tagging[/li]

View File

@ -616,6 +616,29 @@ function service_class_fetch($uid,$property) {
return((array_key_exists($property,$arr)) ? $arr[$property] : false);
}
// like service_class_fetch but queries by account rather than channel
function account_service_class_fetch($aid,$property) {
$r = q("select account_service_class as service_class from account where account_id = %d limit 1",
intval($aid)
);
if($r !== false && count($r)) {
$service_class = $r[0]['service_class'];
}
if(! x($service_class))
return false; // everything is allowed
$arr = get_config('service_class',$service_class);
if(! is_array($arr) || (! count($arr)))
return false;
return((array_key_exists($property,$arr)) ? $arr[$property] : false);
}
function upgrade_link($bbcode = false) {
$l = get_config('service_class','upgrade_link');
if(! $l)

View File

@ -269,12 +269,12 @@ function bb2diaspora_itemwallwall(&$item) {
logger('bb2diaspora_itemwallwall: author: ' . print_r($item['author'],true), LOGGER_DEBUG);
}
if(($item['mid'] == $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (is_array($item['author'])) && $item['author']['url'] && $item['author']['name'] && $item['author']['photo']['src']) {
if(($item['mid'] == $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) {
logger('bb2diaspora_itemwallwall: wall to wall post',LOGGER_DEBUG);
// post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author.
$item['body'] = "\n\n"
. '[img]' . $item['author']['photo']['src'] . '[/img]'
. '[url=' . $item['author']['url'] . ']' . $item['author']['name'] . '[/url]' . "\n\n"
. '[img]' . $item['author']['xchan_photo_m'] . '[/img]'
. '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n"
. $item['body'];
}
}

View File

@ -2043,35 +2043,33 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
}
if($type === 'StatusMessage' || $type === 'Comment' || $type === 'Like') {
$r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1",
$r = q("select * from item where mid = '%s' and uid = %d limit 1",
dbesc($guid),
intval($importer['channel_id'])
);
if(count($r)) {
if(link_compare($r[0]['author-link'],$contact['url'])) {
q("update item set `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' where `id` = %d",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($r[0]['id'])
);
if($r) {
if($r[0]['author_xchan'] == $contact['xchan_hash']) {
drop_item($r[0]['id'],false, DROPITEM_PHASE1);
// Now check if the retraction needs to be relayed by us
//
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
// return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
// The only item with `parent` and `id` as the parent id is the parent item.
$p = q("select origin from item where parent = %d and id = %d limit 1",
$p = q("select item_flags from item where parent = %d and id = %d limit 1",
$r[0]['parent'],
$r[0]['parent']
);
if(count($p)) {
if(($p[0]['origin']) && (! $parent_author_signature)) {
q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
$r[0]['id'],
dbesc($signed_data),
dbesc($sig),
dbesc($diaspora_handle)
);
if($p) {
if(($p[0]['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) {
// FIXME so we can relay this
// q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
// $r[0]['id'],
// dbesc($signed_data),
// dbesc($sig),
// dbesc($diaspora_handle)
// );
// the existence of parent_author_signature would have meant the parent_author or owner
// is already relaying.

View File

@ -63,6 +63,13 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$my_perms = PERMS_W_STREAM|PERMS_W_MAIL;
$role = get_pconfig($uid,'system','permissions_role');
if($role) {
$x = get_role_perms($role);
if($x['perms_follow'])
$my_perms = $x['perms_follow'];
}
logger('follow: ' . $url . ' ' . print_r($j,true), LOGGER_DEBUG);
@ -153,6 +160,12 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$xchan_hash = $r[0]['xchan_hash'];
$their_perms = 0;
$my_perms = PERMS_W_STREAM|PERMS_W_MAIL;
$role = get_pconfig($uid,'system','permissions_role');
if($role) {
$x = get_role_perms($role);
if($x['perms_follow'])
$my_perms = $x['perms_follow'];
}
}
}

View File

@ -215,18 +215,38 @@ function create_identity($arr) {
if(array_key_exists('primary', $arr))
$primary = intval($arr['primary']);
$perms_sql = '';
$defperms = site_default_perms();
$role_permissions = null;
$global_perms = get_perms();
foreach($defperms as $p => $v) {
$perms_keys .= ', ' . $global_perms[$p][0];
$perms_vals .= ', ' . intval($v);
if(array_key_exists('permissions_role',$arr) && $arr['permissions_role']) {
$role_permissions = get_role_perms($arr['permissions_role']);
if($role_permissions) {
foreach($role_permissions as $p => $v) {
if(strpos($p,'channel_') !== false) {
$perms_keys .= ', ' . $p;
$perms_vals .= ', ' . intval($v);
}
if($p === 'directory_publish')
$publish = intval($v);
}
}
}
else {
$defperms = site_default_perms();
foreach($defperms as $p => $v) {
$perms_keys .= ', ' . $global_perms[$p][0];
$perms_vals .= ', ' . intval($v);
}
}
$expire = get_config('system', 'default_expire_days');
$expire = (($expire===false)? '0': $expire);
$r = q("insert into channel ( channel_account_id, channel_primary,
channel_name, channel_address, channel_guid, channel_guid_sig,
channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_expire_days $perms_keys )
@ -246,8 +266,6 @@ function create_identity($arr) {
);
$r = q("select * from channel where channel_account_id = %d
and channel_guid = '%s' limit 1",
intval($arr['account_id']),
@ -322,24 +340,55 @@ function create_identity($arr) {
dbesc($a->get_baseurl() . "/photo/profile/m/{$newuid}")
);
$r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_flags )
values ( %d, %d, '%s', %d, '%s', '%s', %d ) ",
$myperms = 0;
if($role_permissions) {
$myperms = ((array_key_exists('perms_auto',$role_permissions) && $role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0);
}
$r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_flags, abook_my_perms )
values ( %d, %d, '%s', %d, '%s', '%s', %d, %d ) ",
intval($ret['channel']['channel_account_id']),
intval($newuid),
dbesc($hash),
intval(0),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval(ABOOK_FLAG_SELF)
intval(ABOOK_FLAG_SELF),
intval($myperms)
);
if(intval($ret['channel']['channel_account_id'])) {
// Create a group with no members. This allows somebody to use it
// Save our permissions role so we can perhaps call it up and modify it later.
if($role_permissions) {
set_pconfig($newuid,'system','permissions_role',$arr['permissions_role']);
if(array_key_exists('online',$role_permissions))
set_pconfig('system','hide_presence',1-intval($role_permissions['online']));
}
// Create a group with yourself as a member. This allows somebody to use it
// right away as a default group for new contacts.
require_once('include/group.php');
group_add($newuid, t('Friends'));
group_add_member($newuid,t('Friends'),$ret['channel']['channel_hash']);
// if our role_permissions indicate that we're using a default collection ACL, add it.
if(is_array($role_permissions) && $role_permissions['default_collection']) {
$r = q("select hash from groups where uid = %d and name = '%s' limit 1",
intval($newuid),
dbesc( t('Friends') )
);
if($r) {
q("update channel set channel_allow_gid = '%s' where channel_id = %d limit 1",
dbesc('<' . $r[0]['hash'] . '>'),
intval($newuid)
);
}
}
call_hooks('register_account', $newuid);
@ -396,7 +445,7 @@ function set_default_login_identity($account_id,$channel_id,$force = true) {
*
*/
function identity_basic_export($channel_id) {
function identity_basic_export($channel_id, $items = false) {
/*
* Red basic channel export
@ -468,8 +517,36 @@ function identity_basic_export($channel_id) {
$ret['photo'] = array('type' => $r[0]['type'], 'data' => base64url_encode($r[0]['data']));
}
if(! $items)
return $ret;
$r = q("select * from item_id where uid = %d",
intval($channel_id)
);
if($r)
$ret['item_id'] = $r;
$key = get_config('system','prvkey');
// warning: this may run into memory limits on smaller systems
$r = q("select * from item where (item_flags & %d) and not (item_restrict & %d) and uid = %d",
intval(ITEM_WALL),
intval(ITEM_DELETED),
intval($channel_id)
);
if($r) {
$ret['item'] = array();
xchan_query($r);
$r = fetch_post_tags($r,true);
foreach($r as $rr)
$ret['item'][] = encode_item($rr,true);
}
return $ret;
}

View File

@ -1007,8 +1007,7 @@ function import_author_unknown($x) {
}
function encode_item($item) {
function encode_item($item,$mirror = false) {
$x = array();
$x['type'] = 'activity';
$x['encoding'] = 'zot';
@ -1030,14 +1029,37 @@ function encode_item($item) {
$c_scope = map_scope($comment_scope);
$key = get_config('system','prvkey');
if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
$key = get_config('system','prvkey');
if($item['title'])
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
if($item['body'])
$item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
}
// If we're trying to backup an item so that it's recoverable or for export/imprt,
// add all the attributes we need to recover it
if($mirror) {
$x['id'] = $item['id'];
$x['parent'] = $item['parent'];
$x['uid'] = $item['uid'];
$x['allow_cid'] = $item['allow_cid'];
$x['allow_gid'] = $item['allow_gid'];
$x['deny_cid'] = $item['deny_cid'];
$x['deny_gid'] = $item['deny_gid'];
$x['revision'] = $item['revision'];
$x['layout_mid'] = $item['layout_mid'];
$x['postopts'] = $item['postopts'];
$x['resource_id'] = $item['resource_id'];
$x['resource_type'] = $item['resource_type'];
$x['item_restrict'] = $item['item_restrict'];
$x['item_flags'] = $item['item_flags'];
$x['diaspora_meta'] = crypto_unencapsulate(json_decode($item['diaspora_meta'],true),$key);
$x['attach'] = $item['attach'];
}
$x['message_id'] = $item['mid'];
$x['message_top'] = $item['parent_mid'];

View File

@ -38,6 +38,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
return false;
@curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@curl_setopt($ch, CURLOPT_CAINFO, get_capath());
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@ -47,11 +48,8 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
if($ciphers)
@curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
if (x($opts,'accept_content')){
@curl_setopt($ch,CURLOPT_HTTPHEADER, array (
"Accept: " . $opts['accept_content']
));
}
if(x($opts,'headers'))
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
if(x($opts,'timeout') && intval($opts['timeout'])) {
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
@ -126,6 +124,10 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
}
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
if(x($opts,'debug')) {
$ret['debug'] = $curl_info;
}
@curl_close($ch);
return($ret);
@ -166,6 +168,7 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
return ret;
@curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@curl_setopt($ch, CURLOPT_CAINFO, get_capath());
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@curl_setopt($ch, CURLOPT_POST,1);
@ -176,12 +179,6 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
if($ciphers)
@curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
if (x($opts,'accept_content')){
@curl_setopt($ch,CURLOPT_HTTPHEADER, array (
"Accept: " . $opts['accept_content']
));
}
if(x($opts,'headers'))
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
@ -258,11 +255,24 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
if(x($opts,'debug')) {
$ret['debug'] = $curl_info;
}
curl_close($ch);
return($ret);
}
function z_post_url_json($url,$params,$redirects = 0, $opts = array()) {
$opts = array_merge($opts,array('headers' => array('Content-Type: application/json')));
return z_post_url($url,json_encode($params),$redirects,$opts);
}
function json_return_and_die($x) {
header("content-type: application/json");

View File

@ -455,8 +455,8 @@ function notifier_run($argv, $argc){
// for public posts always include our own hub
$sql_extra = (($private) ? "" : " or hubloc_url = '" . dbesc(z_root()) . "' ");
// this shouldn't be needed any more. collect_recipients should take care of it.
// $sql_extra = (($private) ? "" : " or hubloc_url = '" . dbesc(z_root()) . "' ");
logger('notifier: hub choice: ' . intval($relay_to_owner) . ' ' . intval($private) . ' ' . $cmd, LOGGER_DEBUG);
@ -478,7 +478,9 @@ function notifier_run($argv, $argc){
}
else {
$r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc
where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey");
where hubloc_hash in (" . implode(',',$recipients) . ") and not (hubloc_flags & %d) group by hubloc_sitekey",
intval(HUBLOC_FLAGS_DELETED)
);
}
if(! $r) {
@ -493,6 +495,7 @@ function notifier_run($argv, $argc){
foreach($hubs as $hub) {
// don't try to deliver to deleted hublocs - and inexplicably SQL "distinct" and "group by"
// both return records with duplicate keys in rare circumstances
// FIXME this is probably redundant now.
if((! ($hub['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && (! in_array($hub['hubloc_sitekey'],$keys))) {
$hublist[] = $hub['hubloc_host'];
$keys[] = $hub['hubloc_sitekey'];

View File

@ -419,11 +419,12 @@ function site_default_perms() {
*
* Given a string for the channel role ('social','forum', etc)
* return an array of all permission fields pre-filled for this role.
* This includes the channel permission scope indicators as well as
* perms_auto: The permissions to apply automatically on receipt of a connection request
* This includes the channel permission scope indicators (anything beginning with 'channel_') as well as
* perms_auto: true or false to create auto-permissions for this channel
* perms_follow: The permissions to apply when initiating a connection request to another channel
* perms_accept: The permissions to apply when accepting a connection request from another channel (not automatic)
*
* default_collection: true or false to make the default ACL include the channel's default collection
* directory_publish: true or false to publish this channel in the directory
* Any attributes may be extended (new roles defined) and modified (specific permissions altered) by plugins
*
*/
@ -436,7 +437,10 @@ function get_role_perms($role) {
switch($role) {
case 'social':
$ret['perms_auto'] = 0;
$ret['perms_auto'] = false;
$ret['default_collection'] = false;
$ret['directory_publish'] = true;
$ret['online'] = true;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_A_REPUBLISH|PERMS_W_LIKE;
@ -462,6 +466,259 @@ function get_role_perms($role) {
$ret['channel_w_like'] = PERMS_NETWORK;
break;
case 'social_restricted':
$ret['perms_auto'] = false;
$ret['default_collection'] = true;
$ret['directory_publish'] = true;
$ret['online'] = true;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_PUBLIC;
$ret['channel_r_photos'] = PERMS_PUBLIC;
$ret['channel_r_abook'] = PERMS_PUBLIC;
$ret['channel_w_stream'] = PERMS_CONTACTS;
$ret['channel_w_wall'] = PERMS_CONTACTS;
$ret['channel_w_tagwall'] = PERMS_SPECIFIC;
$ret['channel_w_comment'] = PERMS_CONTACTS;
$ret['channel_w_mail'] = PERMS_CONTACTS;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = PERMS_CONTACTS;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_PUBLIC;
$ret['channel_r_pages'] = PERMS_PUBLIC;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_SPECIFIC;
$ret['channel_w_like'] = PERMS_CONTACTS;
break;
case 'social_private':
$ret['perms_auto'] = false;
$ret['default_collection'] = true;
$ret['directory_publish'] = false;
$ret['online'] = false;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_PUBLIC;
$ret['channel_r_photos'] = PERMS_PUBLIC;
$ret['channel_r_abook'] = PERMS_CONTACTS;
$ret['channel_w_stream'] = PERMS_CONTACTS;
$ret['channel_w_wall'] = PERMS_CONTACTS;
$ret['channel_w_tagwall'] = PERMS_SPECIFIC;
$ret['channel_w_comment'] = PERMS_CONTACTS;
$ret['channel_w_mail'] = PERMS_SPECIFIC;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = PERMS_SPECIFIC;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_PUBLIC;
$ret['channel_r_pages'] = PERMS_PUBLIC;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_SPECIFIC;
$ret['channel_w_like'] = PERMS_CONTACTS;
break;
case 'forum':
$ret['perms_auto'] = true;
$ret['default_collection'] = false;
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_A_REPUBLISH|PERMS_W_LIKE|PERMS_W_TAGWALL;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_A_REPUBLISH|PERMS_W_LIKE|PERMS_W_TAGWALL;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_PUBLIC;
$ret['channel_r_photos'] = PERMS_PUBLIC;
$ret['channel_r_abook'] = PERMS_PUBLIC;
$ret['channel_w_stream'] = PERMS_CONTACTS;
$ret['channel_w_wall'] = PERMS_CONTACTS;
$ret['channel_w_tagwall'] = PERMS_CONTACTS;
$ret['channel_w_comment'] = PERMS_CONTACTS;
$ret['channel_w_mail'] = PERMS_CONTACTS;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = PERMS_CONTACTS;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_PUBLIC;
$ret['channel_r_pages'] = PERMS_PUBLIC;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_SPECIFIC;
$ret['channel_w_like'] = PERMS_NETWORK;
break;
case 'forum_restricted':
$ret['perms_auto'] = false;
$ret['default_collection'] = true;
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE|PERMS_W_TAGWALL;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE|PERMS_W_TAGWALL;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_PUBLIC;
$ret['channel_r_photos'] = PERMS_PUBLIC;
$ret['channel_r_abook'] = PERMS_PUBLIC;
$ret['channel_w_stream'] = PERMS_CONTACTS;
$ret['channel_w_wall'] = PERMS_CONTACTS;
$ret['channel_w_tagwall'] = PERMS_SPECIFIC;
$ret['channel_w_comment'] = PERMS_CONTACTS;
$ret['channel_w_mail'] = PERMS_CONTACTS;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = PERMS_CONTACTS;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_PUBLIC;
$ret['channel_r_pages'] = PERMS_PUBLIC;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_SPECIFIC;
$ret['channel_w_like'] = PERMS_CONTACTS;
break;
case 'forum_private':
$ret['perms_auto'] = false;
$ret['default_collection'] = true;
$ret['directory_publish'] = false;
$ret['online'] = false;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_CONTACTS;
$ret['channel_r_photos'] = PERMS_CONTACTS;
$ret['channel_r_abook'] = PERMS_CONTACTS;
$ret['channel_w_stream'] = PERMS_CONTACTS;
$ret['channel_w_wall'] = PERMS_CONTACTS;
$ret['channel_w_tagwall'] = 0;
$ret['channel_w_comment'] = PERMS_CONTACTS;
$ret['channel_w_mail'] = PERMS_SPECIFIC;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = PERMS_SPECIFIC;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_CONTACTS;
$ret['channel_r_pages'] = PERMS_CONTACTS;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_SPECIFIC;
$ret['channel_w_like'] = PERMS_CONTACTS;
break;
case 'feed':
$ret['perms_auto'] = true;
$ret['default_collection'] = false;
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_A_REPUBLISH|PERMS_W_LIKE;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_A_REPUBLISH|PERMS_W_LIKE;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_PUBLIC;
$ret['channel_r_photos'] = PERMS_PUBLIC;
$ret['channel_r_abook'] = PERMS_PUBLIC;
$ret['channel_w_stream'] = PERMS_CONTACTS;
$ret['channel_w_wall'] = PERMS_CONTACTS;
$ret['channel_w_tagwall'] = PERMS_SPECIFIC;
$ret['channel_w_comment'] = PERMS_CONTACTS;
$ret['channel_w_mail'] = PERMS_CONTACTS;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = PERMS_CONTACTS;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_PUBLIC;
$ret['channel_r_pages'] = PERMS_PUBLIC;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_NETWORK;
$ret['channel_w_like'] = PERMS_NETWORK;
break;
case 'feed_restricted':
$ret['perms_auto'] = false;
$ret['default_collection'] = true;
$ret['directory_publish'] = false;
$ret['online'] = false;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_PUBLIC;
$ret['channel_r_photos'] = PERMS_PUBLIC;
$ret['channel_r_abook'] = PERMS_PUBLIC;
$ret['channel_w_stream'] = PERMS_CONTACTS;
$ret['channel_w_wall'] = PERMS_CONTACTS;
$ret['channel_w_tagwall'] = PERMS_SPECIFIC;
$ret['channel_w_comment'] = PERMS_CONTACTS;
$ret['channel_w_mail'] = PERMS_CONTACTS;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = PERMS_CONTACTS;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_PUBLIC;
$ret['channel_r_pages'] = PERMS_PUBLIC;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_SPECIFIC;
$ret['channel_w_like'] = PERMS_NETWORK;
break;
case 'soapbox':
$ret['perms_auto'] = true;
$ret['default_collection'] = false;
$ret['directory_publish'] = true;
$ret['online'] = false;
$ret['perms_follow'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_A_REPUBLISH|PERMS_W_LIKE;
$ret['perms_accept'] = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_A_REPUBLISH|PERMS_W_LIKE;
$ret['channel_r_stream'] = PERMS_PUBLIC;
$ret['channel_r_profile'] = PERMS_PUBLIC;
$ret['channel_r_photos'] = PERMS_PUBLIC;
$ret['channel_r_abook'] = PERMS_PUBLIC;
$ret['channel_w_stream'] = 0;
$ret['channel_w_wall'] = 0;
$ret['channel_w_tagwall'] = 0;
$ret['channel_w_comment'] = 0;
$ret['channel_w_mail'] = 0;
$ret['channel_w_photos'] = 0;
$ret['channel_w_chat'] = 0;
$ret['channel_a_delegate'] = 0;
$ret['channel_r_storage'] = PERMS_PUBLIC;
$ret['channel_r_pages'] = PERMS_PUBLIC;
$ret['channel_w_pages'] = 0;
$ret['channel_a_republish'] = PERMS_SPECIFIC;
$ret['channel_w_like'] = PERMS_NETWORK;
break;
default:
break;
}
@ -471,3 +728,28 @@ function get_role_perms($role) {
}
function role_selector($current) {
$roles = array(
'social' => array( t('Social Networking'),
array('social' => t('Mostly Public'), 'social_restricted' => t('Restricted'), 'social_private' => t('Private'))),
'forum' => array( t('Community Forum'),
array('forum' => t('Mostly Public'), 'forum_restricted' => t('Restricted'), 'forum_private' => t('Private'))),
'feed' => array( t('Feed Republish'),
array('feed' => t('Mostly Public'), 'feed_restricted' => t('Restricted'))),
'soapbox' => array( t('Celebrity/Soapbox'),
array('soapbox' => t('Mostly Public'))),
'other' => array( t('Other'),
array('custom' => t('Custom/Expert Mode'))));
$o = '<select name="permissions_role" id="privacy-role-select">';
foreach($roles as $k => $v) {
$o .= '<optgroup label="'. htmlspecialchars($v[0]) . '" >';
foreach($v[1] as $kk => $vv) {
$selected = (($kk === $current) ? ' selected="selected" ' : '');
$o .= '<option value="' . $kk . '" ' . $selected . '>' . htmlspecialchars($vv) . '</option>';
}
$o .= '<optgroup>';
}
$o .= '</select>';
return $o;
}

View File

@ -266,6 +266,7 @@ function photo_upload($channel, $observer, $args) {
proc_run('php', "include/notifier.php", 'wall-new', $item_id);
$ret['success'] = true;
$ret['item'] = $arr;
$ret['body'] = $arr['body'];
$ret['resource_id'] = $photo_hash;
$ret['photoitem_id'] = $item_id;

View File

@ -481,11 +481,11 @@ function widget_settings_menu($arr) {
'selected' => ''
),
// array(
// 'label' => t('Export account'),
// 'url' => $a->get_baseurl(true) . '/uexport/complete',
// 'selected' => ''
// ),
array(
'label' => t('Export content'),
'url' => $a->get_baseurl(true) . '/uexport/complete',
'selected' => ''
),
array(
'label' => t('Automatic Permissions (Advanced)'),

View File

@ -1844,8 +1844,10 @@ function sync_locations($sender,$arr,$absolute = false) {
if($absolute && $xisting) {
foreach($xisting as $x) {
if(! array_key_exists('updated',$x)) {
logger('sync_locations: removing unreferenced hub location ' . $x['hubloc_url']);
$r = q("delete from hubloc where hubloc_id = %d limit 1",
logger('sync_locations: deleting unreferenced hub location ' . $x['hubloc_url']);
$r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d), hubloc_updated = '%s' where hubloc_id = %d limit 1",
intval(HUBLOC_FLAGS_DELETED),
dbesc(datetime_convert()),
intval($x['hubloc_id'])
);
$what .= 'removed_hub';
@ -2336,7 +2338,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
function process_channel_sync_delivery($sender,$arr,$deliveries) {
// FIXME - this will sync red structures (channel, pconfig and abook). Eventually we need to make this application agnostic.
// TODO: missing group membership changes
$result = array();
@ -2352,6 +2354,10 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
$channel = $r[0];
$max_friends = service_class_fetch($channel['channel_id'],'total_channels');
$max_feeds = account_service_class_fetch($channel['channel_account_id'],'total_feeds');
if($channel['channel_hash'] != $sender['hash']) {
logger('process_channel_sync_delivery: possible forgery. Sender ' . $sender['hash'] . ' is not ' . $channel['channel_hash']);
$result[] = array($d['hash'],'channel mismatch',$channel['channel_name'],'');
@ -2385,6 +2391,19 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
if(array_key_exists('abook',$arr) && is_array($arr['abook']) && count($arr['abook'])) {
$total_friends = 0;
$total_feeds = 0;
$r = q("select abook_id, abook_flags from abook where abook_channel = %d",
intval($channel['channel_id'])
);
if($r) {
// don't count yourself
$total_friends = ((count($r) > 0) ? $count($r) - 1 : 0);
foreach($r as $rr)
if($rr['abook_flags'] & ABOOK_FLAG_FEED)
$total_feeds ++;
}
$disallowed = array('abook_id','abook_account','abook_channel');
@ -2395,14 +2414,18 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
logger('process_channel_sync_delivery: removing abook entry for ' . $abook['abook_xchan']);
require_once('include/Contact.php');
$r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d and not ( abook_flags & %d ) limit 1",
$r = q("select abook_id, abook_flags from abook where abook_xchan = '%s' and abook_channel = %d and not ( abook_flags & %d ) limit 1",
dbesc($abook['abook_xchan']),
intval($channel['channel_id']),
intval(ABOOK_FLAG_SELF)
);
if($r)
if($r) {
contact_remove($channel['channel_id'],$r[0]['abook_id']);
if($total_friends)
$total_friends --;
if($r[0]['abook_flags'] & ABOOK_FLAG_FEED)
$total_feeds --;
}
continue;
}
@ -2449,10 +2472,21 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
// make sure we have an abook entry for this xchan on this system
if(! $r) {
if($max_friends !== false && $total_friends > $max_friends) {
logger('process_channel_sync_delivery: total_channels service class limit exceeded');
continue;
}
if($max_feeds !== false && ($clean['abook_flags'] & ABOOK_FLAG_FEED) && $total_feeds > $max_feeds) {
logger('process_channel_sync_delivery: total_feeds service class limit exceeded');
continue;
}
q("insert into abook ( abook_xchan, abook_channel ) values ('%s', %d ) ",
dbesc($clean['abook_xchan']),
intval($channel['channel_id'])
);
$total_friends ++;
if($clean['abook_flags'] & ABOOK_FLAG_FEED)
$total_feeds ++;
}
if(count($clean)) {

37
library/oauth/LICENSE Normal file
View File

@ -0,0 +1,37 @@
PHP OAuth API - Access API authorized by the users
using the OAuth protocol
This LICENSE is in the BSD license style.
License Version Control:
@(#) $Id: LICENSE,v 1.2 2013/02/11 05:17:53 mlemos Exp $
Copyright (c) 2012-2013, Manuel Lemos
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of Manuel Lemos nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

36
library/oauth/LICENSE.txt Normal file
View File

@ -0,0 +1,36 @@
HTTP client PHP class
This LICENSE is in the BSD license style.
License Version Control:
@(#) $Id: LICENSE.txt,v 1.1 2006/04/17 19:44:04 mlemos Exp $
Copyright (c) 1999 - 2006, Manuel Lemos
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of Manuel Lemos nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

2092
library/oauth/http.php Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,607 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Class: OAuth client</title>
</head>
<body>
<center><h1>Class: OAuth client</h1></center>
<hr />
<ul>
<p><b>Version:</b> <tt>@(#) $Id: oauth_client.php,v 1.58 2013/04/11 09:33:16 mlemos Exp $</tt></p>
<h2><a name="table_of_contents">Contents</a></h2>
<ul>
<li><a href="#2.1.1">Summary</a></li>
<ul>
<li><a href="#3.2.0">Name</a></li>
<li><a href="#3.2.0.0">Author</a></li>
<li><a href="#3.2.0.1">Copyright</a></li>
<li><a href="#3.2.0.2">Version</a></li>
<li><a href="#3.2.0.3">Purpose</a></li>
<li><a href="#3.2.0.4">Usage</a></li>
</ul>
<li><a href="#4.1.1">Variables</a></li>
<ul>
<li><a href="#5.2.31">error</a></li>
<li><a href="#5.2.32">debug</a></li>
<li><a href="#5.2.33">debug_http</a></li>
<li><a href="#5.2.34">exit</a></li>
<li><a href="#5.2.35">debug_output</a></li>
<li><a href="#5.2.36">debug_prefix</a></li>
<li><a href="#5.2.37">server</a></li>
<li><a href="#5.2.38">request_token_url</a></li>
<li><a href="#5.2.39">dialog_url</a></li>
<li><a href="#5.2.40">offline_dialog_url</a></li>
<li><a href="#5.2.41">append_state_to_redirect_uri</a></li>
<li><a href="#5.2.42">access_token_url</a></li>
<li><a href="#5.2.43">oauth_version</a></li>
<li><a href="#5.2.44">url_parameters</a></li>
<li><a href="#5.2.45">authorization_header</a></li>
<li><a href="#5.2.46">token_request_method</a></li>
<li><a href="#5.2.47">signature_method</a></li>
<li><a href="#5.2.48">redirect_uri</a></li>
<li><a href="#5.2.49">client_id</a></li>
<li><a href="#5.2.50">client_secret</a></li>
<li><a href="#5.2.51">scope</a></li>
<li><a href="#5.2.52">offline</a></li>
<li><a href="#5.2.53">access_token</a></li>
<li><a href="#5.2.54">access_token_secret</a></li>
<li><a href="#5.2.55">access_token_expiry</a></li>
<li><a href="#5.2.56">access_token_type</a></li>
<li><a href="#5.2.57">refresh_token</a></li>
<li><a href="#5.2.58">access_token_error</a></li>
<li><a href="#5.2.59">authorization_error</a></li>
<li><a href="#5.2.60">response_status</a></li>
</ul>
<li><a href="#6.1.1">Functions</a></li>
<ul>
<li><a href="#7.2.9">StoreAccessToken</a></li>
<li><a href="#9.2.10">GetAccessToken</a></li>
<li><a href="#11.2.11">ResetAccessToken</a></li>
<li><a href="#11.2.12">CallAPI</a></li>
<li><a href="#13.2.13">Initialize</a></li>
<li><a href="#13.2.14">Process</a></li>
<li><a href="#13.2.15">Finalize</a></li>
<li><a href="#15.2.16">Output</a></li>
</ul>
</ul>
<p><a href="#table_of_contents">Top of the table of contents</a></p>
</ul>
<hr />
<ul>
<h2><li><a name="2.1.1">Summary</a></li></h2>
<ul>
<h3><a name="3.2.0">Name</a></h3>
<p>OAuth client</p>
<h3><a name="3.2.0.0">Author</a></h3>
<p>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</p>
<h3><a name="3.2.0.1">Copyright</a></h3>
<p>Copyright &copy; (C) Manuel Lemos 2012</p>
<h3><a name="3.2.0.2">Version</a></h3>
<p>@(#) $Id: oauth_client.php,v 1.58 2013/04/11 09:33:16 mlemos Exp $</p>
<h3><a name="3.2.0.3">Purpose</a></h3>
<p>This class serves two main purposes:</p>
<p> 1) Implement the OAuth protocol to retrieve a token from a server to authorize the access to an API on behalf of the current user.</p>
<p> 2) Perform calls to a Web services API using a token previously obtained using this class or a token provided some other way by the Web services provider.</p>
<h3><a name="3.2.0.4">Usage</a></h3>
<p>Regardless of your purposes, you always need to start calling the class <tt><a href="#function_Initialize">Initialize</a></tt> function after initializing setup variables. After you are done with the class, always call the <tt><a href="#function_Finalize">Finalize</a></tt> function at the end.</p>
<p> This class supports either OAuth protocol versions 1.0, 1.0a and 2.0. It abstracts the differences between these protocol versions, so the class usage is the same independently of the OAuth version of the server.</p>
<p> The class also provides built-in support to several popular OAuth servers, so you do not have to manually configure all the details to access those servers. Just set the <tt><a href="#variable_server">server</a></tt> variable to configure the class to access one of the built-in supported servers.</p>
<p> If you need to access one type of server that is not yet directly supported by the class, you need to configure it explicitly setting the variables: <tt><a href="#variable_oauth_version">oauth_version</a></tt>, <tt><a href="#variable_url_parameters">url_parameters</a></tt>, <tt><a href="#variable_authorization_header">authorization_header</a></tt>, <tt><a href="#variable_request_token_url">request_token_url</a></tt>, <tt><a href="#variable_dialog_url">dialog_url</a></tt>, <tt><a href="#variable_offline_dialog_url">offline_dialog_url</a></tt>, <tt><a href="#variable_append_state_to_redirect_uri">append_state_to_redirect_uri</a></tt> and <tt><a href="#variable_access_token_url">access_token_url</a></tt>.</p>
<p> Before proceeding to the actual OAuth authorization process, you need to have registered your application with the OAuth server. The registration provides you values to set the variables <tt><a href="#variable_client_id">client_id</a></tt> and <tt><a href="#variable_client_secret">client_secret</a></tt>.</p>
<p> You also need to set the variables <tt><a href="#variable_redirect_uri">redirect_uri</a></tt> and <tt><a href="#variable_scope">scope</a></tt> before calling the <tt><a href="#function_Process">Process</a></tt> function to make the class perform the necessary interactions with the OAuth server.</p>
<p> The OAuth protocol involves multiple steps that include redirection to the OAuth server. There it asks permission to the current user to grant your application access to APIs on his/her behalf. When there is a redirection, the class will set the <tt><a href="#variable_exit">exit</a></tt> variable to 1. Then your script should exit immediately without outputting anything.</p>
<p> When the OAuth access token is successfully obtained, the following variables are set by the class with the obtained values: <tt><a href="#variable_access_token">access_token</a></tt>, <tt><a href="#variable_access_token_secret">access_token_secret</a></tt>, <tt><a href="#variable_access_token_expiry">access_token_expiry</a></tt>, <tt><a href="#variable_access_token_type">access_token_type</a></tt>. You may want to store these values to use them later when calling the server APIs.</p>
<p> If there was a problem during OAuth authorization process, check the variable <tt><a href="#variable_authorization_error">authorization_error</a></tt> to determine the reason.</p>
<p> Once you get the access token, you can call the server APIs using the <tt><a href="#function_CallAPI">CallAPI</a></tt> function. Check the <tt><a href="#variable_access_token_error">access_token_error</a></tt> variable to determine if there was an error when trying to to call the API.</p>
<p> If for some reason the user has revoked the access to your application, you need to ask the user to authorize your application again. First you may need to call the function <tt><a href="#function_ResetAccessToken">ResetAccessToken</a></tt> to reset the value of the access token that may be cached in session variables.</p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="variables"></a><a name="4.1.1">Variables</a></li></h2>
<ul>
<li><tt><a href="#variable_error">error</a></tt></li><br />
<li><tt><a href="#variable_debug">debug</a></tt></li><br />
<li><tt><a href="#variable_debug_http">debug_http</a></tt></li><br />
<li><tt><a href="#variable_exit">exit</a></tt></li><br />
<li><tt><a href="#variable_debug_output">debug_output</a></tt></li><br />
<li><tt><a href="#variable_debug_prefix">debug_prefix</a></tt></li><br />
<li><tt><a href="#variable_server">server</a></tt></li><br />
<li><tt><a href="#variable_request_token_url">request_token_url</a></tt></li><br />
<li><tt><a href="#variable_dialog_url">dialog_url</a></tt></li><br />
<li><tt><a href="#variable_offline_dialog_url">offline_dialog_url</a></tt></li><br />
<li><tt><a href="#variable_append_state_to_redirect_uri">append_state_to_redirect_uri</a></tt></li><br />
<li><tt><a href="#variable_access_token_url">access_token_url</a></tt></li><br />
<li><tt><a href="#variable_oauth_version">oauth_version</a></tt></li><br />
<li><tt><a href="#variable_url_parameters">url_parameters</a></tt></li><br />
<li><tt><a href="#variable_authorization_header">authorization_header</a></tt></li><br />
<li><tt><a href="#variable_token_request_method">token_request_method</a></tt></li><br />
<li><tt><a href="#variable_signature_method">signature_method</a></tt></li><br />
<li><tt><a href="#variable_redirect_uri">redirect_uri</a></tt></li><br />
<li><tt><a href="#variable_client_id">client_id</a></tt></li><br />
<li><tt><a href="#variable_client_secret">client_secret</a></tt></li><br />
<li><tt><a href="#variable_scope">scope</a></tt></li><br />
<li><tt><a href="#variable_offline">offline</a></tt></li><br />
<li><tt><a href="#variable_access_token">access_token</a></tt></li><br />
<li><tt><a href="#variable_access_token_secret">access_token_secret</a></tt></li><br />
<li><tt><a href="#variable_access_token_expiry">access_token_expiry</a></tt></li><br />
<li><tt><a href="#variable_access_token_type">access_token_type</a></tt></li><br />
<li><tt><a href="#variable_refresh_token">refresh_token</a></tt></li><br />
<li><tt><a href="#variable_access_token_error">access_token_error</a></tt></li><br />
<li><tt><a href="#variable_authorization_error">authorization_error</a></tt></li><br />
<li><tt><a href="#variable_response_status">response_status</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="variable_error"></a><li><a name="5.2.31">error</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Store the message that is returned when an error occurs.</p>
<h3>Usage</h3>
<p>Check this variable to understand what happened when a call to any of the class functions has failed.</p>
<p> This class uses cumulative error handling. This means that if one class functions that may fail is called and this variable was already set to an error message due to a failure in a previous call to the same or other function, the function will also fail and does not do anything.</p>
<p> This allows programs using this class to safely call several functions that may fail and only check the failure condition after the last function call.</p>
<p> Just set this variable to an empty string to clear the error condition.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_debug"></a><li><a name="5.2.32">debug</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Control whether debug output is enabled</p>
<h3>Usage</h3>
<p>Set this variable to 1 if you need to check what is going on during calls to the class. When enabled, the debug output goes either to the variable <tt><a href="#variable_debug_output">debug_output</a></tt> and the PHP error log.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_debug_http"></a><li><a name="5.2.33">debug_http</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Control whether the dialog with the remote Web server should also be logged.</p>
<h3>Usage</h3>
<p>Set this variable to 1 if you want to inspect the data exchange with the OAuth server.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_exit"></a><li><a name="5.2.34">exit</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Determine if the current script should be exited.</p>
<h3>Usage</h3>
<p>Check this variable after calling the <tt><a href="#function_Process">Process</a></tt> function and exit your script immediately if the variable is set to 1.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_debug_output"></a><li><a name="5.2.35">debug_output</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Capture the debug output generated by the class</p>
<h3>Usage</h3>
<p>Inspect this variable if you need to see what happened during the class function calls.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_debug_prefix"></a><li><a name="5.2.36">debug_prefix</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'OAuth client: '</tt></p>
<h3>Purpose</h3>
<p>Mark the lines of the debug output to identify actions performed by this class.</p>
<h3>Usage</h3>
<p>Change this variable if you prefer the debug output lines to be prefixed with a different text.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_server"></a><li><a name="5.2.37">server</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Identify the type of OAuth server to access.</p>
<h3>Usage</h3>
<p>The class provides built-in support to several types of OAuth servers. This means that the class can automatically initialize several configuration variables just by setting this server variable.</p>
<p> Currently it supports the following servers: 'Bitbucket', 'Box', 'Dropbox', 'Eventful', 'Facebook', 'Fitbit', 'Flickr', 'Foursquare', 'github', 'Google', 'Instagram', 'LinkedIn', 'Microsoft', 'Scoop.it', 'StockTwits', 'Tumblr', 'Twitter', 'XING' and 'Yahoo'. Please contact the author if you would like to ask to add built-in support for other types of OAuth servers.</p>
<p> If you want to access other types of OAuth servers that are not yet supported, set this variable to an empty string and configure other variables with values specific to those servers.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_request_token_url"></a><li><a name="5.2.38">request_token_url</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>URL of the OAuth server to request the initial token for OAuth 1.0 and 1.0a servers.</p>
<h3>Usage</h3>
<p>Set this variable to the OAuth request token URL when you are not accessing one of the built-in supported OAuth servers.</p>
<p> For OAuth 1.0 and 1.0a servers, the request token URL can have certain marks that will act as template placeholders which will be replaced with given values before requesting the authorization token. Currently it supports the following placeholder marks:</p>
<p> {SCOPE} - scope of the requested permissions to the granted by the OAuth server with the user permissions</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_dialog_url"></a><li><a name="5.2.39">dialog_url</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>URL of the OAuth server to redirect the browser so the user can grant access to your application.</p>
<h3>Usage</h3>
<p>Set this variable to the OAuth request token URL when you are not accessing one of the built-in supported OAuth servers.</p>
<p> For certain servers, the dialog URL can have certain marks that will act as template placeholders which will be replaced with values defined before redirecting the users browser. Currently it supports the following placeholder marks:</p>
<p> {REDIRECT_URI} - URL to redirect when returning from the OAuth server authorization page</p>
<p> {CLIENT_ID} - client application identifier registered at the server</p>
<p> {SCOPE} - scope of the requested permissions to the granted by the OAuth server with the user permissions</p>
<p> {STATE} - identifier of the OAuth session state</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_offline_dialog_url"></a><li><a name="5.2.40">offline_dialog_url</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>URL of the OAuth server to redirect the browser so the user can grant access to your application when offline access is requested.</p>
<h3>Usage</h3>
<p>Set this variable to the OAuth request token URL when you are not accessing one of the built-in supported OAuth servers and the OAuth server supports offline access.</p>
<p> It should have the same format as the <tt><a href="#variable_dialog_url">dialog_url</a></tt> variable.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_append_state_to_redirect_uri"></a><li><a name="5.2.41">append_state_to_redirect_uri</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Pass the OAuth session state in a variable with a different name to work around implementation bugs of certain OAuth servers</p>
<h3>Usage</h3>
<p>Set this variable when you are not accessing one of the built-in supported OAuth servers if the OAuth server has a bug that makes it not pass back the OAuth state identifier in a request variable named state.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_access_token_url"></a><li><a name="5.2.42">access_token_url</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>OAuth server URL that will return the access token URL.</p>
<h3>Usage</h3>
<p>Set this variable to the OAuth access token URL when you are not accessing one of the built-in supported OAuth servers.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_oauth_version"></a><li><a name="5.2.43">oauth_version</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'2.0'</tt></p>
<h3>Purpose</h3>
<p>Version of the protocol version supported by the OAuth server.</p>
<h3>Usage</h3>
<p>Set this variable to the OAuth server protocol version when you are not accessing one of the built-in supported OAuth servers.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_url_parameters"></a><li><a name="5.2.44">url_parameters</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Determine if the API call parameters should be moved to the call URL.</p>
<h3>Usage</h3>
<p>Set this variable to 1 if the API you need to call requires that the call parameters always be passed via the API URL.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_authorization_header"></a><li><a name="5.2.45">authorization_header</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>Determine if the OAuth parameters should be passed via HTTP Authorization request header.</p>
<h3>Usage</h3>
<p>Set this variable to 1 if the OAuth server requires that the OAuth parameters be passed using the HTTP Authorization instead of the request URI parameters.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_token_request_method"></a><li><a name="5.2.46">token_request_method</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'GET'</tt></p>
<h3>Purpose</h3>
<p>Define the HTTP method that should be used to request tokens from the server.</p>
<h3>Usage</h3>
<p>Set this variable to 'POST' if the OAuth server does not support requesting tokens using the HTTP GET method.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_signature_method"></a><li><a name="5.2.47">signature_method</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>'HMAC-SHA1'</tt></p>
<h3>Purpose</h3>
<p>Define the method to generate the signature for API request parameters values.</p>
<h3>Usage</h3>
<p>Currently it supports 'PLAINTEXT' and 'HMAC-SHA1'.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_redirect_uri"></a><li><a name="5.2.48">redirect_uri</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>URL of the current script page that is calling this class</p>
<h3>Usage</h3>
<p>Set this variable to the current script page URL before proceeding the the OAuth authorization process.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_client_id"></a><li><a name="5.2.49">client_id</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Identifier of your application registered with the OAuth server</p>
<h3>Usage</h3>
<p>Set this variable to the application identifier that is provided by the OAuth server when you register the application.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_client_secret"></a><li><a name="5.2.50">client_secret</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Secret value assigned to your application when it is registered with the OAuth server.</p>
<h3>Usage</h3>
<p>Set this variable to the application secret that is provided by the OAuth server when you register the application.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_scope"></a><li><a name="5.2.51">scope</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Permissions that your application needs to call the OAuth server APIs</p>
<h3>Usage</h3>
<p>Check the documentation of the APIs that your application needs to call to set this variable with the identifiers of the permissions that the user needs to grant to your application.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_offline"></a><li><a name="5.2.52">offline</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>Specify whether it will be necessary to call the API when the user is not present and the server supports renewing expired access tokens using refresh tokens.</p>
<h3>Usage</h3>
<p>Set this variable to 1 if the server supports renewing expired tokens automatically when the user is not present.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_access_token"></a><li><a name="5.2.53">access_token</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Access token obtained from the OAuth server</p>
<h3>Usage</h3>
<p>Check this variable to get the obtained access token upon successful OAuth authorization.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_access_token_secret"></a><li><a name="5.2.54">access_token_secret</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Access token secret obtained from the OAuth server</p>
<h3>Usage</h3>
<p>If the OAuth protocol version is 1.0 or 1.0a, check this variable to get the obtained access token secret upon successful OAuth authorization.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_access_token_expiry"></a><li><a name="5.2.55">access_token_expiry</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Timestamp of the expiry of the access token obtained from the OAuth server.</p>
<h3>Usage</h3>
<p>Check this variable to get the obtained access token expiry time upon successful OAuth authorization. If this variable is empty, that means no expiry time was set.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_access_token_type"></a><li><a name="5.2.56">access_token_type</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Type of access token obtained from the OAuth server.</p>
<h3>Usage</h3>
<p>Check this variable to get the obtained access token type upon successful OAuth authorization.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_refresh_token"></a><li><a name="5.2.57">refresh_token</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Refresh token obtained from the OAuth server</p>
<h3>Usage</h3>
<p>Check this variable to get the obtained refresh token upon successful OAuth authorization.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_access_token_error"></a><li><a name="5.2.58">access_token_error</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Error message returned when a call to the API fails.</p>
<h3>Usage</h3>
<p>Check this variable to determine if there was an error while calling the Web services API when using the <tt><a href="#function_CallAPI">CallAPI</a></tt> function.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_authorization_error"></a><li><a name="5.2.59">authorization_error</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Error message returned when it was not possible to obtain an OAuth access token</p>
<h3>Usage</h3>
<p>Check this variable to determine if there was an error while trying to obtain the OAuth access token.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_response_status"></a><li><a name="5.2.60">response_status</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>HTTP response status returned by the server when calling an API</p>
<h3>Usage</h3>
<p>Check this variable after calling the <tt><a href="#function_CallAPI">CallAPI</a></tt> function if the API calls and you need to process the error depending the response status. 200 means no error. 0 means the server response was not retrieved.</p>
<p><a href="#variables">Variables</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="functions"></a><a name="6.1.1">Functions</a></li></h2>
<ul>
<li><tt><a href="#function_StoreAccessToken">StoreAccessToken</a></tt></li><br />
<li><tt><a href="#function_GetAccessToken">GetAccessToken</a></tt></li><br />
<li><tt><a href="#function_ResetAccessToken">ResetAccessToken</a></tt></li><br />
<li><tt><a href="#function_CallAPI">CallAPI</a></tt></li><br />
<li><tt><a href="#function_Initialize">Initialize</a></tt></li><br />
<li><tt><a href="#function_Process">Process</a></tt></li><br />
<li><tt><a href="#function_Finalize">Finalize</a></tt></li><br />
<li><tt><a href="#function_Output">Output</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="function_StoreAccessToken"></a><li><a name="7.2.9">StoreAccessToken</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> StoreAccessToken(</tt><ul>
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_StoreAccessToken_access_token">access_token</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Store the values of the access token when it is succefully retrieved from the OAuth server.</p>
<h3>Usage</h3>
<p>This function is meant to be only be called from inside the class. By default it stores access tokens in a session variable named 'OAUTH_ACCESS_TOKEN'.</p>
<p> Actual implementations should create a sub-class and override this function to make the access token values be stored in other types of containers, like for instance databases.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_StoreAccessToken_access_token">access_token</a></b></tt> - Associative array with properties of the access token. The array may have set the following properties:</p>
<p> 'value': string value of the access token</p>
<p> 'authorized': boolean value that determines if the access token was obtained successfully</p>
<p> 'expiry': (optional) timestamp in ISO format relative to UTC time zone of the access token expiry time</p>
<p> 'type': (optional) type of OAuth token that may determine how it should be used when sending API call requests.</p>
<p> 'refresh': (optional) token that some servers may set to allowing refreshing access tokens when they expire.</p>
</ul>
<h3>Return value</h3>
<p>This function should return 1 if the access token was stored successfully.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_GetAccessToken"></a><li><a name="9.2.10">GetAccessToken</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> GetAccessToken(</tt><ul>
<tt>(output) <i>string &amp;</i> </tt><tt><a href="#argument_GetAccessToken_access_token">access_token</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Retrieve the OAuth access token if it was already previously stored by the <tt><a href="#function_StoreAccessToken">StoreAccessToken</a></tt> function.</p>
<h3>Usage</h3>
<p>This function is meant to be only be called from inside the class. By default it retrieves access tokens stored in a session variable named 'OAUTH_ACCESS_TOKEN'.</p>
<p> Actual implementations should create a sub-class and override this function to retrieve the access token values from other types of containers, like for instance databases.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_GetAccessToken_access_token">access_token</a></b></tt> - Return the properties of the access token in an associative array. If the access token was not yet stored, it returns an empty array. Otherwise, the properties it may return are the same that may be passed to the <tt><a href="#function_StoreAccessToken">StoreAccessToken</a></tt>.</p>
</ul>
<h3>Return value</h3>
<p>This function should return 1 if the access token was retrieved successfully.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_ResetAccessToken"></a><li><a name="11.2.11">ResetAccessToken</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> ResetAccessToken(</tt><tt>)</tt></p>
<h3>Purpose</h3>
<p>Reset the access token to a state back when the user has not yet authorized the access to the OAuth server API.</p>
<h3>Usage</h3>
<p>Call this function if for some reason the token to access the API was revoked and you need to ask the user to authorize the access again.</p>
<p> By default the class stores and retrieves access tokens in a session variable named 'OAUTH_ACCESS_TOKEN'.</p>
<p> This function must be called when the user is accessing your site pages, so it can reset the information stored in session variables that cache the state of a previously retrieved access token.</p>
<p> Actual implementations should create a sub-class and override this function to reset the access token state when it is stored in other types of containers, like for instance databases.</p>
<h3>Return value</h3>
<p>This function should return 1 if the access token was resetted successfully.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_CallAPI"></a><li><a name="11.2.12">CallAPI</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> CallAPI(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_CallAPI_url">url</a></tt><tt>,</tt><br />
<tt><i>string</i> </tt><tt><a href="#argument_CallAPI_method">method</a></tt><tt>,</tt><br />
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_CallAPI_parameters">parameters</a></tt><tt>,</tt><br />
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_CallAPI_options">options</a></tt><tt>,</tt><br />
<tt>(output) <i>string &amp;</i> </tt><tt><a href="#argument_CallAPI_response">response</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Send a HTTP request to the Web services API using a previously obtained authorization token via OAuth.</p>
<h3>Usage</h3>
<p>This function can be used to call an API after having previously obtained an access token through the OAuth protocol using the <tt><a href="#function_Process">Process</a></tt> function, or by directly setting the variables <tt><a href="#variable_access_token">access_token</a></tt>, as well as <tt><a href="#variable_access_token_secret">access_token_secret</a></tt> in case of using OAuth 1.0 or 1.0a services.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_CallAPI_url">url</a></b></tt> - URL of the API where the HTTP request will be sent.</p>
<p><tt><b><a name="argument_CallAPI_method">method</a></b></tt> - HTTP method that will be used to send the request. It can be 'GET', 'POST', 'DELETE', 'PUT', etc..</p>
<p><tt><b><a name="argument_CallAPI_parameters">parameters</a></b></tt> - Associative array with the names and values of the API call request parameters.</p>
<p><tt><b><a name="argument_CallAPI_options">options</a></b></tt> - Associative array with additional options to configure the request. Currently it supports the following options:</p>
<p> '2Legged': boolean option that determines if the API request should be 2 legged. The default value is <tt>0</tt>.</p>
<p> 'Accept': content type value of the Accept HTTP header to be sent in the API call HTTP request. Some APIs require that a certain value be sent to specify which version of the API is being called. The default value is '*/*'.</p>
<p> 'ConvertObjects': boolean option that determines if objects should be converted into arrays when the response is returned in JSON format. The default value is 0.</p>
<p> 'FailOnAccessError': boolean option that determines if this functions should fail when the server response status is not between 200 and 299. The default value is 0.</p>
<p> 'Files': associative array with details of the parameters that must be passed as file uploads. The array indexes must have the same name of the parameters to be sent as files. The respective array entry values must also be associative arrays with the parameters for each file. Currently it supports the following parameters:</p>
<p> - <tt>Type</tt> - defines how the parameter value should be treated. It can be <tt>'FileName'</tt> if the parameter value is is the name of a local file to be uploaded. It may also be <tt>'Data'</tt> if the parameter value is the actual data of the file to be uploaded.</p>
<p> - Default: <tt>'FileName'</tt></p>
<p> - <tt>ContentType</tt> - MIME value of the content type of the file. It can be <tt>'automatic/name'</tt> if the content type should be determine from the file name extension.</p>
<p> - Default: <tt>'automatic/name'</tt></p>
<p> 'PostValuesInURI': boolean option to determine that a POST request should pass the request values in the URI. The default value is 0.</p>
<p> 'FollowRedirection': limit number of times that HTTP response redirects will be followed. If it is set to 0, redirection responses fail in error. The default value is 0.</p>
<p> 'RequestBody': request body data of a custom type. The 'RequestContentType' option must be specified, so the 'RequestBody' option is considered.</p>
<p> 'RequestContentType': content type that should be used to send the request values. It can be either 'application/x-www-form-urlencoded' for sending values like from Web forms, or 'application/json' for sending the values encoded in JSON format. Other types are accepted if the 'RequestBody' option is specified. The default value is 'application/x-www-form-urlencoded'.</p>
<p> 'RequestBody': request body data of a custom type. The 'RequestContentType' option must be specified, so the 'RequestBody' option is considered.</p>
<p> 'Resource': string with a label that will be used in the error messages and debug log entries to identify what operation the request is performing. The default value is 'API call'.</p>
<p> 'ResponseContentType': content type that should be considered when decoding the API request response. This overrides the <tt>Content-Type</tt> header returned by the server. If the content type is 'application/x-www-form-urlencoded' the function will parse the data returning an array of key-value pairs. If the content type is 'application/json' the response will be decode as a JSON-encoded data type. Other content type values will make the function return the original response value as it was returned from the server. The default value for this option is to use what the server returned in the <tt>Content-Type</tt> header.</p>
<p><tt><b><a name="argument_CallAPI_response">response</a></b></tt> - Return the value of the API response. If the value is JSON encoded, this function will decode it and return the value converted to respective types. If the value is form encoded, this function will decode the response and return it as an array. Otherwise, the class will return the value as a string.</p>
</ul>
<h3>Return value</h3>
<p>This function returns 1 if the call was done successfully.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_Initialize"></a><li><a name="13.2.13">Initialize</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> Initialize(</tt><tt>)</tt></p>
<h3>Purpose</h3>
<p>Initialize the class variables and internal state. It must be called before calling other class functions.</p>
<h3>Usage</h3>
<p>Set the <tt><a href="#variable_server">server</a></tt> variable before calling this function to let it initialize the class variables to work with the specified server type. Alternatively, you can set other class variables manually to make it work with servers that are not yet built-in supported.</p>
<h3>Return value</h3>
<p>This function returns 1 if it was able to successfully initialize the class for the specified server type.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_Process"></a><li><a name="13.2.14">Process</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> Process(</tt><tt>)</tt></p>
<h3>Purpose</h3>
<p>Process the OAuth protocol interaction with the OAuth server.</p>
<h3>Usage</h3>
<p>Call this function when you need to retrieve the OAuth access token. Check the <tt><a href="#variable_access_token">access_token</a></tt> to determine if the access token was obtained successfully.</p>
<h3>Return value</h3>
<p>This function returns 1 if the OAuth protocol was processed without errors.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_Finalize"></a><li><a name="13.2.15">Finalize</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> Finalize(</tt><ul>
<tt><i>bool</i> </tt><tt><a href="#argument_Finalize_success">success</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Cleanup any resources that may have been used during the OAuth protocol processing or execution of API calls.</p>
<h3>Usage</h3>
<p>Always call this function as the last step after calling the functions <tt><a href="#function_Process">Process</a></tt> or <tt><a href="#function_CallAPI">CallAPI</a></tt>.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_Finalize_success">success</a></b></tt> - Pass the last success state returned by the class or any external code processing the class function results.</p>
</ul>
<h3>Return value</h3>
<p>This function returns 1 if the function cleaned up any resources successfully.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_Output"></a><li><a name="15.2.16">Output</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i></i> Output(</tt><tt>)</tt></p>
<h3>Purpose</h3>
<p>Display the results of the OAuth protocol processing.</p>
<h3>Usage</h3>
<p>Only call this function if you are debugging the OAuth authorization process and you need to view what was its results.</p>
<p><a href="#functions">Functions</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<address>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</address>
</body>
</html>

View File

@ -768,7 +768,7 @@ function admin_page_channels_post(&$a){
);
proc_run('php','include/directory.php',$uid,'nopush');
}
notice( sprintf( tt("%s channel censored/uncensored", "%s channelss censored/uncensored", count($channels)), count($channels)) );
notice( sprintf( tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)) );
}
if (x($_POST,'page_channels_delete')){
require_once("include/Contact.php");
@ -814,6 +814,7 @@ function admin_page_channels(&$a){
intval(PAGE_CENSORED),
intval( $uid )
);
proc_run('php','include/directory.php',$uid,'nopush');
notice( sprintf( (($channel[0]['channel_pageflags'] & PAGE_CENSORED) ? t("Channel '%s' uncensored"): t("Channel '%s' censored")) , $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')' ) . EOL);
}; break;

View File

@ -255,6 +255,28 @@ function connedit_content(&$a) {
return login();
}
$my_perms = 0;
$role = get_pconfig(local_user(),'system','permissions_role');
if($role) {
$x = get_role_perms($role);
if($x['perms_accept'])
$my_perms = $x['perms_accept'];
}
if($my_perms) {
$o .= "<script>function connectDefaultShare() {
\$('.abook-edit-me').each(function() {
if(! $(this).is(':disabled'))
$(this).removeAttr('checked');
});\n\n";
$perms = get_perms();
foreach($perms as $p => $v) {
if($my_perms & $v[1]) {
$o .= "\$('#me_id_perms_" . $p . "').attr('checked','checked'); \n";
}
}
$o .= "abook_perms_msg(); }\n</script>\n";
}
if(argc() == 3) {
$contact_id = intval(argv(1));

View File

@ -9,10 +9,25 @@ require_once('include/identity.php');
function import_post(&$a) {
if(! get_account_id()) {
$account_id = get_account_id();
if(! $account_id)
return;
$max_identities = account_service_class_fetch($account_id,'total_identities');
$max_friends = account_service_class_fetch($account_id,'total_channels');
$max_feeds = account_service_class_fetch($account_id,'total_feeds');
if($max_identities !== false) {
$r = q("select channel_id from channel where channel_account_id = %d",
intval($account_id)
);
if($r && count($r) > $max_identities) {
notice( sprintf( t('Your service plan only allows %d channels.'), $max_identities) . EOL);
return;
}
}
$data = null;
$seize = ((x($_REQUEST,'make_primary')) ? intval($_REQUEST['make_primary']) : 0);
@ -276,10 +291,18 @@ function import_post(&$a) {
// FIXME - ensure we have an xchan if somebody is trying to pull a fast one
$friends = 0;
$feeds = 0;
// import contacts
$abooks = $data['abook'];
if($abooks) {
foreach($abooks as $abook) {
if($max_friends !== false && $friends > $max_friends)
continue;
if($max_feeds !== false && ($abook['abook_flags'] & ABOOK_FLAG_FEED) && $feeds > $max_feeds)
continue;
unset($abook['abook_id']);
$abook['abook_account'] = get_account_id();
$abook['abook_channel'] = $channel['channel_id'];
@ -289,6 +312,10 @@ function import_post(&$a) {
. "`) VALUES ('"
. implode("', '", array_values($abook))
. "')" );
$friends ++;
if($abook['abook_flags'] & ABOOK_FLAG_FEED)
$feeds ++;
}
}
@ -349,18 +376,20 @@ function import_post(&$a) {
}
}
//FIXME just a note here for when folks want to import content - be very careful to unset ITEM_ORIGIN on all imported content. Or you could end up with a nasty routing loop when somebody tries to reply to one of those posts.
// FIXME - ensure we have a self entry if somebody is trying to pull a fast one
if($seize) {
// notify old server that it is no longer primary.
}
// send out refresh requests
// notify old server that it may no longer be primary.
proc_run('php','include/notifier.php','location',$channel['channel_id']);
// This will indirectly perform a refresh_all *and* update the directory
proc_run('php', 'include/directory.php', $channel['channel_id']);
// send out refresh requests
notice( t('Import completed.') . EOL);
@ -368,7 +397,6 @@ function import_post(&$a) {
goaway(z_root() . '/network' );
}

View File

@ -1,6 +1,8 @@
<?php
require_once('include/identity.php');
require_once('include/permissions.php');
function new_channel_init(&$a) {
@ -100,7 +102,7 @@ function new_channel_content(&$a) {
$name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : "" );
$nickname = ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : "" );
$privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "" );
$o = replace_macros(get_markup_template('new_channel.tpl'), array(
@ -113,6 +115,9 @@ 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'),
'$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'),
'$nickname' => $nickname,
'$submit' => t('Create')
));

View File

@ -18,7 +18,7 @@ function uexport_init(&$a) {
}
if(argc() > 1 && argv(1) === 'complete') {
echo json_encode('not yet implemented');
echo json_encode(identity_basic_export(local_user(),true));
killme();
}

View File

@ -7,7 +7,7 @@ function xchan_content(&$a) {
$o .= '<h3>Xchan Lookup</h3>';
$o .= '<form action="xchan" method="get">';
$o .= 'Lookup xchan beginning with: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" />';
$o .= 'Lookup xchan beginning with (or webbie): <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" />';
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
@ -15,28 +15,28 @@ function xchan_content(&$a) {
if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$r = q("select * from xchan where xchan_hash like '%s%%'",
$r = q("select * from xchan where xchan_hash like '%s%%' or xchan_addr = '%s' group by xchan_hash",
dbesc($addr),
dbesc($addr)
);
if($r) {
foreach($r as $rr)
$o .= str_replace("\n","<br />",print_r($rr,true)) . EOL;
foreach($r as $rr) {
$o .= str_replace(array("\n"," "),array("<br/>","&nbsp;"),print_r($rr,true)) . EOL;
$s = q("select * from hubloc where hubloc_hash like '%s'",
dbesc($r[0]['xchan_hash'])
);
if($s) {
foreach($s as $rr)
$o .= str_replace(array("\n"," "),array("<br/>","&nbsp;"),print_r($rr,true)) . EOL;
}
}
}
else
notice( t('Not found.') . EOL);
$r = q("select * from hubloc where hubloc_hash like '%s%%'",
dbesc($addr)
);
if($r) {
foreach($r as $rr)
$o .= str_replace("\n","<br />",print_r($rr,true)) . EOL;
}
}
return $o;
}

View File

@ -1 +1 @@
2014-09-14.798
2014-09-17.801

View File

@ -1,13 +1,13 @@
h2 {
margin-left: 15%;
margin-top: 15%;
margin-top: 5%;
}
#newchannel-form {
font-size: 1.4em;
margin-left: 15%;
margin-top: 5%;
margin-top: 20px;
width: 50%;
}

View File

@ -27,3 +27,5 @@ $a->strings["Do you want to authorize this application to access your posts and
$a->strings["If your certificate is not recognized, members of other sites (who may themselves have valid certificates) will get a warning message on their own site complaining about security issues."] = "If your certificate is not recognised, members of other sites (who may themselves have valid certificates) will get a warning message on their own site complaining about security issues.";
$a->strings["This is a hub of the Red Matrix - a global cooperative network of decentralized privacy enhanced websites."] = "This is a hub of the Red Matrix - a global cooperative network of decentralised privacy enhanced websites.";
$a->strings["You are cordially invited to join me and some other close friends on the Red Matrix - a revolutionary new decentralized communication and information tool."] = "You are cordially invited to join me and some other close friends on the Red Matrix - a revolutionary new decentralised communication and information tool.";
$a->strings["l F d, Y \\@ g:i A"] = "l j F, Y \\@ G:i";
$a->strings["D, d M Y - g:i A"] = "D, d M Y - G:i";

View File

@ -1114,7 +1114,7 @@ $(window).scroll(function () {
$('#more').show();
}
if($(window).scrollTop() + $(window).height() == $(document).height()) {
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
if((pageHasMoreContent) && (! loadingPage)) {
$('#more').hide();
$('#no-more').hide();
@ -1134,7 +1134,7 @@ $(window).scroll(function () {
$('#more').show();
}
if($(window).scrollTop() + $(window).height() == $(document).height()) {
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
if((pageHasMoreContent) && (! loadingPage) && (! justifiedGalleryActive)) {
$('#more').hide();
$('#no-more').hide();

View File

@ -6,11 +6,18 @@ function abook_perms_msg() {
}
$(document).ready(function() {
if(typeof(after_following) !== 'undefined' && after_following)
connectFullShare();
if(typeof(after_following) !== 'undefined' && after_following) {
if(typeof(connectDefaultShare) !== 'undefined')
connectDefaultShare();
else
connectFullShare();
}
$('#id_pending').click(function() {
connectFullShare();
if(typeof(connectDefaultShare) !== 'undefined')
connectDefaultShare();
else
connectFullShare();
});
$('.abook-edit-me').click(function() {

View File

@ -1,16 +1,20 @@
$(document).ready(function() {
$("#newchannel-name").blur(function() {
$("#name-spinner").spin('small');
var zreg_name = $("#newchannel-name").val();
$.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) {
$("#newchannel-nickname").val(data);
zFormError("#newchannel-name-feedback",data.error);
$("#name-spinner").spin(false);
});
});
$("#newchannel-nickname").blur(function() {
$("#nick-spinner").spin('small');
var zreg_nick = $("#newchannel-nickname").val();
$.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick),function(data) {
$("#newchannel-nickname").val(data);
zFormError("#newchannel-nickname-feedback",data.error);
$("#nick-spinner").spin(false);
});
});

View File

@ -2060,11 +2060,11 @@ img.mail-list-sender-photo {
.wall-item-ago {
color: #777;
font-size: 0.8em;
font-size: 0.833em;
}
.wall-item-ago i {
font-size: 0.8em;
font-size: 0.833em;
}
.wall-item-content {
@ -2082,7 +2082,7 @@ img.mail-list-sender-photo {
}
.comment-icon {
font-size: 0.8em;
font-size: 0.833em;
color: $toolicon_colour;
}
@ -2256,15 +2256,27 @@ blockquote {
}
h1, h2 {
font-size: 1.15rem;
font-size: 1.583em;
}
h3, h4 {
font-size: $font_size;
font-size: 1.334em;
}
h5, h6 {
font-size: $body_font_size;
font-size: 0.75rem;
}
.wall-item-content h1, .wall-item-content h2 {
font-size: 1.319em;
}
.wall-item-title {
font-size: $font_size;
}
.wall-item-title h3, .wall-item-content h3, .wall-item-content h4 {
font-size: 1.112em;
}
.dropdown-menu {

View File

@ -64,7 +64,7 @@ if(! $a->install) {
// should leave it for admins to define for themselves.
if (! $schema) {
if(file_exists('view/theme/redbasic/schema/default.php')) {
$schemefile = 'view/theme/redbasic/schema/' . 'default.php';
$schemefile = 'view/theme/redbasic/schema/default.php';
require_once ($schemefile);
}
}

View File

@ -58,7 +58,7 @@
<i class="icon-eye-open comment-icon" ></i>
</button>
{{/if}}
<button id="comment-edit-submit-{{$id}}" class="btn btn-primary btn-xs" type="submit" name="submit" onclick="post_comment({{$id}}); return false;">{{$submit}}</button>
<button id="comment-edit-submit-{{$id}}" class="btn btn-primary btn-xs" type="submit" name="button-submit" onclick="post_comment({{$id}}); return false;">{{$submit}}</button>
</div>
</div>
<div class="clear"></div>

View File

@ -85,7 +85,7 @@
<i class="icon-eye-open jot-icons" ></i>
</button>
{{/if}}
<button class="btn btn-primary btn-sm" type="submit" name="submit">{{$share}}</button>
<button class="btn btn-primary btn-sm" type="submit" name="button-submit">{{$share}}</button>
</div>
<div id="profile-jot-perms-end"></div>
<div id="profile-jot-plugin-wrapper">

View File

@ -4,8 +4,16 @@
<div id="newchannel-desc" class="descriptive-paragraph">{{$desc}}</div>
<div id="newchannel-role-help" class="descriptive-paragraph">{{$help_role}}</div>
<label for="newchannel-role" id="label-newchannel-role" class="newchannel-label" >{{$label_role}}</label>
{{$role_select}}
<div id="newchannel-role-end" class="newchannel-field-end"></div>
<label for="newchannel-name" id="label-newchannel-name" class="newchannel-label" >{{$label_name}}</label>
<input type="text" name="name" id="newchannel-name" class="newchannel-input" value="{{$name}}" />
<div id="name-spinner"></div>
<div id="newchannel-name-feedback" class="newchannel-feedback"></div>
<div id="newchannel-name-end" class="newchannel-field-end"></div>
@ -13,6 +21,7 @@
<label for="newchannel-nickname" id="label-newchannel-nickname" class="newchannel-label" >{{$label_nick}}</label>
<input type="text" name="nickname" id="newchannel-nickname" class="newchannel-input" value="{{$nickname}}" />
<div id="nick-spinner"></div>
<div id="newchannel-nickname-feedback" class="newchannel-feedback"></div>
<div id="newchannel-nickname-end" class="newchannel-field-end"></div>