/**
	 * Helpdesk view display method
	 * @return void
	 **/
	function display($tpl = null)
    {               
        $canDo = HelpdeskHelper::getActions();

		JToolBarHelper::title(JText::_('COM_HELPDESK_MANAGER_HELPDESK'), 'helpdesk' );
		if ($canDo->get('core.create')) {
			JToolBarHelper::addNew('entry.add');
		}
		if ($canDo->get('core.edit')) {
			JToolBarHelper::editList('entry.edit');
		}
		if ($canDo->get('core.edit.state')) {
			JToolBarHelper::divider();
			JToolBarHelper::publishList('helpdesk.publish');
			JToolBarHelper::unpublishList('helpdesk.unpublish');
		}
		if ($canDo->get('core.delete')) {
			JToolBarHelper::divider();
			JToolBarHelper::deleteList('', 'helpdesk.delete');
		}
		if ($canDo->get('core.admin')) {
			JToolBarHelper::divider();
			JToolBarHelper::preferences('com_helpdesk', '500');
		}
		JHtml::_('stylesheet', 'admin.css', JURI::root().'/media/com_helpdesk/css/');

        // Get data from the model
		$items		= $this->get('Items');
		$pagination	= $this->get('Pagination');
		
		$this->assignRef('pagination' , $pagination);
        $this->assignRef('items', $items);

        parent::display($tpl);
    }
Beispiel #2
0
	/**
	 * save a record (and redirect to main page)
	 * @return void
	 */
	function save()
	{
		// Check for request forgeries.
		JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		// Initialise variables.
		$app		= JFactory::getApplication();
		$lang		= JFactory::getLanguage();
		$model		= $this->getModel();
		$table		= $model->getTable();

 		$uri  = JFactory::getURI();
		$mail = JFactory::getMailer();
		$db   = JFactory::getDBO();
		
		$data = JRequest::get('post');

		$decline		= $data['jform']['hstatus'];
		$name			= $data['jform']['hname'];
		$comment		= $data['jform']['hcomment'];
		$usermail		= $data['jform']['hmail'];
		$decline_mail	= $data['jform']['declinemail'];

		//ACL stuff
		$canDo		= HelpdeskHelper::getActions();
		$canAdd 	= $canDo->get('core.create');
		$canEdit	= $canDo->get('core.edit');

		//get mail addresses of all super administrators
		$query = 'SELECT email' .
				' FROM #__users' .
				' WHERE LOWER( usertype ) = "super administrator" AND sendEmail = 1';
		$db->setQuery( $query );
		$admins = $db->loadResultArray();

		$msg = '';
		if ($model->save($data['jform'])) {
        	$msg .= JText::_( 'Entry Saved' );
  			$type = 'message';

  			if (($decline == -1) && ($decline_mail==1)) {
				$body = JText::_('COM_HELPDESK_ENTRY_DECLINED_MAIL_BODY'). $comment;
				$mail->IsHTML(true);
				$mail->setSubject(JText::_('COM_HELPDESK_ENTRY_DECLINED_MAIL_SUBJECT'));
				$mail->setBody( $body );
				$mail->addRecipient( $usermail );
				$mail->addBCC( $admins );
				$mail->Send();
				$msg .= ".  ".JText::_('COM_HELPDESK_DECLINE_MAIL_SENT');
  				$type = 'message';
			}
	    } else {
	        $msg = JText::_('COM_HELPDESK_ERROR_SAVING_ENTRY');
	        $type = 'error';
	    }

		$this->setRedirect( 'index.php?option=com_helpdesk', $msg, $type);
	}
	/**
	 * Helpdesk view display method
	 * @return void
	 **/
	function display($tpl = null)
	{	
		$app	= JFactory::getApplication();
		$doc	= JFactory::getDocument();
		$menus	= &JSite::getMenu();
		$params = &$app->getParams('com_helpdesk');
		
		// Set CSS File
		JHtml::_('stylesheet', 'helpdesk.css', JURI::root().'/media/com_helpdesk/css/');
		
		// Get some Data
		$entrys		= $this->get('Items');
		$count		= $this->get('Total');
		$pagination	= $this->get('Pagination');
		
		// Show RSS Feed
		$link		= '&format=feed&limitstart=';
		$attribs	= array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
		$doc->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
		$attribs	= array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
		$doc->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
		
		// Prepare ACL checks
		$canDo = HelpdeskHelper::getActions();
		$access = new stdClass();
	
		$access->canAdd			= $canDo->get('core.create');
	
		$access->canPublishOwn	= $canDo->get('core.edit.state');
		$access->canRemoveOwn	= $canDo->get('core.edit.own');
		$access->canEditOwn		= $canDo->get('core.edit.own');
	
		$access->canPublish		= $canDo->get('core.edit.state');
		$access->canRemove		= $canDo->get('core.delete');
		$access->canEdit		= $canDo->get('core.edit');
		$access->canComment		= $canDo->get('core.edit');

		// Assign Data to template
		$this->assignRef( 'heading', $doc->getTitle() );
		$this->assignRef( 'entrys',	$entrys );
		$this->assignRef( 'count', $count);
		$this->assignRef( 'pagination', $pagination);
		$this->assignRef( 'params', $params);
		$this->assignRef( 'access', $access);
		
		// Add HTML Head Link
		$paginationdata = $pagination->getData();
		if ($paginationdata->start->link) {
			$doc->addHeadLink($paginationdata->start->link, "first");
		}
		if ($paginationdata->previous->link) {
			$doc->addHeadLink($paginationdata->previous->link, "prev");
		}
		if ($paginationdata->next->link) {
			$doc->addHeadLink($paginationdata->next->link, "next");
		}
		if ($paginationdata->end->link) {
			$doc->addHeadLink($paginationdata->end->link, "last");
		}

		// Display template
		parent::display($tpl);
	}
Beispiel #4
0
	/**
	 * save a record (and redirect to main page)
	 * @return void
	 */
	function save()
	{
		global $mainframe;
		$app	=  JFactory::getApplication();
 		$uri	=  JFactory::getURI();
		$mail	=& JFactory::getMailer();
		$db		=& JFactory::getDBO();
		$params	=& $app->getParams();			
		
		//ACL stuff
		$canDo	= HelpdeskHelper::getActions();
		$canAdd	= $canDo->get('core.create');
		$canEdit= $canDo->get('core.edit');
		
		//get mail addresses of all super administrators
		//TODO16 This doesn't work anymore in Joomla 1.6
		$query = 'SELECT email' .
				' FROM #__users' .
				' WHERE LOWER( usertype ) = "super administrator" AND sendEmail = 1';
		$db->setQuery( $query );
		$admins = $db->loadResultArray();
		
		//get entry id from request
		$temp = JRequest::get( 'post' );
		$id = $temp['id'];
		$name = $temp['hname'];
		$text = $temp['htext'];

		$filename = $_FILES["hfile"]["name"];
		$filename = str_replace(" ", "_",$filename);
		$filetype = $_FILES["hfile"]["type"];
		$filesize = $_FILES["hfile"]["size"];
		$tmpname  = $_FILES['hfile']['tmp_name'];
		//$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
		//$ext = pathinfo($filename, PATHINFO_EXTENSION);
		$ext = ".".pathinfo($filename, PATHINFO_EXTENSION);
		//$ext =  $info['extenstion'];
//$msg .= "!!! ".$ext."  ";
		$upload_location = $params->get('file_dir','./uploads');
		if ( substr( $upload_location , strlen($upload_location) - 1) != "/" ) {
			$upload_location .= "/";
		}

		$upload_filetypes = $params->get('file_type','');
		$upload_maxsize = $params->get('file_size', '10000000');

		if ((!$id && $canAdd) || ($id && $canEdit)) {
			$model = $this->getModel('entry');
	
			if ($model->store()) {
				//Set redirection options
				if ($params->get('default_published', true)) {
					$msg .= JText::_('COM_HELPDESK_ENTRY_SAVED');
					$type = 'message';
				} else {
					$msg .= JText::_('COM_HELPDESK_ENTRY_NEEDS_APPROVAL');
					$type = 'notice';
				}
				$link = JRoute::_( 'index.php?option=com_helpdesk&view=helpdesk', false );

				if ((strlen($filename) > 0)) {
		
					if(!in_array(strtolower($ext),explode(',',strtolower($upload_filetypes))))	 {
						$filetypeok = false;
					} else {
						$filetypeok = true;
					}
					
					if ($upload_filetypes == "*") {
						$filetypeok = true;
					}
				if (($filetypeok > 0) && ($filesize < $upload_maxsize)) {
	
					if (file_exists($upload_location . $filename)) {
		
						$unique_suffix = 1;
						$base = explode($ext,$filename);
						$upload_base = str_replace(" ", "_", $base[0]);
						$new_filename = $upload_location . $filename;
				
						while (file_exists($new_filename))
						{
							$upload_base = $upload_base . "_" . $unique_suffix++;
							$new_filename = $upload_location . $upload_base  . $ext;
						}

						$new_filename = $upload_base  . $ext;

						rename($upload_location . $filename, $upload_location . $new_filename);

						$query = "UPDATE #__helpdesk SET hfile='" . $new_filename . "' WHERE id = LAST_INSERT_ID()";
	
						$db->setQuery($query);
						$db->query();

						$upload_fileexist = "no";
					} else {
						$upload_fileexist = "no";
					}
		
					if ( $upload_fileexist == "no" ) {			
						move_uploaded_file($tmpname, $upload_location . $filename);
						$query = "UPDATE #__helpdesk SET hfile='" . $filename . "' WHERE id = LAST_INSERT_ID()";
							
						$db->setQuery($query);
						$db->query();		
					}
				} else {
					$msg .= "<br />" . JText::sprintf('COM_HELPDESK_ERROR_UPLOAD', $ext) . "<br />" . JText::_('Allowed types') . ": " . $upload_filetypes . "<br />" . JText::_('File max size') . " (kb): " . ($upload_maxsize / 1024)."<br />";
					$link = JRoute::_( 'index.php?option=com_helpdesk&controller=entry&task=add&retry=true', false );
					$type = 'notice';
					$ferror = true;
				}
				}

				//Send information-mail to administrators
				if ( (!$id AND $params->get('send_mail', true)) && (!$ferror) ) {
					$mail->setSubject(JTEXT::_('COM_HELPDESK_ENTRY_NEW_MAIL_SUBJECT'));
					$mail->setBody(JTEXT::sprintf('COM_HELPDESK_ENTRY_NEW_MAIL_BODY', $uri->base(), $name, $text));
					$mail->addBCC($admins);
					$mail->Send();
				}
			} else {
				if($filename){
					if(!in_array(strtolower($ext),explode(',',strtolower($upload_filetypes)))){
						$filetypeok = false;
					} else {
						$filetypeok = true;
					}
								
					if ($upload_filetypes == "*") {
						$filetypeok = true;
					}
						
					if (($filetypeok > 0) && ($filesize < $upload_maxsize)){
				
					} else {
						$msg .= JText::sprintf('COM_HELPDESK_ERROR_UPLOAD', $ext) . "<br />" . JText::_('Allowed types') . ": " . $upload_filetypes . "<br />" . JText::_('File max size') . " (kb): " . ($upload_maxsize / 1024)."<br />";				
					}
				}

				$msg .= JText::_('COM_HELPDESK_ERROR_VALIDATE_INPUTS');
				$link = JRoute::_('index.php?option=com_helpdesk&controller=entry&task=add&retry=true', false );
				$type = 'notice';
			}
			$this->setRedirect($link, $msg, $type);
		} else {
			JError::raiseError(403, JText::_('ALERTNOTAUTH'));
		}
	}