public function getImage() { $ini = microtime(true); /** Initialization */ $this->ImageAllocate(); /** Text insertion */ $text = $this->getRandomText() . ' ' . $this->getRandomText(); $fontcfg = $this->fonts[array_rand($this->fonts)]; $this->WriteText($text, $fontcfg); JRequest::setvar('com_jobboard_humanv', $text, 'post'); $app =& JFactory::getApplication(); $app->getUserStateFromRequest('com_jobboard.humanv', 'com_jobboard_humanv', $text); /** Transformations */ $this->WaveImage(); if ($this->blur && function_exists('imagefilter')) { imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR); } $this->ReduceImage(); if ($this->debug) { imagestring($this->im, 1, 1, $this->height - 8, "{$text} {$fontcfg['font']} " . round((microtime(true) - $ini) * 1000) . "ms", $this->GdFgColor); } /** Output */ $this->WriteImage(); $this->Cleanup(); }
/** * Render the view */ function display($tpl = null) { // Load the helper(s) $this->loadHelper('html'); $this->loadHelper('html'); $this->loadHelper('currencydisplay'); $this->loadHelper('reportFunctions'); $model = VmModel::getModel(); // $config = JFactory::getConfig(); // $tzoffset = $config->getValue('config.offset'); JRequest::setvar('task', ''); // set period //$date_presets = $model->getDatePresets(); $this->SetViewTitle('REPORT'); $myCurrencyDisplay = CurrencyDisplay::getInstance(); $this->addStandardDefaultViewLists($model); $revenueBasic = $model->getRevenue(); if ($revenueBasic) { $totalReport['revenueTotal_brutto'] = $totalReport['revenueTotal_netto'] = $totalReport['number_of_ordersTotal'] = $totalReport['itemsSoldTotal'] = 0; foreach ($revenueBasic as &$j) { vmdebug('VirtuemartViewReport revenue', $j); $totalReport['revenueTotal_netto'] += $j['order_subtotal_netto']; $totalReport['revenueTotal_brutto'] += $j['order_subtotal_brutto']; $totalReport['number_of_ordersTotal'] += $j['count_order_id']; $j['order_subtotal_netto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_netto']); $j['order_subtotal_brutto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_brutto']); $j['product_quantity'] = $model->getItemsByRevenue($j); $totalReport['itemsSoldTotal'] += $j['product_quantity']; } $totalReport['revenueTotal_netto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_netto']); $totalReport['revenueTotal_brutto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_brutto']); // if ( 'product_quantity'==JRequest::getWord('filter_order')) { // foreach ($revenueBasic as $key => $row) { // $created_on[] =$row['created_on']; // $intervals[] =$row['intervals']; // $itemsSold[] =$row['product_quantity']; // $number_of_orders[] =$row['count_order_id']; // $revenue[] =$row['revenue']; // } // if (JRequest::getWord('filter_order_Dir') == 'desc') array_multisort($itemsSold, SORT_DESC,$revenueBasic); // else array_multisort($itemsSold, SORT_ASC,$revenueBasic); // } } $this->assignRef('report', $revenueBasic); $this->assignRef('totalReport', $totalReport); //$itemsSold = $model->getItemsSold($revenueBasic); //$this->assignRef('itemsSold', $itemsSold); // I tihnk is to use in a different layout such as product solds // PATRICK K. // $productList = $model->getOrderItems(); // $this->assignRef('productList', $productList); $this->lists['select_date'] = $model->renderDateSelectList(); $this->lists['state_list'] = $model->renderOrderstatesList(); $this->lists['intervals'] = $model->renderIntervalsList(); $this->assignRef('from_period', $model->from_period); $this->assignRef('until_period', $model->until_period); $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); parent::display($tpl); }
public function filter() { // Check for request forgeries //JRequest::checkToken() or die('Invalid Token'); $model = JModel::getInstance('List', 'FabrikFEModel'); $id = JRequest::getInt('listid'); $model->setId($id); JRequest::setvar('cid', $id); $request = $model->getRequestData(); $model->storeRequestData($request); $this->view(); }
/** * get html form fields for a plugin (filled with * current element's plugin data * @param string $plugin * @return string html form fields */ function getPluginHTML($plugin = null) { $item = $this->getItem(); if (is_null($plugin)) { $plugin = $item->plugin; } JRequest::setvar('view', 'visualization'); JPluginHelper::importPlugin('fabrik_visualizaton', $plugin); $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel'); if ($plugin == '') { $str = JText::_('COM_FABRIK_SELECT_A_PLUGIN'); } else { $plugin = $pluginManager->getPlugIn($plugin, 'Visualization'); $str = $plugin->onRenderAdminSettings(JArrayHelper::fromObject($item)); } return $str; }
function __construct($config = array()) { parent::__construct($config); JHTML::addIncludePath(OSEMSC_F_HELPER); // add detect $detect = new Mobile_Detect(); //$this->isMobile = $detect->isMobile(); $this->isMobile = false; $view = JRequest::getCmd('view'); if ($this->isMobile && !empty($view) && in_array($view, array('login', 'register', 'member'))) { // Any mobile device. $this->setLayout('mobile'); JRequest::setvar('tmpl', 'component'); oseHtml::loadTouchJs(); oseHTML::stylesheet('components/com_osemsc/assets/css/msc5mobile.css', '1.5'); } else { $jversion = (JOOMLA16 == true) ? '1.6' : '1.5'; oseHTML::script('media/system/js/core.js', $jversion); $this->loadViewJs(); } }
function display($tpl = null) { $config = oseRegistry::call('msc')->getConfig('global', 'obj'); $frontend_style = $config->frontend_style; $config = oseRegistry::call('msc')->getConfig('register', 'obj'); if ($this->isMobile) { // Any mobile device. $this->setLayout('mobile'); JRequest::setvar('tmpl', 'component'); } else { $com = OSECPU_PATH_JS . '/com_ose_cpu/extjs'; oseHTML::initScript(); oseHTML::script($com . '/ose/app.msg.js', '1.5'); oseHTML::script(OSEMSC_F_URL . '/libraries/init.js', '1.5'); oseHTML::stylesheet(OSEMSC_F_URL . '/assets/css/' . $frontend_style . '.css', (JOOMLA16) ? '1.6' : '1.5'); } $this->assignRef('enable_fblogin', $config->enable_fblogin); $this->assignRef('facebookapiid', $config->facebookapiid); $this->prepareDocument(); parent::display($tpl); }
function display($tpl = null) { $tpl = null; $this->set('_layout', 'default'); $user = JFactory::getUser(); $app = JFactory::getApplication('SITE'); if ($user->guest) { $session = JFactory::getSession(); $session->set('oseReturnUrl', base64_encode('index.php?option=com_osemsc&view=member')); $app->redirect('index.php?option=com_osemsc&view=login'); } else { if (!$this->isMobile) { $this->loadViewJs(); $this->loadGridJs(); $this->loadMultiSelect(); $member = oseRegistry::call('member'); $view = $member->getInstance('PanelView'); $member->instance($user->id); $hasMember = $member->getMemberOwnedMscInfo(true, null, 'obj'); if ($hasMember > 0) { $result = $member->getMemberPanelView('Member'); if (isset($result['layout'])) { $this->set('_layout', $result['layout']); } if (!empty($result['tpl'])) { $tpl = $result['tpl']; } $companyAddons = $this->getAddons('member_company'); $this->assignRef('companyAddons', $companyAddons); } else { $this->set('_layout', 'default'); } } else { $this->setLayout('mobile'); JRequest::setvar('tmpl', 'component'); } } $this->prepareDocument(); parent::display($tpl); }
/** * do the plugin action * * @return number of records updated */ function process(&$data, &$listModel) { $app = JFactory::getApplication(); $params = $this->getParams(); //Get plugin settings and save state of request array vars we might change $maxFiles = (int) $params->get('cron_importcsv_maxfiles', 1); $deleteFile = $params->get('cron_importcsv_deletefile', true); $cronDir = $params->get('cron_importcsv_directory'); $useTableName = (int) $params->get('cron_importcsv_usetablename', false); $dropdata = $params->get('cron_importcsv_dropdata', '0'); $orig_dropdata = JRequest::getVar('dropdata', -1); $overwrite = $params->get('cron_importcsv_overwrite', '0'); $orig_overwrite = JRequest::getVar('overwrite', -1); $jform = array(); $jform['drop_data'] = $dropdata; $jform['overwrite'] = $overwrite; JRequest::setVar('jform', $jform); $orig_listid = JRequest::getInt('listid', -1); //Fabrik use this as the base directory, so we need a new directory under 'media' define("FABRIK_CSV_IMPORT_ROOT", JPATH_ROOT . DS . 'media'); $d = FABRIK_CSV_IMPORT_ROOT . DS . $cronDir; //TODO: Need to also have a FILTER for CSV files ONLY. $filter = "\\.CSV\$|\\.csv\$"; $exclude = array('done', '.svn', 'CVS'); $arrfiles = JFolder::files($d, $filter, true, true, $exclude); // the csv import class needs to know we are doing a cron import JRequest::setVar('cron_csvimport', true); $xfiles = 0; foreach ($arrfiles as $full_csvfile) { if (++$xfiles > $maxFiles) { break; } FabrikWorker::log('plg.cron.cronimportcsv.information', "Starting import: {$full_csvfile}: "); $clsImportCSV = JModel::getInstance('Importcsv', 'FabrikFEModel'); if ($useTableName) { $listid = $this->getListIdFromFileName(basename($full_csvfile)); } else { $table =& $listModel->getTable(); $listid = $table->id; } if (empty($listid)) { FabrikWorker::log('plg.cron.cronimportcsv.warning', "List with name {$filename} does not exist"); continue; } JRequest::setVar('listid', $listid); // grab the CSV file, need to strip import root off path first $csvfile = str_replace(FABRIK_CSV_IMPORT_ROOT, '', $full_csvfile); $clsImportCSV->setBaseDir(FABRIK_CSV_IMPORT_ROOT); $clsImportCSV->readCSV($csvfile); //get this->matchedHeading $clsImportCSV->findExistingElements(); $msg = $clsImportCSV->makeTableFromCSV(); if ($app->isAdmin()) { $app->enqueueMessage($msg); } if ($deleteFile == '1') { JFile::delete($full_csvfile); } else { if ($deleteFile == '2') { $new_csvfile = $full_csvfile . '.' . time(); JFile::move($full_csvfile, $new_csvfile); } else { if ($deleteFile == '3') { $done_folder = dirname($full_csvfile) . DS . 'done'; if (JFolder::exists($done_folder)) { $new_csvfile = $done_folder . DS . basename($full_csvfile); JFile::move($full_csvfile, $new_csvfile); } else { if ($app->isAdmin()) { $app->enqueueMessage("Move file requested, but can't find 'done' folder: {$done_folder}"); } } } } } FabrikWorker::log('plg.cron.cronimportcsv.information', $msg); } // Leave the request array how we found it if (!empty($orig_listid)) { JRequest::setvar('listid', $orig_listid); } if ($orig_dropdata != -1) { JRequest::setVar('drop_data', $orig_dropdata); } if ($orig_overwrite != -1) { JRequest::setVar('overwite', $orig_overwrite); } if ($xfiles > 0) { $updates = $clsImportCSV->addedCount + $clsImportCSV->updatedCount; } else { $updates = 0; } return $updates; }
/** * get html form fields for a plugin (filled with * current element's plugin data * @param string $plugin * @return string html form fields */ function getPluginHTML($plugin = null) { $item = $this->getItem(); if (is_null($plugin)) { $plugin = $item->plugin; } JRequest::setvar('view', 'element'); JPluginHelper::importPlugin('fabrik_element', $plugin); $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel'); if ($plugin == '') { $str = JText::_('COM_FABRIK_SELECT_A_PLUGIN'); } else { $plugin = $pluginManager->getPlugIn($plugin, 'Element'); if (!is_object($plugin)) { JError::raiseNotice(500, 'Could not load plugin:' . $plugin); } else { $str = $plugin->onRenderAdminSettings(JArrayHelper::fromObject($item)); } } return $str; }
public function filter() { // Check for request forgeries JRequest::checkToken() or die('Invalid Token'); //JModel::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_fabrik'.DS.'models'); $model = JModel::getInstance('List', 'FabrikFEModel'); $id = JRequest::getInt('listid'); $model->setId($id); JRequest::setvar('cid', $id); $request = $model->getRequestData(); $model->storeRequestData($request); $this->view(); }
/** * Filter the list data * * @return void */ public function filter() { // Check for request forgeries JSession::checkToken() or die('Invalid Token'); $model = JModel::getInstance('List', 'FabrikFEModel'); $id = JRequest::getInt('listid'); $model->setId($id); JRequest::setvar('cid', $id); $request = $model->getRequestData(); $model->storeRequestData($request); // $$$ rob pass in the model otherwise display() rebuilds it and the request data is rebuilt $this->view($model); }
/** * Render the view */ function display($tpl = null) { if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } $model = VmModel::getModel(); JRequest::setvar('task', ''); $this->SetViewTitle('REPORT'); $myCurrencyDisplay = CurrencyDisplay::getInstance(); //update order items button $q = 'SELECT * FROM #__virtuemart_order_items WHERE `product_discountedPriceWithoutTax` IS NULL '; $db = JFactory::getDBO(); $db->setQuery($q); $res = $db->loadRow(); if ($res) { JToolBarHelper::customX('updateOrderItems', 'new', 'new', JText::_('COM_VIRTUEMART_REPORT_UPDATEORDERITEMS'), false); vmError('COM_VIRTUEMART_REPORT_UPDATEORDERITEMS_WARN'); } $this->addStandardDefaultViewLists($model); $revenueBasic = $model->getRevenue(); if ($revenueBasic) { $totalReport['revenueTotal_brutto'] = $totalReport['revenueTotal_netto'] = $totalReport['number_of_ordersTotal'] = $totalReport['itemsSoldTotal'] = 0; foreach ($revenueBasic as &$j) { $totalReport['revenueTotal_netto'] += $j['order_subtotal_netto']; $totalReport['revenueTotal_brutto'] += $j['order_subtotal_brutto']; $totalReport['number_of_ordersTotal'] += $j['count_order_id']; $j['order_subtotal_netto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_netto']); $j['order_subtotal_brutto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_brutto']); //$j['product_quantity'] = $model->getItemsByRevenue($j); $totalReport['itemsSoldTotal'] += $j['product_quantity']; } $totalReport['revenueTotal_netto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_netto']); $totalReport['revenueTotal_brutto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_brutto']); // if ( 'product_quantity'==JRequest::getWord('filter_order')) { // foreach ($revenueBasic as $key => $row) { // $created_on[] =$row['created_on']; // $intervals[] =$row['intervals']; // $itemsSold[] =$row['product_quantity']; // $number_of_orders[] =$row['count_order_id']; // $revenue[] =$row['revenue']; // } // if (JRequest::getWord('filter_order_Dir') == 'desc') array_multisort($itemsSold, SORT_DESC,$revenueBasic); // else array_multisort($itemsSold, SORT_ASC,$revenueBasic); // } } $this->assignRef('report', $revenueBasic); $this->assignRef('totalReport', $totalReport); //$itemsSold = $model->getItemsSold($revenueBasic); //$this->assignRef('itemsSold', $itemsSold); // I tihnk is to use in a different layout such as product solds // PATRICK K. // $productList = $model->getOrderItems(); // $this->assignRef('productList', $productList); $orderstatusM = VmModel::getModel('orderstatus'); $this->lists['select_date'] = $model->renderDateSelectList(); $orderstates = JRequest::getVar('order_status_code', array('C', 'S')); $this->lists['state_list'] = $orderstatusM->renderOSList($orderstates, 'order_status_code', TRUE); $this->lists['intervals'] = $model->renderIntervalsList(); $this->assignRef('from_period', $model->from_period); $this->assignRef('until_period', $model->until_period); $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); parent::display($tpl); }
/** * get html form fields for a plugin (filled with * current element's plugin data * @param string $plugin * @return string html form fields */ function getPluginHTML($plugin = null) { $item = $this->getItem(); if (is_null($plugin)) { $plugin = $item->plugin; } JRequest::setvar('view', 'element'); JPluginHelper::importPlugin('fabrik_element', $plugin); //JModel::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_fabrik'.DS.'models'); $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel'); if ($plugin == '') { $str = JText::_('COM_FABRIK_SELECT_A_PLUGIN'); } else { $plugin = $pluginManager->getPlugIn($plugin, 'Element'); $str = $plugin->onRenderAdminSettings(JArrayHelper::fromObject($item)); } return $str; }
/** * Logic to save an item * * @access public * @return void * @since 1.0 */ function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); //echo '<html> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <body>'; // Initialize variables $app = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $config = JFactory::getConfig(); $session = JFactory::getSession(); $task = JRequest::getVar('task'); $ctrl_task = 'task=items.'; // ********************* // Get data from request // ********************* // Retrieve form data these are subject to basic filtering $data = JRequest::getVar('jform', array(), 'post', 'array'); // Core Fields and and item Parameters $custom = JRequest::getVar('custom', array(), 'post', 'array'); // Custom Fields $jfdata = JRequest::getVar('jfdata', array(), 'post', 'array'); // Joomfish Data // Set into model: id (needed for loading correct item), and type id (e.g. needed for getting correct type parameters for new items) $data_id = (int) $data['id']; $isnew = $data_id == 0; // If new make sure that type id is set too, before creating the model if ($isnew) { $typeid = JRequest::setvar('typeid', (int) @$data['type_id']); } // Get the model $model = $this->getModel('item'); $model->setId($data_id); // Make sure id is correct // Get some flags this will also trigger item loading if not already loaded $isOwner = $model->get('created_by') == $user->get('id'); // Get merged parameters: component, type, menu (FE) $params = new JRegistry(); $model_params = $model->getComponentTypeParams(); $params->merge($model_params); // Unique id for new items, needed by some fields for temporary data $unique_tmp_itemid = JRequest::getVar('unique_tmp_itemid'); // Auto title for some content types if ($params->get('auto_title', 0)) { $data['title'] = (int) $data['id']; } // item id or ZERO for new items // ************************************* // ENFORCE can change category ACL perms // ************************************* $perms = FlexicontentHelperPerm::getPerm(); // Per content type change category permissions $current_type_id = $isnew || !$model->get('type_id') ? (int) @$data['type_id'] : $model->get('type_id'); // GET current (existing/old) item TYPE ID $CanChangeFeatCat = $user->authorise('flexicontent.change.cat.feat', 'com_flexicontent.type.' . $current_type_id); $CanChangeSecCat = $user->authorise('flexicontent.change.cat.sec', 'com_flexicontent.type.' . $current_type_id); $CanChangeCat = $user->authorise('flexicontent.change.cat', 'com_flexicontent.type.' . $current_type_id); $AutoApproveChanges = $perms->AutoApproveChanges; $enable_featured_cid_selector = $perms->MultiCat && $CanChangeFeatCat; $enable_cid_selector = $perms->MultiCat && $CanChangeSecCat; $enable_catid_selector = $isnew && !$params->get('catid_default') || !$isnew && !$model->get('catid') || $CanChangeCat; // Enforce maintaining featured categories $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); if ($featured_cats_parent && !$enable_featured_cid_selector) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_cid = array(); if (!$isnew) { foreach ($model->get('categories') as $item_cat) { if (isset($featured_tree[$item_cat]) && !isset($disabled_cats[$item_cat])) { $featured_cid[] = $item_cat; } } } $data['featured_cid'] = $featured_cid; } // Enforce maintaining secondary categories if (!$enable_cid_selector) { if ($isnew) { $data['cid'] = $params->get('cid_default'); } else { if (isset($featured_cid)) { $featured_cid_arr = array_flip($featured_cid); $sec_cid = array(); foreach ($model->get('cats') as $item_cat) { if (!isset($featured_cid_arr[$item_cat])) { $sec_cid[] = $item_cat; } } $data['cid'] = $sec_cid; } else { $data['cid'] = $model->get('cats'); } } } if (!$enable_catid_selector) { if ($isnew && $params->get('catid_default')) { $data['catid'] = $params->get('catid_default'); } else { if ($model->get('catid')) { $data['catid'] = $model->get('catid'); } } } // ************************** // Basic Form data validation // ************************** // Get the JForm object, but do not pass any data we only want the form object, // in order to validate the data and not create a filled-in form $form = $model->getForm(); // Validate Form data for core fields and for parameters $post = $model->validate($form, $data); // Check for validation error if (!$post) { // Get the validation messages and push up to three validation messages out to the user $errors = $form->getErrors(); for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { $app->enqueueMessage($errors[$i] instanceof Exception ? $errors[$i]->getMessage() : $errors[$i], 'error'); } // Set POST form date into the session, so that they get reloaded $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data); // Save the jform data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom); // Save the custom fields data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata); // Save the falang translations into the session $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid); // Save temporary unique item id into the session // Redirect back to the item form $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return false; //die('error'); } // Some values need to be assigned after validation $post['attribs'] = @$data['attribs']; // Workaround for item's template parameters being clear by validation since they are not present in item.xml $post['custom'] =& $custom; // Assign array of custom field values, they are in the 'custom' form array instead of jform $post['jfdata'] =& $jfdata; // Assign array of Joomfish field values, they are in the 'jfdata' form array instead of jform // Assign template parameters of the select ilayout as an sub-array (the DB model will handle the merging of parameters) $ilayout = $data['attribs']['ilayout']; if (!empty($data['layouts'][$ilayout])) { //echo "<pre>"; print_r($post['attribs']); //$post['attribs'] = array_merge($post['attribs'], $data['layouts'][$ilayout]); $post['attribs']['layouts'] = $data['layouts']; //echo "<pre>"; print_r($post['attribs']); exit; } // USEFULL FOR DEBUGING for J2.5 (do not remove commented code) //$diff_arr = array_diff_assoc ( $data, $post); //echo "<pre>"; print_r($diff_arr); jexit(); // Make sure Content ID in the REQUEST is set, this is needed in BACKEND, needed in some cases // NOTE this is not the same as jform['cid'] which is the category IDs of the Content Item JRequest::setVar('cid', array($model->getId()), 'post', 'array'); // ******************************************************************************** // PERFORM ACCESS CHECKS, NOTE: we need to check access again, despite having // checked them on edit form load, because user may have tampered with the form ... // ******************************************************************************** $itemAccess = $model->getItemAccess(); $canAdd = $itemAccess->get('access-create'); // includes check of creating in at least one category $canEdit = $itemAccess->get('access-edit'); // includes privileges edit and edit-own $type_id = (int) @$post['type_id']; // Typecast to int, (already done for J2.5 via validating) if (!$isnew && $model->get('type_id') == $type_id) { // Existing item with Type not being ALTERED, content type can be maintained regardless of privilege $canCreateType = true; } else { // New item or existing item with Type is being ALTERED, check privilege to create items of this type $canCreateType = $model->canCreateType(array($type_id), true, $types); } // ***************************************************************** // Calculate user's CREATE / EDIT privileges on current content item // ***************************************************************** $hasCoupon = false; // Normally used in frontend only if (!$isnew) { // If no edit privilege, check if item is editable till logoff if (!$canEdit) { if ($session->has('rendered_uneditable', 'flexicontent')) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $canEdit = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')]; $hasCoupon = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')] == 2; // editable via coupon } } } else { // No special CREATE allowing case for backend } // New item: check if user can create in at least one category if ($isnew && !$canAdd) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE')); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } // Existing item: Check if user can edit current item if (!$isnew && !$canEdit) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_EDIT')); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } if (!$canCreateType) { $msg = isset($types[$type_id]) ? JText::sprintf('FLEXI_NO_ACCESS_CREATE_CONTENT_OF_TYPE', JText::_($types[$type_id]->name)) : ' Content Type ' . $type_id . ' was not found OR is not published'; JError::raiseWarning(403, $msg); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } // Get "BEFORE SAVE" categories for information mail $before_cats = array(); if (!$isnew) { $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id'); $db->setQuery($query); $before_cats = $db->loadObjectList('id'); $before_maincat = $model->get('catid'); $original_item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = 0); } // **************************************** // Try to store the form data into the item // **************************************** if (!$model->store($post)) { // Set error message about saving failed, and also the reason (=model's error message) $msg = JText::_('FLEXI_ERROR_STORING_ITEM'); JError::raiseWarning(500, $msg . ": " . $model->getError()); // Set POST form date into the session, so that they get reloaded $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data); // Save the jform data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom); // Save the custom fields data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata); // Save the falang translations into the session $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid); // Save temporary unique item id into the session // Saving has failed check-in and redirect back to the item form, // redirect back to the item form reloading the posted data $model->checkin(); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; //die('save error'); } // ************************************************** // Check in model and get item id in case of new item // ************************************************** $model->checkin(); $post['id'] = $isnew ? (int) $model->get('id') : $post['id']; // Get items marked as newly submitted $newly_submitted = $session->get('newly_submitted', array(), 'flexicontent'); if ($isnew) { // Mark item as newly submitted, to allow to a proper "THANKS" message after final save & close operation (since user may have clicked add instead of add & close) $newly_submitted[$model->get('id')] = 1; $session->set('newly_submitted', $newly_submitted, 'flexicontent'); } $newly_submitted_item = @$newly_submitted[$model->get('id')]; // *********************************************************************************************************** // Get newly saved -latest- version (store task gets latest) of the item, and also calculate publish privelege // *********************************************************************************************************** $item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = -1); $canPublish = $model->canEditState($item, $check_cat_perm = true) || $hasCoupon; // ******************************************************************************************** // Use session to detect multiple item saves to avoid sending notification EMAIL multiple times // ******************************************************************************************** $is_first_save = true; if ($session->has('saved_fcitems', 'flexicontent')) { $saved_fcitems = $session->get('saved_fcitems', array(), 'flexicontent'); $is_first_save = $isnew ? true : !isset($saved_fcitems[$model->get('id')]); } // Add item to saved items of the corresponding session array $saved_fcitems[$model->get('id')] = $timestamp = time(); // Current time as seconds since Unix epoc; $session->set('saved_fcitems', $saved_fcitems, 'flexicontent'); // ******************************************** // Get categories added / removed from the item // ******************************************** $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id'); $db->setQuery($query); $after_cats = $db->loadObjectList('id'); if (!$isnew) { $cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats)); foreach ($cats_added_ids as $cats_added_id) { $cats_added_titles[] = $after_cats[$cats_added_id]->title; } $cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats)); foreach ($cats_removed_ids as $cats_removed_id) { $cats_removed_titles[] = $before_cats[$cats_removed_id]->title; } $cats_altered = count($cats_added_ids) + count($cats_removed_ids); $after_maincat = $model->get('catid'); } // ******************************************************************************************************************* // We need to get emails to notify, from Global/item's Content Type parameters -AND- from item's categories parameters // ******************************************************************************************************************* $notify_emails = array(); if ($is_first_save || $cats_altered || $params->get('nf_enable_debug', 0)) { // Get needed flags regarding the saved items $approve_version = 2; $pending_approval_state = -3; $draft_state = -4; $current_version = FLEXIUtilities::getCurrentVersions($item->id, true); // Get current item version $last_version = FLEXIUtilities::getLastVersions($item->id, true); // Get last version (=latest one saved, highest version id), // $post variables vstate & state may have been (a) tampered in the form, and/or (b) altered by save procedure so better not use them $needs_version_reviewal = !$isnew && $last_version > $current_version && !$canPublish && !$AutoApproveChanges; $needs_publication_approval = $isnew && $item->state == $pending_approval_state && !$canPublish; $draft_from_non_publisher = $item->state == $draft_state && !$canPublish; if ($draft_from_non_publisher) { // Suppress notifications for draft-state items (new or existing ones), for these each author will publication approval manually via a button $nConf = false; } else { // Get notifications configuration and select appropriate emails for current saving case $nConf = $model->getNotificationsConf($params); //echo "<pre>"; print_r($nConf); "</pre>"; } if ($nConf) { $states_notify_new = $params->get('states_notify_new', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5)); if (empty($states_notify_new)) { $states_notify_new = array(); } else { if (!is_array($states_notify_new)) { $states_notify_new = !FLEXI_J16GE ? array($states_notify_new) : explode("|", $states_notify_new); } } $states_notify_existing = $params->get('states_notify_existing', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5)); if (empty($states_notify_existing)) { $states_notify_existing = array(); } else { if (!is_array($states_notify_existing)) { $states_notify_existing = !FLEXI_J16GE ? array($states_notify_existing) : explode("|", $states_notify_existing); } } $n_state_ok = in_array($item->state, $states_notify_new); $e_state_ok = in_array($item->state, $states_notify_existing); if ($needs_publication_approval) { $notify_emails = $nConf->emails->notify_new_pending; } else { if ($isnew && $n_state_ok) { $notify_emails = $nConf->emails->notify_new; } else { if ($isnew) { $notify_emails = array(); } else { if ($needs_version_reviewal) { $notify_emails = $nConf->emails->notify_existing_reviewal; } else { if (!$isnew && $e_state_ok) { $notify_emails = $nConf->emails->notify_existing; } else { if (!$isnew) { $notify_emails = array(); } } } } } } if ($needs_publication_approval) { $notify_text = $params->get('text_notify_new_pending'); } else { if ($isnew) { $notify_text = $params->get('text_notify_new'); } else { if ($needs_version_reviewal) { $notify_text = $params->get('text_notify_existing_reviewal'); } else { if (!$isnew) { $notify_text = $params->get('text_notify_existing'); } } } } //print_r($notify_emails); jexit(); } } // ********************************************************************************************************************* // If there are emails to notify for current saving case, then send the notifications emails, but // ********************************************************************************************************************* if (!empty($notify_emails) && count($notify_emails)) { $notify_vars = new stdClass(); $notify_vars->needs_version_reviewal = $needs_version_reviewal; $notify_vars->needs_publication_approval = $needs_publication_approval; $notify_vars->isnew = $isnew; $notify_vars->notify_emails = $notify_emails; $notify_vars->notify_text = $notify_text; $notify_vars->before_cats = $before_cats; $notify_vars->after_cats = $after_cats; $notify_vars->original_item = @$original_item; $model->sendNotificationEmails($notify_vars, $params, $manual_approval_request = 0); } // *************************************************** // CLEAN THE CACHE so that our changes appear realtime // *************************************************** $cache = FLEXIUtilities::getCache($group = '', 0); $cache->clean('com_flexicontent_items'); $cache->clean('com_flexicontent_filters'); $cache = FLEXIUtilities::getCache($group = '', 1); $cache->clean('com_flexicontent_items'); $cache->clean('com_flexicontent_filters'); // **************************************************************************************************************************** // Recalculate EDIT PRIVILEGE of new item. Reason for needing to do this is because we can have create permission in a category // and thus being able to set this category as item's main category, but then have no edit/editown permission for this category // **************************************************************************************************************************** $asset = 'com_content.article.' . $model->get('id'); $canEdit = $user->authorise('core.edit', $asset) || $user->authorise('core.edit.own', $asset) && $isOwner; // ALTERNATIVE 1 //$canEdit = $model->getItemAccess()->get('access-edit'); // includes privileges edit and edit-own // ALTERNATIVE 2 //$rights = FlexicontentHelperPerm::checkAllItemAccess($user->get('id'), 'item', $model->get('id')); //$canEdit = in_array('edit', $rights) || (in_array('edit.own', $rights) && $isOwner) ; // ******************************************************************************************************* // Check if user can not edit item further (due to changed main category, without edit/editown permission) // ******************************************************************************************************* if (!$canEdit) { if ($task == 'apply' || $task == 'apply_type') { // APPLY TASK: Temporarily set item to be editable till closing it and not through all session // (we will/should clear this flag when item is closed, since we have another flag to indicate new items $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = -1; $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } else { if ($newly_submitted_item) { // NEW ITEM: Do not use editable till logoff behaviour // ALSO: Clear editable FLAG set in the case that 'apply' button was used during new item creation if (!$params->get('items_session_editable', 0)) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); if (isset($rendered_uneditable[$model->get('id')])) { unset($rendered_uneditable[$model->get('id')]); $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); } } } else { // EXISTING ITEM: (if enabled) Use the editable till logoff behaviour if ($params->get('items_session_editable', 0)) { // Set notice for existing item being editable till logoff JError::raiseNotice(403, JText::_('FLEXI_CANNOT_EDIT_AFTER_LOGOFF')); // Allow item to be editable till logoff $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = 1; $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } } } // Set notice about saving an item that cannot be changed further if (!$canEdit) { $app->enqueueMessage(JText::_('FLEXI_CANNOT_MAKE_FURTHER_CHANGES_TO_CONTENT'), 'message'); } } // **************************************************************** // Check for new Content Item is being closed, and clear some flags // **************************************************************** if ($task != 'apply' && $task != 'apply_type' && $newly_submitted_item) { // Clear item from being marked as newly submitted unset($newly_submitted[$model->get('id')]); $session->set('newly_submitted', $newly_submitted, 'flexicontent'); // The 'apply' task may set 'editable till logoff' FLAG ... // CLEAR IT, since NEW content this is meant to be used temporarily if (!$params->get('items_session_editable', 0)) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); if (isset($rendered_uneditable[$model->get('id')])) { unset($rendered_uneditable[$model->get('id')]); $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); } } } // **************************************** // Saving is done, decide where to redirect // **************************************** switch ($task) { case 'apply': case 'apply_type': $link = 'index.php?option=com_flexicontent&' . $ctrl_task . 'edit&cid=' . (int) $model->get('id'); break; case 'saveandnew': $link = $type_id ? 'index.php?option=com_flexicontent&view=item&typeid=' . $type_id : 'index.php?option=com_flexicontent&view=item'; break; default: $link = 'index.php?option=com_flexicontent&view=items'; break; } $msg = JText::_('FLEXI_ITEM_SAVED'); $this->setRedirect($link, $msg); if (JRequest::getVar('fc_doajax_submit')) { JFactory::getApplication()->enqueueMessage($msg, 'message'); echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } }
public function conteudo() { $script = ''; if (!$this->funcao) { // abre as configurações do programa $this->config = $this->get_config($this->programa); if ($this->pagina == 'index') { $this->pagina = $this->config['default']; JRequest::setvar('pagina', $this->config['default']); } // carrega os menus laterais jimport('edesktop.menu.lateral'); // verifica se existe o arquivo menus.php if (file_exists($this->pasta . DS . 'menus.php')) { require_once $this->pasta . DS . 'menus.php'; } // inicia a class $dados = new stdClass(); // carrega a messagem de retorno $dados->msg = JRequest::getvar('msg', ''); $dados->msgTipo = JRequest::getvar('msg_tipo', 'error'); // inicia as variaveis de sessão do dialog/pagina $script = "<script type=\"text/javascript\">\n \$(function(){\n var processID = '{$this->processID}';\n var \$dialog = \$('#d' +processID);\n var \$main = \$dialog.parent();\n\n var url_js = '{$this->url_programa}/js';\n var url_base = '{$this->url_base}';\n var url_programa = '{$this->url_programa}';\n \n var msg = '{$dados->msg}';\n \n\t\t\t\t\t\t\t\t\tif(msg != '')\n\t\t\t\t\t\t\t\t\t\teDesktop.dialog.aviso(msg, '{$dados->msgTipo}', \$('.corpo', \$main));\n\n var pagina = '{$this->pagina}';\n var programa = '{$this->programa}';\n\n var formURL = function(pagina, programa){\n programa = (programa == undefined) ? '{$this->programa}' : programa;\n return '?{$this->token}=1&template={$this->template}&class=programa&programa=' +programa+ '&method=conteudo&pagina=' + pagina;\n };\n \n // botões\n \$('.button, .acoes .submit').button();\n "; // verifica se existe o arquivo js $js_file = $this->pasta_paginas . DS . $this->pagina . '.js'; if (file_exists($js_file) && filesize($js_file)) { $handle = fopen($js_file, "r"); $js_file = fread($handle, filesize($js_file)); fclose($handle); $script .= "// js_file\n\n" . $js_file . "\n\n"; } $script .= "});\n</script>\n\n"; } // verifica a permissão do usuário jAccess($this->pagina); // envia o formURL para o smarty $this->smarty->assign('formURL', $this->formURL('')); // envia o processID para o smarty $this->smarty->assign('processID', $this->processID); // abre a página $pagina = $this->pasta_paginas . DS . $this->pagina; // carrega o php if (file_exists($pagina . '.php')) { require_once $pagina . '.php'; if (!$this->funcao) { echo $script; if (file_exists($pagina . '.html')) { echo $this->smarty->fetch($pagina . '.html'); } } } else { if ($this->funcao) { echo "{ 'msg' : 'Arquivo não encontrado! \"{$this->pagina}.html\"', 'retorno' : false, 'tipo' : 'error' }"; } else { echo "Arquivo não encontrado!<br><br>{$pagina}.html<br><br><br><br><a href=\"javascript:void(0);\" class=\"link\" rel=\"{}\">Voltar</a>"; } } }
require_once JPATH_COMPONENT . '/controller.php'; jimport('joomla.application.component.model'); require_once JPATH_COMPONENT . '/models/model.php'; jimport('joomla.application.component.helper'); JHTML::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers'); // ===============set the default values ======================== $task = JRequest::getVar('task', 'browse'); $config =& JComponentHelper::getParams('com_szavazasok'); $viewname = JRequest::getWord('view', 'szavazasoklist'); // view="szavazasok" id=0 az alapértelmezett hivás --> vita_alt if ($viewname == 'szavazasok' & JRequest::getVar('id') == 0 & JRequest::getVar('task') == '') { $viewname = 'szavazasoklist'; $task = 'browse'; } JRequest::setVar('task', $task); JRequest::setvar('view', $viewname); // ============================================================== // load specific controller if exists $path = JPATH_COMPONENT . '/controllers/' . $viewname . '.php'; if (file_exists($path)) { require_once $path; $controllername = $viewname; } else { $controllername = ''; } $ControllerConfig = array('viewname' => strtolower($viewname), 'mainmodel' => strtolower($viewname), 'itemname' => ucfirst(strtolower($viewname))); // Create the controller $classname = 'SzavazasokController' . $controllername; $controller = new $classname($ControllerConfig); // Perform the Request task $controller->execute($task);
$cfgset = JRequest::getvar('cfgset'); JRequest::setvar('task', "configuration"); $cfg = new sc_configuration($cfgset); display::header(); $cfg->show(); break; } break; case "view_prod": $a = new products(); $alist = $a->getPublishedProducts(); display::view_prod($alist); break; case "about": switch ($task) { default: JRequest::setvar('task', "about"); display::ShowAbout(); break; } break; default: JRequest::setvar('task', "control"); display::MainMenu(); } if ($debug) { echo "<p>Development debug info</p><strong>task= '{$task}'<br>action='{$action}'</strong>"; } if (!JRequest::getvar('no_html')) { display::afFooter(); }
function edit() { JRequest::setvar('layout', 'edit'); parent::display(); }
function show() { JRequest::setvar('task', "vouchers"); $voucher = new voucher(); $alist = $voucher->getAllVouchers($this->field, $this->order); display::showVouchers($alist); }
function manageattendees() { $acl = UserAcl::getInstance(); $xref = JRequest::getInt('xref'); if ($acl->canManageAttendees($xref)) { $layout = 'manageattendees'; } else { if ($acl->canViewAttendees($xref)) { $layout = 'default'; } else { $this->setRedirect(RedeventHelperRoute::getMyEventsRoute(), JText::_('COM_REDEVENT_ACCESS_NOT_ALLOWED'), 'error'); $this->redirect(); } } JRequest::setvar('view', 'attendees'); JRequest::setvar('layout', $layout); parent::display(); }