[geeklog-cvs] geeklog-1.3/system memberdetail.thtml,NONE,1.1 lib-custom.php,1.5,1.6

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Thu Jul 17 13:09:29 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/system
In directory internal.geeklog.net:/tmp/cvs-serv30874

Modified Files:
	lib-custom.php 
Added Files:
	memberdetail.thtml 
Log Message:
Added Blaine's sample code for the custom registration.


--- NEW FILE: memberdetail.thtml ---
<!-- sample template for a custom registration form - see lib-custom.php -->
{startblock}
{message}
<form action="{post_url}" method="post">
	<table border="0" cellspacing="0" cellpadding="2" bgcolor='#f6f6ff' width=550>
		<tr>
			<td align="right" valign=middle><font color='#000000'><b>{USERNAME}</b></font><br><font color=#676767 size=1>{USERNAME_HELP}</font></td>
			<td align=left valign=middle><input type="text" name="username" size="25" maxlength="16" value="{username}"></td> 
			<td><img src='/images/speck.gif' width=30 height=1></td>
		</tr>
		{passwd_input} 
		<tr> 
			<td align="right" valign=middle><font color='#000000'><b>{EMAIL}</b></font><br><font color=#676767 size=1>{EMAIL_HELP}</font></td> 
			<td align=left valign=middle><input type="text" name="email" size="25" maxlength="100" value="{email}"></td> 
		        <td><img src='/images/speck.gif' width=30 height=1></td>
		</tr> 
		<tr>
 	 		<td align="right" valign=middle><font color='#000000'><b>{WEBSITE}</b></font><br><font color=#676767 size=1>{WEBSITE_HELP}</font></td>
			<td align=left valign=middle><input type="text" name="homepage" size="25" maxlength="255" value="{website}"></td> 
		    <td><img src='/images/speck.gif' width=30 height=1></td>
		</tr> 		
		<tr>
			<td align="right" valign=middle><font color='#000000'><b>{FIRSTNAME}</b></font><br><font color=#676767 size=1>{FIRSTNAME_HELP}</font></td>
			<td align=left valign=middle><input type="text" name="firstname" size="25" maxlength="40" value="{firstname}"></td> 
		       <td><img src='/images/speck.gif' width=30 height=1></td>
	       </tr> 
		<tr>
			<td align="right" valign=middle><font color='#000000'><b>{LASTNAME}</b></font><br><font color=#676767 size=1>{LASTNAME_HELP}</font></td>
			<td><input type="text" name="lastname" size="25" maxlength="40" value="{lastname}"></td> 
		       <td><img src='/images/speck.gif' width=30 height=1></td>
   	        </tr> 
		<tr>
			<td align="right" valign=middle><font color='#000000'><b>{COUNTRY}</b></font><br><font color=#676767 size=1>{COUNTRY_HELP}</font></td>
			<td align=left valign=middle><input type="text" name="country" size="25" maxlength="30" value="{country}"></td> 
			<td><img src='/images/speck.gif' width=30 height=1></td>
		</tr> 
		<tr>
			<td align="right" valign=middle><font color='#000000'><b>{COMPANY}</b></font><br><font color=#676767 size=1>{COMPANY_HELP}</font></td> 
			<td align=left valign=middle><input type="text" name="company" size="25" maxlength="80" value="{company}"></td> 
	               <td><img src='/images/speck.gif' width=30 height=1></td>
		</tr> 
		<tr> 
			<td align="center" colspan="2"><input type="hidden" name="uid" value="{user_id}"><HR><BR>
			<input type="hidden" name="mode" value="{postmode}">{submitbutton}</td> 
		</tr> 
	</table>
</form>
{endblock}

Index: lib-custom.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/system/lib-custom.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** lib-custom.php	2 Jul 2003 14:29:31 -0000	1.5
--- lib-custom.php	17 Jul 2003 17:09:27 -0000	1.6
***************
*** 135,137 ****
--- 135,280 ----
  }
  
+ 
+ /*  Sample Custom Member Functions to create and update Custom Membership registration and profile 
+ 
+ 	  Required Table Structure for this example:
+ 		CREATE TABLE `custom_memberinfo` (
+ 		  `uid` mediumint(9) NOT NULL default '0',
+ 		  `firstname` varchar(128) NOT NULL default '',
+ 		  `lastname` varchar(128) NOT NULL default '',
+ 		  `country` varchar(128) NOT NULL default '',
+ 		  `company` varchar(128) NOT NULL default '',
+ 		  KEY `uid` (`uid`)
+ 		) TYPE=MyISAM;
+ 
+ 	Note1: You also need to include a defintion for the new table in lib-database.php 
+ 	$_TABLES['custom_memberinfo'] = $_DB_table_prefix . 'custom_memberinfo';
+ 
+ 	Note2: Enable CustomRegistration Feature in config.php
+ 	$_CONF['custom_registration'] = true;  // Set to true if you have custom code
+ 
+ 	Note3: This example requries a template file called memberdetail.thtml to be
+ 	located under the theme_dir/custom directory
+ 
+ 	4 Functions have been provided that are called from the Core Geeklog User admin code
+ 	- This works with User Moderation as well
+ 	- Admin will see the new registration info when checking a members profile only
+ 	- All other users will see the standard GL User profile information
+ 
+ */
+ 
+ function custom_usercreate($uid) {
+     global $_CONF,$_TABLES,$HTTP_POST_VARS;
+ 
+ 	// Note you will need to ensure all data is prepared correctly before inserts - as quotes may need to be escaped with addslashes()
+ 
+     DB_query("INSERT INTO {$_TABLES['custom_memberinfo']} (uid,company,firstname,lastname,country) VALUES
+        ($uid,'{$HTTP_POST_VARS['company']}','{$HTTP_POST_VARS['firstname']}','{$HTTP_POST_VARS['lastname']}','{$HTTP_POST_VARS['country']}')");
+ 	DB_query("UPDATE {$_TABLES['users']} SET email='{$HTTP_POST_VARS['email']}',homepage='{$HTTP_POST_VARS['homepage']}', fullname='{$HTTP_POST_VARS['firstname']} {$HTTP_POST_VARS['lastname']}' WHERE uid=$uid");
+ 
+     return true;
+ 
+ }
+ 
+ function custom_usersave($uid) {
+     global $_CONF,$_TABLES,$HTTP_POST_VARS;
+ 
+ 	// Note you will need to ensure all data is prepared correctly before inserts - as quotes may need to be escaped with addslashes()
+ 
+     DB_query("UPDATE {$_TABLES['custom_memberinfo']} SET
+ 	    company='{$HTTP_POST_VARS['company']}',
+ 		firstname='{$HTTP_POST_VARS['firstname']}',
+ 		lastname='{$HTTP_POST_VARS['lastname']}',
+ 		country='{$HTTP_POST_VARS['country']}'
+         WHERE uid=$uid");
+ 
+ 	DB_query("UPDATE {$_TABLES['users']} SET 
+ 	    email='{$HTTP_POST_VARS['email']}',
+ 		homepage='{$HTTP_POST_VARS['homepage']}', 
+ 		fullname='{$HTTP_POST_VARS['firstname']} {$HTTP_POST_VARS['lastname']}' 
+ 		WHERE uid=$uid");
+ 
+     return true;
+ 
+ }
+ 
+ function custom_userdelete($uid) {
+     global $_TABLES;
+     DB_query("DELETE FROM {$_TABLES['custom_memberinfo']} WHERE uid=$uid");
+ 
+ 	return true;
+ }
+ 
+ /* Main Form used for Custom membership to add/edit and display custom user form */
+ function custom_userform($mode,$uid="",$msg="") {
+     global $_CONF,$_TABLES, $LANG04;
+ 	if (!empty($msg)) {
+ 		$retval .= COM_startBlock($LANG04[21]) . $msg . COM_endBlock();
+ 	}
+ 
+ 	if ($mode == "edit") {
+         $post_url = $_CONF['site_url']."/usersettings.php";
+ 		$postmode = "saveuser";
+         $submitbutton = '<input type="submit" value="Update User Profile">';
+ 		$passwd_input = '<tr valign="top">' . LB
+ 	        . '<td align="right"><b>Password</b></td>' . LB
+ 	        . '<td><input type="password" name="passwd" size="32" maxlength="32" value=""></td>' . LB
+ 	        . '</tr>' . LB;
+         $result = DB_query("SELECT * FROM {$_TABLES['users']},{$_TABLES['custom_memberinfo']} WHERE {$_TABLES['users']}.uid = $uid AND {$_TABLES['custom_memberinfo']}.uid = $uid");
+         $A = DB_fetchArray($result);
+         $message = "<br><font size=3><br></font><font size=2 color=black><b>Edit your membership below. Once you have completed, click the Update button to save the record.</b></font>";
+     
+     } elseif ($mode == "moderate" ) {
+ 	   $submitbutton = '<input type="button" value="Back" onclick="javascript:history.go(-1)">';
+ 	   $result = DB_query("SELECT * FROM {$_TABLES['users']},{$_TABLES['custom_memberinfo']} WHERE {$_TABLES['users']}.uid = $uid AND {$_TABLES['custom_memberinfo']}.uid = $uid");
+        $A = DB_fetchArray($result);
+ 			
+ 	} else {
+         $post_url = $_CONF['site_url']."/users.php";
+ 		$postmode = "create";
+         $submitbutton = '<input type="submit" value="Register Now!">';
+ 		$passwd_input = "";
+ 		$message = "<br><font size=2 color=black><b>Please complete the application below. Once you have completed the application, click the Submit button and the application will be processed immediately.</b></font>";
+ 		$A=array();
+     }
+ 
+     $user_templates = new Template ($_CONF['path_layout'] . 'custom');
+     $user_templates->set_file('memberdetail', 'memberdetail.thtml');
+     $user_templates->set_var('layout_url', $_CONF['layout_url']);
+     $user_templates->set_var('post_url', $post_url);
+     $user_templates->set_var('startblock', COM_startBlock("New Member User Registration"));
+     $user_templates->set_var('message', $message);    
+     $user_templates->set_var('USERNAME', "Username");
+     $user_templates->set_var('USERNAME_HELP', "Name to be used when accessing this site");
+     $user_templates->set_var('username', $A['username']);
+     $user_templates->set_var('passwd_input', $passwd_input);
+     $user_templates->set_var('EMAIL', "Email Address");
+     $user_templates->set_var('EMAIL_HELP', "");
+     $user_templates->set_var('email', $A['email']);
+     $user_templates->set_var('WEBSITE', "website");
+     $user_templates->set_var('WEBSITE_HELP', "");
+     $user_templates->set_var('website', $A['homepage']);
+     $user_templates->set_var('COMPANY', "Company Name");
+     $user_templates->set_var('COMPANY_HELP', "Enter your Company Name");
+     $user_templates->set_var('company', $A['company']);
+     $user_templates->set_var('FIRSTNAME', "First Name");
+     $user_templates->set_var('FIRSTNAME_HELP', "");
+     $user_templates->set_var('firstname', $A['firstname']);
+     $user_templates->set_var('LASTNAME', "Last Name");
+     $user_templates->set_var('LASTNAME_HELP', "");
+     $user_templates->set_var('lastname', $A['lastname']);
+     $user_templates->set_var('COUNTRY', "Country");
+     $user_templates->set_var('COUNTRY_HELP', "Enter your country");
+     $user_templates->set_var('country', $A['country']);	
+     $user_templates->set_var('user_id', $user);
+     $user_templates->set_var('postmode', $postmode);
+     $user_templates->set_var('submitbutton', $submitbutton);
+ 
+     $user_templates->set_var('endblock', COM_endBlock());
+     $user_templates->parse('output', 'memberdetail');
+     $retval .= $user_templates->finish($user_templates->get_var('output'));
+ 
+ 	return $retval;
+ }
+ 
  ?>





More information about the geeklog-cvs mailing list