Ejemplo n.º 1
0
    def update(self):
        super(NotificationMail, self).update()

        content = self.context
        event = self.contexts[0]
        request = self.request

        self.url = "%s/" % absoluteURL(content, request)

        principal = IOwnership(content).owner

        profile = IPersonalProfile(principal)
        if profile.email:
            author = profile.title
            self.author = author
            self.addHeader(u"From", formataddr((author, profile.email)))
            self.addHeader(u"To", formataddr((self.author, profile.email)))
        else:
            self.author = principal.title or principal.id

        self.site = getSite()

        if profile.space is not None:
            self.space = u"%s/" % absoluteURL(profile.space, request)

        cId = getUtility(IIntIds).getId(content)

        self.messageId = u"<*****@*****.**>" % (cId, time.time())
Ejemplo n.º 2
0
    def update(self):
        topic = self.context
        request = self.request
        formatter = getFormatter(request, 'fancyDatetime', 'medium')

        name = topic.__name__
        owner = IOwnership(topic).owner
        profile = IPersonalProfile(owner)
        space = getattr(profile, 'space', None)

        self.name = name
        self.replies = len(topic)-1
        self.owner = getattr(profile, 'title', '')
        self.avatar = profile is not None and profile.avatarUrl(request) or '#',
        self.personal = '%s/'%(space and absoluteURL(space, request) or '',)

        message = topic.lastMessage

        if message is not None:
            owner = IOwnership(message).owner
            profile = IPersonalProfile(owner, None)
            space = getattr(profile, 'space', None)

            self.lastmessage = {
                'date': formatter.format(IDCTimes(message).modified),
                'owner': getattr(profile, 'title', ''),
                'personal': '%s/'%(space and absoluteURL(space,request) or '',),
                'avatar': profile is not None and profile.avatarUrl(request) or '#',
                'url': '%s/%s/'%(name, message.__name__)}
Ejemplo n.º 3
0
    def getUserInfo(self, loginOrId):
        """Return the user name details, and avatar url for given userid"""

        principal = getPrincipal(loginOrId)
        if principal is None:
            principal = getPrincipalByLogin(loginOrId)

        if principal is not None:
            profile = IPersonalProfile(principal, None)
            homeFolder = IPersonalSpace(principal, None)
            profileUrl = homeFolder is not None and '%s/profile/'%absoluteURL(homeFolder, self.request) or ''

            if profile.avatar is not None:
                iconURL = '%s/profile.avatar/%s' % (absoluteURL(getSite(), self.request), principal.id)
            else:
                iconURL = '%sprofileImage' % profileUrl

            return {'username' : loginOrId,
                    'fullname' : principal.title,
                    'email' : profile.email,
                    'home_page' : profileUrl,
                    'location' : profileUrl,
                    'description' : principal.description,
                    'portrait_url' : iconURL
                    }
        else:
            raise ValueError("User %s Does not Exist!" % loginOrId)
Ejemplo n.º 4
0
    def __call__(self):
        """Create breadcrumbs for an interface object.

        The breadcrumbs are rooted at the code browser.
        """
        docroot = findAPIDocumentationRoot(self.context)
        codeModule = traverse(docroot, "Code")
        crumbs = [{
            'name': _('[top]'),
            'url': absoluteURL(codeModule, self.request)
        }]
        # We need the __module__ of the interface, not of a location proxy,
        # so we have to remove all proxies.
        iface = removeAllProxies(self.context)
        mod_names = iface.__module__.split('.')
        obj = codeModule
        for name in mod_names:
            try:
                obj = traverse(obj, name)
            except KeyError: # pragma: no cover
                # An unknown (root) module, such as logging
                continue
            crumbs.append({
                'name': name,
                'url': absoluteURL(obj, self.request)
            })
        crumbs.append({
            'name': iface.__name__,
            'url': absoluteURL(self.context, self.request)
        })
        return crumbs
Ejemplo n.º 5
0
    def listDrafts(self):
        ids = getUtility(IIntIds)
        request = self.request
        context = self.context

        drafts = []
        for name in context:
            draft = context[name]
            if not checkPermission('zope.View', draft):
                continue

            try:
                loc = ids.queryObject(draft.location)
                locTitle = loc.title
                locUrl = '%s/'%absoluteURL(loc, request)
            except:
                locTitle = _('Unknown')
                locUrl = u''

            dc = ICMFDublinCore(draft.content)

            info = {'name': name,
                    'title': draft.title or _('[No title]'),
                    'description': draft.description,
                    'url': '%s/'%absoluteURL(draft, request),
                    'location': locTitle,
                    'locationURL': locUrl,
                    'icon': queryMultiAdapter((draft, request), name='zmi_icon'),
                    'draft': draft,
                    'modified': dc.modified,
                    'status': ISubmittedDraftContent.providedBy(draft),
                    'contentType': IContentType(draft.content)}
            drafts.append(info)

        return drafts
Ejemplo n.º 6
0
    def update(self):
        super(MemberMessageNotification, self).update()

        context = self.context
        request = self.request

        group = removeAllProxies(context.context).__parent__
        visible = checkPermission('zope.View', group)

        owner = IOwnership(group).owner
        profile = IPersonalProfile(owner, None)

        message = cgi.escape(context.message)
        message = message.replace(' ', '&nbsp;')
        message = message.replace('\n', '<br />')

        self.title = group.title
        self.sender = getattr(profile, 'title', 'Unknown member')

        self.info = {
            'title': group.title,
            'description': group.description,
            'created': IDCTimes(group).created,
            'members': len(group),
            'url': '%s/'%absoluteURL(group, request),
            'message': message,
            'default': not visible or not bool(getattr(group, 'logo', None)),
            'sender': self.sender}

        if profile is not None:
            self.addHeader(u'From', formataddr((self.sender, profile.email),))

        self.site = getSite()
        self.siteTitle = getattr(self.site, 'title', u'') or self.site.__name__
        self.siteURL = u'%s'%absoluteURL(self.site, request)
Ejemplo n.º 7
0
    def query(self, default=None):
        request = self.request
        content = self.getLocation()
        if content is None:
            return

        item = IItem(content, None)

        title = u''
        description = u''
        if item is not None:
            title = item.title
            description = item.description

        view = queryMultiAdapter((content, request), IContentViewView)
        if view is not None:
            url = '%s/%s'%(absoluteURL(content, request), view.name)
        else:
            url = '%s/'%absoluteURL(content, request)

        return {'url': url,
                'title': title or _('[No title]'),
                'content': content,
                'icon': queryMultiAdapter((content, request), name='zmi_icon'),
                'description': description or u''}
Ejemplo n.º 8
0
    def update(self):
        super(TaskDeletedNotification, self).update()

        context = removeAllProxies(self.context)
        request = self.request
        principal = self.request.principal

        self.name = context.__name__

        mailer = getUtility(IMailer)

        profile = IPersonalProfile(principal, None)
        if profile is not None and profile.email:
            author = profile.title
            self.author = author
            self.addHeader(u"To", formataddr((author, profile.email)))
        else:
            self.author = principal.title or principal.id

        self.addHeader(u"From", formataddr((self.author, mailer.email_from_address)))

        self.url = "%s/" % absoluteURL(context, request)
        self.project = context.__parent__.__parent__

        # project
        self.projectTitle = self.project.title
        self.projectUrl = u"%s/" % absoluteURL(self.project, request)
Ejemplo n.º 9
0
    def handlePublish(self, action):
        errorSteps = []
        for step in self.steps:
            if not step.isComplete():
                errorSteps.append(step)

        if errorSteps:
            IStatusMessage(self.request).add(errorSteps, 'wizardError')
            return

        draft = self.draft
        request = self.request
        try:
            content = draft.publish()
            IStatusMessage(self.request).add(
                _(u'Your ${type_title} has been published.',
                  mapping={'type_title': IContentType(content).title}))

            view = queryMultiAdapter((content, request), IContentViewView)
            if view is not None:
                self.redirect('%s/%s'%(absoluteURL(content,request), view.name))
            else:
                self.redirect('%s/'%absoluteURL(content, request))

            del draft.__parent__[draft.__name__]
        except DraftException, err:
            IStatusMessage(request).add(str(err), 'error')
            self.wizard.setCurrentStep('content')
            self.redirect('%s/index.html'%absoluteURL(draft, request))
Ejemplo n.º 10
0
    def update(self):
        try:
            author = getUtility(IAuthentication).getPrincipal(
                self.context.author)
        except:
            author = None

        if author is not None:
            profile = IPersonalProfile(author)
            self.avatar = profile.avatarUrl(self.request)
            self.author = profile.title

            if profile.space is not None:
                self.url = absoluteURL(profile.space, self.request)
        else:
            self.avatar = u'%s/@@profile.avatar/0'%absoluteURL(
                getSite(), self.request)

        if author is not None or author == u'Unauthenticated User':
            if getattr(self.context, 'authorName'):
                self.author = self.context.authorName
                if 'social_avatar_url' in dir(self.context) and self.context.social_type:
                    self.social_avatar = self.context.social_avatar_url
                    if self.context.social_type==1:
                        self.social_name = 'Twitter'
                    elif self.context.social_type==2:
                        self.social_name = 'Facebook'

        self.comment = self.context.comment

        content = self.context.content
        self.postsAllowed = (
            IContentDiscussion(content).status in [1, 4] and
            checkPermission('zojax.AddComment', content))
Ejemplo n.º 11
0
    def update(self):
        super(EventDeletedNotification, self).update()

        context = removeAllProxies(self.context)
        request = self.request
        principal = self.request.principal

        self.name = context.__name__

        mailer = getUtility(IMailer)

        profile = IPersonalProfile(principal, None)
        if profile is not None and profile.email:
            author = profile.title
            self.author = author
            self.addHeader(u'To', formataddr((author, profile.email),))
        else:
            self.author = principal.title or principal.id

        self.addHeader(u'From', formataddr((self.author, mailer.email_from_address),))

        self.url = '%s/'%absoluteURL(context, request)
        self.calendar = context.__parent__

        # calendar
        self.calendarUrl = u'%s/'%absoluteURL(self.calendar, request)
Ejemplo n.º 12
0
    def handleNext(self, action):
        currentStep = self.step

        if IPageletForm.providedBy(currentStep):
            data, errors = currentStep.extractData()
            if errors:
                return

        if not currentStep.isComplete():
            return

        self.updateSteps()

        nextStep = self.request.get(self.nextStepName)
        if nextStep:
            try:
                nextStep = int(nextStep)
            except:
                nextStep = int(nextStep[0])
            self.redirect(
                '%s/'%absoluteURL(self.steps[nextStep], self.request))
        else:
            for pos, step in enumerate(self.steps):
                if currentStep.name == step.name:
                    break
            self.redirect('%s/'%absoluteURL(self.steps[pos+1], self.request))
Ejemplo n.º 13
0
    def update(self):
        super(CommentNotificationMail, self).update()

        content = self.context
        comment = self.context0
        self.comment = comment

        request = self.request

        principal = self.request.principal

        mailer = getUtility(IMailer)

        profile = IPersonalProfile(principal, None)
        if profile is not None and profile.email:
            author = profile.title
            self.author = author
            space = getattr(profile, 'space', None)
            if space is not None:
                self.profile_url = '%s/profile/' % absoluteURL(space, request)
            self.addHeader(u'To', formataddr((author, profile.email),))
            self.addHeader(u'From', formataddr((author, mailer.email_from_address),))
        else:
            self.author = principal.title or principal.id

        view = queryMultiAdapter((content, request), IContentViewView)
        if view is not None:
            self.url = '%s/%s'%(absoluteURL(content, request), view.name)
        else:
            self.url = '%s/'%absoluteURL(content, request)

        self.content = comment.content
        self.portal_title = getMultiAdapter((getSite(), request), IBreadcrumb).name
        self.available = comment.isAvailable()
Ejemplo n.º 14
0
    def listComments(self):
        auth = getUtility(IAuthentication)
        formatter = getFormatter(self.request, 'fancyDatetime', 'medium')

        comments = []
        for comment in self.comments:
            info = {'name': comment.__name__,
                    'title': comment.content.title,
                    'url': absoluteURL(comment.content, self.request),
                    'author': None,
                    'profile': None,
                    'date': comment.date,
                    'fomratteddate': formatter.format(comment.date)}

            try:
                principal = auth.getPrincipal(comment.author)
                profile = IPersonalProfile(principal)
                info['author'] = profile.title

                space = profile.space
                if space is not None:
                    info['profile'] = '%s/'%absoluteURL(space, self.request)

            except PrincipalLookupError:
                pass

            comments.append(info)

        return comments
Ejemplo n.º 15
0
 def getLinkURL(self, item):
     """Setup link url."""
     state = IWorkflowState(item).getState()
     if state != None:
         state = titleForState(state)
     if self.linkName is not None and state == "Entwurf":
         return '%s/%s' % (absoluteURL(item, self.request), self.linkName)
     return absoluteURL(item, self.request)
Ejemplo n.º 16
0
 def url(self):
     viewName = queryMultiAdapter(
         (self.context, self.request), IContentViewView)
     if viewName is not None:
         return '%s/%s'%(
             absoluteURL(self.context, self.request), viewName.name)
     else:
         return '%s/'%(absoluteURL(self.context, self.request))
Ejemplo n.º 17
0
 def nextURL(self):
     viewName = queryMultiAdapter(
         (self._addedObject, self.request), IContentViewView)
     if viewName is not None:
         return '%s/%s'%(
             absoluteURL(self._addedObject, self.request), viewName.name)
     else:
         return '%s/'%absoluteURL(self._addedObject, self.request)
Ejemplo n.º 18
0
 def nextURL(self):
     if 'person_id' in self.request:
         person_id = self.request['person_id']
         app = ISchoolToolApplication(None)
         persons = app['persons']
         if person_id in persons:
             return absoluteURL(persons[person_id], self.request)
     return absoluteURL(self.context, self.request)
Ejemplo n.º 19
0
    def update(self):
        super(EventNotification, self).update()

        context = removeAllProxies(self.context)
        request = self.request
        principal = self.request.principal
        ids = getUtility(IIntIds)

        self.name = context.__name__

        mailer = getUtility(IMailer)

        profile = IPersonalProfile(principal, None)
        if profile is not None and profile.email:
            author = profile.title
            self.author = author
            self.addHeader(u'To', formataddr((author, profile.email),))
        else:
            self.author = principal.title or principal.id

        self.addHeader(u'From', formataddr((self.author, mailer.email_from_address),))

        self.addHeader(u'In-Reply-To', u'<*****@*****.**>'%ids.getId(context))

        self.url = u'%s/'%absoluteURL(context, request)
        self.title = u'%s'%context.title
        self.calendar = context.__parent__

        # calendar
        self.calendarUrl = u'%s/'%absoluteURL(self.calendar, request)

        # owner
        self.owner = IOwnership(context).owner

        members = []
        for member in context.attendees:
            principal = getPrincipal(member)
            oneMember = {}

            homeFolder = IPersonalSpace(principal, None)
            profileUrl = homeFolder is not None \
                and '%s/profile/'%absoluteURL(homeFolder, request) or ''

            oneMember["url"] = profileUrl
            oneMember["title"] = principal.title
            members.append(oneMember)

        info = {
            'event': context,
            'sdDate': context.startDate.strftime('%m/%d/%Y'),
            'sdTime': context.startDate.strftime('%H:%M'),
            'edDate': context.endDate.strftime('%m/%d/%Y'),
            'edTime': context.endDate.strftime('%H:%M'),
            'members': members}

        self.info = info
Ejemplo n.º 20
0
    def contentUrl(self):
        content = self.content
        request = self.request

        view = queryMultiAdapter((content, request), IContentViewView)
        if view is not None:
            url = '%s/%s'%(absoluteURL(content, request), view.name)
        else:
            url = '%s/'%absoluteURL(content, request)

        return url
Ejemplo n.º 21
0
 def update(self):
     base_resource_url = '%s/@@/jquery-uploadify/' % absoluteURL(getSite(), self.request)
     url = self.request.getURL()
     params = {
         'uploader_url': base_resource_url + 'uploadify.swf',
         'script_url': '%s/bulk-upload-process' % absoluteURL(self.context, self.request),
         'ticket': issueTicket(url),
         'button_text': translate(self.buttonText, context=self.request),
         'cancel_image_url': base_resource_url + 'cancel.png',
     }
     includeInplaceSource(INIT_TEMPLATE % params, ('jquery-uploadify',))
Ejemplo n.º 22
0
    def update(self):
        super(MessageTemplate, self).update()

        request, context = self.request, self.context

        self.portal_title = getMultiAdapter((getSite(), request), IBreadcrumb).name
        self.portal_url = '%s/' % absoluteURL(getSite(), request)
        self.url = '%s/' % absoluteURL(context, request)

        self.form = getMultiAdapter((context, request), IFormResults)
        self.form.update(self.record)
Ejemplo n.º 23
0
 def render(self, item):
     content = item.getObject()
     title = content.get_title_or_id()
     if IVersion.providedBy(content):
         url = absoluteURL(content.get_silva_object(), self.request)
     else:
         url = absoluteURL(content, self.request)
     ellipsis = '&#8230;'
     if len(title) > 50:
         title = title[:50] + ellipsis
     return '<a href="%s" class="searchresult-link">%s</a>' % (url, title)
Ejemplo n.º 24
0
 def update(self):
     feed_provider = IFeedEntryProvider(self.context, None)
     if feed_provider is None:
         container = self.context.get_container()
         self.have_feeds = container.allow_feeds()
         self.feed_url = absoluteURL(container, self.request)
     else:
         if hasattr(self.context, 'allow_feeds'):
             self.have_feeds = self.context.allow_feeds()
         else:
             self.have_feeds = True
         self.feed_url = absoluteURL(self.context, self.request)
Ejemplo n.º 25
0
    def update(self):
        context, request = self.context, self.request

        configlet = getUtility(IFacebookCommentingConfig)

        params = {
            'client_id': configlet.appID,
            'redirect_uri': absoluteURL(self, request)
        }

        if 'logout' in self.request.keys():
            params['redirect_uri'] += '?logout=true'

        # step1: log in at facebook

        if not 'code' in self.request.keys():
            request.response.redirect(
                fb_authorize_url + urllib.urlencode(params))

        # step2: authorize App and grants necessary permissions

        if 'code' in self.request.keys():
            params["client_secret"] = configlet.appSecret
            params["code"] = self.request.get("code")

            response = dict(
                _parse_qsl(urllib.urlopen(fb_access_token_url + urllib.urlencode(params)).read()))

            access_token = response["access_token"]

            if not access_token:
                raise Exception('Invalid response from Facebook')

            if 'logout' in self.request.keys():
                request.response.expireCookie('fb_author')
                request.response.expireCookie('facebook_id')
                # request.response.expireCookie('fb_author_url')
                url = fb_logout_url + \
                    "next=%s&access_token=%s" % (
                        absoluteURL(self, request), access_token)
                request.response.redirect(url)

            # step3: make call to GraphAPI and get required user info

            profile = json.load(
                urllib.urlopen(fb_show_url + urllib.urlencode(dict(access_token=access_token))))

            exptime = _expire_time(30000000)  # 347 days

            self.request.response.setCookie(
                'fb_author', profile["name"], expires=exptime)
            self.request.response.setCookie(
                'facebook_id', str(profile["id"]), expires=exptime)
Ejemplo n.º 26
0
    def listContents(self):
        context = self.context
        request = self.request
        catalog = getUtility(ICatalog)
        ids = getUtility(IIntIds)
        formatter = getFormatter(request, 'humanDatetime', 'medium')

        query = {'traversablePath': {'any_of':(context,)},
                 'sort_order': 'reverse',
                 'sort_on': 'modified',
                 'isDraft': {'any_of': (False,)}}

        if '__all__' in self.types:
            query['typeType']={'any_of': ('Portal type',)}
        else:
            query['type']={'any_of': self.types}

        try:
            local_context = self.manager.view.maincontext
        except AttributeError:
            local_context = context

        if self.spaceMode == 2:
            query['contentSpace'] = {'any_of': [ids.queryId(removeSecurityProxy(getSpace(local_context)))] }
            del query['traversablePath']
        elif self.spaceMode == 3:
            query['traversablePath'] = {'any_of':(getSpace(local_context),)}

        query.update(self.extraParameters())

        docs = []
        for document in catalog.searchResults(**query)[:self.number]:
            view = queryMultiAdapter((document, request), IContentViewView)
            if view is not None:
                url = '%s/%s'%(absoluteURL(document, request), view.name)
            else:
                url = '%s/'%absoluteURL(document, request)

            space = getSpace(document, context)
            item = IItem(document, None)

            docs.append({'url': url,
                         'title': getattr(item, 'title', document.__name__),
                         'description': getattr(item, 'description', u''),
                         'date': formatter.format(IDCTimes(document).modified),
                         'icon': queryMultiAdapter(
                                   (document, request), name='zmi_icon'),
                         'space': space.title,
                         'spacedescription': space.description,
                         'spaceurl': '%s/'%absoluteURL(space, request),
                         'content': document,
                         })
        return docs
Ejemplo n.º 27
0
    def items(self):
        request = self.request
        types = {}

        for record in getUtility(IActivity).search(
            contexts = (self.context,))[:50]:

            content = record.object

            view = queryMultiAdapter((content, request), IContentViewView)
            try:
                if view is not None:
                    url = '%s/%s'%(absoluteURL(content, request), view.name)
                else:
                    url = '%s/'%absoluteURL(content, request)
            except:
                continue

            if record.type not in types:
                types[record.type] = record.description

            type = types.get(record.type, record.type) or record.type
            if type is not None:
                title = type.title
            else:
                title = _('Unknown')

            info = {
                'title': title,
                'link': '%s'%url,
                'guid': str(record.date),
                'pubDate': rfc822.formatdate(time.mktime(record.date.timetuple())),
                'description': u'',
                'isPermaLink': True}

            auth = getUtility(IAuthentication)
            try:
                principal = auth.getPrincipal(record.principal)
            except:
                principal = None

            if principal is not None:
                profile = IPersonalProfile(principal)
                author = profile.title
                info['author'] = u'%s (%s)'%(profile.email, author)

                info['description'] = u'by %s '%author

            info['description'] += 'on %s'%getattr(
                content, 'title', getattr(content, '__name__', u''))

            yield info
Ejemplo n.º 28
0
    def update(self):
        queryObject = getUtility(IIntIds).queryObject
        self.categories = categories = []
        for uid in self.context.category:
            category = queryObject(uid)
            if category is not None:
                categories.append(category)
        categories.sort(key=attrgetter('title'))
        self.date = IZopeDublinCore(self.context).created
        self.autoplay = str(self.context.autoplay).lower()

        if self.context.mediaSource:
            self.mediaURL = None
        else:
            self.mediaURL = (self.context.mediaData is not None \
                             and self.context.mediaData.data) \
                            and '%s/view.html' % absoluteURL(self.context, self.request) \
                            or (self.context.mediaURL or '')
            if self.context.mediaURLList:
                self.mediaURL = self.context.mediaURLList[0]
                mediaURLList = self.context.mediaURLList
            else:
                mediaURLList = [self.mediaURL]
            urls = map(lambda x: r"""{\'url\':\'%s\', \'autoPlay\': %s}""" % (urllib.quote(x[1]), \
                                                                                 x[0]==0 and self.autoplay or 'true'), \
                                            enumerate(mediaURLList))
            self.mediaURLListEncoded = r"\'playlist\': [%s]" % ','.join(urls)
        discussion = IContentDiscussion(self.context, None)
        self.comments = discussion is not None and len(discussion)
        self.discussible = discussion is not None and discussion.status != 3
        self.addcomment = self.discussible and discussion.status != 2
        self.tags = IContentTags(self.context, None)
        self.tags = self.tags is not None and self.tags.tags or []
        self.url = absoluteURL(self.context, self.request)
        self.space = getSpace(self.context)
        self.container_url = absoluteURL(self.space, self.request)
        self.site_url = absoluteURL(getSite(), self.request)
        owner = IOwnership(self.context).owner
        space = IPersonalSpace(owner, None)
        profile = IPersonalProfile(owner, None)
        # author
        try:
            self.author = '%s %s'%(profile.firstname, profile.lastname)
            self.avatar_url = profile.avatarUrl(self.request)
        except AttributeError:
            self.author = getattr(owner,'title','')
            self.avatar_url = '#'

        if space is not None:
            self.profile_url = '%s/profile/'%absoluteURL(space, self.request)
        self.container_title = self.space.title
        include('jquery-plugins')
Ejemplo n.º 29
0
    def update(self):
        super(NotificationMail, self).update()

        topic = self.context
        self.topic = topic
        message = self.contexts[0]
        forum = topic.__parent__
        request = self.request
        self.url = '%s/'%absoluteURL(message, request)
        self.message = message
        self.forum = forum
        self.forumurl = absoluteURL(forum, request)
        self.topicurl = absoluteURL(topic, request)

        principal = IOwnership(message).owner

        profile = IPersonalProfile(principal)
        if profile.email:
            author = profile.title
            self.author = author
            self.addHeader(u'From', formataddr((author, profile.email),))
        else:
            self.author = principal.title or principal.id

        self.site = getSite()

        destination = IMailInDestination(forum)
        if destination.enabled:
            self.addHeader(u'To', destination.address)
            self.addHeader(u'Reply-To', destination.address)
            self.addHeader(u'List-Post', u'<mailto:%s>'%destination.address)
        else:
            self.addHeader(u'To', formataddr((self.author, profile.email),))

        ids = getUtility(IIntIds)
        msgId = ids.getId(message)
        topicId = ids.getId(topic)

        if message.__name__ == TOPIC_FIRST_MESSAGE:
            self.messageId = u'<*****@*****.**>'%(topicId)
        else:
            self.messageId = u'<*****@*****.**>'%(topicId, msgId)

        self.addHeader(u'List-Id', u'%s'%forum.title)
        self.addHeader(u'List-Unsubscribe', u'%s/@@notifications'%self.forumurl)
        self.addHeader(u'List-Subscribe', u'%s/@@notifications'%self.forumurl)
        self.addHeader(u'List-Archive', u'%s/'%self.forumurl)

        self.addHeader(u'In-Reply-To', u'<*****@*****.**>'%topicId)
        self.addHeader(u'References', u'<*****@*****.**>'%topicId)
Ejemplo n.º 30
0
    def getContents(self):
        request = self.request

        for content in self.contents:
            dc = ICMFDublinCore(content)
            parent = content.__parent__

            yield {'title': content.title,
                   'description': content.description,
                   'modified': dc.modified,
                   'url': '%s/'%absoluteURL(content, request),
                   'icon': queryMultiAdapter((content, request), name="zmi_icon"),
                   'parentTitle': getattr(parent, 'title', parent.__name__),
                   'parentDescription': getattr(parent, 'description', u''),
                   'parentURL': absoluteURL(parent, request)}
 def resultURL(self, context, request):
     examples = zope.component.getUtility(
         IExampleContainer,
         context=context)
     return absoluteURL(examples, request) + u"/@@searchResult.html"
Ejemplo n.º 32
0
 def nextURL(self):
     """ don't forward the browser """
     return absoluteURL(self.context, self.request)
Ejemplo n.º 33
0
 def anchor(value, item, formatter):
     url = absoluteURL(item, formatter.request) + '/' + view
     return u'<a href="%s" title="%s">%s</a>' %(url, title, value)