/[drupal]/contributions/modules/bookmarks/bookmarks.admin.inc
ViewVC logotype

Diff of /contributions/modules/bookmarks/bookmarks.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5.2.6 by darthclue, Fri Jan 23 18:50:45 2009 UTC revision 1.5.2.7 by darthclue, Sun Jan 25 04:06:05 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: bookmarks.admin.inc,v 1.5.2.5 2009/01/23 16:14:35 darthclue Exp $  // $Id: bookmarks.admin.inc,v 1.5.2.4 2009/01/20 15:02:42 darthclue Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 304  function theme_bookmarks_overview_form($ Line 304  function theme_bookmarks_overview_form($
304  function bookmarks_edit_item(&$form_state, $type, $item, $menu) {  function bookmarks_edit_item(&$form_state, $type, $item, $menu) {
305    global $user;    global $user;
306    
307      if ($menu['menu_name'] == 'enumresuym') {
308        $menu['menu_name']='bookmarks-'. $user->uid;
309      }
310      // The item must belong to the current user or the current user must be editting one of the system menus and have the proper rights.
311      if (($menu['menu_name'] != $item['menu_name']) && $type == 'edit') {
312        if (!((($item['menu_name'] == 'bookmarks-presets') || ($item['menu_name'] == 'bookmarks-defaults')) && user_access('administer bookmarks'))) {
313          drupal_set_message('You do not have permission to edit that item.','error');
314          drupal_goto('bookmarks/mine');
315          return;
316        }
317      }
318    $form['bookmarks'] = array(    $form['bookmarks'] = array(
319      '#type' => 'fieldset',      '#type' => 'fieldset',
320      '#title' => t('Menu settings'),      '#title' => t('Menu settings'),
# Line 313  function bookmarks_edit_item(&$form_stat Line 324  function bookmarks_edit_item(&$form_stat
324      '#attributes' => array('class' => 'menu-item-form'),      '#attributes' => array('class' => 'menu-item-form'),
325      '#item' => $item,      '#item' => $item,
326    );    );
   if ($menu['menu_name']=='enumresuym') {  
     $menu['menu_name']='bookmarks-'. $user->uid;  
   }  
327    if ($type == 'add' || empty($item)) {    if ($type == 'add' || empty($item)) {
328      // This is an add form, initialize the menu link.      // This is an add form, initialize the menu link.
329      $item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu['menu_name'], 'weight' => 0, 'link_path' => '', 'options' => array(), 'module' => 'bookmarks', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0, 'newwindow' => 0);      $item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu['menu_name'], 'weight' => 0, 'link_path' => '', 'options' => array(), 'module' => 'bookmarks', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0, 'newwindow' => 0);
     if ($_GET['q']!='bookmarks/mine/add' && $_GET['q']!='bookmarks/mine/edit' && strpos($_GET['q'],'admin/build/bookmarks-customize/bookmarks-') === false) {  
       $item['link_path']=str_replace('bookmarks/mine/addpage/', '', $_GET['q']);  
       $menu_item = menu_get_item($item['link_path']);  
       $item['link_title'] = $menu_item['title'];  
     }  
330    }    }
331    if ($type == 'addpage') {    if ($type == 'addpage') {
332      // This is an add this page form, initialize the menu link.      // This is an add this page form, initialize the menu link.
333      $item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu['menu_name'], 'weight' => 0, 'link_path' => '', 'options' => array(), 'module' => 'bookmarks', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0, 'newwindow' => 0);      $item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu['menu_name'], 'weight' => 0, 'link_path' => '', 'options' => array(), 'module' => 'bookmarks', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0, 'newwindow' => 0);
334      if ($_GET['q']!='bookmarks/mine/add' && $_GET['q']!='bookmarks/mine/edit') {      $item['link_path']=drupal_get_normal_path(drupal_get_path_alias(str_replace('bookmarks/item/addpage/', '', $_GET['q'])));
335        $item['link_path']=drupal_get_normal_path(drupal_get_path_alias(str_replace('bookmarks/item/addpage/', '', $_GET['q'])));      $menu_item = menu_get_item($item['link_path']);
336        $menu_item = menu_get_item($item['link_path']);      $item['link_title'] = $menu_item['title'];
       $item['link_title'] = $menu_item['title'];  
     }  
337    }    }
338    foreach (array('link_path', 'mlid', 'module', 'has_children', 'options') as $key) {    foreach (array('link_path', 'mlid', 'module', 'has_children', 'options') as $key) {
339      $form['bookmarks'][$key] = array('#type' => 'value', '#value' => $item[$key]);      $form['bookmarks'][$key] = array('#type' => 'value', '#value' => $item[$key]);
# Line 350  function bookmarks_edit_item(&$form_stat Line 351  function bookmarks_edit_item(&$form_stat
351    }    }
352    if ($item['module'] == 'bookmarks') {    if ($item['module'] == 'bookmarks') {
353      $form['bookmarks']['link_path'] = array(      $form['bookmarks']['link_path'] = array(
354        '#type' => (($_GET['q']!='bookmarks/mine/add' && $_GET['q']!='bookmarks/mine/edit' && strpos($_GET['q'],'admin/build/bookmarks-customize/bookmarks-') === false) ? 'hidden' : 'textfield'),        '#type' => (($_GET['q']!='bookmarks/mine/add' && strpos($_GET['q'],'bookmarks/item/edit') === false && strpos($_GET['q'],'admin/build/bookmarks-customize/bookmarks-') === false) ? 'hidden' : 'textfield'),
355        '#title' => t('Path'),        '#title' => t('Path'),
356        '#default_value' => $path,        '#default_value' => $path,
357        '#description' => t('The path this bookmark links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page. Enter %folder to make this item a folder.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org', '%folder' => '<folder>')),        '#description' => t('The path this bookmark links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page. Enter %folder to make this item a folder.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org', '%folder' => '<folder>')),
# Line 722  function bookmarks_add_preset($item, $pl Line 723  function bookmarks_add_preset($item, $pl
723   * Helper function to add presets to the current users bookmarks.   * Helper function to add presets to the current users bookmarks.
724   */   */
725  function _bookmarks_add_preset($item, $plid, $depth) {  function _bookmarks_add_preset($item, $plid, $depth) {
   global $user;  
726    $item = menu_link_load($item['mlid']);    $item = menu_link_load($item['mlid']);
727      global $user;
728    
729    db_query("INSERT INTO {menu_links} (menu_name, plid, link_path, router_path, link_title, options, module, hidden, external, has_children, expanded, weight, depth, customized, p1, p2, p3, p4, p5, p6, p7, p8, p9, updated) SELECT 'bookmarks-%d', %d, link_path, router_path, link_title, options, 'bookmarks', hidden, external, has_children, expanded, 0, %d, customized, %d, %d, %d, %d, %d, %d, %d, %d, %d, updated FROM menu_links WHERE mlid=%d", $user->uid, $plid['p1'], $depth, $plid['p1'], $plid['p2'], $plid['p3'], $plid['p4'], $plid['p5'], $plid['p6'], $plid['p7'], $plid['p8'], $plid['p9'], $item['mlid']);    db_query("INSERT INTO {menu_links} (menu_name, plid, link_path, router_path, link_title, options, module, hidden, external, has_children, expanded, weight, depth, customized, p1, p2, p3, p4, p5, p6, p7, p8, p9, updated) SELECT 'bookmarks-%d', %d, link_path, router_path, link_title, options, 'bookmarks', hidden, external, has_children, expanded, 0, %d, customized, %d, %d, %d, %d, %d, %d, %d, %d, %d, updated FROM menu_links WHERE mlid=%d", $user->uid, $plid['p1'], $depth, $plid['p1'], $plid['p2'], $plid['p3'], $plid['p4'], $plid['p5'], $plid['p6'], $plid['p7'], $plid['p8'], $plid['p9'], $item['mlid']);
730    

Legend:
Removed from v.1.5.2.6  
changed lines
  Added in v.1.5.2.7

  ViewVC Help
Powered by ViewVC 1.1.3