コード例 #1
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Printer
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayPrinter($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_PRINTER");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     // Initialiase variables.
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'printer.printer');
     $this->item = $item = $this->get('Item');
     $this->canDo = $canDo = RtiprintHelper::getActions($model->getId());
     $lists = array();
     $this->lists =& $lists;
     $user = JFactory::getUser();
     $isNew = $model->getId() == 0;
     //Check ACL before opening the view (prevent from direct access)
     if (!$model->canAccess($item)) {
         $model->setError(JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // Check for errors.
     if (count($errors = $model->getErrors())) {
         JError::raiseError(500, implode(BR, array_unique($errors)));
         return false;
     }
     $jinput = JFactory::getApplication()->input;
     //Hide the component menu in item layout
     $jinput->set('hidemainmenu', true);
     //Toolbar initialization
     // Cancel
     CkJToolBarHelper::cancel('printer.cancel', "RTIPRINT_JTOOLBAR_CANCEL");
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Printer
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayPrinter($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_PRINTER");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     // Initialiase variables.
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'printer.printer');
     $this->item = $item = $this->get('Item');
     $this->form = $form = $this->get('Form');
     $this->canDo = $canDo = RtiprintHelper::getActions($model->getId());
     $lists = array();
     $this->lists =& $lists;
     $user = JFactory::getUser();
     $isNew = $model->getId() == 0;
     //Check ACL before opening the form (prevent from direct access)
     if (!$model->canEdit($item, true)) {
         $model->setError(JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // Check for errors.
     if (count($errors = $model->getErrors())) {
         JError::raiseError(500, implode(BR, array_unique($errors)));
         return false;
     }
     $jinput = JFactory::getApplication()->input;
     //Hide the component menu in item layout
     $jinput->set('hidemainmenu', true);
     //Toolbar initialization
     JToolBarHelper::title(JText::_('RTIPRINT_LAYOUT_PRINTER'), 'rtiprint_printers');
     // Save
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::apply('printer.apply', "RTIPRINT_JTOOLBAR_SAVE");
     }
     // Save & Close
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::save('printer.save', "RTIPRINT_JTOOLBAR_SAVE_CLOSE");
     }
     // Save & New
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::save2new('printer.save2new', "RTIPRINT_JTOOLBAR_SAVE_NEW");
     }
     // Save to Copy
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::save2copy('printer.save2copy', "RTIPRINT_JTOOLBAR_SAVE_TO_COPY");
     }
     // Cancel
     CkJToolBarHelper::cancel('printer.cancel', "RTIPRINT_JTOOLBAR_CANCEL");
     // Delete
     if (!$isNew && $item->params->get('access-delete')) {
         JToolbar::getInstance('toolbar')->appendButton('Confirm', JText::_('RTIPRINT_JTOOLBAR_ARE_YOU_SURE_TO_DELETE'), 'delete', "RTIPRINT_JTOOLBAR_DELETE", 'printer.delete', false);
     }
     $model_printer_model = CkJModel::getInstance('Printermdls', 'RtiprintModel');
     $model_printer_model->addGroupOrder("a.name");
     $lists['fk']['printer_model'] = $model_printer_model->getItems();
     $model_server = CkJModel::getInstance('Servers', 'RtiprintModel');
     $model_server->addGroupOrder("a.name");
     $lists['fk']['server'] = $model_server->getItems();
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : RT iPrint
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayDefault($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_RT_IPRINT");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->menu = RtiprintHelper::addSubmenu('cpanel', 'default', 'cpanel');
     //Toolbar initialization
 }
コード例 #4
0
ファイル: controller.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Method to display a view.
  *
  * @access	public
  * @param	boolean	$cachable	If true, the view output will be cached.
  * @param	array	$urlparams	An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}..
  * @return	void
  *
  * @since	Cook 1.0
  */
 public function display($cachable = false, $urlparams = false)
 {
     $jinput = JFactory::getApplication()->input;
     $this->_parentDisplay();
     //If page is called through POST, reconstruct the url
     if ($jinput->getMethod(null, null) == 'POST') {
         //Kill the post and rebuild the url
         $this->setRedirect(RtiprintHelper::urlRequest());
         return;
     }
     return $this;
 }
コード例 #5
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Town
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayTown($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_TOWN");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     // Initialiase variables.
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'town.town');
     $this->item = $item = $this->get('Item');
     $this->form = $form = $this->get('Form');
     $this->canDo = $canDo = RtiprintHelper::getActions($model->getId());
     $lists = array();
     $this->lists =& $lists;
     $user = JFactory::getUser();
     $isNew = $model->getId() == 0;
     //Check ACL before opening the form (prevent from direct access)
     if (!$model->canEdit($item, true)) {
         $model->setError(JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // Check for errors.
     if (count($errors = $model->getErrors())) {
         JError::raiseError(500, implode(BR, array_unique($errors)));
         return false;
     }
     $jinput = JFactory::getApplication()->input;
     //Hide the component menu in item layout
     $jinput->set('hidemainmenu', true);
     //Toolbar initialization
     JToolBarHelper::title(JText::_('RTIPRINT_LAYOUT_TOWN'), 'rtiprint_towns');
     // Preview
     CkJToolBarHelper::preview('index.php?option=com_rtiprint&view=town&layout=town&tmpl=component&cid=' . $model->getState('town.id'));
     // Save
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::apply('town.apply', "RTIPRINT_JTOOLBAR_SAVE");
     }
     // Save & Close
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::save('town.save', "RTIPRINT_JTOOLBAR_SAVE_CLOSE");
     }
     // Save & New
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::save2new('town.save2new', "RTIPRINT_JTOOLBAR_SAVE_NEW");
     }
     // Save to Copy
     if ($isNew && $model->canCreate() || !$isNew && $item->params->get('access-edit')) {
         CkJToolBarHelper::save2copy('town.save2copy', "RTIPRINT_JTOOLBAR_SAVE_TO_COPY");
     }
     // Cancel
     CkJToolBarHelper::cancel('town.cancel', "RTIPRINT_JTOOLBAR_CANCEL");
 }
コード例 #6
0
ファイル: field.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Method to check the authorisations.
  *
  * @access	public
  *
  * @return	boolean	True if user is allowed to see the field.
  */
 public function canView()
 {
     if (!isset($this->element['access'])) {
         return true;
     }
     $access = (string) $this->element['access'];
     $acl = RtiprintHelper::getActions();
     foreach (explode(",", $access) as $action) {
         if ($acl->get($action)) {
             return true;
         }
     }
     return false;
 }
コード例 #7
0
ファイル: towns.php プロジェクト: gwtrains/comRTiPrint
 public function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $acl = RtiprintHelper::getActions();
     parent::populateState('a.ordering', 'asc');
     //Only show the published items
     if (!$acl->get('core.admin') && !$acl->get('core.edit.state')) {
         $this->setState('filter.published', 1);
     }
     $this->setState('list.limit', 0);
     $this->setState('list.ordering', 'a.town');
     $this->setState('list.direction', 'ASC');
 }
コード例 #8
0
ファイル: printer.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Preparation of the query.
  *
  * @access	protected
  * @param	object	&$query	returns a filled query object.
  * @param	integer	$pk	The primary id key of the printer
  * @return	void
  */
 protected function prepareQuery(&$query, $pk)
 {
     $acl = RtiprintHelper::getActions();
     //FROM : Main table
     $query->from('#__rtiprint_printers AS a');
     //IMPORTANT REQUIRED FIELDS
     $this->addSelect('a.id,' . 'a.created_by,' . 'a.published');
     switch ($this->getState('context', 'all')) {
         case 'printer.printer':
             //BASE FIELDS
             $this->addSelect('a.ip_address,' . 'a.location,' . 'a.name,' . 'a.printer_model,' . 'a.server');
             //SELECT
             $this->addSelect('_printer_model_.name AS `_printer_model_name`');
             $this->addSelect('_printer_model_.asset_code AS `_printer_model_asset_code`');
             $this->addSelect('_printer_model_.manual AS `_printer_model_manual`');
             $this->addSelect('_printer_model_.manufacturer AS `_printer_model_manufacturer`');
             $this->addSelect('_printer_model_manufacturer_.name AS `_printer_model_manufacturer_name`');
             $this->addSelect('_printer_model_.image AS `_printer_model_image`');
             $this->addSelect('_server_.name AS `_server_name`');
             $this->addSelect('_server_.ip_address AS `_server_ip_address`');
             //JOIN
             $this->addJoin('`#__rtiprint_printermdls` AS _printer_model_ ON _printer_model_.id = a.printer_model', 'LEFT');
             $this->addJoin('`#__rtiprint_manufacturers` AS _printer_model_manufacturer_ ON _printer_model_manufacturer_.id = _printer_model_.manufacturer', 'LEFT');
             $this->addJoin('`#__rtiprint_servers` AS _server_ ON _server_.id = a.server', 'LEFT');
             break;
         case 'all':
             //SELECT : raw complete query without joins
             $query->select('a.*');
             break;
     }
     //WHERE : Item layout (based on $pk)
     $query->where('a.id = ' . (int) $pk);
     //TABLE KEY
     //FILTER - Access for : Root table
     $wherePublished = $allowAuthor = true;
     $whereAccess = false;
     $this->prepareQueryAccess('a', $whereAccess, $wherePublished, $allowAuthor);
     $query->where("({$allowAuthor} OR {$wherePublished})");
     //SELECT : Instance Add-ons
     foreach ($this->getState('query.select', array()) as $select) {
         $query->select($select);
     }
     //JOIN : Instance Add-ons
     foreach ($this->getState('query.join.left', array()) as $join) {
         $query->join('LEFT', $join);
     }
 }
コード例 #9
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Contents
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayModal($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_CONTENTS");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'thirdcontents.modal');
     $this->items = $items = $this->get('Items');
     $this->canDo = $canDo = RtiprintHelper::getActions();
     $this->pagination = $this->get('Pagination');
     $this->menu = RtiprintHelper::addSubmenu('contents', 'modal');
     $lists = array();
     $this->lists =& $lists;
     //Toolbar initialization
     JToolBarHelper::title(JText::_('RTIPRINT_LAYOUT_CONTENTS'), 'rtiprint_contents');
 }
コード例 #10
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Users
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayModal($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_USERS");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'thirdusers.modal');
     $this->items = $items = $this->get('Items');
     $this->canDo = $canDo = RtiprintHelper::getActions();
     $this->pagination = $this->get('Pagination');
     $this->filters = $filters = $model->getForm('modal.filters');
     $this->menu = RtiprintHelper::addSubmenu('users', 'modal');
     $lists = array();
     $this->lists =& $lists;
     //Filters
     // Limit
     $filters['limit']->jdomOptions = array('pagination' => $this->pagination);
     //Toolbar initialization
     JToolBarHelper::title(JText::_('RTIPRINT_LAYOUT_USERS'), 'rtiprint_users');
 }
コード例 #11
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : ControlPanel
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayDefault($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_CONTROLPANEL");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'changelogs.default');
     $this->items = $items = $this->get('Items');
     $this->canDo = $canDo = RtiprintHelper::getActions();
     $this->pagination = $this->get('Pagination');
     $this->menu = RtiprintHelper::addSubmenu('changelogs', 'default');
     $this->mainmenu = RtiprintHelper::addSubmenu('changelogs', 'default', 'mainmenu');
     $this->geographymenu = RtiprintHelper::addSubmenu('changelogs', 'default', 'geographymenu');
     $this->systemmenu = RtiprintHelper::addSubmenu('changelogs', 'default', 'systemmenu');
     $lists = array();
     $this->lists =& $lists;
     //Toolbar initialization
     JToolBarHelper::title(JText::_('RTIPRINT_LAYOUT_CONTROLPANEL'), 'rtiprint_changelogs');
     // Config
     if ($model->canAdmin()) {
         CkJToolBarHelper::preferences('com_rtiprint');
     }
 }
コード例 #12
0
 /**
  * Preparation of the list query.
  *
  * @access	protected
  * @param	object	&$query	returns a filled query object.
  * @return	void
  */
 protected function prepareQuery(&$query)
 {
     $acl = RtiprintHelper::getActions();
     //FROM : Main table
     $query->from('#__rtiprint_operatingsystems AS a');
     //IMPORTANT REQUIRED FIELDS
     $this->addSelect('a.id,' . 'a.created_by,' . 'a.published');
     switch ($this->getState('context', 'all')) {
         case 'operatingsystems.default':
             //BASE FIELDS
             $this->addSelect('a.creation_date,' . 'a.modification_date,' . 'a.name,' . 'a.ordering');
             //SELECT
             $this->addSelect('_created_by_.name AS `_created_by_name`');
             //JOIN
             $this->addJoin('`#__users` AS _created_by_ ON _created_by_.id = a.created_by', 'LEFT');
             break;
         case 'operatingsystems.modal':
             //BASE FIELDS
             $this->addSelect('a.name');
             break;
         case 'all':
             //SELECT : raw complete query without joins
             $this->addSelect('a.*');
             // Disable the pagination
             $this->setState('list.limit', null);
             $this->setState('list.start', null);
             break;
     }
     //FILTER - Access for : Root table
     $wherePublished = $allowAuthor = true;
     $whereAccess = false;
     $this->prepareQueryAccess('a', $whereAccess, $wherePublished, $allowAuthor);
     $query->where("({$allowAuthor} OR {$wherePublished})");
     //WHERE - SEARCH : search_search : search on Name
     $search_search = $this->getState('search.search');
     $this->addSearch('search', 'a.name', 'like');
     if ($search_search != '' && ($search_search_val = $this->buildSearch('search', $search_search))) {
         $this->addWhere($search_search_val);
     }
     //WHERE - FILTER : Publish state
     $published = $this->getState('filter.published');
     if (is_numeric($published)) {
         $allowAuthor = '';
         if ($published == 1 && !$acl->get('core.edit.state')) {
             //Allow the author to see its own unpublished/archived/trashed items
             if ($acl->get('core.edit.own') || $acl->get('core.view.own')) {
                 $allowAuthor = ' OR a.created_by = ' . (int) JFactory::getUser()->get('id');
             }
         }
         $query->where('(a.published = ' . (int) $published . $allowAuthor . ')');
     } elseif (!$published) {
         $query->where('(a.published = 0 OR a.published = 1 OR a.published IS NULL)');
     }
     //WHERE - SEARCH : search_search_1 : search on Name
     $search_search_1 = $this->getState('search.search_1');
     $this->addSearch('search_1', 'a.name', 'like');
     if ($search_search_1 != '' && ($search_search_1_val = $this->buildSearch('search_1', $search_search_1))) {
         $this->addWhere($search_search_1_val);
     }
     //Populate only uniques strings to the query
     //SELECT
     foreach ($this->getState('query.select', array()) as $select) {
         $query->select($select);
     }
     //JOIN
     foreach ($this->getState('query.join.left', array()) as $join) {
         $query->join('LEFT', $join);
     }
     //WHERE
     foreach ($this->getState('query.where', array()) as $where) {
         $query->where($where);
     }
     //GROUP ORDER : Prioritary order for groups in lists
     foreach ($this->getState('query.groupOrder', array()) as $groupOrder) {
         $query->order($groupOrder);
     }
     //ORDER
     foreach ($this->getState('query.order', array()) as $order) {
         $query->order($order);
     }
     //ORDER
     $orderCol = $this->getState('list.ordering');
     $orderDir = $this->getState('list.direction', 'asc');
     if ($orderCol) {
         $query->order($orderCol . ' ' . $orderDir);
     }
 }
コード例 #13
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : PrinterModels
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayModal($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_PRINTERMODELS");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'printermdls.modal');
     $this->items = $items = $this->get('Items');
     $this->canDo = $canDo = RtiprintHelper::getActions();
     $this->pagination = $this->get('Pagination');
     $this->filters = $filters = $model->getForm('modal.filters');
     $this->menu = RtiprintHelper::addSubmenu('printermdls', 'modal');
     $lists = array();
     $this->lists =& $lists;
     //Filters
     // Manufacturer
     $modelManufacturer = CkJModel::getInstance('manufacturers', 'RtiprintModel');
     $filters['filter_manufacturer']->jdomOptions = array('list' => $modelManufacturer->getItems());
     // Limit
     $filters['limit']->jdomOptions = array('pagination' => $this->pagination);
     //Toolbar initialization
 }
コード例 #14
0
ファイル: list.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Prepare the query for filtering accesses. Can be used on foreign keys.
  *
  * @access	protected
  * @param	varchar	$table	The table alias (_tablealias_).
  * @param	varchar	&$whereAccess	The returned SQL access filter. Set to true to activate it.
  * @param	varchar	&$wherePublished	The returned SQL published filter. Set to true to activate it.
  * @param	varchar	&$allowAuthor	The returned SQL to allow author to pass. Set to true to activate it.
  * @return	void
  */
 protected function prepareQueryAccess($table = 'a', &$whereAccess = null, &$wherePublished = null, &$allowAuthor = null)
 {
     $acl = RtiprintHelper::getActions();
     // Must be aliased ex : _tablename_
     if ($table != 'a') {
         $table = '_' . trim($table, '_') . '_';
     }
     // ACCESS - View Level Access
     if ($whereAccess) {
         // Select fields requirements
         if ($table != 'a') {
             $this->addSelect($table . '.access AS `' . $table . 'access`');
         }
         $whereAccess = '1';
         if (!$this->canAdmin()) {
             $groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
             $whereAccess = $table . '.access IN (' . $groups . ')';
         }
     }
     // ACCESS - Author
     if ($allowAuthor) {
         // Select fields requirements
         if ($table != 'a') {
             $this->addSelect($table . '.created_by AS `' . $table . 'created_by`');
         }
         $allowAuthor = '0';
         //Allow the author to see its own unpublished/archived/trashed items
         if ($acl->get('core.edit.own') || $acl->get('core.view.own') || $acl->get('core.delete.own')) {
             $allowAuthor = $table . '.created_by = ' . (int) JFactory::getUser()->get('id');
         }
     }
     // ACCESS - Publish state
     if ($wherePublished) {
         // Select fields requirements
         if ($table != 'a') {
             $this->addSelect($table . '.published AS `' . $table . 'published`');
         }
         $wherePublished = '(' . $table . '.published = 1 OR ' . $table . '.published IS NULL)';
         //Published or undefined state
         //Allow some users to access (core.edit.state)
         if ($acl->get('core.edit.state')) {
             $wherePublished = '1';
         }
         //Do not filter
         // FILTER - Published state
         $published = $this->getState('filter.published');
         //Only apply filter on current table. Aand only if ACL permits.
         if ($table == 'a' && is_numeric($published) && $acl->get('core.edit.state')) {
             //Limit to publish state when filter is applied
             $wherePublished = $table . '.published = ' . (int) $published;
             //Does not apply the author condition when filter is defined
             $allowAuthor = '0';
         }
     }
     // Fallback values
     if (!$whereAccess) {
         $whereAccess = '1';
     }
     if (!$allowAuthor) {
         $allowAuthor = '0';
     }
     if (!$wherePublished) {
         $wherePublished = '1';
     }
 }
コード例 #15
0
ファイル: file.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Deprecated. see Helper::getDirectories()
  *
  * @access	public static
  *
  * @return	array	Directories shortcuts.
  *
  * @since	Cook 1.1
  */
 public static function getMarkers()
 {
     return RtiprintHelper::getDirectories();
 }
コード例 #16
0
ファイル: changelogs.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Preparation of the list query.
  *
  * @access	protected
  * @param	object	&$query	returns a filled query object.
  * @return	void
  */
 protected function prepareQuery(&$query)
 {
     $acl = RtiprintHelper::getActions();
     //FROM : Main table
     $query->from('#__rtiprint_changelogs AS a');
     //IMPORTANT REQUIRED FIELDS
     $this->addSelect('a.id,' . 'a.created_by,' . 'a.published');
     switch ($this->getState('context', 'all')) {
         case 'changelogs.default':
             //BASE FIELDS
             $this->addSelect('a.creation_date,' . 'a.summary,' . 'a.version');
             break;
         case 'all':
             //SELECT : raw complete query without joins
             $this->addSelect('a.*');
             // Disable the pagination
             $this->setState('list.limit', null);
             $this->setState('list.start', null);
             break;
     }
     //FILTER - Access for : Root table
     $wherePublished = $allowAuthor = true;
     $whereAccess = false;
     $this->prepareQueryAccess('a', $whereAccess, $wherePublished, $allowAuthor);
     $query->where("({$allowAuthor} OR {$wherePublished})");
     //Populate only uniques strings to the query
     //SELECT
     foreach ($this->getState('query.select', array()) as $select) {
         $query->select($select);
     }
     //JOIN
     foreach ($this->getState('query.join.left', array()) as $join) {
         $query->join('LEFT', $join);
     }
     //WHERE
     foreach ($this->getState('query.where', array()) as $where) {
         $query->where($where);
     }
     //GROUP ORDER : Prioritary order for groups in lists
     foreach ($this->getState('query.groupOrder', array()) as $groupOrder) {
         $query->order($groupOrder);
     }
     //ORDER
     foreach ($this->getState('query.order', array()) as $order) {
         $query->order($order);
     }
     //ORDER
     $orderCol = $this->getState('list.ordering');
     $orderDir = $this->getState('list.direction', 'asc');
     if ($orderCol) {
         $query->order($orderCol . ' ' . $orderDir);
     }
 }
コード例 #17
0
ファイル: printer.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Save an item.
  *
  * @access	public
  * @param	array	$data	The post values.
  *
  * @return	boolean	True on success.
  */
 public function save($data)
 {
     //Convert from a non-SQL formated date (created)
     $data['created'] = RtiprintHelperDates::getSqlDate($data['created'], array('Y-m-d'), true);
     //Convert from a non-SQL formated date (modified)
     $data['modified'] = RtiprintHelperDates::getSqlDate($data['modified'], array('Y-m-d'), true);
     //Some security checks
     $acl = RtiprintHelper::getActions();
     //Secure the published tag if not allowed to change
     if (isset($data['published']) && !$acl->get('core.edit.state')) {
         unset($data['published']);
     }
     //Secure the author key if not allowed to change
     if (isset($data['created_by']) && !$acl->get('core.edit')) {
         unset($data['created_by']);
     }
     if (parent::save($data)) {
         return true;
     }
     return false;
 }
コード例 #18
0
 /**
  * Preparation of the list query.
  *
  * @access	protected
  * @param	object	&$query	returns a filled query object.
  * @return	void
  */
 protected function prepareQuery(&$query)
 {
     $acl = RtiprintHelper::getActions();
     //FROM : Main table
     $query->from('#__viewlevels AS a');
     switch ($this->getState('context', 'all')) {
         case 'all':
             //SELECT : raw complete query without joins
             $this->addSelect('a.*');
             // Disable the pagination
             $this->setState('list.limit', null);
             $this->setState('list.start', null);
             break;
     }
     //Populate only uniques strings to the query
     //SELECT
     foreach ($this->getState('query.select', array()) as $select) {
         $query->select($select);
     }
     //JOIN
     foreach ($this->getState('query.join.left', array()) as $join) {
         $query->join('LEFT', $join);
     }
     //WHERE
     foreach ($this->getState('query.where', array()) as $where) {
         $query->where($where);
     }
     //GROUP ORDER : Prioritary order for groups in lists
     foreach ($this->getState('query.groupOrder', array()) as $groupOrder) {
         $query->order($groupOrder);
     }
     //ORDER
     foreach ($this->getState('query.order', array()) as $order) {
         $query->order($order);
     }
     //ORDER
     $orderCol = $this->getState('list.ordering');
     $orderDir = $this->getState('list.direction', 'asc');
     if ($orderCol) {
         $query->order($orderCol . ' ' . $orderDir);
     }
 }
コード例 #19
0
ファイル: favourite.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Save an item.
  *
  * @access	public
  * @param	array	$data	The post values.
  *
  * @return	boolean	True on success.
  */
 public function save($data)
 {
     //Some security checks
     $acl = RtiprintHelper::getActions();
     //Secure the published tag if not allowed to change
     if (isset($data['published']) && !$acl->get('core.edit.state')) {
         unset($data['published']);
     }
     //Secure the author key if not allowed to change
     if (isset($data['created_by']) && !$acl->get('core.edit')) {
         unset($data['created_by']);
     }
     if (parent::save($data)) {
         return true;
     }
     return false;
 }
コード例 #20
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Buildings
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayModal($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_BUILDINGS");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'buildings.modal');
     $this->items = $items = $this->get('Items');
     $this->canDo = $canDo = RtiprintHelper::getActions();
     $this->pagination = $this->get('Pagination');
     $this->filters = $filters = $model->getForm('modal.filters');
     $this->menu = RtiprintHelper::addSubmenu('buildings', 'modal');
     $lists = array();
     $this->lists =& $lists;
     //Filters
     // Towns
     $filters['filter_town']->jdomOptions = array('ajaxVars' => array('values' => array($model->getState("filter.town"))));
     // Limit
     $filters['limit']->jdomOptions = array('pagination' => $this->pagination);
     //Toolbar initialization
 }
コード例 #21
0
ファイル: favourites.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Preparation of the list query.
  *
  * @access	protected
  * @param	object	&$query	returns a filled query object.
  * @return	void
  */
 protected function prepareQuery(&$query)
 {
     $acl = RtiprintHelper::getActions();
     //FROM : Main table
     $query->from('#__rtiprint_favourites AS a');
     //IMPORTANT REQUIRED FIELDS
     $this->addSelect('a.id,' . 'a.created_by,' . 'a.published');
     switch ($this->getState('context', 'all')) {
         case 'favourites.default':
             //BASE FIELDS
             $this->addSelect('a.printer');
             //SELECT
             $this->addSelect('_printer_.name AS `_printer_name`');
             $this->addSelect('_printer_.building AS `_printer_building`');
             $this->addSelect('_printer_.printer_model AS `_printer_printer_model`');
             $this->addSelect('_printer_printer_model_.name AS `_printer_printer_model_name`');
             $this->addSelect('_printer_building_.building AS `_printer_building_building`');
             $this->addSelect('_printer_building_.town AS `_printer_building_town`');
             $this->addSelect('_printer_building_town_.town AS `_printer_building_town_town`');
             //JOIN
             $this->addJoin('`#__rtiprint_printers` AS _printer_ ON _printer_.id = a.printer', 'LEFT');
             $this->addJoin('`#__rtiprint_printermdls` AS _printer_printer_model_ ON _printer_printer_model_.id = _printer_.printer_model', 'LEFT');
             $this->addJoin('`#__rtiprint_buildings` AS _printer_building_ ON _printer_building_.id = _printer_.building', 'LEFT');
             $this->addJoin('`#__rtiprint_towns` AS _printer_building_town_ ON _printer_building_town_.id = _printer_building_.town', 'LEFT');
             break;
         case 'all':
             //SELECT : raw complete query without joins
             $this->addSelect('a.*');
             // Disable the pagination
             $this->setState('list.limit', null);
             $this->setState('list.start', null);
             break;
     }
     //FILTER - Access for : Root table
     $wherePublished = $allowAuthor = true;
     $whereAccess = false;
     $this->prepareQueryAccess('a', $whereAccess, $wherePublished, $allowAuthor);
     $query->where("({$allowAuthor} OR {$wherePublished})");
     //WHERE - FILTER : User
     if ((int) $this->getState('filter.created_by') > 0) {
         $this->addWhere("a.created_by = " . (int) $this->getState('filter.created_by'));
     } else {
         if ($this->getState('filter.created_by') == 'auto') {
             $this->addWhere('a.created_by = ' . (int) JFactory::getUser()->get('id'));
         }
     }
     //Populate only uniques strings to the query
     //SELECT
     foreach ($this->getState('query.select', array()) as $select) {
         $query->select($select);
     }
     //JOIN
     foreach ($this->getState('query.join.left', array()) as $join) {
         $query->join('LEFT', $join);
     }
     //WHERE
     foreach ($this->getState('query.where', array()) as $where) {
         $query->where($where);
     }
     //GROUP ORDER : Prioritary order for groups in lists
     foreach ($this->getState('query.groupOrder', array()) as $groupOrder) {
         $query->order($groupOrder);
     }
     //ORDER
     foreach ($this->getState('query.order', array()) as $order) {
         $query->order($order);
     }
     //ORDER
     $orderCol = $this->getState('list.ordering');
     $orderDir = $this->getState('list.direction', 'asc');
     if ($orderCol) {
         $query->order($orderCol . ' ' . $orderDir);
     }
 }
コード例 #22
0
 /**
  * Preparation of the query.
  *
  * @access	protected
  * @param	object	&$query	returns a filled query object.
  * @param	integer	$pk	The primary id key of the viewlevel
  * @return	void
  */
 protected function prepareQuery(&$query, $pk)
 {
     $acl = RtiprintHelper::getActions();
     //FROM : Main table
     $query->from('#__viewlevels AS a');
     switch ($this->getState('context', 'all')) {
         case 'all':
             //SELECT : raw complete query without joins
             $query->select('a.*');
             break;
     }
     //WHERE : Item layout (based on $pk)
     $query->where('a.id = ' . (int) $pk);
     //TABLE KEY
     //FILTER - Access for : Root table
     //SELECT : Instance Add-ons
     foreach ($this->getState('query.select', array()) as $select) {
         $query->select($select);
     }
     //JOIN : Instance Add-ons
     foreach ($this->getState('query.join.left', array()) as $join) {
         $query->join('LEFT', $join);
     }
 }
コード例 #23
0
* --------oOOO-----(_)-----OOOo------------------------------ www.moledesign.biz --- +
* @version		2.2.2
* @package		RT iPrint
* @subpackage	Buildings
* @copyright	Copyright FGW 2014, All rights reserved
* @author		MOLEDesign (Morgan Leecy) - http://www.moledesign.biz - morgan@moledesign.biz
* @license		GNU/GPL
*
*             .oooO  Oooo.
*             (   )  (   )
* -------------\ (----) /----------------------------------------------------------- +
*               \_)  (_/
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
RtiprintHelper::headerDeclarations();
//Load the formvalidator scripts requirements.
JDom::_('html.toolbar');
?>
<script language="javascript" type="text/javascript">
	//Secure the user navigation on the page, in order preserve datas.
	var holdForm = true;
	window.onbeforeunload = function closeIt(){	if (holdForm) return false;};
</script>

<form action="<?php 
echo JRoute::_("index.php");
?>
" method="post" name="adminForm" id="adminForm" class='form-validate' enctype='multipart/form-data'>
	<?php 
$compat = '1.6';
コード例 #24
0
ファイル: buildings.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Preparation of the list query.
  *
  * @access	protected
  * @param	object	&$query	returns a filled query object.
  * @return	void
  */
 protected function prepareQuery(&$query)
 {
     $acl = RtiprintHelper::getActions();
     //FROM : Main table
     $query->from('#__rtiprint_buildings AS a');
     //IMPORTANT REQUIRED FIELDS
     $this->addSelect('a.id,' . 'a.created_by,' . 'a.published');
     switch ($this->getState('context', 'all')) {
         case 'buildings.default':
             //BASE FIELDS
             $this->addSelect('a.building,' . 'a.town');
             //SELECT
             $this->addSelect('_town_.town AS `_town_town`');
             //JOIN
             $this->addJoin('`#__rtiprint_towns` AS _town_ ON _town_.id = a.town', 'LEFT');
             //GROUP BY (PRIMARY ORDER)
             $this->addGroupOrder('a.town');
             break;
         case 'all':
             //SELECT : raw complete query without joins
             $this->addSelect('a.*');
             // Disable the pagination
             $this->setState('list.limit', null);
             $this->setState('list.start', null);
             break;
     }
     //FILTER - Access for : Root table
     $wherePublished = $allowAuthor = true;
     $whereAccess = false;
     $this->prepareQueryAccess('a', $whereAccess, $wherePublished, $allowAuthor);
     $query->where("({$allowAuthor} OR {$wherePublished})");
     //WHERE - SEARCH : search_search : search on Building
     $search_search = $this->getState('search.search');
     $this->addSearch('search', 'a.building', 'like');
     if ($search_search != '' && ($search_search_val = $this->buildSearch('search', $search_search))) {
         $this->addWhere($search_search_val);
     }
     //WHERE - FILTER : Town
     if ((int) $this->getState('filter.town') > 0) {
         $this->addWhere("a.town = " . (int) $this->getState('filter.town'));
     }
     //Populate only uniques strings to the query
     //SELECT
     foreach ($this->getState('query.select', array()) as $select) {
         $query->select($select);
     }
     //JOIN
     foreach ($this->getState('query.join.left', array()) as $join) {
         $query->join('LEFT', $join);
     }
     //WHERE
     foreach ($this->getState('query.where', array()) as $where) {
         $query->where($where);
     }
     //GROUP ORDER : Prioritary order for groups in lists
     foreach ($this->getState('query.groupOrder', array()) as $groupOrder) {
         $query->order($groupOrder);
     }
     //ORDER
     foreach ($this->getState('query.order', array()) as $order) {
         $query->order($order);
     }
     //ORDER
     $orderCol = $this->getState('list.ordering');
     $orderDir = $this->getState('list.direction', 'asc');
     if ($orderCol) {
         $query->order($orderCol . ' ' . $orderDir);
     }
 }
コード例 #25
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Favourites
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayModal($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_FAVOURITES");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'favourites.modal');
     $this->items = $items = $this->get('Items');
     $this->canDo = $canDo = RtiprintHelper::getActions();
     $this->pagination = $this->get('Pagination');
     $this->filters = $filters = $model->getForm('modal.filters');
     $this->menu = RtiprintHelper::addSubmenu('favourites', 'modal');
     $lists = array();
     $this->lists =& $lists;
     //Filters
     // User > Name
     $modelCreated_by = CkJModel::getInstance('thirdusers', 'RtiprintModel');
     $filters['filter_created_by']->jdomOptions = array('list' => $modelCreated_by->getItems());
     // Limit
     $filters['limit']->jdomOptions = array('pagination' => $this->pagination);
     //Toolbar initialization
 }
コード例 #26
0
ファイル: view.html.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Execute and display a template : Printers
  *
  * @access	protected
  * @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
  *
  * @return	mixed	A string if successful, otherwise a JError object.
  *
  * @since	11.1
  */
 protected function displayModal($tpl = null)
 {
     $document = JFactory::getDocument();
     $this->title = JText::_("RTIPRINT_LAYOUT_PRINTERS");
     $document->title = $document->titlePrefix . $this->title . $document->titleSuffix;
     $this->model = $model = $this->getModel();
     $this->state = $state = $this->get('State');
     $state->set('context', 'printers.modal');
     $this->items = $items = $this->get('Items');
     $this->canDo = $canDo = RtiprintHelper::getActions();
     $this->pagination = $this->get('Pagination');
     $this->filters = $filters = $model->getForm('modal.filters');
     $this->menu = RtiprintHelper::addSubmenu('printers', 'modal');
     $lists = array();
     $this->lists =& $lists;
     //Filters
     // Printer Model > Name
     $modelPrinter_model = CkJModel::getInstance('printermdls', 'RtiprintModel');
     $filters['filter_printer_model']->jdomOptions = array('list' => $modelPrinter_model->getItems());
     // Building > Building
     $filters['filter_building']->jdomOptions = array('ajaxVars' => array('values' => array($model->getState("filter.building"), $model->getState("filter.building_town"))));
     // Server > Name
     $modelServer = CkJModel::getInstance('servers', 'RtiprintModel');
     $filters['filter_server']->jdomOptions = array('list' => $modelServer->getItems());
     // Limit
     $filters['limit']->jdomOptions = array('pagination' => $this->pagination);
     //Toolbar initialization
     JToolBarHelper::title(JText::_('RTIPRINT_LAYOUT_PRINTERS'), 'rtiprint_printers');
 }
コード例 #27
0
ファイル: item.php プロジェクト: gwtrains/comRTiPrint
 /**
  * Customize the redirection depending on result.
  * (proposed by Cook Self Service).
  *
  * @access	protected
  * @param	mixed	$result	bool or integer. The result from  the task operation
  * @param	array	$redirections	The redirections (option.view.layout) ordered by task result [0,1,...]
  * @param	array	$vars	Eventual added vars to the redirection.
  *
  * @return	void	
  * @return	void
  */
 protected function applyRedirection($result, $redirections, $vars = array())
 {
     if ($result === null) {
         $result = 1;
     } else {
         $result = (int) $result;
     }
     if (!$this->_result) {
         $this->_result = $result;
     }
     if (!isset($redirections[$result])) {
         return;
     }
     //Keep the default redirection
     //Get the selected redirection depending on result
     $redirection = $redirections[$result];
     switch ($redirection) {
         //Stay on the same page
         case 'stay':
             $this->setRedirect(RtiprintHelper::urlRequest());
             return;
             break;
             //Return to the previous page in navigation history
         //Return to the previous page in navigation history
         case 'previous':
             //TODO
             break;
     }
     $url = explode(".", $redirection);
     //Get from given url parts (empty string will keep the current value)
     if (isset($url[0])) {
         $values['option'] = !empty($url[0]) ? $url[0] : $this->option;
     }
     if (isset($url[1])) {
         $values['view'] = !empty($url[1]) ? $url[1] : $this->view_list;
     }
     if (isset($url[2])) {
         $values['layout'] = !empty($url[2]) ? $url[2] : $this->getLayout(true);
     }
     $jinput = JFactory::getApplication()->input;
     //Followers : If value is defined in the current form, it will be added in the request
     $followers = array('cid' => 'ARRAY', 'tmpl' => 'CMD', 'Itemid' => 'CMD', 'lang' => 'CMD');
     //Filters followers
     $model = CkJModel::getInstance($this->view_list, 'RtiprintModel');
     if ($model) {
         $filters = $model->get('filter_vars');
         foreach ($filters as $filterName => $type) {
             $type = 'STRING';
             //When filter is empty, don't follow, so FILTER is not used.
             $filterVar = 'filter_' . $filterName;
             //Adds a filter follower
             $followers[$filterVar] = $type;
         }
     }
     //Apply the followers values
     foreach ($followers as $varName => $varType) {
         if ($pos = strpos($varType, ":")) {
             $varType = substr($varType, 0, $pos);
         }
         $value = $jinput->get($varName, '', strtoupper($varType));
         if ($varType == 'ARRAY' && !empty($value)) {
             $value = implode(",", $value);
             $varName .= "[]";
         }
         if ($value != '') {
             $values[$varName] = $value;
         }
     }
     //Override with vars in params
     foreach ($vars as $key => $value) {
         $values[$key] = $value;
     }
     //Prepare the url
     foreach ($values as $key => $value) {
         if ($value !== null) {
             $parts[] = $key . '=' . $value;
         }
     }
     //Apply redirection
     $this->setRedirect(JRoute::_("index.php?" . implode("&", $parts), false));
 }