/[drupal]/contributions/modules/blogroll/blogroll.module
ViewVC logotype

Diff of /contributions/modules/blogroll/blogroll.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.9, Mon Jan 31 01:22:19 2005 UTC revision 1.10, Mon Jan 31 02:37:41 2005 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: blogroll.module,v 1.8 2005/01/30 17:29:16 ahynes1 Exp $  // $Id: blogroll.module,v 1.9 2005/01/31 01:22:19 grantbow Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 76  function blogroll_edit_display($edit, $u Line 76  function blogroll_edit_display($edit, $u
76    $header = array(t('Delete'), t('URL'), t('Name'), t('Weight'));    $header = array(t('Delete'), t('URL'), t('Name'), t('Weight'));
77    $rolls = db_query("SELECT b.uid, b.name, b.url, b.weight FROM {blogroll} b WHERE b.uid = %d ORDER BY b.weight", $uid);    $rolls = db_query("SELECT b.uid, b.name, b.url, b.weight FROM {blogroll} b WHERE b.uid = %d ORDER BY b.weight", $uid);
78    while ($roll = db_fetch_object($rolls)) {    while ($roll = db_fetch_object($rolls)) {
     // little $delete_form for delete buttons  
79      $rows[] = array(      $rows[] = array(
80        array('data' => form_checkbox(NULL, $roll->url .'][delete', 1, 0), 'align' => 'center', 'class' => 'delete'),        array('data' => form_checkbox(NULL, $roll->url .'][delete', 1, 0), 'align' => 'center', 'class' => 'delete'),
81        array('data' => $roll->url, 'class' => 'url'),        array('data' => $roll->url, 'class' => 'url'),
# Line 141  function blogroll_edit() { Line 140  function blogroll_edit() {
140        case 'Update blogs':        case 'Update blogs':
141          foreach ($edit as $url => $roll) {          foreach ($edit as $url => $roll) {
142            if ($roll['delete']) {            if ($roll['delete']) {
143              db_query("DELETE from {blogroll} b WHERE b.uid = '%d' and b.url= '%s'", $uid, $url);              db_query("DELETE FROM {blogroll} WHERE uid = '%d' AND url= '%s'", $uid, $url);
144            } else {            } else {
145              db_query("UPDATE {blogroll} b SET b.name = '%s', b.weight = %d WHERE b.uid = '%d' AND b.url = '%s'", $roll['name'], $roll['weight'], $uid, $url);              db_query("UPDATE {blogroll} b SET b.name = '%s', b.weight = %d WHERE b.uid = '%d' AND b.url = '%s'", $roll['name'], $roll['weight'], $uid, $url);
146            }            }
# Line 177  function blogroll_block($op = 'list', $d Line 176  function blogroll_block($op = 'list', $d
176        return $block;        return $block;
177      case('view'):      case('view'):
178        if (user_access('access content')) {        if (user_access('access content')) {
   
179          $output = '<ul>';          $output = '<ul>';
180          $request_uid = arg(1); // arg(1), won't work when URL is non-numeric or viewing a blog node          $request_uid = arg(1); // arg(1), won't work when URL is non-numeric or viewing a blog node
181            if ((arg(0) == 'blogroll') and (arg(1) == 'edit')) { // for /blogroll/edit
182                $request_uid = $user->uid;
183            }
184          if ($request_uid) {          if ($request_uid) {
185              $block['subject'] = t('Blogroll');
186            $rolls = db_query("SELECT b.uid, b.name, b.url, b.weight FROM {blogroll} b WHERE b.uid = %d ORDER BY b.weight", $request_uid);            $rolls = db_query("SELECT b.uid, b.name, b.url, b.weight FROM {blogroll} b WHERE b.uid = %d ORDER BY b.weight", $request_uid);
187            while ($roll = db_fetch_object($rolls) and ($count < variable_get('blogroll_block_num', '5'))) {            while ($roll = db_fetch_object($rolls) and ($count < variable_get('blogroll_block_num', '5'))) {
188              $output .= '<li><a href="'. $roll->url .'">'. $roll->name .'</a></li>';              $output .= '<li><a href="'. $roll->url .'">'. $roll->name .'</a></li>';
# Line 189  function blogroll_block($op = 'list', $d Line 191  function blogroll_block($op = 'list', $d
191            if ($user->uid == $request_uid) {  // owner viewing own blog            if ($user->uid == $request_uid) {  // owner viewing own blog
192              $output .= '<div class="more-link">'. l('edit', 'blogroll/edit', array('title' => t('Edit'))) .'</div>';              $output .= '<div class="more-link">'. l('edit', 'blogroll/edit', array('title' => t('Edit'))) .'</div>';
193            }            }
194          } else { // for community /blog collection          } else { // for community /blog collection and /blogroll
195              $block['subject'] = t('Community blogroll');
196            // should handle identical URLs with different names.            // should handle identical URLs with different names.
197            $rolls = db_query_range('SELECT name, url, count(*) as cnt FROM {blogroll} GROUP BY name, url ORDER BY cnt, name', 0, variable_get('blogroll_block_num', 5));            $rolls = db_query_range('SELECT b.name, b.url, count(*) as cnt FROM {blogroll} b GROUP BY b.name, b.url ORDER BY cnt, b.name', 0, variable_get('blogroll_block_num', 5));
198            while ($roll = db_fetch_object($rolls)) {            while ($roll = db_fetch_object($rolls)) {
199              $output .= '<li><a href="'. $roll->url .'">'. $roll->name .'</a> ('. $roll->cnt .')</li>';              $output .= '<li><a href="'. $roll->url .'">'. $roll->name .'</a> ('. $roll->cnt .')</li>';
200            }            }
201            $output .= t('</ul>');            $output .= t('</ul>');
202            $output .= '<div class="more-link">'. l('more', 'blogroll', array('title' => t('more'))) .'</div>';            $output .= '<div class="more-link">'. l('more', 'blogroll', array('title' => t('more'))) .'</div>';
203          }          }
         $block['subject'] = t('Blogroll');  
204          $block['content'] = $output;          $block['content'] = $output;
205        }        }
206        return $block;        return $block;
# Line 212  function blogroll_page($uid = 0) { Line 214  function blogroll_page($uid = 0) {
214    $output = '<p>'. t('A community blogroll is a list of all the blogs blogrolled by personal bloggers of this site. It is sorted by frequency, then by name. The most frequent blogs may be provided by a block.') .'</p>';    $output = '<p>'. t('A community blogroll is a list of all the blogs blogrolled by personal bloggers of this site. It is sorted by frequency, then by name. The most frequent blogs may be provided by a block.') .'</p>';
215    $output .= '<ul>';    $output .= '<ul>';
216    // should handle identical URLs with different names.    // should handle identical URLs with different names.
217    $rolls = db_query('SELECT name, url, count(*) as cnt FROM {blogroll} GROUP BY name, url ORDER BY cnt, name');    $rolls = db_query('SELECT b.name, b.url, count(*) as cnt FROM {blogroll} b GROUP BY b.name, b.url ORDER BY cnt, b.name');
218    while ($roll = db_fetch_object($rolls)) {    while ($roll = db_fetch_object($rolls)) {
219      $output .= '<li><a href="'. $roll->url .'">'. $roll->name .'</a> ('. $roll->cnt .')</li>';      $output .= '<li><a href="'. $roll->url .'">'. $roll->name .'</a> ('. $roll->cnt .')</li>';
220    }    }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.2