Example #1
0
 /**
  * Reports a content action with dependencies to the log
  * @param Content $content The content being manipulated
  * @param Enums\Action $action The operation executed on the content
  */
 function ReportContentAction(Content $content, Enums\Action $action)
 {
     $logItem = $this->CreateLogItem(Enums\ObjectType::Content(), $action);
     if (!$action->Equals(Enums\Action::Delete())) {
         $logContent = new LogContent();
         $logContent->SetLogItem($logItem);
         $logContent->SetContent($content);
         $logContent->Save();
     } else {
         if ($content->GetContainerContent()) {
             $this->ReportContainerAction($content->GetContainerContent()->GetContainer(), Enums\Action::ChildDelete());
         } else {
             if ($content->GetPageContent()) {
                 $this->ReportPageAction($content->GetPageContent()->GetPage(), Enums\Action::ChildDelete());
             } else {
                 if ($content->GetLayoutContent()) {
                     $this->ReportAreaAction($content->GetLayoutContent()->GetArea(), Enums\Action::ChildDelete());
                 }
             }
         }
     }
 }
Example #2
0
 /**
  * The last log item that is directly related to the content
  * @param Content $content The content
  * @return LogItem Returns the log item
  */
 static function LastContentLog(Content $content)
 {
     $tblLogContent = LogContent::Schema()->Table();
     $tblLogItem = LogItem::Schema()->Table();
     $sql = Access::SqlBuilder();
     $orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
     $joinCond = $sql->Equals($tblLogContent->Field('LogItem'), $tblLogItem->Field('ID'));
     $where = $sql->Equals($tblLogContent->Field('Content'), $sql->Value($content->GetID()));
     return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogContent), JoinType::Inner(), $joinCond);
 }