Commit 5f880c3e authored by David Byers's avatar David Byers
Browse files

Added privilege display and manipulation code.

Detailed changes:
> 2003-12-07  David Byers  <byers@lysator.liu.se>
>
> 	Handle user privileges:
> 	* commands2.el (kom-change-privileges): New command.
> 	 (kom-status-person): Print privileges.
>
> 	* komtypes.el (pers-stat): Make privileges read-write.
>
> 	* utilities.el (lyskom-privilege-string): New function.
>
> 	* vars.el.in (lyskom-default-conference-strategy): Added
> 	change-conf-type, which was missing, to this list.
>
parent 652c1d22
2003-12-07 David Byers <byers@lysator.liu.se>
Handle user privileges:
* commands2.el (kom-change-privileges): New command.
(kom-status-person): Print privileges.
* komtypes.el (pers-stat): Make privileges read-write.
* utilities.el (lyskom-privilege-string): New function.
* vars.el.in (lyskom-default-conference-strategy): Added
change-conf-type, which was missing, to this list.
2003-12-04 David Byers <byers@lysator.liu.se>
* lyskom-rest.el (lyskom-read-number): Use lyskom-string-to-int so
......
......@@ -454,6 +454,12 @@ This command accepts text number prefix arguments \(see
'date-and-time
(conf-stat->last-written conf-stat)))
(let* ((a (lyskom-format 'pers-has-privileges ""))
(b (concat "\n" (make-string (lyskom-string-width a) ?\ ))))
(lyskom-format-insert 'pers-has-privileges
(lyskom-privilege-string (pers-stat->privileges pers-stat)
'pers-has-privileges-2
b)))
(let ((superconf (conf-stat->super-conf conf-stat)))
(lyskom-format-insert 'superconf
superconf
......@@ -2111,9 +2117,8 @@ See `kom-become-anonymous' for information on anonymous mode."
Using this command you can set all flags of a conference, with
the exception of the letterbox flag (which cannot be modified)."
(interactive)
(let* ((uconf-stat (lyskom-read-uconf-stat
(lyskom-get-string 'what-conf-to-change)
'(conf pers) nil "" t))
(let* ((uconf-stat (lyskom-read-uconf-stat 'what-conf-to-change
'(conf pers) nil "" t))
(type (uconf-stat->conf-type uconf-stat))
(box (conf-type->letterbox type))
(ori (conf-type->original type))
......@@ -2164,6 +2169,7 @@ the exception of the letterbox flag (which cannot be modified)."
(lyskom-insert-string 'done)))))
;;; ============================================================
;;; ndra sprk
;;;
......@@ -3599,6 +3605,56 @@ was given."
(def-kom-command kom-change-privileges (&optional set-all)
"Change privileges for a user.
Using this command you can change all privileges for a user."
(interactive "P")
(let* ((uconf-stat (lyskom-read-uconf-stat 'what-pers-privs-to-change
'(pers) nil "" t))
(pers-stat (blocking-do 'get-pers-stat
(uconf-stat->conf-no uconf-stat)))
(privs (pers-stat->privileges pers-stat)))
(lyskom-format-insert
'change-pers-privs-prompt
uconf-stat
(lyskom-privilege-string privs nil "\n "))
(let* ((wheel (lyskom-j-or-n-p (lyskom-get-string 'set-wheel-priv-q)))
(admin (lyskom-j-or-n-p (lyskom-get-string 'set-admin-priv-q)))
(statistic (lyskom-j-or-n-p (lyskom-get-string 'set-statistic-priv-q)))
(create-pers (lyskom-j-or-n-p (lyskom-get-string 'set-create-pers-priv-q)))
(create-conf (lyskom-j-or-n-p (lyskom-get-string 'set-create-conf-priv-q)))
(change-name (lyskom-j-or-n-p (lyskom-get-string 'set-change-name-priv-q)))
(flg7 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg7-priv-q)) (privs->flg7 privs)))
(flg8 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg8-priv-q)) (privs->flg8 privs)))
(flg9 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg9-priv-q)) (privs->flg9 privs)))
(flg10 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg10-priv-q)) (privs->flg10 privs)))
(flg11 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg11-priv-q)) (privs->flg11 privs)))
(flg12 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg12-priv-q)) (privs->flg12 privs)))
(flg13 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg13-priv-q)) (privs->flg13 privs)))
(flg14 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg14-priv-q)) (privs->flg14 privs)))
(flg15 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg15-priv-q)) (privs->flg15 privs)))
(flg16 (if set-all (lyskom-j-or-n-p (lyskom-get-string 'set-flg16-priv-q)) (privs->flg16 privs)))
(new-privs (lyskom-create-privs wheel admin statistic create-pers
create-conf change-name flg7 flg8
flg9 flg10 flg11 flg12
flg13 flg14 flg15 flg16)))
(if (not (blocking-do
'set-priv-bits
(pers-stat->pers-no pers-stat)
new-privs))
(progn (lyskom-insert-string 'nope)
(lyskom-insert-error))
(when (setq pers-stat
(cache-get-pers-stat (pers-stat->pers-no pers-stat)))
(set-pers-stat->privileges pers-stat new-privs))
(lyskom-insert-string 'done)))))
;;; ================================================================
;;; Temporary function for when we moved kom-extended-command from a
;;; to x.
......
......@@ -651,6 +651,8 @@ Read all about it at http://www.lysator.liu.se/history/")
(highest-local-no . "Highest local number: %20#1d\n")
(last-text-time . "Time of last text: %20#1s (according to your cache)\n")
(no-of-motd . "Notice in text: %13#1n\n")
(pers-has-privileges . "Privileges: %#1s\n")
(pers-has-privileges-2 . "%28#1s")
(superconf-is-no-name . "Superconference: %25#1m %#3s(%#2M)\n")
(permitted-submitters-no-name . "Allowed authors: %25#1m %#3s(%#2M)\n")
(supervisor-is-no-name . "Supervisor: %30#1p %#3s(%#2P)\n")
......@@ -1997,6 +1999,47 @@ written a presentation.%]
(mark-confs-as-known . "Mark these %#2d %#1s as known? ")
(no-new-conferences . "No new %#2s%#1?b%[ since %#1s%]%[%].\n")
(new-conferences-since . "New %#2s%#1?b%[ since %#1s%]%[%]:\n")
(privs-wheel . "wheel")
(privs-admin . "administrator")
(privs-statistic . "statistics")
(privs-create-conf . "create conferences")
(privs-create-pers . "create persons")
(privs-change-name . "change names")
(privs-flg7 . "unknown (7)")
(privs-flg8 . "unknown (8)")
(privs-flg9 . "unknown (9)")
(privs-flg10 . "unknown (10)")
(privs-flg11 . "unknown (11)")
(privs-flg12 . "unknown (12)")
(privs-flg13 . "unknown (13)")
(privs-flg14 . "unknown (14)")
(privs-flg15 . "unknown (15)")
(privs-flg16 . "unknown (16)")
(lyskom-no-privileges . "no permissions")
(what-pers-privs-to-change . "Whose privileges do you want to change? ")
(change-pers-privs-prompt . "\
Current privileges for %#1P (%#1p):
%#2s
Change privileges for %#1P (%#1p)...")
(set-wheel-priv-q . "Activate wheel privileges? ")
(set-admin-priv-q . "Activate administrator privileges? ")
(set-statistic-priv-q . "Activate statistics privileges? ")
(set-create-conf-priv-q . "Activate right to create conferences? ")
(set-create-pers-priv-q . "Activate right to create persons? ")
(set-change-name-priv-q . "Activate right to change names? ")
(set-flg7-priv-q . "Activate unknown privilege 7? ")
(set-flg8-priv-q . "Activate unknown privilege 8? ")
(set-flg9-priv-q . "Activate unknown privilege 9? ")
(set-flg10-priv-q . "Activate unknown privilege 10? ")
(set-flg11-priv-q . "Activate unknown privilege 11? ")
(set-flg12-priv-q . "Activate unknown privilege 12? ")
(set-flg13-priv-q . "Activate unknown privilege 13? ")
(set-flg14-priv-q . "Activate unknown privilege 14? ")
(set-flg15-priv-q . "Activate unknown privilege 15? ")
(set-flg16-priv-q . "Activate unknown privilege 16? ")
))
......@@ -2232,6 +2275,7 @@ written a presentation.%]
(kom-list-server-faqs . "List server-FAQs")
(kom-list-new-conferences . "List new conferences")
(kom-list-new-persons . "List new users")
(kom-change-privileges . "Change privileges")
))
(lyskom-language-var global lyskom-language-codes en
......
......@@ -265,7 +265,7 @@ Automatically created with def-komtype" type)
(def-komtype pers-stat
((pers-no :read-only t)
(username :read-only t)
(privileges :read-only t)
privileges
(flags :read-only t)
(last-login :read-only t)
user-area
......
......@@ -646,9 +646,10 @@ i svensk datorhistoria. L
(keep-commented . "Minsta livslngd fr kommenterade inlgg: %#1d dag%#1?d%[%]%[ar%]\n")
(lowest-local-no ."Lgsta existerande lokala nummer: %8#1d\n")
(highest-local-no . "Hgsta existerande lokala nummer: %8#1d\n")
(last-text-time .
"Tid fr senaste inlgg: %18#1s (str det i din cache)\n")
(last-text-time . "Tid fr senaste inlgg: %18#1s (str det i din cache)\n")
(no-of-motd . "Lapp p drren i text nummer: %12#1n\n")
(pers-has-privileges . "Rttigheter: %#1s\n")
(pers-has-privileges-2 . "%28#1s")
(superconf-is-no-name . "Supermte: %25#1m %#3s(%#2M)\n")
(permitted-submitters-no-name . "Tilltna frfattare:%22#1m %#3s(%#2M)\n")
(supervisor-is-no-name . "Organisatr: %25#1p %#3s(%#2P)\n")
......@@ -2027,6 +2028,47 @@ att upprepas d
(mark-confs-as-known . "Markera dessa %#2d %#1s som knda? ")
(no-new-conferences . "Inga nya %#2s%#1?b%[ sedan %#1s%]%[%].\n")
(new-conferences-since . "Nya %#2s%#1?b%[ sedan %#1s%]%[%]:\n")
(privs-wheel . "operatr")
(privs-admin . "administratr")
(privs-statistic . "statistik")
(privs-create-conf . "skapa mten")
(privs-create-pers . "skapa personer")
(privs-change-name . "ndra namn")
(privs-flg7 . "oknd (7)")
(privs-flg8 . "oknd (8)")
(privs-flg9 . "oknd (9)")
(privs-flg10 . "oknd (10)")
(privs-flg11 . "oknd (11)")
(privs-flg12 . "oknd (12)")
(privs-flg13 . "oknd (13)")
(privs-flg14 . "oknd (14)")
(privs-flg15 . "oknd (15)")
(privs-flg16 . "oknd (16)")
(lyskom-no-privileges . "inga rttigheter")
(what-pers-privs-to-change . "Vems rttigheter vill du ndra? ")
(change-pers-privs-prompt . "\
Nuvarande rttigheter fr %#1P (%#1p):
%#2s
ndra rttigheter fr %#1P (%#1p)...")
(set-wheel-priv-q . "Aktivera operatrsrttigheter? ")
(set-admin-priv-q . "Aktivera administratrsrttigheter? ")
(set-statistic-priv-q . "Aktivera statistikrttigheter? ")
(set-create-conf-priv-q . "Aktivera rtt att skapa mten? ")
(set-create-pers-priv-q . "Aktivera rtt att skapa personer? ")
(set-change-name-priv-q . "Aktivera rtt att ndra namn? ")
(set-flg7-priv-q . "Aktivera oknd rttighet 7? ")
(set-flg8-priv-q . "Aktivera oknd rttighet 8? ")
(set-flg9-priv-q . "Aktivera oknd rttighet 9? ")
(set-flg10-priv-q . "Aktivera oknd rttighet 10? ")
(set-flg11-priv-q . "Aktivera oknd rttighet 11? ")
(set-flg12-priv-q . "Aktivera oknd rttighet 12? ")
(set-flg13-priv-q . "Aktivera oknd rttighet 13? ")
(set-flg14-priv-q . "Aktivera oknd rttighet 14? ")
(set-flg15-priv-q . "Aktivera oknd rttighet 15? ")
(set-flg16-priv-q . "Aktivera oknd rttighet 16? ")
))
(lyskom-language-var local lyskom-month-names sv
......@@ -2261,6 +2303,7 @@ att upprepas d
(kom-list-server-faqs . "Lista server-FAQ")
(kom-list-new-conferences . "Lista nya mten")
(kom-list-new-persons . "Lista nya personer")
(kom-change-privileges . "ndra rttigheter")
))
(lyskom-language-var local lyskom-language-codes sv
......
......@@ -2176,4 +2176,30 @@ It ignores leading spaces and tabs."
(and signal-error
(signal 'lyskom-integer-conversion-error string))))
(defun lyskom-privilege-string (privs &optional format sep)
(setq format (or format "%#1s")
sep (or sep ", "))
(mapconcat (lambda (x) (lyskom-format format (lyskom-get-string x)))
(or (delq nil (list
(and (privs->wheel privs) 'privs-wheel)
(and (privs->admin privs) 'privs-admin)
(and (privs->statistic privs) 'privs-statistic)
(and (privs->create_pers privs) 'privs-create-pers)
(and (privs->create_conf privs) 'privs-create-conf)
(and (privs->change_name privs) 'privs-change-name)
(and (privs->flg7 privs) 'privs-flg7)
(and (privs->flg8 privs) 'privs-flg8)
(and (privs->flg9 privs) 'privs-flg9)
(and (privs->flg10 privs) 'privs-flg10)
(and (privs->flg11 privs) 'privs-flg11)
(and (privs->flg12 privs) 'privs-flg12)
(and (privs->flg13 privs) 'privs-flg13)
(and (privs->flg14 privs) 'privs-flg14)
(and (privs->flg15 privs) 'privs-flg15)
(and (privs->flg16 privs) 'privs-flg16)
))
'(lyskom-no-privileges))
sep))
(put 'lyskom-with-magic-minibuffer 'edebug-form-spec '(body))
......@@ -406,6 +406,8 @@ the priority among links that match the same text is undefined."
(kom-filter-subject (filter-in-conf))
(kom-filter-recipient (filter-recipient))
(kom-filter-text (filter-in-conf))
(kom-change-conf-type (what-conf-to-change))
(kom-change-privileges (what-pers-privs-to-change))
(t (t (default . (lyskom-default-conference-at-point
lyskom-default-conference-current))))
......@@ -3332,6 +3334,7 @@ Users are encouraged to use their best sense of humor."
kom-list-server-faqs
kom-list-new-conferences
kom-list-new-persons
kom-change-privileges
))
;;; ================================================================
......@@ -4268,7 +4271,8 @@ the value of kom-tell-phrases for fun.")
kom-add-server-faq
kom-del-server-faq
kom-change-server-faq
kom-recommend-conference))
kom-recommend-conference
kom-change-privileges))
;;; ================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment