Hey guys,
I'm trying to programatically set the status of a page_standard asset and cascade the status to it's children. I've found processStatusChange($new_status) in core/include/asset_status/asset_status.inc but it's not seeming to do what I would expect. Actually, I'm not even sure it's working at all. I'm suspecting that the function uses HIPO which I'm not using.
Can anyone fill in the details?
Am I using the right function?
Am I using it correctly?
Do I need to use it?
etc…
I am able to update the page_standard assets status. I'm setting that to Up For Review. The rest of the child assets which have just been created under this existing page_standard asset have a status of Under Construction. While this works it's not very elegant or tidy. I'd prefer being able to set the children to Up For Review also.
Two points:
1/ you are on the right track when you talk about a HIPO; although it is possible to use processStatusChange() to change statuses, it is probably better to use the 'Edit Status' HIPO job (core/hipo/jobs/hipo_job_edit_status.inc) - possibly by 'freestyling' it; as you're only changing four assets, there shouldn't be too many problems with memory - to cascade it.
2/ Also, there is a defined path between the possible statuses, so not all of the statii can be reached from every other status. (I'm drawing up a quick and dirty diagram and edit this post shortly.) "Up for Review" can only be reached from "Live" status, not from "Under Construction" - if you run the HIPO with the children of the page still on U/C you would get errors about it not being able to change the status. They would all have to be "Live" before they could all be made "Up for Review".
-------
Edit: Attaching promised asset status diagram (admittedly VERY roughly drawn - I certainly have the hand of a developer, not that of a designer :D).
asset_status.png (44.7 KB)
Hmm… I think I might have been taking the wrong approach to this. I’ve just been examining the code in core/include/asset_static_screens/detail.inc that handles updateing the status of an asset. Looks like HIPO could be the way to go for this one.
I found this;
$hh = &$GLOBALS[‘SQ_SYSTEM’]->getHipoHerder();which seems to do what I want but I’ve hit a small snag.
$vars = Array(‘assetid’ => $owner->id, ‘new_status’ => $_POST[$prefix.’_change_status’], ‘dependants_only’ => $dependants_only);
$hh->queueHipo(‘hipo_job_edit_status’, $vars);
I’m unable to set the status of the new assets to Up For Review as they’re initially Under Construction. I have to go via Live. So I thought I’d run it twice. First seting Live and then setting it to Up For Review. The HIPO ran fine but left the assets Live.
Basically in order to run it twice I repeated the code above with the first setting it live and the second to Up For Review. Anyone have any ideas why this didn’t run?
I wonder… Can $vars be an array of arrays?
So that $hh->queueHipo('hipo_job_edit_status', $vars); is only called once.
I don't think you can do it that way (multi-dimensional array); it does have to be two steps.
I'm not sure whether queueHipo() is the right function for this instance - perhaps it is running one and the other is still queued up; I don't know. I suggest you try replacing your $hh->queueHipo() line with this (this is the so-called 'freestyling' of the HIPO, ie. it does it all at once):
$status_errors = $hh->freestyleHipo('hipo_job_edit_status', $vars);Any errors that are picked up will be placed in $status_errors as an array - if the page still doesn't change to "Up for Review" you might be able to glean some info from that.
Yep. the multi dimentional array didn't work. Trying this now…
That did the trick.
Thanks Luke.
Are there any docs on HIPO? Jobs that are available etc…
Not yet. I actually just finsihed a draft of the permissions system doco - but im waiting on people to look at that. I can send you a copy if your interested and you can tell me if you learnt anything 
Sounds like a plan. Looks like the forum hides e-mail addresses pretty good and I'm assuming it's an attachment? What format?
My e-mail address : gold_at_babel_dot_com_dot_au