/** * @return string * @autoTestable * @permissions view */ protected function actionBrowserChooser() { $strReturn = ""; if ($this->getParam("CKEditorFuncNum") != "") { $strReturn .= "<script type=\"text/javascript\">window.opener.KAJONA.admin.folderview.selectCallbackCKEditorFuncNum = " . (int) $this->getParam("CKEditorFuncNum") . ";</script>"; } $intCounter = 1; $strReturn .= $this->objToolkit->listHeader(); if (class_module_system_module::getModuleByName("pages") !== null) { $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("pages", "pagesFolderBrowser", "&pages=1&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygPagesBrowser"), $this->getLang("wysiwygPagesBrowser"), "icon_folderActionOpen")); $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygPagesBrowser"), "", $strAction, $intCounter++); } $strRepoId = class_module_system_setting::getConfigValue("_mediamanager_default_filesrepoid_"); if (validateSystemid($strRepoId) && class_module_system_module::getModuleByName("mediamanager") !== null && class_objectfactory::getInstance()->getObject($strRepoId) !== null) { $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("mediamanager", "folderContentFolderviewMode", "&systemid=" . $strRepoId . "&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygFilesBrowser"), $this->getLang("wysiwygFilesBrowser"), "icon_folderActionOpen")); $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygFilesBrowser"), "", $strAction, $intCounter++); } $strRepoId = class_module_system_setting::getConfigValue("_mediamanager_default_imagesrepoid_"); if (validateSystemid($strRepoId) && class_module_system_module::getModuleByName("mediamanager") !== null && class_objectfactory::getInstance()->getObject($strRepoId) !== null) { $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("mediamanager", "folderContentFolderviewMode", "&systemid=" . $strRepoId . "&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygImagesBrowser"), $this->getLang("wysiwygImagesBrowser"), "icon_folderActionOpen")); $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygImagesBrowser"), "", $strAction, $intCounter++); } if (class_module_system_module::getModuleByName("mediamanager") !== null) { $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin("mediamanager", "folderContentFolderviewMode", "&form_element=" . $this->getParam("form_element") . "&bit_link=1", $this->getLang("wysiwygRepoBrowser"), $this->getLang("wysiwygRepoBrowser"), "icon_folderActionOpen")); $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), $this->getLang("wysiwygRepoBrowser"), "", $strAction, $intCounter++); } $strReturn .= $this->objToolkit->listFooter(); return $strReturn; }
/** * Contructor * * @param $objElementData */ public function __construct($objElementData) { parent::__construct($objElementData); if ($this->getParam("action") == "saveGuestbook") { $this->setStrCacheAddon(generateSystemid()); } }
/** * Generates a new entry in the log-table * * @param string $strSeachterm * * @return bool * @static */ public static function generateLogEntry($strSeachterm) { $objLanguage = new class_module_languages_language(); $strLanguage = $objLanguage->getStrPortalLanguage(); $strQuery = "INSERT INTO " . _dbprefix_ . "search_log \n (search_log_id, search_log_date, search_log_query, search_log_language) VALUES\n (?, ?, ?, ? )"; return class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array(generateSystemid(), (int) time(), $strSeachterm, $strLanguage)); }
/** * Generates an entry in the logbook an increases the hits-counter * * @param \class_module_mediamanager_file $objFile */ public static function generateDlLog(class_module_mediamanager_file $objFile) { $objDB = class_carrier::getInstance()->getObjDB(); $strQuery = "INSERT INTO " . _dbprefix_ . "mediamanager_dllog\n\t (downloads_log_id, downloads_log_date, downloads_log_file, downloads_log_user, downloads_log_ip) VALUES\n\t (?, ?, ?, ?, ?)"; $objDB->_pQuery($strQuery, array(generateSystemid(), (int) time(), basename($objFile->getStrFilename()), class_carrier::getInstance()->getObjSession()->getUsername(), getServer("REMOTE_ADDR"))); $objFile->increaseHits(); }
protected function setUp() { $objObject = $this->createObject("class_module_system_aspect", ""); self::$arrObjectIds[] = $objObject->getSystemid(); $objSearchIndexWriter = new class_module_search_indexwriter(); $objSearchIndexWriter->clearIndex(); $objSearchDocument_1 = new class_module_search_document(); $objSearchDocument_1->setStrSystemId($objObject->getSystemid()); $objSearchDocument_1->setDocumentId(generateSystemid()); $objSearchDocument_1->addContent("title", "hallo"); $objSearchDocument_1->addContent("text", "welt"); $objSearchDocument_1->addContent("subtitle", "blub"); $objSearchDocument_1->addContent("text2", "blub"); $objObject = $this->createObject("class_module_search_search", ""); self::$arrObjectIds[] = $objObject->getSystemid(); $objSearchDocument_2 = new class_module_search_document(); $objSearchDocument_2->setStrSystemId($objObject->getSystemid()); $objSearchDocument_2->setDocumentId(generateSystemid()); $objSearchDocument_2->addContent("title", "hallo"); $objSearchDocument_2->addContent("text", "welt"); $objObject = $this->createObject("class_module_system_aspect", ""); self::$arrObjectIds[] = $objObject->getSystemid(); $objSearchDocument_3 = new class_module_search_document(); $objSearchDocument_3->setStrSystemId($objObject->getSystemid()); $objSearchDocument_3->setDocumentId(generateSystemid()); $objSearchDocument_3->addContent("title", "lorem ipsum dolor ipsum"); $objSearchDocument_3->addContent("text", "dolor ipsum sit amet, consetetur."); $objSearchIndexWriter->updateSearchDocumentToDb($objSearchDocument_1); $objSearchIndexWriter->updateSearchDocumentToDb($objSearchDocument_2); $objSearchIndexWriter->updateSearchDocumentToDb($objSearchDocument_3); parent::setUp(); }
public function testCopyPage() { $strTitle = generateSystemid(); $objPage = new class_module_pages_page(); $objPage->setStrName($strTitle); $objPage->setStrBrowsername(generateSystemid()); $objPage->setStrSeostring(generateSystemid()); $objPage->setStrDesc(generateSystemid()); $objPage->setStrTemplate("standard.tpl"); $objPage->updateObjectToDb(); $strOldSystemid = $objPage->getSystemid(); $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("text_paragraph"); $objPagelement->setStrName("text"); $objPagelement->setStrElement("paragraph"); $objPagelement->updateObjectToDb($objPage->getSystemid()); $objPagelement = new class_module_pages_pageelement($objPagelement->getSystemid()); //and finally create the object /** @var $objElement class_element_paragraph_admin */ $objElement = $objPagelement->getConcreteAdminInstance(); $objElement->setStrTitle("autotest"); $objElement->doBeforeSaveToDb(); $objElement->updateForeignElement(); $objElement->doAfterSaveToDb(); //copy the page itself $objPage->copyObject(); $strNewSystemid = $objPage->getSystemid(); $this->flushDBCache(); $objOldPage = new class_module_pages_page($strOldSystemid); $objNewPage = new class_module_pages_page($strNewSystemid); $this->assertNotEquals($objOldPage->getStrName(), $objNewPage->getStrName()); $this->assertEquals($objOldPage->getStrBrowsername(), $objNewPage->getStrBrowsername()); $this->assertEquals($objOldPage->getStrSeostring(), $objNewPage->getStrSeostring()); $this->assertEquals($objOldPage->getStrDesc(), $objNewPage->getStrDesc()); $this->assertEquals($objOldPage->getStrTemplate(), $objNewPage->getStrTemplate()); $arrOldElements = class_module_pages_pageelement::getAllElementsOnPage($strOldSystemid); $arrNewElements = class_module_pages_pageelement::getAllElementsOnPage($strNewSystemid); $this->assertEquals(count($arrOldElements), count($arrNewElements)); $this->assertEquals(1, count($arrOldElements)); $this->assertEquals(1, count($arrNewElements)); $objOldElement = $arrOldElements[0]; $objNewElement = $arrNewElements[0]; $this->assertEquals($objOldElement->getStrPlaceholder(), $objNewElement->getStrPlaceholder()); $this->assertEquals($objOldElement->getStrLanguage(), $objNewElement->getStrLanguage()); $this->assertEquals($objOldElement->getStrElement(), $objNewElement->getStrElement()); /** @var class_element_paragraph_admin $objOldElementInstance */ $objOldElementInstance = $objOldElement->getConcreteAdminInstance(); $arrOldElementData = $objOldElementInstance->loadElementData(); /** @var class_element_paragraph_admin $objNewElementInstance */ $objNewElementInstance = $objNewElement->getConcreteAdminInstance(); $arrNewElementData = $objNewElementInstance->loadElementData(); $this->assertNotEquals($arrOldElementData["content_id"], $arrNewElementData["content_id"]); $this->assertEquals($arrOldElementData["paragraph_title"], $arrNewElementData["paragraph_title"]); $this->assertEquals($objOldElementInstance->getStrTitle(), $objNewElementInstance->getStrTitle()); $this->assertEquals($objOldElementInstance->getStrTitle(), "autotest"); $this->assertEquals($objNewElementInstance->getStrTitle(), "autotest"); $objNewPage->deleteObjectFromDatabase(); $objOldPage->deleteObjectFromDatabase(); }
public function __construct($strName = "") { if ($strName == "") { $strName = generateSystemid(); } parent::__construct("", $strName); //set the default validator $this->setObjValidator(new class_dummy_validator()); }
public function __construct($strForm = "", $strName = "", $objSourceObject = null) { if ($strName == "") { $strName = generateSystemid(); } class_formentry_base::__construct($strForm, $strName, $objSourceObject); //set the default validator $this->setObjValidator(new class_dummy_validator()); }
public function testImportExport() { class_carrier::getInstance()->getObjRights()->setBitTestMode(true); $strName = generateSystemid(); $strBrowsername = generateSystemid(); $strSeoString = generateSystemid(); $strDesc = generateSystemid(); $objPage = new class_module_pages_page(); $objPage->setStrName($strName); $objPage->setStrBrowsername($strBrowsername); $objPage->setStrSeostring($strSeoString); $objPage->setStrDesc($strDesc); $objPage->setStrTemplate("standard.tpl"); $objPage->updateObjectToDb(); $strPagesystemid = $objPage->getSystemid(); $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("text_paragraph"); $objPagelement->setStrName("text"); $objPagelement->setStrElement("paragraph"); $objPagelement->updateObjectToDb($objPage->getSystemid()); $objElement = new class_element_paragraph_admin($objPagelement->getSystemid()); $objElement->setSystemid($objPagelement->getSystemid()); $objElement->loadElementData(); $objElement->setStrTitle("para_title"); $objElement->updateForeignElement(); $objPagelement = new class_module_pages_pageelement($objPagelement->getSystemid()); class_carrier::getInstance()->setParam("pageExport", $strName); $objPageExport = new class_systemtask_pageexport(); $objPageExport->executeTask(); $objPage->deleteObjectFromDatabase(); class_orm_rowcache::flushCache(); class_db::getInstance()->flushQueryCache(); $this->assertNull(class_module_pages_page::getPageByName($strName)); $this->assertFileExists(_realpath_ . _projectpath_ . "/temp/" . $strPagesystemid . ".xml"); class_carrier::getInstance()->setParam("pageimport_file", _projectpath_ . "/temp/" . $strPagesystemid . ".xml"); $objImport = new class_systemtask_pageimport(); $objImport->executeTask(); $objPage = class_module_pages_page::getPageByName($strName); $this->assertNotNull($objPage); $this->assertEquals($objPage->getStrName(), $strName); $this->assertEquals($objPage->getStrDesc(), $strDesc); $this->assertEquals($objPage->getStrSeostring(), $strSeoString); $this->assertEquals($objPage->getStrBrowsername(), $strBrowsername); $objElements = class_module_pages_pageelement::getAllElementsOnPage($objPage->getSystemid()); $this->assertEquals(1, count($objElements)); $objElements = $objElements[0]; $this->assertEquals($objElements->getStrClassAdmin(), "class_element_paragraph_admin.php"); $objElement = $objElements->getConcreteAdminInstance(); $objElement->setSystemid($objElements->getSystemid()); $objElement->loadElementData(); $this->assertEquals("para_title", $objElement->getStrTitle()); $objPage->deleteObjectFromDatabase(); }
/** * Creates a new workflow-instance in order to index changed objects in a decoupled process */ private function processDeferred() { $arrRows = array(); foreach (array_keys(self::$arrToIndex) as $strOneId) { $arrRows[] = array(generateSystemid(), $strOneId, class_search_enum_indexaction::INDEX() . ""); } foreach (array_keys(self::$arrToDelete) as $strOneId) { $arrRows[] = array(generateSystemid(), $strOneId, class_search_enum_indexaction::DELETE() . ""); } $objQueue = new class_search_indexqueue(); $objQueue->addRowsToQueue($arrRows); }
/** * Called whenever a record was copied. * copies the tag-assignments from the source object to the target object * * @param string $strEventName * @param array $arrArguments * * @return bool */ public function handleEvent($strEventName, array $arrArguments) { //unwrap arguments $strOldSystemid = $arrArguments[0]; $strNewSystemid = $arrArguments[1]; $strQuery = "SELECT tags_tagid, tags_attribute, tags_owner\n FROM " . _dbprefix_ . "tags_member\n WHERE tags_systemid = ?"; $arrRows = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array($strOldSystemid)); foreach ($arrRows as $arrSingleRow) { $strQuery = "INSERT INTO " . _dbprefix_ . "tags_member (tags_memberid, tags_tagid, tags_systemid, tags_attribute, tags_owner) VALUES (?, ?, ?, ?, ?)"; class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array(generateSystemid(), $arrSingleRow["tags_tagid"], $strNewSystemid, $arrSingleRow["tags_attribute"], $arrSingleRow["tags_owner"])); } return true; }
public function test() { $objDB = class_carrier::getInstance()->getObjDB(); echo "testing database...\n"; echo "current driver: " . class_carrier::getInstance()->getObjConfig()->getConfig("dbdriver") . "\n"; echo "\tcreating a new table...\n"; $arrFields = array(); $arrFields["temp_id"] = array("char20", false); $arrFields["temp_long"] = array("long", true); $arrFields["temp_double"] = array("double", true); $arrFields["temp_char10"] = array("char10", true); $arrFields["temp_char20"] = array("char20", true); $arrFields["temp_char100"] = array("char100", true); $arrFields["temp_char254"] = array("char254", true); $arrFields["temp_char500"] = array("char500", true); $arrFields["temp_text"] = array("text", true); $this->assertTrue($objDB->createTable("temp_autotest", $arrFields, array("temp_id")), "testTx createTable"); echo "\ttesting non-tx mode..\n"; echo "\tcreating 50 records...\n"; $intI = 1; $strQuery = "INSERT INTO " . _dbprefix_ . "temp_autotest\n (temp_id, temp_long, temp_double, temp_char10, temp_char20, temp_char100, temp_char254, temp_char500, temp_text)\n VALUES\n ('" . generateSystemid() . "', 123456" . $intI . ", 23.45" . $intI . ", '" . $intI . "', 'char20" . $intI . "', 'char100" . $intI . "', 'char254" . $intI . "', 'char500" . $intI . "', 'text" . $intI . "')"; $this->assertTrue($objDB->_query($strQuery), "testTx insert"); echo "\tgetRow test\n"; $strQuery = "SELECT * FROM " . _dbprefix_ . "temp_autotest ORDER BY temp_long ASC"; $arrRow = $objDB->getPArray($strQuery, array()); $this->assertEquals(count($arrRow), 1, "testDataBase getRow count"); $this->assertEquals($arrRow[0]["temp_char10"], "1", "testTx getRow content"); $objDB->flushQueryCache(); echo "starting tx...\n"; $objDB->transactionBegin(); $intI = 2; $strQuery = "INSERT INTO " . _dbprefix_ . "temp_autotest\n (temp_id, temp_long, temp_double, temp_char10, temp_char20, temp_char100, temp_char254, temp_char500, temp_text)\n VALUES\n ('" . generateSystemid() . "', 123456" . $intI . ", 23.45" . $intI . ", '" . $intI . "', 'char20" . $intI . "', 'char100" . $intI . "', 'char254" . $intI . "', 'char500" . $intI . "', 'text" . $intI . "')"; $this->assertTrue($objDB->_query($strQuery), "testTx insert"); echo "rollback...\n"; $objDB->transactionRollback(); $arrCount = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "temp_autotest", array()); $this->assertEquals($arrCount["COUNT(*)"], 1, "testTx rollback"); $objDB->flushQueryCache(); echo "starting tx...\n"; $objDB->transactionBegin(); $this->assertTrue($objDB->_query($strQuery), "testTx insert"); echo "commit...\n"; $objDB->transactionCommit(); $arrCount = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "temp_autotest", array()); $this->assertEquals($arrCount["COUNT(*)"], 2, "testTx rollback"); $objDB->flushQueryCache(); echo "\tdeleting table\n"; $strQuery = "DROP TABLE " . _dbprefix_ . "temp_autotest"; $this->assertTrue($objDB->_query($strQuery), "testTx dropTable"); }
/** * Updates the current object to the database. * Overwrites class_roots' logic since a ldap group is not reflected in the system-table * * @param bool $strPrevId * * @return bool */ public function updateObjectToDb($strPrevId = false) { //mode-splitting if ($this->getSystemid() == "") { class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("saved new ldap group " . $this->getStrSystemid(), class_logger::$levelInfo); $strGrId = generateSystemid(); $this->setSystemid($strGrId); $strQuery = "INSERT INTO " . _dbprefix_ . "user_group_ldap\r\n (group_ldap_id, group_ldap_dn, group_ldap_cfg) VALUES\r\n (?, ?, ?)"; return $this->objDB->_pQuery($strQuery, array($strGrId, $this->getStrDn(), $this->getIntCfg())); } else { class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("updated ldap group " . $this->getSystemid(), class_logger::$levelInfo); $strQuery = "UPDATE " . _dbprefix_ . "user_group_ldap\r\n SET group_ldap_dn=?, group_ldap_cfg=?\r\n WHERE group_ldap_id=?"; return $this->objDB->_pQuery($strQuery, array($this->getStrDn(), $this->getIntCfg(), $this->getSystemid())); } }
/** * Updates the current object to the database * * @param bool $strPrevId * * @return bool */ public function updateObjectToDb($strPrevId = false) { if ($this->getSystemid() == "") { $strUserid = generateSystemid(); $this->setSystemid($strUserid); $strQuery = "INSERT INTO " . _dbprefix_ . "user_ldap (\r\n user_ldap_id, \r\n user_ldap_email, user_ldap_familyname,\r\n user_ldap_givenname, user_ldap_dn, user_ldap_cfg\r\n\r\n ) VALUES (?,?,?,?,?,?)"; class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("new ldap user: "******"UPDATE " . _dbprefix_ . "user_ldap SET\r\n user_ldap_email=?, user_ldap_familyname=?, user_ldap_givenname=?, user_ldap_dn=?, user_ldap_cfg=? WHERE user_ldap_id = ?"; $arrParams = array($this->getStrEmail(), $this->getStrFamilyname(), $this->getStrGivenname(), $this->getStrDN(), $this->getIntCfg(), $this->getSystemid()); class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("updated user " . $this->getStrDN(), class_logger::$levelInfo); return $this->objDB->_pQuery($strQuery, $arrParams); } }
/** * Generates a login-log-entry * * @param int $intStatus * @param string $strOtherUsername * * @return bool * @static */ public static function generateLog($intStatus = 1, $strOtherUsername = "") { $arrParams = array(); $strQuery = "INSERT INTO " . _dbprefix_ . "user_log\n\t\t\t\t\t\t(user_log_id, user_log_userid, user_log_date, user_log_status, user_log_ip, user_log_sessid) VALUES\n\t\t\t\t\t\t(?, ?, ?, ?, ?, ?)"; $arrParams[] = generateSystemid(); if ($strOtherUsername == "") { $arrParams[] = class_carrier::getInstance()->getObjSession()->getUserID() == "" ? "0" : class_carrier::getInstance()->getObjSession()->getUserID(); } else { $arrParams[] = $strOtherUsername; } $arrParams[] = class_date::getCurrentTimestamp(); $arrParams[] = (int) $intStatus; $arrParams[] = getServer("REMOTE_ADDR"); $arrParams[] = class_carrier::getInstance()->getObjSession()->getInternalSessionId(); return class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, $arrParams); }
/** * Updates the current state to the database * * @param bool $strPrevId * * @return bool */ public function updateObjectToDb($strPrevId = false) { //new one or existing one? if ($this->getSystemid() == "") { $strSystemid = generateSystemid(); $this->setSystemid($strSystemid); } else { //remove old records $strQuery = "DELETE FROM " . _dbprefix_ . "languages_languageset WHERE languageset_id = ?"; $this->objDB->_pQuery($strQuery, array($this->getSystemid())); } class_logger::getInstance()->addLogRow("updating languageset " . $this->getSystemid(), class_logger::$levelInfo); $arrValues = array(); foreach ($this->arrLanguageSet as $strLanguage => $strSystemid) { $arrValues[] = array($this->getSystemid(), $strLanguage, $strSystemid); } return $this->objDB->multiInsert("languages_languageset", array("languageset_id", "languageset_language", "languageset_systemid"), $arrValues); }
public function testInserts() { $objDB = class_carrier::getInstance()->getObjDB(); echo "testing database...\n"; echo "current driver: " . class_carrier::getInstance()->getObjConfig()->getConfig("dbdriver") . "\n"; echo "\tcreating a new table...\n"; $arrFields = array(); $arrFields["temp_id"] = array("char20", false); $arrFields["temp_char100"] = array("char100", true); $arrFields["temp_char254"] = array("char254", true); $this->assertTrue($objDB->createTable("temp_autotest", $arrFields, array("temp_id")), "testDataBase createTable"); echo "\tcreating 50 records...\n"; $arrValues = array(); for ($intI = 1; $intI <= 50; $intI++) { $arrValues[] = array(generateSystemid(), "text long " . $intI, "text " . $intI); } $this->assertTrue($objDB->multiInsert("temp_autotest", array("temp_id", "temp_char254", "temp_char100"), $arrValues)); $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "temp_autotest", array()); $this->assertEquals($arrRow["COUNT(*)"], 50); for ($intI = 1; $intI <= 50; $intI++) { $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "temp_autotest WHERE temp_char100 = ?", array("text " . $intI)); $this->assertEquals($arrRow["COUNT(*)"], 1); $arrRow = $objDB->getPRow("SELECT * FROM " . _dbprefix_ . "temp_autotest WHERE temp_char100 = ?", array("text " . $intI)); $this->assertEquals($arrRow["temp_char254"], "text long " . $intI); } $strQuery = "DELETE FROM " . _dbprefix_ . "temp_autotest"; $this->assertTrue($objDB->_pQuery($strQuery, array()), "testDataBase truncateTable"); $objDB->flushQueryCache(); $strQuery = "SELECT COUNT(*) FROM " . _dbprefix_ . "temp_autotest"; $this->assertEquals(0, $objDB->getPRow($strQuery, array())["COUNT(*)"], "testDataBase countLimitReach"); $objDB->flushQueryCache(); echo "\tcreating 1200 records...\n"; $arrValues = array(); for ($intI = 1; $intI <= 1200; $intI++) { $arrValues[] = array(generateSystemid(), "text long " . $intI, "text " . $intI); } $this->assertTrue($objDB->multiInsert("temp_autotest", array("temp_id", "temp_char254", "temp_char100"), $arrValues)); $strQuery = "SELECT COUNT(*) FROM " . _dbprefix_ . "temp_autotest"; $this->assertEquals(1200, $objDB->getPRow($strQuery, array())["COUNT(*)"], "testDataBase countLimitReach"); $strQuery = "DROP TABLE " . _dbprefix_ . "temp_autotest"; $this->assertTrue($objDB->_pQuery($strQuery, array()), "testDataBase dropTable"); }
public function testTagAssignment() { if (class_module_system_module::getModuleByName("pages") === null) { return true; } $strName = generateSystemid(); $arrPages = class_module_pages_page::getAllPages(); if (count($arrPages) == 0) { return; } $objTag = new class_module_tags_tag(); $objTag->setStrName($strName); $objTag->updateObjectToDb(); foreach ($arrPages as $objOnePage) { $objTag->assignToSystemrecord($objOnePage->getSystemid()); break; } $arrFolder = class_module_pages_folder::getFolderList(); foreach ($arrFolder as $objOneFolder) { $objTag->assignToSystemrecord($objOneFolder->getSystemid()); break; } $this->flushDBCache(); $objTag = class_module_tags_tag::getTagByName($strName); $this->assertEquals($objTag->getIntAssignments(), 2); $arrPlainAssignments = $objTag->getListOfAssignments(); $this->assertEquals(count($arrPlainAssignments), 2); $arrAssignment = $objTag->getArrAssignedRecords(); $this->assertEquals(count($arrAssignment), 2); $this->assertTrue($arrAssignment[0] instanceof class_module_pages_page || $arrAssignment[0] instanceof class_module_pages_folder); $this->assertTrue($arrAssignment[1] instanceof class_module_pages_page || $arrAssignment[1] instanceof class_module_pages_folder); $strOldSysid = $objTag->getSystemid(); $objTag->copyObject(); $this->assertNotEquals($strOldSysid, $objTag->getSystemid()); $this->assertEquals($objTag->getStrName(), $strName . "_1"); $this->assertEquals($objTag->getIntAssignments(), 2); $arrAssignment = $objTag->getArrAssignedRecords(); $this->assertEquals(count($arrAssignment), 2); $this->assertTrue($arrAssignment[0] instanceof class_module_pages_page || $arrAssignment[0] instanceof class_module_pages_folder); $this->assertTrue($arrAssignment[1] instanceof class_module_pages_page || $arrAssignment[1] instanceof class_module_pages_folder); $objTag->deleteObjectFromDatabase(); }
public function testIndexEvent() { if (class_module_system_module::getModuleByName("tags") == null || class_module_system_module::getModuleByName("system") == null) { return; } $strSearchKey1 = generateSystemid(); $objAspect = new class_module_system_aspect(); $objAspect->setStrName($strSearchKey1); $objAspect->updateObjectToDb(); $objSearchCommons = new class_module_search_commons(); $objSearchParams = new class_module_search_search(); $objSearchParams->setStrQuery($strSearchKey1); $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null); $this->assertEquals(count($arrResult), 1); $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid()); $strSearchKey2 = generateSystemid(); $objTag = new class_module_tags_tag(); $objTag->setStrName($strSearchKey2); $objTag->updateObjectToDb(); $objSearchParams = new class_module_search_search(); $objSearchParams->setStrQuery($strSearchKey2); $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null); $this->assertEquals(count($arrResult), 1); $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid()); $objTag->assignToSystemrecord($objAspect->getStrSystemid()); $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null); $this->assertEquals(count($arrResult), 2); $objSearchParams->setStrInternalFilterModules(_system_modul_id_); $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null); $this->assertEquals(count($arrResult), 1); $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid()); $objTag->removeFromSystemrecord($objAspect->getStrSystemid()); //the aspect itself should not be found any more $objSearchParams = new class_module_search_search(); $objSearchParams->setStrQuery($strSearchKey2); $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null); $this->assertEquals(count($arrResult), 1); $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid()); $objAspect->deleteObjectFromDatabase(); $objTag->deleteObjectFromDatabase(); }
/** * The real "download" or "upload" should be handled right here. * All packages have to be downloaded to /project/temp in order to be processed afterwards. * * @return string the filename of the package downloaded */ public function processPackageUpload() { //fetch the upload, validate a few settings and copy the package to /project/temp $arrSource = class_carrier::getInstance()->getParam("provider_local_file"); $strTarget = "/project/temp/" . generateSystemid() . ".zip"; $objFilesystem = new class_filesystem(); //Check file for correct filters $strSuffix = uniStrtolower(uniSubstr($arrSource["name"], uniStrrpos($arrSource["name"], "."))); if (in_array($strSuffix, array(".zip"))) { if ($objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"])) { class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("uploaded package " . $arrSource["name"] . " to " . $strTarget, class_logger::$levelInfo); class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); class_reflection::flushCache(); return $strTarget; } } class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("error in uploaded package " . $arrSource["name"] . " either wrong format or not writeable target folder", class_logger::$levelInfo); @unlink($arrSource["tmp_name"]); return null; }
public function testQueryDatabase() { $objDB = class_carrier::getInstance()->getObjDB(); $arrFields = array(); $arrFields["temp_systemid"] = array("char40", true); $arrFields["temp_name"] = array("char254", true); $this->assertTrue($objDB->createTable("temp_propertyintest", $arrFields, array("temp_systemid")), "testDataBase createTable"); echo "\tcreating 50 records...\n"; $arrValues = array(); for ($intI = 1; $intI <= 50; $intI++) { $arrValues[] = array(generateSystemid(), "text " . $intI); } $this->assertTrue($objDB->multiInsert("temp_propertyintest", array("temp_systemid", "temp_name"), $arrValues)); $arrParams = array(); for ($intI = 1; $intI <= class_orm_objectlist_in_restriction::MAX_IN_VALUES + 10; $intI++) { $arrParams[] = generateSystemid(); } $arrParams[] = $arrValues[0][0]; $objRestriction = new class_orm_objectlist_in_restriction("temp_systemid", $arrParams); $arrResult = $objDB->getPArray("SELECT * FROM " . _dbprefix_ . "temp_propertyintest WHERE 1=1 " . $objRestriction->getStrWhere(), $objRestriction->getArrParams()); $this->assertEquals("text 1", $arrResult[0]["temp_name"]); }
/** * Adds a rating-value to the record saved in the db * * @param float $floatRating * * @return bool */ public function saveRating($floatRating) { if ($floatRating < 0 || !$this->isRateableByCurrentUser() || $floatRating > class_module_rating_rate::$intMaxRatingValue) { return false; } $floatRatingOriginal = $floatRating; $objRatingAlgo = new class_module_rating_algo_gaussian(); $floatRating = $objRatingAlgo->doRating($this, $floatRating); class_logger::getInstance()->addLogRow("updated rating of record " . $this->getSystemid() . ", added " . $floatRating, class_logger::$levelInfo); //update the values to remain consistent $this->setFloatRating($floatRating); $this->setIntHits($this->getIntHits() + 1); //save a hint in the history table //if($this->objSession->getUserID() != "") { $strInsert = "INSERT INTO " . $this->objDB->encloseTableName(_dbprefix_ . "rating_history") . "\n \t (rating_history_id, rating_history_rating, rating_history_user, rating_history_timestamp, rating_history_value) VALUES\n \t (?, ?, ?, ?, ?)"; $this->objDB->_pQuery($strInsert, array(generateSystemid(), $this->getSystemid(), $this->objSession->getUserID(), (int) time(), $floatRatingOriginal)); //} //and save it in a cookie $objCookie = new class_cookie(); $objCookie->setCookie(class_module_rating_rate::RATING_COOKIE, getCookie(class_module_rating_rate::RATING_COOKIE) . $this->getSystemid() . ","); //flush the page-cache to have all pages rendered using the correct values $this->flushCompletePagesCache(); return true; }
/** * Adds a menu-button to the second entry of the path-array. The menu renders the list of all modules installed, * including a quick-jump link. * * * @param array $arrPathEntries * @param string $strSourceModule * * @static * @internal param array $arrModuleActions * @return string */ public static function getAdminPathNavi($arrPathEntries, $strSourceModule = "") { //modify some of the entries $arrMenuEntries = array(); $arrModules = class_module_system_module::getModulesInNaviAsArray(); foreach ($arrModules as $arrOneModule) { $objModule = class_module_system_module::getModuleByName($arrOneModule["module_name"]); if (!$objModule->rightView()) { continue; } $arrCurMenuEntry = array("name" => class_carrier::getInstance()->getObjLang()->getLang("modul_titel", $arrOneModule["module_name"]), "onclick" => "location.href='" . class_link::getLinkAdminHref($arrOneModule["module_name"], "", "", false) . "'", "link" => "#"); //fetch the submenu entries if ($objModule != null) { $arrActionMenuEntries = array(); $arrModuleActions = self::getModuleActionNaviHelper($objModule); foreach ($arrModuleActions as $strOneAction) { if ($strOneAction != "") { $arrLink = splitUpLink($strOneAction); if ($arrLink["name"] != "" && $arrLink["href"] != "") { $arrActionMenuEntries[] = array("name" => $arrLink["name"], "onclick" => "location.href='" . $arrLink["href"] . "'", "link" => $arrLink["href"]); } } else { if ($strOneAction == "") { $arrActionMenuEntries[] = array("name" => ""); } } } $arrCurMenuEntry["submenu"] = $arrActionMenuEntries; } $arrMenuEntries[] = $arrCurMenuEntry; } $strModuleMenuId = generateSystemid(); $strModuleSwitcher = "\n <span class='dropdown moduleSwitch'><a href='#' data-toggle='dropdown' class='moduleSwitchLink' role='button'><i class='fa fa-home'></i></a>\n " . class_carrier::getInstance()->getObjToolkit("admin")->registerMenu($strModuleMenuId, $arrMenuEntries) . "</span>"; array_unshift($arrPathEntries, $strModuleSwitcher); return class_carrier::getInstance()->getObjToolkit("admin")->getPathNavigation($arrPathEntries); }
public function testUnreadCount() { $strText = generateSystemid() . " autotest"; $objMessageHandler = new class_module_messaging_messagehandler(); $objMessageHandler->sendMessage($strText, new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")), new class_messageprovider_exceptions()); $bitFound = false; $objGroup = new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")); $arrUsers = $objGroup->getObjSourceGroup()->getUserIdsForGroup(); $arrMessages = class_module_messaging_message::getObjectList($arrUsers[0]); $intUnread = class_module_messaging_message::getNumberOfMessagesForUser($arrUsers[0], true); $this->assertTrue($intUnread > 0); $this->flushDBCache(); foreach ($arrMessages as $objOneMessage) { if ($objOneMessage->getStrBody() == $strText && $objOneMessage->getStrMessageProvider() == "class_messageprovider_exceptions") { $bitFound = true; $objOneMessage->setBitRead(true); $objOneMessage->updateObjectToDb(); $this->assertEquals($intUnread - 1, class_module_messaging_message::getNumberOfMessagesForUser($arrUsers[0], true)); $objOneMessage->deleteObjectFromDatabase(); } } $this->assertTrue($bitFound); $this->flushDBCache(); }
/** * Tests method getWorkflowsForSystemid with newly created workflow objects */ public function test_getWorkflowsForSystemid_2() { //1 Init settings $strSystemId1 = generateSystemid(); $strSystemId2 = generateSystemid(); $arrWorkflowsClasses = array(array("class" => "class_workflow_workflows_messagesummary", "systemid" => $strSystemId1, "amount" => 5), array("class" => "class_workflow_workflows_messagesummary", "systemid" => $strSystemId2, "amount" => 5), array("class" => "class_workflow_workflows_dbdump", "systemid" => $strSystemId2, "amount" => 23)); //2. Create the workflow objects $arrCreatedWorkflows = array(); foreach ($arrWorkflowsClasses as $arrInfo) { for ($intI = 0; $intI < $arrInfo["amount"]; $intI++) { $objWorkflow = new class_module_workflows_workflow(); $objWorkflow->setStrClass($arrInfo["class"]); $objWorkflow->setStrAffectedSystemid($arrInfo["systemid"]); $objWorkflow->updateObjectToDb(); $arrCreatedWorkflows[] = $objWorkflow; } } $this->flushDBCache(); //3. Assert number of workflows foreach ($arrWorkflowsClasses as $arrInfo) { $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($arrInfo["systemid"], false, $arrInfo["class"]); $this->assertEquals(count($arrWorkflows), $arrInfo["amount"]); $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($arrInfo["systemid"], false, array($arrInfo["class"])); $this->assertEquals(count($arrWorkflows), $arrInfo["amount"]); } $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($strSystemId1, false, array("class_workflow_workflows_messagesummary")); $this->assertEquals(count($arrWorkflows), 5); $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($strSystemId2, false, array("class_workflow_workflows_dbdump", "class_workflow_workflows_messagesummary")); $this->assertEquals(count($arrWorkflows), 28); //4. Delete created workflow objects /** @var class_module_workflows_workflow $objWorkflow*/ foreach ($arrCreatedWorkflows as $objWorkflow) { $objWorkflow->deleteObjectFromDatabase(); } $this->resetCaches(); }
/** * Used to send a create table statement to the database * By passing the query through this method, the driver can * add db-specific commands. * The array of fields should have the following structure * $array[string columnName] = array(string datatype, boolean isNull [, default (only if not null)]) * whereas datatype is one of the following: * int * long * double * char10 * char20 * char100 * char254 * char500 * text * longtext * * @param string $strName * @param array $arrFields array of fields / columns * @param array $arrKeys array of primary keys * @param array $arrIndices array of additional indices * @param bool $bitTxSafe Should the table support transactions? * * @return bool */ public function createTable($strName, $arrFields, $arrKeys, $arrIndices = array(), $bitTxSafe = true) { $strQuery = ""; //loop over existing tables to check, if the table already exists $arrTables = $this->getTables(); foreach ($arrTables as $arrOneTable) { if ($arrOneTable["name"] == $strName) { return true; } } //build the oracle code $strQuery .= "CREATE TABLE " . $strName . " ( \n"; //loop the fields foreach ($arrFields as $strFieldName => $arrColumnSettings) { $strQuery .= " " . $strFieldName . " "; $strQuery .= $this->getDatatype($arrColumnSettings[0]); //any default? if (isset($arrColumnSettings[2])) { $strQuery .= "DEFAULT " . $arrColumnSettings[2] . " "; } //nullable? if ($arrColumnSettings[1] === true) { $strQuery .= " NULL "; } else { $strQuery .= " NOT NULL "; } $strQuery .= " , \n"; } //primary keys $strQuery .= " CONSTRAINT pk_" . generateSystemid() . " primary key ( " . implode(" , ", $arrKeys) . " ) \n"; $strQuery .= ") "; $bitCreate = $this->_pQuery($strQuery, array()); if ($bitCreate && count($arrIndices) > 0) { $strQuery = "CREATE INDEX ix_" . generateSystemid() . " ON " . $strName . " ( " . implode(", ", $arrIndices) . ") "; $bitCreate = $bitCreate && $this->_pQuery($strQuery, array()); } return $bitCreate; }
protected function setUp() { self::$strTestId = generateSystemid(); parent::setUp(); echo "test cache...\n"; }
/** * Generates a form to add tags to the passed systemid. * Since all functionality is performed using ajax, there's no page-reload when adding or removing tags. * Therefore the form-handling of existing forms can remain as is * * @param string $strTargetSystemid the systemid to tag * @param string $strAttribute additional info used to differ between tag-sets for a single systemid * * @return string * @permissions view */ public function getTagForm($strTargetSystemid, $strAttribute = null) { $strTagContent = ""; $strTagsWrapperId = generateSystemid(); $strTagContent .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "saveTags"), "", "", "KAJONA.admin.tags.saveTag(document.getElementById('tagname').value+'', '" . $strTargetSystemid . "', '" . $strAttribute . "');return false;"); $strTagContent .= $this->objToolkit->formTextRow($this->getLang("tag_name_hint")); $strTagContent .= $this->objToolkit->formInputTagSelector("tagname", $this->getLang("form_tags_name")); $strTagContent .= $this->objToolkit->formInputSubmit($this->getLang("button_add"), $this->getLang("button_add"), ""); $strTagContent .= $this->objToolkit->formClose(); $strTagContent .= $this->objToolkit->setBrowserFocus("tagname"); $strTagContent .= $this->objToolkit->getTaglistWrapper($strTagsWrapperId, $strTargetSystemid, $strAttribute); return $strTagContent; }
/** * Returns a list of available navigation-points * * @return string * @permissions view */ protected function actionNavigationPointBrowser() { $strReturn = ""; $this->setArrModuleEntry("template", "/folderview.tpl"); $intCounter = 1; //Load all navis $arrPoints = class_module_navigation_point::getNaviLayer($this->getSystemid()); $strReturn .= $this->objToolkit->listHeader(); $objPoint = class_objectfactory::getInstance()->getObject($this->getSystemid()); //Link one level up $strPrevID = $objPoint->getPrevId(); if ($strPrevID != $this->getObjModule()->getSystemid()) { $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "navigationPointBrowser", "&systemid=" . $strPrevID . "&form_element=" . $this->getParam("form_element"), $this->getLang("commons_one_level_up"), $this->getLang("commons_one_level_up"), "icon_treeLevelUp")); $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), "..", getImageAdmin("icon_treeRoot"), $strAction, $intCounter++); } else { $strAction = $this->objToolkit->listButton("<a href=\"#\" title=\"" . $this->getLang("navigation_point_accept") . "\" rel=\"tooltip\" onclick=\"KAJONA.admin.folderview.selectCallback([['" . $this->getParam("form_element") . "', ''],['" . $this->getParam("form_element") . "_id', '" . $this->getSystemid() . "']]);\">" . getImageAdmin("icon_accept") . "</a>"); $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), ".", getImageAdmin("icon_treeLeaf"), $strAction, $intCounter++); } if (count($arrPoints) > 0) { /** @var class_module_navigation_point $objSinglePoint */ foreach ($arrPoints as $objSinglePoint) { if ($objSinglePoint->rightView()) { $strAction = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "navigationPointBrowser", "&systemid=" . $objSinglePoint->getSystemid() . "&form_element=" . $this->getParam("form_element"), $this->getLang("navigationp_anzeigen"), $this->getLang("navigationp_anzeigen"), "icon_treeBranchOpen")); $strAction .= $this->objToolkit->listButton("<a href=\"#\" title=\"" . $this->getLang("navigation_point_accept") . "\" rel=\"tooltip\" onclick=\"KAJONA.admin.folderview.selectCallback([['" . $this->getParam("form_element") . "', '" . $objSinglePoint->getStrName() . "'],['" . $this->getParam("form_element") . "_id', '" . $objSinglePoint->getSystemid() . "']]);\">" . getImageAdmin("icon_accept") . "</a>"); $strReturn .= $this->objToolkit->simpleAdminList($objSinglePoint, $strAction, $intCounter++); } } } $strReturn .= $this->objToolkit->listFooter(); return $strReturn; }
/** * If multiple new actions are given, all buttons are merged into a new, single button. * The button itself is rendering the different buttons using a new dropdown-menu. * @param array $arrActions * @return string */ private function mergeNewEntryActions($arrActions) { if (!is_array($arrActions)) { return $arrActions; } if (is_array($arrActions) && count($arrActions) == 0) { return ""; } if (is_array($arrActions) && count($arrActions) == 1) { return $arrActions[0]; } //create a menu and merge all buttons $arrActionMenuEntries = array(); foreach ($arrActions as $strOneAction) { $strOneAction = trim($strOneAction); //search for a title attribute $arrMatches = array(); if (preg_match('/<a.*?title=(["\'])(.*?)\\1.*$/i', $strOneAction, $arrMatches)) { if (uniSubstr($strOneAction, -11) == "</a></span>") { $strOneAction = uniSubstr($strOneAction, 0, -11) . $arrMatches[2] . "</a></span>"; } else { $strOneAction .= $arrMatches[2]; } } $arrActionMenuEntries[] = array("fullentry" => $strOneAction); } return $this->objToolkit->listButton("<span class='dropdown pull-right'><a href='#' data-toggle='dropdown' role='button'>" . class_adminskin_helper::getAdminImage("icon_new_multi") . "</a>" . $this->objToolkit->registerMenu(generateSystemid(), $arrActionMenuEntries) . "</span>"); }