[Zope-CMF] Conversion from PHP to ZODB/CMF Registration
Norman Khine
khine@bmpublications.co.uk
Fri, 1 Jun 2001 12:27:17 +0100
What will be the alternative code for the following PHP file, if I want to
include it into a CMF?
All registered users are Members, and the data is held on a MySQL db. I
would like to:
1. Extend the current CMF registration form to include other fields and use
the ZODB, instead of using MySQL.
2. A clearer insight as to how the validation process works in the CMF and
how it can be extended.
3. In the join_form of the CMF there is couple of fields that are being
commented out, uncommenting these I get the FullName and Company -- how does
one retrive this information from the ZODB.
I have looked in the roster code, but I am afraid I am LOST.
4. How do I register new fields in the ZODB, if I want to create say an
address fields for each member, so that to each address I can have a number
of Members?
<?
// verify username and password via SQL query
// returns user's first name if successful
function valid_user()
{
global $username, $password;
$res = sql_one_row("select PersonID, LoginName, Password from Person where
LoginName = '$username'");
if ($username == $res[1] && $password == $res[2])
{
return $res[0];
}
else
{
return false;
}
}
require("library/conf.php");
require("library/sql.php");
require("library/db-mysql.php");
require("library/misc.php");
// if login form submitted
if ($submit)
{
// if user is valid!
if ($res = valid_user())
{
$res2 = sql_one_row("select FirstName, FK_GroupsID from Person where
PersonID = '$res'");
// check Remember Me status and set cookie if true
if ($sticky == "yes")
{
setCookie("cookie_user", $username, time()+2592000);
}
// start session, register user's first name as session variable
session_start();
session_register("SESSION");
session_register("SESSION_USERNAME");
session_register("SESSION_UID");
$SESSION_USERNAME = $res2[0];
$SESSION_UID = $res;
$gid = $res2[1];
include("body.inc");
}
else
// if user is not valid, display error
{
$status="error";
include("body.inc");
}
}
else
{
session_start();
// initial page, no login attempt yet
if (!session_is_registered("SESSION"))
{
include("body.inc");
}
// user logged-in, returning to page from elsewhere
else
{
include("body.inc");
}
}
?>
<?
require("footer.inc");
?>
Thanks
Norman