コード例 #1
0
 /**
  * Gets the working days for a given month and year.
  * Working days are all TAGERT2-Days.
  *
  * @param $intMonth
  * @param $intYear
  *
  * @return array of class_date objects
  */
 public function getWorkingDays($intMonth, $intYear)
 {
     $arrWorkingDays = array();
     $objDate = new class_date();
     $objDate->setIntYear($intYear)->setIntMonth($intMonth)->setIntDay(1)->setIntHour(0)->setIntMin(0)->setIntSec(0);
     while ($objDate->getIntMonth() == $intMonth) {
         if ($this->isValidTarget2Day($objDate)) {
             $arrWorkingDays[] = clone $objDate;
         }
         $objDate->setNextDay();
     }
     return $arrWorkingDays;
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 /**
  * @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("&nbsp;");
             $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;
 }
コード例 #4
0
 /**
  * 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 "";
 }
コード例 #5
0
    /**
     * Creates a calendar-based view of the current month.
     * Single objects may register themselves to be rendered within the calendar.
     * The calendar-view consists of a view single elements:
     * +---------------------------+
     * | control-elements (pager)  |
     * +---------------------------+
     * | wrapper                   |
     * +---------------------------+
     * | the column headers        |
     * +---------------------------+
     * | a row for each week (4x)  |
     * +---------------------------+
     * | wrapper                   |
     * +---------------------------+
     * | legend                    |
     * +---------------------------+
     *
     * The calendar internally is loaded via ajax since fetching all events
     * may take some time.
     *
     * @return string
     * @since 3.4
     * @autoTestable
     * @permissions view
     */
    protected function actionCalendar()
    {
        $strReturn = "";
        //save dates to session
        if ($this->getParam("month") != "") {
            $this->objSession->setSession($this->strStartMonthKey, $this->getParam("month"));
        }
        if ($this->getParam("year") != "") {
            $this->objSession->setSession($this->strStartYearKey, $this->getParam("year"));
        }
        $strContainerId = generateSystemid();
        $strContent = "<script type=\"text/javascript\">";
        $strContent .= <<<JS
            \$(document).ready(function() {
                  KAJONA.admin.ajax.genericAjaxCall("dashboard", "renderCalendar", "{$strContainerId}", function(data, status, jqXHR) {
                    if(status == 'success') {
                        var intStart = data.indexOf("[CDATA[")+7;
                        \$("#{$strContainerId}").html(data.substr(
                          intStart, data.indexOf("]]")-intStart
                        ));
                        if(data.indexOf("[CDATA[") < 0) {
                            var intStart = data.indexOf("<error>")+7;
                            \$("#{$strContainerId}").html(o.responseText.substr(
                              intStart, data.indexOf("</error>")-intStart
                            ));
                        }
                        KAJONA.util.evalScript(data);
                        KAJONA.admin.tooltip.initTooltip();
                    }
                    else {
                        KAJONA.admin.statusDisplay.messageError("<b>Request failed!</b><br />" + data);
                    }
                  })
            });
JS;
        $strContent .= "</script>";
        //fetch modules relevant for processing
        $arrLegendEntries = array();
        $arrFilterEntries = array();
        $arrModules = class_module_system_module::getAllModules();
        foreach ($arrModules as $objSingleModule) {
            /** @var $objAdminInstance interface_calendarsource_admin|class_module_system_module */
            $objAdminInstance = $objSingleModule->getAdminInstanceOfConcreteModule();
            if ($objSingleModule->getIntRecordStatus() == 1 && $objAdminInstance instanceof interface_calendarsource_admin) {
                //TODO: switch to plugin manager
                $arrLegendEntries = array_merge($arrLegendEntries, $objAdminInstance->getArrLegendEntries());
                $arrFilterEntries = array_merge($arrFilterEntries, $objAdminInstance->getArrFilterEntries());
            }
        }
        if ($this->getParam("doCalendarFilter") != "") {
            //update filter-criteria
            foreach (array_keys($arrFilterEntries) as $strOneId) {
                if ($this->getParam($strOneId) != "") {
                    $this->objSession->sessionUnset($strOneId);
                } else {
                    $this->objSession->setSession($strOneId, "disabled");
                }
            }
        }
        //render the single rows. calculate the first day of the row
        $objDate = new class_date();
        $objDate->setIntDay(1);
        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));
        }
        //pager-setup
        $objEndDate = clone $objDate;
        $objEndDate->setNextMonth();
        $objEndDate->setPreviousDay();
        $strCenter = dateToString($objDate, false) . " - " . dateToString($objEndDate, false);
        $objEndDate->setNextDay();
        $objPrevDate = clone $objDate;
        $objPrevDate->setPreviousDay();
        $strPrev = class_link::getLinkAdmin($this->getArrModule("modul"), "calendar", "&month=" . $objPrevDate->getIntMonth() . "&year=" . $objPrevDate->getIntYear(), $this->getLang("calendar_prev"));
        $strNext = class_link::getLinkAdmin($this->getArrModule("modul"), "calendar", "&month=" . $objEndDate->getIntMonth() . "&year=" . $objEndDate->getIntYear(), $this->getLang("calendar_next"));
        $strReturn .= $this->objToolkit->getCalendarPager($strPrev, $strCenter, $strNext);
        $strReturn .= $strContent;
        $strReturn .= $this->objToolkit->getCalendarContainer($strContainerId);
        $strReturn .= $this->objToolkit->getCalendarLegend($arrLegendEntries);
        $strReturn .= $this->objToolkit->getCalendarFilter($arrFilterEntries);
        return $strReturn;
    }