Main Page | Directories | File List | File Members

include/trackers_run/admin/notification_settings.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: notification_settings.php 5429 2006-02-17 22:59:20Z toddy $
00006 #
00007 #  Copyright 2001-2002 (c) Laurent Julliard, CodeX Team, Xerox
00008 #
00009 #  Copyright 2003-2004 (c) Mathieu Roy <yeupou--gnu.org>
00010 #
00011 # The Savane project is free software; you can redistribute it and/or
00012 # modify it under the terms of the GNU General Public License
00013 # as published by the Free Software Foundation; either version 2
00014 # of the License, or (at your option) any later version.
00015 #
00016 # The Savane project is distributed in the hope that it will be useful,
00017 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 # GNU General Public License for more details.
00020 #
00021 # You should have received a copy of the GNU General Public License
00022 # along with the Savane project; if not, write to the Free Software
00023 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00024 
00025 require_directory("project");
00026 
00027 $is_admin_page='y';
00028 
00029 /*  ==================================================
00030     Check access permission
00031  ================================================== */
00032 if (!$group_id)
00033 {
00034   exit_no_group(); # need a group_id !!
00035 }
00036 
00037 if (!user_isloggedin())
00038 {
00039   # Must be at least logged in to set up your personal notification
00040   # preference
00041   exit_permission_denied();
00042 }
00043 $is_user_a_member = user_ismember($group_id);
00044 
00045 /*  ==================================================
00046     Set up some data structure needed throughout the script
00047  ================================================== */
00048 
00049 $user_id = user_getid();
00050 # get notification roles
00051 $res_roles = trackers_data_get_notification_roles();
00052 $num_roles = db_numrows($res_roles);
00053 $i=0;
00054 while ($arr = db_fetch_array($res_roles))
00055 {
00056   $arr_roles[$i] = $arr; $i++;
00057 }
00058 
00059 # get notification events
00060 $res_events = trackers_data_get_notification_events();
00061 $num_events = db_numrows($res_events);
00062 $i=0;
00063 while ($arr = db_fetch_array($res_events))
00064 {
00065   $arr_events[$i] = $arr; $i++;
00066 }
00067 
00068 # build the default notif settings in case the user has not yet defined her own
00069 # By default it's all 'yes'
00070 for ($i=0; $i<$num_roles; $i++)
00071 {
00072   $role_id = $arr_roles[$i]['role_id'];
00073   for ($j=0; $j<$num_events; $j++)
00074     {
00075       $event_id = $arr_events[$j]['event_id'];
00076       $arr_notif[$role_id][$event_id] = 1;
00077     }
00078 }
00079 
00080 # Overwrite with user settings if any
00081 $res_notif = trackers_data_get_notification($user_id);
00082 while ($arr = db_fetch_array($res_notif))
00083 {
00084   $arr_notif[$arr['role_id']][$arr['event_id']] = $arr['notify'];
00085 }
00086 
00087 /*  ==================================================
00088     The form has been submitted - update the database
00089  ================================================== */
00090 
00091 if ($submit)
00092 {
00093 
00094   $res_new = trackers_data_post_notification_settings($group_id, ARTIFACT);
00095 
00096   if ($res_new == 1)
00097     {
00098       fb(_("Changed notification email settings"));
00099       group_add_history ('Changed Notification Email Settings','',$group_id);
00100     }
00101   else
00102     {
00103       fb(_("Update failed"));
00104     }
00105 
00106 } # end submit
00107 
00108 
00109 /*  ==================================================
00110     Show Main Page
00111  ================================================== */
00112 
00113 trackers_header_admin(array ('title'=>_("Email Notification Settings")));
00114 
00115 print '
00116 <form action="'.$PHP_SELF.'" method="post">
00117 <input type="hidden" name="group_id" value="'.$group_id.'" />';
00118 
00119 
00120  if (user_ismember($group_id,'A'))
00121  {
00122    trackers_data_show_notification_settings($group_id, ARTIFACT, 1);
00123  }
00124 
00125 
00126 print '
00127 <p align="center"><input type="submit" name="submit" class="bold" value="'._("Submit Changes").'" />
00128 </form>';
00129 
00130 trackers_footer(array());
00131 
00132 ?>

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