function _jdrupal_resource_content_types_list in jDrupal 7
Returns a collection of content types from the {node_type} table.
It also bundles other available information about each content type with the return results.
Parameters
array $options: An array of options.
Return value
object MySQL object results from the {node_type} table
1 call to _jdrupal_resource_content_types_list()
- _jdrupal_resource_content_types_user_permissions in ./
jdrupal.resource.inc - Returns a collection of permissions from content types for the current user.
1 string reference to '_jdrupal_resource_content_types_list'
- jdrupal_services_resources in ./
jdrupal.services.inc - Defines function signatures for resources available to services.
File
- ./
jdrupal.resource.inc, line 45 - This file implements the jdrupal service resource call back functions.
Code
function _jdrupal_resource_content_types_list($options = array()) {
// Grab content types.
$sql = "SELECT * FROM {node_type} ORDER BY name ASC";
$content_types_result = db_query($sql);
if ($content_types_result) {
$content_types = $content_types_result
->fetchAll();
foreach ($content_types as $i => $content_type) {
// Grab comment settings for content type.
$names = array(
'comment_anonymous_' . $content_type->type,
'comment_' . $content_type->type,
'comment_default_mode_' . $content_type->type,
'comment_default_per_page_' . $content_type->type,
'comment_form_location_' . $content_type->type,
'comment_preview_' . $content_type->type,
'comment_subject_field_' . $content_type->type,
);
$sql = "SELECT * FROM {variable} WHERE name IN (:names)";
$variable_results = db_query($sql, array(
':names' => $names,
));
if ($variable_results) {
// Extract comment settings variables and attach to content type result.
$variables = $variable_results
->fetchAll();
foreach ($variables as $variable) {
// Strip the '_type' from the end.
$end = drupal_strlen($variable->name) - (drupal_strlen($content_type->type) + 1);
$variable_name = drupal_substr($variable->name, 0, $end);
$content_types[$i]->{$variable_name} = unserialize($variable->value);
}
}
}
return $content_types;
}
}