Jump to content

improve unsearchableNodeIds node permission


BomAle

Recommended Posts

	/**
	 * Return either NULL for no restrictions, or a list of container IDs we cannot search in because of app specific permissions and configuration
	 * You do not need to check for 'view' permissions against the logged in member here. The Query search class does this for you.
	 * This method is intended for more complex set up items, like needing to have X posts to see a forum, etc.
	 * This is used for search and the activity stream.
	 * We return a list of IDs and not node objects for memory efficiency.
	 *
	 * return 	null|array
	 */
	public static function unsearchableNodeIds()

This function is useful but it don't cover parents permissions at this time.

I am here to suggest to integrate some other checks (into forum there is a check for min_posts_view) by default

massUpdate is a slow action, editing all index item, it cover all parents permissions... I suggest to define a immediate check:

- avoiding task routine

- improve user expirience on permissions

- third parts satisfaction when use inbuilt search class

$unsearchableIds = array();
if ( $this instanceof \IPS\Node\Permissions )
{
	$list = iterator_to_array(
		\IPS\Db::i()
		       ->select( static::$databasePrefix . static::$databaseColumnId, static::$databaseTable )
		       ->setKeyField( static::$databasePrefix . static::$databaseColumnId )
	);

	/* If we're trying to *read* a content item (or in fact anything, but we only check read since if we managed to access it we don't need to check this again for other permissions),
	check if we can *view* (i.e. access) all of the parents. This is so if an admin, for example, removes a group's permission to view (i.e. access) a node, they will not be able
	to access content within it. Though this is not in line with conventional ACL practices, it is how the suite has always worked and we don't want to mess up permissions for upgrades  */
	foreach ( $list as $id )
	{
		if ( !static::load($id)->can( 'view' ) ) //or read?
		{
			$unsearchableIds[] = $id;
		}
	}
	static::$unsearchableNodeIds = count( $unsearchableIds ) ? $unsearchableIds : NULL;
}

return static::$unsearchableNodeIds;

OR more easy:

disable/remove/save corresponding permissions on child nodes into form/module admincp when into a parent node is changed the permissions (massChange could help here)

example:

if i don't have permission on parent node because on permission sets of the child node i do? :rofl:

@Matt @bfarber

Link to comment
Share on other sites

i have written a app to fetch polls along suite including into pages app. For easy manage I don't use internal item search index because the function (on first post) don't cover parent permissions directly.

The counting of results could not be aligned with permissions.

Link to comment
Share on other sites

Ok so breaking it down, you're trying to find topics that contain polls that the user can see, is that right? And the problem you're running in to is that you're having topics returned that are stored in forums the user could 'see' but actually can't because the parent permissions block access?

Link to comment
Share on other sites

When we store a content item in the search index, we call to searchIndexPermissions() to fetch permissions for the content item, which inherently checks the parents already. What you are describing seems like it would be a major issue for every search if it were the case (searching for a topic pulls topics you can "see" even if you can't see the parent forums where the topic is located), and I can't seem to reproduce that, ignoring the rest of what you are talking about.

Link to comment
Share on other sites

I don't understand a thing:

I see that the permissions are not aligned in the subnode. (why?)

this.thumb.png.08b11d4904459f40d48d81daae3f754e.png

you prefer handle permissions into your script to avoid check parent when is the case?

you align the search index item but not the node?

(see screenshot) a topic into SUB forum with permission to read is not readable because into "A test Category" is not able to view forum. if I not wrong the topic was visible on 3.4.x

Link to comment
Share on other sites

For the search index, we don't explicitly just grab the permissions stored in core_permission_index, however. The content item method searchIndexPermissions() (which just pulls from Node\Model searchIndexPermissions()) specifically walks up the tree to make sure the parents can be read as well, and this permission merge is what is stored in the search index.

Link to comment
Share on other sites

Personally I don't like this procedure, because you use disabledPermissions() and permission() when get form to edit node/model (I like it) but this check don't cover parent... (why this decision not update directly the child or give it a option to update the child? could you at least notice the admin that such permission is disabled on parent?)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...