Beispiel #1
0
		document.redirectForm.thread_id.value = tid;
		document.redirectForm.page.value = 1;
		document.redirectForm.submit ();
	}

	function replyToComment (cid) {
		document.redirectForm.action = "view_thread.php";
		document.redirectForm.paction.value = "composeReply";
		document.redirectForm.comment_id.value = cid;
		document.redirectForm.submit ();
	}
</script>

<?php 
//$curr_discussion = new Discussion ($_POST["discussion_id"], true);
$curr_thread = new DiscussionThread($discussion_id, $thread_id, true);
$pages = ceil(count($curr_discussion->discussionComments) / $MAX_PAGE_COMMENTS);
?>

<form name="redirectForm" action="view_thread.php" method="post">
	<input type="hidden" name="paction" value="">
	<input type="hidden" name="page" value="">
	<input type="hidden" name="discussion_id" value="<?php 
echo $curr_thread->discussionID;
?>
">
	<input type="hidden" name="thread_id" value="<?php 
echo $curr_thread->threadID;
?>
">
	<input type="hidden" name="comment_id" value="">
 function do_changestate()
 {
     $aErrorOptions = array('redirect_to' => array('main', sprintf('fDocumentId=%d', $this->oDocument->getId())));
     $iThreadId = KTUtil::arrayGet($_REQUEST, 'fThreadId');
     $oThread = DiscussionThread::get($iThreadId);
     $this->oValidator->notError($oThread, $aErrorOptions);
     $aErrorOptions = array('redirect_to' => array('viewthread', sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId())));
     $oPermission =& KTPermission::getByName('ktcore.permissions.workflow');
     $sRedirectTo = implode('&', $aErrorOptions['redirect_to']);
     if (PEAR::isError($oPermission)) {
         $this->errorRedirectTo($sRedirectTo, _kt("Error getting permission"));
         exit(0);
     }
     if (!KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) {
         $this->errorRedirectTo($sRedirectTo, _kt("You do not have permission to close this thread"));
         exit(0);
     }
     $iStateId = KTUtil::arrayGet($_REQUEST, 'state');
     if (!in_array($iStateId, $this->aTransitions[$oThread->getState()])) {
         $this->errorRedirectTo($sRedirectTo, _kt("Invalid transition"));
         exit(0);
     }
     $aErrorOptions['message'] = _kt("No reason provided");
     $sReason = $this->oValidator->validateString(KTUtil::arrayGet($_REQUEST, 'reason'), $aErrorOptions);
     if ($iStateId > $oThread->getState()) {
         $sTransactionNamespace = 'ktcore.transactions.collaboration_step_approve';
     } else {
         $sTransactionNamespace = 'ktcore.transactions.collaboration_step_rollback';
     }
     // Start the transaction comment creation
     $this->startTransaction();
     $oThread->setState($iStateId);
     if ($iStateId == DISCUSSION_CLOSED) {
         $oThread->setCloseMetadataVersion($this->oDocument->getMetadataVersion());
     } else {
         if ($iStateId == DISCUSSION_CONCLUSION) {
             $oThread->setCloseReason($sReason);
         }
     }
     $oDocumentTransaction = new DocumentTransaction($this->oDocument, $sReason, $sTransactionNamespace);
     $oDocumentTransaction->create();
     $res = $oThread->update();
     $aErrorOptions['message'] = _kt("There was an error updating the thread with the new comment");
     $this->oValidator->notError($res, $aErrorOptions);
     // Thread closed correctly, so commit
     $this->commitTransaction();
     $this->successRedirectTo('viewThread', _kt("Thread state changed"), sprintf('fDocumentId=%d&fThreadId=%d', $this->oDocument->getId(), $oThread->getId()));
     exit(0);
 }