An enabled status makes skins available to the end-user configuring the look of their site.

Setting the status of a skin per theme is currently only possible in the skin plugin (in code).
We currently have a UI at admin/appearance/skinr/skins (which is broken) that allows an admin to override the status settings from the skin plugin.

The question is whether we really need it, considering you could enable or disable the module containing the skin.

Comments

moonray’s picture

Some previous discussion (and some code) is available in #977118: Skins in disabled basetheme cannot be enabled for basetheme (to appear in subtheme) in comments #23 through #26.

moonray’s picture

Here's an argument for having this functionality:
A module or theme will usually have a multitude of skins. Enabling/disabling the module or theme will also enable/disable every skin, not allowing you to fine-tune your selection of skins. This means you'd have to have separate modules for related skins that conflict with each other. An example of this is 960 grid system where you can have 12, 16, or 24 column layouts which you might not all want enabled at the same time.

ChrisBryant’s picture

I think it's important to be able to disable skins, as we had it before, due to the same reason you mention. Disabling the module or theme providing it wouldn't be sufficient.

Ideally access to enabling and disabling skins should also be able to be controlled by a specific permission for it.

jacine’s picture

Agreed.

I would like to stop allowing edits of all enabled themes at the same time, but that's really a separate issue.

So, what do we need to do to fix this?

jacine’s picture

Ideally access to enabling and disabling skins should also be able to be controlled by a specific permission for it.

We already have different permissions for configuring skin settings vs. administering skinr. Anything else would be overkill IMO.

ChrisBryant’s picture

@jacine, makes sense and fine with me. :-)

sun’s picture

x-posting:

set the status of a skin (from plugin info, not an applied skin) has nothing to do with the ability to apply skins

I understand. However, manual administration/management of skin statuses is a much larger topic, which we need to discuss in detail in a separate issue. Based on the current code, it seems like that information was previously stored in the database. Technically, this information rather belongs into a system variable — unless we are going to revamp the entire handling of skin information to be stored in the database, too (i.e., a {skinr_info} table that'd be similar to the {system} table, tracking what exists, information and API versions, status, etc); but as of now, I don't really see a need for this yet, and TBH, if you ever dealt with bug reports and issues related to that {system} table behavior, you'd be similarly hesitant of forking/using that pattern. In the end, there's a lot to discuss with regard to manual configuration of skin statuses, and most likely also plenty of expectations (which might have changed?).

moonray’s picture

Let me try and sum up expectations:

  1. We start with applying the default status
  2. This gets overridden by status (per theme) in the skin plugin
  3. This, again, gets overridden by user-applied status
  • When status is TRUE the skin is available to the user to apply to a page element
  • When status is FALSE the skin is NOT available
  • The status is displayed in the admin UI, and can be set there
coltrane’s picture

In order to satisfy the order you provide moonray would the user-applied status override default status in the skin object? Otherwise there needs to be another property that is checked when applying.

moonray’s picture

Default status already gets overridden by status in existing code. We just need to add user-configurable (through admin ui) status overrides.

coltrane’s picture

Status: Active » Needs work
StatusFileSize
new4.32 KB

Here's the start of this, it allows the admin/appearance/skinr/skins screen to save Skin statuses to skinr_skinsets table, and correctly loads the saved status with a new skinr.module function skinr_get_skin_statuses().

The next step, assuming this approach is correct, would be to invoke skinr_get_skin_statuses() in skinr_preprocess() I think. But I'm not sure what skinr_skin_extract() is about and where the best place to check if the skin is enabled.

Also, I've seen discussion about the table skinr_skinsets. It seems the agreement is to handle the renaming of the tables (if at all) in another issue.

moonray’s picture

@coltrane: I'm sorry you had to do all this work for nothing. I had already contributed a similar patch in comment #22 of issue #977118: Skins in disabled basetheme cannot be enabled for basetheme (to appear in subtheme) (see post #1 in this issue). I'll repost what was discussed in the other thread to hopefully avoid further issues.

sun: @moonray: Sorry, but that's the exact opposite of where we need to go; this logic does not belong into the skin processing code. Skin info handling has to be entirely decoupled from actual skin configuration. In other words: We have two APIs - one for registering and handling skin information (and only that), and second and separate one for loading/saving/applying skins ("skin configuration objects" if you will).

moonray: The ability to set the status of a skin (from plugin info, not an applied skin) has nothing to do with the ability to apply skins. I don't see how that needs to be separated.

sun: I understand. However, manual administration/management of skin statuses is a much larger topic, which we need to discuss in detail in a separate issue. Based on the current code, it seems like that information was previously stored in the database. Technically, this information rather belongs into a system variable — unless we are going to revamp the entire handling of skin information to be stored in the database, too (i.e., a {skinr_info} table that'd be similar to the {system} table, tracking what exists, information and API versions, status, etc); but as of now, I don't really see a need for this yet, and TBH, if you ever dealt with bug reports and issues related to that {system} table behavior, you'd be similarly hesitant of forking/using that pattern. In the end, there's a lot to discuss with regard to manual configuration of skin statuses, and most likely also plenty of expectations (which might have changed?).

(emphasis mine)

sun’s picture

The next step, assuming this approach is correct, would be to invoke skinr_get_skin_statuses() in skinr_preprocess() I think.

skinr_preprocess() is the heart and performance-critical part of the runtime logic. In there, we only deal with applying configured skins, and nothing else. If a skin has been configured, and later on disabled, then we will still apply it. The administrative UI needs to disallow disabling of skins for which configuration exists.

aquariumtap’s picture

@coltrane - I started to build out this patch as well. This is a hard project to jump into! And this seems like a natural starting point. The "enabled" checkbox in the admin UI is a manual override to the skin info's "default status". That default status itself has a default --- disabled --- which was chosen to encourage site administers to only enable the skins they intend to use, to avoid end-user UI clutter. Right now, unless someone is aware of this "default status" property, they'll never get to the point of fully registering a new skin.

skinr_preprocess() is the heart and performance-critical part of the runtime logic. In there, we only deal with applying configured skins, and nothing else. If a skin has been configured, and later on disabled, then we will still apply it.

That makes sense to me, but where should this go? What function is responsible for listing out applicable skins to the end (administrative) user?

Technically, this information rather belongs into a system variable — unless we are going to revamp the entire handling of skin information to be stored in the database, too (i.e., a {skinr_info} table that'd be similar to the {system} table, tracking what exists, information and API versions, status, etc); but as of now, I don't really see a need for this yet

System variables are only name/value pairs, and the values are json encrypted. It would not allow us to write a query to gather a list of enabled skins, for example -- unless that is exactly the data stored in the json-encrypted object. What benefits would come from using the variables table?

Either way, moving from {skinr_skinsets} to {variable} for storage seems fairly easy at this point. As for the bigger consideration that would require lots of discussion, using a more robust structure like {system}: is there a need for storing multiple skinr data formats (i.e., from different API versions) in the same table? Unless there's a strong case for that, it'd be great to move forward with this patch as-is.

moonray’s picture

I found that we're going to need more granular control over skin configuration; we need to be able to easily disable skin configurations that contains skins that get disabled. Hence #1082842: Update storage of skin configurations to give more granular control.

Once that's in we can get my patch (which I've almost completed) posted and tested.

moonray’s picture

Status: Needs work » Needs review

This patch, commit a51b62f7c45c89a7bd19ccdf748f613129cab4b1 on github, depends on #1082842: Update storage of skin configurations to give more granular control, but I thought I'd share it anyway since git makes things so much more flexible.

Obviously we should review, tweak and commit the patch this one depends on first, but I felt we need to move things along and get Skinr to a fully usable state as soon as possible.

So, the above kept in mind, feel free to leave your feedback on my proposed approach.

rickmanelius’s picture

StatusFileSize
new16.19 KB

Hey Everyone,

I definitely understand the need for granularity. Hashing out some ideas on paper, let me put this out there.

Sun mentioned here http://drupal.org/node/1029058#comment-4014070
The need for "one theme, one theme hook, and one skin".

Moonray posted a suggestion here http://drupal.org/node/1050472#comment-4048414
Stating the need for a default status, per theme status, and then user status.

Moonray also gave an example of a situation where many skins may become available but they might not be relevant
http://drupal.org/node/1050472#comment-4044918

So why not have a skin install settings menu (see attached)
This could provide a default enable skinset and enable skin option per theme. And even a default setting for new
themes. This would essentially control the default toggles for these urls
admin/build/skinr/skins
admin/build/skinr/skins/settings/tables

Now if a theme or module creates a skin that it NEEDS but the system is set to NOT ENABLE it by default, send a system warning saying this module needs it to be enabled.

Lastly, for situations where there is a conflict. Perhaps a skinset (particularly in a theme or module) defines a new default tag so that if one has both the skinset and the skins enabled by default for a theme, that only one or one set of the initial skins are enabled per toggled theme.

Thoughts?

coltrane’s picture

@rickman, I'm not seeing how that's better/different than the current UI, except that the current one lives within admin/appearance

moonray’s picture

StatusFileSize
new23.46 KB

Rerolled patch now that #1082842: Update storage of skin configurations to give more granular control has been committed.

To reiterate:

  • Note that fixing up of the page at admin/appearance/skinr/skins will happen in #984402: Add "details" link that shows preview of rendered skin widget and additional info (this page's form, i.e. using the 'Save configuration' button, has been broken for a while now).
  • The admin page that has been updated and needs testing is admin/appearance/skinr/skins/settings/* (click on a configure link on admin/appearance/skinr/skins to get there).
  • Tests are included to test status override functionality.
coltrane’s picture

StatusFileSize
new23.14 KB

Patch works well!

Minor issues:

1. skinr_ui_skin_status_set() is defined in skinr_ui.module but the menu definition loads skinr_ui.admin.inc, so I think the definition could be moved over to it

Questions:

2. There's little UI change when you enable/disable a Skin's configuration status, perhaps a drupal_set_message() in skinr_ui_skin_status_set() would be good?

3. Is this patch/functionality suppose to touch the appearance of the widget settings form? For example, with a Skin's element disabled on admin/appearance/skinr the form for it still appears (with it's default value set) and when saved it re-enables the element. Is that suppose to be? If not that's fine, if so I'd like to talk about the UX of it. A status of disabled (IMO) implies the form wouldn't be available.

4. The skin configuration enable/disable URL is susceptible to a CSRF attack, though there's little value for an attacker to exploit it. Does it seem worth it to you to tokenize those URLs?

5. Additionally, the enable/disable URL could be one menu router definition, admin/appearance/skinr/toggle/%skinr_skin which would just flip the status of the requested skin. Seem worth it?

Attached patch does items (1), (2), and (5).

coltrane’s picture

StatusFileSize
new23.19 KB

#20 was wrong patch actually. This patch implements items 1, 2, and 5 of what's discussed in #20

moonray’s picture

Status: Needs review » Needs work
  1. The reason I put skinr_ui_skin_status_set() in the main module file is that it's an API function that could be used without the admin interface. Think of CTools export in the future, for instance. You were actually right on this one.
  2. Some additional messages seem reasonable.
  3. I'm not 100% sure what your referring to here. Let me try to explain what I believe should happen:
    • When you disable a skin at admin/appearance/skinr/skins/settings/% it should disable all related skin configs at admin/appearance/skinr. That skin should no longer show up when editing the skin config for an element at for instance admin/appearance/skinr/edit/nojs/%/%/configure.
    • When you enable a disabled skin at admin/appearance/skinr/skins/settings/% all disabled skins at admin/appearance/skinr should be re-enabled, and the skin should now once again appear when editing a skin cofig for an element at admin/appearance/skinr/edit/nojs/%/%/configure.
  4. Probably better safe than sorry. Anyone else want to chime in here?
  5. I consciously chose not to use a toggle because you never know what you get in the end. If you haven't reloaded a page and hit a link for a seemingly disable item (that was actually already disabled from another page), you won't get the desired result. I think we should avoid the toggle.
moonray’s picture

  1. There's a whole discussion on menu enable/disable #178608: Menu disable / enable on GET request; vulnerable to CSRF when it happened for D6 core. Perhaps we should remove the menu hook and enable/disable links and only allow it through the 'mass update' (checkboxes and select the update option from the drop-down, then click update button). Will that be improving or the UI or making it harder to use?
    Thoughts?
jacine’s picture

Regarding tokenizing the URLs, I think it'd be worth it. It would be strange to only be able to toggle these settings via bulk updating. Having the "actions" listed next to each skin seems to be standard UI practice anyway.

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new23.97 KB

And now we have tokenized URLs for enable/disable links.
That should wrap up any issues.

Please test and set to RTBC. :)

moonray’s picture

Status: Needs review » Needs work

Tests need to account for tokenized URLs.

coltrane’s picture

Still works great, leaving as CNW for the tests though per #26

One change I'd recommend is the text on the confirmation form when you disable skin sets for an entire theme, I found it pretty confusing. I propose changing

skinr-ui-disable-confirm.jpg

to

skinr-ui-disable-confirm-after.jpg

Attached patch with the change, or here is the relevant code (note that $themes = list_themes(); can be removed from later in the fn)

function skinr_ui_admin_skin_info_settings($form, &$form_state, $skin_info) {
  $themes = list_themes();
  if (isset($form_state['storage']['disable_sids'])) {
    foreach ($form_state['storage']['themes'] as $theme) {
      $items[] = $themes[$theme]->info['name'];
    }
    $message = t('Would you like to disable the skin configurations for the selected themes?') . theme('item_list', array('items' => $items));
    // Insert a confirmation form.
    return confirm_form(
      $form,
      t('Disable all skin configurations for selected themes?'),
      'admin/appearance/skinr/skins',
      $message,
      t('Yes'),
      t('No')
    );
  }
moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new24.06 KB

Changes from #27 are incorporated (thanks @coltrane) and the tests now work again.

g76’s picture

subscribe

moonray’s picture

Status: Needs review » Fixed

Committed this.
Any problems, file a bug report. :)

Status: Fixed » Closed (fixed)

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

CharlieCastle’s picture

Can someone please tell a newbie how to apply a .patch?

I've got the problem discussed in this tread but don't know how to fix it.

I did a bit of googling and found http://drupal.org/node/60108 which may have the needed information.

But I get an access denied on that page. Why?

rickmanelius’s picture

@CharlieCastle Here's an example of how to apply a patch: http://data.agaric.com/how-apply-patch-drupal-module