[wp-cvs] wordpress/wp-includes functions-post.php,1.3,1.4
Michel Valdrighi
michelvaldrighi at users.sourceforge.net
Wed Aug 25 15:12:12 UTC 2004
Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23755/wp-includes
Modified Files:
functions-post.php
Log Message:
added user_can_edit_post and user_can_delete_post
Index: functions-post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions-post.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** functions-post.php 25 Aug 2004 14:22:39 -0000 1.3
--- functions-post.php 25 Aug 2004 15:12:10 -0000 1.4
***************
*** 355,357 ****
--- 355,382 ----
}
+
+ // query user capabilities
+
+ /* returns true if a given $user_id can edit a given $post_id.
+ note: optional $blog_id for future usage? */
+ function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
+ $author_data = get_userdata($user_id);
+ $post_data = get_postdata($post_id);
+ $post_author_data = get_userdata($post_data['Author_ID']);
+
+ if ( ($user_id == $post_author_data->ID)
+ || ($author_data->user_level > $post_author_data->user_level) ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /* returns true if a given $user_id can delete a given $post_id.
+ note: optional $blog_id for future usage? */
+ function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit, one can delete
+ return user_can_edit_post($user_id, $post_id, $blog_id);
+ }
+
?>
\ No newline at end of file
More information about the cvs
mailing list