# -*- coding: utf-8 # $Id$ # # Copyright 2001, 2002 by IVA Team and contributors # # This file is part of IVA. # # IVA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # IVA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with IVA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Contains class Webtop, which is the root object for users' webtops.""" __version__ = "$Revision$"[11:-2] import Globals #from Globals import Persistent, HTMLFile import AccessControl #import TraversableWrapper import WebtopFolder from TraversableWrapper import TWFolder from common import perm_view, perm_edit, perm_manage, perm_add_lo from zope.interface import implements from interfaces import IWebtopItem # This object is the root of a user's webtop and should reside inside # the UserInfo object of the user. # # A webtop contains a clipboard folder, a trash folder and any # WebtopItems the user has created. WebtopItem is a superclass, and # actually the webtop will contain specific subclass instances, like # WebtopFolder, WebtopFile, WebtopLink and WebtopMemo. # # Clipboard is removed starting from IVA 0.7.+ class Webtop( WebtopFolder.WebtopFolder, ): """User's Webtop.""" meta_type = "Webtop" location_type="standard" #Jaagup, 10.10.2002 implements(IWebtopItem) def index_html(self, REQUEST=None): "Avaleht" return self.fle_root().wt_index_html(self, REQUEST) security = AccessControl.ClassSecurityInfo() def __init__(self, newlocationtype="standard"): #Jaagup """Construct the webtop root object.""" self.__id_counter = 0L self.toplevel=1 self.location_type=newlocationtype #Jaagup self.id = 'webtop' WebtopFolder.WebtopFolder.__init__(self, None, 'webtop') security.declarePrivate('generate_id') def generate_id(self): """Return a unique (within this webtop) id. These ids are used for any and all WebtopItems created instead of their visible names so we avoid any problems with visible name conflicts and can use more complex visible names for items.""" self.__id_counter += 1L while hasattr(self.aq_self,"wt"+str(self.__id_counter)): self.__id_counter += 1L return "wt"+str(self.__id_counter) security.declareProtected(perm_view, 'is_quota_limit_reached') def is_quota_limit_reached(self,REQUEST=None): """Is quota limit reached?""" limit = self.get_quota() #Do the multiply if limit < 0: return 0 # no quota else: ui = getattr(self.fle_root().fle_users, str(REQUEST.AUTHENTICATED_USER)) limit = limit * len(ui.user_courses()) return self.get_size() >= limit security.declareProtected(perm_view, 'search_form_handler') def search_form_handler( self, REQUEST, cancel=None, # submit buttons submit=None, # get_name = None, get_content= None ): """Search form handler.""" if submit and ((get_name) or (get_content)): for s in 'get_name', 'get_content': REQUEST.set(s, REQUEST[s]) if REQUEST['get_author_name'] == '___anyone___': uname = str(self.REQUEST.AUTHENTICATED_USER) if len(self.fle_users.get_user_info(uname).user_courses()) > 0: REQUEST.set('get_author_name', self.courses.get_unames_on_my_courses(REQUEST)) else: REQUEST.set('get_author_name', uname) else: REQUEST.set('get_author_name', REQUEST['get_author_name']) return self.wt_search_results(self, REQUEST) elif cancel: REQUEST.RESPONSE.redirect('index_html') else: REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER']) Globals.InitializeClass(Webtop) # EOF