function updateProperties($user_id, $properties) { if (empty($properties)) { return; } $user = $this->getBy('id', $user_id); //filling other properties foreach ($user->properties as $k => $v) { if (!isset($properties[$k])) { $properties[$k] = $v; } } //cleaning values foreach ($properties as &$p) { if ($p === 'false') { $p = false; } if ($p === 'true') { $p = true; } } require_once APPPATH . 'models/cacheManagers/user_cm.php'; $cm = new user_cm($user->username); $cache = $cm->delete(); $this->update(array('properties' => json_encode($properties)), array('id' => $user_id)); }
function removeAjax() { $user = $this->auth->getUser(); $this->load->model('feed'); $this->load->model('subscription'); $subscription = $this->subscription->removeTwitter($user->id); $this->feed->delete(array('id' => $subscription->feed_id)); $this->user->update(array('twitter_uid' => null), array('id' => $user->id)); require_once APPPATH . 'models/cacheManagers/user_cm.php'; $cm = new user_cm($user->username); $cache = $cm->delete(); $this->sendToAjax(array('success' => true)); }
function saveSettingsAjax() { $response = array(); $post = $this->input->post(); $user = $this->auth->getUser(); if (count($post) == 0) { $response['success'] = false; $this->sendToAjax($response); } $data = array(); $properties = array(); foreach ($post as $field => $value) { if (substr($field, 0, 9) === 'property_') { $field = substr($field, 9); if ($field == 'isAdmin') { exit; } if ($value == '1') { $value = true; } if ($value == '0') { $value = false; } $properties[$field] = $value; } else { $data[$field] = $value; } } $this->user->updateProperties($user->id, $properties); if (!empty($data)) { $this->user->update($data, array('id' => $user->id)); } require_once APPPATH . 'models/cacheManagers/user_cm.php'; $cm = new user_cm($user->username); $cache = $cm->delete(); $response['success'] = true; $this->sendToAjax($response); }
function usernameStillValid($username) { $user = $this->user->getBy('username', $username); if (is_object($user) && $user->active == 1) { return true; } require_once APPPATH . 'models/cacheManagers/user_cm.php'; $cm = new user_cm($username); $cache = $cm->delete(); $this->logout($username); return false; }
function resetPasswordAction() { $code = $this->getParam('code'); $password = $this->input->post('password'); $this->load->model('reset_password'); $user = $this->reset_password->fetchAssociatedUser($code); $this->__default(); $this->setLayoutVar('title', 'Reset Password'); $this->setLayoutVar('url', 'reset_password'); if (!$user) { $this->setView('reset_password_expired', 'pages'); } else { if (!empty($password)) { $sha1 = sha1($password); $this->user->update(array('password' => $sha1), array('id' => $user->id)); $this->reset_password->delete(array('email' => $user->email)); //reset cache require_once APPPATH . 'models/cacheManagers/user_cm.php'; $cm = new user_cm($user->username); $cache = $cm->delete(); $this->setView('password_was_reset', 'pages'); } else { $data = array('user' => $user); $this->setView('reset_password', 'pages', $data); } } }