示例#1
0
文件: language.php 项目: akksi/jcg
 /**
  * Method to get the field options.
  *
  * @return	array	The field option objects.
  * @since	1.6
  */
 protected function getOptions()
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Detect the native language.
     $native = JLanguageHelper::detectLanguage();
     if (empty($native)) {
         $native = 'en-GB';
     }
     // Get a forced language if it exists.
     $forced = $app->getLocalise();
     if (!empty($forced['language'])) {
         $native = $forced['language'];
     }
     // If a language is already set in the session, use this instead
     $session = JFactory::getSession()->get('setup.options', array());
     if (!empty($session['language'])) {
         $native = $session['language'];
     }
     // Get the list of available languages.
     $options = JLanguageHelper::createLanguageList($native);
     if (!$options || JError::isError($options)) {
         $options = array();
     }
     // Set the default value from the native language.
     $this->value = $native;
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
示例#2
0
 public function onBeforeDispatcherDispatch(KEvent $event)
 {
     $application = JFactory::getApplication();
     if ($application->getName() != 'site') {
         return;
     }
     //var_dump($_SERVER); exit();
     // check if SSO header is set
     $personnumber = KRequest::get('server.HTTP_P_SSO_IDENTIFIER', 'alnum');
     if (empty($personnumber) || !preg_match('/P\\d+/is', $personnumber)) {
         // TODO set proper http response
         throw new KException('Access not allowed');
     }
     // check if user is already logged in
     $user = JFactory::getUser();
     // make sure personnumber is still the same
     if (!$user->guest && $user->username != $personnumber) {
         $application->logout();
         $application->redirect(KRequest::url());
     }
     if ($user->guest) {
         $credentials = array('username' => $personnumber, 'password' => $personnumber);
         $result = $application->login($credentials, array());
         if (JError::isError($result)) {
             // TODO set proper http response
             throw new KException($result->getError());
         } else {
             $application->redirect('index.php');
         }
     }
 }
示例#3
0
 public function display($cachable = false, $urlparams = false)
 {
     // Get the view name from the query string
     $viewName = JRequest::getVar("view", "playground");
     // Get the view
     $view = $this->getView($viewName);
     // Get the joomleague model
     $jl = $this->getModel("joomleague", "JoomleagueModel");
     $jl->set("_name", "joomleague");
     if (!JError::isError($jl)) {
         $view->setModel($jl);
     }
     // Get the playground model
     $pg = $this->getModel("playground", "JoomleagueModel");
     $pg->set("_name", "playground");
     if (!JError::isError($pg)) {
         $view->setModel($pg);
     }
     // Get the countries model
     $cn = $this->getModel("countries", "JoomleagueModel");
     $cn->set("_name", "countries");
     if (!JError::isError($cn)) {
         $view->setModel($cn);
     }
     // Get the Google map model
     $gm = $this->getModel("googlemap", "JoomleagueModel");
     $gm->set("_name", "googlemap");
     if (!JError::isError($gm)) {
         $view->setModel($gm);
     }
     $this->showprojectheading();
     $view->display();
     $this->showbackbutton();
     $this->showfooter();
 }
示例#4
0
 /**
  * Display the view
  */
 function display()
 {
     $document = JFactory::getDocument();
     $viewName = str_replace('FabrikControllerVisualization', '', get_class($this));
     if ($viewName == '') {
         // if we are using a url like http://localhost/fabrik3.0.x/index.php?option=com_fabrik&view=visualization&id=6
         // then we need to ascertain which viz to use
         $viewName = $this->getViewName();
     }
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view = $this->getView($viewName, $viewType);
     // Push a model into the view
     $model = $this->getModel($viewName);
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     // f3 cache with raw view gives error
     if (in_array(JRequest::getCmd('format'), array('raw', 'csv'))) {
         $view->display();
     } else {
         $post = JRequest::get('post');
         //build unique cache id on url, post and user id
         $user = JFactory::getUser();
         $cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
         $cache = JFactory::getCache('com_fabrik', 'view');
         $cache->get($view, 'display', $cacheid);
     }
 }
 function display()
 {
     // Get the view name from the query string
     $viewName = JRequest::getVar("view", "matchreport");
     // Get the view
     $view =& $this->getView($viewName);
     // Get the joomleague model
     $jl = $this->getModel("joomleague", "JoomleagueModel");
     $jl->set("_name", "joomleague");
     if (!JError::isError($jl)) {
         $view->setModel($jl);
     }
     // Get the joomleague model
     $sr = $this->getModel("matchreport", "JoomleagueModel");
     $sr->set("_name", "matchreport");
     if (!JError::isError($sr)) {
         $view->setModel($sr);
     }
     $this->showprojectheading();
     if (JRequest::getInt('mid', 0) == 0) {
         $view->showreports();
     } else {
         $view->display();
     }
     $this->showbackbutton();
     $this->showfooter();
 }
 function save()
 {
     if (!igGeneralHelper::authorise('core.admin')) {
         return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $app = JFactory::getApplication();
     $data = JRequest::getVar('jform', array(), 'post', 'NONE', 4);
     $id = (int) $data['id'];
     if (empty($id[0])) {
         if (!igGeneralHelper::authorise('core.create')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     } else {
         if (!igGeneralHelper::authorise('core.edit')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     }
     if (strlen($_FILES['jform']['name']['watermark_filename']) > 2) {
         $fileName = $_FILES['jform']['name']['watermark_filename'];
         $tmpPath = $_FILES['jform']['tmp_name']['watermark_filename'];
         $uploadError = $_FILES['jform']['error']['watermark_filename'];
         if (!($uploadedFile = igUploadHelper::upload_file($fileName, $tmpPath, $uploadError, IG_WATERMARK_PATH, true))) {
             return false;
         }
         $data['watermark_filename'] = $uploadedFile;
     }
     $model = $this->getModel();
     $form = $model->getForm($data, false);
     if (!$form) {
         $app->enqueueMessage($model->getError(), 'error');
         return false;
     }
     $validData = $model->validate($form, $data);
     if ($validData === false) {
         $errors = $model->getErrors();
         for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
             if (JError::isError($errors[$i])) {
                 $app->enqueueMessage($errors[$i]->getMessage(), 'warning');
             } else {
                 $app->enqueueMessage($errors[$i], 'warning');
             }
         }
         $this->setRedirect('index.php?option=com_igallery&view=profile&id=' . $id, false);
         return false;
     }
     if (!$model->save($validData)) {
         JError::raise(2, 500, $model->getError());
         $msg = '';
     } else {
         $msg = JText::_('SUCCESSFULLY_SAVED');
     }
     switch ($this->task) {
         case 'apply':
             $url = 'index.php?option=com_igallery&view=profile&id=' . $id;
             break;
         case 'save':
             $url = 'index.php?option=com_igallery&view=profiles';
     }
     $this->setRedirect($url, $msg);
 }
示例#7
0
 /**
  * Save a comment.
  *
  * @access	public
  * @return	void
  * @since	1.0
  */
 function save()
 {
     // check for request forgeries.
     JRequest::checkToken();
     // get posted form variables.
     $values = JRequest::getVar('jxform', array(), 'post', 'array');
     $post = JRequest::get('post', JREQUEST_ALLOWHTML);
     // handle the post body
     $body = $post['jxform']['body'];
     // make sure that html special characters are encoded in code tags
     function codeEscape($matches)
     {
         return htmlspecialchars($matches[0]);
     }
     $body = preg_replace_callback('/\\[code=(.+?)\\](.+?)\\[\\/code\\]/is', 'codeEscape', $body);
     // if html is not enabled, then lets filter it out
     $config =& JComponentHelper::getParams('com_comments');
     if (!$config->get('enable_html', 0)) {
         $body = strip_tags($body);
     }
     // reset the body field in the posted values array
     $values['body'] = $body;
     // get the id of the item out of the session.
     $session =& JFactory::getSession();
     $id = (int) $session->get('comments.comment.id');
     $values['id'] = $id;
     // Get the comment model and set the post request in its state.
     $model =& $this->getModel('comment');
     $model->setState('request', JRequest::get('post'));
     // get the items to moderate from the request
     $c_id = JRequest::getVar('moderate', array(), '', 'array');
     // moderate the items if set
     if (is_array($c_id) and !empty($c_id)) {
         // split out the keys and values for the request array so that we can clean them
         $keys = array_keys($c_id);
         $vals = array_values($c_id);
         // clean the keys and values from the request array using JArrayHelper
         jimport('joomla.utilities.arrayhelper');
         JArrayHelper::toInteger($keys);
         JArrayHelper::toInteger($vals);
         // re-initialize the array and build it with cleaned data
         $c_id = array();
         for ($i = 0, $n = count($keys); $i < $n; $i++) {
             $cid[$keys[$i]] = $vals[$i];
         }
         // moderate the items.
         $model->moderate($c_id);
     }
     // save the comment and check for an error state
     $result = $model->save($values);
     $msg = JError::isError($result) ? $result->message : 'COMMENTS_SAVED';
     // redirect to the appropriate place based on the task
     if ($this->_task == 'apply') {
         $this->setRedirect(JRoute::_('index.php?option=com_comments&view=comment&layout=edit', false), JText::_($msg));
     } else {
         $session->set('comments.comment.id', null);
         $model->checkin($id);
         $this->setRedirect(JRoute::_('index.php?option=com_comments&view=comments', false), JText::_($msg));
     }
 }
示例#8
0
 /**
  * Display the view
  */
 function display($model = null)
 {
     //menu links use fabriklayout parameters rather than layout
     $flayout = JRequest::getVar('fabriklayout');
     if ($flayout != '') {
         JRequest::setVar('layout', $flayout);
     }
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'table', 'default', 'cmd');
     $modelName = $viewName;
     $layout = JRequest::getWord('layout', 'default');
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     $view->setLayout($layout);
     // Push a model into the view
     if (is_null($model)) {
         $model =& $this->getModel($modelName);
     }
     if (!JError::isError($model) && is_object($model)) {
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     $post = JRequest::get('post');
     if ($model->getParams()->get('list_disable_caching', '0') !== '1') {
         //build unique cache id on url, post and user id
         $user =& JFactory::getUser();
         $cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
         $cache =& JFactory::getCache('com_fabrik', 'view');
         $cache->get($view, 'display', $cacheid);
     } else {
         $view->display();
     }
 }
示例#9
0
 /**
  * display the template
  *
  * @param sting $tpl
  */
 function display($tpl = null)
 {
     FabrikHelperHTML::framework();
     $element = JRequest::getVar('element');
     $elementid = JRequest::getVar('elid');
     $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel');
     $className = JRequest::getVar('plugin');
     $plugin = $pluginManager->getPlugIn($className, 'element');
     if (JError::isError($plugin)) {
         JError::handleMessage($plugin);
         return;
     }
     $plugin->setId($elementid);
     $data = array();
     $repeatCounter = 0;
     $groupModel = $plugin->getGroup();
     $srcs = array();
     $plugin->formJavascriptClass($srcs);
     echo "srcs = ";
     print_r($srcs);
     FabrikHelperHTML::script($srcs, true);
     $html = '<script>';
     $html .= $plugin->elementJavascript($repeatCounter);
     $html .= '</script>';
     $html .= $plugin->_getElement($data, $repeatCounter, $groupModel);
     echo $html;
 }
示例#10
0
 /**
  * Validate the data
  *
  * @return	boolean	true if data is valid, false otherwise
  */
 protected function validate()
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     $form = $model->getForm($data, false);
     $validData = $model->validate($form, $data);
     $recordId = JRequest::getInt('id');
     if ($validData === false) {
         // Get the validation messages.
         $errors = $model->getErrors();
         // Push up to three validation messages out to the user.
         for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
             if (JError::isError($errors[$i])) {
                 $app->enqueueMessage($errors[$i]->getMessage(), 'warning');
             } else {
                 $app->enqueueMessage($errors[$i], 'warning');
             }
         }
         // Save the data in the session.
         if (isset($data[0])) {
             $app->setUserState($context . '.data', $data);
         }
         // Redirect back to the edit screen.
         $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false));
         return false;
     }
     return true;
 }
 function display()
 {
     // Get the view name from the query string
     $viewName = JRequest::getVar("view", "predictionranking");
     // Get the view
     $view =& $this->getView($viewName);
     // Get the joomleague model
     $jl = $this->getModel("joomleague", "JoomleagueModel");
     $jl->set("_name", "joomleague");
     if (!JError::isError($jl)) {
         $view->setModel($jl);
     }
     // Get the joomleague model
     $sr = $this->getModel('prediction', 'JoomleagueModel');
     $sr->set('_name', 'prediction');
     if (!JError::isError($sr)) {
         $view->setModel($sr);
     }
     // Get the joomleague model
     $jl = $this->getModel('project', 'JoomleagueModel');
     $jl->set('_name', 'project');
     if (!JError::isError($jl)) {
         $view->setModel($jl);
     }
     $this->showprojectheading();
     $view->display();
     $this->showbackbutton();
     $this->showfooter();
 }
示例#12
0
 /**
  * Method to get the row form.
  *
  * @return  mixed  JForm object on success, false on failure.
  */
 public function getForm()
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Get the form.
     jimport('joomla.form.form');
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $form = JForm::getInstance('com_localise.languages', 'languages', array('control' => 'filters', 'event' => 'onPrepareForm'));
     // Check for an error.
     if (JError::isError($form)) {
         $this->setError($form->getMessage());
         return false;
     }
     // Check the session for previously entered form data.
     $data = $app->getUserState('com_localise.select', array());
     // Bind the form data if present.
     if (!empty($data)) {
         $form->bind(array('select' => $data));
     }
     // Check the session for previously entered form data.
     $data = $app->getUserState('com_localise.languages.search', array());
     // Bind the form data if present.
     if (!empty($data)) {
         $form->bind(array('search' => $data));
     }
     return $form;
 }
 function chartdata()
 {
     // Get the view name from the query string
     $viewName = JRequest::getVar("view", "stats");
     // Get the view
     $view =& $this->getView($viewName);
     // Get the joomleague model
     $jl = $this->getModel("joomleague", "JoomleagueModel");
     $jl->set("_name", "joomleague");
     if (!JError::isError($jl)) {
         $view->setModel($jl);
     }
     // Get the joomleague model
     $sr = $this->getModel("stats", "JoomleagueModel");
     $sr->set("_name", "stats");
     if (!JError::isError($sr)) {
         $view->setModel($sr);
     }
     // Get the joomleague model
     $sr = $this->getModel("eventsranking", "JoomleagueModel");
     $sr->set("_name", "eventsranking");
     if (!JError::isError($sr)) {
         $view->setModel($sr);
     }
     $view->setLayout("chartdata");
     $view->display();
 }
	public static function setUpBeforeClass()
	{
		jimport('joomla.database.database');
		jimport('joomla.database.table');

		// Load the config if available.
		@ include_once JPATH_TESTS . '/config.php';
		if (class_exists('JTestConfig')) {
			$config = new JTestConfig;
		}

		if (!is_object(self :: $dbo)) {
			$options = array (
				'driver' => isset ($config) ? $config->dbtype : 'mysql',
				'host' => isset ($config) ? $config->host : '127.0.0.1',
				'user' => isset ($config) ? $config->user : '******',
				'password' => isset ($config) ? $config->password : '******',
				'database' => isset ($config) ? $config->db : 'joomla_ut',
				'prefix' => isset ($config) ? $config->dbprefix : 'jos_'
			);

			self :: $dbo = JDatabase :: getInstance($options);

			if (JError :: isError(self :: $dbo)) {
				//ignore errors
				define('DB_NOT_AVAILABLE', true);
			}
		}
		self :: $database = JFactory :: $database;
		JFactory :: $database = self :: $dbo;
	}
示例#15
0
 public function display()
 {
     $document =& JFactory::getDocument();
     /* @var $document JDocument */
     $viewType = $document->getType();
     // Get layout value
     $viewLayout = JRequest::getVar('layout', 'default');
     // Get view value
     $viewName = JRequest::getVar('view', 'Twitter');
     // Get view
     $view = $this->getView($viewName, $viewType, "View");
     // Get model
     $model = $this->getModel($viewName, "Model");
     if (!JError::isError($model)) {
         // Set model to view
         $view->setModel($model, true);
     }
     // Set layout into view
     $view->setLayout($viewLayout);
     try {
         // Display view
         $view->display();
     } catch (Exception $e) {
         $itpSecurity = new ItpSecurity($e);
         $itpSecurity->AlertMe();
         JError::raiseError(500, JText::_('ITP_ERROR_SYSTEM'));
         jexit(JText::_('ITP_ERROR_SYSTEM'));
     }
 }
示例#16
0
文件: cron.php 项目: rogeriocc/fabrik
 /**
  * Display the view
  *
  * @return  null
  */
 public function display()
 {
     $document = JFactory::getDocument();
     $viewName = $this->getViewName();
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view = $this->getView($viewName, $viewType);
     // Push a model into the view
     $model = $this->getModel($viewName);
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     // F3 cache with raw view gives error
     if (in_array(JRequest::getCmd('format'), array('raw', 'csv'))) {
         $view->display();
     } else {
         $post = JRequest::get('post');
         // Build unique cache id on url, post and user id
         $user = JFactory::getUser();
         $cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
         $cache = JFactory::getCache('com_fabrik', 'view');
         $cache->get($view, 'display', $cacheid);
     }
 }
示例#17
0
 public function display($cachable = false, $urlparams = false)
 {
     // Get the view name from the query string
     $viewName = JRequest::getVar("view", "clubplan");
     $startdate = JRequest::getVar("startdate", null);
     $enddate = JRequest::getVar("enddate", null);
     // Get the view
     $view = $this->getView($viewName);
     // Get the joomleague model
     $jl = $this->getModel("joomleague", "JoomleagueModel");
     $jl->set("_name", "joomleague");
     if (!JError::isError($jl)) {
         $view->setModel($jl);
     }
     $mdlClubPlan = $this->getModel("clubplan", "JoomleagueModel");
     $mdlClubPlan->set("_name", "clubplan");
     $mdlClubPlan->setStartDate($startdate);
     $mdlClubPlan->setEndDate($enddate);
     if (!JError::isError($mdlClubPlan)) {
         $view->setModel($mdlClubPlan);
     }
     $this->showprojectheading();
     $view->display();
     $this->showbackbutton();
     $this->showfooter();
 }
示例#18
0
文件: api.php 项目: q0821/esportshop
 public function auth($data)
 {
     if (empty($data['username']) || empty($data['password'])) {
         $this->setHeaders(array('error' => 500));
         return false;
     }
     $options = array('remember' => false, 'return' => false);
     $credentials = array('username' => $data['username'], 'password' => $data['password']);
     $app = JFactory::getApplication();
     $error = $app->login($credentials, $options);
     $user = JFactory::getUser();
     if (JError::isError($error)) {
         $this->setHeaders(array('error' => $error));
         return false;
     }
     if ($user->guest) {
         $this->setHeaders(array('error' => 401));
         return false;
     }
     $hkUser = hikashop_loadUser(true);
     $api_salt = $this->getSalt();
     $timestamp = time();
     $timestamp -= $timestamp % 60;
     $token_frame = (int) $this->plugin_params->get('token_frame', 15);
     if ($token_frame < 2) {
         $token_frame = 2;
     }
     $timestamp -= $timestamp % ($token_frame * 60);
     return array('user' => $hkUser->user_email, 'token' => sha1((int) $hkUser->user_id . '#' . (int) $hkUser->user_cms_id . '#' . (int) $hkUser->user_created . '#' . date('dmY:Hi', $timestamp) . '#' . $api_salt));
 }
示例#19
0
 /**
  * Display the view
  */
 function display()
 {
     $document = JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'package', 'default', 'cmd');
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view = $this->getView($viewName, $viewType);
     //if the view is a package create and assign the table and form views
     $tableView = $this->getView('list', $viewType);
     $listModel = $this->getModel('list', 'FabrikFEModel');
     $tableView->setModel($listModel, true);
     $view->_tableView = $tableView;
     $view->_formView =& $this->getView('Form', $viewType);
     $formModel = $this->getModel('Form', 'FabrikFEModel');
     $formModel->setDbo(FabrikWorker::getDbo());
     $view->_formView->setModel($formModel, true);
     // Push a model into the view
     $model = $this->getModel($viewName, 'FabrikFEModel');
     $model->setDbo(FabrikWorker::getDbo());
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     $view->display();
 }
示例#20
0
	/**
	 * Method to reset the seach log table.
	 *
	 * @return	boolean
	 */
	public function reset()
	{
		// Check for request forgeries.
		JRequest::checkToken() or $this->sendResponse(new JException(JText::_('JINVALID_TOKEN'), 403));

		$r = new JObject();
		
		// Initialise variables.
		$model = $this->getModel('Searches');

		if (!$model->reset()) {
			$errors	= $model->getErrors();
			// Push up to three errors messages out to the user.
			for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
			{
				if (JError::isError($errors[$i])) {
					$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
				} else {
					$app->enqueueMessage($errors[$i], 'warning');
				}
			}
			$r->success = false;

		} else {
			$r->success = true;
		}

		$this->sendJsonResponse($r);
	}
示例#21
0
文件: list.php 项目: romuland/khparts
 /**
  * Display the view
  */
 function display($model = null)
 {
     $document = JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'list', 'default', 'cmd');
     $modelName = $viewName;
     $layout = JRequest::getWord('layout', 'default');
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view = $this->getView($viewName, $viewType);
     $view->setLayout($layout);
     // Push a model into the view
     if (is_null($model)) {
         $model = $this->getModel($modelName, 'FabrikFEModel');
     }
     if (!JError::isError($model) && is_object($model)) {
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     $post = JRequest::get('post');
     //build unique cache id on url, post and user id
     $user = JFactory::getUser();
     $cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
     $cache = JFactory::getCache('com_fabrik', 'view');
     // f3 cache with raw view gives error
     if (in_array(JRequest::getCmd('format'), array('raw', 'csv', 'pdf', 'json', 'fabrikfeed'))) {
         $view->display();
     } else {
         $cache->get($view, 'display', $cacheid);
     }
 }
示例#22
0
 function display()
 {
     $document =& JFactory::getDocument();
     $viewName = 'chown';
     $viewType = $document->getType();
     $view =& $this->getView($viewName, $viewType);
     $model =& $this->getModel('chown');
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     $view->assign('error', $this->getError());
     $renderOrder = JRequest::getInt('renderOrder', 0);
     $tableModel =& $this->getModel('Table');
     $tableModel->setId(JRequest::getVar('id', 0));
     //$formModel =& $tableModel->getFormModel();
     $params =& $tableModel->getParams();
     $chown_to_table = $params->get('chown_to_table', '');
     if (is_array($chown_to_table)) {
         $chown_to_table = $chown_to_table[$renderOrder];
     }
     if (empty($chown_to_table)) {
         $chown_to_table_name = '#__users';
         $chown_to_pk_name = 'id';
         $chown_to_label_name = 'name';
         $db = JFactory::getDBO();
         $db->setQuery("SELECT DISTINCT({$chown_to_pk_name}) AS value, {$chown_to_label_name} AS text FROM {$chown_to_table_name}");
         $options = $db->loadObjectList();
     } else {
         $chown_to_pk = $params->get('chown_to_pk', '');
         if (is_array($chown_to_pk)) {
             $chown_to_pk = $chown_to_pk[$renderOrder];
         }
         $chown_to_pk_name = FabrikString::safeColName($chown_to_pk);
         $chown_to_label = $params->get('chown_to_label', '');
         if (is_array($chown_to_label)) {
             $chown_to_label = $chown_to_label[$renderOrder];
         }
         $chown_to_label_name = FabrikString::safeColName($chown_to_label);
         $toTableModel =& $this->getModel('Table');
         $toTableModel->setId($chown_to_table);
         //$toTable = $toTableModel->getTable();
         $toDb = $toTableModel->getDb();
         $chown_to_table_name = $toDb->nameQuote($toTableModel->getTable()->db_table_name);
         $toDb->setQuery("SELECT DISTINCT({$chown_to_pk_name}) AS value, {$chown_to_label_name} AS text FROM {$chown_to_table_name}");
         $options = $toDb->loadObjectList();
     }
     $chown_to_menu_label = $params->get('chown_to_menu_label', 'New Owner');
     if (is_array($chown_to_menu_label)) {
         $chown_to_menu_label = $chown_to_menu_label[$renderOrder];
     }
     $chown_to_intro = $params->get('chown_to_intro', '');
     if (is_array($chown_to_intro)) {
         $chown_to_intro = $chown_to_intro[$renderOrder];
     }
     $view->assign('chown_to_options', $options);
     $view->assign('chown_to', $chown_to_pk_name);
     $view->assign('chown_to_menu_label', $chown_to_menu_label);
     $view->assign('chown_to_intro', $chown_to_intro);
     return $view->display();
 }
示例#23
0
 /**
  * This method should handle any login logic and report back to the subject
  *
  * @access	public
  * @param   array   holds the user data
  * @param 	array   array holding options (remember, autoregister, group)
  * @return	boolean	True on success
  * @since	1.5
  */
 function onLoginUser($user, $options = array())
 {
     jimport('joomla.user.helper');
     $instance =& $this->_getUser($user, $options);
     // if _getUser returned an error, then pass it back.
     if (JError::isError($instance)) {
         return $instance;
     }
     // If the user is blocked, redirect with an error
     if ($instance->get('block') == 1) {
         return JError::raiseWarning('SOME_ERROR_CODE', JText::_('E_NOLOGIN_BLOCKED'));
     }
     //Authorise the user based on the group information
     if (!isset($options['group'])) {
         $options['group'] = 'USERS';
     }
     jimport('joomla.access.access');
     $result = JAccess::check($instance->id, $options['action']);
     if (!$result) {
         return JError::raiseWarning(401, JText::_('JError_Login_denied'));
     }
     //Mark the user as logged in
     $instance->set('guest', 0);
     // Register the needed session variables
     $session =& JFactory::getSession();
     $session->set('user', $instance);
     // Update the user related fields for the Joomla sessions table.
     $db = JFactory::getDBO();
     $db->setQuery('UPDATE `#__session`' . ' SET `guest` = ' . $db->quote($instance->get('guest')) . ',' . '	  `username` = ' . $db->quote($instance->get('username')) . ',' . '	  `userid` = ' . (int) $instance->get('id') . ' WHERE `session_id` = ' . $db->quote($session->getId()));
     $db->query();
     // Hit the user last visit field
     $instance->setLastVisit();
     return true;
 }
示例#24
0
 /**
  * Display the view
  */
 function display()
 {
     $document =& JFactory::getDocument();
     $viewName = str_replace('FabrikControllerVisualization', '', get_class($this));
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     //create a form view as well to render the add event form.
     $view->_formView =& $this->getView('Form', $viewType);
     $formModel =& $this->getModel('Form');
     $view->_formView->setModel($formModel, true);
     // Push a model into the view
     $model =& $this->getModel($viewName);
     if (!JError::isError($model)) {
         //$model->setAdmin( false);
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     $post = JRequest::get('post');
     //build unique cache id on url, post and user id
     $user =& JFactory::getUser();
     $cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
     $cache =& JFactory::getCache('com_fabrik', 'view');
     echo $cache->get($view, 'display', $cacheid);
 }
示例#25
0
 public function login()
 {
     $app = JFactory::getApplication();
     $return = array();
     // Populate the data array:
     $data = array();
     $data['username'] = JRequest::getVar('username', '', 'method', JREQUEST_ALLOWRAW);
     $data['password'] = JRequest::getString('password', '', 'method', JREQUEST_ALLOWRAW);
     // Get the log in credentials.
     $credentials = array();
     $credentials['username'] = $data['username'];
     $credentials['password'] = $data['password'];
     // Perform the log in.
     $error = $app->login($credentials, $options);
     // Check if the log in succeeded.
     if (!JError::isError($error)) {
         $merchant = JModel::getInstance('merchant', 'enmasseModel')->getByUserName(JFactory::getUser()->get('username'));
         if ($merchant) {
             JFactory::getSession()->set('merchantId', $merchant->id);
             JFactory::getSession()->close();
             $return['success'] = true;
             $return['token'] = JFactory::getSession()->getName();
             echo json_encode($return);
             die;
         }
     }
     //login fail
     $return['success'] = false;
     $return['message'] = $app->getError();
     echo json_encode($return);
     die;
 }
示例#26
0
 /**
  * set up the popup window containing the form to create the
  * email message
  *
  * @return string html
  */
 function popupwin()
 {
     $document = JFactory::getDocument();
     $viewName = 'popupwin';
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     $listModel =& $this->getModel('List', 'FabrikFEModel');
     $listModel->setId(JRequest::getInt('id'));
     $formModel =& $listModel->getFormModel();
     // Push a model into the view
     $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel');
     $model = $pluginManager->getPlugIn('email', 'list');
     $model->formModel = $formModel;
     $model->listModel = $listModel;
     $model->setParams($listModel->getParams(), JRequest::getInt('renderOrder'));
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     $view->setModel($listModel);
     $view->setModel($formModel);
     // Display the view
     $view->assign('error', $this->getError());
     return $view->display();
 }
示例#27
0
 /**
  * Display the view
  */
 function display()
 {
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('task', 'catsone', 'default', 'cmd');
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     // Push a model into the view
     $model =& $this->getModel($viewName);
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     $subpage = JRequest::getVar('subpage');
     if ($subpage == "save") {
         $view->displaySubpage();
     } elseif ($subpage == "saveAnswer") {
         $view->saveAnswer();
     } elseif ($subpage == "search") {
         $view->search();
     } else {
         $view->display();
     }
 }
示例#28
0
 public static function logout()
 {
     global $mainframe;
     $result = $mainframe->logout();
     if (!JError::isError($result)) {
         $mainframe->redirect('index.php?option=com_login');
     }
 }
示例#29
0
文件: view.php 项目: 01J/topm
 /**
  * Execute and display a template script.
  *
  * @param string $tpl The name of the template file to parse;
  * automatically searches through the template paths.
  *
  * @throws object An JError object.
  * JView::display()
  * @copyright Copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
  * @license GNU/GPL, see LICENSE.php
  */
 public function display($tpl = null)
 {
     $result = $this->loadTemplate($tpl);
     if (JError::isError($result)) {
         return $result;
     }
     echo $result;
 }
示例#30
0
 /**
  * @todo Implement testIsError().
  */
 public function testIsError()
 {
     $exception = new JException('This is the error message', 1056, 'error');
     $this->assertThat(JError::isError($exception), $this->isTrue(), 'We passed JError::isError an Exception but it returned false');
     $error = 'This is not an object';
     $this->assertThat(JError::isError($error), $this->isFalse(), 'We passed JError::isError a string but it returned true');
     $this->assertThat(JError::isError($this), $this->isFalse(), 'We passed JError::isError an object that was not an exception but it returneed true');
 }