/** * Delete user * @param int $user_id User ID * @return boolean TRUE on success or FALSE on error */ function deleteUser($user_id) { $result = false; if (!empty($user_id) && $this->_db_getList('id', 'id = ' . $user_id, 1)) { // Delete user if ($result = $this->_db_deleteRow($user_id)) { // Delete all avatars owned by user _pcpin_loadClass('avatar'); $avatar = new PCPIN_Avatar($this); $avatar->deleteAvatar($user_id); // Delete all nicknames owned by user _pcpin_loadClass('nickname'); $nickname = new PCPIN_Nickname($this); $nickname->deleteAllNickname($user_id); // Delete all messages sent TO this user _pcpin_loadClass('message'); $message = new PCPIN_Message($this); if ($message->_db_getList('id', 'target_user_id = ' . $user_id)) { $message_ids = array(); foreach ($message->_db_list as $data) { $message_ids[] = $data['id']; } $message->_db_freeList(); $message->deleteMessages($message_ids); } // Delete userdata _pcpin_loadClass('userdata'); $userdata = new PCPIN_UserData($this); $userdata->deleteUserData($user_id); // Update all users who ignored deleted user if ($res = $this->_db_query($this->_db_makeQuery(2050, $user_id))) { $this->_db_freeResult($res); } } } return $result; }
* (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/>. */ /** * Delete avatar * @param int $avatar_id Avatar ID */ if (empty($avatar_id) || !pcpin_ctype_digit($avatar_id)) { $avatar_id = 0; } if (empty($profile_user_id) || $profile_user_id != $current_user->id && $current_user->is_admin !== 'y') { $profile_user_id = $current_user->id; } _pcpin_loadClass('avatar'); $avatar = new PCPIN_Avatar($session); _pcpin_loadClass('message'); $msg = new PCPIN_Message($session); if (!empty($profile_user_id) && !empty($avatar_id)) { // Delete avatar $avatar->deleteAvatar($profile_user_id, $avatar_id); $xmlwriter->setHeaderMessage($l->g('avatar_deleted')); $xmlwriter->setHeaderStatus(0); $msg->addMessage(1010, 'n', 0, '', $session->_s_room_id, 0, $profile_user_id); }
$current_user->_db_updateRow($current_user_set['id'], 'id', $update_args); // Update additional userdata $current_userdata->_db_getList('user_id = ' . $current_user_set['id'], 1); $current_userdata_set = $current_userdata->_db_list[0]; $current_userdata->_db_freeList(); $update_args = array(); foreach ($_pcpin_slave_userdata as $key => $val) { if (!is_null($val) && isset($current_userdata_set[$key]) && $current_userdata_set[$key] != $val) { $update_args[$key] = $val; } } if (!empty($update_args)) { $current_userdata->_db_updateRow($current_user_set['id'], 'user_id', $update_args); } // Avatar $avatar->deleteAvatar($current_user_set['id']); if (!empty($_pcpin_slave_userdata['avatar'])) { $new_avatar_data = null; if (PCPIN_IMAGE_CHECK_OK === PCPIN_Image::checkImage($new_avatar_data, $_pcpin_slave_userdata['avatar'], $session->_conf_all['avatar_image_types'], 0, 0, 0, true)) { if ($binaryfile->newBinaryFile(file_get_contents($_pcpin_slave_userdata['avatar']), $new_avatar_data['mime'], $new_avatar_data['width'], $new_avatar_data['height'], 'log')) { $avatar->addAvatar($binaryfile->id, $current_user_set['id']); } } } } } else { // User not exists yet $login = $_pcpin_slave_userdata['login']; // Create new user $current_user->newUser($_pcpin_slave_userdata['login'], PCPIN_Common::randomString(32), $_pcpin_slave_userdata['email'], $_pcpin_slave_userdata['hide_email'], 'n', ''); $current_user->password = $_pcpin_slave_userdata['password'];