Firefox PHP

Module: Birthdays

Posted by Steve H 
Re: Module: Birthdays
February 11, 2008 01:24PM
well, sure. you just need to run your own replacements on the language strings before using them ;).
something like
$PHORUM['DATA']['LANG']['MyLanguageString'] = str_replace("[#]",$myvariablewiththatnumber,$PHORUM['DATA']['LANG']['MyLanguageString']);


Thomas Seifert
Re: Module: Birthdays
February 11, 2008 02:25PM
It shold be like that

[next 30 days] [in] [no birthdays]

according to turkish. Also


I hope that I could explain :)



Edited 1 time(s). Last edit at 02/11/2008 02:28PM by scabboy.
pat
Re: Module: Birthdays
February 11, 2008 02:59PM
regular:

"BlockContentNone" => "No birthdays in the next",
"Days" => "days",

[No birthdays in the next] $30 [days]

___________________________________

turkish:

"BlockContentNone" => "next ",
"Days" => "days in no birthdays",



[next] $30 [days in no birthdays]
Re: Module: Birthdays
February 11, 2008 03:09PM
Quote
mmakaay
You can use phorum_api_user_search_custom_profile_field() for that.
Here a excerpt from the Google Maps module which does a lookup on a custom profile field:
// Collect all users which have a "mod_google_maps" custom user profile field.
require_once('./include/api/custom_profile_fields.php');
$field = phorum_api_custom_profile_field_byname('mod_google_maps');
if (empty($field)) trigger_error(
    'No custom profile field named "mod_google_maps" available',
    E_USER_ERROR
);
$user_ids = phorum_api_user_search_custom_profile_field(
    $field[0], '', '%', TRUE
);

I've been playing with this without success. My problem is that the custom field I need to search on is in an array:

mod_birthdays["birthday"]

I'm not sure if this api will support that, and if it will, what the proper syntax is?

Beyond that, I suspect that there is no good way to search for current birthdays as timestamps with simple pattern matching. I need to store them as separate fields for month, day and year so I can ignore the year when searching. (or perhaps store an additional "fake" timestamp with the year set to an arbitrary year strictly for searching)

...
Steve H, currently on: (version 5.2.23)
contributions:
Birthdays mod, Top Users mod, Icon legend.tpl, (plus a handful of bugfixes and old 5.0 creations)
Re: Module: Birthdays
February 11, 2008 03:48PM
More on phorum_api_user_search_custom_profile_field()...

What is the best way to combine this with phorum_api_user_search() so that I can search on both regular user fields (like "active") and custom profile fields?

Also, I see that you're using an unspecified operator (%):
$user_ids = phorum_api_user_search_custom_profile_field(
    $field[0], '', '%', TRUE
);
Quote

Valid operators are "=", "!=", "<>", "<", ">", ">=" and "<=", "*". The "*" operator is for executing a "LIKE '%value%'" matching query.

Is % equivalent to *?

edit...
upon further study.. it is also giving an undefined offset warning, thus it should be:
        $field['id'], '', '*', TRUE

...
Steve H, currently on: (version 5.2.23)
contributions:
Birthdays mod, Top Users mod, Icon legend.tpl, (plus a handful of bugfixes and old 5.0 creations)




Edited 2 time(s). Last edit at 02/11/2008 04:12PM by stevehealy.
Re: Module: Birthdays
February 11, 2008 05:17PM
Likek thomas pointed out, it is possible to do your own rewriting on the strings. Till now, the main language file and some modules use %variable% as the variable name. So if you want to use this type of rewriting, then use %days% to be compliant with the other code.

For plural words it is fun how some languages might even have different wordings for one, two or more than two. So in my latest module code, I try to leave using different strings open for the language file writer. Here's a slightly generalized excerpt from the onlineusers module file that implements this:
            $lang = $PHORUM['DATA']['LANG']['MOD_.....'];
            $count = ...some code to get a count ...;
            $str = isset($lang["SomeLanguageKey$count"])
                 ? $lang["SomeLanguageKey$count"]
                 : $lang['SomeLanguageKey'];
            $str = str_replace('%count%', $count, $str);

Using this, the language file could define the strings:
$PHORUM['DATA']['LANG']['MOD_.....'] = array(
    "SomeLanguageKey0" => "None at all!",
    "SomeLanguageKey1" => "One single lonely.",
    "SomeLanguageKey2" => "A duo!",
    "SomeLanguagekey"  => "There are %count% of them."
);


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Birthdays
February 11, 2008 06:52PM
New version uploaded, with some new language strings.

Also the user search now only loads those users with birthdays defined. This should improve performance, at least until all your users add their birthdays. ;) I think it still needs some work, but it may require another overhaul of the code.

...
Steve H, currently on: (version 5.2.23)
contributions:
Birthdays mod, Top Users mod, Icon legend.tpl, (plus a handful of bugfixes and old 5.0 creations)
Re: Module: Birthdays
February 12, 2008 04:45AM
Thanks for your hard work on this Steve, this is working for me now! Yay!
Re: Module: Birthdays
February 12, 2008 05:01AM
Quote
stevehealy
Also the user search now only loads those users with birthdays defined. This should improve performance, at least until all your users add their birthdays. ;)

If you store the birthday as "YYYYMMDD" in the field, then you could use "<" and ">" operators to select only a range from the birthdays. There is no need to pull in all configured birthdays. That should make the script scale just fine, unless you get thousands of user birthdays on a single day ;)


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Birthdays
February 12, 2008 12:00PM
Quote
mmakaay
Quote
stevehealy
Also the user search now only loads those users with birthdays defined. This should improve performance, at least until all your users add their birthdays. ;)

If you store the birthday as "YYYYMMDD" in the field, then you could use "<" and ">" operators to select only a range from the birthdays. There is no need to pull in all configured birthdays. That should make the script scale just fine, unless you get thousands of user birthdays on a single day ;)

Actually, that won't work because the YYYY will be all over the place. (depending on the age of users) That's why I said earlier that I need to ignore the year when searching.

On top of that, the birthday is stored in an array which doesn't seem to be accessible from the phorum_api_user_search_custom_profile_field. If it is, I need help with the syntax.

My custom profile is "mod_birthdays", which is an array containing "birthday" and "age".

...
Steve H, currently on: (version 5.2.23)
contributions:
Birthdays mod, Top Users mod, Icon legend.tpl, (plus a handful of bugfixes and old 5.0 creations)
Sorry, only registered users may post in this forum.

Click here to login