I've been using fe_block successfully to maintain revision control over a couple simple blocks (one generated by a view, another containing custom HTML).

Both of these blocks have role visibility settings applied, and I noticed that the fe_block module (current dev version, I believe), doesn't capture these settings. My work-around is to run SQL update command to update the blocks_roles table appropriately, but I am curious if the fe_block module would ultimately be able to capture role visibility settings as well.

Thanks for writing a great module!

Comments

westbywest’s picture

It turns you can work-around this by adding PHP code for block visibility that senses the user's current role. The fe_block module will capture the PHP code.

For example, this code would only display the block to anonymous users:

<?php
global $user;
return ($user->uid == 0);
?>
wizonesolutions’s picture

Status: Active » Closed (cannot reproduce)

These are captured, but you have to add both the block and the block settings. I know this works as of now as least, so marking this closed.

netw3rker’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Closed (cannot reproduce) » Active
StatusFileSize
new2.44 KB

Role settings by themselves are definitely not being exported/imported. To reproduce this simply take a block, mark it as visible to only authenticated users and place it in a sidebar. when you export that block, then import it to a clean environment, the block will be visible to both anon & authenticated users. this is because the roles are not added to the $block when exported.

I'm bumping this up to a 7.x issue since the original was closed, and also including a patch to fe_block to include and manage roles. also note that this treats the roles as exportables, so it wont assume that the RID is the same between environments. Instead it uses role name and adds a dependency on features' user_role functionality.

Hope this helps!

Codecaster-2’s picture

I have tried your patch and roles weren't exported, I couldn't see them in the exported code.

tatyana’s picture

Here is a patch to export and revert both roles and types visibility settings. Hope will be useful.

pfrenssen’s picture

@tatyana, what a coincidence, I have been working on this as well :)

I notice that your patch exports the role and content type settings per theme (as did my initial version), but unfortunately these settings are not theme dependent but set once across all themes. Once I realized this the complexity of the patch increased a lot. The problem is that if your site has many themes the size of the exported file will increase dramatically, as will the time needed to revert. Also editing the Feature by hand (as I do so often these days :) will become very impractical because of all the duplicated data.

As I found out, trying to generate a proper export breaks the current implementation, and it is necessary to add some code to provide backwards compatibility.

vinmassaro’s picture

@pfrenssen: what was your solution? I need to export the visibility settings for only one block.

derhasi’s picture

I Just ditched into that issue again, as I need role visibility settings to be exported. ou mentioned to restructure the export. I'd very welcome that, as the current implementation does not work very well with the Features UI (as well as diffing code is a mess too).

As you allready mentioned I did some work in a D6 sandbox, that at the end generated output like this:

//...
$export['menu-menu-application'] = array(
    'module' => 'menu',
    'delta' => 'menu-application',
    'custom' => '0',
    'visibility' => '0',
    'pages' => '',
    'title' => '',
    'cache' => '-1',
    'themes' => array(
      'mycustom' => array(
        'theme' => 'mycustom',
        'status' => 0,
        'weight' => '-49',
        'region' => '',
      ),
      'rubik' => array(
        'theme' => 'rubik',
        'status' => 0,
        'weight' => '-54',
        'region' => '',
      ),
    ),
    'roles' => array(
      'admin' => '4',
      'authenticated user' => '2',
    ),
  );
//...

I'll try to post a patch on that approch, so we maybe will get some cleaner output some time ;)

derhasi’s picture

Status: Active » Needs review
StatusFileSize
new20.39 KB

I really got through it, and could rework the module, to output it in the further mentioned manner.

  • Added "roles" settings for the role visibility settings.
  • Export array is structured in a per block, not per theme way. So we do not duplicate information anymore, and even better: features now really can have a "Default" state, and aren't allways in "Overriden" state.
  • Theme specific settings are located in the block's theme array. So we can associate those settings directly with the rest of the themes and the "global" settings.
  • There's a converter function too, that should convert "old" fe_block setting exports to the new format for reverting correctly.

And there's the patch.

Status: Needs review » Needs work

The last submitted patch, fe_block_rework-868828-9.patch, failed testing.

derhasi’s picture

Status: Needs work » Needs review
StatusFileSize
new20.44 KB

Arg, sorry had to do some fixes, now it should really work for roles.

Status: Needs review » Needs work

The last submitted patch, fe_block_reworkk-868828-10.patch, failed testing.

pfrenssen’s picture

Thanks for the work, I really like your export format, but this is out of scope for this issue. Could you perhaps open a separate issue for reworking the export format and keep this about capturing role visibility? Since we are still in alpha it is fine to make big changes to the export format.

What do you mean with the following:

Export array is structured in a per block, not per theme way. So we do not duplicate information anymore, and even better: features now really can have a "Default" state, and aren't allways in "Overriden" state.

I am not experiencing this at all with the current code base, none of my features are overridden anymore. I have also written tests that assert that the code can be reverted to Default state properly. Anyway if you have found a bug in the state detection that is also a different issue :)

derhasi’s picture

@pfrenssen, yes maybe it is a bit out of scope ;) I created a new issue in #1820142: Reworking fe_block_settings export format.. But I think it would be worth the effort of tackeling that issue as fast as we could, so I directly mixed it with the role visibility thing.

Regarding the "Default" and "Overriden" state: I mixed that up, with the fact the Features UI currently cannot recoginze if a block setting is already exported to a feature. The latter one is the "bug". The "overriden"-statt just occured locally due to some real changes, I guess.

Forthis issue we could use the _fe_block_get_block_roles() and _fe_block_settings_update_block_roles() functions to implement it for the "old" export.

derhasi’s picture

Status: Needs work » Needs review
StatusFileSize
new3.81 KB

Status: Needs review » Needs work

The last submitted patch, fe_block-role-visibility-868828-15.patch, failed testing.

pfrenssen’s picture

Status: Needs work » Postponed
pfrenssen’s picture

Status: Postponed » Active

#1820142: Reworking fe_block_settings export format. got in, this is no longer blocked.

derhasi’s picture

StatusFileSize
new4.07 KB

Oh yeah, great, sure. There's a reworked patch.

derhasi’s picture

Status: Active » Needs review
pfrenssen’s picture

Status: Needs review » Fixed

Excellent stuff, committed with some minor documentation changes: commit bd3ae05. Thanks!!

Status: Fixed » Closed (fixed)

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