@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | |
30 | 30 | if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp')) |
31 | 31 | { |
32 | - ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir |
|
32 | + ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // Include PEAR::Console_Getopt |
36 | 36 | require_once 'Console/Getopt.php'; |
37 | 37 | |
38 | 38 | // Define exit codes for errors |
39 | -define('HEADER_NOT_FOUND',9); |
|
40 | -define('NO_ARGS',10); |
|
41 | -define('INVALID_OPTION',11); |
|
39 | +define('HEADER_NOT_FOUND', 9); |
|
40 | +define('NO_ARGS', 10); |
|
41 | +define('INVALID_OPTION', 11); |
|
42 | 42 | |
43 | 43 | // Reading the incoming arguments - same as $argv |
44 | 44 | $args = Console_Getopt::readPHPArgv(); |
45 | 45 | |
46 | 46 | // Make sure we got them (for non CLI binaries) |
47 | 47 | if (PEAR::isError($args)) { |
48 | - fwrite(STDERR,"importexport_cli: ".$args->getMessage()."\n".$usage); |
|
48 | + fwrite(STDERR, "importexport_cli: ".$args->getMessage()."\n".$usage); |
|
49 | 49 | exit(NO_ARGS); |
50 | 50 | } |
51 | 51 | |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | // Convert the arguments to options - check for the first argument |
66 | -if ( realpath($_SERVER['argv'][0]) == __FILE__ ) { |
|
67 | - $options = Console_Getopt::getOpt($args,$short_opts,$long_opts); |
|
66 | +if (realpath($_SERVER['argv'][0]) == __FILE__) { |
|
67 | + $options = Console_Getopt::getOpt($args, $short_opts, $long_opts); |
|
68 | 68 | } else { |
69 | - $options = Console_Getopt::getOpt2($args,$short_opts,$long_opts); |
|
69 | + $options = Console_Getopt::getOpt2($args, $short_opts, $long_opts); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Check the options are valid |
73 | 73 | if (PEAR::isError($options)) { |
74 | - fwrite(STDERR,"importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
|
74 | + fwrite(STDERR, "importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
|
75 | 75 | exit(INVALID_OPTION); |
76 | 76 | } |
77 | 77 | |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | $dryrun = true; |
99 | 99 | break; |
100 | 100 | default : |
101 | - fwrite (STDERR,$usage."\n"); |
|
101 | + fwrite(STDERR, $usage."\n"); |
|
102 | 102 | exit(INVALID_OPTION); |
103 | 103 | } |
104 | 104 | } |
105 | 105 | // check file |
106 | -if ( !$user || !$password ) { |
|
107 | - fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage); |
|
106 | +if (!$user || !$password) { |
|
107 | + fwrite(STDERR, 'importexport_cli: You have to supply a username / password'."\n".$usage); |
|
108 | 108 | exit(INVALID_OPTION); |
109 | 109 | } |
110 | 110 | |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | 'nonavbar' => True, |
118 | 118 | 'currentapp' => 'importexport', |
119 | 119 | 'autocreate_session_callback' => 'import_export_access', |
120 | - 'login' => $user . '@' . $domain, |
|
120 | + 'login' => $user.'@'.$domain, |
|
121 | 121 | 'passwd' => $password, |
122 | 122 | ); |
123 | 123 | if (!is_readable($path_to_egroupware.'/header.inc.php')) |
124 | 124 | { |
125 | - fwrite(STDERR,"importexport.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"); |
|
125 | + fwrite(STDERR, "importexport.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"); |
|
126 | 126 | exit(HEADER_NOT_FOUND); |
127 | 127 | } |
128 | 128 | include($path_to_egroupware.'/header.inc.php'); |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | // check file |
131 | 131 | if (!is_readable($file)) |
132 | 132 | { |
133 | - fwrite(STDERR,"importexport_cli: ". $file. ' is not readable'."\n"); |
|
133 | + fwrite(STDERR, "importexport_cli: ".$file.' is not readable'."\n"); |
|
134 | 134 | exit(INVALID_OPTION); |
135 | 135 | } |
136 | 136 | |
137 | 137 | $definition = new importexport_definition($definition); |
138 | -if( $definition->get_identifier() < 1 ) { |
|
139 | - fwrite(STDERR,"importexport_cli: Definition not found! \n"); |
|
138 | +if ($definition->get_identifier() < 1) { |
|
139 | + fwrite(STDERR, "importexport_cli: Definition not found! \n"); |
|
140 | 140 | exit(INVALID_OPTION); |
141 | 141 | } |
142 | 142 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | |
148 | 148 | $po = new $definition->plugin; |
149 | 149 | |
150 | -$resource = fopen( $file, 'r' ); |
|
151 | -$po->$type( $resource, $definition ); |
|
150 | +$resource = fopen($file, 'r'); |
|
151 | +$po->$type($resource, $definition); |
|
152 | 152 | |
153 | 153 | exit(); |
154 | 154 |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | --dry-run no real action, just console output |
24 | 24 | \n"; |
25 | 25 | |
26 | -if (php_sapi_name() != 'cli') { |
|
26 | +if (php_sapi_name() != 'cli') |
|
27 | +{ |
|
27 | 28 | die('This script only runs form command line'); |
28 | 29 | } |
29 | 30 | |
@@ -44,7 +45,8 @@ discard block |
||
44 | 45 | $args = Console_Getopt::readPHPArgv(); |
45 | 46 | |
46 | 47 | // Make sure we got them (for non CLI binaries) |
47 | -if (PEAR::isError($args)) { |
|
48 | +if (PEAR::isError($args)) |
|
49 | +{ |
|
48 | 50 | fwrite(STDERR,"importexport_cli: ".$args->getMessage()."\n".$usage); |
49 | 51 | exit(NO_ARGS); |
50 | 52 | } |
@@ -63,22 +65,28 @@ discard block |
||
63 | 65 | ); |
64 | 66 | |
65 | 67 | // Convert the arguments to options - check for the first argument |
66 | -if ( realpath($_SERVER['argv'][0]) == __FILE__ ) { |
|
68 | +if ( realpath($_SERVER['argv'][0]) == __FILE__ ) |
|
69 | +{ |
|
67 | 70 | $options = Console_Getopt::getOpt($args,$short_opts,$long_opts); |
68 | -} else { |
|
71 | +} |
|
72 | +else |
|
73 | +{ |
|
69 | 74 | $options = Console_Getopt::getOpt2($args,$short_opts,$long_opts); |
70 | 75 | } |
71 | 76 | |
72 | 77 | // Check the options are valid |
73 | -if (PEAR::isError($options)) { |
|
78 | +if (PEAR::isError($options)) |
|
79 | +{ |
|
74 | 80 | fwrite(STDERR,"importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
75 | 81 | exit(INVALID_OPTION); |
76 | 82 | } |
77 | 83 | |
78 | 84 | $domain = 'default'; |
79 | 85 | $dryrun = false; |
80 | -foreach ($options[0] as $option) { |
|
81 | - switch ($option[0]) { |
|
86 | +foreach ($options[0] as $option) |
|
87 | +{ |
|
88 | + switch ($option[0]) |
|
89 | + { |
|
82 | 90 | case '--file' : |
83 | 91 | $file = $option[1]; |
84 | 92 | break; |
@@ -103,7 +111,8 @@ discard block |
||
103 | 111 | } |
104 | 112 | } |
105 | 113 | // check file |
106 | -if ( !$user || !$password ) { |
|
114 | +if ( !$user || !$password ) |
|
115 | +{ |
|
107 | 116 | fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage); |
108 | 117 | exit(INVALID_OPTION); |
109 | 118 | } |
@@ -135,7 +144,8 @@ discard block |
||
135 | 144 | } |
136 | 145 | |
137 | 146 | $definition = new importexport_definition($definition); |
138 | -if( $definition->get_identifier() < 1 ) { |
|
147 | +if( $definition->get_identifier() < 1 ) |
|
148 | +{ |
|
139 | 149 | fwrite(STDERR,"importexport_cli: Definition not found! \n"); |
140 | 150 | exit(INVALID_OPTION); |
141 | 151 | } |
@@ -15,37 +15,37 @@ |
||
15 | 15 | $phpgw_baseline = array( |
16 | 16 | 'egw_admin_queue' => array( |
17 | 17 | 'fd' => array( |
18 | - 'cmd_id' => array('type' => 'auto','nullable' => False), |
|
19 | - 'cmd_uid' => array('type' => 'ascii','precision' => '64','nullable' => False), |
|
20 | - 'cmd_creator' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False), |
|
21 | - 'cmd_creator_email' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
22 | - 'cmd_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False), |
|
23 | - 'cmd_type' => array('type' => 'ascii','precision' => '32','nullable' => False,'default' => 'admin_cmd'), |
|
24 | - 'cmd_status' => array('type' => 'int','precision' => '1'), |
|
25 | - 'cmd_scheduled' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
26 | - 'cmd_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
27 | - 'cmd_modifier' => array('type' => 'int','meta' => 'user','precision' => '4'), |
|
28 | - 'cmd_modifier_email' => array('type' => 'varchar','precision' => '128'), |
|
29 | - 'cmd_error' => array('type' => 'varchar','precision' => '255'), |
|
30 | - 'cmd_errno' => array('type' => 'int','precision' => '4'), |
|
31 | - 'cmd_requested' => array('type' => 'int','precision' => '4'), |
|
32 | - 'cmd_requested_email' => array('type' => 'varchar','precision' => '128'), |
|
33 | - 'cmd_comment' => array('type' => 'varchar','precision' => '255'), |
|
34 | - 'cmd_data' => array('type' => 'ascii','precision' => '16384'), |
|
35 | - 'remote_id' => array('type' => 'int','precision' => '4') |
|
18 | + 'cmd_id' => array('type' => 'auto', 'nullable' => False), |
|
19 | + 'cmd_uid' => array('type' => 'ascii', 'precision' => '64', 'nullable' => False), |
|
20 | + 'cmd_creator' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False), |
|
21 | + 'cmd_creator_email' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
22 | + 'cmd_created' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False), |
|
23 | + 'cmd_type' => array('type' => 'ascii', 'precision' => '32', 'nullable' => False, 'default' => 'admin_cmd'), |
|
24 | + 'cmd_status' => array('type' => 'int', 'precision' => '1'), |
|
25 | + 'cmd_scheduled' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
26 | + 'cmd_modified' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
27 | + 'cmd_modifier' => array('type' => 'int', 'meta' => 'user', 'precision' => '4'), |
|
28 | + 'cmd_modifier_email' => array('type' => 'varchar', 'precision' => '128'), |
|
29 | + 'cmd_error' => array('type' => 'varchar', 'precision' => '255'), |
|
30 | + 'cmd_errno' => array('type' => 'int', 'precision' => '4'), |
|
31 | + 'cmd_requested' => array('type' => 'int', 'precision' => '4'), |
|
32 | + 'cmd_requested_email' => array('type' => 'varchar', 'precision' => '128'), |
|
33 | + 'cmd_comment' => array('type' => 'varchar', 'precision' => '255'), |
|
34 | + 'cmd_data' => array('type' => 'ascii', 'precision' => '16384'), |
|
35 | + 'remote_id' => array('type' => 'int', 'precision' => '4') |
|
36 | 36 | ), |
37 | 37 | 'pk' => array('cmd_id'), |
38 | 38 | 'fk' => array(), |
39 | - 'ix' => array('cmd_status','cmd_scheduled'), |
|
39 | + 'ix' => array('cmd_status', 'cmd_scheduled'), |
|
40 | 40 | 'uc' => array('cmd_uid') |
41 | 41 | ), |
42 | 42 | 'egw_admin_remote' => array( |
43 | 43 | 'fd' => array( |
44 | - 'remote_id' => array('type' => 'auto','nullable' => False), |
|
45 | - 'remote_name' => array('type' => 'varchar','precision' => '64','nullable' => False), |
|
46 | - 'remote_hash' => array('type' => 'ascii','precision' => '32','nullable' => False), |
|
47 | - 'remote_url' => array('type' => 'ascii','precision' => '128','nullable' => False), |
|
48 | - 'remote_domain' => array('type' => 'ascii','precision' => '64','nullable' => False) |
|
44 | + 'remote_id' => array('type' => 'auto', 'nullable' => False), |
|
45 | + 'remote_name' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False), |
|
46 | + 'remote_hash' => array('type' => 'ascii', 'precision' => '32', 'nullable' => False), |
|
47 | + 'remote_url' => array('type' => 'ascii', 'precision' => '128', 'nullable' => False), |
|
48 | + 'remote_domain' => array('type' => 'ascii', 'precision' => '64', 'nullable' => False) |
|
49 | 49 | ), |
50 | 50 | 'pk' => array('remote_id'), |
51 | 51 | 'fk' => array(), |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | |
21 | 21 | function admin_upgrade1_4() |
22 | 22 | { |
23 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_queue',array( |
|
23 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_queue', array( |
|
24 | 24 | 'fd' => array( |
25 | 25 | 'cmd_id' => array('type' => 'auto'), |
26 | - 'cmd_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
27 | - 'cmd_creator' => array('type' => 'int','precision' => '4','nullable' => False), |
|
28 | - 'cmd_creator_email' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
29 | - 'cmd_created' => array('type' => 'int','precision' => '8','nullable' => False), |
|
30 | - 'cmd_type' => array('type' => 'varchar','precision' => '32','nullable' => False,'default' => 'admin_cmd'), |
|
31 | - 'cmd_status' => array('type' => 'int','precision' => '1'), |
|
32 | - 'cmd_scheduled' => array('type' => 'int','precision' => '8'), |
|
33 | - 'cmd_modified' => array('type' => 'int','precision' => '8'), |
|
34 | - 'cmd_modifier' => array('type' => 'int','precision' => '4'), |
|
35 | - 'cmd_modifier_email' => array('type' => 'varchar','precision' => '128'), |
|
36 | - 'cmd_error' => array('type' => 'varchar','precision' => '255'), |
|
37 | - 'cmd_errno' => array('type' => 'int','precision' => '4'), |
|
38 | - 'cmd_requested' => array('type' => 'int','precision' => '4'), |
|
39 | - 'cmd_requested_email' => array('type' => 'varchar','precision' => '128'), |
|
40 | - 'cmd_comment' => array('type' => 'varchar','precision' => '255'), |
|
26 | + 'cmd_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
27 | + 'cmd_creator' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
28 | + 'cmd_creator_email' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
29 | + 'cmd_created' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
30 | + 'cmd_type' => array('type' => 'varchar', 'precision' => '32', 'nullable' => False, 'default' => 'admin_cmd'), |
|
31 | + 'cmd_status' => array('type' => 'int', 'precision' => '1'), |
|
32 | + 'cmd_scheduled' => array('type' => 'int', 'precision' => '8'), |
|
33 | + 'cmd_modified' => array('type' => 'int', 'precision' => '8'), |
|
34 | + 'cmd_modifier' => array('type' => 'int', 'precision' => '4'), |
|
35 | + 'cmd_modifier_email' => array('type' => 'varchar', 'precision' => '128'), |
|
36 | + 'cmd_error' => array('type' => 'varchar', 'precision' => '255'), |
|
37 | + 'cmd_errno' => array('type' => 'int', 'precision' => '4'), |
|
38 | + 'cmd_requested' => array('type' => 'int', 'precision' => '4'), |
|
39 | + 'cmd_requested_email' => array('type' => 'varchar', 'precision' => '128'), |
|
40 | + 'cmd_comment' => array('type' => 'varchar', 'precision' => '255'), |
|
41 | 41 | 'cmd_data' => array('type' => 'blob') |
42 | 42 | ), |
43 | 43 | 'pk' => array('cmd_id'), |
44 | 44 | 'fk' => array(), |
45 | - 'ix' => array('cmd_status','cmd_scheduled'), |
|
45 | + 'ix' => array('cmd_status', 'cmd_scheduled'), |
|
46 | 46 | 'uc' => array('cmd_uid') |
47 | 47 | )); |
48 | 48 | return $GLOBALS['setup_info']['admin']['currentver'] = '1.5.001'; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | |
52 | 52 | function admin_upgrade1_5_001() |
53 | 53 | { |
54 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_remote',array( |
|
54 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_remote', array( |
|
55 | 55 | 'fd' => array( |
56 | 56 | 'remote_id' => array('type' => 'auto'), |
57 | - 'remote_name' => array('type' => 'varchar','precision' => '64','nullable' => False), |
|
58 | - 'remote_hash' => array('type' => 'varchar','precision' => '32','nullable' => False), |
|
59 | - 'remote_url' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
60 | - 'remote_domain' => array('type' => 'varchar','precision' => '64','nullable' => False) |
|
57 | + 'remote_name' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False), |
|
58 | + 'remote_hash' => array('type' => 'varchar', 'precision' => '32', 'nullable' => False), |
|
59 | + 'remote_url' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
60 | + 'remote_domain' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False) |
|
61 | 61 | ), |
62 | 62 | 'pk' => array('remote_id'), |
63 | 63 | 'fk' => array(), |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | function admin_upgrade1_5_002() |
73 | 73 | { |
74 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','remote_id',array( |
|
74 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue', 'remote_id', array( |
|
75 | 75 | 'type' => 'int', |
76 | 76 | 'precision' => '4' |
77 | 77 | )); |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | |
111 | 111 | function admin_upgrade14_1() |
112 | 112 | { |
113 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_uid',array( |
|
113 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_uid', array( |
|
114 | 114 | 'type' => 'ascii', |
115 | 115 | 'precision' => '64', |
116 | 116 | 'nullable' => False |
117 | 117 | )); |
118 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_type',array( |
|
118 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_type', array( |
|
119 | 119 | 'type' => 'ascii', |
120 | 120 | 'precision' => '32', |
121 | 121 | 'nullable' => False, |
122 | 122 | 'default' => 'admin_cmd' |
123 | 123 | )); |
124 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_data',array( |
|
124 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_data', array( |
|
125 | 125 | 'type' => 'ascii', |
126 | 126 | 'precision' => '16384' |
127 | 127 | )); |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | |
133 | 133 | function admin_upgrade14_2_001() |
134 | 134 | { |
135 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_hash',array( |
|
135 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_hash', array( |
|
136 | 136 | 'type' => 'ascii', |
137 | 137 | 'precision' => '32', |
138 | 138 | 'nullable' => False |
139 | 139 | )); |
140 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_url',array( |
|
140 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_url', array( |
|
141 | 141 | 'type' => 'ascii', |
142 | 142 | 'precision' => '128', |
143 | 143 | 'nullable' => False |
144 | 144 | )); |
145 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_domain',array( |
|
145 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_domain', array( |
|
146 | 146 | 'type' => 'ascii', |
147 | 147 | 'precision' => '64', |
148 | 148 | 'nullable' => False |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | // asuming everythings not MySQL uses PostgreSQL regular expression syntax |
162 | 162 | $regexp = substr($GLOBALS['egw_setup']->db->Type, 0, 5) == 'mysql' ? 'REGEXP' : '~*'; |
163 | 163 | |
164 | - foreach($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_data', |
|
164 | + foreach ($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_data', |
|
165 | 165 | 'cmd_status NOT IN ('.implode(',', admin_cmd::$require_pw_stati).") AND cmd_data $regexp '(pw|passwd\\_?\\d*|password|db\\_pass)\\?\"'", |
166 | 166 | __LINE__, __FILE__, false, '', 'admin') as $row) |
167 | 167 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param string $password =null password |
26 | 26 | * @param boolean $run_addaccount_hook =null default run addaccount for new Api\Accounts and editaccount for existing ones |
27 | 27 | */ |
28 | - function __construct($account,$set=null,$password=null,$run_addaccount_hook=null) |
|
28 | + function __construct($account, $set = null, $password = null, $run_addaccount_hook = null) |
|
29 | 29 | { |
30 | 30 | if (!is_array($account)) |
31 | 31 | { |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
50 | 50 | * @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99); |
51 | 51 | */ |
52 | - protected function exec($check_only=false) |
|
52 | + protected function exec($check_only = false) |
|
53 | 53 | { |
54 | 54 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
55 | - if ($this->creator) $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
55 | + if ($this->creator) $this->_check_admin('account_access', $this->account ? 16 : 4); |
|
56 | 56 | |
57 | 57 | admin_cmd::_instanciate_accounts(); |
58 | 58 | |
@@ -68,29 +68,29 @@ discard block |
||
68 | 68 | } |
69 | 69 | if (!$data['account_lid'] && (!$this->account || !is_null($data['account_lid']))) |
70 | 70 | { |
71 | - throw new Api\Exception\WrongUserinput(lang('You must enter a loginid'),9); |
|
71 | + throw new Api\Exception\WrongUserinput(lang('You must enter a loginid'), 9); |
|
72 | 72 | } |
73 | 73 | // Check if an account already exists as system user, and if it does deny creation |
74 | 74 | if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' && |
75 | 75 | !$GLOBALS['egw_info']['server']['ldap_allow_systemusernames'] && !$data['account_id'] && |
76 | 76 | function_exists('posix_getpwnam') && posix_getpwnam($data['account_lid'])) |
77 | 77 | { |
78 | - throw new Api\Exception\WrongUserinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'),99); |
|
78 | + throw new Api\Exception\WrongUserinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'), 99); |
|
79 | 79 | } |
80 | 80 | if (!$data['account_lastname'] && (!$this->account || !is_null($data['account_lastname']))) |
81 | 81 | { |
82 | - throw new Api\Exception\WrongUserinput(lang('You must enter a lastname'),9); |
|
82 | + throw new Api\Exception\WrongUserinput(lang('You must enter a lastname'), 9); |
|
83 | 83 | } |
84 | - if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'],'account_lid','u')) && |
|
84 | + if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'], 'account_lid', 'u')) && |
|
85 | 85 | (string)$id !== (string)$data['account_id']) |
86 | 86 | { |
87 | - throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'),999); |
|
87 | + throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'), 999); |
|
88 | 88 | } |
89 | 89 | if (isset($data['account_passwd_2']) && $data['account_passwd'] != $data['account_passwd_2']) |
90 | 90 | { |
91 | - throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'),0); |
|
91 | + throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'), 0); |
|
92 | 92 | } |
93 | - $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account); |
|
93 | + $expires = self::_parse_expired($data['account_expires'], (boolean)$this->account); |
|
94 | 94 | if ($expires === 0) // deactivated |
95 | 95 | { |
96 | 96 | $data['account_expires'] = -1; |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | $data['account_status'] = is_null($expires) ? null : ($expires == -1 || $expires > time() ? 'A' : ''); |
103 | 103 | } |
104 | 104 | |
105 | - $data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'],$this->account ? null : true); |
|
106 | - $data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'],$this->account ? null : false); |
|
105 | + $data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'], $this->account ? null : true); |
|
106 | + $data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'], $this->account ? null : false); |
|
107 | 107 | if ($data['mustchangepassword'] && $data['changepassword']) |
108 | 108 | { |
109 | - $data['account_lastpwd_change']=0; |
|
109 | + $data['account_lastpwd_change'] = 0; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if (!$data['account_primary_group'] && $this->account) |
113 | 113 | { |
114 | - $data['account_primary_group'] = null; // dont change |
|
114 | + $data['account_primary_group'] = null; // dont change |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | { |
120 | 120 | $data['account_primary_group'] = 'Default'; |
121 | 121 | } |
122 | - $data['account_primary_group'] = admin_cmd::parse_account($data['account_primary_group'],false); |
|
122 | + $data['account_primary_group'] = admin_cmd::parse_account($data['account_primary_group'], false); |
|
123 | 123 | } |
124 | 124 | if (!$data['account_groups'] && $this->account) |
125 | 125 | { |
126 | - $data['account_groups'] = null; // dont change |
|
126 | + $data['account_groups'] = null; // dont change |
|
127 | 127 | } |
128 | 128 | else |
129 | 129 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | { |
132 | 132 | $data['account_groups'] = array('Default'); |
133 | 133 | } |
134 | - $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'],false); |
|
134 | + $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'], false); |
|
135 | 135 | } |
136 | 136 | if ($check_only) return true; |
137 | 137 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | Api\Accounts::cache_invalidate($data['account_id']); |
142 | 142 | if (!($old = admin_cmd::$accounts->read($data['account_id']))) |
143 | 143 | { |
144 | - throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
|
144 | + throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $this->account), 15); |
|
145 | 145 | } |
146 | 146 | // as the current account class always sets all values, we have to add the not specified ones |
147 | - foreach($data as $name => &$value) |
|
147 | + foreach ($data as $name => &$value) |
|
148 | 148 | { |
149 | 149 | if (is_null($value)) $value = $old[$name]; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
154 | - unset($data['account_id']); // otherwise add will fail under postgres |
|
154 | + unset($data['account_id']); // otherwise add will fail under postgres |
|
155 | 155 | } |
156 | 156 | // hook allowing apps to intercept adding/editing Api\Accounts before saving them |
157 | - Api\Hooks::process($data+array( |
|
157 | + Api\Hooks::process($data + array( |
|
158 | 158 | 'location' => $this->account ? 'pre_editaccount' : 'pre_addaccount', |
159 | - ),False,True); // called for every app now, not only enabled ones) |
|
159 | + ), False, True); // called for every app now, not only enabled ones) |
|
160 | 160 | |
161 | 161 | if (!($data['account_id'] = admin_cmd::$accounts->save($data))) |
162 | 162 | { |
163 | 163 | //_debug_array($data); |
164 | - throw new Api\Db\Exception(lang("Error saving account!"),11); |
|
164 | + throw new Api\Db\Exception(lang("Error saving account!"), 11); |
|
165 | 165 | } |
166 | 166 | // make new account_id available to caller |
167 | 167 | $update = (boolean)$this->account; |
@@ -169,44 +169,44 @@ discard block |
||
169 | 169 | |
170 | 170 | if ($data['account_groups']) |
171 | 171 | { |
172 | - admin_cmd::$accounts->set_memberships($data['account_groups'],$data['account_id']); |
|
172 | + admin_cmd::$accounts->set_memberships($data['account_groups'], $data['account_id']); |
|
173 | 173 | } |
174 | 174 | if (!is_null($data['anonymous'])) |
175 | 175 | { |
176 | 176 | admin_cmd::_instanciate_acl(); |
177 | 177 | if ($data['anonymous']) |
178 | 178 | { |
179 | - admin_cmd::$acl->add_repository('phpgwapi','anonymous',$data['account_id'],1); |
|
179 | + admin_cmd::$acl->add_repository('phpgwapi', 'anonymous', $data['account_id'], 1); |
|
180 | 180 | } |
181 | 181 | else |
182 | 182 | { |
183 | - admin_cmd::$acl->delete_repository('phpgwapi','anonymous',$data['account_id']); |
|
183 | + admin_cmd::$acl->delete_repository('phpgwapi', 'anonymous', $data['account_id']); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | if (!is_null($data['changepassword'])) |
187 | 187 | { |
188 | 188 | if (!$data['changepassword']) |
189 | 189 | { |
190 | - admin_cmd::$acl->add_repository('preferences','nopasswordchange',$data['account_id'],1); |
|
190 | + admin_cmd::$acl->add_repository('preferences', 'nopasswordchange', $data['account_id'], 1); |
|
191 | 191 | } |
192 | 192 | else |
193 | 193 | { |
194 | - admin_cmd::$acl->delete_repository('preferences','nopasswordchange',$data['account_id']); |
|
194 | + admin_cmd::$acl->delete_repository('preferences', 'nopasswordchange', $data['account_id']); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | // if we have a password and it's not a hash, and auth_type != account_repository |
198 | 198 | if (!is_null($this->password) && |
199 | - !preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$this->password) && |
|
200 | - !preg_match('/^[0-9a-f]{32}$/',$this->password) && // md5 hash |
|
199 | + !preg_match('/^\\{[a-z5]{3,5}\\}.+/i', $this->password) && |
|
200 | + !preg_match('/^[0-9a-f]{32}$/', $this->password) && // md5 hash |
|
201 | 201 | admin_cmd::$accounts->config['auth_type'] != admin_cmd::$accounts->config['account_repository']) |
202 | 202 | { |
203 | - admin_cmd_change_pw::exec(); // calling the exec method of the admin_cmd_change_pw |
|
203 | + admin_cmd_change_pw::exec(); // calling the exec method of the admin_cmd_change_pw |
|
204 | 204 | } |
205 | 205 | $data['account_passwd'] = $this->password; |
206 | - $GLOBALS['hook_values'] =& $data; |
|
207 | - Api\Hooks::process($GLOBALS['hook_values']+array( |
|
206 | + $GLOBALS['hook_values'] = & $data; |
|
207 | + Api\Hooks::process($GLOBALS['hook_values'] + array( |
|
208 | 208 | 'location' => $update && $this->run_addaccount_hook !== true ? 'editaccount' : 'addaccount' |
209 | - ),False,True); // called for every app now, not only enabled ones) |
|
209 | + ), False, True); // called for every app now, not only enabled ones) |
|
210 | 210 | |
211 | 211 | return lang("Account %1 %2", $data['account_lid'] ? $data['account_lid'] : Api\Accounts::id2name($this->account), |
212 | 212 | $update ? lang('updated') : lang("created with id #%1", $this->account)); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | function __tostring() |
221 | 221 | { |
222 | - return lang('%1 user %2',$this->account ? lang('Edit') : lang('Add'), |
|
222 | + return lang('%1 user %2', $this->account ? lang('Edit') : lang('Add'), |
|
223 | 223 | admin_cmd::display_account($this->account ? $this->account : $this->set['account_lid'])); |
224 | 224 | } |
225 | 225 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * @return int timestamp, 0 for already, -1 for never or null for dont change |
232 | 232 | * @throws Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6); |
233 | 233 | */ |
234 | - private function _parse_expired($str,$existing) |
|
234 | + private function _parse_expired($str, $existing) |
|
235 | 235 | { |
236 | - switch($str) |
|
236 | + switch ($str) |
|
237 | 237 | { |
238 | 238 | case '': |
239 | 239 | if ($existing) return null; |
@@ -52,16 +52,22 @@ discard block |
||
52 | 52 | protected function exec($check_only=false) |
53 | 53 | { |
54 | 54 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
55 | - if ($this->creator) $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
55 | + if ($this->creator) |
|
56 | + { |
|
57 | + $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | admin_cmd::_instanciate_accounts(); |
58 | 61 | |
59 | 62 | $data = $this->set; |
60 | 63 | $data['account_type'] = 'u'; |
61 | 64 | |
62 | - if ($this->account) // existing account |
|
65 | + if ($this->account) |
|
66 | + { |
|
67 | + // existing account |
|
63 | 68 | { |
64 | 69 | $data['account_id'] = admin_cmd::parse_account($this->account); |
70 | + } |
|
65 | 71 | //error_log(__METHOD__."($check_only) this->account=".array2string($this->account).', data[account_id]='.array2string($data['account_id']).", ...)"); |
66 | 72 | |
67 | 73 | $data['old_loginid'] = admin_cmd::$accounts->id2name($data['account_id']); |
@@ -91,9 +97,12 @@ discard block |
||
91 | 97 | throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'),0); |
92 | 98 | } |
93 | 99 | $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account); |
94 | - if ($expires === 0) // deactivated |
|
100 | + if ($expires === 0) |
|
101 | + { |
|
102 | + // deactivated |
|
95 | 103 | { |
96 | 104 | $data['account_expires'] = -1; |
105 | + } |
|
97 | 106 | $data['account_status'] = ''; |
98 | 107 | } |
99 | 108 | else |
@@ -133,7 +142,10 @@ discard block |
||
133 | 142 | } |
134 | 143 | $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'],false); |
135 | 144 | } |
136 | - if ($check_only) return true; |
|
145 | + if ($check_only) |
|
146 | + { |
|
147 | + return true; |
|
148 | + } |
|
137 | 149 | |
138 | 150 | if ($this->account) |
139 | 151 | { |
@@ -146,7 +158,10 @@ discard block |
||
146 | 158 | // as the current account class always sets all values, we have to add the not specified ones |
147 | 159 | foreach($data as $name => &$value) |
148 | 160 | { |
149 | - if (is_null($value)) $value = $old[$name]; |
|
161 | + if (is_null($value)) |
|
162 | + { |
|
163 | + $value = $old[$name]; |
|
164 | + } |
|
150 | 165 | } |
151 | 166 | } |
152 | 167 | else |
@@ -165,7 +180,10 @@ discard block |
||
165 | 180 | } |
166 | 181 | // make new account_id available to caller |
167 | 182 | $update = (boolean)$this->account; |
168 | - if (!$this->account) $this->account = $data['account_id']; |
|
183 | + if (!$this->account) |
|
184 | + { |
|
185 | + $this->account = $data['account_id']; |
|
186 | + } |
|
169 | 187 | |
170 | 188 | if ($data['account_groups']) |
171 | 189 | { |
@@ -236,7 +254,10 @@ discard block |
||
236 | 254 | switch($str) |
237 | 255 | { |
238 | 256 | case '': |
239 | - if ($existing) return null; |
|
257 | + if ($existing) |
|
258 | + { |
|
259 | + return null; |
|
260 | + } |
|
240 | 261 | // fall through --> default for new Api\Accounts is never |
241 | 262 | case 'never': |
242 | 263 | return -1; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | var $public_functions = array('index' => True); |
22 | 22 | |
23 | - function index($params=null) |
|
23 | + function index($params = null) |
|
24 | 24 | { |
25 | 25 | // if we have a xet file, run new et2 config |
26 | 26 | if (file_exists(EGW_SERVER_ROOT.'/'.$_GET['appname'].'/templates/default/config.xet')) |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | //_debug_array($params); |
47 | 47 | $_appname = $_GET['appname']; |
48 | 48 | } |
49 | - if ($GLOBALS['egw']->acl->check('site_config_acce',1,'admin')) |
|
49 | + if ($GLOBALS['egw']->acl->check('site_config_acce', 1, 'admin')) |
|
50 | 50 | { |
51 | 51 | Egw::redirect_link('/index.php'); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | Api\Translation::add_app($_appname); |
58 | 58 | } |
59 | 59 | |
60 | - if(get_magic_quotes_gpc() && is_array($_POST['newsettings'])) |
|
60 | + if (get_magic_quotes_gpc() && is_array($_POST['newsettings'])) |
|
61 | 61 | { |
62 | 62 | $_POST['newsettings'] = array_stripslashes($_POST['newsettings']); |
63 | 63 | } |
64 | 64 | |
65 | - switch($_appname) |
|
65 | + switch ($_appname) |
|
66 | 66 | { |
67 | 67 | case 'admin': |
68 | 68 | case 'addressbook': |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $t = new Framework\Template(Framework\Template::get_dir($appname)); |
90 | 90 | $t->set_unknowns('keep'); |
91 | 91 | $t->set_file(array('config' => 'config.tpl')); |
92 | - $t->set_block('config','header','header'); |
|
92 | + $t->set_block('config', 'header', 'header'); |
|
93 | 93 | |
94 | 94 | // fix header templates missing essential parts like display of validation errors |
95 | 95 | $header = $t->get_var('header'); |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | } |
108 | 108 | $t->set_var('header', $header); |
109 | 109 | |
110 | - $t->set_block('config','body','body'); |
|
111 | - $t->set_block('config','footer','footer'); |
|
110 | + $t->set_block('config', 'body', 'body'); |
|
111 | + $t->set_block('config', 'footer', 'footer'); |
|
112 | 112 | |
113 | 113 | // fix footer submit buttons to just {submit} {cancel} |
114 | 114 | $t->set_var('footer', preg_replace('/<input[^>]+value="{lang_(submit|cancel)}"[^>]*>/', '{$1}', $t->get_var('footer'))); |
115 | 115 | |
116 | 116 | $c = new Api\Config($config_appname); |
117 | 117 | $c->read_repository(); |
118 | - if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce',2,'admin')) |
|
118 | + if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin')) |
|
119 | 119 | { |
120 | 120 | Egw::redirect_link('/admin/index.php?ajax=true'); |
121 | 121 | } |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | if ($_POST['submit'] || $_POST['save'] || $_POST['apply']) |
124 | 124 | { |
125 | 125 | /* Load hook file with functions to validate each Api\Config (one/none/all) */ |
126 | - Api\Hooks::single('config_validate',$appname); |
|
126 | + Api\Hooks::single('config_validate', $appname); |
|
127 | 127 | |
128 | - foreach($_POST['newsettings'] as $key => $config) |
|
128 | + foreach ($_POST['newsettings'] as $key => $config) |
|
129 | 129 | { |
130 | 130 | if ($config) |
131 | 131 | { |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | if (in_array($key, (array)$GLOBALS['egw_info']['server']['found_validation_hook'], true) && function_exists($key)) |
134 | 134 | { |
135 | 135 | call_user_func($key, $config, $c); |
136 | - if($GLOBALS['config_error']) |
|
136 | + if ($GLOBALS['config_error']) |
|
137 | 137 | { |
138 | - $errors .= lang($GLOBALS['config_error']) . "\n"; |
|
138 | + $errors .= lang($GLOBALS['config_error'])."\n"; |
|
139 | 139 | $GLOBALS['config_error'] = False; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
143 | 143 | /* don't erase passwords, since we also don't print them */ |
144 | - elseif(strpos($key,'passwd') === false && strpos($key,'password') === false && strpos($key,'root_pw') === false) |
|
144 | + elseif (strpos($key, 'passwd') === false && strpos($key, 'password') === false && strpos($key, 'root_pw') === false) |
|
145 | 145 | { |
146 | 146 | unset($c->config_data[$key]); |
147 | 147 | } |
148 | 148 | } |
149 | - if(in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) && |
|
149 | + if (in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) && |
|
150 | 150 | function_exists('final_validation')) |
151 | 151 | { |
152 | 152 | final_validation($_POST['newsettings']); |
153 | - if($GLOBALS['config_error']) |
|
153 | + if ($GLOBALS['config_error']) |
|
154 | 154 | { |
155 | - $errors .= lang($GLOBALS['config_error']) . "\n"; |
|
155 | + $errors .= lang($GLOBALS['config_error'])."\n"; |
|
156 | 156 | $GLOBALS['config_error'] = False; |
157 | 157 | } |
158 | 158 | unset($GLOBALS['egw_info']['server']['found_validation_hook']); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | $c->save_repository(); |
162 | 162 | |
163 | - if(!$errors && !$_POST['apply']) |
|
163 | + if (!$errors && !$_POST['apply']) |
|
164 | 164 | { |
165 | 165 | Framework::message(lang('Configuration saved.'), 'success'); |
166 | 166 | Egw::redirect_link('/index.php', array( |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - $t->set_var('error',''); |
|
174 | - if($errors) |
|
173 | + $t->set_var('error', ''); |
|
174 | + if ($errors) |
|
175 | 175 | { |
176 | - Framework::message(lang('Error') . ': ' . $errors, 'error'); |
|
176 | + Framework::message(lang('Error').': '.$errors, 'error'); |
|
177 | 177 | unset($errors); |
178 | 178 | unset($GLOBALS['config_error']); |
179 | 179 | } |
@@ -181,41 +181,41 @@ discard block |
||
181 | 181 | { |
182 | 182 | Framework::message(lang('Configuration saved.'), 'success'); |
183 | 183 | } |
184 | - $t->set_var('title',lang('Site Configuration')); |
|
185 | - $t->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)); |
|
186 | - $t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']); |
|
187 | - $t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']); |
|
188 | - $t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']); |
|
189 | - $t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']); |
|
184 | + $t->set_var('title', lang('Site Configuration')); |
|
185 | + $t->set_var('action_url', $GLOBALS['egw']->link('/index.php', 'menuaction=admin.uiconfig.index&appname='.$appname)); |
|
186 | + $t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']); |
|
187 | + $t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']); |
|
188 | + $t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']); |
|
189 | + $t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']); |
|
190 | 190 | $t->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__CLASS__))); |
191 | 191 | |
192 | 192 | $vars = $t->get_undefined('body'); |
193 | 193 | |
194 | - if (Api\Hooks::single('config',$appname)) // reload the config-values, they might have changed |
|
194 | + if (Api\Hooks::single('config', $appname)) // reload the config-values, they might have changed |
|
195 | 195 | { |
196 | 196 | $c->read_repository(); |
197 | 197 | } |
198 | - foreach($vars as $value) |
|
198 | + foreach ($vars as $value) |
|
199 | 199 | { |
200 | - $valarray = explode('_',$value); |
|
200 | + $valarray = explode('_', $value); |
|
201 | 201 | $type = array_shift($valarray); |
202 | - $newval = implode(' ',$valarray); |
|
202 | + $newval = implode(' ', $valarray); |
|
203 | 203 | |
204 | 204 | switch ($type) |
205 | 205 | { |
206 | 206 | case 'lang': |
207 | - $t->set_var($value,lang($newval)); |
|
207 | + $t->set_var($value, lang($newval)); |
|
208 | 208 | break; |
209 | 209 | case 'value': |
210 | - $newval = str_replace(' ','_',$newval); |
|
210 | + $newval = str_replace(' ', '_', $newval); |
|
211 | 211 | /* Don't show passwords in the form */ |
212 | - if(strpos($value,'passwd') !== false || strpos($value,'password') !== false || strpos($value,'root_pw') !== false) |
|
212 | + if (strpos($value, 'passwd') !== false || strpos($value, 'password') !== false || strpos($value, 'root_pw') !== false) |
|
213 | 213 | { |
214 | - $t->set_var($value,''); |
|
214 | + $t->set_var($value, ''); |
|
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - $t->set_var($value,$c->config_data[$newval]); |
|
218 | + $t->set_var($value, $c->config_data[$newval]); |
|
219 | 219 | } |
220 | 220 | break; |
221 | 221 | /* |
@@ -233,46 +233,45 @@ discard block |
||
233 | 233 | */ |
234 | 234 | case 'selected': |
235 | 235 | $configs = array(); |
236 | - $newvals = explode(' ',$newval); |
|
236 | + $newvals = explode(' ', $newval); |
|
237 | 237 | $setting = end($newvals); |
238 | - for ($i=0;$i<(count($newvals) - 1); $i++) |
|
238 | + for ($i = 0; $i < (count($newvals) - 1); $i++) |
|
239 | 239 | { |
240 | 240 | $configs[] = $newvals[$i]; |
241 | 241 | } |
242 | - $config = implode('_',$configs); |
|
242 | + $config = implode('_', $configs); |
|
243 | 243 | /* echo $config . '=' . $c->config_data[$config]; */ |
244 | 244 | if ($c->config_data[$config] == $setting) |
245 | 245 | { |
246 | - $t->set_var($value,' selected'); |
|
246 | + $t->set_var($value, ' selected'); |
|
247 | 247 | } |
248 | 248 | else |
249 | 249 | { |
250 | - $t->set_var($value,''); |
|
250 | + $t->set_var($value, ''); |
|
251 | 251 | } |
252 | 252 | break; |
253 | 253 | case 'hook': |
254 | - $newval = str_replace(' ','_',$newval); |
|
255 | - if(function_exists($newval)) |
|
254 | + $newval = str_replace(' ', '_', $newval); |
|
255 | + if (function_exists($newval)) |
|
256 | 256 | { |
257 | - $t->set_var($value,$newval($c->config_data)); |
|
257 | + $t->set_var($value, $newval($c->config_data)); |
|
258 | 258 | } |
259 | 259 | else |
260 | 260 | { |
261 | - $t->set_var($value,''); |
|
261 | + $t->set_var($value, ''); |
|
262 | 262 | } |
263 | 263 | break; |
264 | 264 | case 'call': // eg. call_class::method or call_app.class.method |
265 | - $newval = str_replace(' ','_',$newval); |
|
266 | - $t->set_var($value,ExecMethod($newval,$c->config_data)); |
|
265 | + $newval = str_replace(' ', '_', $newval); |
|
266 | + $t->set_var($value, ExecMethod($newval, $c->config_data)); |
|
267 | 267 | break; |
268 | 268 | default: |
269 | - $t->set_var($value,''); |
|
269 | + $t->set_var($value, ''); |
|
270 | 270 | break; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | $t->set_var('submit', '<div class="dialogFooterToolbar" style="text-align: left">'. |
274 | - ($GLOBALS['egw']->acl->check('site_config_acce',2,'admin') ? '' : |
|
275 | - Api\Html::submit_button('save', 'Save')."\n". |
|
274 | + ($GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin') ? '' : Api\Html::submit_button('save', 'Save')."\n". |
|
276 | 275 | Api\Html::submit_button('apply', 'Apply'))); |
277 | 276 | $t->set_var('cancel', Api\Html::submit_button('cancel', 'Cancel').'</div>'); |
278 | 277 | |
@@ -282,10 +281,10 @@ discard block |
||
282 | 281 | // render the page |
283 | 282 | $GLOBALS['egw']->framework->render( |
284 | 283 | '<div id="admin-config-'.$appname.'" class="admin-config">'. |
285 | - $t->parse('out','header'). |
|
286 | - $t->fp('out','body'). |
|
287 | - $t->fp('out','footer').'</div>', |
|
288 | - null,true |
|
284 | + $t->parse('out', 'header'). |
|
285 | + $t->fp('out', 'body'). |
|
286 | + $t->fp('out', 'footer').'</div>', |
|
287 | + null, true |
|
289 | 288 | ); |
290 | 289 | } |
291 | 290 | } |
@@ -85,7 +85,11 @@ discard block |
||
85 | 85 | $config_appname = $appname; |
86 | 86 | break; |
87 | 87 | } |
88 | - if (ob_get_contents()) ob_end_flush(); // if there is output in buffer, flush it now. |
|
88 | + if (ob_get_contents()) |
|
89 | + { |
|
90 | + ob_end_flush(); |
|
91 | + } |
|
92 | + // if there is output in buffer, flush it now. |
|
89 | 93 | $t = new Framework\Template(Framework\Template::get_dir($appname)); |
90 | 94 | $t->set_unknowns('keep'); |
91 | 95 | $t->set_file(array('config' => 'config.tpl')); |
@@ -191,10 +195,13 @@ discard block |
||
191 | 195 | |
192 | 196 | $vars = $t->get_undefined('body'); |
193 | 197 | |
194 | - if (Api\Hooks::single('config',$appname)) // reload the config-values, they might have changed |
|
198 | + if (Api\Hooks::single('config',$appname)) |
|
199 | + { |
|
200 | + // reload the config-values, they might have changed |
|
195 | 201 | { |
196 | 202 | $c->read_repository(); |
197 | 203 | } |
204 | + } |
|
198 | 205 | foreach($vars as $value) |
199 | 206 | { |
200 | 207 | $valarray = explode('_',$value); |
@@ -31,25 +31,24 @@ discard block |
||
31 | 31 | * @param array &$readonlys |
32 | 32 | * @return int |
33 | 33 | */ |
34 | - static function get_rows(array $query,&$rows,&$readonlys) |
|
34 | + static function get_rows(array $query, &$rows, &$readonlys) |
|
35 | 35 | { |
36 | 36 | Api\Cache::setSession('admin', 'cmds', $query); |
37 | 37 | |
38 | - $total = admin_cmd::get_rows($query,$rows,$readonlys); |
|
38 | + $total = admin_cmd::get_rows($query, $rows, $readonlys); |
|
39 | 39 | |
40 | 40 | if (!$rows) return array(); |
41 | 41 | |
42 | - foreach($rows as &$row) |
|
42 | + foreach ($rows as &$row) |
|
43 | 43 | { |
44 | 44 | try { |
45 | 45 | $cmd = admin_cmd::instanciate($row); |
46 | - $row['title'] = $cmd->__tostring(); // we call __tostring explicit, as a cast to string requires php5.2+ |
|
46 | + $row['title'] = $cmd->__tostring(); // we call __tostring explicit, as a cast to string requires php5.2+ |
|
47 | 47 | } |
48 | 48 | catch (Exception $e) { |
49 | 49 | $row['title'] = $e->getMessage(); |
50 | 50 | } |
51 | - $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : |
|
52 | - json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
51 | + $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
53 | 52 | |
54 | 53 | if ($row['status'] == admin_cmd::scheduled) |
55 | 54 | { |
@@ -65,7 +64,7 @@ discard block |
||
65 | 64 | * |
66 | 65 | * @param array $content =null |
67 | 66 | */ |
68 | - static function index(array $content=null) |
|
67 | + static function index(array $content = null) |
|
69 | 68 | { |
70 | 69 | $tpl = new Etemplate('admin.cmds'); |
71 | 70 | |
@@ -75,10 +74,10 @@ discard block |
||
75 | 74 | if (!is_array($content['nm'])) |
76 | 75 | { |
77 | 76 | $content['nm'] = array( |
78 | - 'get_rows' => 'admin.admin_cmds.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
79 | - 'no_filter' => true, // I disable the 1. filter |
|
80 | - 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
81 | - 'no_cat' => true, // I disable the cat-selectbox |
|
77 | + 'get_rows' => 'admin.admin_cmds.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
78 | + 'no_filter' => true, // I disable the 1. filter |
|
79 | + 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
80 | + 'no_cat' => true, // I disable the cat-selectbox |
|
82 | 81 | 'order' => 'cmd_created', |
83 | 82 | 'sort' => 'DESC', |
84 | 83 | 'row_id' => 'id', |
@@ -98,10 +97,10 @@ discard block |
||
98 | 97 | } |
99 | 98 | unset($cmd); |
100 | 99 | } |
101 | - $tpl->exec('admin.admin_cmds.index',$content,array( |
|
100 | + $tpl->exec('admin.admin_cmds.index', $content, array( |
|
102 | 101 | 'status' => admin_cmd::$stati, |
103 | 102 | 'remote_id' => admin_cmd::remote_sites(), |
104 | - ),array(),$content); |
|
103 | + ), array(), $content); |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | /** |
@@ -127,9 +126,9 @@ discard block |
||
127 | 126 | * @param array &$readonlys |
128 | 127 | * @return int |
129 | 128 | */ |
130 | - static function get_remotes(array $query,&$rows,&$readonlys) |
|
129 | + static function get_remotes(array $query, &$rows, &$readonlys) |
|
131 | 130 | { |
132 | - return admin_cmd::get_remotes($query,$rows,$readonlys); |
|
131 | + return admin_cmd::get_remotes($query, $rows, $readonlys); |
|
133 | 132 | } |
134 | 133 | |
135 | 134 | /** |
@@ -137,7 +136,7 @@ discard block |
||
137 | 136 | * |
138 | 137 | * @param array $content =null |
139 | 138 | */ |
140 | - static function remotes(array $content=null) |
|
139 | + static function remotes(array $content = null) |
|
141 | 140 | { |
142 | 141 | $tpl = new Etemplate('admin.remotes'); |
143 | 142 | |
@@ -147,10 +146,10 @@ discard block |
||
147 | 146 | if (!is_array($content['nm'])) |
148 | 147 | { |
149 | 148 | $content['nm'] = array( |
150 | - 'get_rows' => 'admin.admin_cmds.get_remotes', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
151 | - 'no_filter' => true, // I disable the 1. filter |
|
152 | - 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
153 | - 'no_cat' => true, // I disable the cat-selectbox |
|
149 | + 'get_rows' => 'admin.admin_cmds.get_remotes', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
150 | + 'no_filter' => true, // I disable the 1. filter |
|
151 | + 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
152 | + 'no_cat' => true, // I disable the cat-selectbox |
|
154 | 153 | 'order' => 'remote_name', |
155 | 154 | 'sort' => 'ASC', |
156 | 155 | 'row_id' => 'remote_id', |
@@ -165,7 +164,7 @@ discard block |
||
165 | 164 | |
166 | 165 | if ($content['nm']['action']) |
167 | 166 | { |
168 | - switch($content['nm']['action']) |
|
167 | + switch ($content['nm']['action']) |
|
169 | 168 | { |
170 | 169 | case 'edit': |
171 | 170 | $content['remote'] = admin_cmd::read_remote($content['nm']['selected'][0]); |
@@ -175,11 +174,11 @@ discard block |
||
175 | 174 | } |
176 | 175 | unset($content['nm']['action']); |
177 | 176 | } |
178 | - elseif($content['remote']['button']) |
|
177 | + elseif ($content['remote']['button']) |
|
179 | 178 | { |
180 | 179 | list($button) = each($content['remote']['button']); |
181 | 180 | unset($content['remote']['button']); |
182 | - switch($button) |
|
181 | + switch ($button) |
|
183 | 182 | { |
184 | 183 | case 'save': |
185 | 184 | case 'apply': |
@@ -210,7 +209,7 @@ discard block |
||
210 | 209 | unset($content['nm']['add']); |
211 | 210 | } |
212 | 211 | } |
213 | - $tpl->exec('admin.admin_cmds.remotes',$content,array(),array(),$content); |
|
212 | + $tpl->exec('admin.admin_cmds.remotes', $content, array(), array(), $content); |
|
214 | 213 | } |
215 | 214 | |
216 | 215 | /** |
@@ -226,7 +225,7 @@ discard block |
||
226 | 225 | 'default' => true, |
227 | 226 | 'allowOnMultiple' => false, |
228 | 227 | 'nm_action' => 'submit', |
229 | - 'group' => $group=0, |
|
228 | + 'group' => $group = 0, |
|
230 | 229 | ), |
231 | 230 | 'add' => array( |
232 | 231 | 'caption' => 'Add', |
@@ -37,7 +37,10 @@ discard block |
||
37 | 37 | |
38 | 38 | $total = admin_cmd::get_rows($query,$rows,$readonlys); |
39 | 39 | |
40 | - if (!$rows) return array(); |
|
40 | + if (!$rows) |
|
41 | + { |
|
42 | + return array(); |
|
43 | + } |
|
41 | 44 | |
42 | 45 | foreach($rows as &$row) |
43 | 46 | { |
@@ -193,11 +196,15 @@ discard block |
||
193 | 196 | try { |
194 | 197 | $content['remote']['remote_id'] = admin_cmd::save_remote($content['remote']); |
195 | 198 | $content['msg'] = lang('Remote instance saved'); |
196 | - } catch (Exception $e) { |
|
199 | + } |
|
200 | + catch (Exception $e) { |
|
197 | 201 | $content['msg'] = lang('Error saving').': '.$e->getMessage().' ('.$e->getCode().')'; |
198 | 202 | break; |
199 | 203 | } |
200 | - if ($button == 'apply') break; |
|
204 | + if ($button == 'apply') |
|
205 | + { |
|
206 | + break; |
|
207 | + } |
|
201 | 208 | // fall through for save |
202 | 209 | case 'cancel': |
203 | 210 | unset($content['remote']); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string|int|array $account account name or id, or array with all parameters |
24 | 24 | * @param string $password =null password |
25 | 25 | */ |
26 | - function __construct($account,$password=null) |
|
26 | + function __construct($account, $password = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($account)) |
29 | 29 | { |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
45 | 45 | * @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99); |
46 | 46 | */ |
47 | - protected function exec($check_only=false) |
|
47 | + protected function exec($check_only = false) |
|
48 | 48 | { |
49 | - $account_id = admin_cmd::parse_account($this->account,true); // true = user, no group |
|
49 | + $account_id = admin_cmd::parse_account($this->account, true); // true = user, no group |
|
50 | 50 | // check creator is still admin and not explicitly forbidden to edit Api\Accounts |
51 | - if ($this->creator) $this->_check_admin('account_access',16); |
|
51 | + if ($this->creator) $this->_check_admin('account_access', 16); |
|
52 | 52 | |
53 | 53 | if ($check_only) return true; |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | if (!$auth->change_password(null, $this->password, $account_id)) |
58 | 58 | { |
59 | 59 | // as long as the Api\Auth class is not throwing itself ... |
60 | - throw new Exception(lang('Error changing the password for %1 !!!',$this->account),99); |
|
60 | + throw new Exception(lang('Error changing the password for %1 !!!', $this->account), 99); |
|
61 | 61 | } |
62 | 62 | return lang('Password updated'); |
63 | 63 | } |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function __tostring() |
71 | 71 | { |
72 | - return lang('change password for %1',admin_cmd::display_account($this->account)); |
|
72 | + return lang('change password for %1', admin_cmd::display_account($this->account)); |
|
73 | 73 | } |
74 | 74 | } |
@@ -48,9 +48,15 @@ |
||
48 | 48 | { |
49 | 49 | $account_id = admin_cmd::parse_account($this->account,true); // true = user, no group |
50 | 50 | // check creator is still admin and not explicitly forbidden to edit Api\Accounts |
51 | - if ($this->creator) $this->_check_admin('account_access',16); |
|
51 | + if ($this->creator) |
|
52 | + { |
|
53 | + $this->_check_admin('account_access',16); |
|
54 | + } |
|
52 | 55 | |
53 | - if ($check_only) return true; |
|
56 | + if ($check_only) |
|
57 | + { |
|
58 | + return true; |
|
59 | + } |
|
54 | 60 | |
55 | 61 | $auth = new Api\Auth; |
56 | 62 |
@@ -275,37 +275,37 @@ |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
278 | - * Returns warnings that were encountered during importing |
|
279 | - * Maximum of one warning message per record, but you can concatenate them if you need to |
|
280 | - * |
|
281 | - * @return Array ( |
|
282 | - * record_# => warning message |
|
283 | - * ) |
|
284 | - */ |
|
278 | + * Returns warnings that were encountered during importing |
|
279 | + * Maximum of one warning message per record, but you can concatenate them if you need to |
|
280 | + * |
|
281 | + * @return Array ( |
|
282 | + * record_# => warning message |
|
283 | + * ) |
|
284 | + */ |
|
285 | 285 | public function get_warnings() { |
286 | 286 | return $this->warnings; |
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
290 | - * Returns errors that were encountered during importing |
|
291 | - * Maximum of one error message per record, but you can append if you need to |
|
292 | - * |
|
293 | - * @return Array ( |
|
294 | - * record_# => error message |
|
295 | - * ) |
|
296 | - */ |
|
290 | + * Returns errors that were encountered during importing |
|
291 | + * Maximum of one error message per record, but you can append if you need to |
|
292 | + * |
|
293 | + * @return Array ( |
|
294 | + * record_# => error message |
|
295 | + * ) |
|
296 | + */ |
|
297 | 297 | public function get_errors() { |
298 | 298 | return $this->errors; |
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
302 | - * Returns a list of actions taken, and the number of records for that action. |
|
303 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
304 | - * |
|
305 | - * @return Array ( |
|
306 | - * action => record count |
|
307 | - * ) |
|
308 | - */ |
|
302 | + * Returns a list of actions taken, and the number of records for that action. |
|
303 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
304 | + * |
|
305 | + * @return Array ( |
|
306 | + * action => record count |
|
307 | + * ) |
|
308 | + */ |
|
309 | 309 | public function get_results() { |
310 | 310 | return $this->results; |
311 | 311 | } |
@@ -77,8 +77,7 @@ |
||
77 | 77 | /** |
78 | 78 | * imports entries according to given definition object. |
79 | 79 | * @param resource $_stream |
80 | - * @param string $_charset |
|
81 | - * @param definition $_definition |
|
80 | + * @param importexport_definition $_definition |
|
82 | 81 | */ |
83 | 82 | public function import( $_stream, importexport_definition $_definition ) { |
84 | 83 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for admin (users) |
17 | 17 | */ |
18 | -class admin_import_users_csv implements importexport_iface_import_plugin { |
|
18 | +class admin_import_users_csv implements importexport_iface_import_plugin { |
|
19 | 19 | |
20 | 20 | private static $plugin_options = array( |
21 | - 'fieldsep', // char |
|
22 | - 'charset', // string |
|
21 | + 'fieldsep', // char |
|
22 | + 'charset', // string |
|
23 | 23 | 'num_header_lines', // int number of header lines |
24 | 24 | 'field_conversion', // array( $csv_col_num => conversion) |
25 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | - 'conditions', /* => array containing condition arrays: |
|
25 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | + 'conditions', /* => array containing condition arrays: |
|
27 | 27 | 'type' => exists, // exists |
28 | 28 | 'string' => '#kundennummer', |
29 | 29 | 'true' => array( |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * actions which could be done to data entries |
42 | 42 | */ |
43 | - protected static $actions = array( 'none', 'update', 'create', 'delete', 'disable', 'enable' ); |
|
43 | + protected static $actions = array('none', 'update', 'create', 'delete', 'disable', 'enable'); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * conditions for actions |
47 | 47 | * |
48 | 48 | * @var array |
49 | 49 | */ |
50 | - protected static $conditions = array( 'exists' ); |
|
50 | + protected static $conditions = array('exists'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var definition |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * @param string $_charset |
91 | 91 | * @param definition $_definition |
92 | 92 | */ |
93 | - public function import( $_stream, importexport_definition $_definition ) { |
|
94 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
93 | + public function import($_stream, importexport_definition $_definition) { |
|
94 | + $import_csv = new importexport_import_csv($_stream, array( |
|
95 | 95 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
96 | 96 | 'charset' => $_definition->plugin_options['charset'], |
97 | 97 | )); |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | $this->definition = $_definition; |
100 | 100 | |
101 | 101 | // user, is admin ? |
102 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
102 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
103 | 103 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
104 | 104 | |
105 | 105 | // dry run? |
106 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
106 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
107 | 107 | |
108 | 108 | // set FieldMapping. |
109 | 109 | $import_csv->mapping = $_definition->plugin_options['field_mapping']; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
113 | 113 | |
114 | 114 | //check if file has a header lines |
115 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
115 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
116 | 116 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
117 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
117 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
118 | 118 | // First method is preferred |
119 | 119 | $import_csv->skip_records(1); |
120 | 120 | } |
@@ -130,22 +130,22 @@ discard block |
||
130 | 130 | 'account_status' => array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')), |
131 | 131 | ); |
132 | 132 | |
133 | - while ( $record = $import_csv->get_record() ) { |
|
133 | + while ($record = $import_csv->get_record()) { |
|
134 | 134 | $success = false; |
135 | 135 | // don't import empty records |
136 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
136 | + if (count(array_unique($record)) < 2) continue; |
|
137 | 137 | |
138 | - if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1; |
|
138 | + if (strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1; |
|
139 | 139 | importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups); |
140 | 140 | |
141 | - if ( $_definition->plugin_options['conditions'] ) { |
|
142 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
143 | - switch ( $condition['type'] ) { |
|
141 | + if ($_definition->plugin_options['conditions']) { |
|
142 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
143 | + switch ($condition['type']) { |
|
144 | 144 | // exists |
145 | 145 | case 'exists' : |
146 | 146 | $accounts = array(); |
147 | 147 | // Skip the search if the field is empty |
148 | - if($record[$condition['string']] !== '') |
|
148 | + if ($record[$condition['string']] !== '') |
|
149 | 149 | { |
150 | 150 | $accounts = $GLOBALS['egw']->accounts->search(array( |
151 | 151 | 'type' => 'accounts', |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | )); |
155 | 155 | } |
156 | 156 | // Search looks in the given field, but doesn't do an exact match |
157 | - foreach ( (array)$accounts as $key => $account ) |
|
157 | + foreach ((array)$accounts as $key => $account) |
|
158 | 158 | { |
159 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
159 | + if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
160 | 160 | } |
161 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
161 | + if (is_array($accounts) && count($accounts) >= 1) { |
|
162 | 162 | // apply action to all contacts matching this exists condition |
163 | 163 | $action = $condition['true']; |
164 | - foreach ( (array)$accounts as $account ) { |
|
164 | + foreach ((array)$accounts as $account) { |
|
165 | 165 | $record['account_id'] = $account['account_id']; |
166 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
166 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
167 | 167 | } |
168 | 168 | } else { |
169 | 169 | $action = $condition['false']; |
170 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
170 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
171 | 171 | } |
172 | 172 | break; |
173 | 173 | |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | } |
180 | 180 | } else { |
181 | 181 | // unconditional insert |
182 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
182 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
183 | 183 | } |
184 | - if($success) $count++; |
|
184 | + if ($success) $count++; |
|
185 | 185 | } |
186 | 186 | return $count; |
187 | 187 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param array $_data contact data for the action |
194 | 194 | * @return bool success or not |
195 | 195 | */ |
196 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
196 | + private function action($_action, $_data, $record_num = 0) { |
|
197 | 197 | switch ($_action) { |
198 | 198 | case 'none' : |
199 | 199 | return true; |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | $_data['account_expires'] = $_action == 'disable' ? 'already' : ''; |
203 | 203 | case 'create' : |
204 | 204 | case 'update' : |
205 | - $command = new admin_cmd_edit_user(($_action=='create'?null:$_data['account_lid']), $_data); |
|
206 | - if($this->dry_run) { |
|
205 | + $command = new admin_cmd_edit_user(($_action == 'create' ?null:$_data['account_lid']), $_data); |
|
206 | + if ($this->dry_run) { |
|
207 | 207 | $this->results[$_action]++; |
208 | 208 | return true; |
209 | 209 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * preserv => array, |
261 | 261 | * ) |
262 | 262 | */ |
263 | - public function get_options_etpl(importexport_definition &$definition=null) |
|
263 | + public function get_options_etpl(importexport_definition &$definition = null) |
|
264 | 264 | { |
265 | 265 | // lets do it! |
266 | 266 | } |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for admin (users) |
17 | 17 | */ |
18 | -class admin_import_users_csv implements importexport_iface_import_plugin { |
|
18 | +class admin_import_users_csv implements importexport_iface_import_plugin |
|
19 | +{ |
|
19 | 20 | |
20 | 21 | private static $plugin_options = array( |
21 | 22 | 'fieldsep', // char |
@@ -90,7 +91,8 @@ discard block |
||
90 | 91 | * @param string $_charset |
91 | 92 | * @param definition $_definition |
92 | 93 | */ |
93 | - public function import( $_stream, importexport_definition $_definition ) { |
|
94 | + public function import( $_stream, importexport_definition $_definition ) |
|
95 | + { |
|
94 | 96 | $import_csv = new importexport_import_csv( $_stream, array( |
95 | 97 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
96 | 98 | 'charset' => $_definition->plugin_options['charset'], |
@@ -112,9 +114,12 @@ discard block |
||
112 | 114 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
113 | 115 | |
114 | 116 | //check if file has a header lines |
115 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
117 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
118 | + { |
|
116 | 119 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
117 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
120 | + } |
|
121 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
122 | + { |
|
118 | 123 | // First method is preferred |
119 | 124 | $import_csv->skip_records(1); |
120 | 125 | } |
@@ -130,17 +135,27 @@ discard block |
||
130 | 135 | 'account_status' => array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')), |
131 | 136 | ); |
132 | 137 | |
133 | - while ( $record = $import_csv->get_record() ) { |
|
138 | + while ( $record = $import_csv->get_record() ) |
|
139 | + { |
|
134 | 140 | $success = false; |
135 | 141 | // don't import empty records |
136 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
142 | + if( count( array_unique( $record ) ) < 2 ) |
|
143 | + { |
|
144 | + continue; |
|
145 | + } |
|
137 | 146 | |
138 | - if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1; |
|
147 | + if(strtolower($record['account_expires']) == 'never') |
|
148 | + { |
|
149 | + $record['account_expires'] = -1; |
|
150 | + } |
|
139 | 151 | importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups); |
140 | 152 | |
141 | - if ( $_definition->plugin_options['conditions'] ) { |
|
142 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
143 | - switch ( $condition['type'] ) { |
|
153 | + if ( $_definition->plugin_options['conditions'] ) |
|
154 | + { |
|
155 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
156 | + { |
|
157 | + switch ( $condition['type'] ) |
|
158 | + { |
|
144 | 159 | // exists |
145 | 160 | case 'exists' : |
146 | 161 | $accounts = array(); |
@@ -156,16 +171,23 @@ discard block |
||
156 | 171 | // Search looks in the given field, but doesn't do an exact match |
157 | 172 | foreach ( (array)$accounts as $key => $account ) |
158 | 173 | { |
159 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
174 | + if($account[$condition['string']] != $record[$condition['string']]) |
|
175 | + { |
|
176 | + unset($accounts[$key]); |
|
177 | + } |
|
160 | 178 | } |
161 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
179 | + if ( is_array( $accounts ) && count( $accounts ) >= 1 ) |
|
180 | + { |
|
162 | 181 | // apply action to all contacts matching this exists condition |
163 | 182 | $action = $condition['true']; |
164 | - foreach ( (array)$accounts as $account ) { |
|
183 | + foreach ( (array)$accounts as $account ) |
|
184 | + { |
|
165 | 185 | $record['account_id'] = $account['account_id']; |
166 | 186 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
167 | 187 | } |
168 | - } else { |
|
188 | + } |
|
189 | + else |
|
190 | + { |
|
169 | 191 | $action = $condition['false']; |
170 | 192 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
171 | 193 | } |
@@ -175,13 +197,21 @@ discard block |
||
175 | 197 | default : |
176 | 198 | die('condition / action not supported!!!'); |
177 | 199 | } |
178 | - if ($action['last']) break; |
|
200 | + if ($action['last']) |
|
201 | + { |
|
202 | + break; |
|
203 | + } |
|
179 | 204 | } |
180 | - } else { |
|
205 | + } |
|
206 | + else |
|
207 | + { |
|
181 | 208 | // unconditional insert |
182 | 209 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
183 | 210 | } |
184 | - if($success) $count++; |
|
211 | + if($success) |
|
212 | + { |
|
213 | + $count++; |
|
214 | + } |
|
185 | 215 | } |
186 | 216 | return $count; |
187 | 217 | } |
@@ -193,8 +223,10 @@ discard block |
||
193 | 223 | * @param array $_data contact data for the action |
194 | 224 | * @return bool success or not |
195 | 225 | */ |
196 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
197 | - switch ($_action) { |
|
226 | + private function action ( $_action, $_data, $record_num = 0 ) |
|
227 | + { |
|
228 | + switch ($_action) |
|
229 | + { |
|
198 | 230 | case 'none' : |
199 | 231 | return true; |
200 | 232 | case 'disable': |
@@ -203,13 +235,15 @@ discard block |
||
203 | 235 | case 'create' : |
204 | 236 | case 'update' : |
205 | 237 | $command = new admin_cmd_edit_user(($_action=='create'?null:$_data['account_lid']), $_data); |
206 | - if($this->dry_run) { |
|
238 | + if($this->dry_run) |
|
239 | + { |
|
207 | 240 | $this->results[$_action]++; |
208 | 241 | return true; |
209 | 242 | } |
210 | 243 | try { |
211 | 244 | $command->run(); |
212 | - } catch (Exception $e) { |
|
245 | + } |
|
246 | + catch (Exception $e) { |
|
213 | 247 | $this->errors[$record_num] = $e->getMessage(); |
214 | 248 | return false; |
215 | 249 | } |
@@ -226,7 +260,8 @@ discard block |
||
226 | 260 | * |
227 | 261 | * @return string name |
228 | 262 | */ |
229 | - public static function get_name() { |
|
263 | + public static function get_name() |
|
264 | + { |
|
230 | 265 | return lang('User CSV import'); |
231 | 266 | } |
232 | 267 | |
@@ -235,7 +270,8 @@ discard block |
||
235 | 270 | * |
236 | 271 | * @return string descriprion |
237 | 272 | */ |
238 | - public static function get_description() { |
|
273 | + public static function get_description() |
|
274 | + { |
|
239 | 275 | return lang("Creates / updates user accounts from CSV file"); |
240 | 276 | } |
241 | 277 | |
@@ -244,7 +280,8 @@ discard block |
||
244 | 280 | * |
245 | 281 | * @return string suffix (comma seperated) |
246 | 282 | */ |
247 | - public static function get_filesuffix() { |
|
283 | + public static function get_filesuffix() |
|
284 | + { |
|
248 | 285 | return 'csv'; |
249 | 286 | } |
250 | 287 | |
@@ -270,7 +307,8 @@ discard block |
||
270 | 307 | * |
271 | 308 | * @return string etemplate name |
272 | 309 | */ |
273 | - public function get_selectors_etpl() { |
|
310 | + public function get_selectors_etpl() |
|
311 | + { |
|
274 | 312 | // lets do it! |
275 | 313 | } |
276 | 314 | |
@@ -282,7 +320,8 @@ discard block |
||
282 | 320 | * record_# => warning message |
283 | 321 | * ) |
284 | 322 | */ |
285 | - public function get_warnings() { |
|
323 | + public function get_warnings() |
|
324 | + { |
|
286 | 325 | return $this->warnings; |
287 | 326 | } |
288 | 327 | |
@@ -294,7 +333,8 @@ discard block |
||
294 | 333 | * record_# => error message |
295 | 334 | * ) |
296 | 335 | */ |
297 | - public function get_errors() { |
|
336 | + public function get_errors() |
|
337 | + { |
|
298 | 338 | return $this->errors; |
299 | 339 | } |
300 | 340 | |
@@ -306,7 +346,8 @@ discard block |
||
306 | 346 | * action => record count |
307 | 347 | * ) |
308 | 348 | */ |
309 | - public function get_results() { |
|
349 | + public function get_results() |
|
350 | + { |
|
310 | 351 | return $this->results; |
311 | 352 | } |
312 | 353 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $_content =null |
35 | 35 | * @param string $msg ='' |
36 | 36 | */ |
37 | - function index(array $_content=null, $msg='') |
|
37 | + function index(array $_content = null, $msg = '') |
|
38 | 38 | { |
39 | 39 | if (is_array($_content)) |
40 | 40 | { |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | list($action) = each($_content['button']); |
45 | 45 | unset($_content['button']); |
46 | 46 | } |
47 | - elseif($_content['rows']['delete']) |
|
47 | + elseif ($_content['rows']['delete']) |
|
48 | 48 | { |
49 | 49 | list($action) = each($_content['rows']['delete']); |
50 | 50 | unset($_content['rows']['delete']); |
51 | 51 | } |
52 | - switch($action) |
|
52 | + switch ($action) |
|
53 | 53 | { |
54 | 54 | case 'save': |
55 | 55 | case 'apply': |
56 | 56 | $saved = 0; |
57 | - foreach($_content['rows'] as $data) |
|
57 | + foreach ($_content['rows'] as $data) |
|
58 | 58 | { |
59 | 59 | if (!empty($data['phrase'])) |
60 | 60 | { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | } |
81 | 81 | $content = array('rows' => array()); |
82 | - foreach(Api\Translation::load_app('custom', 'en') as $phrase => $translation) |
|
82 | + foreach (Api\Translation::load_app('custom', 'en') as $phrase => $translation) |
|
83 | 83 | { |
84 | 84 | $content['rows'][++$row] = array( |
85 | 85 | 'phrase' => $phrase, |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'phrase' => '', |
92 | 92 | 'translation' => '', |
93 | 93 | ); |
94 | - $readonlys["delete[$row]"] = true; // no delete for empty row |
|
94 | + $readonlys["delete[$row]"] = true; // no delete for empty row |
|
95 | 95 | $content['msg'] = $msg; |
96 | 96 | |
97 | 97 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Custom translation'); |
@@ -62,8 +62,14 @@ |
||
62 | 62 | ++$saved; |
63 | 63 | } |
64 | 64 | } |
65 | - if ($saved) $msg = lang('%1 phrases saved.', $saved); |
|
66 | - if ($action == 'apply') break; |
|
65 | + if ($saved) |
|
66 | + { |
|
67 | + $msg = lang('%1 phrases saved.', $saved); |
|
68 | + } |
|
69 | + if ($action == 'apply') |
|
70 | + { |
|
71 | + break; |
|
72 | + } |
|
67 | 73 | // fall through |
68 | 74 | case 'cancel': |
69 | 75 | Egw::redirect_link('/admin/index.php'); |