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

rush86999’s picture

<?php
// $Id: user_relationship_node_access.module,v 1.1.4.11 2009/07/06 13:11:07 alexk Exp $
// Copyright (C) 2008 Jonathan Brown
// http://openpackage.biz/




//implementation of hook_user

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);
		}
	}
}
	
}



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 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; 
	}
}

sorry 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...

rush86999’s picture

i forked it form node_access for UR so ignore the Id$ tag...

yelvington’s picture

I don't see that this has anything to do with the Facebook Status module.

Perhaps you mean "facebook-styles statuses?"

rush86999’s picture

sorry i guess i selected the wrong drop down menu item

yelvington’s picture

Status: Active » Closed (fixed)