本文整理汇总了PHP中Publication::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP Publication::getError方法的具体用法?PHP Publication::getError怎么用?PHP Publication::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publication
的用法示例。
在下文中一共展示了Publication::getError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteReportedItem
/**
* Removes an item reported as abusive
*
* @param integer $referenceid ID of the database table row
* @param integer $parentid If the element has a parent element
* @param string $category Element type (determines table to look in)
* @param string $message Message to user to append to
* @return string
*/
public function deleteReportedItem($referenceid, $parentid, $category, $message)
{
if ($category != 'pubreview' && $category != 'pubreviewcomment') {
return null;
}
$this->loadLanguage();
$msg = Lang::txt('PLG_SUPPORT_PUBLICATIONS_CONTENT_FOUND_OBJECTIONABLE');
$database = App::get('db');
switch ($category) {
case 'review':
include_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'publication.php';
include_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'review.php';
// Delete the review
$review = new PublicationReview($database);
$review->load($referenceid);
//$comment->anonymous = 1;
if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $review->comment, $matches)) {
$format = strtolower(trim($matches[1]));
switch ($format) {
case 'html':
$review->comment = '<!-- {FORMAT:HTML} --><span class="warning">' . $msg . '</span>';
break;
case 'wiki':
default:
$review->comment = '<!-- {FORMAT:WIKI} -->[[Span(' . $msg . ', class="warning")]]';
break;
}
} else {
$review->comment = '[[Span(' . $msg . ', class="warning")]]';
}
$review->store();
// Recalculate the average rating for the parent resource
$pub = new Publication($database);
$pub->load($parentid);
$pub->calculateRating();
$pub->updateRating();
if (!$pub->store()) {
$this->setError($pub->getError());
return false;
}
$message .= Lang::txt('PLG_SUPPORT_PUBLICATIONS_NOTIFICATION_OF_REMOVAL', $parentid);
break;
case 'reviewcomment':
$comment = \Hubzero\Item\Comment::oneOrFail($referenceid);
if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $comment->get('content'), $matches)) {
$format = strtolower(trim($matches[1]));
switch ($format) {
case 'html':
$comment->set('content', '<!-- {FORMAT:HTML} --><span class="warning">' . $msg . '</span>');
break;
case 'wiki':
default:
$comment->set('content', '<!-- {FORMAT:WIKI} -->[[Span(' . $msg . ', class="warning")]]');
break;
}
} else {
$comment->set('content', '[[Span(' . $msg . ', class="warning")]]');
}
if (!$comment->save()) {
$this->setError($comment->getError());
return false;
}
$message .= Lang::txt('PLG_SUPPORT_PUBLICATIONS_NOTIFICATION_OF_REMOVAL', $parentid);
break;
}
return $message;
}