/**
  * Returns an instance of system wide event-dispatcher
  * @return class_core_eventdispatcher
  */
 public static function getInstance()
 {
     if (self::$objInstance == null) {
         self::$objInstance = new class_core_eventdispatcher();
     }
     return self::$objInstance;
 }
 public function testEventHandler()
 {
     self::$bitHandled = false;
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("test");
     $objAspect->updateObjectToDb();
     class_core_eventdispatcher::getInstance()->addListener(class_system_eventidentifier::EVENT_SYSTEM_STATUSCHANGED, new class_test_statuchangedhandler($objAspect->getSystemid(), $this));
     $this->assertTrue(!self::$bitHandled);
     $objAspect->setIntRecordStatus(0);
     $this->assertTrue(!self::$bitHandled);
     $objAspect->updateObjectToDb();
     $this->assertTrue(self::$bitHandled);
     $objAspect->deleteObjectFromDatabase();
 }
 /**
  * Global controller entry, triggers all further actions, splits up admin- and portal loading
  *
  * @param bool $bitAdmin
  * @param string $strModule
  * @param string $strAction
  * @param string $strLanguageParam
  *
  * @return string
  */
 public function processRequest($bitAdmin, $strModule, $strAction, $strLanguageParam)
 {
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_STARTPROCESSING, array($bitAdmin, $strModule, $strAction, $strLanguageParam));
     if ($bitAdmin) {
         $strReturn = $this->processAdminRequest($strModule, $strAction, $strLanguageParam);
         $strReturn = $this->callScriptlets($strReturn, interface_scriptlet::BIT_CONTEXT_ADMIN);
     } else {
         $strReturn = $this->processPortalRequest($strModule, $strAction, $strLanguageParam);
         $strReturn = $this->callScriptlets($strReturn, interface_scriptlet::BIT_CONTEXT_PORTAL_PAGE);
     }
     $strReturn = $this->cleanupOutput($strReturn);
     $strReturn = $this->getDebugInfo($strReturn);
     $this->sendConditionalGetHeaders($strReturn);
     $this->objResponse->setStrContent($strReturn);
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_ENDPROCESSING, array($bitAdmin, $strModule, $strAction, $strLanguageParam));
     $this->objSession->sessionClose();
 }
 /**
  * Deletes a user from the systems
  *
  * @throws class_exception
  * @return bool
  */
 public function deleteObject()
 {
     if ($this->objSession->getUserID() == $this->getSystemid()) {
         throw new class_exception("You can't delete yourself", class_exception::$level_FATALERROR);
     }
     class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("deleted user with id " . $this->getSystemid() . " (" . $this->getStrUsername() . " / " . $this->getStrName() . "," . $this->getStrForename() . ")", class_logger::$levelWarning);
     $this->getObjSourceUser()->deleteUser();
     $strQuery = "UPDATE " . _dbprefix_ . "user SET user_deleted = 1, user_active = 0 WHERE user_id = ?";
     $bitReturn = $this->objDB->_pQuery($strQuery, array($this->getSystemid()));
     //call other models that may be interested
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED, array($this->getSystemid(), get_class($this)));
     return $bitReturn;
 }
 /**
  * Internal init to register the event listener, called on file-inclusion, e.g. by the class-loader
  * @return void
  */
 public static function staticConstruct()
 {
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, new class_module_search_request_endprocessinglistener());
 }
 /**
  * Triggers the update sequence for assignment properties
  * @return bool
  */
 private function updateAssignments()
 {
     $bitReturn = true;
     $objReflection = new class_reflection($this->getObjObject());
     //get the mapped properties
     $arrProperties = $objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_OBJECTLIST, class_reflection_enum::PARAMS());
     foreach ($arrProperties as $strPropertyName => $arrValues) {
         $objCfg = class_orm_assignment_config::getConfigForProperty($this->getObjObject(), $strPropertyName);
         //try to load the orm config of the arrayObject - if given
         $strGetter = $objReflection->getGetter($strPropertyName);
         $arrValues = null;
         if ($strGetter !== null) {
             $arrValues = call_user_func(array($this->getObjObject(), $strGetter));
         }
         $objAssignmentDeleteHandling = $this->getIntCombinedLogicalDeletionConfig();
         if ($arrValues != null && $arrValues instanceof class_orm_assignment_array) {
             $objAssignmentDeleteHandling = $arrValues->getObjDeletedHandling();
         }
         //try to restore the object-set from the database using the same config as when initializing the object
         $objOldHandling = $this->getIntCombinedLogicalDeletionConfig();
         $this->setObjHandleLogicalDeleted($objAssignmentDeleteHandling);
         $arrAssignmentsFromObject = $this->getAssignmentValuesFromObject($strPropertyName, $objCfg->getArrTypeFilter());
         $arrAssignmentsFromDatabase = $this->getAssignmentsFromDatabase($strPropertyName);
         $this->setObjHandleLogicalDeleted($objOldHandling);
         //if the delete handling was set to excluded when loading the assignment, the logically deleted nodes should be merged with the values from db
         if ($objAssignmentDeleteHandling->equals(class_orm_deletedhandling_enum::EXCLUDED())) {
             $this->setObjHandleLogicalDeleted(class_orm_deletedhandling_enum::EXCLUSIVE());
             $arrDeletedIds = $this->getAssignmentsFromDatabase($strPropertyName);
             $this->setObjHandleLogicalDeleted($objOldHandling);
             foreach ($arrDeletedIds as $strOneId) {
                 if (!in_array($strOneId, $arrAssignmentsFromDatabase)) {
                     $arrAssignmentsFromDatabase[] = $strOneId;
                 }
                 if (!in_array($strOneId, $arrAssignmentsFromObject)) {
                     $arrAssignmentsFromObject[] = $strOneId;
                 }
             }
         }
         sort($arrAssignmentsFromObject);
         sort($arrAssignmentsFromDatabase);
         //only do s.th. if the array differs
         $arrNewAssignments = array_diff($arrAssignmentsFromObject, $arrAssignmentsFromDatabase);
         $arrDeletedAssignments = array_diff($arrAssignmentsFromDatabase, $arrAssignmentsFromObject);
         //skip in case there's nothing to do
         if (count($arrNewAssignments) == 0 && count($arrDeletedAssignments) == 0) {
             continue;
         }
         $objDB = class_carrier::getInstance()->getObjDB();
         $arrInserts = array();
         foreach ($arrAssignmentsFromObject as $strOneTargetId) {
             $arrInserts[] = array($this->getObjObject()->getSystemid(), $strOneTargetId);
         }
         $bitReturn = $bitReturn && $objDB->_pQuery("DELETE FROM " . $objDB->encloseTableName(_dbprefix_ . $objCfg->getStrTableName()) . " WHERE " . $objDB->encloseColumnName($objCfg->getStrSourceColumn()) . " = ?", array($this->getObjObject()->getSystemid()));
         $bitReturn = $bitReturn && $objDB->multiInsert($objCfg->getStrTableName(), array($objCfg->getStrSourceColumn(), $objCfg->getStrTargetColumn()), $arrInserts);
         $bitReturn = $bitReturn && class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_OBJECTASSIGNMENTSUPDATED, array(array_values($arrNewAssignments), array_values($arrDeletedAssignments), array_values($arrAssignmentsFromObject), $this->getObjObject(), $strPropertyName));
         if ($objReflection->hasPropertyAnnotation($strPropertyName, class_module_system_changelog::ANNOTATION_PROPERTY_VERSIONABLE)) {
             $objChanges = new class_module_system_changelog();
             $objChanges->setOldValueForSystemidAndProperty($this->getObjObject()->getSystemid(), $strPropertyName, implode(",", $arrAssignmentsFromDatabase));
         }
     }
     return $bitReturn;
 }
Esempio n. 7
0
 /**
  * Updates the current record to the database and saves all relevant fields.
  * Please note that this method is triggered internally.
  *
  * @return bool
  * @final
  * @since 3.4.1
  *
  * @todo find ussages and make private
  */
 protected final function updateSystemrecord()
 {
     if (!validateSystemid($this->getSystemid())) {
         return true;
     }
     class_logger::getInstance()->addLogRow("updated systemrecord " . $this->getStrSystemid() . " data", class_logger::$levelInfo);
     if (class_module_system_module::getModuleByName("system") != null && version_compare(class_module_system_module::getModuleByName("system")->getStrVersion(), 4.5, "lt")) {
         $strQuery = "UPDATE " . _dbprefix_ . "system\n                        SET system_prev_id = ?,\n                            system_module_nr = ?,\n                            system_sort = ?,\n                            system_owner = ?,\n                            system_lm_user = ?,\n                            system_lm_time = ?,\n                            system_lock_id = ?,\n                            system_lock_time = ?,\n                            system_status = ?,\n                            system_comment = ?,\n                            system_class = ?,\n                            system_create_date = ?\n                      WHERE system_id = ? ";
         $bitReturn = $this->objDB->_pQuery($strQuery, array($this->getStrPrevId(), (int) $this->getIntModuleNr(), (int) $this->getIntSort(), $this->getStrOwner(), $this->objSession->getUserID(), time(), $this->getStrLockId(), (int) $this->getIntLockTime(), (int) $this->getIntRecordStatus(), uniStrTrim($this->getStrRecordComment(), 245), $this->getStrRecordClass(), $this->getLongCreateDate(), $this->getSystemid()));
     } else {
         $strQuery = "UPDATE " . _dbprefix_ . "system\n                        SET system_prev_id = ?,\n                            system_module_nr = ?,\n                            system_sort = ?,\n                            system_owner = ?,\n                            system_lm_user = ?,\n                            system_lm_time = ?,\n                            system_lock_id = ?,\n                            system_lock_time = ?,\n                            system_status = ?,\n                            system_comment = ?,\n                            system_class = ?,\n                            system_create_date = ?,\n                            system_deleted = ?\n                      WHERE system_id = ? ";
         $bitReturn = $this->objDB->_pQuery($strQuery, array($this->getStrPrevId(), (int) $this->getIntModuleNr(), (int) $this->getIntSort(), $this->getStrOwner(), $this->objSession->getUserID(), time(), $this->getStrLockId(), (int) $this->getIntLockTime(), (int) $this->getIntRecordStatus(), uniStrTrim($this->getStrRecordComment(), 245), $this->getStrRecordClass(), $this->getLongCreateDate(), $this->getIntRecordDeleted(), $this->getSystemid()));
     }
     if ($this->bitDatesChanges) {
         $this->processDateChanges();
     }
     class_carrier::getInstance()->flushCache(class_carrier::INT_CACHE_TYPE_DBQUERIES | class_carrier::INT_CACHE_TYPE_ORMCACHE);
     if ($this->strOldPrevId != $this->strPrevId && $this->strOldPrevId != -1) {
         class_carrier::getInstance()->getObjRights()->rebuildRightsStructure($this->getSystemid());
         class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_PREVIDCHANGED, array($this->getSystemid(), $this->strOldPrevId, $this->strPrevId));
     }
     if ($this->strOldPrevId != $this->strPrevId) {
         $this->objSortManager->fixSortOnPrevIdChange($this->strOldPrevId, $this->strPrevId);
     }
     $this->strOldPrevId = $this->strPrevId;
     $this->intOldRecordStatus = $this->intRecordStatus;
     return $bitReturn;
 }
 /**
  * Internal init to register the event listener, called on file-inclusion, e.g. by the class-loader
  * @return void
  */
 public static function staticConstruct()
 {
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_RECORDUPDATED, new class_module_packagemanager_recordupdatedlistener());
 }
Esempio n. 9
0
 /**
  * Logs a user off from the system
  * @return void
  */
 public function logout()
 {
     class_logger::getInstance()->addLogRow("User: "******" successfully logged out", class_logger::$levelInfo);
     class_module_user_log::registerLogout();
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_USERLOGOUT, array($this->getUserID()));
     $this->getObjInternalSession()->setStrLoginstatus(class_module_system_session::$LOGINSTATUS_LOGGEDOUT);
     $this->getObjInternalSession()->updateObjectToDb();
     $this->getObjInternalSession()->deleteObjectFromDatabase();
     $this->objInternalSession = null;
     $this->objUser = null;
     if (isset($_COOKIE[session_name()])) {
         setcookie(session_name(), '', time() - 42000);
     }
     // Finally, destroy the session.
     session_destroy();
     //start a new one
     $this->sessionStart();
     //and create a new sessid
     @session_regenerate_id();
     $this->initInternalSession();
     return;
 }
 *
 */
class class_module_system_changelog_aftercontentsendlistener implements interface_genericevent_listener
{
    /**
     * Searches for languagesets containing the current systemid. either as a language or a referenced record.
     * Called whenever a records was deleted using the common methods.
     * Implement this method to be notified when a record is deleted, e.g. to to additional cleanups afterwards.
     * There's no need to register the listener, this is done automatically.
     * Make sure to return a matching boolean-value, otherwise the transaction may be rolled back.
     *
     * @param string $strEventName
     * @param array $arrArguments
     *
     * @return bool
     */
    public function handleEvent($strEventName, array $arrArguments)
    {
        $objChangelog = new class_module_system_changelog();
        return $objChangelog->processCachedInserts();
    }
    /**
     * Internal init to register the event listener, called on file-inclusion, e.g. by the class-loader
     * @return void
     */
    public static function staticConstruct()
    {
    }
}
class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, new class_module_system_changelog_aftercontentsendlistener());
 public function testRemoveAndAddListener()
 {
     $objListener1 = new class_module_genericeventdispatcher_test();
     $objListener1->strHandlerName = "handler 1";
     $objListener1->objCallable = function ($strName, $arrArguments) {
         $this->assertEquals($strName, "handler 1");
     };
     $objListener2 = new class_module_genericeventdispatcher_test();
     $objListener2->strHandlerName = "handler 2";
     $objListener2->objCallable = function ($strName, $arrArguments) {
         $this->assertEquals($strName, "handler 2");
     };
     $objDispatcher = class_core_eventdispatcher::getInstance();
     $objDispatcher->addListener("core.system.test.removeandadd", $objListener1);
     $objDispatcher->addListener("core.system.test.removeandadd", $objListener2);
     $arrListeners = $objDispatcher->getRegisteredListeners("core.system.test.removeandadd");
     $this->assertEquals(count($arrListeners), 2);
     $this->assertEquals(array_values($arrListeners)[0]->strHandlerName, "handler 1");
     $this->assertEquals(array_values($arrListeners)[1]->strHandlerName, "handler 2");
     $objListener3 = new class_module_genericeventdispatcher_test();
     $objListener3->strHandlerName = "handler 3";
     $objDispatcher->removeAndAddListener("core.system.test.removeandadd", $objListener3);
     $arrListeners = $objDispatcher->getRegisteredListeners("core.system.test.removeandadd");
     $this->assertEquals(count($arrListeners), 1);
     $this->assertEquals(array_values($arrListeners)[0]->strHandlerName, "handler 3");
 }
Esempio n. 12
0
            echo "Loading path for " . getGet("debugfile") . "\n";
            $strPath = array_search(getGet("debugfile"), class_resourceloader::getInstance()->getFolderContent("/debug", array(".php")));
            if ($strPath !== false) {
                echo "Passing request to " . $strPath . "\n\n";
                include _realpath_ . $strPath;
            }
        } else {
            echo "Searching for debug-scripts available...\n";
            $arrFiles = class_resourceloader::getInstance()->getFolderContent("/debug", array(".php"));
            echo "<ul>";
            foreach ($arrFiles as $strPath => $strOneFile) {
                echo "<li><a href='?debugfile=" . $strOneFile . "' >" . $strOneFile . "</a> <br />" . $strPath . "</li>";
            }
            echo "</ul>";
        }
        $arrTimestampEnde = gettimeofday();
        $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000;
        echo "\n\n<b>PHP-Time:</b>                              " . number_format($intTimeUsed, 6) . " sec \n";
        echo "<b>Queries db/cachesize/cached/fired:</b>     " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . "\n";
        echo "<b>Templates cached:</b>                      " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n";
        echo "<b>Memory/Max Memory:</b>                     " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n";
        echo "<b>Classes Loaded:</b>                        " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n";
        echo "<b>Cache requests/hits/saves/cachesize:</b>   " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n";
        echo "</pre>";
    }
}
header("Content-Type: text/html; charset=utf-8");
$objDebug = new class_debug_helper();
$objDebug->debugHelper();
class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, array(class_request_entrypoint_enum::DEBUG()));
 /**
  * Triggers the indexing of a single object.
  *
  * @param class_model $objInstance
  *
  * @return void
  */
 public function indexObject(class_model $objInstance = null)
 {
     if (!self::isIndexAvailable()) {
         return;
     }
     if ($objInstance != null && $objInstance instanceof class_module_pages_pageelement) {
         $objInstance = $objInstance->getConcreteAdminInstance();
         if ($objInstance != null) {
             $objInstance->loadElementData();
         }
     }
     if ($objInstance == null) {
         return;
     }
     $objSearchDocument = new class_module_search_document();
     $objSearchDocument->setDocumentId(generateSystemid());
     $objSearchDocument->setStrSystemId($objInstance->getSystemid());
     if ($objInstance instanceof interface_search_portalobject) {
         $objSearchDocument->setBitPortalObject(true);
         $objSearchDocument->setStrContentLanguage($objInstance->getContentLang());
     }
     $objReflection = new class_reflection($objInstance);
     $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_ANNOTATION_ADDSEARCHINDEX);
     foreach ($arrProperties as $strPropertyName => $strAnnotationValue) {
         $getter = $objReflection->getGetter($strPropertyName);
         $strContent = $objInstance->{$getter}();
         $objSearchDocument->addContent($strPropertyName, $strContent);
     }
     //trigger event-listeners
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_search_eventidentifier::EVENT_SEARCH_OBJECTINDEXED, array($objInstance, $objSearchDocument));
     $this->updateSearchDocumentToDb($objSearchDocument);
 }
 *
 */
class class_module_system_aspectrecorddeletedlistener implements interface_genericevent_listener
{
    /**
     *
     * @param string $strEventName
     * @param array $arrArguments
     *
     * @return bool
     */
    public function handleEvent($strEventName, array $arrArguments)
    {
        //unwrap arguments
        list($strSystemid, $strSourceClass) = $arrArguments;
        if ($strSourceClass == "class_module_system_aspect") {
            //if we have just one aspect remaining, set this one as default
            if (class_module_system_aspect::getObjectCount() == 1) {
                /** @var class_module_system_aspect[] $arrObjAspects */
                $arrObjAspects = class_module_system_aspect::getObjectList();
                $objOneAspect = $arrObjAspects[0];
                $objOneAspect->setBitDefault(1);
                return $objOneAspect->updateObjectToDb();
            }
        }
        return true;
    }
}
//static inits
class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED_LOGICALLY, new class_module_system_aspectrecorddeletedlistener());
 /**
  * Internal init to register the event listener, called on file-inclusion, e.g. by the class-loader
  * @return void
  */
 public static function staticConstruct()
 {
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED, new class_module_search_objectdeletedlistener());
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED_LOGICALLY, new class_module_search_objectdeletedlistener());
 }
 /**
  * Deletes a user from the systems
  *
  * @return bool
  */
 public function deleteUser()
 {
     class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("deleted user with id " . $this->getSystemid(), class_logger::$levelInfo);
     $this->deleteAllUserMemberships();
     $strQuery = "DELETE FROM " . _dbprefix_ . "user_kajona WHERE user_id=?";
     //call other models that may be interested
     $bitDelete = $this->objDB->_pQuery($strQuery, array($this->getSystemid()));
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED, array($this->getSystemid(), get_class($this)));
     return $bitDelete;
 }
 /**
  * Internal init block, called on file-inclusion, e.g. by the class-loader
  *
  * @return void
  */
 public static function staticConstruct()
 {
     class_core_eventdispatcher::getInstance()->removeAndAddListener("core.search.objectindexed", new class_module_tags_objectindexedlistener());
 }
{
    /**
     * This generic method is called in case of dispatched events.
     * The first param is the name of the event, the second argument is an array of
     * event-specific arguments.
     * Make sure to return a matching boolean value, indicating if the event-process was successful or not. The event source may
     * depend on a valid return value.
     *
     * @param string $strEventIdentifier
     * @param array $arrArguments
     *
     * @return bool
     */
    public function handleEvent($strEventIdentifier, array $arrArguments)
    {
        /** @var class_request_entrypoint_enum $objEntrypoint */
        $objEntrypoint = $arrArguments[0];
        if ($objEntrypoint->equals(class_request_entrypoint_enum::INDEX()) && class_carrier::getInstance()->getParam("admin") == "") {
            //process stats request
            $objStats = class_module_system_module::getModuleByName("stats");
            if ($objStats != null) {
                //Collect Data
                $objLanguage = new class_module_languages_language();
                $objStats = new class_module_stats_worker();
                $objStats->createStatsEntry(getServer("REMOTE_ADDR"), time(), class_carrier::getInstance()->getParam("page"), rtrim(getServer("HTTP_REFERER"), "/"), getServer("HTTP_USER_AGENT"), $objLanguage->getPortalLanguage());
            }
        }
    }
}
class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, new class_module_stats_processinglistener());
 /**
  * Deletes the given group
  *
  * @return bool
  */
 public function deleteObjectFromDatabase()
 {
     class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("deleted group with id " . $this->getSystemid() . " (" . $this->getStrName() . ")", class_logger::$levelWarning);
     //Delete related group
     $this->getObjSourceGroup()->deleteGroup();
     $strQuery = "DELETE FROM " . _dbprefix_ . "user_group WHERE group_id=?";
     $bitReturn = $this->objDB->_pQuery($strQuery, array($this->getSystemid()));
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED, array($this->getSystemid(), get_class($this)));
     return $bitReturn;
 }
 /**
  * Internal init to register the event listener, called on file-inclusion, e.g. by the class-loader
  * @return void
  */
 public static function staticConstruct()
 {
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_USERLOGOUT, new class_module_system_userlogoutlistener());
 }
 public function testObjectassignmentEventHandling()
 {
     $objDB = class_carrier::getInstance()->getObjDB();
     $objHandler = new orm_objectlist_testhandler();
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_OBJECTASSIGNMENTSUPDATED, $objHandler);
     /** @var orm_objectlist_testclass $objTestobject */
     $objTestobject = $this->getObject("testobject");
     $arrAspects = array($this->getObject("aspect1"), $this->getObject("aspect2"));
     $objTestobject->setArrObject1($arrAspects);
     $this->assertTrue($objHandler->arrCurrentAssignments == null);
     $this->assertTrue($objHandler->arrNewAssignments == null);
     $this->assertTrue($objHandler->arrRemovedAssignments == null);
     $this->assertTrue($objHandler->objObject == null);
     $this->assertTrue($objHandler->strProperty == null);
     $objTestobject->updateObjectToDb();
     $this->assertEquals(count($objHandler->arrNewAssignments), 2);
     $this->assertEquals(count($objHandler->arrRemovedAssignments), 0);
     $this->assertEquals(count($objHandler->arrCurrentAssignments), 2);
     $this->assertTrue(in_array($objHandler->arrNewAssignments[0], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     $this->assertTrue(in_array($objHandler->arrNewAssignments[1], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     $this->assertTrue(in_array($objHandler->arrCurrentAssignments[0], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     $this->assertTrue(in_array($objHandler->arrCurrentAssignments[1], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     //change the assignments
     $objHandler = new orm_objectlist_testhandler();
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_OBJECTASSIGNMENTSUPDATED, $objHandler);
     $objTestobject = $this->getObject("testobject");
     $arrAspects = array($this->getObject("aspect2"));
     $objTestobject->setArrObject1($arrAspects);
     $this->assertTrue($objHandler->arrCurrentAssignments == null);
     $this->assertTrue($objHandler->arrNewAssignments == null);
     $this->assertTrue($objHandler->arrRemovedAssignments == null);
     $this->assertTrue($objHandler->objObject == null);
     $this->assertTrue($objHandler->strProperty == null);
     $objTestobject->updateObjectToDb();
     $this->assertEquals(count($objHandler->arrNewAssignments), 0);
     $this->assertEquals(count($objHandler->arrRemovedAssignments), 1);
     $this->assertEquals(count($objHandler->arrCurrentAssignments), 1);
     $this->assertTrue(in_array($objHandler->arrRemovedAssignments[0], array($this->getObject("aspect1")->getSystemid())));
     $this->assertTrue(in_array($objHandler->arrCurrentAssignments[0], array($this->getObject("aspect2")->getSystemid())));
     //change the assignments
     $objHandler = new orm_objectlist_testhandler();
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_OBJECTASSIGNMENTSUPDATED, $objHandler);
     $objTestobject = $this->getObject("testobject");
     $objTestobject->setArrObject1(array());
     $this->assertTrue($objHandler->arrCurrentAssignments == null);
     $this->assertTrue($objHandler->arrNewAssignments == null);
     $this->assertTrue($objHandler->arrRemovedAssignments == null);
     $this->assertTrue($objHandler->objObject == null);
     $this->assertTrue($objHandler->strProperty == null);
     $objTestobject->updateObjectToDb();
     $this->assertEquals(count($objHandler->arrNewAssignments), 0);
     $this->assertEquals(count($objHandler->arrRemovedAssignments), 1);
     $this->assertEquals(count($objHandler->arrCurrentAssignments), 0);
     $this->assertTrue(in_array($objHandler->arrRemovedAssignments[0], array($this->getObject("aspect2")->getSystemid())));
     //change the assignments
     $objHandler = new orm_objectlist_testhandler();
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_OBJECTASSIGNMENTSUPDATED, $objHandler);
     $objTestobject = $this->getObject("testobject");
     $arrAspects = array($this->getObject("aspect2"), $this->getObject("aspect1")->getSystemid());
     $objTestobject->setArrObject1($arrAspects);
     $this->assertTrue($objHandler->arrCurrentAssignments == null);
     $this->assertTrue($objHandler->arrNewAssignments == null);
     $this->assertTrue($objHandler->arrRemovedAssignments == null);
     $this->assertTrue($objHandler->objObject == null);
     $this->assertTrue($objHandler->strProperty == null);
     $objTestobject->updateObjectToDb();
     $this->assertEquals(count($objHandler->arrNewAssignments), 2);
     $this->assertEquals(count($objHandler->arrRemovedAssignments), 0);
     $this->assertEquals(count($objHandler->arrCurrentAssignments), 2);
     $this->assertTrue(in_array($objHandler->arrNewAssignments[0], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     $this->assertTrue(in_array($objHandler->arrNewAssignments[1], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     $this->assertTrue(in_array($objHandler->arrCurrentAssignments[0], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     $this->assertTrue(in_array($objHandler->arrCurrentAssignments[1], array($this->getObject("aspect1")->getSystemid(), $this->getObject("aspect2")->getSystemid())));
     //do nothing
     $objHandler = new orm_objectlist_testhandler();
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_OBJECTASSIGNMENTSUPDATED, $objHandler);
     $objTestobject = $this->getObject("testobject");
     $arrAspects = array($this->getObject("aspect2"), $this->getObject("aspect1")->getSystemid());
     $objTestobject->setArrObject1($arrAspects);
     $this->assertTrue($objHandler->arrCurrentAssignments == null);
     $this->assertTrue($objHandler->arrNewAssignments == null);
     $this->assertTrue($objHandler->arrRemovedAssignments == null);
     $this->assertTrue($objHandler->objObject == null);
     $this->assertTrue($objHandler->strProperty == null);
     $objTestobject->updateObjectToDb();
     $this->assertTrue($objHandler->arrCurrentAssignments == null);
     $this->assertTrue($objHandler->arrNewAssignments == null);
     $this->assertTrue($objHandler->arrRemovedAssignments == null);
     $this->assertTrue($objHandler->objObject == null);
     $this->assertTrue($objHandler->strProperty == null);
 }
 /**
  * Internal init to register the event listener, called on file-inclusion, e.g. by the class-loader
  * @return void
  */
 public static function staticConstruct()
 {
     class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED, new class_module_pages_recorddeletedlistener());
 }
 /**
  * Deletes the given group
  *
  * @return bool
  */
 public function deleteGroup()
 {
     class_logger::getInstance()->addLogRow("deleted ldap group with id " . $this->getSystemid(), class_logger::$levelInfo);
     $strQuery = "DELETE FROM " . _dbprefix_ . "user_group_ldap WHERE group_ldap_id=?";
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED, array($this->getSystemid(), get_class($this)));
     return $this->objDB->_pQuery($strQuery, array($this->getSystemid()));
 }
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
********************************************************************************************************/
/**
 * Listener processing basic http authentication headers.
 * If passed, the systems tries to log in the user.
 *
 * @package module_basicauth
 * @author sidler@mulchprod.de
 * @since 4.7
 */
class class_module_basicauth_startprocessinglistener implements interface_genericevent_listener
{
    /**
     * Handles the event as dispatched by the request-dispatcher
     *
     * @param string $strEventName
     * @param array $arrArguments
     *
     * @return bool|void
     */
    public function handleEvent($strEventName, array $arrArguments)
    {
        $objSession = class_carrier::getInstance()->getObjSession();
        if (isset($_SERVER["PHP_AUTH_USER"]) && isset($_SERVER["PHP_AUTH_PW"]) && !$objSession->isLoggedin()) {
            $objSession->login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]);
        }
        return true;
    }
}
class_core_eventdispatcher::getInstance()->removeAndAddListener(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_STARTPROCESSING, new class_module_basicauth_startprocessinglistener());
Esempio n. 25
0
 /**
  * Generates the surrounding layout and embeds the installer-output
  *
  * @return string
  */
 private function renderOutput()
 {
     class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_ENDPROCESSING, array());
     if ($this->strLogfile != "") {
         $strTemplateID = $this->objTemplates->readTemplate(class_resourceloader::getInstance()->getCorePathForModule("module_installer") . "/module_installer/installer.tpl", "installer_log", true);
         $this->strLogfile = $this->objTemplates->fillTemplate(array("log_content" => $this->strLogfile, "systemlog" => $this->getLang("installer_systemlog")), $strTemplateID);
     }
     //build the progress-entries
     $strCurrentCommand = isset($_GET["step"]) ? $_GET["step"] : "";
     if ($strCurrentCommand == "") {
         $strCurrentCommand = "phpsettings";
     }
     $arrProgressEntries = array("phpsettings" => $this->getLang("installer_step_phpsettings"), "config" => $this->getLang("installer_step_dbsettings"), "loginData" => $this->getLang("installer_step_adminsettings"), "modeSelect" => $this->getLang("installer_step_modeselect"), "install" => $this->getLang("installer_step_modules"), "samplecontent" => $this->getLang("installer_step_samplecontent"), "finish" => $this->getLang("installer_step_finish"));
     $strProgress = "";
     $strTemplateEntryTodoID = $this->objTemplates->readTemplate(class_resourceloader::getInstance()->getCorePathForModule("module_installer") . "/module_installer/installer.tpl", "installer_progress_entry", true);
     $strTemplateEntryCurrentID = $this->objTemplates->readTemplate(class_resourceloader::getInstance()->getCorePathForModule("module_installer") . "/module_installer/installer.tpl", "installer_progress_entry_current", true);
     $strTemplateEntryDoneID = $this->objTemplates->readTemplate(class_resourceloader::getInstance()->getCorePathForModule("module_installer") . "/module_installer/installer.tpl", "installer_progress_entry_done", true);
     $strTemplateEntryID = $strTemplateEntryDoneID;
     foreach ($arrProgressEntries as $strKey => $strValue) {
         $arrTemplateEntry = array();
         $arrTemplateEntry["entry_name"] = $strValue;
         //choose the correct template section
         if ($strCurrentCommand == $strKey) {
             $strProgress .= $this->objTemplates->fillTemplate($arrTemplateEntry, $strTemplateEntryCurrentID, true);
             $strTemplateEntryID = $strTemplateEntryTodoID;
         } else {
             $strProgress .= $this->objTemplates->fillTemplate($arrTemplateEntry, $strTemplateEntryID, true);
         }
     }
     $arrTemplate = array();
     $arrTemplate["installer_progress"] = $strProgress;
     $arrTemplate["installer_version"] = $this->strVersion;
     $arrTemplate["installer_output"] = $this->strOutput;
     $arrTemplate["installer_forward"] = $this->strForwardLink;
     $arrTemplate["installer_backward"] = $this->strBackwardLink;
     $arrTemplate["installer_logfile"] = $this->strLogfile;
     $strTemplateID = $this->objTemplates->readTemplate(class_resourceloader::getInstance()->getCorePathForModule("module_installer") . "/module_installer/installer.tpl", "installer_main", true);
     $strReturn = $this->objTemplates->fillTemplate($arrTemplate, $strTemplateID);
     $strReturn = $this->callScriptlets($strReturn);
     $this->objTemplates->setTemplate($strReturn);
     $this->objTemplates->deletePlaceholder();
     $strReturn = $this->objTemplates->getTemplate();
     return $strReturn;
 }