PERMISSIONS TABLE
482803
private function createPermissionsTbl()
    {
        Schema::create('tbl_permissions', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->integer('brand_id')->unsigned();
            $table->integer('component_id')->unsigned();
            $table->integer('role_id')->unsigned();
            $table->integer('action_id')->unsigned();
            $table->tinyInteger('allowed')->default(1);
        });
        Schema::table('tbl_permissions', function(Blueprint $table) {
            $table->foreign('brand_id')
                    ->references('id')
                    ->on('tbl_brands')
                    ->onDelete('cascade');

            $table->foreign('component_id')
                    ->references('id')
                    ->on('tbl_components')
                    ->onDelete('cascade');

            $table->foreign('role_id')
                    ->references('id')
                    ->on('tbl_roles')
                    ->onDelete('cascade');

            $table->foreign('action_id')
                    ->references('id')
                    ->on('tbl_actions')
                    ->onDelete('cascade');
        });
    }
91815
protected void setPermissionStatus(PermissionStatus ps) {
    setUser(ps.getUserName());
    setGroup(ps.getGroupName());
    setPermission(ps.getPermission());
  }
134489
void setPermissions() {

        IndexedContainer container = (IndexedContainer)m_permissions.getContainerDataSource();
        int allowed = 0;
        int denied = 0;
        for (Object itemId : container.getItemIds()) {
            Item item = container.getItem(itemId);
            Integer value = (Integer)item.getItemProperty(PROPERTY_VALUE).getValue();
            if (((Boolean)item.getItemProperty(PROPERTY_ALLOWED).getValue()).booleanValue()) {
                allowed |= value.intValue();
            }
            if (((Boolean)item.getItemProperty(PROPERTY_DENIED).getValue()).booleanValue()) {
                denied |= value.intValue();
            }
        }
        int flags = m_entry.getFlags();

        // modify the ace flags to determine inheritance of the current ace
        if (m_inheritCheckbox.getValue().booleanValue()) {
            flags |= CmsAccessControlEntry.ACCESS_FLAGS_INHERIT;
        } else {
            flags &= ~CmsAccessControlEntry.ACCESS_FLAGS_INHERIT;
        }

        // modify the ace flags to determine overwriting of inherited ace
        if (m_overwriteCheckbox.getValue().booleanValue()) {
            flags |= CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE;
        } else {
            flags &= ~CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE;
        }

        if (m_responsibleCheckbox.getValue().booleanValue()) {
            flags |= CmsAccessControlEntry.ACCESS_FLAGS_RESPONSIBLE;
        } else {
            flags &= ~CmsAccessControlEntry.ACCESS_FLAGS_RESPONSIBLE;
        }

        m_changeHandler.setPermissions(new CmsPermissionBean(m_principalType, m_principalName, allowed, denied, flags));
    }
1281114
function permissions($Role, $OnlyIDs = true)
	{
	    if (! is_numeric ($Role))
	        $Role = $this->returnId($Role);

		if ($OnlyIDs)
		{
			$Res = Jf::sql ( "SELECT PermissionID AS `ID` FROM {$this->tablePrefix()}rolepermissions WHERE RoleID=? ORDER BY PermissionID", $Role );
			if (is_array ( $Res ))
			{
				$out = array ();
				foreach ( $Res as $R )
					$out [] = $R ['ID'];
				return $out;
			}
			else
				return null;
		} else {
	        return Jf::sql ( "SELECT `TP`.ID, `TP`.Title, `TP`.Description FROM {$this->tablePrefix()}permissions AS `TP`
		        LEFT JOIN {$this->tablePrefix()}rolepermissions AS `TR` ON (`TR`.PermissionID=`TP`.ID)
		        WHERE RoleID=? ORDER BY TP.ID", $Role );
		}
	}
1231585
def create_permissions():
    
    current_app.appbuilder.add_permissions(update_perms=True)
    click.echo(click.style("Created all permissions", fg="green"))
145412
def permissions(cls, instance, db_session=None):
        
        db_session = get_db_session(db_session, instance)
        query = db_session.query(
            cls.models_proxy.GroupPermission.group_id.label("owner_id"),
            cls.models_proxy.GroupPermission.perm_name.label("perm_name"),
            sa.literal("group").label("type"),
        )
        query = query.filter(
            cls.models_proxy.GroupPermission.group_id
            == cls.models_proxy.UserGroup.group_id
        )
        query = query.filter(
            cls.models_proxy.User.id == cls.models_proxy.UserGroup.user_id
        )
        query = query.filter(cls.models_proxy.User.id == instance.id)

        query2 = db_session.query(
            cls.models_proxy.UserPermission.user_id.label("owner_id"),
            cls.models_proxy.UserPermission.perm_name.label("perm_name"),
            sa.literal("user").label("type"),
        )
        query2 = query2.filter(cls.models_proxy.UserPermission.user_id == instance.id)
        query = query.union(query2)
        groups_dict = dict([(g.id, g) for g in instance.groups])
        return [
            PermissionTuple(
                instance,
                row.perm_name,
                row.type,
                groups_dict.get(row.owner_id) if row.type == "group" else None,
                None,
                False,
                True,
            )
            for row in query
        ]
360489
def permission_attributes=(permissions)
      self.permissions = [] # Reset permissions in anticipation for re-population
    
      permissions.each do |key, value|
        key, value = key.dup, value.dup
      
        # Component Permissions
        if key.ends_with? "_permissions"
          grant_permissions(value)
        # Singular Permission
        elsif key.chomp! "_permission"
          grant_permissions(key) if value.to_i != 0
        end
      end
    end
424554
def has_permissions(self, object, group, operations):
        ''''''
        if self.is_superuser:
            return 1
        else:
            models = self.session.router
            # valid permissions
            query = models.permission.for_object(object, operation=operations)
            objects = models[models.role.permissions.model]
            return objects.filter(role=self.role.query(),
                                  permission=query).count()
1272810
def fix_permissions (self):
        """"""
        if os.name == 'posix' and not self.dry_run:
            # Make the data files we just installed world-readable,
            # and the directories world-executable as well.
            for path in self.get_outputs():
                mode = os.stat(path)[stat.ST_MODE]
                if stat.S_ISDIR(mode):
                    mode |= 0o11
                mode |= 0o44
                os.chmod(path, mode)
97205
function assignPermissions (done) {
  async.map(defaults.permissions, function (pair, callback) {
    Role.addScopes(pair[0], pair[1], function (err, result) {
      callback(err, result)
    })
  }, function (err, results) {
    done(err, results)
  })
}
516657
def _get_all_permissions(opts):
    ""
    perms = []
    for action in settings.DEFAULT_PERMISSIONS:
        perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name_raw)))
    return perms + list(opts.permissions)
145524
public function permissions($table) {
		$table = config('center.tables.' . $table);
		$permissions = DB::table(config('center.db.permissions'))->where('table', $table->name)->lists('level', 'user_id');
		$users = DB::table(config('center.db.users'))->get();
		foreach ($users as &$user) {
			$user->level = (isset($permissions[$user->id])) ? $permissions[$user->id] : null;
		}
		$permission_levels = LoginController::getPermissionLevels();
		return view('center::tables.permissions', compact('users', 'table', 'permission_levels'));
	}
287092
def permitted?(requested_flags = 0)
      current_user_roles.any?{|ug| ug.admin?} ||
      current_model_permissions.any?{|cp| cp.permitted?(requested_flags)}
    end
871762
def assign_contributor_permissions(obj, contributor=None):
    """"""
    for permission in get_all_perms(obj):
        assign_perm(permission, contributor if contributor else obj.contributor, obj)
1036774
private function scanRolesAndPermissions()
    {
        $files = $this->getConfigFiles();

        if( ! empty($files) )
            foreach ( $files as $filePath ) {
                $config = json_decode(file_get_contents($filePath), true);

                if( is_null($config) )
                    $this->info('Invalid json file: ' . $filePath);
                else {
                    $packageName = array_get($config, 'general.serviceProviderNameSpace');

                    if( is_null($packageName) || $packageName == '' ) {
                        $this->error('SKIPPING! Package must have a name! file: ' . $filePath);
                        continue;
                    }

                    if( array_key_exists('acl', $config) ) {
                        $this->aclData[] = [
                            'packageName' => $packageName,
                            'acl'         => array_get($config, 'acl'),
                        ];
                    }
                }
            }
    }
58588
def get_permissions(self):
        
        return [p.permission.code for p in self.Permissions if p.permission.code]
1369204
private Permission createReadPermission(String table) {
        return _permissionResolver.resolvePermission(Permissions.readSorTable(new NamedResource(table)));
    }