Merge "Don't check namespace in SpecialWantedtemplates"
[lhc/web/wiklou.git] / includes / changetags / ChangeTagsLogList.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Change tagging
20 */
21
22 /**
23 * Stores a list of taggable log entries.
24 * @since 1.25
25 */
26 class ChangeTagsLogList extends ChangeTagsList {
27 public function getType() {
28 return 'logentry';
29 }
30
31 /**
32 * @param DatabaseBase $db
33 * @return mixed
34 */
35 public function doQuery( $db ) {
36 $ids = array_map( 'intval', $this->ids );
37 $queryInfo = DatabaseLogEntry::getSelectQueryData();
38 $queryInfo['conds'] += array( 'log_id' => $ids );
39 $queryInfo['options'] += array( 'ORDER BY' => 'log_id DESC' );
40 ChangeTags::modifyDisplayQuery(
41 $queryInfo['tables'],
42 $queryInfo['fields'],
43 $queryInfo['conds'],
44 $queryInfo['join_conds'],
45 $queryInfo['options'],
46 ''
47 );
48 return $db->select(
49 $queryInfo['tables'],
50 $queryInfo['fields'],
51 $queryInfo['conds'],
52 __METHOD__,
53 $queryInfo['options'],
54 $queryInfo['join_conds']
55 );
56 }
57
58 public function newItem( $row ) {
59 return new ChangeTagsLogItem( $this, $row );
60 }
61
62 /**
63 * Add/remove change tags from all the log entries in the list.
64 *
65 * @param array $tagsToAdd
66 * @param array $tagsToRemove
67 * @param array $params
68 * @param string $reason
69 * @param User $user
70 * @return Status
71 */
72 public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params,
73 $reason, $user ) {
74
75 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
76 for ( $this->reset(); $this->current(); $this->next() ) {
77 // @codingStandardsIgnoreEnd
78 $item = $this->current();
79 $status = ChangeTags::updateTagsWithChecks( $tagsToAdd, $tagsToRemove,
80 null, null, $item->getId(), $params, $reason, $user );
81 // Should only fail on second and subsequent times if the user trips
82 // the rate limiter
83 if ( !$status->isOK() ) {
84 break;
85 }
86 }
87
88 return $status;
89 }
90 }