/**
  * Method to delete item(s).
  *
  * @access	public
  * @param	array	&$pks	Ids of the items to delete.
  *
  * @return	boolean	True on success.
  */
 public function delete(&$pks)
 {
     if (!count($pks)) {
         return true;
     }
     if (!parent::delete($pks)) {
         return false;
     }
     //Integrity : Cascade delete in server on operating_system
     $model = CkJModel::getInstance('server', 'RtiprintModel');
     if (!$model->integrityDelete('operating_system', $pks)) {
         JError::raiseWarning(1301, JText::_("RTIPRINT_ALERT_ERROR_ON_CASCAD_DELETE"));
         return false;
     }
     return true;
 }
Exemple #2
0
 /**
  * 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');
 }
Exemple #3
0
 /**
  * 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
 }
Exemple #4
0
 /**
  * Prepare some additional important values.
  *
  * @access	public
  * @param	array	&$items	The objects to populate.
  * @return	void
  */
 public function populateParams(&$items)
 {
     if (!isset($items) || empty($items)) {
         return;
     }
     $model = CkJModel::getInstance($this->view_item, 'RtiprintModel');
     foreach ($items as &$item) {
         // TODO : attribs
         //			$itemParams = new JRegistry;
         //			$itemParams->loadString((isset($item->attribs)?$item->attribs:$item->params));
         //$item->params = clone $this->getState('params');
         $item->params = new JObject();
         if ($model) {
             if ($model->canView($item)) {
                 $item->params->set('access-view', true);
             }
             if ($model->canEdit($item)) {
                 $item->params->set('access-edit', true);
             }
             if ($model->canDelete($item)) {
                 $item->params->set('access-delete', true);
             }
             if ($model->isCheckedIn($item)) {
                 $item->params->set('tag-checkedout', true);
             }
             if (isset($item->published)) {
                 $item->params->set('tag-published', $item->published);
             }
             if (isset($item->default)) {
                 $item->params->set('tag-default', $item->default);
             }
         }
     }
 }
Exemple #5
0
 /**
  * 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
 }
Exemple #6
0
 /**
  * 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();
 }
Exemple #7
0
 /**
  * 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));
 }
Exemple #8
0
 /**
  * Generate the aliased file path from database index and ACLs.
  *
  * @access	public static
  * @param	string	$view	List model name
  * @param	string	$key	Field name where is stored the filename
  * @param	string	$id	Item id
  *
  * @return	string	File path with directory alias.
  *
  * @since	Cook 2.6.1
  */
 public static function getFromIndex($view, $key, $id)
 {
     $dir = '[DIR_' . strtoupper($view) . '_' . strtoupper($key) . ']';
     $model = CkJModel::getInstance($view, 'RtiprintModel');
     if (!$model) {
         return;
     }
     if (empty($key)) {
         return;
     }
     $model->addWhere('a.id = ' . (int) $id);
     $model->addSelect('a.' . $key);
     // Model is appling accesses restrictions for this file
     $model->setState('file');
     $items = $model->getItems();
     if (!count($items)) {
         return;
     }
     if (!($img = $items[0]->{$key})) {
         return;
     }
     return $dir . DS . $img;
 }