aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-23 21:15:40 -0800
committerfriendica <info@friendica.com>2013-01-23 21:15:40 -0800
commit6e6b268e2523d95624361d29a8bd80b1133aa627 (patch)
tree95c01140f753fe42f0031064597b12c7dc297835
parentc1a5c88720cf00a041ac4838c4e799ee53933ae9 (diff)
downloadvolse-hubzilla-6e6b268e2523d95624361d29a8bd80b1133aa627.tar.gz
volse-hubzilla-6e6b268e2523d95624361d29a8bd80b1133aa627.tar.bz2
volse-hubzilla-6e6b268e2523d95624361d29a8bd80b1133aa627.zip
auto permissions (such as for forums or whatever) - untested but might just work
-rw-r--r--include/permissions.php10
-rw-r--r--mod/connections.php233
-rw-r--r--mod/settings.php21
-rw-r--r--view/js/mod_connections.js18
-rw-r--r--view/tpl/abook_edit.tpl13
-rw-r--r--view/tpl/smarty3/abook_edit.tpl13
6 files changed, 188 insertions, 120 deletions
diff --git a/include/permissions.php b/include/permissions.php
index 69f5d75af..ab40a7017 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -86,9 +86,10 @@ function get_all_perms($uid,$observer,$internal_use = true) {
if($observer) {
if(! $abook_checked) {
$x = q("select abook_my_perms, abook_flags from abook
- where abook_channel = %d and abook_xchan = '%s' limit 1",
+ where abook_channel = %d and abook_xchan = '%s' and not ( abook_flags & %d ) limit 1",
intval($uid),
- dbesc($observer)
+ dbesc($observer),
+ intval(ABOOK_FLAG_SELF)
);
$abook_checked = true;
}
@@ -210,9 +211,10 @@ function perm_is_allowed($uid,$observer,$permission) {
return false;
if($observer) {
- $x = q("select abook_my_perms, abook_flags from abook where abook_channel = %d and abook_xchan = '%s' limit 1",
+ $x = q("select abook_my_perms, abook_flags from abook where abook_channel = %d and abook_xchan = '%s' and not ( abook_flags & %d ) limit 1",
intval($uid),
- dbesc($observer)
+ dbesc($observer),
+ intval(ABOOK_FLAG_SELF)
);
// If they're blocked - they can't read or write
diff --git a/mod/connections.php b/mod/connections.php
index 8a668ad2a..94982631a 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -107,8 +107,8 @@ function connections_post(&$a) {
notice( t('Failed to update connnection record.') . EOL);
- if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms) {
- // FIXME - this message type is not yet handled in the notifier
+ if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms
+ && (! ($a->data['abook']['abook_flags'] & ABOOK_FLAG_SELF))) {
proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
}
@@ -238,66 +238,69 @@ function connections_content(&$a) {
$contact = $a->data['abook'];
- $tabs = array(
-
- array(
- 'label' => t('View Profile'),
- 'url' => $a->get_baseurl(true) . '/chanview/?f=&cid=' . $contact['abook_id'],
- 'sel' => '',
- 'title' => sprintf( t('View %s\'s profile'), $contact['xchan_name']),
- ),
-
- array(
- 'label' => t('Refresh Permissions'),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/refresh',
- 'sel' => '',
- 'title' => t('Fetch updated permissions'),
- ),
-
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/block',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''),
- 'title' => t('Block or Unblock this connection'),
- ),
-
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/ignore',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''),
- 'title' => t('Ignore or Unignore this connection'),
- ),
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/archive',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''),
- 'title' => t('Archive or Unarchive this connection'),
- ),
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/hide',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''),
- 'title' => t('Hide or Unhide this connection'),
- ),
-
- array(
- 'label' => t('Delete'),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/drop',
- 'sel' => '',
- 'title' => t('Delete this connection'),
- ),
-
- );
-
- $tab_tpl = get_markup_template('common_tabs.tpl');
- $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
+ $tabs = array(
+
+ array(
+ 'label' => t('View Profile'),
+ 'url' => $a->get_baseurl(true) . '/chanview/?f=&cid=' . $contact['abook_id'],
+ 'sel' => '',
+ 'title' => sprintf( t('View %s\'s profile'), $contact['xchan_name']),
+ ),
+
+ array(
+ 'label' => t('Refresh Permissions'),
+ 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/refresh',
+ 'sel' => '',
+ 'title' => t('Fetch updated permissions'),
+ ),
+
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')),
+ 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/block',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''),
+ 'title' => t('Block or Unblock this connection'),
+ ),
+
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')),
+ 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/ignore',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''),
+ 'title' => t('Ignore or Unignore this connection'),
+ ),
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')),
+ 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/archive',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''),
+ 'title' => t('Archive or Unarchive this connection'),
+ ),
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')),
+ 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/hide',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''),
+ 'title' => t('Hide or Unhide this connection'),
+ ),
+
+ array(
+ 'label' => t('Delete'),
+ 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/drop',
+ 'sel' => '',
+ 'title' => t('Delete this connection'),
+ ),
+ );
+ $self = false;
+ if(! ($contact['abook_flags'] & ABOOK_FLAG_SELF)) {
+ $tab_tpl = get_markup_template('common_tabs.tpl');
+ $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
+ }
+ else
+ $self = true;
$a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
'$baseurl' => $a->get_baseurl(true),
- '$editselect' => $editselect,
+ '$editselect' => $editselect
));
require_once('include/contact_selectors.php');
@@ -324,66 +327,70 @@ function connections_content(&$a) {
$global_perms = get_perms();
$existing = get_all_perms(local_user(),$contact);
-
+
foreach($global_perms as $k => $v) {
$perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),((($contact['abook_my_perms'] & $v[1]) || $existing[$k]) ? "1" : ""), $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4]);
}
-
$o .= replace_macros($tpl,array(
- '$header' => sprintf( t('Connections: settings for %s'),$contact['xchan_name']),
- '$addr' => $contact['xchan_addr'],
- '$viewprof' => t('View Profile'),
- '$lbl_slider' => t('Slide to adjust your degree of friendship'),
- '$slide' => $slide,
- '$tabs' => $t,
- '$tab_str' => $tab_str,
- '$submit' => t('Submit'),
- '$lbl_vis1' => t('Profile Visibility'),
- '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']),
- '$lbl_info1' => t('Contact Information / Notes'),
- '$infedit' => t('Edit contact notes'),
- '$close' => $contact['abook_closeness'],
- '$them' => t('Their Settings'),
- '$me' => t('My Settings'),
- '$perms' => $perms,
- '$full' => t('Full Sharing'),
- '$cautious' => t('Cautious Sharing'),
- '$follow' => t('Follow Only'),
- '$advanced' => t('Advanced Permissions'),
- '$quick' => t('Quick Links'),
- '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
- '$all_friends' => $all_friends,
- '$relation_text' => $relation_text,
- '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['xchan_name'],$contact['xchan_url']),
- '$blockunblock' => t('Block/Unblock contact'),
- '$ignorecont' => t('Ignore contact'),
- '$lblcrepair' => t("Repair URL settings"),
- '$lblrecent' => t('View conversations'),
- '$lblsuggest' => $lblsuggest,
- '$delete' => t('Delete contact'),
- '$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)),
- '$poll_enabled' => $poll_enabled,
- '$lastupdtext' => t('Last update:'),
- '$lost_contact' => $lost_contact,
- '$updpub' => t('Update public posts'),
- '$last_update' => $last_update,
- '$udnow' => t('Update now'),
+ '$header' => (($self) ? t('Automatic Permissions Settings') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])),
+ '$addr' => $contact['xchan_addr'],
+ '$notself' => (($self) ? '' : '1'),
+ '$self' => (($self) ? '1' : ''),
+ '$autolbl' => t('When receiving a channel introduction, any permissions provided here will be applied to the new connnection automatically and the introduction approved. Leave this page if you do not wish to use this feature.'),
+ '$viewprof' => t('View Profile'),
+ '$lbl_slider' => t('Slide to adjust your degree of friendship'),
+ '$slide' => $slide,
+ '$tabs' => $t,
+ '$tab_str' => $tab_str,
+ '$submit' => t('Submit'),
+ '$lbl_vis1' => t('Profile Visibility'),
+ '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']),
+ '$lbl_info1' => t('Contact Information / Notes'),
+ '$infedit' => t('Edit contact notes'),
+ '$close' => $contact['abook_closeness'],
+ '$them' => t('Their Settings'),
+ '$me' => t('My Settings'),
+ '$perms' => $perms,
+ '$forum' => t('Forum Members'),
+ '$full' => t('Full Sharing'),
+ '$cautious' => t('Cautious Sharing'),
+ '$follow' => t('Follow Only'),
+ '$permlbl' => t('Permissions'),
+ '$advanced' => t('Advanced Permissions'),
+ '$quick' => t('Quick Links'),
+ '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
+ '$all_friends' => $all_friends,
+ '$relation_text' => $relation_text,
+ '$visit' => sprintf( t('Visit %s\'s profile - %s'),$contact['xchan_name'],$contact['xchan_url']),
+ '$blockunblock' => t('Block/Unblock contact'),
+ '$ignorecont' => t('Ignore contact'),
+ '$lblcrepair' => t("Repair URL settings"),
+ '$lblrecent' => t('View conversations'),
+ '$lblsuggest' => $lblsuggest,
+ '$delete' => t('Delete contact'),
+ '$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)),
+ '$poll_enabled' => $poll_enabled,
+ '$lastupdtext' => t('Last update:'),
+ '$lost_contact' => $lost_contact,
+ '$updpub' => t('Update public posts'),
+ '$last_update' => $last_update,
+ '$udnow' => t('Update now'),
// '$profile_select' => contact_profile_assign($contact['profile_id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
- '$contact_id' => $contact['abook_id'],
- '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
- '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
- '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
- '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
- '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
- '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
- '$photo' => $contact['photo'],
- '$name' => $contact['name'],
- '$dir_icon' => $dir_icon,
- '$alt_text' => $alt_text,
- '$sparkle' => $sparkle,
- '$url' => $url
+ '$contact_id' => $contact['abook_id'],
+ '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
+ '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
+ '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
+ '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
+ '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
+ '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
+ '$photo' => $contact['photo'],
+ '$name' => $contact['name'],
+ '$dir_icon' => $dir_icon,
+ '$alt_text' => $alt_text,
+ '$sparkle' => $sparkle,
+ '$url' => $url
));
@@ -395,10 +402,10 @@ function connections_content(&$a) {
}
- $blocked = false;
- $hidden = false;
- $ignored = false;
- $archived = false;
+ $blocked = false;
+ $hidden = false;
+ $ignored = false;
+ $archived = false;
$unblocked = false;
$all = false;
diff --git a/mod/settings.php b/mod/settings.php
index d75fe3043..c1380e159 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -14,16 +14,29 @@ function get_theme_config_file($theme){
return null;
}
-function settings_init(&$a) {
+function settings_aside(&$a) {
// default is channel settings in the absence of other arguments
if(argc() == 1) {
+ // We are setting these values - don't use the argc(), argv() functions here
$a->argc = 2;
$a->argv[] = 'channel';
}
+ $abook_self_id = 0;
+
+ // Retrieve the 'self' address book entry for use in the auto-permissions link
+ if(local_user()) {
+ $abk = q("select abook_id from abook where abook_channel = %d and ( abook_flags & %d ) limit 1",
+ intval(local_user()),
+ intval(ABOOK_FLAG_SELF)
+ );
+ if($abk)
+ $abook_self_id = $abk[0]['abook_id'];
+ }
+
$tabs = array(
array(
@@ -74,6 +87,12 @@ function settings_init(&$a) {
// 'selected' => ''
// ),
+ array(
+ 'label' => t('Automatic Permissions (Advanced)'),
+ 'url' => $a->get_baseurl(true) . '/connections/' . $abook_self_id,
+ 'selected' => ''
+ ),
+
);
diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js
index 7fb38b56e..485e2244b 100644
--- a/view/js/mod_connections.js
+++ b/view/js/mod_connections.js
@@ -26,6 +26,8 @@ function connectFullShare() {
$('#me_id_perms_view_profile').attr('checked','checked');
$('#me_id_perms_view_photos').attr('checked','checked');
$('#me_id_perms_view_contacts').attr('checked','checked');
+ $('#me_id_perms_view_storage').attr('checked','checked');
+ $('#me_id_perms_view_pages').attr('checked','checked');
$('#me_id_perms_send_stream').attr('checked','checked');
$('#me_id_perms_post_wall').attr('checked','checked');
$('#me_id_perms_post_comments').attr('checked','checked');
@@ -39,12 +41,28 @@ function connectCautiousShare() {
$('#me_id_perms_view_stream').attr('checked','checked');
$('#me_id_perms_view_profile').attr('checked','checked');
$('#me_id_perms_view_photos').attr('checked','checked');
+ $('#me_id_perms_view_storage').attr('checked','checked');
+ $('#me_id_perms_view_pages').attr('checked','checked');
$('#me_id_perms_send_stream').attr('checked','checked');
$('#me_id_perms_post_comments').attr('checked','checked');
$('#me_id_perms_post_mail').attr('checked','checked');
}
+function connectForum() {
+ $('#me_id_perms_view_stream').attr('checked','checked');
+ $('#me_id_perms_view_profile').attr('checked','checked');
+ $('#me_id_perms_view_photos').attr('checked','checked');
+ $('#me_id_perms_view_contacts').attr('checked','checked');
+ $('#me_id_perms_view_storage').attr('checked','checked');
+ $('#me_id_perms_view_pages').attr('checked','checked');
+ $('#me_id_perms_send_stream').attr('checked','checked');
+ $('#me_id_perms_post_comments').attr('checked','checked');
+ $('#me_id_perms_post_mail').attr('checked','checked');
+ $('#me_id_perms_tag_deliver').attr('checked','checked');
+}
+
+
function connectFollowOnly() {
$('#me_id_perms_send_stream').attr('checked','checked');
diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl
index 606e61b80..4deb84823 100644
--- a/view/tpl/abook_edit.tpl
+++ b/view/tpl/abook_edit.tpl
@@ -3,20 +3,28 @@
<h3>$addr</h3>
+{{ if $notself }}
<div id="connection-flag-tabs">
$tabs
</div>
+{{ endif }}
+
+{{ if $self }}
+<div id="autoperm-desc" class="descriptive-paragraph">$autolbl</div>
+{{ endif }}
<div id="contact-edit-wrapper">
+{{ if $notself }}
{{ if $slide }}
<h3>$lbl_slider</h3>
$slide
{{ endif }}
+{{ endif }}
-<h3>Permissions</h3>
+<h3>$permlbl</h3>
<form action="connections/$contact_id" method="post" >
<input type="hidden" name="contact_id" value="$contact_id">
@@ -25,6 +33,9 @@ $slide
<br />
<b>$quick</b>
<ul>
+{{ if $self }}
+<li><a href="#" onclick="connectForum(); return false;">$forum</a></li>
+{{ endif }}
<li><a href="#" onclick="connectFullShare(); return false;">$full</a></li>
<li><a href="#" onclick="connectCautiousShare(); return false;">$cautious</a></li>
<li><a href="#" onclick="connectFollowOnly(); return false;">$follow</a></li>
diff --git a/view/tpl/smarty3/abook_edit.tpl b/view/tpl/smarty3/abook_edit.tpl
index 623f13dd4..e3da32999 100644
--- a/view/tpl/smarty3/abook_edit.tpl
+++ b/view/tpl/smarty3/abook_edit.tpl
@@ -3,20 +3,28 @@
<h3>{{$addr}}</h3>
+{{if $notself}}
<div id="connection-flag-tabs">
{{$tabs}}
</div>
+{{/if}}
+
+{{if $self}}
+<div id="autoperm-desc" class="descriptive-paragraph">{{$autolbl}}</div>
+{{/if}}
<div id="contact-edit-wrapper">
+{{if $notself}}
{{if $slide}}
<h3>{{$lbl_slider}}</h3>
{{$slide}}
{{/if}}
+{{/if}}
-<h3>Permissions</h3>
+<h3>{{$permlbl}}</h3>
<form action="connections/{{$contact_id}}" method="post" >
<input type="hidden" name="contact_id" value="{{$contact_id}}">
@@ -25,6 +33,9 @@
<br />
<b>{{$quick}}</b>
<ul>
+{{if $self}}
+<li><a href="#" onclick="connectForum(); return false;">{{$forum}}</a></li>
+{{/if}}
<li><a href="#" onclick="connectFullShare(); return false;">{{$full}}</a></li>
<li><a href="#" onclick="connectCautiousShare(); return false;">{{$cautious}}</a></li>
<li><a href="#" onclick="connectFollowOnly(); return false;">{{$follow}}</a></li>