Example #1
0
    def getSpaces(self, parentUID=None):
        """Returns objects of type Space below passed parent UID."""
        from ubify.cyninv2theme import getRootURL
        cat = getToolByName(self.context, 'uid_catalog', None)
        portal_catalog = getToolByName(self.context, 'portal_catalog', None)
        p_url = getToolByName(self.context, "portal_url")

        strPath = "/".join(
            p_url.getPortalObject().getPhysicalPath()) + getRootURL()

        if parentUID is not None:
            resbrains = cat.searchResults(UID=parentUID)
            if len(resbrains) == 1:
                strPath = "/".join(resbrains[0].getObject().getPhysicalPath())
            resbrains = []

        query = {
            'path': {
                'query': strPath,
                'depth': 1
            },
            'portal_type': ['ContentSpace'],
            'sort_on': 'getObjPositionInParent',
            'sort_order': 'asc'
        }
        resbrains = portal_catalog(query)

        outlist = []

        def getChildren(item, catalog, lstchildren):
            try:
                strPath = "/".join(item.getPhysicalPath())
                query = {
                    'path': {
                        'query': strPath,
                        'depth': 1
                    },
                    'portal_type': ['ContentSpace'],
                    'sort_on': 'getObjPositionInParent',
                    'sort_order': 'asc'
                }
                results = catalog(query)

                if len(results) > 0:
                    for o in results:
                        itemresult = {'spaceid': o.UID, 'c': []}
                        getChildren(o.getObject(), catalog, itemresult['c'])
                        lstchildren.append(itemresult)
            except AttributeError:
                return ""

        for obj in resbrains:
            itemresult = {'spaceid': obj.UID, 'c': []}
            getChildren(obj.getObject(), portal_catalog, itemresult['c'])

            outlist.append(itemresult)
        return outlist
    def getSpaces(self,parentUID=None):
        """Returns objects of type Space below passed parent UID."""
        from ubify.cyninv2theme import getRootURL
        cat = getToolByName(self.context, 'uid_catalog', None)
        portal_catalog = getToolByName(self.context,'portal_catalog',None)
        p_url = getToolByName(self.context,"portal_url")
        
        strPath = "/".join(p_url.getPortalObject().getPhysicalPath()) + getRootURL()

        if parentUID is not None:
            resbrains = cat.searchResults(UID=parentUID)
            if len(resbrains) == 1:
                strPath = "/".join(resbrains[0].getObject().getPhysicalPath())
            resbrains = []

        query = {'path': {'query': strPath,'depth':1}, 'portal_type': ['ContentSpace'], 'sort_on': 'getObjPositionInParent', 'sort_order': 'asc'}
        resbrains = portal_catalog(query)

        outlist = []
        def getChildren(item,catalog,lstchildren):
            try:
                strPath = "/".join(item.getPhysicalPath())
                query = {'path': {'query': strPath,'depth':1}, 'portal_type': ['ContentSpace'], 'sort_on': 'getObjPositionInParent', 'sort_order': 'asc'}
                results = catalog(query)

                if len(results) > 0:
                    for o in results:
                        itemresult = {
                                        'spaceid':o.UID,
                                        'c': []
                                     }
                        getChildren(o.getObject(),catalog,itemresult['c'])
                        lstchildren.append(itemresult)
            except AttributeError:
                return ""

        for obj in resbrains:
            itemresult = {
                            'spaceid':obj.UID,
                            'c': []
                         }
            getChildren(obj.getObject(),portal_catalog,itemresult['c'])

            outlist.append(itemresult)
        return outlist
    def update(self):
        portal_state = getMultiAdapter((self.context, self.request),name=u'plone_portal_state')

        catalog = getToolByName(self.context, "portal_catalog")
        p_url = getToolByName(self.context,"portal_url")

        #strPath = "/" + self.context.portal_url.getPortalObject().virtual_url_path() + "/spaces"
        strPath = "/".join(p_url.getPortalObject().getPhysicalPath()) + getRootURL()
        query = {'path': {'query': strPath,'depth':1}, 'portal_type': ['ContentSpace'], 'sort_on': 'getObjPositionInParent', 'sort_order': 'asc'}
        objects = [b.getObject() for b in catalog(query)]
        self.spacesbrains = objects

        strPath = "/".join(p_url.getPortalObject().getPhysicalPath()) + "/views"
        query = {'path': {'query': strPath,'depth':1}, 'portal_type': ['SmartView','Topic'], 'sort_on': 'getObjPositionInParent', 'sort_order': 'asc'}
        objects = [b.getObject() for b in catalog(query)]
        self.viewbrains = objects

        self.display_managemenu = False
        sm = getSecurityManager()
        if sm.checkPermission('Manage portal', self.context):
            self.display_managemenu = True
Example #4
0
    def update(self):
        portal_state = getMultiAdapter((self.context, self.request),
                                       name=u'plone_portal_state')

        catalog = getToolByName(self.context, "portal_catalog")
        p_url = getToolByName(self.context, "portal_url")

        #strPath = "/" + self.context.portal_url.getPortalObject().virtual_url_path() + "/spaces"
        strPath = "/".join(
            p_url.getPortalObject().getPhysicalPath()) + getRootURL()
        query = {
            'path': {
                'query': strPath,
                'depth': 1
            },
            'portal_type': ['ContentSpace'],
            'sort_on': 'getObjPositionInParent',
            'sort_order': 'asc'
        }
        objects = [b.getObject() for b in catalog(query)]
        self.spacesbrains = objects

        strPath = "/".join(
            p_url.getPortalObject().getPhysicalPath()) + "/views"
        query = {
            'path': {
                'query': strPath,
                'depth': 1
            },
            'portal_type': ['SmartView', 'Topic'],
            'sort_on': 'getObjPositionInParent',
            'sort_order': 'asc'
        }
        objects = [b.getObject() for b in catalog(query)]
        self.viewbrains = objects

        self.display_managemenu = False
        sm = getSecurityManager()
        if sm.checkPermission('Manage portal', self.context):
            self.display_managemenu = True