/** * Add new userdata record * @param int $user_id User ID * @param array $fields Associative array with field ID as KEY and field value as VAL */ function addNewUserData($user_id, $fields = array()) { // Get available userdata fields _pcpin_loadClass('userdata_field'); $userdata_field = new PCPIN_UserData_Field($this); $userdata_field->_db_getList('id,default_value'); $list = $userdata_field->_db_list; $userdata_field->_db_freeList(); $fields_new = array(); foreach ($list as $data) { if (isset($fields[$data['id']])) { $fields_new[$data['id']] = $fields[$data['id']]; } else { $fields_new[$data['id']] = $data['default_value']; } } // Insert data rows $this->user_id = $user_id; foreach ($fields_new as $key => $val) { $this->field_id = $key; $this->field_value = $val; $this->_db_insertObj(); } }
* * "PCPIN Chat 6" is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * "PCPIN Chat 6" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ _pcpin_loadClass('userdata_field'); $userdata_field = new PCPIN_UserData_Field($session); if (!isset($field_id)) { $field_id = 0; } $status = -1; $messages = array(); if (is_object($session) && !empty($current_user->id) && $session->_s_user_id == $current_user->id && $current_user->is_admin === 'y') { $status = 1; if (!empty($field_id)) { if (isset($name)) { $name = trim($name); if ($name == '') { $messages[] = $l->g('name_empty_error'); } } if (isset($type) && ($type == 'choice' || $type == 'multichoice')) {
<?php /** * This file is part of "PCPIN Chat 6". * * "PCPIN Chat 6" is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * "PCPIN Chat 6" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ _pcpin_loadClass('userdata_field'); $userdata_field = new PCPIN_UserData_Field($session); $fields = array(); if (is_object($session) && !empty($current_user->id) && $session->_s_user_id == $current_user->id && $current_user->is_admin === 'y') { $xmlwriter->setHeaderMessage('OK'); $xmlwriter->setHeaderStatus(0); $fields = $userdata_field->getFields(); } $xmlwriter->setData(array('field' => $fields));
<?php /** * This file is part of "PCPIN Chat 6". * * "PCPIN Chat 6" is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * "PCPIN Chat 6" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ _pcpin_loadClass('userdata_field'); $userdata_field = new PCPIN_UserData_Field($session); if (!isset($field_id)) { $field_id = 0; } if (is_object($session) && !empty($current_user->id) && $session->_s_user_id == $current_user->id && $current_user->is_admin === 'y') { if (!empty($field_id)) { $userdata_field->deleteField($field_id); } $xmlwriter->setHeaderMessage($l->g('field_deleted')); $xmlwriter->setHeaderStatus(0); }
* * "PCPIN Chat 6" is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * "PCPIN Chat 6" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ _pcpin_loadClass('userdata_field'); $userdata_field = new PCPIN_UserData_Field($session); $status = -1; $messages = array(); if (!isset($name)) { $name = ''; } if (!isset($default_value)) { $default_value = ''; } if (!isset($type)) { $type = ''; } if (!isset($choices)) { $choices = ''; } if (!isset($visibility)) {