Main Page | Directories | File List | File Members

menu.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: menu.php 5379 2006-02-15 14:11:03Z yeupou $
00006 #
00007 #  Copyright 1999-2000 (c) The SourceForge Crew
00008 #  Copyright 2000-2003 (c) Free Software Foundation
00009 #
00010 #  Copyright 2003-2005 (c) Mathieu Roy <yeupou--gnu.org>
00011 #                          Yves Perrin <yves.perrin--cern.ch>
00012 #
00013 # The Savane project is free software; you can redistribute it and/or
00014 # modify it under the terms of the GNU General Public License
00015 # as published by the Free Software Foundation; either version 2
00016 # of the License, or (at your option) any later version.
00017 #
00018 # The Savane project is distributed in the hope that it will be useful,
00019 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 # GNU General Public License for more details.
00022 #
00023 # You should have received a copy of the GNU General Public License
00024 # along with the Savane project; if not, write to the Free Software
00025 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00026 
00027 
00028 function menu_print_sidebar($params)
00029 {
00030   global $HTML;
00031 
00032   print '
00033  <ul class="menu">
00034         <li class="menulogo">
00035 ';
00036 
00037   if ($GLOBALS['sys_logo_name'])
00038     {
00039       print '          '.utils_link($GLOBALS['sys_home'], html_image($GLOBALS['sys_logo_name'],array('alt'=>sprintf(_("Back to %s Homepage"), $GLOBALS['sys_name'])), 0));
00040     }
00041   else
00042     {
00043       print '          <br />'.utils_link($GLOBALS['sys_home'], $GLOBALS['sys_name'], 0, 1, sprintf(_("Back to %s Homepage"), $GLOBALS['sys_name']));
00044     }
00045 
00046   print '
00047         </li><!-- end menulogo -->';
00048   if (!user_isloggedin())
00049     {
00050       print menu_notloggedin();
00051     }
00052   else
00053     {
00054       print menu_loggedin($params['title'], $params['toptab'], $params['group']);
00055     }
00056   print menu_thispage($params['title'], $params['toptab'], $params['group']);
00057   print menu_search();
00058   # Site Admin menu added here
00059   if (user_can_be_super_user())
00060     {
00061       print menu_site_admin();
00062     }
00063   print menu_projects();
00064   print menu_help();
00065   # Valid HTML is now part of the site specific content
00066   utils_get_content("menu");
00067 
00068   print '
00069  </ul><!-- end menu -->
00070 ';
00071 
00072 }
00073 
00074 
00075 # Menu entry  for all admin tasks when logged as site administor
00076 function menu_site_admin()
00077 {
00078   # This menu is shown whether the user is a logged as super user or not
00079   global $HTML;
00080   $is_su = user_is_super_user();
00081   $HTML->menuhtml_top($GLOBALS['sys_name'].' '._("Administration"));
00082   $HTML->menu_entry($GLOBALS['sys_home'].'siteadmin/',_("Main page"), $is_su);
00083   $HTML->menu_entry($GLOBALS['sys_home'].'task/?group='.$GLOBALS['sys_unix_group_name'].'&amp;category_id=1&amp;status_id=1&amp;set=custom#results',_("Pending projects"));
00084   $HTML->menu_entry($GLOBALS['sys_home'].'news/approve.php?group='.$GLOBALS['sys_unix_group_name'],_("Site news approval"), $is_su);
00085 
00086   $HTML->menuhtml_bottom();
00087 
00088 }
00089 
00090 function menu_search()
00091 {
00092   global $HTML,$group_id;
00093   $HTML->menuhtml_top(_("Search"));
00094   print '       <li class="menusearch">';
00095   print search_box("", "menu");
00096   print '       </li><!-- end menusearch -->';
00097   $HTML->menuhtml_bottom();
00098 }
00099 
00100 
00101 #deprecated - theme wrapper
00102 function menuhtml_top($title)
00103 {
00104   /*
00105                 Use only for the top most menu
00106   */
00107   theme_menuhtml_top($title);
00108 }
00109 
00110 # Hosted projects
00111 function menu_projects()
00112 {
00113   global $HTML;
00114   $HTML->menuhtml_top(_("Hosted Projects"));
00115   $HTML->menu_entry($GLOBALS['sys_home'].'register/',
00116                     _("Register New Project"),
00117                     user_isloggedin(),
00118                     sprintf(_("Register your project at %s"),$GLOBALS['sys_name']));
00119  $HTML->menu_entry($GLOBALS['sys_home'].'search/index.php?type_of_search=soft&amp;words=%%%',
00120                    _("Full List"),
00121                    1,
00122                    _("Browse the full list of hosted projects"));
00123  $HTML->menu_entry($GLOBALS['sys_home'].'stats/',
00124                    _("Statistics"),
00125                    1,
00126                    sprintf(_("Browse statistics about %s"),$GLOBALS['sys_name']));
00127   $HTML->menuhtml_bottom();
00128 }
00129 
00133 function menu_thispage($page_title, $page_toptab=0, $page_group=0)
00134 {
00135   global $HTML, $sys_group_id, $group_id;
00136 
00137   $HTML->menuhtml_top(_("This Page"));
00138   if ($_SERVER["REQUEST_METHOD"] == "POST")
00139     {
00140       if ($GLOBALS['group_name'])
00141         { $extraurl .= "&amp;group=".htmlspecialchars($GLOBALS['group_name'])."&amp;"; }
00142       if ($GLOBALS['item_id'])
00143         { $extraurl .= "&amp;func=detailitem&amp;item_id=".htmlspecialchars($GLOBALS['item_id'])."&amp;"; }
00144     }
00145   else
00146     {
00147       if ($GLOBALS['item_id'] && is_numeric($_SERVER["argv"][0]))
00148         {
00149           # Short link case (like support/?212)
00150           $extraurl .= "&amp;func=detailitem&amp;item_id=".htmlspecialchars($GLOBALS['item_id']);
00151         }
00152       else
00153         {
00154           $extraurl = htmlspecialchars($_SERVER["QUERY_STRING"]);
00155           $extraurl = str_replace("reload=1&amp;", "", $extraurl);
00156           $extraurl = str_replace("printer=1&amp;", "", $extraurl);
00157           $extraurl = "&amp;".$extraurl;        }
00158     }
00159 
00160   $HTML->menu_entry($_ENV["SCRIPT_NAME"]."?reload=1".$extraurl,
00161                     _("Clean Reload"),
00162                     1,
00163                     _("Reload the page without risk of reposting data"));
00164   $HTML->menu_entry($_ENV["SCRIPT_NAME"]."?printer=1".$extraurl,
00165                     _("Printer Version"),
00166                     1,
00167                     _("Show this page with a style adapted to printers"));
00168   $HTML->menuhtml_bottom();
00169 
00170   if (!$GLOBALS['HTTP_POST_VARS'])
00171     {
00172       if (user_isloggedin() && user_get_preference("use_bookmarks"))
00173         {
00174           $bookmark_title = urlencode(context_title());
00175           
00176           if ($page_title)
00177             { $bookmark_title .= urlencode(_(": ").$page_title); }
00178             
00179             $HTML->menu_entry($GLOBALS['sys_home'].'my/bookmarks.php?add=1&amp;url='.urlencode($GLOBALS['REQUEST_URI']).'&amp;title='.$bookmark_title,
00180                               _("Bookmark It"),
00181                               1,
00182                               _("Add this page to my bookmarks"));
00183         }
00184     }
00185   
00186   ##
00187   # Show related recipes. Maybe not the best way to put it, but in "this page"
00188   # it makes sense.
00189   # And it is hard to find a place elsewhere where it would not be really nasty
00190   unset($sql_groupid, $sql_role);
00191   if ($group_id)
00192     {
00193       # We are on a group page
00194       $sql_groupid = "OR group_id='$group_id'"; 
00195     }
00196   if (defined('ARTIFACT') && AUDIENCE == 'members')
00197     {
00198       # We are on a tracker and we have a project member:
00199       #  - it may be a manager or a technician, or both
00200       # We must select
00201       #  - items for all members
00202       #  + items for manager if we have a manager
00203       #  + items for technicians if we have a technician
00204       # Which leads to
00205       #  allmembers=1 OR (manager=1 if manager) OR (technician=1 if technician)
00206       if (member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'1'))
00207         {
00208           # It is a technician
00209           $sql_role = "OR audience_technicians='1'";
00210         }
00211       if (member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'3'))
00212         {
00213           # It is a manager
00214           $sql_role .= " OR audience_managers='1'";
00215         }      
00216     }
00217 
00218   # If CONTEXT or SUBCONTEXT was set to non-existent context, the SQL will
00219   # simply fail.
00220   $sql = "SELECT recipe_id FROM cookbook_context2recipe WHERE (group_id='$sys_group_id' $sql_groupid) AND context_".CONTEXT."='1' AND subcontext_".SUBCONTEXT."='1' AND (audience_".AUDIENCE."='1' $sql_role)";
00221 
00222   $result = db_query($sql);
00223   $rows = db_numrows($result);
00224 
00225   # No recipe found? End here
00226   if ($rows < 1)
00227     { return; }
00228 
00229   # Put a limit on the number of shown recipe to 25
00230   $limit = 25;
00231   
00232   # Build a sql to obtain summaries
00233   unset($sql_itemid, $sql_privateitems);
00234   # Check whether the user is authorized to read private items for the active
00235   # project, if there is an active project
00236   if ($group_id)
00237     {
00238       if (!member_check_private(0, $group_id))
00239         {
00240           $sql_privateitem = "AND privacy<>'2'";
00241         }
00242     }
00243 
00244   for ($i = 0; $i < $rows; $i++) 
00245     {
00246       if ($sql_itemid)
00247         { $sql_itemid .= " OR "; }
00248       $sql_itemid .= "bug_id='".db_result($result, $i, 'recipe_id')."'";
00249     }
00250   $sql = "SELECT bug_id,priority,summary FROM cookbook WHERE ($sql_itemid) AND resolution_id='1' $sql_privateitem ORDER BY priority DESC, summary ASC LIMIT $limit";
00251   $result = db_query($sql);
00252   $rows = db_numrows($result);
00253 
00254   # No recipe found? End here
00255   # Such test has been made before, but before we did not knew if the item
00256   # was actually approved
00257   if ($rows < 1)
00258     { return; }
00259 
00260   print "\n";
00261   print '<li class="relatedrecipes">';
00262   print '<div><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/help.png" alt="'._("Related Recipes:").'" class="icon" />'._("Related Recipes:").'</div>';
00263   for ($i = 0; $i < $rows; $i++) 
00264     {
00265       print '<div class="relatedrecipesitem">';
00266       # Show specific background color only for high priority item, no
00267       # need to disturb the eye otherwise
00268       $priority = db_result($result, $i, 'priority');
00269       if ($priority > 4)
00270         {
00271           print '<div class="priore">';
00272         }
00273 
00274       # The full summary will only be in a help balloon, the summary directly
00275       # shown will be cut to 40 characters.
00276       # Summaries should be kept short.
00277       print utils_link($GLOBALS['sys_home'].'cookbook/?func=detailitem&amp;comingfrom='.$group_id.'&amp;item_id='.db_result($result, $i, 'bug_id'),
00278                        utils_cutstring(db_result($result, $i, 'summary'),40),
00279                        "menulink",
00280                        '1',
00281                        db_result($result, $i, 'summary'));
00282       if ($priority > 4)
00283         {
00284           print '</div>';
00285         }
00286       print '</div>';
00287     }
00288   print '</li><!-- end relatedrecipes -->';
00289 
00290 }
00291 
00292 # Help / Docs
00293 function menu_help()
00294 {
00295   global $HTML;
00296   $HTML->menuhtml_top($GLOBALS['sys_name'].' '._("Help"));
00297   $HTML->menu_entry($GLOBALS['sys_home'].'cookbook/?group='.$GLOBALS['sys_unix_group_name'],
00298                     _("User Docs: Cookbook"),
00299                     1,
00300                     _("Recipes dedicated to any users, including Project Admins"));
00301   $HTML->menu_entry($GLOBALS['sys_home'].'userguide/',
00302                     _("User Docs: In Depth Guide"),
00303                     1,
00304                     _("In-depth Documentation dedicated to any users, including Project Admins"));
00305 
00306   $HTML->menu_entry($GLOBALS['sys_home'].'support/?group='.$GLOBALS['sys_unix_group_name'],
00307                     _("Get Support"),
00308                     1,
00309                     sprintf(_("Get help from the Admins of %s, when documentation is not enough"), $GLOBALS['sys_name']));
00310   $HTML->menu_entry($GLOBALS['sys_home'].'people/',
00311                     _("Contributor Wanted"),
00312                     1,
00313                     _("Browse the list of request for contributions"));
00314   $HTML->menuhtml_bottom();
00315   $HTML->menu_entry($GLOBALS['sys_home'].'contact.php',
00316                     _("Contact Us"),
00317                     1,
00318                     sprintf(_("Contact address of %s Admins"),$GLOBALS['sys_name']));
00319   $HTML->menuhtml_bottom();
00320 }
00321 
00322 function menu_loggedin($page_title, $page_toptab=0, $page_group=0)
00323 {
00324   global $HTML;
00325   /*
00326                 Show links appropriate for someone logged in, like account maintenance, etc
00327   */
00328   if (!user_is_super_user())
00329     {
00330       $HTML->menuhtml_top(sprintf(_("Logged in as %s"), user_getname()));
00331     }
00332   else
00333     {
00334       $HTML->menuhtml_top('<span class="warn">'.sprintf(_("%s logged in as superuser"), user_getname()).'</span>');
00335     }
00336   if (user_can_be_super_user() && !user_is_super_user())
00337     {
00338       $HTML->menu_entry($GLOBALS['sys_home'].'account/su.php?action=login&amp;uri='.urlencode($GLOBALS['REQUEST_URI']),
00339                         _("Become Superuser"),
00340                         1,
00341                         _("Superuser rights are required to perform site admin tasks"));
00342     }
00343   $HTML->menu_entry($GLOBALS['sys_home'].'my/',
00344                     _("My Incoming Items"),
00345                     1,
00346                     _("What's new for me: new items I should have a look at"));
00347   $HTML->menu_entry($GLOBALS['sys_home'].'my/items.php',
00348                     _("My Items"),
00349                     1,
00350                     _("Browse my items (submitted by me or assigned to me)"));
00351   if (user_use_votes())
00352     {
00353       $HTML->menu_entry($GLOBALS['sys_home'].'my/votes.php',
00354                         _("My Votes"),
00355                         1,
00356                         _("Browse items I voted for"));
00357     }
00358 
00359   $HTML->menu_entry($GLOBALS['sys_home'].'my/groups.php',
00360                     _("My Groups"),
00361                     1,
00362                     _("List the groups I belong to"));
00363   if (user_get_preference("use_bookmarks"))
00364     {
00365       $HTML->menu_entry($GLOBALS['sys_home'].'my/bookmarks.php',
00366                         _("My Bookmarks"),
00367                         1,
00368                         _("Show my bookmarks"));
00369     }
00370 
00371   $HTML->menu_entry($GLOBALS['sys_home'].'my/admin/',
00372                     _("My Account Conf"),
00373                     1,
00374                     _("Account configuration: authentication, cosmetics preferences..."));
00375 
00376  if (user_is_super_user())
00377     {
00378       $HTML->menu_entry($GLOBALS['sys_home'].'account/su.php?action=logout&amp;uri='.urlencode($GLOBALS['REQUEST_URI']),
00379                         _("Logout Superuser"),
00380                         1,
00381                         _("End the Superuser session, go back to normal user session"));
00382     }
00383   $HTML->menu_entry($GLOBALS['sys_home'].'account/logout.php',
00384                     _("Logout"),
00385                     1,
00386                     _("End the session, remove the session cookie"));
00387   $HTML->menuhtml_bottom();
00388 }
00389 
00390 function menu_notloggedin()
00391 {
00392   global $HTML;
00393   $HTML->menuhtml_top(_("Login Status:"));
00394   print '
00395         <li class="menuitem"> <span class="error">'._("Not Logged In").'</span></li>';
00396   $HTML->menu_entry($GLOBALS['sys_https_url'].$GLOBALS['sys_home'].'account/login.php?uri='.urlencode($GLOBALS['REQUEST_URI']),
00397                     _("Login via SSL"),
00398                     1,
00399                     _("Login page - you must have registered an account first"));
00400   $HTML->menu_entry($GLOBALS['sys_https_url'].$GLOBALS['sys_home'].'account/register.php',
00401                     _("New User via SSL"),
00402                     1,
00403                     _("Account registration form"));
00404   $HTML->menuhtml_bottom();
00405 }
00406 
00407 ?>

Generated on Sun Feb 26 13:23:04 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4