New multiple location of class

Author Message

Siniša Šehović

Thursday 07 October 2004 6:51:26 am

Hi ppl

I have one problem.
I have 600 users in users section now I need to link them(new location) to standard section in predefined folder.(Could use template to show them but I need link)
I know how to do it by hand one by one:-)
How can I do it by php code?

Please help!

Best regards,
Sinisa

---
If at first you don't succeed, look in the trash for the instructions.

Gunnstein Lye

Monday 11 October 2004 4:07:53 am

Something like this should work:
(fill in for the question marks)

<?php

$currentParentNodeID = ?;
$extraParentNodeID = ?;

$nodeList =& eZContentObjectTreeNode::subTree( array( 'ClassID' => 4,
                                                      'Depth' => 1,
                                                      'AsObject' => false ),
                                               $currentParentNodeID );

foreach( $nodeList as $node )
{
    // Fetch object
    $contentObject =& eZContentObject::fetch( $node['contentobject_id'] );

    // Create extra node assignment
    $nodeAssignment =& eZNodeAssignment::create(
        array( 'contentobject_id' => $contentObject->attribute( 'id' ),
               'contentobject_version' => $contentObject->attribute( 'current_version' ),
               'is_main' => 0,
               'parent_node' => $extraParentNodeID ) );
    $nodeAssignment->store();

    // Publish the new object
    include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
    $operationResult = eZOperationHandler::execute( 'content', 'publish',
                                                    array( 'object_id' => $contentObject->attribute( 'id' ),
                                                           'version' => $contentObject->attribute( 'current_version' ) ) );
}

?>

Siniša Šehović

Monday 11 October 2004 5:23:57 am

Hi Lye,

How can I execute that script?
I tryied directly by calling it from http://website/script_name.php but nothing happend!?
Also tryied from command prompt(test server is on winblows) php script_name.php and still nothing.
I have changed

$currentParentNodeID = 63; //ID of user_group under users
$extraParentNodeID = 62; //ID of new direcotory

Not even error msg:)

What I'm dooing wrong?

Best regards,
Sinisa

---
If at first you don't succeed, look in the trash for the instructions.

Gunnstein Lye

Monday 11 October 2004 5:41:41 am

Well, I did not test this at all so there could be bugs in it. I suggest running it from the command line and using print() statements for debugging.

Siniša Šehović

Monday 11 October 2004 5:55:34 am

Hi

I did that but nothing happend.
What files(classes) I have to include_once?

I have for testing put simple echo but echo isn't shown on command line!??!

Sinisa

---
If at first you don't succeed, look in the trash for the instructions.

Siniša Šehović

Monday 11 October 2004 6:10:03 am

Hi

Here is what I get from php output:

<b>Warning</b>: Invalid argument supplied for foreach() in <b>D:\wwwroot\ezdemo
\lib\ezutils\classes\ezmoduleoperationinfo.php</b> on line <b>78</b><br />

What is wrong?
I use eZp 3.5alpha from svn

Sinisa

---
If at first you don't succeed, look in the trash for the instructions.

Gunnstein Lye

Monday 11 October 2004 6:25:09 am

If you miss an include_once, you will get a crash.
I don't know what could be wrong with your print/echo. Maybe a php setting.

The warning means that $nodeList is not an array, which probably means that the subTree() call returned false. That could be because some of the parameters are wrong.

Sorry, but that's all I can do to help.

Siniša Šehović

Wednesday 13 October 2004 2:07:47 am

Hi Lye

I have figured out what could be wrong.
I need to be authenticated to run that script.
But don't know how to do that.
Please help!

How to say to php that I'm administrator and have permisson to update database?

Best regards,
Sinisa

---
If at first you don't succeed, look in the trash for the instructions.

Gunnstein Lye

Wednesday 13 October 2004 5:23:23 am

This should do the trick:

<?php
include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
eZUser::loginUser( $login, $password );
?>

You need to add the user name and password, of course. And be careful, it is a security risk to put your plaintext admin password in a file like this.

Siniša Šehović

Wednesday 13 October 2004 5:50:49 am

Hi

Thanx for quick replay.
Still getting empty array in $nodeList?!?

$currentParentNodeID = 101 and $extraParentNodeID = 112 are existing one.

I want to make link form user class in users section of web into newly created section(eg. members) and that section has only one folder named members. Is it possible to do with that code?

Best regards,
Sinisa

---
If at first you don't succeed, look in the trash for the instructions.

Gunnstein Lye

Thursday 14 October 2004 5:03:27 am

Sorry, then I don't know what is wrong.

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

eZ debug

Timing: Jan 19 2025 19:57:44
Script start
Timing: Jan 19 2025 19:57:44
Module start 'layout'
Timing: Jan 19 2025 19:57:44
Module start 'content'
Timing: Jan 19 2025 19:57:44
Module end 'content'
Timing: Jan 19 2025 19:57:44
Script end

Main resources:

Total runtime0.0177 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 589.1563152.6250
Module start 'layout' 0.00700.0037 741.781339.4453
Module start 'content' 0.01070.0051 781.2266105.4453
Module end 'content' 0.01580.0018 886.671946.3047
Script end 0.0176  932.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002715.3699140.0002
Check MTime0.00137.3340140.0001
Mysql Total
Database connection0.00137.551310.0013
Mysqli_queries0.003217.927530.0011
Looping result0.00000.113410.0000
Template Total0.00158.510.0015
Template load0.00084.262210.0008
Template processing0.00074.244710.0007
Override
Cache load0.00053.090710.0005
General
dbfile0.00031.486080.0000
String conversion0.00000.058040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs