/**
  * Returns a list of all packages available.
  * By default a json-encoded array-like structure.
  *
  * @return string|json
  * @permissions view
  * @xml
  */
 protected function actionList()
 {
     $arrPackages = array();
     $intNrOfFiles = 0;
     $intStart = $this->ensureNumericValue($this->getParam("start"), null);
     $intEnd = $this->ensureNumericValue($this->getParam("end"), null);
     $strTypeFilter = $this->isValidCategoryFilter($this->getParam("type")) ? $this->getParam("type") : false;
     $strNameFilter = trim($this->getParam("title")) != "" ? trim($this->getParam("title")) : false;
     if ($this->isValidPagingParameter($intStart) && $this->isValidPagingParameter($intEnd)) {
         if ($intEnd >= $intStart) {
             $intNrOfFiles = $this->getAllPackagesCount(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, $strNameFilter);
             $arrDBFiles = $this->getAllPackages(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, $intStart, $intEnd, $strNameFilter);
             //error-handling: a new filter and a offset is passed. but maybe the passed offset is no longer valid for the new filter criteria
             if (count($arrDBFiles) == 0 && $intNrOfFiles > 0) {
                 $arrDBFiles = $this->getAllPackages(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, 0, $intNrOfFiles, $strNameFilter);
             }
             $objManager = new class_module_packagemanager_manager();
             foreach ($arrDBFiles as $objOneFile) {
                 try {
                     $objMetadata = $objManager->getPackageManagerForPath($objOneFile->getStrFilename());
                     $arrPackages[] = array("systemid" => $objOneFile->getSystemid(), "title" => $objMetadata->getObjMetadata()->getStrTitle(), "version" => $objMetadata->getObjMetadata()->getStrVersion(), "description" => $objMetadata->getObjMetadata()->getStrDescription(), "type" => $objMetadata->getObjMetadata()->getStrType());
                 } catch (class_exception $objEx) {
                 }
             }
             class_module_packageserver_log::generateDlLog($strNameFilter !== false ? $strNameFilter : "", isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "::1", urldecode($this->getParam("domain")));
             class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON);
         }
     }
     $result = array();
     $result['numberOfTotalItems'] = $intNrOfFiles;
     $result['items'] = $arrPackages;
     $result['protocolVersion'] = self::PROTOCOL_VERSION;
     $strReturn = json_encode($result);
     return $strReturn;
 }
 public function install()
 {
     $strReturn = "";
     $objManager = new class_orm_schemamanager();
     $strReturn .= "Installing table votings_voting...\n";
     $objManager->createTable("class_module_votings_voting");
     $strReturn .= "Installing table votings_answer...\n";
     $objManager->createTable("class_module_votings_answer");
     //register the module
     $strSystemID = $this->registerModule($this->objMetadata->getStrTitle(), _votings_module_id_, "class_module_votings_portal.php", "class_module_votings_admin.php", $this->objMetadata->getStrVersion(), true);
     //modify default rights to allow guests to vote
     $strReturn .= "Modifying modules' rights node...\n";
     class_carrier::getInstance()->getObjRights()->addGroupToRight(class_module_system_setting::getConfigValue("_guests_group_id_"), $strSystemID, "right1");
     $strReturn .= "Registering votings-element...\n";
     if (class_module_pages_element::getElement("votings") == null) {
         $objElement = new class_module_pages_element();
         $objElement->setStrName("votings");
         $objElement->setStrClassAdmin("class_element_votings_admin.php");
         $objElement->setStrClassPortal("class_element_votings_portal.php");
         $objElement->setIntCachetime(-1);
         $objElement->setIntRepeat(1);
         $objElement->setStrVersion($this->objMetadata->getStrVersion());
         $objElement->updateObjectToDb();
         $strReturn .= "Element registered...\n";
     } else {
         $strReturn .= "Element already installed!...\n";
     }
     $strReturn .= "Setting aspect assignments...\n";
     if (class_module_system_aspect::getAspectByName("content") != null) {
         $objModule = class_module_system_module::getModuleByName($this->objMetadata->getStrTitle());
         $objModule->setStrAspect(class_module_system_aspect::getAspectByName("content")->getSystemid());
         $objModule->updateObjectToDb();
     }
     return $strReturn;
 }
 /**
  * Triggered as soon as a record is updated
  *
  * @param string $strEventName
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventName, array $arrArguments)
 {
     $objRecord = $arrArguments[0];
     if ($objRecord instanceof class_module_packagemanager_template) {
         if ($objRecord->getIntRecordStatus() == 1) {
             $objOrm = new class_orm_objectlist();
             $objOrm->addWhereRestriction(new class_orm_objectlist_systemstatus_restriction(class_orm_comparator_enum::Equal(), 1));
             $arrPacks = $objOrm->getObjectList("class_module_packagemanager_template");
             foreach ($arrPacks as $objPack) {
                 if ($objPack->getSystemid() != $objRecord->getSystemid()) {
                     $objPack->setIntRecordStatus(0);
                     $objPack->updateObjectToDb();
                 }
             }
             //update the active-pack constant
             $objSetting = class_module_system_setting::getConfigByName("_packagemanager_defaulttemplate_");
             if ($objSetting !== null) {
                 $objSetting->setStrValue($objRecord->getStrName());
                 $objSetting->updateObjectToDb();
             }
             class_cache::flushCache("class_element_portal");
         }
     }
     return true;
 }
 /**
  * @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;
 }
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     $objNews = $this->getObjSourceobject();
     if ($objNews->getSystemid() != class_module_system_module::getModuleByName("news")->getSystemid()) {
         //search the languages maintained
         $objLanguageManager = class_module_languages_languageset::getLanguagesetForSystemid($objNews->getSystemid());
         if ($objLanguageManager != null) {
             $arrMaintained = $objLanguageManager->getArrLanguageSet();
             $arrDD = array();
             foreach ($arrMaintained as $strLanguageId => $strSystemid) {
                 $objLanguage = new class_module_languages_language($strLanguageId);
                 $arrDD[$strSystemid] = $this->getLang("lang_" . $objLanguage->getStrName(), "languages");
             }
             class_module_languages_admin::enableLanguageSwitch();
             class_module_languages_admin::setArrLanguageSwitchEntries($arrDD);
             class_module_languages_admin::setStrOnChangeHandler("window.location='" . class_link::getLinkAdminHref("news", "editNews") . (class_module_system_setting::getConfigValue("_system_mod_rewrite_") == "true" ? "?" : "&") . "systemid='+this.value+'&pe=" . class_carrier::getInstance()->getParam("pe") . "';");
             class_module_languages_admin::setStrActiveKey($objNews->getSystemid());
         }
     }
     $arrCats = class_module_news_category::getObjectList();
     if (count($arrCats) > 0) {
         $arrKeyValues = array();
         /** @var class_module_news_category $objOneCat */
         foreach ($arrCats as $objOneCat) {
             $arrKeyValues[$objOneCat->getSystemid()] = $objOneCat->getStrDisplayName();
         }
         $this->getField("cats")->setStrLabel($this->getLang("commons_categories"))->setArrKeyValues($arrKeyValues);
     }
     if (class_module_system_setting::getConfigValue("_news_news_datetime_") == "true") {
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateStart", $objNews), "datestart")->setBitMandatory(true)->setStrLabel($this->getLang("form_news_datestart"));
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateEnd", $objNews), "dateend")->setStrLabel($this->getLang("form_news_dateend"));
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateSpecial", $objNews), "datespecial")->setStrLabel($this->getLang("form_news_datespecial"));
     }
 }
 /**
  * Constructor to create a valid object
  *
  * @param string $strSystemid (use "" on new objects)
  */
 public function __construct($strSystemid = "")
 {
     if (class_module_system_setting::getConfigValue("_tags_defaultprivate_") == "true") {
         $this->intPrivate = 1;
     }
     parent::__construct($strSystemid);
 }
Beispiel #7
0
 /**
  * Sends the requested file to the browser
  * @return string
  */
 public function actionDownload()
 {
     //Load filedetails
     if (validateSystemid($this->getSystemid())) {
         /** @var $objFile class_module_mediamanager_file */
         $objFile = class_objectfactory::getInstance()->getObject($this->getSystemid());
         //Succeeded?
         if ($objFile instanceof class_module_mediamanager_file && $objFile->getIntRecordStatus() == "1" && $objFile->getIntType() == class_module_mediamanager_file::$INT_TYPE_FILE) {
             //Check rights
             if ($objFile->rightRight2()) {
                 //Log the download
                 class_module_mediamanager_logbook::generateDlLog($objFile);
                 //Send the data to the browser
                 $strBrowser = getServer("HTTP_USER_AGENT");
                 //Check the current browsertype
                 if (uniStrpos($strBrowser, "IE") !== false) {
                     //Internet Explorer
                     class_response_object::getInstance()->addHeader("Content-type: application/x-ms-download");
                     class_response_object::getInstance()->addHeader("Content-type: x-type/subtype\n");
                     class_response_object::getInstance()->addHeader("Content-type: application/force-download");
                     class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . preg_replace('/\\./', '%2e', saveUrlEncode(trim(basename($objFile->getStrFilename()))), substr_count(basename($objFile->getStrFilename()), '.') - 1));
                 } else {
                     //Good: another browser vendor
                     class_response_object::getInstance()->addHeader("Content-Type: application/octet-stream");
                     class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . saveUrlEncode(trim(basename($objFile->getStrFilename()))));
                 }
                 //Common headers
                 class_response_object::getInstance()->addHeader("Expires: Mon, 01 Jan 1995 00:00:00 GMT");
                 class_response_object::getInstance()->addHeader("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                 class_response_object::getInstance()->addHeader("Pragma: no-cache");
                 class_response_object::getInstance()->addHeader("Content-description: JustThum-Generated Data\n");
                 class_response_object::getInstance()->addHeader("Content-Length: " . filesize(_realpath_ . $objFile->getStrFilename()));
                 //End Session
                 $this->objSession->sessionClose();
                 class_response_object::getInstance()->sendHeaders();
                 //Loop the file
                 $ptrFile = @fopen(_realpath_ . $objFile->getStrFilename(), 'rb');
                 fpassthru($ptrFile);
                 @fclose($ptrFile);
                 ob_flush();
                 flush();
                 return "";
             } else {
                 class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_FORBIDDEN);
             }
         } else {
             class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
         }
     } else {
         class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
     }
     //if we reach up here, something gone wrong :/
     class_response_object::getInstance()->setStrRedirectUrl(str_replace(array("_indexpath_", "&amp;"), array(_indexpath_, "&"), class_link::getLinkPortalHref(class_module_system_setting::getConfigValue("_pages_errorpage_"))));
     class_response_object::getInstance()->sendHeaders();
     class_response_object::getInstance()->sendContent();
     return "";
 }
 /**
  * Renders the field itself.
  * In most cases, based on the current toolkit.
  *
  * @return string
  */
 public function renderField()
 {
     $objToolkit = class_carrier::getInstance()->getObjToolkit("admin");
     $strReturn = "";
     if ($this->getStrHint() != null) {
         $strReturn .= $objToolkit->formTextRow($this->getStrHint());
     }
     $strReturn .= $objToolkit->formInputFileSelector($this->getStrEntryName(), $this->getStrLabel(), $this->getStrValue(), class_module_system_setting::getConfigValue("_mediamanager_default_filesrepoid_"));
     return $strReturn;
 }
 public function testObjectIndexerPerformance()
 {
     if (class_module_system_module::getModuleByName("news") === null) {
         return;
     }
     $arrNewsIds = array();
     echo "Indexing without deferred indexer...\n";
     class_module_system_changelog::$bitChangelogEnabled = false;
     $intTimeStart = microtime(true);
     $intQueriesStart = class_db::getInstance()->getNumber();
     for ($intI = 0; $intI < 15; $intI++) {
         $objNews = new class_module_news_news();
         $objNews->setStrTitle("demo 1");
         $objNews->setStrIntro("intro demo news");
         $objNews->setStrText("text demo news");
         $objNews->updateObjectToDb();
         $arrNewsIds[] = $objNews->getSystemid();
     }
     echo "Queries pre indexing: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n";
     $objHandler = new class_module_search_request_endprocessinglistener();
     $objHandler->handleEvent(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, array());
     $intTimeEnd = microtime(true);
     $time = $intTimeEnd - $intTimeStart;
     echo "Object updates: ", sprintf('%f', $time), " sec.\n";
     echo "Queries total: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n";
     echo "\nIndexing with deferred indexer...\n";
     $objConfig = class_module_system_setting::getConfigByName("_search_deferred_indexer_");
     $objConfig->setStrValue("true");
     $objConfig->updateObjectToDb();
     $intTimeStart = microtime(true);
     $intQueriesStart = class_db::getInstance()->getNumber();
     for ($intI = 0; $intI < 15; $intI++) {
         $objNews = new class_module_news_news();
         $objNews->setStrTitle("demo 1");
         $objNews->setStrIntro("intro demo news");
         $objNews->setStrText("text demo news");
         $objNews->updateObjectToDb();
         $arrNewsIds[] = $objNews->getSystemid();
     }
     echo "Queries pre indexing: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n";
     echo "Triggering queue update event...\n";
     $objHandler = new class_module_search_request_endprocessinglistener();
     $objHandler->handleEvent(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, array());
     $intTimeEnd = microtime(true);
     $time = $intTimeEnd - $intTimeStart;
     echo "Object updates: ", sprintf('%f', $time), " sec.\n";
     echo "Queries total: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n";
     $objConfig = class_module_system_setting::getConfigByName("_search_deferred_indexer_");
     $objConfig->setStrValue("false");
     $objConfig->updateObjectToDb();
     foreach ($arrNewsIds as $strNewsId) {
         class_objectfactory::getInstance()->getObject($strNewsId)->deleteObjectFromDatabase();
     }
 }
 /**
  * Processes the content.
  * Make sure to return the string again, otherwise the output will remain blank.
  *
  * @param string $strContent
  *
  * @return string
  */
 public function processContent($strContent)
 {
     $arrConstants = array("_indexpath_", "_webpath_", "_system_browser_cachebuster_", "_gentime_");
     $arrValues = array(_indexpath_, _webpath_, class_module_system_setting::getConfigValue("_system_browser_cachebuster_"), date("d.m.y H:i", time()));
     $arrConstants[] = "_packagemanager_defaulttemplate_";
     $arrValues[] = class_module_system_setting::getConfigValue("_packagemanager_defaulttemplate_");
     if (defined("_skinwebpath_")) {
         $arrConstants[] = "_skinwebpath_";
         $arrValues[] = _skinwebpath_;
     }
     return str_replace($arrConstants, $arrValues, $strContent);
 }
 /**
  * Triggers the workflow engine
  *
  * @xml
  * @return string
  */
 protected function actionTrigger()
 {
     class_carrier::getInstance()->getObjSession()->setBitBlockDbUpdate(true);
     if ($this->getParam("authkey") == class_module_system_setting::getConfigValue("_workflows_trigger_authkey_")) {
         $objWorkflowController = new class_workflows_controller();
         $objWorkflowController->scheduleWorkflows();
         $objWorkflowController->runWorkflows();
         return "<message>Execution successful</message>";
     }
     class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED);
     return "<message><error>Not authorized</error></message>";
 }
 /**
  * Returns the contents of the info-block
  *
  * @return mixed
  */
 public function getArrContent()
 {
     $strOldTimezone = date_default_timezone_get();
     $objLang = class_carrier::getInstance()->getObjLang();
     $arrReturn = array();
     $arrReturn[] = array($objLang->getLang("time_phptimestamp", "system"), time());
     $arrReturn[] = array($objLang->getLang("time_systemtimezone", "system"), date_default_timezone_get());
     $arrReturn[] = array($objLang->getLang("time_localsystemtime", "system"), timeToString(time()));
     date_default_timezone_set("UTC");
     $arrReturn[] = array($objLang->getLang("time_systemtime_UTC", "system"), date('Y-m-d H:i:s'));
     $arrReturn[] = array($objLang->getLang("time_systemzone_manual_setting", "system"), class_module_system_setting::getConfigValue("_system_timezone_"));
     date_default_timezone_set($strOldTimezone);
     return $arrReturn;
 }
 /**
  * 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)
 {
     $strReturn .= "Removing settings...\n";
     if (class_module_system_setting::getConfigByName("_tags_defaultprivate_") != null) {
         class_module_system_setting::getConfigByName("_tags_defaultprivate_")->deleteObjectFromDatabase();
     }
     //delete the page-element
     if (class_module_system_module::getModuleByName("pages") !== null && class_module_pages_element::getElement("tags") != null) {
         $objElement = class_module_pages_element::getElement("tags");
         if ($objElement != null) {
             $strReturn .= "Deleting page-element 'tags'...\n";
             $objElement->deleteObjectFromDatabase();
         } else {
             $strReturn .= "Error finding page-element 'guestbook', tags.\n";
             return false;
         }
     }
     /** @var class_module_tags_favorite $objOneObject */
     foreach (class_module_tags_favorite::getObjectList() as $objOneObject) {
         $strReturn .= "Deleting object '" . $objOneObject->getStrDisplayName() . "' ...\n";
         if (!$objOneObject->deleteObjectFromDatabase()) {
             $strReturn .= "Error deleting object, aborting.\n";
             return false;
         }
     }
     /** @var class_module_tags_tag $objOneObject */
     foreach (class_module_tags_tag::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("tags_tag", "tags_member", "tags_favorite") 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;
 }
 /**
  * @see interface_admin_systemtask::executeTask()
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("system")->rightRight2()) {
         return $this->getLang("commons_error_permissions");
     }
     //increase the cachebuster, so browsers are forced to reload JS and CSS files
     $objCachebuster = class_module_system_setting::getConfigByName("_system_browser_cachebuster_");
     $objCachebuster->setStrValue((int) $objCachebuster->getStrValue() + 1);
     $objCachebuster->updateObjectToDb();
     if (class_cache::flushCache($this->getParam("cacheSource"))) {
         return $this->objToolkit->getTextRow($this->getLang("systemtask_flushcache_success"));
     } else {
         return $this->objToolkit->getTextRow($this->getLang("systemtask_flushcache_error"));
     }
 }
 /**
  * Generic list of all packages available on the local filesystem
  * @return string
  * @permissions view
  * @autoTestable
  */
 protected function actionOpenFolder()
 {
     if (validateSystemid(class_module_system_setting::getConfigValue("_packageserver_repo_id_"))) {
         if ($this->getSystemid() == "") {
             $this->setSystemid(class_module_system_setting::getConfigValue("_packageserver_repo_id_"));
         }
         $objIterator = new class_array_section_iterator(class_module_mediamanager_file::getFileCount($this->getSystemid(), false, false, true));
         $objIterator->setPageNumber($this->getParam("pv"));
         $objIterator->setArraySection(class_module_mediamanager_file::loadFilesDB($this->getSystemid(), false, false, $objIterator->calculateStartPos(), $objIterator->calculateEndPos(), true));
     } else {
         $objIterator = new class_array_section_iterator(class_module_mediamanager_file::getFlatPackageListCount(false, false));
         $objIterator->setPageNumber($this->getParam("pv"));
         $objIterator->setArraySection(class_module_mediamanager_file::getFlatPackageList(false, false, $objIterator->calculateStartPos(), $objIterator->calculateEndPos()));
     }
     return $this->renderList($objIterator);
 }
 /**
  * Does the hard work: installs the module and registers needed constants
  *
  * @return string
  */
 public function install()
 {
     $strReturn = "";
     $strReturn .= "Creating picture upload folder\n";
     if (!is_dir(_realpath_ . _filespath_ . "/images/upload")) {
         mkdir(_realpath_ . _filespath_ . "/images/upload", 0777, true);
     }
     $strReturn .= "Creating new picture repository\n";
     $objRepo = new class_module_mediamanager_repo();
     if ($this->strContentLanguage == "de") {
         $objRepo->setStrTitle("Hochgeladene Bilder");
     } else {
         $objRepo->setStrTitle("Picture uploads");
     }
     $objRepo->setStrPath(_filespath_ . "/images/upload");
     $objRepo->setStrUploadFilter(".jpg,.png,.gif,.jpeg");
     $objRepo->setStrViewFilter(".jpg,.png,.gif,.jpeg");
     $objRepo->updateObjectToDb();
     $objRepo->syncRepo();
     $strReturn .= "ID of new repo: " . $objRepo->getSystemid() . "\n";
     $strReturn .= "Setting the repository as the default images repository\n";
     $objSetting = class_module_system_setting::getConfigByName("_mediamanager_default_imagesrepoid_");
     $objSetting->setStrValue($objRepo->getSystemid());
     $objSetting->updateObjectToDb();
     $strReturn .= "Creating file upload folder\n";
     if (!is_dir(_realpath_ . _filespath_ . "/public")) {
         mkdir(_realpath_ . _filespath_ . "/public", 0777, true);
     }
     $strReturn .= "Creating new file repository\n";
     $objRepo = new class_module_mediamanager_repo();
     if ($this->strContentLanguage == "de") {
         $objRepo->setStrTitle("Hochgeladene Dateien");
     } else {
         $objRepo->setStrTitle("File uploads");
     }
     $objRepo->setStrPath(_filespath_ . "/downloads");
     $objRepo->setStrUploadFilter(".zip,.pdf,.txt");
     $objRepo->setStrViewFilter(".zip,.pdf,.txt");
     $objRepo->updateObjectToDb();
     $objRepo->syncRepo();
     $strReturn .= "ID of new repo: " . $objRepo->getSystemid() . "\n";
     $strReturn .= "Setting the repository as the default files repository\n";
     $objSetting = class_module_system_setting::getConfigByName("_mediamanager_default_filesrepoid_");
     $objSetting->setStrValue($objRepo->getSystemid());
     $objSetting->updateObjectToDb();
     return $strReturn;
 }
 /**
  * Creates a graph-instance either based on the current config or
  * based on the passed param
  *
  * @param string $strType
  *
  * @throws class_exception
  * @return interface_graph
  */
 public static function getGraphInstance($strType = "")
 {
     if ($strType == "") {
         if (class_module_system_setting::getConfigValue("_system_graph_type_") != "") {
             $strType = class_module_system_setting::getConfigValue("_system_graph_type_");
         } else {
             $strType = "jqplot";
         }
     }
     $strClassname = "class_graph_" . $strType;
     $strPath = class_resourceloader::getInstance()->getPathForFile("/system/" . $strClassname . ".php");
     if ($strPath !== false) {
         $objReflection = new ReflectionClass($strClassname);
         if (!$objReflection->isAbstract() && $objReflection->implementsInterface("interface_graph")) {
             return $objReflection->newInstance();
         }
     }
     throw new class_exception("Requested charts-plugin " . $strType . " not existing", class_exception::$level_FATALERROR);
 }
 /**
  * @param string $strEventName
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventName, array $arrArguments)
 {
     if (count(self::$arrToDelete) == 0 && count(self::$arrToIndex) == 0) {
         return true;
     }
     //clean and reduce arrays to avoid logical duplicates
     foreach (self::$arrToDelete as $strOneId => $strObject) {
         if (isset(self::$arrToIndex[$strOneId])) {
             unset(self::$arrToIndex[$strOneId]);
         }
     }
     $strConfigValue = class_module_system_setting::getConfigValue("_search_deferred_indexer_");
     if ($strConfigValue !== null && $strConfigValue == "true") {
         $this->processDeferred();
     } else {
         $this->processDirectly();
     }
     self::$arrToDelete = array();
     self::$arrToIndex = array();
     return true;
 }
 /**
  * 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)
 {
     $strReturn .= "Deleting config-entries..\n";
     class_module_system_setting::getConfigByName("_packageserver_repo_id_")->deleteObjectFromDatabase();
     //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("packageserver_log") 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;
 }
 /**
  * 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)
 {
     $strReturn .= "Removing system settings...\n";
     if (class_module_system_setting::getConfigByName("_workflows_trigger_authkey_") != null) {
         class_module_system_setting::getConfigByName("_workflows_trigger_authkey_")->deleteObjectFromDatabase();
     }
     /** @var class_module_workflows_workflow $objOneObject */
     foreach (class_module_workflows_workflow::getObjectList() as $objOneObject) {
         $strReturn .= "Deleting object '" . $objOneObject->getStrDisplayName() . "' ...\n";
         if (!$objOneObject->deleteObjectFromDatabase()) {
             $strReturn .= "Error deleting object, aborting.\n";
             return false;
         }
     }
     /** @var class_module_workflows_handler $objOneObject */
     foreach (class_module_workflows_handler::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("workflows_handler", "workflows") 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;
 }
 /**
  * Copies the extracted(!) package from the temp-folder
  * to the target-folder.
  * In most cases, this is either located at /core or at /templates.
  * The original should be deleted afterwards.
  *
  * @throws class_exception
  * @return void
  */
 public function move2Filesystem()
 {
     $strSource = $this->objMetadata->getStrPath();
     if (!is_dir(_realpath_ . $strSource)) {
         throw new class_exception("current package " . $strSource . " is not a folder.", class_exception::$level_ERROR);
     }
     class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("moving " . $strSource . " to " . $this->getStrTargetPath(), class_logger::$levelInfo);
     $objFilesystem = new class_filesystem();
     //set a chmod before copying the files - at least try to
     $objFilesystem->chmod($this->getStrTargetPath(), 0777);
     $objFilesystem->folderCopyRecursive($strSource, $this->getStrTargetPath(), true);
     $this->objMetadata->setStrPath($this->getStrTargetPath());
     //reset chmod after copying the files
     $objFilesystem->chmod($this->getStrTargetPath());
     $objFilesystem->folderDeleteRecursive($strSource);
     //shift the cache buster
     $objSetting = class_module_system_setting::getConfigByName("_system_browser_cachebuster_");
     if ($objSetting != null) {
         $objSetting->setStrValue((int) $objSetting->getStrValue() + 1);
         $objSetting->updateObjectToDb();
     }
 }
 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();
 }
 /**
  * Saves the rights passed by form
  *
  * @throws class_exception
  * @return string "" in case of success
  * @permissions right
  * @xml
  */
 protected function actionSaveRights()
 {
     class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON);
     $arrRequest = json_decode($this->getParam("json"));
     //Collecting & sorting the passed values
     $strSystemid = $this->getSystemid();
     $objRights = class_carrier::getInstance()->getObjRights();
     if ($this->getParam("systemid") == "0") {
         $objTarget = new class_module_system_common("0");
         $objTarget->setStrSystemid("0");
         $strSystemid = "0";
     } else {
         $objTarget = class_objectfactory::getInstance()->getObject($this->getSystemid());
     }
     //Special case: The root-record.
     if (!$objTarget->rightRight()) {
         return $this->objToolkit->warningBox($this->getLang("commons_error_permissions"), "alert-danger");
     }
     //Inheritance?
     if ($arrRequest->bitInherited) {
         $intInherit = 1;
     } else {
         $intInherit = 0;
     }
     //Modified RootRecord? Here Inheritance is NOT allowed!
     if ($strSystemid == "0") {
         $intInherit = 0;
     }
     $strAdminsGroupId = class_module_system_setting::getConfigValue("_admins_group_id_");
     $strView = $strAdminsGroupId;
     $strEdit = $strAdminsGroupId;
     $strDelete = $strAdminsGroupId;
     $strRight = $strAdminsGroupId;
     $strRight1 = $strAdminsGroupId;
     $strRight2 = $strAdminsGroupId;
     $strRight3 = $strAdminsGroupId;
     $strRight4 = $strAdminsGroupId;
     $strRight5 = $strAdminsGroupId;
     $strChangelog = $strAdminsGroupId;
     foreach ($arrRequest->arrConfigs as $strOneCfg) {
         $arrRow = explode(",", $strOneCfg);
         if ($arrRow[1] == $strAdminsGroupId) {
             continue;
         }
         switch ($arrRow[0]) {
             case "1":
                 $strView .= "," . $arrRow[1];
                 break;
             case "2":
                 $strEdit .= "," . $arrRow[1];
                 break;
             case "3":
                 $strDelete .= "," . $arrRow[1];
                 break;
             case "4":
                 $strRight .= "," . $arrRow[1];
                 break;
             case "5":
                 $strRight1 .= "," . $arrRow[1];
                 break;
             case "6":
                 $strRight2 .= "," . $arrRow[1];
                 break;
             case "7":
                 $strRight3 .= "," . $arrRow[1];
                 break;
             case "8":
                 $strRight4 .= "," . $arrRow[1];
                 break;
             case "9":
                 $strRight5 .= "," . $arrRow[1];
                 break;
             case "10":
                 $strChangelog .= "," . $arrRow[1];
                 break;
         }
     }
     $arrReturn = array("inherit" => $intInherit, "view" => $strView, "edit" => $strEdit, "delete" => $strDelete, "right" => $strRight, "right1" => $strRight1, "right2" => $strRight2, "right3" => $strRight3, "right4" => $strRight4, "right5" => $strRight5, "changelog" => $strChangelog);
     //Pass to right-class
     if ($objRights->setRights($arrReturn, $strSystemid)) {
         $strReturn = $this->objToolkit->warningBox($this->getLang("permissions_success"), "alert-success");
     } else {
         $strReturn = $this->objToolkit->warningBox($this->getLang("fehler_setzen"), "alert-danger");
     }
     return json_encode(array("message" => $strReturn));
 }
 /**
  * Renders the button to open the records' change history. In most cases, this is done in a overlay.
  * To open the change-history, the permission "right3" on the system-module is required.
  *
  * @param class_model|interface_model $objListEntry
  *
  * @return string
  */
 protected function renderChangeHistoryAction(class_model $objListEntry)
 {
     if (class_module_system_setting::getConfigValue("_system_changehistory_enabled_") == "true" && $objListEntry instanceof interface_versionable && $objListEntry->rightChangelog()) {
         return $this->objToolkit->listButton(class_link::getLinkAdminDialog("system", "genericChangelog", "&systemid=" . $objListEntry->getSystemid() . "&folderview=1", $this->getLang("commons_edit_history"), $this->getLang("commons_edit_history"), "icon_history", $objListEntry->getStrDisplayName()));
     }
     return "";
 }
 /**
  * @param interface_model|class_root $objListEntry
  *
  * @return string
  */
 protected function renderDeleteAction(interface_model $objListEntry)
 {
     if ($objListEntry->rightDelete() && $this->getObjModule()->rightDelete()) {
         if (class_module_system_setting::getConfigValue("_packagemanager_defaulttemplate_") == $objListEntry->getStrName()) {
             return $this->objToolkit->listButton(class_adminskin_helper::getAdminImage("icon_deleteDisabled", $this->getLang("pack_active_no_delete")));
         } else {
             return $this->objToolkit->listDeleteButton($objListEntry->getStrDisplayName(), $this->getLang("delete_question"), class_link::getLinkAdminHref($this->getArrModule("modul"), "deleteTemplate", "&systemid=" . $objListEntry->getSystemid() . ""));
         }
     }
     return "";
 }
Beispiel #26
0
echo "+-------------------------------------------------------------------------------+\n";
echo "| Kajona Debug Subsystem                                                        |\n";
echo "|                                                                               |\n";
echo "| Delete all tables                                                             |\n";
echo "|                                                                               |\n";
echo "+-------------------------------------------------------------------------------+\n";
if (issetPost("dodelete")) {
    $strUsername = getPost("username");
    $strPassword = getPost("password");
    $objUsersource = new class_module_user_sourcefactory();
    $objUser = $objUsersource->getUserByUsername($strUsername);
    echo "Authenticating user...\n";
    if ($objUsersource->authenticateUser($strUsername, $strPassword)) {
        echo " ... authenticated.\n";
        $arrGroupIds = $objUser->getArrGroupIds();
        if (in_array(class_module_system_setting::getConfigValue("_admins_group_id_"), $arrGroupIds)) {
            echo "User is member of admin-group.\n";
            $arrTables = class_carrier::getInstance()->getObjDB()->getTables();
            foreach ($arrTables as $strOneTable) {
                $strQuery = "DROP TABLE " . $strOneTable;
                echo " executing " . $strQuery . "\n";
                class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array());
            }
        } else {
            echo "User is not a member of the admin-group!\n";
        }
    } else {
        echo "Authentication failed!\n";
    }
} else {
    $arrTables = class_carrier::getInstance()->getObjDB()->getTables();
Beispiel #27
0
<?php

/*"******************************************************************************************************
*   (c) 2007-2015 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id$                                         *
********************************************************************************************************/
/*
 * This files specified a list of "excluded groups".
 * All group-ids specified are non-editable while editing group assignments.
 * This may be used to block privilege escalations in special scenarios.
 * The groups are removed from the assignment-table unless you are a super-admin.
 *
 * Provide a comma-separated list of group-ids.
 */
$config["blockedgroups"] = "" . class_module_system_setting::getConfigValue("_admins_group_id_");
 /**
  * Does the hard work: installs the module and registers needed constants
  *
  * @return string
  */
 public function install()
 {
     $strReturn = "";
     if (class_module_system_module::getModuleByName("mediamanager") == null) {
         return "Mediamanger not installed, skipping element\n";
     }
     //fetch navifolder-id
     $strNaviFolderId = "";
     $arrFolder = class_module_pages_folder::getFolderList();
     foreach ($arrFolder as $objOneFolder) {
         if ($objOneFolder->getStrName() == "mainnavigation") {
             $strNaviFolderId = $objOneFolder->getSystemid();
         }
     }
     $strReturn .= "Creating new downloads...\n";
     $objDownloads = new class_module_mediamanager_repo();
     $objDownloads->setStrTitle("Sample downloads");
     $objDownloads->setStrPath("/files/downloads");
     $objDownloads->updateObjectToDb();
     $strDownloadsID = $objDownloads->getSystemid();
     $objDownloads->syncRepo();
     $strReturn .= "Adding download-permissions for guests...\n";
     class_carrier::getInstance()->getObjRights()->addGroupToRight(class_module_system_setting::getConfigValue("_guests_group_id_"), $objDownloads->getSystemid(), "right2");
     $strReturn .= "Adding rating-permissions for guests...\n";
     class_carrier::getInstance()->getObjRights()->addGroupToRight(class_module_system_setting::getConfigValue("_guests_group_id_"), $objDownloads->getSystemid(), "right3");
     $strReturn .= "Creating new downloads page...\n";
     $objPage = new class_module_pages_page();
     $objPage->setStrName("downloads");
     $objPage->setStrBrowsername("Downloads");
     $objPage->setStrTemplate("standard.tpl");
     $objPage->updateObjectToDb($strNaviFolderId);
     $strDownloadsPageId = $objPage->getSystemid();
     $strReturn .= "ID of new page: " . $strDownloadsPageId . "\n";
     $strReturn .= "Adding pagelement to new page\n";
     $objPagelement = new class_module_pages_pageelement();
     if (class_module_pages_element::getElement("downloads") != null) {
         $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("downloads");
         $objPagelement->updateObjectToDb($strDownloadsPageId);
         $strElementId = $objPagelement->getSystemid();
         $strQuery = "UPDATE " . _dbprefix_ . "element_downloads\n                            SET download_id = ?,\n                                download_template = ?\n                            WHERE content_id = ? ";
         if ($this->objDB->_pQuery($strQuery, array($strDownloadsID, "downloads.tpl", $strElementId))) {
             $strReturn .= "downloads element created.\n";
         } else {
             $strReturn .= "Error creating downloads element.\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($strDownloadsPageId);
         $strElementId = $objPagelement->getSystemid();
         $strQuery = "UPDATE " . _dbprefix_ . "element_paragraph\n                                SET paragraph_title = ?\n                                WHERE content_id = ?";
         if ($this->objDB->_pQuery($strQuery, array("Downloads", $strElementId))) {
             $strReturn .= "Headline element created.\n";
         } else {
             $strReturn .= "Error creating headline element.\n";
         }
     }
     return $strReturn;
 }
 /**
  * Updates the current object to the database.
  * Only the value is updated!!!
  *
  * @param bool $strPrevId
  *
  * @return bool
  */
 public function updateObjectToDb($strPrevId = false)
 {
     $objChangelog = new class_module_system_changelog();
     $objChangelog->createLogEntry($this, class_module_system_changelog::$STR_ACTION_EDIT);
     self::$arrInstanceCache = null;
     if (!class_module_system_setting::checkConfigExisting($this->getStrName())) {
         class_logger::getInstance()->addLogRow("new constant " . $this->getStrName() . " with value " . $this->getStrValue(), class_logger::$levelInfo);
         $strQuery = "INSERT INTO " . _dbprefix_ . "system_config\n                        (system_config_id, system_config_name, system_config_value, system_config_type, system_config_module) VALUES\n                        (?, ?, ?, ?, ?)";
         return $this->objDB->_pQuery($strQuery, array(generateSystemid(), $this->getStrName(), $this->getStrValue(), (int) $this->getIntType(), (int) $this->getIntModule()));
     } else {
         class_logger::getInstance()->addLogRow("updated constant " . $this->getStrName() . " to value " . $this->getStrValue(), class_logger::$levelInfo);
         $strQuery = "UPDATE " . _dbprefix_ . "system_config\n                        SET system_config_value = ?\n                      WHERE system_config_name = ?";
         return $this->objDB->_pQuery($strQuery, array($this->getStrValue(), $this->getStrName()));
     }
 }
Beispiel #30
0
 /**
  * Checks if a given user-id is granted the passed permission for the passed systemid.
  *
  * @param string $strUserid
  * @param string $strPermission
  * @param string $strSystemid
  *
  * @return bool
  */
 public function checkPermissionForUserId($strUserid, $strPermission, $strSystemid)
 {
     if ($strSystemid == "") {
         return false;
     }
     if ($this->bitTestMode) {
         return true;
     }
     $arrGroupIds = array();
     if (validateSystemid($strUserid)) {
         if ($strUserid == $this->objSession->getUserID()) {
             $arrGroupIds = $this->objSession->getGroupIdsAsArray();
         } else {
             $objUser = new class_module_user_user($strUserid);
             $arrGroupIds = $objUser->getArrGroupIds();
         }
     } else {
         if (validateSystemid($this->objSession->getUserID())) {
             $arrGroupIds = $this->objSession->getGroupIdsAsArray();
         } else {
             $arrGroupIds[] = class_module_system_setting::getConfigValue("_guests_group_id_");
         }
     }
     foreach ($arrGroupIds as $strOneGroupId) {
         if ($this->checkPermissionForGroup($strOneGroupId, $strPermission, $strSystemid)) {
             return true;
         }
     }
     return false;
 }