Using generic name fro user-created cronjobs
authorAlexander Ebert <ebert@woltlab.com>
Tue, 28 Jun 2016 10:15:03 +0000 (12:15 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 28 Jun 2016 10:15:03 +0000 (12:15 +0200)
wcfsetup/install/files/lib/acp/form/CronjobAddForm.class.php

index c0941b1753be03096282ea7774fe8905da3a4e42..530213ee21d92d94db822d41b593fbacb79ab657 100755 (executable)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\acp\form;
+use wcf\data\cronjob\Cronjob;
 use wcf\data\cronjob\CronjobAction;
 use wcf\data\cronjob\CronjobEditor;
 use wcf\form\AbstractForm;
@@ -152,6 +153,7 @@ class CronjobAddForm extends AbstractForm {
                $data = array_merge($this->additionalFields, [
                        'className' => $this->className,
                        'packageID' => $this->packageID,
+                       'cronjobName' => 'com.woltlab.wcf.cronjob',
                        'description' => $this->description,
                        'startMinute' => $this->startMinute,
                        'startHour' => $this->startHour,
@@ -161,20 +163,23 @@ class CronjobAddForm extends AbstractForm {
                ]);
                
                $this->objectAction = new CronjobAction([], 'create', ['data' => $data]);
-               $this->objectAction->executeAction();
+               /** @var Cronjob $cronjob */
+               $cronjob = $this->objectAction->executeAction()['returnValues'];
+               $cronjobID = $cronjob->cronjobID;
+               
+               // update `cronjobName`
+               $data = ['cronjobName' => 'com.woltlab.wcf.cronjob' . $cronjobID];
                
                if (!I18nHandler::getInstance()->isPlainValue('description')) {
-                       $returnValues = $this->objectAction->getReturnValues();
-                       $cronjobID = $returnValues['returnValues']->cronjobID;
                        I18nHandler::getInstance()->save('description', 'wcf.acp.cronjob.description.cronjob'.$cronjobID, 'wcf.acp.cronjob', $this->packageID);
                        
                        // update group name
-                       $cronjobEditor = new CronjobEditor($returnValues['returnValues']);
-                       $cronjobEditor->update([
-                               'description' => 'wcf.acp.cronjob.description.cronjob'.$cronjobID
-                       ]);
+                       $data['description'] = 'wcf.acp.cronjob.description.cronjob' . $cronjobID;
                }
                
+               $cronjobEditor = new CronjobEditor($cronjob);
+               $cronjobEditor->update($data);
+               
                $this->saved();
                
                // reset values