def _create(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. After creation, it also retrieves some more information from the newly created room. Returns None if success. Returns a VidyoError if there is a problem, such as the name being duplicated. """ result = ExternalOperationsManager.execute(self, "createRoom", VidyoOperations.createRoom, self) if isinstance(result, VidyoError): return result else: # Link to a Session or Contribution if requested self._roomId = str( result.roomID ) #we need to convert values read to str or there will be a ZODB exception self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName)) self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self) VidyoTools.getIndexByVidyoRoom().indexBooking(self) self._setAutomute()
def _delete(self, fromDeleteOld=False, maxDate=None): """ Deletes the Vidyo Public room associated to this CSBooking, based on the roomId Returns None if success. If trying to delete a non existing room, there will be a message in self._warning so that it is caught by Main.js's postDelete function. """ if self.isCreated(): deleteRemote = unindexBooking = False if self.hasToBeDeleted(fromDeleteOld, maxDate): self.setCreated(False) deleteRemote = unindexBooking = True elif not fromDeleteOld: unindexBooking = True if deleteRemote: result = ExternalOperationsManager.execute( self, "deleteRoom", VidyoOperations.deleteRoom, self, self._roomId) if isinstance(result, VidyoError): if result.getErrorType( ) == "unknownRoom" and result.getOperation() == "delete": if not fromDeleteOld: self._warning = "cannotDeleteNonExistant" else: return result if unindexBooking: VidyoTools.getEventEndDateIndex().unindexBooking(self) VidyoTools.getIndexByVidyoRoom().unindexBooking(self)
def _attach(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. Returns None if success. Returns a VidyoError if there is a problem. """ result = ExternalOperationsManager.execute(self, "attachRoom", VidyoOperations.attachRoom, self) if isinstance(result, VidyoError): return result else: self._roomId = str(result.roomID) self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName), updateAvatar=True) recoveredDescription = VidyoTools.recoverVidyoDescription( result.description) if recoveredDescription: self._bookingParams["roomDescription"] = recoveredDescription else: self._warning = "invalidDescription" if bool(result.RoomMode.hasPIN): self.setPin(str(result.RoomMode.roomPIN)) else: self.setPin("") if bool(result.RoomMode.hasModeratorPIN): self.setModeratorPin(str(result.RoomMode.moderatorPIN)) else: self.setModeratorPin("") self._bookingParams["autoMute"] = self._getAutomute() self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self) VidyoTools.getIndexByVidyoRoom().indexBooking(self)
def _attach(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. Returns None if success. Returns a VidyoError if there is a problem. """ result = ExternalOperationsManager.execute(self, "attachRoom", VidyoOperations.attachRoom, self) if isinstance(result, VidyoError): return result else: self._roomId = str(result.roomID) self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName), updateAvatar = True) recoveredDescription = VidyoTools.recoverVidyoDescription(result.description) if recoveredDescription: self._bookingParams["roomDescription"] = recoveredDescription else: self._warning = "invalidDescription" if bool(result.RoomMode.hasPIN): self.setPin(str(result.RoomMode.roomPIN)) else: self.setPin("") if bool(result.RoomMode.hasModeratorPIN): self.setModeratorPin(str(result.RoomMode.moderatorPIN)) else: self.setModeratorPin("") self._bookingParams["autoMute"] = self._getAutomute() self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self) VidyoTools.getIndexByVidyoRoom().indexBooking(self)
def _delete(self, fromDeleteOld = False, maxDate = None): """ Deletes the Vidyo Public room associated to this CSBooking, based on the roomId Returns None if success. If trying to delete a non existing room, there will be a message in self._warning so that it is caught by Main.js's postDelete function. """ if self.isCreated(): deleteRemote = unindexBooking = False if self.hasToBeDeleted(fromDeleteOld, maxDate): self.setCreated(False) deleteRemote = unindexBooking = True elif not fromDeleteOld: unindexBooking = True if deleteRemote: result = ExternalOperationsManager.execute(self, "deleteRoom", VidyoOperations.deleteRoom, self, self._roomId) if isinstance(result, VidyoError): if result.getErrorType() == "unknownRoom" and result.getOperation() == "delete": if not fromDeleteOld: self._warning = "cannotDeleteNonExistant" else: return result if unindexBooking: VidyoTools.getEventEndDateIndex().unindexBooking(self) VidyoTools.getIndexByVidyoRoom().unindexBooking(self)
def setBookingNotPresent(self): """ Changes some of the booking's attributes when the room is still in the Indico DB but not in the remote system any more. """ self._created = False #booking is not present remotely so no need to delete it later VidyoTools.getEventEndDateIndex().unindexBooking(self) for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(self.getRoomId()): VidyoTools.getIndexByVidyoRoom().unindexBooking(booking) booking.setCreated(False)
def setBookingNotPresent(self): """ Changes some of the booking's attributes when the room is still in the Indico DB but not in the remote system any more. """ self._created = False #booking is not present remotely so no need to delete it later VidyoTools.getEventEndDateIndex().unindexBooking(self) for booking in VidyoTools.getIndexByVidyoRoom().getBookingList( self.getRoomId()): VidyoTools.getIndexByVidyoRoom().unindexBooking(booking) booking.setCreated(False)
def cloneEvent(cls, confToClone, params): """ we'll clone only the vidyo services created by the user who is cloning the conference""" conf = params['conf'] options = params['options'] if options.get("vidyo", True): for vs in confToClone.getCSBookingManager().getBookingList(filterByType="Vidyo"): # Do not cloning the booking when were are NOT cloning the timetable (optionas has sessions and contribs) # and the booking is linked to a contrib/session if (options.get('sessions', False) and options.get('contributions', False)) or not vs.hasSessionOrContributionLink(): newBooking = vs.clone(conf) conf.getCSBookingManager().addBooking(newBooking) VidyoTools.getIndexByVidyoRoom().index_obj(newBooking)
def cloneEvent(cls, confToClone, params): """ we'll clone only the vidyo services created by the user who is cloning the conference""" conf = params['conf'] options = params['options'] if options.get("vidyo", True): for vs in Catalog.getIdx("cs_bookingmanager_conference").get(confToClone.getId()).getBookingList(filterByType="Vidyo"): # Do not cloning the booking when were are NOT cloning the timetable (optionas has sessions and contribs) # and the booking is linked to a contrib/session if (options.get('sessions', False) and options.get('contributions', False)) or not vs.hasSessionOrContributionLink(): newBooking = vs.clone(conf) Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId()).addBooking(newBooking) VidyoTools.getIndexByVidyoRoom().indexBooking(newBooking) VidyoTools.getEventEndDateIndex().indexBooking(newBooking)
def _updateRelatedBookings(self): for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(self.getRoomId()): booking.setExtension(self.getExtension()) booking.setPin(self.getPin()) booking.setModeratorPin(self.getModeratorPin()) booking.setURL(self.getURL()) booking.setOwnerAccount(self.getOwnerAccount(), True) booking.setBookingOK() booking._bookingParams["roomName"] = self._bookingParams["roomName"] booking._bookingParams["roomDescription"] = self._bookingParams["roomDescription"] booking._bookingParams["autoMute"] = self._bookingParams["autoMute"]
def _create(self): """ Creates the Vidyo public room that will be associated to this CSBooking, based on the booking params. After creation, it also retrieves some more information from the newly created room. Returns None if success. Returns a VidyoError if there is a problem, such as the name being duplicated. """ result = ExternalOperationsManager.execute(self, "createRoom", VidyoOperations.createRoom, self) if isinstance(result, VidyoError): return result else: # Link to a Session or Contribution if requested self._roomId = str(result.roomID) #we need to convert values read to str or there will be a ZODB exception self._extension = str(result.extension) self._url = str(result.RoomMode.roomURL) self.setOwnerAccount(str(result.ownerName)) self.setBookingOK() VidyoTools.getEventEndDateIndex().indexBooking(self) VidyoTools.getIndexByVidyoRoom().indexBooking(self) self._setAutomute()
def _search(cls, user, query, offset=0, limit=None): if not query.strip(): return [], None ask_for_more = True allowed_rooms = [] while ask_for_more: result = VidyoOperations.searchRooms(query, offset=offset, limit=limit) if isinstance(result, VidyoError): # query held no results? there's nothing left. return result, offset if not result: # set offset to None, meaning that the bottom of the "search stream" has been reached offset = None break for room in result: av = VidyoTools.getAvatarByAccountName(room.ownerName) # go through all bookings that use this room and check if this user has any privileges # over them for booking in VidyoTools.getIndexByVidyoRoom().getBookingList( room.roomID): if av == user or booking.getConference() in user.getLinkTo("conference", "manager") \ or user == booking.getConference().getCreator() \ or RCVideoServicesManager.hasRights(user, booking.getConference(), ["Vidyo"]) \ or user.isAdmin(): # if that's the case, add the booking to our list bookingParams = booking.getBookingParams().copy() bookingParams["videoLinkType"] = "event" bookingParams["videoLinkSession"] = "" bookingParams["videoLinkContribution"] = "" allowed_rooms.append(bookingParams) break offset += 1 if limit is not None and len(allowed_rooms) >= limit: # reached limit? that's enough! ask_for_more = False break return (allowed_rooms, offset)
def _updateRelatedBookings(self): for booking in VidyoTools.getIndexByVidyoRoom().getBookingList( self.getRoomId()): booking.setExtension(self.getExtension()) booking.setPin(self.getPin()) booking.setModeratorPin(self.getModeratorPin()) booking.setURL(self.getURL()) booking.setOwnerAccount(self.getOwnerAccount(), True) booking.setBookingOK() booking._bookingParams["roomName"] = self._bookingParams[ "roomName"] booking._bookingParams["roomDescription"] = self._bookingParams[ "roomDescription"] booking._bookingParams["autoMute"] = self._bookingParams[ "autoMute"]
def _search(cls, user, query, offset=0, limit=None): if not query.strip(): return [], None ask_for_more = True allowed_rooms = [] while ask_for_more: result = VidyoOperations.searchRooms(query, offset=offset, limit=limit) if isinstance(result, VidyoError): # query held no results? there's nothing left. return result, offset if not result: # set offset to None, meaning that the bottom of the "search stream" has been reached offset = None break for room in result: av = VidyoTools.getAvatarByAccountName(room.ownerName) # go through all bookings that use this room and check if this user has any privileges # over them for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(room.roomID): if av == user or booking.getConference() in user.getLinkTo("conference", "manager") \ or user == booking.getConference().getCreator() \ or RCVideoServicesManager.hasRights(user, booking.getConference(), ["Vidyo"]) \ or user.isAdmin(): # if that's the case, add the booking to our list bookingParams = booking.getBookingParams().copy() bookingParams["videoLinkType"] = "event" bookingParams["videoLinkSession"] = "" bookingParams["videoLinkContribution"] = "" allowed_rooms.append(bookingParams) break offset += 1 if limit is not None and len(allowed_rooms) >= limit: # reached limit? that's enough! ask_for_more = False break return (allowed_rooms, offset)
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()
def _search(cls, user, query, offset=0, limit=None): if query == "": return[] result = VidyoOperations.searchRooms(query) if isinstance(result, VidyoError): return result allowedRooms = [] for room in result: av = VidyoTools.getAvatarByAccountName(room.ownerName) for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(room.roomID): if av == user or booking.getConference() in user.getLinkTo("conference", "manager") \ or user == booking.getConference().getCreator() \ or RCVideoServicesManager.hasRights(user, booking.getConference(), ["Vidyo"]): bookingParams = booking.getBookingParams().copy() bookingParams["videoLinkType"] = "event" bookingParams["videoLinkSession"] = "" bookingParams["videoLinkContribution"] = "" allowedRooms.append(bookingParams) break limit = limit if limit else (len(allowedRooms) - 1) return allowedRooms[offset:offset+limit]
def hasToBeDeleted(self, fromDeleteOld, maxDate): return len(VidyoTools.getIndexByVidyoRoom().getBookingList(self._roomId)) == 1 or (fromDeleteOld and not self._hasRecentClones(maxDate))
def _hasRecentClones(self, date): for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(self._roomId): if booking.getEndDate() > date: return True return False
def _hasRecentClones(self, date): for booking in VidyoTools.getIndexByVidyoRoom().getBookingList( self._roomId): if booking.getEndDate() > date: return True return False
def isRoomInMultipleBookings(self): """ If different CSBookings contains the same Vidyo Room. """ return len(VidyoTools.getIndexByVidyoRoom().getBookingList( self._roomId)) > 1
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()
def hasToBeDeleted(self, fromDeleteOld, maxDate): return len(VidyoTools.getIndexByVidyoRoom().getBookingList( self._roomId)) == 1 or (fromDeleteOld and not self._hasRecentClones(maxDate))
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, pluginActive): ###################### #Update Vidyo indexes: ###################### if not pluginActive: return csbm = conf.getCSBookingManager() for booking in csbm.getBookingList(): if booking.getType() == "Vidyo" and booking.isCreated(): endDateIndex.indexBooking(booking) vidyoRoomIndex.indexBooking(booking) endDateIndex = VidyoTools.getEventEndDateIndex() vidyoRoomIndex = VidyoTools.getIndexByVidyoRoom() endDateIndex.clear() vidyoRoomIndex.clear() ph = PluginsHolder() collaboration_pt = ph.getPluginType("Collaboration") pluginActive = collaboration_pt.isActive() and collaboration_pt.getPlugin("Vidyo").isActive() ch = ConferenceHolder() i = 0 for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'): updateSupport(conf) updateNonInheritedChildren(conf) updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex, pluginActive) if i % 10000 == 9999: dbi.commit() i += 1 dbi.commit()
def _setPINFromAttachedRoom(self): bookingList = VidyoTools.getIndexByVidyoRoom().getBookingList(self.getRoomId()) if bookingList: booking = bookingList[0] self.setPin(booking.getPin()) self.setModeratorPin(booking.getModeratorPin())
def isRoomInMultipleBookings(self): """ If different CSBookings contains the same Vidyo Room. """ return len(VidyoTools.getIndexByVidyoRoom().getBookingList(self._roomId)) > 1