| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | <?php// $Id: profiloo.module,v 1.2 2008-10-13 13:43:08 marand Exp $/** * @file *   An OO wrapper around the profile module * * Copyright 2008 Ouest Systemes Informatiques (OSI) http://www.osinet.eu/ * License: GPL2 or later * Author: Frederic G. MARAND *//** * The wrapper class */class Profiloo {  /**   * Return a list of the currently defined profile fields.   *   * This function is not subject to access control.   *   * @param array $ar_filter   * @return 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 ';    if (empty($ar_filter)) {      $q = db_query($sq);    }    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 ', $ar_query);      $q = db_query($sq, $ar_params);    }    $ar_fields = array();    while (is_object($o = db_fetch_object($q))) {      $ar_fields[$o->fid] = $o;    }    return $ar_fields;  }  /**   * Return a list of the currently defined fields as a FormsAPI #select needs them.   *   * This function is not subject to access control.   *   * @param array $ar_filter   * @return array   */  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;  }}
 |