Author
|
Message
|
Felix Laate
|
Friday 10 March 2006 5:18:50 am
Hi all, just a quick question to kick off the weekend! I have added an attribute "active" to the user class. This is not set by default. Now I need to set it programmicaly from an externsion. I don't know the nodeid or the objectid, but i know the phonenumber (which also was added to the user class as an attribute). So I gather I need to fetch the user with the given phonenumber and then update the active-attribute of that user. Any help might make my weekend pleasant! Felix
Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com
|
Kåre Køhler Høvik
|
Sunday 12 March 2006 12:07:00 am
Hi This depends a bit on what kind of attribute it is, but I guess it's a boolean/checkbox in your case. Here is how to do it:
$object = eZContentObject::fetch( <object_id> );
$dataMap = $object->attribute( 'data_map' );
$active = $dataMap['<class attribute identifier>']; // Guess 'active' is your case
$active->setAttribute( 'data_int', <0|1> );
$active->sync();
Kåre Høvik
|
Felix Laate
|
Monday 13 March 2006 3:29:29 am
Hi Kåre, thank you very much for your answer. It helped me alot! Then I only need to figure out how I can get the objectid of the user with the given phonenumber. Any ideas? Felix
Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com
|
Kåre Køhler Høvik
|
Monday 13 March 2006 4:45:14 am
Hi Felix You can use the subtree function in content object tree node. Example :
$node = eZContentObjectTreeNode::subtree( 'AttributeFilter' =>
array( array( 'user/number', '=', '12345678' ) ) ), <parent node id> );
$object = $node->attribute( 'object' );
See also : http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/list
Kåre Høvik
|
Felix Laate
|
Monday 13 March 2006 5:31:38 am
Hi again, thank you again! The code returned a
unexpected T_DOUBLE_ARROW
I think I solved it by changing the code to
$node = eZContentObjectTreeNode::subtree( array('AttributeFilter' => array( array( 'user/mobiltelefon', '=', _a_real_phone_number_))), 125 );
But now the problem is that it ruturns nothing. I also tried to change the attribute and fetch by the login-name, but it gave the same result. Felix
Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com
|
Kåre Køhler Høvik
|
Monday 13 March 2006 5:48:46 am
Hi Felix
125 is a parent node id, not a parent object id ?
If you enable SQL output, how does the SQL look like ? What kind of datatype is the "mobilnummer" ?
Kåre Høvik
|
Felix Laate
|
Monday 13 March 2006 5:57:22 am
Hi Kåre, 125 is the NODE id where the users I want to fetch amongst are. Here is the SQL output:
SELECT ezcontentobject.*,
ezcontentobject_tree.*,
ezcontentclass.name as class_name,
ezcontentclass.identifier as class_identifier
, ezcontentobject_name.name as name, ezcontentobject_name.real_translation
FROM
ezcontentobject_tree,
ezcontentobject,ezcontentclass
, ezcontentobject_name
, ezcontentobject_attribute a0
WHERE
path_string like '/1/5/125/%' and
a0.contentobject_id = ezcontentobject.id AND
a0.contentclassattribute_id = 238 AND
a0.version = ezcontentobject_name.content_version AND
a0.language_code = ezcontentobject_name.real_translation AND
( a0.sort_key_string = 12345678) AND
ezcontentclass.version=0 AND
node_id != 125 AND
ezcontentobject_tree.contentobject_id = ezcontentobject.id AND
ezcontentclass.id = ezcontentobject.contentclass_id AND
ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and
ezcontentobject_name.content_translation = 'nor-NO'
AND ezcontentobject_tree.is_invisible = 0
AND ((ezcontentobject.section_id in (1)) OR (ezcontentobject.section_id in (3)))
ORDER BY path_string ASC
"mobiltelefon" is text line. Felix
Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com
|
Felix Laate
|
Wednesday 15 March 2006 3:16:05 am
Hi again, just wanted to tell you that I figured out what the problem was. The object(s) I wanted to fetch was situated in the users section, and I guess the <i>eZContentObjectTreeNode</i> class is the wrong class to use to fetch something from there. Had a look at the <i>eZUser</i> class, but couldn't find anything to meet my needs. So I moved the objects into the content structure. Now it works, but I'm not completly satisfied as the objects really belong to the user section. Felix
Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com
|
Xavier Dutoit
|
Tuesday 03 April 2007 6:04:51 am
Hi, Access right issue ? What's the user that run the php code ?
http://www.sydesy.com
|
André R.
|
Tuesday 03 April 2007 6:05:25 am
Example for selection datatype, updating selection index from 3 to 4:
$dataMap = $object->attribute( 'data_map' );
$active = $dataMap['status'];
if ($active->attribute( 'data_text' ) == '3')
{
$active->setAttribute( 'data_text', '4' );
$active->sync();
}
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom
|