It works on version 0.9.0.12/0.9.1
Some words in advance, I am totally new in PHP and any other language. All I done is copy and combine different mods and hark. I just wanna link some useful function togather.
In b2evo, there is a function allows users registering by themselves. Well that seems good but for nothing as users have to wait for admin's permission. Another dispointment is that, as long as an user was assigned right to write/edit, he was also given the right to edit other people's articles, including admin's.
Simple steps solve the two problem:
The first hark is from Barkingstar's original version,but work perfectly with b2evo 0.9.0.12 (http://forums.b2evolution.net/viewtopic.php?t=2952&highlight=allowing+post+blogs+registering)
Step1,
Open /blogs/htsrv/register.php and go down to this bit (around line 130) find out this code:
send_mail( $admin_email, T_('new user registration on your blog'), $message, $notify_from );
locale_restore_previous();
// Display confirmation screen:
require( dirname(__FILE__).'/_reg_complete.php' );
exit();
break; // case 'register'
Now insert the following code like so:
send_mail( $admin_email, T_('new user registration on your blog'), $message, $notify_from );
locale_restore_previous();
// HORRIBLE CLUDGE
$loginid = $DB->get_var( "SELECT ID FROM evo_users WHERE user_login='$login'" );
$DB->query( "INSERT INTO evo_blogusers (bloguser_blog_id,bloguser_user_id,bloguser_perm_poststatuses,bloguser_ismember) VALUES('1','$loginid','published','1')" );
$DB->query( "INSERT INTO evo_blogusers (bloguser_blog_id,bloguser_user_id,bloguser_perm_poststatuses,bloguser_ismember) VALUES('2','$loginid','published','1')" );
$DB->query( "INSERT INTO evo_blogusers (bloguser_blog_id,bloguser_user_id,bloguser_perm_poststatuses,bloguser_ismember) VALUES('3','$loginid','published','1')" );
$DB->query( "INSERT INTO evo_blogusers (bloguser_blog_id,bloguser_user_id,bloguser_perm_poststatuses,bloguser_ismember) VALUES('4','$loginid','published','1')" );
$DB->query( "INSERT INTO evo_blogusers (bloguser_blog_id,bloguser_user_id,bloguser_perm_poststatuses,bloguser_ismember) VALUES('5','$loginid','published','1')" );
$DB->query( "INSERT INTO evo_blogusers (bloguser_blog_id,bloguser_user_id,bloguser_perm_poststatuses,bloguser_ismember) VALUES('6','$loginid','published','1')" );
// END HORRIBLE CLUDGE
// Display confirmation screen:
require( dirname(__FILE__).'/_reg_complete.php' );
exit();
break; // case 'register'
I made some changes according to my board needs. The number that immediately follows VALUES is the ID number of the blog you want users to have access to. As you can see in the above example, I'm giving my users write access to six of my blogs (blog number 1,2,3,4,5 and 6). If I had even more blogs to give access to that I'd just add more of those INSERT lines with the extra ID numbers.
Now new users can register and write anything without any waiting.
Second part from Wonderwinds.com(http://wonderwinds.com/hackblog.php/2005/01/31/lim_iting_who_can_delete_edit_publish_po
Step2,
Open up b2evocore/_class_item in your favorite editor and scroll down until you find function delete_link. A few lines inside that function you will see this:
if( ! $current_User->check_perm( 'blog_del_post', 'any', false, $this->blog_ID ) )
{ // User has right to delete this post
return false;
}
Further down the file you will see a similar block for edit_link function and another similar block for publish_link function. After the permission of edit_link checks you will want to add the following:
// only the author (or admin) can delete posts
if( $current_User->get( 'ID' ) != $this->Author->get( 'ID' ) )
{ // test for author
if( $current_User->get( 'ID' ) != 1 )
{ // test for admin
return false;
}
}
As my own board, it looks like:
function edit_link( $before = ' ', $after = ' ', $text = '#', $title = '#', $class = '', $glue = '&' )
{
global $current_User, $admin_url;
if( ! is_logged_in() ) return false;
if( ! $current_User->check_perm( 'blog_post_statuses', $this->status, false,
$this->blog_ID ) )
{ // User has no right to edit this post
return false;
}
// only the author (or admin) can edit posts
if( $current_User->get( 'ID' ) != $this->Author->get( 'ID' ) )
{ // test for author
if( $current_User->get( 'ID' ) != 1 )
{ // test for admin
return false;
}
}
if( $text == '#' ) $text = T_('Edit');
if( $title == '#' ) $title = T_('Edit this post');
echo $before;
echo '<a href="'.$admin_url.'/b2edit.php?action=edit'.$glue.'post='.$this->ID;
echo '" title="'.$title.'"';
if( !empty( $class ) ) echo ' class="'.$class.'"';
echo '>'.$text.'</a>';
echo $after;
return true;
}
Thats it! The two hack works fine together. Hope it help someone. If u wanna make further change about new user permission, just follow the second Url from Wonderwinds.com. NB. Im not ads here. :)
I wonder will someone take further consideration? Step 1 just allow new users to write and edit articles. How to change the code if we wnnna give more access right (likes 'Protected', 'Private', 'Draft' and 'Delete', at lease a writer has the right to del his works)to users when they sign up instead of promote them in the board one by one.
If somebody done that it will be much more perfect! What a shame I got no idea about PHP, or I can do it myself. >:(