home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / notes / notes.inc < prev    next >
Text File  |  2004-03-08  |  8KB  |  221 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. if (isset($_REQUEST['delete_note_id']) && $_REQUEST['delete_note_id'] > 0)
  14. {
  15.     $note = $notes->get_note($_REQUEST['delete_note_id']);
  16.     if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $note['acl_write']))
  17.     {
  18.         if($notes->delete_note($_REQUEST['delete_note_id']))
  19.         {
  20.             $GO_SECURITY->delete_acl($note['acl_read']);
  21.             $GO_SECURITY->delete_acl($note['acl_write']);
  22.         }
  23.     }else
  24.     {
  25.         $feedback = '<p class="Error">'.$strAccessDenied.'</p>';
  26.     }
  27. }
  28.  
  29. $notes_module_url = isset($notes_module_url) ? $notes_module_url : $GO_MODULES->url;
  30.  
  31. //define the items to show
  32. $max_rows = isset($_REQUEST['max_rows']) ? $_REQUEST['max_rows'] : $_SESSION['GO_SESSION']['max_rows_list'];
  33. $first = isset($_REQUEST['first']) ? $_REQUEST['first'] : 0;
  34.  
  35. $_COOKIE['no_show'] = isset($_COOKIE['no_show']) ? $_COOKIE['no_show'] : SHOW_ALL;
  36. $show = isset($_REQUEST['show']) ? $_REQUEST['show'] : $_COOKIE['no_show'];
  37.  
  38. //define load parameters
  39. $project_id = isset($project_id) ? $project_id : 0;
  40. $contact_id = isset($contact_id) ? $contact_id : 0;
  41. $file_path = isset($file_path) ? $file_path : '';
  42.  
  43. //determine sorting
  44. $no_sort_field = isset($_COOKIE['no_sort_field']) ? $_COOKIE['no_sort_field'] : 'name';
  45. $no_sort_direction = isset($_COOKIE['no_sort_direction']) ? $_COOKIE['no_sort_direction'] : 'ASC';
  46.  
  47. if ($no_sort_direction == "DESC")
  48. {
  49.     $sort_arrow = ' <img src="'.$GO_THEME->images['arrow_down'].'" border="0" />';
  50.     $new_sort_direction = "ASC";
  51. }else
  52. {
  53.     $sort_arrow = ' <img src="'.$GO_THEME->images['arrow_up'].'" border="0" />';
  54.     $new_sort_direction = "DESC";
  55. }
  56.  
  57. echo '<a href="'.$notes_module_url.'note.php?contact_id='.$contact_id.'&project_id='.$project_id.'&file_path='.urlencode($file_path).'&return_to='.urlencode($link_back).'" class="normal">'.$cmdAdd.'</a><br /><br />';
  58.  
  59. $count = $notes->get_notes($GO_SECURITY->user_id, $project_id, $contact_id, $file_path, $show, $no_sort_field, $no_sort_direction, $first, $max_rows);
  60.  
  61. echo '<input type="hidden" name="first" value="'.$first.'" />';
  62. echo '<input type="hidden" name="max_rows" value="'.$max_rows.'" />';
  63. echo '<input type="hidden" name="delete_note_id" />';
  64. echo '<input type="hidden" name="new_sort_field" value="'.$no_sort_field.'" />';
  65. echo '<input type="hidden" name="new_sort_direction" value="'.$no_sort_direction.'" />';
  66. echo '<input type="hidden" name="show" value="'.$show.'" />';
  67.  
  68. echo '<table border="0" cellspacing="0" cellpadding="1">';
  69. $str_count = $count == 1 ? $no_notes_count_single : $no_notes_count;
  70. echo '<tr><td>';
  71. $dropbox = new dropbox();
  72. $dropbox->add_value(SHOW_ALL, $no_show_all);
  73. $dropbox->add_value(SHOW_OWN, $no_show_own);
  74. $dropbox->add_value(SHOW_RESPONSIBLE, $no_show_responsible);
  75. $dropbox->print_dropbox('show', $show, 'onchange="javascript:document.forms[0].submit();"');
  76.  
  77. echo '</td><td colspan="99" class="small" align="right">'.$count.' '.$str_count.'</td></tr>';
  78. echo '<tr height="20">';
  79. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="javascript:_sort(\'name\',\''.$new_sort_direction.'\');">'.$strName.'</a>';
  80. if ($no_sort_field == 'name')
  81. {
  82.     echo $sort_arrow;
  83. }
  84. echo '</td>';
  85.  
  86. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="javascript:_sort(\'catagory_name\',\''.$new_sort_direction.'\');">'.$no_catagory.'</a>';
  87. if ($no_sort_field == 'catagory_name')
  88. {
  89.     echo $sort_arrow;
  90. }
  91. echo '</td>';
  92. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="javascript:_sort(\'due_date\',\''.$new_sort_direction.'\');">'.$no_due_date.'</a>';
  93. if ($no_sort_field == 'due_date')
  94. {
  95.     echo $sort_arrow;
  96. }
  97. echo '</td>';
  98. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="javascript:_sort(\'mtime\',\''.$new_sort_direction.'\');">'.$strModifiedAt.'</a>';
  99. if ($no_sort_field == 'mtime')
  100. {
  101.     echo $sort_arrow;
  102. }
  103. echo '</td>';
  104. echo '<td class="TableHead2"> </td></tr>';
  105.  
  106. if ($count > 0)
  107. {
  108.     $notes_module_url = isset($notes_module_url) ? $notes_module_url : $GO_MODULES->url;
  109.     while($notes->next_record())
  110.     {
  111.         $catagory_name = ($notes->f('catagory_name') == '') ? $no_none : $notes->f('catagory_name');
  112.         echo '<tr><td><a class="normal" href="'.$notes_module_url.'note.php?note_id='.$notes->f('id').'&return_to='.rawurlencode($link_back).'">'.$notes->f('name').'</a></td>';
  113.         echo '<td>'.$catagory_name.'</td>';
  114.         $due_date = $notes->f('due_date') > 0 ? date($_SESSION['GO_SESSION']['date_format'], $notes->f('due_date')) : '';
  115.         echo '<td>'.$due_date.'</td>';
  116.         echo '<td>'.date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], $notes->f('mtime')+($_SESSION['GO_SESSION']['timezone']*3600)).'</td>';
  117.         echo "<td><a href='javascript:confirm_action(\"javascript:delete_note(".$notes->f('id').")\",\"".rawurlencode($strDeletePrefix."'".$notes->f('name')."'".$strDeleteSuffix)."\")' title=\"".$strDeleteItem." '".$notes->f('name')."'\"><img src=\"".$GO_THEME->images['delete']."\" border=\"0\"></a></td>\n";
  118.         echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  119.     }
  120.  
  121.     $links = '';
  122.     $max_links=10;
  123.     if ($max_rows != 0)
  124.     {
  125.         if ($count > $max_rows)
  126.         {
  127.             $links = '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>';
  128.             $next_start = $first+$max_rows;
  129.             $previous_start = $first-$max_rows;
  130.             if ($first != 0)
  131.             {
  132.                 $links .= '<a href="javascript:change_list(0, '.$max_rows.');"><<</a> ';
  133.                 $links .= '<a href="javascript:change_list('.$previous_start.', '.$max_rows.');">'.$cmdPrevious.'</a> ';
  134.             }else
  135.             {
  136.                 $links .= '<font color="#cccccc"><< '.$cmdPrevious.'</font> ';
  137.             }
  138.  
  139.             $start = ($first-(($max_links/2)*$max_rows));
  140.  
  141.             $end = ($first+(($max_links/2)*$max_rows));
  142.  
  143.             if ($start < 0)
  144.             {
  145.                 $end = $end - $start;
  146.                 $start=0;
  147.             }
  148.             if ($end > $count)
  149.             {
  150.                 $end = $count;
  151.             }
  152.             if ($start > 0)
  153.             {
  154.                 $links .= '... ';
  155.             }
  156.  
  157.             for ($i=$start;$i<$end;$i+=$max_rows)
  158.             {
  159.                 $page = ($i/$max_rows)+1;
  160.                 if ($i==$first)
  161.                 {
  162.                     $links .= '<b><i>'.$page.'</i></b> ';
  163.                 }else
  164.                 {
  165.                     $links .= '<a href="'.$_SERVER['PHP_SELF'].'?post_action=projects&first='.$i.'">'.$page.'</a> ';
  166.                 }
  167.             }
  168.  
  169.             if ($end < $count)
  170.             {
  171.                 $links .= '... ';
  172.             }
  173.  
  174.             $last_page = floor($count/$max_rows)*$max_rows;
  175.  
  176.             if ($count > $next_start)
  177.             {
  178.                 $links .= '<a href="javascript:change_list('.$next_start.', '.$max_rows.');">'.$cmdNext.'</a> ';
  179.                 $links .= '<a href="javascript:change_list('.$last_page.', '.$max_rows.');">>></a>';
  180.             }else
  181.             {
  182.                 $links .= '<font color="#cccccc">'.$cmdNext.' >></font>';
  183.             }
  184.             $links .= '</td><td align="right"><a class="normal" href="javascript:change_list(0, 0);">'.$cmdShowAll.'</a></td></tr></table>';
  185.  
  186.             echo '<tr height="20"><td colspan="99">'.$links.'</td></tr>';
  187.             echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  188.         }
  189.     }
  190.  
  191. }else
  192. {
  193.     echo '<tr><td colspan="99">'.$no_no_notes.'</td></tr>';
  194.     echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  195. }
  196. echo '</table>';
  197. ?>
  198.  
  199. <script type="text/javascript">
  200.  
  201. function _sort(field, direction)
  202. {
  203.     document.forms[0].new_sort_field.value=field;
  204.     document.forms[0].new_sort_direction.value=direction;
  205.     document.forms[0].submit();
  206. }
  207.  
  208. function delete_note(id)
  209. {
  210.     document.forms[0].delete_note_id.value=id;
  211.     document.forms[0].submit();
  212. }
  213.  
  214. function change_list(first, max_rows)
  215. {
  216.     document.forms[0].first.value=first;
  217.     document.forms[0].max_rows.value=max_rows;
  218.     document.forms[0].submit();
  219. }
  220. </script>
  221.