[Astrospaces-commits] SF.net SVN: astrospaces: [13] trunk
Brought to you by:
p3net
From: <p3...@us...> - 2007-03-18 11:14:10
|
Revision: 13 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=13&view=rev Author: p3net Date: 2007-03-17 15:48:13 -0700 (Sat, 17 Mar 2007) Log Message: ----------- -Add as friend function --Added -Update TODO --List of users who have requested to be your friend Modified Paths: -------------- trunk/TODO.txt trunk/common.php trunk/includes/profile.php trunk/profile.php trunk/space.php trunk/styles/default/space.tpl Modified: trunk/TODO.txt =================================================================== --- trunk/TODO.txt 2007-03-17 19:55:05 UTC (rev 12) +++ trunk/TODO.txt 2007-03-17 22:48:13 UTC (rev 13) @@ -1,6 +1,6 @@ TODO: --Edit space.tpl after we have all of our functions done (add comment, send PM, add friend, etc) ---Add as friend function +--Accept friend request function --Comment function --PM function \ No newline at end of file Modified: trunk/common.php =================================================================== --- trunk/common.php 2007-03-17 19:55:05 UTC (rev 12) +++ trunk/common.php 2007-03-17 22:48:13 UTC (rev 13) @@ -181,4 +181,27 @@ $_query=$db->array($_query); return $_query["icon"]; } +function is_friend($id) +{ + if(!logged_in()) + { + return 0; + } + else + { + $_query="SELECT `id` FROM " . DB_FRIENDS . " WHERE `from`='" . SESSION_ID . + "' AND `to`='" . $id . "' OR `to`='" . SESSION_ID . "' AND `from`='" . + $id . "'"; + + $_query=$db->array($db->query($_query)); + if(count($_query)>0) + { + return 1; + } + else + { + return 0; + } + } +} ?> \ No newline at end of file Modified: trunk/includes/profile.php =================================================================== --- trunk/includes/profile.php 2007-03-17 19:55:05 UTC (rev 12) +++ trunk/includes/profile.php 2007-03-17 22:48:13 UTC (rev 13) @@ -252,5 +252,37 @@ $db->query($_query); thankyou("updating your profile", "to your space", "space.php"); } + function friend_request($id) + { + //If we aren't logged in, let's do it now + if(!logged_in()) + { + redirect("?action=login"); + } + + //Are they our friend? + $_query="SELECT `accepted` FROM " . DB_FRIENDS . " WHERE `from`='" . SESSION_ID + . " AND `to`='" . $id . "'"; + if(count($db->array($db->query($_query)))>0) + { + thankyou("for attempting to add this user as a friend. However, they already are.", + "to return to your space", "space.php"); + } + $_query="SELECT `accepted` FROM " . DB_FRIENDS . " WHERE `to`='" . SESSION_ID + . " AND `from`='" . $id . "'"; + if(count($db->array($db->query($_query)))>0) + { + thankyou("for attempting to add this user as a friend. However, they already are.", + "to return to your space", "space.php"); + } + + //OK, they're not, so let's add them now + //However, they'll still be unaccepted... + $_query="INSERT INTO " . DB_FRIENDS . " VALUES('" . SESSION_ID . "', '" . $id . + "', '0');"; + $db->query($_query); + thankyou("for adding this user as your friend. They will be added to your friends list when your + request is accepted.", "return to your space", "space.php"); + } } ?> \ No newline at end of file Modified: trunk/profile.php =================================================================== --- trunk/profile.php 2007-03-17 19:55:05 UTC (rev 12) +++ trunk/profile.php 2007-03-17 22:48:13 UTC (rev 13) @@ -65,5 +65,8 @@ case 'update': $profile->update($_POST, $_FILES); break; + case 'friend_request': + $profile->request($_GET["id"]); + break; } ?> \ No newline at end of file Modified: trunk/space.php =================================================================== --- trunk/space.php 2007-03-17 19:55:05 UTC (rev 12) +++ trunk/space.php 2007-03-17 22:48:13 UTC (rev 13) @@ -150,6 +150,17 @@ $space->set('friend_id', $friends_id); //Friend's ID $space->set('friend_icon', $friends_icon); //Friend's Icon +//Few more things + +//Owner of the space? +$me= (SESSION_ID == $id) ? '1' : '0'; + +//Friend? +$friend= (is_friend($id)) ? '1' : '0'; + +$space->set('me', $me); +$space->set('friend', $friend); +$space->set('level', SESSION_LEVEL); //Now it's time to finish the template $outer =& new template('outer.tpl'); $outer->set('content', $space); Modified: trunk/styles/default/space.tpl =================================================================== --- trunk/styles/default/space.tpl 2007-03-17 19:55:05 UTC (rev 12) +++ trunk/styles/default/space.tpl 2007-03-17 22:48:13 UTC (rev 13) @@ -2,7 +2,9 @@ <?php echo $username; ?><br> "<?php echo $headline; ?>"<br> <img src="uploads/<?php echo $id; ?>/<?php echo $icon; ?>"><br> - <!-- Links to do stuff go here --> + <?php if($level>0 && friend==0) { ?> + <a href="profile.php?mode=friend_request&id=<?php echo $id; ?>">Add as Friend</a> + <?php } ?> <?php echo $space_left; ?> </div> <div id="right"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |