The stable and forward-directed XOOPS 2.0.x trunk doesn't officially have an easy way to make modifications to registration profile fields, such as what is available in the 2.2.x "fork" that is being officially merged back into the 2.0.x branch. However, SmartFactory's SmartProfile module provides that functionality.

Note: this SmartProfile module was still buggy and development on it seems to have stalled (since the CVS 2007-06-15 aka 1.03). I ran into a number of issues with it working well and correctly in XOOPS 2.3.x branch, and have finally migrated over to the Profile Module as included in the XOOPS 2.3.x+ branch. Migration is fairly easy.

This module by SmartFactory, developed by the same developer that brought the xoops 2.2.x branch and its profiles module, provides the ability to have customizable profiles in XOOPS. This functionality included in the XOOPS 2.2.x fork was sorely missing in XOOPS 2.0.x fork. SmartProfiles also requires the SmartObjects framework (a collection of functions used by SmartFactory projects).

SmartProfiles 1.0 requires PHP5. The CVS version 1.03 supposedly is PHP4 ready. Some of the original bugs and enhancements I had suggested for 1.0 showed up in 1.03. Below are notes on my changes to the 1.03 unofficial release version. I had done some extensive work on the 1.0 PHP 5 version and then they released the CVS noted above which is supposed to support PHP4 as well. I've noted below if any of the changes were fixed (or added) in the CVS version.

My Version

This download includes all the changes noted below. I've also updated the SQL to include the basic default fields that my clients generally want to have (name, address, state, country, newsletter, etc.) -- note that the country one isn't quite working yet and needs a manual fix in the database. This should hopefully make it easier to get started (still easier to delete and pull back than add and construct). It also includes a modification to the admin fields page to show more information that was contributed by akitson. It also includes an extras folder with updated edituser.php, register.php, user.php, and userinfo.php files to redirect those basic functions to the module (ala xoops 2.2.x).

Installation

Requirements

First install SmartObjects framework, also by SmartFactory. Then install this just like any XOOPS module. You will also need to update a number of files related to registration and user information (implement similar to what is done in the XOOPS 2.2.x files) so that you use the correct registration and user-info functions:

edituser.php

register.php

user.php

userinfo.php

SmartProfile Defects

I have generally logged the errors and requests to the SmartFactory website, to XOOPS forums, and/or here. Noted are defects that are an issue in the CVS version noted above. Also, there are a number of pieces of HTML that are embedded into the code. My creedo is that no HTML should be put in the code in general because you can't dissect it easily and present it differently in the templates. I haven't necessarily reported all those (yet), and I've only "fixed" those I've needed to have show differently.

Registration Form

Primary User Fields Lost

Update: This one is fixed in the CVS version except for the disclaimer one below. This appears to be philosophical. The author indicated a preference for this behavior; my clients (and I) don't. As a user, I've already checked it once, so why check it every page.

In multi-step registrations, the primary user fields (uname, email, pass, agree_disc) were not being created in the database resulting in an error saying no e-mail could be sent (it was bounced to admin). The problem is that the fields weren't POSTed from the registration form beyond step 1. Make the following changes:

Required Field Verification

The registration form wasn't verifying for required fields. I found out that the form verification javascript wasn't displaying, fixed in the template. Also, it wasn't working in Microsoft IE because IE requires the name attribute.

Note: verification is via javascript and quite limited in scope (i.e., drop downs required aren't really that useful -- to some degree this is a failing of XOOPS forms, though, and not the module). There should be some other code on the server side on this, though, to actually verify as the javascript verification is just to reduce server load.

Required Field Indication

The registration form (and all XOOPS forms) should display the required fields as being required. This wasn't occurring.

That dealt with all required fields but the disclaimer -- another issue to deal with. (Note: the /class/xoopsform/form.php would be the logical place for this, but in this case, the /modules/profile/register.php has a function that supercedes this, so I put it there for this mode).

Defaults Not Loaded

I noticed that some fields weren't being set per the defaults specified in the module. Turns out it was only the original XOOPS core fields and those defaults weren't loaded before displaying the form. I fixed it by adding a function and changing one line of code. The problem is that when the $newuser is created it doesn't get the defaults from the field options stored in this module.

Blank Screen

Some users complained of a blank screen. I got this after registering and going back to the registration page (which is where you are directed by the index page if not logged in). After the user was activated, it would work again without blank screen.

This occurs because the user was registered but not activated yet, and the $_SESSION['smartprofile']['uid'] was still stored in the session, the page tried to pull the user from the database and could but the user was still deactivated and there was no code for that so the system went blank.

So, I put in a cleanser line of code to dump that session if you hit the register page again at the beginning (without any posted values). Realistically, it should be fine that way, but there is likely a better way to deal with this (it might go better in the postSaveProcess function).

register.php - before old line 146:

include_once 'include/forms.php';

add new line 146:

$_SESSION['smartprofile'] = array();

Disclaimer Shows More than Once

The disclaimer shows in every registration step prior to save. akitson had contributed PHP4 code with this fix in it, but this does it, too, checking the step info.

Register Should Redirect if Logged In

Update: This still exists in CVS

The register form should redirect to the user page if the user is logged in. The following code inserted at the top of the page should do that (otherwise they can register again), insert before line 35:

Fields

Options Field - Length

Because I wanted to include drop down selects for states/provinces and countries, I had to extend the size of this field to accommodate by changing it from varchar(255) to text in the database (now included in the installation SQL statements).

Options Field - Apostrophes

Also, field with array options containing apostrophe's doesn't retrieve correctly. The data os stored with addslashes, so upon retrieval for display, we have to remove it. The code fix I did was in the getEditElement function of the field class.

class/field.php - replace old line 80 (83 in CVS):

$options[$optkey] = $optval;

with:

$options[$optkey] = $myts->stripSlashesGPC($optval);

which requires this line which I added as the first line of the getEditElement function as new line 68:

$myts =& MyTextSanitizer::getInstance();

After this change, while displaying properly on the user side, it still displays incorrectly on the Admin side so that must be handled differently.

Date Value Requires Conversion Prior to Storing

Update: This still exists in the CVS version.

For a date field, the module stores the POSTed date which is YYYY-MM-DD (and HH:MM:SS for datetime). The value needs to be converted to a unix timestamp prior to storing it in the database. There were several places to fix this.

This deals with changing the text date to a unix time stamp in the register page so the expected value is where it should be.

Date Values Restricted to 1970 or Later

Update: Fixed in the CVS version.

There were a couple of issues I found on this one. Date values weren't allowed prior to 1970-01-01 (the unix timestamp of zero (0)). The field class restricted the value to greater than zero. I took care of that with this code:

Edit User

Edit User Fails xoopsSecurity

The ability to edit users first in admin and then also by users was failing. I found that it was because of the xoopsSecurity checks without the code being put on the page.

include/forms.php - just before old line 441:

return $form;

add new line 441:

$form->addElement(new XoopsFormHiddenToken());

Edit User as Admin Doesn't Save Data

An admin using the edit user form in the module admin couldn't save the user profile information. The editablefields wasn't pulling the correct permissions info causing the profile fields to be empty. Fix in admin/user.php, change line 139 from:

TimeZone Allows Multiple Select

The select statement for TimeZone allows more than one selection. ???? Why?

Change Email

New Email Won't Submit

I couldn't get the e-mail change form to actually submit. The issue is that in line 34, the code checks for an OR where it should be an AND (!POST method or not set "oldmail" variable). Changed from an OR (||) to an AND (&&) fixed it.

Newmail Field Missing

I couldn't get the form to work because it's trying to store the entered e-mail in a newemail variable in the profile class and then store and retrieve it. Since the field didn't exist in the database, it couldn't store it nor thus retrieve it. The post-installation script uses a addProfileFields() call to insert a field. It didn't work on my installation, so I had to add the field manually because this doesn't work otherwise, and it fails silently otherwise.

Duplicate Email Allowed for Entry

I can set the e-mail to one that already exists in the database and it won't warn me. However, when I try to activate it, then it gives me the error. Why not check before sending the activation/confirmation email?

Admin Visibility Permissions

The drop-down link in permissions that takes you to visibility doesn't work correctly in this version. The problem is that the code uses the php header command to change the location via re-direct, but this doesn't work if output has already occurred. Thus, in the permissions.php file, I had to move

Other

These I have not yet posted anywhere:

Email Change Request should be templated just like the other pages. I'm not a fan of the XoopsForm except if it were more templateable.

Category Display in Register Form: to get the Categories to show in the register form on each step, I commented out line 276 in include/forms.php. Didn't work. Still need to work on this. Pending.

Deleting a field in the administrator gives an error but still works. It calls a getmodulehandler('fieldcategory') but this class doesn't exist. Hey, it works. And how often are you gonna delete anyways?

I had a problem with the calendar javascript for date fields. It turns out it was a script in the theme that was conflicting with it (coral_reef). Changed themes, no problem!

Can't get longdate to work (not sure why I would want to, either, maybe disable?)

Profile data isn't verified on the server side for field constraints prior to committing to the database. It's only "verified" by required by client-side javascript.

Enhancement Requests

Rules (min/max length for text; min/max numbers, phone numbers, etc.)

Search page - Currently, I can't control searches by username and e-mail. They always display. You can obfuscate it, but one can still submit a form to do a search. From a privacy standpoint, this needs to change and allow control for every field, and then if no fields are accessible by permission, then it should also not be shown at all.

Need a "resend activation" capability.

Need a "deactivate permanently" (no re-activation by the user) capability.

Ability to receive notification of registration submissions when confirmation is set to require confirmation, before the user actually confirms.

Old Notes that I didn't want to remove for some reason.

PHP5 to PHP4 Port

Update: According to one SmartFactory post, this CVS Version took care of the entire PHP4 issue, but I didn't find that to be the case. If on PHP4, you'll need to look for these issues.

Obsolete Solutions

Before this, we had the Photos and Profiles Hack, a less than desirable, but somewhat workable, solution. It required hacks to many of the core files making upgrades much harder to accomplish, especially if you are already hacking those files. I did this hacking for one of my sites, and it was hard to keep up with all the time involved for each update. NOT RECOMMENDED!!