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

Source for file Area_Admin_Areas.php

Documentation is available at Area_Admin_Areas.php

  1. <?php
  2. require_once 'index.php';
  3. echo '<h3>Area Admin Areas</h3>';
  4.  
  5. $applications $admin->perm->getApplications();
  6. if ($applications === false{
  7.     echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  8.     print_r($admin->getErrors());
  9. elseif  (empty($applications)) {
  10.     echo 'Run the <strong>Application</strong> test first<br />';
  11.     exit;
  12. }
  13.  
  14. $areas $admin->perm->getAreas();
  15. if ($areas === false{
  16.     echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  17.     print_r($admin->getErrors());
  18. elseif (empty($areas)) {
  19.     echo 'Run the <strong>Areas</strong> test first<br />';
  20.     exit;
  21. }
  22.  
  23. $users $admin->getUsers(array('filters' => array('perm_type' => '3')));
  24. if ($users === false{
  25.     echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  26.     print_r($admin->getErrors());
  27. elseif (empty($users)) {
  28.     echo 'Please run the <a href="User.php'.$qstring.'">User</a> file to be able to test the area admin part.<br />';
  29.     exit;
  30. }
  31.  
  32. // Add
  33. for ($i = 0; $i < 15; $i++{
  34.     $id array_rand($areas);
  35.     $uid array_rand($users);
  36.  
  37.     $data = array(
  38.         'area_id' => $areas[$id]['area_id'],
  39.         'perm_user_id' => $users[$uid]['perm_user_id']
  40.     );
  41.  
  42.     $result $admin->perm->addAreaAdmin($data);
  43.     if ($result === false{
  44.         echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  45.         print_r($admin->getErrors());
  46.     else {
  47.         echo 'perm user id <strong>' $users[$uid]['perm_user_id''</strong> was added as admin over area id <strong>' $areas[$id]['area_id''</strong><br />';
  48.     }
  49. }
  50.  
  51. // Remove
  52. // By area id
  53. $id array_rand($areas);
  54. $filters = array(
  55.     'area_id' => $areas[$id]['area_id']
  56. );
  57.  
  58. $filter = array('filters' => $filters);
  59. $result $admin->perm->getAreas($filter);
  60. echo '<br /><br />The area admins we\'re about to remove<br />';
  61. Var_Dump::display($result);
  62.  
  63. $result $admin->perm->removeAreaAdmin($filters);
  64.  
  65. if ($result === false{
  66.     echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  67.     print_r($admin->getErrors());
  68. else {
  69.    echo 'Removed area admin with area id <strong>' $areas[$id]['area_id''</strong><br />';
  70. }
  71.  
  72. unset($areas[$id]);
  73.  
  74. // by right id
  75. $uid array_rand($users);
  76. $filters = array(
  77.     'perm_user_id' => $users[$uid]['perm_user_id'],
  78. );
  79.  
  80. $filter = array('filters' => $filters);
  81. $result $admin->perm->getAreas($filter);
  82. echo '<br /><br />The areas that the admin was over and we\'re about to remove<br />';
  83. Var_Dump::display($result);
  84.  
  85. $result $admin->perm->removeAreaAdmin($filters);
  86.  
  87. if ($result === false{
  88.     echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  89.     print_r($admin->getErrors());
  90. else {
  91.     echo 'Removed area admin with perm user id <strong>' $users[$uid]['perm_user_id''</strong><br />';
  92. }
  93.  
  94. unset($users[$uid]);
  95.  
  96. // by area and right id
  97. $id array_rand($areas);
  98. $uid array_rand($users);
  99. $filters = array(
  100.     'perm_user_id' => $users[$uid]['perm_user_id'],
  101.     'area_id' => $areas[$id]['area_id']
  102. );
  103.  
  104. $filter = array('filters' => $filters);
  105. $result $admin->perm->getAreas($filter);
  106. echo '<br /><br />The area admin we\'re about to remove<br />';
  107. Var_Dump::display($result);
  108.  
  109. $result $admin->perm->removeAreaAdmin($filters);
  110. if ($result === false{
  111.     echo '<strong>Error on line: '.__LINE__.'</strong><br />';
  112.     print_r($admin->getErrors());
  113. else {
  114.     echo 'Removed area admin with perm user id <strong>' $users[$uid]['perm_user_id''</strong>
  115.          and area id <strong>' $areas[$id]['area_id''</strong><br />';
  116. }
  117.  
  118. unset($areas[$id]);
  119. unset($users[$uid]);
  120. ?>

Documentation generated on Mon, 11 Mar 2019 15:39:42 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.