Store Fields.ini in db or link to external File?

A place for users and developers of the Xataface to discuss and receive support.

Store Fields.ini in db or link to external File?

Postby ge11er » Fri Jan 08, 2010 8:00 am

I'm have a site (in long development) with the potential for 200+ users, who will have 3 different subscription levels, with increasing levels, giving them more features -> to more rows accessed -> different fields.ini files?

I pull valuelist from DB so....

If I could store the fields.ini for each level in the DB or externally then future development for me would be much simpler.

Is this possible? Is it necessary? Is there a better way to do it?
ge11er
 
Posts: 18
Joined: Wed Feb 11, 2009 4:52 pm

Re: Store Fields.ini in db or link to external File?

Postby shannah » Mon Jan 11, 2010 11:39 am

So you are wanting drastically different configurations depending on the level of user that is logged in, and want to be able to have different sets of configuration files for different users? This currently isn't really possible, however I have achieved similar things by using the decorateFieldsINI() event that was added in Xataface 1.2 (I believe)... not documented yet.

Example: In the application delegate class
Code: Select all
/**
  * Function called after fields.ini file is finished loading for each table.
  * @param array &$conf The contents of the fields.ini file as a 2-d array.
  * @param Dataface_Table  &$table The database table object for which the fields.ini were just loaded.
  * @return void  This just modifies $conf in place.
  */
function decorateFieldsINI(&$conf, &$table){
      if ( preg_match('/^conference_feed/', $table->tablename) ){
         $newconf = parse_ini_file('tables/conference_feed/fields.ini', true);
         foreach ( $newconf as $key=>$val){
            $conf[$key] = $val;
         }
      } else if ( preg_match('/^courses_feed/', $table->tablename) ){
         $newconf = parse_ini_file('tables/courses_feed/fields.ini', true);
         foreach ( $newconf as $key=>$val){
            $conf[$key] = $val;
         }
      } else if ( preg_match('/^authors_feed/', $table->tablename) ){
         $newconf = parse_ini_file('tables/authors_feed/fields.ini', true);
         foreach ( $newconf as $key=>$val){
            $conf[$key] = $val;
         }
         
      }
   }


So you can have a base fields.ini file and then decorate it with whatever parameters you like by overlaying other configuration information.

This strategy opens the door for you to store your configuration information however you like (at least as it pertains to the fields.ini file).
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved