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
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
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)))