Ejemplo n.º 1
0
         *
         * @param IAclObject $object The object
         * @param string $role One or more object IDs as string or array.
         * @param IAclSubject $subject One or more user or group IDs as string or array.
         * @param boolean $access One of the acl::ACL_* flags.
         */
        static function setAccess(IAclObject $object, $role, IAclSubject $subject, $access)
        {
            // If the subject is not specified, set it to the current user.
            if (!$subject) {
                $subject = user::getActiveUser();
            }
            // Retrieve the uuid of the subject and the object
            $suuid = $subject->getSubjectUuid();
            $ouuid = $object->getObjectUuid();
            // Convert the access into a string
            if ($access === self::ACL_NULL) {
                $accesstr = '-';
            } elseif ($access === self::ACL_ALLOW) {
                $accesstr = 'Y';
            } else {
                $accesstr = 'N';
            }
            // Update the record
            $db = new DatabaseConnection();
            $db->updateRow("REPLACE INTO aclconf (object,role,subject,access) VALUES (%s,%s,%s,%s)", $ouuid, $role, $suuid, $accesstr);
        }
    }
    // Initialize the ACL subsystem
    acl::initialize();
}