Exemplo n.º 1
0
        #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    default:
        return ERROR | @Trigger_Error(101);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Types = $Notifies['Types'];
$Code = 'Default';
#-------------------------------------------------------------------------------
foreach (Array_Keys($Types) as $TypeID) {
    #-------------------------------------------------------------------------------
    #Debug(SPrintF('[comp/www/UserNotifiesSet]: TypeID = %s',$TypeID));
    $Type = $Types[$TypeID];
    #-------------------------------------------------------------------------------
    $Entrance = Tree_Entrance('Groups', (int) $Type['GroupID']);
    #-------------------------------------------------------------------------------
    switch (ValueOf($Entrance)) {
        case 'error':
            return ERROR | @Trigger_Error(500);
        case 'exception':
            return ERROR | @Trigger_Error(400);
        case 'array':
            #-------------------------------------------------------------------------------
            if (!In_Array($GLOBALS['__USER']['GroupID'], $Entrance)) {
                continue 2;
            }
            #-------------------------------------------------------------------------------
            break;
            #-------------------------------------------------------------------------------
        #-------------------------------------------------------------------------------
Exemplo n.º 2
0
        return ERROR | @Trigger_Error(500);
    }
    #-------------------------------------------------------------------------------
    $Form->AddChild($Comp);
    #-------------------------------------------------------------------------------
    $DOM->AddChild('Into', $Form);
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $Out = $DOM->Build();
    #-------------------------------------------------------------------------------
    return $Out;
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# получаем список всех сотрудников
$Entrance = Tree_Entrance('Groups', 3000000);
#-------------------------------------------------------------------
switch (ValueOf($Entrance)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return ERROR | @Trigger_Error(400);
    case 'array':
        #---------------------------------------------------------------
        $String = Implode(',', $Entrance);
        #---------------------------------------------------------------
        $Employers = DB_Select('Users', 'ID', array('Where' => SPrintF('`GroupID` IN (%s)', $String)));
        #---------------------------------------------------------------
        switch (ValueOf($Employers)) {
            case 'error':
                return ERROR | @Trigger_Error(500);
Exemplo n.º 3
0
function Tree_Entrance($TableID, $RowID)
{
    /****************************************************************************/
    $__args_types = array('string', 'integer');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $Regulars = Regulars();
    #-----------------------------------------------------------------------------
    if (!Preg_Match($Regulars['ID'], $TableID)) {
        return new gException('WRONG_TABLE_ID', 'Неверный идентификатор таблицы');
    }
    #-----------------------------------------------------------------------------
    $CacheID = SPrintF('Tree_Entrance[%s]', Md5(SPrintF('%s:%u', $TableID, $RowID)));
    #-----------------------------------------------------------------------------
    $Result = CacheManager::get($CacheID);
    if (!$Result) {
        #---------------------------------------------------------------------------
        $Row = DB_Select($TableID, '*', array('UNIQ', 'ID' => $RowID));
        #---------------------------------------------------------------------------
        switch (ValueOf($Row)) {
            case 'error':
                return ERROR | @Trigger_Error('[Tree_Entrance]: не возможно найти запись');
            case 'exception':
                return new gException('ROW_NOT_FOUND', 'Запись не найдена');
            case 'array':
                #-----------------------------------------------------------------------
                $Result = array($Row['ID']);
                #-----------------------------------------------------------------------
                $Where = SPrintF('`ParentID` = %u AND `ID` != `ParentID`', $Row['ID']);
                #-----------------------------------------------------------------------
                $Childs = DB_Select($TableID, '*', array('Where' => $Where));
                #-----------------------------------------------------------------------
                switch (ValueOf($Childs)) {
                    case 'error':
                        return ERROR | @Trigger_Error('[Tree_Entrance]: не возможно найти дочерние записи');
                    case 'exception':
                        #----->
                        break;
                    case 'array':
                        #-------------------------------------------------------------------
                        foreach ($Childs as $Child) {
                            #-----------------------------------------------------------------
                            $Entrance = Tree_Entrance($TableID, (int) $Child['ID']);
                            #-----------------------------------------------------------------
                            switch (ValueOf($Entrance)) {
                                case 'error':
                                    return ERROR | @Trigger_Error('[Tree_Entrance]: не возможно определить дочерние вхождения записей');
                                case 'exception':
                                    return ERROR | @Trigger_Error('[Tree_Entrance]: запись оказавшаяся дочерней не найдена');
                                case 'array':
                                    $Result = Array_Merge($Result, $Entrance);
                                    break;
                                default:
                                    return ERROR | @Trigger_Error(101);
                            }
                        }
                        break;
                    default:
                        return ERROR | @Trigger_Error(101);
                }
                #-----------------------------------------------------------------------
                CacheManager::add($CacheID, $Result);
                break;
            default:
                return ERROR | @Trigger_Error(101);
        }
    }
    #-----------------------------------------------------------------------------
    return $Result;
}
Exemplo n.º 4
0
    }
    #-------------------------------------------------------------------------------
    return array('Status' => 'Ok');
    #-------------------------------------------------------------------------------
} else {
    #-------------------------------------------------------------------------------
    $Edesk = DB_Select('Edesks', array('ID', 'TargetGroupID', 'Theme'), array('UNIQ', 'ID' => $EdeskID));
    #-------------------------------------------------------------------------------
    switch (ValueOf($Edesk)) {
        case 'error':
            return ERROR | @Trigger_Error(500);
        case 'exception':
            return ERROR | @Trigger_Error(400);
        case 'array':
            #-------------------------------------------------------------------------------
            $Entrance = Tree_Entrance('Groups', (int) $Edesk['TargetGroupID']);
            #-------------------------------------------------------------------------------
            switch (ValueOf($Entrance)) {
                case 'error':
                    return ERROR | @Trigger_Error(500);
                case 'exception':
                    return ERROR | @Trigger_Error(400);
                case 'array':
                    # No more...
                    break;
                default:
                    return ERROR | @Trigger_Error(101);
            }
            #-------------------------------------------------------------------------------
            if (!In_Array($__USER['GroupID'], $Entrance)) {
                return ERROR | @Trigger_Error(700);
Exemplo n.º 5
0
    #-------------------------------------------------------------------------------
    CacheManager::add($CacheID, $InterfaceID);
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$User['InterfaceID'] = $InterfaceID;
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$IsQuery = DB_Query(SPrintF("SET @local.__USER_GROUPS_PATH = '%s'", Implode(',', Array_Reverse($Path))));
if (Is_Error($IsQuery)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Entrance = Tree_Entrance('Groups', (int) $User['GroupID']);
#-------------------------------------------------------------------------------
switch (ValueOf($Entrance)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return ERROR | @Trigger_Error(400);
    case 'array':
        break;
    default:
        return ERROR | @Trigger_Error(101);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$IsQuery = DB_Query(SPrintF("SET @local.__USER_GROUPS_ENTRANCE = '%s'", Implode(',', $Entrance)));
if (Is_Error($IsQuery)) {
Exemplo n.º 6
0
             # Update -> `IsNotify`='yes'
             $IsUpdate = DB_Update('EdesksMessages', array('IsNotify' => 'yes'), array('ID' => $Message['ID']));
             if (Is_Error($IsUpdate)) {
                 return ERROR | @Trigger_Error(500);
             }
             #-------------------------------------------------------------------------------
             break;
             #-------------------------------------------------------------------------------
         #-------------------------------------------------------------------------------
         default:
             return ERROR | @Trigger_Error(101);
     }
     #-------------------------------------------------------------------------------
 } else {
     #-------------------------------------------------------------------------------
     $Entrance = Tree_Entrance('Groups', $TargetGroupID);
     #-------------------------------------------------------------------------------
     switch (ValueOf($Entrance)) {
         case 'error':
             return ERROR | @Trigger_Error(500);
         case 'exception':
             return ERROR | @Trigger_Error(400);
         case 'array':
             break;
         default:
             return ERROR | @Trigger_Error(101);
     }
     #-------------------------------------------------------------------------------
     $String = Implode(',', $Entrance);
     #-------------------------------------------------------------------------------
     $Employers = DB_Select('Users', 'ID', array('Where' => SPrintF('`GroupID` IN (%s)', $String)));
Exemplo n.º 7
0
function Permission_Check($Name, $UserID, $OwnerID = 1)
{
    /****************************************************************************/
    $__args_types = array('string', 'integer', 'integer');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    if (Is_Error(System_Load('libs/Tree.php'))) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    if (!$Name) {
        return new gException('RULE_NAME_IS_EMPTY', 'Введите имя правила доступа');
    }
    #-----------------------------------------------------------------------------
    $Rules = DB_Select('Permissions', '*', array('Where' => SPrintF("'%s' LIKE `Name`", DB_Escape($Name)), 'SortOn' => 'Metric'));
    #-----------------------------------------------------------------------------
    switch (ValueOf($Rules)) {
        case 'error':
            return ERROR | @Trigger_Error('[Permission_Check]: не удалось получить права доступа');
        case 'exception':
            return FALSE;
        case 'array':
            #-------------------------------------------------------------------------
            $User = DB_Select('Users', array('ID', 'GroupID'), array('UNIQ', 'ID' => $UserID));
            #-------------------------------------------------------------------------
            switch (ValueOf($User)) {
                case 'error':
                    return ERROR | @Trigger_Error('[Permission_Check]: не удалось выбрать пользователя осуществляющего запрос');
                case 'exception':
                    return new gException('USER_NOT_FOUND', 'Пользователь осуществляющий запрос доступа не найден');
                case 'array':
                    #---------------------------------------------------------------------
                    $Owner = DB_Select('Users', array('ID', 'GroupID', 'OwnerID', 'IsManaged'), array('UNIQ', 'ID' => $OwnerID));
                    #---------------------------------------------------------------------
                    switch (ValueOf($Owner)) {
                        case 'error':
                            return ERROR | @Trigger_Error('[Permission_Check]: не удалось выбрать владельца');
                        case 'exception':
                            return new gException('OWNER_NOT_FOUND', 'Владелец объекта не найден');
                        case 'array':
                            #-----------------------------------------------------------------
                            $IsPermission = FALSE;
                            #-----------------------------------------------------------------
                            foreach ($Rules as $Rule) {
                                #---------------------------------------------------------------
                                $Entrance = Tree_Entrance('Groups', (int) $Rule['UserGroupID']);
                                #---------------------------------------------------------------
                                switch (ValueOf($Entrance)) {
                                    case 'error':
                                        return ERROR | @Trigger_Error('[Permission_Check]: не удалось определить дочерние группы правила доступа');
                                    case 'exception':
                                        return new gException('CHILD_GROUPS_PERMISSION_RULE_NOT_FOUND', 'Дочерние группы правила доступа не определены');
                                    case 'array':
                                        # No more...
                                        break;
                                    default:
                                        return ERROR | @Trigger_Error(101);
                                }
                                #---------------------------------------------------------------
                                if (In_Array($User['GroupID'], $Entrance) || $UserID == $Rule['UserID']) {
                                    #-------------------------------------------------------------
                                    if ($User['ID'] != $Owner['ID'] && ($User['ID'] != $Owner['OwnerID'] || !$Owner['IsManaged'])) {
                                        #-----------------------------------------------------------
                                        $Entrance = Tree_Entrance('Groups', (int) $Rule['OwnerGroupID']);
                                        #-----------------------------------------------------------
                                        switch (ValueOf($Entrance)) {
                                            case 'error':
                                                return ERROR | @Trigger_Error('[Permission_Check]: не удалось определить дочерние группы правила делегирования');
                                            case 'exception':
                                                return new gException('CHILD_GROUPS_DELIGATE_RULE_NOT_FOUND', 'Дочерние группы правила делегирования не определены');
                                            case 'array':
                                                # No more...
                                                break;
                                            default:
                                                return ERROR | @Trigger_Error(101);
                                        }
                                        #-----------------------------------------------------------
                                        if (In_Array($Owner['GroupID'], $Entrance) || $OwnerID == $Rule['OwnerID']) {
                                            #---------------------------------------------------------
                                            $IsPermission = $Rule['IsAccess'];
                                        }
                                    } else {
                                        $IsPermission = $Rule['IsAccess'];
                                    }
                                }
                            }
                            #-----------------------------------------------------------------
                            return $IsPermission;
                        default:
                            return ERROR | @Trigger_Error(101);
                    }
                default:
                    return ERROR | @Trigger_Error(101);
            }
        default:
            return ERROR | @Trigger_Error(101);
    }
}