Allowing default user settings for DB-based preferences.

View: New views
3 Messages — Rating Filter:   Alert me  

Allowing default user settings for DB-based preferences.

by Thierry Godefroy-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greetings,

Unlike what happens whenever the user settings are saved as files, there is no
way to set default user preferences whenever the user settings are stored in a
database.

The attached patch cures this problem (it uses the config/default_pref file as
a source for the default settings, just like for the file-based prefs).

Regards,

Thierry.


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs
diff -urN squirrelmail/functions/db_prefs.php squirrelmail-patched/functions/db_prefs.php
--- squirrelmail/functions/db_prefs.php 2008-01-05 07:05:40.000000000 +0100
+++ squirrelmail-patched/functions/db_prefs.php 2008-02-11 09:55:33.000000000 +0100
@@ -165,6 +165,27 @@
 
 
     /**
+     * initialize the default preferences array.
+     *
+     */
+    function dbPrefs() {
+        // Try and read the default preferences file.
+        $default_pref = SM_PATH . 'config/default_pref';
+        if (@file_exists($default_pref)) {
+            if ($file = @fopen($default_pref, 'r')) {
+                while (!feof($file)) {
+                    $pref = fgets($file, 1024);
+                    $i = strpos($pref, '=');
+                    if ($i > 0) {
+                        $this->default[trim(substr($pref, 0, $i))] = trim(substr($pref, $i + 1));
+                    }
+                }
+                fclose($file);
+            }
+        }
+    }
+
+    /**
      * initialize DB connection object
      *
      * @return boolean true, if object is initialized

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Allowing default user settings for DB-based preferences.

by Paul Lesniewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Feb 11, 2008 2:07 AM, Thierry Godefroy <melinda_devel@...> wrote:
> Greetings,
>
> Unlike what happens whenever the user settings are saved as files, there is no
> way to set default user preferences whenever the user settings are stored in a
> database.

Not true.  See the class variable $default, which contains (hard
coded) defaults.  Obviously, this is not ideal; I'm not sure why this
was left this way.  Your solution is obviously more desirable,
although as someone else recently posted, there should be a way to get
the defaults from the DB itself as well.  I think I might take the
best of both solutions and do something about it this evening.

Thanks

> The attached patch cures this problem (it uses the config/default_pref file as
> a source for the default settings, just like for the file-based prefs).
>
> Regards,
>
> Thierry.
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Allowing default user settings for DB-based preferences.

by Thijs Kinkhorst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tuesday 12 February 2008 04:02, Paul Lesniewski wrote:

> On Feb 11, 2008 2:07 AM, Thierry Godefroy <melinda_devel@...> wrote:
> > Greetings,
> >
> > Unlike what happens whenever the user settings are saved as files, there
> > is no way to set default user preferences whenever the user settings are
> > stored in a database.
>
> Not true.  See the class variable $default, which contains (hard
> coded) defaults.  Obviously, this is not ideal; I'm not sure why this
> was left this way.  Your solution is obviously more desirable,
> although as someone else recently posted, there should be a way to get
> the defaults from the DB itself as well.  I think I might take the
> best of both solutions and do something about it this evening.

I've committed the patch into trunk now - Thierry's patch is good and although
your point is even better there's no need to wait with the good solution
until we have a better solution :-)


Thijs

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel
LightInTheBox - Buy quality products at wholesale price