eZ Community » Forums » Developer » attributeedit policy
expandshrink

attributeedit policy

attributeedit policy

Tuesday 11 April 2006 11:12:48 am - 30 replies

Hi guys

I've made a hack to limit the editing of content objects to specific attributes.

You can download the modified files for eZ publish 3.7.5 at
http://pubsvn.ez.no/community/trunk/hacks/attributeedit_policy/3.7.5

You can now use a new policy content/attributeedit with limitations to full classes or specific attributes. You still need the content/edit policy to edit an object.

Note: only modified template for content/edit_attribute.tpl of the admin interface is provided.

Please test it and let me know what you think about it. Have fun!

Modified on Thursday 13 April 2006 4:13:09 pm by Kristof Coomans

Sunday 07 October 2007 9:37:25 pm

3.10.0 compatibility.

Hi Kristof,

I migrated to 3.10.0 and found that the ezcontentobject.php file must be modified to take into account the allLanguages and createWithNodeAssignment new functions.

line 221

'all_languages' => 'allLanguages',

Line 3278

/* ADDED FOR 3.10.0 compatibility 
    /*
     * Creates object with nodeAssignment from given parent Node, class ID and language code.
     */
    function createWithNodeAssignment( $parentNode, $contentClassID, $languageCode, $remoteID = false )
    {

        $class = eZContentClass::fetch( $contentClassID );
        $parentObject = $parentNode->attribute( 'object' );

        // Check if the user has access to create a folder here
        if ( strtolower( get_class( $class ) ) == "ezcontentclass" and
             $parentObject->checkAccess( 'create', $contentClassID, false, false, $languageCode ) == '1' )
        {
            // Set section of the newly created object to the section's value of it's parent object
            $sectionID = $parentObject->attribute( 'section_id' );

            include_once( "kernel/classes/datatypes/ezuser/ezuser.php" );
            $userID = eZUser::currentUserID();

            $db =& eZDB::instance();
            $db->begin();
            $contentObject = $class->instantiateIn( $languageCode, $userID, $sectionID, false, EZ_VERSION_STATUS_INTERNAL_DRAFT );
            $nodeAssignment = $contentObject->createNodeAssignment( $parentNode->attribute( 'node_id' ),
                                                                    true, $remoteID,
                                                                    $class->attribute( 'sort_field' ),
                                                                    $class->attribute( 'sort_order' ) );
            $db->commit();
            return $contentObject;
        }
        return null;
    }

Line 4622

/* added for 3.10.0 COMPATIBILITY */

    function &allLanguages()
    {
        $languages = isset( $this->LanguageMask ) ? eZContentLanguage::languagesByMask( $this->LanguageMask ) : array();
        return $languages;
    }

Looks to work fine like that.

Jacques-andré

Modified on Sunday 07 October 2007 9:38:03 pm by J-A Eberhard

Friday 09 November 2007 1:09:55 pm

Hi Kristof,

is there any plan to merge this hack into eZ main release in the soon future?

Saturday 15 December 2007 11:39:54 pm

*Bump*

Sunday 16 December 2007 10:30:36 pm

Hi

Sorry for the late answer, must have missed the question. Currently there are no plans to incorporate this into the kernel.

Sunday 16 December 2007 10:39:41 pm

Hello Kristof,

Are their plans to migrate the existing svn repository for this solution to projects.ez.no (say to support a 3.9, 3.10 or 4.0 specific branches)?

Respectfully,
Heath

Sunday 16 December 2007 10:46:20 pm

Sounds fine to me. I'll add it soon on projects.ez.no. If I forget, then kick me blunk.gif Emoticon

Monday 17 December 2007 8:25:33 am

Hi Kristof,

Thanks or the answer. Is there a rationale - other than time constraints - why this shouldn't be incorporated in the kernel? I find the hack very useful and my experience is that the workarounds if one can't set policy on attribute level tends to get very comlex and messy.

Thursday 27 March 2008 2:53:18 pm

closed

Modified on Thursday 30 April 2009 11:05:21 pm by Peter Schlund

Tuesday 16 September 2008 10:29:53 am

Hello,

Does the hack work with ez publish 4.0.0 ??

thanks,

Saturday 11 July 2009 5:11:18 am

I also would like to know if it works with eZ Publish 4.x.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu