permissions and contact permissions are now sticky
This commit is contained in:
parent
3d56ab227d
commit
c1b931549c
@ -4,19 +4,19 @@
|
|||||||
function get_perms() {
|
function get_perms() {
|
||||||
$global_perms = array(
|
$global_perms = array(
|
||||||
// Read only permissions
|
// Read only permissions
|
||||||
'view_stream' => array('channel_r_stream', intval(PERMS_R_STREAM), true, t('Who can view your "public" stream and posts'), ''),
|
'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('Who can view your "public" channel profile'), ''),
|
'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('Who can view your "public" photo albums'), ''),
|
'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('Who can view your "public" address book'), ''),
|
'view_contacts' => array('channel_r_abook', intval(PERMS_R_ABOOK), true, t('Can view my "public" address book'), ''),
|
||||||
|
|
||||||
// Write permissions
|
// Write permissions
|
||||||
'send_stream' => array('channel_w_stream', intval(PERMS_W_STREAM), false, t('Who can send you their channel stream and posts'), ''),
|
'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('Who can post on your channel page'), ''),
|
'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('Who can comment on your posts'), ''),
|
'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('Who can send you private mail messages'), ''),
|
'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('Who can post photos to your photo albums'), ''),
|
'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('Who can forward to all your channel contacts via post tags'), t('Advanced - useful for creating group forum channels')),
|
'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('Who can chat with you (when available)'), t('Requires compatible chat plugin')),
|
'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;
|
return $global_perms;
|
||||||
}
|
}
|
||||||
|
@ -63,18 +63,18 @@ function connections_post(&$a) {
|
|||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$contact_id = intval($a->argv[1]);
|
$contact_id = intval(argv(1));
|
||||||
if(! $contact_id)
|
if(! $contact_id)
|
||||||
return;
|
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($contact_id),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! count($orig_record)) {
|
if(! $orig_record) {
|
||||||
notice( t('Could not access contact record.') . EOL);
|
notice( t('Could not access contact record.') . EOL);
|
||||||
goaway($a->get_baseurl(true) . '/contacts');
|
goaway($a->get_baseurl(true) . '/connnections');
|
||||||
return; // NOTREACHED
|
return; // NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,29 +102,41 @@ function connections_post(&$a) {
|
|||||||
if($closeness < 0)
|
if($closeness < 0)
|
||||||
$closeness = 99;
|
$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',
|
foreach($_POST as $k => $v) {
|
||||||
`hidden` = %d, closeness = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
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($profile_id),
|
||||||
intval($priority),
|
intval($abook_my_perms),
|
||||||
dbesc($info),
|
|
||||||
intval($hidden),
|
|
||||||
intval($closeness),
|
intval($closeness),
|
||||||
intval($contact_id),
|
intval($contact_id),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
if($r)
|
if($r)
|
||||||
info( t('Contact updated.') . EOL);
|
info( t('Connection updated.') . EOL);
|
||||||
else
|
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),
|
// Refresh the structure in memory with the new data
|
||||||
intval(local_user())
|
|
||||||
|
$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))
|
if($r)
|
||||||
$a->data['contact'] = $r[0];
|
$a->data['abook'] = $r[0];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -378,6 +390,15 @@ EOT;
|
|||||||
'$world' => t('Unknown')
|
'$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(
|
$o .= replace_macros($tpl,array(
|
||||||
|
|
||||||
'$header' => t('Contact Settings') . ' for ' . $contact['xchan_name'],
|
'$header' => t('Contact Settings') . ' for ' . $contact['xchan_name'],
|
||||||
@ -393,18 +414,7 @@ EOT;
|
|||||||
'$close' => $contact['abook_closeness'],
|
'$close' => $contact['abook_closeness'],
|
||||||
'$them' => t('Their Settings'),
|
'$them' => t('Their Settings'),
|
||||||
'$me' => t('My Settings'),
|
'$me' => t('My Settings'),
|
||||||
|
'$perms' => $perms,
|
||||||
'$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')),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
|
'$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
|
||||||
|
@ -328,17 +328,17 @@ function settings_post(&$a) {
|
|||||||
$post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
|
$post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
$arr['channel_r_stream'] = (($_POST['channel_r_stream']) ? $_POST['channel_r_stream'] : 0);
|
$arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0);
|
||||||
$arr['channel_r_profile'] = (($_POST['channel_r_profile']) ? $_POST['channel_r_profile'] : 0);
|
$arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0);
|
||||||
$arr['channel_r_photos'] = (($_POST['channel_r_photos']) ? $_POST['channel_r_photos'] : 0);
|
$arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0);
|
||||||
$arr['channel_r_abook'] = (($_POST['channel_r_abook']) ? $_POST['channel_r_abook'] : 0);
|
$arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0);
|
||||||
$arr['channel_w_stream'] = (($_POST['channel_w_stream']) ? $_POST['channel_w_stream'] : 0);
|
$arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0);
|
||||||
$arr['channel_w_wall'] = (($_POST['channel_w_wall']) ? $_POST['channel_w_wall'] : 0);
|
$arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0);
|
||||||
$arr['channel_w_tagwall'] = (($_POST['channel_w_tagwall']) ? $_POST['channel_w_tagwall'] : 0);
|
$arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0);
|
||||||
$arr['channel_w_comment'] = (($_POST['channel_w_comment']) ? $_POST['channel_w_comment'] : 0);
|
$arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0);
|
||||||
$arr['channel_w_mail'] = (($_POST['channel_w_mail']) ? $_POST['channel_w_mail'] : 0);
|
$arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0);
|
||||||
$arr['channel_w_photos'] = (($_POST['channel_w_photos']) ? $_POST['channel_w_photos'] : 0);
|
$arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0);
|
||||||
$arr['channel_w_chat'] = (($_POST['channel_w_chat']) ? $_POST['channel_w_chat'] : 0);
|
$arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2012-11-07.131
|
2012-11-08.132
|
||||||
|
@ -16,7 +16,7 @@ $slide
|
|||||||
|
|
||||||
<h3>Permissions</h3>
|
<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 type="hidden" name="contact_id" value="$contact_id">
|
||||||
<input id="contact-closeness-mirror" type="hidden" name="closeness" value="$close" />
|
<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>
|
<span class="abook-them">$them</span><span class="abook-me">$me</span>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
{{inc field_acheckbox.tpl with $field=$perm01 }}{{endinc}}
|
{{ for $perms as $prm }}
|
||||||
{{inc field_acheckbox.tpl with $field=$perm02 }}{{endinc}}
|
{{inc field_acheckbox.tpl with $field=$prm }}{{endinc}}
|
||||||
{{inc field_acheckbox.tpl with $field=$perm03 }}{{endinc}}
|
{{ endfor }}
|
||||||
{{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}}
|
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<div class='field acheckbox'>
|
<div class='field acheckbox'>
|
||||||
<label for='id_$field.0'>$field.1</label>
|
<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-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 }} />
|
<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.3</span>
|
<span class='field_abook_help'>$field.6</span>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user