def onInit(self): osiris.IMainPage.onInit(self) document = osiris.XMLDocument() self.root = document.create("isis") template = osiris.HtmlXSLControl() template.stylesheet = self.loadStylesheet( os.path.join(os.path.dirname(__file__), "isis.xsl")) template.document = document if (self.ajax): self.controls.add(template) else: self.getArea(osiris.pageAreaContent).controls.add(template) self.act = self.session.request.getUrlParam("act") if (self.act == ""): self.act = "home" self.root.setAttributeString("action", self.act) if (self.act == "home"): #osiris.events.connect(self.events.get("onAdd"), self.onAdd) #osiris.events.connect(self.events.get("onEdit"), self.onEdit) osiris.events.connect(self.events.get("onRemove"), self.onRemove) elif ((self.act == "add") or (self.act == "edit")): self.saveCommand = osiris.IdeButton( self.getText("common.actions.save")) self.saveCommand.id = "save" self.saveCommand.iconHref = self.skin.getImageUrl( "icons/16x16/save.png") osiris.events.connect(self.saveCommand.eventClick, self.onSave) template.addChildParam(self.saveCommand) self.cboPortal = osiris.HtmlComboBox() self.cboPortal.id = "portal" self.cboPortal.size = 40 template.addChildParam(self.cboPortal) self.txtName = osiris.HtmlTextBox() self.txtName.id = "name" self.txtName.size = 40 template.addChildParam(self.txtName) self.txtUrl = osiris.HtmlTextBox() self.txtUrl.id = "url" self.txtUrl.size = 40 template.addChildParam(self.txtUrl) self.txtPassword = osiris.HtmlTextBox() self.txtPassword.id = "password" self.txtPassword.size = 40 template.addChildParam(self.txtPassword) self.chkEnabled = osiris.IdePickerBool() self.chkEnabled.id = "enabled" template.addChildParam(self.chkEnabled)
def onLoad(self): osiris.IPortalPage.onLoad(self) osiris.events.connect(self.events.get("onPortalRemove"), self.onPortalRemove) document = osiris.XMLDocument() self.root = document.create("info") template = osiris.HtmlXSLControl() template.stylesheet = self.loadStylesheet( os.path.join(os.path.dirname(__file__), "info.xsl")) template.document = document if (self.ajax): self.controls.add(template) else: self.getArea(osiris.pageAreaContent).controls.add(template) node = self.root node.setAttributeString("mode", self.request.getUrlParam("mode")) if (self.act == "home"): if (self.sessionAccount.isLogged()): #self.showMessage("logged") self.isUserOfPov = (self.sessionAccount.userID.getString() == self.portal.povID.getString()) self.root.setAttributeBool("isUserOfPov", self.isUserOfPov) self.povOfUser = osiris.PortalsSystem.instance().getPortal( self.portal.portalID, self.sessionAccount.userID.getString()) self.root.setAttributeBool("povOfUserExists", (self.povOfUser != None)) nodeActions = node.nodes.add("actions") nodeAction = nodeActions.nodes.add("action") nodeAction.attributes.set("name", "home") nodeAction.attributes.set("href", self.portal.getLink("view")) if (self.sessionAccount.isLogged()): if (self.isUserOfPov): nodeAction = nodeActions.nodes.add("action") nodeAction.attributes.set("name", "acp") nodeAction.attributes.set("href", self.portal.getLink("acp")) elif (self.povOfUser == None): params = {} params["mode"] = "fork" params["name"] = self.portal.name params["id"] = self.portal.portalID.toWide() nodeAction = nodeActions.nodes.add("action") nodeAction.attributes.set("name", "fork") nodeAction.attributes.set("prefix", "main.pages.subscribe") nodeAction.attributes.set( "href", osiris.PortalsSystem.instance().getMainLink( "subscribe", params)) #nodeAction = nodeActions.nodes.add("action") #nodeAction.attributes.set("name", "info") #nodeAction.attributes.set("href", self.portal.getLink("info")) #nodeAction = nodeActions.nodes.add("action") #nodeAction.attributes.set("name", "accounts") #nodeAction.attributes.set("href", osiris.PortalsSystem.instance().getMainLink("accounts?portal=" + self.portal.getFullPovID())) nodeAction = nodeActions.nodes.add("action") nodeAction.attributes.set("name", "settings") nodeAction.attributes.set( "href", osiris.PortalsSystem.instance().getMainLink( "settings?portal=" + self.portal.getFullPovID())) #nodeAction = nodeActions.nodes.add("action") #nodeAction.attributes.set("name", "invite") #nodeAction.attributes.set("call", self.portal.getLink("invite?mode=dialog")) nodeAction = nodeActions.nodes.add("action") nodeAction.attributes.set("name", "remove") #nodeAction.attributes.set("href", osiris.PortalsSystem.instance().getMainLink("removeportal?portal=" + self.portal.getFullPovID())) nodeAction.attributes.set("prefix", "portal.pages.info") nodeAction.attributes.set( "href", self.getEventCommand("onPortalRemove", self.portal.getFullPovID())) nodeAction.attributes.set("confirm", "true") # Details node.attributes.set("id", self.portal.portalID.string) node.attributes.set("pov", self.portal.povID.string) node.attributes.set("name", self.portal.name) if self.portal.optionsShared.portalDescription != "": node.attributes.set( "description", self.portal.optionsShared.portalDescription) #node.setAttributeString("machine_id", osiris.Engine.instance().getMachineID()) #node.setAttributeString("align_hash", self.portal.options.getAlignHash().getString()) #node.setAttributeString("acceptable_hash", self.portal.optionsShared.getAcceptableHash()) nodeIsisEndpoints = node.nodes.add("isis") isisEndpoints = self.portal.options.isisEndpoints osiris.events.connect(self.events.get("onIsisRemove"), self.onIsisRemove) for isisEndpointID in isisEndpoints.keys(): isisEndpoint = isisEndpoints[isisEndpointID] nodeIsis = nodeIsisEndpoints.nodes.add("isis") nodeIsis.attributes.set("name", isisEndpoint.getName()) nodeIsis.attributes.set("url", isisEndpoint.url.toString()) nodeIsis.attributes.set("enabled", isisEndpoint.enabled) nodeIsis.attributes.set("last_event", isisEndpoint.getLastEvent()) nodeIsis.attributes.set( "edit_href", self.portal.getLink("info") + "?act=isis_edit&id=" + str(isisEndpointID)) nodeIsis.attributes.set( "remove_href", self.getEventCommand("onIsisRemove", str(isisEndpointID))) nodeIsisEndpoints.attributes.set( "add_href", self.portal.getLink("info") + "?act=isis_add") node.attributes.set( "exchangeEnabled", "true" if self.portal.options.exchangeEnabled else "false") if (osiris.Options.instance().getWebMcpPassword() != ""): node.attributes.set( "publicEnabled", "true" if self.portal.options.publicEnabled else "false") node.attributes.set( "default", "true" if (osiris.Options.instance().getWebDefaultPortal() == self.portal.getFullPovID().toUTF16()) else "false") node.attributes.set("lastObjectDate", self.portal.options.lastObjectDate.toXML()) node.attributes.set("lastExchangeDate", self.portal.options.lastExchangeDate.toXML()) node.attributes.set( "lastDownloadedObjectDate", self.portal.options.lastDownloadedObjectDate.toXML()) node.attributes.set( "lastUploadedObjectDate", self.portal.options.lastUploadedObjectDate.toXML()) node.attributes.set( "lastOptimizationDate", self.portal.options.lastOptimizationDate.toXML()) node.attributes.set("lastSyncDate", self.portal.options.lastSyncDate.toXML()) node.setAttributeUint32("nodesSameAlign", self.portal.nodesSameAlign) node.setAttributeUint32("nodesSamePortalPov", self.portal.nodesSamePortalPov) # Invite self.root.setAttributeString("subscribe_href", self.portal.generateInviteLink(False)) self.root.setAttributeString("isis_subscribe_href", self.portal.generateInviteLink(True)) self.root.setAttributeString("export_href", self.portal.generateExportLink()) # Settings self.saveCommand = osiris.IdeButton( self.getText("common.actions.save")) self.saveCommand.id = "save" self.saveCommand.iconHref = self.skin.getImageUrl( "icons/16x16/save.png") osiris.events.connect(self.saveCommand.eventClick, self.onSave) template.addChildParam(self.saveCommand) self.chkExchange = osiris.IdePickerBool() self.chkExchange.id = "exchange" template.addChildParam(self.chkExchange) self.txtPassword = osiris.HtmlTextBox() self.txtPassword.id = "password" self.txtPassword.size = 20 template.addChildParam(self.txtPassword) self.cboSync = osiris.HtmlComboBox() self.cboSync.id = "sync" template.addChildParam(self.cboSync) self.cboSync.addOption( self.getText("portal.pages.info.settings.sync.none"), "") subscribedPortals = osiris.PortalsSystem.instance().portals for portal2 in subscribedPortals: #osiris.LogManager.instance().log(portal2.getPovName() + "," + self.portal.getPortalID().getString() + "-" + portal2.getPortalID().getString()) if (self.portal.getPortalID().getString() == portal2.getPortalID().getString()): if (self.portal.getPovID().getString() != portal2.getPovID().getString()): self.cboSync.addOption(portal2.getPovName(), portal2.getFullPovID()) if (self.postBack == False): self.chkExchange.check = self.portal.options.getExchangeEnabled( ) self.txtPassword.value = self.portal.options.getPassword() self.cboSync.value = self.portal.getSync() elif ((self.act == "isis_add") or (self.act == "isis_edit")): self.saveCommand = osiris.IdeButton( self.getText("common.actions.save")) self.saveCommand.id = "save" self.saveCommand.iconHref = self.skin.getImageUrl( "icons/16x16/save.png") osiris.events.connect(self.saveCommand.eventClick, self.onIsisSave) template.addChildParam(self.saveCommand) self.txtName = osiris.HtmlTextBox() self.txtName.id = "name" self.txtName.size = 40 template.addChildParam(self.txtName) self.txtUrl = osiris.HtmlTextBox() self.txtUrl.id = "url" self.txtUrl.size = 40 template.addChildParam(self.txtUrl) self.txtPassword = osiris.HtmlTextBox() self.txtPassword.id = "password" self.txtPassword.size = 40 template.addChildParam(self.txtPassword) self.chkEnabled = osiris.IdePickerBool() self.chkEnabled.id = "enabled" template.addChildParam(self.chkEnabled)
def onLoad(self): osiris.IPortalPage.onLoad(self) self.act = self.session.request.getUrlParam("act") if (self.act == ""): self.act = "home" self.document = osiris.XMLDocument() self.root = self.document.create(self.act) template = osiris.HtmlXSLControl() template.stylesheet = self.loadStylesheet( os.path.join(os.path.dirname(__file__), "acp.xsl")) template.document = self.document #self.document.root.setAttributeString("page_url",self.request.rawUrl); osiris.LogManager.instance().log( self.sessionAccount.userID.getString()) osiris.LogManager.instance().log(self.portal.povID.getString()) if (self.sessionAccount.userID.getString() == self.portal.povID.getString()): osiris.LogManager.instance().log("kkk") isGuest = self.sessionAccount.isPortalGuest(self.database) self.root.setAttributeBool("isGuest", isGuest) self.root.setAttributeString( "stabilization_stats_href", self.portal.getLink("stabilization_stats")) self.root.setAttributeString("trash_href", self.portal.getLink("trash")) if (isGuest == False): # Hack, to fix: senza le getString le rileva diversi sempre... isUserOfPov = (self.sessionAccount.isPortalGuest(self.database) == False and self.sessionAccount.userID.getString() == self.portal.povID.getString()) self.root.setAttributeBool("isUserOfPov", isUserOfPov) povOfUser = osiris.PortalsSystem.instance().getPortal( self.portal.portalID, self.sessionAccount.userID.getString()) self.root.setAttributeBool("povOfUserExists", (povOfUser != None)) povOfUserHref = "" if (povOfUser != None): povOfUserHref = povOfUser.getLink("acp") else: params = {} params["mode"] = "fork" params["name"] = self.portal.optionsShared.portalName params["id"] = self.portal.portalID.toWide() povOfUserHref = osiris.PortalsSystem.instance().getMainLink( "subscribe", params) self.root.setAttributeString("povOfUserHref", povOfUserHref) if (self.act == "home"): self.saveCommand = osiris.IdeButton( self.getText("common.actions.save")) self.saveCommand.id = "saveCommand" self.saveCommand.iconHref = self.skin.getImageUrl( "icons/16x16/save.png") osiris.events.connect(self.saveCommand.eventClick, self.onSave) template.addChildParam(self.saveCommand) self.portalName = osiris.HtmlTextBox() self.portalName.id = "portalName" self.portalName.css = "os_input_full" self.portalName.getAttributes().set("data-os-otype", "string") self.portalName.getAttributes().set("data-os-minchars", "5") self.portalName.getAttributes().set("data-os-submit", "page-saveCommand") template.addChildParam(self.portalName) self.portalDescription = osiris.HtmlTextBox() self.portalDescription.id = "portalDescription" self.portalDescription.css = "os_input_full" template.addChildParam(self.portalDescription) self.authorsReputationThreshold = osiris.HtmlComboBox() self.authorsReputationThreshold.id = "authorsReputationThreshold" template.addChildParam(self.authorsReputationThreshold) self.authorsReputationThreshold.addOption( self.getText("reputation.threshold.all"), "0") self.authorsReputationThreshold.addOption( self.getText("reputation.threshold.negative"), "1") self.authorsReputationThreshold.addOption( self.getText("reputation.threshold.not_negative"), "2") self.authorsReputationThreshold.addOption( self.getText("reputation.threshold.positive"), "3") self.editorsReputationThreshold = osiris.HtmlComboBox() self.editorsReputationThreshold.id = "editorsReputationThreshold" template.addChildParam(self.editorsReputationThreshold) self.editorsReputationThreshold.addOption( self.getText("reputation.threshold.all"), "0") self.editorsReputationThreshold.addOption( self.getText("reputation.threshold.negative"), "1") self.editorsReputationThreshold.addOption( self.getText("reputation.threshold.not_negative"), "2") self.editorsReputationThreshold.addOption( self.getText("reputation.threshold.positive"), "3") self.txtPovWhiteList = osiris.HtmlTextBox() self.txtPovWhiteList.id = "povWhiteList" self.txtPovWhiteList.css = "os_input_full" template.addChildParam(self.txtPovWhiteList) self.txtPovBlackList = osiris.HtmlTextBox() self.txtPovBlackList.id = "povBlackList" self.txtPovBlackList.css = "os_input_full" template.addChildParam(self.txtPovBlackList) # Layout self.layoutComponent = osiris.IdePickerComponent() self.layoutComponent.id = "layoutComponent" self.layoutComponent.css = "os_input_full" template.addChildParam(self.layoutComponent) #self.registerTerms = osiris.IdeOMLEditor() #self.registerTerms.id = "registerTerms" #self.registerTerms.css = "os_input_full" #template.addChildParam(self.registerTerms) self.layoutTileImage = osiris.IdePickerObject() self.layoutTileImage.id = "layoutTileImage" template.addChildParam(self.layoutTileImage) self.layoutTileColorBackground = osiris.IdePickerColor() self.layoutTileColorBackground.id = "layoutTileColorBackground" template.addChildParam(self.layoutTileColorBackground) self.layoutTileColorForeground = osiris.IdePickerColor() self.layoutTileColorForeground.id = "layoutTileColorForeground" template.addChildParam(self.layoutTileColorForeground) self.layoutSkinParams = osiris.IdeOMLEditor() self.layoutSkinParams.id = "layoutSkinParams" self.layoutSkinParams.css = "os_input_full" template.addChildParam(self.layoutSkinParams) self.layoutCss = osiris.IdeOMLEditor() self.layoutCss.id = "layoutCss" self.layoutCss.css = "os_input_full" template.addChildParam(self.layoutCss) self.layoutHeader = osiris.IdePickerBool() self.layoutHeader.id = "layoutHeader" template.addChildParam(self.layoutHeader) # Rules self.objectsMaxSize = osiris.IdePickerNumber() self.objectsMaxSize.id = "objectsMaxSize" template.addChildParam(self.objectsMaxSize) self.badWords = osiris.HtmlTextBox() self.badWords.id = "badWords" self.badWords.css = "os_input_full" template.addChildParam(self.badWords) # Rules ex self.allowObjectInFuture = osiris.IdePickerBool() self.allowObjectInFuture.id = "allowObjectInFuture" template.addChildParam(self.allowObjectInFuture) self.allowObjectUnsigned = osiris.IdePickerBool() self.allowObjectUnsigned.id = "allowObjectUnsigned" template.addChildParam(self.allowObjectUnsigned) self.objectsPhysicalRemove = osiris.IdePickerBool() self.objectsPhysicalRemove.id = "objectsPhysicalRemove" template.addChildParam(self.objectsPhysicalRemove) self.objectsPhysicalRemoveDays = osiris.IdePickerNumber() self.objectsPhysicalRemoveDays.id = "objectsPhysicalRemoveDays" template.addChildParam(self.objectsPhysicalRemoveDays) if (self.postBack == False): # Main self.portalName.value = self.portal.name self.portalDescription.value = self.portal.optionsShared.portalDescription self.authorsReputationThreshold.value = self.portal.optionsShared.authorsReputationThreshold self.editorsReputationThreshold.value = self.portal.optionsShared.editorsReputationThreshold self.txtPovWhiteList.value = self.portal.optionsShared.povWhiteList self.txtPovBlackList.value = self.portal.optionsShared.povBlackList # Layout self.layoutComponent.value = self.portal.optionsShared.layoutComponent #self.registerTerms.value = self.portal.optionsShared.registerTerms self.layoutTileImage.value = self.portal.optionsShared.layoutTileImage self.layoutTileColorBackground.value = self.portal.optionsShared.layoutTileColorBackground self.layoutTileColorForeground.value = self.portal.optionsShared.layoutTileColorForeground self.layoutSkinParams.value = self.portal.optionsShared.layoutSkinParams self.layoutCss.value = self.portal.optionsShared.layoutCss self.layoutHeader.check = self.portal.optionsShared.layoutHeader # Rules self.objectsMaxSize.value = self.portal.optionsShared.objectsMaxSize self.badWords.value = self.portal.optionsShared.badWords # Rules Ex self.allowObjectInFuture.check = self.portal.optionsShared.allowObjectInFuture self.allowObjectUnsigned.check = self.portal.optionsShared.allowObjectUnsigned self.objectsPhysicalRemove.check = self.portal.optionsShared.objectsPhysicalRemove self.objectsPhysicalRemoveDays.value = self.portal.optionsShared.objectsPhysicalRemoveDays if (self.ajax): self.controls.add(template) else: self.getArea(osiris.pageAreaContent).controls.add(template)
def onInit(self): osiris.IMainPage.onInit(self) document = osiris.XMLDocument() root = document.create("subscribe") template = osiris.HtmlXSLControl() template.stylesheet = self.loadStylesheet( os.path.join(os.path.dirname(__file__), "subscribe.xsl")) template.document = document self.mode = self.request.getUrlParam("mode") document.root.setAttributeString("mode", self.mode) self.valid = True self.accountRequired = False if (self.mode != 'subscribe'): self.accountRequired = True if (self.accountRequired): if (self.sessionAccount.isLogged() == False): self.showError(self.getText("errors.account_required")) self.valid = False return if ((self.mode != 'subscribe') and (self.mode != 'create') and (self.mode != 'self') and (self.mode != 'fork')): self.showError(self.getText("errors.invalid_params")) self.valid = False return self.portalName = osiris.HtmlTextBox() self.portalName.id = "name" self.portalName.size = 40 self.portalName.getAttributes().set("data-os-otype", "string") self.portalName.getAttributes().set("data-os-minchars", "5") self.portalName.getAttributes().set("data-os-submit", "page-subscribe") template.addChildParam(self.portalName) self.portalPassword = osiris.HtmlTextBox() self.portalPassword.id = "password" self.portalPassword.size = 40 self.portalPassword.password = True self.portalPassword.attributes.set("data-os-otype", "password") self.portalPassword.attributes.set("data-os-login", "page-name") template.addChildParam(self.portalPassword) self.portalEnableExchange = osiris.IdePickerBool() self.portalEnableExchange.id = "enableExchange" template.addChildParam(self.portalEnableExchange) self.portalId = osiris.HtmlTextBox() self.portalId.id = "id" self.portalId.size = 40 self.portalId.getAttributes().set("data-os-otype", "string") self.portalId.getAttributes().set("data-os-minchars", "40") template.addChildParam(self.portalId) self.portalPov = osiris.HtmlTextBox() self.portalPov.id = "pov" self.portalPov.size = 40 self.portalPov.getAttributes().set("data-os-otype", "string") self.portalPov.getAttributes().set("data-os-minchars", "40") template.addChildParam(self.portalPov) self.databaseDriver = osiris.HtmlComboBox() self.databaseDriver.id = "databaseDriver" self.databaseDriver.autoPostBack = True template.addChildParam(self.databaseDriver) drivers = osiris.DatabasesSystem.instance().drivers for driver in drivers: self.databaseDriver.addOption(driver.description, driver.name) self.databaseDriver.value = osiris.DatabasesSystem.instance( ).defaultDriver.name subscribeLabel = "create" if (self.mode == "subscribe"): subscribeLabel = "subscribe" self.cmdSubscribe = osiris.IdeButton( self.getText("main.pages.subscribe.action." + subscribeLabel)) self.cmdSubscribe.id = "subscribe" self.cmdSubscribe.iconHref = self.skin.getImageUrl( "icons/16x16/save.png") self.cmdSubscribe.isDefault = True osiris.events.connect(self.cmdSubscribe.eventClick, self.onSubscribe) template.addChildParam(self.cmdSubscribe) self.getArea(osiris.pageAreaContent).controls.add(template) if (self.mode == 'self'): self.portalName.value = self.sessionAccount.account.name self.portalId.value = self.sessionAccount.userID.toAscii() self.portalPov.value = self.sessionAccount.userID.toAscii() elif (self.mode == 'fork'): self.portalName.value = self.getText( "main.pages.subscribe.fork_of" ) + " " + self.request.getUrlParam("name") self.portalId.value = self.request.getUrlParam("id") self.portalPov.value = self.sessionAccount.userID.toAscii() elif (self.mode == 'create'): self.portalPov.value = self.sessionAccount.userID.toAscii()