function testSortOnDelete()
 {
     $objRootAspect = new class_module_system_aspect();
     $objRootAspect->setStrName("testroot");
     $objRootAspect->updateObjectToDb();
     /** @var class_module_system_aspect[] $arrAspects */
     $arrAspects = array();
     for ($intI = 0; $intI < 100; $intI++) {
         $objAspect = new class_module_system_aspect();
         $objAspect->setStrName("autotest_" . $intI);
         $objAspect->updateObjectToDb($objRootAspect->getSystemid());
         $arrAspects[] = $objAspect;
     }
     //delete the 5th element - massive queries required
     $intQueriesPre = class_db::getInstance()->getNumber();
     echo " Setting new position\n";
     $arrAspects[5]->deleteObjectFromDatabase();
     $intQueriesPost = class_db::getInstance()->getNumber();
     echo "Queries: " . ($intQueriesPost - $intQueriesPre) . " \n";
     $objOrm = new class_orm_objectlist();
     $arrChilds = $objOrm->getObjectList("class_module_system_aspect", $objRootAspect->getSystemid());
     $this->assertEquals(count($arrChilds), 99);
     for ($intI = 1; $intI <= 99; $intI++) {
         $this->assertEquals($arrChilds[$intI - 1]->getIntSort(), $intI);
     }
     $objRootAspect->deleteObjectFromDatabase();
 }
 /**
  * Triggered as soon as a record is updated
  *
  * @param string $strEventName
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventName, array $arrArguments)
 {
     $objRecord = $arrArguments[0];
     if ($objRecord instanceof class_module_packagemanager_template) {
         if ($objRecord->getIntRecordStatus() == 1) {
             $objOrm = new class_orm_objectlist();
             $objOrm->addWhereRestriction(new class_orm_objectlist_systemstatus_restriction(class_orm_comparator_enum::Equal(), 1));
             $arrPacks = $objOrm->getObjectList("class_module_packagemanager_template");
             foreach ($arrPacks as $objPack) {
                 if ($objPack->getSystemid() != $objRecord->getSystemid()) {
                     $objPack->setIntRecordStatus(0);
                     $objPack->updateObjectToDb();
                 }
             }
             //update the active-pack constant
             $objSetting = class_module_system_setting::getConfigByName("_packagemanager_defaulttemplate_");
             if ($objSetting !== null) {
                 $objSetting->setStrValue($objRecord->getStrName());
                 $objSetting->updateObjectToDb();
             }
             class_cache::flushCache("class_element_portal");
         }
     }
     return true;
 }
 /**
  * Implementing callback to react on user-delete events
  *
  * Called whenever a record 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)
 {
     //unwrap arguments
     list($strSystemid, $strSourceClass) = $arrArguments;
     if ($strSourceClass == "class_module_user_user" && validateSystemid($strSystemid)) {
         $objORM = new class_orm_objectlist();
         $objORM->addWhereRestriction(new class_orm_objectlist_property_restriction("strUser", class_orm_comparator_enum::Equal(), $strSystemid));
         $objORM->setObjHandleLogicalDeleted(class_orm_deletedhandling_enum::INCLUDED());
         $arrWidgets = $objORM->getObjectList("class_module_dashboard_widget");
         foreach ($arrWidgets as $objWidget) {
             $objWidget->deleteObjectFromDatabase();
         }
     }
     return true;
 }
 /**
  * Searches for ratings belonging to the systemid
  * to be deleted.
  *
  * @param string $strEventName
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventName, array $arrArguments)
 {
     //unwrap arguments
     list($strSystemid, $strSourceClass) = $arrArguments;
     $bitReturn = true;
     //ratings installed as a module?
     if ($strSourceClass == "class_module_rating_rate") {
         //delete history entries of the current rating
         return class_carrier::getInstance()->getObjDB()->_pQuery("DELETE FROM " . _dbprefix_ . "rating_history" . " WHERE rating_history_rating=? ", array($strSystemid));
     }
     //if another record was deleted, remove the ratings alltogether
     $objOrmList = new class_orm_objectlist();
     $objOrmList->addWhereRestriction(new class_orm_objectlist_property_restriction("strRatingSystemid", class_orm_comparator_enum::Equal(), $strSystemid));
     $arrRatings = $objOrmList->getObjectList("class_module_rating_rate");
     foreach ($arrRatings as $objRating) {
         $bitReturn = $bitReturn && $objRating->deleteObjectFromDatabase();
     }
     return $bitReturn;
 }
 /**
  * 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)
 {
     //unwrap arguments
     list($strSystemid, $strSourceClass) = $arrArguments;
     $bitReturn = true;
     //module installed?
     if ($strSourceClass == "class_module_postacomment_post" || class_module_system_module::getModuleByName("postacomment") == null) {
         return true;
     }
     $objOrm = new class_orm_objectlist();
     $objOrm->setObjHandleLogicalDeleted(class_orm_deletedhandling_enum::INCLUDED());
     $objOrm->addWhereRestriction(new class_orm_objectlist_restriction(" AND (postacomment_page = ? OR  postacomment_systemid = ? ) ", array($strSystemid, $strSystemid)));
     $arrComments = $objOrm->getObjectList("class_module_postacomment_post");
     foreach ($arrComments as $objPost) {
         if ($strEventName == class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED_LOGICALLY) {
             $objPost->deleteObject();
         }
         if ($strEventName == class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED) {
             $objPost->deleteObjectFromDatabase();
         }
     }
     return $bitReturn;
 }
 /**
  * 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);
 }
 /**
  * Loads all posts belonging to the given systemid (in most cases a guestbook)
  *
  * @param string $strPrevId
  * @param bool $bitJustActive
  * @param null $intStart
  * @param null $intEnd
  *
  * @return class_module_guestbook_post[]
  * @static
  */
 public static function getPosts($strPrevId = "", $bitJustActive = false, $intStart = null, $intEnd = null)
 {
     $objORM = new class_orm_objectlist();
     if ($bitJustActive) {
         $objORM->addWhereRestriction(new class_orm_objectlist_systemstatus_restriction(class_orm_comparator_enum::Equal(), 1));
     }
     $objORM->addOrderBy(new class_orm_objectlist_orderby("guestbook_post_date DESC"));
     return $objORM->getObjectList(get_called_class(), $strPrevId, $intStart, $intEnd);
 }
 /**
  * Retrieves the list of workflows available
  *
  * @param bool|int $intStart
  * @param bool|int $intEnd
  *
  * @return class_module_workflows_workflow[]
  */
 public static function getAllworkflows($intStart = null, $intEnd = null)
 {
     $objOrmMapper = new class_orm_objectlist();
     $objOrmMapper->addOrderBy(new class_orm_objectlist_orderby("workflows_state ASC"));
     $objOrmMapper->addOrderBy(new class_orm_objectlist_orderby("system_date_start DESC"));
     return $objOrmMapper->getObjectList("class_module_workflows_workflow", "", $intStart, $intEnd);
 }
 /**
  * Tries to find a single mediamanager file identified by its path.
  * Pass the systemid of the matching repo/parent-id in order to find the correct file (e.g. if the file
  * is saved in multiple repos).
  *
  * @param string $strRepoId
  * @param string $strPath
  *
  * @return class_module_mediamanager_file|null
  */
 public static function getFileForPath($strRepoId, $strPath)
 {
     $objORM = new class_orm_objectlist();
     $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND file_filename = ?", array($strPath)));
     $arrFiles = $objORM->getObjectList(get_called_class());
     foreach ($arrFiles as $objFile) {
         $objTemp = class_objectfactory::getInstance()->getObject($objFile->getStrPrevId());
         while (validateSystemid($objTemp->getSystemid())) {
             if ($objTemp->getSystemid() == $strRepoId) {
                 return $objFile;
             }
             $objTemp = class_objectfactory::getInstance()->getObject($objTemp->getStrPrevId());
         }
     }
     return null;
 }
 /**
  * Loads all navigation-points linking on the passed page
  *
  * @param string $strPagename
  *
  * @static
  * @return class_module_navigation_point[]
  */
 public static function loadPagePoint($strPagename)
 {
     $objOrm = new class_orm_objectlist();
     $objOrm->addWhereRestriction(new class_orm_objectlist_restriction(" AND system_status = 1 ", array()));
     $objOrm->addWhereRestriction(new class_orm_objectlist_restriction(" AND navigation_page_i = ? ", array($strPagename)));
     return $objOrm->getObjectList(get_called_class());
 }
Example #11
0
 /**
  * A generic approach to load a list of objects currently available.
  * This method is only a simple approach to determine the instances in the
  * database, if you need more specific loaders, overwrite this method or add your own
  * implementation to the derived class.
  *
  * @param string $strPrevid
  * @param null|int $intStart
  * @param null|int $intEnd
  *
  * @return self[]
  */
 public static function getObjectList($strPrevid = "", $intStart = null, $intEnd = null)
 {
     $objORM = new class_orm_objectlist();
     return $objORM->getObjectList(get_called_class(), $strPrevid, $intStart, $intEnd);
 }
 /**
  * Looks up the widgets placed in a given column and
  * returns a list of instances, reduced for the current user
  *
  * @param string $strColumn
  * @param string $strAspectFilter
  * @param string $strUserId
  *
  * @return array of class_module_dashboard_widget
  */
 public function getWidgetsForColumn($strColumn, $strAspectFilter = "", $strUserId = "")
 {
     if ($strUserId == "") {
         $strUserId = $this->objSession->getUserID();
     }
     $objORM = new class_orm_objectlist();
     $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND dashboard_user = ?", array($strUserId)));
     $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND dashboard_column = ?", array($strColumn)));
     return $objORM->getObjectList(get_called_class(), self::getWidgetsRootNodeForUser($strUserId, $strAspectFilter));
 }
 /**
  * Returns an array of all aspects available
  *
  * @return class_module_system_aspect[]
  * @static
  */
 public static function getActiveObjectList()
 {
     $objOrm = new class_orm_objectlist();
     $objOrm->addWhereRestriction(new class_orm_objectlist_systemstatus_restriction(class_orm_comparator_enum::NotEqual(), 0));
     return $objOrm->getObjectList(__CLASS__, "");
 }
 /**
  * Creates a list of tags matching the passed filter.
  *
  * @param string $strFilter
  * @return class_module_tags_tag[]
  */
 public static function getTagsByFilter($strFilter)
 {
     $objORM = new class_orm_objectlist();
     $objORM->addWhereRestriction(new class_orm_objectlist_property_restriction("strName", class_orm_comparator_enum::Like(), trim($strFilter . "%")));
     $objORM->addOrderBy(new class_orm_objectlist_orderby("tags_tag_name ASC"));
     return $objORM->getObjectList(get_called_class());
 }
 /**
  * Loads all available categories from the db,
  * so a kind of factory method for voting-object
  *
  * @param bool $bitOnlyActive
  * @param bool $intStart
  * @param bool $intEnd
  *
  * @return class_module_votings_voting[]
  * @static
  */
 public static function getObjectList($bitOnlyActive = false, $intStart = false, $intEnd = false)
 {
     $objOrm = new class_orm_objectlist();
     if ($bitOnlyActive) {
         $objOrm->addWhereRestriction(new class_orm_objectlist_systemstatus_restriction(class_orm_comparator_enum::NotEqual(), 0));
     }
     return $objOrm->getObjectList(__CLASS__, "", $intStart, $intEnd);
 }
 /**
  * Loads all pages known by the system
  *
  * @param int $intStart
  * @param int $intEnd
  * @param string $strFilter
  *
  * @return class_module_pages_page[]
  * @static
  */
 public static function getAllPages($intStart = null, $intEnd = null, $strFilter = "")
 {
     $objORM = new class_orm_objectlist();
     if ($strFilter != "") {
         $objORM->addWhereRestriction(new class_orm_objectlist_restriction("AND page_name LIKE ?", $strFilter . "%"));
     }
     $objORM->addOrderBy(new class_orm_objectlist_orderby("page_name ASC"));
     return $objORM->getObjectList(get_called_class(), "", $intStart, $intEnd);
 }
 /**
  * Returns a list of posts
  *
  * @param bool $bitJustActive
  * @param string $strPagefilter
  * @param string $strSystemidfilter false to ignore the filter
  * @param string $strLanguagefilter
  * @param bool $intStart
  * @param bool $intEnd
  *
  * @return class_module_postacomment_post[]
  */
 public static function loadPostList($bitJustActive = true, $strPagefilter = "", $strSystemidfilter = "", $strLanguagefilter = "", $intStart = null, $intEnd = null)
 {
     $objORM = new class_orm_objectlist();
     if ($strPagefilter != "") {
         $objORM->addWhereRestriction(new class_orm_objectlist_restriction(" AND postacomment_page = ? ", $strPagefilter));
     }
     if ($strSystemidfilter != "") {
         $objORM->addWhereRestriction(new class_orm_objectlist_restriction(" AND postacomment_systemid = ? ", $strSystemidfilter));
     }
     if ($strLanguagefilter != "") {
         //check against '' to remain backwards-compatible
         $objORM->addWhereRestriction(new class_orm_objectlist_restriction(" AND (postacomment_language = ? OR postacomment_language = '')", $strLanguagefilter));
     }
     if ($bitJustActive) {
         $objORM->addWhereRestriction(new class_orm_objectlist_restriction(" AND system_status = ? ", 1));
     }
     $objORM->addOrderBy(new class_orm_objectlist_orderby("postacomment_page ASC"));
     $objORM->addOrderBy(new class_orm_objectlist_orderby("postacomment_language ASC"));
     $objORM->addOrderBy(new class_orm_objectlist_orderby("postacomment_date DESC"));
     return $objORM->getObjectList(get_called_class(), "", $intStart, $intEnd);
 }
 /**
  * Looks up a navigation by its name
  *
  * @param string $strName
  *
  * @return class_module_navigation_tree
  * @static
  */
 public static function getNavigationByName($strName)
 {
     $objOrm = new class_orm_objectlist();
     $objOrm->addWhereRestriction(new class_orm_objectlist_property_restriction("strName", class_orm_comparator_enum::Equal(), $strName));
     $arrRows = $objOrm->getObjectList("class_module_navigation_tree", class_module_system_module::getModuleIdByNr(_navigation_modul_id_));
     if (count($arrRows) == 1) {
         return $arrRows[0];
     }
     return null;
 }
 /**
  * Returns an array of all messages matching the passed identifier
  *
  * @param string $strIdentifier
  * @param bool|int $intStart
  * @param bool|int $intEnd
  *
  * @return class_module_messaging_message[]
  * @static
  */
 public static function getMessagesByIdentifier($strIdentifier, $intStart = null, $intEnd = null)
 {
     $objOrm = new class_orm_objectlist();
     $objOrm->addWhereRestriction(new class_orm_objectlist_property_restriction("strInternalIdentifier", class_orm_comparator_enum::Equal(), $strIdentifier));
     $objOrm->addOrderBy(new class_orm_objectlist_orderby("message_read ASC"));
     $objOrm->addOrderBy(new class_orm_objectlist_orderby("system_create_date DESC"));
     return $objOrm->getObjectList(__CLASS__, $intStart, $intEnd);
 }
 /**
  * Returns the language requested.
  * If the language doesn't exist, false is returned
  *
  * @param string $strName
  *
  * @static
  * @return  class_module_languages_language or false
  */
 public static function getLanguageByName($strName)
 {
     $objOrmList = new class_orm_objectlist();
     $objOrmList->addWhereRestriction(new class_orm_objectlist_property_restriction("strName", class_orm_comparator_enum::Equal(), $strName));
     $arrReturn = $objOrmList->getObjectList(__CLASS__);
     if (count($arrReturn) > 0) {
         return $arrReturn[0];
     } else {
         return false;
     }
 }