private function generateAktuelleErgebnisse() { $db = Database::getDbObject(); $query = "SELECT `spieltag` FROM `spieltage` WHERE `datum` < CURDATE() LIMIT 1;"; $stmt = $db->prepare($query); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $id = 0; $stmt->bind_result($id); $stmt->fetch(); $spieltag = new Spieltag($id); $st = array(); $i = 0; foreach ($spieltag as $v) { $st[$i] = array(); $st[$i]['spiel'] = $v; try { $tipp = new DbTipp(User::getIdByName($_SESSION['session']->getUserName()), $v->getId()); $st[$i]['tipp'] = $tipp; } catch (TippExistiertNichtException $e) { $st[$i]['tipp'] = null; } ++$i; } $this->raintpl->assign('aktuelleErgebnisse', true); $this->raintpl->assign('aktuelleSpiele', $st); $this->raintpl->assign('spieltagAktuell', $id); } else { $this->raintpl->assign('aktuelleErgebnisse', false); } }
public function bug($id, $request) { $ticket = Ticket::find($id); $message = "Après étude de votre problème, il en résulte qu'il ne s'agit pas d'un incident isolé mais bien d'un problème technique interne à DreamVids (bug). Nous travaillons actuellement à la détection et à la résolution de ce bug mais nous ne pouvons vous donner de plus amples informations. Nous nous excusons pour la gêne occasionnée et vous remerçions de votre patience."; $this->mail($ticket, $message); if ($ticket->conv_id != '' && Conversation::exists($ticket->conv_id)) { Conversation::find($ticket->conv_id)->removeChannel(User::find(User::getIdByName($ticket->tech))->getMainChannel()); } $ticket->delete(); return new RedirectResponse(WEBROOT . 'admin/tickets'); }
/** Import a user from a specific ldap server * * @param $params array of parameters : method (IDENTIFIER_LOGIN or IDENTIFIER_EMAIL) + value * @param $action synchoronize (true) or import (false) * @param $ldap_server ID of the LDAP server to use * @param $display display message information on redirect * * @return nothing **/ static function ldapImportUserByServerId($params = array(), $action, $ldap_server, $display = false) { global $DB, $LANG; static $conn_cache = array(); $params = stripslashes_deep($params); $config_ldap = new AuthLDAP(); $res = $config_ldap->getFromDB($ldap_server); $ldap_users = array(); // we prevent some delay... if (!$res) { return false; } $search_parameters = array(); //Connect to the directory if (isset($conn_cache[$ldap_server])) { $ds = $conn_cache[$ldap_server]; } else { $ds = $config_ldap->connect(); } if ($ds) { $conn_cache[$ldap_server] = $ds; $search_parameters['method'] = $params['method']; $search_parameters['fields'][self::IDENTIFIER_LOGIN] = $config_ldap->fields['login_field']; if ($params['method'] == self::IDENTIFIER_EMAIL) { $search_parameters['fields'][self::IDENTIFIER_EMAIL] = $config_ldap->fields['email_field']; } //Get the user's dn & login $attribs = array('basedn' => $config_ldap->fields['basedn'], 'login_field' => $search_parameters['fields'][$search_parameters['method']], 'search_parameters' => $search_parameters, 'user_params' => $params, 'condition' => $config_ldap->fields['condition']); $infos = self::searchUserDn($ds, $attribs); if ($infos && $infos['dn']) { $user_dn = $infos['dn']; $login = $infos[$config_ldap->fields['login_field']]; $groups = array(); $user = new User(); //Get informations from LDAP if ($user->getFromLDAP($ds, $config_ldap->fields, $user_dn, addslashes($login))) { // Add the auth method // Force date sync $user->fields["date_sync"] = $_SESSION["glpi_currenttime"]; if ($action == self::ACTION_IMPORT) { $user->fields["authtype"] = Auth::LDAP; $user->fields["auths_id"] = $ldap_server; //Save informations in database ! $input = $user->fields; // Display message after redirect if ($display) { $input['add'] = 1; } $user->fields["id"] = $user->add($input); return array('action' => self::USER_IMPORTED, 'id' => $user->fields["id"]); } $input = $user->fields; $input['id'] = User::getIdByName($login); if ($display) { $input['update'] = 1; } $user->update($input); return array('action' => self::USER_SYNCHRONIZED, 'id' => $input['id']); } return false; } if ($action != self::ACTION_IMPORT) { $users_id = User::getIdByName($params['value']); User::manageDeletedUserInLdap($users_id); return array('action' => self::USER_DELETED_LDAP, 'id' => $users_id); } } else { return false; } }
public static function register($username, $password, $mail) { $appConfig = new Config(CONFIG . 'app.json'); $appConfig->parseFile(); $userRank = $appConfig->getValue('rankUser'); User::create(array('username' => $username, 'email' => $mail, 'pass' => password_hash($password, PASSWORD_BCRYPT), 'subscriptions' => '', 'reg_timestamp' => Utils::tps(), 'reg_ip' => $_SERVER['REMOTE_ADDR'], 'actual_ip' => $_SERVER['REMOTE_ADDR'], 'rank' => $userRank, 'settings' => json_encode(array()))); UserChannel::create(array('id' => UserChannel::generateId(6), 'name' => $username, 'description' => 'Chaîne de ' . $username, 'owner_id' => User::getIdByName($username), 'admins_ids' => ';' . User::getIdByName($username) . ';', 'avatar' => Config::getValue_('default-avatar'), 'background' => Config::getValue_('default-background'), 'subscribers' => 0, 'subs_list' => 0, 'views' => 0, 'verified' => 0)); }
$page = isset($_GET['page']) ? $_GET['page'] : 1; if(!isset($page) || empty($page)) $page = 1; $keyword = isset($_GET['keyword']) && !empty($_GET['keyword']) ? $_GET['keyword'] : ''; $type = isset($_GET['type']) && !empty($_GET['type']) ? $_GET['type'] : 'blogname'; $params = ''; if(!empty($keyword)) { $params = '&keyword=' . rawurlencode($keyword) . '&type=' . $type; if($type == 'owner') { requireComponent('Bloglounge.Model.Users'); $id = User::getId($keyword); $sQuery = ' owner = ' . $id; } else if($type == 'ownername') { requireComponent('Bloglounge.Model.Users'); $id = User::getIdByName($keyword); $sQuery = ' owner = ' . $id; } else { $sQuery = ' title LIKE "%' . $keyword . '%"'; } if(!empty($read)) { $page = Feed::getPredictionPage($read,$pageCount,$sQuery); } if($is_admin) { list($feeds, $totalFeeds) = Feed::getFeeds($page,$pageCount,$sQuery); } else { list($feeds, $totalFeeds) = Feed::getFeedsByOwner(getLoggedId(), $page, $pageCount,$sQuery); } } else { if(!empty($read)) { $page = Feed::getPredictionPage($read,$pageCount); } if($is_admin) { list($feeds, $totalFeeds) = Feed::getFeeds($page,$pageCount); } else {
/** * Add a followup to a existing ticket * for an authenticated user * * @param $params array of options (ticket, content) * @param $protocol * * @return array of hashtable **/ static function methodAddTicketFollowup($params, $protocol) { if (isset($params['help'])) { return array('ticket' => 'integer,mandatory', 'content' => 'string,mandatory', 'users_login' => 'string,optional', 'close' => 'bool,optional', 'reopen' => 'bool,optional', 'source' => 'string,optional', 'private' => 'bool,optional', 'help' => 'bool,optional'); } if (!Session::getLoginUserID()) { return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED); } $ticket = new Ticket(); if (isset($params['users_login']) && is_numeric($params['users_login'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'users_login should be a string'); } if (isset($params['users_login']) && is_string($params['users_login'])) { $user = new User(); if (!($users_id = $user->getIdByName($params['users_login']))) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'unable to get users_id with the users_login'); } } if (!isset($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket'); } if (!is_numeric($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket'); } if (!$ticket->can($params['ticket'], 'r')) { return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND); } if (!$ticket->canAddFollowups()) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray()) && !$ticket->canApprove()) { // Logged user not allowed if (isset($users_id)) { // If we get the users id $approbationSolution = self::checkApprobationSolution($users_id, $ticket); if (!$approbationSolution) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } } else { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } } if (!isset($params['content'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'content'); } // Source of the ticket, dynamically created if (isset($params['source'])) { if (empty($params['content'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'source'); } $source = Dropdown::importExternal('RequestType', $params['source']); } else { $source = Dropdown::importExternal('RequestType', 'WebServices'); } $private = isset($params['private']) && $params['private'] ? 1 : 0; $followup = new TicketFollowup(); $user = 0; if (isset($users_id)) { $user = $users_id; } $data = array('tickets_id' => $params['ticket'], 'requesttypes_id' => $source, 'is_private' => $private, 'users_id' => $user, 'content' => addslashes(Toolbox::clean_cross_side_scripting_deep($params["content"]))); if (isset($params['close'])) { if (isset($params['reopen'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'can\'t use both reopen and close options'); } if (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray())) { $data['add_close'] = 1; if (isset($users_id)) { $data['users_id'] = $users_id; } } else { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'close for not solved ticket'); } } if (isset($params['reopen'])) { if (in_array($ticket->fields['status'], array(Ticket::SOLVED, Ticket::WAITING))) { $data['add_reopen'] = 1; if (isset($users_id)) { $data['users_id'] = $users_id; } } else { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'reopen for not solved or waiting ticket'); } } if (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray()) && !isset($params['close']) && !isset($params['reopen'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'missing reopen/close option for solved ticket'); } if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'cannot add to a closed ticket'); } if ($followup->add($data)) { return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol); } return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError()); }
public function getUserId() { return User::getIdByName($this->userName); }
Validator::extend('validate_file_cobranzas', 'CustomValidation@validate_file_cobranzas', array('var1' => 'pepe')); // Validator::extend('validate_file_cobranzas_content', 'CustomValidation@validate_file_cobranzas_content', array('var1'=>'pepe')); /** * POST del login **/ Route::post('login', array('before' => 'csrf', function () { // DATOS $data = Input::all(); // Mensajes de validación $messages = array('validate_email' => 'El email ingresado no es valido.', 'validate_password' => 'La clave ingresada es incorrecta.', 'required' => 'El campo :attribute debe ser completado'); // Reglas de validación $rules = array('email' => array('validate_email', 'required'), 'password' => array('validate_password', 'required')); $validator = Validator::make($data, $rules, $messages); if ($validator->passes() || Auth::check()) { // $user_login = new User(); User::getIdByName(Input::get('email')); if (Auth::check()) { $id = Auth::id(); $user = User::find($id); $image_name = $user->image; Session::put('image_user', $image_name); return Redirect::to('homepage'); } else { return Redirect::to('homepage'); } } else { // ERROR. Clave o email incorrectos. return Redirect::to('login')->withErrors($validator); } })); Route::get('homepage', array(function () {