Subversion Repositories php_users

Rev

Rev 16 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 rodolico 1
<!DOCTYPE html>
2
<?php
3
   include_once( '../UsersDataSourceMySQLi.class.php' );
4
   include_once( '../Users.class.php' );
5
   /*
6
    * this is an example of adding additional fields to a user record
7
    * In this case, we have added a MySQL text field named where_clause
8
    * to the database. It will be displayed as a textarea in the input
9
    * forms.
10
    * While the "For Users Class" is needed only for the new User call
11
    * and the For Data Source is only used for the new usersDataSource
12
    * call, it is completely acceptable to pass all the data to both
13
    * since they will ignore any array entries they don't know how to 
14
    * handle.
15
    */
16
   $customFields = array( 
17
      'tables' => array(
18
         'users' => array(
19
            'fields' => array(
20
               'where_clause' => array(
21
                  // For Users class
22
                     // this will be the display label on the form
23
                     'label'  => 'Limit via SQL where clause',
24
                     // the input type to use for data entry
25
                     'html type' => 'textarea',
26
                     // you can only edit this if an admin and changing someone
27
                     // else' record
28
                     'restrict' => true,
29
                     // will be displayed on a hover in HTML5 (ie, title=)
30
                     'instructions' => 'This will be added to every SQL query to limit access, or 1=1 for everything',
31
                     // this is entered in an empty box, ie placeholder=
32
                     'hint'     => 'Enter an SQL where clause',
33
                     // for Data Source
34
                     'dbColumn'  =>  'where_clause',
35
                     // actual mySQL column type
36
                     'type'      => 'text',
37
                     // set it to not null if we build the table ourselves
38
                     'required'  => false,
39
                     // set a default value
40
                     'default'   => '1=1'
41
                     )
42
                  )
43
               )
44
            )
45
      );
46
 
47
 
48
   $connection = new usersDataSource( 
49
         null,
50
         $customFields, 
51
         array( 'username' => 'test', 'password' => 'test', 'database' => 'test' ) 
52
      );
53
   $connection->buildTable( 'admin', 'admin', true );
54
?>
55
<html>
56
	<head>
57
		<meta charset="utf-8">
58
		<title>Build Table</title>
59
	</head>
60
	<body>
61
      <h1>
62
      <?php
63
         if ( $connection->test() ) {
64
            print "Table (re)built";
65
         } else {
66
            print "Something went wrong, check apache2 logs";
67
         }
68
      ?>
69
      </h1>
70
	</body>
71
</html>