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 NoticeDirectory filter : [ all ] / postnuke_modules / articles [ view in CVS ]
| Date | Directory [filter] | File(s) [view] | Author [filter] |
| 28 Jul 2002 20:42:07 | postnuke_modules/articles | pninit.php,1.15,1.16 | Mike |
| add default categories & configuration | |||
Update of /home/cvsroot/postnuke_modules/articles
In directory ns7.hostnuke.net:/tmp/cvs-serv3938
Modified Files:
pninit.php
Log Message:
add default categories & configuration
Index: pninit.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pninit.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** pninit.php 27 Jul 2002 17:23:12 -0000 1.15
--- pninit.php 28 Jul 2002 20:42:05 -0000 1.16
***************
*** 29,32 ****
--- 29,40 ----
function articles_init()
{
+
+ // make sure the categories module is activated first
+ if (!pnModAvailable('categories') || !pnModAPILoad('categories','admin')) {
+ // Report failed initialisation attempt
+ pnSessionSetVar('errormsg', 'This module needs the "categories" utility module to work properly. Please initialize and activate that module first...');
+ return false;
+ }
+
// Get database information
list($dbconn) = pnDBGetConn();
***************
*** 116,120 ****
// TODO: the following tables are unused (cfr. RFC 1 for more generic approach)
!
$articlespagestable = $pntable['articles_pages'];
$articlespagescolumn = &$pntable['articles_pages_column'];
--- 124,128 ----
// TODO: the following tables are unused (cfr. RFC 1 for more generic approach)
! /*
$articlespagestable = $pntable['articles_pages'];
$articlespagescolumn = &$pntable['articles_pages_column'];
***************
*** 149,158 ****
return false;
}
!
// Set up module variables
pnModSetVar('articles', 'itemsperpage', 10);
- pnModSetVar('articles', 'number_of_categories', 2);
pnModSetVar('articles', 'SupportShortURLs', 0);
// Initialisation successful
return true;
--- 157,212 ----
return false;
}
! */
// Set up module variables
pnModSetVar('articles', 'itemsperpage', 10);
pnModSetVar('articles', 'SupportShortURLs', 0);
+ // some starting categories
+ $articlecategories = array();
+ $articlecategories[] = array('name' => 'Generic1',
+ 'description' => 'Generic Category 1',
+ 'children' => array('Generic1 Sub1',
+ 'Generic1 Sub2'));
+ $articlecategories[] = array('name' => 'Generic2',
+ 'description' => 'Generic Category 2',
+ 'children' => array('Generic2 Sub1',
+ 'Generic2 Sub2'));
+ $articlecategories[] = array('name' => 'Topics',
+ 'description' => 'News Topics (.7x style)',
+ 'children' => array('Topic 1',
+ 'Topic 2'));
+ $articlecategories[] = array('name' => 'Categories',
+ 'description' => 'News Categories (.7x style)',
+ 'children' => array('Category 1',
+ 'Category 2'));
+ $articlecategories[] = array('name' => 'Sections',
+ 'description' => 'Sections (.7x style)',
+ 'children' => array('Section 1',
+ 'Section 2'));
+ foreach (array_reverse($articlecategories,TRUE) as $category) {
+ $cid[$category['name']] = pnModAPIFunc('categories',
+ 'admin',
+ 'create',
+ Array('name' => $category['name'],
+ 'description' => $category['description'],
+ 'parent_id' => 0));
+ foreach (array_reverse($category['children']) as $child) {
+ $cid[$child] = pnModAPIFunc('categories',
+ 'admin',
+ 'create',
+ Array('name' => $child,
+ 'description' => $child,
+ 'parent_id' => $cid[$category['name']]));
+ }
+ }
+
+ // set default configurations
+ pnModSetVar('articles', 'number_of_categories', 2);
+ pnModSetVar('articles','cids',$cid['Generic1'] . ';' . $cid['Generic2']);
+ pnModSetVar('articles', 'number_of_categories.1', 2);
+ pnModSetVar('articles','cids.1',$cid['Topics'] . ';' . $cid['Categories']);
+ pnModSetVar('articles', 'number_of_categories.2', 1);
+ pnModSetVar('articles','cids.2',$cid['Sections']);
+
// Initialisation successful
return true;
***************
*** 168,230 ****
case 1.0:
// Code to upgrade from version 1.0 goes here
-
- // TODO: remove for release
-
- // Get database information
- list($dbconn) = pnDBGetConn();
- $pntable = pnDBGetTables();
-
- // Create tables
- $articlestable = $pntable['articles'];
- $articlescolumn = &$pntable['articles_column'];
- $sql = "ALTER TABLE $articlestable
- ADD COLUMN $articlescolumn[pubtypeid] INT(4) NOT NULL DEFAULT '1'";
- $dbconn->Execute($sql);
-
- // Check database result
- if ($dbconn->ErrorNo() != 0) {
- // Report failed upgrade attempt
- return false;
- }
-
- // Create tables
- $pubtypestable = $pntable['publication_types'];
- $pubtypescolumn = &$pntable['publication_types_column'];
- $sql = "CREATE TABLE $pubtypestable (
- $pubtypescolumn[pubtypeid] INT(4) NOT NULL AUTO_INCREMENT,
- $pubtypescolumn[pubtypename] VARCHAR(30) NOT NULL,
- $pubtypescolumn[pubtypedescr] VARCHAR(255) NOT NULL DEFAULT '',
- PRIMARY KEY(pn_pubtypeid))";
- $dbconn->Execute($sql);
-
- // Check database result
- if ($dbconn->ErrorNo() != 0) {
- // Report failed upgrade attempt
- return false;
- }
-
- // 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);
-
- // Check database result
- if ($dbconn->ErrorNo() != 0) {
- // Report failed upgrade attempt
- return false;
- }
- }
-
break;
case 2.0:
--- 222,225 ----
***************
*** 275,279 ****
if ($dbconn->ErrorNo() != 0) {
// Report failed deletion attempt
! return false;
}
--- 270,274 ----
if ($dbconn->ErrorNo() != 0) {
// Report failed deletion attempt
! // return false;
}
***************
*** 284,294 ****
if ($dbconn->ErrorNo() != 0) {
// Report failed deletion attempt
! return false;
}
// Delete module variables
pnModDelVar('articles', 'itemsperpage');
- pnModDelVar('articles', 'number_of_categories');
pnModDelVar('articles', 'SupportShortURLs');
// Deletion successful
--- 279,295 ----
if ($dbconn->ErrorNo() != 0) {
// Report failed deletion attempt
! // return false;
}
// Delete module variables
pnModDelVar('articles', 'itemsperpage');
pnModDelVar('articles', 'SupportShortURLs');
+
+ pnModDelVar('articles', 'number_of_categories');
+ pnModDelVar('articles', 'cids');
+ pnModDelVar('articles', 'number_of_categories.1');
+ pnModDelVar('articles', 'cids.1');
+ pnModDelVar('articles', 'number_of_categories.2');
+ pnModDelVar('articles', 'cids.2');
// Deletion successful
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 |