I have pagemaster and few pub types:
News
Articles
Classifields
Companies Catalogue
Each of them have its own workflow
News user submit to waiting and have option to edit his pub in waiting state without rev
moderator is able to approve pub then user is able to make a change new revision is maked and it is gooing to waiting state
Articles user submit to waiting and have option to edit his pub in waiting state without rev.
Moderator approve pub then user is able to make a change new revision is created and it is going to waiting state
Classifieds user is submitting have option to save it for 3 or 7 days (expire date) and the pub is going on line user is able to update pub, extend expire date, or delate pub.
Companies Catalogue user is submitting pub then he can edit pub in waiting state without new rev then moderator approve it. In approved user is able to make changes new revision is created and it is going on line old rev is off line but it is still in approve state.
When you starting with pagemaster it is hard to find out how it works.
First issue is that you make user to see all his pubs if "edit own" is on, he see even those witch are off line or in different state of course it is depending on permissions.
One "problem" with that is that links should be according to online state pid id
like this (publist without filter we want him to see all)
Code
<!--[if $pubitem.core_online == "1" ]-->
<a href="<!--[pnmodurl modname='pagemaster' type='user' func='viewpub' tid=$tid pid=$pubitem.core_pid]-->"><!--[$pubitem._NEWSTITLENAME]--></a>
<!--[elseif $pubitem.core_online == "0" ]-->
<a href="<!--[pnmodurl modname='pagemaster' type='user' func='viewpub' tid=$tid id=$pubitem.id]-->"><!--[$pubitem._NEWSTITLENAME]--></a>
<!--[/if]-->
<a href="<!--[pnmodurl modname='pagemaster' type='user' func='viewpub' tid=$tid pid=$pubitem.core_pid]-->"><!--[$pubitem._NEWSTITLENAME]--></a>
<!--[elseif $pubitem.core_online == "0" ]-->
<a href="<!--[pnmodurl modname='pagemaster' type='user' func='viewpub' tid=$tid id=$pubitem.id]-->"><!--[$pubitem._NEWSTITLENAME]--></a>
<!--[/if]-->
pnuserapi.php publist
Code
if (!SecurityUtil::checkPermission('pagemaster:full:', "$tid::", ACCESS_ADMIN) )
{
if (!empty($uid) && $pubtype['enableeditown'] == 1) {
//here he is getting list with all online pubs including all his own in all states
$where .= '('.$tbl_alias.'pm_author = '.$uid.' OR ('.$tbl_alias.'pm_online = 1 AND '.$tbl_alias.'pm_showinlist = 1))';
} else {
$where .= ' '.$tbl_alias.'pm_online = 1 AND '.$tbl_alias.'pm_showinlist = 1';
}
$where .= ' AND '.$tbl_alias.'pm_indepot = 0 ';
$where .= ' AND ( '.$tbl_alias.'pm_language = \'\' OR '.$tbl_alias.'pm_language = \''.pnUserGetLang().'\')';
$where .= ' AND ( '.$tbl_alias.'pm_publishdate <= NOW() OR '.$tbl_alias.'pm_publishdate IS NULL)';
$where .= ' AND ( '.$tbl_alias.'pm_expiredate >= NOW() OR '.$tbl_alias.'pm_expiredate IS NULL)';
}else
{
$where .= ' 1=1 ';
}
if (!empty($filter_where['where'])) {
$where .= ' AND '.$filter_where['where'];
}
{
if (!empty($uid) && $pubtype['enableeditown'] == 1) {
//here he is getting list with all online pubs including all his own in all states
$where .= '('.$tbl_alias.'pm_author = '.$uid.' OR ('.$tbl_alias.'pm_online = 1 AND '.$tbl_alias.'pm_showinlist = 1))';
} else {
$where .= ' '.$tbl_alias.'pm_online = 1 AND '.$tbl_alias.'pm_showinlist = 1';
}
$where .= ' AND '.$tbl_alias.'pm_indepot = 0 ';
$where .= ' AND ( '.$tbl_alias.'pm_language = \'\' OR '.$tbl_alias.'pm_language = \''.pnUserGetLang().'\')';
$where .= ' AND ( '.$tbl_alias.'pm_publishdate <= NOW() OR '.$tbl_alias.'pm_publishdate IS NULL)';
$where .= ' AND ( '.$tbl_alias.'pm_expiredate >= NOW() OR '.$tbl_alias.'pm_expiredate IS NULL)';
}else
{
$where .= ' 1=1 ';
}
if (!empty($filter_where['where'])) {
$where .= ' AND '.$filter_where['where'];
}
Now I am assuming that user is able to see his own pubs on the list witch are off line and we are happy with that
So now he have link in template with id (not pid!) to view that pub
pnuserapi.php getpub
Code
if (!SecurityUtil::checkPermission('pagemaster:full:', "$tid::", ACCESS_ADMIN) )
{
if (!empty($uid) && $pubtype['enableeditown'] == 1) {
//now we have uid, enableeditown is on and we are looking for pub if he is looking for online one he will get it
//but when he want offline one? To many pubs found!
$where .= ' ( pm_author = '.$uid.' OR pm_online = 1 )';
} else {
$where .= ' pm_online = 1 ';
}
$where .= ' AND pm_indepot = 0 ';
$where .= ' AND (pm_language = \'\' OR pm_language = \''.pnUserGetLang().'\')';
$where .= ' AND (pm_publishdate <= NOW() OR pm_publishdate IS NULL)';
$where .= ' AND (pm_expiredate >= NOW() OR pm_expiredate IS NULL)';
} else {
$where .= ' 1=1 ';
}
if (empty($args['id'])) {
// another question let say that in approved state we have 3 pubs they have the same pid but only one is online
//pid should point only to online one
//I need that for companies catalogue because since moderator approve publication I want user to be able to do
//changes in it and send it online as new rev so he have few revisions and can switch them online or offline
// as he want I can do another state but why approved is ok
//so as admin Im trying to view his online pub and Im ending with to many pubs found error
$where .= ' AND pm_pid = '.$args['pid'];
} else {
$where .= ' AND pm_id = '.$args['id'];
{
if (!empty($uid) && $pubtype['enableeditown'] == 1) {
//now we have uid, enableeditown is on and we are looking for pub if he is looking for online one he will get it
//but when he want offline one? To many pubs found!
$where .= ' ( pm_author = '.$uid.' OR pm_online = 1 )';
} else {
$where .= ' pm_online = 1 ';
}
$where .= ' AND pm_indepot = 0 ';
$where .= ' AND (pm_language = \'\' OR pm_language = \''.pnUserGetLang().'\')';
$where .= ' AND (pm_publishdate <= NOW() OR pm_publishdate IS NULL)';
$where .= ' AND (pm_expiredate >= NOW() OR pm_expiredate IS NULL)';
} else {
$where .= ' 1=1 ';
}
if (empty($args['id'])) {
// another question let say that in approved state we have 3 pubs they have the same pid but only one is online
//pid should point only to online one
//I need that for companies catalogue because since moderator approve publication I want user to be able to do
//changes in it and send it online as new rev so he have few revisions and can switch them online or offline
// as he want I can do another state but why approved is ok
//so as admin Im trying to view his online pub and Im ending with to many pubs found error
$where .= ' AND pm_pid = '.$args['pid'];
} else {
$where .= ' AND pm_id = '.$args['id'];
I made some changes to that and it is working but I don't know if it is ok, it is working at least:)
Code
if (!SecurityUtil::checkPermission('pagemaster:full:', "$tid::", ACCESS_ADMIN) )
{
if (!empty($uid) && $pubtype['enableeditown'] == 1)
{
if (empty($args['id'])) {
$where .= ' ( pm_author = '.$uid.' OR pm_online = 1 )';
} else {
$where .= ' pm_id = '.$args['id'];
}
} else {
if (empty($args['id'])) {
$where .= ' pm_online = 1 AND pm_pid = '.$args['pid'];
} else {
$where .= ' pm_id = '.$args['id'];
}
}
$where .= ' AND pm_indepot = 0 ';
$where .= ' AND (pm_language = \'\' OR pm_language = \''.pnUserGetLang().'\')';
$where .= ' AND (pm_publishdate <= NOW() OR pm_publishdate IS NULL)';
$where .= ' AND (pm_expiredate >= NOW() OR pm_expiredate IS NULL)';
} else {
$where .= ' 1=1 ';
}
if (empty($args['id'])) {
$where .= 'AND pm_online = 1 AND pm_pid = '.$args['pid'];
} else {
$where .= ' AND pm_id = '.$args['id'];
}
{
if (!empty($uid) && $pubtype['enableeditown'] == 1)
{
if (empty($args['id'])) {
$where .= ' ( pm_author = '.$uid.' OR pm_online = 1 )';
} else {
$where .= ' pm_id = '.$args['id'];
}
} else {
if (empty($args['id'])) {
$where .= ' pm_online = 1 AND pm_pid = '.$args['pid'];
} else {
$where .= ' pm_id = '.$args['id'];
}
}
$where .= ' AND pm_indepot = 0 ';
$where .= ' AND (pm_language = \'\' OR pm_language = \''.pnUserGetLang().'\')';
$where .= ' AND (pm_publishdate <= NOW() OR pm_publishdate IS NULL)';
$where .= ' AND (pm_expiredate >= NOW() OR pm_expiredate IS NULL)';
} else {
$where .= ' 1=1 ';
}
if (empty($args['id'])) {
$where .= 'AND pm_online = 1 AND pm_pid = '.$args['pid'];
} else {
$where .= ' AND pm_id = '.$args['id'];
}
Another thing witch is making error is this bit
pnuser.php pagemaster_user_dynHandler
Code
// sombody change this always back, pls let it be like this, otherwise stepmode does not work!
// if the item moved to the depot
if ($data[$args['commandName']]['core_indepot'] == 1) {
$this->goto = pnModURL('pagemaster', 'user', 'main',
array('tid' => $data['tid']));
}elseif ($this->goto == 'stepmode') {
// stepmode can be used to go automaticaly from one workflowstep to the next
$this->goto = pnModURL('pagemaster', 'user', 'pubedit',
array('tid' => $data['tid'],
'id' => $data['id'],
'goto' => 'stepmode'));
}elseif (empty($this->goto)) {
$this->goto = pnModURL('pagemaster', 'user', 'viewpub',
array('tid' => $data['tid'],
'pid' => $data['core_pid']));
// here if ther is no goto and if we are in approved pub and we are editing it let say taking offline or deleting
//we have missing pub error ;/
}
if (empty($data)) {
return false;
} else {
return $render->pnFormRedirect($this->goto);
}
}
}
// if the item moved to the depot
if ($data[$args['commandName']]['core_indepot'] == 1) {
$this->goto = pnModURL('pagemaster', 'user', 'main',
array('tid' => $data['tid']));
}elseif ($this->goto == 'stepmode') {
// stepmode can be used to go automaticaly from one workflowstep to the next
$this->goto = pnModURL('pagemaster', 'user', 'pubedit',
array('tid' => $data['tid'],
'id' => $data['id'],
'goto' => 'stepmode'));
}elseif (empty($this->goto)) {
$this->goto = pnModURL('pagemaster', 'user', 'viewpub',
array('tid' => $data['tid'],
'pid' => $data['core_pid']));
// here if ther is no goto and if we are in approved pub and we are editing it let say taking offline or deleting
//we have missing pub error ;/
}
if (empty($data)) {
return false;
} else {
return $render->pnFormRedirect($this->goto);
}
}
}
I have change it to this it is not affecting stepmode
Code
And at the end :)
function.updatePub.php
Code
if (isset($params['online'])) //should be nexstate
$nextState = $params['nextstate'];
else
$nextState = $obj['__WORKFLOW__']['state'];
$nextState = $params['nextstate'];
else
$nextState = $obj['__WORKFLOW__']['state'];
function.updateOnlineState.php
Code
function pagemaster_operation_updateOnlineState(&$obj, $params)
{
// set the online parameter, or set it offline if is not set
$obj['core_online'] = isset($params['online']) ? (int)$params['online'] : 0;
//this way with online=1 if we have one online pub already we will have two of them in online=1 and same pid
// return the updated object
return DBUtil::updateObject($obj, $obj['__WORKFLOW__']['obj_table']);
}
{
// set the online parameter, or set it offline if is not set
$obj['core_online'] = isset($params['online']) ? (int)$params['online'] : 0;
//this way with online=1 if we have one online pub already we will have two of them in online=1 and same pid
// return the updated object
return DBUtil::updateObject($obj, $obj['__WORKFLOW__']['obj_table']);
}
I fix it this way
Code
function pagemaster_operation_updateOnlineState(&$obj, $params)
{
if (isset($params['online']) && $params['online'] == 1) {
//set all other to offline
$data = array('core_online' => 0);
$result = DBUtil::updateObject($data, $obj['__WORKFLOW__']['obj_table'], 'pm_online = 1 and pm_pid = '.$obj['core_pid']);
$obj['core_online'] = $params['online'];
} elseif (isset($params['online']) && $params['online'] == 0) {
//set it offline if is not set
$obj['core_online'] = isset($params['online']) ? (int)$params['online'] : 0;
}
// return the updated object
return DBUtil::updateObject($obj, $obj['__WORKFLOW__']['obj_table']);
}
{
if (isset($params['online']) && $params['online'] == 1) {
//set all other to offline
$data = array('core_online' => 0);
$result = DBUtil::updateObject($data, $obj['__WORKFLOW__']['obj_table'], 'pm_online = 1 and pm_pid = '.$obj['core_pid']);
$obj['core_online'] = $params['online'];
} elseif (isset($params['online']) && $params['online'] == 0) {
//set it offline if is not set
$obj['core_online'] = isset($params['online']) ? (int)$params['online'] : 0;
}
// return the updated object
return DBUtil::updateObject($obj, $obj['__WORKFLOW__']['obj_table']);
}
And that is all...:)
If you can tell me if thats are bugs or it supposed to work this way?
--
rgfdgafgaf
