| 1 |
<?php |
<?php |
| 2 |
// $Id: favorite_nodes.module,v 1.8.2.7 2008/09/29 16:08:52 kbahey Exp $ |
// $Id: favorite_nodes.module,v 1.8.2.8 2008/09/29 16:46:00 kbahey Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 22 |
define('FAVORITE_NODES_MENUS', 'favorite_nodes_menu'); |
define('FAVORITE_NODES_MENUS', 'favorite_nodes_menu'); |
| 23 |
define('FAVORITE_NODES_TEASER', 'favorite_nodes_teaser'); |
define('FAVORITE_NODES_TEASER', 'favorite_nodes_teaser'); |
| 24 |
define('FAVORITE_NODES_LIST_EMPTY_TITLES', 'favorite_nodes_list_empty_titles'); |
define('FAVORITE_NODES_LIST_EMPTY_TITLES', 'favorite_nodes_list_empty_titles'); |
| 25 |
|
define('FAVORITE_NODES_SHOWLINK', 'favorite_nodes_showlink'); |
| 26 |
|
|
| 27 |
/** |
/** |
| 28 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 172 |
} |
} |
| 173 |
|
|
| 174 |
/** |
/** |
| 175 |
|
* List of favorite enabled content types with favorites |
| 176 |
|
*/ |
| 177 |
|
function theme_favorite_nodes_user_page($account) { |
| 178 |
|
$fav_list = array(); |
| 179 |
|
foreach (_node_types_natcasesort() as $type) { |
| 180 |
|
if (variable_get(FAVORITE_NODES_NODE_TYPE . $type->type, 0)) { |
| 181 |
|
$uid = intval($account->uid); |
| 182 |
|
$favorites = favorite_nodes_get($uid, $type->type, variable_get(FAVORITE_NODES_BLOCK_LIMIT, 5)); |
| 183 |
|
$items = array(); |
| 184 |
|
if (!empty($favorites)) { |
| 185 |
|
foreach ($favorites as $favorite) { |
| 186 |
|
$items[] = l($favorite->title, "node/$favorite->nid"); |
| 187 |
|
} |
| 188 |
|
} |
| 189 |
|
$fav_list[] = array( |
| 190 |
|
'title' => $items ? l($type->name, "favorite_nodes/view/$account->uid/$type->type") : $type->name, |
| 191 |
|
'value' => theme('item_list', $items), |
| 192 |
|
); |
| 193 |
|
} |
| 194 |
|
} |
| 195 |
|
return array(t('Favorites') => $fav_list); |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
/** |
| 199 |
* Implementation of hook_nodeapi(). |
* Implementation of hook_nodeapi(). |
| 200 |
*/ |
*/ |
| 201 |
function favorite_nodes_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
function favorite_nodes_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
| 316 |
if (user_access(FAVORITE_NODES_PERM_ADD)) { |
if (user_access(FAVORITE_NODES_PERM_ADD)) { |
| 317 |
if (!_favorite_nodes_check($node->nid)) { |
if (!_favorite_nodes_check($node->nid)) { |
| 318 |
if (!$teaser) { |
if (!$teaser) { |
| 319 |
$links[] = array('title' => t('add to favorites'), 'href' => 'favorite_nodes/add/'. $node->nid); |
$links['add_to_favorites'] = array( |
| 320 |
|
'title' => t('add to favorites'), |
| 321 |
|
'href' => 'favorite_nodes/add/'. $node->nid |
| 322 |
|
); |
| 323 |
} |
} |
| 324 |
elseif ($teaser && variable_get('favorite_nodes_teaser', 0) == 1) { |
elseif ($teaser && variable_get('favorite_nodes_teaser', 0) == 1) { |
| 325 |
$links[] = array('title' => t('add to favorites'), 'href' => 'favorite_nodes/add/'. $node->nid); |
$links['add_to_favorites'] = array( |
| 326 |
|
'title' => t('add to favorites'), |
| 327 |
|
'href' => 'favorite_nodes/add/'. $node->nid |
| 328 |
|
); |
| 329 |
} |
} |
| 330 |
} |
} |
| 331 |
else { |
else { |
| 332 |
if (user_access(FAVORITE_NODES_PERM_VIEW)) { |
if (user_access(FAVORITE_NODES_PERM_VIEW)) { |
| 333 |
if (!$teaser) { |
if (!$teaser) { |
| 334 |
$links[] = array('title' => t('in favorites')); |
$links['in_favorites'] = array( |
| 335 |
$links[] = array('title' => t('remove from favorites'), 'href' => 'favorite_nodes/delete/'. $node->nid); |
'title' => t('in favorites') |
| 336 |
|
); |
| 337 |
|
$links['remove_from_favorites'] = array( |
| 338 |
|
'title' => t('remove from favorites'), |
| 339 |
|
'href' => 'favorite_nodes/delete/'. $node->nid |
| 340 |
|
); |
| 341 |
} |
} |
| 342 |
elseif ($teaser && variable_get('favorite_nodes_teaser', 0) == 1) { |
elseif ($teaser && variable_get('favorite_nodes_teaser', 0) == 1) { |
| 343 |
$links[] = array('title' => t('in favorites')); |
$links['in_favorites'] = array( |
| 344 |
$links[] = array('title' => t('remove from favorites'), 'href' => 'favorite_nodes/delete/'. $node->nid); |
'title' => t('in favorites') |
| 345 |
|
); |
| 346 |
|
$links['remove_from_favorites'] = array( |
| 347 |
|
'title' => t('remove from favorites'), |
| 348 |
|
'href' => 'favorite_nodes/delete/'. $node->nid |
| 349 |
|
); |
| 350 |
} |
} |
| 351 |
} |
} |
| 352 |
} |
} |
| 411 |
'#description' => t('By default, all node types are listed on the user favorite nodes table view. In many cases, you may want to limit the lists to those that have favorite nodes actually bookmarked. Selecting this option will allow all the lists to appear regardless of whether they contain nodes or not. Unselecting this option will restirct the list to only those actually containing nodes.'), |
'#description' => t('By default, all node types are listed on the user favorite nodes table view. In many cases, you may want to limit the lists to those that have favorite nodes actually bookmarked. Selecting this option will allow all the lists to appear regardless of whether they contain nodes or not. Unselecting this option will restirct the list to only those actually containing nodes.'), |
| 412 |
); |
); |
| 413 |
|
|
| 414 |
|
$form[$set][FAVORITE_NODES_SHOWLINK] = array( |
| 415 |
|
'#type' => 'checkbox', |
| 416 |
|
'#title' => t('Display Favorite Node options as links'), |
| 417 |
|
'#return_value' => 1, |
| 418 |
|
'#default_value' => variable_get(FAVORITE_NODES_SHOWLINK, 1), |
| 419 |
|
'#description' => t('Whether to show link items in the node view?'), |
| 420 |
|
); |
| 421 |
|
|
| 422 |
$set = 'types'; |
$set = 'types'; |
| 423 |
$form[$set] = array( |
$form[$set] = array( |
| 424 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |