Recent Topics

1 Sep 09, 2005 13:28    

Hello, I have multi user blog system.

Problem is that user cannot edit or delete his own posts, and admin cannot do that also on users blogs.

I have made integration with my current members database.

Here is the code that creates new blog user and new blog for my existing user:


$new_Blogger = & new User();
$new_Blogger->set( 'login', $username);
$new_Blogger->set( 'pass', $pass_md5);
$new_Blogger->set( 'nickname', $nickname);
$new_Blogger->set( 'email', $email);
$new_Blogger->set( 'ip', '127.0.0.1');
$new_Blogger->set( 'domain', 'localhost');
$new_Blogger->set( 'ip', $_SERVER['REMOTE_ADDR']);
$new_Blogger->set( 'domain', $_SERVER['REMOTE_HOST']);
$new_Blogger->set( 'browser', $_SERVER['HTTP_USER_AGENT']);
$new_Blogger->set_datecreated( $localtimenow );
$new_Blogger->set( 'level', $Settings->get('newusers_level') );
$new_Blogger->set( 'locale', $Settings->get('default_locale') );
$new_Blogger->set( 'idmode', 'nickname');

$newusers_grp_ID = $Settings->get('newusers_grp_ID');
$new_user_Group = $GroupCache->get_by_ID( $newusers_grp_ID);
$new_Blogger->setGroup( $new_user_Group );
$new_Blogger->dbinsert();

// get the new blog ID number
$new_Blogger_ID = $new_Blogger->ID;

$new_Blog = & new Blog(NULL);
$new_Blog->set( 'tagline', "" );
$new_Blog->set( 'longdesc', "" );
$new_Blog->set( 'notes', "" );
$new_Blog->set( 'name', $new_Blogger->get( 'nickname' ) );
$new_Blog->set( 'shortname', $new_Blogger->get( 'nickname' ) );
$new_Blog->set( 'description', "" );
$new_Blog->set( 'locale', $new_Blogger->get( 'locale' ) );
$new_Blog->set( 'access_type', "index.php" );
$new_Blog->set( 'siteurl', "" );
$new_Blog->set( 'stub', $new_Blogger->get( 'nickname' ) );
$new_Blog->set( 'keywords', "" );
$new_Blog->set( 'disp_bloglist', 0 );
$new_Blog->set( 'in_bloglist', 0 );
$new_Blog->set( 'links_blog_ID', "" );
$new_Blog->set( 'default_skin', "originalb2" );
$new_Blog->set( 'force_skin', 1 );
$new_Blog->set( 'staticfilename', $new_Blogger->get( 'nickname' ) . ".html" );
$new_Blog->set( 'pingweblogs', 0 );
$new_Blog->set( 'allowtrackbacks', 0 );
$new_Blog->set( 'allowpingbacks', 0 );
$new_Blog->dbinsert();

// Set admin permissions for the new blog
$DB->query( "INSERT INTO $tableblogusers (bloguser_blog_ID, bloguser_user_ID, bloguser_ismember, bloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_comments, bloguser_perm_cats, bloguser_perm_properties ) VALUES ( $new_Blog->ID, 1, 1, 'published,protected,private,draft,deprecated', 1, 1, 1, 1 )" );
// Set default user permissions for this blog
$DB->query( "INSERT INTO $tableblogusers( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember, bloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_comments, bloguser_perm_cats, bloguser_perm_properties ) VALUES ( $new_Blog->ID, $new_Blogger->ID, 1, 'published,protected,private,draft,deprecated', 1, 1, 1, 1 )" );

// Commit changes in cache:
$BlogCache->add($new_Blog);

// create category for the new blog
$DB->query( "INSERT INTO $tablecategories ( cat_name, cat_blog_ID ) VALUES ( 'Public', $new_Blog->ID )" );

Any ideas?

2 Sep 09, 2005 15:30

Compare what I do [url=http://wonderwinds.com/hackblog.php/2005/08/14/automatically_create_a_blog_for_a_new_bl]in this hack[/url] with what you're doing. Mine is to give a NEW blogger a blog and category - it does nothing for existing bloggers. I also make sure the admin and blogger have full permissions (except the blogger can not remove the admin's permissions). You might then want to look at [url=http://wonderwinds.com/hackblog.php/2005/01/31/lim_iting_who_can_delete_edit_publish_po]this hack[/url] as well.

3 Sep 10, 2005 11:47

Ok, I fixed every, EdB, thanks.

Another small problem related to PUBLISH NOW of draft posts.
It seems in code that only users with level more than 5 can do that because permission for edit_timestamps is checked while publishing draft posts.

Is it normal? Should I give users level 5 to let them publish their own draft posts?
Is it really necessary to check this for publish operation:
$current_User->check_perm( 'edit_timestamp' ) ?

4 Sep 10, 2005 15:34

I didn't know that, and I really can't say if it's important or not. All I do is hack stuff! I guess if they have to be level 5 to get a "Publish NOW" then make them be level 5 when you decide to give them an automatic blog. If you can find in the code where that is set you might want to make it be a lower number, but it's up to you. In the auto-blog installation I'm doing we're making the auto-bloggers start at level 6 just so they're above the level 3s (who will be above the level 0s), so I accidentally set them high enough to see that button.

I can't think of the reason for such a thing??????

5 Sep 10, 2005 16:45

Ok, I changed that permission level to 3.

6 Sep 10, 2005 17:09

Level 5 is needed to be able to change 'edit-time'
And 'PUBLISH NOW' is changing the edit time..

I can't think of reason why you should not level-up your users.

7 Sep 10, 2005 17:17

Thanks for the explanation Topanga, but I can think of a reason: It is possible that you want your bloggers to have easy publishing of drafts WITHOUT letting them go in and change a date to the middle of last week. In the multiblogger installation I'm doing my motivation for not having the ability to edit the publication date is just to keep the posting area as clean as can be.

I have to look at how I currently 'hid' the edit timestamp feature from the average blogger, but I think I like making edit timestamp be for only admins. (I'm using group a lot in this installation because, well, just because!)

Ilg: where did you make the change to level 3? What file?

8 Sep 10, 2005 17:34

Topanga,

I don't want to make their level up because I don't know what you will assign for levels in future.

EdB, its a core/_class_user.php
look for

case 'edit_timestamp':
// Global permission to edit timestamps...
$perm = ($this->level >= 5);
break;


Form is loading...