public function testCrud()
 {
     $rightAcc = new Right();
     $right = new \TMT\model\Right();
     $right->ID = 1;
     $right->rightName = "Test";
     $right->description = "Description";
     $right->rightType = "BASIC";
     $right->rightLevel = 1;
     $right->area = 1;
     $right->guid = null;
     $inserted = $rightAcc->insert($right);
     $inserted->guid = null;
     $this->assertEquals($right, $inserted);
     $right->rightName = "Updated";
     $updated = $rightAcc->update($right);
     $updated->guid = null;
     $this->assertEquals($right, $updated);
     $deleted = $rightAcc->delete($right);
     $this->assertEquals(null, $deleted->ID);
     $this->assertEquals(null, $deleted->rightName);
     $this->assertEquals(null, $deleted->description);
     $this->assertEquals(null, $deleted->rightType);
     $this->assertEquals(null, $deleted->rightLevel);
     $this->assertEquals(null, $deleted->area);
     $this->assertEquals(null, $deleted->guid);
 }
Exemple #2
0
 public static function remove($name)
 {
     $sectionManager = new Section();
     $sectionManager->load(array('label' => $name));
     $rightManager = new Right();
     $rightManager->delete(array('section' => $sectionManager->getId()));
     $sectionManager->delete(array('id' => $sectionManager->getId()));
 }
 private function getModuleRights($moduleId)
 {
     $sql = "SELECT * FROM ink_rights A INNER JOIN ink_module_rights B ON (A.rightId = B.rightId) WHERE B.moduleId = ?";
     $data = $this->runManyQuery($sql, array($moduleId));
     $rights = array();
     foreach ($data as $index => $row) {
         $right = new Right();
         $right->setProperties(array('id' => $row['rightId'], 'name' => $row['name'], 'key' => $row['key'], 'description', $row['description']));
         $rights[] = $right;
     }
     return $rights;
 }
Exemple #4
0
 public function testEither()
 {
     $addOne = function ($x) {
         return $x + 1;
     };
     $takeOne = function ($x) {
         return $x - 1;
     };
     $a = new Right(2);
     $b = new Left(2);
     $this->assertEquals($a->either($addOne, $takeOne), 1, 'Eithers a Right.');
     $this->assertEquals($b->either($addOne, $takeOne), 3, 'Eithers a Left.');
 }
Exemple #5
0
 public function testMap()
 {
     $addTwo = function ($x) {
         return $x + 2;
     };
     $id = function ($x) {
         return $x;
     };
     $a = new Right(5);
     $b = new Left(4);
     $this->assertEquals($a->map($addTwo)->either($id, $id), 7, 'Maps a Right.');
     $this->assertEquals($b->map($addTwo)->either($id, $id), 4, 'Maps a Left.');
 }
 public function getAll()
 {
     if (!isset($this->Elements) || $this->countElements() < 0) {
         return Right::getEmptyInstance();
     }
     return $this->Elements;
 }
Exemple #7
0
 public function testBimap()
 {
     $addOne = function ($x) {
         return $x + 1;
     };
     $takeOne = function ($x) {
         return $x - 1;
     };
     $id = function ($x) {
         return $x;
     };
     $a = new Right(2);
     $b = new Left(2);
     $this->assertEquals($a->bimap($addOne, $takeOne)->either($id, $id), 1, 'Bimaps a Right.');
     $this->assertEquals($b->bimap($addOne, $takeOne)->either($id, $id), 3, 'Bimaps a Left.');
 }
Exemple #8
0
 function loadRight()
 {
     $rightManager = new Right();
     $rights = $rightManager->loadAll(array('rank' => $this->getRank()));
     $sectionManager = new Section();
     foreach ($rights as $right) {
         $section = $sectionManager->getById($right->getSection());
         if (is_object($section)) {
             $this->rights[$section->getLabel()]['c'] = $right->getCreate() == '1' ? true : false;
             $this->rights[$section->getLabel()]['r'] = $right->getRead() == '1' ? true : false;
             $this->rights[$section->getLabel()]['u'] = $right->getUpdate() == '1' ? true : false;
             $this->rights[$section->getLabel()]['d'] = $right->getDelete() == '1' ? true : false;
         } else {
             $rightManager->delete(array('section' => $right->getSection()));
         }
     }
 }
 public static function actionAddUser($data)
 {
     $user = null;
     if (ControleurRights::canAddUser()) {
         $user = User::fetchEntity($data);
         if ($data['id'] != null) {
             $user->updateEntity();
         } else {
             $filter[] = User::getFilter(UserColumns::login, $user->getFirst_name() . "." . $user->getLast_name());
             $existing_users = User::getEntitySet($filter);
             if ($existing_users && count($existing_users) > 0) {
                 $user->setLogin($user->getFirst_name() . "." . $user->getLast_name() . "." . count($existing_users));
             } else {
                 $user->setLogin($user->getFirst_name() . "." . $user->getLast_name());
             }
             $user->setSalt(ControleurConnexion::mdpAleatoire(36));
             $new_password = ControleurConnexion::mdpAleatoire(10);
             $user->setPassword(sha1($new_password . $user->getSalt()));
             $user->addEntity();
             // Ajout des droits
             $right = new Right();
             $right->setId($user->getId());
             $right->setEnabled(true);
             $right->addEntity();
             // Envoi d'un mail
             $message = "<p>Bonjour " . $user->getFirst_name() . ",</p>\n\t\t\t\t<p>Votre compte A-Bime a été créé.<br><br>\n\t\t\t\tLes paramètres de connexion au site sont les suivants :<br>\n\t\t\t\tVotre identifiant est : " . $user->getLogin() . "<br>\n\t\t\t\tVotre mot de passe est : " . $new_password . "</p>\n\t\t\t\t<p>Pour vous rendre sur le site d'A-Bime, <a href='http://www.a-bime.com'>cliquez ici</a>.</p>\n\t\t\t\t<p>L'équipe A-Bime</p>";
             // Function mail
             // To
             $to = $user->getProfessional_mail();
             // Subject
             $subject = "A-Bime : création de compte";
             // Headers
             $headers = 'From: A-Bime <*****@*****.**>' . "\r\n";
             $headers .= 'Mime-Version: 1.0' . "\r\n";
             $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
             $headers .= "\r\n";
             // Message
             $msg = $message;
             // Function mail()
             /*if (! mail ( $to, $subject, $msg, $headers )) {
             			exit ( "L'envoi du mail a échoué. Merci de réessayer." );
             		}*/
         }
     }
     return $user;
 }
Exemple #10
0
 public static function checkRights($page, $action, $token)
 {
     loadClass('status');
     loadClass('token');
     loadClass('action');
     loadClass('right');
     loadClass('customer');
     if (is_null($action)) {
         Functions::setResponse(400);
     }
     $pagename = str_replace('.php', '', basename($page));
     $actionName = $pagename . '-' . $action;
     $whereClause = 'name=:name';
     $params = array(array('id' => ':name', 'value' => $actionName));
     $result = Action::search($whereClause, $params);
     if (!count($result)) {
         echo 'Please update actions and rights!';
         Functions::setResponse(500);
     }
     $action = $result[0];
     define('LOGGED_OUT_STATUS', 'standard');
     $loggedOut = false;
     if (is_null($token) || strtolower($token) == 'none') {
         $loggedOut = true;
     } else {
         $whereClause = 'value=:value';
         $params = array(array('id' => ':value', 'value' => $token));
         $result = Token::search($whereClause, $params);
         if (!count($result)) {
             Functions::setResponse(498);
         } else {
             $token = $result[0];
             $customer = new Customer($token->get('customerId'));
             $status = new Status($customer->get('statusId'));
         }
     }
     if ($loggedOut) {
         $whereClause = 'name=:name';
         $params = array(array('id' => ':name', 'value' => LOGGED_OUT_STATUS));
         $result = Status::search($whereClause, $params);
         if (!count($result)) {
             Functions::setResponse(500);
         }
         $status = $result[0];
     }
     $whereClause = 'action_id=:action_id AND status_id=:status_id';
     $params = array(array('id' => ':action_id', 'value' => $action->get('id')), array('id' => ':status_id', 'value' => $status->get('id')));
     $result = Right::search($whereClause, $params);
     if (!count($result)) {
         Functions::setResponse(401);
     }
     if ($result[0]->get('right') == 'deny') {
         Functions::setResponse(401);
     }
 }
 /**
  * @param $vars
  * @return array
  */
 public function checkAssignVarsOk($vars)
 {
     $errors = array();
     if (empty($vars['username'])) {
         $errors[] = 'AdminRightsUsernameEmpty';
     } else {
         // check if user name exists
         $member = new Member();
         $member = $member->findByUsername($vars['username']);
         if (!$member) {
             $errors[] = 'AdminRightsUsernameNotExisting';
         }
     }
     if ($vars['rightid'] == 0) {
         $errors[] = 'AdminRightsNoRightSelected';
     } else {
         // check if right is already assigned
         if (isset($member)) {
             $right = new Right($vars['rightid']);
             $assigned = $right->getRightForMember($member);
             if ($assigned) {
                 $errors[] = 'AdminRightsAlreadyAssigned';
             }
         }
     }
     if ($vars['level'] == 0) {
         $errors[] = 'AdminRightsNoLevelSelected';
     }
     if (empty($vars['scope'])) {
         $errors[] = 'AdminRightsScopeEmpty';
     } else {
         // check if scope is well formed
         if (!$this->checkScopeWellFormed($vars['scope'])) {
             $errors[] = 'AdminRightsScopeNotWellFormed';
         }
     }
     if (empty($vars['comment'])) {
         $errors[] = 'AdminRightsCommentEmpty';
     }
     return $errors;
 }
 public function testRightsPropagationViaRoles()
 {
     $parentRole = Role::getByName('Sales Manager');
     $childRole = Role::getByName('Sales Person');
     $childChildRole = Role::getByName('Junior Sales Person');
     $userInParentRole = $parentRole->users[0];
     $userInChildRole = $childRole->users[0];
     $userInChildChildRole = $childChildRole->users[0];
     $this->assertEquals(Right::DENY, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInChildRole->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $this->assertTrue($userInChildRole->save());
     $this->assertEquals(Right::ALLOW, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::ALLOW, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInParentRole->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API, Right::DENY);
     $this->assertTrue($userInParentRole->save());
     $this->assertEquals(Right::ALLOW, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInParentRole->removeRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $this->assertTrue($userInParentRole->save());
     $this->assertEquals(Right::ALLOW, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::ALLOW, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInChildRole->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API, Right::DENY);
     $this->assertTrue($userInChildRole->save());
     $this->assertEquals(Right::DENY, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInParentRole->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $this->assertTrue($userInParentRole->save());
     $this->assertEquals(Right::DENY, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::ALLOW, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInParentRole->removeRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $this->assertTrue($userInParentRole->save());
     $this->assertEquals(Right::DENY, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInChildRole->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $this->assertTrue($userInChildRole->save());
     $this->assertEquals(Right::ALLOW, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::ALLOW, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInChildRole->removeRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $this->assertTrue($userInChildRole->save());
     $this->assertEquals(Right::DENY, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $userInChildChildRole->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $this->assertTrue($userInChildChildRole->save());
     $this->assertEquals(Right::ALLOW, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::ALLOW, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::ALLOW, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     Right::deleteAll();
     //Clear the cache since the method above removeAll calls directly to the database.
     RightsCache::forgetAll();
     $userInParentRoleId = $userInParentRole->id;
     $userInChildRoleId = $userInChildRole->id;
     $userInChildChildRoleId = $userInChildChildRole->id;
     RedBeanModel::forgetAll();
     unset($userInParentRole);
     unset($userInChildRole);
     unset($userInChildChildRole);
     $userInParentRole = User::getById($userInParentRoleId);
     $userInChildRole = User::getById($userInChildRoleId);
     $userInChildChildRole = User::getById($userInChildChildRoleId);
     $this->assertEquals(Right::DENY, $userInParentRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
     $this->assertEquals(Right::DENY, $userInChildChildRole->getEffectiveRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API));
 }
Exemple #13
0
 /**
  * @inheritdoc
  * @return Right
  */
 public static function ofRight($value)
 {
     return Right::of($value);
 }
Exemple #14
0
 /**
  *
  * @param string $email        	
  * @param string $password        	
  * @param string $right        	
  * @param boolean $actif        	
  */
 public static function create($email, $password, $right, $actif)
 {
     // Vérifie que les champs soit du bon format.
     if (!Tools::isStringValid($email) || !Tools::isStringValid($password) || !Tools::isStringValid($right) || !Tools::isBooleanValid($actif)) {
         throw new Exception("Invalid user arguments type.");
     }
     // Vérifie s'il s'agit d'un email.
     if (!Tools::verifyEmail($email)) {
         throw new Exception("Invalid email format.");
     }
     // Vérifie que l'utilisateur n'existe pas déjà.
     if (User::findByEmail($email) != null) {
         throw new Exception("Invalid email, user already exist.");
     }
     // Crée un nouvel utilisateur.
     $user = new User();
     // Récupère le droit utilisateur.
     $user->right = Right::findByName($right);
     if ($user->right == null) {
         throw new Exception("Invalid right.");
     }
     // Set les autres paramètres
     $user->id = null;
     $user->email = $email;
     $user->photo = "";
     $user->salt = Tools::randomSalt();
     $user->password = Tools::doHash($password, $user->salt);
     $user->actif = $actif;
     try {
         // Effectue une connexion à la DB.
         $pdo = DBconnect();
         // Commence la transaction.
         $pdo->beginTransaction();
         // Prépare la requête.
         $stmt = $pdo->prepare("INSERT INTO t_user(email, password, salt, actif, fk_right) VALUES (:email, :password, :salt, :actif, :fk_right)");
         $stmt->bindParam(":email", $user->email);
         $stmt->bindParam(":password", $user->password);
         $stmt->bindParam(":salt", $user->salt);
         $stmt->bindParam(":actif", $user->actif);
         $stmt->bindParam(":fk_right", $user->right->getId());
         if ($stmt->execute()) {
             $pdo->commit();
         } else {
             throw new Exception();
         }
     } catch (Exception $e) {
         // Revient en arrière si une erreur c'est produite.
         $pdo->rollBack();
         // Envoie à nouveau une exception.
         throw new Exception("Create user aborted , an error occurated.");
     } finally {
         // Ferme le traitement.
         $stmt->closeCursor();
         // Ferme la connexion vers la base de donnée.
         $pdo = null;
     }
 }
Exemple #15
0
function infoFields()
{
    $s = new Right();
    return $s->getFields();
}
foreach ($actions as $action) {
    foreach ($statuses as $status) {
        $listRights[] = $action->get('id') . '.' . $status->get('id');
    }
}
$oldrights = array();
foreach ($rights as $right) {
    $actionId = $right->get('actionId');
    $statusId = $right->get('statusId');
    if (!in_array($actionId . '.' . $statusId, $listRights)) {
        echo "Deleting ({$actionId},{$statusId})<br />\n";
        $right->delete();
    } else {
        $oldrights[] = $actionId . '.' . $statusId;
    }
}
foreach ($actions as $action) {
    foreach ($statuses as $status) {
        $actionId = $action->get('id');
        $statusId = $status->get('id');
        if (!in_array($actionId . '.' . $statusId, $oldrights)) {
            echo "Adding ({$actionId},{$statusId})<br />\n";
            $new = new Right();
            $new->set('actionId', $actionId);
            $new->set('statusId', $statusId);
            $new->set('right', 'deny');
            $new->save();
        }
    }
}
/* </controller> */
Exemple #17
0
 /**
  * @param	Right $right The right object to add.
  */
 protected function doAddRight($right)
 {
     $this->collRights[] = $right;
     $right->setPage($this);
 }
Exemple #18
0
 /**
  * Filter the query by a related Right object
  *
  * @param   Right|PropelObjectCollection $right  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 PageQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByRight($right, $comparison = null)
 {
     if ($right instanceof Right) {
         return $this->addUsingAlias(PagePeer::ID, $right->getPageId(), $comparison);
     } elseif ($right instanceof PropelObjectCollection) {
         return $this->useRightQuery()->filterByPrimaryKeys($right->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByRight() only accepts arguments of type Right or PropelCollection');
     }
 }
Exemple #19
0
<?php

require_once 'Widget.class.php';
$table = new Widget();
$table->drop();
$table_section = new Section();
$id_section = $table_section->load(array("label" => "dashboard"))->getId();
$table_section->delete(array('label' => 'dashboard'));
$table_right = new Right();
$table_right->delete(array('section' => $id_section));
 public function remove()
 {
     $this->checkRights('Rights');
     $rightId = $this->route_vars['id'];
     $username = $this->route_vars['username'];
     // Check if right and user exist and if right is assigned to user at all; redirect if not
     $right = new Right($rightId);
     if (!$right) {
         $this->redirectAbsolute($this->router->url('admin_rights_overview'));
     }
     $temp = new Member();
     $member = $temp->findByUsername($username);
     if (!$member) {
         $this->redirectAbsolute($this->router->url('admin_rights_overview'));
     }
     $assigned = $right->getRightForMember($member);
     if (!$assigned) {
         $this->redirectAbsolute($this->router->url('admin_rights_overview'));
     }
     $page = new AdminRightsRemovePage();
     $rights = $this->model->getRights(true);
     $page->rights = $rights;
     $redirectTo = '';
     if (isset($_SERVER['HTTP_REFERER'])) {
         if (strpos($_SERVER['HTTP_REFERER'], "/list/members") !== false) {
             $redirectTo = 'members';
         }
         if (strpos($_SERVER['HTTP_REFERER'], "/list/member/") !== false) {
             $redirectTo = 'member';
         }
         if (strpos($_SERVER['HTTP_REFERER'], "/list/rights") !== false) {
             $redirectTo = 'rights';
         }
         if (strpos($_SERVER['HTTP_REFERER'], "/list/right/") !== false) {
             $redirectTo = 'right';
         }
     }
     $vars = array('username' => $username, 'right' => $rightId, 'level' => $assigned->Level, 'scope' => $assigned->Scope, 'comment' => $assigned->Comment, 'redirect' => $redirectTo);
     $page->vars = $vars;
     return $page;
 }
Exemple #21
0
         $selected = $rankManager->getById($id_modrank);
         $description = $selected->getLabel();
         $button = "Modifier";
         $tpl->assign('id_modrank', $id_modrank);
         $tpl->assign('label_rank', $selected->getLabel());
         $tpl->assign('description_rank', $selected->getDescription());
     } else {
         $description = "Ajout d'un rang";
         $button = "Ajouter";
     }
     $tpl->assign('description', $description);
     $tpl->assign('button', $button);
     $tpl->assign('ranks', $ranks);
     break;
 case 'right':
     $rightManager = new Right();
     $sectionManager = new Section();
     $rank = new Rank();
     $rank = $rank->getById($_['id']);
     $rights = $rightManager->loadAll(array('rank' => $_['id']));
     $rightsDictionnary = array();
     foreach ($rights as $value) {
         $rightsDictionnary[$value->getSection()]['c'] = $value->getCreate();
         $rightsDictionnary[$value->getSection()]['r'] = $value->getRead();
         $rightsDictionnary[$value->getSection()]['u'] = $value->getUpdate();
         $rightsDictionnary[$value->getSection()]['d'] = $value->getDelete();
     }
     $tpl->assign('rights', $rightsDictionnary);
     $tpl->assign('sections', $sectionManager->populate('label'));
     $tpl->assign('rank', $rank);
     break;
Exemple #22
0
 public static function canAddSkills($id_user = null)
 {
     $rights = Right::getEntity(ControleurRights::parseUser($id_user));
     return $rights->getAdd_skill();
 }
Exemple #23
0
             break;
         case 'u':
             $right->setUpdate($_['state']);
             break;
         case 'd':
             $right->setDelete($_['state']);
             break;
     }
     $right->setRank($_['rank']);
     $right->save();
     break;
     if (!$myUser->can('configuration', 'd')) {
         exit('ERREUR: Permissions insuffisantes.');
     }
 case 'access_delete_right':
     $rankManager = new Right();
     $rankManager->delete(array('id' => $_['id']));
     Functions::goback("setting", "right", "&id=" . $_['rankRight']);
     break;
 case 'logout':
     global $conf;
     //Détruire le cookie uniquement s'il existe sur cette ordinateur
     //Afin de le garder dans la BD pour les autres ordinateurs/navigateurs
     if (isset($_COOKIE[$conf->get('COOKIE_NAME')])) {
         $user = new User();
         $user = $userManager->load(array("id" => $myUser->getId()));
         $user->setCookie("");
         $user->save();
         Functions::destroyCookie($conf->get('COOKIE_NAME'));
     }
     $_SESSION = array();
Exemple #24
0
 public static function actionGetEntity()
 {
     if (isset($_GET['t']) && $_GET['t']) {
         $table = $_GET['t'];
         if (isset($_GET['i']) && $_GET['i'] && $_GET['i'] != null) {
             $id = $_GET['i'];
         } else {
             $id = null;
         }
         if ($table == 'customers' && ControleurRights::canAddCustomer()) {
             return Customer::getEntity($id);
         } elseif ($table == 'team_member' && ControleurRights::canAddTeamMember()) {
             $member = TeamMember::getEntity($id);
             $member->setSkills(Skill::getSkillsForUser($id));
             return $member;
         } elseif ($table == 'users' && ControleurRights::canAddUser()) {
             $user = User::getEntity($id);
             $user->setPicture();
             return $user;
         } elseif ($table == 'projects' && ControleurRights::canDisplayProjects()) {
             $project = Project::getEntity($id);
             $project->setSkills(Skill::getSkillsForProject($id));
             return $project;
         } elseif ($table == 'plans' && ControleurRights::canDisplayPlans()) {
             return Plan::getEntity($id);
         } elseif ($table == 'right' && ControleurRights::canAddUser()) {
             $right = Right::getEntity($id);
             $rightClass = new ReflectionClass('RightColumnsLabel');
             $right->setLabels($rightClass->getConstants());
             return $right;
         } elseif ($table == 'skills' && ControleurRights::canAddSkills()) {
             return Skill::getEntity($id);
         } else {
             return "Table " . $table . " non configurée dans le CRUD ou interdiction d'accès à l'utilisateur";
         }
     }
 }
Exemple #25
0
<?php

require_once 'KodiCmd.class.php';
$table = new KodiCmd();
$table->create();
$s1 = new Section();
$s1->setLabel('kodi');
$s1->save();
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$conf = new Configuration();
$conf->put('plugin_kodiCmd_api_url_kodi', 'http://192.168.1.107:85/jsonrpc');
$conf->put('plugin_kodiCmd_api_timeout_kodi', 5);
$conf->put('plugin_kodiCmd_api_recognition_status', '');
$ro = new Room();
$ro->setName('KODI');
$ro->setDescription('De la bonne zic, un bon p\'tit film....');
$ro->save();
$roomManager = new Room();
$rooms = $roomManager->populate();
foreach ($rooms as $room) {
    if ($room->getName() == "KODI") {
        $kodiRoomId = $room->getId();
    }
}
Exemple #26
0
 $configuration->put('VOCAL_ENTITY_NAME', 'YANA');
 $configuration->put('PROGRAM_VERSION', '3.0.6');
 $configuration->put('HOME_PAGE', 'index.php');
 $configuration->put('VOCAL_SENSITIVITY', '0.0');
 //Création du rang admin
 $rank = new Rank();
 $rank->setLabel('admin');
 $rank->save();
 //Déclaration des sections du programme
 $sections = array('event', 'vocal', 'user', 'plugin', 'configuration', 'admin');
 //Création des sections déclarées et attribution de tous les droits sur toutes ces sections pour l'admin
 foreach ($sections as $sectionName) {
     $s = new Section();
     $s->setLabel($sectionName);
     $s->save();
     $r = new Right();
     $r->setSection($s->getId());
     $r->setRead('1');
     $r->setDelete('1');
     $r->setCreate('1');
     $r->setUpdate('1');
     $r->setRank($rank->getId());
     $r->save();
 }
 $personalities = array('John Travolta', 'Jeff Buckley', 'Tom Cruise', 'John Lennon', 'Emmet Brown', 'Geo trouvetou', 'Luke Skywalker', 'Mac Gyver', 'Marty McFly');
 $im = $personalities[rand(0, count($personalities) - 1)];
 list($fn, $n) = explode(' ', $im);
 //Creation du premier compte et assignation en admin
 $user->setMail($_POST['email']);
 $user->setPassword($_POST['password']);
 $user->setLogin($_POST['login']);
Exemple #27
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param Right $obj A Right object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         RightPeer::$instances[$key] = $obj;
     }
 }
 public function saveData($aRoleData)
 {
     $oRole = null;
     if ($this->sRoleId === null) {
         $oRole = new Role();
     } else {
         $oRole = RoleQuery::create()->findPk($this->sRoleId);
         // If the role_key has changed and the new key does not exist yet, delete the current role and create a new one
         if ($oRole->getRoleKey() !== $aRoleData['role_key']) {
             if (RoleQuery::create()->filterByRoleKey($aRoleData['role_key'])->count() === 0) {
                 $oRole->delete();
                 $oRole = new Role();
             }
         }
     }
     $this->validate($aRoleData, $oRole);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $oRole->setRoleKey($aRoleData['role_key']);
     $oRole->setDescription($aRoleData['description']);
     if (isset($aRoleData['page_id'])) {
         if (!$oRole->isNew()) {
             RightQuery::create()->filterByRole($oRole)->delete();
         }
         $aRights = array();
         foreach ($aRoleData['page_id'] as $iCounter => $sPageId) {
             $sRightKey = $sPageId . ($aRoleData['is_inherited'][$iCounter] ? "_inherited" : "_uninherited");
             if (isset($aRights[$sRightKey])) {
                 $oRight = $aRights[$sRightKey];
                 $oRight->setMayEditPageContents($oRight->getMayEditPageContents() || $aRoleData['may_edit_page_contents'][$iCounter]);
                 $oRight->setMayEditPageDetails($oRight->getMayEditPageDetails() || $aRoleData['may_edit_page_details'][$iCounter]);
                 $oRight->setMayDelete($oRight->getMayDelete() || $aRoleData['may_delete'][$iCounter]);
                 $oRight->setMayCreateChildren($oRight->getMayCreateChildren() || $aRoleData['may_create_children'][$iCounter]);
                 $oRight->setMayViewPage($oRight->getMayViewPage() || $aRoleData['may_view_page'][$iCounter]);
             } else {
                 $oRight = new Right();
                 $oRight->setPageId($sPageId);
                 $oRight->setRole($oRole);
                 $oRight->setIsInherited($aRoleData['is_inherited'][$iCounter]);
                 $oRight->setMayEditPageContents($aRoleData['may_edit_page_contents'][$iCounter]);
                 $oRight->setMayEditPageDetails($aRoleData['may_edit_page_details'][$iCounter]);
                 $oRight->setMayDelete($aRoleData['may_delete'][$iCounter]);
                 $oRight->setMayCreateChildren($aRoleData['may_create_children'][$iCounter]);
                 $oRight->setMayViewPage($aRoleData['may_view_page'][$iCounter]);
                 $aRights[$sRightKey] = $oRight;
             }
         }
         foreach ($aRights as $oRight) {
             $oRight->save();
         }
     }
     $oRole->save();
     return array('id' => $oRole->getRoleKey());
 }
Exemple #29
0
         // Vérifie email
         if (!Tools::verifyEmail($email)) {
             $formValid = false;
             $errors["email"] = "You must insert a valid email.";
         } else {
             if (User::findByEmail($email) != null) {
                 $formValid = false;
                 $errors["email"] = "Email address already used.";
             }
         }
         // Si mot de passe valide
         if (!Tools::verifyPassword($pwd)) {
             $formValid = false;
             $errors["pwd"] = "You must insert a valid password see password <a href=\"#\">hint</a>.";
         }
         if (Right::findByName($right) == null) {
             $formValid = false;
             $errors["right"] = "You must select a correct user right.";
         }
         if ($formValid) {
             try {
                 User::create($email, $pwd, $right, $actif);
             } catch (Exception $e) {
                 $formValid = false;
                 $errors["other"] = $e->getMessage();
             }
         }
     }
 } else {
     if (isset($get)) {
         if (Tools::isStringValid($get) && isDetail($get)) {
Exemple #30
0
 /**
  * Exclude object from result
  *
  * @param   Right $right Object to remove from the list of results
  *
  * @return RightQuery The current query, for fluid interface
  */
 public function prune($right = null)
 {
     if ($right) {
         $this->addUsingAlias(RightPeer::ID, $right->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }