コード例 #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 : 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");
 }
コード例 #4
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;
 }
コード例 #5
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');
 }
コード例 #6
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);
     }
 }
コード例 #7
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');
 }
コード例 #8
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');
 }
コード例 #9
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');
     }
 }
コード例 #10
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);
     }
 }
コード例 #11
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);
     }
 }
コード例 #12
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
 }
コード例 #13
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';
     }
 }
コード例 #14
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
 }
コード例 #15
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;
 }
コード例 #16
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
 }
コード例 #17
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);
     }
 }
コード例 #18
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);
     }
 }
コード例 #19
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;
 }
コード例 #20
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);
     }
 }
コード例 #21
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');
 }
コード例 #22
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);
     }
 }