/**
  * Triggers the workflows scheduled for running.
  */
 public function runWorkflows()
 {
     $arrWorkflows = class_module_workflows_workflow::getWorkflowsByType(class_module_workflows_workflow::$INT_STATE_SCHEDULED);
     class_logger::getInstance(self::STR_LOGFILE)->addLogRow("running workflows, count: " . count($arrWorkflows), class_logger::$levelInfo);
     foreach ($arrWorkflows as $objOneWorkflow) {
         //lock the workflow
         $objLockmanager = new class_lockmanager($objOneWorkflow->getSystemid());
         if ($objLockmanager->isLocked()) {
             class_logger::getInstance(self::STR_LOGFILE)->addLogRow("workflow " . $objOneWorkflow->getSystemid() . " is locked, can't be scheduled", class_logger::$levelWarning);
             continue;
         }
         $objLockmanager->lockRecord();
         /**
          * @var interface_workflows_handler
          */
         $objHandler = $objOneWorkflow->getObjWorkflowHandler();
         //trigger the workflow
         class_logger::getInstance(self::STR_LOGFILE)->addLogRow("executing workflow " . $objOneWorkflow->getSystemid(), class_logger::$levelInfo);
         if ($objHandler->execute()) {
             //handler executed successfully. shift to state 'executed'
             $objOneWorkflow->setIntState(class_module_workflows_workflow::$INT_STATE_EXECUTED);
             class_logger::getInstance(self::STR_LOGFILE)->addLogRow(" execution finished, new state: executed", class_logger::$levelInfo);
         } else {
             //handler failed to execute. reschedule.
             $objHandler->schedule();
             $objOneWorkflow->setIntState(class_module_workflows_workflow::$INT_STATE_SCHEDULED);
             class_logger::getInstance(self::STR_LOGFILE)->addLogRow(" execution finished, new state: scheduled", class_logger::$levelInfo);
         }
         $objOneWorkflow->setIntRuns($objOneWorkflow->getIntRuns() + 1);
         $objOneWorkflow->updateObjectToDb();
         $objLockmanager->unlockRecord(true);
     }
     class_logger::getInstance(self::STR_LOGFILE)->addLogRow("running workflows finished", class_logger::$levelInfo);
 }
예제 #2
0
 /**
  * @param string $strSystemid
  */
 public function __construct($strSystemid = "")
 {
     parent::__construct($strSystemid);
     if ($this->getParam("pe") == "1") {
         $this->strPeAddon = "&pe=1";
     }
     if ($this->getParam("unlockid") != "") {
         $objLockmanager = new class_lockmanager($this->getParam("unlockid"));
         $objLockmanager->unlockRecord(true);
     }
 }
 /**
  * Handles the userlogout event and unlocks all records currently locked by the current user.
  *
  * @param string $strEventName
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventName, array $arrArguments)
 {
     //unwrap arguments
     list($strUserid) = $arrArguments;
     foreach (class_lockmanager::getLockedRecordsForUser($strUserid) as $objOneLock) {
         $objOneLock->getLockManager()->unlockRecord();
     }
     return true;
 }
 /**
  * @xml
  * @permissions edit
  * @return string
  */
 protected function actionUpdateObjectProperty()
 {
     $strReturn = "";
     //get the object to update
     /** @var $objObject class_module_pages_element */
     $objObject = class_objectfactory::getInstance()->getObject($this->getSystemid());
     if ($objObject->rightEdit()) {
         //differ between two modes - page-elements or regular objects
         if ($objObject instanceof class_module_pages_pageelement) {
             $strPageSystemid = $objObject->getPrevId();
             $objLockmanager = new class_lockmanager($objObject->getSystemid());
             if (!$objLockmanager->isLocked()) {
                 $objLockmanager->lockRecord();
             }
             if ($objLockmanager->isLockedByCurrentUser()) {
                 //and finally create the object
                 /** @var class_module_pages_pageelement $objElement */
                 $strElementClass = str_replace(".php", "", $objObject->getStrClassAdmin());
                 //and finally create the object
                 /** @var $objElement class_element_admin */
                 $objElement = new $strElementClass();
                 $objElement->setSystemid($this->getSystemid());
                 $arrElementData = $objElement->loadElementData();
                 //see if we could set the param to the element
                 if ($this->getParam("property") != "") {
                     $strProperty = null;
                     //try to fetch the matching setter
                     $objReflection = new class_reflection($objElement);
                     //try to fetch the property based on the orm annotations
                     $strTargetTable = $objReflection->getAnnotationValuesFromClass(class_orm_base::STR_ANNOTATION_TARGETTABLE);
                     if (count($strTargetTable) > 0) {
                         $strTargetTable = $strTargetTable[0];
                     }
                     $arrTable = explode(".", $strTargetTable);
                     if (count($arrTable) == 2) {
                         $strTargetTable = $arrTable[0];
                     }
                     $arrOrmProperty = $objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_TABLECOLUMN);
                     foreach ($arrOrmProperty as $strCurProperty => $strValue) {
                         if ($strValue == $strTargetTable . "." . $this->getParam("property")) {
                             $strProperty = $strCurProperty;
                         }
                     }
                     if ($strProperty == null) {
                         $strProperty = $this->getParam("property");
                     }
                     $strSetter = $objReflection->getSetter($strProperty);
                     if ($strSetter != null) {
                         call_user_func(array($objElement, $strSetter), $this->getParam("value"));
                     } else {
                         $arrElementData[$this->getParam("property")] = $this->getParam("value");
                         $objElement->setArrParamData($arrElementData);
                     }
                 }
                 //pass the data to the element, maybe the element wants to update some data
                 $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();
                 //allow the element to run actions after saving
                 $objElement->doAfterSaveToDb();
                 //Loading the data of the corresp site
                 $this->flushCompletePagesCache();
                 $strReturn = "<message><success>element update succeeded</success></message>";
             }
         } else {
             //any other object - try to find the matching property and write the value
             if ($this->getParam("property") == "") {
                 class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST);
                 return "<message><error>missing property param</error></message>";
             }
             $objReflection = new class_reflection($objObject);
             $strSetter = $objReflection->getSetter($this->getParam("property"));
             if ($strSetter == null) {
                 class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST);
                 return "<message><error>setter not found</error></message>";
             }
             call_user_func(array($objObject, $strSetter), $this->getParam("value"));
             $objObject->updateObjectToDb();
             $this->flushCompletePagesCache();
             $strReturn = "<message><success>object update succeeded</success></message>";
         }
     } else {
         class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED);
         $strReturn = "<message><error>" . $this->getLang("ds_gesperrt") . "." . $this->getLang("commons_error_permissions") . "</error></message>";
     }
     return $strReturn;
 }
 /**
  * Renders a list of records currently locked
  *
  * @permissions right1
  * @return string
  * @autoTestable
  */
 protected function actionLockedRecords()
 {
     $objArraySectionIterator = new class_array_section_iterator(class_lockmanager::getLockedRecordsCount());
     $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1));
     $objArraySectionIterator->setArraySection(class_lockmanager::getLockedRecords($objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos()));
     $strReturn = "";
     if (!$objArraySectionIterator->valid()) {
         $strReturn .= $this->getLang("commons_list_empty");
     }
     $strReturn .= $this->objToolkit->listHeader();
     foreach ($objArraySectionIterator as $objOneRecord) {
         $strImage = "";
         if ($objOneRecord instanceof interface_admin_listable) {
             $strImage = $objOneRecord->getStrIcon();
             if (is_array($strImage)) {
                 $strImage = class_adminskin_helper::getAdminImage($strImage[0], $strImage[1]);
             } else {
                 $strImage = class_adminskin_helper::getAdminImage($strImage);
             }
         }
         $strActions = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "lockedRecords", "&unlockid=" . $objOneRecord->getSystemid(), $this->getLang("action_unlock_record"), $this->getLang("action_unlock_record"), "icon_lockerOpen"));
         $objLockUser = new class_module_user_user($objOneRecord->getLockManager()->getLockId());
         $strReturn .= $this->objToolkit->genericAdminList($objOneRecord->getSystemid(), $objOneRecord instanceof interface_model ? $objOneRecord->getStrDisplayName() : get_class($objOneRecord), $strImage, $strActions, 0, get_class($objOneRecord), $this->getLang("locked_record_info", array(dateToString(new class_date($objOneRecord->getIntLockTime())), $objLockUser->getStrDisplayName())));
     }
     $strReturn .= $this->objToolkit->listFooter();
     $strReturn .= $this->objToolkit->getPageview($objArraySectionIterator, "system", "lockedRecords");
     return $strReturn;
 }