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

Source for file admin_example.php

Documentation is available at admin_example.php

  1. <?php
  2. require_once 'conf.php';
  3. require_once 'LiveUser/Admin/Perm/Container/DB_Medium.php';
  4. require_once 'LiveUser/Admin/Auth/Container/DB.php';
  5.  
  6. $lu_dsn = array('dsn' => $dsn);
  7.  
  8. $objRightsAdminAuth = new
  9.         $lu_dsn, $conf['authContainers'][0]
  10.     );
  11.  
  12. $objRightsAdminPerm = new
  13.     LiveUser_Admin_Perm_Container_DB_Medium($lu_dsn, $conf);
  14.  
  15. if (!$objRightsAdminPerm->init_ok) {
  16.     die('impossible to initialize' . $objRightsAdminPerm->getMessage());
  17. }
  18.  
  19. $objRightsAdminPerm->setCurrentLanguage('FR');
  20.  
  21. // Add a user to the database
  22. // LiveUser design allowing for several containers
  23. // the user must be added to both containers
  24. $user_auth_id = $objRightsAdminAuth->addUser('johndoe', 'dummypass', true);
  25.  
  26. if (DB::isError($user_auth_id)) {
  27.     $user_auth_id->getMessage();
  28.     //exit;
  29. }
  30.  
  31. $user_perm_id = $objRightsAdminPerm->addUser($user_auth_id);
  32.  
  33. echo '$user_id created ' . $user_auth_id . "\n";
  34.  
  35. // create application and areas
  36. $app_id = $objRightsAdminPerm->addApplication('LIVEUSER', 'website');
  37. $area_id = $objRightsAdminPerm->addArea($app_id, 'ONLY_AREA', 'the one and only area');
  38.  
  39.  
  40. // Then he adds three rights
  41. $right_1 = $objRightsAdminPerm->addright($area_id, 'MODIFYNEWS',   'read something');
  42. $right_2 = $objRightsAdminPerm->addright($area_id, 'EDITNEWS',  'write something');
  43.  
  44. echo 'Created two rights with id ' . $right_1 . ' and ' . $right_2 . "\n";
  45.  
  46. // Grant the user rights
  47. $objRightsAdminPerm->grantUserRight($user_perm_id, $right_1);
  48. $objRightsAdminPerm->grantUserRight($user_perm_id, $right_2);
  49.  
  50. $cols = array(
  51.     'name',
  52.     'email'
  53.     );
  54.  
  55. $filters = array(
  56.     array('email' => array('op' => '=', 'value' => 'fleh@example.com', 'cond' => ''))
  57. );
  58.  
  59. $userInfo = $objRightsAdminAuth->getUsers($filters, $cols);
  60. print_r($userInfo);
  61. ?>

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