-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added unpublish action and moved set property from editable user forms #238
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6845267
Added unpublish action and moved set property from editable user forms
Neumes 4daab24
Fixed up naming publish -> unpublish and fixed queued job unpublish
Neumes 4fa3182
Changed canUnpub... to canPub... no canUnpublish perm
Neumes bbf30f6
Changed SetProperty to WorkflowAction conventions. Added translation …
Neumes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,76 @@ | ||
<?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/publish.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 publication '); | ||
$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; | ||
} | ||
|
||
/** | ||
* Unpublish action allows a user who is currently assigned at this point of the workflow to | ||
* | ||
* @param DataObject $target | ||
* @return bool | ||
*/ | ||
public function canPublishTarget(DataObject $target) { | ||
return true; | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Delay un-publishing" maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, missed changing the text there...