Forums / Developer / New multiple location of class

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.

eZ debug

Timing: Jan 19 2025 18:55:30
Script start
Timing: Jan 19 2025 18:55:30
Module start 'content'
Timing: Jan 19 2025 18:55:31
Module end 'content'
Timing: Jan 19 2025 18:55:31
Script end

Main resources:

Total runtime1.2930 sec
Peak memory usage4,096.0000 KB
Database Queries218

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0083 588.9531180.8359
Module start 'content' 0.00831.0457 769.7891657.5938
Module end 'content' 1.05400.2389 1,427.3828348.4375
Script end 1.2929  1,775.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.3267210.0002
Check MTime0.00170.1320210.0001
Mysql Total
Database connection0.00070.054510.0007
Mysqli_queries1.169190.41562180.0054
Looping result0.00320.24402160.0000
Template Total1.254397.020.6271
Template load0.00200.155420.0010
Template processing1.252396.850820.6261
Template load and register function0.00010.008910.0001
states
state_id_array0.00140.108410.0014
state_identifier_array0.00110.083920.0005
Override
Cache load0.00210.1595810.0000
Sytem overhead
Fetch class attribute can translate value0.00190.150530.0006
Fetch class attribute name0.00150.1138130.0001
XML
Image XML parsing0.00640.495330.0021
class_abstraction
Instantiating content class attribute0.00010.0040220.0000
General
dbfile0.01361.0514320.0004
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
11content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
11content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
24content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
13content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 64
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs