Example #1
0
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) $this->_identifier["id"];
     }
     $this->__load();
     return parent::getId();
 }
 public function addAction($reception = null)
 {
     $this->view->setVar("TopMenuSelected", 'work');
     $this->view->setVar("MenuSelected", 'add');
     $this->view->setVar("MenuItemActive", $reception);
     if (!empty($reception)) {
         $this->view->setVar("countries", References::getCountries());
         $this->view->setVar("currency", References::getCurrency());
         $this->view->setVar("units_1", References::getUnits(NULL, array(1))['units']);
         $this->view->setVar("units_34", References::getUnits(NULL, array(3, 4))['units']);
         $this->view->setVar("date_on_reception_default", date('d-m-Y H:i:s'));
         $this->view->pick('/package/' . $reception);
         View::addJs($this, ['/js/async/jquery.tmpl.min.js', '/js/async/scripts_package_add.js', '/js/async/jquery.mb.browser.js', '/js/async/jquery.mousewheel.js', '/js/async/calendar_date-time.js']);
         View::addCss($this, ['/css/calendar_date-time.css']);
     }
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         $user_id = Users::getId($this);
         $station_id = Users::getStationId($this);
         $package_document = $post['cont_type'];
         if ($package_document == '0') {
             $pcp = $post['pack_cont_pl'];
             $package_contents_places = array();
             for ($i = 0; $i < count($pcp); $i++) {
                 $pcpa = $pcp[$i]['att'];
                 $package_contents_place_attachments = array();
                 for ($j = 0; $j < count($pcpa); $j++) {
                     $package_contents_place_attachments[] = array('description' => $pcpa[$j]['descr'], 'unit_count' => $pcpa[$j]['u_count'], 'units_id' => $pcpa[$j]['units'], 'unit_price' => $pcpa[$j]['price']);
                 }
                 $package_contents_places[] = array('length' => $pcp[$i]['length'], 'width' => $pcp[$i]['width'], 'height' => $pcp[$i]['height'], 'units_id' => $post['pack_cont_pl_units'], 'attachment' => $package_contents_place_attachments);
             }
             $time_arr = explode(' ', $post['date_on_reception']);
             $date_arr = explode('-', $time_arr[0]);
             $date_on_reception = $date_arr[2] . '-' . $date_arr[1] . '-' . $date_arr[0] . ' ' . $time_arr[1];
             for ($i = 0; $i < count($post['package_rec_name']); $i++) {
                 for ($j = 0; $j < count($post['package_send_name']); $j++) {
                     $package_id = Package::addNotDocument($post['package_send_name'][$i], $post['package_send_addr'][$i], $post['package_send_country'][$i], $post['package_rec_name'][$j], $post['package_rec_addr'][$j], $post['package_rec_country'][$j], $station_id, $post['pack_cont_descr_nd'], $post['pack_cont_pl_count_nd'], $post['pack_cont_weight_nd'], $post['pack_cont_curr_nd'], $package_contents_places, $post['pack_cont_comm_nd'], 'null', 'null', $post['package_send_phone'][$i], $post['package_rec_phone'][$j], $post['package_guar'], $date_on_reception);
                     /**/
                     $res = Package::setStatus($package_id[0]['package_add_all_not_document'], 2, 'true', $user_id, 'null');
                     /**/
                 }
             }
         } else {
             for ($i = 0; $i < count($post['package_rec_name']); $i++) {
                 for ($j = 0; $j < count($post['package_send_name']); $j++) {
                     $package_id = Package::addDocument($post['package_send_name'][$i], $post['package_send_addr'][$i], $post['package_send_country'][$i], $post['package_rec_name'][$j], $post['package_rec_addr'][$j], $post['package_rec_country'][$j], $station_id, $post['pack_cont_descr_d'], $post['pack_cont_pl_count_d'], $post['pack_cont_weight_d'], 'null', $post['pack_cont_comm_d'], 'null', 'null', $post['package_send_phone'][$i], $post['package_rec_phone'][$j], $post['package_guar'], $date_on_reception);
                     /**/
                     $res = Package::setStatus($package_id[0]['package_add_all_document'], 2, 'true', $user_id, 'null');
                     /**/
                 }
             }
         }
         //$this->response->redirect('/search/full/package', '/');
         //$this->view->setVar("test", $package_id);
     }
 }
 public function update(Users $user)
 {
     $id = $user->getId();
     $query = "UPDATE users SET content = '" . $content . "', id_author = '" . $id_author . "' WHERE id = '" . $id . "'";
     $result = mysqli_query($this->database, $query);
     if ($result) {
         return $this->findById($id);
     } else {
         return "Erreur serveur.";
     }
 }
Example #4
0
 public function addAction()
 {
     $this->view->title = "Send - ";
     $this->view->selectmenu = "user";
     if ($this->request->isPost()) {
         $user = new Users();
         $user->name = $this->request->getPost('name');
         $user->alias = $this->request->getPost('alias');
         $user->num = $this->request->getPost('num');
         $user->group = $this->request->getPost('group');
         $user->save();
         $response = $user->getId();
         return $this->dispatcher->forward(array('action' => 'sent', 'params' => array($this->view->title, $this->view->selectmenu, $response)));
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $environment = $this->configuration instanceof sfApplicationConfiguration ? $this->configuration->getEnvironment() : $options['env'];
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $conn = Doctrine_Manager::connection();
     $user = new Users();
     $user['given_name'] = $this->ask('Given Name :');
     $user['family_name'] = $this->ask('Family Name :');
     while ($user['family_name'] == "") {
         $this->logSection('Invalid name', "The family name can't be empty, please provide one", null, 'ERROR');
         $user['family_name'] = $this->ask('Family Name :');
     }
     $user['db_user_type'] = Users::ADMIN;
     $user->save();
     $this->logSection('User added', 'User is added with admin rights');
     $login = $this->ask('Login :'******'Invalid login', "The login can't be empty, please provide one", null, 'ERROR');
         $login = $this->ask('Login :'******'Password :'******'Invalid password', "The password can't be empty, please provide one", null, 'ERROR');
         $password = $this->ask('Password :'******'local');
     $login_info->setUserRef($user->getId());
     $login_info->save();
     $this->logSection('Widgets', "Start adding widgets for this user");
     $user->addUserWidgets();
     $this->logSection('Finished', "Widget added");
 }
 public function setUser(Users $user)
 {
     $this->id_user = $user->getId();
     return true;
 }
Example #7
0
 /**
  * Save User
  * @param Language $language
  * @return void
  */
 public function saveUser(Users $user)
 {
     try {
         if ($user->getId() == '') {
             $idGenService = new IDGeneratorService();
             $idGenService->setEntity($user);
             $user->setId($idGenService->getNextID());
         }
         $user->save();
     } catch (Exception $e) {
         throw new AdminServiceException($e->getMessage());
     }
 }
Example #8
0
<?php

include 'Blocs/toutePageConectee.php';
if ($conecte == 1) {
    $userProfile = new Users();
    if (isset($_GET['userName'])) {
        $userProfile->setIdWithUserName($_GET['userName'], $bdd);
        $userProfile->hydrateTotalWithId($bdd);
    } else {
        if (isset($_GET['userId'])) {
            $userProfile->setId($_GET['userId']);
            $userProfile->hydrateTotalWithId($bdd);
        }
    }
    $userProfile->amIFollowing($userProfile->getId(), $bdd);
    //$userProfile->getAllMyFollowers($bdd);
    //var_dump($userProfile->getMesFollowers());
} else {
    header("Location: index.php");
}
Example #9
0
    $('input[name=phone]').val(selectedOption.data('phone') );
    $('input[name=email]').val(selectedOption.data('email') );
})});
</script>
<?php 
if (!defined('__ROOT__')) {
    define('__ROOT__', dirname(dirname(__FILE__)));
}
if (!isset($_SESSION)) {
    session_start();
}
require_once __ROOT__ . '/class/Users.php';
require_once __ROOT__ . '/class/UsersList.php';
$user = new Users($_SESSION['id_user']);
$user->read();
$id = $user->getId();
$name = $user->getName();
$lastname = $user->getLastName();
$address = $user->getAddress();
$phone = $user->getPhone();
$email = $user->getMail();
if (isset($_POST['update'])) {
    $newId = $_POST['id_update'];
    $newAddress = $_POST['address'];
    $newPhone = $_POST['phone'];
    $newEmail = $_POST['email'];
    $newPass = $_POST['pass'];
    if ($newPass != '') {
        $newPass = md5($newPass);
        $updateUser = new Users($newId, null, null, $newAddress, $newPhone, $newEmail, $newPass);
        $updateUser->update();
Example #10
0
<?php 
require_once 'Classes/ListUsers.class.php';
require_once '/Blocs/toutesPagesApi.php';
$listeUsers = new ListUsers();
$listeUsers->getAllUsers($bdd);
if (isset($_GET['idUser'])) {
    $listeUsers->getListeByIdUser($_GET['idUser'], $bdd);
} else {
    if (isset($_GET['userName'])) {
        $user = new Users();
        $user->setIdWithUserName($_GET['userName'], $bdd);
        $listeUsers->getListeByIdUser($user->getId(), $bdd);
    }
}
//var_dump($listePosts->getListePosts());
$arrayToJson = $listeUsers->toArray();
$cat = SpecimensTable::getDistinctCategories();
$t->is(count($cat), 13, 'Number of differents categories: "13"');
$t->is($cat['undefined'], 'Undefined', 'get the first category: "Undefined"');
$t->is($cat['collect'], 'Collect', 'get the last category: "Collect"');
/* Prepare data for the test of findConservatories method */
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// User creation/extraction
$userEvil = Doctrine::getTable('Users')->findOneByFamilyName('Evil');
$brol_user = new Users();
$brol_user->setFamilyName('Brolus');
$brol_user->setGivenName('Brolus');
$brol_user->setDbUserType(Users::REGISTERED_USER);
$brol_user->save();
$conn = Doctrine_Manager::connection();
// Collection Rights association for the "brol" user - rights on Molusca, Amphibia  and Aves collections
$conn->exec("INSERT INTO collections_rights (collection_ref, user_ref, db_user_type)\n              (\n                SELECT id, ? , ?\n                FROM collections\n                WHERE name_indexed IN ('molusca', 'amphibia', 'aves')\n              )", array($brol_user->getId(), $brol_user->getDbUserType()));
// Building and Floor creation for specimens under Molusca and Amphibia collections
$conn->exec("UPDATE specimens\n              SET building = CASE WHEN id = 1 THEN 'De Vestel' ElSE 'Geology' END,\n                  floor = CASE WHEN id = 1 THEN '14' ElSE '-1' END\n              WHERE collection_ref IN (\n                                        SELECT id\n                                        FROM collections\n                                        WHERE name_indexed IN ('molusca', 'amphibia')\n                                      )\n            ");
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$t->info('Test of "findConservatories" - part 1 - registered user - building list searched');
$conservatories_counts = Doctrine::getTable("Specimens")->findConservatories($brol_user, 'building', array());
$t->is('', $conservatories_counts[0]['item'], '"1" specimen in "empty" building (in aves collection)');
$t->is(1, $conservatories_counts[0]['ctn'], '"1" specimen in "empty" building in (aves collection)');
$t->is('De Vestel', $conservatories_counts[1]['item'], '"1" specimen in building "De Vestel"');
$t->is(1, $conservatories_counts[1]['ctn'], '"1" specimen in building "De Vestel"');
$t->is('Geology', $conservatories_counts[2]['item'], '"2" specimen in building "Geology"');
$t->is(2, $conservatories_counts[2]['ctn'], '"2" specimen in building "De Vestel"');
$t->info('Test of "findConservatories" - part 2 - registered user - floor list searched for "De Vestel" building');
$floor_counts = Doctrine::getTable("Specimens")->findConservatories($brol_user, 'floor', array("building" => $conservatories_counts[2]['item']));
$t->is('-1', $floor_counts[0]['item'], '"2" specimens on floor "-1" for "Geology" building');
$t->is(2, $floor_counts[0]['ctn'], '"2" specimens on floor "-1" for "Geology" building');
Example #12
0
 public function deleteAction($user_login)
 {
     $this->getConnectedUser()->assertRight('user_delete');
     Users::deleteOne(Users::getId($user_login));
 }
Example #13
0
 public function putAction($user_login)
 {
     Users::updateOne(Users::getId($user_login), $_POST);
     $this->setParameter('user_login', $_POST['user_login']);
 }
$t->is($widgets[0]->getOrderBy(), 2, "Is order set for everyone");
$t->is($widgets[0]->getColNum(), 2, "Is col_num set correctly");
$t->comment('->changeOrder()');
Doctrine::getTable('MyWidgets')->setUserRef($userEvil)->changeOrder('board_widget', array("savedSpecimens"), array("savedSearch"));
$widgets = Doctrine::getTable('MyWidgets')->setUserRef($userEvil)->createQuery()->andWhereIn("group_name", array("savedSpecimens", "savedSearch"))->orderBy('group_name ASC')->execute();
$t->is($widgets[0]->getOrderBy(), 1, "Is order set correctly");
$t->is($widgets[1]->getOrderBy(), 1, "Is order set for everyone");
$t->is($widgets[0]->getColNum(), 2, "Is col_num set correctly");
$t->is($widgets[1]->getColNum(), 1, "Is col_num for everyone");
$q = Doctrine_Query::create()->delete('MyWidgets p')->Where('p.user_ref = ?', $userEvil)->execute();
$t->is(count(Doctrine::getTable('MyWidgets')->setUserRef($userEvil)->getWidgets('board_widget')), 0, 'All widget would have been deleted');
$t->comment('->addWidgets()');
$brol_user = new Users();
$brol_user->setFamilyName('Brolus');
$brol_user->setGivenName('Brolus');
$brol_user->setDbUserType(Users::REGISTERED_USER);
$brol_user->save();
$brol_user->addUserWidgets();
$t->comment('->updateWigetsAvailabilityForRole()');
$t->is(count(Doctrine::getTable('MyWidgets')->setUserRef($brol_user->getId())->setDbUserType(Users::REGISTERED_USER)->getWidgets('board_widget')), 5, '6 board widgets but only 5 visible for a registered user');
$widget_workflowsSummary = Doctrine_Query::create()->from("MyWidgets p")->where("p.user_ref = ?", array($brol_user->getId()))->andWhere("p.category = ?", array("board_widget"))->andWhere("p.group_name = ?", array("workflowsSummary"))->fetchArray();
$collection_mollusca = Doctrine_Query::create()->select("c.id")->from("Collections c")->where("c.name = ?", array("Molusca"))->fetchArray();
$t->info('Testing the "doUpdateWidgetRight" method');
Doctrine::getTable('MyWidgets')->setUserRef($brol_user->getId())->setDbUserType(Users::REGISTERED_USER)->doUpdateWidgetRight($collection_mollusca[0]['id'], array($widget_workflowsSummary[0]['id']), 'insert');
$widget_workflowsSummary = Doctrine_Query::create()->from("MyWidgets p")->where("p.user_ref = ?", array($brol_user->getId()))->andWhere("p.category = ?", array("board_widget"))->andWhere("p.group_name = ?", array("workflowsSummary"))->fetchArray();
$t->is(count(Doctrine::getTable('MyWidgets')->setUserRef($brol_user->getId())->setDbUserType(Users::REGISTERED_USER)->getWidgets('board_widget', $collection_mollusca[0]['id'])), 6, '6 board widgets if Molusca collection given');
$t->info('Testing the "doUpdateWidgetRight" method - clap 2nd: remove of Mollusca collection for workflowsSummary widget');
Doctrine::getTable('MyWidgets')->setUserRef($brol_user->getId())->setDbUserType(Users::REGISTERED_USER)->doUpdateWidgetRight($collection_mollusca[0]['id'], array($widget_workflowsSummary[0]['id']), 'delete');
$t->is(count(Doctrine::getTable('MyWidgets')->setUserRef($brol_user->getId())->setDbUserType(Users::REGISTERED_USER)->getWidgets('board_widget', $collection_mollusca[0]['id'])), 5, 'Back to 5 board widgets even with Molusca collection given');
Doctrine::getTable('MyWidgets')->setUserRef($brol_user->getId())->updateWigetsAvailabilityForRole(Users::REGISTERED_USER, false);
$t->is(count(Doctrine::getTable('MyWidgets')->setUserRef($brol_user->getId())->getWidgets('board_widget')), 1, 'Removing \'Registered user\' right : 1 board widgets visible now (stats)');
Example #15
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(4, new lime_output_color());
$t->comment('->getUserByPassword()');
$t->is(Doctrine::getTable('Users')->getUserByPassword("root", "brol"), false, 'Test the local login with a wrong password');
$t->is(Doctrine::getTable('Users')->getUserByPassword("root", "evil")->getFamilyName(), "Evil", 'Test the local login with a good password');
$t->is('' . Doctrine::getTable('Users')->getUserByPassword("root", "evil"), "Evil Root (Mr)", 'Test the local login with a good password');
$u = Doctrine::getTable('Users')->getUserByPassword("root", "evil");
$nu = new Users();
$nu->setFamilyName('Chambert');
$nu->setGivenName('Yann');
$nu->setGender('M');
$nu->setDbUserType(1);
$nu->setIsPhysical(true);
$nu->save();
$t->comment('->findUser()');
$t->is(Doctrine::getTable('Users')->findUser($nu->getId())->getFamilyName(), 'Chambert', 'User Chambert is created');
$uli = new UsersLoginInfos();
Example #16
0
 /**
  * set session
  */
 public function setSession(\Users $user)
 {
     Session::set('auth', array('id' => $user->getId()));
 }
Example #17
0
 private function getParams(Users $Users)
 {
     $params = array(':id' => $Users->getId(), ':username' => $Users->getUsername(), ':email' => $Users->getEmail(), ':password' => $Users->getPassword());
     if ($Users->getId()) {
         // unset created date, this one is never updated
         unset($params[':created_on']);
     }
     return $params;
 }
Example #18
0
<?php

require_once 'Classes/ListePosts.class.php';
require_once '/Blocs/toutesPagesApi.php';
$listePosts = new ListePosts();
if (isset($_GET['idUser'])) {
    $listePosts->getListeByIdUser($_GET['idUser'], $bdd);
} else {
    if (isset($_GET['userName'])) {
        $user = new Users();
        $user->setIdWithUserName($_GET['userName'], $bdd);
        $listePosts->getListeByIdUser($user->getId(), $bdd);
    }
}
//var_dump($listePosts->getListePosts());
$arrayToJson = $listePosts->toArray();