[Astrospaces-commits] SF.net SVN: astrospaces: [15] trunk
Brought to you by:
p3net
|
From: <p3...@us...> - 2007-03-18 23:13:31
|
Revision: 15
http://astrospaces.svn.sourceforge.net/astrospaces/?rev=15&view=rev
Author: p3net
Date: 2007-03-18 10:42:04 -0700 (Sun, 18 Mar 2007)
Log Message:
-----------
-Finish friend request function
--Request list
--Accept friend
--Count on your space
-Edit space.tpl to include a few things
--If friend
---Add comment
--If owner
---Edit Space
---View pending requests
-Edit TODO to update all the changes
Modified Paths:
--------------
trunk/TODO.txt
trunk/includes/profile.php
trunk/profile.php
trunk/space.php
trunk/styles/default/space.tpl
Added Paths:
-----------
trunk/styles/default/comment.tpl
trunk/styles/default/friend_list.tpl
Modified: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt 2007-03-18 00:29:04 UTC (rev 14)
+++ trunk/TODO.txt 2007-03-18 17:42:04 UTC (rev 15)
@@ -1,6 +1,4 @@
TODO:
---Edit space.tpl after we have all of our functions done (add comment, send PM, add friend, etc)
---Accept friend request function
---Comment function
+--Edit space.tpl after we have all of our functions done (send PM, etc)
--PM function
\ No newline at end of file
Modified: trunk/includes/profile.php
===================================================================
--- trunk/includes/profile.php 2007-03-18 00:29:04 UTC (rev 14)
+++ trunk/includes/profile.php 2007-03-18 17:42:04 UTC (rev 15)
@@ -284,5 +284,62 @@
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");
}
+ function request_list()
+ {
+ if(!(logged_in()))
+ {
+ redirect('?mode=login');
+ }
+ $_query="SELECT * FROM " . DB_FRIENDS . " WHERE `to`='" . SESSION_ID . "' AND `approved` = '0'";
+ $_query=$db->query($_query);
+
+ $i=0;
+ while($friend=$db->array($_query))
+ {
+ $from[$i]=$friend["from"];
+ $from_username[$i]=get_username_by_id($from[$i]);
+ $i++;
+ }
+ $page =& new template('friend_list.tpl');
+ $page->set('from', $from);
+ $page->set('username', $from_username);
+
+ $outer =& new template('outer.tpl');
+ $outer->set('content', $page);
+ }
+ function approve($id)
+ {
+ //First, make sure we are logged in
+ if(!logged_in())
+ {
+ redirect("?mode=login");
+ }
+
+ $_query="UPDATE " . DB_FRIENDS . " SET `approved` = '1' WHERE `to`='" . SESSION_ID .
+ " AND `from`='" . $id . " AND `approved` = '0' LIMIT 1";
+ $db->query($_query);
+ thankyou("for accepting this friend request.", "return to your space", "space.php",
+ "go to your new friends' space", "space.php?id=" . $id);
+ }
+ function comment($to)
+ {
+ //First, make sure they are our friend
+ if(!is_friend($to))
+ {
+ redirect("?mode=friend_request&id=" . $to);
+ }
+ $page =& new template('comment.tpl');
+ $page->set('to', $to);
+ $outer = & new template('outer.tpl');
+ $outer->set('content', $page);
+ }
+ function comment_proccess($vars)
+ {
+ $_query="INSERT INTO " . DB_COMMENT . " VALUES('', '" . time() . "', '" . SESSION_ID .
+ "', '" . $vars["to"] . "', '" . $vars["comment"] . "');";
+ $db->query($_query);
+ thankyou("for commenting", "return to your space", "space.php",
+ "return to your friends space", "space.php?id=" . $vars["to"]);
+ }
}
?>
\ No newline at end of file
Modified: trunk/profile.php
===================================================================
--- trunk/profile.php 2007-03-18 00:29:04 UTC (rev 14)
+++ trunk/profile.php 2007-03-18 17:42:04 UTC (rev 15)
@@ -68,5 +68,17 @@
case 'friend_request':
$profile->request($_GET["id"]);
break;
+ case 'request_list':
+ $profile->request_list();
+ break;
+ case 'approve':
+ $profile->approve($_GET["id"]);
+ break;
+ case 'comment':
+ $profile->comment($_GET["to"]);
+ break;
+ case 'comm_proc':
+ $profile->comment_proccess($_POST);
+ break;
}
?>
\ No newline at end of file
Modified: trunk/space.php
===================================================================
--- trunk/space.php 2007-03-18 00:29:04 UTC (rev 14)
+++ trunk/space.php 2007-03-18 17:42:04 UTC (rev 15)
@@ -124,22 +124,6 @@
$j++;
}
//Now we need to look up some permission stuff (ie, if a user is our friend)
-if(login_check) //Why can't I remember the name of this function?
-{
- //See if this is your space
- if($id=SESSION_ID)
- {
- $space->set('owner', 1);
- }
- //Are you a friend?
- foreach($friends_id as $friend)
- {
- if($friend == SESSION_ID)
- {
- $space->set('friend', 1);
- }
- }
-}
//Now it's time to assign some of our vars from up above
$space->set('from_username', $comments_from_username); //Comment author
$space->set('from_id', $comments_from); //Comment author ID
@@ -158,6 +142,9 @@
//Friend?
$friend= (is_friend($id)) ? '1' : '0';
+//Number of friend requests
+$_query="SELECT `from` FROM " . DB_FRIENDS . " WHERE `approved`='0'";
+$space->set('friend_req', count($db->array($db->query($_query)));
$space->set('me', $me);
$space->set('friend', $friend);
$space->set('level', SESSION_LEVEL);
Added: trunk/styles/default/comment.tpl
===================================================================
--- trunk/styles/default/comment.tpl (rev 0)
+++ trunk/styles/default/comment.tpl 2007-03-18 17:42:04 UTC (rev 15)
@@ -0,0 +1,4 @@
+<form action="?mode=comm_proc" method="post">
+<input type="hidden" name="to" value="<?php echo $to; ?>">
+Comment: <textarea name="comment" rows="6" cols="60"></textarea>
+<br><input type="submit" value="Comment"></form>
\ No newline at end of file
Added: trunk/styles/default/friend_list.tpl
===================================================================
--- trunk/styles/default/friend_list.tpl (rev 0)
+++ trunk/styles/default/friend_list.tpl 2007-03-18 17:42:04 UTC (rev 15)
@@ -0,0 +1,16 @@
+<table>
+ <tr>
+ <td>Username</td>
+ <td>Action</td>
+ </tr>
+ <?php
+ $i=0;
+ for($i, $i<count($username), $i++)
+ {
+ ?>
+ <tr>
+ <td><?php echo $username[$i]; ?></td>
+ <td><a href="?mode=approve&id=<?php echo $from; ?>">Approve</a></td>
+ </tr>
+ <?php } ?>
+</table>
\ No newline at end of file
Modified: trunk/styles/default/space.tpl
===================================================================
--- trunk/styles/default/space.tpl 2007-03-18 00:29:04 UTC (rev 14)
+++ trunk/styles/default/space.tpl 2007-03-18 17:42:04 UTC (rev 15)
@@ -1,10 +1,29 @@
<div id="left">
<?php echo $username; ?><br>
"<?php echo $headline; ?>"<br>
- <img src="uploads/<?php echo $id; ?>/<?php echo $icon; ?>"><br>
- <?php if($level>0 && friend==0) { ?>
- <a href="profile.php?mode=friend_request&id=<?php echo $id; ?>">Add as Friend</a>
- <?php } ?>
+ <img src="uploads/<?php echo $id; ?>/<?php echo $icon; ?>"><br>
+
+ <!-- BEGIN profile_functions -->
+ <!-- IF is_not_friend AND is_logged_in -->
+ <?php if($level>0 && friend==0) { ?>
+ <a href="profile.php?mode=friend_request&id=<?php echo $id; ?>">Add as Friend</a>
+ <?php } ?>
+ <!-- END IF -->
+
+ <!-- IF is_friend -->
+ <?php if($friend == 1) { ?>
+ <a href="profile.php?action=comment&to=<?php echo $id; ?>">Add Comment</a><br>
+ <?php } ?>
+ <!-- END IF -->
+
+ <!-- IF IS OWNER -->
+ <?php if($me == 1) { ?>
+ <a href="profile.php?mode=edit">Edit Profile/Space</a><br>
+ <a href="profile.php?mode=request_list">View Pending Friend Requests (<?php echo $friend_req; ?>)<br>
+ <?php } ?>
+ <!-- END IF -->
+ <!-- END profile_functions -->
+
<?php echo $space_left; ?>
</div>
<div id="right">
@@ -18,7 +37,10 @@
$nbsp;<?php echo $friend[$i]; ?>" /><br>
<?php } ?>
<!-- END friends -->
- <!-- BEGIN comments -->
+ <!-- BEGIN comments -->
+ <?php if($friend == 1) { ?>
+ <a href="profile.php?action=comment&to=<?php echo $id; ?>">Add Comment</a><br>
+ <?php } ?>
<table>
<?php
$i=0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|