/**
  * Gets the top most content of the container
  * @return ContainerContent The first and root container content
  */
 function TopMost()
 {
     $sql = Access::SqlBuilder();
     $tbl = ContainerContent::Schema()->Table();
     $where = $sql->Equals($tbl->Field('Container'), $sql->Value($this->container->GetID()))->And_($sql->IsNull($tbl->Field('Parent')))->And_($sql->IsNull($tbl->Field('Previous')));
     return ContainerContent::Schema()->First($where);
 }
 private function AddContainerField()
 {
     $name = 'Container';
     $value = $this->container->Exists() ? $this->container->GetContainer()->GetID() : '';
     $select = new Select($name, $value);
     $select->AddOption('', Trans('Core.PleaseSelect'));
     $sql = Access::SqlBuilder();
     $tblContainer = Container::Schema()->Table();
     $orderBy = $sql->OrderList($sql->OrderAsc($tblContainer->Field('Name')));
     $containers = Container::Schema()->Fetch(false, null, $orderBy);
     foreach ($containers as $container) {
         $select->AddOption($container->GetID(), $container->GetName());
     }
     $this->AddField($select);
     $this->SetRequired($name);
 }
 /**
  * Saves group and rights
  */
 private function SaveRights()
 {
     $groupID = $this->Value('UserGroup');
     $userGroup = Usergroup::Schema()->ByID($groupID);
     $this->container->SetUserGroup($userGroup);
     if (!$userGroup) {
         $oldRights = $this->container->GetUserGroupRights();
         if ($oldRights) {
             $oldRights->GetContentRights()->Delete();
         }
         $this->container->SetUserGroupRights(null);
     } else {
         $this->container->SetUserGroup($userGroup);
         $this->containerRights->Save();
         $this->container->SetUserGroupRights($this->containerRights->Rights());
     }
     $this->container->Save();
 }
 /**
  * The edit/create url base parameters
  * @return array Returns the parameters for creating/editing
  */
 protected function EditParams()
 {
     $params = array();
     $params['container'] = $this->container->GetID();
     return $params;
 }
 protected function CreateFormUrl()
 {
     $args = array('container' => $this->container->GetID());
     return BackendRouter::ModuleUrl(new ModuleForm(), $args);
 }
Exemple #6
0
 /**
  * Adds the module type option, if allowed
  * @param Select $select The select box
  * @param string $type The module type
  */
 private function AddModuleTypeOption(Select $select, $type)
 {
     if ($type != 'BuiltIn-Container' || !Request::GetData('container') && Container::Schema()->Count() > 0) {
         $select->AddOption($type, Trans($type));
     }
 }
Exemple #7
0
 /**
  * Grant evaluation for adding content on top of a container
  * @param Container $container The container
  * @return GrantResult Returns the grant result telling if creation is allowed
  */
 function GrantAddContentToContainer(Container $container)
 {
     //dummy content for evaluation
     $content = new Content();
     $content->SetUserGroup($container->GetUserGroup());
     $containerRights = $container->GetUserGroupRights();
     if ($containerRights) {
         $content->SetUserGroupRights($containerRights->GetContentRights());
     }
     return $this->Grant(BackendAction::Create(), $content);
 }
 /**
  * The url to the content tree of the container
  * @param Container $container
  * @return string
  */
 protected function ContentTreeUrl(Container $container)
 {
     return BackendRouter::ModuleUrl(new ContainerContentTree(), array('container' => $container->GetID()));
 }
 /**
  * The last log item that is directly related to the container
  * @param Container $container The container
  * @return LogItem Returns the log item
  */
 static function LastContainerLog(Container $container)
 {
     $tblLogContainer = LogContainer::Schema()->Table();
     $tblLogItem = LogItem::Schema()->Table();
     $sql = Access::SqlBuilder();
     $orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
     $joinCond = $sql->Equals($tblLogContainer->Field('LogItem'), $tblLogItem->Field('ID'));
     $where = $sql->Equals($tblLogContainer->Field('Container'), $sql->Value($container->GetID()));
     return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogContainer), JoinType::Inner(), $joinCond);
 }