-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* | ||
* @author Marcus Nyeholt <marcus@silverstripe.com.au> | ||
*/ | ||
class SetPropertyWorkflowAction extends WorkflowAction { | ||
private static $db = array( | ||
'Property' => 'Varchar', | ||
'Value' => 'Text', | ||
); | ||
|
||
public function execute(WorkflowInstance $workflow) { | ||
if (!$target = $workflow->getTarget()) { | ||
return true; | ||
} | ||
|
||
if ($target->hasField($this->Property)) { | ||
$target->setField($this->Property, $this->Value); | ||
} | ||
|
||
$target->write(); | ||
|
||
return true; | ||
} | ||
|
||
public function getCMSFields() { | ||
$fields = parent::getCMSFields(); | ||
|
||
$fields->addFieldsToTab('Root.Main', array( | ||
TextField::create('Property', _t('SetPropertyWorkflowAction.PROPERTY', 'Property')) | ||
->setRightTitle(_t('SetPropertyWorkflowAction.PROPERTYTITLE', 'Property to set; if this exists as a setter method, will be called passing the value')), | ||
TextField::create('Value', 'Value') | ||
)); | ||
|
||
return $fields; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Unpublishes an item | ||
* | ||
* @author marcus@silverstripe.com.au | ||
* @license BSD License (http://silverstripe.org/bsd-license/) | ||
* @package advancedworkflow | ||
* @subpackage actions | ||
*/ | ||
class UnpublishItemWorkflowAction extends WorkflowAction { | ||
|
||
private static $db = array( | ||
'UnpublishDelay' => 'Int' | ||
); | ||
|
||
public static $icon = 'advancedworkflow/images/unpublish.png'; | ||
|
||
public function execute(WorkflowInstance $workflow) { | ||
if (!$target = $workflow->getTarget()) { | ||
return true; | ||
} | ||
|
||
if (class_exists('AbstractQueuedJob') && $this->UnpublishDelay) { | ||
$job = new WorkflowPublishTargetJob($target, "unpublish"); | ||
$days = $this->UnpublishDelay; | ||
$after = date('Y-m-d H:i:s', strtotime("+$days days")); | ||
singleton('QueuedJobService')->queueJob($job, $after); | ||
} else if ($target->hasExtension('WorkflowEmbargoExpiryExtension')) { | ||
// setting future date stuff if needbe | ||
|
||
// set these values regardless | ||
$target->DesiredUnPublishDate = ''; | ||
$target->DesiredPublishDate = ''; | ||
$target->write(); | ||
|
||
if ($target->hasMethod('doUnpublish')) { | ||
$target->doUnpublish(); | ||
} | ||
} else { | ||
if ($target->hasMethod('doUnpublish')) { | ||
$target->doUnpublish(); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function getCMSFields() { | ||
$fields = parent::getCMSFields(); | ||
|
||
if (class_exists('AbstractQueuedJob')) { | ||
$before = _t('UnpublishItemWorkflowAction.DELAYUNPUBDAYSBEFORE', 'Delay unpublishing by '); | ||
$after = _t('UnpublishItemWorkflowAction.DELAYUNPUBDAYSAFTER', ' days'); | ||
|
||
$fields->addFieldToTab('Root.Main', new FieldGroup( | ||
_t('UnpublishItemWorkflowAction.UNPUBLICATIONDELAY', 'Delay Un-publishing'), | ||
new LabelField('UnpublishDelayBefore', $before), | ||
new NumericField('UnpublishDelay', ''), | ||
new LabelField('UnpublishDelayAfter', $after) | ||
)); | ||
} | ||
|
||
return $fields; | ||
} | ||
|
||
/** | ||
* @param DataObject $target | ||
* @return bool | ||
*/ | ||
public function canPublishTarget(DataObject $target) { | ||
return false; | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.