Filtering the cronjob log
authorMarcel Werk <burntime@woltlab.com>
Sat, 6 Jun 2020 17:52:58 +0000 (19:52 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sat, 6 Jun 2020 17:52:58 +0000 (19:52 +0200)
Closes #3359

wcfsetup/install/files/acp/templates/cronjobLogList.tpl
wcfsetup/install/files/lib/acp/page/CronjobLogListPage.class.php

index 3c86a6e744d310ba7c4c0d40b4a79cc8138db2f8..b6f8ae9e6348d525b9cc95d0600f1d580008dec1 100644 (file)
        {/hascontent}
 </header>
 
+<form method="post" action="{link controller='CronjobLogList'}{/link}">
+       <section class="section">
+               <h2 class="sectionTitle">{lang}wcf.global.filter{/lang}</h2>
+               
+               <div class="row rowColGap formGrid">
+                       <dl class="col-xs-12 col-md-4">
+                               <dt></dt>
+                               <dd>
+                                       <select name="cronjobID" aria-label="{lang}wcf.acp.cronjob.description{/lang}">
+                                               <option value="0">{lang}wcf.acp.cronjob.description{/lang}</option>
+                                               {foreach from=$availableCronjobs item=availableCronjob}
+                                                       <option value="{@$availableCronjob->cronjobID}"{if $availableCronjob->cronjobID == $cronjobID} selected{/if}>{$availableCronjob->description|language}</option>
+                                               {/foreach}
+                                       </select>
+                               </dd>
+                       </dl>
+                       
+                       <dl class="col-xs-12 col-md-4">
+                               <dt></dt>
+                               <dd>
+                                       <select name="success" aria-label="{lang}wcf.acp.cronjob.log.status{/lang}">
+                                               <option value="-1">{lang}wcf.acp.cronjob.log.status{/lang}</option>
+                                               <option value="1"{if $success == 1} selected{/if}>{lang}wcf.acp.cronjob.log.success{/lang}</option>
+                                               <option value="0"{if $success == 0} selected{/if}>{lang}wcf.acp.cronjob.log.error{/lang}</option>
+                                       </select>
+                               </dd>
+                       </dl>
+                       
+                       {event name='filterFields'}
+               </div>
+               
+               <div class="formSubmit">
+                       <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
+                       {@SECURITY_TOKEN_INPUT_TAG}
+               </div>
+       </section>
+</form>
+
+{assign var='linkParameters' value=''}
+{if $cronjobID}{capture append=linkParameters}&cronjobID={@$cronjobID}{/capture}{/if}
+{if $success != -1}{capture append=linkParameters}&success={@$success}{/capture}{/if}
+
 {hascontent}
        <div class="paginationTop">
-               {content}{pages print=true assign=pagesLinks controller="CronjobLogList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content}
+               {content}{pages print=true assign=pagesLinks controller="CronjobLogList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}{/content}
        </div>
 {/hascontent}
 
                <table class="table">
                        <thead>
                                <tr>
-                                       <th class="columnID columnCronjobID{if $sortField == 'cronjobID'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=cronjobID&sortOrder={if $sortField == 'cronjobID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
-                                       <th class="columnTitle columnClassName{if $sortField == 'className'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=className&sortOrder={if $sortField == 'className' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.cronjob.className{/lang}</a></th>
-                                       <th class="columnText columnDescription{if $sortField == 'description'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=description&sortOrder={if $sortField == 'description' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.cronjob.description{/lang}</a></th>
-                                       <th class="columnDate columnExecTime{if $sortField == 'execTime'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=execTime&sortOrder={if $sortField == 'execTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.cronjob.log.execTime{/lang}</a></th>
-                                       <th class="columnText columnSuccess{if $sortField == 'success'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=success&sortOrder={if $sortField == 'success' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.cronjob.log.status{/lang}</a></th>
+                                       <th class="columnID columnCronjobID{if $sortField == 'cronjobID'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=cronjobID&sortOrder={if $sortField == 'cronjobID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
+                                       <th class="columnTitle columnClassName{if $sortField == 'className'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=className&sortOrder={if $sortField == 'className' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.cronjob.className{/lang}</a></th>
+                                       <th class="columnText columnDescription{if $sortField == 'description'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=description&sortOrder={if $sortField == 'description' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.cronjob.description{/lang}</a></th>
+                                       <th class="columnDate columnExecTime{if $sortField == 'execTime'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=execTime&sortOrder={if $sortField == 'execTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.cronjob.log.execTime{/lang}</a></th>
+                                       <th class="columnText columnSuccess{if $sortField == 'success'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobLogList'}pageNo={@$pageNo}&sortField=success&sortOrder={if $sortField == 'success' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.cronjob.log.status{/lang}</a></th>
                                        
                                        {event name='columnHeads'}
                                </tr>
index a459262c6168733f32da8e486f867457c0caca25..4c7dfea87d71aedbd7a15a80c49959c258bb142a 100755 (executable)
@@ -1,7 +1,9 @@
 <?php
 namespace wcf\acp\page;
+use wcf\data\cronjob\CronjobList;
 use wcf\data\cronjob\log\CronjobLogList;
 use wcf\page\SortablePage;
+use wcf\system\WCF;
 
 /**
  * Shows cronjob log information.
@@ -49,6 +51,31 @@ class CronjobLogListPage extends SortablePage {
         */
        public $objectListClassName = CronjobLogList::class;
        
+       /**
+        * @var integer
+        */
+       public $cronjobID = 0;
+       
+       /**
+        * @var integer
+        */
+       public $success = -1;
+       
+       /**
+        * @var CronjobList
+        */
+       public $availableCronjobs;
+       
+       /**
+        * @inheritDoc
+        */
+       public function readParameters() {
+               parent::readParameters();
+               
+               if (!empty($_REQUEST['cronjobID'])) $this->cronjobID = intval($_REQUEST['cronjobID']);
+               if (isset($_REQUEST['success'])) $this->success = intval($_REQUEST['success']);
+       }
+       
        /**
         * @inheritDoc
         */
@@ -57,6 +84,13 @@ class CronjobLogListPage extends SortablePage {
                
                $this->objectList->sqlSelects = "cronjob.*";
                $this->objectList->sqlJoins = "LEFT JOIN wcf".WCF_N."_cronjob cronjob ON (cronjob.cronjobID = cronjob_log.cronjobID)";
+               
+               if ($this->cronjobID) {
+                       $this->objectList->getConditionBuilder()->add('cronjob_log.cronjobID = ?', [$this->cronjobID]);
+               }
+               if ($this->success != -1) {
+                       $this->objectList->getConditionBuilder()->add('cronjob_log.success = ?', [$this->success]);
+               }
        }
        
        /**
@@ -67,4 +101,28 @@ class CronjobLogListPage extends SortablePage {
                
                parent::readObjects();
        }
+       
+       /**
+        * @inheritDoc
+        */
+       public function readData() {
+               parent::readData();
+               
+               $this->availableCronjobs = new CronjobList();
+               $this->availableCronjobs->sqlOrderBy = 'cronjobID';
+               $this->availableCronjobs->readObjects();
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign([
+                       'cronjobID' => $this->cronjobID,
+                       'success' => $this->success,
+                       'availableCronjobs' => $this->availableCronjobs,
+               ]);
+       }
 }