Exemplo n.º 1
0
 /**
  * Reports a layout action with dependencies to the log
  * @param Layout $layout The layout being manipulated
  * @param Enums\Action $action The operation executed on the layout
  */
 function ReportLayoutAction(Layout $layout, Enums\Action $action)
 {
     $logItem = $this->CreateLogItem(Enums\ObjectType::Layout(), $action);
     if (!$action->Equals(Enums\Action::Delete())) {
         $logLayout = new LogLayout();
         $logLayout->SetLogItem($logItem);
         $logLayout->SetLayout($layout);
         $logLayout->Save();
     } else {
         //pages are deleted in cascade
         $pages = Page::Schema()->FetchByLayout(false, $layout);
         foreach ($pages as $page) {
             $this->ReportPageAction($page, Enums\Action::Delete());
         }
     }
 }
Exemplo n.º 2
0
 /**
  * The last log item that is directly related to the layout
  * @param Layout $layout The layout
  * @return LogItem Returns the log item
  */
 static function LastLayoutLog(Layout $layout)
 {
     $tblLogLayout = LogLayout::Schema()->Table();
     $tblLogItem = LogItem::Schema()->Table();
     $sql = Access::SqlBuilder();
     $orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
     $joinCond = $sql->Equals($tblLogLayout->Field('LogItem'), $tblLogItem->Field('ID'));
     $where = $sql->Equals($tblLogLayout->Field('Layout'), $sql->Value($layout->GetID()));
     return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogLayout), JoinType::Inner(), $joinCond);
 }