boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

password protected blog
Goto page Previous  1, 2
 
Post new topic   Reply to topic    boardom Forum Index -> Feature requests
View previous topic :: View next topic  
Author Message
imeridian



Joined: 12 Feb 2002
Posts: 191

PostPosted: Wed Oct 30, 2002 12:46 am    Post subject: Reply with quote

No... you don't seem to understand what I'm saying.

This is already built into b2 by design and for this purpose.

I don't write "hacks," I write code for b2.

The only thing not yet available in the script is the "unpublished" category itself and a way to display them outside of the b2edit.php... and that is what my instructions provide.

Everywhere throughout b2 there is exclusion for posts in category zero, if you read back through the forum it had already been discussed that using a specific category for 'hidden' posts was the way to go, and thus working with Michel we refined specific areas to make sure that this worked properly.
_________________
-indi<br>
http://indiboi.com
http://artlikepornstars.com
http://www.positivefusion.com
Back to top
View user's profile Send private message Visit poster's website
Drinyth



Joined: 28 Oct 2002
Posts: 17

PostPosted: Wed Oct 30, 2002 1:48 am    Post subject: Reply with quote

Oh. Thanks for the bold. Smile

Sorry... I actually just installed B2 a couple days ago, so I'm not up on the history or what's already been discussed. What you have been saying makes much more sense now. I was wondering why you were trying so hard to sell me your "hack" at first. Smile
Back to top
View user's profile Send private message
imeridian



Joined: 12 Feb 2002
Posts: 191

PostPosted: Wed Oct 30, 2002 2:00 am    Post subject: Reply with quote

Yeah... lol.. I didn't want to be rude about it, but I got the distinct impression that I wasn't coming across in the right way.

Anyhow, I'm writing a little script to automate the process of adding the category properly, since involves a couple of mysql queries within phpmyadmin otherwise. I'll also give me detailed instructions (ie, a copy) of the modified blog.header.php -- but you only need that if you want to see posts outside of b2edit.php.
_________________
-indi<br>
http://indiboi.com
http://artlikepornstars.com
http://www.positivefusion.com
Back to top
View user's profile Send private message Visit poster's website
imeridian



Joined: 12 Feb 2002
Posts: 191

PostPosted: Wed Oct 30, 2002 2:36 am    Post subject: Reply with quote

That will create a category with the ID of "0" named "Unpublished" while setting the default category to "1" instead of "Unpublished, because having the category defaulted to unpublished would be pretty annoying after a while if most entries aren't private.


Code:
<?php

include("./b2config.php");
include("$b2inc/b2functions.php");

dbconnect();

$sql = "INSERT INTO $tablecategories(cat_ID,cat_name) VALUES('0','Unpublished')";
$result = mysql_query($sql) or die("OH MY GOSH:<br />\n".mysql_error());
echo "Added Category Named Unpublished<br />";
$sql2 = "UPDATE $tablecategories SET cat_ID=\"0\" WHERE cat_name = \"Unpublished\"";
$result2 = mysql_query($sql2) or die("Oops...<br />\n".mysql_error());
echo "Set Category ID to 0<br />";
$sql3 = "ALTER TABLE $tableposts CHANGE post_category post_category INT(4) DEFAULT '1' NOT NULL";
$result3 = mysql_query($sql3) or die("Oops...<br />\n".mysql_error());
echo "Resetting Default Category to 1<br />";
echo "<hr /><br />Done, now all posts in the Unpublished category will not be shown outside of b2edit";

?>


Copy & paste this code into "makecat0.php" or something similar, and then all you need to do is upload the page to your b2 directory and load it in your browser.

I've tested this several times and it seems to work fine, but.... that doesn't mean you shouldn't backup your database first... I'm not responsible if this destroys anything! (but it won't, so don't worry too much) :)

If you want to display the entries outside of b2edit.php:
You only need to make one change, save it as "private.header.php" or whatever you'd like and load that header file instead of blog.header.php in your private.php, etc.
Quote:

248c248
< $where .= ' AND post_category > 0';
---
> $where .= ' AND post_category = 0';


What that means is on line 248 there is "> 0" and you want it to be "= 0" so it shows only those private posts.

Of course to make it actually private, it'd be best to put the new index which loads the "private.header.php" into a separate directory which is protected via .htaccess authentication... Showing the private posts is rather a secondary function to the ability to actually make them private and shown only to the author.

Showing the posts outside of b2edit.php is the only "hackish" part of this... but all you're really doing is removing the restriction against showing those private posts, and the reason for the script to add category zero is just because by default the database will increment the cat_ID number up to the next one, which wouldn't be zero of course.... so it makes it easy to do this way.
_________________
-indi<br>
http://indiboi.com
http://artlikepornstars.com
http://www.positivefusion.com
Back to top
View user's profile Send private message Visit poster's website
Gadget Girl



Joined: 25 Jan 2002
Posts: 305
Location: Virginia

PostPosted: Sat Apr 12, 2003 6:41 pm    Post subject: Reply with quote

Hi Indi,

Thanks for this, it almost works.

When I load up private.php I do get my sidebars, but this is there instead of the posts:
Code:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/simply/public_html/blog/private.php on line 98


Line 98:
Code:
<?php while($row = mysql_fetch_object($result)) { start_b2(); ?>


Any hints or clues? Anyone?

Thanks in advance!

Smile Sara
Back to top
View user's profile Send private message
neil



Joined: 12 Apr 2003
Posts: 9

PostPosted: Sun Apr 13, 2003 9:11 am    Post subject: Reply with quote

quick question about this,

is there any way to make the new Unpublished category the default? i went into phpmyadmin and changed the default value to 0, but when i log in, it remained as Category 1 (general). i tried refreshing, but it didn't make any difference.

also, is there a code for "greater than or equal to"? i'd like to be able to view all categories, including 0, on my private page. thanks for any help.
Back to top
View user's profile Send private message AIM Address
Tom



Joined: 11 Apr 2003
Posts: 6
Location: England

PostPosted: Sun Apr 13, 2003 9:26 am    Post subject: Reply with quote

greater than or equal to is, just as an example
Code:

if($x >= $y) {
   // do whatever
}

_________________
http://www.paper-bags.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
beachgerl



Joined: 14 Apr 2003
Posts: 37
Location: San Diego

PostPosted: Mon Apr 14, 2003 2:41 am    Post subject: Setting category 0 up Reply with quote

imeridian wrote:
There is support for a private category, it's just not turned on by default.

B2 will not show posts that are in category 0, but of course you can't add a category 0 through B2 itself, so you need to do it with phpmyadmin or via mysql command line, etc, naming it something like "private" or "unpublished"

Can you describe the steps for setting category 0 up in myphpadmin? I just want a category 0 (for keeping entries private from visitors).

TIA.
Back to top
View user's profile Send private message
beachgerl



Joined: 14 Apr 2003
Posts: 37
Location: San Diego

PostPosted: Mon Apr 14, 2003 5:17 am    Post subject: Re: Setting category 0 up Reply with quote

beachgerl wrote:
imeridian wrote:
There is support for a private category, it's just not turned on by default.

B2 will not show posts that are in category 0, but of course you can't add a category 0 through B2 itself, so you need to do it with phpmyadmin or via mysql command line, etc, naming it something like "private" or "unpublished"

Can you describe the steps for setting category 0 up in myphpadmin? I just want a category 0 (for keeping entries private from visitors).

TIA.

Never mind. I added the cat 0 using myphpadmin which made things much easier. Your instructions are great, imeridian! It'll be nice to see this feature as well as protected entries added to B2 script in the future. B2 rocks and is easy to install/setup for me so far! No terrible errors to date. Very Happy
Back to top
View user's profile Send private message
alisa



Joined: 06 Apr 2003
Posts: 5
Location: Scotland

PostPosted: Wed May 07, 2003 1:19 am    Post subject: Reply with quote

When you've installed this, is the comments supposed to not work on the category 0 posts? If so is there any way to over-ride it?
_________________
"Hardware: the parts of a computer that can be kicked."
-Jeff Pesis


alisa
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
donncha



Joined: 18 Feb 2003
Posts: 43
Location: Cork, Ireland

PostPosted: Fri May 09, 2003 10:02 pm    Post subject: thanks, but modify b2categories.php too Reply with quote

Nice "Hack" Smile

You should probably edit b2categories.php so the blog editor can't edit or delete the 0 category, should add a check for cat 1 too while we're at it..
Modifiy line 141:
Code:
$query="SELECT * FROM $tablecategories ORDER BY cat_ID";

so it looks like:
Code:
$query="SELECT * FROM $tablecategories where cat_ID != '0' and cat_ID != '1' ORDER BY cat_ID";



Sara - remove the variable $result from your mysql_fetch_object() call. That'll probably fix your error.

I'm going to put this into b2++ as a "Draft Post" feature. A real "private" post feature should have a generic security layer so you could protect posts via any number of methods (ie. logged in user, IP, password, the phase of the moon..) but that'll require modification of the tableposts table and a lot of code IMO.

Donncha.
Back to top
View user's profile Send private message Visit poster's website
rakhesh



Joined: 11 Feb 2003
Posts: 8
Location: New Delhi, India

PostPosted: Sun May 25, 2003 8:43 am    Post subject: More than one private categories? Reply with quote

imeridian wrote:
B2 will not show posts that are in category 0, but of course you can't add a category 0 through B2 itself, so you need to do it with phpmyadmin or via mysql command line, etc, naming it something like "private" or "unpublished"

If you then want someone other than yourself to see them you need to make a copy of the blog.header.php and change the mysql queries where it says "AND post_category > 0" to "AND post_category = 0" then include this new blog.header.php, renamed to something like zero.header.php in a seperate b2 index, which can use all the other files from your existing b2 installation. As mentioned then, simply put an .htaccess mod_auth block on it.


Is it possible to have more than one private categories? Say, but having categories 0, -1, -2, etc ...?

Or alternatively, if one can't have -ve category numbers, is it possible to have more than one private categories by changing the line "AND post_category > 0" to something like "AND post_category > 2", and this way make categories 0, 1, and 2 as private?

One last question: do RSS feeds include the postings in these private categories? Or would I have to do something extra to create feeds for these categories?

Thanks,
Rakhesh Smile
Back to top
View user's profile Send private message Visit poster's website
yuchy



Joined: 22 Jun 2003
Posts: 28

PostPosted: Wed Aug 27, 2003 12:01 pm    Post subject: Reply with quote

the following call

b2edit.php?cat=0&submit=View

does not return the posts in the private category. but when i do a search on some of the key phrases in my private posts, it does show me my private posts. what is wrong here?
Back to top
View user's profile Send private message
mccollin



Joined: 06 Jul 2003
Posts: 5
Location: NY

PostPosted: Thu Aug 28, 2003 6:43 pm    Post subject: Reply with quote

How do you get the Private category to show up in the category list on the right margin of the index page. I have a private index page now, but only the non-0 categories show up there.
_________________
Mike Collins
http://pdaphonehome.com
Back to top
View user's profile Send private message
mccollin



Joined: 06 Jul 2003
Posts: 5
Location: NY

PostPosted: Thu Aug 28, 2003 6:49 pm    Post subject: Reply with quote

One more question. If I move the privateindex.php to another directory, it isn't going to find any of the other files... how do I keep the current directory set to html_root, while moving privateindex.php to /html_root/private. Thanks.
_________________
Mike Collins
http://pdaphonehome.com
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Feature requests All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group