/** * called via ajax to perform viz ajax task (defined by plugintask method) */ public function display() { $document = JFactory::getDocument(); $id = JRequest::getInt('visualizationid'); $viz = FabTable::getInstance('Visualization', 'FabrikTable'); $viz->load($id); $modelpaths = JModel::addIncludePath(JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/models'); $model = $this->getModel($viz->plugin); $model->setId($id); $pluginTask = JRequest::getVar('plugintask', '', 'request'); if ($pluginTask !== '') { echo $model->{$pluginTask}(); } else { $task = JRequest::getVar('task'); $path = JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/controllers/' . $viz->plugin . '.php'; if (file_exists($path)) { require_once $path; } else { JError::raiseNotice(400, 'could not load viz:' . $viz->plugin); return; } $controllerName = 'FabrikControllerVisualization' . $viz->plugin; $controller = new $controllerName(); $controller->addViewPath(JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/views'); $controller->addViewPath(COM_FABRIK_FRONTEND . '/views'); //add the model path $modelpaths = JModel::addIncludePath(JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/models'); $modelpaths = JModel::addIncludePath(COM_FABRIK_FRONTEND . '/models'); $origId = JRequest::getInt('visualizationid'); JRequest::setVar('visualizationid', $id); $controller->{$task}(); } }
/** * Method to handle the onInit event. * - Initializes the JCE WYSIWYG Editor * * @access public * @return string JavaScript Initialization string * @since 1.5 */ public function onInit() { $app = JFactory::getApplication(); $language = JFactory::getLanguage(); $document = JFactory::getDocument(); // set IE mode //$document->setMetaData('X-UA-Compatible', 'IE=Edge', true); // Check for existence of Admin Component if (!is_dir(JPATH_SITE . DS . 'components' . DS . 'com_jce') || !is_dir(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jce')) { JError::raiseWarning('SOME_ERROR_CODE', 'WF_COMPONENT_MISSING'); } $language->load('plg_editors_jce', JPATH_ADMINISTRATOR); $language->load('com_jce', JPATH_ADMINISTRATOR); // set admin base path $base = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jce'; // load constants and loader require_once($base . DS . 'includes' . DS . 'base.php'); // load model JModel::addIncludePath($base . DS . 'models'); $model = JModel::getInstance('editor', 'WFModel'); $model->buildEditor(); }
/** * * @return unknown_type */ function getItems() { // Check the registry to see if our Tienda class has been overridden if (!class_exists('Tienda')) { JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php"); } // load the config class Tienda::load('Tienda', 'defines'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); // get the model $model = JModel::getInstance('Manufacturers', 'TiendaModel'); // TODO Make this depend on the current filter_category? // setting the model's state tells it what items to return $model->setState('filter_enabled', '1'); $model->setState('order', 'tbl.manufacturer_name'); // set the states based on the parameters // using the set filters, get a list $items = $model->getList(); if (!empty($items)) { foreach ($items as $item) { // this gives error $item->itemid = Tienda::getClass("TiendaHelperRoute", 'helpers.route')->manufacturer($item->manufacturer_id, false); if (empty($item->itemid)) { $item->itemid = $this->params->get('itemid'); } } } return $items; }
function &getModel() { jimport('joomla.application.component.model'); JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'pricing' . DS . self::getItemName() . DS . 'models'); $model = JModel::getInstance(self::getItemName(), 'JBidPricingModel'); return $model; }
function ThemeClassic() { $pathModelShowcaseTheme = JPATH_PLUGINS . DS . $this->_pluginType . DS . $this->_pluginName . DS . 'models'; $pathTableShowcaseTheme = JPATH_PLUGINS . DS . $this->_pluginType . DS . $this->_pluginName . DS . 'tables'; JModel::addIncludePath($pathModelShowcaseTheme); JTable::addIncludePath($pathTableShowcaseTheme); }
/** * Method to calculate statistics about manufacturers in an order * * @param $items Array of order items * * @return Array with list of manufacturers and their stats */ function calculateStatsOrder($items) { $db = JFactory::getDbo(); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); Tienda::load('TiendaQuery', 'library.query'); $q = new TiendaQuery(); $q->select('manufacturer_id'); $q->from('`#__tienda_products`'); $result = array(); foreach ($items as $item) { $q->where('product_id = ' . (int) $item->product_id); $db->setQuery($q); $res = $db->loadObject(); if ($res == null) { $man_id = 0; } else { $man_id = $res->manufacturer_id; } if (!isset($result[$man_id])) { $model = JModel::getInstance('Manufacturers', 'TiendaModel'); $model->setId($man_id); if (!($man_item = $model->getItem())) { $man_item = new stdClass(); } $result[$man_id] = $man_item; $result[$man_id]->subtotal = 0; $result[$man_id]->total_tax = 0; } $result[$man_id]->subtotal += $item->orderitem_final_price; $result[$man_id]->total_tax += $item->orderitem_tax; } return $result; }
/** * Overrides method to try to load model from extension if it exists */ public static function &getInstance($type, $prefix = '', $config = array()) { $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p')); foreach ($extensions as $e => $extension) { $modelType = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $modelClass = $prefix . ucfirst($modelType) . ucfirst($extension); $result = false; if (!class_exists($modelClass)) { jimport('joomla.filesystem.path'); $path = JPath::find(JModel::addIncludePath(), JModel::_createFileName('model', array('name' => $modelType))); if ($path) { require_once $path; if (class_exists($modelClass)) { $result = new $modelClass($config); return $result; } } } else { $result = new $modelClass($config); return $result; } } $instance = parent::getInstance($type, $prefix, $config); return $instance; }
public function post() { // Set variables to be used JMHelper::setSessionUser(); JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR); // Include dependencies jimport('joomla.application.component.controller'); jimport('joomla.form.form'); jimport('joomla.database.table'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models'); JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/models/forms'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/tables'); // Get user data $data = JRequest::getVar('jform', array(), 'post', 'array'); if (!isset($data['groups'])) { $data['groups'] = array(); } // Save user $model = JModel::getInstance('User', 'UsersModel'); $model->getState('user.id'); // This is only here to trigger populateState() $success = $model->save($data); if ($model->getError()) { $response = $this->getErrorResponse(400, $model->getError()); } elseif (!$success) { $response = $this->getErrorResponse(400, JText::_('COM_JM_ERROR_OCURRED')); } else { $response = $this->getSuccessResponse(201, JText::_('COM_JM_SUCCESS')); $response->id = $model->getState('user.id'); } $this->plugin->setResponse($response); }
function config() { jimport('joomla.html.editor'); JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'htmlelements'); $model = JModel::getInstance('Comission', 'J' . APP_PREFIX . 'PricingModel'); $r = $model->getItemPrices($this->commissionType); JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'thefactory' . DS . 'category' . DS . 'models'); $catModel = JModel::getInstance('Category', 'JTheFactoryModel'); $cattree = $catModel->getCategoryTree(); $pricing = $model->loadPricingObject(); $params = new JParameter($pricing->params); $editor = JFactory::getEditor(); $viewMenu = $this->getView('menu'); $viewMenu->display(); $view = $this->getView('Config'); $view->assign('default_price', $r->default_price); $view->assign('price_powerseller', $r->price_powerseller); $view->assign('price_verified', $r->price_verified); $view->assign('category_pricing_enabled', $r->category_pricing_enabled); $view->assign('category_pricing', $r->category_pricing); $view->assign('category_tree', $cattree); $view->assign('itemname', $this->itemname); $view->assign('editor', $editor); $view->assign('email_text', base64_decode($params->get('email_text'))); $view->display(); }
/** * AS SMVC entity here we treat HTTP request and identifier map * @access public * @param $cachable string * the view output will be cached * @return void */ function display($cachable = false, $urlparams = false) { // Id entità risposta ajax che identifica il subtask da eseguire in questo caso $params = json_decode($this->app->input->getString('data', null)); // Load additional models and make Dependency Injection thanks to JS controls $DIModels = @$params->DIModels; $models = array(); if (!empty($DIModels)) { foreach ($DIModels as $DIModel) { if ($DIModel->modelside != $this->app->getClientId()) { // Add extra include paths JModel::addIncludePath(JPATH_COMPONENT_SITE . 'models/'); } $models[$DIModel->modelname] = $this->getModel($DIModel->modelname); } } // This model maps Remote Procedure Call $model = $this->getModel(); $userData = $model->loadAjaxEntity($params->idtask, $params->param, $models); // Format response for JS client as requested $document = JFactory::getDocument(); $viewType = $document->getType(); $coreName = $this->getNames(); $view = $this->getView($coreName, $viewType, '', array('base_path' => $this->basePath)); $view->display($userData); }
public function get() { JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models'); $extraFieldsModel = JModel::getInstance('ExtraFields', 'K2Model'); $groups = $extraFieldsModel->getGroups(); $this->plugin->setResponse($groups); }
public function display($cachable = false, $urlparams = false) { $session = JFactory::getSession(); $session->clear('tienda.opc.method'); $session->clear('tienda.opc.billingAddress'); $session->clear('tienda.opc.shippingAddress'); $session->clear('tienda.opc.shippingRates'); $session->clear('tienda.opc.shippingMethod'); $session->clear('tienda.opc.userCoupons'); $session->clear('tienda.opc.userCredit'); $session->clear('tienda.opc.requireShipping'); if (!$this->user->id) { $session->set('old_sessionid', $session->getId()); } $view = $this->getView($this->get('suffix'), 'html'); $view->setTask(true); $order = $this->_order; $order = $this->populateOrder(); $view->assign('order', $order); $view->assign('user', $this->user); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance('addresses', 'TiendaModel'); $model->setState("filter_userid", $this->user->id); $model->setState("filter_deleted", 0); $addresses = $model->getList(); $view->assign('addresses', $addresses); $view->setModel($model); $showShipping = $order->isShippingRequired(); $view->assign('showShipping', $showShipping); $session->set('tienda.opc.requireShipping', serialize($showShipping)); $view->assign('default_country', $this->default_country); $view->assign('default_country_id', $this->default_country_id); TiendaController::display($cachable, $urlparams); }
private function _getField() { $i = 0; $html = ''; $customfields = $this->form->getValue('customfield', 'params'); $customfields = $customfields['joomla']; jimport('joomla.application.component.model'); JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_categories' . DS . 'models', 'categories'); $model = JModel::getInstance('Categories', 'CategoriesModel', array('ignore_request' => true)); $model->setState('list.limit', '200'); $model->setState('filter.extension', 'com_content'); $mitems = $model->getItems(); $children = array(); if ($mitems) { foreach ($mitems as $v) { $v->parent_id = $v->parentid; $pt = $v->parentid; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } } $mitems = array(); foreach ($list as $item) { $item->treename = str_repeat('- ', $item->level - 1) . $item->title; $mitems[] = JHTML::_('select.option', $item->id, ' ' . $item->treename); } $output = JHTML::_('select.genericlist', $mitems, $this->name, 'class="inputbox" multiple="multiple" size="15"', 'value', 'text', $this->value, $this->id); return $output; }
/** * Base Controller Constructor * * @param array $config Controller initialization configuration parameters * @return void * @since 0.1 */ public function __construct($config = array()) { parent::__construct($config); $this->set('option', JRequest::getCmd('option')); JModel::addIncludePath(JPATH_SITE . '/components/com_api/models'); JTable::addIncludePath(JPATH_SITE . '/components/com_api/tables'); }
function export() { Tienda::load('TiendaCSV', 'library.csv'); $request = JRequest::get('request'); //// load the plugins JPluginHelper::importPlugin('tienda'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $params = json_decode(base64_decode($request['exportParams'])); $model = JModel::getInstance($params->view, 'TiendaModel'); $list = $model->getList(); $arr = array(); $header = array(); // header -> it'll be filled out when $fill_header = true; // we need to fill header for ($i = 0, $c = count($list); $i < $c; $i++) { if ($fill_header) { $list_vars = get_object_vars($list[$i]); foreach ($list_vars as $key => $value) { if ($fill_header) { $header[] = $key; } } $fill_header = false; // header is filled } $arr[] = $this->objectToString($list[$i], true); } $f_name = 'tmp/' . $params->view . '_' . time() . '.csv'; $res = TiendaCSV::FromArrayToFile($f_name, $arr, $header); $this->render_page($f_name, $params->view); }
public function feed() { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $document->setMimeEncoding('application/rss+xml'); $article_id = JRequest::getInt('article_id'); // Get some info about the article JModel::addIncludePath(JPATH_SITE . '/components/com_content/models'); $model = $this->getModel('Article', 'ContentModel', array('ignore_request' => true)); $model->setState('article.id', $article_id); $model->setState('params', $app->getParams()); $model->setState('item.select', 'a.id, a.title, a.alias, a.catid, a.attribs, a.access, a.metadata, a.language'); $article = $model->getItem($article_id); // Get the view $view = $this->getView('comments', 'feed', '', array('layout' => 'rss')); // Get/Create the model $model = $this->getModel('comments', '', array('ignore_request' => true)); $model->setState('article.id', $article_id); $model->setState('list.limit', $app->getCfg('feed_limit')); $view->setModel($model, true); // Send data to the view $view->document = $document; $view->comments = $model->getItems(); $view->article = $article; // Display the view $view->display(); return $this; }
/** * Link the object item to a menu * @param string fabrik action * @param string fabrik data to passwith action */ function menuLink($view = 'table', $linkData = 'tableid=0') { $db =& JFactory::getDBO(); $menu = JRequest::getVar('menuselect', '', 'post'); $link = JRequest::getVar('link_name', '', 'post'); $alias = JRequest::getVar('alias', $link, 'post'); JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'models'); $model =& JModel::getInstance('Item', 'MenusModel'); $row =& $model->getItem(); $row->menutype = $menu; $row->name = $link; $row->alias = $alias; /* was url but this doesnt work with dyamic template swapping on link */ $row->type = 'component'; $row->published = 1; $row->link = "index.php?option=com_fabrik&view={$view}"; $sql = "SELECT id FROM #__components WHERE `option` = 'com_fabrik' AND link <> '' AND link IS NOT NULL"; $db->setQuery($sql); $componentId = $db->loadResult(); $row->componentid = $componentId; $row->params = $linkData; $row->ordering = 9999; if (!$row->store()) { JError::raiseWarning(500, $row->getError()); return false; } $row->checkin(); $row->reorder("menutype='{$row->menutype}' "); return true; }
function getAvatar($userID, $email = NULL, $width = 50) { jimport('joomla.filesystem.folder'); jimport('joomla.application.component.model'); $mainframe =& JFactory::getApplication(); $params =& K2HelperUtilities::getParams('com_k2'); if (K2_CB && $userID != 'alias') { $cbUser = CBuser::getInstance((int) $userID); if (is_object($cbUser)) { $avatar = $cbUser->getField('avatar', null, 'csv', 'none', 'profile'); return $avatar; } } /* // JomSocial Avatar integration if(JFolder::exists(JPATH_SITE.DS.'components'.DS.'com_community') && $userID>0){ $userInfo = &CFactory::getUser($userID); return $userInfo->getThumbAvatar(); } */ // Check for placeholder overrides if (JFile::exists(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'images' . DS . 'placeholder' . DS . 'user.png')) { $avatarPath = 'templates/' . $mainframe->getTemplate() . '/images/placeholder/user.png'; } else { $avatarPath = 'components/com_k2/images/placeholder/user.png'; } // Continue with default K2 avatar determination if ($userID == 'alias') { $avatar = JURI::root(true) . '/' . $avatarPath; } else { if ($userID == 0) { if ($params->get('gravatar') && !is_null($email)) { $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&default=' . urlencode(JURI::root() . $avatarPath); } else { $avatar = JURI::root(true) . '/' . $avatarPath; } } else { if (is_numeric($userID) && $userID > 0) { JModel::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models'); $model =& JModel::getInstance('Item', 'K2Model'); $profile = $model->getUserProfile($userID); $avatar = is_null($profile) ? '' : $profile->image; if (empty($avatar)) { if ($params->get('gravatar') && !is_null($email)) { $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&default=' . urlencode(JURI::root() . $avatarPath); } else { $avatar = JURI::root(true) . '/' . $avatarPath; } } else { $avatar = JURI::root(true) . '/media/k2/users/' . $avatar; } } } } if (!$params->get('userImageDefault') && $avatar == JURI::root(true) . '/' . $avatarPath) { $avatar = ''; } return $avatar; }
public function get() { JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/models'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables'); $model = JModel::getInstance('tag', 'K2Model'); $tag = (object) $model->getData()->getProperties(); $this->plugin->setResponse($tag); }
/** * Test JController::addModelPath * * @since 11.3 * * @covers JController::addModelPath */ public function testAddModelPath() { $path = JPath::clean(JPATH_ROOT . '/addmodelpath'); JController::addModelPath($path); // The default path is the class file folder/forms $valid = JPATH_PLATFORM . '/joomla/form/fields'; $this->assertThat(in_array($path, JModel::addIncludePath()), $this->isTrue(), 'Line:' . __LINE__ . ' The path should be added to the JModel paths.'); }
/** * Generic method to display the data from a model/query * can be override in the child class * @return array - array object */ function loadDataList() { JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance($this->getName(), 'TiendaModel'); $this->_setModelState($model); $items = $model->getList($model); return $items; }
function register($user, $renter) { $db = JFactory::getDbo(); $query = $db->getQuery(true); // Initialise variables. $app = JFactory::getApplication(); JModel::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_users' . DS . 'models'); $model = JModel::getInstance('Registration', 'UsersModel'); // Get the user data. //$requestData = JRequest::getVar('jform', array(), 'post', 'array'); $requestData = array('name' => $user['first_name'] . ' ' . $user['last_name'], 'username' => $user['email'], 'password1' => $user['password'], 'password2' => $user['password'], 'email1' => $user['email'], 'email2' => $user['email']); // Validate the posted data. JForm::addFormPath(JPATH_ROOT . DS . 'components' . DS . 'com_users' . DS . 'models' . DS . 'forms'); $form = $model->getForm(); if (!$form) { $return['code'] = 11; $return['msg'] = 'system error: form not exists'; return $return; } $data = $model->validate($form, $requestData); // Check for validation errors. if ($data === false) { // Get the validation messages. $errors = $model->getErrors(); var_dump($errors); die; } // Attempt to save the data. $model->register($data); $username = $user['email']; $userId = $this->getUserId($username); //Active user $db = JFactory::getDbo(); $activeUser = new stdClass(); $activeUser->id = $userId; $activeUser->block = 0; $db->updateObject('#__users', $activeUser, 'id'); $apartmenSize = serialize($renter['apartment_size_ids']); $neighborhood = serialize($renter['neighborhood_ids']); $roommatesEmail = serialize($renter['roommates_email']); $financialInfo = array('gross_salary' => isset($renter['gross_salary']) ? $renter['gross_salary'] : '', 'credit_score' => isset($renter['credit_score']) ? $renter['credit_score'] : '', 'has_guarantor' => isset($renter['has_guarantor']) ? $renter['has_guarantor'] : ''); // var_dump($user, $renter, $financialInfo); $financialInfo = serialize($financialInfo); // move date $tmpDate = explode('/', $renter['move_date']); $moveDate = $tmpDate[2] . '-' . $tmpDate[0] . '-' . $tmpDate[1]; //insert into table renter user $query = $db->getQuery(true); $query->insert('#__rental_renters (user_id, first_name, last_name, phone_number, apartment_size, neighborhood_ids, move_date, max_rent, have_a_pet, roommate, email_alert, financial_info, more_info, created)')->values('"' . $userId . '", "' . $user['first_name'] . '", "' . $user['last_name'] . '", "' . $user['phone_number'] . '", \'' . $apartmenSize . '\', \'' . $neighborhood . '\', "' . $moveDate . '", "' . $renter['maximum_rent'] . '", "' . $renter['have_pet'] . '", "' . $renter['roommates_total'] . '", \'' . $roommatesEmail . '\', \'' . $financialInfo . '\', "' . $renter['comments_for_broker'] . '", "' . date('Y-m-d H:i:s') . '"'); // echo $query; die; $db->setQuery($query); $db->query(); if ($db->getErrorMsg()) { die($db->getErrorMsg()); } return true; }
/** * */ public function forceUpdatesRefresh() { jimport('joomla.application.component.model'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_installer/models'); /** @var $model InstallerModelUpdate */ $model = JModel::getInstance('update', 'InstallerModel'); $model->purge(); @$model->findUpdates(); }
/** * if loading via id then we want to get the view name and add the plugin view and model paths * @return string view name */ protected function getViewName() { $viz = FabTable::getInstance('Visualization', 'FabrikTable'); $viz->load(JRequest::getInt('id')); $viewName = $viz->plugin; $this->addViewPath(JPATH_SITE . DS . 'plugins' . DS . 'fabrik_visualization' . DS . $viewName . DS . 'views'); JModel::addIncludePath(JPATH_SITE . DS . 'plugins' . DS . 'fabrik_visualization' . DS . $viewName . DS . 'models'); return $viewName; }
/** * */ public function display($cachable = false, $urlparams = false) { if ($_POST) { $params = JRequest::getVar('params'); $user = JXFactory::getUser(); $mainframe = JFactory::getApplication(); $emailChange = false; if ($user->email != $params['email']) { $emailChange = true; $oldEmail = $user->email; } // Only process this if there is an email change if ($emailChange) { $dummy = new JXUser(); $loadUser = $dummy->loadUserByEmail($params['email']); // Email is being used by another user; if ($loadUser === true && $dummy->id != $user->id) { $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_EMAIL_USED'), 'error'); return false; } else { // update invitation in case there are invitations from the previous email JModel::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'models'); $usersInvite = JModel::getInstance('usersInvite', 'AccountModel'); $usersInvite->updateFromEmail($oldEmail, $params['email'], $user); } } $params['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW); $params['password2'] = JRequest::getVar('confirm_password', '', 'post', 'string', JREQUEST_ALLOWRAW); // do a password safety check if (JString::strlen($params['password']) || JString::strlen($params['password2'])) { // so that "0" can be used as password e.g. if ($params['password'] != $params['password2']) { $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_REGISTER_ERRMSG_PASSWORD_MISMATCH'), 'error'); return false; } } $user->set('name', $params['name']); $user->set('email', $params['email']); $user->setParam('language', $params['language']); $user->setParam('about_me', $params['about_me']); $user->setParam('timezone', $params['timezone']); $user->setParam('style', $params['style']); $user->bind($params); if ($user->save()) { $percentageFilled = $user->getCalculateCompletion(); $user->setGettingStartedCompletion(JXUser::GSTARTED_COMPLETE_PROFILE, $percentageFilled); // Reload the user session $user->reloadSession(); /* Redirect to clear the previous user values */ $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_SAVE_PROFILE_SUCCESS')); } else { $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_SAVE_PROFILE_FAILED'), 'error'); } } parent::display(null); }
/** * Given a coupon id or code, checks if the coupon is available for use today. * If given a user_id, checks if the user can use the coupon * * @param $coupon string * @param $id_type string * @param $user_id * * @return boolean if false, coupon object if true */ function isValid($coupon_id, $id_type = 'code', $user_id = '') { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); switch ($id_type) { case 'id': case 'coupon_id': $coupon = JTable::getInstance('Coupons', 'TiendaTable'); $coupon->load(array('coupon_id' => $coupon_id)); break; case 'code': case 'coupon_code': default: $coupon = JTable::getInstance('Coupons', 'TiendaTable'); $coupon->load(array('coupon_code' => $coupon_id)); break; } // do we need individualized error reporting? if (empty($coupon->coupon_id)) { $this->setError(JText::_('COM_TIENDA_INVALID_COUPON')); return false; } // is the coupon enabled? if (empty($coupon->coupon_enabled)) { $this->setError(JText::_('COM_TIENDA_COUPON_NOT_ENABLED')); return false; } $date = JFactory::getDate(); if ($date->toMySQL() < $coupon->start_date) { $this->setError(JText::_('COM_TIENDA_COUPON_NOT_VALID_TODAY')); return false; } $db = JFactory::getDBO(); $nullDate = $db->getNullDate(); if ($coupon->expiration_date != $nullDate && $date->toMySQL() > $coupon->expiration_date) { $this->setError(JText::_('COM_TIENDA_COUPON_EXPIRED')); return false; } if ($coupon->coupon_max_uses > '-1' && $coupon->coupon_uses >= $coupon->coupon_max_uses) { $this->setError(JText::_('COM_TIENDA_COUPON_MAXIMUM_USES_REACHED')); return false; } if (!empty($user_id)) { // Check the user's uses of this coupon $model = JModel::getInstance('OrderCoupons', 'TiendaModel'); $model->setState('filter_user', $user_id); $model->setState('filter_coupon', $coupon->coupon_id); $user_uses = $model->getResult(); if ($coupon->coupon_max_uses_per_user > '-1' && $user_uses >= $coupon->coupon_max_uses_per_user) { $this->setError(JText::_('COM_TIENDA_COUPON_USED_MAXIMUM_NUMBER_OF_TIMES')); return false; } } // all ok return $coupon; }
/** * method must be called after preflight * Sets the paths and loads VMFramework config */ public function loadVm() { // $this->path = JInstaller::getInstance()->getPath('extension_administrator'); if (empty($this->path)) { $this->path = JPATH_VM_ADMINISTRATOR; } require_once $this->path . DS . 'helpers' . DS . 'config.php'; JTable::addIncludePath($this->path . DS . 'tables'); JModel::addIncludePath($this->path . DS . 'models'); }
/** * Test JController::addModelPath * * @since 1.6 */ public function testAddModelPath() { // Include JModel as this method is a proxy for JModel::addIncludePath require_once JPATH_PLATFORM . '/joomla/application/component/model.php'; $path = JPATH_ROOT . '/addmodelpath'; JController::addModelPath($path); // The default path is the class file folder/forms $valid = JPATH_PLATFORM . '/joomla/form/fields'; $this->assertThat(in_array($path, JModel::addIncludePath()), $this->isTrue(), 'Line:' . __LINE__ . ' The path should be added to the JModel paths.'); }
/** * Test JController::addModelPath * * @since 1.6 */ public function testAddModelPath() { // Include JModel as this method is a proxy for JModel::addIncludePath require_once JPATH_BASE . '/libraries/joomla/application/component/model.php'; $path = dirname(__FILE__) . DS . 'addmodelpath'; JController::addModelPath($path); // The default path is the class file folder/forms $valid = JPATH_LIBRARIES . DS . 'joomla' . DS . 'form/fields'; $this->assertThat(in_array($path, JModel::addIncludePath()), $this->isTrue(), 'Line:' . __LINE__ . ' The path should be added to the JModel paths.'); }
function onLoginUser($user, $options) { $device = JRequest::getVar('device', ''); if ($_SERVER['REMOTE_ADDR'] == '174.111.57.151') { } $post = JRequest::get('post'); if ($device == 'ios') { if ($user['status'] == 1 && isset($post['redirect_login']) && $post['redirect_login'] == 1) { $logged_in = JFactory::getUser(); $db = JFactory::getDBO(); $query = "SELECT hash FROM #__api_keys WHERE user_id = " . $db->Quote($logged_in->id); $db->setQuery($query); $apikey = $db->loadResult(); if (!$apikey) { jimport('joomla.application.component.model'); JTable::addIncludePath(JPATH_SITE . '/components/com_api/tables'); JModel::addIncludePath(JPATH_SITE . '/components/com_api/models'); JLoader::register('ApiModel', JPATH_SITE . '/components/com_api/libraries/model.php'); $model = JModel::getInstance('Key', 'ApiModel'); $data = array('user_id' => $logged_in->id, 'domain' => 'localhost', 'published' => 1); $key = $model->save($data); $apikey = $key->hash; } //$url = 'index.php?option=com_api&app=community&resource=user&data=1&key='.$apikey; $url = 'hooked://' . $apikey; //JFactory::getApplication()->redirect($url); header("Location: " . $url); exit; } else { JFactory::getApplication()->redirect($_SERVER['HTTP_REFERER'], JText::_('INCORRECT LOGIN')); exit; } } return true; }