a2e php_users documentation

a2e php_users documentation

How to install, configure use and extend the a2e php_users user managment system – documentation to be created.

1 History

  • 2007-04-22 phm creates this directory.

2 Invocation Syntax

In this example we retrieve data about a photo of a recent activity of FFII from our database, apply some modifications and write the modified data back to the database.

db_init('photo_form', array('login', 'photo_id', 'photo_url', 'photo_width', 'photo_height', 'photo_descr', 'photo_date'))
$photo_id = 'patman070329'
$photo_info[$photo_id] = db_get('photo_form', array('photo_id' =>$photo_id))
  // photo information processing code starts here
  // ...
  $photo_info[$photo_id]['photo_descr'] = "PatMan: fat for the future, asking for more patents, less innovation"
  $photo_info[$photo_id]['photo_date'= '2007-03-29'
  // ... 
  // photo informationn processing finished, now we write the result back to the database
db_put('photo_form', $photo_info)

db_init initialises a connection between a web form and the database backend. Argument one is the name of the connection, argument 2 is a list of fields, with the names that we use in our web form (not those used in the database). Any later read/write actions using this connection are limited in scope to this set of fields.

db_get retrieves data from the database connection of argument 1 and returns it as an associative array of field data.

db_put writes an associative array of field data into the database using the mapping rules defined by the connection.

All three commands shield the user from the database backend. Names of tables and columns as well as rules for mapping them to the fields are stored in a mapping configuration file such as include/users_schema_pgsql3.inc.

It is possible to convert contents of several fields into contents of several columns and back. E.g. the backend might store a photo_height of 60 and photo_width 240 as ‘240x60’ in a column called ‘photo_size’, and this might be in a separate table. Such structural differences between the frontend and backend need not concern the web form designer.

3 Mapping Configuration Syntax

4 Development and Packaging Tools

Not part of the package which we will distribute, largely of private nature, but still to some extent documented in the Development Tools directory.

5 Resources

  • ../include/users_sql.inc – all the SQL commands of php_users are concentrated here and replaced by more abstract functions, see inline documentation, a good entry point may be the function pair db_get and db_put
  • ../sites/ffii/include/ffii_users_schema.inc – mapping from php_users form fields naming scheme to database scheme
  • apache test server configuration
  • ../include – this directory is listed in the test server’s include_path
  • ../sites/eupat/include, ../sites/ffii/include – the application specific directories that are specified in the $USER_SITES array are also listed in the test server’s include_path
  • ../sites/eupat/include/eupat_start.phps – the test server’s auto_prepend_file, contains a few lines of server-specific configuration settings, including selection of database backend by $USERS_DBNAME and form fields to database columns mapping $USERS_SCHEMA
  • ../include/start.phps – invoked from each server’s auto_prepend_file, defines function users_sidepanel
  • Deplate TemplatesDeplate template, invokes function users_sidepanel, thus makes php_users functionality available to all web pages that are generated from Deplate (wiki-like) source text
  • ../include/users.conf:configuration file; special settings: $DSN = "pgsql://apache@/php_users2"; $USER_COOKIE   = "uz_X4fo"
  • ../htdocs/newaccount.phps: this php_users form should not need to invoke much more than the functions sql_newaccount_get and sql_newaccount_put in order to communicate with the database backend
  • available default database schemas(s) – more is to be done here, currently these are not used
  • constraints: column names must be lower case alphanum, because fetchRow(DB_FETCHMODE_ASSOC) converts everything to lowercase
  • ../htdocs/user_edit.php – simplified version of users_edit: edit only my own profile
  • WDDX
  • book “Programming PHP” by Rasmus Lerdorf, Kevin Tatroe & Peter MacIntyre, published by O’Reilly, 2nd Edition
  • php.ini, some characteristic settings include
    • session.serialize_handler = wddx
    • session.save_path = “/var/lib/php5” (should perhaps be changed to something like /var/lib/wddx/session)
    • register_globals = Off
    • post_max_size = 8M
    • magic_quotes_gpc = Off
    • magic_quotes_runtime = Off
  • Custom functions for reading and writing registered variables, in book “Programming PHP” p. 192
[ ADP | php | users | 0.2.4 | documentation| php_users/htdocs| php_users/include| a2e php_users: local extensions| a2e php_user meta utilities ]
Valid XHTML 1.0! Valid CSS! deplate
http://a2e.de/adv/php/users/v0_2_4/doc
© 2007-04-22 Hartmut PILCH