Browse Source

- Modifiy coding style to passer coder.module validation

Frederic G. Marand 15 years ago
parent
commit
c3dc2cc2f4
1 changed files with 35 additions and 42 deletions
  1. 35 42
      profiloo.module

+ 35 - 42
profiloo.module

@@ -1,5 +1,5 @@
 <?php
-// $Id: profiloo.module,v 1.1 2008-10-08 09:01:35 marand Exp $
+// $Id: profiloo.module,v 1.2 2008-10-13 13:43:08 marand Exp $
 /**
  * @file
  *   An OO wrapper around the profile module
@@ -19,47 +19,41 @@ class Profiloo {
    *
    * This function is not subject to access control.
    *
-   * @param array $arFilter
+   * @param array $ar_filter
    * @return array
    */
-  static function getFields($arFilter = array()) {
+  static function get_fields($ar_filter = array()) {
 
     $sq = 'SELECT pf.fid, pf.title, pf.name, pf.explanation, pf.category, '
-        . '  pf.page, pf.type, pf.weight, pf.required, pf.register, '
-        . '  pf.visibility, pf.autocomplete, pf.options '
-        . 'FROM {profile_fields} pf ';
+        .'  pf.page, pf.type, pf.weight, pf.required, pf.register, '
+        .'  pf.visibility, pf.autocomplete, pf.options '
+        .'FROM {profile_fields} pf ';
 
-    if (empty($arFilter))
-      {
+    if (empty($ar_filter)) {
       $q = db_query($sq);
-      }
-    else
-      {
-      $arQuery  = array();
-      $arParams = array();
-      foreach ($arFilter as $key => $value)
-        {
-        if (in_array($key, array('fid', 'weight', 'required', 'register', 'visibility', 'autocomplete')))
-          {
-          $arQuery[] = "pf.$key = %d";
-          $arParams[] = $value;
-          }
-        else
-          {
-          $arQuery[] = "LOWER(pf.$key) = LOWER('%s')";
-          $arParams[] = $value;
-          }
+    }
+    else {
+      $ar_query  = array();
+      $ar_params = array();
+      foreach ($ar_filter as $key => $value) {
+        if (in_array($key, array('fid', 'weight', 'required', 'register', 'visibility', 'autocomplete'))) {
+          $ar_query[] = "pf.$key = %d";
+          $ar_params[] = $value;
+        }
+        else {
+          $ar_query[] = "LOWER(pf.$key) = LOWER('%s')";
+          $ar_params[] = $value;
         }
-      $sq .= 'WHERE ' . implode(' AND ', $arQuery);
-      $q = db_query($sq, $arParams);
       }
+      $sq .= 'WHERE '. implode(' AND ', $ar_query);
+      $q = db_query($sq, $ar_params);
+    }
 
-    $arFields = array();
-    while (is_object($o = db_fetch_object($q)))
-      {
-      $arFields[$o->fid] = $o;
-      }
-    return $arFields;
+    $ar_fields = array();
+    while (is_object($o = db_fetch_object($q))) {
+      $ar_fields[$o->fid] = $o;
+    }
+    return $ar_fields;
   }
 
   /**
@@ -67,16 +61,15 @@ class Profiloo {
    *
    * This function is not subject to access control.
    *
-   * @param array $arFilter
+   * @param array $ar_filter
    * @return array
    */
-  static function getFieldsAsOptions($arFilter = array()) {
-    $arFields = self::getFields($arFilter);
-    $arRet = array();
-    foreach($arFields as $fid => $oField)
-      {
-      $arRet[$fid] = $oField->title;
-      }
-    return $arRet;
+  static function get_fields_as_options($ar_filter = array()) {
+    $ar_fields = self::get_fields($ar_filter);
+    $ar_ret = array();
+    foreach ($ar_fields as $fid => $o_field) {
+      $ar_ret[$fid] = $o_field->title;
+    }
+    return $ar_ret;
   }
 }