Forum Activity for @tig

TiG
@tig
12/01/18 09:36:25AM
184 posts

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,
TiG
@tig
11/30/18 08:02:44PM
184 posts

Dynamically changing $_user quota settings


Jamroom Developers

Michael

The session_started listener is an elegant method for accomplishing my intent. The change works fine but only for a short time. Trouble is, any change to $_user quota_ fields is overwritten later on by calls to jrProfile_get_quota() whose results are re-assigned to $_user.

Best I can tell the only way to dynamically override a quota field in $_user and make it stick is to do so within this function. I see no customer appropriate means to override a quota_ field in $_user that will survive long enough to have an effect.

Largely this is an FYI, but if anything else comes to mind please let me know.

Thanks,
TiG
@tig
11/29/18 11:13:35PM
184 posts

Dynamically changing $_user quota settings


Jamroom Developers

Michael

Perfect! Thanks much for the help.
TiG
@tig
11/29/18 11:01:25PM
184 posts

Dynamically changing $_user quota settings


Jamroom Developers

Hi Michael

What I am looking for is an event right after $_user is created (or updated) that would allow me to override fields such as $_user['quota_jrSmiley_active'] for a tiny minority of users.

Thanks
TiG
@tig
11/29/18 02:00:15PM
184 posts

Dynamically changing $_user quota settings


Jamroom Developers

Hi Paul

This would never change the stored quota itself (because that quota applies to many users - not just the users of interest). I only want to change that which has been processed as part of the $_user array and only for select users. ( The quota might apply to 100 users but this change might affect only 2 of them. )

Here is what we are trying to accomplish - using smileys as the example:

Some users will lose smiley privileges (due to abuse). We want a moderator to be able to simply note this in the moderator console (an extant custom module of NT) and then have it go into effect. The moderator has no idea of the underlying quota mechanics - just wants to disable the privilege for a period of time (the moderator console has expiration builtin).

Since tinymce (in this example) renders the smiley button if it finds
$_user['quota_jrSmiley_active']=='on'
if we could simply set this to 'off' the desired effect will be cleanly implemented for that user.

Given there is no intent to change the stored quota itself - just adjust the in-memory quota as represented in $_user for select users - I need an appropriate listener with which to turn the $_user quota item to 'off' for a given user at the proper time.

Thanks
updated by @tig: 11/29/18 02:02:12PM
TiG
@tig
11/29/18 09:25:00AM
184 posts

Dynamically changing $_user quota settings


Jamroom Developers

What is the recommended method for dynamically changing a
$_user
quota setting such as
$_user['quota_jrSmiley_allowed']
?

We have a need to adjust select quota '_allowed' settings on a per user basis in real time. For example, some users will (conditionally) not have access to smileys. This is not something that can be handled by manually reassigning their quotas; we need to have a programmatic way to make these changes. Basically to conditionally override select fields in their quota on a per user basis.

Is this possible? If so, which listener should I use?

Thanks
updated by @tig: 03/01/19 09:46:43PM
TiG
@tig
07/27/18 11:42:15AM
184 posts

Upgrading to latest Share This module 2.0.0


Announcements

Brian

Perfection. Thanks!
TiG
@tig
07/26/18 10:23:35PM
184 posts

Upgrading to latest Share This module 2.0.0


Announcements

Michael

Thanks for the clean method. Will check this out tomorrow (very late here).

Thanks,
TiG
TiG
@tig
07/26/18 08:49:15PM
184 posts

Upgrading to latest Share This module 2.0.0


Announcements

One thing that we can control in jamroom is the positioning of the buttons. The new jrShareThis module seems to implement the buttons as a detail feature and thus they show up at the bottom of the content.

Is there a reasonably sound way to position the buttons elsewhere (in our case we would position them below the article and above the comments)? It looks like we would have to somehow stop the feature mechanism for jrShareThis and then manually insert the ShareThis interface code in our templates. (We do not want to change the position of the other detail features.)

As usual, I am looking for advice on how to best accomplish this considering JR design intent.
TiG
@tig
07/20/18 08:31:54AM
184 posts

Newlines in database converted to HTML break for presentation


Jamroom Developers

Thanks. I had looked for this function before and could not find any meaningful reference to
<br>
in the code. No wonder I did not discover the culprit. :)
updated by @tig: 07/20/18 08:32:42AM
  6