本文整理汇总了PHP中comment::can_view方法的典型用法代码示例。如果您正苦于以下问题:PHP comment::can_view方法的具体用法?PHP comment::can_view怎么用?PHP comment::can_view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comment
的用法示例。
在下文中一共展示了comment::can_view方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
echo json_encode($result);
die;
}
}
break;
case 'delete':
$comment_record = $DB->get_record('comments', array('id' => $commentid));
if ($manager->can_delete($commentid) || $comment_record->userid == $USER->id) {
if ($manager->delete($commentid)) {
$result = array('client_id' => $client_id, 'commentid' => $commentid);
echo json_encode($result);
die;
}
}
break;
case 'get':
default:
if ($manager->can_view()) {
$comments = $manager->get_comments($page);
$result = array('list' => $comments, 'count' => $manager->count(), 'pagination' => $manager->get_pagination($page), 'client_id' => $client_id);
echo json_encode($result);
die;
}
break;
}
if (!isloggedin()) {
// tell user to log in to view comments
echo json_encode(array('error' => 'require_login'));
}
// ignore request
die;
示例2: get_component_comments_since
/**
* Get comments created since a given time.
*
* @param stdClass $course course object
* @param stdClass $context context object
* @param string $component component name
* @param int $since the time to check
* @param stdClass $cm course module object
* @return array list of comments db records since the given timelimit
* @since Moodle 3.2
*/
public function get_component_comments_since($course, $context, $component, $since, $cm = null)
{
global $DB;
$commentssince = array();
$where = 'contextid = ? AND component = ? AND timecreated > ?';
$comments = $DB->get_records_select('comments', $where, array($context->id, $component, $since));
// Check item by item if we have permissions.
$managersviewstatus = array();
foreach ($comments as $comment) {
// Check if the manager for the item is cached.
if (!isset($managersviewstatus[$comment->commentarea]) or !isset($managersviewstatus[$comment->commentarea][$comment->itemid])) {
$args = new stdClass();
$args->area = $comment->commentarea;
$args->itemid = $comment->itemid;
$args->context = $context;
$args->course = $course;
$args->client_id = 0;
$args->component = $component;
if (!empty($cm)) {
$args->cm = $cm;
}
$manager = new comment($args);
$managersviewstatus[$comment->commentarea][$comment->itemid] = $manager->can_view();
}
if ($managersviewstatus[$comment->commentarea][$comment->itemid]) {
$commentssince[$comment->id] = $comment;
}
}
return $commentssince;
}