Closed (fixed)
Project:
Nodequeue
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2008 at 15:49 UTC
Updated:
23 May 2011 at 12:11 UTC
I have the start of a nodequeue.inc file. It just has one function that allows you to add nodequeues.
<?php
/**
* Add a nodqueue
*
* @param $queue
* An array of nodqueue properties
* - title
* - subqueue_title
* - reverse
* - link
* - link_remove
* - roles - (array of roles $rid => $role)
* - types (array of content types)
* - owner
* - show_in_links
* - show_in_tab
* - show_in_ui
* - reference
* - subqueues (array)
* - new
* - add_subqueue (array)
*
* @return
* The qid of the nodequeue
*/
function install_nodequeue_save($queue) {
$defaults = array(
'title' => null,
'subqueue_title' => null,
'size' => null,
'reverse' => 0,
'link' => 'Add',
'link_remove' => 'Remove',
'roles' => array(
),
'types' => array(
),
'owner' => 'nodequeue',
'show_in_links' => 1,
'show_in_tab' => 1,
'show_in_ui' => 1,
'reference' => 0,
'new' => 1,
);
$queue = (object) array_merge($defaults, $queue);
$qid = nodequeue_save($queue);
return $qid;
}
Sorry if this should have been added as a patch?
Comments
Comment #1
boris mann commentedThanks! I don't have my local setup nicely to work on this right now, and no problem on it not being a patch ... these .inc files are pretty simple, after all, and cut and pasting them here is a great start.
Comment #2
moshe weitzman commentedComment #3
dwwI don't see why we need this function at all. What good is it doing over calling nodequeue_save() yourself? Just the fact that it sets the defaults for you? Is that worth it to include in this API? Why not a patch for nodequeue so that nodequeue_save() tries to set reasonable defaults like this if you don't call it with a completely full array?
Comment #4
dwwI asked merlinofchaos his take on this issue via IRC. He agreed with my assessment. If anything, we should just make nodequeue_save() more friendly by providing defaults if you don't specify all the values. Then we don't need to clutter the Install profile API with this, and everyone gets the benefit of the nicer API, not just install profiles.
Comment #5
aaustin commentedAwesome. I know merlinofchaos has spent a lot of time making nodequeue extensible for other modules to use and has put a priority on that. But knowing the number of requests that he gets for features, etc. I was a little hesitant to ask. Thanks for asking.
As far as the larger philosophical question for the Install Profile API module, what differentiates the sort of crud function that gets put in to this module and a feature request for a specific module? In an even larger picture, shouldn't each module be providing these types of functionality for install profiles and other automated site building tools, in some uniform manner? Just some thoughts...
Comment #6
dww@aaustin: "As far as the larger philosophical question for the Install Profile API module, what differentiates the sort of crud function that gets put in to this module and a feature request for a specific module? In an even larger picture, shouldn't each module be providing these types of functionality for install profiles and other automated site building tools, in some uniform manner? Just some thoughts..."
Good questions, but sort of out of scope for this issue. Short answer: things should only go into install profile API if there's no alternative. Adding features or changing the API in a stable release of core is impossible, so we have to do it in the install profile API for D5 and D6, and try to get them into core for D7. Everything else should move into the modules themselves, instead of living in the install profile API, if possible...
Comment #7
damienmckennaI think this should be marked as Fixed as the nodequeue_queue class assigns a whole bunch of defaults.
Comment #8
damienmckennaFYI I caught a small bug in the nodequeue_queue class's default values that was causing errors if you didn't define a numerical value for 'reverse': #1151446: Default value for nodequeue_queue->reverse is incorrect