public function importData()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // check if import is allowed for this user.
     $user = JFactory::getUser();
     if ($user->authorise('look.import', 'com_demo') && $user->authorise('core.import', 'com_demo')) {
         // Get the import model
         $model = $this->getModel('Looks');
         // get the headers to import
         $headers = $model->getExImPortHeaders();
         if (DemoHelper::checkObject($headers)) {
             // Load headers to session.
             $session = JFactory::getSession();
             $headers = json_encode($headers);
             $session->set('look_VDM_IMPORTHEADERS', $headers);
             $session->set('backto_VDM_IMPORT', 'looks');
             $session->set('dataType_VDM_IMPORTINTO', 'look');
             // Redirect to import view.
             $message = JText::_('COM_DEMO_IMPORT_SELECT_FILE_FOR_LOOKS');
             $this->setRedirect(JRoute::_('index.php?option=com_demo&view=import', false), $message);
             return;
         }
     }
     // Redirect to the list screen with error.
     $message = JText::_('COM_DEMO_IMPORT_FAILED');
     $this->setRedirect(JRoute::_('index.php?option=com_demo&view=looks', false), $message, 'error');
     return;
 }
 /**
  * Method to get list export data.
  *
  * @return mixed  An array of data items on success, false on failure.
  */
 public function getExportData($pks)
 {
     // setup the query
     if (DemoHelper::checkArray($pks)) {
         // Set a value to know this is exporting method.
         $_export = true;
         // Get the user object.
         $user = JFactory::getUser();
         // Create a new query object.
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         // Select some fields
         $query->select('a.*');
         // From the demo_help_document table
         $query->from($db->quoteName('#__demo_help_document', 'a'));
         $query->where('a.id IN (' . implode(',', $pks) . ')');
         // Implement View Level Access
         if (!$user->authorise('core.options', 'com_demo')) {
             $groups = implode(',', $user->getAuthorisedViewLevels());
             $query->where('a.access IN (' . $groups . ')');
         }
         // Order the results by ordering
         $query->order('a.ordering  ASC');
         // Load the items
         $db->setQuery($query);
         $db->execute();
         if ($db->getNumRows()) {
             $items = $db->loadObjectList();
             // set values to display correctly.
             if (DemoHelper::checkArray($items)) {
                 // get user object.
                 $user = JFactory::getUser();
                 foreach ($items as $nr => &$item) {
                     $access = $user->authorise('help_document.access', 'com_demo.help_document.' . (int) $item->id) && $user->authorise('help_document.access', 'com_demo');
                     if (!$access) {
                         unset($items[$nr]);
                         continue;
                     }
                     // unset the values we don't want exported.
                     unset($item->asset_id);
                     unset($item->checked_out);
                     unset($item->checked_out_time);
                 }
             }
             // Add headers to items array.
             $headers = $this->getExImPortHeaders();
             if (DemoHelper::checkObject($headers)) {
                 array_unshift($items, $headers);
             }
             return $items;
         }
     }
     return false;
 }