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

Diff of /contributions/modules/profile_pages/profile_pages.module

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

revision 1.4, Thu Sep 14 21:00:36 2006 UTC revision 1.4.2.1, Mon Oct 22 22:07:43 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: profile_pages.module,v 1.3 2006/09/14 09:09:56 heine Exp $  // $Id: profile_pages.module,v 1.5 2007/10/22 21:57:46 jrbeeman Exp $
 /**  
  * @file  
  * Provides a callback URL that lists, on one page,  
  * users with a specified profile field set  
  */  
3    
4  function profile_pages_help($section)  {  /**
5    switch($section) {  * Implementation of hook_perm
6      case 'admin/modules#description':  */
7        return t('This module lists users with a specified profile field set on one page, i.e. "Users who have ICQ" and then it lists all their ICQ accounts.');  function profile_pages_perm()  {
8        break;    return array('view profile pages');
   }  
9  }  }
10    
11  function profile_pages_menu($may_cache) {  
12      $result = db_query("SELECT fid,name,title,type from {profile_fields}");  /**
13    * Implementation of hook_menu
14    */
15    function profile_pages_menu($may_cache) {
16      $items = array();
17      if ($may_cache)  {      if ($may_cache)  {
18        while ($field = db_fetch_object($result))  {        $items[] = array(
19              $items[] = array('path' => "profile_pages/". check_plain($field->name), 'title' => check_plain($field->title),          'path' => 'profile_pages',
20                'access' => user_access('view profile pages'),          'access' => user_access('view profile pages'),
21                'callback' => 'profile_pages_view',          'callback' => 'profile_pages_view',
22                'callback arguments' => array($field->fid, $field->type),          'type' => MENU_CALLBACK
23                'type' => MENU_CALLBACK);        );
 /*            $items[] = array('path' => "profile/".$field->name, 'title' => $field->title,  
               'access' => user_access('view profile pages'),  
               'callback' => 'profile_pages_view',  
               'callback arguments' => array($field->fid,$field->type),  
               'type' => MENU_CALLBACK);*/  
       }  
24      }      }
25      return $items;      return $items;
26  }  }
27    
 function profile_pages_view($fid, $type)  {  
   if (!$fid || !is_numeric($fid) || !$type)  {  
     drupal_not_found();  
     return;  
   }  
28    
29    $result = db_query("SELECT * from {users} as u,{profile_values} as p where u.uid=p.uid and p.fid='%d' ORDER BY u.name ASC",$fid);  /**
30     * Menu callback, for viewing entries of a profile
31     * @param $name String The field name of the profile field to be viewed
32     */
33    function profile_pages_view($name = null)  {
34      // If the field name is provided, show all the entries for all the users
35      if ($name)  {
36        $sql = "SELECT u.uid, u.name, pv.value FROM {users} u, {profile_values} pv, {profile_fields} pf WHERE u.uid = pv.uid AND u.status = 1 AND pf.name = '%s' AND pv.fid = pf.fid AND pv.value != '' ORDER BY u.name ASC";
37        $result = pager_query($sql, 50, 0, NULL, check_plain($name));
38        while ($row = db_fetch_object($result))  {
39          if ($row->value)  {
40            $output .= theme('profile_page_listing', $row, $row->value);
41          }
42        }
43        $output .= theme('pager', NULL, 50, 0);
44        return $output;
45      }
46    
47    while ($user = db_fetch_object($result))  {    // If no field name is provided, show a list of profile fields
48      if ($type == "list") // turn commas into newlines    else {
49        $user->value = implode("\n",split(',', $user->value));      $result = db_query("SELECT fid, name, title from {profile_fields} ORDER BY name");
50      if ($user->value)  {      $items = array();
51        $user->value = nl2br($user->value);      while ($row = db_fetch_object($result)) {
52        $output .= theme('profile_page_listing', $user);        $items[] = l($row->title, 'profile_pages/'.$row->name);
53      }      }
54        return theme('item_list', $items);
55    }    }
   print theme('page', $output);  
56  }  }
57    
 /**  
  * set permissions for module access  
  *  
  * @return array  
  */  
 function profile_pages_perm()  {  
   return array('view profile pages');  
 }  
58    
59  /**  /**
60   * Lists a user name and the value for the profile item   * Render an individual listing on the profile page
61   *   * @param $user The user object
62   * @param object $user   * @param $value The value of the profile field
  * @return string  
63   */   */
 function theme_profile_page_listing($user)  {  
   return check_plain($user->name) .': '. check_plain($user->value) .'<br />';  
 }  
 ?>  
64    function theme_profile_page_listing($user, $value)  {
65      $value = implode("\n", explode(",", $value));
66      $values = explode("\n", $value);
67      $items = array();
68      foreach ($values as $value) {
69        $items[] = $value;
70      }
71      return theme('item_list', $items, theme('username', $user));
72    }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.4.2.1

  ViewVC Help
Powered by ViewVC 1.1.2