/**
  * Returns the top most area
  * @return Area
  */
 public function TopMost()
 {
     $sql = Access::SqlBuilder();
     $tblArea = Area::Schema()->Table();
     $where = $sql->Equals($tblArea->Field('Layout'), $sql->Value($this->layout->GetID()))->And_($sql->IsNull($tblArea->Field('Previous')));
     return Area::Schema()->First($where);
 }
 /**
  * Gets the first page url parameter
  * @return PageUrlParameter Returns the first parameter or null if none exists
  */
 public function TopMost()
 {
     $sql = Access::SqlBuilder();
     $tblParams = PageUrlParameter::Schema()->Table();
     $where = $sql->Equals($tblParams->Field('PageUrl'), $sql->Value($this->pageUrl->GetID()))->And_($sql->IsNull($tblParams->Field('Previous')));
     return PageUrlParameter::Schema()->First($where);
 }
 private function InitGroups()
 {
     $sql = Access::SqlBuilder();
     $tblGroup = Usergroup::Schema()->Table();
     $order = $sql->OrderAsc($tblGroup->Field('Name'));
     $this->groups = Usergroup::Schema()->Fetch(false, null, $sql->OrderList($order));
 }
Exemple #4
0
 private function InitUsers()
 {
     $sql = Access::SqlBuilder();
     $tbl = User::Schema()->Table();
     $order = $sql->OrderList($sql->OrderAsc($tbl->Field('Name')));
     $this->users = User::Schema()->Fetch(false, null, $order);
 }
Exemple #5
0
 function Init()
 {
     $sql = Access::SqlBuilder();
     $tblLayout = Layout::Schema()->Table();
     $orderBy = $sql->OrderList($sql->OrderAsc($tblLayout->Field('Name')));
     $this->layouts = Layout::Schema()->Fetch(false, null, $orderBy);
     return parent::Init();
 }
 /**
  * Gets the first user that is an admin
  * @return User The admin user, if present
  */
 private function FirstAdmin()
 {
     $sql = Access::SqlBuilder();
     $tblUser = User::Schema()->Table();
     $where = $sql->Equals($tblUser->Field('IsAdmin'), $sql->Value(true));
     $orderBy = $sql->OrderList($sql->OrderAsc($tblUser->Field('ID')));
     return User::Schema()->First($where, $orderBy);
 }
 function Init()
 {
     $sql = Access::SqlBuilder();
     $tblContainer = Container::Schema()->Table();
     $orderBy = $sql->OrderList($sql->OrderAsc($tblContainer->Field('Name')));
     $this->containers = Container::Schema()->Fetch(false, null, $orderBy);
     return parent::Init();
 }
 /**
  * Initiaizes the set of groups
  */
 protected function Init()
 {
     $sql = Access::SqlBuilder();
     $tbl = Membergroup::Schema()->Table();
     $order = $sql->OrderList($sql->OrderAsc($tbl->Field('Name')));
     $this->groups = Membergroup::Schema()->Fetch(false, null, $order);
     return parent::Init();
 }
 static function AddLanguageOptions(Select $field, Condition $where = null)
 {
     $sql = Access::SqlBuilder();
     $tblLang = Language::Schema()->Table();
     $orderBy = $sql->OrderList($sql->OrderAsc($tblLang->Field('Name')));
     $langs = Language::Schema()->Fetch(false, $where, $orderBy);
     foreach ($langs as $lang) {
         $field->AddOption($lang->GetID(), $lang->GetName() . ' (' . $lang->GetCode() . ')');
     }
 }
 /**
  * Gets the first child of the item
  * @param ContainerContent $item The item
  * @return ContainerContent Returns the first child
  */
 public function FirstChildOf($item)
 {
     if ($item) {
         $sql = Access::SqlBuilder();
         $tbl = ContainerContent::Schema()->Table();
         $where = $sql->Equals($tbl->Field('Parent'), $sql->Value($item->GetID()))->And_($sql->IsNull($tbl->Field('Previous')));
         return ContainerContent::Schema()->First($where);
     } else {
         return $this->TopMost();
     }
 }
 /**
  * Initializes the areas and stores them in a list with area names as keys
  */
 private function InitAreas()
 {
     $sql = Access::SqlBuilder();
     $tbl = Area::Schema()->Table();
     $where = $sql->Equals($tbl->Field('Layout'), $sql->Value($this->layout->GetID()))->And_($sql->IsNull($tbl->Field('Previous')));
     $area = Area::Schema()->First($where);
     while ($area) {
         $this->areas[$area->GetName()] = $area;
         $area = Area::Schema()->ByPrevious($area);
     }
 }
 private function InitSites()
 {
     $siteID = Request::GetData('site');
     if ($siteID) {
         $this->sites = array(Site::Schema()->ByID($siteID));
         return;
     }
     $sql = Access::SqlBuilder();
     $tblSite = Site::Schema()->Table();
     $orderBy = $sql->OrderList($sql->OrderAsc($tblSite->Field('Name')));
     $this->sites = Site::Schema()->Fetch(false, null, $orderBy);
 }
Exemple #13
0
 private function AddLanguageField()
 {
     $name = 'Language';
     $lang = $this->user->GetLanguage();
     $field = new Select($name, $lang ? $lang->GetID() : '');
     $field->AddOption('', Trans('Core.PleaseSelect'));
     $sql = Access::SqlBuilder();
     $tbl = Language::Schema()->Table();
     $where = $sql->Equals($tbl->Field('IsBackendTranslated'), $sql->Value(true));
     DBSelectUtil::AddLanguageOptions($field, $where);
     $this->AddField($field);
     $this->SetRequired($name);
 }
Exemple #14
0
 /**
  * Initiaizes the set of sites
  */
 protected function Init()
 {
     $sql = Access::SqlBuilder();
     $tbl = Site::Schema()->Table();
     $order = $sql->OrderList($sql->OrderAsc($tbl->Field('Name')));
     $sites = Site::Schema()->Fetch(false, null, $order);
     $this->sites = array();
     foreach ($sites as $site) {
         if (self::Guard()->Allow(BackendAction::Read(), $site)) {
             $this->sites[] = $site;
         }
     }
     return parent::Init();
 }
 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);
 }
 protected function UpdateUsages($newTemplate)
 {
     $sql = Access::SqlBuilder();
     $tblContent = Content::Schema()->Table();
     $where = $sql->Equals($tblContent->Field('Template'), $sql->Value($this->template))->And_($sql->Equals($tblContent->Field('Type'), $sql->Value($this->module->MyType())));
     $setList = $sql->SetList('Template', $sql->Value($newTemplate));
     Content::Schema()->Update($setList, $where);
 }
 /**
  * Finds the 404 page for a site
  * @param Site $site The site whise 404 page is searched for
  * @return Page The 404 page
  */
 static function Page404(Site $site)
 {
     $sql = Access::SqlBuilder();
     $tblPage = Page::Schema()->Table();
     $where = $sql->Equals($tblPage->Field('Type'), $sql->Value((string) PageType::NotFound()))->And_($sql->Equals($tblPage->Field('Site'), $sql->Value($site->GetID())));
     return Page::Schema()->First($where);
 }
 private function UserGroupWhere(Usergroup $group)
 {
     $sql = Access::SqlBuilder();
     $tblUug = UserUsergroup::Schema()->Table();
     return $sql->Equals($tblUug->Field('User'), $sql->Value($this->user->GetID()))->And_($sql->Equals($tblUug->Field('UserGroup'), $sql->Value($group->GetID())));
 }
Exemple #19
0
 /**
  * Deletes the unselected group ids
  * @param array $exGroupIDs Currently assigned group ids
  * @param array $selGroupIDs Selected group ids
  */
 private function DeleteOldGroups(array $selGroupIDs)
 {
     $tblMmg = MemberMembergroup::Schema()->Table();
     $sql = Access::SqlBuilder();
     $where = $sql->Equals($tblMmg->Field('Member'), $sql->Value($this->member->GetID()));
     if (count($selGroupIDs) > 0) {
         $selectedList = $sql->InListFromValues($selGroupIDs);
         $where = $where->And_($sql->NotIn($tblMmg->Field('MemberGroup'), $selectedList));
     }
     MemberMembergroup::Schema()->Delete($where);
 }
 /**
  * Adds the member group options to the checklist
  * @param CheckList $field
  */
 private static function AddMembergroupOptions(CheckList $field)
 {
     $sql = Access::SqlBuilder();
     $tbl = Membergroup::Schema()->Table();
     $orderBy = $sql->OrderList($sql->OrderAsc($tbl->Field('Name')));
     $groups = Membergroup::Schema()->Fetch(false, null, $orderBy);
     foreach ($groups as $group) {
         $field->AddOption($group->GetID(), $group->GetName());
     }
 }
 private function DeleteUsages(FrontendModule $module, $templateName)
 {
     $sql = Access::SqlBuilder();
     $tblContent = Content::Schema()->Table();
     $where = $sql->Equals($tblContent->Field('Type'), $sql->Value($module->MyType()))->And_($sql->Equals($tblContent->Field('Template'), $sql->Value($templateName)));
     $setList = $sql->SetList('Template', $sql->Value(''));
     Content::Schema()->Update($setList, $where);
 }
Exemple #22
0
 private function GrantOnModule(ModuleBase $module)
 {
     $bundle = $module->MyBundle();
     $moduleName = $module->MyName();
     $inList = $this->GetGroupList();
     $tblModLock = ModuleLock::Schema()->Table();
     $sql = Access::SqlBuilder();
     $where = $sql->Equals($tblModLock->Field('Bundle'), $sql->Value($bundle))->And_($sql->In($tblModLock->Field('UserGroup'), $inList))->And_($sql->Equals($tblModLock->Field('Module'), $sql->Value(''))->Or_($sql->Equals($tblModLock->Field('Module'), $sql->Value($moduleName))));
     if (ModuleLock::Schema()->Count(false, $where) > 0) {
         return GrantResult::NoAccess();
     }
     return GrantResult::Allowed();
 }
Exemple #23
0
 private function AreaNameExists($name)
 {
     $sql = Access::SqlBuilder();
     $tblArea = Area::Schema()->Table();
     $where = $sql->Equals($tblArea->Field('Layout'), $sql->Value($this->layout->GetID()))->And_($sql->Equals($tblArea->Field('Name'), $sql->Value($name)));
     return Area::Schema()->Count(false, $where) > 0;
 }
 private function ClearMembergroups(array $selectedIDs)
 {
     $sql = Access::SqlBuilder();
     $tblConfirmGroup = RegisterConfirmMembergroup::Schema()->Table();
     $where = $sql->Equals($tblConfirmGroup->Field('Confirm'), $sql->Value($this->confirm->GetID()));
     if (count($selectedIDs)) {
         $where = $where->And_($sql->NotIn($tblConfirmGroup->Field('MemberGroup'), $sql->InListFromValues($selectedIDs)));
     }
     RegisterConfirmMembergroup::Schema()->Delete($where);
 }
Exemple #25
0
 /**
  * Finds the wording with the given placeholder name
  * @param string $name The placeholder name
  * @return ContentWording Gets the matching content wording
  */
 private function FindWording($name)
 {
     if (!$this->Content()->Exists()) {
         return null;
     }
     $sql = Access::SqlBuilder();
     $tblWording = ContentWording::Schema()->Table();
     $where = $sql->Equals($tblWording->Field('Content'), $sql->Value($this->Content()->GetID()))->And_($sql->Equals($tblWording->Field('Placeholder'), $sql->Value($name)));
     return ContentWording::Schema()->First($where);
 }
Exemple #26
0
 /**
  * Deletes the old member groups
  * @param array $selectedIDs The selected member ids
  */
 private function DeleteOldMemberGroups(array $selectedIDs)
 {
     $sql = Access::SqlBuilder();
     $tblPgGrp = PageMembergroup::Schema()->Table();
     $where = $sql->Equals($tblPgGrp->Field('Page'), $sql->Value($this->page->GetID()));
     if (count($selectedIDs)) {
         $inSelected = $sql->InListFromValues($selectedIDs);
         $where = $where->And_($sql->NotIn($tblPgGrp->Field('MemberGroup'), $inSelected));
     }
     PageMembergroup::Schema()->Delete($where);
 }
Exemple #27
0
 /**
  * Deletes log items older then the given amount of days
  * @param int $days The days
  */
 private function DeleteOldLogItems()
 {
     $days = SettingsProxy::Singleton()->Settings()->GetLogLifetime();
     $deleteBefore = Date::Now();
     $deleteBefore->AddDays(-$days);
     $tblLogItem = LogItem::Schema()->Table();
     $sql = Access::SqlBuilder();
     $where = $sql->LT($tblLogItem->Field('Changed'), $sql->Value($deleteBefore));
     LogItem::Schema()->Delete($where);
 }
 /**
  * Clears the parameters of the page url
  * @param PageUrl $pageUrl The page url
  */
 private function ClearParams(PageUrl $pageUrl)
 {
     $sql = Access::SqlBuilder();
     $tblParams = PageUrlParameter::Schema()->Table();
     $where = $sql->Equals($tblParams->Field('PageUrl'), $sql->Value($pageUrl->GetID()));
     PageUrlParameter::Schema()->Delete($where);
 }
 /**
  * 
  * Gets the top most navigation item
  * @return NavigationItem
  */
 public function TopMost()
 {
     $tblNavItem = NavigationItem::Schema()->Table();
     $sql = Access::SqlBuilder();
     $where = $sql->Equals($tblNavItem->Field('Navigation'), $sql->Value($this->navi->GetID()))->And_($sql->IsNull($tblNavItem->Field('Parent')))->And_($sql->IsNull($tblNavItem->Field('Previous')));
     return NavigationItem::Schema()->First($where);
 }
 /**
  * True if a lock with given bundle and module are set
  * @param string $bundle The bundle name
  * @param string $module The module name
  * @return boolean Returns true if the lock is set
  */
 private function HasLock($bundle, $module = '')
 {
     $sql = Access::SqlBuilder();
     $tblModLock = ModuleLock::Schema()->Table();
     $where = $sql->Equals($tblModLock->Field('Bundle'), $sql->Value($bundle))->And_($sql->Equals($tblModLock->Field('Module'), $sql->Value($module)))->And_($sql->Equals($tblModLock->Field('UserGroup'), $sql->Value($this->group->GetID())));
     return ModuleLock::Schema()->Count(false, $where) > 0;
 }