public function getAdminForm() { $objForm = parent::getAdminForm(); $arrRawVotings = class_module_votings_voting::getObjectList(true); $arrVotings = array(); foreach ($arrRawVotings as $objOneVoting) { $arrVotings[$objOneVoting->getSystemid()] = $objOneVoting->getStrTitle(); } $objForm->getField("char1")->setArrKeyValues($arrVotings); return $objForm; }
/** * Removes the elements / modules handled by the current installer. * Use the reference param to add a human readable logging. * * @param string &$strReturn * * @return bool */ public function remove(&$strReturn) { //delete the page-element $objElement = class_module_pages_element::getElement("votings"); if ($objElement != null) { $strReturn .= "Deleting page-element 'votings'...\n"; $objElement->deleteObjectFromDatabase(); } else { $strReturn .= "Error finding page-element 'votings', aborting.\n"; return false; } /** @var class_module_votings_voting $objOneObject */ foreach (class_module_votings_voting::getObjectList() as $objOneObject) { $strReturn .= "Deleting object '" . $objOneObject->getStrDisplayName() . "' ...\n"; if (!$objOneObject->deleteObjectFromDatabase()) { $strReturn .= "Error deleting object, aborting.\n"; return false; } } //delete the module-node $strReturn .= "Deleting the module-registration...\n"; $objModule = class_module_system_module::getModuleByName($this->objMetadata->getStrTitle(), true); if (!$objModule->deleteObjectFromDatabase()) { $strReturn .= "Error deleting module, aborting.\n"; return false; } //delete the tables foreach (array("votings_voting", "votings_answer") as $strOneTable) { $strReturn .= "Dropping table " . $strOneTable . "...\n"; if (!$this->objDB->_pQuery("DROP TABLE " . $this->objDB->encloseTableName(_dbprefix_ . $strOneTable) . "", array())) { $strReturn .= "Error deleting table, aborting.\n"; return false; } } return true; }
public function install() { $strReturn = ""; //fetch navifolder-id $strNaviFolderId = ""; $arrFolder = class_module_pages_folder::getFolderList(); foreach ($arrFolder as $objOneFolder) { if ($objOneFolder->getStrName() == "mainnavigation") { $strNaviFolderId = $objOneFolder->getSystemid(); } } $strReturn .= "Creating voting\n"; $objVoting = new class_module_votings_voting(); if ($this->strContentLanguage == "de") { $objVoting->setStrTitle("Wie gefällt Ihnen unsere neue Webseite?"); } else { $objVoting->setStrTitle("How do you like our new website?"); } $objVoting->updateObjectToDb(); $objAnswer1 = new class_module_votings_answer(); $objAnswer2 = new class_module_votings_answer(); $objAnswer3 = new class_module_votings_answer(); if ($this->strContentLanguage == "de") { $objAnswer1->setStrText("Gefällt mir sehr gut!"); $objAnswer2->setStrText("Ausbaufähig..."); $objAnswer3->setStrText("Brennt im Kühlschrank immer Licht?"); } else { $objAnswer1->setStrText("I like it!"); $objAnswer2->setStrText("Well, work on it"); $objAnswer3->setStrText("Sunglasses at night"); } $objAnswer1->updateObjectToDb($objVoting->getSystemid()); $objAnswer2->updateObjectToDb($objVoting->getSystemid()); $objAnswer3->updateObjectToDb($objVoting->getSystemid()); $strReturn .= "Creating voting-page\n"; $objPage = new class_module_pages_page(); $objPage->setStrName("votings"); $objPage->setStrBrowsername("Votings"); $objPage->setStrTemplate("standard.tpl"); $objPage->updateObjectToDb($strNaviFolderId); $strFaqsPageId = $objPage->getSystemid(); $strReturn .= "ID of new page: " . $strFaqsPageId . "\n"; $strReturn .= "Adding votings-element 1 to new page\n"; if (class_module_pages_element::getElement("faqs") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("special_news|guestbook|downloads|gallery|galleryRandom|form|tellafriend|maps|search|navigation|faqs|postacomment|votings|userlist|rssfeed|tagto|portallogin|portalregistration|portalupload|directorybrowser|lastmodified|tagcloud|downloadstoplist|flash|mediaplayer|tags|eventmanager"); $objPagelement->setStrName("special"); $objPagelement->setStrElement("votings"); $objPagelement->updateObjectToDb($strFaqsPageId); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_universal\n SET " . $this->objDB->encloseColumnName("int1") . " = ?,\n " . $this->objDB->encloseColumnName("char1") . " = ?,\n " . $this->objDB->encloseColumnName("char2") . " = ?\n WHERE content_id = ? "; if ($this->objDB->_pQuery($strQuery, array(0, $objVoting->getSystemid(), "votings.tpl", $strElementId))) { $strReturn .= "faqselement created.\n"; } else { $strReturn .= "Error creating faqselement.\n"; } } $strReturn .= "Adding votings-element 2 to new page\n"; if (class_module_pages_element::getElement("faqs") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("special_news|guestbook|downloads|gallery|galleryRandom|form|tellafriend|maps|search|navigation|faqs|postacomment|votings|userlist|rssfeed|tagto|portallogin|portalregistration|portalupload|directorybrowser|lastmodified|tagcloud|downloadstoplist|flash|mediaplayer|tags|eventmanager"); $objPagelement->setStrName("special"); $objPagelement->setStrElement("votings"); $objPagelement->updateObjectToDb($strFaqsPageId); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_universal\n SET " . $this->objDB->encloseColumnName("int1") . " = ?,\n " . $this->objDB->encloseColumnName("char1") . " = ?,\n " . $this->objDB->encloseColumnName("char2") . " = ?\n WHERE content_id = ? "; if ($this->objDB->_pQuery($strQuery, array(1, $objVoting->getSystemid(), "votings.tpl", $strElementId))) { $strReturn .= "faqselement created.\n"; } else { $strReturn .= "Error creating faqselement.\n"; } } $strReturn .= "Adding headline-element to new page\n"; if (class_module_pages_element::getElement("row") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("headline_row"); $objPagelement->setStrName("headline"); $objPagelement->setStrElement("row"); $objPagelement->updateObjectToDb($strFaqsPageId); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_paragraph\n SET paragraph_title = ?\n WHERE content_id = ?"; if ($this->objDB->_pQuery($strQuery, array("Votings", $strElementId))) { $strReturn .= "Headline element created.\n"; } else { $strReturn .= "Error creating headline element.\n"; } } return $strReturn; }
/** * Helper method, does the internal updates of the voting-answers * * @return void * @permissions right1 */ private function actionSubmitVoting() { //load the current voting $objVoting = new class_module_votings_voting($this->arrElementData["char1"]); // check if the submitted vote matches the current one -> multiple votings per page if ($objVoting->getSystemid() == $this->getParam("systemid")) { //recheck permissions if (!in_array($objVoting->getSystemid(), $this->arrCookieValues)) { //load the submitted answer $strAnswerID = $this->getParam("voting_" . $objVoting->getSystemid()); if (validateSystemid($strAnswerID)) { $objAnswer = new class_module_votings_answer($strAnswerID); $objAnswer->setIntHits($objAnswer->getIntHits() + 1); $objAnswer->updateObjectToDb(); $this->arrCookieValues[] = $objVoting->getSystemid(); $objCookie = new class_cookie(); $objCookie->setCookie($this->STR_COOKIE_NAME, implode(",", $this->arrCookieValues)); } } } }