aboutsummaryrefslogtreecommitdiff
path: root/mod/messages/views/default/messages/forms/send.php
blob: 9a83ce103f9c1851259b295e9f9da7db9261b958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* Elgg send a message view
* 
* @package ElggMessages
 * @uses $vars['friends'] This is an array of a user's friends and is used to populate the list of
 * people the user can message
 *
 */
 
//grab the user id to send a message to. This will only happen if a user clicks on the 'send a message'
//link on a user's profile or hover-over menu
$send_to = get_input('send_to');
if ($send_to === "")
	$send_to = $_SESSION['msg_to'];

$msg_title = $_SESSION['msg_title'];
$msg_content = $_SESSION['msg_contents'];

// clear sticky form cache in case user browses away from page and comes back 
unset($_SESSION['msg_to']);
unset($_SESSION['msg_title']);
unset($_SESSION['msg_contents']);
?>
<form id="messages_send_form" action="<?php echo elgg_get_site_url(); ?>action/messages/send" method="post" name="messageForm">
<?php
	echo elgg_view('input/securitytoken'); 
        //check to see if the message recipient has already been selected
		if($send_to){
			
			//get the user object  
	        $user = get_user($send_to);
	        
	        echo "<div class='entity-listing messages clearfix'><div class='entity-listing-icon'>".elgg_view("profile/icon",array('entity' => $user, 'size' => 'tiny'))."</div>";
	        
	        //draw it
			echo "<div class='entity-listing-info'>".elgg_echo("messages:to").": <a href='".elgg_get_site_url()."pg/profile/".$user->username."'>".$user->name."</a>";
			//set the hidden input field to the recipients guid
	        echo "<input type='hidden' name='send_to' value=\"{$send_to}\" />";	
			echo "</div></div>";
		    
        } else {
    ?>
        
        <p class="margin-top"><label><?php echo elgg_echo("messages:to"); ?>: </label>
	    <select name='send_to'>
	    <?php 
			// make the first option blank
	    	echo "<option value=''>".elgg_echo("messages:recipient")."</option>";
	        foreach($vars['friends'] as $friend){
    	        //populate the send to box with a user's friends
			    echo "<option value='{$friend->guid}'>" . $friend->name . "</option>";
		    }
        ?>
		</select></p>
    <?php
        }
    ?>
    
	<p class="margin-top"><label><?php echo elgg_echo("messages:title"); ?>: <br /><input type='text' name='title' value='<?php echo $msg_title; ?>' class="input-text" /></label></p>
	<p class="longtext_inputarea"><label><?php echo elgg_echo("messages:message"); ?>:</label>
	<?php
		echo elgg_view("input/longtext", array(
						"internalname" => "message",
						"value" => $msg_content,
		));
	?>
	</p>
	<p><input type="submit" class="submit-button" value="<?php echo elgg_echo("messages:fly"); ?>" /></p>
</form>