MINOR Removed old workflow instances in the cms module. See ticket #3044

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@66310 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-11-20 08:04:44 +00:00 committed by Sam Minnee
parent be0ca474eb
commit 77ea25ca07
8 changed files with 1 additions and 291 deletions

View File

@ -41,7 +41,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'duplicatewithchildren',
'filtersitetree',
'getpagecount',
'getpagemembers',
'getversion',
'publishall',
'publishitems',
@ -606,122 +605,6 @@ JS;
}
}
//------------------------------------------------------------------------------------------//
// Workflow handlers
/**
* Send this page on to another user for review
*/
function submit() {
$page = DataObject::get_by_id("SiteTree", $_REQUEST['ID']);
$recipient = DataObject::get_by_id("Member", $_REQUEST['RecipientID']);
if(!$recipient) user_error("CMSMain::submit() Can't find recipient #$_REQUEST[RecipientID]", E_USER_ERROR);
$comment = new WorkflowPageComment();
$comment->Comment = $_REQUEST['Message'];
$comment->PageID = $page->ID;
$comment->AuthorID = Member::currentUserID();
$comment->Recipient = $recipient;
$comment->Action = $_REQUEST['Status'];
$comment->write();
$emailData = $page->customise(array(
"Message" => $_REQUEST['Message'],
"Recipient" => $recipient,
"Sender" => Member::currentUser(),
"ApproveLink" => "admin/approve/$page->ID",
"EditLink" => "admin/show/$page->ID",
"StageLink" => "$page->URLSegment/?stage=Stage",
));
$email = new Page_WorkflowSubmitEmail();
$email->populateTemplate($emailData);
$email->send();
$page->AssignedToID = $recipient->ID;
$page->RequestedByID = Member::currentUserID();
$page->Status = $_REQUEST['Status'];
$page->writeWithoutVersion();
FormResponse::status_message(sprintf(_t('CMSMain.SENTTO',"Sent to %s %s for approval.",PR_LOW,"First param is first name, and second is surname"),
$recipient->FirstName, $recipient->Surname), "good");
return FormResponse::respond();
}
function getpagemembers() {
$relationName = $_REQUEST['SecurityLevel'];
$pageID = $this->urlParams['ID'];
$page = DataObject::get_by_id('SiteTree',$pageID);
if($page) {
foreach($page->$relationName() as $editorGroup) $groupIDs[] = $editorGroup->ID;
if($groupIDs) {
$groupList = implode(", ", $groupIDs);
$members = DataObject::get("Member","","",
"INNER JOIN `Group_Members` ON `Group_Members`.MemberID = `Member`.ID AND `Group_Members`.GroupID IN ($groupList)");
}
if($members) {
if( $page->RequestedByID )
$members->shift( $page->RequestedBy() );
foreach($members as $editor) {
$options .= "<option value=\"$editor->ID\">$editor->FirstName $editor->Surname ($editor->Email)</option>";
}
} else {
$options = "<option>(no-one available)</option>";
}
return <<<HTML
<label class="left">Send to</label>
<select name="RecipientID">$options</select>
HTML;
} else {
user_error("CMSMain::getpagemembers() Cannot find page #$pageID", E_USER_ERROR);
}
}
function tasklist() {
$tasks = DataObject::get("Page", "AssignedToID = " . Member::currentUserID(), "Created DESC");
if($tasks) {
$data = new ArrayData(array(
"Tasks" => $tasks,
"Message" => sprintf(_t('CMSMain.WORKTODO',"You have work to do on these <b>%d</b> pages."),$tasks->Count()),
));
} else {
$data = new ArrayData(array(
"Message" => _t('CMSMain.NOTHINGASSIGNED',"You have nothing assigned to you."),
));
}
return $data->renderWith("TaskList");
}
function waitingon() {
$tasks = DataObject::get("Page", "RequestedByID = " . Member::currentUserID(), "Created DESC");
if($tasks) {
$data = new ArrayData(array(
"Tasks" => $tasks,
"Message" => sprintf(_t('CMSMain.WAITINGON',"You are waiting on other people to work on these <b>%d</b> pages."),$tasks->Count()),
));
} else {
$data = new ArrayData(array(
"Message" => _t('CMSMain.NOWAITINGON','You aren\'t waiting on anybody.'),
));
}
return $data->renderWith("WaitingOn");
}
function comments() {
if($this->urlParams['ID']) {
$comments = DataObject::get("WorkflowPageComment", "PageID = " . $this->urlParams['ID'], "Created DESC");
$data = new ArrayData(array(
"Comments" => $comments,
));
return $data->renderWith("CommentList");
}
}
/**
* Return a dropdown for selecting reports
*/

View File

@ -14,18 +14,7 @@ function action_revert_right() {
}
});
}
/*function action_submit_right() {
$('action_submit_options').configure('CanApprove', 'Awaiting editor approval');
$('action_submit_options').toggle();
}*/
function action_reject_right() {
$('action_submit_options').configure('CanReject', 'Content declined');
$('action_submit_options').toggle();
}
function action_submit_right() {
$('action_submit_options').configure('CanPublish', 'Awaiting final approval');
$('action_submit_options').toggle();
}
function action_rollback_right() {
var options = {
OK: function() {
@ -66,21 +55,6 @@ function action_print_right() {
window.open(printURL, 'printable');
}
Submit_ActionPropertiesForm = Class.extend('ActionPropertiesForm');
Submit_ActionPropertiesForm.applyTo('#action_submit_options');
Submit_ActionPropertiesForm.prototype = {
/**
* Define how this form is to be used
*/
configure : function(securityLevel, status) {
this.securityLevel = securityLevel;
this.elements.Status.value = status
this.elements.Status.parentNode.getElementsByTagName('span')[0].innerHTML= status;
}
}
function suggestStageSiteLink() {
var el = $('viewStageSite');
el.flasher = setInterval(flashColor.bind(el), 300);

View File

@ -1,13 +0,0 @@
CommentList = Class.extend('SidePanel');
CommentList.prototype = {
destroy: function() {
if(this.SidePanel) this.SidePanel.destroy();
this.SidePanel = null;
},
onpagechanged : function() {
this.body.innerHTML = '<p>loading...</p>';
this.ajaxGetPanel(this.afterPanelLoaded);
}
}
CommentList.applyTo('#comments_holder');

View File

@ -334,75 +334,6 @@ function action_save_right() {
$('Form_EditForm').save(false);
}
ActionPropertiesForm = Class.create();
ActionPropertiesForm.prototype = {
/**
* Open the form
*/
open : function() {
var allInputs = this.getElementsByTagName('input');
this.submitButton = allInputs[allInputs.length-1];
this.submitButton.onclick = this.send.bind(this);
this.style.display = '';
// This detects whether we've opened a new page
if($('Form_EditForm').elements.ID.value != this.elements.ID.value) {
this.elements.ID.value = $('Form_EditForm').elements.ID.value;
new Ajax.Updater(
'action_submit_options_recipient',
'admin/getpagemembers/' + this.elements.ID.value + '?SecurityLevel=' + this.securityLevel
);
}
},
close : function() {
this.style.display = 'none';
},
toggle : function() {
if(this.style.display == '') this.close();
else this.open();
},
/**
* Submit the option form and carry out the action
*/
send : function() {
// Show a "submitting..." box
if(!this.sendingText) {
this.sendingText = document.createElement('div');
this.sendingText.innerHTML = 'Submitting...';
this.sendingText.className = 'sendingText';
Element.setOpacity(this.sendingText, 0.9);
this.appendChild(this.sendingText);
}
this.sendingText.style.display = '';
// Send the request
var buttons = document.getElementsBySelector('#' + this.id + ' .Actions input');
var actionButton = null;
if( buttons )
actionButton = buttons[0];
ajaxSubmitForm(false, this.onComplete.bind(this), this, actionButton ? actionButton.name : '', 'submit');
return false;
},
/**
* Process the action's Ajax response
*/
onComplete: function() {
this.sendingText.style.display = 'none';
if(this.elements.Message) this.elements.Message.value = '';
this.close();
$('Form_EditForm').getPageFromServer($('Form_EditForm_ID').value);
}
}
/**
* Handle auto-saving. Detects if changes have been made, and if so save everything on the page.
* If confirmation is true it will ask for confirmation.

View File

@ -1,21 +0,0 @@
TaskList = Class.extend('SidePanel');
TaskList.prototype = {
destroy: function() {
if(this.SidePanel) this.SidePanel.destroy();
this.SidePanel = null;
},
/**
* Called after the panel has been ajax-loaded in
*/
afterPanelLoaded : function() {
TaskListRecord.applyTo('#' + this.id + ' a');
}
}
TaskListRecord = SidePanelRecord;
TaskListRecord.applyTo('#tasklist_holder a');
TaskList.applyTo('#tasklist_holder');
TaskListRecord.applyTo('#waiting_holder a');
TaskList.applyTo('#waitingon_holder');

View File

@ -1,14 +0,0 @@
<% if Comments %>
<ul id="CommentList">
<% control Comments %>
<li class="$EvenOdd">
$Comment
<div class="extra">$Action $Created.Ago - $Author.FirstName&nbsp;$Author.Surname.Initial</div>
</li>
<% end_control %>
</ul>
<% else %>
<p><% _t('NOCOM','There are no comments on this page.') %></p>
<p><% _t('CREATEDW',"Comments are created whenever one of the 'workflow actions'
are undertaken - Publish, Reject, Submit.") %></p>
<% end_if %>

View File

@ -3,26 +3,6 @@
<div id="form_actions_right" class="ajaxActions">
</div>
<form class="actionparams" id="action_submit_options" style="display:none" action="admin/submit">
<fieldset>
<input type="hidden" name="ID" />
<div class="field" id="action_submit_options_recipient">
<label class="left"><% _t('SENDTO','Send to') %></label>
<span><% _t('LOADING','loading...') %></span>
</div>
<div class="field" id="action_submit_options_status">
<label class="left"><% _t('STATUS','Status') %></label>
<input type="hidden" name="Status" />
<span></span>
</div>
<p class="label"><% _t('ANYMESSAGE','Do you have any message for your editor?') %></p>
<textarea name="<% _t('MESSAGE','Message') %>" rows="4" cols="20"></textarea>
</fieldset>
<p class="actions">
<input type="submit" value="<% _t('SUBMIT','Submit for approval') %>" />
</p>
</form>
<% if EditForm %>
$EditForm
<% else %>

View File

@ -1,10 +0,0 @@
<p>$Message</p>
<ul id="TaskList">
<% control Tasks %>
<li class="$EvenOdd">
<a href="admin/show/$ID">$Title</a>
<div class="extra"><% _t('ATO','assigned to') %> $AssignedTo.FirstName&nbsp;$AssignedTo.Surname.Initial $LastEdited.Ago</div>
</li>
<% end_control %>
</ul>