Esempio n. 1
0
    def meetingAndLectureDisplay(cls, obj, params):
        out = params['out']
        conf = params['conf']
        if DBHelpers.roomsToShow(conf):
            linksList = PluginsHolder().getPluginType('InstantMessaging').getOption('customLinks').getValue()
            out.openTag("chatrooms")
            for chatroom in DBHelpers.getShowableRooms(conf):
                out.openTag("chatroom")

                out.writeTag("id", chatroom.getId())
                out.writeTag("name", chatroom.getTitle())
                out.writeTag("server", 'conference.' + chatroom.getHost() if chatroom.getCreatedInLocalServer() else chatroom.getHost())
                out.writeTag("description", chatroom.getDescription())
                out.writeTag("reqPassword", _('Yes') if chatroom.getPassword() else _('No'))
                out.writeTag("showPassword", chatroom.getShowPass())
                out.writeTag("password", chatroom.getPassword())
                out.writeTag("createdInLocalServer", chatroom.getCreatedInLocalServer())
                out.openTag("links")
                if linksList.__len__() > 0:
                    out.writeTag("linksToShow", 'true')
                else:
                    out.writeTag("linksToShow", 'false')

                for link in linksList:
                    out.openTag("customLink")
                    out.writeTag("name", link['name'])
                    out.writeTag("structure", GeneralLinkGenerator(chatroom, link['structure']).generate())
                    out.closeTag("customLink")

                out.closeTag("links")
                out.closeTag("chatroom")
            out.closeTag("chatrooms")

            out.writeTag("how2connect", PluginFieldsWrapper('InstantMessaging', 'XMPP').getOption('ckEditor'))
Esempio n. 2
0
 def getUpdateInterval(self):
     """
     Returns the interval for which cached values should live before
     new data is requested from the server.
     """
     statsPlugin = PluginsHolder().getPluginType('statistics')
     return statsPlugin.getOptions()['cacheTTL'].getValue()
Esempio n. 3
0
 def getOptionValue(cls, pluginName, optionName):
     """ Returns the value of an option of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginName).getOption(optionName).getValue()
Esempio n. 4
0
    def hasRights(request=None, user=None, plugins=[]):
        """ Returns True if the user is an admin of one of the plugins corresponding to pluginNames
            plugins: a list of Plugin objects (e.g. EVO, RecordingRequest) or strings with the plugin name ('EVO', 'RecordingRequest')
                     or the string 'any' (we will then check if the user is manager of any plugin),
        """
        if not PluginsHolder().hasPluginType("Collaboration"):
            return False

        if user is None:
            if request is None:
                return False
            else:
                user = request._getUser()

        coll = PluginsHolder().getPluginType('Collaboration')

        if plugins == 'any':
            plugins = []
            for p in CollaborationTools.getCollaborationPluginType(
            ).getPluginList():
                plugins.append(p.getName())

        if plugins:
            for plugin in plugins:
                if not isinstance(plugin, Plugin):
                    plugin = coll.getPlugin(plugin)

                if user in plugin.getOption('admins').getValue():
                    return True

        return False
Esempio n. 5
0
 def getOptionValue(cls, pluginName, optionName):
     """ Returns the value of an option of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginName).getOption(optionName).getValue()
Esempio n. 6
0
 def hasRights(request = None, user = None, plugins = []):
     """ Returns True if the user is an admin of one of the plugins corresponding to pluginNames
         plugins: a list of Plugin objects (e.g. EVO, RecordingRequest) or strings with the plugin name ('EVO', 'RecordingRequest')
                  or the string 'any' (we will then check if the user is manager of any plugin),
     """
     if not PluginsHolder().hasPluginType("Collaboration"):
         return False
     
     if user is None:
         if request is None:
             return False
         else:
             user = request._getUser()
     
     coll = PluginsHolder().getPluginType('Collaboration')
     
     if plugins == 'any':
         plugins = []
         for p in CollaborationTools.getCollaborationPluginType().getPluginList():
             plugins.append(p.getName())
     
     if plugins:
         for plugin in plugins:
             if not isinstance(plugin, Plugin):
                 plugin = coll.getPlugin(plugin)
             
             if user in plugin.getOption('admins').getValue():
                 return True
             
     return False
Esempio n. 7
0
 def getUpdateInterval(self):
     """
     Returns the interval for which cached values should live before
     new data is requested from the server.
     """
     statsPlugin = PluginsHolder().getPluginType('statistics')
     return statsPlugin.getOptions()['cacheTTL'].getValue()
Esempio n. 8
0
def toIndex(obj):
    plugin = PluginsHolder().getPluginType('search').getPlugin("repozer")
    if type(obj).__name__ == 'Conference':
        return plugin.getOptions()["indexConference"].getValue()
    if type(obj).__name__ == 'Contribution':
        return plugin.getOptions()["indexContribution"].getValue()
    if type(obj).__name__ == 'LocalFile':
        return plugin.getOptions()["indexMaterial"].getValue()
    return False
Esempio n. 9
0
def toIndex(obj):
    plugin = PluginsHolder().getPluginType('search').getPlugin("repozer")
    if type(obj).__name__ == 'Conference':
        return plugin.getOptions()["indexConference"].getValue()
    if type(obj).__name__ == 'Contribution':
        return plugin.getOptions()["indexContribution"].getValue()
    if type(obj).__name__ == 'LocalFile':
        return plugin.getOptions()["indexMaterial"].getValue()
    return False
Esempio n. 10
0
 def getPluginTPlDir(self, pTypeName, pluginName, tplName):
     pType = PluginsHolder().getPluginType(pTypeName)
     if pType == None:
         raise Exception(_("The plugin type does not exist"))
     if pluginName != None:
         plugin = pType.getPlugin(pluginName)
         if plugin == None:
             raise Exception(_("The plugin does not exist"))
         return posixpath.normpath(pkg_resources.resource_filename(plugin.getModule().__name__, 'tpls/{0}'.format(tplName)))
     return posixpath.normpath(pkg_resources.resource_filename(pType.getModule().__name__, 'tpls/{0}'.format(tplName)))
Esempio n. 11
0
 def getPluginTPlDir(self, pTypeName, pluginName, tplName):
     pType = PluginsHolder().getPluginType(pTypeName)
     if pType == None:
         raise Exception(_("The plugin type does not exist"))
     if pluginName != None:
         plugin = pType.getPlugin(pluginName)
         if plugin == None:
             raise Exception(_("The plugin does not exist"))
         return posixpath.normpath(pkg_resources.resource_filename(plugin.getModule().__name__, 'tpls/{0}'.format(tplName)))
     return posixpath.normpath(pkg_resources.resource_filename(pType.getModule().__name__, 'tpls/{0}'.format(tplName)))
Esempio n. 12
0
    def isActive(self):
        """
        Wrapper around the original PluginsHolder method.
        """
        ph = PluginsHolder()
        stats = ph.getById('statistics')
        k = self.getName().lower()

        if not k in stats.getPlugins():
            return False
        else:
            return stats.getPlugins().get(k).isActive()
Esempio n. 13
0
def chatroomIndexMigration(dbi, withRBDB, prevVersion):
    """
    Migrating Chat Room index to new structure
    """

    # The structure of the indexes is such that for each one self._data
    #    is a BTree and each node is referenced by the IndexBy___ designation,
    #    where ___ is the ID in question. Each node is then a TreeSet of
    #    ChatRoom or XMPPChatRoom objects originally orderded by ID, we need
    #    this to be ordered by title for effective searching / querying.
    #   The __cmp__ method has been altered to accommodate this new format,
    #    take each subnode, iterate through saving the current objects, clear the
    #    index and reinsert them - they will now be in the correct order.

    from MaKaC.plugins.InstantMessaging.indexes import IndexByUser, IndexByConf, IndexByCRName, IndexByID

    im_plugin = PluginsHolder().getPluginType('InstantMessaging')

    if not im_plugin.isUsable():
        print console.colored('  IM plugin not usable - jumping task',
                              'yellow')
        return

    try:
        for idx in [IndexByUser(), IndexByConf(), IndexByCRName()]:
            tmp_idx = defaultdict(list)
            print console.colored("  * Index: " + str(idx), 'blue')

            for key, node in idx._data.iteritems():
                for leaf in node:
                    tmp_idx[key].append(leaf)

            # reset index
            idx._data.clear()

            for accum, rooms in tmp_idx.iteritems():
                for room in rooms:
                    # Specific handling as IndexByUser & IndexByConf have different
                    # arguements for tree insertion.
                    if isinstance(idx, IndexByUser) or isinstance(
                            idx, IndexByConf):
                        idx.index(str(accum), room)
                    else:
                        idx.index(room)

        print console.colored(
            "\tAll indexes have now been re-indexed and committed to the DB.",
            'green')
    except:
        dbi.abort()
        print console.colored(
            "Process failed, ended abruptly, changes not committed.", 'red')
        raise
Esempio n. 14
0
    def isActive(self):
        """
        Wrapper around the original PluginsHolder method.
        """
        ph = PluginsHolder()
        stats = ph.getById('statistics')
        k = self.getName().lower()

        if not k in stats.getPlugins():
            return False
        else:
            return stats.getPlugins().get(k).isActive()
Esempio n. 15
0
    def isActive(self):
        """
        Wrapper around the original PluginsHolder method.
        """
        ph = PluginsHolder()
        search = ph.getById('search')
        k = self.getId().lower()

        if not k in search.getPlugins():
            return False
        else:
            return search.getPlugins().get(k).isActive()
Esempio n. 16
0
    def isActive(self):
        """
        Wrapper around the original PluginsHolder method.
        """
        ph = PluginsHolder()
        search = ph.getById('search')
        k = self.getId().lower()

        if not k in search.getPlugins():
            return False
        else:
            return search.getPlugins().get(k).isActive()
Esempio n. 17
0
 def _checkParams(self, params):
     RHAdminBase._checkParams(self, params)
     self._pluginType = params.get("pluginType", None)
     self._pluginId = params.get("pluginId", None)
     self._ph = PluginsHolder()
     if self._pluginType and not self._ph.hasPluginType(self._pluginType,
                                                        mustBeActive=False):
         raise PluginError("The plugin type " + self._pluginType +
                           " does not exist or is not visible")
     elif self._pluginType and self._pluginId and not self._ph.getPluginType(
             self._pluginType).hasPlugin(self._pluginId):
         raise PluginError("The plugin " + self._pluginId +
                           " does not exist")
Esempio n. 18
0
 def _process( self ):
     
     if self._conf.isClosed():
         p = conferences.WPConferenceModificationClosed( self, self._target )
         return p.display()
     else:
         ph = PluginsHolder()
         if ph.getPluginType('Collaboration').getOption("useHTTPS").getValue():
             self._tohttps = True
             if self._checkHttpsRedirect():
                 return ""
         
         p = collaboration.WPConfModifCollaboration( self, self._conf)
         return p.display()
Esempio n. 19
0
 def getImporter(pluginName):
     """
     Returns importer class from the specified plugin. If plugin doesn't exist or it's not active returns None.
     """
     if PluginsHolder().getPluginType('importer').hasPlugin(pluginName) and \
        PluginsHolder().getPluginType('importer').getPlugin(pluginName).isActive():
         try:
             moduleName = PluginsHolder().getPluginType('importer').getPlugin(pluginName).getModuleName()
             className = pluginName.title() + "Importer"
             importerClass = getattr(__import__(moduleName + '.importer', globals(), locals(), 'importer'), className)
         except (ImportError, AttributeError):
             return None
         return importerClass
     else:
         return None
Esempio n. 20
0
class RHAdminPluginsBase(RHAdminBase):
    """ Base RH class for all plugin management requests.
        It will store 2 string parameters: pluginType and pluginId.
        Example: pluginType = "COllaboration" & pluginId = "EVO"
    """ 
    
    def _checkParams(self, params):
        RHAdminBase._checkParams(self, params)
        self._pluginType = params.get("pluginType", None)
        self._pluginId = params.get("pluginId", None)
        self._ph = PluginsHolder()
        if self._pluginType and not self._ph.hasPluginType(self._pluginType, mustBeActive = False):
            raise PluginError("The plugin type " + self._pluginType + " does not exist or is not visible")
        elif self._pluginType and self._pluginId and not self._ph.getPluginType(self._pluginType).hasPlugin(self._pluginId):
            raise PluginError("The plugin " + self._pluginId + " does not exist")
Esempio n. 21
0
    def _process(self):

        if self._conf.isClosed():
            p = conferences.WPConferenceModificationClosed(self, self._target)
            return p.display()
        else:
            ph = PluginsHolder()
            if ph.getPluginType('Collaboration').getOption(
                    "useHTTPS").getValue():
                self._tohttps = True
                if self._checkHttpsRedirect():
                    return ""

            p = collaboration.WPConfModifCollaboration(self, self._conf)
            return p.display()
Esempio n. 22
0
def chatroomIndexMigration(dbi, withRBDB, prevVersion):
    """
    Migrating Chat Room index to new structure
    """

    # The structure of the indexes is such that for each one self._data
    #    is a BTree and each node is referenced by the IndexBy___ designation,
    #    where ___ is the ID in question. Each node is then a TreeSet of
    #    ChatRoom or XMPPChatRoom objects originally orderded by ID, we need
    #    this to be ordered by title for effective searching / querying.
    #   The __cmp__ method has been altered to accommodate this new format,
    #    take each subnode, iterate through saving the current objects, clear the
    #    index and reinsert them - they will now be in the correct order.

    from MaKaC.plugins.InstantMessaging.indexes import IndexByUser, IndexByConf, IndexByCRName, IndexByID

    im_plugin = PluginsHolder().getPluginType('InstantMessaging')

    if not im_plugin.isUsable():
        print console.colored('  IM plugin not usable - jumping task', 'yellow')
        return

    try:
        for idx in [IndexByUser(), IndexByConf(), IndexByCRName()]:
            tmp_idx = defaultdict(list)
            print console.colored("  * Index: " + str(idx), 'blue')

            for key, node in idx._data.iteritems():
                for leaf in node:
                    tmp_idx[key].append(leaf)

            # reset index
            idx._data.clear()

            for accum, rooms in tmp_idx.iteritems():
                for room in rooms:
                    # Specific handling as IndexByUser & IndexByConf have different
                    # arguements for tree insertion.
                    if isinstance(idx, IndexByUser) or isinstance(idx, IndexByConf):
                        idx.index(str(accum), room)
                    else:
                        idx.index(room)

        print console.colored("\tAll indexes have now been re-indexed and committed to the DB.", 'green')
    except:
        dbi.abort()
        print console.colored("Process failed, ended abruptly, changes not committed.", 'red')
        raise
Esempio n. 23
0
    def hasRights(request, plugins=[]):
        """ Returns True if the logged in user has rights to operate with bookings of at least one of a list of plugins, for an event.
            This is true if:
                -the user is a Video Services manager (can operate with all plugins)
                -the user is a plugin manager of one of the plugins
            Of course, it's also true if the user is event manager or server admin, but this class does not cover that case.
             
            request: an RH or Service object
            plugins: either a list of plugin names, or Plugin objects (we will then check if the user is manager of any of those plugins),
                     or the string 'any' (we will then check if the user is manager of any plugin),
                     or nothing (we will then check if the user is a Video Services manager).
        """
        if not PluginsHolder().hasPluginType("Collaboration"):
            return False

        user = request.getAW().getUser()

        csbm = request._conf.getCSBookingManager()
        if csbm.isVideoServicesManager(user):
            return True

        if plugins == 'any':
            return csbm.isPluginManagerOfAnyPlugin(user)

        for plugin in plugins:
            if isinstance(plugin, Plugin):
                plugin = plugin.getName()
            if csbm.isPluginManager(plugin, user):
                return True

        return False
Esempio n. 24
0
def pluginReload(dbi, withRBDB, prevVersion):
    """
    Reloading all plugins
    """
    PluginsHolder().reloadAllPlugins()
    dbi.commit()
    if withRBDB:
        DALManager.commit()
Esempio n. 25
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     
     vars["HasCollaboration"] = PluginsHolder().hasPluginType("Collaboration")
     vars["IsAdmin"] = RCAdmin.hasRights(self._rh)
     vars["IsCollaborationAdmin"] = RCCollaborationAdmin.hasRights(self._rh)
     
     return vars
Esempio n. 26
0
    def meetingAndLectureDisplay(cls, obj, params):
        out = params['out']
        conf = params['conf']
        if DBHelpers.roomsToShow(conf):
            linksList = PluginsHolder().getPluginType(
                'InstantMessaging').getOption('customLinks').getValue()
            out.openTag("chatrooms")
            for chatroom in DBHelpers.getShowableRooms(conf):
                out.openTag("chatroom")

                out.writeTag("id", chatroom.getId())
                out.writeTag("name", chatroom.getTitle())
                out.writeTag(
                    "server", 'conference.' + chatroom.getHost() if
                    chatroom.getCreatedInLocalServer() else chatroom.getHost())
                out.writeTag("description", chatroom.getDescription())
                out.writeTag("reqPassword",
                             _('Yes') if chatroom.getPassword() else _('No'))
                out.writeTag("showPassword", chatroom.getShowPass())
                out.writeTag("password", chatroom.getPassword())
                out.writeTag("createdInLocalServer",
                             chatroom.getCreatedInLocalServer())
                out.openTag("links")
                if linksList.__len__() > 0:
                    out.writeTag("linksToShow", 'true')
                else:
                    out.writeTag("linksToShow", 'false')

                for link in linksList:
                    out.openTag("customLink")
                    out.writeTag("name", link['name'])
                    out.writeTag(
                        "structure",
                        GeneralLinkGenerator(chatroom,
                                             link['structure']).generate())
                    out.closeTag("customLink")

                out.closeTag("links")
                out.closeTag("chatroom")
            out.closeTag("chatrooms")

            out.writeTag(
                "how2connect",
                PluginFieldsWrapper('InstantMessaging',
                                    'XMPP').getOption('ckEditor'))
Esempio n. 27
0
    def getCollaborationPluginType(cls):
        #This commented code tried to gain some performance by caching the collaboration
        # PluginType object, but sometimes there would be problems by
        # different requests sharing memory and trying to access the database
        # after a connection was closed. This happened under Apache in Windows Vista with ZODB 3.8
#        if not cls._cpt:
#            cls._cpt = PluginsHolder().getPluginType("Collaboration")
#        return cls._cpt
        return PluginsHolder().getPluginType("Collaboration")
Esempio n. 28
0
 def _checkParams(self, params):
     RHAdminBase._checkParams(self, params)
     self._pluginType = params.get("pluginType", None)
     self._pluginId = params.get("pluginId", None)
     self._ph = PluginsHolder()
     if self._pluginType and not self._ph.hasPluginType(self._pluginType, mustBeActive = False):
         raise PluginError("The plugin type " + self._pluginType + " does not exist or is not visible")
     elif self._pluginType and self._pluginId and not self._ph.getPluginType(self._pluginType).hasPlugin(self._pluginId):
         raise PluginError("The plugin " + self._pluginId + " does not exist")
Esempio n. 29
0
def pluginOptionsRoomGUIDs(dbi, withRBDB, prevVersion):
    """
    Modifying Room GUIDs
    """
    if not withRBDB:
        return

    ph = PluginsHolder()
    for pluginName, roomsOpt in [('WebcastRequest', 'webcastCapableRooms'),
                                 ('RecordingRequest', 'recordingCapableRooms')]:
        opt = ph.getPluginType('Collaboration').getPlugin(pluginName).getOption(roomsOpt)
        newValue = []
        for name in opt.getValue():
            loc, name = name.split(':')
            room = CrossLocationQueries.getRooms(location=loc, roomName=name)
            if room:
                newValue.append(str(room.guid))
        opt.setValue(newValue)
Esempio n. 30
0
def changeVidyoRoomNames(dbi, withRBDB, prevVersion):
    """
    Changing Vidyo Room Names
    """
    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    if not collaboration_pt.isActive() or not collaboration_pt.getPlugin("Vidyo").isActive():
        return
    i = 0
    for booking in VidyoTools.getIndexByVidyoRoom().itervalues():
        if hasattr(booking, '_originalConferenceId'):
            roomName = booking.getBookingParamByName("roomName") + '_indico_' + booking._originalConferenceId
            booking._bookingParams["roomName"] = roomName.decode("utf-8")
            del booking._originalConferenceId
        i += 1
        if i % 10000 == 0:
            dbi.commit()
    dbi.commit()
Esempio n. 31
0
def pluginOptionsRoomGUIDs(dbi, withRBDB, prevVersion):
    """
    Modifying Room GUIDs
    """
    if not withRBDB:
        return

    ph = PluginsHolder()
    for pluginName, roomsOpt in [('WebcastRequest', 'webcastCapableRooms'),
                                 ('RecordingRequest', 'recordingCapableRooms')]:
        opt = ph.getPluginType('Collaboration').getPlugin(pluginName).getOption(roomsOpt)
        newValue = []
        for name in opt.getValue():
            loc, name = name.split(':')
            room = CrossLocationQueries.getRooms(location=loc, roomName=name)
            if room:
                newValue.append(str(room.guid))
        opt.setValue(newValue)
Esempio n. 32
0
def changeVidyoRoomNames(dbi, withRBDB, prevVersion):
    """
    Changing Vidyo Room Names
    """
    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    if not collaboration_pt.isActive() or not collaboration_pt.getPlugin("Vidyo").isActive():
        return
    i = 0
    for booking in VidyoTools.getIndexByVidyoRoom().itervalues():
        if hasattr(booking, '_originalConferenceId'):
            roomName = booking.getBookingParamByName("roomName") + '_indico_' + booking._originalConferenceId
            booking._bookingParams["roomName"] = roomName.decode("utf-8")
            del booking._originalConferenceId
        i += 1
        if i % 10000 == 0:
            dbi.commit()
    dbi.commit()
Esempio n. 33
0
class RHAdminPluginsBase(RHAdminBase):
    """ Base RH class for all plugin management requests.
        It will store 2 string parameters: pluginType and pluginId.
        Example: pluginType = "COllaboration" & pluginId = "EVO"
    """
    def _checkParams(self, params):
        RHAdminBase._checkParams(self, params)
        self._pluginType = params.get("pluginType", None)
        self._pluginId = params.get("pluginId", None)
        self._ph = PluginsHolder()
        if self._pluginType and not self._ph.hasPluginType(self._pluginType,
                                                           mustBeActive=False):
            raise PluginError("The plugin type " + self._pluginType +
                              " does not exist or is not visible")
        elif self._pluginType and self._pluginId and not self._ph.getPluginType(
                self._pluginType).hasPlugin(self._pluginId):
            raise PluginError("The plugin " + self._pluginId +
                              " does not exist")
Esempio n. 34
0
    def getById(self, id):
        """returns an object from the index which id corresponds to the one
            which is specified.
        """

        if id not in self.__allowedIdxs:
            raise MaKaCError(_("Unknown index: %s") % id)
        Idx = self._getIdx()
        if id in Idx:
            return Idx[id]
        else:
            if id == "email":
                Idx[str(id)] = EmailIndex()
            elif id == "name":
                Idx[str(id)] = NameIndex()
            elif id == "surName":
                Idx[str(id)] = SurNameIndex()
            elif id == "organisation":
                Idx[str(id)] = OrganisationIndex()
            elif id == "status":
                Idx[str(id)] = StatusIndex()
            elif id == "group":
                Idx[str(id)] = GroupIndex()
            elif id == "calendar":
                Idx[str(id)] = CalendarIndex()
            elif id == "category":
                Idx[str(id)] = CategoryIndex()
            elif id == "categoryDate":
                Idx[str(id)] = CategoryDayIndex()
            elif id == "categoryDateAll":
                Idx[str(id)] = CategoryDayIndex(visibility=False)
            elif id == "categoryName":
                Idx[str(id)] = TextIndex()
            elif id == "pendingSubmitters":
                Idx[str(id)] = PendingSubmittersIndex()
            elif id == "pendingSubmittersTasks":
                Idx[str(id)] = PendingSubmittersTasksIndex()
            elif id == "pendingManagers":
                Idx[str(id)] = PendingManagersIndex()
            elif id == "pendingManagersTasks":
                Idx[str(id)] = PendingManagersTasksIndex()
            elif id == "pendingCoordinators":
                Idx[str(id)] = PendingManagersIndex()
            elif id == "pendingCoordinatorsTasks":
                Idx[str(id)] = PendingManagersTasksIndex()
            elif id == "collaboration":
                if PluginsHolder().hasPluginType("Collaboration",
                                                 mustBeActive=False):
                    from MaKaC.plugins.Collaboration.indexes import CollaborationIndex
                    Idx[str(id)] = CollaborationIndex()
                else:
                    raise MaKaCError(
                        _("Tried to retrieve collaboration index, but Collaboration plugins are not present"
                          ))

            return Idx[str(id)]
Esempio n. 35
0
    def _checkProtection(self):
        if not PluginsHolder().hasPluginType("Collaboration"):
            raise PluginError("Collaboration plugin system is not active")

        if not RCCollaborationAdmin.hasRights(
                self, None
        ) and not RCCollaborationPluginAdmin.hasRights(
                self, plugins="any"
        ):  #RCCollaborationPluginAdmin.hasRights(self, None, self._tabPlugins):
            RHAdminBase._checkProtection(self)
Esempio n. 36
0
 def fillManagementSideMenu(cls, obj, params={}):
     instantMessagingAdmins = []
     for imPlugin in PluginsHolder().getPluginType(
             'InstantMessaging').getPluginList():
         instantMessagingAdmins.extend(
             imPlugin.getOption("admins").getValue())
     if obj._conf.canModify(obj._rh._aw) or obj._rh._aw.getUser(
     ) in instantMessagingAdmins:
         params['Instant Messaging'] = wcomponents.SideMenuItem(
             _("Chat Rooms"), urlHandlers.UHConfModifChat.getURL(obj._conf))
Esempio n. 37
0
    def _process(self):
        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()

        active = minfo.getRoomBookingModuleActive()
        if not active:
            # Initialize built-in plugin on activation
            from MaKaC.plugins.RoomBooking.CERN.initialize import initializeRoomBookingDB
            from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN
            PluginsHolder().reloadAllPlugins()
            if not PluginsHolder().getPluginType("RoomBooking").isActive():
                PluginsHolder().getPluginType("RoomBooking").setActive(True)
            DALManagerCERN.connect()
            initializeRoomBookingDB("Universe",
                                    force=False)  # Safe if data present
            DALManagerCERN.disconnect()

        minfo.setRoomBookingModuleActive(not active)

        self._redirect(urlHandlers.UHRoomBookingPluginAdmin.getURL())
Esempio n. 38
0
    def _checkProtection(self):
        if not PluginsHolder().hasPluginType("Collaboration"):
            raise PluginError("Collaboration plugin system is not active")

        hasRights = RCCollaborationAdmin.hasRights(self, None) or \
                    RCCollaborationPluginAdmin.hasRights(self, None, self._tabPlugins) or \
                    RCVideoServicesManager.hasRights(self, self._tabPlugins)

        if not hasRights:
            RHConferenceModifBase._checkProtection(self)
Esempio n. 39
0
def pluginMigration(dbi, withRBDB, prevVersion):
    """
    Adding new plugins and adapting existing ones to new name policies
    """

    PLUGIN_REMAP = {
        'PayPal': 'payPal',
        'WorldPay': 'worldPay',
        'YellowPay': 'yellowPay',
        "Dummyimporter": "dummy",
        "CDSInvenio": "invenio",
        "CERNSearchPOST": "cern_search",
        "InvenioBatchUploader": "invenio"
    }

    root = dbi.getDBConnection().root()
    if 'plugins' in root:
        ptl = []
        ps = root['plugins']
        for k, v in ps.iteritems():
            if isinstance(v, PluginType):
                ptl.append(v)
        for pt in ptl:
            pt.setUsable(True)
            for p in pt.getPluginList(includeNonPresent=True,
                                      includeTestPlugins=True,
                                      includeNonActive=True):
                if hasattr(p, '_Plugin__id'):
                    pid = p.getId()
                else:
                    pid = p.getName()

                if pid in PLUGIN_REMAP:
                    pid = PLUGIN_REMAP[pid]

                p.setId(pid)
                p.setUsable(True)

    dbi.commit()
    if withRBDB:
        DALManager.commit()

    # load new plugins, so that we can update them after
    PluginsHolder().reloadAllPlugins()
    dbi.commit()
    if withRBDB:
        DALManager.commit()

    if prevVersion < parse_version("0.98b1"):
        # update db for specific plugins
        livesync.db.updateDBStructures(root)
        dbi.commit()
        if withRBDB:
            DALManager.commit()
Esempio n. 40
0
def updatePluginSettingsNewRB(dbi, prevVersion):
    """Migrate plugin settings to be compatible with the new RB module"""
    ph = PluginsHolder()
    # Custom attributes are now loercase-with-dashes internally
    opt = ph.getPluginType('Collaboration').getPlugin('CERNMCU').getOption('H323_IP_att_name')
    if opt.getValue() == 'H323 IP':
        opt.setValue('h323-ip')
    # Replace room GUIDs with plain room IDs
    for plugin_name, rooms_opt in [('WebcastRequest', 'webcastCapableRooms'),
                                   ('RecordingRequest', 'recordingCapableRooms')]:
        opt = ph.getPluginType('Collaboration').getPlugin(plugin_name).getOption(rooms_opt)
        room_ids = []
        for room_id in opt.getValue():
            if isinstance(room_id, basestring):
                room_id = int(room_id.split('|')[1].strip())
            if Room.get(room_id):
                room_ids.append(room_id)
        opt.setValue(room_ids)

    dbi.commit()
Esempio n. 41
0
def catalogMigration(dbi, prevVersion):
    """
    Initializing/updating index catalog
    """
    PluginsHolder().reloadAllPlugins(disable_if_broken=False)
    skip = False

    for plugin in (p for p in PluginsHolder().getList() if isinstance(p, Plugin) or isinstance(p, PluginType)):
        if plugin.isActive() and not plugin.isUsable():
            print console.colored(
                "\r  Plugin '{0}' is going to be disabled: {1}".format(
                    plugin.getName(),
                    plugin.getNotUsableReason()
                ), 'yellow')
            skip = True

    if skip and not console.yesno('\r  Do you want to continue the migration anyway?'):
        raise ControlledExit()

    Catalog.updateDB(dbi=dbi)
Esempio n. 42
0
    def hasRights(request=None, user=None):
        """ Returns True if the user is a Server Admin or a Collaboration admin 
            request: an RH or Service object
            user: an Avatar object
            If user is not None, the request object will be used to check the user's privileges.
            Otherwise the user will be retrieved from the request object 
        """
        if not PluginsHolder().hasPluginType("Collaboration"):
            return False

        if user is None:
            if request is None:
                return False
            else:
                user = request._getUser()

        # check if user is Server Admin, Collaboration Admin
        collaborationAdmins = PluginsHolder().getPluginType(
            'Collaboration').getOption('collaborationAdmins').getValue()

        return RCAdmin.hasRights(None, user) or user in collaborationAdmins
Esempio n. 43
0
    def __init__(self, catalogName=confCatalog):
        self.catalog = {}
        self.db = db.DBMgr.getInstance().getDBConnection()
        self.ch = ConferenceHolder()

        plugin = PluginsHolder().getPluginType('search').getPlugin("repozer")
        self.iConf = plugin.getOptions()["indexConference"].getValue()
        self.iContrib = plugin.getOptions()["indexContribution"].getValue()
        self.iMat = plugin.getOptions()["indexMaterial"].getValue()

        # init all standard catalogs
        for cat in [confCatalog,contribCatalog,matCatalog]:
            if cat not in self.db.root():
                self.catalogName = cat
                self.init_catalog()        
        
        self.catalogName = catalogName

        # init customized catalog        
        if self.catalogName not in [confCatalog,contribCatalog,matCatalog] and self.catalogName not in self.db.root():
            self.init_catalog()
            
        self.catalog = self.db.root()[self.catalogName]
Esempio n. 44
0
    def _hasAccess(self, aw):
        """Check if the impersonated user may access the RB module

        Admins can always access it; otherwise the authorized list must be empty or
        the user must be present in that list (or member of a group in that list).
        """
        user = aw.getUser()
        if user.isAdmin():
            return True
        authorizedList = PluginsHolder().getPluginType("RoomBooking").getOption("AuthorisedUsersGroups").getValue()
        if not authorizedList:
            return True
        for entity in authorizedList:
            if ((isinstance(entity, Group) and entity.containsUser(user)) or
               (isinstance(entity, Avatar) and entity == user)):
                return True
        return False
Esempio n. 45
0
 def _checkParams(self):
     optionName = self._params.get('optionName', None)
     if optionName:
         options = optionName.split('.')
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError('ERR-PLUG4', 'plugin: ' + str(plugin) + ' does not exist')
             else:
                 raise ServiceError('ERR-PLUG3', 'pluginType: ' + str(pluginType) + ' does not exist, is not visible or not active')
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(pluginType).getOption(option)
             else:
                 raise ServiceError('ERR-PLUG3', 'pluginType: ' + str(pluginType) + ' does not exist, is not visible or not active')
         else:
             raise ServiceError('ERR-PLUG1', 'optionName argument does not have the proper pluginType.plugin.option format')
     else:
         raise ServiceError('ERR-PLUG0', 'optionName argument not present') 
Esempio n. 46
0
 def getPluginImplementation(self, obj):
     plugin = PluginsHolder().getPluginType('search').getPlugin("invenio")
     typeSearch = plugin.getOptions()["type"].getValue()
     return ("invenio", InvenioRedirectSEA if typeSearch == "redirect" else InvenioSEA)
Esempio n. 47
0
def toIndex(obj):
    plugin = PluginsHolder().getPluginType('search').getPlugin("repozer")
    liveUpdate = plugin.getOptions()["liveUpdate"].getValue()
    return liveUpdate and type(obj).__name__ in typesToIndex and not(obj.hasAnyProtection())
Esempio n. 48
0
def conferenceMigration1_0(dbi, withRBDB, prevVersion):
    """
    Tasks: 1. Moving support info fields from conference to a dedicated class
           2. Update non inherited children list
           3. Update Vidyo indexes
    """

    def _updateMaterial(obj):
        for material in obj.getAllMaterialList(sort=False):
            material.getAccessController().setNonInheritingChildren(set())
            if material.getAccessController().getAccessProtectionLevel() != 0:
                material.notify_protection_to_owner(material)
            for resource in material.getResourceList(sort=False):
                if resource.getAccessController().getAccessProtectionLevel() != 0:
                    resource.notify_protection_to_owner()

    def updateSupport(conf):
        #################################################################
        #Moving support info fields from conference to a dedicated class:
        #################################################################

        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf)
        caption = email = telephone = ""

        if hasattr(dMgr, "_supportEmailCaption"):
            caption = dMgr._supportEmailCaption
            del dMgr._supportEmailCaption
        if hasattr(conf, "_supportEmail"):
            email = conf._supportEmail
            del conf._supportEmail

        supportInfo = SupportInfo(conf, caption, email, telephone)
        conf.setSupportInfo(supportInfo)

    def updateNonInheritedChildren (conf):
        ####################################
        #Update non inherited children list:
        ####################################

        conf.getAccessController().setNonInheritingChildren(set())
        _updateMaterial(conf)

        for session in conf.getSessionList():
            session.getAccessController().setNonInheritingChildren(set())
            if session.getAccessController().getAccessProtectionLevel() != 0:
                session.notify_protection_to_owner(session)
            _updateMaterial(session)
        for contrib in conf.getContributionList():
            contrib.getAccessController().setNonInheritingChildren(set())
            if contrib.getAccessController().getAccessProtectionLevel() != 0:
                contrib.notify_protection_to_owner(contrib)
            _updateMaterial(contrib)
            for subContrib in contrib.getSubContributionList():
                _updateMaterial(subContrib)

    def updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex):
        ####################################
        #Update vidyo indexes:
        ####################################
        csbm = getattr(conf, "_CSBookingManager", None)
        if csbm is None:
            return
        for booking in csbm.getBookingList():
            if booking.getType() == "Vidyo" and booking.isCreated():
                endDateIndex.indexBooking(booking)
                vidyoRoomIndex.indexBooking(booking)

    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    vidyoPluginActive = collaboration_pt.isActive() and collaboration_pt.getPlugin("Vidyo").isActive()
    if vidyoPluginActive:
        endDateIndex = VidyoTools.getEventEndDateIndex()
        vidyoRoomIndex = VidyoTools.getIndexByVidyoRoom()
        endDateIndex.clear()
        vidyoRoomIndex.clear()

    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        updateSupport(conf)
        updateNonInheritedChildren(conf)
        if vidyoPluginActive:
            updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 49
0
 def getSearchEngineAgentList(self):
     """
     Returns the default Search Engine Agent of the plugin
     """
     searchPlugin = PluginsHolder().getPluginType('search')
     return searchPlugin.getPlugins().keys()
Esempio n. 50
0
 def getDefaultSearchEngineAgent(self):
     """
     Returns the default Search Engine Agent of the plugin
     """
     searchPlugin = PluginsHolder().getPluginType('search')
     return searchPlugin.getOptions()['defaultSearch'].getValue()
Esempio n. 51
0
 def setDefaultSearchEngineAgent(self, value):
     """
     Sets the default Search Engine Agent of the plugin
     """
     searchPlugin = PluginsHolder().getPluginType('search')
     searchPlugin.getOptions()['defaultSearch'].setValue(value)
Esempio n. 52
0
 def hasCacheEnabled(self):
     """
     True if the plugin is configured for cached reporting.
     """
     statsPlugin = PluginsHolder().getPluginType('statistics')
     return statsPlugin.getOptions()['cacheEnabled'].getValue()
Esempio n. 53
0
 def getVarFromPluginStorage(self, varName):
     """
     Retrieves varName from the options of the plugin.
     """
     plugin = PluginsHolder().getPluginType('search').getPlugin(self._id)
     return plugin.getOptions()[varName].getValue()