? .svn ? saved_searches_user.patch Index: views_savedsearches.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_savedsearches/views_savedsearches.module,v retrieving revision 1.4 diff -u -p -r1.4 views_savedsearches.module --- views_savedsearches.module 27 Jan 2009 08:57:08 -0000 1.4 +++ views_savedsearches.module 3 Mar 2009 13:54:14 -0000 @@ -115,6 +115,52 @@ function views_savedsearches_form_alter( } } +/** + * Implementation of hook_block(). + */ +function views_savedsearches_block($op = 'list', $delta = 0, $edit = array()) { + if ('list' == $op) { + $blocks = array(); + $blocks['views-savedsearches-per-user'] = array( + 'info' => t('My views saved searches'), + ); + + return $blocks; + } + else if ('view' == $op) { + $block = array(); + switch ($delta) { + case 'views-savedsearches-per-user': + if (arg(0) == 'user' && is_numeric(arg(1))) { + $block = views_savedsearches_per_user(arg(1)); + } + else { + global $user; + $block = views_savedsearches_per_user($user->uid); + } + + break; + } + return $block; + } +} + +function views_savedsearches_per_user($uid = NULL) { + // Default to global $user. + if (empty($uid)) { + global $user; + $uid = $user->uid; + } + + $saved_searches = views_savedsearches_load_multiple($uid, 1); + + foreach ($saved_searches as $sid => $saved_search) { + $query = _views_savedsearches_filters_to_params($saved_search->filters); + + $items[] = l($saved_search->name, 'search/companies', array('query' => $query)); + } + return array('subject' => 'My saved searches', 'content' => theme('item_list', $items)); +} //---------------------------------------------------------------------------- // Views hooks. @@ -499,7 +545,10 @@ function _views_savedsearches_params_to_ } } } - + // hack to add support for saving advanced views + if ($params['adv-flag']) { + $filters['adv-flag'] = $params['adv-flag']; + } return $filters; }