View | Details | Raw Unified | Return to bug 22902 | Differences between
and this patch

Collapse All | Expand All

(-)debian/control (+1 lines)
 Lines 16-21    Link Here 
16
 foomatic-db
16
 foomatic-db
17
Standards-Version: 3.8.2
17
Standards-Version: 3.8.2
18
18
19
19
Package: univention-printserver
20
Package: univention-printserver
20
Architecture: all
21
Architecture: all
21
Depends: ${misc:Depends}, ${python:Depends},
22
Depends: ${misc:Depends}, ${python:Depends},
(-)umc/python/printers/de.po (-3 / +3 lines)
 Lines 4-13    Link Here 
4
"Project-Id-Version: univention-management-console-module-printers\n"
4
"Project-Id-Version: univention-management-console-module-printers\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
6
"POT-Creation-Date: 2011-11-07 12:45+0100\n"
6
"POT-Creation-Date: 2011-11-07 12:45+0100\n"
7
"PO-Revision-Date: 2011-11-09 20:20+0100\n"
7
"PO-Revision-Date: 2011-11-17 14:18+0100\n"
8
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
"Last-Translator: Frank Greif <fg@it25.de>\n"
9
"Language-Team: LANGUAGE <LL@li.org>\n"
9
"Language-Team: LANGUAGE <LL@li.org>\n"
10
"Language: \n"
10
"Language: de\n"
11
"MIME-Version: 1.0\n"
11
"MIME-Version: 1.0\n"
12
"Content-Type: text/plain; charset=UTF-8\n"
12
"Content-Type: text/plain; charset=UTF-8\n"
13
"Content-Transfer-Encoding: 8bit\n"
13
"Content-Transfer-Encoding: 8bit\n"
(-)umc/python/printers/__init__.py (-6 / +216 lines)
 Lines 38-43    Link Here 
38
import univention.config_registry
38
import univention.config_registry
39
39
40
from fnmatch import *
40
from fnmatch import *
41
from time import sleep
41
import re
42
import re
42
import string
43
import string
43
import subprocess
44
import subprocess
 Lines 107-113    Link Here 
107
108
108
		self.finished(request.id,result)
109
		self.finished(request.id,result)
109
110
110
	def get(self,request):
111
	def get_printer(self,request):
111
		""" gets detail data for one printer. """
112
		""" gets detail data for one printer. """
112
		
113
		
113
		# ----------- DEBUG -----------------
114
		# ----------- DEBUG -----------------
 Lines 145-151    Link Here 
145
			MODULE.info("   << %s" % s)
146
			MODULE.info("   << %s" % s)
146
		# -----------------------------------
147
		# -----------------------------------
147
		
148
		
148
		result = self._job_list(request.options.get('printer',''))
149
		printer = request.options.get('printer','')
150
		result = self._job_list(printer)
149
		
151
		
150
		# ---------- DEBUG --------------
152
		# ---------- DEBUG --------------
151
		MODULE.info("printers/jobs/query returns:")
153
		MODULE.info("printers/jobs/query returns:")
 Lines 166-178    Link Here 
166
	def list_quota(self,request):
168
	def list_quota(self,request):
167
		""" lists all quota entries related to this printer. """
169
		""" lists all quota entries related to this printer. """
168
		
170
		
169
		# fill a dummy result table.
171
		# ----------- DEBUG -----------------
172
		MODULE.info("printers/quota/query invoked with:")
173
		pp = pprint.PrettyPrinter(indent=4)
174
		st = pp.pformat(request.options).split("\n")
175
		for s in st:
176
			MODULE.info("   << %s" % s)
177
		# -----------------------------------
178
		
170
		printer = request.options.get('printer','')
179
		printer = request.options.get('printer','')
180
171
		result = []
181
		result = []
182
183
		(stdout,stderr,status) = self._shell_command(['/usr/bin/pkusers','--list'],{'LANG':'C'})
184
		users = []
185
		expr = re.compile('^\s*(.*?)\s+\-\s\<')
186
		if status == 0:
187
			for line in stdout.split("\n"):
188
				match = expr.match(line)
189
				if match:
190
					users.append(match.group(1))
191
					
192
		result = []
193
		for user in users:
194
			(stdout,stderr,status) = self._shell_command(['/usr/bin/repykota','-P',printer,user],{'LANG':'C'})
195
			if status == 0:
196
				for line in stdout.split("\n"):
197
					data = line[16:].split()		# ignore possibly truncated user name
198
					if len(data) >= 7:
199
						ok = True
200
						for n in (2,3,4,len(data)-3):
201
							if not data[n].isdigit():
202
								ok = False
203
						if ok:
204
							MODULE.info("      -> user='%s' used=%s soft=%s hard=%s total=%s" % (user,data[2],data[3],data[4],data[len(data)-3]))
205
							entry = {
206
								'user':		user,
207
								'used':		data[2],
208
								'soft':		data[3],
209
								'hard':		data[4],
210
								'total':	data[len(data)-3]
211
							}
212
							result.append(entry)
172
		
213
		
214
		# ---------- DEBUG --------------
215
		MODULE.info("printers/quota/query returns:")
216
		pp = pprint.PrettyPrinter(indent=4)
217
		st = ''
218
		if len(result) > 5:
219
			tmp = result[0:5]
220
			MODULE.info("   >> %d entries, first 5 are:" % len(result))
221
			st = pp.pformat(tmp).split("\n")
222
		else:
223
			st = pp.pformat(result).split("\n")
224
		for s in st:
225
			MODULE.info("   >> %s" % s)
226
		# --------------------------------
227
173
		self.finished(request.id,result)
228
		self.finished(request.id,result)
174
		
229
		
175
	def enable(self,request):
230
	def list_users(self,request):
231
		""" convenience function for the username entry. Lists
232
			all user names. We don't return this as an array of {id,label}
233
			tuples because:
234
			
235
			(1) id and label are always the same here
236
			(2) at the frontend, we must do some postprocessing, and an array
237
				is easier to handle.
238
			(3)	the ComboBox is able to handle a plain array. 
239
		"""
240
		
241
		# ----------- DEBUG -----------------
242
		MODULE.info("printers/users/query invoked with:")
243
		pp = pprint.PrettyPrinter(indent=4)
244
		st = pp.pformat(request.options).split("\n")
245
		for s in st:
246
			MODULE.info("   << %s" % s)
247
		# -----------------------------------
248
		
249
		result = []
250
		expr = re.compile('^\s*username:\s*(.*?)\s*$')
251
		(stdout,stderr,status) = self._shell_command(['/usr/sbin/univention-directory-manager','users/user','list'],{'LANG':'C'})
252
		if status == 0:
253
			for line in stdout.split("\n"):
254
				match = expr.match(line)
255
				if match:
256
					MODULE.warn("  -> %s" % match.group(1))
257
					result.append(match.group(1))
258
					
259
		# simulate 10000 more users
260
		for g in range(0,100):
261
			gn = 'group %d' % g
262
			for u in range(0,100):
263
				un = 'user %d' % u
264
				result.append('%s in %s' % (un,gn))
265
266
		# ---------- DEBUG --------------
267
		MODULE.info("printers/users/query returns:")
268
		pp = pprint.PrettyPrinter(indent=4)
269
		st = ''
270
		if len(result) > 5:
271
			tmp = result[0:5]
272
			MODULE.info("   >> %d entries, first 5 are:" % len(result))
273
			st = pp.pformat(tmp).split("\n")
274
		else:
275
			st = pp.pformat(result).split("\n")
276
		for s in st:
277
			MODULE.info("   >> %s" % s)
278
		# --------------------------------
279
280
		self.finished(request.id,result)
281
		
282
	def enable_printer(self,request):
176
		""" can enable or disable a printer, depending on args.
283
		""" can enable or disable a printer, depending on args.
177
			returns empty string on success, else error message. 
284
			returns empty string on success, else error message. 
178
		"""
285
		"""
 Lines 200-206    Link Here 
200
307
201
		self.finished(request.id, result)
308
		self.finished(request.id, result)
202
		
309
		
203
	def cancel(self,request):
310
	def cancel_jobs(self,request):
204
		""" cancels one or more print jobs. Job IDs are passed
311
		""" cancels one or more print jobs. Job IDs are passed
205
			as an array that can be directly passed on to the
312
			as an array that can be directly passed on to the
206
			_shell_command() method
313
			_shell_command() method
 Lines 228-235    Link Here 
228
335
229
		self.finished(request.id, result)
336
		self.finished(request.id, result)
230
		
337
		
338
339
	def set_quota(self,request):
340
		""" sets quota limits for a (printer,user) combination.
341
			optionally tries to create the corresponding user entry.
342
		"""
343
344
		# ----------- DEBUG -----------------
345
		MODULE.info("printers/quota/set invoked with:")
346
		pp = pprint.PrettyPrinter(indent=4)
347
		st = pp.pformat(request.options).split("\n")
348
		for s in st:
349
			MODULE.info("   << %s" % s)
350
		# -----------------------------------
351
352
		printer = request.options.get('printer','')
353
		user = request.options.get('user','')
354
		soft = request.options.get('soft',0)
355
		hard = request.options.get('hard',0)
231
		
356
		
357
		if printer=='' or user=='':
358
			result = "Required parameter missing"
359
		else:
360
			result = self._set_quota(printer,user,soft,hard)
232
		
361
		
362
		# ---------- DEBUG --------------
363
		MODULE.info("printers/quota/set returns:")
364
		pp = pprint.PrettyPrinter(indent=4)
365
		st = pp.pformat(result).split("\n")
366
		for s in st:
367
			MODULE.info("   >> %s" % s)
368
		# --------------------------------
369
370
		self.finished(request.id, result)
371
		
372
		
373
	def reset_quota(self,request):
374
		""" resets quota for a (printer,user) combination.
375
		"""
376
377
		# ----------- DEBUG -----------------
378
		MODULE.info("printers/quota/reset invoked with:")
379
		pp = pprint.PrettyPrinter(indent=4)
380
		st = pp.pformat(request.options).split("\n")
381
		for s in st:
382
			MODULE.info("   << %s" % s)
383
		# -----------------------------------
384
385
		printer = request.options.get('printer','')
386
		users = request.options.get('users',[])
387
388
		result = self._reset_quota(printer,users)
389
		
390
		# ---------- DEBUG --------------
391
		MODULE.info("printers/quota/reset returns:")
392
		pp = pprint.PrettyPrinter(indent=4)
393
		st = pp.pformat(result).split("\n")
394
		for s in st:
395
			MODULE.info("   >> %s" % s)
396
		# --------------------------------
397
398
		self.finished(request.id, result)
399
		
400
		
233
	# ----------------------- Internal functions -------------------------
401
	# ----------------------- Internal functions -------------------------
234
402
235
	def _job_list(self,printer):
403
	def _job_list(self,printer):
 Lines 317-322    Link Here 
317
		
485
		
318
		return ''
486
		return ''
319
	
487
	
488
	def _set_quota(self,printer,user,soft,hard):
489
		""" sets a quota entry. Can also add a user """
490
		
491
		# Before we can set quota we have to ensure that the user is
492
		# already known to PyKota. Fortunately these tools don't complain
493
		# if we try to create a user that doesn't already exist.
494
		
495
		self._shell_command(['/usr/bin/pkusers','--skipexisting','--add',user],{'LANG':'C'})
496
		
497
		# Caution! order of args is important!
498
		
499
		(stdout,stderr,status) = self._shell_command([
500
			'/usr/bin/edpykota',
501
			'--printer',printer,
502
			'--softlimit',str(soft),
503
			'--hardlimit',str(hard),
504
			'--add',user
505
		],{'LANG':'C'})
506
507
		# not all errors are propagated in exit codes...
508
		# but at least they adhere to the general rule that
509
		# progress is printed to STDOUT and errors/warnings to STDERR
510
		if status or len(stderr):
511
			return stderr
512
		
513
		return ''
514
	
515
	def _reset_quota(self,printer,users):
516
		""" resets the 'used' counter on a quota entry. """
517
		
518
		cmd = [	'/usr/bin/edpykota','--printer',printer,'--reset' ]
519
		# appending user names to the args array -> spaces in user names
520
		# don't confuse edpykota (In 2.4, this was a problem)
521
		for user in users:
522
			cmd.append(user)
523
		(stdout,stderr,status) = self._shell_command(cmd,{'LANG':'C'})
524
	
525
		if status or len(stderr):
526
			return stderr
527
		
528
		return ''
529
320
	def _quota_enabled(self,printer=None):
530
	def _quota_enabled(self,printer=None):
321
		""" returns a dictionary with printer names and their 'quota active' status.
531
		""" returns a dictionary with printer names and their 'quota active' status.
322
			if printer is specified, returns only quota status for this printer.
532
			if printer is specified, returns only quota status for this printer.
 Lines 363-366    Link Here 
363
		outputs = proc.communicate()
573
		outputs = proc.communicate()
364
		
574
		
365
		return (outputs[0],outputs[1],proc.returncode)
575
		return (outputs[0],outputs[1],proc.returncode)
366
			
576
			
(-)umc/printers.xml (-3 / +21 lines)
 Lines 9-19    Link Here 
9
9
10
	<command name="printers/query" function="list_printers"/>
10
	<command name="printers/query" function="list_printers"/>
11
11
12
	<command name="printers/get" function="get">
12
	<command name="printers/get" function="get_printer">
13
		<attribute name="printer" syntax="String"/>
13
		<attribute name="printer" syntax="String"/>
14
	</command>
14
	</command>
15
15
16
	<command name="printers/enable" function="enable">
16
	<command name="printers/enable" function="enable_printer">
17
		<attribute name="printer" syntax="String"/>
17
		<attribute name="printer" syntax="String"/>
18
		<attribute name="on" syntax="Bool"/>
18
		<attribute name="on" syntax="Bool"/>
19
	</command>
19
	</command>
 Lines 22-28    Link Here 
22
		<attribute name="printer" syntax="String"/>
22
		<attribute name="printer" syntax="String"/>
23
	</command>
23
	</command>
24
24
25
	<command name="printers/jobs/cancel" function="cancel">
25
	<command name="printers/jobs/cancel" function="cancel_jobs">
26
		<attribute name="printer" syntax="String"/>
26
		<attribute name="printer" syntax="String"/>
27
		<attribute name="jobs" syntax="String"/>
27
		<attribute name="jobs" syntax="String"/>
28
	</command>
28
	</command>
 Lines 31-35    Link Here 
31
		<attribute name="printer" syntax="String"/>
31
		<attribute name="printer" syntax="String"/>
32
	</command>
32
	</command>
33
33
34
	<command name="printers/users/query" function="list_users"/>
35
36
	<!-- equally used to add or to edit an entry -->
37
	<command name="printers/quota/set" function="set_quota">
38
		<attribute name="printer" syntax="String"/>
39
		<attribute name="user" syntax="String"/>
40
		<attribute name="soft" syntax="Integer"/>
41
		<attribute name="hard" syntax="Integer"/>
42
	</command>
43
44
	<!-- how about deleting an entry? -->
45
46
	<!-- seperate call: reset 'used' counter -->
47
	<command name="printers/quota/reset" function="reset_quota">
48
		<attribute name="printer" syntax="String"/>
49
		<attribute name="users" syntax="Array"/>
50
	</command>
51
34
  </module>
52
  </module>
35
</umc>
53
</umc>
(-)umc/js/de.po (-34 / +72 lines)
 Lines 3-18    Link Here 
3
msgstr ""
3
msgstr ""
4
"Project-Id-Version: univention-management-console-module-printers\n"
4
"Project-Id-Version: univention-management-console-module-printers\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
6
"POT-Creation-Date: 2011-11-09 17:57+0100\n"
6
"POT-Creation-Date: 2011-11-17 12:15+0100\n"
7
"PO-Revision-Date: 2011-11-09 20:20+0100\n"
7
"PO-Revision-Date: 2011-11-17 14:28+0100\n"
8
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
"Last-Translator: Frank Greif <fg@it25.de>\n"
9
"Language-Team: LANGUAGE <LL@li.org>\n"
9
"Language-Team: LANGUAGE <LL@li.org>\n"
10
"Language: \n"
10
"Language: de\n"
11
"MIME-Version: 1.0\n"
11
"MIME-Version: 1.0\n"
12
"Content-Type: text/plain; charset=UTF-8\n"
12
"Content-Type: text/plain; charset=UTF-8\n"
13
"Content-Transfer-Encoding: 8bit\n"
13
"Content-Transfer-Encoding: 8bit\n"
14
14
15
#: umc/js/_printers/DetailPage.js:59 umc/js/_printers/OverviewPage.js:133
15
#: umc/js/_printers/DetailPage.js:59
16
#: umc/js/_printers/OverviewPage.js:133
16
msgid "Activate"
17
msgid "Activate"
17
msgstr "Aktivieren"
18
msgstr "Aktivieren"
18
19
 Lines 20-26    Link Here 
20
msgid "Activate this printer"
21
msgid "Activate this printer"
21
msgstr "diesen Drucker aktivieren"
22
msgstr "diesen Drucker aktivieren"
22
23
23
#: umc/js/_printers/QuotaPage.js:88
24
#: umc/js/_printers/QuotaPage.js:108
25
msgid "Add new record"
26
msgstr "Eintrag hinzufügen"
27
28
#: umc/js/_printers/QuotaPage.js:227
29
msgid "Add quota entry"
30
msgstr "Quota-Eintrag hinzufügen"
31
32
#: umc/js/_printers/QuotaPage.js:92
24
msgid "Back"
33
msgid "Back"
25
msgstr "zurück"
34
msgstr "zurück"
26
35
 Lines 29-34    Link Here 
29
msgstr "Zurück zur Übersicht"
38
msgstr "Zurück zur Übersicht"
30
39
31
#: umc/js/_printers/DetailPage.js:129
40
#: umc/js/_printers/DetailPage.js:129
41
#: umc/js/_printers/QuotaDialog.js:36
32
msgid "Cancel"
42
msgid "Cancel"
33
msgstr "Abbrechen"
43
msgstr "Abbrechen"
34
44
 Lines 36-46    Link Here 
36
msgid "Cancel this job/these jobs"
46
msgid "Cancel this job/these jobs"
37
msgstr "Diesen Druckauftrag (oder mehrere) abbrechen"
47
msgstr "Diesen Druckauftrag (oder mehrere) abbrechen"
38
48
39
#: umc/js/_printers/QuotaPage.js:25
49
#: umc/js/_printers/QuotaPage.js:27
40
msgid "Current quota records for printer"
50
msgid "Current quota records for printer"
41
msgstr "Aktuelle Quota-Einträge für diesen Drucker"
51
msgstr "Aktuelle Quota-Einträge für diesen Drucker"
42
52
43
#: umc/js/_printers/DetailPage.js:71 umc/js/_printers/OverviewPage.js:151
53
#: umc/js/_printers/DetailPage.js:71
54
#: umc/js/_printers/OverviewPage.js:151
44
msgid "Deactivate"
55
msgid "Deactivate"
45
msgstr "Deaktivieren"
56
msgstr "Deaktivieren"
46
57
 Lines 48-54    Link Here 
48
msgid "Deactivate this printer"
59
msgid "Deactivate this printer"
49
msgstr "diesen Drucker deaktivieren"
60
msgstr "diesen Drucker deaktivieren"
50
61
51
#: umc/js/_printers/DetailPage.js:232 umc/js/_printers/OverviewPage.js:53
62
#: umc/js/_printers/DetailPage.js:232
63
#: umc/js/_printers/OverviewPage.js:53
52
#: umc/js/_printers/OverviewPage.js:118
64
#: umc/js/_printers/OverviewPage.js:118
53
msgid "Description"
65
msgid "Description"
54
msgstr "Beschreibung"
66
msgstr "Beschreibung"
 Lines 57-75    Link Here 
57
msgid "Details for printer <b>{printer}</b>"
69
msgid "Details for printer <b>{printer}</b>"
58
msgstr "Details für Drucker <b>{printer}</b>"
70
msgstr "Details für Drucker <b>{printer}</b>"
59
71
60
#: umc/js/_printers/QuotaPage.js:81
72
#: umc/js/_printers/QuotaPage.js:84
61
msgid "Edit"
73
msgid "Edit"
62
msgstr "Bearbeiten"
74
msgstr "Bearbeiten"
63
75
64
#: umc/js/_printers/DetailPage.js:83 umc/js/_printers/OverviewPage.js:169
76
#: umc/js/_printers/DetailPage.js:83
77
#: umc/js/_printers/OverviewPage.js:169
65
msgid "Edit quota"
78
msgid "Edit quota"
66
msgstr "Quota bearbeiten"
79
msgstr "Quota bearbeiten"
67
80
81
#: umc/js/_printers/QuotaPage.js:240
82
msgid "Edit quota entry"
83
msgstr "Quota bearbeiten"
84
68
#: umc/js/_printers/DetailPage.js:84
85
#: umc/js/_printers/DetailPage.js:84
69
msgid "Edit quota related to this printer"
86
msgid "Edit quota related to this printer"
70
msgstr "Quota-Einträge für diesen Drucker bearbeiten"
87
msgstr "Quota-Einträge für diesen Drucker bearbeiten"
71
88
72
#: umc/js/_printers/QuotaPage.js:63
89
#: umc/js/_printers/QuotaPage.js:65
90
#: umc/js/_printers/QuotaDialog.js:71
73
msgid "Hard limit"
91
msgid "Hard limit"
74
msgstr "Hard limit"
92
msgstr "Hard limit"
75
93
 Lines 77-87    Link Here 
77
msgid "Job"
95
msgid "Job"
78
msgstr "Druckauftrag"
96
msgstr "Druckauftrag"
79
97
80
#: umc/js/_printers/QuotaPage.js:67
98
#: umc/js/_printers/QuotaPage.js:69
81
msgid "Lifetime page counter"
99
msgid "Lifetime page counter"
82
msgstr "Seitenzähler"
100
msgstr "Seitenzähler"
83
101
84
#: umc/js/_printers/DetailPage.js:231 umc/js/_printers/OverviewPage.js:54
102
#: umc/js/_printers/DetailPage.js:231
103
#: umc/js/_printers/OverviewPage.js:54
85
#: umc/js/_printers/OverviewPage.js:114
104
#: umc/js/_printers/OverviewPage.js:114
86
msgid "Location"
105
msgid "Location"
87
msgstr "Ort"
106
msgstr "Ort"
 Lines 90-96    Link Here 
90
msgid "Owner"
109
msgid "Owner"
91
msgstr "Eigentümer"
110
msgstr "Eigentümer"
92
111
93
#: umc/js/_printers/QuotaPage.js:55
112
#: umc/js/_printers/QuotaPage.js:57
94
msgid "Pages used"
113
msgid "Pages used"
95
msgstr "gedruckte Seiten"
114
msgstr "gedruckte Seiten"
96
115
 Lines 102-132    Link Here 
102
msgid "Printer"
121
msgid "Printer"
103
msgstr "Drucker"
122
msgstr "Drucker"
104
123
105
#: umc/js/_printers/OverviewPage.js:29 umc/js/_printers/OverviewPage.js:40
124
#: umc/js/_printers/OverviewPage.js:29
125
#: umc/js/_printers/OverviewPage.js:40
106
msgid "Printer administration"
126
msgid "Printer administration"
107
msgstr "Druckerverwaltung"
127
msgstr "Druckerverwaltung"
108
128
109
#: umc/js/_printers/DetailPage.js:27 umc/js/_printers/DetailPage.js:38
129
#: umc/js/_printers/DetailPage.js:27
130
#: umc/js/_printers/DetailPage.js:38
110
msgid "Printer details"
131
msgid "Printer details"
111
msgstr "Druckerdetails"
132
msgstr "Druckerdetails"
112
133
113
#: umc/js/_printers/OverviewPage.js:52
134
#: umc/js/_printers/OverviewPage.js:52
135
#: umc/js/_printers/QuotaDialog.js:49
114
msgid "Printer name"
136
msgid "Printer name"
115
msgstr "Druckername"
137
msgstr "Druckername"
116
138
117
#: umc/js/_printers/QuotaPage.js:26 umc/js/_printers/QuotaPage.js:37
139
#: umc/js/_printers/QuotaPage.js:28
140
#: umc/js/_printers/QuotaPage.js:39
118
msgid "Printer quota"
141
msgid "Printer quota"
119
msgstr "Druckername"
142
msgstr "Druckername"
120
143
121
#: umc/js/_printers/DetailPage.js:229 umc/js/_printers/OverviewPage.js:103
144
#: umc/js/_printers/DetailPage.js:229
145
#: umc/js/_printers/OverviewPage.js:103
122
msgid "Quota"
146
msgid "Quota"
123
msgstr "Quota"
147
msgstr "Quota"
124
148
125
#: umc/js/_printers/QuotaPage.js:131
149
#: umc/js/_printers/QuotaPage.js:174
126
msgid "Quota entries for printer <b>{printer}</b>"
150
msgid "Quota entries for printer <b>{printer}</b>"
127
msgstr "Quota-Einträge für Drucker <b>{printer}</b>"
151
msgstr "Quota-Einträge für Drucker <b>{printer}</b>"
128
152
129
#: umc/js/_printers/QuotaPage.js:96
153
#: umc/js/_printers/QuotaPage.js:100
130
msgid "Refresh"
154
msgid "Refresh"
131
msgstr "Aktualisieren"
155
msgstr "Aktualisieren"
132
156
 Lines 138-152    Link Here 
138
msgid "Refresh printer list"
162
msgid "Refresh printer list"
139
msgstr "Drucker-Liste aktualisieren"
163
msgstr "Drucker-Liste aktualisieren"
140
164
141
#: umc/js/_printers/QuotaPage.js:74
165
#: umc/js/_printers/QuotaPage.js:76
142
msgid "Reset user quota"
166
msgid "Reset user quota"
143
msgstr "Quota für diesen Nutzer zurücksetzen"
167
msgstr "Quota für diesen Nutzer zurücksetzen"
144
168
169
#: umc/js/_printers/QuotaDialog.js:29
170
msgid "Save changes"
171
msgstr "Eintrag speichern"
172
145
#: umc/js/_printers/OverviewPage.js:50
173
#: umc/js/_printers/OverviewPage.js:50
146
msgid "Search key"
174
msgid "Search key"
147
msgstr "Suchbegriff"
175
msgstr "Suchbegriff"
148
176
149
#: umc/js/_printers/DetailPage.js:224 umc/js/_printers/OverviewPage.js:80
177
#: umc/js/_printers/DetailPage.js:224
178
#: umc/js/_printers/OverviewPage.js:80
150
msgid "Server"
179
msgid "Server"
151
msgstr "Server"
180
msgstr "Server"
152
181
 Lines 154-164    Link Here 
154
msgid "Size"
183
msgid "Size"
155
msgstr "Größe"
184
msgstr "Größe"
156
185
157
#: umc/js/_printers/QuotaPage.js:59
186
#: umc/js/_printers/QuotaPage.js:61
187
#: umc/js/_printers/QuotaDialog.js:64
158
msgid "Soft limit"
188
msgid "Soft limit"
159
msgstr "Soft limit"
189
msgstr "Soft limit"
160
190
161
#: umc/js/_printers/DetailPage.js:225 umc/js/_printers/OverviewPage.js:88
191
#: umc/js/_printers/DetailPage.js:225
192
#: umc/js/_printers/OverviewPage.js:88
162
msgid "Status"
193
msgid "Status"
163
msgstr "Status"
194
msgstr "Status"
164
195
 Lines 168-181    Link Here 
168
199
169
#: umc/js/_printers/OverviewPage.js:28
200
#: umc/js/_printers/OverviewPage.js:28
170
msgid "This module lets you manage the printers defined on your machine"
201
msgid "This module lets you manage the printers defined on your machine"
171
msgstr ""
202
msgstr "In diesem Modul können Sie die Drucker verwalten, die auf Ihrer Maschine "
172
"In diesem Modul können Sie die Drucker verwalten, die auf Ihrer Maschine "
173
"definiert sind."
203
"definiert sind."
174
204
175
#: umc/js/_printers/QuotaPage.js:51
205
#: umc/js/_printers/QuotaPage.js:53
176
msgid "User"
206
msgid "User"
177
msgstr "Nutzer"
207
msgstr "Nutzer"
178
208
209
#: umc/js/_printers/QuotaDialog.js:55
210
msgid "User name"
211
msgstr "Nutzername"
212
179
#: umc/js/_printers/OverviewPage.js:125
213
#: umc/js/_printers/OverviewPage.js:125
180
msgid "View details"
214
msgid "View details"
181
msgstr "Details ansehen"
215
msgstr "Details ansehen"
 Lines 185-205    Link Here 
185
"You see the details of this printer and its print jobs. You can activate/"
219
"You see the details of this printer and its print jobs. You can activate/"
186
"deactivate the printer, edit its quota definitions if quota is enabled, and "
220
"deactivate the printer, edit its quota definitions if quota is enabled, and "
187
"cancel print jobs."
221
"cancel print jobs."
188
msgstr ""
222
msgstr "Sie sehen die Details des Druckers sowie seine aktuellen Druckaufträge. Sie "
189
"Sie sehen die Details des Druckers sowie seine aktuellen Druckaufträge. Sie "
190
"können den Drucker aktivieren/deaktivieren, Quota-Einträge verwalten und "
223
"können den Drucker aktivieren/deaktivieren, Quota-Einträge verwalten und "
191
"Druckaufträge abbrechen."
224
"Druckaufträge abbrechen."
192
225
193
#: umc/js/_printers/DetailPage.js:218 umc/js/_printers/DetailPage.js:229
226
#: umc/js/_printers/DetailPage.js:218
194
#: umc/js/_printers/OverviewPage.js:95 umc/js/_printers/OverviewPage.js:107
227
#: umc/js/_printers/DetailPage.js:229
228
#: umc/js/_printers/OverviewPage.js:95
229
#: umc/js/_printers/OverviewPage.js:107
195
msgid "active"
230
msgid "active"
196
msgstr "aktiv"
231
msgstr "aktiv"
197
232
198
#: umc/js/_printers/DetailPage.js:219 umc/js/_printers/OverviewPage.js:96
233
#: umc/js/_printers/DetailPage.js:219
234
#: umc/js/_printers/OverviewPage.js:96
199
#: umc/js/_printers/OverviewPage.js:109
235
#: umc/js/_printers/OverviewPage.js:109
200
msgid "inactive"
236
msgid "inactive"
201
msgstr "inaktiv"
237
msgstr "inaktiv"
202
238
203
#: umc/js/_printers/DetailPage.js:215 umc/js/_printers/OverviewPage.js:98
239
#: umc/js/_printers/DetailPage.js:215
240
#: umc/js/_printers/OverviewPage.js:98
204
msgid "unknown"
241
msgid "unknown"
205
msgstr "unbekannt"
242
msgstr "unbekannt"
243
(-)umc/js/_printers/QuotaPage.js (-5 / +195 lines)
 Lines 11-16    Link Here 
11
dojo.require("umc.widgets.Grid");
11
dojo.require("umc.widgets.Grid");
12
dojo.require("umc.widgets.Form");
12
dojo.require("umc.widgets.Form");
13
13
14
dojo.require("umc.modules._printers.QuotaDialog");
15
14
dojo.declare("umc.modules._printers.QuotaPage",
16
dojo.declare("umc.modules._printers.QuotaPage",
15
[
17
[
16
	umc.widgets.Page,
18
	umc.widgets.Page,
 Lines 72-86    Link Here 
72
			{
74
			{
73
				name:				'clear',
75
				name:				'clear',
74
				label:				this._("Reset user quota"),
76
				label:				this._("Reset user quota"),
75
				callback: dojo.hitch(this, function(ids) {
77
				isMultiAction:		true,
76
					// TODO do something useful here
78
				callback: dojo.hitch(this, function(ids,values) {
79
					this._reset_quota_entries(values);
77
				})
80
				})
78
			},
81
			},
79
			{
82
			{
80
				name:				'edit',
83
				name:				'edit',
81
				label:				this._("Edit"),
84
				label:				this._("Edit"),
82
				callback: dojo.hitch(this, function(ids) {
85
				callback: dojo.hitch(this, function(ids,values) {
83
					// TODO do something useful here
86
					// always use the first value since multiselect doesn't make sense.
87
					this._edit_quota_entry(values[0]);
84
				})
88
				})
85
			},
89
			},
86
			{
90
			{
 Lines 98-103    Link Here 
98
				callback: dojo.hitch(this, function() {
102
				callback: dojo.hitch(this, function() {
99
					this._refresh_view();
103
					this._refresh_view();
100
				})
104
				})
105
			},
106
			{
107
				name:				'add',
108
				label:				this._("Add new record"),
109
				isContextAction:	false,
110
				callback: dojo.hitch(this, function(ids) {
111
					this._add_quota_entry();
112
				})
101
			}
113
			}
102
        ];
114
        ];
103
        
115
        
 Lines 110-115    Link Here 
110
        pane.addChild(this._grid);
122
        pane.addChild(this._grid);
111
        
123
        
112
	},
124
	},
125
	
126
	startup: function() {
127
		
128
		this.inherited(arguments);
129
		
130
        // fetch the userlist
131
		umc.tools.umcpCommand('printers/users/query').then(
132
			dojo.hitch(this, function(data) {
133
				if (data.result.length)
134
				{
135
					// we keep this list unchanged; it will be fetched only once.
136
					// on open of 'add quota' dialog, we pass a userlist that
137
					// is cleaned up from users already having a quota entry.
138
					this._userlist = data.result;
139
				}
140
			}),
141
			dojo.hitch(this, function(data) {
142
				umc.dialog.alert('Error fetching userlist: ' + data.message);
143
			})
144
		);
145
	},
113
    
146
    
114
	// Calling page passes args here. Arg is here the printer ID.
147
	// Calling page passes args here. Arg is here the printer ID.
115
	setArgs: function(args) {
148
	setArgs: function(args) {
 Lines 119-129    Link Here 
119
	},
152
	},
120
	
153
	
121
	onHide: function() {
154
	onHide: function() {
122
		// force clean state
155
		
156
		this.inherited(arguments);		// do I need this?
157
		
158
		// on next show(), the previous content
159
		// should not be visible anymore.
123
		this._head.set('content','');		// clear header text
160
		this._head.set('content','');		// clear header text
124
		this._grid.filter();				// clear grid data
161
		this._grid.filter();				// clear grid data
125
	},
162
	},
126
	
163
	
164
	onShow: function() {
165
		
166
		this.inherited(arguments);		// do I need this?
167
168
	},
169
	
127
	// called when the page is shown, but can equally be called
170
	// called when the page is shown, but can equally be called
128
	// on a manual or automatic refresh.
171
	// on a manual or automatic refresh.
129
	_refresh_view: function() {
172
	_refresh_view: function() {
 Lines 132-139    Link Here 
132
		
175
		
133
		// read current quota list
176
		// read current quota list
134
		this._grid.filter({printer:this._printer_id});
177
		this._grid.filter({printer:this._printer_id});
178
179
		// on first open: create the child dialog where we can edit one quota entry.
180
		if (! this._dialog)
181
		{
182
			this._dialog = new umc.modules._printers.QuotaDialog();
183
184
			// listen to the events of the dialog
185
	        dojo.connect(this._dialog,'onSubmit',dojo.hitch(this, function(values) {
186
	        	this._set_quota_entry(values);
187
	        }));
188
//	        dojo.connect(this._dialog,'onCancel',dojo.hitch(this, function() {
189
//	        	// nothing to do here.
190
//	        }));
191
192
		}
193
		
135
	},
194
	},
136
	
195
	
196
	// called from different places: the function that sets
197
	// a quota entry. When called with soft=0 and hard=0 this
198
	// would effectively forbid the user from printing...
199
	_set_quota_entry: function(values) {
200
    	umc.tools.umcpCommand('printers/quota/set',values).then(
201
    		dojo.hitch(this,function(data) {
202
    			if (data.result)
203
    			{
204
    				// an error message from the edpykota tool
205
    				umc.dialog.alert(data.result);
206
    			}
207
    			else
208
    			{
209
    				// success -> refresh view.
210
    				this._refresh_view();
211
    			}
212
    		}),
213
    		dojo.hitch(this,function(data) {
214
    			// error message from framework
215
    			umc.dialog.alert(data.message);
216
    		})
217
		);
218
	},
219
	
220
	// prepares everything to add a new quota entry.
221
	_add_quota_entry: function() {
222
		this._dialog.setValues({
223
			printer: 		this._printer_id,
224
			soft:			null,
225
			hard:			null,
226
			users:			this._cleaned_userlist(),
227
			title:			this._("Add quota entry")
228
		});
229
		this._dialog.show();
230
	},
231
	
232
	// prepares the edit dialog and shows it.
233
	// values is here a tuple of fields; this is always a single action.
234
	_edit_quota_entry: function(values) {
235
236
		try
237
		{
238
			var val = {
239
				printer:	this._printer_id,
240
				title:		this._("Edit quota entry")
241
			};
242
			this._dialog.setValues(dojo.mixin(val,values));
243
			this._dialog.show();
244
		}
245
		catch(ex)
246
		{
247
			console.error('edit_quota_entry(): ' + ex.message);
248
		}
249
	},
250
	
251
	// resets the 'used' counter on a list of users.
252
	// values is the array of field tuples of those users.
253
	_reset_quota_entries: function(values) {
254
		
255
		// if nothing is selected... why does the grid call the callback?
256
		if (values.length == 0)
257
		{
258
			return;
259
		}
260
		
261
		// ** NOTE ** we transfer the user names as an array since
262
		//			we can't know if some of them contain spaces or
263
		//			any other separator chars.
264
		var users = [];
265
		for (var u in values)
266
		{
267
			users.push(values[u]['user']);
268
		}
269
270
		umc.tools.umcpCommand('printers/quota/reset',{
271
			printer:			this._printer_id,
272
			users:				users
273
		}).then(
274
    		dojo.hitch(this,function(data) {
275
    			if (data.result)
276
    			{
277
    				// an error message from the edpykota tool
278
    				umc.dialog.alert(data.result);
279
    			}
280
    			else
281
    			{
282
    				// success -> refresh view.
283
    				this._refresh_view();
284
    			}
285
    		}),
286
    		dojo.hitch(this,function(data) {
287
    			// error message from framework
288
    			umc.dialog.alert(data.message);
289
    		})
290
		);
291
	},
292
293
	// prepares the list of users eligible for adding a quota entry:
294
	// this is the list of all users minus those that already have
295
	// a quota entry for this printer.
296
	//
297
	// Will be called only directly before a 'add quota entry' dialog
298
	// will be shown.
299
	_cleaned_userlist: function() {
300
		
301
		var result = [];
302
		var src = this._userlist;
303
		
304
		var usr = {};	// not an array: i want to to check for containedness!
305
		var items = this._grid.getAllItems();
306
		for (var i in items)
307
		{
308
			var u = items[i]['user'];
309
			usr[u] = u;
310
		}
311
		
312
		for (var s in src)
313
		{
314
			var sitem = src[s];
315
			
316
			// take this source item only if it is not contained
317
			// in the 'usr' dict.
318
			if (typeof(usr[sitem]) == 'undefined')
319
			{
320
				result.push(sitem);
321
			}
322
		}
323
		
324
		return result;
325
	},
326
	
137
    // main module listens here to return to the detail page
327
    // main module listens here to return to the detail page
138
    closeQuota: function(args) {
328
    closeQuota: function(args) {
139
    }
329
    }

Return to bug 22902