Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

New Delegation in UserManager, SaveIdentity

Hello Mark,
I would like to have a new delegation in the UserManager class.
In function SaveIdentity($User) { before executing the UPDATE in Line 765:
$this->DelegateParameters['User'] = &$User; $this->DelegateParameters['SqlBuilder'] = &$s; $this->CallDelegate('PreDataUpdate');
Similary to the delegation in the SaveIdentity function in this class.
I need this for the Predefined Attributes Extension. Possible?

Comments

  • Upps I just noticed that the code above will not work.
    The UserManager is initiated before extensions are included on the account.php having the PostBackAction "ProcessIdentity". So GetDelegatesFromContext will get nothing.

    Do I have to call AddToDelegate driectly on the UserManger Object? Then I have to make sure that the object exists and only fire AddToDelegate on this specific PostBackAction. That makes things complicated (in mind, not in code).

    Or are you going to add $this->GetDelegatesFromContext(); in the first line of the SaveIdentity function?
    Or is there a third way i didn't get yet?
  • MarkMark Vanilla Staff
    Hmmm. Are you sure that it uses a UserManager object that is loaded before the extensions? I don't think that is the case at all:

    * The extensions are loaded in the appg/init_vanilla.php file, which is included on line 15 of account.php.
    * The UserManager object is created on line 22 of account.php.

    I've added the lines to the UserManager class, but instead of "PreDataUpdate", I called the delegate "PreIdentityUpdate".
  • Thanks for adding the delegation.

    I'll check it again, why it does not work.
  • I checked it:

    init_vanilla.php calls $Context->StartSession(); (Line 47, before including the extensions in Line 113)

    In Session class Line 64 the UserManger is initialized:
    $UserManager = $Context->ObjectFactory->NewContextObject($Context, 'UserManager');

    Therefore line 24 in account.php
    if (!@$UserManager) $UserManager = $Context->ObjectFactory->NewContextObject($Context, "UserManager");
    does no re-initialisation, cause $UserManger allready exists.

    What do I have to do?
  • MarkMark Vanilla Staff
    Hmmmm. That's a good catch, michael. I'm thinking that maybe I'll just remove the if (!@$UserManager) part and explicitly re-create the usermanager. It's a tiny bit of extra overhead, but the account page isn't really a majorly active part of the application anyway - and it will solve your problem. Gimme 5 and it will be done.
  • 1 2 3 4 5.
    Thanks.
  • MarkMark Vanilla Staff
    Okay, it's done...
This discussion has been closed.