Skip to content

Commit

Permalink
Undo a large commit earlier today, at 2002/07/17 16:04:57 GMT (as wel…
Browse files Browse the repository at this point in the history
…l as

a few other changes committed today), while keeping the other changes made
today.  Tag before *this* commit is "rb20020717a" (rb for "rollback"),
tag after this commit will be "rb20020717b".
  • Loading branch information
jamiemccarthy committed Jul 17, 2002
1 parent a2ed0df commit b92be62
Show file tree
Hide file tree
Showing 29 changed files with 237 additions and 350 deletions.
20 changes: 7 additions & 13 deletions Slash/DB/MySQL/MySQL.pm
Expand Up @@ -2409,23 +2409,17 @@ sub updateFormkeyVal {
# use this in case the function you call fails prior to updateFormkey # use this in case the function you call fails prior to updateFormkey
# but after updateFormkeyVal # but after updateFormkeyVal
sub resetFormkey { sub resetFormkey {
my($self, $formkey, $formname) = @_; my($self, $formkey) = @_;


my $constants = getCurrentStatic(); my $constants = getCurrentStatic();


# reset the formkey to 0, and reset the ts # reset the formkey to 0, and reset the ts

my $updated = $self->sqlUpdate("formkeys", {
my $update_ref = { -value => 0,
-value => 0, -idcount => '(idcount -1)',
-idcount => '(idcount -1)', ts => time(),
ts => time(), submit_ts => '0',
submit_ts => '0', }, "formkey=" . $self->sqlQuote($formkey));
};
$update_ref->{formname} = $formname if $formname;

my $updated = $self->sqlUpdate("formkeys",
$update_ref,
"formkey=" . $self->sqlQuote($formkey));


print STDERR "RESET formkey $updated\n" if $constants->{DEBUG}; print STDERR "RESET formkey $updated\n" if $constants->{DEBUG};
return($updated); return($updated);
Expand Down
3 changes: 2 additions & 1 deletion Slash/Slash.pm
Expand Up @@ -932,7 +932,8 @@ hashref of author data, and hashref of topic data.
=cut =cut


sub displayStory { sub displayStory {
my($sid, $full, $other) = @_; # caller is the pagename of the calling script
my($sid, $full, $other) = @_; # , $caller no longer needed? -- pudge


my $slashdb = getCurrentDB(); my $slashdb = getCurrentDB();
my $story = $slashdb->getStory($sid); my $story = $slashdb->getStory($sid);
Expand Down
4 changes: 2 additions & 2 deletions Slash/Utility/Access/Access.pm
Expand Up @@ -288,12 +288,12 @@ sub formkeyHandler {
$slashdb->updateFormkeyId($formname, $formkey, $user->{uid}, $form->{rlogin}, $form->{upasswd}); $slashdb->updateFormkeyId($formname, $formkey, $user->{uid}, $form->{rlogin}, $form->{upasswd});
} elsif ($formkey_op eq 'valid_check') { } elsif ($formkey_op eq 'valid_check') {
my $valid = $slashdb->validFormkey($formname, $options); my $valid = $slashdb->validFormkey($formname, $options);
print STDERR "formkeyHandler valid_check formname $formname valid '$valid'\n"; #print STDERR "formkeyHandler valid_check valid '$valid'\n";
if ($valid eq 'ok') { if ($valid eq 'ok') {
# All is well. # All is well.
} else { } else {
$msg = formkeyError($valid, $formname); $msg = formkeyError($valid, $formname);
print STDERR "formkeyHandler valid_check valid '$valid' formname '$formname' msg '$msg'\n"; #print STDERR "formkeyHandler valid_check valid '$valid' formname '$formname' msg '$msg'\n";
if ($valid eq 'invalidhcretry' if ($valid eq 'invalidhcretry'
|| $valid eq 'invalidhc') { || $valid eq 'invalidhc') {
# It's OK, the user can retry. # It's OK, the user can retry.
Expand Down
6 changes: 2 additions & 4 deletions Slash/Utility/Anchor/Anchor.pm
Expand Up @@ -158,12 +158,10 @@ sub header {
# $adhtml = getAd(1); # $adhtml = getAd(1);
# } # }


# pass section - otherwise, static pages will get 'index' as the section
# PMG 7/12/02
if ($options->{admin} && $user->{is_admin}) { if ($options->{admin} && $user->{is_admin}) {
slashDisplay('header-admin', { title => $title, section => $section}); slashDisplay('header-admin', $title);
} else { } else {
slashDisplay('header', { title => $title, section => $section} ); slashDisplay('header', $title);
} }


if ($constants->{admin_check_clearpass} if ($constants->{admin_check_clearpass}
Expand Down
125 changes: 75 additions & 50 deletions plugins/Admin/admin.pl
Expand Up @@ -25,10 +25,6 @@ sub main {
my($tbtitle); my($tbtitle);


my $ops = { my $ops = {
slashd => {
function => \&displaySlashd,
seclev => 500,
},
edit_keyword => { edit_keyword => {
function => \&editKeyword, function => \&editKeyword,
seclev => 10000, seclev => 10000,
Expand All @@ -51,7 +47,7 @@ sub main {
}, },
'delete' => { 'delete' => {
function => \&listStories, function => \&listStories,
seclev => 100, seclev => 10000,
}, },
preview => { preview => {
function => \&editStory, function => \&editStory,
Expand All @@ -67,7 +63,7 @@ sub main {


function => \&blockEdit, function => \&blockEdit,


seclev => 100, seclev => 500,
}, },
colors => { # colored,colorpreview,colorsave,colorrevert, colors => { # colored,colorpreview,colorsave,colorrevert,
# colororig,colorsavedef, # colororig,colorsavedef,
Expand Down Expand Up @@ -107,6 +103,14 @@ sub main {
function => \&varEdit, function => \&varEdit,
seclev => 10000, seclev => 10000,
}, },
slashd => {
function => \&displaySlashd,
seclev => 500,
},
recent => {
function => \&displayRecent,
seclev => 500,
},
}; };


# admin.pl is not for regular users # admin.pl is not for regular users
Expand Down Expand Up @@ -427,8 +431,6 @@ sub templateDelete {
sub blockEdit { sub blockEdit {
my($form, $slashdb, $user, $constants) = @_; my($form, $slashdb, $user, $constants) = @_;


my $section = $user->{section} || $form->{section};

my($bid); my($bid);


if ($form->{blocksave} || $form->{blocksavedef}) { if ($form->{blocksave} || $form->{blocksavedef}) {
Expand Down Expand Up @@ -478,7 +480,7 @@ sub blockEdit {
my($static_blocks, $portal_blocks); my($static_blocks, $portal_blocks);
if ($user->{section}) { if ($user->{section}) {
$static_blocks = $slashdb->getDescriptions('static_block_section', { seclev => $user->{seclev}, section => $user->{section} }, 1); $static_blocks = $slashdb->getDescriptions('static_block_section', { seclev => $user->{seclev}, section => $user->{section} }, 1);
$portal_blocks = $slashdb->getDescriptions('portald_block_section', { seclev => $user->{seclev}, section => $user->{section} }, 1); $static_blocks = $slashdb->getDescriptions('portald_block_section', { seclev => $user->{seclev}, section => $user->{section} }, 1);
} else { } else {
$static_blocks = $slashdb->getDescriptions('static_block', $user->{seclev}, 1); $static_blocks = $slashdb->getDescriptions('static_block', $user->{seclev}, 1);
$portal_blocks = $slashdb->getDescriptions('portald_block', $user->{seclev}, 1); $portal_blocks = $slashdb->getDescriptions('portald_block', $user->{seclev}, 1);
Expand Down Expand Up @@ -710,7 +712,7 @@ sub topicEdit {
$form->{nexttid} ? $form->{nexttid} : $constants->{defaulttopic}, 1); $form->{nexttid} ? $form->{nexttid} : $constants->{defaulttopic}, 1);
my $sections = {}; my $sections = {};
if ($user->{section} && $user->{seclev} <= 9000) { if ($user->{section} && $user->{seclev} <= 9000) {
$sections->{$user->{section}} = $slashdb->getSection($user->{section},'title','',1); $sections->{$user->{section}} = $slashdb->getSection($user->{section},'title');
} else { } else {
$sections = $slashdb->getDescriptions('sections-contained', '', 1); $sections = $slashdb->getDescriptions('sections-contained', '', 1);
} }
Expand All @@ -734,7 +736,7 @@ sub topicEdit {


if (!$form->{topicdelete}) { if (!$form->{topicdelete}) {
if (!$form->{topicnew} && $form->{nexttid}) { if (!$form->{topicnew} && $form->{nexttid}) {
$topic = $slashdb->getTopic($form->{nexttid}); $topic = $slashdb->getTopic($form->{nexttid}, 0, 1);
} else { } else {
$topic = {}; $topic = {};
} }
Expand Down Expand Up @@ -1026,11 +1028,10 @@ sub editStory {
my $extracolref = {}; my $extracolref = {};
my($fixquotes_check, $autonode_check, my($fixquotes_check, $autonode_check,
$fastforward_check, $shortcuts_check) = $fastforward_check, $shortcuts_check) =
('','','',''); ('','','','');
my($multi_topics, $story_topics); my($multi_topics, $story_topics);
my $page = 'index'; my $page = 'index';
# my $section = $user->{section} ? $user->{section} : ''; my $section = $user->{section} ? $user->{section} : '';
my $section = $constants->{section} || $storyref->{section};


for (keys %{$form}) { $storyref->{$_} = $form->{$_} } for (keys %{$form}) { $storyref->{$_} = $form->{$_} }


Expand Down Expand Up @@ -1130,15 +1131,7 @@ sub editStory {
$story_topics->{$storyref->{tid}} ||= 1 ; $story_topics->{$storyref->{tid}} ||= 1 ;
} }


if ($constants->{use_alt_topic}) { $topic_select = selectTopic('tid', $storyref->{tid}, $storyref->{section}, 1);
$topic_select = createSelect('tid',$slashdb->getDescriptions('topics_section_type', $section, $constants->{use_alt_topic}),$storyref->{tid},1);
} else {
if ($section) {
$topic_select = createSelect('tid', $slashdb->getDescriptions('topics_section', $section),$storyref->{tid}, 1);
} else {
$topic_select = createSelect('tid', $slashdb->getDescriptions('topics'),$storyref->{tid}, 1);
}
}


$section_select = selectSection('section', $storyref->{section}, $sections, 1) unless $user->{section}; $section_select = selectSection('section', $storyref->{section}, $sections, 1) unless $user->{section};


Expand All @@ -1153,11 +1146,10 @@ sub editStory {


$locktest = lockTest($storyref->{title}); $locktest = lockTest($storyref->{title});


my $display_codes = $user->{section} ? 'displaycodes_sectional' : 'displaycodes'; unless ($user->{section}) {

$description = $slashdb->getDescriptions('displaycodes');
$description = $slashdb->getDescriptions($display_codes); $displaystatus_select = createSelect('displaystatus', $description, $storyref->{displaystatus}, 1);
$displaystatus_select = createSelect('displaystatus', $description, $storyref->{displaystatus}, 1); }

$description = $slashdb->getDescriptions('commentcodes'); $description = $slashdb->getDescriptions('commentcodes');
$commentstatus_select = createSelect('commentstatus', $description, $storyref->{commentstatus}, 1); $commentstatus_select = createSelect('commentstatus', $description, $storyref->{commentstatus}, 1);


Expand Down Expand Up @@ -1323,7 +1315,8 @@ sub listStories {
} }


for (@$storylist) { for (@$storylist) {
my($hits, $comments, $sid, $title, $aid, $time_plain, $topic, $subsection,$section, my($hits, $comments, $sid, $title, $aid, $time_plain, $topic,
$subsection, $section,
$displaystatus, $writestatus) = @$_; $displaystatus, $writestatus) = @$_;
my $time = timeCalc($time_plain, '%H:%M', 0); my $time = timeCalc($time_plain, '%H:%M', 0);
my $td = timeCalc($time_plain, '%A %B %d', 0); my $td = timeCalc($time_plain, '%A %B %d', 0);
Expand All @@ -1345,7 +1338,6 @@ sub listStories {
'time' => $time, 'time' => $time,
canedit => $canedit, canedit => $canedit,
topic => $topic, topic => $topic,
subsection => $subsection,
section => $section, section => $section,
td => $td, td => $td,
td2 => $td2, td2 => $td2,
Expand Down Expand Up @@ -1447,7 +1439,12 @@ sub updateStory {


my $tid_ref; my $tid_ref;
my $default_set = 0; my $default_set = 0;
my $topic = $form->{tid};
# Some users can only post to a fixed section
if (my $section = getCurrentUser('section')) {
$form->{section} = $section;
$form->{displaystatus} = 1;
}


$form->{dept} =~ s/ /-/g; $form->{dept} =~ s/ /-/g;


Expand All @@ -1461,20 +1458,16 @@ sub updateStory {
? $slashdb->getTime() ? $slashdb->getTime()
: $form->{'time'}; : $form->{'time'};


if ($constants->{use_alt_topic} && $constants->{enable_index_topic} && $constants->{organise_stories}) {
$topic = $form->{$constants->{organise_stories}};
}

if ($constants->{multitopics_enabled}) { if ($constants->{multitopics_enabled}) {
for my $k (keys %$form) { for my $k (keys %$form) {
if ($k =~ /tid_(.*)/) { if ($k =~ /tid_(.*)/) {
push @$tid_ref, $1; push @$tid_ref, $1;
} }
} }
for (@{$tid_ref}) { for (@{$tid_ref}) {
$default_set++ if ($_ eq $topic && $topic); $default_set++ if ($_ eq $form->{tid} && $form->{tid});
} }
push @$tid_ref, $topic if !$default_set; push @$tid_ref, $form->{tid} if !$default_set;


$slashdb->setStoryTopics($form->{sid}, $tid_ref); $slashdb->setStoryTopics($form->{sid}, $tid_ref);
} }
Expand All @@ -1488,7 +1481,7 @@ sub updateStory {
sid => $form->{sid}, sid => $form->{sid},
title => $form->{title}, title => $form->{title},
section => $form->{section}, section => $form->{section},
tid => $topic, tid => $form->{tid},
dept => $form->{dept}, dept => $form->{dept},
'time' => $time, 'time' => $time,
displaystatus => $form->{displaystatus}, displaystatus => $form->{displaystatus},
Expand Down Expand Up @@ -1550,15 +1543,52 @@ sub displaySlashd {
}); });
} }


##################################################################
sub displayRecent {
my($form, $slashdb, $user, $constants) = @_;
my($min, $max) = (undef, undef);
$min = $form->{min} if defined($form->{min});
$max = $form->{max} if defined($form->{max});
my $startat = $form->{startat} || undef;

my $max_cid = $slashdb->sqlSelect("MAX(cid)", "comments");
my $recent_comments = $slashdb->getRecentComments({
min => $min,
max => $max,
startat => $startat,
num => 30,
}) || [ ];

my $id_vislen = $constants->{id_md5_vislength};
my $subj_vislen = 30;
for my $comm (@$recent_comments) {
$comm->{ipid_vis} = substr($comm->{ipid}, 0, $id_vislen);
$comm->{subject_vis} = substr($comm->{subject}, 0, $subj_vislen);
$comm->{date} = substr($comm->{date}, 5); # strip off year
}

slashDisplay('recent', {
startat => $startat,
max_cid => $max_cid,
recent_comments => $recent_comments,
min => $min,
max => $max,
});
}

################################################################## ##################################################################
sub saveStory { sub saveStory {
my($form, $slashdb, $user, $constants) = @_; my($form, $slashdb, $user, $constants) = @_;


my $edituser = $slashdb->getUser($form->{uid}); my $edituser = $slashdb->getUser($form->{uid});
my $tid_ref; my $tid_ref;
my $topic = $form->{tid};
my $default_set = 0; my $default_set = 0;


# In the previous form of this, a section only
# editor could assign a story to a different user
# and bypass their own restrictions for what section
# they could post to. -Brian
$form->{displaystatus} ||= 1 if ($user->{section} || $edituser->{section});
if ($user->{section} || $edituser->{section}) { if ($user->{section} || $edituser->{section}) {
$form->{section} = $user->{section} ? $user->{section} : $edituser->{section}; $form->{section} = $user->{section} ? $user->{section} : $edituser->{section};
} }
Expand All @@ -1575,11 +1605,6 @@ sub saveStory {
? $slashdb->getTime() ? $slashdb->getTime()
: $form->{'time'}; : $form->{'time'};



if ($constants->{use_alt_topic} && $constants->{enable_index_topic} && $constants->{organise_stories}) {
$topic = $form->{$constants->{organise_stories}};
}

# used to just pass $form to createStory, which is not # used to just pass $form to createStory, which is not
# a good idea because you end up getting form values # a good idea because you end up getting form values
# such as op and apache_request saved into story_param # such as op and apache_request saved into story_param
Expand All @@ -1589,7 +1614,7 @@ sub saveStory {
title => $form->{title}, title => $form->{title},
section => $form->{section}, section => $form->{section},
submitter => $form->{submitter}, submitter => $form->{submitter},
tid => $topic, tid => $form->{tid},
dept => $form->{dept}, dept => $form->{dept},
'time' => $time, 'time' => $time,
displaystatus => $form->{displaystatus}, displaystatus => $form->{displaystatus},
Expand All @@ -1608,6 +1633,7 @@ sub saveStory {
$data->{$key} = $form->{$key} if $form->{$key}; $data->{$key} = $form->{$key} if $form->{$key};
} }
} }
#use Data::Dumper; print STDERR "saveStory createStory extras '@$extras' data " . Dumper($data);
my $sid = $slashdb->createStory($data); my $sid = $slashdb->createStory($data);


# we can use multiple values in forms now, we don't # we can use multiple values in forms now, we don't
Expand All @@ -1619,23 +1645,22 @@ sub saveStory {
} }
} }
for (@{$tid_ref}) { for (@{$tid_ref}) {
$default_set++ if $_ eq $topic; $default_set++ if $_ eq $form->{tid};
} }
push @$tid_ref, $topic if !$default_set; push @$tid_ref, $form->{tid} if !$default_set;


$slashdb->setStoryTopics($sid, $tid_ref); $slashdb->setStoryTopics($sid, $tid_ref);
} }


if ($sid) { if ($sid) {

my $section = $slashdb->getSection($form->{section}); my $section = $slashdb->getSection($form->{section});
my $rootdir = $section->{rootdir} || $constants->{rootdir}; my $rootdir = $section->{rootdir} || $constants->{rootdir};


my $id = $slashdb->createDiscussion( { my $id = $slashdb->createDiscussion( {
title => $form->{title}, title => $form->{title},
section => $form->{section}, section => $form->{section},
topic => $topic, topic => $form->{tid},
url => "$rootdir/article.pl?sid=$sid&tid=$topic", url => "$rootdir/article.pl?sid=$sid&tid=$form->{tid}",
sid => $sid, sid => $sid,
ts => $form->{'time'} ts => $form->{'time'}
}); });
Expand Down

0 comments on commit b92be62

Please sign in to comment.