Location: PHPKode > projects > Toutateam Groupware > toutateam-v1.56/notes/notes_view.php
<?php

// notes_view.php - PHProjekt Version 4.0
// copyright  ©  2000-2003 Albrecht Guenther  hide@address.com
// www.phprojekt.com
// Author: Albrecht Guenther

// check whether the lib has been included - authentication!
if (!defined("lib_included")) { die("Please use index.php!"); }

// check role
if (check_role("notes") < 1) { die("You are not allowed to do this!"); }

$include_path = $path_pre."lib/permission.inc.php";
include_once $include_path;


  // **************
  // navigation bar

  // filter & items per page
  TT_Template::BlockBegin("notes","notesnav","","mod_header");
  
  echo "<table border=0 cellpadding=\"4\" cellspacing=\"0\">\n";
  echo "<form action='notes.php' method=post>\n";
  if(SID) echo "<input type='hidden' name='PHPSESSID' value='$PHPSESSID'>\n";
  echo "<input type='hidden' name='up' value='$up'>\n";
  echo "<input type='hidden' name='sort' value='$sort'>\n";

  // title and link to help file
  echo "<tr><td ><a href='$doc/notes.html' target=m><b>$o_notes</b></a></td>\n";

  // filter
  echo "<td >$rts_21:</td><td ><input type='text' size='15' name='keyword' value='$keyword'></td><td>$rts_22</td>\n";
  echo "<td><select name='filter'>";
  foreach ($fields as $field1 => $field2) {  
    echo "<option value='$field1'";
    if ($field1 == $filter) { echo " selected"; }
    echo ">$field2</option>\n";
  }
  echo "</select></td>\n";
  // end filter

  // perpage select box
  echo "<td>&nbsp;<select name='perpage'>\n";
  foreach ($perpage_values as $j) {
    echo "<option value='$j'";
    if ($j == $perpage) { echo " selected"; }
    echo ">$j</option>\n";
  }
  echo "</select> $items</td>\n";
  // end perpage slect box, next submit button
  echo "<td><input type=image src='".$img_los."' border='0' id='tr'></td></tr></form></table>\n";

  TT_Template::BlockEnd();  
  TT_Template::BlockBegin("notes","notessearch","","mod_header");


  // link for new notes
  if(check_role("notes") > 1) {
    echo "<table border=0 cellpadding=\"4\" cellspacing=\"0\" >\n";
	echo "<tr>\n";
	echo "<td>\n";
	echo "<div align=\"left\">\n";
	echo "<a class=\"stylebutton\" href='notes.php?mode=view&action=add&new_note=1&sort=$sort&up=$up&page=$page&perpage=$perpage&keyword=$keyword&filter=$filter$sid' class=\"stylebutton\">$con_text4</a> </div></td>\n";
  }
  else echo "<tr><td>&nbsp;</td>\n";

  // keyword
  if ($keyword) {
    if ($filter == "all") { $where =  "(notes.name like '%$keyword%' or notes.remark like '%$keyword%') and"; }
    else { $where = "$filter like '%$keyword%' and"; }
  }
  
  // define access: 
  // 1. groupless system
  if (!$groups) { $where .= " (notes.von = $user_ID or notes.ext = '1')"; }
  
  // 2.a) if user is root in group system (doesn't belong to any group and $user_ID = 1), he has access to his own notes
  elseif ($groups and $user_ID == 1) { $where .= " notes.von = $user_ID"; }

  // 2.b) all other users in the group system: own notes and additionally to the open notes of his/her group  
  else { $where .= " (notes.von = $user_ID or notes.ext = $user_group)"; }

  // define 'next' & 'previous' button
  $result = db_query("select count(ID) from notes where $where") or db_die();
  $row = db_fetch_row($result);
  if ($row[0] > $perpage) { echo "<td colspan=6>&nbsp;\n"; }
  $page_n = $page + 1;
  $page_p = $page - 1;
  if ($page) {
    echo "<a href='notes.php?mode=view&perpage=$perpage&page=$page_p&up=$up&sort=$sort&filter=$filter&keyword=$keyword$sid' class=\"stylebutton\">$previous</a>&nbsp;&nbsp;\n";
  }
  if ($row[0] > $page_n*$perpage) {
    echo "<a href='notes.php?mode=view&perpage=$perpage&page=$page_n&up=$up&sort=$sort&filter=$filter&keyword=$keyword$sid' class=\"stylebutton\">$next</a>\n";
  }
  // end of navigation bar
  echo "</td></tr></table>";
  TT_Template::BlockEnd();

if ((!$new_note and !$ID and !$contact_ID and !$projekt_ID) or $notes_view_both )
	include_once $path_pre."notes/notes_list.php";
if(!$ID && $notes_view_both)
{
	$new_note=1;
	$action="add";	
}
// form - appears whether the button new has been selected, a link from other modules asks to create a new record, an ID has been given or it should appear anyway :-)
if ($new_note or $ID or ($notes_view_both && $ID) or ($notes_view_both && $new_note))
{
	switch($action)
	{
		case "add":
		case "edit":
			include_once $path_pre."notes/notes_forms.php";
			break;
		default:
			include_once $path_pre."notes/notes_details.php";
			break;
	}
}
?>
Return current item: Toutateam Groupware