Closed (fixed)
Project:
Favorites
Version:
6.x-1.3
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Mar 2011 at 17:46 UTC
Updated:
30 Dec 2011 at 12:10 UTC
I have added some already requested features and fixed some bugs:
Attached my version of the module (be aware that, lazy me, did not implement an update function for the DB change. Feel free to contribute that yourself) and both diffs:
--- favorites.module.original So 28. Feb 18:36:54 2010
+++ favorites.module Do 17. Mrz 18:08:20 2011
@@ -12,7 +12,7 @@
* Implementation of hook_perm().
*/
function favorites_perm() {
- return array('manage own favorites', 'manage all favorites');
+ return array('manage own favorites'); // this is not implemented yet: , 'manage all favorites');
}
/*
@@ -53,7 +53,7 @@
*/
function favorites_remove_favorite($favorite) {
global $user;
- $access = (user_access('manage own favorites') && $user->uid == $favorite->uid) || user_access('manage all favorites');
+ $access = (user_access('manage own favorites') && $user->uid == $favorite->uid); // no admin page implemented yet! || user_access('manage all favorites');
if (!$access) {
drupal_set_message(t("You do not have permission to remove this favorite."));
drupal_goto();
@@ -96,9 +96,9 @@
function favorites_user_block() {
global $user;
$output = '';
- $output .= drupal_get_form('favorites_add_favorite_form');
$favorites = favorites_load_favorites($user->uid);
$output .= theme('favorites', $favorites);
+ $output .= drupal_get_form('favorites_add_favorite_form');
$block['subject'] = t('My Favorites');
$block['content'] = $output;
return $block;
@@ -114,7 +114,22 @@
$destination = str_replace('destination=', '', $destination);
foreach ($favorites as $favorite) {
$query = array();
- $items[]= l($favorite->title, $favorite->path, array('query' => $favorite->query)) . ' ' . l('x', 'favorites/remove/' . $favorite->fid, array('class' => 'favorites-remove', 'query' => array('token' => $favorite->token, 'destination' => $destination)));
+ $items[]= l($favorite->title, $favorite->path, array('query' => $favorite->query))
+ . ' '
+ . l(
+ 'x',
+ 'favorites/remove/' . $favorite->fid,
+ array(
+ 'class' => 'favorites-remove',
+ 'query' => array(
+ 'token' => $favorite->token, 'destination' => $destination
+ ),
+ 'attributes' => array(
+ 'title' => t('delete this item'),
+ ),
+ )
+ )
+ ;
}
return theme('item_list', $items);
}
@@ -135,9 +150,33 @@
function favorites_add_favorite_form() {
global $user;
- $form['submit'] = array(
+ $title = htmlspecialchars_decode(drupal_get_title());
+ if (empty($title)) {
+ $title = check_plain(variable_get('site_name', 'Home'));
+ }
+
+ $title = strip_tags($title);
+ // add a collapsible container
+ $form['add'] = array(
+ '#type' => 'fieldset',
+ '#collapsible' => true,
+ '#collapsed' => true,
+ '#title' => t('add this page'),
+ );
+ $form['add']['title'] = array(
+ '#type' => 'textfield',
+ '#size' => 20,
+ '#maxlength' => 255,
+ '#default_value' => $title,
+ '#attributes' => array(
+ 'style' => 'width: 90%',
+ 'class' => 'favorites-add-textfield',
+ ),
+ );
+
+ $form['add']['submit'] = array(
'#type' => 'submit',
- '#value' => t("Add to my favorites"),
+ '#value' => t("Add"),
'#submit' => array('favorites_add_favorite_form_submit'),
);
$form['path'] = array(
@@ -150,17 +189,6 @@
'#value' => drupal_query_string_encode($_GET, array('q')),
);
- $title = drupal_get_title();
- if (empty($title)) {
- $title = check_plain(variable_get('site_name', 'Home'));
- }
-
- $title = strip_tags($title);
- $form['title'] = array(
- '#type' => 'value',
- '#value' => $title,
- );
-
//Preserve the current path with query string.
$destination = drupal_get_destination();
$form['#redirect'] = array($_GET['q'], drupal_query_string_encode($_GET, array('q')));
--- favorites.install.original So 28. Feb 18:36:54 2010
+++ favorites.install Do 17. Mrz 18:44:56 2011
@@ -37,19 +37,19 @@
'not null' => TRUE,
),
'path' => array(
- 'decription' => "The favorited path",
+ 'description' => "The favorited path",
'type' => 'varchar',
- 'length' => 255,
+ 'length' => 2048,
'not null' => TRUE,
),
'title' => array(
- 'decription' => "The title of the favorite",
+ 'description' => "The title of the favorite",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'query' => array(
- 'decription' => "The query parameters for the saved path.",
+ 'description' => "The query parameters for the saved path.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
| Comment | File | Size | Author |
|---|---|---|---|
| favorites.install.diff | 344 bytes | doitDave | |
| favorites.module.diff | 3.66 KB | doitDave | |
| favorites-6.x-1.2.y.zip | 9.47 KB | doitDave |
Comments
Comment #1
doitDave commentedissue status corrected
Comment #2
doitDave commentedFixed with the 1.3 release.