Exemple #1
0
    /**
     * Create panel directory structure and settings xml file
     * @param  $panel
     * @return bool
     */
    public function create($panel)
    {
        if (empty($panel)) {
            throw new Exception("Empty panel name given");
        }
        $a = new Shopware_Components_Xml_SimpleXml();
        if (!is_file($this->panelXML)) {
            $a->setNamespace('Panels')->create();
        } else {
            $a->loadFile($this->panelXML);
            if ($a->attributeExists('Panels','name',$panel)==true) {
                throw new Exception("Panel with name $panel already exists");
            }
        }

        $temp["Panel"]["@attributes"] = array("name"=>$panel);
        $temp["Panel"]["label"] = "New Panel";
        $temp["Panel"]["authProvider"] = array("@attributes"=>array("name"=>"test"));
        $temp["Panel"]["widgets"] = array();
        $temp["Panel"]["columns"] = array();
        $a->set($a->getXmlAtNode('Panels'),$temp);
        $a->setFilename($this->panelXML);
        $a->save();
       return true;
    }
Exemple #2
0
    /**
     * Update widget permissions
     * @param  $name
     * @param  $rights
     * @return bool
     */
    public function updatePermissions($name,$rights)
    {
        $XML = new Shopware_Components_Xml_SimpleXml();
        $XML->loadFile($this->widgetXML);
        $XML->SimpleXML->removeNodes('//Widget[@name="'.$name.'"]//permissions');
        $search = '//Widget[@name="'.$name.'"]';
        $temp = $XML->SimpleXML->firstOf($search);

        $permissions = $temp->addChild("permissions");
        $permissions->addChild("aclGroup",$rights["aclGroup"]);
        $users = $permissions->addChild("Users");
        foreach ($rights["users"] as $user) {
            $users->addChild("user")->addAttribute("id",$user);
        }
        $XML->SimpleXML->replaceNodes('//Widget[@name="'.$name.'"]',$temp);

        $XML->setFilename($this->widgetXML);
        $XML->save();

        return true;
    }