| 265 |
//Purge from navigation menu. We don't want these to show under Site Building / Bookmarks. |
//Purge from navigation menu. We don't want these to show under Site Building / Bookmarks. |
| 266 |
db_query("DELETE FROM {menu_links} WHERE link_title = '%s'", 'bookmarks-'. $user->uid); |
db_query("DELETE FROM {menu_links} WHERE link_title = '%s'", 'bookmarks-'. $user->uid); |
| 267 |
//Insert default bookmarks |
//Insert default bookmarks |
| 268 |
$result = db_query("SELECT m.mlid FROM {menu_links} m WHERE m.menu_name='defaults'"); |
$result = db_query("SELECT m.mlid FROM {menu_links} m WHERE m.menu_name='bookmarks-defaults'"); |
| 269 |
$mobjs = array(); |
$mobjs = array(); |
| 270 |
while ($mlid = db_fetch_object($result)) { |
while ($mlid = db_fetch_object($result)) { |
| 271 |
$mlid = menu_link_load($mlid->mlid); |
$mlid = menu_link_load($mlid->mlid); |
| 289 |
} |
} |
| 290 |
} |
} |
| 291 |
// Add admin options to bottom of block. |
// Add admin options to bottom of block. |
| 292 |
$block['content'] .= '<ul class="menu no-dhtml">'; |
$block['content'] .= '<div style="text-align:center;">'; |
|
$block['content'] .= '<li class="expanded active-trail no-dhtml">Options'; |
|
|
$block['content'] .= '<ul class="menu no-dhtml">'; |
|
| 293 |
$path = drupal_urlencode(drupal_get_normal_path(drupal_get_path_alias($_GET['q']))); |
$path = drupal_urlencode(drupal_get_normal_path(drupal_get_path_alias($_GET['q']))); |
| 294 |
if (!empty($path)) { |
if (!empty($path)) { |
| 295 |
$block['content'] .= '<li class="leaf first no-dhtml">'. l('Add this page', 'bookmarks/item/addpage/'. $path) .'</li>'; |
$block['content'] .= l(t('Add this page'), 'bookmarks/item/addpage/'. $path); |
| 296 |
$block['content'] .= '<li class="leaf last no-dhtml">'. l('Customize', 'bookmarks/mine') .'</li>'; |
$block['content'] .= ' | '. l(t('Customize'), 'bookmarks/mine'); |
| 297 |
} |
} |
| 298 |
else { |
else { |
| 299 |
$block['content'] .= '<li class="leaf no-dhtml">'. l('Customize', 'bookmarks/mine') .'</li>'; |
$block['content'] .= l(t('Customize'), 'bookmarks/mine'); |
| 300 |
} |
} |
| 301 |
$block['content'] .= '</ul>'; |
$block['content'] .= '</div>'; |
|
$block['content'] .= '</li></ul>'; |
|
| 302 |
|
|
| 303 |
return $block; |
return $block; |
| 304 |
} |
} |
| 350 |
} |
} |
| 351 |
return $rows; |
return $rows; |
| 352 |
} |
} |
| 353 |
|
|
| 354 |
|
/** |
| 355 |
|
* Alter menu item editing form so that we can update bookmarks if menu items are changed. |
| 356 |
|
*/ |
| 357 |
|
function bookmarks_form_alter(&$form, $form_state, $form_id) { |
| 358 |
|
if ($form_id=='menu_edit_item' && isset($form['menu']['#item'])) { |
| 359 |
|
$form['#submit'][] = 'bookmarks_menu_edit_item_submit'; |
| 360 |
|
} |
| 361 |
|
} |
| 362 |
|
|
| 363 |
|
/** |
| 364 |
|
* Update bookmarks when menu items get changed |
| 365 |
|
*/ |
| 366 |
|
function bookmarks_menu_edit_item_submit($form_id, $form_values) { |
| 367 |
|
// $form_values['values']['menu']['link_path'] |
| 368 |
|
// $form_values['values']['menu']['original_item']['link_path'] |
| 369 |
|
// select * from menu_links where menu_name like 'bookmarks-%' and link_path=''; |
| 370 |
|
$sql = "UPDATE {menu_links} set link_path = '%s' where menu_name like 'bookmarks-%' and link_path = '%s'"; |
| 371 |
|
$result = db_query($sql, $form_values['values']['menu']['link_path'], $form_values['values']['menu']['original_item']['link_path']); |
| 372 |
|
} |