/** * Triggers the "real" creation of the report and wraps the code inline into a xml-structure * * @return string * @permissions view */ protected function actionGetReport() { $strPlugin = $this->getParam("plugin"); $strReturn = ""; $objPluginManager = new class_pluginmanager(class_module_stats_admin::$STR_PLUGIN_EXTENSION_POINT, "/admin/statsreports"); $objPlugin = null; foreach ($objPluginManager->getPlugins(array(class_carrier::getInstance()->getObjDB(), $this->objToolkit, $this->getObjLang())) as $objOneReport) { if (uniStrReplace("class_stats_report_", "", get_class($objOneReport)) == $strPlugin) { $objPlugin = $objOneReport; break; } } if ($objPlugin !== null && $objPlugin instanceof interface_admin_statsreports) { //get date-params as ints $intStartDate = mktime(0, 0, 0, $this->objDateStart->getIntMonth(), $this->objDateStart->getIntDay(), $this->objDateStart->getIntYear()); $intEndDate = mktime(0, 0, 0, $this->objDateEnd->getIntMonth(), $this->objDateEnd->getIntDay(), $this->objDateEnd->getIntYear()); $objPlugin->setEndDate($intEndDate); $objPlugin->setStartDate($intStartDate); $objPlugin->setInterval($this->intInterval); $arrImage = $objPlugin->getReportGraph(); if (!is_array($arrImage)) { $arrImage = array($arrImage); } foreach ($arrImage as $strImage) { if ($strImage != "") { $strReturn .= $this->objToolkit->getGraphContainer($strImage); } } $strReturn .= $objPlugin->getReport(); $strReturn = "<content><![CDATA[" . $strReturn . "]]></content>"; } return $strReturn; }
/** * Creates the list of events available * * @return string * @permissions view */ protected function actionList() { $strReturn = ""; $strEvents = ""; //switch between calendar and list-modes if ($this->arrElementData["int2"] == "0") { //calendar mode $strWrapperID = $this->objTemplate->readTemplate("/module_eventmanager/" . $this->arrElementData["char1"], "event_calendar"); $arrTemplate = array(); $arrTemplate["cal_eventsource"] = _xmlpath_ . "?module=eventmanager&action=getJsonEvents&page=" . $this->getPagename(); $arrTemplate["rssurl"] = _xmlpath_ . "?module=eventmanager&action=eventRssFeed&page=" . $this->getPagename(); $strReturn .= $this->objTemplate->fillTemplate($arrTemplate, $strWrapperID); } else { //list based mode $objFilterStartDate = null; $objFilterEndDate = null; $intFilterStatus = $this->getParam("event_filter_status") != "" ? htmlspecialchars($this->getParam("event_filter_status"), ENT_QUOTES, "UTF-8", false) : null; if ($this->getParam("event_filter_date_from") != "") { $objDateTime = DateTime::createFromFormat("Y-m-d", $this->getParam("event_filter_date_from")); $objFilterStartDate = new class_date(); $objFilterStartDate->setTimeInOldStyle($objDateTime->getTimestamp()); } if ($this->getParam("event_filter_date_to") != "") { $objDateTime = DateTime::createFromFormat("Y-m-d", $this->getParam("event_filter_date_to")); $objFilterEndDate = new class_date(); $objFilterEndDate->setTimeInOldStyle($objDateTime->getTimestamp()); } $arrEvents = class_module_eventmanager_event::getAllEvents(false, false, $objFilterStartDate, $objFilterEndDate, true, $this->arrElementData["int1"], $intFilterStatus); foreach ($arrEvents as $objOneEvent) { if ($objOneEvent->rightView()) { $objMapper = new class_template_mapper($objOneEvent); //legacy support $objMapper->addPlaceholder("dateTimeFrom", dateToString($objOneEvent->getObjStartDate(), true)); $objMapper->addPlaceholder("dateFrom", dateToString($objOneEvent->getObjStartDate(), false)); $objMapper->addPlaceholder("dateTimeUntil", dateToString($objOneEvent->getObjEndDate(), true)); $objMapper->addPlaceholder("dateUntil", dateToString($objOneEvent->getObjEndDate(), false)); $objMapper->addPlaceholder("title", $objOneEvent->getStrTitle()); $objMapper->addPlaceholder("description", $objOneEvent->getStrDescription()); $objMapper->addPlaceholder("location", $objOneEvent->getStrLocation()); $objMapper->addPlaceholder("eventStatus", $objOneEvent->getIntEventStatus()); $objMapper->addPlaceholder("systemid", $objOneEvent->getSystemid()); $objMapper->addPlaceholder("detailsLinkHref", class_link::getLinkPortalHref($this->getPagename(), "", "eventDetails", "", $objOneEvent->getSystemid(), "", $objOneEvent->getStrTitle())); if ($objOneEvent->getIntRegistrationRequired() == "1" && $objOneEvent->rightRight1()) { $objMapper->addPlaceholder("registerLinkHref", class_link::getLinkPortalHref($this->getPagename(), "", "registerForEvent", "", $objOneEvent->getSystemid(), "", $objOneEvent->getStrTitle())); $objMapper->addPlaceholder("registerLink", $objMapper->writeToTemplate("/module_eventmanager/" . $this->arrElementData["char1"], "event_details_registerlink")); } $strEvents .= $objMapper->writeToTemplate("/module_eventmanager/" . $this->arrElementData["char1"], "event_list_entry"); } } $strRssUrl = _xmlpath_ . "?module=eventmanager&action=eventRssFeed&page=" . $this->getPagename(); $arrListTemplate = array("events" => $strEvents, "rssurl" => $strRssUrl, "formaction" => class_link::getLinkPortalHref($this->getPagename()), "event_filter_status" => $intFilterStatus != null ? $intFilterStatus : "", "event_filter_date_from" => $objFilterStartDate != null ? htmlspecialchars($this->getParam("event_filter_date_from"), ENT_QUOTES, "UTF-8", false) : "", "event_filter_date_to" => $objFilterEndDate != null ? htmlspecialchars($this->getParam("event_filter_date_to"), ENT_QUOTES, "UTF-8", false) : ""); $strWrapperID = $this->objTemplate->readTemplate("/module_eventmanager/" . $this->arrElementData["char1"], "event_list"); $strReturn .= $this->objTemplate->fillTemplate($arrListTemplate, $strWrapperID); } return $strReturn; }
public function validateValue() { $objDate = new class_date("0"); $arrParams = class_carrier::getAllParams(); if (array_key_exists($this->getStrEntryName(), $arrParams)) { $objDate->generateDateFromParams($this->getStrEntryName(), $arrParams); } else { $objDate = new class_date($this->getStrValue()); } return $this->getObjValidator()->validate($objDate); }
/** * Compares two dates of type class_date. * * @param class_date $objDateLeft * @param class_date $objDateRight * * @return int * 0, if the dates are equal * 1, if $objDateLeft is greater than $objDateRight * -1, if $objDateLeft is less than $objDateRight * null, if $objDateLeft or $objDateRight are null (then no comparison is possible) */ public static function compareDates(class_date $objDateLeft = null, class_date $objDateRight = null) { if ($objDateLeft != null && $objDateRight != null) { if ($objDateLeft->getLongTimestamp() < $objDateRight->getLongTimestamp()) { return -1; //less; } if ($objDateLeft->getLongTimestamp() > $objDateRight->getLongTimestamp()) { return 1; //greater } else { return 0; //equals } } return null; }
public function testReports() { if (!defined("_skinwebpath_")) { define("_skinwebpath_", "1"); } echo "processing reports...\n"; $arrReportsInFs = class_resourceloader::getInstance()->getFolderContent("/admin/statsreports", array(".php"), false, function ($strOneFile) { if (uniStripos($strOneFile, "class_stats_report") === false) { return false; } return true; }, function (&$strOneFile) { $strOneFile = uniSubstr($strOneFile, 0, -4); $strOneFile = new $strOneFile(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang()); }); $arrReports = array(); foreach ($arrReportsInFs as $objReport) { if ($objReport instanceof interface_admin_statsreports) { $arrReports[$objReport->getTitle()] = $objReport; } $objStartDate = new class_date(); $objStartDate->setPreviousDay(); $objEndDate = new class_date(); $objEndDate->setNextDay(); $intStartDate = mktime(0, 0, 0, $objStartDate->getIntMonth(), $objStartDate->getIntDay(), $objStartDate->getIntYear()); $intEndDate = mktime(0, 0, 0, $objEndDate->getIntMonth(), $objEndDate->getIntDay(), $objEndDate->getIntYear()); $objReport->setEndDate($intEndDate); $objReport->setStartDate($intStartDate); $objReport->setInterval(2); } /** @var interface_admin_statsreports $objReport */ foreach ($arrReports as $objReport) { ob_start(); echo "processing report " . $objReport->getTitle() . "\n"; $objReport->getReport(); $objReport->getReportGraph(); } }
/** * Adds metadata-query parts to the statement to be generated * * @param string &$strQuery * @param string[] &$arrParams * @return void */ public function getQuery(&$strQuery, &$arrParams) { //add the module filter if (count($this->arrFilterModules) > 0) { $strIn = ""; foreach ($this->arrFilterModules as $intModuleId) { $arrParams[] = $intModuleId; $strIn .= "?,"; } $strIn = substr($strIn, 0, -1); $strQuery .= " AND system_module_nr in (" . $strIn . ") "; } //add the user filter if (!empty($this->strFilterUser)) { $strQuery .= " AND system_owner = ? "; $arrParams[] = $this->strFilterUser; } //add the class filter if (count($this->arrFilterClasses) > 0) { $strIn = ""; foreach ($this->arrFilterClasses as $strOneClass) { $arrParams[] = $strOneClass; $strIn .= "?,"; } $strIn = substr($strIn, 0, -1); $strQuery .= " AND system_class in (" . $strIn . ") "; } //add the start-date filter if ($this->objFilterChangeStartDate !== null) { $strQuery .= "AND system_lm_time >= ? "; $arrParams[] = $this->objFilterChangeStartDate->getTimeInOldStyle(); } //add the end-date filter if ($this->objFilterChangeEndDate !== null) { $strQuery .= "AND system_lm_time <= ? "; $arrParams[] = $this->objFilterChangeEndDate->getTimeInOldStyle(); } if ($this->getBitPortalSearch()) { $strQuery .= " AND D.search_ix_portal_object = 1 "; $strQuery .= " AND system_status = 1 "; } if ($this->getStrPortalLang() != "") { $strQuery .= " AND ( D.search_ix_content_lang IS NULL OR D.search_ix_content_lang ='' OR D.search_ix_content_lang = ? )"; $arrParams[] = $this->getStrPortalLang(); } }
/** * Creates int-values of the passed date-values */ private function processDates() { if ($this->getParam("filter") == "true") { $this->objDateStart = new class_date(); $this->objDateStart->generateDateFromParams("start", $this->getAllParams()); $this->objDateEnd = new class_date(); $this->objDateEnd->generateDateFromParams("end", $this->getAllParams()); class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_DATE_START, $this->objDateStart->getTimeInOldStyle()); class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_DATE_END, $this->objDateEnd->getTimeInOldStyle()); if ($this->getParam("interval") != "") { $this->intInterval = (int) $this->getParam("interval"); } else { $this->intInterval = 2; } class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_INTERVAL, $this->intInterval); } }
/** * Responsible for creating the xml-feed * * @param string $strTitle * @param string $strLink * @param string $strDesc * @param string $strPage * @param class_module_news_news[] $arrNews * * @return string */ private function createNewsfeedXML($strTitle, $strLink, $strDesc, $strPage, $arrNews) { $objFeed = new class_rssfeed(); $objFeed->setStrTitle($strTitle); $objFeed->setStrLink($strLink); $objFeed->setStrDesc($strDesc); foreach ($arrNews as $objOneNews) { if ($objOneNews->rightView()) { $objDate = $objOneNews->getObjStartDate(); if ($objDate == null) { $objDate = new class_date(); } $objFeed->addElement($objOneNews->getStrTitle(), getLinkPortalHref($strPage, "", "newsDetail", "", $objOneNews->getSystemid(), "", $objOneNews->getStrTitle()), $objOneNews->getSystemid(), $objOneNews->getStrIntro(), mktime($objDate->getIntHour(), $objDate->getIntMin(), $objDate->getIntSec(), $objDate->getIntMonth(), $objDate->getIntDay(), $objDate->getIntYear())); } } return $objFeed->generateFeed(); }
/** * Returns a simple date-form element. By default used to enter a date without a time. * * @param string $strName * @param string $strTitle * @param class_date $objDateToShow * @param string $strClass = inputDate * @param boolean $bitWithTime * * @throws class_exception * @return string * @since 3.2.0.9 */ public function formDateSingle($strName, $strTitle, $objDateToShow, $strClass = "", $bitWithTime = false) { //check passed param if ($objDateToShow != null && !$objDateToShow instanceof class_date) { throw new class_exception("param passed to class_toolkit_admin::formDateSingle is not an instance of class_date", class_exception::$level_ERROR); } if ($bitWithTime) { $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "input_datetime_simple"); } else { $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "input_date_simple"); } $arrTemplate = array(); $arrTemplate["class"] = $strClass; $arrTemplate["titleDay"] = $strName . "_day"; $arrTemplate["titleMonth"] = $strName . "_month"; $arrTemplate["titleYear"] = $strName . "_year"; $arrTemplate["titleHour"] = $strName . "_hour"; $arrTemplate["titleMin"] = $strName . "_minute"; $arrTemplate["title"] = $strTitle; $arrTemplate["valueDay"] = $objDateToShow != null ? $objDateToShow->getIntDay() : ""; $arrTemplate["valueMonth"] = $objDateToShow != null ? $objDateToShow->getIntMonth() : ""; $arrTemplate["valueYear"] = $objDateToShow != null ? $objDateToShow->getIntYear() : ""; $arrTemplate["valueHour"] = $objDateToShow != null ? $objDateToShow->getIntHour() : ""; $arrTemplate["valueMin"] = $objDateToShow != null ? $objDateToShow->getIntMin() : ""; $arrTemplate["valuePlain"] = dateToString($objDateToShow, false); // if($bitWithTime) $arrTemplate["dateFormat"] = class_carrier::getInstance()->getObjLang()->getLang("dateStyleShort", "system"); // else // $arrTemplate["dateFormat"] = class_carrier::getInstance()->getObjLang()->getLang("dateStyleLong", "system"); $arrTemplate["calendarLang"] = class_carrier::getInstance()->getObjSession()->getAdminLanguage(); $arrTemplate["titleTime"] = class_carrier::getInstance()->getObjLang()->getLang("titleTime", "system"); //set up the container div $arrTemplate["calendarId"] = $strName; $strContainerId = $strName . "_calendarContainer"; $arrTemplate["calendarContainerId"] = $strContainerId; $arrTemplate["calendarLang_weekday"] = " [" . class_carrier::getInstance()->getObjLang()->getLang("toolsetCalendarWeekday", "system") . "]\n"; $arrTemplate["calendarLang_month"] = " [" . class_carrier::getInstance()->getObjLang()->getLang("toolsetCalendarMonth", "system") . "]\n"; return $this->objTemplate->fillTemplate($arrTemplate, $strTemplateID); }
/** * Creates and array which contains the years until 2099 starting from the current year * * @return array */ private static function getArrYear() { $arrDropDownYear = array(); $objCurrentDate = new class_date(); for ($intI = $objCurrentDate->getIntYear(); $intI < 2100; $intI++) { $arrDropDownYear[$intI . ""] = $intI; } return $arrDropDownYear; }
/** * Creates a form to edit a users data * * @return string */ private function editUserData() { $arrErrors = array(); $bitForm = true; //what to do? if ($this->getParam("submitUserForm") != "") { if ($this->getParam("password") != "") { if ($this->getParam("password") != $this->getParam("password2")) { $arrErrors[] = $this->getLang("passwordsUnequal"); } } $objValidator = new class_email_validator(); if (!$objValidator->validate($this->getParam("email"))) { $arrErrors[] = $this->getLang("invalidEmailadress"); } if (count($arrErrors) == 0) { $bitForm = false; } } if ($bitForm) { if ($this->arrElementData["portallogin_editmode"] == 1) { $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_complete"); } else { $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_minimal"); } $arrTemplate = array(); $objUser = new class_module_user_user($this->objSession->getUserID()); if ($objUser->getObjSourceUser()->isEditable() && $objUser->getStrSubsystem() == "kajona" && $objUser->getObjSourceUser() instanceof class_usersources_user_kajona) { $arrTemplate["username"] = $objUser->getStrUsername(); $arrTemplate["email"] = $objUser->getObjSourceUser()->getStrEmail(); $arrTemplate["forename"] = $objUser->getObjSourceUser()->getStrForename(); $arrTemplate["name"] = $objUser->getObjSourceUser()->getStrName(); $arrTemplate["street"] = $objUser->getObjSourceUser()->getStrStreet(); $arrTemplate["postal"] = $objUser->getObjSourceUser()->getStrPostal(); $arrTemplate["city"] = $objUser->getObjSourceUser()->getStrCity(); $arrTemplate["phone"] = $objUser->getObjSourceUser()->getStrTel(); $arrTemplate["mobile"] = $objUser->getObjSourceUser()->getStrMobile(); $arrTemplate["portallogin_elsystemid"] = $this->arrElementData["content_id"]; $objDate = new class_date($objUser->getObjSourceUser()->getLongDate()); $arrTemplate["date_day"] = $objDate->getIntDay(); $arrTemplate["date_month"] = $objDate->getIntMonth(); $arrTemplate["date_year"] = $objDate->getIntYear(); $arrTemplate["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "portalEditProfile"); $arrTemplate["formErrors"] = ""; if (count($arrErrors) > 0) { foreach ($arrErrors as $strOneError) { $strErrTemplate = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "errorRow"); $arrTemplate["formErrors"] .= "" . $this->fillTemplate(array("error" => $strOneError), $strErrTemplate); } } return $this->fillTemplate($arrTemplate, $strTemplateID); } else { return "Login provider not supported."; } } else { $objUser = new class_module_user_user($this->objSession->getUserID()); if ($objUser->getObjSourceUser() instanceof class_usersources_user_kajona) { $objUser->getObjSourceUser()->setStrEmail($this->getParam("email")); $objUser->getObjSourceUser()->setStrForename($this->getParam("forename")); $objUser->getObjSourceUser()->setStrName($this->getParam("name")); $objUser->getObjSourceUser()->setStrPass($this->getParam("password")); if ($this->arrElementData["portallogin_editmode"] == 1) { $objUser->getObjSourceUser()->setStrStreet($this->getParam("street")); $objUser->getObjSourceUser()->setStrPostal($this->getParam("postal")); $objUser->getObjSourceUser()->setStrCity($this->getParam("city")); $objUser->getObjSourceUser()->setStrTel($this->getParam("phone")); $objUser->getObjSourceUser()->setStrMobile($this->getParam("mobile")); $objDate = new class_date(); $objDate->setIntDay($this->getParam("date_day")); $objDate->setIntMonth($this->getParam("date_month")); $objDate->setIntYear($this->getParam("date_year")); $objUser->getObjSourceUser()->setLongDate($objDate->getLongTimestamp()); } $objUser->getObjSourceUser()->updateObjectToDb(); } $this->portalReload(class_link::getLinkPortalHref($this->getPagename())); } return ""; }
/** * Returns a list of events available * * @param bool|int $intStart * @param bool|int $intEnd * @param class_date $objStartDate * @param class_Date $objEndDate * @param bool $bitOnlyActive * @param int $intOrder * @param null $intStatusFilter * * @return class_module_eventmanager_event[] */ public static function getAllEvents($intStart = false, $intEnd = false, class_date $objStartDate = null, class_date $objEndDate = null, $bitOnlyActive = false, $intOrder = 0, $intStatusFilter = null) { $objORM = new class_orm_objectlist(); if ($objStartDate != null && $objEndDate != null) { $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND (system_date_start > ? AND system_date_start <= ?", array($objStartDate->getLongTimestamp(), $objEndDate->getLongTimestamp()))); } if ($intStatusFilter != null) { $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND em_ev_eventstatus = ?", array($intStatusFilter))); } if ($bitOnlyActive) { $objORM->addWhereRestriction(new class_orm_objectlist_systemstatus_restriction(class_orm_comparator_enum::Equal(), 1)); } $objORM->addOrderBy(new class_orm_objectlist_orderby("system_date_start " . ($intOrder == "1" ? " ASC " : " DESC "))); $objORM->addOrderBy(new class_orm_objectlist_orderby("em_ev_title ASC ")); return $objORM->getObjectList(get_called_class(), "", $intStart, $intEnd); }
/** * @return string * @permissions view */ protected function actionRenderCalendar() { $strReturn = ""; $strContent = ""; $arrJsHighlights = array(); $strReturn .= "<content><![CDATA["; /** @var interface_calendarsource_admin[] $arrRelevantModules */ $arrRelevantModules = array(); //fetch modules relevant for processing $arrModules = class_module_system_module::getAllModules(); foreach ($arrModules as $objSingleModule) { if ($objSingleModule->getIntRecordStatus() == 1 && $objSingleModule->getAdminInstanceOfConcreteModule() instanceof interface_calendarsource_admin) { $arrRelevantModules[] = $objSingleModule->getAdminInstanceOfConcreteModule(); } } //the header row $arrWeekdays = explode(",", $this->getLang("calendar_weekday")); foreach ($arrWeekdays as $intKey => $strValue) { $arrWeekdays[$intKey] = trim(uniStrReplace("\"", "", $strValue)); } $strContent .= $this->objToolkit->getCalendarHeaderRow($arrWeekdays); //render the single rows. calculate the first day of the row $objDate = new class_date(); $objDate->setIntDay(1); //set to interval stored in session if ($this->objSession->getSession($this->strStartMonthKey) != "") { $objDate->setIntMonth($this->objSession->getSession($this->strStartMonthKey)); } if ($this->objSession->getSession($this->strStartYearKey) != "") { $objDate->setIntYear($this->objSession->getSession($this->strStartYearKey)); } $intCurMonth = $objDate->getIntMonth(); $intCurYear = $objDate->getIntYear(); $objToday = new class_date(); //start by monday while ($objDate->getIntDayOfWeek() != 1) { $objDate->setPreviousDay(); } $strEntries = ""; $intRowEntryCount = 0; while ($objDate->getIntMonth() <= $intCurMonth && $objDate->getIntYear() <= $intCurYear || $objDate->getIntMonth() == 12 && $objDate->getIntYear() < $intCurYear || $intRowEntryCount % 7 != 0) { $intRowEntryCount++; $strDate = $objDate->getIntDay(); $arrEvents = array(); if ($objDate->getIntMonth() == $intCurMonth) { //Query modules for dates $objStartDate = clone $objDate; $objStartDate->setIntHour(0)->setIntMin(0)->setIntSec(0); $objEndDate = clone $objDate; $objEndDate->setIntHour(23)->setIntMin(59)->setIntSec(59); foreach ($arrRelevantModules as $objOneModule) { $arrEvents = array_merge($objOneModule->getArrCalendarEntries($objStartDate, $objEndDate), $arrEvents); } } while (count($arrEvents) <= 3) { $objDummy = new class_calendarentry(); $objDummy->setStrClass("spacer"); $objDummy->setStrName(" "); $arrEvents[] = $objDummy; } $strEvents = ""; /** @var class_calendarentry $objOneEvent */ foreach ($arrEvents as $objOneEvent) { $strName = $objOneEvent->getStrName(); $strSecondLine = $objOneEvent->getStrSecondLine(); if ($strSecondLine != "") { $strSecondLine = "<br />" . $strSecondLine; } //register mouse-over highlight relations if ($objOneEvent->getStrHighlightId() != "" && $objOneEvent->getStrSystemid() != "") { if (!isset($arrJsHighlights[$objOneEvent->getStrHighlightId()])) { $arrJsHighlights[$objOneEvent->getStrHighlightId()] = array(); } $arrJsHighlights[$objOneEvent->getStrHighlightId()][] = $objOneEvent->getStrSystemid(); } $strEvents .= $this->objToolkit->getCalendarEvent($strName . $strSecondLine, $objOneEvent->getStrSystemid(), $objOneEvent->getStrHighlightId(), $objOneEvent->getStrClass()); } $bitBlocked = false; if ($objDate->getIntDayOfWeek() == 0 || $objDate->getIntDayOfWeek() == 6) { $bitBlocked = true; } $strToday = ""; if ($objToday->getIntYear() == $objDate->getIntYear() && $objToday->getIntMonth() == $objDate->getIntMonth() && $objToday->getIntDay() == $objDate->getIntDay()) { $strToday = " calendarDateToday"; } if ($objDate->getIntMonth() != $intCurMonth) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryOutOfRange" . $strToday); } else { if ($bitBlocked) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryBlocked" . $strToday); } else { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntry" . $strToday); } } if ($intRowEntryCount % 7 == 0) { $strContent .= $this->objToolkit->getCalendarRow($strEntries); $strEntries = ""; } $objDate->setNextDay(); } if ($strEntries != "") { $strContent .= $this->objToolkit->getCalendarRow($strEntries); } $strReturn .= $this->objToolkit->getCalendarWrapper($strContent); //build js-arrays $strJs = "<script type=\"text/javascript\">"; foreach ($arrJsHighlights as $strCommonId => $arrEntries) { $strJs .= " var kj_cal_" . $strCommonId . " = new Array();"; foreach ($arrEntries as $strOneIdentifier) { $strJs .= "kj_cal_" . $strCommonId . ".push('" . $strOneIdentifier . "');"; } } $strJs .= "</script>"; $strReturn .= $strJs; $strReturn .= "]]></content>"; return $strReturn; }
/** * Calculates the first day of the given period depending on the given date. * * For period Weeks: Last day of a week is always sunday * * @param class_date_period_enum $objPeriod * @param class_date $objDate * * @return class_date */ public function lastDayOfThis(class_date_period_enum $objPeriod, class_date $objDate) { $strRelativeString = ""; if ($objPeriod->equals(class_date_period_enum::YEAR())) { $strRelativeString = "last day of december"; } else { if ($objPeriod->equals(class_date_period_enum::HALFYEAR())) { $intMonth = $objDate->getIntMonth(); if ($intMonth < 7) { $strRelativeString = "last day of june"; } else { $strRelativeString = "last day of december"; } } else { if ($objPeriod->equals(class_date_period_enum::QUARTER())) { $intMonth = $objDate->getIntMonth(); if ($intMonth < 4) { $strRelativeString = "last day of march"; } elseif ($intMonth > 3 && $intMonth < 7) { $strRelativeString = "last day of june"; } elseif ($intMonth > 6 && $intMonth < 10) { $strRelativeString = "last day of september"; } elseif ($intMonth > 9) { $strRelativeString = "last day of december"; } } else { if ($objPeriod->equals(class_date_period_enum::MONTH())) { $strRelativeString = "last day of this month"; } else { if ($objPeriod->equals(class_date_period_enum::WEEK())) { if ($objDate->getIntDayOfWeek() == 0) { $strRelativeString = "now"; } else { //check if correct? $strRelativeString = "sunday this week"; } } } } } } $objNewDate = self::calcDateRelativeFormatString($objDate, $strRelativeString); $objNewDate->setIntHour($objDate->getIntHour()); $objNewDate->setIntMin($objDate->getIntMin()); $objNewDate->setIntSec($objDate->getIntSec()); return $objNewDate; }
/** * Returns the latest new_value in the date range per systemid * * @param $strClass * @param $strProperty * @param class_date $objDateFrom * @param class_date $objDateTo * @param array $arrAllowedSystemIds * @return array */ public static function getNewValuesForDateRange($strClass, $strProperty, class_date $objDateFrom = null, class_date $objDateTo = null, array $arrAllowedSystemIds) { $arrParams = array($strClass, $strProperty); //system id filter $objRestriction = new class_orm_objectlist_in_restriction("log.change_systemid", $arrAllowedSystemIds); $strQueryCondition = $objRestriction->getStrWhere(); $arrParams = array_merge($arrParams, $objRestriction->getArrParams()); //filter by create date from if ($objDateFrom != null) { $objRestriction = new class_orm_objectlist_restriction("AND ( log.change_date >= ? )", array($objDateFrom->getLongTimestamp())); $strQueryCondition .= $objRestriction->getStrWhere() . " "; $arrParams[] = $objDateFrom->getLongTimestamp(); } //filter by create end to if ($objDateTo != null) { $objRestriction = new class_orm_objectlist_restriction("AND ( log.change_date <= ? )", array($objDateTo->getLongTimestamp())); $strQueryCondition .= $objRestriction->getStrWhere() . " "; $arrParams[] = $objDateTo->getLongTimestamp(); } $strQuery = " SELECT change_systemid,\n change_newvalue\n FROM " . _dbprefix_ . self::getTableForClass($strClass) . " log\n WHERE log.change_class = ?\n AND log.change_property = ?\n {$strQueryCondition}\n ORDER BY log.change_systemid ASC, log.change_date DESC"; $arrResult = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, $arrParams); $arrData = array(); $strLastId = ""; foreach ($arrResult as $arrRow) { if ($strLastId != $arrRow["change_systemid"]) { $arrData[] = array("change_systemid" => $arrRow["change_systemid"], "change_newvalue" => $arrRow["change_newvalue"]); } $strLastId = $arrRow["change_systemid"]; } return $arrData; }
/** * This method is called, when the widget should generate it's content. * Return the complete content using the methods provided by the base class. * Do NOT use the toolkit right here! * * @return string */ public function getWidgetOutput() { $strReturn = ""; if (!class_module_system_module::getModuleByName("stats")->rightView()) { return $this->getLang("commons_error_permissions"); } $objStatsCommon = new class_stats_report_common(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang()); //check wich infos to produce if ($this->getFieldValue("current") == "checked") { $strReturn .= $this->getLang("stats_online") . $objStatsCommon->getNumberOfCurrentUsers(); $strReturn .= $this->widgetSeparator(); } if ($this->getFieldValue("chart") == "checked") { //load the last view days $objDate = new class_date(); $objDate->setIntHour(0); $objDate->setIntMin(0); $objDate->setIntSec(0); $arrHits = array(); $arrLabels = array(); for ($intI = 0; $intI < 7; $intI++) { $objEndDate = clone $objDate; $objEndDate->setNextDay(); $objStatsCommon->setStartDate($objDate->getTimeInOldStyle()); $objStatsCommon->setEndDate($objEndDate->getTimeInOldStyle()); $arrHits[] = $objStatsCommon->getHits(); $arrLabels[] = $objDate->getIntDay(); $objDate->setPreviousDay(); } $arrHits = array_reverse($arrHits); $arrLabels = array_reverse($arrLabels); $strReturn .= $this->widgetText($this->getLang("stats_hits")); $objChart = class_graph_factory::getGraphInstance(); $objChart->setArrXAxisTickLabels($arrLabels); $objChart->addLinePlot($arrHits, ""); $objChart->setBitRenderLegend(false); $objChart->setIntHeight(220); $objChart->setIntWidth(300); $objChart->setStrXAxisTitle(""); $objChart->setStrYAxisTitle(""); $strReturn .= $objChart->renderGraph(); } if ($this->getFieldValue("day") == "checked") { //current day: //pass date to commons-object $objDate = new class_date(); $objDate->setIntHour(0); $objDate->setIntMin(0); $objDate->setIntSec(0); $strReturn .= $this->widgetText(dateToString($objDate, false)); $objStatsCommon->setStartDate($objDate->getTimeInOldStyle()); $objDate->setNextDay(); $objStatsCommon->setEndDate($objDate->getTimeInOldStyle()); $strReturn .= $this->widgetText($this->getLang("stats_hits") . " " . $objStatsCommon->getHits()); $strReturn .= $this->widgetText($this->getLang("stats_visitors") . " " . $objStatsCommon->getVisitors()); $strReturn .= $this->widgetSeparator(); } if ($this->getFieldValue("last") == "checked") { $strReturn .= $this->widgetText($this->getLang("stats_ip") . " " . $this->getLang("stats_page")); $intMaxRecords = $this->getFieldValue("nrLast"); if (!is_numeric($intMaxRecords) || $intMaxRecords > 15) { $intMaxRecords = 15; } $arrRecordsets = class_carrier::getInstance()->getObjDB()->getPArray("SELECT * FROM " . _dbprefix_ . "stats_data ORDER BY stats_date DESC ", array(), 0, $intMaxRecords - 1); foreach ($arrRecordsets as $arrOneRecord) { $strReturn .= $this->widgetText($arrOneRecord["stats_ip"] . " " . $arrOneRecord["stats_page"]); } } return $strReturn; }
/** * Updates a record in the date table. Make sure to use a proper system-id! * Up from Kajona V3.3, the signature changed. Pass instances of class_date instead of * int-values. * * @param string $strSystemid * @param class_date $objStartDate * @param class_date $objEndDate * @param class_date $objSpecialDate * @deprecated use the internal date-objects to have all dates handled automatically * @return bool */ public function updateDateRecord($strSystemid, class_date $objStartDate = null, class_date $objEndDate = null, class_date $objSpecialDate = null) { $intStart = 0; $intEnd = 0; $intSpecial = 0; if ($objStartDate != null && $objStartDate instanceof class_date) { $intStart = $objStartDate->getLongTimestamp(); } if ($objEndDate != null && $objEndDate instanceof class_date) { $intEnd = $objEndDate->getLongTimestamp(); } if ($objSpecialDate != null && $objSpecialDate instanceof class_date) { $intSpecial = $objSpecialDate->getLongTimestamp(); } $strQuery = "UPDATE " . _dbprefix_ . "system_date\n SET system_date_start = ?,\n system_date_end = ?,\n system_date_special = ?\n WHERE system_date_id = ?"; return $this->objDB->_pQuery($strQuery, array($intStart, $intEnd, $intSpecial, $strSystemid)); }
<?php echo "<pre>\n"; echo "+-------------------------------------------------------------------------------+\n"; echo "| Kajona Debug Subsystem |\n"; echo "| |\n"; echo "| |\n"; echo "+-------------------------------------------------------------------------------+\n"; $objStartDate = new class_date(); $objEndDate = new class_date(); echo str_pad("Month", 15); echo str_pad("Hits", 15); echo str_pad("Visitors", 15); echo str_pad("Downloads", 15); echo str_pad("PServer-Requests", 20); echo str_pad("PServer-Unique", 20); echo "\n"; for ($intYear = 2012; $intYear <= 2014; $intYear++) { for ($intMonth = 1; $intMonth <= 12; $intMonth++) { $objStartDate->setIntDay(1)->setIntMonth($intMonth)->setIntYear($intYear)->setIntHour(0)->setIntMin(0)->setIntSec(1); $objEndDate = clone $objStartDate; $objEndDate->setNextDay(); while ($objEndDate->getIntDay() != 1) { $objEndDate->setNextDay(); } $objEndDate->setPreviousDay()->setIntHour(23)->setIntMin(59)->setIntSec(59); echo str_pad($objStartDate->getIntMonth() . "/" . $objStartDate->getIntYear(), 10); echo str_pad(getHits($objStartDate->getTimeInOldStyle(), $objEndDate->getTimeInOldStyle()), 15, " ", STR_PAD_LEFT); echo str_pad(getVisitors($objStartDate->getTimeInOldStyle(), $objEndDate->getTimeInOldStyle()), 15, " ", STR_PAD_LEFT); echo str_pad(getDownloads($objStartDate->getTimeInOldStyle(), $objEndDate->getTimeInOldStyle()), 15, " ", STR_PAD_LEFT); echo str_pad(getPackageserverRequests($objStartDate->getLongTimestamp(), $objEndDate->getLongTimestamp()), 20, " ", STR_PAD_LEFT);
echo "| DATECONVERTER |\n"; echo "| |\n"; echo "+-------------------------------------------------------------------------------+\n"; echo "<form method=\"post\">"; echo "--- UNIX timestamp handling -----------------------------------------------------\n\n"; echo "integer to date: \n"; echo "\tinteger: <input type=\"text\" value=\"" . getPost("inttime") . "\" name=\"inttime\"/>"; echo " --> " . timeToString(getPost("inttime")) . "\n"; echo "date to integer: \n"; echo "\tdate: d:<input type=\"text\" value=\"" . getPost("strday") . "\" name=\"strday\" size=\"2\" />"; echo " m:<input type=\"text\" value=\"" . getPost("strmonth") . "\" name=\"strmonth\" size=\"2\" />"; echo " y:<input type=\"text\" value=\"" . getPost("stryear") . "\" name=\"stryear\" size=\"4\" />"; echo " --> " . strtotime(getPost("stryear") . "-" . getPost("strmonth") . "-" . getPost("strday")) . "\n"; echo "\n<input type=\"submit\" value=\"submit\" />\n"; echo "\n--- Kajona timestamp handling ---------------------------------------------------\n\n"; echo "integer to date: \n"; $objDateFromInt = new class_date(); $objDateFromInt->setTimeInOldStyle(getPost("kajonainttime")); echo "\tinteger: <input type=\"text\" value=\"" . getPost("kajonainttime") . "\" name=\"kajonainttime\"/>"; echo " --> " . $objDateFromInt . "\n"; $objDateFromInt = new class_date(getPost("kajonainttime")); echo "\tinteger: <input type=\"text\" value=\"" . getPost("kajonainttime") . "\" name=\"kajonainttime\"/>"; echo " --> " . $objDateFromInt . "\n"; echo "\n<input type=\"submit\" value=\"submit\" />\n"; echo "<input type='hidden' name='debugfile' value='" . basename(__FILE__) . "'>"; echo "</form>"; echo "\ncurrent time: " . class_date::getCurrentTimestamp() . "\n"; echo "\n\n"; echo "+-------------------------------------------------------------------------------+\n"; echo "| (c) www.kajona.de |\n"; echo "+-------------------------------------------------------------------------------+\n";
/** * Shows a form or deltes a timeintervall from the logs * * @throws class_exception * @return string "" in case of success * @permissions edit * @autoTestable */ protected function actionLogbookFlush() { $strReturn = ""; if ($this->getParam("flush") == "") { $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "logbookFlush", "flush=1")); $strReturn .= $this->objToolkit->formTextRow($this->getLang("logbook_hint_date")); $strReturn .= $this->objToolkit->formDateSingle("date", $this->getLang("commons_date"), new class_date()); $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save")); $strReturn .= $this->objToolkit->formClose(); } elseif ($this->getParam("flush") == "1") { //Build the date $objDate = new class_date(); $objDate->generateDateFromParams("date", $this->getAllParams()); if (!class_module_mediamanager_logbook::deleteFromLogs($objDate->getTimeInOldStyle())) { throw new class_exception("Error deleting log-rows", class_exception::$level_ERROR); } $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "logbook")); } return $strReturn; }
public function install() { $strReturn = ""; $objManager = new class_orm_schemamanager(); // System table --------------------------------------------------------------------------------- $strReturn .= "Installing table system...\n"; $arrFields = array(); $arrFields["system_id"] = array("char20", false); $arrFields["system_prev_id"] = array("char20", false); $arrFields["system_module_nr"] = array("int", false); $arrFields["system_sort"] = array("int", true); $arrFields["system_owner"] = array("char20", true); $arrFields["system_create_date"] = array("long", true); $arrFields["system_lm_user"] = array("char20", true); $arrFields["system_lm_time"] = array("int", true); $arrFields["system_lock_id"] = array("char20", true); $arrFields["system_lock_time"] = array("int", true); $arrFields["system_status"] = array("int", true); $arrFields["system_class"] = array("char254", true); $arrFields["system_comment"] = array("char254", true); $arrFields["system_deleted"] = array("int", true); if (!$this->objDB->createTable("system", $arrFields, array("system_id"), array("system_prev_id", "system_module_nr", "system_sort", "system_owner", "system_create_date", "system_status", "system_lm_time", "system_lock_time", "system_deleted"))) { $strReturn .= "An error occurred! ...\n"; } //Rights table ---------------------------------------------------------------------------------- $strReturn .= "Installing table system_right...\n"; $arrFields = array(); $arrFields["right_id"] = array("char20", false); $arrFields["right_inherit"] = array("int", true); $arrFields["right_view"] = array("text", true); $arrFields["right_edit"] = array("text", true); $arrFields["right_delete"] = array("text", true); $arrFields["right_right"] = array("text", true); $arrFields["right_right1"] = array("text", true); $arrFields["right_right2"] = array("text", true); $arrFields["right_right3"] = array("text", true); $arrFields["right_right4"] = array("text", true); $arrFields["right_right5"] = array("text", true); $arrFields["right_changelog"] = array("text", true); if (!$this->objDB->createTable("system_right", $arrFields, array("right_id"))) { $strReturn .= "An error occurred! ...\n"; } // Modul table ---------------------------------------------------------------------------------- $strReturn .= "Installing table system_module...\n"; $objManager->createTable("class_module_system_module"); // Date table ----------------------------------------------------------------------------------- $strReturn .= "Installing table system_date...\n"; $arrFields = array(); $arrFields["system_date_id"] = array("char20", false); $arrFields["system_date_start"] = array("long", true); $arrFields["system_date_end"] = array("long", true); $arrFields["system_date_special"] = array("long", true); if (!$this->objDB->createTable("system_date", $arrFields, array("system_date_id"), array("system_date_start", "system_date_end", "system_date_special"))) { $strReturn .= "An error occurred! ...\n"; } // Config table --------------------------------------------------------------------------------- $strReturn .= "Installing table system_config...\n"; $arrFields = array(); $arrFields["system_config_id"] = array("char20", false); $arrFields["system_config_name"] = array("char254", true); $arrFields["system_config_value"] = array("char254", true); $arrFields["system_config_type"] = array("int", true); $arrFields["system_config_module"] = array("int", true); if (!$this->objDB->createTable("system_config", $arrFields, array("system_config_id"))) { $strReturn .= "An error occurred! ...\n"; } // User table ----------------------------------------------------------------------------------- $strReturn .= "Installing table user...\n"; $arrFields = array(); $arrFields["user_id"] = array("char20", false); $arrFields["user_username"] = array("char254", true); $arrFields["user_subsystem"] = array("char254", true); $arrFields["user_logins"] = array("int", true); $arrFields["user_lastlogin"] = array("int", true); $arrFields["user_active"] = array("int", true); $arrFields["user_admin"] = array("int", true); $arrFields["user_portal"] = array("int", true); $arrFields["user_deleted"] = array("int", true); $arrFields["user_admin_skin"] = array("char254", true); $arrFields["user_admin_language"] = array("char254", true); $arrFields["user_admin_module"] = array("char254", true); $arrFields["user_authcode"] = array("char20", true); $arrFields["user_items_per_page"] = array("int", true); if (!$this->objDB->createTable("user", $arrFields, array("user_id"), array("user_username", "user_subsystem", "user_active", "user_deleted"))) { $strReturn .= "An error occurred! ...\n"; } // User table kajona subsystem ----------------------------------------------------------------- $strReturn .= "Installing table user_kajona...\n"; $arrFields = array(); $arrFields["user_id"] = array("char20", false); $arrFields["user_pass"] = array("char254", true); $arrFields["user_salt"] = array("char20", true); $arrFields["user_email"] = array("char254", true); $arrFields["user_forename"] = array("char254", true); $arrFields["user_name"] = array("char254", true); $arrFields["user_street"] = array("char254", true); $arrFields["user_postal"] = array("char254", true); $arrFields["user_city"] = array("char254", true); $arrFields["user_tel"] = array("char254", true); $arrFields["user_mobile"] = array("char254", true); $arrFields["user_date"] = array("long", true); if (!$this->objDB->createTable("user_kajona", $arrFields, array("user_id"))) { $strReturn .= "An error occurred! ...\n"; } // User group table ----------------------------------------------------------------------------- $strReturn .= "Installing table user_group...\n"; $arrFields = array(); $arrFields["group_id"] = array("char20", false); $arrFields["group_name"] = array("char254", true); $arrFields["group_subsystem"] = array("char254", true); if (!$this->objDB->createTable("user_group", $arrFields, array("group_id"), array("group_name", "group_subsystem"))) { $strReturn .= "An error occurred! ...\n"; } $strReturn .= "Installing table user_group_kajona...\n"; $arrFields = array(); $arrFields["group_id"] = array("char20", false); $arrFields["group_desc"] = array("char254", true); if (!$this->objDB->createTable("user_group_kajona", $arrFields, array("group_id"))) { $strReturn .= "An error occurred! ...\n"; } // User group_members table --------------------------------------------------------------------- $strReturn .= "Installing table user_kajona_members...\n"; $arrFields = array(); $arrFields["group_member_group_kajona_id"] = array("char20", false); $arrFields["group_member_user_kajona_id"] = array("char20", false); if (!$this->objDB->createTable("user_kajona_members", $arrFields, array("group_member_group_kajona_id", "group_member_user_kajona_id"))) { $strReturn .= "An error occurred! ...\n"; } // User log table ------------------------------------------------------------------------------- $strReturn .= "Installing table user_log...\n"; $arrFields = array(); $arrFields["user_log_id"] = array("char20", false); $arrFields["user_log_userid"] = array("char254", true); $arrFields["user_log_date"] = array("long", true); $arrFields["user_log_status"] = array("int", true); $arrFields["user_log_ip"] = array("char20", true); $arrFields["user_log_sessid"] = array("char20", true); $arrFields["user_log_enddate"] = array("long", true); if (!$this->objDB->createTable("user_log", $arrFields, array("user_log_id"), array("user_log_sessid"))) { $strReturn .= "An error occurred! ...\n"; } // Sessionmgtm ---------------------------------------------------------------------------------- $strReturn .= "Installing table session...\n"; $arrFields = array(); $arrFields["session_id"] = array("char20", false); $arrFields["session_phpid"] = array("char254", true); $arrFields["session_userid"] = array("char20", true); $arrFields["session_groupids"] = array("text", true); $arrFields["session_releasetime"] = array("int", true); $arrFields["session_loginstatus"] = array("char254", true); $arrFields["session_loginprovider"] = array("char20", true); $arrFields["session_lasturl"] = array("char500", true); if (!$this->objDB->createTable("session", $arrFields, array("session_id"), array("session_phpid", "session_releasetime", "session_userid"))) { $strReturn .= "An error occurred! ...\n"; } // caching -------------------------------------------------------------------------------------- $strReturn .= "Installing table cache...\n"; $arrFields = array(); $arrFields["cache_id"] = array("char20", false); $arrFields["cache_source"] = array("char254", true); $arrFields["cache_hash1"] = array("char254", true); $arrFields["cache_hash2"] = array("char254", true); $arrFields["cache_language"] = array("char20", true); $arrFields["cache_content"] = array("longtext", true); $arrFields["cache_leasetime"] = array("int", true); $arrFields["cache_hits"] = array("int", true); if (!$this->objDB->createTable("cache", $arrFields, array("cache_id"), array("cache_source", "cache_hash1", "cache_leasetime", "cache_language"), false)) { $strReturn .= "An error occurred! ...\n"; } //languages ------------------------------------------------------------------------------------- $strReturn .= "Installing table languages...\n"; $objManager->createTable("class_module_languages_language"); $strReturn .= "Installing table languages_languageset...\n"; $arrFields = array(); $arrFields["languageset_id"] = array("char20", false); $arrFields["languageset_language"] = array("char20", true); $arrFields["languageset_systemid"] = array("char20", true); if (!$this->objDB->createTable("languages_languageset", $arrFields, array("languageset_id", "languageset_systemid"))) { $strReturn .= "An error occurred! ...\n"; } //aspects -------------------------------------------------------------------------------------- $strReturn .= "Installing table aspects...\n"; $objManager->createTable("class_module_system_aspect"); //changelog ------------------------------------------------------------------------------------- $strReturn .= "Installing table changelog...\n"; $this->installChangeTables(); //messages $strReturn .= "Installing table messages...\n"; $objManager->createTable("class_module_messaging_message"); $objManager->createTable("class_module_messaging_config"); //Now we have to register module by module //The Systemkernel $this->registerModule("system", _system_modul_id_, "", "class_module_system_admin.php", $this->objMetadata->getStrVersion(), true, "", "class_module_system_admin_xml.php"); //The Rightsmodule $this->registerModule("right", _system_modul_id_, "", "class_module_right_admin.php", $this->objMetadata->getStrVersion(), false); //The Usermodule $this->registerModule("user", _user_modul_id_, "", "class_module_user_admin.php", $this->objMetadata->getStrVersion(), true); //languages $this->registerModule("languages", _languages_modul_id_, "class_modul_languages_portal.php", "class_module_languages_admin.php", $this->objMetadata->getStrVersion(), true); //messaging $this->registerModule("messaging", _messaging_module_id_, "", "class_module_messaging_admin.php", $this->objMetadata->getStrVersion(), true); //Registering a few constants $strReturn .= "Registering system-constants...\n"; //And the default skin $this->registerConstant("_admin_skin_default_", "kajona_v4", class_module_system_setting::$int_TYPE_STRING, _user_modul_id_); //and a few system-settings $this->registerConstant("_system_portal_disable_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_); $this->registerConstant("_system_portal_disablepage_", "", class_module_system_setting::$int_TYPE_PAGE, _system_modul_id_); //New in 3.0: Number of db-dumps to hold $this->registerConstant("_system_dbdump_amount_", 5, class_module_system_setting::$int_TYPE_INT, _system_modul_id_); //new in 3.0: mod-rewrite on / off $this->registerConstant("_system_mod_rewrite_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_); //New Constant: Max time to lock records $this->registerConstant("_system_lock_maxtime_", 7200, class_module_system_setting::$int_TYPE_INT, _system_modul_id_); //Email to send error-reports $this->registerConstant("_system_admin_email_", $this->objSession->getSession("install_email"), class_module_system_setting::$int_TYPE_STRING, _system_modul_id_); $this->registerConstant("_system_email_defaultsender_", $this->objSession->getSession("install_email"), class_module_system_setting::$int_TYPE_STRING, _system_modul_id_); $this->registerConstant("_system_email_forcesender_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_); //3.0.2: user are allowed to change their settings? $this->registerConstant("_user_selfedit_", "true", class_module_system_setting::$int_TYPE_BOOL, _user_modul_id_); //3.1: nr of rows in admin $this->registerConstant("_admin_nr_of_rows_", 15, class_module_system_setting::$int_TYPE_INT, _system_modul_id_); $this->registerConstant("_admin_only_https_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_); //3.1: remoteloader max cachtime --> default 60 min $this->registerConstant("_remoteloader_max_cachetime_", 60 * 60, class_module_system_setting::$int_TYPE_INT, _system_modul_id_); //3.2: max session duration $this->registerConstant("_system_release_time_", 3600, class_module_system_setting::$int_TYPE_INT, _system_modul_id_); //3.4: cache buster to be able to flush the browsers cache (JS and CSS files) $this->registerConstant("_system_browser_cachebuster_", 0, class_module_system_setting::$int_TYPE_INT, _system_modul_id_); //3.4: Adding constant _system_graph_type_ indicating the chart-engine to use $this->registerConstant("_system_graph_type_", "jqplot", class_module_system_setting::$int_TYPE_STRING, _system_modul_id_); //3.4: Enabling or disabling the internal changehistory $this->registerConstant("_system_changehistory_enabled_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_); $this->registerConstant("_system_timezone_", "", class_module_system_setting::$int_TYPE_STRING, _system_modul_id_); //Creating the admin & guest groups $objAdminGroup = new class_module_user_group(); $objAdminGroup->setStrName("Admins"); $objAdminGroup->updateObjectToDb(); $strReturn .= "Registered Group Admins...\n"; $objGuestGroup = new class_module_user_group(); $objGuestGroup->setStrName("Guests"); $objGuestGroup->updateObjectToDb(); $strReturn .= "Registered Group Guests...\n"; //Systemid of guest-user & admin group $strGuestID = $objGuestGroup->getSystemid(); $strAdminID = $objAdminGroup->getSystemid(); $this->registerConstant("_guests_group_id_", $strGuestID, class_module_system_setting::$int_TYPE_STRING, _user_modul_id_); $this->registerConstant("_admins_group_id_", $strAdminID, class_module_system_setting::$int_TYPE_STRING, _user_modul_id_); //Create an root-record for the tree //So, lets generate the record $strQuery = "INSERT INTO " . _dbprefix_ . "system\n ( system_id, system_prev_id, system_module_nr, system_create_date, system_lm_time, system_status, system_sort, system_class) VALUES\n (?, ?, ?, ?, ?, ?, ?, ?)"; //Send the query to the db $this->objDB->_pQuery($strQuery, array(0, 0, _system_modul_id_, class_date::getCurrentTimestamp(), time(), 1, 1, "class_module_system_common")); //BUT: We have to modify the right-record of the root node, too $strGroupsAll = $strGuestID . "," . $strAdminID; $strGroupsAdmin = $strAdminID; $strQuery = "INSERT INTO " . _dbprefix_ . "system_right\n (right_id, right_inherit, right_view, right_edit, right_delete, right_right, right_right1, right_right2, right_right3, right_right4, right_right5, right_changelog) VALUES\n (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $this->objDB->_pQuery($strQuery, array(0, 0, $strGroupsAll, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin)); $this->objDB->flushQueryCache(); $strReturn .= "Modified root-rights....\n"; class_carrier::getInstance()->getObjRights()->rebuildRightsStructure(); $strReturn .= "Rebuilt rights structures...\n"; //Creating an admin-user $strUsername = "******"; $strPassword = "******"; $strEmail = ""; //Login-Data given from installer? if ($this->objSession->getSession("install_username") !== false && $this->objSession->getSession("install_username") != "" && $this->objSession->getSession("install_password") !== false && $this->objSession->getSession("install_password") != "") { $strUsername = $this->objSession->getSession("install_username"); $strPassword = $this->objSession->getSession("install_password"); $strEmail = $this->objSession->getSession("install_email"); } //create a default language $strReturn .= "Creating new default-language\n"; $objLanguage = new class_module_languages_language(); if ($this->strContentLanguage == "de") { $objLanguage->setStrName("de"); } else { $objLanguage->setStrName("en"); } $objLanguage->setBitDefault(true); $objLanguage->updateObjectToDb(); $strReturn .= "ID of new language: " . $objLanguage->getSystemid() . "\n"; //the admin-language $strAdminLanguage = $this->objSession->getAdminLanguage(); //creating a new default-aspect $strReturn .= "Registering new default aspects...\n"; $objAspect = new class_module_system_aspect(); $objAspect->setStrName("content"); $objAspect->setBitDefault(true); $objAspect->updateObjectToDb(); class_module_system_aspect::setCurrentAspectId($objAspect->getSystemid()); $objAspect = new class_module_system_aspect(); $objAspect->setStrName("management"); $objAspect->updateObjectToDb(); $objUser = new class_module_user_user(); $objUser->setStrUsername($strUsername); $objUser->setIntActive(1); $objUser->setIntAdmin(1); $objUser->setStrAdminlanguage($strAdminLanguage); $objUser->updateObjectToDb(); $objUser->getObjSourceUser()->setStrPass($strPassword); $objUser->getObjSourceUser()->setStrEmail($strEmail); $objUser->getObjSourceUser()->updateObjectToDb(); $strReturn .= "Created User Admin: <strong>Username: "******", Password: ***********</strong> ...\n"; //The Admin should belong to the admin-Group $objAdminGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser()); $strReturn .= "Registered Admin in Admin-Group...\n"; $strReturn .= "Assigning modules to default aspects...\n"; $objModule = class_module_system_module::getModuleByName("system"); $objModule->setStrAspect(class_module_system_aspect::getAspectByName("management")->getSystemid()); $objModule->updateObjectToDb(); $objModule = class_module_system_module::getModuleByName("user"); $objModule->setStrAspect(class_module_system_aspect::getAspectByName("management")->getSystemid()); $objModule->updateObjectToDb(); $objModule = class_module_system_module::getModuleByName("languages"); $objModule->setStrAspect(class_module_system_aspect::getAspectByName("management")->getSystemid()); $objModule->updateObjectToDb(); $strReturn .= "Trying to copy the *.root files to top-level...\n"; $arrFiles = array("index.php", "image.php", "xml.php", ".htaccess", "v3_v4_postupdate.php"); foreach ($arrFiles as $strOneFile) { if (!file_exists(_realpath_ . "/" . $strOneFile) && is_file(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/" . $strOneFile . ".root")) { if (!copy(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/" . $strOneFile . ".root", _realpath_ . "/" . $strOneFile)) { $strReturn .= "<b>Copying " . $strOneFile . ".root to top level failed!!!</b>"; } } } $strReturn .= "Setting messaging to pos 1 in navigation.../n"; $objModule = class_module_system_module::getModuleByName("messaging"); $objModule->setAbsolutePosition(1); return $strReturn; }
public function testChangelogIntervalChanges() { $strSystemid = generateSystemid(); $objStartDate = new class_date(); $objEndDate = new class_date(); $objMiddleDate = new class_date(); $objStartDate->setIntYear(2012)->setIntMonth(10)->setIntDay(1)->setIntHour(10)->setIntMin(0)->setIntSec(0); $objMiddleDate->setIntYear(2012)->setIntMonth(11)->setIntDay(1)->setIntHour(10)->setIntMin(0)->setIntSec(0); $objEndDate->setIntYear(2012)->setIntMonth(12)->setIntDay(1)->setIntHour(10)->setIntMin(0)->setIntSec(0); $objChanges = new class_module_system_changelog(); $objChanges->createLogEntry(new dummyObject($strSystemid), 1); $objChanges->processCachedInserts(); $strQuery = "INSERT INTO " . _dbprefix_ . "changelog\n (change_id,\n change_date,\n change_systemid,\n change_system_previd,\n change_user,\n change_class,\n change_action,\n change_property,\n change_oldvalue,\n change_newvalue) VALUES\n (?,?,?,?,?,?,?,?,?,?)"; class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array(generateSystemid(), $objStartDate->getLongTimestamp(), $strSystemid, "", "", "dummyObject", "edit", "test2", "", "1")); class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array(generateSystemid(), $objMiddleDate->getLongTimestamp(), $strSystemid, "", "", "dummyObject", "edit", "test2", "1", "2")); class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array(generateSystemid(), $objEndDate->getLongTimestamp(), $strSystemid, "", "", "dummyObject", "edit", "test2", "2", "3")); //start middle end // 1 2 3 $objStartDate->setIntDay(2); $objEndDate->setIntHour(9); class_module_system_changelog::changeValueForInterval($strSystemid, "edit", "test2", "", "dummyObject", "", "a", $objStartDate, $objEndDate); $objStartDate->setIntDay(1); $this->assertEquals("1", $objChanges->getValueForDate($strSystemid, "test2", $objStartDate)); $objStartDate->setIntDay(2); $this->assertEquals("a", $objChanges->getValueForDate($strSystemid, "test2", $objStartDate)); $this->assertEquals("a", $objChanges->getValueForDate($strSystemid, "test2", $objMiddleDate)); $objEndDate->setIntHour(8); $this->assertEquals("a", $objChanges->getValueForDate($strSystemid, "test2", $objEndDate)); $objEndDate->setIntHour(9); $this->assertEquals("2", $objChanges->getValueForDate($strSystemid, "test2", $objEndDate)); $objEndDate->setIntHour(11); $this->assertEquals("3", $objChanges->getValueForDate($strSystemid, "test2", $objEndDate)); }
/** * Generates an entry in the logtable * * @param $strQueryParams * @param $strIp * @param $strHostname */ public static function generateDlLog($strQueryParams, $strIp, $strHostname) { $objDB = class_carrier::getInstance()->getObjDB(); $strQuery = "INSERT INTO " . _dbprefix_ . "packageserver_log\n\t (log_id, log_query, log_ip, log_hostname, log_date) VALUES\n\t (?, ?, ?, ?, ?)"; $objDB->_pQuery($strQuery, array(generateSystemid(), $strQueryParams, $strIp, $strHostname, class_date::getCurrentTimestamp())); }
/** * Saves the passed Element to the database (edit or new modes) * * @throws class_exception * @return string "" in case of success */ protected function actionSaveElement() { $strReturn = ""; //There are two modes - edit and new //The element itself just knows the edit mode, so in case of new, we have to create a dummy element - before //passing control to the element if ($this->getParam("mode") == "new") { //Using the passed placeholder-param to load the element and get the table $strPlaceholder = $this->getParam("placeholder"); //Split up the placeholder $arrPlaceholder = explode("_", $strPlaceholder); $strPlaceholderName = $arrPlaceholder[0]; $strPlaceholderElement = $this->getParam("element"); //Now, load all infos about the requested element $objElement = class_module_pages_element::getElement($strPlaceholderElement); //Load the class to create an object $strElementClass = str_replace(".php", "", $objElement->getStrClassAdmin()); //and finally create the object /** @var class_element_admin $objElement */ $objElement = new $strElementClass(); //really continue? try to validate the passed data. if ($objElement->getAdminForm() !== null && !$objElement->getAdminForm()->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionNew(true); return $strReturn; } else { if (!$objElement->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionNew(true); return $strReturn; } } //So, lets do the magic - create the records $objPageElement = new class_module_pages_pageelement(); $objPageElement->setStrName($strPlaceholderName); $objPageElement->setStrPlaceholder($strPlaceholder); $objPageElement->setStrElement($strPlaceholderElement); $objPageElement->setStrLanguage($this->getParam("page_element_ph_language")); if (!$objPageElement->updateObjectToDb($this->getSystemid())) { throw new class_exception("Error saving new element-object to db", class_exception::$level_ERROR); } $strElementSystemId = $objPageElement->getSystemid(); $objLockmanager = new class_lockmanager($strElementSystemId); $objLockmanager->lockRecord(); //To have the element working as expected, set the systemid $this->setSystemid($strElementSystemId); } // ************************************* Edit the current Element ******************************* //check, if the element isn't locked $objCommons = new class_module_system_common($this->getSystemid()); $strPageSystemid = $objCommons->getPrevId(); $objLockmanager = new class_lockmanager($this->getSystemid()); if ($objLockmanager->isLockedByCurrentUser()) { //Load the data of the current element $objElementData = new class_module_pages_pageelement($this->getSystemid()); /** @var $objElement class_element_admin */ $objElement = $objElementData->getConcreteAdminInstance(); //really continue? try to validate the passed data. if ($objElement->getAdminForm() !== null && !$objElement->getAdminForm()->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionEdit(true); return $strReturn; } else { if (!$objElement->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionEdit(true); return $strReturn; } } //pass the data to the element, maybe the element wants to update some data $objElement->setArrParamData($this->getAllParams()); if ($objElement->getAdminForm() !== null) { $objElement->getAdminForm()->updateSourceObject(); } $objElement->doBeforeSaveToDb(); //check, if we could save the data, so the element needn't to //woah, we are soooo great $objElement->updateForeignElement(); //Edit Date of page & unlock $objPage = class_objectfactory::getInstance()->getObject($strPageSystemid); $objPage->updateObjectToDb(); $objLockmanager->unlockRecord(); //And update the internal comment and language $objElementData->setStrTitle($this->getParam("page_element_ph_title")); $objElementData->setStrLanguage($this->getParam("page_element_ph_language")); //placeholder to update? if ($this->getParam("placeholder") != "") { $objElementData->setStrPlaceholder($this->getParam("placeholder")); } $objStartDate = new class_date("0"); $objEndDate = new class_date("0"); $objStartDate->generateDateFromParams("start", $this->getAllParams()); $objEndDate->generateDateFromParams("end", $this->getAllParams()); if ($objStartDate->getIntYear() == "0000") { $objElementData->setObjStartDate(null); } else { $objElementData->setObjStartDate($objStartDate); } if ($objEndDate->getIntYear() == "0000") { $objElementData->setObjEndDate(null); } else { $objElementData->setObjEndDate($objEndDate); } if (!$objElementData->updateObjectToDb()) { throw new class_exception("Error updating object to db", class_exception::$level_ERROR); } //allow the element to run actions after saving $objElement->doAfterSaveToDb(); //Loading the data of the corresponding site $objPage = new class_module_pages_page($strPageSystemid); $this->flushCompletePagesCache(); if ($this->getParam("peClose") == "1") { //generate the elements' output $objPortalElement = $objElementData->getConcretePortalInstance(); $strElementContent = $objPortalElement->getElementOutput(); $strContent = json_encode($strElementContent, JSON_FORCE_OBJECT); //JSON_HEX_QUOT|JSON_HEX_APOS $strReturn = <<<JS parent.KAJONA.admin.portaleditor.changeElementData('{$objElementData->getStrPlaceholder()}', '{$objElementData->getSystemid()}', {$strContent}); parent.KAJONA.admin.portaleditor.closeDialog(true); JS; class_carrier::getInstance()->setParam("peClose", null); return "<script type='text/javascript'>{$strReturn}</script>"; } $this->adminReload(class_link::getLinkAdminHref("pages_content", "list", "systemid=" . $objPage->getSystemid())); } else { $strReturn = $this->objToolkit->warningBox($this->getLang("ds_gesperrt")); } return $strReturn; }
/** * Method used to validate posted form-values. * NOTE: To work with this method, the derived class needs to implement * a method "getRequiredFields()", returning an array of field to validate. * The array returned by getRequiredFields() has to fit the format * [fieldname] = type, whereas type can be one of * string, number, email, folder, systemid * The array saved in $this->$arrValidationErrors return by this method is empty in case of no validation Errors, * otherwise an array with the structure * [nonvalidField] = text from objText * is being created. * * @return bool * @deprecated */ public function validateForm() { $arrReturn = array(); $arrFieldsToCheck = $this->getRequiredFields(); foreach ($arrFieldsToCheck as $strFieldname => $strType) { //backwards compatibility if ($strType == "string") { $strType = "text"; } //backwards compatibility if ($strType == "number") { $strType = "numeric"; } $strValue = $this->getParam($strFieldname); if ($strType == "date") { $objDate = new class_date("0"); $objDate->generateDateFromParams($strFieldname, $this->getAllParams()); $strValue = $objDate; } $objValidator = $this->getValidatorInstance($strType); if (!$objValidator->validate($strValue)) { if ($this->getLang("required_" . $strFieldname) != "!required_" . $strFieldname . "!") { $arrReturn[$strFieldname] = $this->getLang("required_" . $strFieldname); } else { if ($this->getLang($strFieldname) != "!" . $strFieldname . "!") { $arrReturn[$strFieldname] = $this->getLang($strFieldname); } else { $arrReturn[$strFieldname] = $this->getLang("required_" . $strFieldname); } } } } $this->arrValidationErrors = array_merge($this->arrValidationErrors, $arrReturn); return count($this->arrValidationErrors) == 0; }
public function testSetBeginningOfDay() { $objDate = new class_date(20150901133737); $objDate->setBeginningOfDay(); $this->assertEquals($objDate->getLongTimestamp(), 20150901000000); }
/** * @return array */ public function getTotalUniqueHostsInInterval() { $objStart = new class_date($this->intDateStart); $objEnd = new class_date($this->intDateEnd); $strQuery = "SELECT log_hostname, COUNT(*) as anzahl\n\t\t\t\t\t\tFROM " . _dbprefix_ . "packageserver_log\n\t\t\t\t\t\tWHERE log_date > ?\n\t\t\t\t\t\t AND log_date <= ?\n\t\t\t\t GROUP BY log_hostname\n\t\t\t\t ORDER BY anzahl DESC"; $arrRow = $this->objDB->getPArray($strQuery, array($objStart->getLongTimestamp(), $objEnd->getLongTimestamp())); return $arrRow; }
/** * Generates a long-timestamp of the current time * * @return int */ public static function getCurrentTimestamp() { $objDate = new class_date(); return $objDate->getLongTimestamp(); }
/** * Converts a dateobject to a readable string * * @param class_date $objDate * @param bool $bitLong * @param string $strFormat if given, the passed format will be used, otherwise the format defined in the i18n files * usable placeholders are: d, m, y, h, i, s * * @return string */ function dateToString($objDate, $bitLong = true, $strFormat = "") { $strReturn = ""; //if the $objDate is a string, convert it to date object if ($objDate != null && !$objDate instanceof class_date && uniEreg("([0-9]){14}", $objDate)) { $objDate = new class_date($objDate); } if ($objDate instanceof class_date) { //convert to a current date if ($strFormat == "") { if ($bitLong) { $strReturn = uniStrtolower(class_carrier::getInstance()->getObjLang()->getLang("dateStyleLong", "system")); } else { $strReturn = uniStrtolower(class_carrier::getInstance()->getObjLang()->getLang("dateStyleShort", "system")); } } else { $strReturn = $strFormat; } //"d.m.Y H:i:s"; $strReturn = uniStrReplace("d", $objDate->getIntDay(), $strReturn); $strReturn = uniStrReplace("m", $objDate->getIntMonth(), $strReturn); $strReturn = uniStrReplace("y", $objDate->getIntYear(), $strReturn); $strReturn = uniStrReplace("h", $objDate->getIntHour(), $strReturn); $strReturn = uniStrReplace("i", $objDate->getIntMin(), $strReturn); $strReturn = uniStrReplace("s", $objDate->getIntSec(), $strReturn); } return $strReturn; }
/** * Loads the list of elements on a single page. * Returns an array of plain data, not the corresponding objects. * In most cases getElementsOnPage is the right way to go. * * * @param string $strPageId * @param bool $bitJustActive * @param string $strLanguage * * @see class_module_pages_pageelement::getElementsOnPage() * @return array */ public static function getPlainElementsOnPage($strPageId, $bitJustActive = false, $strLanguage = "") { //Calculate the current day as a time-stamp. This improves database-caches e.g. the kajona or mysql-query-cache. $objDate = new class_date(); $objDate->setIntMin(0, true); $objDate->setIntSec(0, true); $objDate->setIntHour(0, true); $longToday = $objDate->getLongTimestamp(); $arrParams = array($strPageId, $strLanguage); $objORM = new class_orm_objectlist(); $strAnd = ""; if ($bitJustActive) { $strAnd = "AND system_status = 1\n AND ( system_date_start IS null OR (system_date_start = 0 OR system_date_start <= ?))\n AND ( system_date_end IS null OR (system_date_end = 0 OR system_date_end >= ?)) "; $arrParams[] = $longToday; $arrParams[] = $longToday; } $strQuery = "SELECT *\n FROM " . _dbprefix_ . "page_element,\n " . _dbprefix_ . "element,\n " . _dbprefix_ . "system_right,\n " . _dbprefix_ . "system as system\n LEFT JOIN " . _dbprefix_ . "system_date\n ON (system_id = system_date_id)\n WHERE system_prev_id= ?\n AND page_element_ph_element = element_name\n AND system_id = page_element_id\n AND system_id = right_id\n AND page_element_ph_language = ?\n " . $strAnd . "\n " . $objORM->getDeletedWhereRestriction() . "\n ORDER BY page_element_ph_placeholder ASC,\n page_element_ph_language ASC,\n system_sort ASC"; $arrReturn = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, $arrParams); foreach ($arrReturn as $arrOneRow) { class_orm_rowcache::addSingleInitRow($arrOneRow); } return $arrReturn; }