@@ -124,7 +124,7 @@ function endElement($parser, $name) {
124124 // Now we can create a group.
125125 if ($ this ->canImport ) {
126126 $ this ->top_role_id = ttRoleHelper::getRoleByRank (512 , 0 );
127- $ group_id = ttTeamHelper:: insert (array (
127+ $ group_id = $ this -> createGroup (array (
128128 'name ' => $ this ->groupData ['NAME ' ],
129129 'currency ' => $ this ->groupData ['CURRENCY ' ],
130130 'decimal_mark ' => $ this ->groupData ['DECIMAL_MARK ' ],
@@ -137,6 +137,8 @@ function endElement($parser, $name) {
137137 'task_required ' => $ this ->groupData ['TASK_REQUIRED ' ],
138138 'record_type ' => $ this ->groupData ['RECORD_TYPE ' ],
139139 'bcc_email ' => $ this ->groupData ['BCC_EMAIL ' ],
140+ 'allow_ip ' => $ this ->groupData ['ALLOW_IP ' ],
141+ 'password_complexity ' => $ this ->groupData ['PASSWORD_COMPLEXITY ' ],
140142 'plugins ' => $ this ->groupData ['PLUGINS ' ],
141143 'lock_spec ' => $ this ->groupData ['LOCK_SPEC ' ],
142144 'workday_minutes ' => $ this ->groupData ['WORKDAY_MINUTES ' ],
@@ -343,7 +345,9 @@ function dataElement($parser, $data) {
343345 || $ this ->currentTag == 'LABEL '
344346 || $ this ->currentTag == 'VALUE '
345347 || $ this ->currentTag == 'COMMENT '
346- || $ this ->currentTag == 'ADDRESS ' ) {
348+ || $ this ->currentTag == 'ADDRESS '
349+ || $ this ->currentTag == 'ALLOW_IP '
350+ || $ this ->currentTag == 'PASSWORD_COMPLEXITY ' ) {
347351 if (isset ($ this ->currentElement [$ this ->currentTag ]))
348352 $ this ->currentElement [$ this ->currentTag ] .= trim ($ data );
349353 else
@@ -432,6 +436,46 @@ function uncompress($in, $out) {
432436 return true ;
433437 }
434438
439+ // createGroup function creates a new group.
440+ private function createGroup ($ fields ) {
441+
442+ global $ user ;
443+ $ mdb2 = getConnection ();
444+
445+ $ columns = '(name, currency, decimal_mark, lang, date_format, time_format, week_start, tracking_mode ' .
446+ ', project_required, task_required, record_type, bcc_email, allow_ip, password_complexity, plugins ' .
447+ ', lock_spec, workday_minutes, config, created, created_ip, created_by) ' ;
448+
449+ $ values = ' values ( ' .$ mdb2 ->quote (trim ($ fields ['name ' ]));
450+ $ values .= ', ' .$ mdb2 ->quote (trim ($ fields ['currency ' ]));
451+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['decimal_mark ' ]);
452+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['lang ' ]);
453+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['date_format ' ]);
454+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['time_format ' ]);
455+ $ values .= ', ' .(int )$ fields ['week_start ' ];
456+ $ values .= ', ' .(int )$ fields ['tracking_mode ' ];
457+ $ values .= ', ' .(int )$ fields ['project_required ' ];
458+ $ values .= ', ' .(int )$ fields ['task_required ' ];
459+ $ values .= ', ' .(int )$ fields ['record_type ' ];
460+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['bcc_email ' ]);
461+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['allow_ip ' ]);
462+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['password_complexity ' ]);
463+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['plugins ' ]);
464+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['lock_spec ' ]);
465+ $ values .= ', ' .(int )$ fields ['workday_minutes ' ];
466+ $ values .= ', ' .$ mdb2 ->quote ($ fields ['config ' ]);
467+ $ values .= ', now(), ' .$ mdb2 ->quote ($ _SERVER ['REMOTE_ADDR ' ]).', ' .$ mdb2 ->quote ($ user ->id );
468+ $ values .= ') ' ;
469+
470+ $ sql = 'insert into tt_groups ' .$ columns .$ values ;
471+ $ affected = $ mdb2 ->exec ($ sql );
472+ if (!is_a ($ affected , 'PEAR_Error ' )) {
473+ $ group_id = $ mdb2 ->lastInsertID ('tt_groups ' , 'id ' );
474+ return $ group_id ;
475+ }
476+ return false ;
477+ }
478+
435479 // insertMonthlyQuota - a helper function to insert a monthly quota.
436480 private function insertMonthlyQuota ($ group_id , $ year , $ month , $ minutes ) {
437481 $ mdb2 = getConnection ();
0 commit comments