Exemplo n.º 1
0
 /**
  * display method of View
  * @return void
  */
 public function display($tpl = null)
 {
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     // Assign the variables
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->script = $this->get('Script');
     $this->state = $this->get('State');
     // get action permissions
     $this->canDo = DemoHelper::getActions('help_document', $this->item);
     // get input
     $jinput = JFactory::getApplication()->input;
     $this->ref = $jinput->get('ref', 0, 'word');
     $this->refid = $jinput->get('refid', 0, 'int');
     $this->referral = '';
     if ($this->refid) {
         // return to the item that refered to this item
         $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid;
     } elseif ($this->ref) {
         // return to the list view that refered to this item
         $this->referral = '&ref=' . (string) $this->ref;
     }
     // Set the toolbar
     $this->addToolBar();
     // Display the template
     parent::display($tpl);
     // Set the document
     $this->setDocument();
 }
Exemplo n.º 2
0
 /**
  * Setting the toolbar
  */
 protected function addToolBar()
 {
     $canDo = DemoHelper::getActions('demo');
     JToolBarHelper::title(JText::_('COM_DEMO_DASHBOARD'), 'grid-2');
     // set help url for this view if found
     $help_url = DemoHelper::getHelpUrl('demo');
     if (DemoHelper::checkString($help_url)) {
         JToolbarHelper::help('COM_DEMO_HELP_MANAGER', false, $help_url);
     }
     if ($canDo->get('core.admin') || $canDo->get('core.options')) {
         JToolBarHelper::preferences('com_demo');
     }
 }
Exemplo n.º 3
0
 /**
  * Help_documents view display method
  * @return void
  */
 function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         // Include helper submenu
         DemoHelper::addSubmenu('help_documents');
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     // Assign data to the view
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->user = JFactory::getUser();
     $this->listOrder = $this->escape($this->state->get('list.ordering'));
     $this->listDirn = $this->escape($this->state->get('list.direction'));
     $this->saveOrder = $this->listOrder == 'ordering';
     // get global action permissions
     $this->canDo = DemoHelper::getActions('help_document');
     $this->canEdit = $this->canDo->get('help_document.edit');
     $this->canState = $this->canDo->get('help_document.edit.state');
     $this->canCreate = $this->canDo->get('help_document.create');
     $this->canDelete = $this->canDo->get('help_document.delete');
     $this->canBatch = $this->canDo->get('core.batch');
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
         $this->sidebar = JHtmlSidebar::render();
         // load the batch html
         if ($this->canCreate && $this->canEdit && $this->canState) {
             $this->batchDisplay = JHtmlBatch_::render();
         }
     }
     // Display the template
     parent::display($tpl);
     // Set the document
     $this->setDocument();
 }
Exemplo n.º 4
0
 public function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         // Include helper submenu
         DemoHelper::addSubmenu('import');
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $paths = new stdClass();
     $paths->first = '';
     $state = $this->get('state');
     $this->paths =& $paths;
     $this->state =& $state;
     // get global action permissions
     $this->canDo = DemoHelper::getActions('import');
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
         $this->sidebar = JHtmlSidebar::render();
     }
     // get the session object
     $session = JFactory::getSession();
     // check if it has package
     $this->hasPackage = $session->get('hasPackage', false);
     $this->dataType = $session->get('dataType', false);
     if ($this->hasPackage && $this->dataType) {
         $this->headerList = json_decode($session->get($this->dataType . '_VDM_IMPORTHEADERS', false), true);
         $this->headers = DemoHelper::getFileHeaders($this->dataType);
         // clear the data type
         $session->clear('dataType');
     }
     // Display the template
     parent::display($tpl);
 }
Exemplo n.º 5
0
 /**
  * Batch move items to a new category
  *
  * @param   integer  $value     The new category ID.
  * @param   array    $pks       An array of row IDs.
  * @param   array    $contexts  An array of item contexts.
  *
  * @return  boolean  True if successful, false otherwise and internal error is set.
  *
  * @since	12.2
  */
 protected function batchMove($values, $pks, $contexts)
 {
     if (empty($this->batchSet)) {
         // Set some needed variables.
         $this->user = JFactory::getUser();
         $this->table = $this->getTable();
         $this->tableClassName = get_class($this->table);
         $this->contentType = new JUcmType();
         $this->type = $this->contentType->getTypeByTable($this->tableClassName);
         $this->canDo = DemoHelper::getActions('look');
     }
     if (!$this->canDo->get('look.edit') && !$this->canDo->get('look.batch')) {
         $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
         return false;
     }
     // make sure published only updates if user has the permission.
     if (isset($values['published']) && !$this->canDo->get('look.edit.state')) {
         unset($values['published']);
     }
     // remove move_copy from array
     unset($values['move_copy']);
     // Parent exists so we proceed
     foreach ($pks as $pk) {
         if (!$this->user->authorise('look.edit', $contexts[$pk])) {
             $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
             return false;
         }
         // Check that the row actually exists
         if (!$this->table->load($pk)) {
             if ($error = $this->table->getError()) {
                 // Fatal error
                 $this->setError($error);
                 return false;
             } else {
                 // Not fatal error
                 $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
                 continue;
             }
         }
         // insert all set values.
         if (DemoHelper::checkArray($values)) {
             foreach ($values as $key => $value) {
                 // Do special action for access.
                 if ('access' == $key && strlen($value) > 0) {
                     $this->table->{$key} = $value;
                 } elseif (strlen($value) > 0 && isset($this->table->{$key})) {
                     $this->table->{$key} = $value;
                 }
             }
         }
         // Check the row.
         if (!$this->table->check()) {
             $this->setError($this->table->getError());
             return false;
         }
         if (!empty($this->type)) {
             $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
         }
         // Store the row.
         if (!$this->table->store()) {
             $this->setError($this->table->getError());
             return false;
         }
     }
     // Clean the cache
     $this->cleanCache();
     return true;
 }
Exemplo n.º 6
0
 /**
  * Save the data from the file to the database
  *
  * @param string  $package Paths to the uploaded package file
  *
  * @return  boolean false on failure
  *
  **/
 protected function save($data, $table)
 {
     // import the data if there is any
     if (DemoHelper::checkArray($data['array'])) {
         // get user object
         $user = JFactory::getUser();
         // remove header if it has headers
         $id_key = $data['target_headers']['id'];
         $published_key = $data['target_headers']['published'];
         $ordering_key = $data['target_headers']['ordering'];
         // get the first array set
         $firstSet = reset($data['array']);
         // check if first array is a header array and remove if true
         if ($firstSet[$id_key] == 'id' || $firstSet[$published_key] == 'published' || $firstSet[$ordering_key] == 'ordering') {
             array_shift($data['array']);
         }
         // make sure there is still values in array and that it was not only headers
         if (DemoHelper::checkArray($data['array']) && $user->authorise($table . '.import', 'com_demo') && $user->authorise('core.import', 'com_demo')) {
             // set target.
             $target = array_flip($data['target_headers']);
             // Get a db connection.
             $db = JFactory::getDbo();
             // set some defaults
             $todayDate = JFactory::getDate()->toSql();
             // get global action permissions
             $canDo = DemoHelper::getActions($table);
             $canEdit = $canDo->get('core.edit');
             $canState = $canDo->get('core.edit.state');
             $canCreate = $canDo->get('core.create');
             $hasAlias = $this->getAliasesUsed($table);
             // prosses the data
             foreach ($data['array'] as $row) {
                 $found = false;
                 if (isset($row[$id_key]) && is_numeric($row[$id_key]) && $row[$id_key] > 0) {
                     // raw items import & update!
                     $query = $db->getQuery(true);
                     $query->select('version')->from($db->quoteName('#__demo_' . $table))->where($db->quoteName('id') . ' = ' . $db->quote($row[$id_key]));
                     // Reset the query using our newly populated query object.
                     $db->setQuery($query);
                     $db->execute();
                     $found = $db->getNumRows();
                 }
                 if ($found && $canEdit) {
                     // update item
                     $id = $row[$id_key];
                     $version = $db->loadResult();
                     // reset all buckets
                     $query = $db->getQuery(true);
                     $fields = array();
                     // Fields to update.
                     foreach ($row as $key => $cell) {
                         // ignore column
                         if ('IGNORE' == $target[$key]) {
                             continue;
                         }
                         // update modified
                         if ('modified_by' == $target[$key]) {
                             continue;
                         }
                         // update modified
                         if ('modified' == $target[$key]) {
                             continue;
                         }
                         // update version
                         if ('version' == $target[$key]) {
                             $cell = (int) $version + 1;
                         }
                         // verify publish authority
                         if ('published' == $target[$key] && !$canState) {
                             continue;
                         }
                         // set to update array
                         if (in_array($key, $data['target_headers']) && is_numeric($cell)) {
                             $fields[] = $db->quoteName($target[$key]) . ' = ' . $cell;
                         } elseif (in_array($key, $data['target_headers']) && is_string($cell)) {
                             $fields[] = $db->quoteName($target[$key]) . ' = ' . $db->quote($cell);
                         } elseif (in_array($key, $data['target_headers']) && is_null($cell)) {
                             // if import data is null then set empty
                             $fields[] = $db->quoteName($target[$key]) . " = ''";
                         }
                     }
                     // load the defaults
                     $fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
                     $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
                     // Conditions for which records should be updated.
                     $conditions = array($db->quoteName('id') . ' = ' . $id);
                     $query->update($db->quoteName('#__demo_' . $table))->set($fields)->where($conditions);
                     $db->setQuery($query);
                     $db->execute();
                 } elseif ($canCreate) {
                     // insert item
                     $query = $db->getQuery(true);
                     // reset all buckets
                     $columns = array();
                     $values = array();
                     $version = false;
                     // Insert columns. Insert values.
                     foreach ($row as $key => $cell) {
                         // ignore column
                         if ('IGNORE' == $target[$key]) {
                             continue;
                         }
                         // remove id
                         if ('id' == $target[$key]) {
                             continue;
                         }
                         // update created
                         if ('created_by' == $target[$key]) {
                             continue;
                         }
                         // update created
                         if ('created' == $target[$key]) {
                             continue;
                         }
                         // Make sure the alias is incremented
                         if ('alias' == $target[$key]) {
                             $cell = $this->getAlias($cell, $table);
                         }
                         // update version
                         if ('version' == $target[$key]) {
                             $cell = 1;
                             $version = true;
                         }
                         // set to insert array
                         if (in_array($key, $data['target_headers']) && is_numeric($cell)) {
                             $columns[] = $target[$key];
                             $values[] = $cell;
                         } elseif (in_array($key, $data['target_headers']) && is_string($cell)) {
                             $columns[] = $target[$key];
                             $values[] = $db->quote($cell);
                         } elseif (in_array($key, $data['target_headers']) && is_null($cell)) {
                             // if import data is null then set empty
                             $columns[] = $target[$key];
                             $values[] = "''";
                         }
                     }
                     // load the defaults
                     $columns[] = 'created_by';
                     $values[] = $db->quote($user->id);
                     $columns[] = 'created';
                     $values[] = $db->quote($todayDate);
                     if (!$version) {
                         $columns[] = 'version';
                         $values[] = 1;
                     }
                     // Prepare the insert query.
                     $query->insert($db->quoteName('#__demo_' . $table))->columns($db->quoteName($columns))->values(implode(',', $values));
                     // Set the query using our newly populated query object and execute it.
                     $db->setQuery($query);
                     $done = $db->execute();
                     if ($done) {
                         $aId = $db->insertid();
                         // make sure the access of asset is set
                         DemoHelper::setAsset($aId, $table);
                     }
                 } else {
                     return false;
                 }
             }
             return true;
         }
     }
     return false;
 }
	@license		GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____  _____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \(  _  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/ )(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__)  (_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$edit = "index.php?option=com_demo&view=help_documents&task=help_document.edit";
foreach ($this->items as $i => $item) {
    ?>
	<?php 
    $canCheckin = $this->user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0;
    $userChkOut = JFactory::getUser($item->checked_out);
    $canDo = DemoHelper::getActions('help_document', $item, 'help_documents');
    ?>
	<tr class="row<?php 
    echo $i % 2;
    ?>
">
		<td class="order nowrap center hidden-phone">
		<?php 
    if ($canDo->get('help_document.edit.state')) {
        ?>
			<?php 
        if ($this->saveOrder) {
            $iconClass = ' inactive';
        } else {
            $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
        }
	@license		GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____  _____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \(  _  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/ )(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__)  (_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$edit = "index.php?option=com_demo&view=looks&task=look.edit";
foreach ($this->items as $i => $item) {
    ?>
	<?php 
    $canCheckin = $this->user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0;
    $userChkOut = JFactory::getUser($item->checked_out);
    $canDo = DemoHelper::getActions('look', $item, 'looks');
    ?>
	<tr class="row<?php 
    echo $i % 2;
    ?>
">
		<td class="order nowrap center hidden-phone">
		<?php 
    if ($canDo->get('look.edit.state')) {
        ?>
			<?php 
        if ($this->saveOrder) {
            $iconClass = ' inactive';
        } else {
            $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
        }