LiveUser_Admin
[ class tree: LiveUser_Admin ] [ index: LiveUser_Admin ] [ all elements ]

Source for file ImplyRights.php

Documentation is available at ImplyRights.php

  1. <?php
  2. require_once 'index.php';
  3. echo '<h3>ImplyRights</h3>';
  4.  
  5. $rights $admin->perm->getRights();
  6. if  (empty($rights)) {
  7.     echo 'Run the <b>Right</b> test first<br />';
  8.     exit;
  9. }
  10. echo '<hr />';
  11.  
  12. // add
  13. for ($i = 0; $i < 25; $i++{
  14.     $right array_rand($rights);
  15.     $imright array_rand($rights);
  16.     $data = array(
  17.         'right_id' => $rights[$right]['right_id'],
  18.         'implied_right_id' => $rights[$imright]['right_id']
  19.     );
  20.     $result $admin->perm->implyRight($data);
  21.     if ($result === false{
  22.         echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  23.         print_r($admin->getErrors());
  24.     else {
  25.         echo '<strong>' $rights[$imright]['right_id''</strong> is now 
  26.               implied right from <strong>'$rights[$right]['right_id'.'</strong><br />';
  27.     }
  28. }
  29. // view all
  30. echo 'All the rights:<br />';
  31. $rights $admin->perm->getRights();
  32. if ($rights === false{
  33.     echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  34.     print_r($admin->getErrors());
  35. elseif (empty($rights)) {
  36.     echo 'No rights were found, thus we\'ve halted the rest of the test<br />';
  37. else {
  38.     Var_Dump::display($rights);
  39.     echo '<br />';
  40.  
  41.     // delete
  42.     // By right id
  43.     $id array_rand($rights);
  44.     $filters = array('right_id' => $rights[$id]['right_id']);
  45.     $unimply $admin->perm->unimplyRight($filters);
  46.  
  47.     if ($unimply === false{
  48.         echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  49.         print_r($admin->getErrors());
  50.     else {
  51.         echo 'Removed all records with the right id <strong>' $rights[$id]['right_id''</strong><br />';
  52.         unset($rights[$id]);
  53.     }
  54.  
  55.     // By implied right id
  56.     $id array_rand($rights);
  57.     $filters = array('implied_right_id' => $rights[$id]['right_id']);
  58.     $unimply $admin->perm->unimplyRight($filters);
  59.  
  60.     if ($unimply === false{
  61.         echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  62.         print_r($admin->getErrors());
  63.     else {
  64.         echo 'Removed all records with the implied right id <strong>' $rights[$id]['right_id''</strong><br />';
  65.         unset($rights[$id]);
  66.     }
  67.  
  68.     // By implied right id and right id
  69.     $right array_rand($rights);
  70.     $impliedRight array_rand($rights);
  71.  
  72.     $filters = array(
  73.         'right_id' => $rights[$right]['right_id'],
  74.         'implied_right_id' => $rights[$impliedRight]['right_id']
  75.     );
  76.     $unimply $admin->perm->unimplyRight($filters);
  77.  
  78.     if ($unimply === false{
  79.         echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  80.         print_r($admin->getErrors());
  81.     else {
  82.         echo 'Removed the record that has <strong>' $rights[$right]['right_id''</strong>
  83.               as right id  and <strong>' $rights[$impliedRight]['right_id''</strong> as implied right id<br />';
  84.     }
  85.  
  86.     // view all
  87.     echo 'All the rights:<br />';
  88.     $rights $admin->perm->getRights();
  89.     if ($rights === false{
  90.         echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  91.         print_r($admin->getErrors());
  92.     elseif (empty($rights)) {
  93.         echo 'No rights were found<br />';
  94.     else {
  95.         Var_Dump::display($rights);
  96.         echo '<br />';
  97.     }
  98. }
  99. echo '<hr />';

Documentation generated on Mon, 11 Mar 2019 14:16:44 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.