本文整理汇总了PHP中user_can_edit_post函数的典型用法代码示例。如果您正苦于以下问题:PHP user_can_edit_post函数的具体用法?PHP user_can_edit_post怎么用?PHP user_can_edit_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_can_edit_post函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_can_edit_post_comments
/**
* Whether user can delete a post.
*
* @since 1.5
* @deprecated 2.0
* @deprecated Use current_user_can()
* @see current_user_can()
*
* @param int $user_id
* @param int $post_id
* @param int $blog_id Not Used
* @return bool returns true if $user_id can edit $post_id's comments
*/
function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1)
{
_deprecated_function(__FUNCTION__, '2.0', 'current_user_can()');
// right now if one can edit a post, one can edit comments made on it
return user_can_edit_post($user_id, $post_id, $blog_id);
}
示例2: mt_publishPost
function mt_publishPost($args) {
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
}
$user_data = get_userdatabylogin($user_login);
if (!user_can_edit_post($user_data->ID, $post_ID)) {
return new IXR_Error(401, 'Sorry, you can not edit this post.');
}
$postdata = wp_get_single_post($post_ID,ARRAY_A);
$postdata['post_status'] = 'publish';
// retain old cats
$cats = wp_get_post_cats('',$post_ID);
$postdata['post_category'] = $cats;
$this->escape($postdata);
$result = wp_update_post($postdata);
return $result;
}
示例3: user_can_edit_post_comments
function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1)
{
// right now if one can edit a post, one can edit comments made on it
return user_can_edit_post($user_id, $post_id, $blog_id);
}
示例4: get_records_sql_array
$posts = get_records_sql_array('SELECT p.id, p.parent, p.path, p.poster, p.subject, p.body, ' . db_format_tsfield('p.ctime', 'ctime') . ', p.deleted
FROM {interaction_forum_post} p
WHERE p.topic = ?
ORDER BY ' . $order, array($topicid), $offset, $limit);
// This is only needed for the 'no_indent' option
$lastpostid = null;
if ($indentmode == 'no_indent') {
$lastpost = get_record_select('interaction_forum_post', 'topic = ? ORDER by ctime DESC, id DESC LIMIT 1', array($topicid));
$lastpostid = $lastpost->id;
}
// Get extra info of posts
$prevdeletedid = false;
foreach ($posts as $postid => $post) {
// Get the number of posts
$post->postcount = get_postcount($post->poster);
$post->canedit = $post->parent && ($moderator || user_can_edit_post($post->poster, $post->ctime)) && $ineditwindow;
$post->ctime = relative_date(get_string('strftimerecentfullrelative', 'interaction.forum'), get_string('strftimerecentfull'), $post->ctime);
// Get post edit records
$post->edit = get_postedits($post->id);
// Get moderator info
$post->moderator = is_moderator($post->poster) ? $post->poster : null;
// Update the subject of posts
$post->subject = !empty($post->subject) ? $post->subject : get_string('re', 'interaction.forum', get_ancestorpostsubject($post->id));
// If this is the own post
$post->ownpost = $USER->get('id') == $post->poster ? true : false;
// Reported reason data
$post->reports = get_records_select_array('objectionable', 'objecttype = ? AND objectid = ? AND resolvedby IS NULL AND resolvedtime IS NULL', array('forum', $post->id));
// Consolidate deleted message posts by the same author into one "X posts by Spammer Joe were deleted"
if ($post->deleted) {
if ($prevdeletedid && $posts[$prevdeletedid]->poster == $post->poster) {
$posts[$prevdeletedid]->deletedcount++;
示例5: user_can_access_forum
$membership = user_can_access_forum((int) $parent->forum);
$moderator = (bool) ($membership & INTERACTION_FORUM_MOD);
if (!isset($postid)) {
// post reply
if (!$membership) {
throw new AccessDeniedException(get_string('cantaddposttoforum', 'interaction.forum'));
}
if (!$moderator && $parent->topicclosed) {
throw new AccessDeniedException(get_string('cantaddposttotopic', 'interaction.forum'));
}
$action = get_string('postreply', 'interaction.forum');
define('TITLE', $parent->topicsubject . ' - ' . $action);
} else {
// edit post
// no record for edits to own posts with 30 minutes
if (user_can_edit_post($post->poster, $post->ctime)) {
$post->editrecord = false;
} else {
if ($moderator) {
$post->editrecord = true;
} else {
throw new AccessDeniedException(get_string('canteditpost', 'interaction.forum'));
}
}
$action = get_string('editpost', 'interaction.forum');
define('TITLE', $parent->topicsubject . ' - ' . $action);
}
$parent->ctime = relative_date(get_string('strftimerecentfullrelative', 'interaction.forum'), get_string('strftimerecentfull'), $parent->ctime);
// Javascript to hide the subject box if it has nothing in it, with a link you
// click to expand it.
$clicksetsubject = json_encode(get_string('clicksetsubject', 'interaction.forum'));
示例6: apply_filters
<div class="storycontent">
<?php
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
</div>
</div>
<?php
break;
case 'editpost':
// die(var_dump('<pre>', $_POST));
if (!isset($blog_ID)) {
$blog_ID = 1;
}
$post_ID = (int) $_POST['post_ID'];
if (!user_can_edit_post($user_ID, $post_ID, $blog_ID)) {
die(__('You are not allowed to edit this post.'));
}
$post_categories = $_POST['post_category'];
if (!$post_categories) {
$post_categories[] = 1;
}
$content = apply_filters('content_save_pre', $_POST['content']);
$excerpt = apply_filters('excerpt_save_pre', $_POST['excerpt']);
$post_title = $_POST['post_title'];
$prev_status = $_POST['prev_status'];
$post_status = $_POST['post_status'];
$menu_order = (int) $_POST['menu_order'];
if (!empty($_POST['post_author_override'])) {
$post_author = (int) $_POST['post_author_override'];
} else {
示例7: define
}
if (!isset($topicid)) {
// new topic
define('TITLE', $forum->title . ' - ' . get_string('addtopic', 'interaction.forum'));
} else {
// edit topic
define('TITLE', $forum->title . ' - ' . get_string('edittopic', 'interaction.forum'));
// no record for edits to own posts with 30 minutes
if (user_can_edit_post($topic->poster, $topic->ctime)) {
$topic->editrecord = false;
$timeleft = (int) get_config_plugin('interaction', 'forum', 'postdelay') - round((time() - $topic->ctime) / 60);
} else {
if ($moderator) {
$topic->editrecord = true;
} else {
if (user_can_edit_post($topic->poster, $topic->ctime, $USER->get('id'), false)) {
$SESSION->add_error_msg(get_string('postaftertimeout', 'interaction.forum', get_config_plugin('interaction', 'forum', 'postdelay')));
redirect('/interaction/forum/topic.php?id=' . $topicid);
} else {
throw new AccessDeniedException(get_string('cantedittopic', 'interaction.forum'));
}
}
}
}
$editform = array('name' => isset($topic) ? 'edittopic' : 'addtopic', 'method' => 'post', 'autofocus' => isset($topic) ? 'body' : 'subject', 'elements' => array('subject' => array('type' => 'text', 'title' => get_string('Subject', 'interaction.forum'), 'defaultvalue' => isset($topic) ? $topic->subject : null, 'rules' => array('required' => true, 'maxlength' => 255)), 'body' => array('type' => 'wysiwyg', 'title' => get_string('Body', 'interaction.forum'), 'rows' => 18, 'cols' => 70, 'defaultvalue' => isset($topic) ? $topic->body : null, 'rules' => array('required' => true, 'maxlength' => 65536)), 'sticky' => array('type' => 'switchbox', 'title' => get_string('Sticky', 'interaction.forum'), 'description' => get_string('stickydescription', 'interaction.forum'), 'defaultvalue' => isset($topic) && $topic->sticky == 1 ? 'checked' : null), 'closed' => array('type' => 'switchbox', 'title' => get_string('Closed', 'interaction.forum'), 'description' => get_string('closeddescription', 'interaction.forum'), 'defaultvalue' => isset($topic) ? $topic->closed : !empty($forumconfig['closetopics']->value)), 'sendnow' => array('type' => 'switchbox', 'title' => get_string('sendnow', 'interaction.forum'), 'description' => get_string('sendnowdescription', 'interaction.forum', get_config_plugin('interaction', 'forum', 'postdelay')), 'defaultvalue' => false), 'submit' => array('type' => 'submitcancel', 'value' => array(isset($topic) ? get_string('save') : get_string('Post', 'interaction.forum'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'interaction/forum/' . (isset($topic) && $returnto != 'view' ? 'topic.php?id=' . $topicid : 'view.php?id=' . $forumid)), 'post' => array('type' => 'hidden', 'value' => isset($topic) ? $topic->postid : false), 'editrecord' => array('type' => 'hidden', 'value' => isset($topic) ? $topic->editrecord : false)));
if (!$moderator) {
if (!group_sendnow($forum->groupid) && !$admintutor) {
unset($editform['elements']['sendnow']);
}
unset($editform['elements']['sticky']);
unset($editform['elements']['closed']);
示例8: JOIN
LEFT JOIN {interaction_forum_topic} t3 ON t3.id = p3.topic
LEFT JOIN (
SELECT m.forum, m.user
FROM {interaction_forum_moderator} m
INNER JOIN {usr} u ON (m.user = u.id AND u.deleted = 0)
) m2 ON (m2.forum = t3.forum AND m2.user = e.user)
WHERE p1.topic = ?
GROUP BY 1, 2, 3, 4, 5, p1.ctime, 7, 8, 10, 11, 12, e.ctime
ORDER BY p1.ctime, p1.id, e.ctime', array($topic->groupid, $topicid));
// $posts has an object for every edit to a post
// this combines all the edits into a single object for each post
// also formats the edits a bit
$count = count($posts);
for ($i = 0; $i < $count; $i++) {
$posts[$i]->postcount = get_string('postsvariable', 'interaction.forum', $posts[$i]->postcount);
$posts[$i]->canedit = $posts[$i]->parent && ($moderator || user_can_edit_post($posts[$i]->poster, $posts[$i]->ctime));
$posts[$i]->ctime = relative_date(get_string('strftimerecentfullrelative', 'interaction.forum'), get_string('strftimerecentfull'), $posts[$i]->ctime);
$postedits = array();
if ($posts[$i]->editor) {
$postedits[] = array('editor' => $posts[$i]->editor, 'edittime' => relative_date(get_string('strftimerecentfullrelative', 'interaction.forum'), get_string('strftimerecentfull'), $posts[$i]->edittime), 'moderator' => $posts[$i]->editormoderator);
}
$temp = $i;
while (isset($posts[$i + 1]) && $posts[$i + 1]->id == $posts[$temp]->id) {
// while the next object is the same post
$i++;
$postedits[] = array('editor' => $posts[$i]->editor, 'edittime' => relative_date(get_string('strftimerecentfullrelative', 'interaction.forum'), get_string('strftimerecentfull'), $posts[$i]->edittime), 'moderator' => $posts[$i]->editormoderator);
unset($posts[$i]);
}
$posts[$temp]->edit = $postedits;
}
// builds the first post (with index 0) which has as children all the posts in the topic
示例9: comment_text
comment_text();
?>
<p><?php
_e('Posted');
echo ' ';
comment_date('M j, g:i A');
if (user_can_edit_post_comments($user_ID, $comment->comment_post_ID)) {
echo " | <a href=\"post.php?action=editcomment&comment=" . $comment->comment_ID . "\">" . __('Edit Comment') . "</a>";
}
if (user_can_delete_post_comments($user_ID, $comment->comment_post_ID)) {
echo " | <a href=\"post.php?action=deletecomment&p=" . $comment->comment_post_ID . "&comment=" . $comment->comment_ID . "\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \\'%s\\'\\n \\'Cancel\\' to stop, \\'OK\\' to delete."), $comment->comment_author) . "')\">" . __('Delete Comment') . "</a> — ";
}
// end if any comments to show
// Get post title
if (user_can_edit_post($user_ID, $comment->comment_post_ID)) {
$post_title = $wpdb->get_var("SELECT post_title FROM {$wpdb->posts} WHERE ID = {$comment->comment_post_ID}");
$post_title = '' == $post_title ? "# {$comment->comment_post_ID}" : $post_title;
?>
<a href="post.php?action=edit&post=<?php
echo $comment->comment_post_ID;
?>
"><?php
printf(__('Edit Post “%s”'), stripslashes($post_title));
?>
</a>
<?php
}
?>
| <a href="<?php
echo get_permalink($comment->comment_post_ID);
示例10: NotFoundException
throw new NotFoundException(get_string('cantfindforum', 'interaction.forum', $forumid));
}
define('GROUP', $forum->groupid);
$membership = user_can_access_forum((int) $forumid);
$moderator = (bool) ($membership & INTERACTION_FORUM_MOD);
if (!$membership) {
throw new AccessDeniedException(get_string('cantaddtopic', 'interaction.forum'));
}
if (!isset($topicid)) {
// new topic
define('TITLE', $forum->title . ' - ' . get_string('addtopic', 'interaction.forum'));
} else {
// edit topic
define('TITLE', $forum->title . ' - ' . get_string('edittopic', 'interaction.forum'));
// no record for edits to own posts with 30 minutes
if (user_can_edit_post($topic->poster, $topic->ctime)) {
$topic->editrecord = false;
} else {
if ($moderator) {
$topic->editrecord = true;
} else {
throw new AccessDeniedException(get_string('cantedittopic', 'interaction.forum'));
}
}
}
$editform = array('name' => isset($topic) ? 'edittopic' : 'addtopic', 'method' => 'post', 'autofocus' => false, 'elements' => array('subject' => array('type' => 'text', 'title' => get_string('Subject', 'interaction.forum'), 'defaultvalue' => isset($topic) ? $topic->subject : null, 'rules' => array('required' => true, 'maxlength' => 255)), 'body' => array('type' => 'wysiwyg', 'title' => get_string('Body', 'interaction.forum'), 'rows' => 10, 'cols' => 70, 'defaultvalue' => isset($topic) ? $topic->body : null, 'rules' => array('required' => true)), 'sticky' => array('type' => 'checkbox', 'title' => get_string('Sticky', 'interaction.forum'), 'description' => get_string('stickydescription', 'interaction.forum'), 'defaultvalue' => isset($topic) && $topic->sticky == 1 ? 'checked' : null), 'closed' => array('type' => 'checkbox', 'title' => get_string('Closed', 'interaction.forum'), 'description' => get_string('closeddescription', 'interaction.forum'), 'defaultvalue' => isset($topic) && $topic->closed == 1 ? 'checked' : null), 'submit' => array('type' => 'submitcancel', 'value' => array(isset($topic) ? get_string('edit') : get_string('Post', 'interaction.forum'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'interaction/forum/' . (isset($topic) && $returnto != 'view' ? 'topic.php?id=' . $topicid : 'view.php?id=' . $forumid)), 'post' => array('type' => 'hidden', 'value' => isset($topic) ? $topic->postid : false), 'editrecord' => array('type' => 'hidden', 'value' => isset($topic) ? $topic->editrecord : false)));
if (!$moderator) {
unset($editform['elements']['sticky']);
unset($editform['elements']['closed']);
}
$editform = pieform($editform);
示例11: __
<?php
break;
case 'control_edit':
?>
<td><?php
if (user_can_edit_post($user_ID, $post->ID)) {
echo "<a href='post.php?action=edit&post={$id}' class='edit'>" . __('Edit') . "</a>";
}
?>
</td>
<?php
break;
case 'control_delete':
?>
<td><?php
if (user_can_edit_post($user_ID, $post->ID)) {
echo "<a href='post.php?action=delete&post={$id}' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \\'%s\\'\\n \\'OK\\' to delete, \\'Cancel\\' to stop."), wp_specialchars(get_the_title('', ''), 1)) . "')\">" . __('Delete') . "</a>";
}
?>
</td>
<?php
break;
default:
?>
<td><?php
do_action('manage_posts_custom_column', $column_name, $id);
?>
</td>
<?php
break;
}
示例12: get_settings
//.........这里部分代码省略.........
// Used to filter values
$allowed_keys = array('author', 'date', 'category', 'title');
$q['orderby'] = urldecode($q['orderby']);
$q['orderby'] = addslashes_gpc($q['orderby']);
$orderby_array = explode(' ', $q['orderby']);
if (!in_array($orderby_array[0], $allowed_keys)) {
$orderby_array[0] = 'date';
}
$q['orderby'] = $orderby_array[0] . ' ' . $q['order'];
if (count($orderby_array) > 1) {
for ($i = 1; $i < count($orderby_array); $i = $i + 1) {
// Only allow certain values for safety
if (in_array($orderby_array[$i], $allowed_keys)) {
$q['orderby'] .= ',post_' . $orderby_array[$i] . ' ' . $q['order'];
}
}
}
}
$now = gmdate('Y-m-d H:i:59');
if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
$where .= " AND post_date_gmt <= '{$now}'";
$distinct = 'DISTINCT';
}
if ($this->is_page) {
$where .= ' AND (post_status = "static")';
} elseif ($this->is_single) {
$where .= ' AND (post_status != "static")';
} else {
$where .= ' AND (post_status = "publish"';
if (isset($user_ID) && '' != intval($user_ID)) {
$where .= " OR post_author = {$user_ID} AND post_status != 'draft' AND post_status != 'static')";
} else {
$where .= ')';
}
}
// Apply filters on where and join prior to paging so that any
// manipulations to them are reflected in the paging by day queries.
$where = apply_filters('posts_where', $where);
$join = apply_filters('posts_join', $join);
// Paging
if (empty($q['nopaging']) && !$this->is_single) {
$page = $q['paged'];
if (empty($page)) {
$page = 1;
}
if ($q['what_to_show'] == 'posts') {
$pgstrt = '';
$pgstrt = (intval($page) - 1) * $q['posts_per_page'] . ', ';
$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
} elseif ($q['what_to_show'] == 'days') {
$startrow = $q['posts_per_page'] * (intval($page) - 1);
$start_date = $wpdb->get_var("SELECT max(post_date) FROM {$wpdb->posts} {$join} WHERE (1=1) {$where} GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT {$startrow},1");
$endrow = $startrow + $q['posts_per_page'] - 1;
$end_date = $wpdb->get_var("SELECT min(post_date) FROM {$wpdb->posts} {$join} WHERE (1=1) {$where} GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT {$endrow},1");
if ($page > 1) {
$where .= " AND post_date >= '{$end_date}' AND post_date <= '{$start_date}'";
} else {
$where .= " AND post_date >= '{$end_date}'";
}
}
}
// Apply post-paging filters on where and join. Only plugins that
// manipulate paging queries should use these hooks.
$where = apply_filters('posts_where_paged', $where);
$where .= " GROUP BY {$wpdb->posts}.ID";
$join = apply_filters('posts_join_paged', $join);
$orderby = "post_" . $q['orderby'];
$orderby = apply_filters('posts_orderby', $orderby);
$request = " SELECT {$distinct} * FROM {$wpdb->posts} {$join} WHERE 1=1" . $where . " ORDER BY " . $orderby . " {$limits}";
$this->posts = $wpdb->get_results($request);
// Check post status to determine if post should be displayed.
if ($this->is_single) {
if ('publish' != $this->posts[0]->post_status) {
if (!(isset($user_ID) && '' != intval($user_ID))) {
// User must be logged in to view unpublished posts.
$this->posts = array();
} else {
if ('draft' == $this->posts[0]->post_status) {
// User must have edit permissions on the draft to preview.
if (!user_can_edit_post($user_ID, $this->posts[0]->ID)) {
$this->posts = array();
}
} elseif ('private' == $this->posts[0]->post_status) {
if ($this->posts[0]->post_author != $user_ID) {
$this->posts = array();
}
}
}
}
}
$this->posts = apply_filters('the_posts', $this->posts);
$this->post_count = count($this->posts);
if ($this->post_count > 0) {
$this->post = $this->posts[0];
}
update_post_caches($this->posts);
// Save any changes made to the query vars.
$this->query_vars = $q;
return $this->posts;
}
示例13: edit_post_link
function edit_post_link($link = 'Edit This', $before = '', $after = '') {
global $user_ID, $post;
get_currentuserinfo();
if ( !user_can_edit_post($user_ID, $post->ID) ) {
return;
}
if ( is_attachment() )
return;
else
$file = 'post';
$location = get_settings('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID";
echo $before . "<a href=\"$location\">$link</a>" . $after;
}
示例14: edit_post_link
function edit_post_link($link = 'Edit This', $before = '', $after = '') {
global $user_ID, $post;
get_currentuserinfo();
if (!user_can_edit_post($user_ID, $post->ID)) {
return;
}
$location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&post=$post->ID";
echo "$before <a href=\"$location\">$link</a> $after";
}