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_official / html / modules / example [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
13 Aug 2002 12:19:22postnuke_official/html/modules/examplepnadmin.php,1.1,1.2 pnadminapi.php,1.1,1.2 pninit.php,1.2,1.3 pnuser.php,1.2,1.3 pnuserapi.php,1.1,1.2Marco Canini
 Nicer exception handling. Need to work more on it, just a start!

Update of /home/cvsroot/postnuke_official/html/modules/example
In directory ns7.hostnuke.net:/tmp/cvs-serv4523

Modified Files:
	pnadmin.php pnadminapi.php pninit.php pnuser.php pnuserapi.php 
Log Message:
Nicer exception handling. Need to work more on it, just a start!


Index: pnadmin.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/example/pnadmin.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pnadmin.php	7 Aug 2002 01:30:22 -0000	1.1
--- pnadmin.php	13 Aug 2002 12:19:20 -0000	1.2
***************
*** 1,3 ****
! <?php // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
--- 1,4 ----
! <?php
! // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
***************
*** 41,46 ****
      // for administration depends on the particular module, but it is generally
      // either 'edit' or 'delete'
!     if (!pnSecAuthAction(0, 'Example::Item', '::', ACCESS_EDIT)) {
!         return _EXAMPLENOAUTH;
      }
  
--- 42,51 ----
      // for administration depends on the particular module, but it is generally
      // either 'edit' or 'delete'
!     if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_EDIT)) {
!         $msg = pnML('Not authorized to access to #(1)',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 92,98 ****
  
      // Specify some labels for display
!     $data['namelabel'] = pnVarPrepForDisplay(_EXAMPLENAME);
!     $data['numberlabel'] = pnVarPrepForDisplay(_EXAMPLENUMBER);
!     $data['optionslabel'] = pnVarPrepForDisplay(_EXAMPLEOPTIONS);
      $data['pager'] = '';
  
--- 97,103 ----
  
      // Specify some labels for display
!     $data['namelabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLENAME'));
!     $data['numberlabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLENUMBER'));
!     $data['optionslabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLEOPTIONS'));
      $data['pager'] = '';
  
***************
*** 100,119 ****
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_EDIT)) {
!         // Fill in some status variable to be shown in the blocklayout template
!         $data['status'] = _EXAMPLENOAUTH;
!         // Return the template variables defined in this function
!         return $data;
      }
  
      // Load API.  Note that this is loading the user 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('example', 'user')) {
!         // Fill in the status variable with the status to be shown
!         $data['status'] = _LOADFAILED;
!         // Return the template variables defined in this function
!         return $data;
!     }
  
      // The user API function is called.  This takes the number of items
--- 105,119 ----
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_EDIT)) {
!         $msg = pnML('Not authorized to access to #(1)',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
      }
  
      // Load API.  Note that this is loading the user 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 the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'user')) return; // throw back
  
      // The user API function is called.  This takes the number of items
***************
*** 127,163 ****
                                  'numitems' => pnModGetVar('example',
                                                            'itemsperpage')));
! 
!     // The return value of the function is checked here, and if the function
!     // failed then an appropriate message is posted here.  Note that if the
!     // API function gave an error, then it should raise an exception that
!     // you can handle here...
!     if ($items == false) {
!         // Throw back any system exceptions (e.g. database failure)
!         if (pnExceptionMajor() == PN_SYSTEM_EXCEPTION) {
!              return; // throw back
!         }
!         // Handle the user exceptions yourself
!         $data['status'] = pnML('No items available');
!         // Possibly handle different exception IDs in specific ways :
!         // if (pnExceptionId() == 'BAD_PARAM') {
!         //     /* do something */
!         // } elseif (pnExceptionId() == 'NO_PERMISSION') {
!         //     /* do something else */
!         // } elseif (pnExceptionId() == 'MyException1') {
!         //     /* do some other thing */
!         // } else {
!         //     /* default handling */
!         // }
!         // Get the information about the exception (in HTML or string format)
!         // $reason = pnExceptionValueHTML();
!         $reason = pnExceptionValueString();
!         if (!empty($reason)) {
!             $data['status'] .= '<br /><br />'. pnML('Reason') .' : '. $reason;
!         }
!         // Free the exception to tell PostNuke that you handled it
!         pnExceptionFree();
!         // Return the template variables defined in this function
!         return $data;
!     }
  
      // Check individual permissions for Edit / Delete
--- 127,132 ----
                                  'numitems' => pnModGetVar('example',
                                                            'itemsperpage')));
!     // Check for exceptions
!     if (!isset($item) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
      // Check individual permissions for Edit / Delete
***************
*** 191,197 ****
  
      // Specify some labels for display
!     $data['namelabel'] = pnVarPrepForDisplay(_EXAMPLENAME);
!     $data['numberlabel'] = pnVarPrepForDisplay(_EXAMPLENUMBER);
!     $data['optionslabel'] = pnVarPrepForDisplay(_EXAMPLEOPTIONS);
  
  // TODO : add a pager (once it exists in BL)
--- 160,166 ----
  
      // Specify some labels for display
!     $data['namelabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLENAME'));
!     $data['numberlabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLENUMBER'));
!     $data['optionslabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLEOPTIONS'));
  
  // TODO : add a pager (once it exists in BL)
***************
*** 225,232 ****
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_EDIT)) {
!         // Fill in some status variable to be shown in the blocklayout template
!         $data['status'] = _EXAMPLENOAUTH;
!         // Return the template variables defined in this function
!         return $data;
      }
  
--- 194,202 ----
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_EDIT)) {
!         $msg = pnML('Not authorized to access to #(1)',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 235,241 ****
  
      // Specify some labels for display
!     $data['namelabel'] = pnVarPrepForDisplay(_EXAMPLENAME);
!     $data['numberlabel'] = pnVarPrepForDisplay(_EXAMPLENUMBER);
!     $data['addbutton'] = pnVarPrepForDisplay(_EXAMPLEADD);
  
      // Return the template variables defined in this function
--- 205,211 ----
  
      // Specify some labels for display
!     $data['namelabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLENAME'));
!     $data['numberlabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLENUMBER'));
!     $data['addbutton'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLEADD'));
  
      // Return the template variables defined in this function
***************
*** 284,296 ****
      // Load API.  All of the actual work for the creation of the new item is
      // done within the API, so we need to load that in before we can do
!     // anything.  If the API fails to load an appropriate error message is
!     // posted and the function returns
!     if (!pnModAPILoad('example', 'admin')) {
!         $msg = pnML('Unable to load #(1) admin API',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
!     }
  
      // The API function is called.  Note that the name of the API function and
--- 254,259 ----
      // Load API.  All of the actual work for the creation of the new item is
      // done within the API, so we need to load that in before we can do
!     // anything. If the API fails to load the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'admin')) return; // throw back
  
      // The API function is called.  Note that the name of the API function and
***************
*** 308,323 ****
      // function did not succeed then the API function should have already
      // posted a failure message so no action is required
!     if ($exid == false) {
!     //    $msg = pnML('Unable to create #(1) item',
!     //                'Example');
!     //    pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!     //                   new SystemException($msg));
!     //    return;
!     } else {
  
      // Success
!     //TODO replace with no exception?
!     pnSessionSetVar('statusmsg', _EXAMPLECREATED);
!     }
  
      // This function generated no output, and so now it is complete we redirect
--- 271,278 ----
      // function did not succeed then the API function should have already
      // posted a failure message so no action is required
!     if (!isset($exid) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
      // Success
!     pnSessionSetVar('statusmsg', pnMLByKey('EXAMPLECREATED'));
  
      // This function generated no output, and so now it is complete we redirect
***************
*** 368,377 ****
      // Load API.  Note that this is loading the user 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('example', 'user')) {
!         return pnML('Unable to load #(1) user API',
!                     'Example');
!     }
  
      // The user API function is called.  This takes the item ID which we
--- 323,328 ----
      // Load API.  Note that this is loading the user 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 the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'user')) return; // throw back
  
      // The user API function is called.  This takes the item ID which we
***************
*** 383,391 ****
                           'get',
                           array('exid' => $exid));
! 
!     if ($item == false) {
!         return pnML('Unable to find #(1) item #(2)',
!                     'Example', pnVarPrepForDisplay($exid));
!     }
  
      // Security check - important to do this as early as possible to avoid
--- 334,339 ----
                           'get',
                           array('exid' => $exid));
!     // Check for exceptions
!     if (!isset($item) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
      // Security check - important to do this as early as possible to avoid
***************
*** 395,400 ****
      // do the check
      if (!pnSecAuthAction(0, 'Example::Item', "$item[name]::$exid", ACCESS_EDIT)) {
!         return pnML('Not authorized to modify #(1) item #(2)',
                      'Example', pnVarPrepForDisplay($exid));
      }
  
--- 343,351 ----
      // do the check
      if (!pnSecAuthAction(0, 'Example::Item', "$item[name]::$exid", ACCESS_EDIT)) {
!         $msg = pnML('Not authorized to modify #(1) item #(2)',
                      'Example', pnVarPrepForDisplay($exid));
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
+                        new SystemException($msg));
+         return;
      }
  
***************
*** 405,411 ****
      // Return the template variables defined in this function
      return array('authid' => pnSecGenAuthKey(),
!                  'namelabel' => pnVarPrepForDisplay(_EXAMPLENAME),
!                  'numberlabel' => pnVarPrepForDisplay(_EXAMPLENUMBER),
!                  'updatebutton' => pnVarPrepForDisplay(_EXAMPLEUPDATE),
                   'item' => $item);
  }
--- 356,362 ----
      // Return the template variables defined in this function
      return array('authid' => pnSecGenAuthKey(),
!                  'namelabel' => pnVarPrepForDisplay(pnMLByKey('EXAMPLENAME')),
!                  'numberlabel' => pnVarPrepForDisplay(pnMLByKey('EXAMPLENUMBER')),
!                  'updatebutton' => pnVarPrepForDisplay(pnMLByKey('EXAMPLEUPDATE')),
                   'item' => $item);
  }
***************
*** 470,482 ****
      // Load API.  All of the actual work for the update of the new item is done
      // within the API, so we need to load that in before we can do anything.
!     // If the API fails to load an appropriate error message is posted and the
!     // function returns
!     if (!pnModAPILoad('example', 'admin')) {
!         $msg = pnML('Unable to load #(1) admin API',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
!     }
  
      // The API function is called.  Note that the name of the API function and
--- 421,426 ----
      // Load API.  All of the actual work for the update of the new item is done
      // within the API, so we need to load that in before we can do anything.
!     // If the API fails to load the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'admin')) return; // throw back
  
      // The API function is called.  Note that the name of the API function and
***************
*** 489,493 ****
      // function did not succeed then the API function should have already
      // posted a failure message so no action is required
!     if(pnModAPIFunc('example',
                      'admin',
                      'update',
--- 433,437 ----
      // function did not succeed then the API function should have already
      // posted a failure message so no action is required
!     if(!pnModAPIFunc('example',
                      'admin',
                      'update',
***************
*** 495,502 ****
                            'name' => $name,
                            'number' => $number))) {
!         // Success
!         //TODO make it an exception?
!         pnSessionSetVar('statusmsg', _EXAMPLEUPDATED);
      }
  
      // This function generated no output, and so now it is complete we redirect
--- 439,445 ----
                            'name' => $name,
                            'number' => $number))) {
!         return; // throw back
      }
+     pnSessionSetVar('statusmsg', pnMLByKey('EXAMPLEUPDATED'));
  
      // This function generated no output, and so now it is complete we redirect
***************
*** 557,569 ****
      // Load API.  Note that this is loading the user 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('example', 'user')) {
!         $msg = pnML('Unable to load #(1) user API',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
!     }
  
      // The user API function is called.  This takes the item ID which we
--- 500,505 ----
      // Load API.  Note that this is loading the user 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 the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'user')) return; // throw back
  
      // The user API function is called.  This takes the item ID which we
***************
*** 575,586 ****
                           'get',
                           array('exid' => $exid));
! 
!     if ($item == false) {
!         $msg = pnML('Unable to find #(1) item #(2)',
!                     'Example', pnVarPrepForDisplay($exid));
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
!     }
  
      // Security check - important to do this as early as possible to avoid
--- 511,516 ----
                           'get',
                           array('exid' => $exid));
!     // Check for exceptions
!     if (!isset($item) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
      // Security check - important to do this as early as possible to avoid
***************
*** 614,618 ****
          $data['confirmtext'] = pnML('Confirm deleting this item ?');
          $data['itemid'] =  pnML('Item ID');
!         $data['namelabel'] =  _EXAMPLENAME;
          $data['namevalue'] = pnVarPrepForDisplay($item['name']);
          $data['confirmbutton'] = pnML('Confirm');
--- 544,548 ----
          $data['confirmtext'] = pnML('Confirm deleting this item ?');
          $data['itemid'] =  pnML('Item ID');
!         $data['namelabel'] =  pnMLByKey('EXAMPLENAME');
          $data['namevalue'] = pnVarPrepForDisplay($item['name']);
          $data['confirmbutton'] = pnML('Confirm');
***************
*** 641,653 ****
      // Load API.  All of the actual work for the deletion of the item is done
      // within the API, so we need to load that in before before we can do
!     // anything.  If the API fails to load an appropriate error message is
!     // posted and the function returns
!     if (!pnModAPILoad('example', 'admin')) {
!         $msg = pnML('Unable to load #(1) admin API',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
!     }
  
      // The API function is called.  Note that the name of the API function and
--- 571,576 ----
      // Load API.  All of the actual work for the deletion of the item is done
      // within the API, so we need to load that in before before we can do
!     // anything.  If the API fails to load the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'admin')) return; // throw back
  
      // The API function is called.  Note that the name of the API function and
***************
*** 660,671 ****
      // function did not succeed then the API function should have already
      // posted a failure message so no action is required
!     if (pnModAPIFunc('example',
                       'admin',
                       'delete',
                       array('exid' => $exid))) {
!         // Success
!         //TODO make this an exception?
!         pnSessionSetVar('statusmsg', _EXAMPLEDELETED);
      }
  
      // This function generated no output, and so now it is complete we redirect
--- 583,594 ----
      // function did not succeed then the API function should have already
      // posted a failure message so no action is required
!     if (!pnModAPIFunc('example',
                       'admin',
                       'delete',
                       array('exid' => $exid))) {
!         return; // throw back
      }
+     pnSessionSetVar('statusmsg', pnMLByKey('EXAMPLEDELETED'));
+ 
  
      // This function generated no output, and so now it is complete we redirect
***************
*** 692,700 ****
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_ADMIN)) {
!         // Fill in some status variable to be shown in the blocklayout template
!         $data['status'] = pnML('Not authorized to modify #(1) configuration settings',
                                 'Example');
!         // Return the template variables defined in this function
!         return $data;
      }
  
--- 615,623 ----
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_ADMIN)) {
!         $msg = pnML('Not authorized to modify #(1) configuration settings',
                                 'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 703,709 ****
  
      // Specify some labels and values for display
!     $data['boldlabel'] = pnVarPrepForDisplay(_EXAMPLEDISPLAYBOLD);
      $data['boldchecked'] = pnModGetVar('example','bold') ? 'checked' : '';
!     $data['itemslabel'] = pnVarPrepForDisplay(_EXAMPLEITEMSPERPAGE);
      $data['itemsvalue'] = pnModGetVar('example', 'itemsperpage');
      $data['updatebutton'] = pnVarPrepForDisplay(pnML('Update Configuration'));
--- 626,632 ----
  
      // Specify some labels and values for display
!     $data['boldlabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLEDISPLAYBOLD'));
      $data['boldchecked'] = pnModGetVar('example','bold') ? 'checked' : '';
!     $data['itemslabel'] = pnVarPrepForDisplay(pnMLByKey('EXAMPLEITEMSPERPAGE'));
      $data['itemsvalue'] = pnModGetVar('example', 'itemsperpage');
      $data['updatebutton'] = pnVarPrepForDisplay(pnML('Update Configuration'));
***************
*** 787,793 ****
  
      // Specify the menu labels to be used in your blocklayout template
!     $menu['menulabel_new'] = _NEWEXAMPLE;
!     $menu['menulabel_view'] = _VIEWEXAMPLE;
!     $menu['menulabel_config'] = _EXAMPLEMODIFYCONFIG;
  
      // Preset some status variable
--- 710,716 ----
  
      // Specify the menu labels to be used in your blocklayout template
!     $menu['menulabel_new'] = pnMLByKey('NEWEXAMPLE');
!     $menu['menulabel_view'] = pnMLByKey('VIEWEXAMPLE');
!     $menu['menulabel_config'] = pnMLByKey('EXAMPLEMODIFYCONFIG');
  
      // Preset some status variable

Index: pnadminapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/example/pnadminapi.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pnadminapi.php	7 Aug 2002 01:30:22 -0000	1.1
--- pnadminapi.php	13 Aug 2002 12:19:20 -0000	1.2
***************
*** 1,3 ****
! <?php // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
--- 1,4 ----
! <?php
! // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
***************
*** 57,63 ****
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      join(', ',$invalid), 'admin', 'create', 'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return false;
      }
  
--- 58,64 ----
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      join(', ',$invalid), 'admin', 'create', 'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 67,73 ****
          $msg = pnML('Not authorized to add #(1) items',
                      'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return false;
      }
  
--- 68,74 ----
          $msg = pnML('Not authorized to add #(1) items',
                      'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 104,122 ****
      $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', 'create', 'Example');
!         // Don't use that for release versions, though...
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'create', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
!         return false;
      }
  
--- 105,115 ----
      $dbconn->Execute($sql);
  
!     // Check for an error with the database code, and if so raise an
!     // appropriate exception
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnMLByKey('DATABASE_ERROR', $sql);
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  
***************
*** 159,165 ****
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      'item ID', 'admin', 'delete', 'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return false;
      }
  
--- 152,158 ----
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      'item ID', 'admin', 'delete', 'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 167,179 ****
      // 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('example', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'Example','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return false;
!     }
  
      // The user API function is called.  This takes the item ID which
--- 160,165 ----
      // 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 the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'user')) return; // throw back
  
      // The user API function is called.  This takes the item ID which
***************
*** 186,196 ****
              array('exid' => $exid));
  
!     if ($item == false) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'item ID', 'user', 'get', 'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
!         return false;
!     }
  
      // Security check - important to do this as early on as possible to
--- 172,177 ----
              array('exid' => $exid));
  
!     // Check for exceptions
!     if (!isset($item) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
      // Security check - important to do this as early on as possible to
***************
*** 202,208 ****
          $msg = pnML('Not authorized to delete #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return false;
      }
  
--- 183,189 ----
          $msg = pnML('Not authorized to delete #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 228,246 ****
      $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', 'delete', 'Example');
!         // Don't use that for release versions, though...
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'delete', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
!         return false;
      }
  
--- 209,219 ----
      $dbconn->Execute($sql);
  
!     // Check for an error with the database code, and if so raise an
!     // appropriate exception
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnMLByKey('DATABASE_ERROR', $sql);
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  
***************
*** 288,294 ****
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      join(', ',$invalid), 'admin', 'update', 'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return false;
      }
  
--- 261,267 ----
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      join(', ',$invalid), 'admin', 'update', 'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 296,308 ****
      // 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('example', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'Example','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return false;
!     }
  
      // The user API function is called.  This takes the item ID which
--- 269,274 ----
      // 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 the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'user')) return; // throw back
  
      // The user API function is called.  This takes the item ID which
***************
*** 315,325 ****
              array('exid' => $exid));
  
!     if ($item == false) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'item ID', 'user', 'get', 'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
!         return false;
!     }
  
      // Security check - important to do this as early on as possible to
--- 281,286 ----
              array('exid' => $exid));
  
!     // Check for exceptions
!     if (!isset($item) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
      // Security check - important to do this as early on as possible to
***************
*** 337,350 ****
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return false;
      }
      if (!pnSecAuthAction(0, 'Example::Item', "$name::$exid", ACCESS_EDIT)) {
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return false;
      }
  
--- 298,311 ----
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return;
      }
      if (!pnSecAuthAction(0, 'Example::Item', "$name::$exid", ACCESS_EDIT)) {
          $msg = pnML('Not authorized to edit #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 375,390 ****
      // 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', 'Example');
!         // Don't use that for release versions, though...
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'update', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
!         return false;
      }
  
--- 336,343 ----
      // appropriate error message and return
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnMLByKey('DATABASE_ERROR', $sql);
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  

Index: pninit.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/example/pninit.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pninit.php	11 Aug 2002 16:51:03 -0000	1.2
--- pninit.php	13 Aug 2002 12:19:20 -0000	1.3
***************
*** 1,3 ****
! <?php // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
--- 1,4 ----
! <?php
! // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
***************
*** 42,51 ****
      // modules
      $exampletable = $pntable['example'];
!     $examplecolumn = &$pntable['example_column'];
  
      // adodb does not provide the functionality to abstract table creates
      // across multiple databases.  Postnuke offers the pnCreateTable function
      // contained in the following file to provide this functionality.
!     include ('pnadodb/pnTableDDL.php');
  
      // Define the table structure in this associative array
--- 43,53 ----
      // modules
      $exampletable = $pntable['example'];
!     // FIXME: <marco> Isn't it obselete?
!     //$examplecolumn = &$pntable['example_column'];
  
      // adodb does not provide the functionality to abstract table creates
      // across multiple databases.  Postnuke offers the pnCreateTable function
      // contained in the following file to provide this functionality.
!     include ('includes/pnTableDDL.php');
  
      // Define the table structure in this associative array
***************
*** 97,115 ****
  
      // Create the Table - the function will return the SQL is successful or
!     // FALSE if it fails to build the SQL
      $sql = pnDBCreateTable($exampletable,$fields);
!     if ($sql == FALSE) {
!         pnSessionSetVar('errormsg', _CREATETABLEFAILED);
!         return false;
!     }
  
      // Pass the Table Create DDL to adodb to create the table
      $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) {
!         pnSessionSetVar('errormsg', _CREATETABLEFAILED);
!         return false;
      }
  
--- 99,116 ----
  
      // Create the Table - the function will return the SQL is successful or
!     // raise an exception if it fails, in this case $sql is empty
      $sql = pnDBCreateTable($exampletable,$fields);
!     if (empty($sql)) return; // throw back
  
      // Pass the Table Create DDL to adodb to create the table
      $dbconn->Execute($sql);
  
!     // Check for an error with the database code, and if so raise the
!     // appropriate exception
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnMLByKey('DATABASE_ERROR', $query);
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  
***************
*** 195,212 ****
              $exampletable = $pntable['example'];
  
!             // Add a column to the table - 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 = "ALTER TABLE $exampletable
!                     ADD pn_number int(5) NOT NULL default 0";
              $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) {
!                 pnSessionSetVar('errormsg', _UPDATETABLEFAILED);
!                 return false;
              }
  
--- 196,224 ----
              $exampletable = $pntable['example'];
  
!             // Add a column to the table
! 
!             // adodb does not provide the functionality to abstract table creates
!             // across multiple databases.  Postnuke offers the pnCreateTable function
!             // contained in the following file to provide this functionality.
!             include ('includes/pnTableDDL.php');
! 
! //            $sql = "ALTER TABLE $exampletable
! //                    ADD pn_number INTEGER NOT NULL DEFAULT '0'";
! 
!             $sql = pnDBAlterTable(array('table' => $exampletable,
!                                         'command' => 'add',
!                                         'field' => 'pn_number',
!                                         'type' => 'integer',
!                                         'null' => false,
!                                         'default' => '0'));
              $dbconn->Execute($sql);
  
!             // Check for an error with the database code, and if so raise the
!             // appropriate exception
              if ($dbconn->ErrorNo() != 0) {
!                 $msg = pnMLByKey('DATABASE_ERROR', $query);
!                 pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                                new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!                 return;
              }
  
***************
*** 246,265 ****
      // across multiple databases.  Postnuke offers the pnDropeTable function
      // contained in the following file to provide this functionality.
!     include ('pnadodb/pnTableDDL.php');
  
      // Generate the SQL to drop the table using the API
      $sql = pnDBDropTable($pntable['example']);
!     if ($dbconn->ErrorNo() != 0) {
!         // Report failed deletion attempt
!         return false;
!     }
  
      // Drop the table
      $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) {
!         // Report failed deletion attempt
!         return false;
      }
  
--- 258,276 ----
      // across multiple databases.  Postnuke offers the pnDropeTable function
      // contained in the following file to provide this functionality.
!     include ('includes/pnTableDDL.php');
  
      // Generate the SQL to drop the table using the API
      $sql = pnDBDropTable($pntable['example']);
!     if (empty($sql)) return; // throw back
  
      // Drop the table
      $dbconn->Execute($sql);
!     // Check for an error with the database code, and if so raise the
!     // appropriate exception
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnMLByKey('DATABASE_ERROR', $query);
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  
***************
*** 268,271 ****
--- 279,287 ----
      pnModDelVar('example', 'bold');
      pnModDelVar('example', 'mastercid');
+ 
+     pnModDelVar('example', 'SupportShortURLs');
+ 
+     pnBlockTypeUnregister('example', 'first');
+     pnBlockTypeUnregister('example', 'others');
  
      // Deletion successful

Index: pnuser.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/example/pnuser.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pnuser.php	11 Aug 2002 16:51:03 -0000	1.2
--- pnuser.php	13 Aug 2002 12:19:20 -0000	1.3
***************
*** 1,3 ****
! <?php // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
--- 1,4 ----
! <?php
! // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
***************
*** 41,45 ****
      // generally either 'overview' or 'read'
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_OVERVIEW)) {
!         return _EXAMPLENOAUTH;
      }
  
--- 42,50 ----
      // generally either 'overview' or 'read'
      if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_OVERVIEW)) {
!         $msg = pnML('Not authorized to access to #(1)',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 96,100 ****
  
      // Specify some other variables for use in the function template
!     $data['someheader'] = _EXAMPLENAME;
      $data['pager'] = '';
  
--- 101,105 ----
  
      // Specify some other variables for use in the function template
!     $data['someheader'] = pnMLByKey('EXAMPLENAME');
      $data['pager'] = '';
  
***************
*** 102,121 ****
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Examples::', '::', ACCESS_OVERVIEW)) {
!         // Fill in some status variable to be shown in the blocklayout template
!         $data['status'] = _EXAMPLENOAUTH;
!         // Return the template variables defined in this function
!         return $data;
      }
  
      // Load API.  All of the actual work for obtaining information on the items
      // is done within the API, so we need to load that in before we can do
!     // anything.  If the API fails to load an appropriate error message is
!     // posted and the function returns
!     if (!pnModAPILoad('example', 'user')) {
!         // Fill in the status variable with the status to be shown
!         $data['status'] = _LOADFAILED;
!         // Return the template variables defined in this function
!         return $data;
!     }
  
      // The API function is called.  The arguments to the function are passed in
--- 107,121 ----
      // potential security holes or just too much wasted processing
      if (!pnSecAuthAction(0, 'Examples::', '::', ACCESS_OVERVIEW)) {
!         $msg = pnML('Not authorized to access to #(1)',
!                     'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return;
      }
  
      // Load API.  All of the actual work for obtaining information on the items
      // is done within the API, so we need to load that in before we can do
!     // anything.  If the API fails to load the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'user')) return; // throw back
  
      // The API function is called.  The arguments to the function are passed in
***************
*** 129,165 ****
                                  'numitems' => pnModGetVar('example',
                                                            'itemsperpage')));
! 
!     // The return value of the function is checked here, and if the function
!     // failed then an appropriate message is posted here.  Note that if the
!     // API function gave an error, then it should raise an exception that 
!     // you can handle here...
!     if ($items == false) {
!         // Throw back any system exceptions (e.g. database failure)
!         if (pnExceptionMajor() == PN_SYSTEM_EXCEPTION) {
!              return; // throw back
!         }
!         // Handle the user exceptions yourself
!         $data['status'] = _EXAMPLEITEMFAILED;
!         // Possibly handle different exception IDs in specific ways :
!         // if (pnExceptionId() == 'BAD_PARAM') {
!         //     /* do something */
!         // } elseif (pnExceptionId() == 'NO_PERMISSION') {
!         //     /* do something else */
!         // } elseif (pnExceptionId() == 'MyException1') {
!         //     /* do some other thing */
!         // } else {
!         //     /* default handling */
!         // }
!         // Get the information about the exception (in HTML or string format)
!         // $reason = pnExceptionValueHTML();
!         $reason = pnExceptionValueString();
!         if (!empty($reason)) {
!             $data['status'] .= '<br /><br />'. pnML('Reason') .' : '. $reason;
!         }
!         // Free the exception to tell PostNuke that you handled it
!         pnExceptionFree();
!         // Return the template variables defined in this function
!         return $data;
!     }
  
  // TODO: check for conflicts between transformation hook output and
--- 129,133 ----
                                  'numitems' => pnModGetVar('example',
                                                            'itemsperpage')));
!     if (!isset($items) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
  // TODO: check for conflicts between transformation hook output and
***************
*** 227,231 ****
  
      // Specify some other variables for use in the function template
!     $data['someheader'] = _EXAMPLENAME;
  
      // Return the template variables defined in this function
--- 195,199 ----
  
      // Specify some other variables for use in the function template
!     $data['someheader'] = pnMLByKey('EXAMPLENAME');
  
      // Return the template variables defined in this function
***************
*** 292,303 ****
      // Load API.  All of the actual work for obtaining information on the items
      // is done within the API, so we need to load that in before we can do
!     // anything.  If the API fails to load an appropriate error message is
!     // posted and the function returns
!     if (!pnModAPILoad('example', 'user')) {
!         // Fill in the status variable with the status to be shown
!         $data['status'] = _LOADFAILED;
!         // Return the template variables defined in this function
!         return $data;
!     }
  
      // The API function is called.  The arguments to the function are passed in
--- 260,265 ----
      // Load API.  All of the actual work for obtaining information on the items
      // is done within the API, so we need to load that in before we can do
!     // anything.  If the API fails to load the raised exception is thrown back to PostNuke
!     if (!pnModAPILoad('example', 'user')) return; // throw back
  
      // The API function is called.  The arguments to the function are passed in
***************
*** 309,345 ****
                            'get',
                            array('exid' => $exid));
! 
!     // The return value of the function is checked here, and if the function
!     // failed then an appropriate message is posted here.  Note that if the
!     // API function gave an error, then it should raise an exception that 
!     // you can handle here...
!     if ($item == false) {
!         // Throw back any system exceptions (e.g. database failure)
!         if (pnExceptionMajor() == PN_SYSTEM_EXCEPTION) {
!              return; // throw back
!         }
!         // Handle the user exceptions yourself
!         $data['status'] = _EXAMPLEITEMFAILED;
!         // Possibly handle different exception IDs in specific ways :
!         // if (pnExceptionId() == 'BAD_PARAM') {
!         //     /* do something */
!         // } elseif (pnExceptionId() == 'NO_PERMISSION') {
!         //     /* do something else */
!         // } elseif (pnExceptionId() == 'MyException1') {
!         //     /* do some other thing */
!         // } else {
!         //     /* default handling */
!         // }
!         // Get the information about the exception (in HTML or string format)
!         // $reason = pnExceptionValueHTML();
!         $reason = pnExceptionValueString();
!         if (!empty($reason)) {
!             $data['status'] .= '<br /><br />'. pnML('Reason') .' : '. $reason;
!         }
!         // Free the exception to tell PostNuke that you handled it
!         pnExceptionFree();
!         // Return the template variables defined in this function
!         return $data;
!     }
  
      // Security check 2 - if your API function does *not* check for the
--- 271,275 ----
                            'get',
                            array('exid' => $exid));
!     if (!isset($item) && pnExceptionMajor() != PN_NO_EXCEPTION) return; // throw back
  
      // Security check 2 - if your API function does *not* check for the
***************
*** 370,376 ****
      // whether or not parts of the item information should be displayed in
      // bold type or not
!     $data['name_label'] = _EXAMPLENAME;
      $data['name_value'] = pnVarCensor($item['name']);
!     $data['number_label'] = _EXAMPLENUMBER;
      $data['number_value'] = $item['number'];
  
--- 300,306 ----
      // whether or not parts of the item information should be displayed in
      // bold type or not
!     $data['name_label'] = pnMLByKey('EXAMPLENAME');
      $data['name_value'] = pnVarCensor($item['name']);
!     $data['number_label'] = pnMLByKey('EXAMPLENUMBER');
      $data['number_value'] = $item['number'];
  
***************
*** 424,431 ****
  
      // Specify the menu title to be used in your blocklayout template
!     $menu['menutitle'] = _EXAMPLE;
  
      // Specify the menu items to be used in your blocklayout template
!     $menu['menulabel_view'] = _EXAMPLEVIEW;
      $menu['menulink_view'] = pnModURL('example','user','view');
  
--- 354,361 ----
  
      // Specify the menu title to be used in your blocklayout template
!     $menu['menutitle'] = pnMLByKey('EXAMPLE');
  
      // Specify the menu items to be used in your blocklayout template
!     $menu['menulabel_view'] = pnMLByKey('EXAMPLEVIEW');
      $menu['menulink_view'] = pnModURL('example','user','view');
  

Index: pnuserapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/example/pnuserapi.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pnuserapi.php	7 Aug 2002 01:30:22 -0000	1.1
--- pnuserapi.php	13 Aug 2002 12:19:20 -0000	1.2
***************
*** 1,3 ****
! <?php // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
--- 1,4 ----
! <?php
! // $Id$
  // ----------------------------------------------------------------------
  // PostNuke Content Management System
***************
*** 64,70 ****
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      join(', ',$invalid), 'user', 'getall', 'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return false;
      }
  
--- 65,71 ----
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      join(', ',$invalid), 'user', 'getall', 'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 76,82 ****
          $msg = pnML('Not authorized to access #(1) items',
                      'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return false;
      }
  
--- 77,83 ----
          $msg = pnML('Not authorized to access #(1) items',
                      'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 114,122 ****
          //             $dbconn->ErrorMsg(), $sql, 'user', 'getall', 'Example');
          // Don't use that for release versions, though...
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
                      'user', 'getall', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
!         return false;
      }
  
--- 115,130 ----
          //             $dbconn->ErrorMsg(), $sql, 'user', 'getall', 'Example');
          // Don't use that for release versions, though...
+         /*
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
                      'user', 'getall', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
!         return;
!         */
!         // This is the API compliant way to raise a db error exception
!         $msg = pnMLByKey('DATABASE_ERROR', $sql);
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  
***************
*** 166,172 ****
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      'item ID', 'user', 'get', 'Example');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return false;
      }
  
--- 174,180 ----
          $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
                      'item ID', 'user', 'get', 'Example');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 203,217 ****
          //             $dbconn->ErrorMsg(), $sql, 'user', 'get', 'Example');
          // Don't use that for release versions, though...
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
                      'user', 'get', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
!         return false;
      }
  
!     // Check for no rows found, and if so, close the result set and return
      if ($result->EOF) {
          $result->Close();
!         return false;
      }
  
--- 211,235 ----
          //             $dbconn->ErrorMsg(), $sql, 'user', 'get', 'Example');
          // Don't use that for release versions, though...
+         /*
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
                      'user', 'get', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
!         return;
!         */
!         // This is the API compliant way to raise a db error exception
!         $msg = pnMLByKey('DATABASE_ERROR', $sql);
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  
!     // Check for no rows found, and if so, close the result set and return an exception
      if ($result->EOF) {
          $result->Close();
!         $msg = pnML('This item does not exists');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'ID_NOT_EXIST',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  
***************
*** 231,237 ****
          $msg = pnML('Not authorized to access #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return false;
      }
  
--- 249,255 ----
          $msg = pnML('Not authorized to access #(1) item #(2)',
                      'Example', pnVarPrepForStore($exid));
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
                         new SystemException($msg));
!         return;
      }
  
***************
*** 285,293 ****
          //          $dbconn->ErrorMsg(), $sql, 'user', 'countitems', 'Example');
          // Don't use that for release versions, though...
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
                      'user', 'countitems', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
!         return false;
      }
  
--- 303,318 ----
          //          $dbconn->ErrorMsg(), $sql, 'user', 'countitems', 'Example');
          // Don't use that for release versions, though...
+         /*
          $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
                      'user', 'countitems', 'Example');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                         new SystemException($msg));
!         return;
!         */
!         // This is the API compliant way to raise a db error exception
!         $msg = pnMLByKey('DATABASE_ERROR', $sql);
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return;
      }
  


Directory filter : [ all ] / postnuke_official / html / modules / example [ 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