Changeset 284

Show
Ignore:
Timestamp:
04/12/08 20:35:29 (8 months ago)
Author:
beni
Message:

RSS for bookmarks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bookmarks/trunk/INSTALL

    r260 r284  
    1919RewriteRule ^bookmarks\/popular$ mod/bookmarks/popular.php 
    2020RewriteRule ^bookmarks\/popular\/skip/([0-9]+)$ mod/bookmarks/popular.php?skip=$1 
     21RewriteRule ^(([A-Za-z0-9])[A-Za-z0-9]+)\/bookmarks\/rss\/?$ mod/newsclient/static.php?username=$1&userref=$2&type=bookmark 
    2122 
    2223That's it. 
  • bookmarks/trunk/lib.php

    r260 r284  
    33 * @package bookmarks 
    44 * @filesource mod/bookmarks/ 
    5  * @version 2.0 
     5 * @version 2.1 
    66 * @author beni<b.taraghi@tugraz.at> 
    77 * @copyright Copyright &copy; 2007, Graz University of Technology - WG Social Learning<http://www.tugraz.at> 
     
    2121 
    2222        if (isloggedin() && user_info("user_type", $_SESSION['userid']) != "external" && !(defined("context") && context == "admin")) { 
    23                 //if (user_type($page_owner) == "person") { 
    2423                        if (defined("context") && context == "bookmarks" && $page_owner == $_SESSION['userid']) { 
    2524                                $PAGE->menu[] = array ( 
     
    3231                                        'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/bookmarks/all/\" >" . __gettext("Your Bookmarks" 
    3332                                ) . '</a></li>'); 
    34                         //} 
    35                 } 
    36                 /* 
    37                 if (user_type($page_owner) == "community") { 
    38                         if (defined("context") && context == "bookmarks") { 
    39                                 $PAGE->menu[] = array ( 
    40                                         'name' => 'bookmarks', 
    41                                         'html' => '<li><a href="' . $CFG->wwwroot . $bm_username . '/bookmarks/all/" class="selected">' . __gettext("Bookmarks" 
    42                                 ) . '</a></li>'); 
    43                         } else { 
    44                                 $PAGE->menu[] = array ( 
    45                                         'name' => 'bookmarks', 
    46                                         'html' => '<li><a href="' . $CFG->wwwroot . $bm_username . '/bookmarks/all/">' . __gettext("Bookmarks" 
    47                                 ) . '</a></li>'); 
    48                         } 
    49                 } 
    50                 */ 
     33                } 
    5134        } 
    5235 
     
    5437 
    5538                if ($page_owner != -1) { 
     39                      $PAGE->menu_sub[]= array ( 
     40                        'name' => 'bookmark:rssfeed', 
     41                        'html' => "<a href=\"{$CFG->wwwroot}{$bm_username}/bookmarks/rss/\"><img src=\"{$CFG->wwwroot}mod/template/icons/rss.png\" border=\"0\" alt=\"rss\" /></a>" 
     42                      ); 
     43 
    5644                        if (run("permissions:check", array ( 
    5745                                        "bookmark:add", 
  • bookmarks/trunk/lib/bookmarks_actions.php

    r249 r284  
    4242         
    4343        if(optional_param('bm_import', "0")) { 
    44                 // not used in ELGG 
    45                 // not nacessary because of js 
    46                 /* 
    47                     if(!Modifications::TagsFromStringAreValid($keywords)) 
    48                     { 
    49                                 $messages[] = __gettext("You must set at least one key word for your bookmark."); 
    50                                 break; 
    51                     } 
    52                     */ 
     44 
    5345                $bool_success = run("bookmarks:import:content", array('import_bookmark_file', $access, $keywords, $category_id, $view)); 
    5446        } 
     
    5951                // commented to let #page=55&view=FitView work for pdfs 
    6052                //$url = preg_replace('/#.*$/', '', $url); 
    61                 /* 
    62             if(!Modifications::TagsFromStringAreValid($keywords)) 
    63             { 
    64                                 $messages[] = __gettext("You must set at least one key word for your bookmark."); 
    65                                 break; 
    66             } 
    67                         */ 
     53 
    6854                if ($bm_exists = get_field('bookmarks','ident','url',$url)) { 
    6955                if (!run("bookmark:subscribed",$bm_exists)) { 
     
    165151        } 
    166152        if($bool_success) {// success 
     153                $rssresult = run("bookmarks:rss:publish", array($page_owner, false)); 
    167154                if($action == "bookmarks:post:add") 
    168155                        define('redirect_url',url . user_info("username",$page_owner) . "/bookmarks/all/"); 
     
    208195 
    209196            } 
     197            $rssresult = run("bookmarks:rss:publish", array($oldpost->bookmark, false)); 
    210198            $messages[] = __gettext("The bookmark has been modified."); // gettext variable 
    211199                } 
     
    224212                                delete_records('tags','tagtype','bookmark','ref',$id); 
    225213 
    226                              
     214                               $rssresult = run("bookmarks:rss:publish", array($post_info->bookmark, false)); 
    227215                                $messages[] = __gettext("The selected bookmark was deleted."); 
     216                                 
    228217                                 
    229218                                // if the user has been the only owner of the bookmark, delete it completely from DB 
  • bookmarks/trunk/lib/bookmarks_user_info_menu.php

    r249 r284  
    3030            $body  = '<ul>'; 
    3131             
    32             $body .= "<li><a href=\"$CFG->wwwroot" .$bm_username ."/bookmarks/all/\">$bookmarks_see</a> ( $cnt_bm )</li>"; 
     32            $rsslink = "<a href=\"{$CFG->wwwroot}{$bm_username}/bookmarks/rss/\"><img src=\"{$CFG->wwwroot}mod/template/icons/rss.png\" border=\"0\" alt=\"rss\" /></a>"; 
     33            $body .= "<li><a href=\"$CFG->wwwroot" .$bm_username ."/bookmarks/all/\">$bookmarks_see</a> {$rsslink} ($cnt_bm)</li>"; 
    3334 
    3435             
  • bookmarks/trunk/lib/function_rss_getitems.php

    r249 r284  
    5656                                            ORDER BY bs.created_on DESC LIMIT '.$numrows,array($userid,'PUBLIC','bookmark',0)); 
    5757 
    58                 $entries_views = get_records_sql('SELECT bs.*, u.username, b.url, b.title as b_title FROM '.$CFG->prefix.'bookmark_subscriptions bs JOIN '.$CFG->prefix.'views v on v.ref = bs.ident JOIN '.$CFG->prefix.'users u ON u.ident = v.view 
    59                                                   JOIN '.$CFG->prefix.'bookmarks b ON b.ident=bs.bookmark_id 
    60                                                   WHERE v.view = ? AND bs.access = ? AND v.viewtype = ?   
    61                                                   AND (SELECT count(ident) FROM '.$CFG->prefix.'tags t WHERE t.tagtype = ? AND t.tag IN ('.$tag_in.') AND t.ref = bs.ident) = ? 
    62                                                   ORDER BY bs.created_on DESC LIMIT '.$numrows,array($userid,'PUBLIC','bookmark','bookmark',0)); 
    63  
    6458            } else if (isset($parameter[3]) && $parameter[3] == "all") { 
    6559                $entries = get_records_sql('SELECT bs.*, u.username, b.url, b.title as b_title FROM '.$CFG->prefix.'bookmark_subscriptions bs JOIN '.$CFG->prefix.'users u ON u.ident = bs.owner 
     
    6862                                            ORDER BY bs.created_on DESC LIMIT '.$numrows,array('PUBLIC','bookmark',0)); 
    6963                                             
    70                 $entries_views = get_records_sql('SELECT bs.*, u.username, b.url, b.title as b_title FROM '.$CFG->prefix.'bookmark_subscriptions bs JOIN '.$CFG->prefix.'users u ON u.ident = bs.owner  
    71                                                                                   JOIN '.$CFG->prefix.'views v on v.ref = bs.ident JOIN '.$CFG->prefix.'bookmarks b ON b.ident=bs.bookmark_id WHERE bs.access = ? AND v.viewtype = ?  
    72                                                   AND (SELECT count(ident) FROM '.$CFG->prefix.'tags t WHERE t.tagtype = ? AND t.tag IN ('.$tag_in.') AND t.ref = bs.ident) = ?  
    73                                                   ORDER BY bs.created_on DESC LIMIT '.$numrows,array('PUBLIC','bookmark','bookmark',0)); 
    74  
    7564            } else if ($tag) { 
    7665                $entries = get_records_sql('SELECT bs.*, u.username, b.url, b.title as b_title FROM '.$CFG->prefix.'tags t JOIN '.$CFG->prefix.'bookmark_subscriptions bs ON bs.ident = t.ref 
     
    8069                                            ORDER BY bs.created_on DESC limit '.$numrows,array($userid,'PUBLIC','bookmark')); 
    8170 
    82                 $entries_views = get_records_sql('SELECT bs.*, u.username, b.url, b.title as b_title FROM '.$CFG->prefix.'tags t JOIN '.$CFG->prefix.'bookmark_subscriptions bs ON bs.ident = t.ref 
    83                                                       JOIN '.$CFG->prefix.'views v on v.ref = bs.ident JOIN '.$CFG->prefix.'users u on u.ident = v.view  
    84                                                   JOIN '.$CFG->prefix.'bookmarks b ON b.ident=bs.bookmark_id 
    85                                                       WHERE v.view = ? AND bs.access = ? AND t.tag IN ('.$tag_in.') AND t.tagtype = ? AND v.viewtype = ? 
    86                                                       ORDER BY bs.created_on DESC limit '.$numrows,array($userid,'PUBLIC','bookmark','bookmark')); 
    87  
    8871            } else { 
    8972                $entries = get_records_sql('SELECT bs.*, u.username, b.url, b.title as b_title FROM '.$CFG->prefix.'bookmark_subscriptions bs JOIN '.$CFG->prefix.'users u ON u.ident = bs.bookmark 
     
    9275                                            ORDER BY bs.created_on DESC LIMIT '.$numrows, array($userid, 'PUBLIC')); 
    9376 
    94                 $entries_views = get_records_sql('SELECT bs.*, u.username, b.url, b.title as b_title FROM '.$CFG->prefix.'bookmark_subscriptions bs JOIN '.$CFG->prefix.'views v ON v.ref = bs.ident 
    95                                                   JOIN '.$CFG->prefix.'users u ON u.ident = v.view JOIN '.$CFG->prefix.'bookmarks b ON b.ident=bs.bookmark_id   
    96                                                   WHERE v.view = ? AND bs.access = ? AND v.viewtype = ?  
    97                                                   ORDER BY bs.created_on DESC LIMIT '.$numrows, array($userid, 'PUBLIC', 'bookmark')); 
    98  
    9977            } 
    10078 
    10179            if(!is_array($entries)) $entries = array(); 
    102             if(!is_array($entries_views)) $entries_views = array(); 
    103             $entries_result = array_merge($entries, $entries_views)
    104             $entries = array(); 
     80 
     81            $entries_result = $entries
     82            $entries = array();$cnt=0; 
    10583            foreach($entries_result as $obj_entries) { 
    106                 $entries[$obj_entries->created_on] = $obj_entries; 
     84                $entries[$obj_entries->created_on + $cnt++] = $obj_entries; 
    10785            } 
    10886            krsort($entries); 
     
    11492                                    $body = '<p><a href="'.$entry->url.'" target="_blank">' . $entry->url . '</a></p>'; 
    11593                                    $body .= '<p>' . $entry->description . '</p>'; 
    116                     $body = (run("bookmarks:text:process",stripslashes($body))); 
     94                    //$body = (run("bookmarks:text:process",stripslashes($body))); 
    11795                    $pubdate = gmdate("D, d M Y H:i:s T", $entry->created_on); 
    11896                    $keywordtags = ""; 
  • bookmarks/trunk/lib/main.php

    r249 r284  
    44 * @package bookmarks 
    55 * @filesource mod/bookmarks/lib/ 
    6  * @version 1.5 
     6 * @version 1.6 
    77 * @author beni<b.taraghi@tugraz.at> 
    88 * @copyright Copyright &copy; 2007, Graz University of Technology - WG Social Learning<http://www.tugraz.at> 
     
    4848// Publish static RSS file of posts 
    4949$function['bookmarks:rss:getitems'][] = dirname(__FILE__) . "/function_rss_getitems.php"; 
    50 // no bookmark.xml => no publishing for now 
    51 //$function['bookmarks:rss:publish'][] =  dirname(__FILE__) . "/function_rss_publish.php"; 
     50$function['bookmarks:rss:publish'][] =  dirname(__FILE__) . "/function_rss_publish.php"; 
    5251// Update URLs 
    5352$function['bookmarks:url:update'][] = dirname(__FILE__) . "/function_url_update.php";