function editComment() { $now = Komento::getDate()->toMySQL(); $profile = Komento::getProfile(); $config = Komento::getConfig(); $id = JRequest::getVar( 'id' ); $edittedComment = JRequest::getVar( 'edittedComment', '', 'post', '', JREQUEST_ALLOWRAW ); // use table instead of commentclass to avoid sending mail $commentObj = Komento::getTable( 'comments' ); $commentObj->load( $id ); $ajax = Komento::getAjax(); $acl = Komento::getHelper( 'Acl' ); if( $acl->allow( 'edit', $commentObj ) ) { // Length check if( trim( $edittedComment ) == '' ) { $ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_REQUIRED' ) ); $ajax->send(); } if( $config->get( 'antispam_min_length_enable' ) && JString::strlen( $edittedComment ) < $config->get( 'antispam_min_length' ) ) { $ajax->fail( '<p>' . JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_SHORT' ) . '. ' . JText::sprintf( 'COM_KOMENTO_FORM_CHARACTER_MIN', $config->get( 'antispam_min_length' ) ) . '.</p>' ); $ajax->send(); } if( $config->get( 'antispam_max_length_enable' ) && JString::strlen( $edittedComment ) > $config->get( 'antispam_max_length' ) ) { $ajax->fail( '<p>' . JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_LONG' ) . '. ' . JText::sprintf( 'COM_KOMENTO_FORM_CHARACTER_MAX', $config->get( 'antispam_max_length' ) ) . '.</p>' ); $ajax->send(); } $commentObj->comment = $edittedComment; $commentObj->modified_by = $profile->id; $commentObj->modified = $now; $result = 1; if( !$commentObj->store() ) { $result = 0; } $comment = KomentoCommentHelper::parseComment( $commentObj->comment ); if( $result ) { // success(parsed comment, modified date/time, by ) $ajax->success( $comment, $commentObj->modified, $profile->name ); } else { $errors = JText::_( 'COM_KOMENTO_ERROR' ); if( $commentObj->getErrors() ) { $errors = implode( '\n', $commentObj->getErrors() ); } $ajax->fail( $errors ); } } else { $ajax->fail( JText::_( 'COM_KOMENTO_ACL_NO_PERMISSION' ) ); } $ajax->send(); }