Gossamer Forum
Home : Products : DBMan : Customization :

categories and multiple database

Quote Reply
categories and multiple database
I need the following configuration of DBMAN:

1.) An individual/new database for every new user

2.) The user need to modify/edit his categories

3.) Categories must be unique to the user

3.) Categories must have a "public flag" sow the user can give the entries to all users

4.) Entries must have a "public flag" to. Than they must appear for all users.

Any suggestion? Is this possible with DBMAN?

Thanks now, and sorry for my bad english..

Kai
Quote Reply
Re: categories and multiple database In reply to
I think that DBMan might be able to do what you want, but I don't really understand what it is that you do want.

Do you want a separate database file for each user or do you want a record for each user?

When refer to "categories," I don't know what you mean. Do you mean records?

My apologies for not understanding. Possibly if you told us what you intend to do, it might help us to answer your questions.

I think this can be done with DBMan, but I'm not sure.


------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
Do you want a separate database file for each user or do you want a record for each
user?
>>> for each user

When refer to "categories," I don't know what you mean. Do you mean records?
>>> no categories

My apologies for not understanding. Possibly if you told us what you intend to do, it
might help us to answer your questions.

>> OK, i need an online-bookmark-management!

This is my idea:

Every user had to have a separate Database - eg. paul.db, maik.db ... for his
bookmarks.
This is to have small *.db - files. If it is not possible i have to use DBMAN SQL.

After "sign-up" the new user can setup (add,modify,delete)own categories eg.
"private", "business", "mp3", "games" ...

The User can share some bookmarks or categories with other users if he want. There must be a checkbox "public" at the bookmark-entry.

If he did so, the "public"-Bookmark should be appear under a new categoriename like the categoriename the user had added i.e.:

the user have a categorie "MP3" and an
"public" entry "www.mp3.com", then in the "public-area" must be a new category "Mp3"
with the entry www.mp3.com. If the category "mp3" is always there (public)(from an
other user) the entry www.mp3.com have to add in this categorie.

More: it was nice if users can rate the public bookmarks.

The user should have an option to display his bookmarks in categories e.g. all
bookmarks in the business-categories or all mp3-bookmarks in the mp3-categorie. I need
a pulldown-menu to change the categories

Hope you understand me and my bad english.

Kai
Quote Reply
Re: categories and multiple database In reply to
It might be possible to do this with DBMan, but I don't know how.

If users could only view their own records, it wouldn't be too difficult to have separate .db files for each user. But the only way I can see that it would be possible to have your "public" records would be to copy the records into a default.db in addition to the one owned by the user. This might end up to be such a large file that the advantage of having separate .db files would be lost.

I suppose another way to do it would be to have the user search for public records in each of the .db files. There is no way that I've found which would allow the script to search in multiple databases during the course of one search.

It seems that your needs center on the ability to have multiple databases. If you can have a public default.db file in addition to your user .db files, then we'll talk about how to do that and how to implement your other needs.


------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
First i am very happy for your quick support.

- i think itīs a good idea to copy the public entries into an default database - now we must have an entry for both - the new bookmark and the new category (if the category is new) in the default.db.

Did you think there is a way for this.

Kai
Quote Reply
Re: categories and multiple database In reply to
Ok. There one more for now: how i can allocate the categories to an user? It seems like the categories are always the same for all users.

Kai
Quote Reply
Re: categories and multiple database In reply to
One idea more... I have seen a mod "dbman links integration". Can I define personal links in links2? I think a solution with DBMAN is the smarter way. I like the "rating"
Option in Links2, is this possible in DBMAN too?

Kai
Quote Reply
Re: categories and multiple database In reply to
I really get confused if I deal with more than one issue at a time. Smile

The only problem I see with creating both individual .db files for each user and creating a default.db file for the public is that, once the file is created it might be a problem to modify it. Hmmmmmm. It might be able to be worked out, though.

What you would do is to add code to sub add_record. If a file for the user does not exist, create one. Then add the record to the user's .db file. If the "public" flag is set, also add the record to the default.db file.

The same thing can probably be done in sub modify_record. When a user modifies his personal record, if the "public" flag is set, the record would also be modified in the default.db file.

As for the categories, you can go several ways. You just have the users enter the categories in a text field, rather than having them in a select field. Or you can have a combination of a select field and a text field, with instructions that, if the desired category is not in the select field, to enter it into a text field. Either way, you can use a function within DBMan to "build_select_field_from_db," which will gather the field values from whatever field you want and create a select field from those values.

I don't know much about Links. If I understand what you're doing correctly, I think it would be better to use DBMan. Links builds pages, so the records would not be immediately available to the user like they would be with DBMan.


------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
OK letīs us skip the "public" entries for this time and let us go step by step...

The most importend thinks are:

1.) allow and enable the user to modify his own categories (add, delete...) without changing other users categories.
-this is most importend for now -

2.) every user should have an own database for his entries.

Now my problem is, that iīm not so good in Perl-Programming. Did u know a mod or code for this solutions?

Kai
Quote Reply
Re: categories and multiple database In reply to
Your two problems will be taken care of at the same time. The user can add new categories to his database, but, since DBMan can only access one .db file at a time, only the categories the user has entered in his own database will be available.

Let's start with creating the .db file for the user.

In sub html_home, right at the beginning, add

Code:
unless (-e "$db_script_path/$db_userid.db") {
open (DB, ">$db_script_path/$db_userid.db")
or &cgierr("unable to create file.\nReason: $!");
print DB "#";
print DB "\n";
close DB;
}

Log on to your database and check to make sure a file is created. It should have a # on one line and then a blank line after it. Take a look at the file and make sure it is correct.

I really think we ought to take this pretty slowly so that we know each step is correct before we goes on.


------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
It works Smile

Now the entry is into the user-database.

For the categories it was be fine if the user have the option to change (add,delete,rename etc.) his categories on a separate Page.

Therefor i need a combination of selectbox and editfield to enter new categories.

Kai
Quote Reply
Re: categories and multiple database In reply to
OK - this is done.

Now i have a new database with "#" as entry for the user. For example the name for admin-database is <<admin.db>>. The next step is to tell dbman to work with his databases, right? How can i do this?

Kai
Quote Reply
Re: categories and multiple database In reply to
Yay! (I really wasn't sure that would work. Smile )

At first I was thinking that it would be more complicated, but now I realize all you have to do is add a line after the code above:

Code:
$db_file_name = $db_script_path . "/$db_userid.db";

At that point, anything that the user does will apply to their own database.

As for the categories, did you want the users to just enter the category names in a text field or did you want to have a combination of a select field and a text field?


------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
After adding the previous code, I realized that it won't work. Sorry 'bout that. (I added a new post rather than editing the previous one in case you read the earlier one while I'm writing this one.)

In db.cgi, sub main, change

Code:
else { ($db_userid) = $db_uid =~ /([A-Za-z0-9]+)\.\d+/; }

to

Code:
else {
($db_userid) = $db_uid =~ /([A-Za-z0-9]+)\.\d+/;
$db_file_name = $db_script_path . "/$db_userid.db";
}

Once we know everything's okay with the users' databases, we'll think about the public ones.



------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
I can't believe this is going so smoothly! Smile I do appreciate your willingness to take it one step at a time. It makes it a lot easier to work with, especially with something so different than I've tried before.

To enter the categories for the user, include something like this in your html_record_form:

Code:
<tr><td>Category:</td>
<td>&nbsp;|;
print &build_select_field_from_db("Category",$rec{'Category'});
print qq|<BR>If the category you want is not listed, enter it below<BR>
<input type="text" name="Category" value="Category" size="40" maxlength="255">
</td></tr>

You will also need to make a little adjustment to your db.cgi file. Go to my "miscellaneous changes" page at http://www.jpdeni.com/dbman/Mods/changes.txt and get the modification to sub parse_form. Paste that over the subroutine of the same name in db.cgi.

This will give them a list of the categories they have already entered, but also give them the option of adding a new one.


------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
Iīm very happy about your support - it works fine. Now - how can i delete or rename a category? And when i delete a category, the entries from the deleted category should move to a default (i.e. general) category. This is better for the entries Wink

Kai
Quote Reply
Re: categories and multiple database In reply to
Deleting categories is really tough.

The categories are just whatever happens to be in the database at the current time. The only way I can think of to change the category is to modify the record.


------------------
JPD





Quote Reply
Re: categories and multiple database In reply to
Ok - itīs look like the user have to move all entries to an other category or to delete all entries in this category. Then i think the category is "deleted".

Now, how we can do "public" entries?

Kai