Commit 00d543de authored by David Byers's avatar David Byers
Browse files

Finished handling of conference recommendations

parent 922eeb68
2002-04-14 David Byers <david.byers@swipnet.se>
Handle conference recommendations:
* lyskom-rest.el (lyskom-reject-recommendation): Renamed from
lyskom-reject-invitation.
(lyskom-recommendation-already-rejected): Renamed from
lyskom-invitation-already-rejected.
(lyskom-update-rejected-recommendations): Renamed from
lyskom-update-rejected-invitations.
(lyskom-check-go-to-conf): Don't record rejected invitations.
(lyskom-startup-check-recommended-memberships): Renamed from
lyskom-startup-check-recommended-memberships. Interactively ask
whether the user wants to become a member of recommended
conferences instead of creating invitations.
* commands1.el (lyskom-try-add-member): Removed use-priority and
use-position again. Added default-priority instead.
* lyskom-rest.el (lyskom-startup-check-recommended-memberships):
New function.
......
......@@ -665,17 +665,15 @@ return non-nil if the item is to be included in the list."
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(let ((conf-no (string-to-int (match-string 1 (aux-item->data item))))
(text-no (string-to-int (match-string 2 (aux-item->data item)))))
(lyskom-format-insert 'status-rejected-invitation-aux-item
(lyskom-format-insert 'status-read-faq-aux-item
conf-no
text-no
(lyskom-aux-item-terminating-button item obj)))))
(defun lyskom-print-elisp-client-rejected-invitation (item &optional obj)
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(let ((conf-no (string-to-int (match-string 1 (aux-item->data item))))
(pers-no (string-to-int (match-string 2 (aux-item->data item)))))
(lyskom-format-insert 'status-read-faq-aux-item
pers-no
(when (string-match "^\\([0-9]+\\)" (aux-item->data item))
(let ((conf-no (string-to-int (match-string 1 (aux-item->data item)))))
(lyskom-format-insert 'status-rejected-recommendation-aux-item
conf-no
(lyskom-aux-item-terminating-button item obj)))))
......
......@@ -523,8 +523,7 @@ for person PERS-NO and send them into lyskom-try-add-member."
membership-type
&optional message-string
need-extra-information
use-priority
use-position)
default-priority)
"Add a member to a conference.
Args: CONF-CONF-STAT PERS-CONF-STAT PERS-STAT
CONF-CONF-STAT: the conf-stat of the conference the person is being added to
......@@ -539,8 +538,6 @@ a list where the first element is the result of add-member and the second
is the position where the membership was placed.
If optional USE-PRIORITY is non-nil then use that as the priority.
If optional USE-POSITION is non-nil, then use that as the position.
"
(if (or (null conf-conf-stat)
(null pers-conf-stat))
......@@ -550,21 +547,21 @@ If optional USE-POSITION is non-nil, then use that as the position.
(lyskom-read-num-range 0 255
(lyskom-get-string 'priority-q)
nil 100)
(if (and (numberp (or use-priority kom-membership-default-priority))
(< (or use-priority kom-membership-default-priority) 256)
(>= (or use-priority kom-membership-default-priority) 0))
(or use-priority kom-membership-default-priority)
(lyskom-read-num-range 0 255 (lyskom-get-string 'priority-q)))))
(if (and (numberp kom-membership-default-priority)
(< kom-membership-default-priority 256)
(>= kom-membership-default-priority 0))
kom-membership-default-priority
(lyskom-read-num-range 0 255 (lyskom-get-string 'priority-q) nil default-priority))))
(where
(if (/= lyskom-pers-no (conf-stat->conf-no pers-conf-stat))
1 ; When adding someone else
(cond
((and (numberp (or use-position kom-membership-default-placement))
(>= (or use-position kom-membership-default-placement) 0))
(or use-position kom-membership-default-placement))
((eq (or use-position kom-membership-default-placement) 'first)
((and (numberp kom-membership-default-placement)
(>= kom-membership-default-placement 0))
kom-membership-default-placement)
((eq kom-membership-default-placement 'first)
0)
((eq (or use-position kom-membership-default-placement) 'last)
((eq kom-membership-default-placement 'last)
(length lyskom-membership))
(t
(lyskom-read-num-range
......
......@@ -602,7 +602,7 @@ Read all about it at http://www.lysator.liu.se/history/")
(conf-mx-list-name . "Imported mailing list: %#1s %#2s\n")
(recommended-conf-aux . "Recommended conference: %#1M <%#1m> %#2s\n")
(status-read-faq-aux-item . "Read FAQ: %15#2n for %#1?z%[%#1M <%#1m>%]%[the server%] %#3s\n")
(status-rejected-invitation-aux-item . "Rejected invitation to: %#2M %#1?z%[%by #1M%]%[created automatically%] %#3s\n")
(status-rejected-recommendation-aux-item . "Rejected recommendation for: %#1M %#2s\n")
(Everybody . "Everyone")
(show-members-list-also-q . "List members? ")
......@@ -1679,6 +1679,9 @@ Number of sessions: %21#1d (total)
(recommend-set-priority-q . "Recommend a priority? ")
(recommend-set-mship-type-q . "Recommend a membership type? ")
(recommending-conf . "Recommending %#1M%#2?b%[ (priority %#2d)%]%[%]%#3?b%[ %#3s%]%[%]...")
(has-recommended-conf . "%#1P has recommended conference %#2M. Do you want to become a member?\n")
(accept-recommendation . "Join conference %#1M? ")
(accepting-recommendataion . "Joining recommended conference %#1M...")
))
......
......@@ -591,9 +591,7 @@ If CONF is nil, check the first conf on the to-do list."
(progn
(let ((kom-unsubscribe-makes-passive nil))
(lyskom-sub-member (blocking-do 'get-pers-stat lyskom-pers-no)
conf-stat)
(lyskom-reject-invitation (conf-stat->conf-no conf-stat)
(membership->created-by mship)))
conf-stat))
(setq continue nil)
)))
......@@ -621,11 +619,12 @@ If CONF is nil, check the first conf on the to-do list."
;;; Return the result
continue))
(defun lyskom-reject-invitation (conf-no pers-no)
"Record that we have rejected an invitation to CONF-NO by PERS-NO"
(unless (lyskom-invitation-already-rejected conf-no pers-no)
(setq lyskom-rejected-invitations (cons (cons conf-no pers-no)
lyskom-rejected-invitations))
(defun lyskom-reject-recommendation (conf-no)
"Record that we have rejected an invitation to CONF-NO
by PERS-NO"
(unless (lyskom-recommendation-already-rejected conf-no)
(setq lyskom-rejected-recommendations
(cons conf-no lyskom-rejected-recommendations))
(initiate-modify-conf-info
'background
nil
......@@ -635,39 +634,37 @@ If CONF is nil, check the first conf on the to-do list."
(lyskom-create-aux-item-flags nil nil t nil
nil nil nil nil)
0
(format "%d %d" conf-no pers-no))))))
(format "%d" conf-no))))))
(defun lyskom-invitation-already-rejected (conf-no pers-no)
"Return non-nil if we have rejected an invitation to CONF-NO from PERS-NO."
(member (cons conf-no pers-no) lyskom-rejected-invitations))
(defun lyskom-recommendation-already-rejected (conf-no)
"Return non-nil if we have rejected recommendation for CONF-NO"
(member conf-no lyskom-rejected-recommendations))
(defun lyskom-update-rejected-invitations ()
"Update the list of rejected invitations"
(setq lyskom-rejected-invitations nil)
(defun lyskom-update-rejected-recommendations ()
"Update the list of rejected recommendations"
(setq lyskom-rejected-recommendations nil)
(let* ((conf-stat (blocking-do 'get-conf-stat lyskom-pers-no))
(aux-list (and conf-stat (lyskom-get-aux-item
(conf-stat->aux-items conf-stat)
10001))))
(lyskom-traverse item aux-list
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(setq lyskom-rejected-invitations
(cons (cons (string-to-int (match-string 1 (aux-item->data item)))
(string-to-int (match-string 2 (aux-item->data item))))
lyskom-rejected-invitations))))))
(when (string-match "^\\([0-9]+\\)" (aux-item->data item))
(setq lyskom-rejected-recommendations
(cons (string-to-int (match-string 1 (aux-item->data item)))
lyskom-rejected-recommendations))))))
(defun lyskom-startup-check-recommended-memberships ()
"Create invitations for new membership recommendations"
(let ((recommendations
(filter-list
(lambda (rec)
(not (lyskom-invitation-already-rejected (car rec)
lyskom-pers-no)))
(not (lyskom-recommendation-already-rejected (car rec))))
(mapcar (lambda (aux)
(when (string-match "^\\([0-9]+\\)\\( [0-9]+\\)?\\( [01]+\\)?" (aux-item->data aux))
(let* ((conf-no (string-to-int (match-string 1 (aux-item->data aux))))
(priority (and conf-no (match-string 2) (string-to-int (match-string 2 (aux-item->data aux)))))
(mship-type (and priority (match-string 3) (match-string 3 (aux-item->data aux)))))
(list conf-no priority mship-type))))
(list conf-no priority mship-type (aux-item->creator aux)))))
(lyskom-get-aux-item (server-info->aux-item-list
lyskom-server-info) 29))))
(collector (make-collector)))
......@@ -695,15 +692,31 @@ If CONF is nil, check the first conf on the to-do list."
;; that we have not rejected and that we are not already members
;; of.
(blocking-do-multiple ((pers-stat (get-pers-stat lyskom-pers-no))
(pers-conf-stat (get-conf-stat lyskom-pers-no)))
(blocking-do-multiple ((pers-conf-stat (get-conf-stat lyskom-pers-no))
(pers-stat (get-pers-stat lyskom-pers-no)))
(lyskom-traverse rec recommendations
(lyskom-try-add-member
(blocking-do 'get-conf-stat (car rec))
pers-conf-stat
pers-stat
(lyskom-create-membership-type t nil nil nil nil nil nil nil)
nil nil 255 0)))))
(let ((conf-stat (blocking-do 'get-conf-stat (elt rec 0))))
(when conf-stat
(lyskom-format-insert 'has-recommended-conf
(elt rec 3)
(elt rec 0))
(if (lyskom-j-or-n-p
(lyskom-format 'accept-recommendation (elt rec 0)))
(let ((kom-membership-default-priority
(if (elt rec 1) 'ask kom-membership-default-priority)))
(lyskom-add-member-answer
(lyskom-try-add-member conf-stat
pers-conf-stat
pers-stat
(lyskom-create-membership-type
nil nil nil nil nil nil nil nil)
'accepting-recommendation
t
(elt rec 1))
conf-stat
pers-conf-stat))
(lyskom-reject-recommendation (elt rec 0)))))))))
(defun lyskom-enter-conf (conf-stat read-info)
......
......@@ -579,10 +579,11 @@ shown to other users."
;; Do some FAQ handling
(condition-case err
(progn (lyskom-update-read-faqs)
(lyskom-update-rejected-invitations)
(lyskom-update-rejected-recommendations)
(lyskom-startup-check-faqs)
(lyskom-startup-check-recommended-memberships))
(error nil))
(error nil)
(quit nil))
(lyskom-end-of-command)))
......
......@@ -583,7 +583,7 @@ i svensk datorhistoria. L
(conf-mx-list-name . "Importerad mailinglista: %#1s %#2s\n")
(recommended-conf-aux . "Rekommenderat mte: %#1M <%#1m> %#2s\n")
(status-read-faq-aux-item . "Lst FAQ: %15#2n fr %#1?z%[%#1M <%#1m>%]%[servern%] %#3s\n")
(status-rejected-invitation-aux-item . "Avvisad mtesinbjudan: %#2M %#1?z%[%by #1M%]%[skapad automatiskt%] %#3s\n")
(status-rejected-recommendation-aux-item . "Avvisad mtesrekommendation: %#1M %#2s\n")
(Everybody . "Alla")
(show-members-list-also-q . "Vill du se medlemslistan ocks? ")
......@@ -1679,6 +1679,9 @@ Antal sessioner: %21#1d (totalt)
(recommend-set-priority-q . "Rekommendera prioritet? ")
(recommend-set-mship-type-q . "Rekommendera mtestyp? ")
(recommending-conf . "Rekommenderar %#1M%#2?b%[ (prioritet %#2d)%]%[%]%#3?b%[ %#3s%]%[%]...")
(has-recommended-conf . "%#1P har rekommenderat mte %#2M. Vill du bli medlem?\n")
(accept-recommendation . "G med i %#1M? ")
(accepting-recommendataion . "G med i rekommenderat mte %#1M...")
))
(lyskom-language-var lyskom-month-names sv
......
......@@ -2585,7 +2585,7 @@ should be dynamically bound whenever it needs to be used.")
"List of FAQs that have been read."
inherited)
(def-kom-var lyskom-rejected-invitations nil
(def-kom-var lyskom-rejected-recommendations nil
"List of invitations that have been rejected."
inherited)
......
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