0.15_04 commit r0_15_04
authorTony Cook <tony@develop-help.com>
Mon, 10 Jan 2005 00:06:22 +0000 (00:06 +0000)
committertony <tony@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Mon, 10 Jan 2005 00:06:22 +0000 (00:06 +0000)
Makefile
site/cgi-bin/modules/BSE/DB/Mysql.pm
site/cgi-bin/modules/BSE/Edit/Article.pm
site/cgi-bin/modules/BSE/Edit/Catalog.pm
site/cgi-bin/modules/BSE/Edit/Product.pm
site/docs/bse.pod
site/docs/config.pod
site/templates/admin/edit_1.tmpl
site/templates/admin/edit_catalog.tmpl
site/templates/admin/edit_product.tmpl
test.cfg

index 8c2bb512f322e575fe2967f4396900875fc238af..59f7380518a9446216efaef00437cbfd125da229 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.15_03
+VERSION=0.15_04
 DISTNAME=bse-$(VERSION)
 DISTBUILD=$(DISTNAME)
 DISTTAR=../$(DISTNAME).tar
index 45f9ed1343f6e8a8dc256cdeb2feff8125925eba..fdea2adb816df117a4ec9f27a0aa04a2bfa23201 100644 (file)
@@ -42,7 +42,7 @@ EOS
 select ar.* from article ar, other_parents op
    where op.childId = ar.id 
      and op.parentId = ? 
-     and date_format(?, '%Y%m%d') between date_format(op.release, '%Y%m%d') and date_format(op.expire, '%Y%m%d')
+     and date_format(?, '%Y%m%d') between date_format(op.release, '%Y%m%d') and date_format(op.expire, '%Y%m%d') and listed <> 0
 EOS
    'Articles.ids'=>'select id from article',
 
index 70bcce795fc2b35ae7eb39433bde68ffa535440c..863ba07eea0a74464fdc62a760d2bff96263954d 100644 (file)
@@ -2679,6 +2679,9 @@ sub default_value {
   my $value = $req->cfg->entry($section, $col);
   defined($value) and return $value;
 
+  $value = $self->type_default_value($req, $col);
+  defined $value and return $value;
+
   exists $defaults{$col} and return $defaults{$col};
 
   $col eq 'release' and return now_sqldate();
@@ -2704,6 +2707,12 @@ sub default_value {
   return;
 }
 
+sub type_default_value {
+  my ($self, $req, $col) = @_;
+
+  return $req->cfg->entry('article defaults', $col);
+}
+
 sub flag_sections {
   return ( 'article flags' );
 }
index fac07fe3a1cc707a594fdc0d34adf2f9a0f61add..4e45dd6f9e056a4b3af363eec91bf5f0b072ab2e 100644 (file)
@@ -112,5 +112,14 @@ sub flag_sections {
   return ( 'catalog flags', $self->SUPER::flag_sections );
 }
 
+sub type_default_value {
+  my ($self, $req, $col) = @_;
+
+  my $value = $req->cfg->entry('catalog defaults', $col);
+  defined $value and return $value;
+
+  return $self->SUPER::type_default_value($req, $col);
+}
+
 1;
 
index e13d65883aef403958bbc4ba8042af232d539312..515e1c4e677680e13613c08093e1a0e0e7ecf966 100644 (file)
@@ -341,4 +341,13 @@ sub default_value {
   return;
 }
 
+sub type_default_value {
+  my ($self, $req, $col) = @_;
+
+  my $value = $req->cfg->entry('product defaults', $col);
+  defined $value and return $value;
+
+  return $self->SUPER::type_default_value($req, $col);
+}
+
 1;
index de82da8aa252eed8da617fb620dc78a72ff055f0..143a87efd7b8001b04fe809ab4facb1ca5fee17a 100644 (file)
@@ -10,6 +10,21 @@ Maybe I'll add some other bits here.
 
 =head1 CHANGES
 
+=head2 0.15_04
+
+=over
+
+=item *
+
+the allkids iterator no longer lists unlisted stepkids
+
+=item *
+
+added the [article defaults], [product defaults] and [catalog
+defaults] configuration file sections, see L<config.pod> for details.
+
+=back
+
 =head2 0.15_03
 
 =over
index 9efb45ba490288b51d2861e6bca100a72b03e96e..3555708336068a3d6142b18f8c0c24100f58696d 100644 (file)
@@ -1136,6 +1136,29 @@ digits for your own use.
 Use the id of the flag as the key, and a description of the flag as
 it's value.
 
+=head2 [article defaults]
+
+=head2 [catalog defaults]
+
+=head2 [product defaults]
+
+These sections contain defaults values for the corresponding article
+types.
+
+Each key is the name of a column for the article type.
+
+If an entry is not found in [catalog defaults] then [article defaults]
+is also checked.
+
+If an entry is not found in [product defaults] then [article defaults]
+is also checked.
+
+These sections are checked B<after> the C<[children of >I<id>C<]> and
+C<[level >I<level>C<]> sections.
+
+These defaults are used when creating an article where no value is
+supplied, they can also be accessed via the <:default I<name>:> tag.
+
 =head1 AUTHOR
 
 Tony Cook <tony@develop-help.com>
index 0080cc0f76bd8035d4e847c67c145c105a077421..db3df38da2731219b49d7f9248b98e84c6d7e10e 100644 (file)
@@ -72,7 +72,7 @@
             <th nowrap="nowrap" bgcolor="#FFFFFF" align="left">Title: 
             </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-            <:ifFieldPerm title:><input type="text" name="title" maxlength="<:cfg fields title_size 255:>" size="64" value="<: old title article title :>" />
+            <:ifFieldPerm title:><input type="text" name="title" maxlength="<:cfg fields title_size 255:>" size="64" value="<: old title default title :>" />
             <:or:><:default title:><:eif:></td>
             <td nowrap="nowrap" bgcolor="#FFFFFF"><:help edit title:> <:error_img title:></td>
           </tr>
@@ -85,7 +85,7 @@
           <tr> 
             <th valign="top" nowrap="nowrap" bgcolor="#FFFFFF" align="left"> Body: </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:if FieldPerm body:><textarea name="body" rows="10" cols="60" wrap="virtual"><: old body article body :></textarea>
+              <:if FieldPerm body:><textarea name="body" rows="10" cols="60" wrap="virtual"><: old body default body :></textarea>
               <:or FieldPerm:><:bodytext article body:><:eif FieldPerm:>
             </td>
             <td valign="top" nowrap="nowrap" bgcolor="#FFFFFF"><:help body body:> <:error_img body:></td>
                  <tr> 
             <th nowrap="nowrap" bgcolor="#FFFFFF" align="left">Release date:</th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:if FieldPerm release:><input type="text" name="release" value="<: old release date "%d/%m/%Y" article release :>" size="10" maxlength="10" />
+              <:if FieldPerm release:><input type="text" name="release" value="<: old release date "%d/%m/%Y" default release :>" size="10" maxlength="10" />
               (dd/mm/yyyy<: ifNew :> - default is today<: or :><: eif :>)<:or FieldPerm:><: date "%d/%m/%Y" article release :><:eif FieldPerm:></td>
             <td nowrap="nowrap" bgcolor="#FFFFFF"><:help edit release:> <:error_img release:></td>
           </tr>
           <tr> 
             <th nowrap="nowrap" bgcolor="#FFFFFF" align="left">Expiry date:</th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:if FieldPerm expire:><input type="text" name="expire" value="<: old expire date "%d/%m/%Y" article expire :>" size="10" maxlength="10" />
+              <:if FieldPerm expire:><input type="text" name="expire" value="<: old expire date "%d/%m/%Y" default expire :>" size="10" maxlength="10" />
               (dd/mm/yyyy - <: ifNew :>default is never, <: or :><: eif :>blank 
               for never expires)<:or FieldPerm:><: date "%d/%m/%Y" article expire :><:eif FieldPerm:></td>
             <td nowrap="nowrap" bgcolor="#FFFFFF"><:help edit expire:> <:error_img expire:></td>
           <tr> 
             <th nowrap="nowrap" bgcolor="#FFFFFF" align="left">Summary length:</th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:if FieldPerm summaryLength:><input type="text" name="summaryLength" size="10" maxlength="10" value="<: old summaryLength article summaryLength :>" />
+              <:if FieldPerm summaryLength:><input type="text" name="summaryLength" size="10" maxlength="10" value="<: old summaryLength default summaryLength :>" />
               (in characters - <: ifNew :>default inherited from <:parentType:>, <: or :><: eif :> 
               zero for no summary)<:or FieldPerm:><: article summaryLength :><:eif FieldPerm:></td>
             <td nowrap="nowrap" bgcolor="#FFFFFF"><:help edit summary:> <:error_img summaryLength:></td>
           <tr> 
             <th nowrap="nowrap" bgcolor="#FFFFFF" align="left">Display threshold:</th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:ifFieldPerm threshold:><input type="text" name="threshold" size="10" maxlength="10" value="<: old threshold article threshold :>" /><:or:><: article threshold :><:eif:>
+              <:ifFieldPerm threshold:><input type="text" name="threshold" size="10" maxlength="10" value="<: old threshold default threshold :>" /><:or:><: article threshold :><:eif:>
             </td>
             <td nowrap="nowrap" bgcolor="#FFFFFF"><:help edit threshold:> <:error_img
             threshold:></td>
           <tr> 
             <th nowrap="nowrap" bgcolor="#FFFFFF" align="left">Keywords:</th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:ifFieldPerm keyword:><input type="text" name="keyword" maxlength="255" size="60" value="<: old keyword article keyword :>" />
+              <:ifFieldPerm keyword:><input type="text" name="keyword" maxlength="255" size="60" value="<: old keyword default keyword :>" />
               (comma separated)<:or:><: article threshold :><:eif:></td>
             <td nowrap="nowrap" bgcolor="#FFFFFF"><:help edit keywords:> <:error_img keyword:></td>
           </tr>
index 5580f94a96b970bb098544e4545b16b002c824f4..a40dceb9112581a673af1460432b63e9bf2d6b93 100644 (file)
           <tr> 
             <th bgcolor="#FFFFFF" nowrap align="left"> Catalog title: </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:ifFieldPerm title:><input type="text" name="title" maxlength="64" size="64" value="<: old title article title :>"><:or:><:default title:><:eif:>
+              <:ifFieldPerm title:><input type="text" name="title" maxlength="64" size="64" value="<: old title default title :>"><:or:><:default title:><:eif:>
             </td>
             <td nowrap bgcolor="#FFFFFF"><:help catalog title:> <:error_img title:></td>
           </tr>
           <tr> 
             <th valign="top" bgcolor="#FFFFFF" nowrap align="left"> Body:</th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:ifFieldPerm body:><textarea name="body" rows="10" cols="60" wrap="virtual"><: old body article body :></textarea><:or:><:bodytext article body:><:eif:>
+              <:ifFieldPerm body:><textarea name="body" rows="10" cols="60" wrap="virtual"><: old body default body :></textarea><:or:><:bodytext article body:><:eif:>
             </td>
             <td valign="top" nowrap bgcolor="#FFFFFF"><:help body body:> <:error_img
             body:></td>
           <tr> 
             <th bgcolor="#FFFFFF" nowrap align="left"> Release date: </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:if FieldPerm release:><input type="text" name="release" value="<: old release date "%d/%m/%Y" article release :>" size="10" maxlength="10">
+              <:if FieldPerm release:><input type="text" name="release" value="<: old release date "%d/%m/%Y" default release :>" size="10" maxlength="10">
               (dd/mm/yyyy<: ifNew :> - default is today<: or :><: eif :>)<:or FieldPerm:><: date "%d/%m/%Y" article release :><:eif FieldPerm:></td>
             <td nowrap bgcolor="#FFFFFF"><:help catalog release:> <:error_img release:></td>
           </tr>
           <tr> 
             <th bgcolor="#FFFFFF" nowrap align="left"> Expiry date: </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:if FieldPerm expire:><input type="text" name="expire" value="<: old expire date "%d/%m/%Y" article expire :>" size="10" maxlength="10">
+              <:if FieldPerm expire:><input type="text" name="expire" value="<: old expire date "%d/%m/%Y" default expire :>" size="10" maxlength="10">
               (dd/mm/yyyy - <: ifNew :>default is never, <: or :><: eif :>blank 
               for never expires)<:or FieldPerm:><: date "%d/%m/%Y" article expire :><:eif FieldPerm:></td>
             <td nowrap bgcolor="#FFFFFF"><:help catalog expire:> <:error_img expire:></td>
           <tr> 
             <th bgcolor="#FFFFFF" nowrap align="left"> Summary length: </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:if FieldPerm summaryLength:><input type="text" name="summaryLength" size="10" maxlength="10" value="<: old summaryLength article summaryLength :>">
+              <:if FieldPerm summaryLength:><input type="text" name="summaryLength" size="10" maxlength="10" value="<: old summaryLength default summaryLength :>">
               (in characters - default inherited from parent catalog or shop, zero 
               for no summary)<:or FieldPerm:><: article summaryLength :><:eif FieldPerm:></td>
             <td nowrap bgcolor="#FFFFFF"><:help catalog summary:> <:error_img summaryLength:></td>
           <tr> 
             <th bgcolor="#FFFFFF" nowrap align="left"> Display threshold: </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:ifFieldPerm threshold:><input type="text" name="threshold" size="10" maxlength="10" value="<: old threshold article threshold :>"><:or:><: article threshold :><:eif:>
+              <:ifFieldPerm threshold:><input type="text" name="threshold" size="10" maxlength="10" value="<: old threshold default threshold :>"><:or:><: article threshold :><:eif:>
             </td>
             <td nowrap bgcolor="#FFFFFF"><:help catalog threshold:> <:error_img threshold:></td>
           </tr>
           <tr> 
             <th bgcolor="#FFFFFF" nowrap align="left"> Keywords: </th>
             <td bgcolor="#FFFFFF" width="100%"> 
-              <:ifFieldPerm keyword:><input type="text" name="keyword" maxlength="255" size="60" value="<: old keyword article keyword :>"><:or:><: article threshold :><:eif:>
+              <:ifFieldPerm keyword:><input type="text" name="keyword" maxlength="255" size="60" value="<: old keyword default keyword :>"><:or:><: article threshold :><:eif:>
               (comma separated) </td>
             <td nowrap bgcolor="#FFFFFF"><:help catalog keywords:> <:error_img keyword:></td>
           </tr>
index 8104a2e2aa1c7f3d3b4a140527ede6a49876c040..27c4f4bbcf72859f8fe3fd563dd838bf6dffb3fc 100644 (file)
           </tr>
                  <tr> 
             <th align="left" bgcolor="#FFFFFF">Title*:</th>
-            <td bgcolor="#FFFFFF"><:ifFieldPerm title:><input type="text" name="title" value="<:old title:>" size="60"><:or:><:product title:><:eif:> </td>
+            <td bgcolor="#FFFFFF"><:ifFieldPerm title:><input type="text" name="title" value="<:old title default title:>" size="60"><:or:><:product title:><:eif:> </td>
             <td nowrap bgcolor="#FFFFFF"><:help product title:> <:error_img title:></td>
           </tr>
           <tr> 
             <th nowrap align="left" bgcolor="#FFFFFF">Summary*:</th>
-            <td nowrap bgcolor="#FFFFFF"><:ifFieldPerm summary:><input type="text" name="summary" value="<:old summary:>" size=60><:or:><:product summary:><:eif:> </td>
+            <td nowrap bgcolor="#FFFFFF"><:ifFieldPerm summary:><input type="text" name="summary" value="<:old summary default summary:>" size=60><:or:><:product summary:><:eif:> </td>
             <td nowrap bgcolor="#FFFFFF"><:help product summary:> <:error_img
             summary:></td>
           </tr>
           <tr> 
             <th align="left" bgcolor="#FFFFFF" valign="top"> Body:</th>
             <td bgcolor="#FFFFFF"> 
-              <:ifFieldPerm body:><textarea name=body rows=15 cols=60 wrap=virtual><:old body product body:></textarea><:or:><:bodytext product body:><:eif:>
+              <:ifFieldPerm body:><textarea name=body rows=15 cols=60 wrap=virtual><:old body default body:></textarea><:or:><:bodytext product body:><:eif:>
             </td>
             <td nowrap bgcolor="#FFFFFF" valign="top"><:help body body:> <:error_img
             body:></td>
             <th nowrap align="left" bgcolor="#FFFFFF">Lead time:</th>
             <td nowrap bgcolor="#FFFFFF"> 
               <:ifFieldPerm leadTime:>
-              <input type="text" name="leadTime" value="<:old leadTime:>" size=5><:or:><:product leadTime:><:eif:>
+              <input type="text" name="leadTime" value="<:old leadTime default leadTime:>" size=5><:or:><:product leadTime:><:eif:>
               days</td>
             <td nowrap bgcolor="#FFFFFF"><:help product leadtime:> <:error_img
             leadTime:></td>
           <tr> 
             <th align="left" bgcolor="#FFFFFF"><:cfg "product fields" retailPrice "Retail price":>:</th>
             <td bgcolor="#FFFFFF">$ 
-              <:ifFieldPerm retailPrice:><input type="text" name="retailPrice" value="<:old retailPrice money product retailPrice:>" size=7>
+              <:ifFieldPerm retailPrice:><input type="text" name="retailPrice" value="<:old retailPrice money default retailPrice:>" size=7>
               (0.00)<:or:><:money product retailPrice:><:eif:> </td>
             <td nowrap bgcolor="#FFFFFF"><:help product retail:> <:error_img retailPrice:></td>
           </tr>
           <tr> 
             <th align="left" bgcolor="#FFFFFF">Wholesale price:</th>
             <td bgcolor="#FFFFFF">$ 
-              <:ifFieldPerm wholesalePrice:><input type="text" name="wholesalePrice" value="<:old wholesalePrice money product wholesalePrice:>" size=7>
+              <:ifFieldPerm wholesalePrice:><input type="text" name="wholesalePrice" value="<:old wholesalePrice money default wholesalePrice:>" size=7>
               (0.00)<:or:><:money product wholesalePrice:><:eif:></td>
             <td nowrap bgcolor="#FFFFFF"><:help product wholesale:> <:error_img wholesalePrice:></td>
           </tr>
           <tr> 
             <th align="left" bgcolor="#FFFFFF">GST:</th>
             <td bgcolor="#FFFFFF">$ 
-              <:ifFieldPerm gst:><input type="text" name="gst" value="<:old gst money product gst:>" size=7>
+              <:ifFieldPerm gst:><input type="text" name="gst" value="<:old gst money default gst:>" size=7>
               (0.00)<:or:><:money product gst:><:eif:></td>
             <td nowrap bgcolor="#FFFFFF"><:help product gst:> <:error_img gst:></td>
           </tr>
           <tr> 
             <th align="left" bgcolor="#FFFFFF">Release date:</th>
             <td bgcolor="#FFFFFF"> 
-              <:ifFieldPerm release:><input type="text" name="release" value="<:old release date "%d/%m/%Y" product release:>" size=11>
+              <:ifFieldPerm release:><input type="text" name="release" value="<:old release date "%d/%m/%Y" default release:>" size=11>
               (dd/mm/yyyy)<:or:><:date "%d/%m/%Y" product release:><:eif:></td>
             <td nowrap bgcolor="#FFFFFF"><:help product release:> <:error_img
             release:></td>
           <tr> 
             <th align="left" bgcolor="#FFFFFF">Expiry date:</th>
             <td bgcolor="#FFFFFF"> 
-              <:ifFieldPerm expire:><input type="text" name="expire" value="<:old expire date "%d/%m/%Y" product expire:>" size=11>
+              <:ifFieldPerm expire:><input type="text" name="expire" value="<:old expire date "%d/%m/%Y" default expire:>" size=11>
               (dd/mm/yyyy)<:or:><:date "%d/%m/%Y" product expire:><:eif:></td>
             <td nowrap bgcolor="#FFFFFF"><:help product expire:> <:error_img
             expire:></td>
           <tr> 
             <th nowrap align="left" bgcolor="#FFFFFF">Summary length:</th>
             <td nowrap bgcolor="#FFFFFF"> 
-              <:ifFieldPerm summaryLength:><input type="text" name="summaryLength" size="10" maxlength="10" value="<:old summaryLength product summaryLength:>"><:or:><:product summaryLength:><:eif:>
+              <:ifFieldPerm summaryLength:><input type="text" name="summaryLength" size="10" maxlength="10" value="<:old summaryLength default summaryLength:>"><:or:><:product summaryLength:><:eif:>
             </td>
             <td nowrap bgcolor="#FFFFFF"><:help product summary:> <:error_img
             summaryLength:></td>
           <tr> 
             <th nowrap align="left" bgcolor="#FFFFFF">Display threshold:</th>
             <td nowrap bgcolor="#FFFFFF"> 
-              <:ifFieldPerm threshold:><input type="text" name="threshold" size=10 maxlength=10 value="<:old threshold product threshold:>"><:or:><:product threshold:><:eif:>
+              <:ifFieldPerm threshold:><input type="text" name="threshold" size=10 maxlength=10 value="<:old threshold default threshold:>"><:or:><:product threshold:><:eif:>
             </td>
             <td nowrap bgcolor="#FFFFFF"><:help product threshold:> <:error_img
             threshold:></td>
           <tr> 
             <th align="left" bgcolor="#FFFFFF">Options:</th>
             <td bgcolor="#FFFFFF"> 
-              <:ifFieldPerm options:><input type="text" name="options" value="<:old options product options:>" size=30>
+              <:ifFieldPerm options:><input type="text" name="options" value="<:old options default options:>" size=30>
               (<:alloptions:>)<:or:><:product options:><:eif:> </td>
             <td bgcolor="#FFFFFF"><:help product options:> <:error_img options:></td>
           </tr>
index 822615a37d92c869bbbea09d06f9d807b25053cf..59bae7c0ba223a399e8a37766f18342c98d3702f 100644 (file)
--- a/test.cfg
+++ b/test.cfg
@@ -103,3 +103,7 @@ test formmail validation.company_description=Organization
 test formmail validation.company_required=0
 
 site.secureadmin=1
+article defaults.title=<set the article title>
+article defaults.body=<set the body>
+product defaults.title=<set the product title>
+catalog defaults.title=<set the catalog title>