Source of file BatchSetExpiry.php
Size: 1,698 Bytes - Last Modified: 2021-12-23T10:28:49+00:00
/var/www/docs.ssmods.com/process/src/code/batchactions/BatchSetExpiry.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | <?php class BatchSetExpiry extends CMSBatchAction { public function getActionTitle() { return _t('BatchSetExpiry.ACTION_TITLE', 'Set expiry date'); } public function getDoingText() { return _t('BatchSetExpiry.DOING_TEXT', 'Setting expiry date'); } public function run(DataObjectSet $pages) { $datefield = Object::create('DatetimeField', 'EmbargoDate_Batch'); $datefield->setValue($_REQUEST['ExpiryDate_Batch']); $date = date('d/m/Y', strtotime($datefield->dataValue())); $time = date('h:i a', strtotime($datefield->dataValue())); return $this->batchaction($pages, 'setExpiry', _t('BatchSetExpiry.ACTIONED_PAGES', 'Set expiry date on %d pages, %d failures'), array($date, $time)); } public function getParameterFields() { return new FieldSet(Object::create('DatetimeField', 'ExpiryDate_Batch')); } public function confirmationDialog($ids) { $pagesWithBacklinks = array(); foreach ($ids as $id) { $page = DataObject::get_by_id('SiteTree', $id); if ($page->DependentPagesCount(false)) { $pagesWithBacklinks[] = $page->AbsoluteLink(); } } return array( 'alert' => count($pagesWithBacklinks) ? true : false, 'content' => 'The following pages will create broken links when they expire:'."\n\n". join("\n", $pagesWithBacklinks)."\n\nProceed?" ); } public function applicablePages($ids) { return $this->applicablePagesHelper($ids, 'canChangeExpiry', true, true); } } |