def registerUser(self, user='', fname='', lname='', email='', npass='', cpass='', REQUEST=None, RESPONSE=None): """ register a new user """ errors = [] if not string.strip(user): errors.append(ERROR102) if not string.strip(fname): errors.append(ERROR100) if not string.strip(lname): errors.append(ERROR101) if not string.strip(email): errors.append(ERROR104) if not string.strip(npass) or not string.strip(cpass): errors.append(ERROR103) if self.getUser(user) or (self._emergency_user and user == self._emergency_user.getUserName()): errors.append(ERROR105) if (npass or cpass) and (npass != cpass): errors.append(ERROR106) users = self.getUserNames() for n in users: us = self.getUser(n) if email.strip() == us.email: errors.append(ERROR113) break if fname == us.firstname and lname == us.lastname: errors.append(ERROR114) break if len(errors): if REQUEST is not None: #save form data to session self.setUserSession(user, '', fname, lname, email) #save error to session self.setSessionErrors(errors) return REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER) else: return errors n = Notification() template_text = self.notification.register.document_src() template_html = self.notification.register_html.document_src() if self.notification.register.title: subject = self.notification.register.title elif self.notification.register_html.title: subject = self.notification.register_html.title else: subject = "finShare notifications" if self.webmaster: webmaster = self.webmaster else: webmaster = "*****@*****.**" n.send_registration(user, email, fname, lname, npass, webmaster, subject, template_text, template_html) if REQUEST is not None and REQUEST.has_key('destination'): return REQUEST.RESPONSE.redirect(REQUEST['destination'] + '?save=ok')
def sendFeedback(self, title, comments, REQUEST=None): """ send feedback """ n = Notification() template_text = self.notification.feedback.document_src() template_html = self.notification.feedback_html.document_src() user = self.REQUEST.AUTHENTICATED_USER.getUserName() user_ob = self.getUser(user) fname = self.getUserFirstName(user_ob) lname = self.getUserLastName(user_ob) email = self.getUserEmail(user_ob) n.send_feedback(title, comments, fname, lname, email, self.getDocManagerURL(), '*****@*****.**', template_text, template_html) if REQUEST is not None and REQUEST.has_key('destination'): return REQUEST.RESPONSE.redirect(REQUEST['destination'] + '?send=ok')
def lostPassword(self, email='', REQUEST=None, RESPONSE=None): """ forgot password """ errors = [] if not string.strip(email): errors.append(ERROR104) pwd = fname = lname = accoount = None if email!='': for n in self.getUserNames(): us = self.getUser(n) if email.strip() == us.email: pwd = self.getUserPassword(us) fname = self.getUserFirstName(us) lname = self.getUserLastName(us) account = self.getUserAccount(us) break if pwd is None: errors.append(ERROR117) if len(errors): if REQUEST is not None: #save form data to session self.setUserSession('', '', '', '', email) #save error to session self.setSessionErrors(errors) return REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER) else: return errors n = Notification() template_text = self.notification.sendpassword.document_src() template_html = self.notification.sendpassword_html.document_src() if self.notification.sendpassword.title: subject = self.notification.sendpassword.title elif self.notification.sendpassword_html.title: subject = self.notification.sendpassword_html.title else: subject = "finShare notifications" if self.webmaster: webmaster = self.webmaster else: webmaster = "*****@*****.**" n.send_passwords(account, email, fname, lname, pwd, webmaster, subject, template_text, template_html) if REQUEST is not None and REQUEST.has_key('destination'): return REQUEST.RESPONSE.redirect(REQUEST['destination'] + '?save=ok')
def sendNotifications(self): """ """ e = Notification() template = self.notification.newsletter.raw e.send_email('*****@*****.**', '*****@*****.**', template)