HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 7.3.33
Disabled: NONE
Upload Files
File: /home/temp/yarusvl.ru/adminx/core/UserGroupAdmin.php
<?php

require_once('api/Mgc.php');

class UserGroupAdmin extends Mgc {
    
    public function fetch() {
        $group = new stdClass;
        /*Прием данных о группе пользователей*/
        if($this->request->method('post')) {
            $group->id = $this->request->post('id', 'integer');
            $group->name = $this->request->post('name');
            $group->discount = $this->request->post('discount');
            
            if (empty($group->name)) {
                $this->design->assign('message_error', 'empty_name');
            } else {
                /*Добавление/Обновление групы пользователей*/
                if(empty($group->id)) {
                    $group->id = $this->users->add_group($group);
                    $this->design->assign('message_success', 'added');
                } else {
                    $group->id = $this->users->update_group($group->id, $group);
                    $this->design->assign('message_success', 'updated');
                }
                $group = $this->users->get_group(intval($group->id));
            }
        } else {
            $id = $this->request->get('id', 'integer');
            if(!empty($id)) {
                $group = $this->users->get_group(intval($id));
            }
        }
        
        if(!empty($group)) {
            $this->design->assign('group', $group);
        }
        
        return $this->design->fetch('user_group.tpl');
    }
    
}