function updateRight($id) { if (is_null($id)) { Functions::setResponse(400); } $data = Functions::getJSONData(); try { $s = new Right($id); foreach ($s->getFields() as $field) { $value = Functions::elt($data, $field['name']); if (is_null($value)) { Functions::setResponse(400); } $s->set($field['name'], $value); } $s->set('id', $id); $s->save(); return true; } catch (RuntimeException $e) { Functions::setResponse(404); } }
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> */
<?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(); } }
$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']); $user->setFirstName($fn); $user->setName($n); $user->setToken(sha1(time() . rand(0, 1000))); $user->setState(1); $user->setRank($rank->getId()); $user->save(); global $myUser;
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()); }
*/ require_once 'Sensor.class.php'; $table = new Sensor(); $table->create(); require_once 'SensorType.class.php'; $table2 = new SensorType(); $table2->create(); $s1 = new Section(); $s1->setLabel('sensor'); $s1->save(); $s2 = new Section(); $s2->setLabel('sensortypes'); $s2->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(); $r2 = new Right(); $r2->setSection($s2->getId()); $r2->setRead('1'); $r2->setDelete('1'); $r2->setCreate('1'); $r2->setUpdate('1'); $r2->setRank('1'); $r2->save(); $conf = new Configuration(); $conf->put('plugin_sensor_receptor_pin', '0');