Browse files

Fixed SourceForge Bug #108355

Fixed a small problem in admin.pl in the topic editor where, if the topic
images directory is empty, the code would print a <SELECT> list with 0
items. It now prints a warning with a textbox containing the current
filename instead.
  • Loading branch information...
1 parent 4c40d5c commit dbf6c966bcc28c69cf312114406e00f8b558a0a2 @Xliff Xliff committed Jun 27, 2000
Showing with 47 additions and 20 deletions.
  1. +9 −0 CHANGES
  2. +19 −10 public_html/admin.pl
  3. +19 −10 themes/slashcode/htdocs/admin.pl
View
9 CHANGES
@@ -45,6 +45,15 @@ slash-1.0.6, 2000.06.xx
user's moderation is voted fair or unfair is now counted in
users_info (columns m2fair and m2unfair)
+* Fixed small bug in admin.pl which would result in bugs while saving
+ and editing topics if $I{basedir} was not derived from $I{datadir}
+ (ie, if the 2 directories were on different partitions)
+
+* If there were no images in the topic images directory, the topic
+ editor would display a select list with no items. Now, a warning
+ is displayed and the user is given an input box filled with the
+ current filename.
+
slash-1.0.5, 2000.06.13
-----------------------
View
29 public_html/admin.pl
@@ -798,7 +798,7 @@ sub topicEd {
return if $I{U}{aseclev} < 1;
my ($tid, $width, $height, $alttext, $image, @available_images);
- opendir(DIR,"$I{datadir}/public_html/images/topics");
+ opendir(DIR,"$I{basedir}/images/topics");
@available_images = grep(!/^\./, readdir(DIR));
closedir(DIR);
@@ -831,19 +831,28 @@ sub topicEd {
<BR>Alt Text<BR>
<INPUT TYPE="TEXT" NAME="alttext" VALUE="$alttext"><BR>
<BR>Image<BR>
- <SELECT name="image">
EOT
- print qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
- for(@available_images) {
- my ($selected);
- $selected = "SELECTED" if ($_ eq $image);
- print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
- $selected = '';
+ if (@available_images) {
+ print qq|<SELECT name="image">|;
+ qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
+ for(@available_images) {
+ my ($selected);
+ $selected = "SELECTED" if ($_ eq $image);
+ print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
+ $selected = '';
+ }
+ print '</SELECT>';
+ } else {
+ # If we don't have images in the proper place, print a message
+ # and use a regular text input field.
+ print <<EOT;
+<P>No images were found in the topic images directory (&lt;basedir&gt;/images/topics).<BR>
+<INPUT TYPE="TEXT" NAME="image" VALUE="$image"><BR><BR>
+EOT
}
print <<EOT;
- </SELECT>
<INPUT TYPE="SUBMIT" NAME="topicsave" VALUE="Save Topic">
<INPUT TYPE="SUBMIT" NAME="topicdelete" VALUE="Delete Topic">
EOT
@@ -869,7 +878,7 @@ sub topicSave {
if ($I{F}{tid}) {
my($rows) = sqlSelect('count(*)', 'topics', 'tid=' . $I{dbh}->quote($I{F}{tid}));
if (!$I{F}{width} && !$I{F}{height}) {
- @{ $I{F} }{'width', 'height'} = imgsize("$I{datadir}/public_html/images/topics/$I{F}{image}");
+ @{ $I{F} }{'width', 'height'} = imgsize("$I{basedir}/images/topics/$I{F}{image}");
}
if($rows == 0 ) {
sqlInsert('topics', {
View
29 themes/slashcode/htdocs/admin.pl
@@ -798,7 +798,7 @@ sub topicEd {
return if $I{U}{aseclev} < 1;
my ($tid, $width, $height, $alttext, $image, @available_images);
- opendir(DIR,"$I{datadir}/public_html/images/topics");
+ opendir(DIR,"$I{basedir}/images/topics");
@available_images = grep(!/^\./, readdir(DIR));
closedir(DIR);
@@ -831,19 +831,28 @@ sub topicEd {
<BR>Alt Text<BR>
<INPUT TYPE="TEXT" NAME="alttext" VALUE="$alttext"><BR>
<BR>Image<BR>
- <SELECT name="image">
EOT
- print qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
- for(@available_images) {
- my ($selected);
- $selected = "SELECTED" if ($_ eq $image);
- print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
- $selected = '';
+ if (@available_images) {
+ print qq|<SELECT name="image">|;
+ qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
+ for(@available_images) {
+ my ($selected);
+ $selected = "SELECTED" if ($_ eq $image);
+ print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
+ $selected = '';
+ }
+ print '</SELECT>';
+ } else {
+ # If we don't have images in the proper place, print a message
+ # and use a regular text input field.
+ print <<EOT;
+<P>No images were found in the topic images directory (&lt;basedir&gt;/images/topics).<BR>
+<INPUT TYPE="TEXT" NAME="image" VALUE="$image"><BR><BR>
+EOT
}
print <<EOT;
- </SELECT>
<INPUT TYPE="SUBMIT" NAME="topicsave" VALUE="Save Topic">
<INPUT TYPE="SUBMIT" NAME="topicdelete" VALUE="Delete Topic">
EOT
@@ -869,7 +878,7 @@ sub topicSave {
if ($I{F}{tid}) {
my($rows) = sqlSelect('count(*)', 'topics', 'tid=' . $I{dbh}->quote($I{F}{tid}));
if (!$I{F}{width} && !$I{F}{height}) {
- @{ $I{F} }{'width', 'height'} = imgsize("$I{datadir}/public_html/images/topics/$I{F}{image}");
+ @{ $I{F} }{'width', 'height'} = imgsize("$I{basedir}/images/topics/$I{F}{image}");
}
if($rows == 0 ) {
sqlInsert('topics', {

0 comments on commit dbf6c96

Please sign in to comment.