Hey Willr,
Thanks for your reply.
For your solution, I thought its bit complex for me.
Currently, what i am doing is to get it done on Forum.php.
function AdminFormFeatures() {
if (!$this->canPost()) return;
$id = (isset($this->urlParams['ID'])) ? $this->urlParams['ID'] : false;
$fields = new FieldList(
new CheckboxField('IsReadOnly', _t('Forum.ISREADONLYTHREAD','Is this query solved?')),
new HiddenField("ID", "Thread")
);
if(($forums = Forum::get()) && $forums->exists()) {
$fields->push(new DropdownField("ForumID", _t('Forum.CHANGETHREADFORUM',"Change Thread Forum"), $forums->map('ID', 'Title', 'Select New Category:')), '', null, 'Select New Location:');
}
$actions = new FieldList(
new FormAction('doAdminFormFeatures', _t('Forum.SAVE', 'Save'))
);
$form = new Form($this, 'AdminFormFeatures', $fields, $actions);
// need this id wrapper since the form method is called on save as
// well and needs to return a valid form object
if($id) {
$thread = ForumThread::get()->byID($id);
$form->loadDataFrom($thread);
}
return $form;
}
/**
* Process's the moving of a given topic. Has to check for admin privledges,
* passed an old topic id (post id in URL) and a new topic id
*/
function doAdminFormFeatures($data, $form) {
if(isset($data['ID'])) {
$thread = ForumThread::get()->byID($data['ID']);
if($thread) {
if (!$thread->canPost()) {
return Security::permissionFailure($this);
}
$form->saveInto($thread);
$thread->write();
}
}
return $this->redirect($this->Link());
}
}
Basically, I have replaced 'canModerator' with 'canPost'. So as non-admin or non-moderator can switch this thread into readonly mode.
However, there are two issues which are bothering me a lot.
1. Even I have changed 'Is this a Read only Thread? ' into 'Is this query solved' on Forum.php, however, it doesnt show up on the site. Also, I couldn't any other code could be possible to store this label.
2. I only wish the topic author can switch this thread into readonly mode. What's the code?
Thanks so much for your help.