import OFS import AccessControl from OFS import SimpleItem import types import time from TraversableWrapper import Traversable from Globals import Persistent from AccessControl import ClassSecurityInfo from Cruft import Cruft from common import add_dtml, translate, perm_edit, perm_view from Products.ZCatalog.CatalogAwareness import CatalogAware class teade( OFS.SimpleItem.Item, Persistent, AccessControl.Role.RoleManager, Traversable, Cruft, CatalogAware ): """ teate kataloogis """ meta_type = 'teade' security = ClassSecurityInfo() security.declareObjectPublic() def __init__(self, sisu, lisaja): "teade eksemplari loomine" self.sisu=sisu self.lisaja=lisaja def kysiAeg(self): "loomise aeg" return time.localtime(self.bobobase_modification_time().timeTime()) class teatedeKataloog( OFS.Folder.Folder, OFS.SimpleItem.Item, Persistent, AccessControl.Role.RoleManager, Traversable, Cruft ): """ Koht teade hoidmiseks """ security = ClassSecurityInfo() security.declareObjectPublic() kasutajaandmed={} lingid_pl={} lingid_url={} teadeNr=0 teema="" yl="" def __init__(self): """ init, set id """ self.id = 'teated' security.declarePrivate('kysiUusNr') def kysiUusNr(self): self.teadeNr=self.teadeNr+1 while hasattr(self.aq_self, 'event'+str(self.teadeNr)): self.teadeNr=self.teadeNr+1 return self.teadeNr def lisateade(self, sisu, lisaja): nr = str(self.kysiUusNr()) t = teade(sisu,lisaja) t.id = nr self._setObject(nr, t) return t def teated_kuular(self, REQUEST, sisu): "Teade andmete salvestamine" kasutajanimi=str(REQUEST.AUTHENTICATED_USER) self.lisateade(sisu, kasutajanimi) REQUEST.RESPONSE.redirect('suhtlemine') return "Olemas" def yl_kuular(self, REQUEST, teema, yl): "ylesande andmete salvestamine" self.teema=teema self.yl=yl "REQUEST.RESPONSE.redirect('suhtlemine')" return "Olemas" def link_kuular(self, REQUEST, pealkiri, url): "ylesande andmete salvestamine" if not hasattr(self, 'lingid_pl'): self.lingid_pl={} if not hasattr(self, 'lingid_url'): self.lingid_url={} self.lingid_pl[len(self.lingid_pl)]=pealkiri self.lingid_url[len(self.lingid_url)]=url self.lingid_pl=self.lingid_pl self.lingid_url=self.lingid_url "REQUEST.RESPONSE.redirect('suhtlemine')" return "Olemas" def kysiyl(self): "kysiyl" return self.yl def kysiteema(self): "kysiyl" return self.teema def kysilingid(self): "kysilink" l1=[] for i in range(len(self.lingid_pl)): l=[] l.append(self.lingid_pl[i]) l.append(self.lingid_url[i]) l1.append(l) "koguslink=len(lingid_pl)" "koguslink=len(lingid_url)" return l1 def kustutalingid(self): "kutsuta lingid" for i in range(len(self.lingid_pl)): self.lingid_pl[i]=null self.lingid_url[i]=null "koguslink=len(lingid_pl)" "koguslink=len(lingid_url)" return l1 def kysiteated(self): "Kataloogis leiduvad teadeobjektid" m=self.objectValues('teade') kogus=len(m) if kogus>10: m=m[-10:] return m def registreeriKylastus(self, REQUEST): "Andmed kylastuse kohta" import time if not hasattr(self, 'kasutajaandmed'): self.kasutajaandmed={} self.kasutajaandmed[str(REQUEST.AUTHENTICATED_USER)]=time.time() def kysiKylastused(self): "Kylastuste loetelu" t=[] for k in self.kasutajaandmed.keys(): temp=self.kasutajaandmed[k]+30 if time.time() < temp: t.append(k) return t