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 / articles [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
05 Aug 2002 01:46:05postnuke_modules/articlespnadmin.php,1.26,1.27 pnadminapi.php,1.10,1.11 pninit.php,1.19,1.20 pntables.php,1.6,1.7 pnuser.php,1.39,1.40 pnuserapi.php,1.32,1.33 pnversion.php,1.8,1.9Mike
 some article changes - pub types, display, exceptions etc.

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

Modified Files:
	pnadmin.php pnadminapi.php pninit.php pntables.php pnuser.php 
	pnuserapi.php pnversion.php 
Log Message:
some article changes - pub types, display, exceptions etc.


Index: pnadmin.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnadmin.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** pnadmin.php	1 Aug 2002 01:38:50 -0000	1.26
--- pnadmin.php	5 Aug 2002 01:46:02 -0000	1.27
***************
*** 50,62 ****
      // Get parameters
      $ptid= pnVarCleanFromInput('ptid');
-     if (!isset($ptid)) {
-         $ptid = '';
-     }
  
      // Load user API to obtain item information function
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) user API',
!                     'Articles');
[...1063 lines suppressed...]
!     $menu['title'] = _ARTICLES;
  
      // Menu options
!     $menu['new'] = _ARTICLESNEW;
!     $menu['view'] = _ARTICLESVIEW;
!     $menu['modifyconfig'] = _ARTICLESMODIFYCONFIG;
  
      return $menu;
--- 1387,1397 ----
  
      // Start options menu
!     $menu['title'] = pnML('Articles Administration');
  
      // Menu options
!     $menu['new'] = pnML('New Article');
!     $menu['view'] = pnML('View Articles');
!     $menu['modifyconfig'] = pnML('Articles Configuration');
!     $menu['pubtypes'] = pnML('Publication Types');
  
      return $menu;

Index: pnadminapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnadminapi.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** pnadminapi.php	1 Aug 2002 01:06:18 -0000	1.10
--- pnadminapi.php	5 Aug 2002 01:46:02 -0000	1.11
***************
*** 32,35 ****
--- 32,37 ----
   * @param $args['bodyfile'] file input text for this item
   * @param $args['langauge'] language of the item
+  * @param $args['notes'] notes for the item
+  * @param $args['status'] status of the item
   * @param $args['ptid'] publication type ID for the item
   * @returns int
***************
*** 50,54 ****
          (!isset($language))
          ) {
!         pnSessionSetVar('errormsg', _MODARGSERROR);
          return false;
      }
--- 52,60 ----
          (!isset($language))
          ) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'parameters', 'admin', 'create',
!                     'Articles');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
          return false;
      }
***************
*** 56,66 ****
      // Security check
      if (!pnModAPILoad('articles', 'user')) {
!         pnSessionSetVar('errormsg', _LOADFAILED);
!         pnRedirect(pnModURL('articles', 'admin', 'view'));
          return false;
      }
      $args['access'] = ACCESS_ADD;
      if (!pnModAPIFunc('articles','user','checksecurity',$args)) {
!         pnSessionSetVar('errormsg', _ARTICLESNOAUTH);
          return false;
      }
--- 62,77 ----
      // Security check
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
          return false;
      }
      $args['access'] = ACCESS_ADD;
      if (!pnModAPIFunc('articles','user','checksecurity',$args)) {
!         $msg = pnML('Not authorized to add #(1) items',
!                     'Article');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
          return false;
      }
***************
*** 91,94 ****
--- 102,107 ----
                $articlescolumn[pubdate],
                $articlescolumn[pubtypeid],
+               $articlescolumn[notes],
+               $articlescolumn[status],
                $articlescolumn[language])
              VALUES (
***************
*** 100,108 ****
                " . pnVarPrepForStore(time()) . ",
                '" . pnvarPrepForStore($ptid) . "',
                '" . pnvarPrepForStore($language) . "')";
      $dbconn->Execute($sql);
  
      if ($dbconn->ErrorNo() != 0) {
!         pnSessionSetVar('errormsg', $sql.mysql_error()._CREATEFAILED);
          return false;
      }
--- 113,126 ----
                " . pnVarPrepForStore(time()) . ",
                '" . pnvarPrepForStore($ptid) . "',
+               '" . pnvarPrepForStore($notes) . "',
+               '" . pnvarPrepForStore($status) . "',
                '" . pnvarPrepForStore($language) . "')";
      $dbconn->Execute($sql);
  
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'create', 'Articles');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
          return false;
      }
***************
*** 125,129 ****
      
          // Create the category Link
!         pnModAPILoad('categories', 'admin');
          pnModAPIFunc('categories',
                       'admin',
--- 143,153 ----
      
          // Create the category Link
!         if (!pnModAPILoad('categories', 'admin')) {
!             $msg = pnML('Unable to load #(1) #(2) API',
!                        'categories','admin');
!             pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                            new SystemException($msg));
!             return false;
!         }
          pnModAPIFunc('categories',
                       'admin',
***************
*** 151,155 ****
      // Argument check
      if (!isset($aid)) {
!         pnSessionSetVar('errormsg', _MODARGSERROR);
          return false;
      }
--- 175,183 ----
      // Argument check
      if (!isset($aid)) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'article ID', 'admin', 'delete',
!                     'Articles');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
          return false;
      }
***************
*** 157,167 ****
      // Security check
      if (!pnModAPILoad('articles', 'user')) {
!         pnSessionSetVar('errormsg', _LOADFAILED);
!         pnRedirect(pnModURL('articles', 'admin', 'view'));
          return false;
      }
      $args['access'] = ACCESS_DELETE;
      if (!pnModAPIFunc('articles','user','checksecurity',$args)) {
!         pnSessionSetVar('errormsg', _ARTICLESNOAUTH);
          return false;
      }
--- 185,200 ----
      // Security check
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
          return false;
      }
      $args['access'] = ACCESS_DELETE;
      if (!pnModAPIFunc('articles','user','checksecurity',$args)) {
!         $msg = pnML('Not authorized to delete #(1) items',
!                     'Article');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
          return false;
      }
***************
*** 178,182 ****
      // Delete Categories Linkages
      if (!pnModAPILoad('categories', 'admin')) {
!         pnSessionSetVar('errormsg', _LOADFAILED);
          return false;
      }
--- 211,218 ----
      // Delete Categories Linkages
      if (!pnModAPILoad('categories', 'admin')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'categories','admin');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
          return false;
      }
***************
*** 198,202 ****
  
      if ($dbconn->ErrorNo() != 0) {
!         pnSessionSetVar('errormsg', _DELETEFAILED);
          return false;
      }
--- 234,241 ----
  
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'delete', 'Articles');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
          return false;
      }
***************
*** 206,216 ****
  
  /**
!  * create articles item
   * @param $args['aid'] ID of the item
   * @param $args['title'] name of the item
!  * @param $args['title'] summary of the item
   * @param $args['bodytype'] type of input for this item
   * @param $args['bodytext'] direct input text for this item
   * @param $args['bodyfile'] file input text for this item
   * @param $args['langauge'] language of the item
   */
--- 245,257 ----
  
  /**
!  * update articles item
   * @param $args['aid'] ID of the item
   * @param $args['title'] name of the item
!  * @param $args['summary'] summary of the item
   * @param $args['bodytype'] type of input for this item
   * @param $args['bodytext'] direct input text for this item
   * @param $args['bodyfile'] file input text for this item
+  * @param $args['notes'] notes for the item
+  * @param $args['status'] status of the item
   * @param $args['langauge'] language of the item
   */
***************
*** 228,232 ****
          ((!isset($bodytext)) && (!isset($bodyfile))) ||
          (!isset($language))) {
!         pnSessionSetVar('errormsg', _MODARGSERROR);
          return false;
      }
--- 269,277 ----
          ((!isset($bodytext)) && (!isset($bodyfile))) ||
          (!isset($language))) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'parameters', 'admin', 'update',
!                     'Articles');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
          return false;
      }
***************
*** 237,247 ****
      // Security check
      if (!pnModAPILoad('articles', 'user')) {
!         pnSessionSetVar('errormsg', _LOADFAILED);
!         pnRedirect(pnModURL('articles', 'admin', 'view'));
          return false;
      }
      $args['access'] = ACCESS_EDIT;
      if (!pnModAPIFunc('articles','user','checksecurity',$args)) {
!         pnSessionSetVar('errormsg', _ARTICLESNOAUTH);
          return false;
      }
--- 282,297 ----
      // Security check
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
          return false;
      }
      $args['access'] = ACCESS_EDIT;
      if (!pnModAPIFunc('articles','user','checksecurity',$args)) {
!         $msg = pnML('Not authorized to update #(1) items',
!                     'Article');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
          return false;
      }
***************
*** 263,268 ****
      
      if (!pnModAPILoad('categories', 'admin')) {
!         pnSessionSetVar('errormsg', _LOADFAILED);
!         pnRedirect(pnModURL('articles', 'admin', 'view'));
          return false;
      }
--- 313,320 ----
      
      if (!pnModAPILoad('categories', 'admin')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'categories','admin');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
          return false;
      }
***************
*** 292,295 ****
--- 344,349 ----
                  $articlescolumn[summary] = '" . pnVarPrepForStore($summary) . "',
                  $articlescolumn[body] = '" . pnVarPrepForStore($body) . "',
+                 $articlescolumn[notes] = '" . pnVarPrepForStore($notes) . "',
+                 $articlescolumn[status] = '" . pnVarPrepForStore($status) . "',
                  $articlescolumn[language] = '" . pnVarPrepForStore($language) . "'
              WHERE $articlescolumn[aid] = " . pnVarPrepForStore($aid);
***************
*** 297,301 ****
  
      if ($dbconn->ErrorNo() != 0) {
!         pnSessionSetVar('errormsg', _UPDATEFAILED);
          return false;
      }
--- 351,556 ----
  
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'update', 'Articles');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     return true;
! }
! 
! /**
!  * create publication type
!  * @param $args['name'] name of the publication type
!  * @param $args['descr'] description of the publication type
!  * @param $args['config'] configuration of the publication type
!  */
! function articles_adminapi_createpubtype($args)
! {
!     // Get arguments from argument array
!     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($name) || !is_string($name) || empty($name)) {
!         $invalid[] = 'name';
!     }
!     if (!isset($descr) || !is_string($descr) || empty($descr)) {
!         $invalid[] = 'description';
!     }
!     if (!isset($config) || !is_array($config) || count($config) == 0) {
!         $invalid[] = 'configuration';
!     }
!     if (count($invalid) > 0) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     join(', ',$invalid), 'admin', 'createpubtype','Articles');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     // Publication type names *must* be lower-case for now
!     $name = strtolower($name);
! 
!     // Security check - we require ADMIN rights here
!     if (!pnSecAuthAction(0, 'articles::classification', '::', ACCESS_ADMIN)) {
!         $msg = pnML('Not authorized to add #(1) items',
!                     'Publication Type');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return false;
!     }
!     // Make sure we have all the configuration fields we need
!     $pubfields = pnModAPIFunc('articles','user','getpubfields');
!     foreach ($pubfields as $field => $value) {
!         if (!isset($config[$field])) {
!             $config[$field] = '';
!         }
!     }
! 
!     // Get database setup
!     list($dbconn) = pnDBGetConn();
!     $pntable = pnDBGetTables();
!     $pubtypestable = $pntable['publication_types'];
! 
!     // Insert the publication type
!     $sql = "INSERT INTO $pubtypestable (pn_pubtypename, pn_pubtypedescr,
!             pn_pubtypeconfig)
!             VALUES ('" . pnVarPrepForStore($name) . "',
!                     '" . pnVarPrepForStore($descr) . "',
!                     '" . pnVarPrepForStore(serialize($config)) . "')";
!     $dbconn->Execute($sql);
! 
!     if ($dbconn->ErrorNo() != 0) {
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'admin', 'createpubtype', 'Articles');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     // Get ptid to return
!     $ptid = $dbconn->PO_Insert_ID($pubtypestable, 'pn_pubtypeid');
! 
!     // Don't call creation hooks here...
!     //pnModCallHooks('item', 'create', $ptid, 'ptid');
! 
!     return $ptid;
! }
! 
! /**
!  * update publication type
!  * @param $args['ptid'] ID of the publication type
!  * @param $args['name'] name of the publication type (not allowed here)
!  * @param $args['descr'] description of the publication type
!  * @param $args['config'] configuration of the publication type
!  */
! function articles_adminapi_updatepubtype($args)
! {
!     // Get arguments from argument array
!     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($ptid) || !is_numeric($ptid) || $ptid < 1) {
!         $invalid[] = 'publication type ID';
!     }
! /*
!     if (!isset($name) || !is_string($name) || empty($name)) {
!         $invalid[] = 'name';
!     }
! */
!     if (!isset($descr) || !is_string($descr) || empty($descr)) {
!         $invalid[] = 'description';
!     }
!     if (!isset($config) || !is_array($config) || count($config) == 0) {
!         $invalid[] = 'configuration';
!     }
!     if (count($invalid) > 0) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     join(', ',$invalid), 'admin', 'updatepubtype','Articles');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     // Security check - we require ADMIN rights here
!     if (!pnSecAuthAction(0, 'articles::classification', $ptid.'::', ACCESS_ADMIN)) {
!         $msg = pnML('Not authorized to update #(1) items',
!                     'Publication Type');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     // Load user API to obtain item information function
!     if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     // Get current publication types
!     $pubtypes = pnModAPIFunc('articles','user','getpubtypes');
!     if (!isset($pubtypes[$ptid])) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'publication type ID', 'admin', 'updatepubtype',
!                     'Articles');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
!         return false;
!     }
! 
!     // Make sure we have all the configuration fields we need
!     $pubfields = pnModAPIFunc('articles','user','getpubfields');
!     foreach ($pubfields as $field => $value) {
!         if (!isset($config[$field])) {
!             $config[$field] = '';
!         }
!     }
! 
!     // Get database setup
!     list($dbconn) = pnDBGetConn();
!     $pntable = pnDBGetTables();
!     $pubtypestable = $pntable['publication_types'];
! 
! /*
!     // Update the publication type
!     $sql = "UPDATE $pubtypestable
!             SET pn_pubtypename = '" . pnVarPrepForStore($name) . "',
!                 pn_pubtypedescr = '" . pnVarPrepForStore($descr) . "'
!             WHERE pn_pubtypeid = " . pnVarPrepForStore($ptid);
! */
!     // Update the publication type
!     $sql = "UPDATE $pubtypestable
!             SET pn_pubtypedescr = '" . pnVarPrepForStore($descr) . "',
!                 pn_pubtypeconfig = '" . pnVarPrepForStore(serialize($config)) . "'
!             WHERE pn_pubtypeid = " . pnVarPrepForStore($ptid);
!     $dbconn->Execute($sql);
! 
!     if ($dbconn->ErrorNo() != 0) {
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3) : #(4) in #(5)',
!                     'admin', 'updatepubtype', 'Articles', $dbconn->ErrorMsg(), $sql);
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
          return false;
      }
***************
*** 303,305 ****
--- 558,635 ----
      return true;
  }
+ 
+ /**
+  * delete publication type
+  * @param $args['ptid'] ID of the publication type
+  */
+ function articles_adminapi_deletepubtype($args)
+ {
+     // Get arguments from argument array
+     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
+     if (!isset($ptid) || !is_numeric($ptid) || $ptid < 1) {
+         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
+                     'publication type ID', 'admin', 'deletepubtype',
+                     'Articles');
+         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
+                        new SystemException($msg));
+         return false;
+     }
+ 
+     // Security check - we require ADMIN rights here
+     if (!pnSecAuthAction(0, 'articles::classification', $ptid.'::', ACCESS_ADMIN)) {
+         $msg = pnML('Not authorized to delete #(1) items',
+                     'Publication Type');
+         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
+                        new SystemException($msg));
+         return false;
+     }
+ 
+     // Load user API to obtain item information function
+     if (!pnModAPILoad('articles', 'user')) {
+         $msg = pnML('Unable to load #(1) #(2) API',
+                     'articles','user');
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
+                        new SystemException($msg));
+         return false;
+     }
+ 
+     // Get current publication types
+     $pubtypes = pnModAPIFunc('articles','user','getpubtypes');
+     if (!isset($pubtypes[$ptid])) {
+         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
+                     'publication type ID', 'admin', 'deletepubtype',
+                     'Articles');
+         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
+                        new SystemException($msg));
+         return false;
+     }
+ 
+     // Don't call deletion hooks here...
+     //pnModCallHooks('item', 'delete', $ptid, 'ptid');
+ 
+     // Get database setup
+     list($dbconn) = pnDBGetConn();
+     $pntable = pnDBGetTables();
+     $pubtypestable = $pntable['publication_types'];
+ 
+     // Delete the publication type
+     $sql = "DELETE FROM $pubtypestable
+             WHERE pn_pubtypeid = " . pnVarPrepForStore($ptid);
+     $dbconn->Execute($sql);
+ 
+     if ($dbconn->ErrorNo() != 0) {
+         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
+                     'admin', 'deletepubtype', 'Articles');
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException($msg));
+         return false;
+     }
+ 
+     return true;
+ }
+ 
  ?>

Index: pninit.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pninit.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** pninit.php	4 Aug 2002 17:02:36 -0000	1.19
--- pninit.php	5 Aug 2002 01:46:02 -0000	1.20
***************
*** 64,70 ****
      $sql = "CREATE TABLE $articlestable (
              $articlescolumn[aid] INT(10) NOT NULL AUTO_INCREMENT,
!             $articlescolumn[title] TEXT NOT NULL DEFAULT '',
              $articlescolumn[summary] TEXT,
              $articlescolumn[body] TEXT,
              $articlescolumn[authorid] INT(11) NOT NULL,
              $articlescolumn[pubdate] INT UNSIGNED NOT NULL,
--- 64,72 ----
      $sql = "CREATE TABLE $articlestable (
              $articlescolumn[aid] INT(10) NOT NULL AUTO_INCREMENT,
!             $articlescolumn[title] VARCHAR(255) NOT NULL DEFAULT '',
              $articlescolumn[summary] TEXT,
              $articlescolumn[body] TEXT,
+             $articlescolumn[notes] TEXT,
+             $articlescolumn[status] TINYINT(2) NOT NULL DEFAULT '0',
              $articlescolumn[authorid] INT(11) NOT NULL,
              $articlescolumn[pubdate] INT UNSIGNED NOT NULL,
***************
*** 72,79 ****
              $articlescolumn[pages] INT UNSIGNED NOT NULL,
              $articlescolumn[language] VARCHAR(30) NOT NULL DEFAULT '',
!             PRIMARY KEY (pn_aid),
              KEY pn_authorid (pn_authorid),
              KEY pn_pubtypeid (pn_pubtypeid),
!             KEY pn_pubdate (pn_pubdate)
              )";
      $dbconn->Execute($sql);
--- 74,82 ----
              $articlescolumn[pages] INT UNSIGNED NOT NULL,
              $articlescolumn[language] VARCHAR(30) NOT NULL DEFAULT '',
!             PRIMARY KEY(pn_aid),
              KEY pn_authorid (pn_authorid),
              KEY pn_pubtypeid (pn_pubtypeid),
!             KEY pn_pubdate (pn_pubdate),
!             KEY pn_status (pn_status)
              )";
      $dbconn->Execute($sql);
***************
*** 93,97 ****
              $pubtypescolumn[pubtypename] VARCHAR(30) NOT NULL,
              $pubtypescolumn[pubtypedescr] VARCHAR(255) NOT NULL DEFAULT '',
!             PRIMARY KEY (pn_pubtypeid))";
      $dbconn->Execute($sql);
  
--- 96,101 ----
              $pubtypescolumn[pubtypename] VARCHAR(30) NOT NULL,
              $pubtypescolumn[pubtypedescr] VARCHAR(255) NOT NULL DEFAULT '',
!             $pubtypescolumn[pubtypeconfig] TEXT,
!             PRIMARY KEY(pn_pubtypeid))";
      $dbconn->Execute($sql);
  
***************
*** 103,120 ****
      }
  
! // TODO: refine according to RFC 1
  
      $values = array(
!                     array(1, 'news', 'News Articles'),
!                     array(2, 'section', 'Section Documents'),
!                     array(3, 'review', 'Reviews'),
!                     array(4, 'faq', 'Frequently Asked Questions'),
                );
  
      foreach ($values as $value) {
!         list($id,$name,$descr) = $value;
          $sql = "INSERT INTO $pubtypestable
!                 (pn_pubtypeid, pn_pubtypename, pn_pubtypedescr)
!                 VALUES ($id, '$name', '$descr')";
          $dbconn->Execute($sql);
  
--- 107,174 ----
      }
  
! // TODO: for .81+, refine according to RFC 1
  
+     // Configuration of the different publication types
+     // An empty field means it's (currently) not used for that type
+     $config['news'] = array(
+         'title' => pnML('Title'),
+         'summary' => pnML('Introduction'),
+         'authorid' => pnML('Author'),
+         'pubdate' => pnML('Publication Date'),
+         'notes' => pnML('Notes'),
+         'bodytext' => pnML('Body Text'),
+         'bodyfile' => '',
+         'status' => pnML('Status')
+     );
+     $config['sections'] = array(
+         'title' => pnML('Subject'),
+         'summary' => '',
+         'authorid' => '',
+         'pubdate' => '',
+         'notes' => '',
+         'bodytext' => pnML('Content Text'),
+         'bodyfile' => pnML('Content File Upload'),
+         'status' => ''
+     );
+ // TODO: adapt/evaluate for reviews
+     $config['reviews'] = array(
+         'title' => pnML('Title'),
+         'summary' => pnML('Summary'),
+         'authorid' => pnML('Author'),
+         'pubdate' => pnML('Publication Date'),
+         'notes' => pnML('Notes'),
+         'bodytext' => pnML('Body Text'),
+         'bodyfile' => pnML('Body File Upload'),
+         'status' => pnML('Status')
+     );
+     $config['faqs'] = array(
+         'title' => pnML('Question'),
+         'summary' => pnML('Details'),
+         'authorid' => '',
+         'pubdate' => '',
+         'notes' => pnML('Submitted by'),
+         'bodytext' => pnML('Answer'),
+         'bodyfile' => '',
+         'status' => ''
+     );
+     // The list of currently supported publication types
      $values = array(
!                     array(1, 'news', 'News Articles',
!                           serialize($config['news'])),
!                     array(2, 'sections', 'Section Documents',
!                           serialize($config['sections'])),
!                     array(3, 'reviews', 'Reviews',
!                           serialize($config['reviews'])),
!                     array(4, 'faqs', 'FAQs',
!                           serialize($config['faqs'])),
                );
  
      foreach ($values as $value) {
!         list($id,$name,$descr,$config) = $value;
          $sql = "INSERT INTO $pubtypestable
!                 (pn_pubtypeid, pn_pubtypename, pn_pubtypedescr,
!                  pn_pubtypeconfig)
!                 VALUES ($id, '$name', '$descr', '"
!                 . pnVarPrepForStore($config) ."')";
          $dbconn->Execute($sql);
  
***************
*** 127,131 ****
      }
  
! // TODO: the following tables are unused (cfr. RFC 1 for more generic approach)
  /*
      $articlespagestable = $pntable['articles_pages'];
--- 181,186 ----
      }
  
! // TODO: the following tables are unused
! // Cfr. RFC 1 for a more generic approach in later versions of Postnuke
  /*
      $articlespagestable = $pntable['articles_pages'];
***************
*** 162,170 ****
      }
  */
      // Set up module variables
      pnModSetVar('articles', 'itemsperpage', 10);
      pnModSetVar('articles', 'SupportShortURLs', 0);
  
!     // some starting categories
      $articlecategories = array();
      $articlecategories[] = array('name' => 'Generic1',
--- 217,226 ----
      }
  */
+ 
      // Set up module variables
      pnModSetVar('articles', 'itemsperpage', 10);
      pnModSetVar('articles', 'SupportShortURLs', 0);
  
!     // Some starting categories as an example
      $articlecategories = array();
      $articlecategories[] = array('name' => 'Generic1',
***************
*** 188,191 ****
--- 244,251 ----
                                   'children' => array('Section 1',
                                                       'Section 2'));
+     $articlecategories[] = array('name' => 'FAQ',
+                                  'description' => 'Frequently Asked Questions (.7x style)',
+                                  'children' => array('FAQ Type 1',
+                                                      'FAQ Type 2'));
      foreach (array_reverse($articlecategories,TRUE) as $category) {
          $cid[$category['name']] = pnModAPIFunc('categories',
***************
*** 208,219 ****
      pnModSetVar('articles', 'number_of_categories', 2);
      pnModSetVar('articles','cids',$cid['Generic1'] . ';' . $cid['Generic2']);
!     // news articles can be in old-style Topics & Categories, and in new Generic
      pnModSetVar('articles', 'number_of_categories.1', 3);
      pnModSetVar('articles','cids.1',$cid['Topics'] . ';' . $cid['Categories'] .
                                      ';' . $cid['Generic1']);
!     // section documents can be in old-style Sections, and in new Generic
      pnModSetVar('articles', 'number_of_categories.2', 2);
      pnModSetVar('articles','cids.2',$cid['Sections'] . ';' . $cid['Generic1']);
  
      // Initialisation successful
      return true;
--- 268,289 ----
      pnModSetVar('articles', 'number_of_categories', 2);
      pnModSetVar('articles','cids',$cid['Generic1'] . ';' . $cid['Generic2']);
! 
!     // news articles can be in old-style Topics & Categories, and in new Generic1
      pnModSetVar('articles', 'number_of_categories.1', 3);
      pnModSetVar('articles','cids.1',$cid['Topics'] . ';' . $cid['Categories'] .
                                      ';' . $cid['Generic1']);
! 
!     // section documents can be in old-style Sections, and in new Generic1
      pnModSetVar('articles', 'number_of_categories.2', 2);
      pnModSetVar('articles','cids.2',$cid['Sections'] . ';' . $cid['Generic1']);
  
+     // reviews can be in new Generic1 (no categories in old-style reviews ?)
+     pnModSetVar('articles', 'number_of_categories.3', 1);
+     pnModSetVar('articles','cids.3',$cid['Generic1']);
+ 
+     // faqs can be in old-style FAQs, and in new Generic1
+     pnModSetVar('articles', 'number_of_categories.4', 2);
+     pnModSetVar('articles','cids.4',$cid['FAQ'] . ';' . $cid['Generic1']);
+ 
      // Initialisation successful
      return true;
***************
*** 230,233 ****
--- 300,309 ----
              // Code to upgrade from version 1.0 goes here
              break;
+ // TODO : remove for release version
+         case 1.1:
+             // Code to upgrade from version 1.1 goes here
+             pnSessionSetVar('errormsg', pnML('Please remove and re-initialize'));
+             return false;
+             break;
          case 2.0:
              // Code to upgrade from version 2.0 goes here
***************
*** 256,262 ****
      if ($dbconn->ErrorNo() != 0) {
          // Report failed deletion attempt
!         return false;
      }
  
      // Delete tables
      $sql = "DROP TABLE $pntable[publication_types]";
--- 332,340 ----
      if ($dbconn->ErrorNo() != 0) {
          // Report failed deletion attempt
! //        return false;
      }
  
+ // TODO: remove entries from categories_linkage !
+ 
      // Delete tables
      $sql = "DROP TABLE $pntable[publication_types]";
***************
*** 269,274 ****
      }
  
! // TODO: the following tables are unused (cfr. RFC 1 for more generic approach)
! 
      $sql = "DROP TABLE $pntable[articles_images]";
      $dbconn->Execute($sql);
--- 347,353 ----
      }
  
! // TODO: the following tables are unused
! // Cfr. RFC 1 for a more generic approach in later versions of Postnuke
! /*
      $sql = "DROP TABLE $pntable[articles_images]";
      $dbconn->Execute($sql);
***************
*** 288,291 ****
--- 367,371 ----
  //        return false;
      }
+ */
  
      // Delete module variables
***************
*** 299,302 ****
--- 379,386 ----
      pnModDelVar('articles', 'number_of_categories.2');
      pnModDelVar('articles', 'cids.2');
+     pnModDelVar('articles', 'number_of_categories.3');
+     pnModDelVar('articles', 'cids.3');
+     pnModDelVar('articles', 'number_of_categories.4');
+     pnModDelVar('articles', 'cids.4');
  
      // Deletion successful

Index: pntables.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pntables.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pntables.php	27 Jul 2002 17:23:12 -0000	1.6
--- pntables.php	5 Aug 2002 01:46:02 -0000	1.7
***************
*** 41,47 ****
                                          'authorid' => $articles . '.pn_authorid',
                                          'pubdate'  => $articles . '.pn_pubdate',
!                                         'pubtypeid'  => $articles . '.pn_pubtypeid',
                                          'pages'    => $articles . '.pn_pages',
                                          'body'     => $articles . '.pn_body',
                                          'language' => $articles . '.pn_language');
  
--- 41,49 ----
                                          'authorid' => $articles . '.pn_authorid',
                                          'pubdate'  => $articles . '.pn_pubdate',
!                                         'pubtypeid' => $articles . '.pn_pubtypeid',
                                          'pages'    => $articles . '.pn_pages',
                                          'body'     => $articles . '.pn_body',
+                                         'notes'    => $articles . '.pn_notes',
+                                         'status'   => $articles . '.pn_status',
                                          'language' => $articles . '.pn_language');
  
***************
*** 56,63 ****
                  'pubtypeid'      => $publicationtypes . '.pn_pubtypeid',
                  'pubtypename'    => $publicationtypes . '.pn_pubtypename',
!                 'pubtypedescr'   => $publicationtypes . '.pn_pubtypedescr');
! 
! // TODO: the following tables are unused (cfr. RFC 1 for more generic approach)
  
      // Name for articles database pages
      $articlespages = pnConfigGetVar('prefix') . '_articles_pages';
--- 58,67 ----
                  'pubtypeid'      => $publicationtypes . '.pn_pubtypeid',
                  'pubtypename'    => $publicationtypes . '.pn_pubtypename',
!                 'pubtypedescr'   => $publicationtypes . '.pn_pubtypedescr',
!                 'pubtypeconfig'   => $publicationtypes . '.pn_pubtypeconfig');
  
+ // TODO: the following tables are unused
+ // Cfr. RFC 1 for a more generic approach in later versions of Postnuke
+ /*
      // Name for articles database pages
      $articlespages = pnConfigGetVar('prefix') . '_articles_pages';
***************
*** 84,87 ****
--- 88,92 ----
                                                 'image'      => $articlesimages . '.pn_image');
  
+ */
  
      // Return table information

Index: pnuser.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnuser.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** pnuser.php	2 Aug 2002 00:08:22 -0000	1.39
--- pnuser.php	5 Aug 2002 01:46:02 -0000	1.40
***************
*** 31,36 ****
      //return articles_user_view();
  // TODO: make this configurable someday ?
!     // redirect to default view with news articles
!     pnRedirect(pnModURL('articles', 'user', 'view', array('ptid' => 1)));
      return;
  }
--- 31,36 ----
      //return articles_user_view();
  // TODO: make this configurable someday ?
!     // redirect to default view (with news articles)
!     pnRedirect(pnModURL('articles', 'user', 'view'));
      return;
  }
***************
*** 53,67 ****
      }
  
! // Example : show only news articles by default
      // publication type ID (for news, sections, reviews, ...)
      if (!isset($cids) && !isset($ptid)) {
          $ptid = 1;
      }
!  
      // Create output object
      $output = new pnHTML();
  
  // TODO: drop $output once we're templated
!     $row = articles_user_showpubtypes($output,$ptid);
      if (count($row) > 0) {
          $output->Text(pnML('Publication Type'));
--- 53,75 ----
      }
  
! // Example : show only frontpage-approved news articles by default
      // publication type ID (for news, sections, reviews, ...)
      if (!isset($cids) && !isset($ptid)) {
+         $ishome = 1;
+         // news articles
          $ptid = 1;
+         // frontpage
+         $status = array(3);
+     } else {
+         $ishome = 0;
+         // frontpage or approved
+         $status = array(3,2);
      }
! 
      // Create output object
      $output = new pnHTML();
  
  // TODO: drop $output once we're templated
!     $row = articles_user_showpubtypes($output,$ptid,$ishome);
      if (count($row) > 0) {
          $output->Text(pnML('Publication Type'));
***************
*** 75,80 ****
      // Load APIs
      if (!pnModAPILoad('articles', 'user')) {
!         $output->Text(_LOADFAILED);
!         return $output->GetOutput();
      }
  
--- 83,91 ----
      // Load APIs
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 104,108 ****
                                     'cids' => $cids,
                                     'ptid' => (isset($ptid) ? $ptid : null),
!                                    'numitems' => $numitems));
  
      if (!is_array($articles)) {
--- 115,121 ----
                                     'cids' => $cids,
                                     'ptid' => (isset($ptid) ? $ptid : null),
!                                    'numitems' => $numitems,
!                                    'status' => $status,
!                                    'enddate' => time()));
  
      if (!is_array($articles)) {
***************
*** 188,193 ****
  
              if (!pnModAPILoad('categories', 'visual')) {
!                 $output->Text(_LOADFAILED);
!                 return $output->GetOutput();
              }
          
--- 201,209 ----
  
              if (!pnModAPILoad('categories', 'visual')) {
!                 $msg = pnML('Unable to load #(1) #(2) API',
!                             'categories','visual');
!                 pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                               new SystemException($msg));
!                 return;
              }
          
***************
*** 270,274 ****
              $article['counter'] = ''; 
              $article['topic_icons'] = '';
!             $article['notes'] = '';
          }
          $template = $pubtypes[$article['pubtypeid']]['name'];
--- 286,290 ----
              $article['counter'] = ''; 
              $article['topic_icons'] = '';
!         //    $article['notes'] = '';
          }
          $template = $pubtypes[$article['pubtypeid']]['name'];
***************
*** 291,298 ****
      if (!pnModAPILoad('categories', 'user'))
      {
!         $msg = pnML('Unable to load (#(1))�s module (#(2))�s functions.', pnML('categories'), pnML('user'));
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!             return;
      }
      $output->Linebreak(2);
--- 307,315 ----
      if (!pnModAPILoad('categories', 'user'))
      {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'categories','user');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
      $output->Linebreak(2);
***************
*** 300,304 ****
  // TODO: make count depend on language in the future
      $output->Pager($startnum,
!                    pnModAPIFunc('articles', 'user', 'countitems', array('cids' => $cids, 'ptid' => (isset($ptid) ? $ptid : null) )),
                     pnModURL('articles',
                              'user',
--- 317,325 ----
  // TODO: make count depend on language in the future
      $output->Pager($startnum,
!                    pnModAPIFunc('articles', 'user', 'countitems',
!                                 array('cids' => $cids,
!                                       'ptid' => (isset($ptid) ? $ptid : null),
!                                       'status' => $status,
!                                       'enddate' => time())),
                     pnModURL('articles',
                              'user',
***************
*** 346,352 ****
      }
  
      // Load API
      if (!pnModAPILoad('articles', 'user')) {
!         return _LOADFAILED;
      }
  
--- 367,381 ----
      }
  
+     if (!isset($aid) || !is_numeric($aid) || $aid < 1) {
+         return _ARTICLESITEMFAILED;
+     }
+ 
      // Load API
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 370,374 ****
      //       their name and description) for this article at once
      if (!pnModAPILoad('categories', 'user')) {
!         return _LOADFAILED;
      }
      $cids = pnModAPIFunc('categories',
--- 399,407 ----
      //       their name and description) for this article at once
      if (!pnModAPILoad('categories', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'categories','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
      $cids = pnModAPIFunc('categories',
***************
*** 428,432 ****
  // TODO: to be defined
      $data['counter'] = ''; 
!     $data['notes'] = '';
  
      if ($article['pubtypeid'] == 1) {
--- 461,465 ----
  // TODO: to be defined
      $data['counter'] = ''; 
! //    $data['notes'] = '';
  
      if ($article['pubtypeid'] == 1) {
***************
*** 435,441 ****
--- 468,492 ----
          $data['date'] = strftime(_DATETIMELONG, $article['pubdate']);
          $data['summary'] = $article['summary'];
+     } else {
+         $data['summary'] = '';
      }
      $data['title'] = $article['title'];
      $data['body'] = $article['body'];
+     $data['notes'] = $article['notes'];
+ 
+     // Let any transformation hooks know that we want to transform some text.
+     // You'll need to specify the item id, and an array containing all the
+     // pieces of text that you want to transform (e.g. for autolinks, wiki,
+     // smilies, bbcode, ...).
+     list($data['title'],
+          $data['summary'],
+          $data['body'],
+          $data['notes']) = pnModCallHooks('item',
+                                           'transform',
+                                           $aid,
+                                           array($data['title'],
+                                                 $data['summary'],
+                                                 $data['body'],
+                                                 $data['notes']));
  
      // Navigation links
***************
*** 482,485 ****
--- 533,537 ----
          $month = '';
      }
+     $status = array(2,3);
  
  // QUESTION: work with user-dependent time settings or not someday ?
***************
*** 496,506 ****
      // Load API
      if (!pnModAPILoad('articles', 'user')) {
!         return _LOADFAILED;
      }
  
      // Get monthly statistics
      $monthcount = pnModAPIFunc('articles','user','getmonthcount',
!                                array('ptid' => $ptid));
!     if(!isset($monthcount)) {
          $monthcount = array();
      }
--- 548,562 ----
      // Load API
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
  
      // Get monthly statistics
      $monthcount = pnModAPIFunc('articles','user','getmonthcount',
!                                array('ptid' => $ptid, 'status' => $status));
!     if(empty($monthcount)) {
          $monthcount = array();
      }
***************
*** 534,538 ****
      // Load API
      if (!pnModAPILoad('categories', 'user')) {
!         return _LOADFAILED;
      }
  
--- 590,598 ----
      // Load API
      if (!pnModAPILoad('categories', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'categories','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 578,581 ****
--- 638,642 ----
                                     'startdate' => $startdate,
                                     'enddate' => $enddate,
+                                    'status' => $status,
                                     'fields' => array('aid','title','pubdate','pubtypeid','cids')
                                    )
***************
*** 647,657 ****
  
      if (!pnModAPILoad('articles', 'user')) {
!         return _LOADFAILED;
      }
      if (!pnModAPILoad('categories', 'user')) {
!         return _LOADFAILED;
      }
      if (!pnModAPILoad('categories', 'visual')) {
!         return _LOADFAILED;
      }
  
--- 708,730 ----
  
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
      if (!pnModAPILoad('categories', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'categories','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
      if (!pnModAPILoad('categories', 'visual')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'categories','visual');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 742,750 ****
   * show publication types
   */
! function articles_user_showpubtypes($output,$ptid = null)
  {
      if (!pnModAPILoad('articles', 'user')) {
!         $output->Text(_LOADFAILED);
!         return $output->GetOutput();
      }
  
--- 815,826 ----
   * show publication types
   */
! function articles_user_showpubtypes($output,$ptid = null,$ishome = 0)
  {
      if (!pnModAPILoad('articles', 'user')) {
!         $msg = pnML('Unable to load #(1) #(2) API',
!                     'articles','user');
!         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                        new SystemException($msg));
!         return;
      }
  
***************
*** 757,761 ****
      foreach ($pubtypes as $id => $pubtype) {
          if (isset($pubcount[$id]) && $pubcount[$id] > 0) {
!              if (isset($ptid) && $ptid == $id) {
                   $out = $output->Text($pubtype['descr']);
               } else {
--- 833,837 ----
      foreach ($pubtypes as $id => $pubtype) {
          if (isset($pubcount[$id]) && $pubcount[$id] > 0) {
!              if (isset($ptid) && $ptid == $id && $ishome == 0) {
                   $out = $output->Text($pubtype['descr']);
               } else {

Index: pnuserapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnuserapi.php,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** pnuserapi.php	2 Aug 2002 00:08:22 -0000	1.32
--- pnuserapi.php	5 Aug 2002 01:46:03 -0000	1.33
***************
*** 52,55 ****
--- 52,56 ----
   * @param $args['authorid'] the ID of the author
   * @param $args['ptid'] publication type ID (for news, sections, reviews, ...)
+  * @param $args['status'] array of requested status(es) for the articles
   * @param $args['cids'] array of category IDs for which to get articles
   *                      (for all categories don�t set it)
***************
*** 60,64 ****
   * @param $args['fields'] array with the fields to return per article
   *                        default list is : 'aid','title','summary','authorid',
!  *                        'pubdate','pubtypeid','body','cids','author'
   * @returns array
   * @return array of articles, or false on failure
--- 61,65 ----
   * @param $args['fields'] array with the fields to return per article
   *                        default list is : 'aid','title','summary','authorid',
!  *                        'pubdate','pubtypeid','notes','status','body','cids','author'
   * @returns array
   * @return array of articles, or false on failure
***************
*** 81,85 ****
      // + 'author' = user name of authorid
      $columns = array('aid','title','summary','authorid','pubdate','pubtypeid',
!                      'body','cids','author');
      if (!isset($fields)) {
          $fields = $columns;
--- 82,86 ----
      // + 'author' = user name of authorid
      $columns = array('aid','title','summary','authorid','pubdate','pubtypeid',
!                      'notes','status','body','cids','author');
      if (!isset($fields)) {
          $fields = $columns;
***************
*** 90,94 ****
      // Security check
      if (!pnSecAuthAction(0, 'articles::', '::', ACCESS_OVERVIEW)) {
!         return $articles;
      }
  
--- 91,99 ----
      // Security check
      if (!pnSecAuthAction(0, 'articles::', '::', ACCESS_OVERVIEW)) {
!         $msg = pnML('Not authorized to view #(1) items',
!                     'Article');
!         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
!                        new SystemException($msg));
!         return false;
      }
  
***************
*** 117,125 ****
          // Load API
          if (!pnModAPILoad('users', 'user')) {
!             $msg = pnML('Unable to load (#(1))�s module (#(2))�s functions.',
!                         pnML('users'), pnML('user'));
              pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                  new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!             return;
          }
          // Get the field names and LEFT JOIN ... ON ... parts from users
--- 122,130 ----
          // Load API
          if (!pnModAPILoad('users', 'user')) {
!             $msg = pnML('Unable to load #(1) #(2) API',
!                         'users','user');
              pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                            new SystemException($msg));
!             return false;
          }
          // Get the field names and LEFT JOIN ... ON ... parts from users
***************
*** 130,138 ****
          // Load API
          if (!pnModAPILoad('categories', 'user')) {
!             $msg = pnML('Unable to load (#(1))�s module (#(2))�s functions.',
!                         pnML('categories'), pnML('user'));
              pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                  new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!             return;
          }
          // Get the LEFT JOIN ... ON ...  and WHERE (!) parts from categories
--- 135,143 ----
          // Load API
          if (!pnModAPILoad('categories', 'user')) {
!             $msg = pnML('Unable to load #(1) #(2) API',
!                         'categories','user');
              pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                            new SystemException($msg));
!             return false;
          }
          // Get the LEFT JOIN ... ON ...  and WHERE (!) parts from categories
***************
*** 193,197 ****
  // TODO: make this configurable too someday ?
      // Create the ORDER BY part
!     $sql .= ' ORDER BY ' . $articlesdef['pubdate'] . ' DESC';
  
      // Run the query - finally :-)
--- 198,202 ----
  // TODO: make this configurable too someday ?
      // Create the ORDER BY part
!     $sql .= ' ORDER BY ' . $articlesdef['pubdate'] . ' DESC, ' . $articlesdef['aid'] . ' DESC';
  
      // Run the query - finally :-)
***************
*** 203,210 ****
  
      if ($dbconn->ErrorNo() != 0) {
!         $msg = 'DATABASE_ERROR :'.$sql.' -> '. $dbconn->ErrorMsg();
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!         return ;
      }
  
--- 208,216 ----
  
      if ($dbconn->ErrorNo() != 0) {
!         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
!                     'user', 'getall', 'Articles');
          pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
!                        new SystemException($msg));
!         return false;
      }
  
***************
*** 221,225 ****
              $item[$field] = $value;
          }
!         // check security
          if (pnSecAuthAction(0, 'articles::item', "$item[title]::$item[aid]", ACCESS_OVERVIEW)) {
              $articles[] = $item;
--- 227,231 ----
              $item[$field] = $value;
          }
!         // check security - don't generate an exception here
          if (pnSecAuthAction(0, 'articles::item', "$item[title]::$item[aid]", ACCESS_OVERVIEW)) {
              $articles[] = $item;
***************
*** 237,244 ****
          // Load API
          if (!pnModAPILoad('categories', 'user')) {
!             $msg = pnML('Unable to load (#(1))�s module (#(2))�s functions.', pnML('categories'), pnML('user'));
              pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                 new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
!                 return;
          }
  
--- 243,251 ----
          // Load API
          if (!pnModAPILoad('categories', 'user')) {
!             $msg = pnML('Unable to load #(1) #(2) API',
!                         'categories','user');
              pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNABLE_TO_LOAD',
!                            new SystemException($msg));
!             return false;
          }
  
***************
*** 274,289 ****
  
      // Argument check
!     if (!isset($aid)) {
!         pnSessionSetVar('errormsg', _MODARGSERROR);
          return false;
      }
  
      // Handle aid being an array
!     if (is_array($aid)) {
!         $aid = join(',', $aid);
!         $where = " IN (" . pnVarPrepForStore($aid) . ")";
!     } else {
          $where = " = " . pnVarPrepForStore($aid);
!     }
  
      // Get database setup
--- 281,301 ----
  
      // Argument check
!     if (!isset($aid) || !is_numeric($aid) || $aid < 1) {
!         $msg = pnML('Invalid #(1) for #(2) function #(3)() in module #(4)',
!                     'article ID', 'user', 'get',
!                     'Articles');
!         pnExceptionSet(PN_USER_EXCEPTION, 'BAD_PARAM',
!                        new SystemException($msg));
          return false;
      }
  
+ // TODO: is anyone using arrays for this ?
      // Handle aid being an array
! //    if (is_array($aid)) {
! //        $aid = join(',', $aid);
! //        $where = " IN (" . pnVarPrepForStore($aid) . ")";
! //    } else {
          $where = " = " . pnVarPrepForStore($aid);
! //    }
  
      // Get database setup
***************
*** 300,303 ****
--- 312,317 ----
                     $articlescolumn[pubdate],
                     $articlescolumn[pubtypeid],
+                    $articlescolumn[notes],
+                    $articlescolumn[status],
                     $articlescolumn[language]
              FROM $articlestable
***************
*** 306,309 ****
--- 320,327 ----
  
      if ($dbconn->ErrorNo() != 0) {
+         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
+                     'user', 'get', 'Articles');
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException($msg));
          return false;
      }
***************
*** 313,321 ****
      }
  
!     list($title, $summary, $body, $authorid, $pubdate, $pubtypeid, $language)
!         = $result->fields;
  
      // Security check
      if (!pnSecAuthAction(0, 'articles::item', "$title::$aid", ACCESS_READ)) {
          return false;
      }
--- 331,343 ----
      }
  
!     list($title, $summary, $body, $authorid, $pubdate, $pubtypeid, $notes,
!          $status, $language) = $result->fields;
  
      // Security check
      if (!pnSecAuthAction(0, 'articles::item', "$title::$aid", ACCESS_READ)) {
+         $msg = pnML('Not authorized to view #(1) #(2)',
+                     'Article', pnVarPrepForStore($aid));
+         pnExceptionSet(PN_USER_EXCEPTION, 'NO_PERMISSION',
+                        new SystemException($msg));
          return false;
      }
***************
*** 328,331 ****
--- 350,355 ----
                       'pubdate' => $pubdate,
                       'pubtypeid' => $pubtypeid,
+                      'notes' => $notes,
+                      'status' => $status,
                       'language' => $language);
  
***************
*** 334,388 ****
  
  /**
-  * get array of links and counts for publication types
-  * @param $args['ptid'] optional publication type ID for which you *don't*
-  *                      want a link (e.g. for the current publication type)
-  * @param $args['all'] optional flag (1) if you want to include publication
-  *                     types that don't have articles too (default 0)
-  * @returns array
-  * @return array of array('pubtitle' => descr,
-  *                        'pubid' => id,
-  *                        'publink' => link,
-  *                        'pubcount' => count)
-  */
- function articles_userapi_getpublinks($args)
- {
-     // Get arguments from argument array
-     extract($args);
- 
-     // Argument check
-     if (!isset($ptid)) {
-         $ptid = null;
-     }
-     if (!isset($all)) {
-         $all = 0;
-     }
- 
-     // Get publication types
-     $pubtypes = pnModAPIFunc('articles','user','getpubtypes');
-     $pubcount = pnModAPIFunc('articles','user','getpubcount');
- 
-     $publinks = array();
-     foreach ($pubtypes as $id => $pubtype) {
-         if ((isset($pubcount[$id]) && $pubcount[$id] > 0) || $all) {
-              $item['pubtitle'] = $pubtype['descr'];
-              $item['pubid'] = $id;
-              if (isset($ptid) && $ptid == $id) {
-                  $item['publink'] = '';
-              } else {
-                  $item['publink'] = pnModURL('articles','user','view',array('ptid' => $id));
-              }
-              if (isset($pubcount[$id])) {
-                  $item['pubcount'] = $pubcount[$id];
-              } else {
-                  $item['pubcount'] = 0;
-              }
-              $publinks[] = $item;
-         }
-     }
- 
-     return $publinks;
- }
- 
- /**
   * get the name and description of all publication types
   * @returns array
--- 358,361 ----
***************
*** 398,403 ****
      }
  
- // TODO: replace with some config option ?
- 
      // Get database setup
      list($dbconn) = pnDBGetConn();
--- 371,374 ----
***************
*** 408,416 ****
      $sql = "SELECT pn_pubtypeid,
                     pn_pubtypename,
!                    pn_pubtypedescr
              FROM $pubtypestable";
      $result = $dbconn->Execute($sql);
  
      if ($dbconn->ErrorNo() != 0) {
          return false;
      }
--- 379,392 ----
      $sql = "SELECT pn_pubtypeid,
                     pn_pubtypename,
!                    pn_pubtypedescr,
!                    pn_pubtypeconfig
              FROM $pubtypestable";
      $result = $dbconn->Execute($sql);
  
      if ($dbconn->ErrorNo() != 0) {
+         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
+                     'user', 'getpubtypes', 'Articles');
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException($msg));
          return false;
      }
***************
*** 420,426 ****
      }
      while (!$result->EOF) {
!         list($id, $name, $descr) = $result->fields;
          $pubtypes[$id] = array('name' => $name,
!                                'descr' => $descr);
          $result->MoveNext();
      }
--- 396,403 ----
      }
      while (!$result->EOF) {
!         list($id, $name, $descr, $config) = $result->fields;
          $pubtypes[$id] = array('name' => $name,
!                                'descr' => $descr,
!                                'config' => unserialize($config));
          $result->MoveNext();
      }
***************
*** 454,457 ****
--- 431,438 ----
  
      if ($dbconn->ErrorNo() != 0) {
+         $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
+                     'user', 'getpubcount', 'Articles');
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException($msg));
          return false;
      }
***************
*** 470,473 ****
--- 451,524 ----
  
  /**
+  * get array of links

Directory filter : [ all ] / postnuke_modules / articles [ 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