Attached patch introduces configurable default owner permissions per ad type.
Users can't edit the contents of a text ad after creating one. Even not, if a user has the manage advertisements permission. This can certainly be treaten as a bug. However, after studying the code I found out that it would take more time to fix the bug than to implement this feature for all ad types at once.
It's done by attaching an option list of available ad permissions to all global settings forms of ad types. To keep this as integrated as possible, I've renamed some of the existing global settings form builder functions to a common standard (ad_[type]_global_settings).
Of course, this could be enhanced further by actually turning the global settings form into a new operation of hook_adapi(). However, since ad modules handle form values differently in form submit functions, I chose the easier way by prepending a common form submit handler for all global settings forms.
Benefit aside from that: Most hook_menu() implementations in ad_[type] modules are gone, which means less duplicate code.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | ad-DRUPAL-5.default-permissions.patch | 6.79 KB | sun |
| #4 | ad-DRUPAL-5.default-permissions.patch | 6.22 KB | sun |
| ad-DRUPAL-5.default-permissions.patch | 7.79 KB | sun |
Comments
Comment #1
sunSmall addition in advance: Yes, there has been this extra condition in ad_owners_add():
However,
ALLis not only undefined, but also not used anywhere else in Advertisement.Comment #2
jeremy commentedThis does not quite work. In particular, "embedded ads" are not a type of ad, they are a way for displaying ads. As such, if we apply your patch we lose access to the embedded ad configuration page. That said, I like the direction you are going with this, and the ability to configure default settings per-ad-type. (I had originally intended to allow these defaults to be set programmatically through an API, but never got around to it.)
Comment #3
sunUnderstood, I'll have a closer look at embedded ads and come up with a new patch shortly.
Comment #4
sunRe-rolled patch against current DRUPAL-5, omitting changes in ad_embed.module as requested in #2.
Comment #5
jeremy commentedLooks good. It should also add an update to ad.install to flush the cache_menu table, as otherwise the settings page isn't accessible.
I plan to commit this after 5.x-1.5 is released.
Comment #6
sunAdded a module update to ad.install - following the improved update numbering scheme which, besides other benefits, primarily allows to determine to which module version/release an update belongs. Although only mentioned in D6's API documentation, all module developers are advised to use this scheme for all new updates.
Comment #7
jeremy commentedFinally committed, with some modifications. It's now possible to set default permissions for all ad types, not just those that define a settings page. Thanks for the patch!!
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.