206 lines
5.4 KiB
PHP
206 lines
5.4 KiB
PHP
<?php
|
|
require_once(ROOT."include/config.inc.php");
|
|
require_once(CMS_DIR."modules/_cmsobject.class.php");
|
|
require_once(CMS_DIR."modules/_flexiconfactory.class.php");
|
|
|
|
/** CMS Root
|
|
*
|
|
* @version 1.9.0
|
|
* @date 2007-03-27
|
|
* @author martin lenzelbauer
|
|
*/
|
|
class Root extends CmsObject{
|
|
|
|
|
|
/** C'tor
|
|
*/
|
|
//-----------------------------------------------
|
|
function Root(){
|
|
//-----------------------------------------------
|
|
parent::CmsObject();
|
|
$this->name = "Startseite";
|
|
}
|
|
|
|
|
|
/** @see CmsObject::load()
|
|
*/
|
|
//-----------------------------------------------
|
|
function load($path=array()){
|
|
//-----------------------------------------------
|
|
$this->childObjects = array();
|
|
|
|
// users with limited root node(s)
|
|
if (!empty($_SESSION['userroot'])) {
|
|
$root = explode(",", $_SESSION['userroot']);
|
|
//create root node(s)
|
|
foreach ($root as $rootId) {
|
|
$id = intval(trim($rootId));
|
|
if ($id > 0) {
|
|
$r = FlexiconFactory::instanceById($id, $this);
|
|
$this->childObjects[] = $r;
|
|
}
|
|
}
|
|
|
|
//create user container
|
|
$u = FlexiconFactory::instanceByClass("UserContainer", $this);
|
|
$u->setId(++$id);
|
|
$this->childObjects[] = $u;
|
|
|
|
//create gallery container
|
|
if (in_array("GalleryContainer", $_SESSION['usermodules'])) {
|
|
$g = FlexiconFactory::instanceByClass("GalleryContainer", $this);
|
|
$g->setId(++$id);
|
|
$this->childObjects[] = $g;
|
|
}
|
|
|
|
//create ticket container
|
|
if (in_array("TicketRoot", $_SESSION['usermodules'])) {
|
|
$g = FlexiconFactory::instanceByClass("TicketRoot", $this);
|
|
$g->setId(++$id);
|
|
$this->childObjects[] = $g;
|
|
}
|
|
|
|
//create newsletter container
|
|
if (in_array("NewsletterRoot", $_SESSION['usermodules'])) {
|
|
$g = FlexiconFactory::instanceByClass("NewsletterRoot", $this);
|
|
$g->setId(++$id);
|
|
$this->childObjects[] = $g;
|
|
}
|
|
|
|
//create customer container
|
|
if (in_array("CustomerRoot", $_SESSION['usermodules'])) {
|
|
$g = FlexiconFactory::instanceByClass("CustomerRoot", $this);
|
|
$g->setId(++$id);
|
|
$this->childObjects[] = $g;
|
|
}
|
|
}
|
|
|
|
else {
|
|
//load website(s)
|
|
$query = sprintf("SELECT id FROM bruckm_index WHERE class = 'website' ORDER BY name ASC");
|
|
$result = dbQuery($query);
|
|
$id = 0;
|
|
if(mysql_num_rows($result) > 0){
|
|
while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){
|
|
$website = FlexiconFactory::instanceById($line['id'], $this);
|
|
$this->childObjects[] = $website;
|
|
if($website->getId() > $id){
|
|
$id = $website->getId();
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
$website = FlexiconFactory::instanceByClass("Website", $this);
|
|
$website->save();
|
|
$this->childObjects[] = $website;
|
|
if($website->getId() > $id){
|
|
$id = $website->getId();
|
|
}
|
|
}
|
|
|
|
//create gallery container
|
|
$g = FlexiconFactory::instanceByClass("GalleryContainer", $this);
|
|
$g->setId(++$id);
|
|
$this->childObjects[] = $g;
|
|
|
|
//create user container
|
|
$u = FlexiconFactory::instanceByClass("UserContainer", $this);
|
|
$u->setId(++$id);
|
|
$this->childObjects[] = $u;
|
|
|
|
//create ticket container
|
|
$t = FlexiconFactory::instanceByClass("TicketRoot", $this);
|
|
$t->setId(++$id);
|
|
$this->childObjects[] = $t;
|
|
|
|
//create newsletter container
|
|
$n = FlexiconFactory::instanceByClass("NewsletterRoot", $this);
|
|
$n->setId(++$id);
|
|
$this->childObjects[] = $n;
|
|
|
|
//create customer container
|
|
$t = FlexiconFactory::instanceByClass("CustomerRoot", $this);
|
|
$t->setId(++$id);
|
|
$this->childObjects[] = $t;
|
|
}
|
|
|
|
array_shift($path);
|
|
foreach($this->childObjects as $i=>$child){
|
|
$this->childObjects[$i]->load($path);
|
|
}
|
|
|
|
$this->loaded = true;
|
|
}
|
|
|
|
|
|
/** @see CmsObject::printContent()
|
|
*/
|
|
//-----------------------------------------------
|
|
function printContent(){
|
|
//-----------------------------------------------
|
|
$t = new Template(CMS_TEMPLATE_DIR."root.html");
|
|
$t->setVar("USERNAME", htmlspecialchars($_SESSION['username']));
|
|
$t->setVar("USERPATH", $this->getUserPath($_SESSION['user']));
|
|
$out = $t->toString();
|
|
foreach($this->childObjects as $i=>$child){
|
|
if($this->childObjects[$i]->isListable()){
|
|
$out .= $this->childObjects[$i]->printChildContent();
|
|
}
|
|
}
|
|
return $out;
|
|
}
|
|
|
|
|
|
/** @see CmsObject::printTreeMenu()
|
|
*/
|
|
//----------------------------------------------------
|
|
function printTreeMenu($path){
|
|
//----------------------------------------------------
|
|
|
|
$out = parent::printTreeMenu($path);
|
|
|
|
//logout menu item
|
|
$out .= "<ul>";
|
|
$out .= "<li class=\"itemLogout\">";
|
|
$out .= "<a href=\"logout.php\" target=\"_self\">Logout</a>";
|
|
$out .= "</li>";
|
|
$out .= "</ul>";
|
|
|
|
return $out;
|
|
}
|
|
|
|
|
|
/** @see Element::getCssClass()
|
|
*/
|
|
//------------------------------------------------
|
|
function getCssClass(){
|
|
//------------------------------------------------
|
|
return "itemNone";
|
|
}
|
|
|
|
|
|
// === ADDITIONAL METHODS ============================================== //
|
|
|
|
|
|
/** returns the path to the CmsObject of the currenly logged in user
|
|
* @param user username of the currently logged in user
|
|
* @return path (string)
|
|
*/
|
|
//------------------------------------------------
|
|
function getUserPath($user){
|
|
//------------------------------------------------
|
|
$path = array($this->id);
|
|
foreach($this->childObjects as $i=>$child){
|
|
if(strtolower(get_class($child)) == "usercontainer"){
|
|
$path[] = $this->childObjects[$i]->getId();
|
|
$path[] = $this->childObjects[$i]->getUserId($user);
|
|
}
|
|
}
|
|
return implode("/", $path);
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
?>
|