Location: PHPKode > projects > ProjectPress > projectpress/profile/notes/index.php
<?php 
/**
 * ProjectPress notes
 *
 * @package ProjectPress
 * @since 2.0
 */

// Starts the session.
session_start();

define('access',true);

include(dirname(dirname(dirname(__FILE__))) . '/config.inc.php');
include(PM_DIR . 'pm-includes/global.inc.php');
require(PM_DIR . 'pm-includes/functions.php');
include(PM_DIR . 'pm-includes/header.php');

// User is logged in.
if($current_user->hasPermission('access_site') != true) { pm_redirect(PM_URI . '/index.php'); }

// Enable for error checking and troubleshooting.
//display_errors();

$sql = pmdb::connect()->query("SELECT * FROM ". DB ."notes WHERE n_user = '".$_GET['username']."'")

?>

<script type="text/javascript" >
$(function() {
$(".n-submit").click(function() 
{
var first_name = $("#first_name").val();
var last_name = $("#last_name").val();
var email = $("#email").val();
var note = $("#note").val();
var n_user = $("#n_user").val();
var dataString = 'first_name='+ first_name + '&last_name='+ last_name + '&email=' + email + '&note=' + note + '&n_user=' + n_user;
if(note=='')
{
alert('You need to add a note');
}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="../../images/ajax-loader.gif" />Loading note...');
$.ajax({
type: "POST",
url: "add_note.php",
data: dataString,
cache: false,
success: function(html){
$("ul#update").append(html);
$("ul#update li:last").fadeIn("slow");
$("#flash").hide();
}
});
}return false;
});

		//deleteUserType
		$('a.n_delete').livequery("click", function(e){
			
			if(confirm('Are you sure you want to delete this note?')==false)

			return false;
	
			e.preventDefault();
			var parent  = $(this).parent();
			var n_id =  $(this).attr('id').replace('NID-','');
			var n_user = $(this).attr('nu').replace('n_user-','');
			
			$.ajax({

				type: 'get',

				url: 'delete_note.php?n_id='+ n_id + '&n_user='+ n_user,

				data: '',

				beforeSend: function(){

				},

				success: function(){

					parent.fadeOut(200,function(){

						parent.remove();

					});

				}

			});
		});
});
</script>

				<div id="page-title">
					<img src="<?php echo PM_URI; ?>/images/note.png" alt="" /><h1>Notes</h1>
				</div>
				<div id="tabs">
					<ul>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "profile.php?username=".$_GET['username']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $_GET['username']; ?>"><span>Wall</span></a>
						</li>
						<?php if($_GET['username'] == $_SESSION['username']) { ?>
						<li <?php if (basename($_SERVER["REQUEST_URI"]) == "index.php?username=".$_GET['username']) echo "class='active_link'";?>>
							<a href="<?php echo PM_URI ?>/profile/notes/index.php?username=<?php echo $_GET['username']; ?>"><span>Notes</span></a>
						</li>
						<?php } ?>
					</ul>
				</div>
				
				<div id="middle">
				<p>Use the form below to add important notes.</p>

				<ul id="update" class="timeline">
						<?php while($r = $sql->fetch_object()) { ?>
					<li class="noteBox">
						<div class="avatar">
						<?php echo get_user_avatar($r->author,$r->email,50); ?>
						</div>

						<div class="note-list">
						<a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $r->author; ?>"><?php echo get_name($r->author); ?></a>&nbsp;
						<?php echo $r->note; ?> <br /><br />
						</div>
						
						<label class="name">
						<span style="float:left;padding-right:5px;">
						<?php echo date("Y-m-d H:i:s",$r->date_created); ?>
						</span>
						</label>
						<a href="#" nu="n_user-<?php echo $r->n_user; ?>" id="NID-<?php echo $r->n_id;?>" class="n_delete">Delete</a>
					</li>
						<?php } ?>
				</ul>
				
				<div id="flash"></div>
				
				<div id="note-form">
					<form action="#" method="post">
						<input type="hidden" id="first_name" value="<?php echo $_SESSION['first_name']; ?>" /><br />
						<input type="hidden" id="last_name" value="<?php echo $_SESSION['last_name']; ?>" /><br />
						<input type="hidden" id="n_user" name="n_user" value="<?php echo $_GET['username']; ?>"/><br />
						<textarea id="note" name="note" class="forminput"></textarea>
						<input type="submit" class="n-submit" id="sub_button" value="Submit Comment " />
					</form>
				</div>
				</div> <!--Ends notes-->


<?php

include(PM_DIR . 'pm-includes/footer.php');
Return current item: ProjectPress