Code Duplication    Length = 9-15 lines in 10 locations

user_account/models/register_account.class.php 2 locations

@@ 61-71 (lines=11) @@
58
   * @param       string $user_account_email     The data value
59
   * @return      false|string                   The query result
60
   */
61
  public function account_email_exists( $user_account_email )
62
  {
63
      $statement = $this->db->prepare("SELECT 
64
            user_account_id
65
            ,user_account_email
66
          FROM user_account
67
          WHERE user_account_email = :user_account_email");
68
      $statement->bindValue(":user_account_email", $user_account_email, PDO::PARAM_INT);
69
      $statement->execute();
70
      return $statement->fetch(PDO::FETCH_ASSOC);
71
  }
72
73
  /**
74
   * Is Registered
@@ 81-94 (lines=14) @@
78
   * @param       int $user_account_id           The data value
79
   * @return      array|bool                     The query result
80
   */
81
  public function is_registered( $user_account_id )
82
  {
83
      $statement = $this->db->prepare("SELECT user_account.acceptable_use_policy
84
          ,GROUP_CONCAT(user_account_groups.group_id SEPARATOR ', ') AS groups
85
          FROM user_account
86
          LEFT JOIN user_account_groups ON user_account.user_account_id = user_account_groups.user_account_id
87
          WHERE user_account.user_account_id = :user_account_id
88
          AND user_account.acceptable_use_policy = 1
89
          GROUP BY user_account.user_account_id
90
          HAVING groups != ''");
91
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
92
      $statement->execute();
93
      return $statement->fetch(PDO::FETCH_ASSOC);
94
  }
95
96
  /**
97
   * Update Emailed Hash

user_account/models/user_account.class.php 8 locations

@@ 156-167 (lines=12) @@
153
   * @param       int $user_account_id    The data value
154
   * @return      array|bool              The query result
155
   */
156
  public function get_user_account_groups($user_account_id)
157
  {
158
      $statement = $this->db->prepare("SELECT `group`.group_id
159
          ,`group`.name AS group_name
160
          FROM user_account_groups
161
          LEFT JOIN `group` ON `group`.group_id = user_account_groups.group_id
162
          WHERE user_account_groups.user_account_id = :user_account_id
163
          GROUP BY `group`.group_id");
164
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
165
      $statement->execute();
166
      return $statement->fetchAll(PDO::FETCH_ASSOC);
167
  }
168
169
  /**
170
   * Get User Group Roles
@@ 178-190 (lines=13) @@
175
   * @param       int $group_id           The data value
176
   * @return      array|bool              The query result
177
   */
178
  public function get_user_group_roles($user_account_id, $group_id)
179
  {
180
      $statement = $this->db->prepare("SELECT user_account_roles.role_id
181
          ,user_account_roles.label AS role_label
182
          FROM user_account_groups
183
          LEFT JOIN user_account_roles ON user_account_roles.role_id = user_account_groups.role_id
184
          WHERE user_account_groups.user_account_id = :user_account_id
185
          AND user_account_groups.group_id = :group_id");
186
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
187
      $statement->bindValue(":group_id", $group_id, PDO::PARAM_INT);
188
      $statement->execute();
189
      return $statement->fetchAll(PDO::FETCH_ASSOC);
190
  }
191
192
  /**
193
   * Get Roles
@@ 224-235 (lines=12) @@
221
   * @param       int $user_account_id    The data value
222
   * @return      array|bool              The query result
223
   */
224
  public function get_user_account_info($user_account_id = false)
225
  {
226
      $statement = $this->db->prepare("SELECT user_account_email
227
          ,first_name
228
          ,last_name
229
          ,user_account_id
230
          FROM user_account
231
          WHERE user_account_id = :user_account_id");
232
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
233
      $statement->execute();
234
      return $statement->fetch(PDO::FETCH_ASSOC);
235
  }
236
237
  /**
238
   * Get Addresses
@@ 245-253 (lines=9) @@
242
   * @param       int $user_account_id    The data value
243
   * @return      array|bool              The query result
244
   */
245
  public function get_addresses($user_account_id = false)
246
  {
247
      $statement = $this->db->prepare("SELECT *
248
          FROM user_account_addresses
249
          WHERE user_account_id = :user_account_id");
250
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
251
      $statement->execute();
252
      return $statement->fetchAll(PDO::FETCH_ASSOC);
253
  }
254
255
  /**
256
   * Insert Addresses
@@ 429-443 (lines=15) @@
426
   * @param       string $search                 The data value
427
   * @return      array|bool                     The query result
428
   */
429
  public function find_user_account( $search )
430
  {
431
      $statement = $this->db->prepare("
432
          SELECT CONCAT(first_name, ' ', last_name) AS displayname
433
              ,first_name
434
              ,last_name
435
              ,user_account_id
436
          FROM user_account
437
          WHERE first_name LIKE :search
438
          OR last_name LIKE :search
439
          LIMIT 20");
440
      $statement->bindValue(":search", "%".$search ."%", PDO::PARAM_STR);
441
      $statement->execute();
442
      return $statement->fetchAll(PDO::FETCH_ASSOC);
443
  }
444
445
  /**
446
   * Delete User Account
@@ 453-463 (lines=11) @@
450
   * @param       int $user_account_id           The data value
451
   * @return      void
452
   */
453
  public function delete_user_account( $user_account_id )
454
  {
455
      // Delete the user from the user_account table.
456
      $statement = $this->db->prepare("DELETE FROM user_account
457
          WHERE user_account_id = :user_account_id");
458
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
459
      $statement->execute();
460
461
      // Delete the user from the user_account_groups table.
462
      $this->delete_user_groups( $user_account_id );
463
  }
464
465
  /**
466
   * Delete User Groups
@@ 489-497 (lines=9) @@
486
   * @param       int $user_account_id           The data value
487
   * @return      array|bool                     The query result
488
   */
489
  public function get_user_roles_list( $user_account_id )
490
  {
491
      $statement = $this->db->prepare("SELECT DISTINCT role_id
492
          FROM user_account_groups
493
          WHERE user_account_id = :user_account_id");
494
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
495
      $statement->execute();
496
      return $statement->fetchAll(PDO::FETCH_ASSOC);
497
  }
498
499
  /**
500
   * Update Acceptable Use Policy
@@ 527-541 (lines=15) @@
524
   * @param       int $group_id           The data value
525
   * @return      array|bool              The query result
526
   */
527
  public function get_users_proxies_for_group( $user_account_id, $group_id )
528
  {
529
      $statement = $this->db->prepare("SELECT 
530
              CONCAT(user_account.first_name, ' ', user_account.last_name) AS displayname
531
              ,user_account.user_account_id
532
          FROM user_account_groups
533
          RIGHT JOIN user_account_proxy ON user_account_proxy.user_account_groups_id = user_account_groups.user_account_groups_id
534
          LEFT JOIN user_account ON user_account.user_account_id = user_account_proxy.proxy_user_account_id
535
          WHERE user_account_groups.user_account_id = :user_account_id
536
          AND user_account_groups.group_id = :group_id");
537
      $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
538
      $statement->bindValue(":group_id", $group_id, PDO::PARAM_INT);
539
      $statement->execute();
540
      return $statement->fetchAll(PDO::FETCH_ASSOC);
541
  }
542
543
  /**
544
   * Get User Group Roles Map