本文整理汇总了PHP中display_default_name函数的典型用法代码示例。如果您正苦于以下问题:PHP display_default_name函数的具体用法?PHP display_default_name怎么用?PHP display_default_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了display_default_name函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Dwoo_Plugin_display_default_name
/**
* Dwoo {display_default_name} function plugin
*
* Type: function<br>
* Date: 2012-06-11<br>
* Purpose: Escape output of display_default_name for use in templates
* @version 1.0
*/
function Dwoo_Plugin_display_default_name(Dwoo $dwoo, $user)
{
if (!$user) {
return '';
}
return hsc(display_default_name($user));
}
示例2: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
require_once get_config('docroot') . 'artefact/lib.php';
$smarty = smarty_core();
$configdata = $instance->get('configdata');
$data = array();
$data['socialprofiles'] = array();
// add in the selected email address
if (!empty($configdata['email'])) {
$configdata['artefactids'][] = $configdata['email'];
}
$viewowner = get_field('view', 'owner', 'id', $instance->get('view'));
// Get data about the profile fields in this blockinstance
if (!empty($configdata['artefactids'])) {
foreach ($configdata['artefactids'] as $id) {
try {
$artefact = artefact_instance_from_id($id);
if (is_a($artefact, 'ArtefactTypeProfile') && $artefact->get('owner') == $viewowner) {
$rendered = $artefact->render_self(array('link' => true));
$artefacttype = $artefact->get('artefacttype');
if ($artefacttype == 'socialprofile') {
if (get_record('blocktype_installed', 'active', 1, 'name', 'socialprofile', 'artefactplugin', 'internal')) {
$data['socialprofiles'][] = array('link' => ArtefactTypeSocialprofile::get_profile_link($artefact->get('title'), $artefact->get('note')), 'title' => $artefact->get('title'), 'description' => $artefact->get('description'), 'note' => $artefact->get('note'));
}
} else {
$data[$artefacttype] = $rendered['html'];
}
}
} catch (ArtefactNotFoundException $e) {
log_debug('Artefact not found when rendering a block instance. ' . 'There might be a bug with deleting artefacts of this type? ' . 'Original error follows:');
log_debug($e->getMessage());
}
}
// Sort social profiles alphabetically (in ASC order)
$description = array();
foreach ($data['socialprofiles'] as $key => $row) {
$description[$key] = $row['description'];
}
array_multisort($description, SORT_ASC, $data['socialprofiles']);
}
// Work out the path to the thumbnail for the profile image
if (!empty($configdata['profileicon'])) {
$downloadpath = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $configdata['profileicon'];
$downloadpath .= '&maxwidth=80';
$smarty->assign('profileiconpath', $downloadpath);
$smarty->assign('profileiconalt', get_string('profileimagetext', 'mahara', display_default_name(get_user($viewowner))));
}
// Override the introduction text if the user has any for this
// particular blockinstance
if (!empty($configdata['introtext'])) {
$data['introduction'] = $configdata['introtext'];
}
$smarty->assign('profileinfo', $data);
return $smarty->fetch('blocktype:profileinfo:content.tpl');
}
示例3: display_name
/**
* converts a user object to a string representation of the user suitable for
* the current user (or specified user) to see
*
* Both parameters should be objects containing id, preferredname, firstname,
* lastname, admin
*
* @param object $user the user that you're trying to format to a string
* @param object $userto the user that is looking at the string representation (if left
* blank, will default to the currently logged in user).
* @param boolean $nameonly do not append the user's username even if $userto can see it.
* @param boolean $realname show the user's real name even if preferredname exists
* @param boolean $username show the user's username even if the viewer is not an admin
*
* @returns string name to display
*/
function display_name($user, $userto = null, $nameonly = false, $realname = false, $username = false)
{
global $USER;
static $tutorcache = array();
static $usercache = array();
if ($nameonly) {
return display_default_name($user);
}
if (empty($userto)) {
$userto = new StdClass();
$userto->id = $USER->get('id');
$userto->username = $USER->get('username');
$userto->preferredname = $USER->get('preferredname');
$userto->firstname = $USER->get('firstname');
$userto->lastname = $USER->get('lastname');
$userto->admin = $USER->get('admin') || $USER->is_institutional_admin();
$userto->staff = $USER->get('staff') || $USER->is_institutional_staff();
} else {
if (is_numeric($userto)) {
if (isset($usercache[$userto])) {
$userto = $usercache[$userto];
} else {
if ($userto == $USER->get('id')) {
$userto = new StdClass();
$userto->id = $USER->get('id');
$userto->username = $USER->get('username');
$userto->preferredname = $USER->get('preferredname');
$userto->firstname = $USER->get('firstname');
$userto->lastname = $USER->get('lastname');
$userto->admin = $USER->get('admin') || $USER->is_institutional_admin();
$userto->staff = $USER->get('staff') || $USER->is_institutional_staff();
$usercache[$userto->id] = $userto;
} else {
$userto = $usercache[$userto] = get_record('usr', 'id', $userto);
}
}
}
}
if (is_array($user)) {
$user = (object) $user;
} else {
if (is_numeric($user)) {
if (isset($usercache[$user])) {
$user = $usercache[$user];
} else {
if ($user == $USER->get('id')) {
$user = new StdClass();
$user->id = $USER->get('id');
$user->username = $USER->get('username');
$user->preferredname = $USER->get('preferredname');
$user->firstname = $USER->get('firstname');
$user->lastname = $USER->get('lastname');
$user->admin = $USER->get('admin') || $USER->is_institutional_admin();
$user->staff = $USER->get('staff') || $USER->is_institutional_staff();
$user->deleted = 0;
$usercache[$user->id] = $user;
} else {
$user = $usercache[$user] = get_record('usr', 'id', $user);
}
}
}
}
if (!is_object($user)) {
throw new InvalidArgumentException("Invalid user passed to display_name");
}
if ($user instanceof User) {
$userObj = $user;
$user = new StdClass();
$user->id = $userObj->get('id');
$user->username = $userObj->get('username');
$user->preferredname = $userObj->get('preferredname');
$user->firstname = $userObj->get('firstname');
$user->lastname = $userObj->get('lastname');
$user->admin = $userObj->get('admin');
$user->staff = $userObj->get('staff');
$user->deleted = $userObj->get('deleted');
}
$user->id = isset($user->id) ? $user->id : null;
$userto->id = isset($userto->id) ? $userto->id : null;
$addusername = $username || !empty($userto->admin) || !empty($userto->staff);
// if they don't have a preferred name set, just return here
if (empty($user->preferredname)) {
$firstlast = full_name($user);
if ($addusername) {
//.........这里部分代码省略.........
示例4: get_htmlmessage
public function get_htmlmessage($user)
{
$viewtitle = hsc($this->view->get('title'));
$reportername = hsc(display_default_name($this->reporter));
$reporterurl = profile_url($this->reporter);
$ctime = strftime(get_string_from_language($user->lang, 'strftimedaydatetime'), $this->ctime);
$message = hsc($this->message);
if (empty($this->artefact)) {
return get_string_from_language($user->lang, 'objectionablecontentviewhtml', 'activity', $viewtitle, $reportername, $ctime, $message, $this->view->get_url(), $viewtitle, $reporterurl, $reportername);
} else {
return get_string_from_language($user->lang, 'objectionablecontentviewartefacthtml', 'activity', $viewtitle, hsc($this->artefact->get('title')), $reportername, $ctime, $message, $this->view->get_url(), $viewtitle, $reporterurl, $reportername);
}
}
示例5: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
$configdata = $instance->get('configdata');
$view = $instance->get('view');
$full = isset($configdata['full']) ? $configdata['full'] : false;
$results = array();
$smarty = smarty_core();
$smarty->assign('view', $view);
$viewownerdisplay = null;
// Display all posts, from all blogs, owned by this user
$tagsin = $tagsout = array();
$results = self::get_blog_posts_in_block($instance, $tagsin, $tagsout);
if ($tagsin || $tagsout) {
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('editing', $editing);
if ($editing) {
// Get list of blogs owned by this user to create the "Add new post" shortcut while editing
$viewowner = $instance->get_view()->get('owner');
if (!$viewowner || !($blogs = get_records_select_array('artefact', 'artefacttype = \'blog\' AND owner = ?', array($viewowner), 'title ASC', 'id, title'))) {
$blogs = array();
}
$smarty->assign('tagselect', implode(', ', $tagsin));
$smarty->assign('blogs', $blogs);
}
// if posts are not found with the selected tag, notify the user
if (!$results) {
$smarty->assign('badtag', implode(', ', $tagsin));
$smarty->assign('badnotag', implode(', ', $tagsout));
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
}
// update the view_artefact table so journal entries are accessible when this is the only block on the page
// referencing this journal
$dataobject = array('view' => $view, 'block' => $instance->get('id'));
require_once get_config('docroot') . 'lib/view.php';
$viewobj = new View($view);
require_once get_config('docroot') . 'artefact/lib.php';
safe_require('artefact', 'blog');
safe_require('artefact', 'comment');
foreach ($results as $result) {
$dataobject["artefact"] = $result->parent;
$result->postedbyon = get_string('postedbyon', 'artefact.blog', display_default_name($result->owner), format_date(strtotime($result->ctime)));
$result->displaydate = format_date(strtotime($result->ctime));
$artefact = new ArtefactTypeBlogpost($result->id);
// get comments for this post
$result->commentcount = count_records_select('artefact_comment_comment', "onartefact = {$result->id} AND private = 0 AND deletedby IS NULL");
$allowcomments = $artefact->get('allowcomments');
if (empty($result->commentcount) && empty($allowcomments)) {
$result->commentcount = null;
}
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $viewobj, null, false);
$result->comments = $comments;
// get all tags for this post
$taglist = get_records_array('artefact_tag', 'artefact', $result->id, "tag DESC");
foreach ($taglist as $t) {
$result->taglist[] = $t->tag;
}
if ($full) {
$rendered = $artefact->render_self(array('viewid' => $view, 'details' => true, 'blockid' => $instance->get('id')));
$result->html = $rendered['html'];
if (!empty($rendered['javascript'])) {
$result->html .= '<script type="application/javascript">' . $rendered['javascript'] . '</script>';
}
}
}
// check if the user viewing the page is the owner of the selected tag
$owner = $results[0]->owner;
if ($USER->id != $owner) {
$viewownerdisplay = get_user_for_display($owner);
}
$smarty->assign('tagsin', $tagsin);
$smarty->assign('tagsout', $tagsout);
} else {
if (!self::get_chooseable_tags()) {
// error if block configuration fails
$smarty->assign('configerror', get_string('notagsavailableerror', 'blocktype.blog/taggedposts'));
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
} else {
// error if block configuration fails
$smarty->assign('configerror', get_string('configerror', 'blocktype.blog/taggedposts'));
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
}
}
// add any needed links to the tags
$tagstr = $tagomitstr = '';
foreach ($tagsin as $key => $tag) {
if ($key > 0) {
$tagstr .= ', ';
}
$tagstr .= $viewownerdisplay ? '"' . $tag . '"' : '"<a href="' . get_config('wwwroot') . 'tags.php?tag=' . $tag . '&sort=name&type=text">' . $tag . '</a>"';
}
if (!empty($tagsout)) {
foreach ($tagsout as $key => $tag) {
if ($key > 0) {
$tagomitstr .= ', ';
}
$tagomitstr .= $viewownerdisplay ? '"' . $tag . '"' : '"<a href="' . get_config('wwwroot') . 'tags.php?tag=' . $tag . '&sort=name&type=text">' . $tag . '</a>"';
}
}
$blockheading = get_string('blockheadingtags', 'blocktype.blog/taggedposts', count($tagsin), $tagstr);
//.........这里部分代码省略.........
示例6: notrude_form_submit
function notrude_form_submit(Pieform $form, $values)
{
global $view, $artefact, $USER;
require_once 'activity.php';
db_begin();
$objection = new stdClass();
if ($artefact) {
$objection->objecttype = 'artefact';
$objection->objectid = $artefact->get('id');
} else {
$objection->objecttype = 'view';
$objection->objectid = $view->get('id');
}
$objection->resolvedby = $USER->get('id');
$objection->resolvedtime = db_format_timestamp(time());
update_record('objectionable', $objection, array('id' => $values['objection']));
// Send notification to other admins.
$reportername = display_default_name($USER);
if ($artefact) {
$goto = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $artefact->get('id') . '&view=' . $view->get('id');
} else {
$goto = $view->get_url();
}
$data = (object) array('view' => $view->get('id'), 'reporter' => $USER->get('id'), 'subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'viewunobjectionablesubject', 'section' => 'view', 'args' => array($view->get('title'), $reportername)), 'message' => (object) array('key' => 'viewunobjectionablebody', 'section' => 'view', 'args' => array($reportername, $view->get('title'), $view->formatted_owner()))));
activity_occurred('objectionable', $data);
db_commit();
$form->reply(PIEFORM_OK, array('message' => get_string('messagesent'), 'goto' => $goto));
}
示例7: display_name
/**
* converts a user object to a string representation of the user suitable for
* the current user (or specified user) to see
*
* Both parameters should be objects containing id, preferredname, firstname,
* lastname, admin
*
* @param mixed $user the user that you're trying to format to a string (accepts an integer, object, or array)
* @param object $userto the user that is looking at the string representation (if left
* blank, will default to the currently logged in user).
* @param boolean $nameonly do not append the user's username even if $userto can see it.
* @param boolean $realname show the user's real name even if preferredname exists
* @param boolean $username show the user's username even if the viewer is not an admin
*
* @returns string name to display
*/
function display_name($user, $userto = null, $nameonly = false, $realname = false, $username = false)
{
global $USER;
static $tutorcache = array();
if ($nameonly) {
return display_default_name($user);
}
$nousernames = get_config('nousernames');
$userto = get_user_for_display($userto);
$user = get_user_for_display($user);
$addusername = $username && empty($nousernames) || !empty($userto->admin) || !empty($userto->staff);
// if they don't have a preferred name set, just return here
if (empty($user->preferredname)) {
$firstlast = full_name($user);
if ($addusername) {
return $firstlast . ' (' . display_username($user) . ')';
}
return $firstlast;
} else {
if ($user->id == $userto->id) {
// If viewing our own name, show it how we like it
return $user->preferredname;
}
}
// Preferred name is set
$addrealname = $realname || !empty($userto->admin) || !empty($userto->staff);
if (!$addrealname) {
// Tutors can always see the user's real name, so we need to check if the
// viewer is a tutor of the user whose name is being displayed
if (!isset($tutorcache[$user->id][$userto->id])) {
$tutorcache[$user->id][$userto->id] = record_exists_sql('
SELECT s.member
FROM {group_member} s
JOIN {group_member} t ON s.group = t.group
JOIN {group} g ON (g.id = s.group AND g.deleted = 0 AND g.submittableto = 1)
JOIN {grouptype_roles} gtr
ON (g.grouptype = gtr.grouptype AND gtr.role = t.role AND gtr.see_submitted_views = 1)
WHERE s.member = ? AND t.member = ?', array($user->id, $userto->id));
}
$addrealname = $tutorcache[$user->id][$userto->id];
}
if ($addrealname) {
$firstlast = full_name($user);
if ($addusername) {
return $user->preferredname . ' (' . $firstlast . ' - ' . display_username($user) . ')';
}
return $user->preferredname . ' (' . $firstlast . ')';
}
if ($addusername) {
return $user->preferredname . ' (' . display_username($user) . ')';
}
return $user->preferredname;
}
示例8: renderpost
function renderpost($post, $indent, $mode)
{
global $moderator, $topic, $groupadmins, $membership, $ineditwindow, $USER;
$reportedaction = $moderator && !empty($post->reports);
$highlightreported = false;
if ($reportedaction) {
$highlightreported = true;
$reportedreason = array();
$objections = array();
foreach ($post->reports as $report) {
$reportedreason['msg_' . strtotime($report->reportedtime)] = array('type' => 'html', 'value' => get_string('reportedpostdetails', 'interaction.forum', display_default_name($report->reportedby), strftime(get_string('strftimedaydatetime'), strtotime($report->reportedtime)), $report->report));
$objections[] = $report->id;
}
$post->postnotobjectionableform = pieform(array('name' => 'postnotobjectionable_' . $post->id, 'validatecallback' => 'postnotobjectionable_validate', 'successcallback' => 'postnotobjectionable_submit', 'renderer' => 'div', 'class' => 'form-condensed', 'plugintype' => 'interaction', 'pluginname' => 'forum', 'autofocus' => false, 'elements' => array('objection' => array('type' => 'hidden', 'value' => implode(',', $objections)), 'text' => array('type' => 'html', 'class' => 'postnotobjectionable', 'value' => get_string('postnotobjectionable', 'interaction.forum')), 'submit' => array('type' => 'submit', 'class' => 'btn-default', 'value' => get_string('postnotobjectionablesubmit', 'interaction.forum')), 'postid' => array('type' => 'hidden', 'value' => $post->id), 'details' => array('type' => 'fieldset', 'class' => 'last', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('reporteddetails', 'interaction.forum'), 'elements' => $reportedreason))));
} else {
if (!empty($post->reports)) {
foreach ($post->reports as $report) {
if ($report->reportedby == $USER->get('id')) {
$highlightreported = true;
break;
}
}
}
}
$smarty = smarty_core();
$smarty->assign('LOGGEDIN', $USER->is_logged_in());
$smarty->assign('post', $post);
$smarty->assign('width', 100 - $indent * 2);
$smarty->assign('groupadmins', $groupadmins);
$smarty->assign('moderator', $moderator);
$smarty->assign('membership', $membership);
$smarty->assign('chronological', $mode == 'no_indent' ? true : false);
$smarty->assign('closed', $topic->closed);
$smarty->assign('ineditwindow', $ineditwindow);
$smarty->assign('highlightreported', $highlightreported);
$smarty->assign('reportedaction', $reportedaction);
return $smarty->fetch('interaction:forum:post.tpl');
}
示例9: get_htmlmessage
public function get_htmlmessage($user)
{
$post = $this->temp->post;
$reportername = hsc(display_default_name($this->reporter));
$reporterurl = profile_url($this->reporter);
$ctime = strftime(get_string_from_language($user->lang, 'strftimedaydatetime'), $this->ctime);
return get_string_from_language($user->lang, 'objectionablecontentposthtml', 'interaction.forum', hsc($post->topicsubject), $reportername, $ctime, $this->message, $post->posttime, $post->htmlbody, get_config('wwwroot') . $this->url, hsc($post->topicsubject), $reporterurl, $reportername);
}
示例10: viewnotrude_submit
function viewnotrude_submit(Pieform $form, $values)
{
global $view, $artefact, $USER;
require_once 'activity.php';
db_begin();
// Set exipiry date on view access record
$accessrecord = (object) array('view' => $view->get('id'), 'accesstype' => 'objectionable', 'allowcomments' => 1, 'approvecomments' => 0, 'visible' => 0, 'stopdate' => db_format_timestamp(time() + 60 * 60 * 24 * 7));
delete_records('view_access', 'view', $view->get('id'), 'accesstype', 'objectionable', 'visible', 0);
insert_record('view_access', $accessrecord);
// Send notification to other admins
$reportername = display_default_name($USER);
if ($artefact) {
$goto = get_config('wwwroot') . 'view/artefact.php?artefact=' . $artefact->get('id') . '&view=' . $view->get('id');
} else {
$goto = get_config('wwwroot') . 'view/view.php?id=' . $view->get('id');
}
$data = (object) array('view' => $view->get('id'), 'reporter' => $USER->get('id'), 'subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'viewunobjectionablesubject', 'section' => 'view', 'args' => array($view->get('title'), $reportername)), 'message' => (object) array('key' => 'viewunobjectionablebody', 'section' => 'view', 'args' => array($reportername, $view->get('title'), $view->formatted_owner()))));
activity_occurred('objectionable', $data);
db_commit();
$form->reply(PIEFORM_OK, array('message' => get_string('messagesent'), 'goto' => $goto));
}
示例11: get_posts
/**
* This function returns a list of posts in a given blog.
*
* @param integer
* @param integer
* @param integer
* @param array
*/
public static function get_posts($id, $limit, $offset, $viewoptions = null)
{
$results = array('limit' => $limit, 'offset' => $offset);
// If viewoptions is null, we're getting posts for the my blogs area,
// and we should get all posts & show drafts first. Otherwise it's a
// blog in a view, and we should only get published posts.
$from = "\n FROM {artefact} a LEFT JOIN {artefact_blog_blogpost} bp ON a.id = bp.blogpost\n WHERE a.artefacttype = 'blogpost' AND a.parent = ?";
if (!is_null($viewoptions)) {
if (isset($viewoptions['before'])) {
$from .= " AND a.ctime < '{$viewoptions['before']}'";
}
$from .= ' AND bp.published = 1';
}
$results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
$data = get_records_sql_assoc('
SELECT
a.id, a.title, a.description, a.author, a.authorname, ' . db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
a.locked, bp.published, a.allowcomments ' . $from . '
ORDER BY bp.published ASC, a.ctime DESC, a.id DESC', array($id), $offset, $limit);
if (!$data) {
$results['data'] = array();
return $results;
}
// Get the attached files.
$postids = array_map(create_function('$a', 'return $a->id;'), $data);
$files = ArtefactType::attachments_from_id_list($postids);
if ($files) {
safe_require('artefact', 'file');
foreach ($files as &$file) {
$params = array('id' => $file->attachment);
if (!empty($viewoptions['viewid'])) {
$params['viewid'] = $viewoptions['viewid'];
}
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', $params);
$data[$file->artefact]->files[] = $file;
}
}
if ($tags = ArtefactType::tags_from_id_list($postids)) {
foreach ($tags as &$at) {
$data[$at->artefact]->tags[] = $at->tag;
}
}
foreach ($data as &$post) {
// Format dates properly
if (is_null($viewoptions)) {
// My Blogs area: create forms for changing post status & deleting posts.
$post->changepoststatus = ArtefactTypeBlogpost::changepoststatus_form($post->id, $post->published);
$post->delete = ArtefactTypeBlogpost::delete_form($post->id, $post->title);
} else {
$by = $post->author ? display_default_name($post->author) : $post->authorname;
$post->postedby = get_string('postedbyon', 'artefact.blog', $by, format_date($post->ctime));
// Get comment counts
if (!empty($viewoptions['countcomments'])) {
safe_require('artefact', 'comment');
require_once get_config('docroot') . 'lib/view.php';
$view = new View($viewoptions['viewid']);
$artefact = artefact_instance_from_id($post->id);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false);
$post->commentcount = $commentcount;
$post->comments = $comments;
}
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
$post->mtime = format_date($post->mtime);
// Ensure images in the post have the right viewid associated with them
if (!empty($viewoptions['viewid'])) {
safe_require('artefact', 'file');
$post->description = ArtefactTypeFolder::append_view_url($post->description, $viewoptions['viewid']);
}
}
$results['data'] = array_values($data);
return $results;
}
示例12: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
$configdata = $instance->get('configdata');
$view = $instance->get('view');
$limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
$full = isset($configdata['full']) ? $configdata['full'] : false;
$results = array();
$smarty = smarty_core();
$smarty->assign('view', $view);
// Display all posts, from all blogs, owned by this user
if (!empty($configdata['tagselect'])) {
$tagselect = $configdata['tagselect'];
$sql = 'SELECT a.title, p.title AS parenttitle, a.id, a.parent, a.owner, a.description, a.allowcomments, at.tag, a.ctime
FROM {artefact} a
JOIN {artefact} p ON a.parent = p.id
JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
JOIN {artefact_tag} at ON (at.artefact = a.id)
WHERE a.artefacttype = \'blogpost\'
AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
AND at.tag = ?
ORDER BY a.ctime DESC, a.id DESC
LIMIT ?';
$results = get_records_sql_array($sql, array($view, $tagselect, $limit));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('editing', $editing);
if ($editing) {
// Get list of blogs owned by this user to create the "Add new post" shortcut while editing
$viewowner = $instance->get_view()->get('owner');
if (!$viewowner || !($blogs = get_records_select_array('artefact', 'artefacttype = \'blog\' AND owner = ?', array($viewowner), 'title ASC', 'id, title'))) {
$blogs = array();
}
$smarty->assign('tagselect', $tagselect);
$smarty->assign('blogs', $blogs);
}
// if posts are not found with the selected tag, notify the user
if (!$results) {
$smarty->assign('badtag', $tagselect);
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
}
// update the view_artefact table so journal entries are accessible when this is the only block on the page
// referencing this journal
$dataobject = array('view' => $view, 'block' => $instance->get('id'));
foreach ($results as $result) {
$dataobject["artefact"] = $result->parent;
ensure_record_exists('view_artefact', $dataobject, $dataobject);
$result->postedbyon = get_string('postedbyon', 'artefact.blog', display_default_name($result->owner), format_date(strtotime($result->ctime)));
$result->displaydate = format_date(strtotime($result->ctime));
// get comment count for this post
$result->commentcount = count_records_select('artefact_comment_comment', "onartefact = {$result->id} AND private = 0 AND deletedby IS NULL");
// get all tags for this post
$taglist = get_records_array('artefact_tag', 'artefact', $result->id, "tag DESC");
foreach ($taglist as $t) {
$result->taglist[] = $t->tag;
}
}
// check if the user viewing the page is the owner of the selected tag
$owner = $results[0]->owner;
if ($USER->id != $owner) {
$viewowner = get_user_for_display($owner);
$smarty->assign('viewowner', $viewowner);
}
$smarty->assign('tag', $tagselect);
} else {
// error if block configuration fails
$smarty->assign('configerror', true);
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
}
$smarty->assign('full', $full);
$smarty->assign('results', $results);
return $smarty->fetch('blocktype:taggedposts:taggedposts.tpl');
}
示例13: array
if (!isset($viewdata[$b->view])) {
$viewdata[$b->view] = (object) array('id' => $b->view, 'title' => $b->viewtitle, 'owner' => $b->owner, 'group' => $b->group, 'institution' => $b->institution, 'ownerformat' => $b->ownerformat, 'urlid' => $b->urlid);
}
}
View::get_extra_view_info($viewdata, false, false);
foreach ($blocks as $b) {
if (!isset($data[$b->artefact]->views)) {
$data[$b->artefact]->views = array();
}
if (!isset($data[$b->artefact]->views[$b->view])) {
$data[$b->artefact]->views[$b->view] = array('view' => $b->view, 'viewtitle' => $b->viewtitle, 'fullurl' => $viewdata[$b->view]['fullurl']);
// Add the view owner's name if it's not the same as the note owner. This will either
// be a group artefact inside an individual's view, or it's an institution/site artefact.
if (!empty($params['group']) && $b->owner || !empty($params['institution']) && $params['institution'] != $b->institution) {
if ($b->owner) {
$ownername = display_default_name($viewdata[$b->view]['user']);
$ownerurl = profile_url($viewdata[$b->view]['user']);
} else {
if ($b->group) {
$ownername = $viewdata[$b->view]['groupdata']['name'];
$ownerurl = group_homepage_url($viewdata[$b->view]['groupdata']);
} else {
if ($b->institution == 'mahara') {
$ownername = get_config('sitename');
} else {
$ownername = $b->institutionname;
$ownerurl = get_config('wwwroot') . 'institution/index.php?institution=' . $b->institution;
}
}
}
$data[$b->artefact]->views[$b->view]['ownername'] = $ownername;
示例14: __construct
/**
* @param array $data Parameters:
* - message (string)
* - view (int)
* - artefact (int) (optional)
* - reporter (int)
*/
function __construct($data, $cron = false)
{
parent::__construct($data, $cron);
if (empty($this->artefact)) {
$this->url = get_config('wwwroot') . 'view/view.php?id=' . $this->view;
} else {
$this->url = get_config('wwwroot') . 'view/artefact.php?artefact=' . $this->artefact . '&view=' . $this->view;
}
if (empty($this->strings->subject)) {
$viewtitle = get_field('view', 'title', 'id', $this->view);
if (empty($this->artefact)) {
$this->strings->subject = (object) array('key' => 'objectionablecontentview', 'section' => 'activity', 'args' => array($viewtitle, display_default_name($this->reporter)));
} else {
$title = get_field('artefact', 'title', 'id', $this->artefact);
$this->strings->subject = (object) array('key' => 'objectionablecontentviewartefact', 'section' => 'activity', 'args' => array($viewtitle, $title, display_default_name($this->reporter)));
}
}
}