/[drupal]/contributions/modules/index/includes/index.data.inc
ViewVC logotype

Diff of /contributions/modules/index/includes/index.data.inc

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

revision 1.1.2.1 by xano, Sun Nov 8 20:13:54 2009 UTC revision 1.1.2.2 by xano, Tue Nov 17 22:34:07 2009 UTC
# Line 8  Line 8 
8  /**  /**
9   * Get user data.   * Get user data.
10   *   *
11   * @return   * @return array
12   *  An array of users as objects.   *  User objects from {users}.
13   */   */
14  function index_data_get_user($key = NULL, array $values = array()) {  function index_data_get_user($key = NULL, array $values = array()) {
15    $where = $key ? " WHERE $key in (" . implode(',', $values) . ')' : NULL;    $where = $key ? " WHERE $key in (" . implode(',', $values) . ')' : NULL;
# Line 29  function index_data_get_user($key = NULL Line 29  function index_data_get_user($key = NULL
29  }  }
30    
31  /**  /**
32     * Count user data.
33     *
34     * @return integer
35     */
36    function index_data_count_user($key = NULL, array $values = array()) {
37      $where = $key ? " WHERE $key in (" . implode(',', $values) . ')' : NULL;
38      $result = db_query("SELECT COUNT(*) FROM {users}" . $where);
39    
40      return db_result($result);
41    }
42    
43    /**
44   * Get user role data.   * Get user role data.
45   *   *
46   * @return   * @return
# Line 36  function index_data_get_user($key = NULL Line 48  function index_data_get_user($key = NULL
48   */   */
49  function index_data_get_user_role($key = NULL, array $values = array()) {  function index_data_get_user_role($key = NULL, array $values = array()) {
50    $where = $key ? " WHERE $key in (" . implode(',', $values) . ')' : NULL;    $where = $key ? " WHERE $key in (" . implode(',', $values) . ')' : NULL;
51    $result = db_query("SELECT * FROM {users_roles} ur LEFT JOIN {role} r ON ur.rid = r.rid" . $where);    $result = db_query("SELECT * FROM {role} r LEFT JOIN {users_roles} ur ON ur.rid = r.rid" . $where);
52    $user_roles = array();    $user_roles = array();
53    while ($user_role = db_fetch_object($result)) {    while ($user_role = db_fetch_object($result)) {
54      $user_role->index_entity_type = 'user_role';      $user_role->index_entity_type = 'user_role';
# Line 50  function index_data_get_user_role($key = Line 62  function index_data_get_user_role($key =
62    
63    return $user_roles;    return $user_roles;
64  }  }
65    
66    /**
67     * Count user role data.
68     *
69     * @return integer
70     */
71    function index_data_count_user_ole($key = NULL, array $values = array()) {
72      $where = $key ? " WHERE $key in (" . implode(',', $values) . ')' : NULL;
73      $result = db_query("SELECT COUNT(*) FROM {role} r LEFT JOIN {users_roles} ur ON ur.rid = r.rid" . $where);
74    
75      return db_result($result);
76    }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.3