public function testChangePassword(FunctionalTester $I) { $I->amGoingTo('test the change password functionality'); // Create one user $user = Commons::createUser(); $I->amGoingTo('login a user'); $loginPage = LoginPage::openBy($I); $loginPage->login(Commons::TEST_EMAIL, Commons::TEST_PASSWORD); $changePasswordPage = ChangePasswordPage::openBy($I); $I->see('Change password'); $I->seeElement('#changepasswordform-newpassword'); $I->seeElement('#changepasswordform-newpasswordrepeat'); $I->dontSeeElement('#changepasswordform-email'); $I->dontSeeElement('#changepasswordform-oldpassword'); $I->amGoingTo('try to change the password with two different passwords for the new password and the new password repeat fields'); $changePasswordPage->changePassword('123123', '234234'); $I->expect('the form will catch the difference'); $I->see('The new passwords are not the same.'); $I->amGoingTo('test adding new password with length lower than the default length'); $changePasswordPage->changePassword('123', '123'); $I->expect('the form will warn the user'); $I->see('New password should contain at least 6 characters'); $I->see('New password repeat should contain at least 6 characters'); $I->amGoingTo('change the password of the user properly'); $changePasswordPage->changePassword('Nik)lay!23', 'Nik)lay!23'); $I->expect('that this time everything will be ok and the user will be redirected to the home page'); $user->refresh(); $I->assertNotNull($user->password_changed_at); $I->seeInCurrentUrl('/'); }
private function validaElector($miembro) { $_esElector = false; $eleccion = Commons::eleccionVigente(); $elector = Elector::model()->find('idmiembro=:idmiembro AND ideleccion=:ideleccion AND estado=:estado', array(':idmiembro' => $miembro->idmiembro, ':ideleccion' => $eleccion->ideleccion, ':estado' => '1')); if (isset($elector)) { $_esElector = false; } return $_esElector; }
public function rptVotosPorMiembro($etapa) { $_selected = array(); $_sql = "SELECT\n\t\t\tCONCAT_WS(' ', UPPER(miembro.apepat), UPPER(miembro.apemat), UPPER(miembro.nombre)) as nombre,\n\t\t\tUPPER(cargo.desccargo) as cargo\n\t\t\tfrom\n\t\t\tvotacion votacion\n\t\t\tJOIN elector elector USING(idelector)\n\t\t\tJOIN elegible elegible USING(idelegible)\n\t\t\tJOIN miembro miembro ON miembro.idmiembro = elegible.idmiembro\n\t\t\tJOIN cargo cargo USING(idcargo)\n\t\t\tWHERE\n\t\t\telector.idelector = :idelector\n\t\t\tAND elegible.ideleccion = :ideleccion\n\t\t\tAND elegible.estado = '1'\n\t\t\tAND votacion.idetapavotacion = :idetapavotacion\n\t\t\tORDER BY\n\t\t\tcargo.idcargo"; $_params = array(':idelector' => Commons::electorVigente()->idelector, ':ideleccion' => Commons::eleccionVigente()->ideleccion, ':idetapavotacion' => $etapa); $reader = Yii::app()->db->createCommand($_sql)->query($_params); foreach ($reader as $row) { array_push($_selected, array('nombre' => $row['nombre'], 'cargo' => $row['cargo'])); } return $_selected; }
public function testResetPassword(FunctionalTester $I) { $user = Commons::createUnconfirmedUser(); $token = Commons::createTokenForUser($user->id); $I->amGoingTo('test that the reset password functionality is working properly'); $I->amGoingTo('to confirm the email for the user'); PasswordResetPage::openBy($I, ['code' => $token->code]); $I->expectTo('see successful reset'); $I->dontSeeRecord(Token::className(), ['user_id' => $user->id]); $I->expectTo('see the user is sent to the change password form'); $I->see('Change password'); $I->seeElement('#changepasswordform-newpassword'); $I->seeElement('#changepasswordform-newpasswordrepeat'); }
public function actionDatosgral() { // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $model = new DatosgralForm(); $model = $model->cargaDatosGenerales(Commons::miembroActivo()->idmiembro); if (isset($_POST['DatosgralForm'])) { // $valid = true; $model->attributes = $_POST['DatosgralForm']; $valid = $model->validate(); Yii::log('submit -> ' . print_r($_POST, true)); Yii::log('model->attributes -> ' . print_r($model->attributes, true)); if ($model->validate()) { $model->guardaDatosGenerales(Commons::miembroActivo()->idmiembro); } else { // CVarDumper::dump($model->getErrors(),5678,true); // Yii::app()->end(); } } $this->render('datosgral', array('model' => $model)); }
public function actionVotar($idetapa) { $model = new VotacionesForm(); $idcargo = null; Yii::log('POST ' . print_r($_POST, true)); if (isset($_POST['envia-votaciones'])) { Yii::log('idelegible ' . $_POST['cid'][0] . ' idcargo ' . $_POST['VotacionesForm']['idcargo_hidden'] . ' idetapa ' . $idetapa); if (isset($_POST['VotacionesForm']['idcargo_hidden'])) { $idcargo = $_POST['VotacionesForm']['idcargo_hidden']; } if (isset($_POST['cid'])) { $idelegible = $_POST['cid'][0]; $model->salvaVotacion($idelegible, $idcargo, $idetapa); } } else { if (isset($_POST['confirma-votaciones'])) { // Guarda como definitivas las votaciones $model->confirmaVotacion($idetapa); } } $this->render('votar', array('idetapa' => $idetapa, 'idelector' => Commons::electorVigente()->idelector, 'data' => $model->resumenVotacion($idetapa))); }
require_once dirname(__FILE__) . '/../../config.php'; global $USER, $CFG; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php'; require_once $CFG->dirroot . '/blocks/webgd_community/menus/Commons.php'; $ultimo_post = optional_param('ultimo_post', 0, PARAM_INT); $id_comunidade = optional_param('id_comunidade', 0, PARAM_INT); require_login(1); $retorno = array('ultimo_post' => $ultimo_post, 'mensagem' => '', 'atualizar' => '0'); $novo_ultimo = $ultimo_post; $webgbDao = new WebgdCommunityDao(); if ($communities = $webgbDao->getAllCommunityPostSince($id_comunidade, $ultimo_post)) { foreach ($communities as $community) { if ($USER->id == $community->userid) { $retorno['mensagem'] .= Commons::printListPost($community, 1, $id_comunidade, 1); //$retorno['mensagem'] .= "userid: ".$community->userid." id:".$community->id." "; } else { $retorno['mensagem'] .= Commons::printListPost($community, 0, $id_comunidade, 1); //$retorno['mensagem'] .= "userid: ".$community->userid." id:".$community->id." "; } if ($novo_ultimo == $ultimo_post) { $novo_ultimo = $community->id; } } } if ($novo_ultimo != $ultimo_post) { $retorno['atualizar'] = '1'; } $retorno['ultimo_post'] = $novo_ultimo; $retorno = json_encode($retorno); echo $retorno;
<?php require_once './php/config.php'; require_once './php/admin_config.php'; require_once './php/db_connect.php'; require_once './php/commons.php'; require_once './php/db_functions.php'; require_once './php/modes.php'; require_once './php/admin_modes.php'; require_once './php/admin_db_functions.php'; $modes = new Modes(); $db = new DBFunctions(); $admin_modes = new AdminModes(); $admin_db = new AdminDBFunctions(); $commons = new Commons(); // set to UTC $db->setMYSQLTimeZone('+08:00'); date_default_timezone_set('Australia/Perth') or die('timezone error'); // no echo / print_r / var_dump $response = array(); $response[KEY_STATUS] = R_STATUS_FAILED; if (SETTING_ERROR) { $response[KEY_ERROR_CODE] = E_UNKNOWN; $response[KEY_ERROR_MESSAGE] = EM_UNKNOWN; } foreach ($_REQUEST as $key => $value) { $_REQUEST[$key] = $commons->clean($value); } if (!isset($_REQUEST[KEY_MODE])) { $response[KEY_STATUS] = R_STATUS_FAILED; if (SETTING_ERROR) {
$PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('standard'); $PAGE->requires->css(CssResources::LIST_HOME_COMMUNITY); echo $OUTPUT->header('themeselector'); $webgdCommunityDao = new WebgdCommunityDao(); if ($listCommunity = $webgdCommunityDao->getListCommunity()) { echo '<span class="titulo_list">' . $OUTPUT->heading(get_string('comunidades', 'block_webgd_community')) . '</span>'; echo '<div class="lista_home">'; echo '<span class="titulo_list"></span>'; foreach ($listCommunity as $community) { $participar = ""; $fechada = 0; if (!$webgdCommunityDao->findUserInCommunityById($community->id, $USER->id)) { if ($community->close_community == 1) { $participar = "<img class='botao_comunidade' src='" . $CFG->wwwroot . ImageResources::COMUNIDADE_FECHADA . "'>"; $fechada = 1; } else { $participar = "<div>" . html_writer::tag('a', "<img class='botao_comunidade' src='" . $CFG->wwwroot . ImageResources::PARTICIPAR_COMUNIDADE . "'>", array('href' => "view.php?community={$community->id}&confirm=1")) . "</div>"; } } else { if ($community->close_community == 1) { $participar = "<img class='botao_comunidade' src='" . $CFG->wwwroot . ImageResources::COMUNIDADE_FECHADA . "'>"; } } Commons::printListHomeCommunity($community, $participar, $fechada); } echo '<div>'; } else { echo get_string('nenhumaComunidadeRegistrada', 'block_webgd_community'); } echo $OUTPUT->footer();
require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php'; require_once $CFG->dirroot . '/blocks/webgd_community/commons/TableResouces.php'; require_once $CFG->dirroot . '/blocks/webgd_community/menus/Commons.php'; require_login(1); global $USER, $DB; $idCommunity = optional_param('community', 0, PARAM_INT); $message = optional_param('message', '', PARAM_TEXT); $webgbDao = new WebgdCommunityDao(); try { $transaction = $DB->start_delegated_transaction(); $post = new stdClass(); $post->community = $idCommunity; $post->userid = $USER->id; $post->time = time(); $post->type = 'text'; $idPost = $webgbDao->insertRecordInTableCommunityPost($post); $postText = new stdClass(); $postText->post = $idPost; $postText->message = $message; $webgbDao->insertRecordInTableCommunityText($postText); $transaction->allow_commit(); if ($communities = $webgbDao->getAllCommunityPost($idCommunity)) { foreach ($communities as $community) { Commons::printListPost($community); } } } catch (Exception $e) { $transaction->rollback($e); }
$connection = new ConnectionDB(); $user = new User($connection, "byEmail", "*****@*****.**"); Commons::print_r($user); // if($user->isUser())Commons::print_r($user); // $password = "******"; // $user = new User($connection,"byPass", "*****@*****.**", $password); // Commons::print_r($user); $newUser = new User($connection, "byEmail", "*****@*****.**"); if (!$newUser->isUser()) { $newUser->setEmail("*****@*****.**"); $newUser->setPassword("locoporvos"); $newUser->setName("Carlos"); $newUser->setLastName("Molina"); $newUser->create($connection); } else { Commons::print_r("The user already exits"); } // if($user->isUser()){$user->setEnabled($connection ,0);}; // Commons::print_r($user); // if(!$user->isEnabled()){$user->setEnabled($connection ,1);}; // Commons::print_r($user); // $user-> updatePassword($connection, $password); // Commons::print_r($user); // $newUser = new User($connection,"byPass", "*****@*****.**", $password); // Commons::print_r($newUser); function writeGetter($value) { $tittle = ucfirst($value); echo "public function get{$tittle}(){<br>\n return \$this->{$value};<br>\n }<br><br>"; } function writeSetter($value)
use nkostadinov\user\models\User; use nkostadinov\user\tests\_pages\LoginPage; use nkostadinov\user\tests\_pages\LogoutPage; $I = new FunctionalTester($scenario); $I->wantTo('see that login works.'); $loginPage = LoginPage::openBy($I); $I->see('Login', 'h3'); //empty username and password $loginPage->login('', ''); $I->expectTo('see validations errors'); $I->see('Username cannot be blank.'); $I->see('Password cannot be blank.'); //wrong username and password $loginPage->login('test', 'test'); $I->expectTo('see validations errors'); $I->see('Incorrect username or password'); //see the forgot password link $I->seeLink('Forgot password?', '/user/recovery/request'); // Test that the login works Commons::createUserWithUsername(); $loginPage->login(Commons::TEST_EMAIL, Commons::TEST_PASSWORD); $I->seeInCurrentUrl('/'); // Logout the user LogoutPage::openBy($I); // Log the user in again $loginPage = LoginPage::openBy($I); // Test that the login works with the username as well $loginPage->login(Commons::TEST_USERNAME, Commons::TEST_PASSWORD); $I->seeInCurrentUrl('/'); User::deleteAll('email = :email', [':email' => Commons::TEST_EMAIL]);
public function muestraIconoVisepres() { $_display = 'none'; $_vis4 = Commons::validaCargo(Commons::miembroActivo()->idmiembro, 4); $_vis5 = Commons::validaCargo(Commons::miembroActivo()->idmiembro, 5); $_vis6 = Commons::validaCargo(Commons::miembroActivo()->idmiembro, 6); $_vis7 = Commons::validaCargo(Commons::miembroActivo()->idmiembro, 7); if ($_vis4 || $_vis5 || $_vis6 || $_vis7) { $_display = 'inline'; } return $_display; }
* This page provides the Administration -> ... -> Theme selector UI. * * @package core * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->dirroot . '/blocks/webgd_community/commons/TableResouces.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php'; require_once $CFG->dirroot . '/blocks/webgd_community/menus/Commons.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/ImageResources.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/CssResources.php'; require_login(1); global $USER, $DB, $CFG; $PAGE->set_url('/course/index.php'); $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('standard'); $PAGE->requires->css(CssResources::LIST_HOME_COMMUNITY); echo $OUTPUT->header('themeselector'); $webgdCommunityDao = new WebgdCommunityDao(); if ($listCommunity = $webgdCommunityDao->getListMyCommunityByUser($USER->id)) { echo '<div class="lista_home">'; echo '<span class="titulo_list">' . $OUTPUT->heading('Minhas Comunidades') . '</span>'; foreach ($listCommunity as $community) { Commons::printListMyCommunity($community); } echo '<div>'; } else { echo get_string('nenhumaComunidadeRegistrada', 'block_webgd_community'); } echo $OUTPUT->footer();
function mentalMapsPage($webgbDao, $idCommunity) { global $USER; $webgdCommunity = new WebgdCommunityDao(); $listMaps = $webgdCommunity->allLinksByCommunity($idCommunity, 'map'); Commons::printListMap($listMaps, $idCommunity, false); }
function generateNewUserId() { $commons = new Commons(); $randomString = $commons->generateRandomString(10); $query = "\n\t\t\tSELECT * FROM " . TAB_USERS . " \n\t\t\tWHERE \t" . COL_USER_ID . " = '{$randomString}' "; $result = $this->mysqli->query($query); if (!$this->mysqli->connect_errno) { if ($result->num_rows == 1) { return $this->generateNewUserId(); } else { return $randomString; } } return false; }
public static function printTimelineComments($idpost, $automatico = 0) { global $CFG, $OUTPUT; $webgdCommunity = new WebgdCommunityDao(); $postComment = $webgdCommunity->postCommentById($idpost); $resposta = ""; foreach ($postComment as $comment) { $images = self::imageById($comment->userid); $resposta .= "<div class='conteudo_post'>\n <div class='titulo_post'>\n <span class='icone_user'>"; foreach ($images as $img) { $resposta .= $OUTPUT->user_picture($img, array('size' => 25, 'alttext' => false, 'link' => false)); } $resposta .= "</span> <span class='nome_criador'>" . html_writer::tag('a', $comment->firstname, array('href' => $CFG->wwwroot . '/user/profile.php?id=' . $comment->userid)) . "</span>\n " . get_string('publicouEm', 'block_webgd_community') . "\n <div class='data'>" . strftime('%d de %B de %Y às %H %M %S ', $comment->time) . "</div>\n </span>\n <div class='informacoes_post'>\n <span>" . Commons::make_links_blank($comment->comentario) . "</span>\n </div></div></div>"; } if ($automatico) { return $resposta; } else { echo $resposta; } }
public function confirmaVotacion($_etapa) { $sql = "SELECT\n\t\t votacion.idvotacion\n\t\tFROM\n\t\t votacion\n\t\t JOIN elegible USING (idelegible)\n\t\tWHERE\n\t\t votacion.idelector = :idelector\n\t\t AND elegible.ideleccion = :ideleccion\n\t\t AND votacion.idetapavotacion = :idetapavotacion\n\t\t AND votacion.estado = '0'"; $_params = array(':idelector' => Commons::electorVigente()->idelector, ':ideleccion' => Commons::eleccionVigente()->ideleccion, ':idetapavotacion' => $_etapa); Yii::log('Parametros ' . print_r($_params, true)); $_list = Yii::app()->db->createCommand($sql)->queryColumn($_params); Yii::log('Lista ' . print_r($_list, true)); foreach ($_list as $_item) { $votacion = Votacion::model()->find('idvotacion=' . $_item); $votacion->estado = '1'; $votacion->save(); } }
public function actionRptcomvota($idetapa) { $model = new ReportesForm(); $this->render('rptcomvota', array('votos' => $model->rptVotosPorMiembro($idetapa), 'idelector' => Commons::electorVigente())); }
public function testChangePasswordAfterFirstLogin() { // Asure that everything is configured properly verify('Check that the advanced directory exists', is_dir(Commons::ADVANCED_MIGRATIONS_DIR))->true(); $files = scandir(Commons::ADVANCED_MIGRATIONS_DIR); $result = preg_grep('/' . self::ATTR_REQUIRE_PASSWORD_CHANGE . '/', $files); verify('Check that the migration exists', $result)->notEmpty(); verify('Check that the field is added to the table (the migration is run)', (new User())->hasAttribute(self::ATTR_REQUIRE_PASSWORD_CHANGE))->true(); // Behavior validations $behavior = Yii::$app->user->attachBehavior('firstLoginPolicy', 'nkostadinov\\user\\behaviors\\FirstLoginPolicyBehavior'); verify('Check that the behavior exists', $behavior)->notNull(); $user = Commons::createUser(); // Defaults validations verify('Check that the default value of the ' . self::ATTR_REQUIRE_PASSWORD_CHANGE . ' field is set to 1', $user->require_password_change)->equals(1); // The user is required to change his password on a first login verify('Check that the login fails', Yii::$app->user->login($user))->false(); // Change the password of the user and check the user is logged in $changePasswordForm = new ChangePasswordForm(); $changePasswordForm->email = Commons::TEST_EMAIL; $changePasswordForm->oldPassword = Commons::TEST_PASSWORD; $changePasswordForm->newPassword = '******'; $changePasswordForm->newPasswordRepeat = 'Risto-Bageristo1'; $changePasswordForm->changePassword(); // The user is logged in after a password change $user->refresh(); verify('Asure the ' . self::ATTR_REQUIRE_PASSWORD_CHANGE . ' is set to 0', $user->require_password_change)->equals(0); verify('Check that the login passes', Yii::$app->user->isGuest)->false(); Yii::$app->user->logout(); // Logout the user to continue testing without a logged in user }