本文整理汇总了PHP中ArtefactTypeComment::get_comment_options方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactTypeComment::get_comment_options方法的具体用法?PHP ArtefactTypeComment::get_comment_options怎么用?PHP ArtefactTypeComment::get_comment_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactTypeComment
的用法示例。
在下文中一共展示了ArtefactTypeComment::get_comment_options方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
if ($editing) {
$smarty = smarty_core();
$smarty->assign('editing', get_string('ineditordescription1', 'blocktype.comment/comment'));
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
// Feedback list pagination requires limit/offset params
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$showcomment = param_integer('showcomment', null);
// Create the "make feedback private form" now if it's been submitted
if (param_variable('make_public_submit', null)) {
pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
} else {
if (param_variable('delete_comment_submit_x', null)) {
pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
}
}
$view = new View($instance->get('view'));
$submittedgroup = (int) $view->get('submittedgroup');
if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
$releaseform = true;
} else {
$releaseform = false;
}
// If the view has comments turned off, tutors can still leave
// comments if the view is submitted to their group.
if (!empty($releaseform) || $view->user_comments_allowed($USER)) {
$addfeedbackpopup = true;
}
safe_require('artefact', 'comment');
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = $limit;
$commentoptions->offset = $offset;
$commentoptions->showcomment = $showcomment;
$commentoptions->view = $instance->get_view();
$feedback = ArtefactTypeComment::get_comments($commentoptions);
$smarty = smarty_core();
$smarty->assign('feedback', $feedback);
if (isset($addfeedbackpopup)) {
$smarty->assign('enablecomments', 1);
$smarty->assign('addfeedbackpopup', $addfeedbackpopup);
}
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
示例2: function
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
// If the view has comments turned off, tutors can still leave
// comments if the view is submitted to their group.
if (!empty($releaseform) || ($commenttype = $view->user_comments_allowed($USER))) {
$defaultprivate = !empty($releaseform);
$moderate = isset($commenttype) && $commenttype === 'private';
$addfeedbackform = pieform(ArtefactTypeComment::add_comment_form($defaultprivate, $moderate));
}
if ($USER->is_logged_in()) {
$objectionform = pieform(objection_form());
if ($notrudeform = notrude_form()) {
$notrudeform = pieform($notrudeform);
}
}
$viewbeingwatched = (int) record_exists('usr_watchlist_view', 'usr', $USER->get('id'), 'view', $viewid);
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = $limit;
$commentoptions->offset = $offset;
$commentoptions->showcomment = $showcomment;
$commentoptions->view = $view;
$feedback = ArtefactTypeComment::get_comments($commentoptions);
// Set up theme
$viewtheme = $view->get('theme');
if ($viewtheme && $THEME->basename != $viewtheme) {
$THEME = new Theme($viewtheme);
}
$headers = array();
$headers[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'js/jquery/jquery-ui/css/ui-lightness/jquery-ui-1.10.2.min.css') . '">';
$headers = array_merge($headers, $view->get_all_blocktype_css());
// Set up skin, if the page has one
$viewskin = $view->get('skin');
示例3: dump_view_export_data
/**
* Dumps all views into the HTML export
*/
private function dump_view_export_data()
{
safe_require('artefact', 'comment');
$progressstart = 55;
$progressend = 75;
$i = 0;
$viewcount = count($this->views);
$rootpath = $this->exportingoneview ? './' : '../../';
$smarty = $this->get_smarty($rootpath);
foreach ($this->views as $viewid => $view) {
$this->notify_progress_callback(intval($progressstart + ++$i / $viewcount * ($progressend - $progressstart)), get_string('exportingviewsprogress', 'export', $i, $viewcount));
$smarty->assign('page_heading', $view->get('title'));
$smarty->assign('viewdescription', $view->get('description'));
if ($this->exportingoneview) {
$smarty->assign('nobreadcrumbs', true);
$directory = $this->exportdir . '/' . $this->rootdir;
} else {
$smarty->assign('breadcrumbs', array(array('text' => get_string('Views', 'view')), array('text' => $view->get('title'), 'path' => 'index.html')));
$directory = $this->exportdir . '/' . $this->rootdir . '/views/' . self::text_to_filename($view->get('title'));
if (is_dir($directory)) {
throw new SystemException(get_string('duplicatepagetitle', 'export.html'));
}
if (!check_dir_exists($directory)) {
throw new SystemException("Could not create directory for view {$viewid}");
}
}
// Collection menu data
if (isset($this->viewcollection[$viewid]) && $this->viewexportmode == PluginExport::EXPORT_COLLECTIONS) {
$smarty->assign_by_ref('collectionname', $this->collections[$this->viewcollection[$viewid]]->get('name'));
$smarty->assign_by_ref('collectionmenu', $this->collection_menu($this->viewcollection[$viewid]));
$smarty->assign('viewid', $viewid);
}
$outputfilter = new HtmlExportOutputFilter($rootpath, $this);
// Include comments
if ($this->includefeedback) {
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->view = $view;
$commentoptions->limit = 0;
$commentoptions->export = true;
if ($feedback = ArtefactTypeComment::get_comments($commentoptions)) {
$feedback->tablerows = $outputfilter->filter($feedback->tablerows);
}
$smarty->assign('feedback', $feedback);
}
$smarty->assign('view', $outputfilter->filter($view->build_rows(false, true)));
$content = $smarty->fetch('export:html:view.tpl');
if (!file_put_contents("{$directory}/index.html", $content)) {
throw new SystemException("Could not write view page for view {$viewid}");
}
}
}
示例4: get_artefact_comments_for_view
/**
* Fetching the comments for an artefact to display on a view
*
* @param ArtefactType $artfact The artefact to display comments for
* @param object $view The view on which the artefact appears
* @param int $blockid The id of the block instance that connects the artefact to the view
* @param bool $html Whether to return the information rendered as html or not
* @param bool $editing Whether we are view edit mode or not
*
* @return array $commentcount, $comments The count of comments and either the comments
* or the html to render them.
*/
public function get_artefact_comments_for_view(ArtefactType $artefact, $view, $blockid, $html = true, $editing = false)
{
global $USER;
if (!is_object($artefact) || !is_object($view)) {
throw new MaharaException('we do not have the right information to display the comments');
}
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = 0;
$commentoptions->view = $view;
$commentoptions->artefact = $artefact;
$commentoptions->onview = true;
$comments = ArtefactTypeComment::get_comments($commentoptions);
$commentcount = isset($comments->count) ? $comments->count : 0;
// If there are no comments, and comments are not allowed, don't display anything.
if ($commentcount == 0 && !$artefact->get('allowcomments')) {
return array(0, '');
}
$artefacttitle = $artefact->title;
$artefacturl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $view->get('id') . '&artefact=' . $artefact->get('id');
if ($html) {
$smarty = smarty_core();
$smarty->assign('artefacturl', $artefacturl);
$smarty->assign('artefacttitle', $artefacttitle);
$smarty->assign('blockid', $blockid);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$smarty->assign('editing', $editing);
$smarty->assign('allowcomments', $artefact->get('allowcomments'));
$smarty->assign('allowcommentsadd', $artefact->get('allowcomments') && ($USER->is_logged_in() || !$USER->is_logged_in() && get_config('anonymouscomments')));
$render = $smarty->fetch('artefact/artefactcommentsview.tpl');
return array($commentcount, $render);
} else {
return array($commentcount, $comments);
}
}
示例5: institution_submit
function institution_submit(Pieform $form, $values)
{
global $SESSION, $institution, $add, $instancearray, $USER, $authinstances, $customthemedefaults;
db_begin();
// Update the basic institution record...
if ($add) {
$newinstitution = new Institution();
$newinstitution->initialise($values['name'], $values['displayname']);
$institution = $newinstitution->name;
} else {
$newinstitution = new Institution($institution);
$newinstitution->displayname = $values['displayname'];
$oldinstitution = get_record('institution', 'name', $institution);
// Clear out any cached menus for this institution
clear_menu_cache($institution);
}
$newinstitution->showonlineusers = !isset($values['showonlineusers']) ? 2 : $values['showonlineusers'];
if (get_config('usersuniquebyusername')) {
// Registering absolutely not allowed when this setting is on, it's a
// security risk. See the documentation for the usersuniquebyusername
// setting for more information
$newinstitution->registerallowed = 0;
} else {
$newinstitution->registerallowed = $values['registerallowed'] ? 1 : 0;
$newinstitution->registerconfirm = $values['registerconfirm'] ? 1 : 0;
}
if (!empty($values['lang'])) {
if ($values['lang'] == 'sitedefault') {
$newinstitution->lang = null;
} else {
$newinstitution->lang = $values['lang'];
}
}
$newinstitution->theme = empty($values['theme']) || $values['theme'] == 'sitedefault' ? null : $values['theme'];
$newinstitution->dropdownmenu = !empty($values['dropdownmenu']) ? 1 : 0;
$newinstitution->skins = !empty($values['skins']) ? 1 : 0;
require_once get_config('docroot') . 'artefact/comment/lib.php';
$commentoptions = ArtefactTypeComment::get_comment_options();
$newinstitution->commentsortorder = empty($values['commentsortorder']) ? $commentoptions->sort : $values['commentsortorder'];
$newinstitution->commentthreaded = !empty($values['commentthreaded']) ? 1 : 0;
if ($newinstitution->theme == 'custom') {
if (!empty($oldinstitution->style)) {
$styleid = $oldinstitution->style;
delete_records('style_property', 'style', $styleid);
} else {
$record = (object) array('title' => get_string('customstylesforinstitution', 'admin', $newinstitution->displayname));
$styleid = insert_record('style', $record, 'id', true);
}
$properties = array();
$record = (object) array('style' => $styleid);
foreach (array_keys($customthemedefaults) as $name) {
$record->field = $name;
$record->value = $values[$name];
insert_record('style_property', $record);
$properties[$name] = $values[$name];
}
// Cache the css
$smarty = smarty_core();
$smarty->assign('data', $properties);
set_field('style', 'css', $smarty->fetch('customcss.tpl'), 'id', $styleid);
$newinstitution->style = $styleid;
} else {
$newinstitution->style = null;
}
if (get_config('licensemetadata')) {
$newinstitution->licensemandatory = !empty($values['licensemandatory']) ? 1 : 0;
$newinstitution->licensedefault = isset($values['licensedefault']) ? $values['licensedefault'] : '';
}
if (!empty($values['resetcustom']) && !empty($oldinstitution->style)) {
$newinstitution->style = null;
}
if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
if (!empty($values['updateuserquotas']) && !empty($values['defaultquota'])) {
execute_sql("UPDATE {usr} SET quota = ? WHERE id IN (SELECT usr FROM {usr_institution} WHERE institution = ?)", array($values['defaultquota'], $institution));
// get all the users from the institution and make sure that they are still below
// their quota threshold
if ($users = get_records_sql_array('SELECT * FROM {usr} u LEFT JOIN {usr_institution} ui ON u.id = ui.usr AND ui.institution = ?', array($institution))) {
$quotanotifylimit = get_config_plugin('artefact', 'file', 'quotanotifylimit');
if ($quotanotifylimit <= 0 || $quotanotifylimit >= 100) {
$quotanotifylimit = 100;
}
foreach ($users as $user) {
$user->quota = $values['defaultquota'];
// check if the user has gone over the quota notify limit
$user->quotausedpercent = $user->quotaused / $user->quota * 100;
$overlimit = false;
if ($quotanotifylimit <= $user->quotausedpercent) {
$overlimit = true;
}
$notified = get_field('usr_account_preference', 'value', 'field', 'quota_exceeded_notified', 'usr', $user->id);
if ($overlimit && '1' !== $notified) {
require_once get_config('docroot') . 'artefact/file/lib.php';
ArtefactTypeFile::notify_users_threshold_exceeded(array($user), false);
// no need to email admin as we can alert them right now
$SESSION->add_error_msg(get_string('useroverquotathreshold', 'artefact.file', display_name($user)));
} else {
if ($notified && !$overlimit) {
set_account_preference($user->id, 'quota_exceeded_notified', false);
}
}
//.........这里部分代码省略.........