Closed (fixed)
Project:
Facebook status
Version:
6.x-1.3
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
14 Aug 2009 at 21:12 UTC
Updated:
1 Sep 2009 at 14:54 UTC
function user_relationship_facebook_status_user($op, &$edit, &$account, $category = NULL) {
global $user;
$types = user_relationships_types_load();
if ($op =='form') {
//not sure what the return is?
if (count($types)) {
$form['user_relationships_facebook_status'] = array(
'#type' => 'fieldset',
'#title' => t('Grant access to your Profile Status Updates')
);
foreach ($types as $rtid => $type) {
$options = array('0' => t('Can\'t view my profile status'),'1' => t('view my profile status'));
$form['user_relationships_facebook_status'][$rtid] = array(
'#type' => 'select',
'#title' => $type->name,
'#options' => $options,
'#default_value' => variable_get($rtid.$type->name, array('0' => t('Can\'t view my profile status'))),
'#description' => t('Select whether you wish to allow or disallow @relationships from viewing your Profile Status Updates.'),
array('@relationships' => $type->plural_name),
);
}
return $form;
}
}
if ($op == 'update') {
if (count($types) > 0) {
global $user;
foreach ($types as $rtid => $type) {
unset($types[$rtid]);
$permission = $form_state['user_relationships_facebook_status']['values'][$rtid.$type->name];
db_query('UPDATE {user_relationship_facebook_status} SET {permissions} = %d WHERE uid = %d AND rtid = %d LIMIT 1', $permission, $user->uid, $rtid);
}
}
}
if ($op == 'insert') {
if (count($types) > 0) {
global $user;
foreach ($types as $rtid => $type) {
unset($types[$rtid]);
$permission = $form_state['user_relationships_facebook_status']['values'][$rtid.$type->name];
db_query('INSERT INTO {user_relationship_facebook_status} SET {permissions} = %d WHERE uid = %d AND rtid = %d', 0, $user->uid, $rtid);
}
}
}
//Insert here
//Delete as well
if ($op == 'delete') {
if (count($types) > 0) {
global $user;
foreach ($types as $rtid => $type) {
unset($types[$rtid]);
//$permission = $form_state['user_relationships_facebook_status']['values'][$rtid.'-'.$type];
db_query('DELETE FROM {user_relationship_facebook_status} WHERE uid = %d AND rtid = %d', $user->uid, $rtid);
}
}
}
}
/**
* Implementation of hook_profile_alter().
*/
function user_relationship_facebook_status_checkaccess($uid) {
global $user;
if($user->uid = $uid) {
return TRUE;
}
$types = user_relationships_types_load();
if (count($types) > 0) {
global $user;
foreach ($types as $rtid => $type) {
unset($types[$rtid]);
//get the list rtids from user's profile where the value is set to true OR 1 as Allowed to view
$rtid = db_fetch_array(db_query('SELECT rtid FROM {user_relationship_facebook_status} WHERE uid = %d AND permissions = %d', $uid, 1));
//get rids for the given $uid from the $rtid array
// $get_rids = db_fetch_array(db_query('SELECT rid {user_relationships} WHERE requester_id = %d OR requestee_id = %d AND rtid = %d', $uid, $uid, $rtid));
//
}
//get the relationships between the two
$relationships_between_two = user_relationships_load($param = array("between" => array($uid, $user->uid)), $count = FALSE, $sort = 'rid', $order = NULL, $limit = NULL, $include_user_info = FALSE);
// get the relationships between two users
if(in_array($rtid, $relationships_between_two)) {
$give_permission = TRUE;
}
else {
$give_permission = false;
}
return $give_permission;
}
}
actually i just need help refining, i don't know how to use CVS though
Comments
Comment #1
rush86999 commentedsorry there was error in the previous one that i already spotted but there already some error in this one that i get about line 644 in menu.inc file even though i don't even call the menu hook;
i would like to contribute this as a sub module that lets users choose there privacy of facebook status wall or any other item just by selecting in the 'edit' path who can see it...
Comment #2
rush86999 commentedi forked it form node_access for UR so ignore the Id$ tag...
Comment #3
yelvington commentedI don't see that this has anything to do with the Facebook Status module.
Perhaps you mean "facebook-styles statuses?"
Comment #4
rush86999 commentedsorry i guess i selected the wrong drop down menu item
Comment #5
yelvington commented