1<?php
2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
4require_once(DOKU_PLUGIN.'admin.php');
5
6/**
7 * All DokuWiki plugins to extend the admin function
8 * need to inherit from this class
9 */
10class admin_plugin_translator extends DokuWiki_Admin_Plugin {
11
12	var $_auth = null;        	// auth object
13	var $functions = null;		// Helper
14	var $revertableUpload = array();
15
16	/**
17	 * Constructor
18	 */
19	function admin_plugin_translator(){
20		global $auth;
21
22		if (!isset($auth)) {
23			$this->disabled = $this->lang['noauth'];
24		} else if (!$auth->canDo('getUsers')) {
25			$this->disabled = $this->lang['nosupport'];
26		} else {
27
28			// we're good to go
29			$this->_auth = & $auth;
30		}
31
32		if ( ! $this->_setup() ) return false;
33		if ( !$this->functions->checkDatabase() ) {
34			$this->functions = null;
35			return false;
36		}
37	}
38
39	/**
40	 * return some info
41	 */
42	function getInfo(){
43		return array_merge(confToHash(dirname(__FILE__).'/info.txt'), array(
44				'name' => 'Translator (Admin Component)',
45		));
46	}
47
48	/**
49	 * return sort order for position in admin menu
50	 */
51	function getMenuSort() {
52		return 100;
53	}
54
55	function forAdminOnly(){
56		return false;
57	}
58
59	/**
60	 * handle user request
61	 */
62	function handle() {
63
64		if (is_null($this->_auth)) return false;
65
66		// extract the command and any specific parameters
67		// submit button name is of the form - fn[cmd][param(s)]
68		$fn   = $_REQUEST['fn'];
69
70		if (is_array($fn)) {
71			$cmd = key($fn);
72			$param = is_array($fn[$cmd]) ? key($fn[$cmd]) : null;
73		} else {
74			$cmd = $fn;
75			$param = null;
76		}
77
78		switch($cmd){
79			case "set_user"    			: $this->_setUser($_REQUEST['user']); break;
80			case "createcategories"		: $this->_createCategory($_REQUEST['CategoryName'], $_REQUEST['FileName']); break;
81			case "updatecategories"    	: $this->_deleteCategory($_REQUEST['deletecategory']); break;
82			case "uploadmaster"			: $this->_handleUploadedFiles($_REQUEST['Category'], $_REQUEST['Version'], $_FILES['File']); break;
83			case "deletemaster"			: $this->_handleDeleteMaster($_REQUEST['deletemaster']); break;
84			case "deleteuser"			: $this->_handleDeleteUser($_REQUEST['deleteuser'], $_REQUEST['manageUser']); break;
85		}
86
87		$this->functions->_handleRequest($fn);
88	}
89
90	/**
91	 * output appropriate html
92	 */
93	function html() {
94		global $ID, $conf;
95
96		if(is_null($this->_auth)) {
97			print $this->lang['badauth'];
98			return false;
99		}
100
101		print $this->locale_xhtml('intro');
102		print '<div id="translator">';
103
104		if ( $_REQUEST['manageUser'] ) {
105			// Display Categories of User
106			$this->_userCategoryManager($_REQUEST['manageUser']);
107		} else {
108			// Set User Languages
109			$this->_userRightsForm();
110
111			// Manager Categories
112			$this->_categoryManager();
113
114			// Import Master and Languages
115			$this->_importManager();
116
117			// Export MAnager
118			$this->functions->_exportManager($this);
119
120			// Delete Master Languages
121			$this->_deleteMasterLanguageManager();
122		}
123		print '</div>';
124	}
125
126	function _importManager() {
127
128		$categories = array_keys($this->functions->_getCategories());
129		if ( count($categories) == 0 ) return;
130
131		$form = $this->_startFieldSet($this->getLang('ImportMasterLanguage'), 'translator_master_import', 'multipart/form-data');
132
133		$form->addElement(form_makeListboxField('Category', $categories, $_REQUEST['Category'], 'Select the Category:'));
134		$form->addElement(form_makeTag('br'));
135		$form->addElement(form_makeTextField('Version', $_REQUEST['Version'], 'Product Version:'));
136		$form->addElement(form_makeTag('br'));
137		$form->addElement(form_makeFileField('File[]', 'Upload File:', null, null, array('multiple' => 'true')));
138		$form->addElement(form_makeTag('br'));
139		$form->addElement(form_makeField('submit', 'fn[uploadmaster]', 'Upload', ''));
140
141		$this->_finishFieldset($form);
142
143		$this->functions->_revertManager($this, $this->revertableUpload);
144	}
145
146	function _deleteMasterLanguageManager() {
147
148		$categories = $this->functions->_getCategories();
149		if ( count($categories) == 0 ) return;
150		$nothingToDo = true;
151
152		$form = $this->_startFieldSet($this->getLang('RemoveMasterLanguage'), 'translator_master_remove');
153
154		foreach ( $categories as $name => $category ) {
155			$formCategories[] = $name;
156			foreach ( $this->functions->_getAvailableVersions($category['CategoryID']) as $Version ) {
157				$nothingToDo = false;
158				$form->addElement(form_makeCheckboxField("deletemaster[$name][$Version]", 1, $name . " ($Version)", null));
159				$form->addElement(form_makeTag('br'));
160			}
161		}
162
163		$form->addElement(form_makeField('submit', 'fn[deletemaster]', 'Delete', ''));
164
165		if ( ! $nothingToDo )
166		$this->_finishFieldset($form);
167	}
168
169	/*
170	 * Print the Manager for Categories
171	 */
172	function _categoryManager() {
173
174		$categories = $this->functions->_getCategories();
175
176		if ( count($categories) > 0 ) {
177
178			$form = $this->_startFieldSet($this->getLang('CategoryManager'), 'translator_categories');
179
180			foreach( $categories as $name => $data ) {
181				$form->addElement(form_makeCheckboxField("deletecategory[{$data['CategoryID']}]", 1, $name . " ({$data['FileName']})", null));
182				$form->addElement(form_makeTag('br'));
183			}
184
185			$form->addElement(form_makeField('submit', 'fn[updatecategories]', $this->getLang('Delete'), ''));
186			$this->_finishFieldset($form);
187		}
188
189
190		$form = $this->_startFieldSet($this->getLang('AddCategory'), 'translator_new_categories');
191
192		$form->addElement(form_makeTextField('CategoryName', $_REQUEST['CategoryName'], $this->getLang('Category') . ':', 'CategoryName', null));
193		$form->addElement(form_makeTag('br'));
194		$form->addElement(form_makeTextField('FileName', $_REQUEST['FileName'], $this->getLang('CategoryFileName') . ':', 'FileName', null));
195		$form->addElement(form_makeTag('br'));
196
197		$form->addElement(form_makeField('submit', 'fn[createcategories]', $this->getLang('Create'), ''));
198		$this->_finishFieldset($form);
199
200	}
201
202	/*
203	 * Print the User Rights formula with update button for Languages
204	 */
205	function _userRightsForm() {
206
207		// System User List
208		$user_list = $this->_getUserLanguages();
209
210		$form = $this->_startFieldSet($this->getLang('UserManager'), 'translator_users');
211		foreach ( $user_list as $user => $values ) {
212
213			$lang = $values['Lang'];
214			$form->addElement(form_makeTextField("user[$user]", $lang, tpl_link(wl($ID, array('do' => 'admin', 'page' => 'translator', 'manageUser' => $user ), true), $user, null, true) . ':', $user, null));
215			$form->addElement(form_makeTag('br'));
216
217		}
218
219		$form->addElement(form_makeField('submit', 'fn[set_user]', $this->getLang('Update'), ''));
220		$this->_finishFieldset($form);
221	}
222
223	/*
224	 * Fieldsets for the admin page
225	 */
226	function _startFieldSet($name, $hid='translator', $formType=null) {
227		global $ID;
228
229		$form = new Doku_Form($hid, wl($ID), 'post', $formType);
230		$form->addHidden('do', 'admin');
231		$form->addHidden('page', 'translator');
232		$form->startFieldset( $name );
233
234		return $form;
235	}
236
237	function _getUserLanguages() {
238		$user_list = $this->_auth->retrieveUsers();
239		$this->functions->database->prepare("SELECT User, Lang FROM tblUserRights;");
240		$this->functions->database->execute();
241
242		if ( $this->functions->database->num_rows() != 0 ) {
243
244			$data = array(); $this->functions->database->bind_assoc($data);
245			while ( $this->functions->database->fetch() ) {
246				$user_list[$data['User']]['Lang'] = $data['Lang'];
247			}
248		}
249
250		return $user_list;
251	}
252
253	function _finishFieldset($form=null) {
254		if ( empty($form) ) return;
255
256		$form->endFieldset();
257		$form->printForm();
258	}
259
260	function _setUser($users=array()) {
261
262		if ( empty($users) || !is_array($users)) { return false; }
263		foreach ( $users as $user => $lang ) {
264
265			$user = trim($user);
266			if ( empty($user) ) continue;
267
268			$lang = trim($lang);
269			if ( empty($lang) )	{
270				$this->functions->database->prepare("DELETE FROM tblUserRights WHERE User=?;");
271				$this->functions->database->execute($user);
272				continue;
273			}
274
275			$lang = preg_replace("/[,;\s]/", "|", $lang);
276			$lang = preg_replace("/\|+/", "|", $lang);
277
278			$this->functions->database->prepare("SELECT * FROM tblUserRights WHERE User=?;");
279			$this->functions->database->execute($user);
280			if ( $this->functions->database->num_rows() > 0 )
281			$this->functions->database->prepare("UPDATE tblUserRights SET Lang=? WHERE User=?;");
282			else
283			$this->functions->database->prepare("INSERT INTO tblUserRights (Lang, User) VALUES(?, ?);");
284
285			$this->functions->database->execute($lang, $user);
286		}
287	}
288
289	function _createCategory($categoryName, $fileName) {
290		if ( empty($categoryName) ) {
291			msg($this->getLang('CategoryNameMissing'), -1);
292			return false;
293		}
294
295		if ( empty($fileName) ) {
296			msg($this->getLang('FileNameMissing'), -1);
297			return false;
298		}
299
300		$this->functions->database->prepare("SELECT * FROM tblCategory WHERE Name=?;");
301		$this->functions->database->execute($categoryName);
302		if ( $this->functions->database->num_rows() > 0 ) {
303			msg($this->getLang('CategoryExists'), -1);
304			return false;
305		}
306
307
308		$this->functions->database->prepare("INSERT INTO tblCategory (Name, FileName) VALUES (?,?);");
309		$this->functions->database->execute($categoryName, $fileName);
310	}
311
312	/*
313	 * Remove Categories
314	 */
315	function _deleteCategory($category=array()) {
316
317		if ( empty($category) || !is_array($category)) { return false; }
318
319		foreach ( $category as $name => $value ) {
320
321			$name = trim($name);
322			if ( empty($name) ) continue;
323
324			$value = trim($value);
325			if ( empty($value) ) {
326				continue;
327			}
328
329			$this->functions->database->prepare("DELETE FROM tblCategory WHERE CategoryID=?;");
330			$this->functions->database->execute($name);
331			$this->_handleDeleteFiles($name, "%", true);
332		}
333	}
334
335	/*
336	 * Reorders the uplaoded Files to insert the master language first
337	 * It also checks and rejects wrong file formats.
338	 */
339	function _handleUploadedFiles($category, $version, $FILES) {
340
341		list($CategoryID, $CategoryRegex)  = $this->functions->_getCategoryFromName($category);
342
343		$orderedFiles = array();
344		for ( $i=0; $i<count($FILES['name']); $i++ ) {
345
346			$FILE = array(
347							'name' => $FILES['name'][$i],
348							'tmp_name' => $FILES['tmp_name'][$i],
349							'current_date_time' => date('Y-m-d H:i:s')
350			);
351
352			// check uploaded FileName to match on the selected Category
353			$matches = array();
354			if ( !preg_match("/$CategoryRegex/", $FILE['name'], $matches) ) {
355				msg($this->functions->_messageReplacer('MasterFileNotInFormat', array($FILE['name'], $CategoryRegex)), -1);
356				return;
357			}
358
359			// Cleanup the Language and set default Language if needed.
360			$FILE['lang'] = preg_replace("/^_?(.*?)_?$/", "$1", $matches[1]);
361
362			// Set Default Language and put in front of all others in ordered list
363			if ( empty($FILE['lang']) ) {
364
365				// Need a version here!
366				if ( empty($version) ) {
367					msg($this->getLang('VersionNeeded'), -1);
368					return;
369				}
370
371				$FILE['lang'] = $this->getConf('default_language');
372				array_unshift($orderedFiles, $FILE);
373
374				continue;
375			}
376
377			$orderedFiles[] = $FILE;
378		}
379
380		foreach ( $orderedFiles as $file ) {
381			$status = $this->_importLanguage($file, $CategoryID, $version);
382
383			// Should be reverted
384			if ( $status === false ) {
385				$this->revertableUpload[] = $file;
386			}
387		}
388
389	}
390
391	/*
392	 * Delete Master Languages
393	 */
394	function _handleDeleteMaster($deleteMaster) {
395		foreach( $deleteMaster as $key => $versions) {
396			foreach ( array_keys($versions) as $version ) {
397				$this->_handleDeleteFiles($key, $version);
398			}
399		}
400	}
401
402	/*
403	 * Cycle through Users to be deleted
404	 */
405	function _handleDeleteUser($deleteUserLanguage, $User) {
406
407		$removed = 0;
408		$removeUserKeys = array();
409
410		foreach( $deleteUserLanguage as $Category => $versions) {
411			if ( !empty($Category) ) {
412				list($CategoryID, $FileName) = $this->functions->_getCategoryFromName($Category);
413			}
414
415			foreach ( $versions as $version => $date ) {
416				if ( !is_array($date) ) {
417					$this->_getTranslastionsForUser($removeUserKeys, $User, $CategoryID, $version);
418					continue;
419				}
420
421				foreach( $date as $dateEntry => $Lang ) {
422					if ( !is_array($Lang) ) {
423						continue;
424					}
425
426					foreach ( array_keys($Lang) as $Language ) {
427						$this->_getTranslastionsForUser($removeUserKeys, $User, $CategoryID, $version, $dateEntry, $Language);
428					}
429				}
430			}
431		}
432
433		$this->functions->database->prepare("DELETE FROM tblTranslation WHERE KeyID=? AND User=? AND Lang=?;");
434		foreach( $removeUserKeys as $Entry) {
435			list($KeyID, $Lang) = $Entry;
436			$this->functions->database->execute($KeyID, $User, $Lang);
437			$removed += $this->functions->database->num_rows();
438		}
439
440		msg($this->functions->_messageReplacer('RemovedUserEntries', array($removed, $User)));
441	}
442
443	function _getTranslastionsForUser(&$removeUserKeys, $User, $CategoryID=null, $Version=null, $Date=null, $Lang=null) {
444
445		$ADDITIONAL = "";
446		$EXECUTE = array($User);
447
448		// If Date is set, check for that one too
449		if ( !empty($Date) ) {
450			$ADDITIONAL .= " AND Date=?";
451			$EXECUTE[] = $Date;
452		}
453
454		// If Date is set, check for that one too
455		if ( !empty($CategoryID) ) {
456			$ADDITIONAL .= " AND CategoryID=?";
457			$EXECUTE[] = $CategoryID;
458		}
459
460		// If Date is set, check for that one too
461		if ( !empty($Version) ) {
462			$ADDITIONAL .= " AND Version=?";
463			$EXECUTE[] = $Version;
464		}
465
466		// If Date is set, check for that one too
467		if ( !empty($Lang) ) {
468			$ADDITIONAL .= " AND Lang=?";
469			$EXECUTE[] = $Lang;
470		}
471
472		$this->functions->database->prepare("SELECT tblTranslation.KeyID FROM tblTranslation INNER JOIN tblMaster ON tblTranslation.KeyID = tblMaster.KeyID WHERE User=? $ADDITIONAL;");
473
474		$this->functions->database->execute($EXECUTE);
475		$data = array(); $this->functions->database->bind_assoc($data);
476		while ( $this->functions->database->fetch() ) {
477			$removeUserKeys[] = array($data['KeyID'],$Lang);
478		}
479	}
480
481	function _handleDeleteFiles($Category, $Version, $isID=false, $User=null) {
482
483		if ( $isID) {
484			$CategoryID = $Category;
485			$Category = array_shift(array_keys($this->functions->_getCategories($CategoryID, true)));
486		} else {
487			list($CategoryID, $FileName) = $this->functions->_getCategoryFromName($Category);
488		}
489
490		$ADDITIONAL = "";
491		$EXECUTE = array($CategoryID, $Version);
492
493		if ( !empty($User) ) {
494			$ADDITIONAL .= " AND User=?";
495			$EXECUTE[] = $User;
496		}
497
498		$this->functions->database->prepare("DELETE FROM tblMaster WHERE CategoryID=? AND Version LIKE ? $ADDITIONAL");
499		$this->functions->database->execute($EXECUTE);
500		if ( $this->functions->database->num_rows() > 0 ) {
501			if ( $Version == '%' ) { $Version = 'any version'; }
502			msg($this->functions->_messageReplacer('RemovedEntries', array($this->functions->database->num_rows(), $Category, $Version)));
503		}
504	}
505
506	function _importLanguage($file, $CategoryID, $version) {
507
508		$FileName = $file['name'];
509		$Lang = $file['lang'];
510		$currentDateTime = $file['current_date_time'];
511		$isMasterLang = $Lang == $this->getConf('default_language');
512
513		$finalStatus = array(
514								'KeysNotInMaster' => array(),
515								'KeysMatchingExisting' => array(),
516								'CountOfKeys' => 0,
517								'CountOfToBeReverted' => 0,
518		);
519
520		// Get Content of uploaded temp file
521		$FileContent = file($file['tmp_name']);
522		@unlink($file['tmp_name']);
523
524		if ( $isMasterLang ) {
525			// Clean Up Current Category and Version Entries
526			$this->functions->database->prepare("DELETE FROM tblMaster WHERE CategoryID=? AND Version=?;");
527			$this->functions->database->execute($CategoryID, $version);
528		}
529
530		$FileContent = preg_grep("/^\s*?(#|\/\/)/", $FileContent, PREG_GREP_INVERT);
531
532		$translation = array();
533
534		// Cycle through the Lines and add them into the MasterDB
535		foreach ( $FileContent as $line ) {
536			// No Comments.
537//			if ( preg_match("/^\s*?(#|\/\/)/", $line) ) {
538//				continue;
539//			}
540
541			list($key, $value) = explode("=", $line, 2);
542			$key = trim($key);
543			$value = trim($value);
544
545			if ( empty($key) || empty($value) ) {
546				continue;
547			}
548
549			$translation[$key] = $value;
550		}
551
552		unset($FileContent);
553
554
555        if ( $isMasterLang ) {
556            // Create Master Entry and finish this entry
557            $this->functions->_createMasterTableEntry($translation, $CategoryID, $version, $finalStatus);
558        } else {
559
560		    // Bottleneck 1
561		    $this->functions->_checkForMasterKeyIDs($translation, $finalStatus, $CategoryID);
562            $this->functions->_insertTranslationArray($translation, $finalStatus, $Lang, $currentDateTime);
563		}
564
565		return $this->functions->_statusResult($finalStatus, $Lang, $FileName);
566	}
567
568	function _printBackToAdmin() {
569		return '<div class="clearer">&nbsp;</div>' . tpl_link(wl($ID, array('do' => 'admin', 'page' => 'translator', ), true), $this->getLang('backToFirstPage'), null, true);
570	}
571
572	function _userCategoryManager($user) {
573		global $conf;
574
575		$this->functions->database->prepare("SELECT tblCategory.CategoryID, tblCategory.Name FROM (tblTranslation INNER JOIN tblMaster ON tblMaster.KeyID=tblTranslation.KeyID) INNER JOIN tblCategory ON tblCategory.CategoryID=tblMaster.CategoryID WHERE tblTranslation.User=? GROUP BY tblMaster.CategoryID");
576		$this->functions->database->execute($user);
577
578		if ( $this->functions->database->num_rows() == 0 ) {
579			print $this->getLang('UserHasNoTranslations');
580			print $this->_printBackToAdmin();
581			return;
582		}
583
584		$categories=array(); $data=array(); $this->functions->database->bind_assoc($data);
585		while ( $this->functions->database->fetch()) {
586			$categories[$data['Name']] = $data['CategoryID'];
587		}
588
589		$form = $this->_startFieldSet($this->functions->_messageReplacer('RemoveUserLanguage', $user), 'translator_user_language_remove');
590		$form->addHidden("manageUser", $user);
591
592		$form->addElement(form_makeOpenTag("table", array('class' => 'translation_table')));
593		$form->addElement(form_makeOpenTag("tr"));
594		$form->addElement(form_makeOpenTag("th")); $form->addElement($this->getLang('Category')); $form->addElement(form_makeCloseTag("th"));
595		$form->addElement(form_makeOpenTag("th")); $form->addElement($this->getLang('Version')); $form->addElement(form_makeCloseTag("th"));
596		$form->addElement(form_makeOpenTag("th")); $form->addElement($this->getLang('AmountOfValues')); $form->addElement(form_makeCloseTag("th"));
597		$form->addElement(form_makeCloseTag("tr"));
598
599		$formByDate = $this->_startFieldSet($this->functions->_messageReplacer('RemoveUserLanguageByDate', $user), 'translator_user_language_date_remove');
600		$formByDate->addHidden("manageUser", $user);
601
602		$formByDate->addElement(form_makeOpenTag("table", array('class' => 'translation_table')));
603		$formByDate->addElement(form_makeOpenTag("tr"));
604		$formByDate->addElement(form_makeOpenTag("th")); $formByDate->addElement($this->getLang('Date')); $formByDate->addElement(form_makeCloseTag("th"));
605		$formByDate->addElement(form_makeOpenTag("th")); $formByDate->addElement($this->getLang('Language')); $formByDate->addElement(form_makeCloseTag("th"));
606		$formByDate->addElement(form_makeOpenTag("th")); $formByDate->addElement($this->getLang('AmountOfValues')); $formByDate->addElement(form_makeCloseTag("th"));
607		$formByDate->addElement(form_makeCloseTag("tr"));
608
609		$onclick = array(	'onclick' => 'var elem=getElementsByClass("edit", this.parentNode); elem[0].firstChild.checked=(elem[0].firstChild.checked ? false : true);',);
610
611		foreach ( $categories as $Name => $CategoryID ) {
612
613			$this->functions->database->prepare("SELECT Version, COUNT(tblTranslation.KeyID) as Amount FROM tblTranslation INNER JOIN tblMaster ON tblMaster.KeyID=tblTranslation.KeyID WHERE tblTranslation.User=? AND CategoryID=? GROUP BY Version;");
614			$this->functions->database->execute($user, $CategoryID);
615
616			$data=array(); $this->functions->database->bind_assoc($data);
617			while ( $this->functions->database->fetch()) {
618				$form->addElement(form_makeOpenTag("tr"));
619				$form->addElement(form_makeOpenTag("td", $onclick)); $form->addElement($Name); $form->addElement(form_makeCloseTag("td"));
620				$form->addElement(form_makeOpenTag("td", $onclick)); $form->addElement($data['Version']); $form->addElement(form_makeCloseTag("td"));
621				$form->addElement(form_makeOpenTag("td", $onclick)); $form->addElement($data['Amount']); $form->addElement(form_makeCloseTag("td"));
622				$form->addElement(form_makeOpenTag("td"));
623				$form->addElement(form_makeCheckboxField("deleteuser[$Name][{$data['Version']}]", 1, '', '', 'edit'));
624				$form->addElement(form_makeCloseTag("td"));
625				$form->addElement(form_makeCloseTag("tr"));
626			}
627		}
628
629		$this->functions->database->prepare("SELECT Date, Lang, COUNT(tblTranslation.KeyID) as Amount FROM tblTranslation WHERE tblTranslation.User=? GROUP BY Date ORDER By Date DESC;");
630		$this->functions->database->execute($user);
631
632		$data=array(); $this->functions->database->bind_assoc($data);
633		while ( $this->functions->database->fetch()) {
634			$formByDate->addElement(form_makeOpenTag("tr"));
635			$formByDate->addElement(form_makeOpenTag("td", $onclick)); $formByDate->addElement(strftime($conf['dformat'], strtotime($data['Date']))); $formByDate->addElement(form_makeCloseTag("td"));
636			$formByDate->addElement(form_makeOpenTag("td", $onclick)); $formByDate->addElement($data['Lang']); $formByDate->addElement(form_makeCloseTag("td"));
637			$formByDate->addElement(form_makeOpenTag("td", $onclick)); $formByDate->addElement($data['Amount']); $formByDate->addElement(form_makeCloseTag("td"));
638			$formByDate->addElement(form_makeOpenTag("td"));
639			$formByDate->addElement(form_makeCheckboxField("deleteuser[][][{$data['Date']}][{$data['Lang']}]", 1, '', '', 'edit'));
640			$formByDate->addElement(form_makeCloseTag("td"));
641			$formByDate->addElement(form_makeCloseTag("tr"));
642		}
643
644		$form->addElement(form_makeCloseTag("table"));
645		$form->addElement(form_makeField('submit', 'fn[deleteuser]', 'Delete', ''));
646		$form->addElement(form_makeTag('br'));
647
648		$formByDate->addElement(form_makeCloseTag("table"));
649		$formByDate->addElement(form_makeField('submit', 'fn[deleteuser]', 'Delete', ''));
650		$formByDate->addElement(form_makeTag('br'));
651
652		$this->_finishFieldset($form);
653		$this->_finishFieldset($formByDate);
654		print $this->_printBackToAdmin();
655	}
656
657	function _setup() {
658		if ( !$this->functions =& plugin_load('helper', 'translator') ) {
659			msg($this->lang['helpermissing'], -1);
660			return false;
661		}
662
663		// check Database
664		return $this->functions->init_database(true);
665	}
666}
667//Setup VIM: ex: et ts=4 enc=utf-8 :