def getSecurity(self, forItem, rolesInherited=None):
     sLang = self.request.getLang()
     user = self.session.user
     # get user role
     iUserRole = objectAccess.getAccess(forItem, user)
     if iUserRole == objectAccess.COORDINATOR:
         rolesInherited = rolesInherited or forItem.inheritRoles
         if rolesInherited:
             sChecked = 'true'
         else:
             sChecked = 'false'
         return SECURITY_TAB % (
             resources.getResource('SECURITY', sLang),
             sChecked,
             resources.getResource('ROLES_INHERITED', sLang),
             sChecked,
             resources.getResource('NAME', sLang),
             resources.getResource('ROLE', sLang),
             resources.getResource('ROLE_1', sLang),
             resources.getResource('ROLE_2', sLang),
             resources.getResource('ROLE_4', sLang),
             resources.getResource('ROLE_8', sLang),
             resources.getResource('ADD', sLang),
             resources.getResource('REMOVE', sLang)
         )
     else:
         return ''
 def setParams(self):
     sLang = self.request.getLang()
     self.params = {
         'URI': self.request.serverVariables['SCRIPT_NAME'] + '/' + self.item.id,
         'TITLE': 'Reset password for user \'%s\'' % self.item.displayName.value,
         'OK': resources.getResource('OK', sLang),
         'CANCEL': resources.getResource('CANCEL', sLang)
     }
 def setParams(self):
     sLang = self.request.getLang()
     sRename = resources.getResource('RENAME', sLang)
     self.params = {
         'TITLE': sRename + ' "' + self.item.displayName.value + '"',
         'ENTER_NEW_NAME': resources.getResource('ENTER_NEW_NAME', sLang),
         'ID': self.item.id,
         'DN': self.item.displayName.value,
         'RENAME': sRename,
         'CANCEL': resources.getResource('CANCEL', sLang)
     }
 def getInfo(self):
     sLang = self.request.getLang()
     lstChildren = []
     children = self.item.getChildren()
     for child in children:
         obj = {
             'id' : child.id,
             'image': child.__image__,
             'displayName' : child.displayName.value,
             'isCollection': child.isCollection,
             'modified': date.Date(child.modified)
         }
         if hasattr(child, 'size'):
             obj['size'] = child.size
         lstChildren.append(obj)
     
     containment = []
     for contained in self.item.containment:
         image = misc.getClassByName(contained).__image__
         if not type(image)==str:
             image = ''
         localestring = resources.getResource(contained, sLang)
         containment.append( [localestring, contained, image] )
         
     return {
         'displayName': self.item.displayName.value,
         'path': misc.getFullPath(self.item),
         'parentid': self.item.parentid,
         'iscollection': self.item.isCollection,
         'containment': containment,
         'user_role': objectAccess.getAccess(self.item, self.session.user),
         'contents': lstChildren
     }
 def getResource(self, name, lang):
     res = resources.getResource(name, lang)
     # if label lookup fails on the system resources
     # try the secondary resources, if set
     if res == name and self.secondaryResources:
         res = self.secondaryResources.getResource(name, lang)
     return res
    def setParams(self):
        self.response.setHeader('cache-control', 'no-cache')
        self.response.setExpiration(1200)
        
        sLang = self.request.getLang()
        sCC = self.request.queryString['cc'][0]
        oNewItem = misc.getClassByName(sCC)()
        
        self.params = {
            'TITLE': '%s "%s"' % (self.getResource('CREATE', sLang),
                    self.getResource(oNewItem.contentclass, sLang)),
            'CREATE': self.getResource('CREATE', sLang),
            'CANCEL': self.getResource('CANCEL', sLang),
        
            'CC': sCC,
            'URI': self.request.serverVariables['SCRIPT_NAME'] + '/' + self.item.id,
            'ICON': oNewItem.__image__,
            'PROPERTIES_TAB': '',
            'EXTRA_TABS': '',
            'SECURITY_TAB': self.getSecurity(self.item, True)
        }

        # inspect item properties
        sProperties = ''
        for attr_name in oNewItem.__props__:
            attr = getattr(oNewItem, attr_name)
            if isinstance(attr, datatypes.DataType):
                control, tab = self.getControlFromAttribute(attr_name, attr, False, True)
                sProperties += control
                self.params['EXTRA_TABS'] += tab
        
        self.params['PROPERTIES_TAB'] = '<a:tab caption="%s">%s</a:tab>' % (resources.getResource('PROPERTIES', sLang), sProperties)
 def setParams(self):
     sLang = self.request.getLang()
     rootFolder = self.server.store.getItem('')
     self.params = {
         'ROOT_ID': '/',
         'ROOT_IMG': rootFolder.__image__,
         'ROOT_DN': rootFolder.displayName.value,
         'ID': self.item.id,
         'SELECT_FOLDER': resources.getResource('SELECT_FOLDER', sLang),
         'CANCEL': resources.getResource('CANCEL', sLang),
         'OK': resources.getResource('OK', sLang)
     }
     sAction = self.request.queryString['action'][0]
     self.params['TITLE'] = resources.getResource(sAction.upper(), sLang)
     
     if sAction!='select_folder':
         self.params['TITLE'] += ' &quot;' + self.item.displayName.value + '&quot;'
 def setParams(self):
     self.isPage = True
     
     sLang = self.request.getLang()
     self.params = {
         'URI': self.request.serverVariables['SCRIPT_NAME'] + '?cmd=login',
         'LOGIN_FAILED': resources.getResource('LOGIN_FAILED', sLang),
         'LOGIN': resources.getResource('LOGIN', sLang),
 
         'CLOSE': resources.getResource('CLOSE', sLang),
         'CANCEL': resources.getResource('CANCEL', sLang),
         'YES': resources.getResource('YES', sLang),
         'NO': resources.getResource('NO', sLang)
     }
 def setParams(self):
     self.response.setHeader('cache-control', 'no-cache')
     sLang = self.request.getLang()        
     self.params = {
         'LOGOFF': resources.getResource('LOGOFF', sLang),
         'LOGOFF?': resources.getResource('LOGOFF?', sLang),
         'START': resources.getResource('START', sLang),
         'APPLICATIONS': resources.getResource('APPLICATIONS', sLang),
         'SETTINGS': resources.getResource('SETTINGS', sLang),
         'INFO': resources.getResource('INFO', sLang),
         'USER': self.session.user.displayName.value,
         'AUTO_RUN' : self.session.user.settings.value.setdefault('AUTO_RUN', ''),
         'RUN_MAXIMIZED' : int(self.session.user.settings.value.setdefault('RUN_MAXIMIZED', False)),
     }
     # has the user access to recycle bin?
     rb_icon = ''
     rb = self.server.store.getItem('rb')
     if rb:
         rb_icon = '''
             <a:icon top="80" left="10" width="80" height="80"
                 imgalign="top" ondblclick="generic.openContainer"
                 img="desktop/images/trashcan_full.gif" color="white"
                 caption="%s">
                     <a:prop name="folderID" value="rb"></a:prop>
             </a:icon>
         ''' % rb.displayName.value
     
     desktop_pane = DESKSTOP_PANE % (self.item.displayName.value, rb_icon)
     
     taskbar_position = self.session.user.settings.value.setdefault('TASK_BAR_POS', 'bottom')
     if taskbar_position == 'bottom':
         self.params['TOP'] = desktop_pane
         self.params['BOTTOM'] = ''
     else:
         self.params['TOP'] = ''
         self.params['BOTTOM'] = desktop_pane
     
     # get applications
     oCmd = OqlCommand()
     sOql = "select launchUrl,displayName,icon from 'apps' order by displayName asc"
     apps = oCmd.execute(sOql)
     sApps = ''
     if len(apps) > 0:
         for app in apps:
             sApps += '<a:menuoption img="%s" caption="%s" onclick="generic.runApp"><a:prop name="url" value="%s"></a:prop></a:menuoption>' % (app['icon'], app['displayName'], app['launchUrl'])
         self.params['APPS'] = sApps
     else:
         self.params['APPS'] = '<a:menuoption caption="%s" disabled="true"></a:menuoption>' % resources.getResource('EMPTY', sLang)
示例#10
0
    def setParams(self):
        self.response.setHeader('cache-control', 'no-cache')
        sLang = self.request.getLang()
        
        self.params['TASK_BAR_POS'] = self.session.user.settings.value.setdefault('TASK_BAR_POS', 'bottom')
        
        if self.params['TASK_BAR_POS'] == 'bottom':
            self.params['CHECKED_TOP'] = 'false'
            self.params['CHECKED_BOTTOM'] = 'true'
        else:
            self.params['CHECKED_TOP'] = 'true'
            self.params['CHECKED_BOTTOM'] = 'false'
            
        autoRun = self.session.user.settings.value.setdefault('AUTO_RUN', '')
            
        if self.session.user.settings.value.setdefault('RUN_MAXIMIZED', False) == True:
            self.params['RUN_MAXIMIZED_VALUE'] = 'true'
        else:
            self.params['RUN_MAXIMIZED_VALUE'] = 'false'

        # get applications
        oCmd = OqlCommand()
        sOql = "select displayName,launchUrl,icon from 'apps' order by displayName asc"
        apps = oCmd.execute(sOql)
        
        sSelected = ''
        if autoRun == '':
            sSelected = 'true'
        
        sApps = '<a:option caption="%s" selected="%s" value=""/>' % (resources.getResource("NONE_APP", sLang), sSelected)
        if len(apps) > 0:
            for app in apps:
                if autoRun == app['launchUrl']:
                    sSelected = 'true'
                else:
                    sSelected = 'false'
                sApps += '<a:option img="%s" caption="%s" value="%s" selected="%s"/>' % (app['icon'], app['displayName'], app['launchUrl'], sSelected)
            self.params['APPS'] = sApps
示例#11
0
 def setParams(self):
     self.response.setHeader('Cache-Control', 'no-cache')
     sLang = self.request.getLang()
     
     user = self.session.user
     iUserRole = objectAccess.getAccess(self.item, user)
     readonly = (iUserRole==1)
     self.params = {
         'UPDATE': self.getResource('UPDATE', sLang),
         'CLOSE': self.getResource('CLOSE', sLang),
         'INFO': self.getResource('INFO', sLang),
         'DATEMOD': self.getResource('DATEMOD', sLang),
         'OBJID': self.getResource('ID', sLang),
         'CLASS': self.getResource('CLASS', sLang),
         'MODIFIEDBY': self.getResource('MODIFIEDBY', sLang),
         
         'ID': self.item.id,
         'URI': self.request.serverVariables['SCRIPT_NAME'] + '/' + self.item.id,
         'ICON': self.item.__image__,
         'NAME': self.item.displayName.value,
         'MODIFIED': date.Date(self.item.modified).format(DATES_FORMAT, sLang),
         'MODIFIED_BY': self.item.modifiedBy,
         'CONTENTCLASS': self.item.contentclass,
         'PROPERTIES_TAB': '',
         'EXTRA_TABS': '',
         'SECURITY_TAB': self.getSecurity(self.item),
         'UPDATE_DISABLED': self.getStringFromBoolean(readonly)    
     }
     # inspect item properties
     sProperties = ''
     for attr_name in self.item.__props__:
         attr = getattr(self.item, attr_name)
         if isinstance(attr, datatypes.DataType):
             control, tab = self.getControlFromAttribute(attr_name, attr, readonly)
             sProperties += control
             self.params['EXTRA_TABS'] += tab
     
     self.params['PROPERTIES_TAB'] = '<a:tab caption="%s">%s</a:tab>' % (resources.getResource('PROPERTIES', sLang), sProperties)
def getInfo(self):
    "Retutns info about the container's contents"
    context = HttpContext.current()
    sLang = context.request.getLang()
    lstChildren = []
    children = self.getChildren()
    for child in children:
        obj = {
            'id' : child.id,
            'cc' : child.contentclass,
            'image': child.__image__,
            'displayName' : child.displayName.value,
            'isCollection': child.isCollection,
            'modified': date.Date(child.modified)
        }
        if hasattr(child, 'size'):
            obj['size'] = child.size
        lstChildren.append(obj)
    
    containment = []
    for contained in self.containment:
        image = misc.getCallableByName(contained).__image__
        if not type(image) == str:
            image = ''
        localestring = resources.getResource(contained, sLang)
        containment.append( [localestring, contained, image] )
        
    return {
        'displayName' : self.displayName.value,
        'path' : misc.getFullPath(self),
        'parentid' : self.parentid,
        'iscollection' : self.isCollection,
        'containment' : containment,
        'user_role' : objectAccess.getAccess(self, context.user),
        'contents' : lstChildren
    }
    def format(self, format, locale='*'):
        """
        Convert the date to a string as specified by the format argument.
        
        @param format: The following directives can be embedded in the format string::
            
                -yyyy  four digit year
                -yy    two digit year
                -month full month
                -mmm   short month
                -mm    month as a decimal number
                -dd    day of the month as a decimal number
                -day   full week day
                -ddd   short week day
                -h24   24-based hours
                -h12   12-based hours
                -min   minutes
                -sec   seconds
                -MM    locale's AM or PM
        @type format: str
        @param locale: The locale string. If ommited the '*' is used.
        @type locale: str
        
        @return: The formatted string
        @rtype: str
        """
        tupTime = time.localtime(self.value)
        sYear = str(tupTime[0])
        iMonth = tupTime[1]-1
        iDate = tupTime[2]
        iHours = tupTime[3]
        if iHours>12:
            iHours12 = iHours - 12
            ampm = resources.getResource('PM', locale)
        else:
            iHours12 = iHours
            ampm = resources.getResource('AM', locale)
        iMins = tupTime[4]
        iSecs = tupTime[5]
        iWeekday = tupTime[6]

        months = resources.getResource('MONTHS', locale)
        days = resources.getResource('DAYS', locale)
        
        format = format.replace('yyyy', sYear)
        format = format.replace('yy', sYear[1:3])
        
        format = format.replace('month', months[iMonth])
        format = format.replace('mmm', unicode(months[iMonth], 'utf-8')[0:3].encode('utf-8'))
        format = format.replace('mm', str(iMonth + 1))
        
        format = format.replace('min', '%02d' % iMins)
        format = format.replace('sec', '%02d' % iSecs)
        
        format = format.replace('ddd', unicode(days[iWeekday], 'utf-8')[0:3].encode('utf-8'))
        format = format.replace('dd', str(iDate))
        format = format.replace('day', days[iWeekday])
        
        format = format.replace('h24', '%02d' % iHours)
        format = format.replace('h12', str(iHours12))
        format = format.replace('MM', ampm)
        
        return format
示例#14
0
    def getControlFromAttribute(self, attrname, attr, readonly, isNew=False):
        sLang = self.request.getLang()
        attrlabel = self.getResource(attrname, sLang)

        sControl = ''
        sTab = ''
        if isinstance(attr, datatypes.String):
            sControl = AUTO_CONTROLS[datatypes.String] % (self.yoffset + 3, attrlabel, attrname, self.yoffset, attr.value, self.getStringFromBoolean(readonly))
            self.yoffset += 25

        elif isinstance(attr, datatypes.Boolean):
            sControl = AUTO_CONTROLS[datatypes.Boolean] % (self.yoffset + 3, attrlabel, attrname, self.yoffset, self.getStringFromBoolean(attr.value), self.getStringFromBoolean(readonly))
            self.yoffset += 25
            
        elif isinstance(attr, datatypes.Date):
            sControl = AUTO_CONTROLS[datatypes.Date] % (self.yoffset + 3, attrlabel, attrname, self.yoffset, attr.toIso8601(), self.getStringFromBoolean(readonly))
            self.yoffset += 25
            
        elif isinstance(attr, datatypes.File):
            if isNew:
                href = ''
            else:
                href = self.request.serverVariables['SCRIPT_NAME'] + '/' + self.item.id + '?cmd=getfile'
            sControl = AUTO_CONTROLS[datatypes.File] % (
                self.yoffset + 3, attrlabel, attrname,
                attr.filename, len(attr), href,
                self.yoffset, self.getStringFromBoolean(readonly)
            )
            self.yoffset += 21
            
        elif isinstance(attr, datatypes.Text):
            sTab = AUTO_CONTROLS[datatypes.Text] % (
                attrlabel, attrname, self.getStringFromBoolean(readonly),
                xmlUtils.XMLEncode(attr.value)
            )
            
        elif isinstance(attr, datatypes.Reference1):
            oRefItem = attr.getItem()
            if oRefItem:
                refid = oRefItem.id
                refname = oRefItem.displayName.value
            else:
                refid = refname = ''
            sReadonly = self.getStringFromBoolean(readonly)
            sControl = AUTO_CONTROLS[datatypes.Reference1] % (
                self.yoffset, self.request.serverVariables['SCRIPT_NAME'] + '/',
                '|'.join(attr.relCc), attrlabel, attrname,
                refid, refname, sReadonly, sReadonly
            )
            self.yoffset += 25
            
        elif isinstance(attr, datatypes.ReferenceN):
            options = ''
            rel_items = attr.getItems()
            for item in rel_items:
                options += '<a:option img="%s" value="%s" ondblclick="autoform.displayRelated" caption="%s"></a:option>' % (item.__image__, item.id, item.displayName.value)
            
            sTab = AUTO_CONTROLS[datatypes.ReferenceN] % (
                attrlabel, attrname,
                self.request.serverVariables['SCRIPT_NAME'] + '/',
                '|'.join(attr.relCc), options, self.getStringFromBoolean(readonly),
                resources.getResource('ADD', sLang),
                resources.getResource('REMOVE', sLang)
            )
        
        return (sControl, sTab)