Committer: azateev
LJSV-2549: replace request with category in support_check_priv subroutine [int]U branches/esn-support/htdocs/support/actmulti.bml U branches/esn-support/htdocs/support/append_request.bml U branches/esn-support/htdocs/support/see_request.bml U branches/esn-support/htdocs/support/stock_answers.bml
Modified: branches/esn-support/htdocs/support/actmulti.bml =================================================================== --- branches/esn-support/htdocs/support/actmulti.bml 2013-01-14 14:53:17 UTC (rev 23538) +++ branches/esn-support/htdocs/support/actmulti.bml 2013-01-14 14:55:18 UTC (rev 23539) @@ -72,7 +72,7 @@ return "<?h1 $ML{'.success'} h1?><?p $ML{'.request.specified'} p?>"; } elsif ($POST{'action:move'}) { return "<?h1 $ML{'.error'} h1?><?p $ML{'.not.have.access.move.request'} p?>" - unless LJ::Support::can_perform_actions({ _cat => $cat }, $remote); + unless LJ::Support::can_perform_actions($cat, $remote); my $newcat = $POST{'changecat'} + 0; my $cats = LJ::Support::load_cats(); Modified: branches/esn-support/htdocs/support/append_request.bml =================================================================== --- branches/esn-support/htdocs/support/append_request.bml 2013-01-14 14:53:17 UTC (rev 23538) +++ branches/esn-support/htdocs/support/append_request.bml 2013-01-14 14:55:18 UTC (rev 23539) @@ -76,21 +76,21 @@ ## can we do the action we want? return LJ::bad_input($ML{'.internal.approve'}) - if $FORM{'approveans'} && ($type ne "internal" || ! LJ::Support::can_help($sp, $remote)); + if $FORM{'approveans'} && ($type ne "internal" || ! LJ::Support::can_help($scat, $remote)); return LJ::bad_input($ML{'.internal.changecat'}) - if $FORM{'changecat'} && ($type ne "internal" || ! LJ::Support::can_perform_actions($sp, $remote)); + if $FORM{'changecat'} && ($type ne "internal" || ! LJ::Support::can_perform_actions($scat, $remote)); return LJ::bad_input($ML{'.internal.changelanguage'}) - if LJ::is_enabled("support_request_language") && $FORM{'changelanguage'} && ($type ne "internal" || ! LJ::Support::can_read_internal($sp, $remote)); + if LJ::is_enabled("support_request_language") && $FORM{'changelanguage'} && ($type ne "internal" || ! LJ::Support::can_read_internal($scat, $remote)); # make sure that the tier/answer combination is valid my $tier; my $require_tier = 0; # tier isn't required for now if (LJ::is_enabled("support_response_tier")) { - my $is_answer = $type eq "answer" && LJ::Support::can_help($sp, $remote) ? 1 : 0; - my $is_approval = $type eq "internal" && LJ::Support::can_help($sp, $remote) && $FORM{approveans} && $FORM{approveas} eq "answer" ? 1 : 0; - my $is_internal = $type eq "internal" && LJ::Support::can_make_internal($sp, $remote) ? 1 : 0; + my $is_answer = $type eq "answer" && LJ::Support::can_help($scat, $remote) ? 1 : 0; + my $is_approval = $type eq "internal" && LJ::Support::can_help($scat, $remote) && $FORM{approveans} && $FORM{approveas} eq "answer" ? 1 : 0; + my $is_internal = $type eq "internal" && LJ::Support::can_make_internal($scat, $remote) ? 1 : 0; if ($FORM{settier}) { return LJ::bad_input($ML{'.internal.settier'}) @@ -109,13 +109,13 @@ return LJ::bad_input($ML{'.internal.touch'}) if ($FORM{'touch'} || $FORM{'untouch'}) && - ($type ne "internal" || ! LJ::Support::can_perform_actions($sp, $remote)); + ($type ne "internal" || ! LJ::Support::can_perform_actions($scat, $remote)); return LJ::bad_input($ML{'.internal.changesum'}) - if $FORM{'changesum'} && ($type ne "internal" || ! LJ::Support::can_change_summary($sp, $remote)); + if $FORM{'changesum'} && ($type ne "internal" || ! LJ::Support::can_change_summary($scat, $remote)); return LJ::bad_input($ML{'.internal.changetags'}) - if $FORM{'changetags'} && ($type ne "internal" || ! LJ::Support::can_read_internal($sp, $remote)); + if $FORM{'changetags'} && ($type ne "internal" || ! LJ::Support::can_read_internal($scat, $remote)); return LJ::bad_input($ML{'.invalid.blank'}) if $FORM{'body'} !~ /\S/ && !$FORM{'approveans'} && !$FORM{'changecat'} && !$FORM{'changelanguage'} && (!$FORM{'settier'} || $type eq "answer") && @@ -296,7 +296,7 @@ foreach my $newtag (@newtags) { my $tagid = LJ::Support::Request::Tag::tag_name_to_id( $newtag, $spcatid, - !LJ::Support::can_help($sp, $remote) + !LJ::Support::can_help($scat, $remote) ); if (defined($tagid)) { Modified: branches/esn-support/htdocs/support/see_request.bml =================================================================== --- branches/esn-support/htdocs/support/see_request.bml 2013-01-14 14:53:17 UTC (rev 23538) +++ branches/esn-support/htdocs/support/see_request.bml 2013-01-14 14:55:18 UTC (rev 23539) @@ -186,6 +186,7 @@ my $spid = $FORM{'id'}+0; my $sp = LJ::Support::load_request($spid); + my $spcat = $sp->{_cat}; my $props = LJ::Support::load_props($spid); my $cats = LJ::Support::load_cats(); my $remote = LJ::get_remote(); @@ -201,7 +202,7 @@ } my $spcatand = ''; if ($sp && ($find eq 'cnext' || $find eq 'cprev')) { - my $spcatid = $sp->{_cat}->{'spcatid'} + 0; + my $spcatid = $spcat->{'spcatid'} + 0; $spcatand = "AND spcatid=$spcatid"; } else { my @filter_cats = LJ::Support::filter_cats($remote, $cats); @@ -287,8 +288,8 @@ } # load category this request is in - my $problemarea = $sp->{_cat}->{'catname'}; - my $catkey = $sp->{_cat}->{'catkey'}; + my $problemarea = $spcat->{'catname'}; + my $catkey = $spcat->{'catkey'}; unless (LJ::Support::can_read($sp, $remote, $auth)) { return "<?h1 $ML{'.error'} h1?><?p $ML{'.nothaveprivilege'} p?>"; @@ -297,8 +298,8 @@ # helper variables for commonly called methods my $can_close = LJ::Support::can_close($sp, $remote, $auth) ? 1 : 0; my $can_reopen = LJ::Support::can_reopen($sp, $remote, $auth) ? 1 : 0; - my $helper_mode = LJ::Support::can_help($sp, $remote) ? 1 : 0; - my $stock_mode = LJ::Support::can_see_stocks($sp, $remote) ? 1 : 0; + my $helper_mode = LJ::Support::can_help($spcat, $remote) ? 1 : 0; + my $stock_mode = LJ::Support::can_see_stocks($spcat, $remote) ? 1 : 0; my $is_poster = LJ::Support::is_poster($sp, $remote, $auth) ? 1 : 0; # fix up the subject if needed @@ -351,7 +352,7 @@ my %show_history = ( user => $has_sh, - email => ($has_fu || ($has_sh && !$sp->{_cat}->{public_read})), + email => ($has_fu || ($has_sh && !$spcat->{public_read})), ); if ($show_history{user} || $show_history{email}) { @@ -561,8 +562,8 @@ } $ret .= "<tr><td align='right' nowrap='nowrap'><b>$ML{'.supportcategory'}:</b></td><td>"; - if (LJ::Support::can_read_cat($sp->{_cat}, $remote)) { - $ret .= "<a href='$LJ::SITEROOT/support/help.bml?cat=$sp->{_cat}->{'catkey'}'>$problemarea</a>"; + if (LJ::Support::can_read_cat($spcat, $remote)) { + $ret .= "<a href='$LJ::SITEROOT/support/help.bml?cat=$spcat->{'catkey'}'>$problemarea</a>"; $ret .= " [<a href='$LJ::SITEROOT/support/see_request.bml?id=$sp->{'spid'}&find=cprev'>$ML{'.previous'}</a>|"; $ret .= "<a href='$LJ::SITEROOT/support/see_request.bml?id=$sp->{'spid'}&find=cnext'>$ML{'.next'}</a>]"; } else { @@ -671,7 +672,7 @@ # put in a "this is private!" box if this is a private request and the user viewing # this page is the person who opened the request - if (!$sp->{_cat}->{public_read} && $is_poster) { + if (!$spcat->{public_read} && $is_poster) { $ret .= "<div style='margin-top: 15px; margin-bottom: 15px; padding: 5px; " . "text-align: center; background-color: #ffff00; border: solid 2px red;'>" . $ML{'.private.request'}."</div>"; @@ -689,9 +690,9 @@ $most_recent_tier = $le->{tier}; } - next if ($le->{'type'} eq "internal" && ! (LJ::Support::can_read_internal($sp, $remote) || + next if ($le->{'type'} eq "internal" && ! (LJ::Support::can_read_internal($spcat, $remote) || ($remote && $remote->{'userid'} == $le->{'userid'} ))); - next if ($le->{'type'} eq "screened" && ! (LJ::Support::can_read_screened($sp, $remote) || + next if ($le->{'type'} eq "screened" && ! (LJ::Support::can_read_screened($spcat, $remote) || ($remote && $remote->{'userid'} == $le->{'userid'} ))); my $up = LJ::load_userid($le->{'userid'}); @@ -906,7 +907,7 @@ } # helpers can do actions: - if (LJ::Support::can_perform_actions($sp, $remote) && ! $is_poster) + if (LJ::Support::can_perform_actions($spcat, $remote) && ! $is_poster) { $ret .= "<tr><td align='right'></td><td>\n"; @@ -940,7 +941,7 @@ my $lang_ret; my $tier_ret; - if (LJ::is_enabled("support_request_language") && LJ::Support::can_read_internal($sp, $remote) && ! $is_poster) { + if (LJ::is_enabled("support_request_language") && LJ::Support::can_read_internal($spcat, $remote) && ! $is_poster) { # language my %langs; my @lang_codes; @@ -962,7 +963,7 @@ $lang_ret .= "</td>"; } - if (LJ::is_enabled("support_response_tier") && LJ::Support::can_perform_actions($sp, $remote) && ! $is_poster && $helper_mode) { + if (LJ::is_enabled("support_response_tier") && LJ::Support::can_perform_actions($spcat, $remote) && ! $is_poster && $helper_mode) { my @valid_tiers = ( tier1 => $ML{'.tier.1'}, tier2 => $ML{'.tier.2'}, @@ -985,7 +986,7 @@ $ret .= "</td></tr>\n"; } - if (LJ::Support::can_perform_actions($sp, $remote) && ! $is_poster) { + if (LJ::Support::can_perform_actions($spcat, $remote) && ! $is_poster) { if ($sp->{'timelasthelp'} > ($sp->{'timetouched'}+5)) { $ret .= "<tr><td align='right'>$ML{'.put.in.queue'}:</td><td>"; $ret .= LJ::html_check({ 'type' => 'checkbox', 'name' => 'touch', @@ -999,7 +1000,7 @@ $ret .= "<?de $ML{'.use.this.to.change.awaiting'} de?>\n"; $ret .= "</td></tr>\n"; } - if (LJ::Support::can_change_summary($sp, $remote)) { + if (LJ::Support::can_change_summary($spcat, $remote)) { $ret .= "<tr><td align='right'>$ML{'.change.summary'}:</td><td>"; $ret .= LJ::html_check({ 'type' => 'checkbox', 'name' => 'changesum', id => 'changesum', 'onClick' => 'doSummaryClick();' }); $ret .= LJ::html_text({ 'type' => 'text', 'name' => 'summary', 'size' => '50', 'maxlength' => '80', 'value' => $sp->{'subject'}, 'onchange' => 'doSummaryChanged();', 'onkeyup' => 'doSummaryChanged();' }); @@ -1010,7 +1011,7 @@ } } - if (LJ::Support::can_read_internal($sp, $remote) && !$is_poster) { + if (LJ::Support::can_read_internal($spcat, $remote) && !$is_poster) { $ret .= '<tr>'; $ret .= '<td align="right">'.$ML{'.change.tags'}.'</td>'; $ret .= '<td>'; @@ -1032,7 +1033,7 @@ $ret .= '</td>'; $ret .= '</tr>'; $ret .= '<tr><td></td><td><p><em>'.$ML{'.tags.only.sh.can.add'}. - '</em></p></td></tr>' unless LJ::Support::can_help($sp, $remote); + '</em></p></td></tr>' unless LJ::Support::can_help($spcat, $remote); } # Prefill an e-mail validation nag, if needed. @@ -1047,7 +1048,7 @@ # add in canned answers if there are any for this category and the user can use them if ($stock_mode && ! $is_poster) { # if one category's stock answers exactly matches another's - my $stock_spcatid = $LJ::SUPPORT_STOCKS_OVERRIDE{$sp->{_cat}->{catkey}} || $sp->{_cat}->{spcatid}; + my $stock_spcatid = $LJ::SUPPORT_STOCKS_OVERRIDE{$spcat->{catkey}} || $spcat->{spcatid}; my $rows = $dbr->selectall_arrayref('SELECT subject, body FROM support_answers WHERE spcatid = ? ORDER BY subject', undef, $stock_spcatid); Modified: branches/esn-support/htdocs/support/stock_answers.bml =================================================================== --- branches/esn-support/htdocs/support/stock_answers.bml 2013-01-14 14:53:17 UTC (rev 23538) +++ branches/esn-support/htdocs/support/stock_answers.bml 2013-01-14 14:55:18 UTC (rev 23539) @@ -35,7 +35,7 @@ my %canview; # spcatid => 0/1 foreach my $cat (values %$cats) { $canview{$cat->{spcatid}} = 1 - if LJ::Support::support_check_priv({ _cat => $cat }, $remote, 'supportviewstocks'); + if LJ::Support::support_check_priv($cat, $remote, 'supportviewstocks'); } return "<?h1 $ML{'.error'} h1?><?p $ML{'.not.have.access.to.view.answers'} p?>" unless %canview;