Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_modules / nascar [ view in CVS ]


Deprecated: Function gmstrftime() is deprecated in /home/mikespub/www/list.php on line 509
Date Directory [filter] File(s) [view] Author [filter]
11 Aug 2002 02:05:05postnuke_modules/nascarpnadmin.php,1.2,1.3 pnadminapi.php,1.1,1.2 pnuserapi.php,1.2,1.3George Neill
 + changed the tracks view output

Update of /home/cvsroot/postnuke_modules/nascar
In directory ns7.hostnuke.net:/tmp/cvs-serv4415

Modified Files:
	pnadmin.php pnadminapi.php pnuserapi.php 
Log Message:

+ changed the tracks view output
+ added code to allow modification of tracks
+ added images for track view.

Still need to clean up and comment everything I have done thus far.

GNeill 2002.08.10 



Index: pnadmin.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/nascar/pnadmin.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pnadmin.php	10 Aug 2002 06:34:54 -0000	1.2
--- pnadmin.php	11 Aug 2002 02:05:02 -0000	1.3
***************
*** 77,86 ****
      $data['tracks_id']          = pnML(pnVarPrepForDisplay(_TRACKSID));
      $data['tracks_name']        = pnML(pnVarPrepForDisplay(_TRACKSNAME));
-     $data['tracks_longname']    = pnML(pnVarPrepForDisplay(_TRACKSLONGNAME));
-     $data['tracks_location']    = pnML(pnVarPrepForDisplay(_TRACKSLOCATION));
-     $data['tracks_weather_url'] = pnML(pnVarPrepForDisplay(_TRACKSWEATHERURL));
-     $data['tracks_image']       = pnML(pnVarPrepForDisplay(_TRACKSIMAGE));
-     $data['tracks_length']      = pnML(pnVarPrepForDisplay(_TRACKSLENGTH));
-     $data['tracks_url']         = pnML(pnVarPrepForDisplay(_TRACKSURL));
      $data['tracks_active']      = pnML(pnVarPrepForDisplay(_TRACKSACTIVE));
   
--- 77,80 ----
***************
*** 99,113 ****
          }
  
!         $data['status'] = pnML('No items available');
! 
!         $reason = pnExceptionValueString();
! 
!         if (!empty($reason)) {
!             $data['status'] .= '<br /><br />'. pnML('Reason') .' : '. $reason;
!         }
! 
!         pnExceptionFree();
  
!         return $data;
      }
  
--- 93,102 ----
          }
  
!         // do I need to do any clean up here ? 
!         //
!         // there are no entries in the DB just go ahead and redirect
!         // to the 'add' page. GN
  
!         pnRedirect(pnModURL('nascar', 'admin', 'new_tracks'));
      }
  
***************
*** 221,225 ****
  
      if ($tid == true) {
!       pnSessionSetVar('statusmsg', _NASCARTRACKSCREATED);
      }
  
--- 210,215 ----
  
      if ($tid == true) {
!       pnSessionSetVar('statusmsg', 
!           pnML(pnVarPrepForDisplay(_NASCARTRACKSCREATED)));
      }
  
***************
*** 230,239 ****
  }
  
- /**
-  * modify an item
-  * This is a standard function that is called whenever an administrator
-  * wishes to modify a current module item
-  * @param 'tid' the id of the item to be modified
-  */
  function nascar_admin_modify_tracks($args)
  {
--- 220,223 ----
***************
*** 242,246 ****
                                           'objectid');
  
- 
      extract($args);
  
--- 226,229 ----
***************
*** 253,257 ****
      }
  
!     $item = pnModAPIFunc('nascar', 'user', 'get', array('tid' => $tid));
  
      if ($item == false) {
--- 236,240 ----
      }
  
!     $item = pnModAPIFunc('nascar', 'user', 'get_tracks', array('tid' => $tid));
  
      if ($item == false) {
***************
*** 259,290 ****
      }
  
!     if (!pnSecAuthAction(0, 'nascar::Item', "$item[name]::$tid", ACCESS_EDIT)) {
          return pnML('Not authorized to modify ', 'nascar', pnVarPrepForDisplay($tid));
      }
  
!     return array('authid'       => pnSecGenAuthKey(),
!                  'namelabel'    => pnVarPrepForDisplay(_NASCARNAME),
!                  'numberlabel'  => pnVarPrepForDisplay(_NASCARNUMBER),
!                  'updatebutton' => pnVarPrepForDisplay(_NASCARUPDATE),
!                  'item'         => $item);
  }
  
! /**
!  * This is a standard function that is called with the results of the
!  * form supplied by nascar_admin_modify() to update a current item
!  * @param 'tid' the id of the item to be updated
!  * @param 'name' the name of the item to be updated
!  * @param 'number' the number of the item to be updated
!  */
! function nascar_admin_update($args)
  {
      list($tid,
           $objectid,
!          $name,
!          $number) = pnVarCleanFromInput('tid',
!                                         'objectid',
!                                         'name',
!                                         'number');
! 
      extract($args);
  
--- 242,289 ----
      }
  
!     if (!pnSecAuthAction(0, 'nascar::Item', "$item[tname]::$tid", ACCESS_EDIT)) {
          return pnML('Not authorized to modify ', 'nascar', pnVarPrepForDisplay($tid));
      }
  
!     return array (
!         'authid'            => pnSecGenAuthKey(),
!         'nascar_home'       => pnML(pnVarPrepForDisplay(_NASCARHOME)),
!         'nascar_title'      => pnML(pnVarPrepForDisplay(_NASCARTITLE)),
!         'label_viewtracks'  => pnML(pnVarPrepForDisplay(_NASCARTRACKS)),
!         'label_id'          => pnML(pnVarPrepForDisplay(_TRACKSID)),
!         'label_name'        => pnML(pnVarPrepForDisplay(_TRACKSNAME)),
!         'label_longname'    => pnML(pnVarPrepForDisplay(_TRACKSLONGNAME)),
!         'label_location'    => pnML(pnVarPrepForDisplay(_TRACKSLOCATION)),
!         'label_weather_url' => pnML(pnVarPrepForDisplay(_TRACKSWEATHERURL)),
!         'label_image'       => pnML(pnVarPrepForDisplay(_TRACKSIMAGE)),
!         'label_length'      => pnML(pnVarPrepForDisplay(_TRACKSLENGTH)),
!         'label_url'         => pnML(pnVarPrepForDisplay(_TRACKSURL)),
!         'label_active'      => pnML(pnVarPrepForDisplay(_TRACKSACTIVE)),
!         'updatebutton'      => pnML('Update'),
!         'item'              => $item
!     );
  }
  
! function nascar_admin_update_tracks($args)
  {
      list($tid,
           $objectid,
!          $tname,
!          $tlongname,
!          $tlocation,
!          $tweather_url,
!          $timage,
!          $tlength,
!          $turl,
!          $tactive ) = pnVarCleanFromInput('tid',
!                                           'objectid',
!                                           'tname',
!                                           'tlongname',
!                                           'tlocation',
!                                           'tweather_url',
!                                           'timage',
!                                           'tlength',
!                                           'turl',
!                                           'tactive'); 
      extract($args);
  
***************
*** 300,303 ****
--- 299,303 ----
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
+ 
          return;
      }
***************
*** 315,327 ****
      if(pnModAPIFunc('nascar',
                      'admin',
!                     'update',
!                     array('tid'    => $tid,
!                           'name'   => $name,
!                           'number' => $number))) {
  
!         pnSessionSetVar('statusmsg', _NASCARUPDATED);
!     }
  
!     pnRedirect(pnModURL('nascar', 'admin', 'view'));
  
      return true;
--- 315,334 ----
      if(pnModAPIFunc('nascar',
                      'admin',
!                     'update_tracks',
!                     array('tid'          => $tid,
!                           'tname'        => $tname,
!                           'tlongname'    => $tlongname,
!                           'tlocation'    => $tlocation,
!                           'tweather_url' => $tweather_url,
!                           'timage'       => $timage,
!                           'tlength'      => $tlength,
!                           'turl'         => $turl,
!                           'tactive'      => $tactive))) {
  
!         pnSessionSetVar('statusmsg', 
!             pnML(pnVarPrepForDisplay(_NASCARTRACKSUPDATED)));
!     } 
  
!     pnRedirect(pnModURL('nascar', 'admin', 'view_tracks'));
  
      return true;
***************
*** 408,412 ****
                       array('tid' => $tid))) {
  
!         pnSessionSetVar('statusmsg', _NASCARTRACKSDELETED);
  
      }
--- 415,420 ----
                       array('tid' => $tid))) {
  
!         pnSessionSetVar('statusmsg', 
!             pnML(pnVarPrepForDisplay(_NASCARTRACKSDELETED)));
  
      }

Index: pnadminapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/nascar/pnadminapi.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pnadminapi.php	10 Aug 2002 06:02:33 -0000	1.1
--- pnadminapi.php	11 Aug 2002 02:05:02 -0000	1.2
***************
*** 28,40 ****
      extract($args);
  
!     $invalid = array();
  
!     if (count($invalid) > 0) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     join(', ',$invalid), 'admin', 'create_tracks', 'Nascar');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
!         return false;
!     }
  
      if (!pnSecAuthAction(0, 'nascar::Item', "$tname::", ACCESS_ADD)) {
--- 28,40 ----
      extract($args);
  
!     //$invalid = array();
  
!     //if (count($invalid) > 0) {
!         //$msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     //join(', ',$invalid), 'admin', 'create_tracks', 'Nascar');
!         //pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        //new SystemException($msg));
!         //return false;
!     //}
  
      if (!pnSecAuthAction(0, 'nascar::Item', "$tname::", ACCESS_ADD)) {
***************
*** 153,201 ****
  }
  
! /**
!  * update a nascar item
!  *
!  * @author the Nascar module development team
!  * @param $args['tid'] the ID of the item
!  * @param $args['name'] the new name of the item
!  * @param $args['number'] the new number of the item
!  * @raise BAD_PARAM, NO_PERMISSION, DATABASE_ERROR
!  */
! function nascar_adminapi_update($args)
  {
-     // Get arguments from argument array - all arguments to this function
-     // should be obtained from the $args array, getting them from other
-     // places such as the environment is not allowed, as that makes
-     // assumptions that will not hold in future versions of PostNuke
      extract($args);
  
-     // Argument check - make sure that all required arguments are present
-     // and in the right format, if not then set an appropriate error
-     // message and return
-     // Note : since we have several arguments we want to check here, we'll
-     // report all those that are invalid at the same time...
      $invalid = array();
!     if (!isset($tid) || !is_numeric($tid)) {
!         $invalid[] = 'item ID';
!     }
!     if (!isset($name) || !is_string($name)) {
!         $invalid[] = 'name';
!     }
!     if (!isset($number) || !is_numeric($number)) {
!         $invalid[] = 'number';
      }
      if (count($invalid) > 0) {
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     join(', ',$invalid), 'admin', 'update', 'Nascar');
          pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
          return false;
      }
  
-     // Load API.  Note that this is loading the user API in addition to
-     // the administration API, that is because the user API contains
-     // the function to obtain item information which is the first thing
-     // that we need to do.  If the API fails to load an appropriate error
-     // message is posted and the function returns
      if (!pnModAPILoad('nascar', 'user')) {
          $msg = pnML('Unable to load #(1) #(2) API',
--- 153,178 ----
  }
  
! function nascar_adminapi_update_tracks($args)
  {
      extract($args);
  
      $invalid = array();
! 
!     if(!isset($tid))
!     {
!       $invalid[] = "track id";
      }
+ 
      if (count($invalid) > 0) {
+ 
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     join(', ',$invalid), 'admin', 'update_tracks', 'Nascar');
! 
          pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
+ 
          return false;
      }
  
      if (!pnModAPILoad('nascar', 'user')) {
          $msg = pnML('Unable to load #(1) #(2) API',
***************
*** 206,221 ****
      }
  
!     // The user API function is called.  This takes the item ID which
!     // we obtained from the input and gets us the information on the
!     // appropriate item.  If the item does not exist we post an appropriate
!     // message and return
!     $item = pnModAPIFunc('nascar',
!             'user',
!             'get',
!             array('tid' => $tid));
  
      if ($item == false) {
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'item ID', 'user', 'get', 'Nascar');
          pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
--- 183,191 ----
      }
  
!     $item = pnModAPIFunc('nascar', 'user', 'get_tracks', array('tid' => $tid));
  
      if ($item == false) {
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'item ID', 'user', 'get_tracks', 'Nascar');
          pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
***************
*** 223,238 ****
      }
  
!     // Security check - important to do this as early on as possible to
!     // avoid potential security holes or just too much wasted processing.
!     // However, in this case we had to wait until we could obtain the item
!     // name to complete the instance information so this is the first
!     // chance we get to do the check
! 
!     // Note that at this stage we have two sets of item information, the
!     // pre-modification and the post-modification.  We need to check against
!     // both of these to ensure that whoever is doing the modification has
!     // suitable permissions to edit the item otherwise people can potentially
!     // edit areas to which they do not have suitable access
!     if (!pnSecAuthAction(0, 'nascar::Item', "$item[name]::$tid", ACCESS_EDIT)) {
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Nascar', pnVarPrepForStore($tid));
--- 193,197 ----
      }
  
!     if (!pnSecAuthAction(0, 'nascar::Item', "$item[tname]::$tid", ACCESS_EDIT)) {
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Nascar', pnVarPrepForStore($tid));
***************
*** 241,245 ****
          return false;
      }
!     if (!pnSecAuthAction(0, 'nascar::Item', "$name::$tid", ACCESS_EDIT)) {
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Nascar', pnVarPrepForStore($tid));
--- 200,205 ----
          return false;
      }
! 
!     if (!pnSecAuthAction(0, 'nascar::Item', "$tname::$tid", ACCESS_EDIT)) {
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Nascar', pnVarPrepForStore($tid));
***************
*** 249,287 ****
      }
  
-     // Get database setup - note that both pnDBGetConn() and pnDBGetTables()
-     // return arrays but we handle them differently.  For pnDBGetConn()
-     // we currently just want the first item, which is the official
-     // database handle.  For pnDBGetTables() we want to keep the entire
-     // tables array together for easy reference later on
      list($dbconn) = pnDBGetConn();
!     $pntable = pnDBGetTables();
! 
!     // It's good practice to name the table and column definitions you
!     // are getting - $table and $column don't cut it in more complex
!     // modules
!     $nascartable = $pntable['nascar'];
  
-     // Update the item - the formatting here is not mandatory, but it does
-     // make the SQL statement relatively easy to read.  Also, separating
-     // out the sql statement from the Execute() command allows for simpler
-     // debug operation if it is ever needed
      $sql = "UPDATE $nascartable
!             SET pn_name = '" . pnVarPrepForStore($name) . "',
!                 pn_number = " . pnVarPrepForStore($number) . "
!             WHERE pn_tid = " . pnVarPrepForStore($tid);
      $dbconn->Execute($sql);
  
-     // Check for an error with the database code, and if so set an
-     // appropriate error message and return
      if ($dbconn->ErrorNo() != 0) {
-         // Hint : for debugging SQL queries, you can use $dbconn->ErrorMsg()
-         // to retrieve the actual database error message, and use e.g. the
-         // following message :
-         // $msg = pnML('Database error #(1) in query #(2) for #(3) function ' .
-         //             '#(4)() in module #(5)',
-         //             $dbconn->ErrorMsg(), $sql, 'admin', 'update', 'Nascar');
-         // Don't use that for release versions, though...
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'update', 'Nascar');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
--- 209,232 ----
      }
  
      list($dbconn) = pnDBGetConn();
!     $pntable      = pnDBGetTables();
!     $nascartable  = $pntable['nascar_tracks'];
  
      $sql = "UPDATE $nascartable
!             SET  pn_track_name   = '" . pnVarPrepForStore($tname) . "', 
!                  pn_longname     = '" . pnVarPrepForStore($tlongname) . "',
!                  pn_location     = '" . pnVarPrepForStore($tlocation) . "',
!                  pn_weather_url  = '" . pnVarPrepForStore($tweather_url) ."',
!                  pn_track_image  = '" . pnVarPrepForStore($timage) . "',
!                  pn_track_length = '" . pnVarPrepForStore($tlength) . "',
!                  pn_track_url    = '" . pnVarPrepForStore($turl) . "',
!                  pn_active       =  " . pnVarPrepForStore($tactive) . "
!             WHERE pn_track_id = " . pnVarPrepForStore($tid);
! 
      $dbconn->Execute($sql);
  
      if ($dbconn->ErrorNo() != 0) {
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'update_tracks', 'Nascar');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
***************
*** 289,293 ****
      }
  
-     // Let the calling process know that we have finished successfully
      return true;
  }
--- 234,237 ----

Index: pnuserapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/nascar/pnuserapi.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pnuserapi.php	10 Aug 2002 06:02:33 -0000	1.2
--- pnuserapi.php	11 Aug 2002 02:05:02 -0000	1.3
***************
*** 95,104 ****
          list($tid, 
               $tname, 
!              $tlongname,
!              $tlocation,
!              $tweather_url,
!              $timage,
!              $tlength,
!              $turl,
               $tactive) = $result->fields;
  
--- 95,104 ----
          list($tid, 
               $tname, 
!              $tlongname, 
!              $tlocation, 
!              $tweather_url, 
!              $timage, 
!              $tlength, 
!              $turl, 
               $tactive) = $result->fields;
  
***************
*** 106,115 ****
             $items[] = array('tid'          => $tid, 
                              'tname'        => $tname,  
!                             'tlongname'    => $tlongname,
!                             'tlocation'    => $tlocation,
!                             'tweather_url' => $tweather_url,
!                             'timage'       => $timage,
!                             'tlength'      => $tlength,
!                             'turl'         => $turl,
                              'tactive'      => $tactive);
          }
--- 106,115 ----
             $items[] = array('tid'          => $tid, 
                              'tname'        => $tname,  
!                             'tlongname'    => $tlongname,  
!                             'tlocation'    => $tlocation,  
!                             'tweather_url' => $tweather_url,  
!                             'timage'       => $timage,  
!                             'tlength'      => $tlength,  
!                             'turl'         => $turl,  
                              'tactive'      => $tactive);
          }
***************
*** 137,141 ****
      $nascartable  = $pntable['nascar_tracks'];
  
!     $sql = "SELECT pn_track_id, pn_track_name
              FROM $nascartable
              WHERE pn_track_id = " . pnVarPrepForStore($tid);
--- 137,149 ----
      $nascartable  = $pntable['nascar_tracks'];
  
!     $sql = "SELECT pn_track_id, 
!                    pn_track_name,
!                    pn_longname,
!                    pn_location,
!                    pn_weather_url,
!                    pn_track_image,
!                    pn_track_length,
!                    pn_track_url,
!                    pn_active
              FROM $nascartable
              WHERE pn_track_id = " . pnVarPrepForStore($tid);
***************
*** 156,160 ****
      }
  
!     list($tid, $tname) = $result->fields;
  
      $result->Close();
--- 164,176 ----
      }
  
!     list($tid, 
!          $tname,
!          $tlongname,
!          $tlocation,
!          $tweather_url,
!          $timage,
!          $tlength,
!          $turl,
!          $tactive) = $result->fields;
  
      $result->Close();
***************
*** 168,174 ****
      }
  
!     $item = array('tid' => $tid, 'tname' => $tname);
! 
!     return $item;
  }
  
--- 184,196 ----
      }
  
!     return(array('tid'          => $tid, 
!                  'tname'        => $tname,
!                  'tlongname'    => $tlongname,
!                  'tlocation'    => $tlocation,
!                  'tweather_url' => $tweather_url,
!                  'timage'       => $timage,
!                  'tlength'      => $tlength,
!                  'turl'         => $turl,
!                  'tactive'      => $tactive));
  }
  


Directory filter : [ all ] / postnuke_modules / nascar [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3