panels_profile/0000755000175000017500000000000010710765454014361 5ustar streslerstreslerpanels_profile/CVS/0000755000175000017500000000000010706462157015013 5ustar streslerstreslerpanels_profile/CVS/Root0000644000175000017500000000010010706462157015650 0ustar streslerstresler:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib panels_profile/CVS/Repository0000644000175000017500000000005110706462157017111 0ustar streslerstreslercontributions/modules/panels/panels_node panels_profile/CVS/Entries0000644000175000017500000000035010706462157016345 0ustar streslerstresler/panels_node.info/1.1.2.1/Wed Aug 29 22:02:04 2007//TDRUPAL-5--2-0-ALPHA11 /panels_node.install/1.1.2.3/Mon Oct 1 20:42:21 2007//TDRUPAL-5--2-0-ALPHA11 /panels_node.module/1.1.2.4/Tue Sep 11 22:08:24 2007//TDRUPAL-5--2-0-ALPHA11 D panels_profile/CVS/Tag0000644000175000017500000000002710706462157015450 0ustar streslerstreslerNDRUPAL-5--2-0-ALPHA11 panels_profile/panels_node.module0000644000175000017500000002032510706500017020044 0ustar streslerstresler 'node/add/panel-node', 'title' => t('Create panel-node'), 'access' => user_access('create panel-nodes'), ); $items[] = array( 'path' => 'admin/panels/panel-node', 'title' => t('Panel nodes settings'), 'description' => t('Configure panel node content availability.'), 'access' => user_access('administer panel-nodes'), 'callback' => 'panels_node_settings', ); } else { if (arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); if ($node && $node->type == 'panel' && node_access('update', $node)) { $base = 'node/' . arg(1) . '/panel_'; $items[] = array( 'path' => $base . 'layout', 'title' => t('Panel layout'), 'access' => TRUE, 'callback' => 'panels_node_edit_layout', 'callback arguments' => array($node), 'weight' => 2, 'type' => MENU_LOCAL_TASK, ); $display = panels_load_display($node->panels_node['did']); $layout = panels_get_layout($display->layout); if (!empty($layout['settings form'])) { $items[] = array( 'path' => $base . 'settings', 'title' => t('Panel layout settings'), 'access' => TRUE, 'callback' => 'panels_node_edit_layout_settings', 'callback arguments' => array($node), 'weight' => 2, 'type' => MENU_LOCAL_TASK, ); } $items[] = array( 'path' => $base . 'content', 'title' => t('Panel content'), 'access' => TRUE, 'callback' => 'panels_node_edit_content', 'callback arguments' => array($node), 'weight' => 3, 'type' => MENU_LOCAL_TASK, ); } } } return $items; } // --------------------------------------------------------------------------- // Node hooks /** * Implementation of hook_node_info */ function panels_node_node_info() { return array( 'panel' => array( 'name' => t('Panel'), 'module' => 'panels_node', 'body_label' => t('Teaser'), 'description' => t("A panel a page layout broken up into rows and columns."), ) ); } /** * Implementation of hook_access */ function panels_node_access($op, $node = NULL) { if (user_access('administer panel-nodes')) { return TRUE; } if ($op == 'create' && user_access('create panel-nodes')) { return TRUE; } if ($op == 'update' && $node->uid == $user->uid && user_access('edit own panel-nodes')) { return TRUE; } } /** * Implementation of hook_form. */ function panels_node_form(&$node, &$param) { $form['panels_node']['#tree'] = TRUE; if (!$node->nid) { // Grab our selected layout from arg(3). If it doesn't exist, present them with // a list to pick from. $layout = arg(3); if (is_null($layout)) { $form['markup']['#value'] = ''; $layouts = panels_get_layouts(); foreach ($layouts as $id => $layout) { $form['markup']['#value'] .= panels_print_layout_link($id, $layout, $_GET['q'] . '/' . $id); } $form['markup']['#value'] .= '
'; return $form; } else { $form['panels_node']['layout'] = array( '#type' => 'value', '#value' => $layout, ); } } $type = node_get_types('type', $node); $form['title'] = array( '#type'=> 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, ); if (!empty($type->body_label)) { $form['body'] = array( '#type' => 'textarea', '#title' => check_plain($type->body_label), '#rows' => 10, '#required' => TRUE, '#description' => t('The teaser is a piece of text to describe when the panel is listed (such as when promoted to front page); the actual content will only be displayed on the full node view.'), '#default_value' => $node->body, ); } // drupal_set_message('
' . check_plain(var_export($node, true)) . '
'); $css_id = ''; if (!empty($node->panels_node['css_id'])) { $css_id = $node->panels_node['css_id']; } $form['panels_node']['css_id'] = array( '#type' => 'textfield', '#title' => t('CSS ID'), '#size' => 30, '#description' => t('An ID that can be used by CSS to style the panel.'), '#default_value' => $css_id, ); return $form; } /** * Implementation of hook_validate() */ function panels_node_validate($node) { if (!$node->nid && empty($node->panels_node['layout'])) { form_set_error('', t('Please select a layout.')); } } /** * Implementation of hook_load() * * Panels does not use revisions for nodes because that would open us up to have completely * separate displays, and we'd have to copy them, and that's going to be a LOT of data. */ function panels_node_load($node) { // We shortcut this because only in some really drastic corruption circumstance will this // not work. $additions['panels_node'] = db_fetch_array(db_query("SELECT * FROM {panels_node} WHERE nid = %d", $node->nid)); return $additions; } /** * Implementation of hook_insert() */ function panels_node_insert(&$node) { // Create a new display and record that. $display = panels_new_display(); $display->layout = $node->panels_node['layout']; panels_save_display($display); $css_id = $node->panels_node['css_id']; db_query("INSERT INTO {panels_node} (nid, did, css_id) VALUES (%d, %d, '%s')", $node->nid, $display->did, $node->panels_node['css_id']); $node->panels_node['did'] = $display->did; } /** * Implementation of hook_update() */ function panels_node_update($node) { db_query("UPDATE {panels_node} SET css_id = '%s' WHERE nid = %d", $node->panels_node['css_id'], $node->nid); } /** * Implementation of hook_view() */ function panels_node_view($node, $teaser = FALSE, $page = FALSE) { if ($teaser) { // Do the standard view for teaser. $node = node_prepare($node, $teaser); } else { $display = panels_load_display($node->panels_node['did']); $display->css_id = $node->panel_node['css_id']; $node->content['body'] = array( '#value' => panels_render_display($display), '#weight' => 0, ); } return $node; } // --------------------------------------------------------------------------- // Administrative pages /** * Settings for panel nodes */ function panels_node_settings() { require_once drupal_get_path('module', 'panels') . '/includes/common.inc'; return drupal_get_form('panels_common_settings', 'panels_node'); } // --------------------------------------------------------------------------- // Meat of the Panels API; almost completely passing through to panels.module /** * Pass through to the panels layout editor. */ function panels_node_edit_layout($node) { $display = panels_load_display($node->panels_node['did']); return panels_edit_layout($display, t('Save'), "node/$node->nid/panel_layout"); } /** * Pass through to the panels layout settings editor. */ function panels_node_edit_layout_settings($node) { $display = panels_load_display($node->panels_node['did']); return panels_edit_layout_settings($display, t('Save'), "node/$node->nid/panel_settings"); } /** * Pass through to the panels content editor. */ function panels_node_edit_content($node) { $display = panels_load_display($node->panels_node['did']); require_once drupal_get_path('module', 'panels') . '/includes/common.inc'; $content_types = panels_common_get_allowed_types('panels_node'); // 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. print theme('page', panels_edit($display, "node/$node->nid/panel_content", $content_types), FALSE); } panels_profile/panels_profile.info0000644000175000017500000000023710706467476020252 0ustar streslerstresler; $Id$ name = Panel profiles description = Create user profiles that are divided into areas with selectable content. package = "Panels" dependencies = panels panels_profile/panels_profile.install0000644000175000017500000000165210710765357020761 0ustar streslerstresler 'node/add/panel-profile', 'title' => t('Create a new profile page'), 'access' => user_access('create panel-profiles'), ); $items[] = array( 'path' => 'admin/panels/panel-profiles', 'title' => t('Panel profiles settings'), 'description' => t('Configure panel profiles content availability.'), 'access' => user_access('administer panel-profiles'), 'callback' => 'panels_profiles_settings', ); } else { //The paths to let users alter their own layouts and content displayed on their pages if (arg(0) == 'user' && is_numeric(arg(1))) { $user = user_load($user = array('uid' => arg(1),)); if ($user) { $base = 'user/' . arg(1) . '/panel_'; $items[] = array( 'path' => $base . 'layout', 'title' => t('Profile page layout'), 'access' => TRUE, 'callback' => 'panels_profile_edit_layout', //does this need the full $user object, is this extraneous loading? 'callback arguments' => array($user), 'weight' => 2, 'type' => MENU_LOCAL_TASK, ); //this doesn't exist yet in the $user object - figure out how panels_node added it to the node object $display = panels_load_display($user->panels_profile['did']); $layout = panels_get_layout($display->layout); //layout settings can stay the same more or less if (!empty($layout['settings form'])) { $items[] = array( 'path' => $base . 'settings', 'title' => t('Panel layout settings'), 'access' => TRUE, 'callback' => 'panels_profile_edit_layout_settings', //again, it seems like we shouldn't need the full user object here, just the uid 'callback arguments' => array($user), 'weight' => 2, 'type' => MENU_LOCAL_TASK, ); } $items[] = array( 'path' => $base . 'content', 'title' => t('Profile content'), 'access' => TRUE, 'callback' => 'panels_profile_edit_content', 'callback arguments' => array($user), 'weight' => 3, 'type' => MENU_LOCAL_TASK, ); } } } return $items; } /************************* ****** User Hooks ******** *************************/ /** * Implementation of hook_node_info */ /** Not applicable, probably delete function panels_node_node_info() { return array( 'panel' => array( 'name' => t('Panel'), 'module' => 'panels_node', 'body_label' => t('Teaser'), 'description' => t("A panel a page layout broken up into rows and columns."), ) ); } **/ /** * Implementation of Access checking */ //We aren't dealing with nodes, thus, don't want to use hook_access, but we do want a very similar set of permissions on how users can interact with their profiles, based on user_access. /** function panels_profile_access($op, $node = NULL) { if (user_access('administer panel-profiles')) { return TRUE; } if ($op == 'create' && user_access('create panel-nodes')) { return TRUE; } if ($op == 'update' && $user->uid > 0 && user_access('edit own panel-profile')) { return TRUE; } } **/ /** * Implementation of hook_form. */ //I don't know what we need but a node-editing form ain't it. /** function panels_profile_form(&$node, &$param) { $form['panels_node']['#tree'] = TRUE; if (!$node->nid) { // Grab our selected layout from arg(3). If it doesn't exist, present them with // a list to pick from. $layout = arg(3); if (is_null($layout)) { $form['markup']['#value'] = ''; $layouts = panels_get_layouts(); foreach ($layouts as $id => $layout) { $form['markup']['#value'] .= panels_print_layout_link($id, $layout, $_GET['q'] . '/' . $id); } $form['markup']['#value'] .= '
'; return $form; } else { $form['panels_node']['layout'] = array( '#type' => 'value', '#value' => $layout, ); } } $type = node_get_types('type', $node); $form['title'] = array( '#type'=> 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, ); if (!empty($type->body_label)) { $form['body'] = array( '#type' => 'textarea', '#title' => check_plain($type->body_label), '#rows' => 10, '#required' => TRUE, '#description' => t('The teaser is a piece of text to describe when the panel is listed (such as when promoted to front page); the actual content will only be displayed on the full node view.'), '#default_value' => $node->body, ); } // drupal_set_message('
' . check_plain(var_export($node, true)) . '
'); $css_id = ''; if (!empty($node->panels_node['css_id'])) { $css_id = $node->panels_node['css_id']; } $form['panels_node']['css_id'] = array( '#type' => 'textfield', '#title' => t('CSS ID'), '#size' => 30, '#description' => t('An ID that can be used by CSS to style the panel.'), '#default_value' => $css_id, ); return $form; } **/ /** * Implementation of hook_validate() */ /** No valiation until I know what we are validating. function panels_profile_validate($node) { if (!$node->nid && empty($node->panels_node['layout'])) { form_set_error('', t('Please select a layout.')); } } **/ /** * Implementation of hook_user() * **/ function panels_profile_user($op, &$edit, &$account, &$category = NULL) { //adding the info from our custom table to the user object. switch($op) { case 'load': $account->panels_profile = db_fetch_array(db_query("SELECT * FROM {panels_profile WHERE uid = %d", $account->uid)); break; //Create a new display and save it default: break; } } /** * Implementation of hook_insert() */ /** take care of with hook_user case function panels_node_insert(&$node) { // Create a new display and record that. $display = panels_new_display(); $display->layout = $node->panels_node['layout']; panels_save_display($display); $css_id = $node->panels_node['css_id']; db_query("INSERT INTO {panels_node} (nid, did, css_id) VALUES (%d, %d, '%s')", $node->nid, $display->did, $node->panels_node['css_id']); $node->panels_node['did'] = $display->did; } /** * Implementation of hook_update() */ /** take care of with hook user case function panels_node_update($node) { db_query("UPDATE {panels_node} SET css_id = '%s' WHERE nid = %d", $node->panels_node['css_id'], $node->nid); } **/ /** * Implementation of hook_view() */ /** Again function panels_node_view($node, $teaser = FALSE, $page = FALSE) { if ($teaser) { // Do the standard view for teaser. $node = node_prepare($node, $teaser); } else { $display = panels_load_display($node->panels_node['did']); $display->css_id = $node->panel_node['css_id']; $node->content['body'] = array( '#value' => panels_render_display($display), '#weight' => 0, ); } return $node; } **/ /*********************************** *******Administrative pages********* ***********************************/ /** * Settings for panel profiles */ function panels_profile_settings() { require_once drupal_get_path('module', 'panels') . '/includes/common.inc'; return drupal_get_form('panels_common_settings', 'panels_profile'); } // --------------------------------------------------------------------------- // Meat of the Panels API; almost completely passing through to panels.module /** * Pass through to the panels layout editor. */ function panels_profile_layout($user) { $display = panels_load_display($user->panels_user['did']); return panels_edit_layout($display, t('Save'), "user/$user->uid/panel_layout"); } /** * Pass through to the panels layout settings editor. */ function panels_profile_edit_layout_settings($user) { $display = panels_load_display($user->panels_profile['did']); return panels_edit_layout_settings($display, t('Save'), "user/$user->uid/panel_settings"); } /** * Pass through to the panels content editor. */ function panels_profile_edit_content($user) { $display = panels_load_display($user->panels_node['did']); require_once drupal_get_path('module', 'panels') . '/includes/common.inc'; $content_types = panels_common_get_allowed_types('panels_profile'); // 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. print theme('page', panels_edit($display, "user/$user->uid/panel_content", $content_types), FALSE); }