private function updatePhoto() { if (isset($this->facebookUser['picture']['data']['url'])) { $this->Users->clear(); $this->Users->id = $this->user['User']['id']; $this->Users->set(array('User' => array('photo_small' => $this->facebookUser['picture']['data']['url']))); $this->Users->save($this->Users->data, false, array('photo_small')); } }
function for_id($id) { // attempt to find the user by their facebook id $user = $this->findByFacebookId($id); //if not in the db create new one if (empty($user)) { $user = new User(); $user->set('facebook_id', $id); $user->set('password', Security::hash('disabled', null, true)); $user->save(); return $user->id; } else { return $user['User']['id']; } }
public static function processAnnotations(User $user) { if ($user->hasAnnotation('net.lukasrosenstock.federatedprofile')) { $value = $user->getAnnotationValue('net.lukasrosenstock.federatedprofile'); $user->set('canonical_url', $value['profile_url']); } }
function save() { $this->import_parameters(); //we need to determine if this is a new client before we do the initial save (it won't be new once we do the //initial save $is_new = $this->is_new(); //unset params that aren't saved to the db $this->unset_param('primary_contact_name'); $this->unset_param('primary_contact_image'); $result = parent::save(); if ($is_new == true) { $primary_contact = new User($_POST['client']); $primary_contact->set('client_id', $this->id); $primary_contact->validate(); if ($primary_contact->validation_passed()) { $primary_contact->save(); //set the client email and the primary contact id $this->set('email', $primary_contact->email); $this->set('primary_contact_id', $primary_contact->id); parent::save(); } else { $this->set_error('first_name', Language::get('errors.saving_primary_contact')); return false; } } return $result; }
function getListJuegoDetalleFactura($condicion = null, $parametros = array()) { if ($condicion === null) { $condicion = ""; } else { $condicion = "where {$condicion}"; } $sql = "select ju.*, de.*, fa.*, cl.* from detalle de \r\n left join juego ju on ju.id_juego = de.id_juego \r\n left join factura fa on fa.num_factura = de.num_factura \r\n left join cliente cl on fa.id_cliente = cl.id_cliente \r\n {$condicion} ORDER BY cl.email, fa.fecha desc "; $this->bd->send($sql, $parametros); $r = array(); $contador = 0; while ($fila = $this->bd->getRow()) { $juego = new Game(); $juego->set($fila); $detalle = new Detalle(); $detalle->set($fila, 8); $factura = new Factura(); $factura->set($fila, 13); $cliente = new User(); $cliente->set($fila, 16); $r[$contador]["juego"] = $juego; $r[$contador]["factura"] = $factura; $r[$contador]["detalle"] = $detalle; $r[$contador]["cliente"] = $cliente; $contador++; } return $r; }
function panel() { $this->load->model('user'); $this->load->model('script'); $this->load->library('facebook'); if ($signedUp = $this->session->flashdata('signedUp')) { $this->session->keep_flashdata('signedUp'); $viewData['signedUp'] = $signedUp; } if ($this->input->post('changePassword')) { if ($this->_checkToken()) { $this->load->library('validation'); $rules['currentPassword'] = '******'; $rules['newPassword'] = '******'; $rules['newPasswordRepeat'] = 'required|matches[newPassword]'; $fields['currentPassword'] = '******'; $fields['newPassword'] = '******'; $fields['newPasswordRepeat'] = 'new password repeated'; $this->validation->set_rules($rules); $this->validation->set_fields($fields); if ($this->validation->run() === true) { $user = new User(); $user->setKey($this->_getUser()); $user->retrieve(); if ($user->get('password') === $user->makePass($this->input->post('currentPassword'))) { $user->set('password', $user->makePass($this->input->post('newPassword'))); $viewData['checkpoints'][] = 'You have successfully changed your password.'; $user->update(); } else { $viewData['errors'][] = 'You did not enter your current password correctly.'; } } } } $viewData['token'] = $this->_token(); $user = new User(); $script = new Script(); $user->retrieve($this->session->userdata('email')); if ($user->getType() === User::FB_CONNECT) { $viewData['email'] = false; $viewData['UID'] = $user->getKey(); $viewData['name'] = $user->name(); $viewData['institution'] = $user->institution(); if (!($subject = $user->subject())) { $subject = 'Not specified on Facebook'; } $viewData['subject'] = $subject; $viewData['fbEmail'] = $user->get('fbEmail'); } else { $viewData['email'] = $user->getKey(); $viewData['name'] = $user->get('name'); $user->get('subject') ? $viewData['subject'] = $user->get('subject') : ($viewData['subject'] = 'Not specified'); $viewData['institution'] = $user->get('institution'); } //$viewData['messages'][] = 'We are on day '.ceil((time() - 1229536800)/86400).' of the Exambuff pilot. Thanks for taking part!'; $this->_template('user/panel', 'Your account', 'my-account', $viewData); }
public function createTestData() { $user1 = new User(); $user1->set('loginname', 'foo2'); $user1->save(); $user2 = new User(); $user2->set('loginname', 'foo3'); $user2->save(); }
function get($ID) { $parametros = array(); $parametros['ID'] = $ID; $this->bd->select($this->tabla, "*", "email=:ID", $parametros); $fila = $this->bd->getRow(); $user = new User(); $user->set($fila); return $user; }
function testRetrieve() { $user = new User($this->DBI); $this->resetTestTable(); $testEmail = 'testerEmail'; $testName = 'testerName'; //set up $user->table = 'test'; // this isn't going to be allowed... $user->set('name', $testName); $user->set('email', $testEmail); //$user->{get_parent_class($user)}(); <- Big realisation - i didn't call parent::Crud(); in user's constructor! $user->create(); $this->resetModel('user'); $user->table = 'test'; $user->retrieve($testEmail); $this->assertEqual($user->get('email'), $testEmail, 'Test email correctly retrieved'); $this->assertEqual($user->get('name'), $testName, 'Test name correctly retrieved'); }
function get($ID) { $parametros = array(); $parametros['ID'] = $ID; $this->bd->select($this->tabla, "*", "id_cliente=:ID", $parametros); $fila = $this->bd->getRow(); $game = new User(); $game->set($fila); return $game; }
function getList() { $this->db->select($this->table, "*", "admin=0"); $r = array(); while ($row = $this->db->getRow()) { $user = new User(); $user->set($row); $r[] = $user; } return $r; }
function getList($page = "1", $nrpp = Constant::_NRPP, $order = "1", $params = []) { $limit = ($page - 1) * $nrpp . ',' . $nrpp; $this->db->query($this->table, '*', $params, $order, $limit); $r = []; while ($row = $this->db->getRow()) { $tmp = new User(); $tmp->set($row); $r[] = $tmp; } return $r; }
function getList($pagina = 1, $nrpp = Contants::NRPP) { $registroIni = ($pagina - 1) * $nrpp; $r = array(); $this->bd->select($this->tabla, "*", "1=1", array(), "ID, Name", "{$registroIni}, {$nrpp}"); while ($row = $this->bd->getRow()) { $user = new User(); $user->set($row); $r[] = $user; } return $r; }
function getList($page = 1, $order = "", $nrpp = Constant::NRPP) { $reg = ($page - 1) * $nrpp; $this->db->select($this->table, "*", "1=1", array(), $order, "{$reg}, {$nrpp}"); $r = array(); while ($row = $this->db->getRow()) { $user = new User(); $user->set($row); $r[] = $user; } return $r; }
function testLoginLogout() { $user = new User(); $user->set('name', 'whatever'); $user->login(); $this->assertTrue($user->isLoggedIn()); $user->logout(); $this->assertFalse($user->isLoggedIn()); $this->assertFalse($user->get('name')); }
function updateProfile() { $input = Input::parse(); if (Token::check($input['token'])) { $user = new User(); $user->set(array('name' => $input['name'], 'username' => $input['username'])); if (!$user->errors()) { $user->update(); Session::flash('success', 'Successfully updated'); Redirect::to('profile'); } else { Session::flash('error', $user->errors()); Redirect::to('profile'); } } }
function getList($pagina = 1, $orden = "", $nrpp = Constant::NRPP, $condicion = "1=1", $parametros = array()) { $ordenPredeterminado = "{$orden}, email, clave"; if ($orden === "" || $orden === null) { $ordenPredeterminado = "email, clave"; } $registroInicial = ($pagina - 1) * $nrpp; $this->bd->select($this->tabla, "*", $condicion, $parametros, $ordenPredeterminado, "{$registroInicial}, {$nrpp}"); $r = array(); while ($fila = $this->bd->getRow()) { $usuario = new User(); $usuario->set($fila); $r[] = $usuario; } return $r; }
public function save() { $model = new User(); $model->setFields($this->params); $model->set('usr_password', sha1($model->get('usr_password'))); $modelId = $model->get("usr_id"); if (!isset($modelId)) { $status = $this->saveNew($model); return $status; } else { if (UserSession::getInstance()->isLogged() !== true) { die("<h1>Forbidden resource for you.</h1>"); } $status = $this->update($model); return $status; } }
function getList($pagina = 1, $order = "", $nrpp = Constant::NRPP, $condicion = "1=1", $parametros = array()) { /*$ordenPredeterminado = "$order, Name, CountryCode, ID"; if ($order=== "" || $order === null) { $ordenPredeterminado = "Name, CountryCode, ID"; }*/ $resgistroInicial = ($pagina - 1) * $nrpp; $this->bd->select($this->tabla, "*", $condicion, $parametros, $ordenPredeterminado, "{$resgistroInicial}, {$nrpp}"); /* limite va desde 1 y saca 10 registros */ $r = array(); while ($fila = $this->bd->getRow()) { $user = new User(); $user->set($fila); $r[] = $user; } return $r; }
public function changeEmail(User $user, $oldEmail, $newEmail) { $ef = $this->getConfig('email_field', 'email'); $list_ids = $this->getDi()->newsletterUserSubscriptionTable->getSubscribedIds($user->pk()); $lists = array(); foreach ($this->getDi()->newsletterListTable->loadIds($list_ids) as $list) { if ($list->plugin_id != $this->getId()) { continue; } $lists[] = $list->plugin_list_id; } $user->set($ef, $oldEmail)->toggleFrozen(true); $this->changeSubscription($user, array(), $lists); // subscribe again $user->set($ef, $newEmail)->toggleFrozen(false); $this->changeSubscription($user, $lists, array()); }
protected function import_users($array) { foreach ($array as $user_data) { $user = new User($user_data->display_name); foreach ($user_data as $key => $value) { if (strstr($key, ':image')) { //insert image $image_key = explode(':', $key); $user->set_image($image_key[0], $value); } elseif (strstr($key, ':repeater')) { $rep_key = explode(':', $key); $user->set_repeater($rep_key[0], $value); } else { $user->set($key, $value); } } } }
/** * Verify credentials and set the right session variables * @param Database $db * @param string $handle (user name) * @param string $passwd * @return bool */ function login($db, $handle, $passwd) { require_once CLASSES . 'User.php'; $user = new User($db); $handle = str_replace(' ', '', $handle); $rv = false; if ($user->login($handle, $passwd)) { $_SESSION['user_pwd'] = $user->password; $rv = true; } else { // Login failed, set the default user $user->set(0); } $_SESSION['user_id'] = $user->id; $_SESSION['user_name'] = $user->name; $_SESSION['access'] = $user->accesslevel; return $rv; }
function getCuadroAutor($condicion = null, $parametros = array()) { if ($condicion === null) { $condicion = ""; } else { $condicion = "where {$condicion}"; } $sql = "select au.*, cu.* from autor au \n left join cuadro cu on cu.id_usuario = au.email \n {$condicion} ORDER BY au.email, cu.fecha desc "; $this->bd->send($sql, $parametros); $r = array(); $contador = 0; while ($fila = $this->bd->getRow()) { $usuario = new User(); $usuario->set($fila); $obra = new Obra(); $obra->set($fila, 12); $r[$contador]["autor"] = $usuario; $r[$contador]["cuadro"] = $obra; $contador++; } return $r; }
public function payoutInfoAction() { $form = new Am_Form(); $form->setAction($this->getUrl()); $this->getModule()->addPayoutInputs($form); $form->addSubmit('_save', array('value' => ___('Save'))); $form->addDataSource(new Am_Request($d = $this->user->toArray())); if ($form->isSubmitted() && $form->validate()) { foreach ($form->getValue() as $k => $v) { if ($k[0] == '_') { continue; } if ($k == 'aff_payout_type') { $this->user->set($k, $v); } else { $this->user->data()->set($k, $v); } } $this->user->update(); } $this->view->form = $form; $this->view->display('aff/payout-info.phtml'); }
public function employee_data_validates($user_data, $row) { $user = new User(); $user->set($user_data["User"]); $emp_data_valid = true; if (!$user->validates(array('fieldList' => array('email', 'password')))) { $emp_data_valid = false; foreach ($user->validationErrors as $field_errors) { foreach ($field_errors as $field_error) { $this->sheet_errors[] = $field_error . " at in USER sheet at row number " . $row; } } } return $emp_data_valid; }
/** * Create sample users and display a process of creating * * @param integer Group ID * @param integer Number of users */ function tool_create_sample_users($group_ID, $num_users) { global $Messages, $DB, $Debuglog; echo T_('Creating of the sample users...'); evo_flush(); /** * Disable log queries because it increases the memory and stops the process with error "Allowed memory size of X bytes exhausted..." */ $DB->log_queries = false; $count = 1; for ($i = 1; $i <= $num_users; $i++) { $login = generate_random_key(rand(3, 20), 'abcdefghijklmnopqrstuvwxyz1234567890'); while (user_exists($login)) { // Generate new unique login $login = generate_random_key(rand(3, 20), 'abcdefghijklmnopqrstuvwxyz1234567890'); } $User = new User(); // Create out of range hashes for better security $User->set('pass', generate_random_key(32, 'abcdefghijklmnopqrstuvwxyz1234567890')); $User->set('login', $login); $User->set('email', 'test_' . $i . '@test.com'); $User->set('firstname', 'Test user ' . $i); $User->set('url', 'http://www.test-' . rand(1, 3) . '.com/test_user_' . $i); $User->set('grp_ID', $group_ID); $User->dbinsert(); $count++; if ($count % 100 == 0) { // Display a process of creating by one dot for 100 users echo ' .'; evo_flush(); } // Clear all debug messages, To avoid an error about full memory $Debuglog->clear('all'); } echo ' OK.'; $Messages->add(sprintf(T_('Created %d users.'), $num_users), 'success'); }
public function testSet() { $user = new User(); $this->assertEqual($user->get('name'),null); $user->set('name', 'Jack'); $this->assertEqual($user->get('name'), 'Jack'); $user->save(); $user = $this->connection->getTable('User')->find($user->identifier()); $this->assertEqual($user->get('name'), 'Jack'); $user->set('name', 'Jack'); $this->assertEqual($user->get('name'), 'Jack'); }
$manager = new ManagerUser($db); $today = getdate(); $params['email'] = Request::req('email'); $params['password'] = sha1(Request::req('password')); $rpass = sha1(Request::req('password')); if ($params['password'] != $rpass) { header('Location:../../login.php?r=2'); exit; } $params['alias'] = Request::req('alias'); $params['dischargeDate'] = $today['year'] . '-' . $today['mon'] . '-' . $today['mday']; $params['active'] = 0; $params['administrator'] = 0; $params['personal'] = 0; if ($params['alias'] === '' || $params['alias'] === NULL) { $params['alias'] = $params['email']; } if (Request::req('rol') == 'administrator') { $params['administrator'] = 1; } else { if (Request::req('rol') == 'personal') { $params['personal'] = 1; } } $user = new User(); $user->set($params); $r = $manager->insert($user); $db->close(); if ($r == 1) { header('Location:../../extra/sendmail.php?user='******'alias']) . '&email=' . urlencode($params['email']) . '&time=' . Server::getRequestDate()); }
function getList($params = NULL, $proyection = '*', $order = '1', $limit = '') { if ($this->db != NULL) { $this->db->read($this->table, $proyection, $params); $r = array(); while ($param = $this->db->getRow()) { $user = new User(); $user->set($param); $r[] = $user; } return $r; } return NULL; }
protected function changeUserPassword() { $user = new User(); $user->clauseSafe('user_id', Application::param('user_id')); $user->also('Group'); $this->user_to_edit = $user; if (Application::param('user_password')) { $form = Form::load('pilot.views.UserPassword'); if ($form->validate()) { $user->set('user_password', Password::cryptPassword(Application::param('user_password'))); $user->save(); $this->state = 'main'; $this->saved = 'Successfully changed password for ' . $user->toString(); $this->user_to_edit = NULL; } else { $this->state = 'change_user_password'; } } else { $this->state = 'change_user_password'; } }