21 defined(
'XOOPS_ROOT_PATH') or die("XOOPS root path not defined");
47 foreach (array_keys(
$fields) as $key ) {
48 $this->initVar($key,
$fields[$key]->getVar(
'field_valuetype'),
$fields[$key]->getVar(
'field_default',
'n'),
$fields[$key]->getVar(
'field_required'),
$fields[$key]->getVar(
'field_maxlength'));
77 parent::__construct(
$db,
"profile_profile",
'profileprofile',
"profile_id");
90 $obj =
new $this->className($this->
loadFields() );
91 $obj->handler =& $this;
92 if ($isNew ===
true) {
105 function &
get(
$uid, $createOnFailure =
true)
107 $obj = parent::get(
$uid);
108 if (!is_object($obj) && $createOnFailure) {
123 $return =& $this->_fHandler->create($isNew);
134 if (count($this->_fields) == 0) {
135 $this->_fields = $this->_fHandler->loadFields();
151 return $this->_fHandler->getObjects(
$criteria, $id_as_key, $as_object);
164 return $this->_fHandler->insert($field, $force);
177 return $this->_fHandler->delete($field, $force);
194 $field->setVar(
'field_name',
$vars[
'name']);
195 $field->setVar(
'field_valuetype',
$vars[
'valuetype']);
196 $field->setVar(
'field_type',
$vars[
'type']);
197 $field->setVar(
'field_weight', $weight);
198 if (isset(
$vars[
'title'])) {
199 $field->setVar(
'field_title',
$vars[
'title']);
201 if (isset(
$vars[
'description'])) {
202 $field->setVar(
'field_description',
$vars[
'description']);
204 if (isset(
$vars[
'required'])) {
205 $field->setVar(
'field_required',
$vars[
'required']);
207 if (isset(
$vars[
'maxlength'])) {
208 $field->setVar(
'field_maxlength',
$vars[
'maxlength']);
210 if (isset(
$vars[
'default'])) {
211 $field->setVar(
'field_default',
$vars[
'default']);
213 if (isset(
$vars[
'notnull'])) {
214 $field->setVar(
'field_notnull',
$vars[
'notnull']);
216 if (isset(
$vars[
'show'])) {
217 $field->setVar(
'field_show',
$vars[
'show']);
219 if (isset(
$vars[
'edit'])) {
220 $field->setVar(
'field_edit',
$vars[
'edit']);
222 if (isset(
$vars[
'config'])) {
223 $field->setVar(
'field_config',
$vars[
'config']);
225 if (isset(
$vars[
'options'])) {
226 $field->setVar(
'field_options',
$vars[
'options']);
228 $field->setVar(
'field_options', array() );
231 $msg =
' Field <strong>' .
$vars[
'name'] .
'</strong> added to the database';
233 $msg =
' <span class="red">ERROR: Could not insert field <strong>' .
$vars[
'name'] .
'</strong> into the database. '.implode(
' ', $field->getErrors()) . $this->db->error() .
'</span>';
249 function insert(&$obj, $force =
false, $checkObject =
true)
252 foreach ($uservars as
$var) {
253 unset($obj->vars[$var]);
255 if (count($obj->vars) == 0) {
258 return parent::insert($obj, $force, $checkObject);
269 return $this->_fHandler->getUserVars();
285 $searchvars_user = array_intersect($searchvars, $uservars);
286 $searchvars_profile = array_diff($searchvars, $uservars);
287 $sv = array(
'u.uid, u.uname, u.email, u.user_viewemail');
288 if (!empty($searchvars_user)) {
289 $sv[0] .=
",u." . implode(
", u.", $searchvars_user);
291 if (!empty($searchvars_profile)) {
292 $sv[] =
"p." . implode(
", p.", $searchvars_profile);
295 $sql_select =
"SELECT " . (empty($searchvars) ?
"u.*, p.*" : implode(
", ", $sv));
296 $sql_from =
" FROM " . $this->db->prefix(
"users") .
" AS u LEFT JOIN " . $this->table .
" AS p ON u.uid=p.profile_id" .
297 (empty(
$groups) ?
"" :
" LEFT JOIN " . $this->db->prefix(
"groups_users_link") .
" AS g ON u.uid=g.uid");
298 $sql_clause =
" WHERE 1=1";
303 $sql_clause .=
" AND " .
$criteria->render();
312 $sql_clause .=
" AND g.groupid IN (" . implode(
", ",
$groups) .
")";
315 $sql_users = $sql_select . $sql_from . $sql_clause . $sql_order;
319 return array(array(), array(), 0);
325 while ($myrow = $this->db->fetchArray(
$result)) {
329 foreach ($myrow as $name => $value) {
330 if (in_array($name, $uservars)) {
331 $user->assignVar($name, $value);
336 $profiles[$myrow[
'uid']] =
$profile;
337 $users[$myrow[
'uid']] =
$user;
340 $count = count($users);
342 $sql_count =
"SELECT COUNT(*)" . $sql_from . $sql_clause;
344 list($count) = $this->db->fetchRow(
$result);
347 return array($users, $profiles, intval($count));