CHEF PLEASE, Let me know if you need more information in order to fix the issue.
JCOOK is no longer generating the component correctly in any of the versions (2.65 or 2.7.1) in order to stay in the Item view after saving.
I did try to generate the component in both versions. I did not work neither in JCOOK component Sandbox nor the downloaded file.
Then I wondered why if I new It was working the first time we downloaded the component. Then I compared the latest version generated with JCOOK and the initial version that I knew it was working.
Bellow are my findings:
I notice some changes on the controller file that are generated.
First version where it was working:
public function add()
{
CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
$this->_result = $result = parent::add();
$model = $this->getModel();
//Define the redirections
switch($this->getLayout() .'.'. $this->getTask())
{
case 'default.add':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.asset.asset'
), array(
));
break;
case 'modal.add':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.asset.asset'
), array(
));
break;
default:
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.asset.asset'
));
break;
}
}
New downloaded version that DOES NOT WORK:
public function add()
{
CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
$this->_result = $result = parent::add();
$model = $this->getModel();
//Define the redirections
switch($this->getLayout() .'.'. $this->getTask())
{
case 'default.':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
), array(
'cid[]' => null
));
break;
case 'modal.':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
), array(
'cid[]' => null
));
break;
default:
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.asset.asset'
));
break;
}
}
Here you would see that each case has something missing.
Also the SAVE function is different:
First version where it was working:
public function save()
{
CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
//Check the ACLs
$model = $this->getModel();
$item = $model->getItem();
$result = false;
if ($model->canEdit($item, true))
{
$result = parent::save();
//Get the model through postSaveHook()
if ($this->model)
{
$model = $this->model;
$item = $model->getItem();
}
}
else
JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('HASTORAGEAPP_JTOOLBAR_SAVE')) );
$this->_result = $result;
//Define the redirections
switch($this->getLayout() .'.'. $this->getTask())
{
case 'asset.apply':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.asset.asset'
), array(
'cid[]' => $model->getState('asset.id')
));
break;
case 'asset.save':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
), array(
'cid[]' => null
));
break;
case 'asset.save2new':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.asset.asset'
), array(
'cid[]' => null
));
break;
default:
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
));
break;
}
}
New downloaded version that DOES NOT WORK:
public function save()
{
CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
//Check the ACLs
$model = $this->getModel();
$item = $model->getItem();
$result = false;
if ($model->canEdit($item, true))
{
$result = parent::save();
//Get the model through postSaveHook()
if ($this->model)
{
$model = $this->model;
$item = $model->getItem();
}
}
else
JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('HASTORAGEAPP_JTOOLBAR_SAVE')) );
$this->_result = $result;
//Define the redirections
switch($this->getLayout() .'.'. $this->getTask())
{
case 'asset.':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
), array(
'cid[]' => null
));
break;
case 'asset.':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
), array(
'cid[]' => null
));
break;
case 'asset.':
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
), array(
'cid[]' => null
));
break;
default:
$this->applyRedirection($result, array(
'stay',
'com_hastorageapp.assets.default'
));
break;
}
}
Here you can see also a difference in each Case value:
Also the redirect is sending it to 'com_hastorageapp.assets.default' (sending it back to the Assets collection view) instead of keeping it on 'com_hastorageapp.asset.asset' (Item view)
Also since it is sending to to the Collection view it is removing the item id:
First version downloaded:
'cid[]' => $model->getState('asset.id')
Latest version NOT WORKING:
Talk to you
Miguel Santana