user_pictures & user_register variables - drupal

I'm trying to pragmatically set those 2 variables upon installing a site.
user_pictures (Disabling user pictures altogether)
user_register (allowing visitors to register without admin)
I'm using Features with strongarm but no luck. Even with the feature enabled the options are wrong in the account settings.
Setting the variable manually with a script doesn't do the trick either, although the options show the correct checkbox as ticked, I still have to to the page a click "save configuration" to confirm the setting.
This goes for maaany other variables I'm tryign to set, and I'm not sure if this is possible but it would be nice.
Thank you!

One solution which only solves part of my problem is to use Install profiles. The problem with those is that some variables still don't seem to take effect or work at all...
https://drupal.org/developing/distributions
https://drupal.org/project/profiler

It looks like this is the intended behavior of the features module, according to this old issue on drupal.org:
Say when developing a site, and set the settings at admin/user/settings for user_register. then you go live, later you decide to change the value, make a feature and strongarm that user_register variable then deploy that. The setting will still be in the database (as a variable), thus the feature is overridden.
The simplest solution is to not rely on features to set your variables on installation. It's much simpler to use hook_install anyway. I suppose we're only supposed to think of the Features module as a means of setting up or updating complicated configuration from the Features administration page, but not when the module itself is enabled or updated.
This will set the variables you describe for the example module:
function example_install() {
variable_set('user_pictures', 0);
variable_set('user_register', 1);
}
If other parts of your feature also aren't being set up correctly, perhaps you should try this instead:
function example_install() {
// This will only revert 'variable' features. Include additional features as needed.
features_revert(array('example' => array('variable')));
}

Related

How to make MultiValueField with Composite Fields and i18n enabled work properly?

Have anyone tried to have a form with MultiValueField in Magnolia having Composite fields with i18n enabled and is working properly?
Currently, I'm encountering some weird behaviour when adding items to English then switching to other language and adding items again then switch back to English with items all gone. In one JIRA post it said it was already fixed but I still encounter this issue. Also encountered issues in sorting which apparently not supported by the DelegatingMultiValueTransformer.
If so, can you please show me the configuration you use to make this work properly? If needed customisation, can you give me ideas on how to do it?
Would really appreciate any help on this.
Btw, I'm using the latest release 5.4.6 now.
Maybe you don't want to put two questions in one request in the future ;)
Re language issue:
did you check that you have i18n enabled also on the subfields, since you are using deletage transformer? AFAIK with delegate you need to have them enabled on all fields in the hierarchy.
Re transformer & ordering:
IMO the only way out is to write custom transformer. Look at source code of MultiValueTransformer and in the part of the code where it goes just two levels down when checking child values, you need to go deeper.
You would also need to define different structure storage for your values there since one used by the MultiValueTransformer would not suffice for multiple levels.
Perhaps you can extend one of the more specialized MultiValue*Transformer or perhaps you try MultiValueJSONTransformer if storing all values in json array is enough for you (you would still need to extend it and to repopulate values back into dialog when opening dialog for editing).
HTH,
Jan

Migating from CakePHP to Drupal, functionality question

(I've posted this on the drupal forum too btw)
I'm converting the company websites to use Drupal, or at least trying to check that its going to be the best way forward. I have a background in PHP development, and I'm currently using the CakePHP framwork. I've built this site (not my design) and I can see how to replicate most of the functionality using Drupal, most likely using the CCK module.
http://preview.tinyurl.com/yk6u8mt
As you can see from the homepage:
A user chooses a country.
The country is passed using an ajax call to a script that decides which phone is best based on 'in country' network coverage.
A div is shown recommending the visitor the best phone for that country.
I'm wondering how to go about this in Drupal, I'm definitely not after a step by step guide, I just want to know if this kind of thing is possible with Drupal, and what approach to use.
If someone can help that would be superb. Thanks.
Okay, so you've got a path you're defining in hook_menu, which is where your form is being presented - or else you've got it set up as a webform in a node, that could work too.
Either way, in your form you're going to be using AHAH - check out http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#ahah and http://drupal.org/node/348475 .
Basically, you're going to define another path in hook_menu that's of type MENU_CALLBACK, and which will receive the country as input, and then will return the div that you'll display on the screen.
One core example of AHAH that may be useful to you is where you're entering a password and it lets you know if the password is secure enough - check that out.
Edit: There's also some good examples at http://drupal.org/project/examples.
I would look into using CCK and views. you can set up filters for the views. If filters don't work, you have the ability to include php code. I have also successfully added jquery code in the header of a view through which I was then able to have my view filtered by what is typed in a text box.
Coming from CakePHP using Drupal is a pain in the a** - even more for developers.
It's application structure might be designed to ease extensibility but this only means you have a system to enable your own plugins and themes.
While modules are basically the M+C-part the themes are the V-part of an MVC-application. The problem is that this seperation is not very strict in Drupal - in fact you have to break it sometimes in order to make things work (e.g. you have to include a theme_mymodule_myfunction() into your module as default output which you then can override with your theme using mytheme_mymodule_myfunction() ) And don't even bother looking for classes ( see http://drupal.org/node/547518 ).
Also there is no real link from a module to a theme. On many occations this is a good thing as you can switch modules and themes seperatly without creating a problem. For application builders coming from CakePHP (or any other framework) you often feel a lack of "wholesomeness" - you create parts for a base software and have to live with it's drawbacks.
IMHO I wouldn't recommend this step. Drupal is fine if you have to manage a website and might add a few modules to add neccessary value (image gallery etc.) but I definetly don't recommend it as a base for a customized web-app.

Controlling UberCart checkout pane hook priorities

I'm using Drupal 6.15 with ubercart 2.x and I'm trying to implement ubercart's hook_checkout_pane() to override their default uc_cart_checkout_pane(). My goal is to disable some of the default checkout panes - customer information and order comments.
I made a function my_module_checkout_pane() in my_module.module and it does get called, but the uc_cart version seems to be generating what's actually rendered.
I understand why both functions get called and I can change the order they're called in by modifying my module's weight in the system table, but doing so doesn't seem to affect what ends up on the page. Whether my_module's function is called first or second, the uc_cart version is what's rendered. The only way I can get my function to affect the page is to actually alter uc_cart_checkout_pane() so it doesn't return any output but that's not a "good" solution.
Is there some other place I need to do something to make Drupal favor my hook implementation over uc_carts'? Alternatively, is there another way to accomplish this?
you can enable or disable checkout panes in "Checkout settings".
btw: no need to alter module weights, you can do this with pane weights.
If I'm not mistaken, hook_checkout_pane is for creating new checkout panes, not overriding default ones. Seems like you'd use hook_checkout_pane to make your own pane and just use that instead? See http://www.ubercart.org/forum/development/11698/alter_checkout_panes
Apologies if I'm mistaken.

How to show inactive task tabs in Drupal

Is there any way to show local tasks to user if they doesn't have necessary permissions? Right now it seems like Drupal just excludes them from page code. I want to show them, but with different CSS class.
Version of Drupal is 5.20
Even though there are some differences concerning the local task building between Drupal 5 and 6, Mac is right that the logic to ignore entries not accessible by the current user is pretty deeply embedded in the menu.inc functions. If you want to look for yourself, start with theme_menu_local_tasks() and follow the function calls from there.
If I had to implement the feature you're looking for, I'd rather avoid Macs suggestion of messing around with the menu access settings directly. Instead, I'd override theme_menu_local_tasks() with a custom version and duplicate the entry retrieval logic in there. The first run would fetch the primary and secondary links as before, and the second would do the same while impersonating another user (probably user 1 in this case). That way, I'd get two versions of the local task markup which I'd then needed to diff somehow in order to find the ones not allowed for the current user, thus needing the extra CSS class.
Note that this would still be somewhat ugly to do, as menu_primary_local_tasks() and menu_secondary_local_tasks() return already themed lists, so the comparison would need to work on the markup, probably parsing out the li tags somehow. So it might be worth spending some time trying to do the same thing (fetching the local tasks as two different users), but using lower level functions to get the entries before theming.
Note: Should you end up using the user impersonation logic, make sure to use the safe, second version that disables session saving during impersonation.
I know the D6 version of hook_menu much better than D5's. AFAIK - however - you can't override that behaviour as it is hardcoded in menu.inc.
If I am right with what above, a workaround (rather inelegant, I must admit) could be:
Remove the access control from the menu item, so that all menu items are visible to all user.
Put access control in the callback directly (you will make the tab non-clickable in a moment, but if the user insert the URL directly, this will prevent access to pages they must not see).
In the page displaying the tabs, load a different js file according to what roles the user has. The js file for users with limited access will select tabs by mean of their text content (at least in D6 tabs do not get any "individual" class: they only get a common "tab" one), it will remove the link to the tabs the user has no permission to visit and it will add a custom class to those tabs that should be displayed differently.
Add CSS theming for your custom class.
As stated before, I do not know D5 much, so it might also turn out that you can actually achieve what you want in a much cleaner way!

Disabling /node view and other hidden views in Drupal?

Many long nights spent on my site, and now I've started doing all sorts of security checks and stumbled upon the following:
www.mysite.com/node
That shows the latest x nodes that a user has access to. I DON't want this view visible to users. And I certainly don't want any other views similar to this available. So, my questions are:
How do I disable this view?
Are there other hidden views that I'm not aware of that an anonymous user can use to access several nodes at once?
You want to use hook_menu_alter() in a custom module to reroute what happens when someone tries to load the page at /node. There are two approaches.
First, you could give an unequivocal access denied:
function custom_module_menu_alter(&$items) {
$items['node']['access callback'] = FALSE;
}
Second, you could reroute the page to one of your choice:
function custom_module_menu_alter(&$items) {
$items['node']['page callback'] = 'custom_module_new_page_content';
}
function custom_module_new_page_content() {
return 'Go away!';
}
Other Listings
If you are worried about listings where users have access, the search results and tracker are the only other places that I can recall.
This comment provides the logic to unset whatever you want from the search results using a custom module.
Unfortunately the Tracker is not particularly customizable without direct hacks. Your best bet is to use one of the tracker replacements in contrib, or easier yet, modify the Tracker replacement that is packaged with the Views module.
EDIT: Clarification- you could also disable the Tracker module form the optional "core" modules. However, it is a very useful functionality so you might want to keep it around in some form.
As for disabling paths you found, I'd second Graysides suggestion of using hook_menu_alter to adjust the access callback.
As for other 'hidden' views, this depends a lot on the modules you use, as many modules add some default 'views' (in the sense of overview pages, not necessarily views module views). So instead of trying to find them indirectly here, I'd suggest to take a look at the menu_router table of your Drupal database. There you'll find all paths currently used by your instance (internal paths, not aliases, but all aliases map to an internal one).
One relatively simple way to do this that works is to turn on the Path module under core and alias /node to something else like /node/1 or whatever ..
Not sure about other urls that get you things you don't wanna see... i would think this technique would work for any you come across
function modulename_menu_alter(&$items) {
$items['node']['page callback'] = 'drupal_not_found';
}
Source: http://drupal.org/node/500296#comment-3532630
the "node" view is the default frontpage view. So it is usually the same tha appear on you're frontpage.

Resources