/[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.9 by darthclue, Mon Oct 19 17:00:59 2009 UTC revision 1.5.2.10 by darthclue, Sat Nov 14 18:46:59 2009 UTC
# Line 129  function _bookmarks_overview_tree_form($ Line 129  function _bookmarks_overview_tree_form($
129          if ($item['module'] == 'bookmarks' || $item['updated'] == 1) {          if ($item['module'] == 'bookmarks' || $item['updated'] == 1) {
130            $operations['delete'] = l(t('delete'), $actionpaths .'item/delete/'. $item['mlid']);            $operations['delete'] = l(t('delete'), $actionpaths .'item/delete/'. $item['mlid']);
131          }          }
132            if ($menu['menu_name'] == 'bookmarks-defaults' || $menu['menu_name'] == 'bookmarks-presets') {
133              $operations['distribute'] = l(t('distribute'), 'admin/build/bookmarks/distribute/' . $item['mlid']);
134            }
135    
136          $form[$mlid]['operations'] = array();          $form[$mlid]['operations'] = array();
137          foreach ($operations as $op => $value) {          foreach ($operations as $op => $value) {
# Line 334  function bookmarks_edit_item(&$form_stat Line 337  function bookmarks_edit_item(&$form_stat
337      $item['link_path']=base64_decode(drupal_get_normal_path(drupal_get_path_alias(str_replace('bookmarks/item/addpage/', '', $_GET['q']))));      $item['link_path']=base64_decode(drupal_get_normal_path(drupal_get_path_alias(str_replace('bookmarks/item/addpage/', '', $_GET['q']))));
338      $menu_item = menu_get_item($item['link_path']);      $menu_item = menu_get_item($item['link_path']);
339      $item['link_title'] = $menu_item['title'];      $item['link_title'] = $menu_item['title'];
     $form['bookmarks']['redirect_after'] = array('#type' => 'hidden', '#value' => $item['link_path']);  
340    }    }
341    foreach (array('link_path', 'mlid', 'module', 'has_children', 'options') as $key) {    foreach (array('link_path', 'mlid', 'module', 'has_children', 'options') as $key) {
342      $form['bookmarks'][$key] = array('#type' => 'value', '#value' => $item[$key]);      $form['bookmarks'][$key] = array('#type' => 'value', '#value' => $item[$key]);
# Line 352  function bookmarks_edit_item(&$form_stat Line 354  function bookmarks_edit_item(&$form_stat
354    }    }
355    if ($item['module'] == 'bookmarks') {    if ($item['module'] == 'bookmarks') {
356      $form['bookmarks']['link_path'] = array(      $form['bookmarks']['link_path'] = array(
357        '#type' => (($_GET['q']!='bookmarks/mine/add' && strpos($_GET['q'],'bookmarks/item/edit') === false && strpos($_GET['q'], 'admin\/build\/bookmarks-customize/item/edit') === false && 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/item/edit') === false && strpos($_GET['q'],'admin/build/bookmarks-customize/bookmarks-') === false) ? 'hidden' : 'textfield'),
358        '#title' => t('Path'),        '#title' => t('Path'),
359        '#default_value' => $path,        '#default_value' => $path,
360        '#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 491  function bookmarks_edit_item_submit($for Line 493  function bookmarks_edit_item_submit($for
493    if (!menu_link_save($item)) {    if (!menu_link_save($item)) {
494      drupal_set_message(t('There was an error saving the menu link.'), 'error');      drupal_set_message(t('There was an error saving the menu link.'), 'error');
495    }    }
496      //If they are editing their menu, they should be doing so with the My Menu link.
497    //If the redirect_after value is set, send them there.    if (user_access('administer own bookmarks') && $item['menu_name']=='bookmarks-'. $user->uid) {
498    if ($item['redirect_after']) {      $form_state['redirect'] = 'bookmarks/mine';
     $form_state['redirect'] = $item['redirect_after'];  
499    }    }
500    else {    else {
501      //If they are editing their menu, they should be doing so with the My Menu link.      $form_state['redirect'] = 'admin/build/bookmarks-customize/'. $item['menu_name'];
     if (user_access('administer own bookmarks') && $item['menu_name']=='bookmarks-'. $user->uid) {  
       $form_state['redirect'] = 'bookmarks/mine';  
     }  
     else {  
       $form_state['redirect'] = 'admin/build/bookmarks-customize/'. $item['menu_name'];  
     }  
   }  
   
   //If this is an item on the defaults or presets menu then we should update all bookmark links.  
   //We don't modify other menus  
   if ($item['menu_name'] == 'bookmarks-presets' || $item['menu_name'] == 'bookmarks-defaults') {  
     $sql = "UPDATE {menu_links} set link_path = '%s' where menu_name like 'bookmarks-%' and link_path = '%s'";  
     $result = db_query($sql, $item['link_path'], $item['original_item']['link_path']);  
     menu_rebuild();  
502    }    }
503  }  }
504    
# Line 723  function bookmarks_item_delete_form_subm Line 710  function bookmarks_item_delete_form_subm
710  }  }
711    
712  /**  /**
713     * Menu callback for distributing defaults and presets to users.
714     */
715    function bookmarks_distribute($item, $plid = array('p1' => 0, 'p2' => 0, 'p3' => 0, 'p4' => 0, 'p5' => 0, 'p6' => 0, 'p7' => 0, 'p8' => 0, 'p9' => 0), $depth = 1) {
716      $output = '';
717      //Loop thru all users and add the specified menu item to each user menu.
718      $result = db_query("SELECT * FROM menu_bookmarks WHERE menu_name != 'bookmarks-defaults' AND menu_name != 'bookmarks-presets'");
719      while ($menu = db_fetch_object($result)) {
720        $user = user_load(str_replace('bookmarks-','',$menu->menu_name));
721        _bookmarks_add_preset($item, $plid, $depth, $user);
722        menu_cache_clear('bookmarks-' . $user->uid );
723      }
724    
725      drupal_set_message('The bookmark has been distributed to all users.');
726      drupal_goto('admin/build/bookmarks');
727      return '';
728    }
729    
730    /**
731   * Add presets to the current users bookmarks   * Add presets to the current users bookmarks
732   */   */
733  function bookmarks_add_preset($item, $plid = array('p1' => 0, 'p2' => 0, 'p3' => 0, 'p4' => 0, 'p5' => 0, 'p6' => 0, 'p7' => 0, 'p8' => 0, 'p9' => 0), $depth = 1) {  function bookmarks_add_preset($item, $plid = array('p1' => 0, 'p2' => 0, 'p3' => 0, 'p4' => 0, 'p5' => 0, 'p6' => 0, 'p7' => 0, 'p8' => 0, 'p9' => 0), $depth = 1) {
734    global $user;    global $user;
735    _bookmarks_add_preset($item, $plid, $depth);    _bookmarks_add_preset($item, $plid, $depth, $user);
736    
737    menu_cache_clear('bookmarks-' . $user->uid );    menu_cache_clear('bookmarks-' . $user->uid );
738    drupal_set_message('The preset has been added to your bookmarks.');    drupal_set_message('The preset has been added to your bookmarks.');
# Line 738  function bookmarks_add_preset($item, $pl Line 743  function bookmarks_add_preset($item, $pl
743  /**  /**
744   * Helper function to add presets to the current users bookmarks.   * Helper function to add presets to the current users bookmarks.
745   */   */
746  function _bookmarks_add_preset($item, $plid, $depth) {  function _bookmarks_add_preset($item, $plid, $depth, $user) {
747    $item = menu_link_load($item['mlid']);    $item = menu_link_load($item['mlid']);
   global $user;  
748    
749    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']);
750    

Legend:
Removed from v.1.5.2.9  
changed lines
  Added in v.1.5.2.10

  ViewVC Help
Powered by ViewVC 1.1.3