aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/permissions.php22
-rw-r--r--mod/connections.php68
-rw-r--r--mod/settings.php22
-rw-r--r--version.inc2
-rw-r--r--view/tpl/abook_edit.tpl16
-rw-r--r--view/tpl/field_acheckbox.tpl4
6 files changed, 68 insertions, 66 deletions
diff --git a/include/permissions.php b/include/permissions.php
index 048019a35..ca44ac4ad 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -4,19 +4,19 @@
function get_perms() {
$global_perms = array(
// Read only permissions
- 'view_stream' => array('channel_r_stream', intval(PERMS_R_STREAM), true, t('Who can view your "public" stream and posts'), ''),
- 'view_profile' => array('channel_r_profile', intval(PERMS_R_PROFILE), true, t('Who can view your "public" channel profile'), ''),
- 'view_photos' => array('channel_r_photos', intval(PERMS_R_PHOTOS), true, t('Who can view your "public" photo albums'), ''),
- 'view_contacts' => array('channel_r_abook', intval(PERMS_R_ABOOK), true, t('Who can view your "public" address book'), ''),
+ 'view_stream' => array('channel_r_stream', intval(PERMS_R_STREAM), true, t('Can view my "public" stream and posts'), ''),
+ 'view_profile' => array('channel_r_profile', intval(PERMS_R_PROFILE), true, t('Can view my "public" channel profile'), ''),
+ 'view_photos' => array('channel_r_photos', intval(PERMS_R_PHOTOS), true, t('Can view my "public" photo albums'), ''),
+ 'view_contacts' => array('channel_r_abook', intval(PERMS_R_ABOOK), true, t('Can view my "public" address book'), ''),
// Write permissions
- 'send_stream' => array('channel_w_stream', intval(PERMS_W_STREAM), false, t('Who can send you their channel stream and posts'), ''),
- 'post_wall' => array('channel_w_wall', intval(PERMS_W_WALL), false, t('Who can post on your channel page'), ''),
- 'post_comments' => array('channel_w_comment', intval(PERMS_W_COMMENT), false, t('Who can comment on your posts'), ''),
- 'post_mail' => array('channel_w_mail', intval(PERMS_W_MAIL), false, t('Who can send you private mail messages'), ''),
- 'post_photos' => array('channel_w_photos', intval(PERMS_W_PHOTOS), false, t('Who can post photos to your photo albums'), ''),
- 'tag_deliver' => array('channel_w_tagwall', intval(PERMS_W_TAGWALL), false, t('Who can forward to all your channel contacts via post tags'), t('Advanced - useful for creating group forum channels')),
- 'chat' => array('channel_w_chat', intval(PERMS_W_CHAT), false, t('Who can chat with you (when available)'), t('Requires compatible chat plugin')),
+ 'send_stream' => array('channel_w_stream', intval(PERMS_W_STREAM), false, t('Can send me their channel stream and posts'), ''),
+ 'post_wall' => array('channel_w_wall', intval(PERMS_W_WALL), false, t('Can post on my channel page ("wall")'), ''),
+ 'post_comments' => array('channel_w_comment', intval(PERMS_W_COMMENT), false, t('Can comment on my posts'), ''),
+ 'post_mail' => array('channel_w_mail', intval(PERMS_W_MAIL), false, t('Can send me private mail messages'), ''),
+ 'post_photos' => array('channel_w_photos', intval(PERMS_W_PHOTOS), false, t('Can post photos to my photo albums'), ''),
+ 'tag_deliver' => array('channel_w_tagwall', intval(PERMS_W_TAGWALL), false, t('Can forward to all my channel contacts via post tags'), t('Advanced - useful for creating group forum channels')),
+ 'chat' => array('channel_w_chat', intval(PERMS_W_CHAT), false, t('Can chat with me (when available)'), t('Requires compatible chat plugin')),
);
return $global_perms;
}
diff --git a/mod/connections.php b/mod/connections.php
index a542abb7a..67a5ee13e 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -63,18 +63,18 @@ function connections_post(&$a) {
if(! local_user())
return;
- $contact_id = intval($a->argv[1]);
+ $contact_id = intval(argv(1));
if(! $contact_id)
return;
- $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ $orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
intval($contact_id),
intval(local_user())
);
- if(! count($orig_record)) {
+ if(! $orig_record) {
notice( t('Could not access contact record.') . EOL);
- goaway($a->get_baseurl(true) . '/contacts');
+ goaway($a->get_baseurl(true) . '/connnections');
return; // NOTREACHED
}
@@ -102,29 +102,41 @@ function connections_post(&$a) {
if($closeness < 0)
$closeness = 99;
- $info = fix_mce_lf(escape_tags(trim($_POST['info'])));
+ $abook_my_perms = 0;
- $r = q("UPDATE `contact` SET `profile_id` = %d, `priority` = %d , `info` = '%s',
- `hidden` = %d, closeness = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ foreach($_POST as $k => $v) {
+ if(strpos($k,'perms_') === 0) {
+ $abook_my_perms += $v;
+ }
+ }
+
+
+
+
+ $r = q("UPDATE abook SET abook_profile = %d, abook_my_perms = %d , abook_closeness = %d
+ where abook_id = %d AND abook_channel = %d LIMIT 1",
intval($profile_id),
- intval($priority),
- dbesc($info),
- intval($hidden),
+ intval($abook_my_perms),
intval($closeness),
intval($contact_id),
intval(local_user())
);
if($r)
- info( t('Contact updated.') . EOL);
+ info( t('Connection updated.') . EOL);
else
- notice( t('Failed to update contact record.') . EOL);
+ notice( t('Failed to update connnection record.') . EOL);
- $r = q("select * from contact where id = %d and uid = %d limit 1",
- intval($contact_id),
- intval(local_user())
+
+ // Refresh the structure in memory with the new data
+
+ $r = q("SELECT abook.*, xchan.*
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and abook_id = %d LIMIT 1",
+ intval(local_user()),
+ intval($contact_id)
);
- if($r && count($r))
- $a->data['contact'] = $r[0];
+ if($r)
+ $a->data['abook'] = $r[0];
return;
@@ -378,6 +390,15 @@ EOT;
'$world' => t('Unknown')
));
+ $perms = array();
+ $channel = $a->get_channel();
+
+ $global_perms = get_perms();
+ 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]) ? "1" : ""), $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4]);
+ }
+
+
$o .= replace_macros($tpl,array(
'$header' => t('Contact Settings') . ' for ' . $contact['xchan_name'],
@@ -393,18 +414,7 @@ EOT;
'$close' => $contact['abook_closeness'],
'$them' => t('Their Settings'),
'$me' => t('My Settings'),
-
- '$perm01' => array( 'perm01', t('Can be seen in my address book')),
- '$perm02' => array( 'perm02', t('Can post to my stream')),
- '$perm03' => array( 'perm03', t('Can see my posts')),
- '$perm04' => array( 'perm04', t('Can comment on my posts')),
- '$perm05' => array( 'perm05', t('Can post to my wall'), false, t('if I allow wall posts')),
- '$perm06' => array( 'perm06', t('Can post to my wall via tags'), false, t('e.g. public groups')),
- '$perm07' => array( 'perm07', t('Can send me email')),
- '$perm08' => array( 'perm08', t('Can see my address book'), false, t('if it is not public')),
- '$perm09' => array( 'perm09', t('Can IM me'), false, t('when available')),
- '$perm10' => array( 'perm10', t('Can see these permissions')),
-
+ '$perms' => $perms,
'$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
diff --git a/mod/settings.php b/mod/settings.php
index d4dd34ad5..5c3d7dead 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -328,17 +328,17 @@ function settings_post(&$a) {
$post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
$arr = array();
- $arr['channel_r_stream'] = (($_POST['channel_r_stream']) ? $_POST['channel_r_stream'] : 0);
- $arr['channel_r_profile'] = (($_POST['channel_r_profile']) ? $_POST['channel_r_profile'] : 0);
- $arr['channel_r_photos'] = (($_POST['channel_r_photos']) ? $_POST['channel_r_photos'] : 0);
- $arr['channel_r_abook'] = (($_POST['channel_r_abook']) ? $_POST['channel_r_abook'] : 0);
- $arr['channel_w_stream'] = (($_POST['channel_w_stream']) ? $_POST['channel_w_stream'] : 0);
- $arr['channel_w_wall'] = (($_POST['channel_w_wall']) ? $_POST['channel_w_wall'] : 0);
- $arr['channel_w_tagwall'] = (($_POST['channel_w_tagwall']) ? $_POST['channel_w_tagwall'] : 0);
- $arr['channel_w_comment'] = (($_POST['channel_w_comment']) ? $_POST['channel_w_comment'] : 0);
- $arr['channel_w_mail'] = (($_POST['channel_w_mail']) ? $_POST['channel_w_mail'] : 0);
- $arr['channel_w_photos'] = (($_POST['channel_w_photos']) ? $_POST['channel_w_photos'] : 0);
- $arr['channel_w_chat'] = (($_POST['channel_w_chat']) ? $_POST['channel_w_chat'] : 0);
+ $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0);
+ $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0);
+ $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0);
+ $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0);
+ $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0);
+ $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0);
+ $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0);
+ $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0);
+ $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0);
+ $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0);
+ $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0);
diff --git a/version.inc b/version.inc
index 924b1152a..f44cb8d64 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-11-07.131
+2012-11-08.132
diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl
index c534dbde7..353abd6ef 100644
--- a/view/tpl/abook_edit.tpl
+++ b/view/tpl/abook_edit.tpl
@@ -16,7 +16,7 @@ $slide
<h3>Permissions</h3>
-<form action="abook/$contact_id" method="post" >
+<form action="connections/$contact_id" method="post" >
<input type="hidden" name="contact_id" value="$contact_id">
<input id="contact-closeness-mirror" type="hidden" name="closeness" value="$close" />
@@ -32,17 +32,9 @@ $slide
<span class="abook-them">$them</span><span class="abook-me">$me</span>
<br />
<br />
-{{inc field_acheckbox.tpl with $field=$perm01 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm02 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm03 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm04 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm05 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm06 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm07 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm08 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm09 }}{{endinc}}
-{{inc field_acheckbox.tpl with $field=$perm10 }}{{endinc}}
-
+{{ for $perms as $prm }}
+{{inc field_acheckbox.tpl with $field=$prm }}{{endinc}}
+{{ endfor }}
<br />
</div>
diff --git a/view/tpl/field_acheckbox.tpl b/view/tpl/field_acheckbox.tpl
index 6b7bd274b..b1edd782e 100644
--- a/view/tpl/field_acheckbox.tpl
+++ b/view/tpl/field_acheckbox.tpl
@@ -2,6 +2,6 @@
<div class='field acheckbox'>
<label for='id_$field.0'>$field.1</label>
<input type="checkbox" class="abook-edit-them" name='$field.0' id='id_$field.0' value="1" disabled="disabled" {{ if $field.2 }}checked="checked"{{ endif }} />
- <input type="checkbox" class="abook-edit-me" name='$field.0' id='id_$field.0' value="1" {{ if $field.2 }}checked="checked"{{ endif }} />
- <span class='field_abook_help'>$field.3</span>
+ <input type="checkbox" class="abook-edit-me" name='$field.0' id='id_$field.0' value="$field.4" {{ if $field.3 }}checked="checked"{{ endif }} {{ if $field.5 }} disabled="disabled" {{ endif }}/>
+ <span class='field_abook_help'>$field.6</span>
</div>