public function processPermissions(Plugin $plugin, &$log = '', $xml = false)
    {
        if(!$xml)
            $xml = $this->loadXML($plugin->Path);

        if(!$xml)
            throw new Exception('Missing plugin.xml file for plugin ['.$plugin->Slug.']');

        // add permissions
        $perms = $xml->permissions;
        if(!empty($perms))
        foreach ( $perms->permission as $perm_xml ) {
            foreach ( array('slug', 'title') as $required_attribute ) {
                if (!$perm_xml->attributes()->$required_attribute)
                    throw new Exception("Required permission attribute '$required_attribute' was not found.");
            }

            if(!$this->Permissions->permissionExists($perm_xml->attributes()->slug))
            {
                try {
                    $this->Permissions->addPermission($plugin, $perm_xml->attributes()->slug, $perm_xml->attributes()->title);
                } catch(ValidationException $ve) {
                    throw new Exception('Permissions: '.$ve->getMessage());
                }
            }


            $log .= "Permission created...\n";
            $log .= "Slug: " . $perm_xml->attributes()->slug . "\n";
            $log .= "Title: " . $perm_xml->attributes()->title . "\n";
            $log .= "\n";
        }
    }
public function processPermissions(Plugin $plugin, &$log = '', $xml = false)
    {
        if(!$xml)
            $xml = $this->loadXML($plugin->Path);

        if(!$xml)
            throw new Exception('Missing plugin.xml file for plugin ['.$plugin->Slug.']');

        // add permissions
        $perms = $xml->permissions;
        if(!empty($perms))
        foreach ( $perms->permission as $perm_xml ) {
            foreach ( array('slug', 'title') as $required_attribute ) {
                if (!$perm_xml->attributes()->$required_attribute)
                    throw new Exception("Required permission attribute '$required_attribute' was not found.");
            }

            if(!$this->Permissions->permissionExists($perm_xml->attributes()->slug))
            {
                try {
                    $this->Permissions->addPermission($plugin, $perm_xml->attributes()->slug, $perm_xml->attributes()->title);
                } catch(ValidationException $ve) {
                    throw new Exception('Permissions: '.$ve->getMessage());
                }
            }


            $log .= "Permission created...\n";
            $log .= "Slug: " . $perm_xml->attributes()->slug . "\n";
            $log .= "Title: " . $perm_xml->attributes()->title . "\n";
            $log .= "\n";
        }
    }
public function processPermissions ( Plugin $ plugin , & $ log = '' , $ xml = false ) { if ( ! $ xml ) $ xml = $ this -> loadXML ( $ plugin -> Path ) ; if ( ! $ xml ) throw new Exception ( 'Missing plugin.xml file for plugin [' . $ plugin -> Slug . ']' ) ; // add permissions $ perms = $ xml -> permissions ; if ( ! empty ( $ perms ) ) foreach ( $ perms -> permission as $ perm_xml ) { foreach ( array ( 'slug' , 'title' ) as $ required_attribute ) { if ( ! $ perm_xml -> attributes ( ) -> $ required_attribute ) throw new Exception ( "Required permission attribute '$required_attribute' was not found." ) ; } if ( ! $ this -> Permissions -> permissionExists ( $ perm_xml -> attributes ( ) -> slug ) ) { try { $ this -> Permissions -> addPermission ( $ plugin , $ perm_xml -> attributes ( ) -> slug , $ perm_xml -> attributes ( ) -> title ) ; } catch ( ValidationException $ ve ) { throw new Exception ( 'Permissions: ' . $ ve -> getMessage ( ) ) ; } } $ log .= "Permission created...\n" ; $ log .= "Slug: " . $ perm_xml -> attributes ( ) -> slug . "\n" ; $ log .= "Title: " . $ perm_xml -> attributes ( ) -> title . "\n" ; $ log .= "\n" ; } }
Add all of the Plugin's permissions from the specified XML

@param Plugin            $plugin The Plugin to process
@param string            &$log   A variable to update with log details
@param SimpleXMLExtended $xml    If specified, process this XML, otherwise load the XML from the plugin

@return void
Add all of the Plugin s permissions from the specified XML