| Current Path : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_poll/views/answer/ |
| Current File : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_poll/views/answer/view.html.php |
<?php
// No direct access
defined( '_JEXEC' ) or die;
/**
* View for edit current element
* @author kirdinyuri
*/
class PollViewAnswer extends JViewLegacy
{
protected $form;
protected $item;
protected $user;
/**
* Method to display the current pattern
* @param String $tpl
*/
public function display( $tpl = null )
{
$this->form = $this->get( 'Form' );
$this->item = $this->get( 'Item' );
$this->user = JFactory::getUser();
if ( count( $errors = $this->get( 'Errors' ) ) ) {
JError::raiseError( 500, implode( '\n', $errors ) );
return false;
}
$this->loadHelper( 'poll' );
$this->canDo = pollHelper::getActions( 'answer' );
$this->_setToolBar();
parent::display( $tpl );
}
/**
* Method to display the toolbar
*/
protected function _setToolBar()
{
JFactory::getApplication()->input->set( 'hidemainmenu', true );
$isNew = ( $this->item->id == 0 );
$canDo = pollHelper::getActions( 'answer', $this->item->id );
JToolBarHelper::title( JText::_( 'COM_POLL' ) . ': <small>[ ' . ( $isNew ? JText::_( 'JTOOLBAR_NEW' ) : JText::_( 'JTOOLBAR_EDIT' ) ) . ']</small>' );
// For new records, check the create permission.
if ( $isNew && ( count( $this->user->getAuthorisedCategories( 'com_poll', 'core.create' ) ) > 0 ) ) {
JToolBarHelper::apply( 'answer.apply' );
JToolBarHelper::save( 'answer.save' );
JToolBarHelper::save2new( 'answer.save2new' );
JToolBarHelper::cancel( 'answer.cancel' );
} else {
// Can't save the record if it's checked out.
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
if ( $canDo->get( 'core.edit' ) || ( $canDo->get( 'core.edit.own' ) && $this->item->created_by == $this->user->get( 'id' ) ) ) {
JToolBarHelper::apply( 'answer.apply' );
JToolBarHelper::save( 'answer.save' );
// We can save this record, but check the create permission to see if we can return to make a new one.
if ( $canDo->get( 'core.create' ) ) {
JToolBarHelper::save2new( 'answer.save2new' );
}
}
// If checked out, we can still save
if ( $canDo->get( 'core.create' ) ) {
JToolBarHelper::save2copy( 'answer.save2copy' );
}
JToolBarHelper::cancel( 'answer.cancel', 'JTOOLBAR_CLOSE' );
}
}
}