Dynamically changing $_user quota settings
Jamroom Developers
Michael
Tweaking using db_get_item appears to cover the bases. Not sure why (difficult to actually trace this to know precisely why this works) but if it works it works, right?
For completeness, here are some details per your last note:
Quote: jrProfile_get_quota() doesnt look like it touches $_user.
jrProfile_get_quota() does indeed not touch $_user but it is called by functions which assign its return array to $_user. So basically one could effect the desired change within jrProfile_get_quota. The following code does indeed accomplish the effect (see @@@):
$tb1 = jrCore_db_table_name('jrProfile', 'quota_setting');
$tb2 = jrCore_db_table_name('jrProfile', 'quota_value');
$req = "SELECT s.`module` AS m, s.`name` AS k, s.`default` AS d, v.`value` AS v FROM {$tb1} s LEFT JOIN {$tb2} v ON (v.`quota_id` = '{$quota_id}' AND v.`module` = s.`module` AND v.`name` = s.`name`)";
$_rt = jrCore_db_query($req, 'NUMERIC');
if (!isset($_rt) || !is_array($_rt)) {
return false;
}
$_qt = array();
foreach ($_rt as $_v) {
$_qt["quota_{$_v['m']}_{$_v['k']}"] = (isset($_v['v']) && strlen($_v['v']) > 0) ? $_v['v'] : $_v['d'];
}
// @@@
$_qt['quota_jrSmiley_allowed'] = 'off';
// @@@
My challenge has been to find a way to effect this change with customer appropriate code.
Quote: ... so you'd be tweaking before it arrived at the session start.
The session_started listener did work great -changes applied and accepted into $_user- but was too early in the process. Myriad functions call jrProfile_get_quota() and overwrite the $_user quota fields. So tweaking things before the session start will not work.
But it appears I have a solution now so these other attempts are just history.
As always, I appreciate your insight and support. Thanks,