Newer
Older
moshe weitzman
committed
<?php
// $Id$
function og_panels_help($section) {
switch ($section) {
moshe weitzman
committed
return t('After enabling this module, visit the new Pages tab on any group. There, group admins may create as many pages as desired for their group. The pages may contain any layout that the site offers and admins may arrange many different types of content as desired. Site admins can restrict the types of content that may be added on the <a href="!settings">og_panels settings</a> page. You might want to make some Views available using <a href="!apv">admin/panels/views</a>. Group admins may designate one page as their group home page.', array('!settings' => url('admin/og/og_panels'), '!apv' => url('admin/panels/views')));
moshe weitzman
committed
case (arg(0) == 'node' && arg(2) == 'og_panels' && !arg(3)):
return '<p>'. t('Create custom pages for your group. Use custom pages to organize your content in a pretty and informative manner. Your group can group to be a whole website within a web site. Each custom page becomes a tab when viewing your group. One of your custom pages should be designated as your <em>group home page</em>. That page will then display when visitors first arrive at your group.') .'</p><p>'. t('Start by clicking the <a href="!url">Add new page</a> tab. Then you will choose a custom layout for your page. Then you will want to <em>edit content</em> for your custom page.', array('!url' => url('node/'. arg(1). '/og_panels/form'))) .'</p>';
moshe weitzman
committed
}
}
function og_panels_menu($may_cache) {
if ($may_cache) {
moshe weitzman
committed
$items[] = array(
'path' => 'admin/og/og_panels',
'title' => t('Organic groups panels'),
'description' => t('Configure the content that is available to group admins when creating group pages.'),
moshe weitzman
committed
'callback' => 'og_panels_admin_content',
'access' => user_access('administer organic groups'),
);
moshe weitzman
committed
}
else {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
moshe weitzman
committed
if (og_is_group_type($node->type) && node_access('view', $node)) {
moshe weitzman
committed
$nid = arg(1);
$items[] = array(
'path' => "node/$nid/og_panels",
'title' => t('Pages'),
'callback' => 'og_panels_overview',
'callback arguments' => array($node),
moshe weitzman
committed
'access' => og_is_node_admin($node) && user_access('manage OG panels pages'),
moshe weitzman
committed
'type' => MENU_LOCAL_TASK,
'weight' => 8,
);
$items[] = array(
'path' => "node/$nid/og_panels/list",
'title' => t('List'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[] = array(
'path' => "node/$nid/og_panels/form",
'callback' => 'drupal_get_form',
'callback arguments' => array('og_panels_form', $node),
'title' => arg(4) ? t('Edit page') : t('Add new page'),
'type' => MENU_LOCAL_TASK,
'weight' => 0,
);
$displays = og_panels_get_all($node->nid);
foreach ($displays as $display) {
if ($display->default_page && $display->published && arg(2) != 'feed') {
moshe weitzman
committed
// Hijack the menu handler for this node.
$items[] = array(
'path' => "node/$nid",
'title' => $node->title, // doesn't work
moshe weitzman
committed
'callback' => 'og_panels_page',
'callback arguments' => array($display->did, $node, $node->title),
moshe weitzman
committed
);
/*
* Optional. Horrible hack since the tab title is not changeable in D5. Add the following code
* to your theme's template.php in the _phptemplate_variables('page') section.
* if (isset($GLOBALS['og_panels_view_tab_fix'])) {
* $variables['tabs'] = str_replace('>View<', '>'. $GLOBALS['og_panels_view_tab_fix']. '<', $variables['tabs']);
* }
*/
$GLOBALS['og_panels_view_tab_fix'] = check_plain($display->page_title);
moshe weitzman
committed
}
else {
$items[] = array(
'path' => "node/$nid/$display->path",
'title' => $display->page_title,
'callback' => 'og_panels_page',
// have to pass all these args so the args are known in panels_page()
'callback arguments' => array($display->did, $node, $display->page_title),
moshe weitzman
committed
'type' => MENU_LOCAL_TASK,
moshe weitzman
committed
'access' => $display->published || (og_is_node_admin($node) && user_access('manage OG panels pages')),
moshe weitzman
committed
);
}
moshe weitzman
committed
}
$items[] = array(
'path' => "node/$nid/og_panels/". arg(3). '/view',
'callback' => 'og_panels_page',
'callback arguments' => array(arg(3), $node),
'type' => MENU_CALLBACK,
);
moshe weitzman
committed
if (is_numeric(arg(3))) {
moshe weitzman
committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
$items[] = array(
'path' => "node/$nid/og_panels/". arg(3). '/panel_layout',
'callback' => 'og_panels_edit_layout',
'callback arguments' => array(arg(3), $node),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => "node/$nid/og_panels/". arg(3). '/panel_settings',
'callback' => 'og_panels_edit_layout_settings',
'callback arguments' => array(arg(3), $node),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => "node/$nid/og_panels/". arg(3). '/panel_content',
'callback' => 'og_panels_edit_content',
'callback arguments' => array(arg(3), $node),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => "node/$nid/og_panels/". arg(3). '/delete',
'title' => t('Delete'),
'callback' => 'drupal_get_form',
'callback arguments' => array('og_panels_delete_confirm', arg(3), $node),
'type' => MENU_CALLBACK,
moshe weitzman
committed
);
}
moshe weitzman
committed
}
}
}
return $items;
}
moshe weitzman
committed
function og_panels_perm() {
return array('manage OG panels pages');
}
moshe weitzman
committed
function og_panels_delete_confirm($did, $group_node) {
$form['did'] = array('#type' => 'value', '#value' => $did);
$form['nid'] = array('#type' => 'value', '#value' => $group_node->nid);
$sql = "SELECT page_title FROM {og_panels} WHERE did = %d";
$page_title = db_result(db_query($sql, $did));
$form['page_title'] = array('#type' => 'value', '#value' => $page_title);
return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $page_title)),
isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $node->nid. 'og_panels',
t('This action cannot be undone.'),
t('Delete'), t('Cancel')
);
}
function og_panels_delete_confirm_submit($form_id, $form_values) {
og_panels_delete($form_values['did']);
drupal_set_message(t('%title has been deleted.', array('%title' => $form_values['page_title'])));
moshe weitzman
committed
}
function og_panels_delete($did) {
$sql = "DELETE FROM {og_panels} WHERE did = %d";
db_query($sql, $did);
panels_delete_display($did);
}
moshe weitzman
committed
/**
* Menu callback. List the pages for this specified group. Provide helpful operations links.
*
* @return string
**/
moshe weitzman
committed
function og_panels_overview($group_node) {
moshe weitzman
committed
$displays = og_panels_get_all($group_node->nid);
$output = drupal_get_form('og_panels_table', $displays, $group_node);
return $output;
}
moshe weitzman
committed
/**
* A form for setting the group homepage. Includes a helpful table of Pages and their operations links.
*
* @return $form array
**/
moshe weitzman
committed
function og_panels_table($displays, $group_node) {
$nid = $group_node->nid;
moshe weitzman
committed
$form['#tree'] = TRUE; // #tree must be true in order to separate out the entries in the weight field
moshe weitzman
committed
foreach ($displays as $display) {
moshe weitzman
committed
$item['page_title'] = array('#value' => l($display->page_title, "node/$nid/$display->path"));
$item['weight'] = array('#type' => 'weight', '#default_value' => $display->weight);
$item['edit content'] = array('#value' => l(t('Edit content'), "node/$nid/og_panels/$display->did/panel_content", array(), drupal_get_destination()));
$item['change layout'] = array('#value' => l(t('Change layout'), "node/$nid/og_panels/$display->did/panel_layout"));
$item['edit layout settings'] = array('#value' => l(t('Edit layout settings'), "node/$nid/og_panels/$display->did/panel_settings"));
$item['edit page'] = array('#value' => l(t('Edit page'), "node/$nid/og_panels/form/$display->did", array(), drupal_get_destination()));
$item['delete page'] = array('#value' => l(t('Delete page'), "node/$nid/og_panels/$display->did/delete", array(), drupal_get_destination()));
moshe weitzman
committed
moshe weitzman
committed
$form['displays'][$display->did] = $item;
// Store the default_page for later.
if ($display->default_page == 1) {
$default_page = $display->did;
}
// Prepare the options for the radios.
$options[$display->did] = '';
moshe weitzman
committed
}
moshe weitzman
committed
moshe weitzman
committed
$form['default_page'] = array(
'#type' => 'radios',
'#options' => $options,
'#default_value' => $default_page,
);
moshe weitzman
committed
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings'),
moshe weitzman
committed
);
moshe weitzman
committed
$form['group_node'] = array('#type' => 'value', '#value' => $group_node);
return $form;
}
moshe weitzman
committed
/**
* Wrangle the $form into a tabular listing of pages.
*
* @ingroup Themeable functions
*
* @return void
**/
moshe weitzman
committed
function theme_og_panels_table($form) {
moshe weitzman
committed
foreach (element_children($form['displays']) as $did) {
moshe weitzman
committed
if (is_numeric($did)) {
$rows[] = array(
drupal_render($form['default_page'][$did]),
moshe weitzman
committed
drupal_render($form['displays'][$did]['page_title']),
drupal_render($form['displays'][$did]['weight']),
drupal_render($form['displays'][$did]['edit content']),
drupal_render($form['displays'][$did]['change layout']),
drupal_render($form['displays'][$did]['edit layout settings']),
drupal_render($form['displays'][$did]['edit page']),
drupal_render($form['displays'][$did]['delete page']),
moshe weitzman
committed
);
}
}
$output = drupal_render($form);
moshe weitzman
committed
$header = array(t('Home page'), t('Title'), t('Weight'), array('align' => 'center', 'colspan' => 5, 'data' => t('Operations')));
moshe weitzman
committed
return theme('table', $header, $rows). $output;
}
function og_panels_table_submit($form_id, $form_values) {
moshe weitzman
committed
db_query("UPDATE {og_panels} SET default_page = 0 WHERE nid = %d", $form_values['group_node']->nid);
foreach ($form_values['displays'] as $did => $settings) {
$default = $did == $form_values['default_page'] ? TRUE : FALSE;
$sql = "UPDATE {og_panels} SET weight = %d, default_page = %d WHERE did = %d";
db_query($sql, $settings['weight'], $default, $did);
}
drupal_set_message(t('Updated panels configuration.'));
moshe weitzman
committed
}
moshe weitzman
committed
/**
moshe weitzman
committed
* A menu callback. Renders an og_panel based upon its display ID.
moshe weitzman
committed
*
* @return void
**/
function og_panels_page($did, $group_node, $title = NULL) {
$og_panel = og_panels_get_one_by_display($did);
// Set breadcrumb and title on non group nodes
if ($title) {
$bc[] = l(t('Home'), "");
$bc[] = l(t('Groups'), "og");
if (!$og_panel->default_page) {
$bc[] = l($group_node->title, "node/$group_node->nid");
}
// $bc[] = array('path' => "node/$og_panel->nid/$og_panel->path", 'title' => $og_panel->page_title);
// I tried MSL but it let me down. again.
// menu_set_location($bc);
drupal_set_breadcrumb($bc);
// Mark node as read and show feed icon for any group panel page (how to do this better?)
drupal_add_feed(url("node/$group_node->nid/feed"), t('@name at @site', array('@name' => $group_node->title, '@site' => variable_get('site_name', 'drupal'))));
node_tag_new($group_node->nid);
$allargs = func_get_args();
$args = array_slice($allargs, 3);
moshe weitzman
committed
$display = og_panels_load_display($did, $group_node);
$display->args = $args;
moshe weitzman
committed
$output = panels_render_display($display);
moshe weitzman
committed
// We print instead of return in order to allow blocks to be suppressed.
print theme('page', $output, $og_panel->show_blocks);
moshe weitzman
committed
}
moshe weitzman
committed
/**
* Add/edit an og_panel.
*
* @return void
**/
moshe weitzman
committed
function og_panels_form($group_node, $did = NULL) {
moshe weitzman
committed
if (!is_null($did)) {
moshe weitzman
committed
$display = og_panels_get_one_by_display($did);
}
else {
$display = new stdClass;
}
moshe weitzman
committed
$form['page_title'] = array(
'#title' => t('Page title'),
'#type' => 'textfield',
'#required' => $display->default_page ? FALSE : TRUE,
'#default_value' => $display->page_title,
'#description' => t('This is the title of the page and of the tab.'),
'#size' => 32,
);
moshe weitzman
committed
global $base_url;
$field_prefix = "$base_url/node/$group_node->nid/";
moshe weitzman
committed
$form[$display->default_page ? 'path_placeholder' : 'path'] = array(
moshe weitzman
committed
'#title' => t('Path'),
'#type' => 'textfield',
'#default_value' => $display->default_page ? '' : $display->path,
moshe weitzman
committed
'#field_prefix' => $field_prefix,
moshe weitzman
committed
'#required' => $display->default_page ? FALSE : TRUE,
moshe weitzman
committed
'#description' => $display->default_page ? t('This page is currently your default group home page and has no configurable path.') : '',
moshe weitzman
committed
'#disabled' => $display->default_page,
'#size' => 32,
);
moshe weitzman
committed
if ($display->default_page) {
$form['path'] = array(
'#type' => 'hidden',
'#value' => $display->path,
);
}
moshe weitzman
committed
$form['show_blocks'] = array(
'#title' => t('Show blocks'),
'#type' => 'checkbox',
'#default_value' => isset($display->show_blocks) ? $display->show_blocks : TRUE,
moshe weitzman
committed
'#description' => t('If unchecked, the standard group blocks will not be shown unless you place them into your page content. This gives admin more control over page presentation.'),
moshe weitzman
committed
);
moshe weitzman
committed
$form['published'] = array(
'#type' => 'checkbox',
'#title' => t('Published'),
'#default_value' => $display->published,
'#description' => t('If unchecked, this page is only accessible by group or site administrators. Thats useful while you are configuring the page.'),
);
$form['submit'] = array(
'#type' => 'submit',
moshe weitzman
committed
'#value' => $did ? t('Update page') : t('Create page'),
moshe weitzman
committed
);
$form['did'] = array('#type' => 'value', '#value' => $did);
$form['nid'] = array('#type' => 'value', '#value' => $group_node->nid);
return $form;
}
moshe weitzman
committed
/**
* Return an array of all og_panels attached to the given nid.
*
* @param int $nid
* @return array $rows
* An associative array keyed by the $did of the og_panel
*/
function og_panels_get_all($nid) {
$sql = "SELECT * FROM {og_panels} WHERE nid = %d ORDER BY default_page DESC, weight ASC";
moshe weitzman
committed
$result = db_query($sql, $nid);
while ($row = db_fetch_object($result)) {
$rows[$row->did] = $row;
}
moshe weitzman
committed
if (isset($rows)) {
return $rows;
}
return array();
moshe weitzman
committed
}
moshe weitzman
committed
/**
* Load an og_panels object.
*
* @param int $did
* @return object $og_panel
*/
moshe weitzman
committed
function og_panels_get_one_by_display($did) {
$sql = "SELECT * FROM {og_panels} WHERE did = %d";
$result = db_query($sql, $did);
return db_fetch_object($result);
}
moshe weitzman
committed
/**
* Load the default og_panels object, if any, for the given nid.
*
* @param int $nid
* @return mixed $og_panel
* Either returns the og_panel object, or FALSE if no default panel was found for the nid
*/
moshe weitzman
committed
function og_panels_get_one_by_nid_default($nid) {
$sql = "SELECT * FROM {og_panels} WHERE nid = %d AND default_page = 1";
$result = db_query($sql, $nid);
moshe weitzman
committed
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
$og_panel = db_fetch_object($result);
return is_object($og_panel) ? $og_panel : FALSE;
}
/**
* Load an og_panel's display information.
*
* Loads a panels display object with various parameters, depending on the information passed into the load function.
*
* @param int $did
* The did of the panels display.
* @param object $group_node = NULL
* The node object for the group to which the panel is attached.
* @param bool $ct = FALSE
* If TRUE, content_types are also loaded into the $display object
*
* @return mixed
* Either returns a display object, or FALSE if no display was found with the parameters provided.
*/
function og_panels_load_display($did, $group_node = NULL, $ct = FALSE) {
panels_load_include('plugins');
$display = panels_load_display($did);
if (is_object($group_node)) {
$display->context = array('og_panels' => panels_context_create('group', $group_node));
if ($ct) {
panels_load_include('common');
$display->content_types = panels_common_get_allowed_types('og_panels', $display->context);
}
}
return is_object($display) ? $display : FALSE;
}
function og_panels_form_validate($form_id, $form_values, $form) {
$pathblacklist = array('view', 'edit', 'delete', 'outline', 'load', 'render', 'clone');
if (in_array($form_values['path'], $pathblacklist)) {
form_error($form['path'], t('%path is a reserved system path, and cannot be used for a group page. Please enter another path.', array('%path' => $form_values['path'])));
}
else if (preg_match("/[^A-Za-z0-9-]/", $form_values['path'])) {
form_error($form['path'], t("Panel paths may only contain alphanumeric characters and dashes."));
}
else if (db_result(db_query("SELECT path FROM {og_panels} WHERE path = '%s' AND did <> %d AND nid = %d", $form_values['path'], $form_values['did'], $form_values['nid']))) {
form_error($form['path'], t("That path is currently in use by another one of your group's pages. Please enter another path."));
}
moshe weitzman
committed
}
moshe weitzman
committed
/**
* INSERT or UPDATE a new og_panel. If insert, redirect to layout form.
*
* @return void
**/
moshe weitzman
committed
function og_panels_form_submit($form_id, $form_values) {
if ($form_values['did']) {
moshe weitzman
committed
$sql = "UPDATE {og_panels} SET page_title='%s', path='%s', published=%d, show_blocks=%d WHERE did = %d";
db_query($sql, $form_values['page_title'], $form_values['path'], $form_values['published'], $form_values['show_blocks'], $form_values['did']);
drupal_set_message(t('Group page updated.'));
moshe weitzman
committed
}
else {
// Create a new display and record that.
$display = panels_new_display();
panels_save_display($display);
moshe weitzman
committed
$sql = "INSERT INTO {og_panels} (did, nid, page_title, path, published, show_blocks) VALUES (%d, %d, '%s', '%s', %d, %d)";
db_query($sql, $display->did, $form_values['nid'], $form_values['page_title'], $form_values['path'], $form_values['published'], $form_values['show_blocks']);
drupal_set_message(t('Group page created.'));
return 'node/'. $form_values['nid']. "/og_panels/$display->did/panel_layout";
moshe weitzman
committed
}
}
function og_panels_set_breadcrumb($section, $group_node = NULL) {
switch ($section) {
case 'panel_edit':
$bc[] = l(t('Home'), '');
moshe weitzman
committed
$bc[] = l(t('Pages'), "node/$group_node->nid/og_panels");
}
drupal_set_breadcrumb($bc);
}
moshe weitzman
committed
function og_panels_nodeapi($node, $op) {
switch ($op) {
case 'delete':
if ($og_panels = og_panels_get_all($node->nid)) {
foreach ($og_panels as $og_panel) {
panels_delete_display($og_panel->did);
}
$sql = "DELETE FROM {og_panels} WHERE nid = %d";
db_query($sql, $node->nid);
drupal_set_message(t('Organic groups panel pages deleted.'));
moshe weitzman
committed
}
break;
}
}
moshe weitzman
committed
// ---------------------------------------------------------------------------
// Meat of the Panels API; almost completely passing through to panels.module
/**
* Pass through to the panels layout editor.
moshe weitzman
committed
*
* @param int $did
* the $did of the og_panel to be edited.
*
* @param object $group_node
* the node object to which the og_panel is attached.
moshe weitzman
committed
*/
function og_panels_edit_layout($did, $group_node) {
og_panels_set_breadcrumb('panel_edit', $group_node);
moshe weitzman
committed
$display = og_panels_load_display($did, $group_node); // TODO I don't believe that having the context present is necessary for editing the layout.
moshe weitzman
committed
return panels_edit_layout($display, t('Save'), "node/$group_node->nid/og_panels");
}
/**
* Pass through to the panels layout settings editor.
moshe weitzman
committed
*
* @param int $did
* the $did of the og_panel to be edited.
*
* @param object $group_node
* the node object to which the og_panel is attached.
moshe weitzman
committed
*/
function og_panels_edit_layout_settings($did, $group_node) {
og_panels_set_breadcrumb('panel_edit', $group_node);
moshe weitzman
committed
$display = og_panels_load_display($did);
moshe weitzman
committed
return panels_edit_layout_settings($display, t('Save'), "node/$group_node->nid/og_panels");
}
/**
* Pass through to the panels content editor.
moshe weitzman
committed
*
* @param int $did
* the $did of the og_panel to be edited.
*
* @param object $group_node
* the node object to which the og_panel is attached.
moshe weitzman
committed
*/
function og_panels_edit_content($did, $group_node) {
og_panels_set_breadcrumb('panel_edit', $group_node);
moshe weitzman
committed
$display = og_panels_load_display($did, $group_node, TRUE);
moshe weitzman
committed
// Print this with theme('page') so that blocks are disabled while editing a display.
// This is important because negative margins in common block layouts (i.e, Garland)
// messes up the drag & drop.
moshe weitzman
committed
print theme('page', panels_edit($display, "node/$group_node->nid/og_panels", $display->content_types), FALSE);
moshe weitzman
committed
}
moshe weitzman
committed
function og_panels_admin_content() {
panels_load_include('common');
return drupal_get_form('panels_common_settings', 'og_panels');
}
moshe weitzman
committed
/**
* Implementation of hook_panels_contexts()
*
*/
function og_panels_panels_contexts() {
moshe weitzman
committed
include_once './'. drupal_get_path('module', 'og_panels') .'/includes/groupcontext.inc';
moshe weitzman
committed
$args['group'] = array(
'title' => t("Group"),
'description' => t('A node object that is flagged as an OG group type.'),
'context' => 'og_panels_context_create_group',
'settings form' => 'og_panels_context_group_settings_form',
'settings form validate' => 'og_panels_context_group_settings_form_validate',
'keyword' => 'group',
'context name' => 'group',
);
return $args;
}
/**
* Implementation of hook_panels_content_types()
*/
moshe weitzman
committed
function og_panels_panels_content_types() {
include_once './'. drupal_get_path('module', 'og_panels') .'/includes/groupcontent.inc';
$items['og_mission'] = array(
'title' => t('OG mission'),
'content_types' => 'og_panels_ct_list_mission',
'single' => TRUE, // only provides a single content type
'render callback' => 'og_panels_ct_render_callback_mission',
// 'add callback' => 'og_panels_content_types_add_callback',
// 'edit callback' => 'og_panels_content_types_edit_callback',
'title callback' => 'og_panels_ct_title_callback_mission',
// 'add submit callback' => 'panels_admin_submit_group',
// 'edit submit callback' => 'panels_admin_submit_group',
// 'validate callback' => 'panels_admin_validate_group',
);
$items['og_description'] = array(
'title' => t('OG description'),
'content_types' => 'og_panels_ct_list_description',
'single' => TRUE, // only provides a single content type
'render callback' => 'og_panels_ct_render_callback_description',
'title callback' => 'og_panels_ct_title_callback_description',
moshe weitzman
committed
);
$items['og_subscribers'] = array(
'title' => t('OG members'),
'content_types' => 'og_panels_ct_list_subscribers',
'single' => TRUE, // only provides a single content type
'render callback' => 'og_panels_ct_render_callback_subscribers',
'add callback' => 'og_panels_content_types_addedit_callback_subscribers',
'edit callback' => 'og_panels_content_types_addedit_callback_subscribers',
'title callback' => 'og_panels_ct_title_callback_subscribers',
'add validate callback' => 'og_panels_content_types_validate_callback_subscribers',
'edit validate callback' => 'og_panels_content_types_validate_callback_subscribers',
);
if (module_exists('search')) {
$items['og_search'] = array(
'title' => t('Group search'),
'content_types' => 'og_panels_ct_list_search',
'single' => TRUE, // only provides a single content type
'render callback' => 'og_panels_ct_render_callback_search',
'title callback' => 'og_panels_ct_title_callback_search',
);
}
if (og_is_picture()) {
$items['og_faces'] = array(
'title' => t('OG faces'),
'content_types' => 'og_panels_ct_list_faces',
'single' => TRUE, // only provides a single content type
'render callback' => 'og_panels_ct_render_callback_faces',
'add callback' => 'og_panels_content_types_addedit_callback_faces',
'edit callback' => 'og_panels_content_types_addedit_callback_faces',
'title callback' => 'og_panels_ct_title_callback_faces',
'add validate callback' => 'og_panels_content_types_validate_callback_faces',
'edit validate callback' => 'og_panels_content_types_validate_callback_faces',
);
}
moshe weitzman
committed
return $items;
moshe weitzman
committed
}
moshe weitzman
committed
// An implementation of hook_panels_relationships.
moshe weitzman
committed
function og_panels_panels_relationships() {
include_once './'. drupal_get_path('module', 'og_panels') .'/includes/grouprelationships.inc';
moshe weitzman
committed
$args['group_from_node'] = array(
'title' => t("Group from node"),
'keyword' => 'group',
'description' => t('Adds a group from a node context; if multiple groups are associated with a node, this will get the "first" group only.'),
'required context' => new panels_required_context(t('Node'), 'node'),
'context' => 'panels_group_from_node_context',
);
return $args;
}
moshe weitzman
committed
// An implementation of hook_panels_block_info. We have to prefix with 'og' and not 'og_panels'.
function og_panels_block_info($module, $delta, &$info) {
switch ($delta) {
case 2:
// Provide alternate versions of these content items
unset($info);
break;
default:
$info['icon'] = 'user-multiple.png';
$info['required context'] = new panels_required_context(t('Group'), 'group');
$info['path'] = drupal_get_path('module', 'og_panels'). '/';
$info['category'] = t('Organic groups');
break;
}
// These blocks do not need group context.
if ($delta == 3 || $delta == 6) {
unset($info['required context']);
}