Location: PHPKode > projects > ProjectPress > projectpress/projects/list_projects.php
<?php 
/**
 * ProjectPress prints a list of projects
 *
 * @package ProjectPress
 * @since 2.0
 */

// Starts the session.
session_start();

define('access',true);

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

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

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

?>

<script type="text/javascript" src="<?php _e(get_javascript_directory_uri()); ?>/projects.js"></script>

				<div id="page-title">
					<img src="<?php echo PM_URI; ?>/images/groups.png" alt="" /><h1>Projects <span id="header-link"><a href="<?php echo PM_URI ?>/projects/add_project.php">Add a Project</a></span></h1>
				</div>

				<div id="middle">
				<div id="groups">
						<table cellpadding="0" cellspacing="0" border="0" align="center">
							<th>Project</th>
							<th>Type</th>
							<th>Join/Leave</th>

<?php
$sql = "SELECT * FROM " . DB . "projects, " . DB . "project_types WHERE ptype_id = pt_id ORDER BY p_id ASC";
$result = pmdb::connect()->query($sql);

//Create a PS_Pagination object
$pager = new PS_Pagination(pmdb::connect(),$sql,10,10);

//The paginate() function returns a mysql result set
$sql = $pager->paginate();

if($result->num_rows > 0) {
while($row = $result->fetch_object()) {

$username = $_SESSION['username'];

$user = pmdb::connect()->query("SELECT pm_user FROM " . DB . "project_members WHERE pp_id = '".$row->p_id."' AND pm_user = '".$username."'");
$user_joins = $user->num_rows;
        
?>
        		
        <tr>
        	<td width="80%"><a href="<?php echo PM_URI ?>/projects/project.php?p_id=<?php echo $row->p_id; ?>"><?php echo $row->project_name; ?></a></td> <td width="20%"><?php echo $row->project_type; ?></td>
        
        	<td width="5%">
        	<span id="join-project-<?php echo $row->p_id ?>">
			<?php
			if($user_joins){?>
				<a href="javascript: void(0)" id="project_id<?php echo $row->p_id ?>" class="leave">Leave Project</a>
			<?php }else{?>
				<a href="javascript: void(0)" id="project_id<?php echo $row->p_id ?>" class="join">Join Project</a>
			<?php }?>
				
			</span>
        	</td>
        
        </tr>

<?php 
	}
} else {
  echo '<p>There are no projects yet.</p>';
}
?>
						</table>
						<!--Display the full navigation in one go-->
						<p>&nbsp;</p>

						<p align="center"><?php _e($pager->renderFullNav()); ?></p>

				</div>
				</div>


<?php

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