示例#1
0
 /**
  * Method to export users to CSV
  *
  * @param null
  * @return null
  */
 public function export()
 {
     // Gather the variables
     $users = $this->getUserList();
     $website_id = MagebridgeModelConfig::load('users_website_id');
     $group_id = MagebridgeModelConfig::load('users_group_id');
     // Perform preliminary checks
     if (empty($users)) {
         $this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('No users found'), 'error');
         return false;
     }
     if (empty($website_id)) {
         $this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('Website not configured in export parameters'), 'error');
         return false;
     }
     if (empty($group_id)) {
         $this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('Customer Group not configured in export parameters'), 'error');
         return false;
     }
     $date = date('Ymd');
     $filename = 'magebridge-export-joomla-users_' . $date . '.csv';
     $output = $this->getOutput($users, $website_id, $group_id);
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Length: ' . YireoHelper::strlen($output));
     header('Content-type: text/x-csv');
     header('Content-Disposition: attachment; filename=' . $filename);
     print $output;
     // Close the application
     $application = JFactory::getApplication();
     $application->close();
 }
示例#2
0
 /**
  * Display method
  *
  * @param string $tpl
  * @return null
  */
 public function display($tpl = null)
 {
     // Set toolbar items for the page
     JToolBarHelper::custom('export', 'export.png', null, 'Export', false);
     JToolBarHelper::custom('import', 'import.png', null, 'Import', false);
     // Initialize common variables
     $application = JFactory::getApplication();
     $option = JFactory::getApplication()->input->getCmd('option') . '-users';
     // Handle the filters
     $filter_type = $application->getUserStateFromRequest($option . 'filter_type', 'filter_type', '', 'word');
     $filter_state = $application->getUserStateFromRequest($option . 'filter_state', 'filter_state', '', 'word');
     $filter_order = $application->getUserStateFromRequest($option . 'filter_order', 'filter_order', 'p.ordering', 'cmd');
     $filter_order_Dir = $application->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
     // Get data from the model
     $this->fetchItems();
     $items = $this->get('Data');
     $total = $this->get('Total');
     $pagination = $this->get('Pagination');
     // Table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // Prepare the items for display
     if (!empty($items)) {
         // Get a matching user list from the API
         $musers = $this->getMagentoUsers($items);
         foreach ($items as $index => $item) {
             $item->magento_name = null;
             $item->magento_id = null;
             if (!empty($musers)) {
                 foreach ($musers as $muser) {
                     if ($muser['email'] == $item->email) {
                         $item->magento_name = $muser['name'];
                         $item->magento_id = $muser['entity_id'];
                         break;
                     }
                 }
             }
             // Make sure demo-users are not seeing any sensitive data
             if (MageBridgeAclHelper::isDemo() == true) {
                 $censored_values = array('name', 'username', 'email', 'magento_name');
                 foreach ($censored_values as $censored_value) {
                     $item->{$censored_value} = str_repeat('*', YireoHelper::strlen($item->{$censored_value}));
                 }
             }
             $item->migrate_link = 'index.php?option=com_magebridge&view=user&task=migrate&cid[]=' . $item->id;
             $items[$index] = $item;
         }
     }
     $this->user = JFactory::getUser();
     $this->lists = $lists;
     $this->items = $items;
     $this->pagination = $pagination;
     parent::display($tpl);
 }
示例#3
0
                }
            }
        }
        if (JFactory::getApplication()->input->getCmd('current') == $return) {
            $css[] = 'current';
        }
        $css = array();
        if (isset($product['status']) && $product['status'] == 1) {
            $css[] = 'active';
        } else {
            $css[] = 'inactive';
        }
        if (YireoHelper::strlen($product['name']) > 50) {
            $product['name'] = substr($product['name'], 0, 47) . '...';
        }
        if (YireoHelper::strlen($product['url_key']) > 30) {
            $product['url_key'] = substr($product['url_key'], 0, 27) . '...';
        }
        $product_name = htmlspecialchars(str_replace("'", '', $product['name']));
        $jsDefault = "window.parent.jSelectProduct('{$return}', '{$product_name}', '" . JFactory::getApplication()->input->get('object') . "');";
        ?>
				<tr class="<?php 
        echo implode(' ', $css);
        ?>
">
					<td>
						<?php 
        echo $this->pagination->getRowOffset($i);
        ?>
					</td>
					<td>
示例#4
0
 /**
  * Method to set a raw header
  *
  * @param string $handle
  * @param string $header
  *
  * @return string
  */
 public function setRawHeader($handle, $header)
 {
     $this->rawheaders[] = $header;
     return YireoHelper::strlen($header);
 }
示例#5
0
 /**
  * Method to export configuration to XML
  */
 public function export()
 {
     // Gather the variables
     $config = MagebridgeModelConfig::load();
     $date = date('Ymd');
     $host = str_replace('.', '_', $_SERVER['HTTP_HOST']);
     $filename = 'magebridge-joomla-' . $host . '-' . $date . '.xml';
     $output = $this->getOutput($config);
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Length: ' . YireoHelper::strlen($output));
     header('Content-type: application/xml');
     header('Content-Disposition: attachment; filename=' . $filename);
     print $output;
     // Close the application
     $application = $this->_app;
     $application->close();
 }