About user editing folder in front web

Author Message

Albert Balagueró

Thursday 05 May 2011 7:28:20 am

Hi,

i would like to know if somebody knows about any complement or configuration of classes that allows to registered user to only edit the images that they have loaded in their own folder, automaticly created on user registration. And do this directly in the front web, not in the admin panel.

Thanks in advance.
Cheers!

Ivo Lukac

Thursday 05 May 2011 1:49:04 pm

There is an extension for this: http://projects.ez.no/personal_folder, but very old. It should be rewritten for newer eZ versions.

Basically you need to trigger a workflow after user registers which creates a folder and applies a specific role to the user so he can create images.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Quoc Huy Nguyen Dinh

Monday 09 May 2011 4:01:33 am

You can achieve this using the existing after-publishing trigger bound to a multiplexer workflow. Then the multiplexer would upon publishing of a 'user' object call a custom workflow which in turns calls a custom workflow event with this:

function execute( $process, $event )
{
    $parameters = $process->attribute( 'parameter_list' );

    // Retreive object info from the parameters
    $objectID = $parameters['object_id'];
    $object = eZContentObject::fetch( $objectID );
    $nodeID = $object->attribute( 'main_node_id' );
    $parentNodeID = $object->attribute( 'main_parent_node_id' );
    $datamap = $object->dataMap();

    // the user account being created 
    $userAccount = $datamap['user_account']->content();
    $userLogin = $userAccount->attribute('login');

    $params = array();

    // Node ID of the parent folder where to create the user personal folder
    // Best is to store that in an INI file
    $params['parent_node_id'] = 637;
    $params['class_identifier'] = 'folder';

    // The creator id is set to the user id
    $params['creator_id'] = $objectID;

    // attributes for the created folder
    $attributesData = array();

    // Set the name of the folder to the name of the user
    $attributesData['name'] = $object->attribute('name');
    // Set the short name to the user login
    $attributesData['short_name'] = $userLogin;

    $params['attributes'] = $attributesData;

    $db = eZDB::instance();
    $db->begin();
    $folderObject = eZContentFunctions::createAndPublishObject( $params );

    // In the user class, you can add a new attribute of datatype Enhanced Object Relation:
    // http://projects.ez.no/enhanced_objectrelation/
    // This can help to locate the user's personal folder
    $userFolderAttribute = $datamap['related_diagram_repository'];

    // Resetting default relation
    $fromObjectID =(int) $object->attribute('id');
    $contentClassAttributeID =(int) $userFolderAttribute->ContentClassAttributeID;
    $contentObjectVersion =(int) $object->attribute('version') + 1;
    $db->query( "DELETE FROM ezcontentobject_link WHERE from_contentobject_id='$fromObjectID' AND from_contentobject_version='$contentObjectVersion' AND  contentclassattribute_id='$contentClassAttributeID'" );

    // Set relation to the user's Folder
    $object->addContentObjectRelation($folderObject->attribute('id'), (int)$object->attribute('version'), $userFolderAttribute->ContentClassAttributeID);

    $db->commit();

    return eZWorkflowType::STATUS_ACCEPTED;

}

Albert Balagueró

Tuesday 24 May 2011 9:53:37 am

Hi to all,
thanks for your responds.

I've tried with personalfolder (I have done it one year ago and it worked) but it does not seem to work. I think that it is a problem with the "patch" files that I must copy to kernel/users. I don't reach to undertand what I'm doing wrong.

For the second option, how I link the workflow code to the trigger, I'm really new in eZ and I don't reach the way to do it like you told Quoc Huy Nguyen Dinh.
Please, I will really apreciate I you would you show me the steps, one by one, to do what you said.

Sorry for may bad english...

Thanks a lot to all!

Albert Balagueró

Tuesday 24 May 2011 9:56:46 am

Sorry, and another question, where do I must put the above code?

Thanks.

Quoc Huy Nguyen Dinh

Tuesday 24 May 2011 12:41:56 pm

Hi there, (what's your name by the way?)

I'm pretty busy these days so won't be able to fully help you with this, but I wrote a tutorial on how to create workflows, so please have a read at it and learn workflows as they are a pretty important eZ Publish feature. If you still have issues, I will try to give more help later.

http://share.ez.no/learn/ez-publish/creating-a-simple-custom-workflow-event

Albert Balagueró

Tuesday 24 May 2011 12:53:03 pm

Ups, sorry, my name is Albert,
if tried yet this tutorial but I'm going crazy, I don't know if I'm doing well all the steps, I don't reach the solution, I think I have a problem understanding the order of workflow creation.

I continue to try.
Thanks anyway.

I really apreciate your comments.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.