Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64
User : palandch ( 1163)
PHP Version : 7.1.33
Disable Function : NONE
Directory :  /home/palandch/www/core/model/modx/processors/security/forms/profile/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/palandch/www/core/model/modx/processors/security/forms/profile/update.class.php
<?php
/**
 * Update a FC Profile
 *
 * @package modx
 * @subpackage processors.security.forms.profile
 */
class modFormCustomizationProfileUpdateProcessor extends modObjectUpdateProcessor {
    public $classKey = 'modFormCustomizationProfile';
    public $languageTopics = array('formcustomization');
    public $permission = 'customize_forms';
    public $objectType = 'profile';

    public function beforeSave() {
        $active = $this->getProperty('active',null);
        if ($active !== null) {
            $this->object->set('active',(boolean)$active);
        }
        return parent::beforeSave();
    }

    public function afterSave() {
        $this->setUserGroups();
        return parent::afterSave();
    }

    public function setUserGroups() {
        /* get usergroups */
        $userGroups = $this->getProperty('usergroups',null);
        if ($userGroups != null) {
            /* erase old ProfileUserGroup records */
            $profileUserGroups = $this->modx->getCollection('modFormCustomizationProfileUserGroup',array(
                'profile' => $this->object->get('id'),
            ));
            /** @var modFormCustomizationProfileUserGroup $profileUserGroup */
            foreach ($profileUserGroups as $profileUserGroup) { $profileUserGroup->remove(); }

            /* reassign */
            $userGroups = is_array($userGroups) ? $userGroups : $this->modx->fromJSON($userGroups);
            foreach ($userGroups as $userGroupArray) {
                if (empty($userGroupArray)) continue;
                /** @var modUserGroup $userGroup */
                $userGroup = $this->modx->getObject('modUserGroup',$userGroupArray['id']);
                if (!empty($userGroup)) {
                    $profileUserGroup = $this->modx->newObject('modFormCustomizationProfileUserGroup');
                    $profileUserGroup->set('usergroup',$userGroup->get('id'));
                    $profileUserGroup->set('profile',$this->object->get('id'));
                    $profileUserGroup->save();
                }
            }
        }
    }
}
return 'modFormCustomizationProfileUpdateProcessor';

Spamworldpro Mini