Currently only the main Subsites module has been upgraded to D7. Use this issue tracker for the upgrade project for the Subsites Access Control submodule.

Comments

francescoq’s picture

Hi, i saw that some of the code of Subsite Access Control was already upgraded, i changed only few lines and now from brief testing it's working, take a look at this.
I don't need this feature in my project atm, so i can't think of problems that may occour.

i changed these lines every time they occur:

  $grants[] = array(
    'realm' => "subsites_view_{$node->type}",
    'gid' => $sid,
    'grant_view' => TRUE,
    'grant_update' => FALSE,
    'grant_delete' => FALSE,
  );

to

  $grants[] = array(
    'realm' => "subsites_view_{$node->type}",
    'gid' => $sid,
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 0,
  );

and so on

francescoq’s picture

Ok, may sounds stupid, but i've never tried to create a content without a subsite associated... and this give three errors:

Notice: Undefined property: stdClass::$subsite in subsites_access_control_form_alter() (line 160 of [...]\sites\all\modules\subsites\subsites_access_control\subsites_access_control.module).
Notice: Trying to get property of non-object in subsites_access_control_form_alter() (line 176 of [...]\sites\all\modules\subsites\subsites_access_control\subsites_access_control.module).

PDOException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'gid' at row 1: INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5), (:db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11), (:db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17), (:db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23), (:db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27, :db_insert_placeholder_28, :db_insert_placeholder_29), (:db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34, :db_insert_placeholder_35); Array ( [:db_insert_placeholder_0] => 26 [:db_insert_placeholder_1] => subsites_view_page [:db_insert_placeholder_2] => -1 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 26 [:db_insert_placeholder_7] => subsites_update_page [:db_insert_placeholder_8] => -1 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => 1 [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => 26 [:db_insert_placeholder_13] => subsites_delete_page [:db_insert_placeholder_14] => -1 [:db_insert_placeholder_15] => 1 [:db_insert_placeholder_16] => 0 [:db_insert_placeholder_17] => 1 [:db_insert_placeholder_18] => 26 [:db_insert_placeholder_19] => subsites_view_own_page_-1 [:db_insert_placeholder_20] => 1 [:db_insert_placeholder_21] => 1 [:db_insert_placeholder_22] => 0 [:db_insert_placeholder_23] => 0 [:db_insert_placeholder_24] => 26 [:db_insert_placeholder_25] => subsites_update_own_page_-1 [:db_insert_placeholder_26] => 1 [:db_insert_placeholder_27] => 1 [:db_insert_placeholder_28] => 1 [:db_insert_placeholder_29] => 0 [:db_insert_placeholder_30] => 26 [:db_insert_placeholder_31] => subsites_delete_own_page_-1 [:db_insert_placeholder_32] => 1 [:db_insert_placeholder_33] => 1 [:db_insert_placeholder_34] => 0 [:db_insert_placeholder_35] => 1 ) in node_access_write_grants() (line 3440 of [...]\modules\node\node.module).

so this have to be fixed.
When I have time I will try to understand the problem.

francescoq’s picture

So.. this should fix the problem, in near future i'll try to test to find out other problems, but atm i haven't errors..

One thing: before building the $grants i added those lines

if ($sid == -1) {
  $sid = 0;
}

because $sid is used as $gid, and $gid column doesn't accept negative value.. i don't know if this is the right way to do it, but from what i can see it's working.

m4olivei’s picture

I added your patches, and found that the anonymous user couldn't see anything after enabling the module.

Going to look into why that is.

m4olivei’s picture

Oh wait, nevermind. I just needed to give permissions to view the content in each subsite and main site then the anonymous user was allowed to view the content.

Humm, this way of doing the access control is intense. At the least, there should be a warning about content becoming unavailable after enabling the module. Better would be some defaults to allow viewing content in all subsites. Best would be, there must be a better way to present this stuff. I'm thinking something like content access (http://drupal.org/files/images/content_access.png). Where we'd put a tab for "Access Control" on each subsite with an interface like Content Access.

Thoughts?

Thanks,
Matt

francescoq’s picture

Yeah, I also think that there should be a setting to let anonymous users view all the content of the subsites, i used Content Access some times and yes, i also think that it's definitely the right way to do it, but i never took a look at its code, if i have enough time i think at something this weekend... but i'm a newbie, i hope to be helpful in some way!

gisle’s picture

Title: Upgrade Subsites Access Control to D7 » SAC: D7 Upgrade
Version: 6.x-1.x-dev » 7.x-1.x-dev
Issue summary: View changes
Status: Active » Postponed

Postponing all Subsites Access Control issues until the main module has been successfully upgraded to Drupal 7.

chunty’s picture

StatusFileSize
new1.47 KB

Here is my version of the subsites access control module after I'd done the same fixes. Basically there are 3 updates I've done to make this work with D7.

  1. Applied the same changes as in #1 so that the permissions updates work see my comment here: https://www.drupal.org/node/800880#comment-10799684
  2. Fix the same problem as in #3 but in a different way
  3. Fix the problem that the function subsites_access_control_perm tried to treat $subsites as a class rather than an array which is how the subsites are now returned - this means the names of the subsites are correctly shown on the permissions pages.

I don't have the ability to make a patch file right now so I'm just uploading the whole module file.

andrey.troeglazov’s picture

Assigned: Unassigned » andrey.troeglazov
Status: Postponed » Active

Checking last comment.
If smn wants to help, it will be good.
Thanks.

  • andrey.troeglazov committed 74405af on 7.x-1.x
    Issue #1248022 by FrancescoQ, chunty, gisle, andrey.troeglazov: SAC: D7...
andrey.troeglazov’s picture

Assigned: andrey.troeglazov » Unassigned
Status: Active » Fixed

Hello, I have reviewed patches and archive from #8.
Committed to dev version with changes.
Thanks to all.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.