function frontendInterface($params, &$smarty) { if (isset($smarty->content[$params['class']])) { return $smarty->content[$params['class']]; } else { return Module::factory($params['class'])->getUserInterface($params); } }
function moduleversions() { $active = Config::getActiveModules(); $versions = array(); foreach ($active as $module) { $cur = Module::factory($module['module']); $versions[] = array('name' => $module['module'], 'version' => $cur->version); unset($cur); } return $versions; }
public static function &factory($module, $path) { try { $mod = parent::factory($module, $path); } catch (Exception $e) { $opt = PEAR::getStaticProperty('m_office', 'options'); $modopt = $opt['modules'][$module]; $mod = new Office_DbModule($module); $mod->_path = $path; $mod->setConfig(array_merge($mod->generateOptions(), $modopt)); $mod->startView(); } return $mod; }
function smarty_function_block($params, &$smarty) { if ($params['class']) { $module = Module::factory($params['class']); $module->smarty->assign('module', $module); $smarty->assign('blockContent', $module->smarty->fetch($params['template'])); } else { $smarty->assign('blockContent', $smarty->fetch($params['template'])); } if ($params['blockid']) { $smarty->assign('blockID', $params['blockid']); } else { $smarty->clear_assign('blockID'); } return $smarty->fetch('block.tpl'); }
public function __construct($id = null, $restriction = false) { if (!is_null($id)) { $this->id = $id; $sql = 'SELECT menu.*, `modules`.module FROM menu, `modules` where menu.module_id=`modules`.id and menu.id=' . $this->id; $item = Database::singleton()->query_fetch($sql); // Create a link using the linkHandler callback. $this->link = Module::factory($item['module'])->linkHandler($item['link']); $this->display = $item['display']; $this->status = $item['status']; $this->sort = $item['sort']; $this->parent = $item['parent_id']; $this->linkType = Module::factory($item['module'])->linkType(); $this->target = $item['target']; $this->link_id = $item['link']; $this->module_id = $item['module_id']; } }
public static function factory($id, $page = '', $args = array(), $initialize = true) { if (!($module = parent::factory($id, 'web'))) { return false; } $module->init($page, $args); if ($initialize) { $module->initialize(); } return $module; }
public function run() { $this->ajaxAuth = true; if ($this->getOption('auth')) { $this->ajaxAuth = false; $subController = new M_Office_Auth($_REQUEST['database']); if (!key_exists('adminPrivileges', $_SESSION) || key_exists('logout', $_REQUEST)) { $this->assign('username', User::getInstance('office')->getProperty('username')); $this->ajaxAuth = true; } elseif (!User::getInstance('office')->isLoggedIn()) { $this->ajaxAuth = false; } else { $subController->initOptions(); $this->assign('username', User::getInstance('office')->getProperty('username')); } } $not = Notifier::getInstance(); $not->addListener($this); if ($this->getOption('auth') && !User::getInstance('office')->isLoggedIn()) { if (self::isAjaxRequest()) { $this->assign('__action', 'ajaxlogin'); } return; } if (key_exists('updateSuccess', $_REQUEST)) { $this->say(__('Record was successfully updated')); M_Office_Util::clearRequest(array('updateSuccess' => 1)); } if (isset($_REQUEST['module'])) { $info = M_Office_Util::getModuleInfo($_REQUEST['module']); $module = $_REQUEST['module']; if (!$info) { if (strpos($_REQUEST['module'], ':')) { $info = array('type' => 'dyn', 'title' => 'Plugin'); $module = $tab[1]; } elseif (preg_match('`^(.+)helper$`', $_REQUEST['module'], $tab)) { $info = array('type' => 'dyn', 'title' => __("modules.{$tab[1]}helper.title")); $module = $_REQUEST['module']; } else { throw new NotFoundException(__('error.module_not_found', array($_REQUEST['module']))); } } } if ($this->isAjaxRequest() && $this->ajaxAuth && $info['type'] != 'dyn') { $this->output = ''; unset($this->localOutput); } if (isset($_REQUEST['debug']) && MODE == 'development') { $debug = (int) $_REQUEST['debug'] % 3; DB_DataObject::debugLevel($debug); ini_set('display_errors', 1); } if ($_REQUEST['livesearch']) { $aj = new M_Office_livesearch($_REQUEST['searchtext'], $_REQUEST['expand']); $this->output = $aj->processRequest(); return; } elseif ($_REQUEST['treesort']) { $aj = new M_Office_treesort(); $this->output = $aj->processRequest(); return; } elseif ($_REQUEST['liveedit']) { $aj = new M_Office_liveedit($_REQUEST['liveedit']); $this->output = $aj->processRequest(); return; } elseif (key_exists('ajaxfromtable', $_REQUEST)) { $table = $_REQUEST['module']; $do = DB_DataObject::factory($table); $do->get($_REQUEST['filterField'], $_REQUEST['filterValue']); $aj = new M_Office_ajaxFromTable($do, $_REQUEST['module'], $_REQUEST['module'], $_REQUEST['filterField'], $_REQUEST['filterValue']); $this->output = $aj->processRequest(); return; } if (isset($_REQUEST['module'])) { if (!$info) { $info = M_Office_Util::getModuleInfo($_REQUEST['module']); } switch ($info['type']) { case 'db': // TODO ajouter ce path en avant-dernier et non en dernier Mreg::get('tpl')->addPath(APP_ROOT . 'app/' . APP_NAME . '/templates/' . $info['table'] . '/', 'after'); Mreg::get('tpl')->addPath(APP_ROOT . 'app/' . APP_NAME . '/templates/' . $_REQUEST['module'] . '/', 'after'); $subController = new M_Office_ShowTable($_REQUEST['module'], $filter); break; case 'dyn': // home module = available for everyone $allowAccess = $_REQUEST['module'] == 'home' || M_Office_Util::getGlobalOption('view', 'showtable', $_REQUEST['module']); if (!$allowAccess) { Log::warn('User is NOT allowed to access ' . $_REQUEST['module']); M_Office_Util::refresh(M_Office::URL(array(), array_keys($_REQUEST))); } else { Log::info('User is allowed to access ' . $_REQUEST['module']); } $subController = Module::factory($_REQUEST['module'], M::getPaths('module')); $subController->executeAction($_REQUEST['action'] ? $_REQUEST['action'] : 'index'); $this->assign('__action', 'dyn'); $layout = $subController->getConfig('layout', $_REQUEST['action'] ? $_REQUEST['action'] : 'index'); if ($layout == '__self') { M_Office::$dsp = '__defaut/ajaxindex'; } elseif ($layout) { M_Office::$dsp = $layout; } $this->assign('output', $subController->output(null, '__self')); break; } $this->assign('currentmodule', $_REQUEST['module']); } else { $subController = new M_Office_FrontEndHome(); } }
<?php /** * Content Module AJAX * @author Christopher Troup <*****@*****.**> * @package Modules * @subpackage Content * @version 2.0 */ require dirname(__FILE__) . '/../../include/Site.php'; require_once 'Pager/Pager.php'; $module = Module::factory('Content'); switch ($_REQUEST['section']) { case 'inactive': switch (@$_REQUEST['action']) { case 'deleteRev': $module->deleteRev($_REQUEST['id']); break; case 'setActiveRev': $module->setActiveRev($_REQUEST['id']); break; } $rows = Database::singleton()->query_fetch_all('select content_page_data.*, locale.display_name as locale from content_page_data, locale WHERE parent_id=' . $_REQUEST['parent_id'] . ' AND locale.id=content_page_data.locale_id and content_page_data.status=0 order by timestamp desc'); $pager_params = array('mode' => 'Sliding', 'append' => false, 'path' => '', 'fileName' => 'javascript:HTML_AJAX.replace(\'inactive\',\'/modules/Content/AJAX_layers.php?section=inactive&parent_id=' . $_REQUEST['parent_id'] . '&pageID=%d\');', 'perPage' => 5, 'delta' => 5, 'itemData' => $rows); $pager =& Pager::factory($pager_params); $data = $pager->getPageData(); $module->smarty->assign('layers', $data); $module->smarty->assign('pager_links', $pager->links); $module->smarty->assign('parent_id', $_REQUEST['parent_id']); $module->smarty->assign('page_numbers', array('current' => $pager->getCurrentPageID(), 'total' => $pager->numPages()));
function setWorldMap() { $data = $this->currentModule->data->getSourceContinentCountries(); $this->setTitleChapter("provenance_mappemonde"); ob_start(); $moduleGR = Module::factory("view_world_map"); $moduleGR->init($this->currentModule->request, null); $moduleGR->showAll(); $out1 = ob_get_contents(); ob_end_clean(); $this->Image("ssgraphworldmap.pngpmv", 40, $this->GetY(), 0, 200 / PDF_COEF_MM_PX, "pngpmv", "", $out1); $this->SetY($this->GetY() + 73); $this->Image(DIR_IMG_MAPS . "/scale.png", 60, $this->GetY(), 0, 7 / PDF_COEF_MM_PX); $this->SetY($this->GetY() + 10); $this->setDisplayDataArray("continent", "provenance_continent", $data); }
public static function factory($id, $page='', $args=array()) { $module = parent::factory($id, 'web'); $module->initialize(); if ($page) { $module->init($page, $args); } return $module; }
error_reporting(E_ALL); /* * Assess whether we are logging in on this page request. */ if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { $auth_container = new CMSAuthContainer(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); } if (@(!isset($_REQUEST['module']))) { $options = Config::singleton()->options; $_REQUEST['module'] = 'Content'; $_REQUEST['page'] = $options['defaultPage']; } require_once 'HTML/AJAX/Helper.php'; $ajaxHelper = new HTML_AJAX_Helper(); if ($ajaxHelper->isAJAX()) { echo Module::factory($_REQUEST['module'], $smarty)->getUserInterface($_REQUEST); } else { //$smarty->addJS('/AJAX/server.php?client=all'); //$smarty->addJS('/js/login.js'); $smarty->addJS('/js/scriptaculous.js'); $smarty->addJS('/modules/Menu/js/sfMenus.js'); //$smarty->addJS('/js/frontend.js'); $smarty->content[$_REQUEST['module']] = Module::factory($_REQUEST['module'], $smarty)->getUserInterface($_REQUEST); $smarty->assign('module', $_REQUEST['module']); if (isset($_SESSION['authenticated_user'])) { $smarty->assign('user', $_SESSION['authenticated_user']); } $smarty->render('db:site.tpl'); }
/** * Factory method * @param string $id the module id to load * @param string $command the command to execute * @param array $args an array of arguments * @return APIModule */ public static function factory($id, $command = '', $args = array()) { if (!($module = parent::factory($id, 'api'))) { return false; } if ($command) { $module->init($command, $args); } return $module; }
// set a custom compile id to ensure Smarty doesent accidentally overwrite duplicate compiled files. $smarty->compile_id = 'admin'; // This is currently a hack since my url-rewriting syntax keeps a trailing slash on the module name $requestedModule = trim(@$_GET['module'], '/'); // assign the requested module $smarty->assign('module', $requestedModule); // render the admin page require_once 'HTML/AJAX/Helper.php'; $ajaxHelper = new HTML_AJAX_Helper(); if ($ajaxHelper->isAJAX()) { echo Module::factory($requestedModule, $smarty)->getAdminInterface(); die; } else { if (!isset($_REQUEST['module'])) { $requestedModule = 'Dashboard'; $smarty->assign('module', $requestedModule); $smarty->assign('module_title', 'Dashboard'); } else { $smarty->content[$requestedModule] = Module::factory($requestedModule, $smarty)->getAdminInterface(); $smarty->assign('module', $requestedModule); $sql = 'select display_name from modules where module="' . e($requestedModule) . '"'; $r = Database::singleton()->query_fetch($sql); $smarty->assign('module_title', $r['display_name']); } $smarty->addCSS('/css/facebox.css'); $smarty->addJS('/js/facebox.js'); $smarty->addJS('/js/help.js'); $smarty->addJS('/js/admin.js'); $smarty->render('admin.tpl'); } }
/** * Charge le module demand� * */ function loadModule() { $moduleName = $this->request->getModuleName(); $db =& Db::getInstance(); if (ereg('admin', $moduleName)) { $this->lang->reloadLangFile(); } if (!$moduleName) { $moduleName = $this->defaultModuleName; } if ($moduleName == 'list_logos') { $authorized = true; } else { $b_writeDir = checkDirWritable(); /** * very first : logo selection is allowed */ /** * first look if installation is needed */ if (!is_file(INCLUDE_PATH . "/config/config.php") || !defined('DB_HOST') || !defined('SU_LOGIN') || !defined('INSTALL_OK')) { if (!Request::isCurrentModuleAnInstallModule()) { Request::redirectToModule('install_welcome'); } $authorized = true; } else { if (!$db->isReady() && substr_count(Request::getCurrentCompleteUrl(), 'mod=login') === 0 && substr_count(Request::getCurrentCompleteUrl(), 'mod=logout') === 0) { Request::redirectToModule('admin_db_config'); } else { if ($b_writeDir === false) { // case there is a write problem, we load server_info page to indicate the user the problem $moduleName = 'admin_server_info'; $authorized = true; } else { if ($db->isReady()) { if (version_compare($db->getVersion(), PHPMV_VERSION) == -1) { $moduleName = 'admin_update'; $authorized = true; } else { if (version_compare($db->getVersion(), PHPMV_VERSION) == 1) { trigger_error("There is a problem : your database is more recent than your phpMyVisites files! Try to upload the last release of phpMyVisites on your server.", E_USER_ERROR); } } } } } } } /** * else it's ok! Load module */ // update module in the object request, used for hidden field in the login form $this->request->setModuleName($moduleName); // manage the user, is he authorized to see this module ? $me =& User::getInstance(); if (isset($authorized) || $me->isAuthorized($moduleName) || $this->request->isCrontabAllowed()) { $module = Module::factory($moduleName); } else { $module = Module::factory('login'); } if (!is_subclass_of($module, 'Module')) { trigger_error('Unable to load: ' . $moduleName . ' module', E_USER_ERROR); } $module->init($this->request, null); $this->module =& $module; }
/** * Factory method * @param string $id the module id to load * @param string $command the command to execute * @param array $args an array of arguments * @param KurogoShellDispatcher $dispatcher an object of KurogoShellDispatcher * @return ShellModule */ public static function factory($id, $command = '', $args = array(), $dispatcher = null) { if (!($module = parent::factory($id, 'shell'))) { return false; } if ($command) { $module->setDispatcher($dispatcher); $module->init($command, $args); } return $module; }
/** * All the cart functionalities are handled here * * Add a product to the cart, remove a product from the cart, checkout, etc * @return string */ public function handleCart($action) { switch ($action) { case 'Add': //Add a new product to the cart $productId = e(@$_REQUEST["productId"]); $product = new Product($productId); if (!$product->getId()) { return $this->smarty->fetch("Error.tpl"); } require_once 'plugins/products/ECommProduct.php'; $hookResults = ECommProduct::clientPluginHooks("BeforeAddToCart", $product, $this); //Add the product to cart $session = Session::getActiveSession(); $cartItem = new CartItem(); $cartItem->setSession($session->getId()); $cartItem->setProduct($productId); $cartItem->setQuantity(@$_REQUEST["quantity"]); $cartItem->setTransaction(0); $cartItem->save(); $hookResults = ECommProduct::clientPluginHooks("AfterAddToCart", $cartItem, $this); $returnURL = @$_REQUEST["returnURL"]; if (!$returnURL) { $returnURL = "/Store/"; } $this->smarty->assign('returnURL', $returnURL); return $this->smarty->fetch("ProductAddedToCart.tpl"); case 'Details': //Get the details of the cart for an ajax call, it will have the format: "subTotal tax shipping total" $cartDetails = Module_EComm::getCartDetails(); return $cartDetails["subTotal"] . " " . $cartDetails["tax"] . " " . $cartDetails["shipping"] . " " . $cartDetails["total"]; break; case 'Delete': //Delete an item from the cart $cartItem = new CartItem(@$_REQUEST["id"]); if ($cartItem->getId()) { if ($cartItem->getSession() == @$_SESSION["ECommSessionId"]) { $cartItem->delete(); return "True"; } } return "Could not be deleted"; break; case 'Display': //Display the cart (before the checkout page) $session = Session::getActiveSession(); $sessionId = $session->getId(); $cartProducts = CartItem::getAll($sessionId); $cartDetails = Module_EComm::getCartDetails($sessionId, $cartProducts); $this->smarty->assign('cartProducts', $cartProducts); $this->smarty->assign('cartDetails', $cartDetails); $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); if ($auth->checkAuth()) { $this->smarty->assign('loggedIn', 1); } $user = Module::factory("User"); $form = $user->getUserAddEditForm('/Store/Cart/&action=Checkout&createAccount=1'); $form->removeElement('a_group'); //In case the administrator is logged in, remove this element because it is not needed $form->removeElement('a_status'); //In case the administrator is logged in, remove this element because it is not needed $form->removeElement('section'); //Remove the section hidden variable from here $form->removeElement('action'); //Remove the action hidden variable from here $this->smarty->assign('user_form', $form); $this->smarty->assign('userExist', @$_REQUEST["userExist"]); $this->smarty->assign('loginFail', @$_REQUEST["loginFail"]); return $this->smarty->fetch("DisplayCart.tpl"); break; case 'displayCartProduct': //Display a product in a cart (similar to display a product from the database but without the option of adding to cart and with some other differences) $cartItem = new CartItem(@$_REQUEST["cartItemId"]); if ($cartItem->getId()) { if ($cartItem->getSession() == @$_SESSION["ECommSessionId"]) { //Make sure the owner of this item is viewing it $product = $cartItem->getCartItemProduct(); $this->smarty->assign('cartItem', $cartItem); require_once 'plugins/products/ECommProduct.php'; $hookResults = ECommProduct::clientPluginHooks("BeforeDisplayCartItem", $cartItem, $this); $html = ""; foreach ($hookResults as $key => $val) { $html .= @$val['HTML']; } $this->smarty->assign('html', $html); $this->smarty->assign('returnURL', '/Store/Cart/&action=' . @$_REQUEST["returnURL"]); return $this->smarty->fetch("DisplayCartItem.tpl"); } } return "Item could not be displayed"; break; case 'Checkout': //Display the checkout page if (@$_REQUEST["createAccount"] == 1) { //Create a new user $user = Module::factory("User"); $form = $user->getUserAddEditForm(); //Then try to log the user in using their username and password $auth_container = new CMSAuthContainer(); $auth = new Auth($auth_container, null, 'authInlineHTML'); //First, log the current user out (if exists) unset($_SESSION['authenticated_user']); $auth->logout(); //And then, log the new user in using the new username and password $_POST["username"] = @$_REQUEST["a_username"]; $_POST["password"] = @$_REQUEST["a_password"]; $_POST["doLogin"] = "******"; $auth->start(); if (!$auth->checkAuth()) { //The login did not happen successfully, which means creating a new user was not successful header('Location: /Store/Cart/&action=Display&userExist=1'); exit; } $this->sendEmailAccountCreated(); } $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); if (!$auth->checkAuth()) { //You need to login to access this page header('Location: /Store/Cart/&action=Display&loginFail=1'); //Invalid username or password exit; } //From this point on, the user is actually logged in $userId = $_SESSION['authenticated_user']->getId(); require_once 'plugins/shipping/ECommShipping.php'; require_once 'plugins/payment/ECommPayment.php'; $this->smarty->assign('username', $_SESSION['authenticated_user']->getUsername()); $session = Session::getActiveSession(); $session->setUser($userId); //Set the default shipping class and payment option, if empty if (!$session->getShippingClass()) { $session->setShippingClass(ECommShipping::getDefaultPlugIn()); } if (!$session->getPaymentClass()) { $session->setPaymentClass(ECommPayment::getDefaultPlugIn()); } $session->save(); $sessionId = $session->getId(); $cartProducts = CartItem::getAll($sessionId); $cartDetails = Module_EComm::getCartDetails($sessionId, $cartProducts); $this->smarty->assign('cartProducts', $cartProducts); $this->smarty->assign('cartDetails', $cartDetails); $userDetails = UserDetails::getUserDetailsBasedOnUserId($userId); $this->smarty->assign('userDetails', $userDetails); $ECommShipping = new ECommShipping(); $this->smarty->assign('shippingClass', $ECommShipping); $this->smarty->assign('selectedShipping', $session->getShippingClass()); $this->smarty->assign('shippingClassDetails', $ECommShipping->getPlugin($session->getShippingClass())->getShippingDetails()); $ECommPayment = new ECommPayment(); $this->smarty->assign('paymentClass', $ECommPayment); $this->smarty->assign('selectedPayment', $session->getPaymentClass()); $this->smarty->assign('paymentClassDetails', $ECommPayment->getPlugin($session->getPaymentClass())->getPaymentDetails()); $this->smarty->assign('paymentForm', $ECommPayment->getPlugin($session->getPaymentClass())->getPaymentForm()); return $this->smarty->fetch("Checkout.tpl"); break; case 'ShippingChange': //Change the shipping class through an ajax call. It returns the details of the new shipping class so it is displayed for the end user if (@$_REQUEST["shippingClass"]) { $session = Session::getActiveSession(); $session->setShippingClass($_REQUEST["shippingClass"]); $session->save(); } require_once 'plugins/shipping/ECommShipping.php'; $ECommShipping = new ECommShipping(); return $ECommShipping->getPlugin(@$_REQUEST["shippingClass"])->getShippingDetails(); break; case 'PaymentChange': //Change the payment class as an ajax call. Returns the details of the new payment method to be displayed to the end user if (@$_REQUEST["paymentClass"]) { $session = Session::getActiveSession(); $session->setPaymentClass($_REQUEST["paymentClass"]); $session->save(); } require_once 'plugins/payment/ECommPayment.php'; $ECommPayment = new ECommPayment(); $details = $ECommPayment->getPlugin(@$_REQUEST["paymentClass"])->getPaymentDetails(); $form = $ECommPayment->getPlugin(@$_REQUEST["paymentClass"])->getPaymentForm(); //This will return the details and the form separated by a new line. //The details must not contain any new line and neither must the form //The ajax call will split the result by \n. The first will will be the details and the second line will be the form return str_replace("\n", " ", $details) . "\n" . str_replace("\n", " ", $form); break; case 'Address': //Change the address or the phone number of the end user in an ajax call $userId = $_SESSION['authenticated_user']->getId(); if (!$userId) { //If the user is not logged in, don't do anything return ""; } $userDetails = UserDetails::getUserDetailsBasedOnUserId($userId); $adr_type = @$_REQUEST['adr_type']; if ($adr_type == "phone_number") { //Change the phone number $form = new Form('phone_addedit', 'post', '/Store/Cart/&action=Address'); $form->addElement('text', 'number', 'Phone Number', array('value' => $userDetails->getPhoneNumber())); $form->setConstants(array('adr_type' => $adr_type)); $form->addElement('hidden', 'adr_type'); $form->addElement('submit', 'submit', 'Submit'); if (isset($_REQUEST['submit'])) { $userDetails->setPhoneNumber(trim($_REQUEST['number'])); $userDetails->save(); $this->smarty->assign('phoneNumber', $userDetails->getPhoneNumber()); return $this->smarty->fetch('PhoneNumber.tpl'); } else { return $form->display(); } } else { //Change the shipping address or billing address $address = $userDetails->getAddress($adr_type); $form = $address->getAddEditForm(); $form->addElement('submit', 'submit', 'Submit'); $form->updateAttributes(array('action' => '/Store/Cart/&action=Address')); $form->setConstants(array('adr_type' => $adr_type)); $form->addElement('hidden', 'adr_type'); if (isset($_REQUEST['submit'])) { $userDetails->setAddress($adr_type, $address); $userDetails->save(); $this->smarty->assign('address', $address); $this->smarty->assign('adr_type', $adr_type); return $this->smarty->fetch('Address.tpl'); } else { return $form->display(); } } break; case 'CheckBeforePayment': //This action is called when the user clicks on the "Buy now" button //Mmake sure that they can checkout in an ajax call before redirecting the user to the payment //For example, the shipping address must be present, the billing address, etc //If the user can checkout, return "0" to the ajax call. Right after doing that, there will be another ajax call to refresh the payment form and then submitting the form $session = Session::getActiveSession(); $cartDetails = Module_EComm::getCartDetails(); $canPurchase = Module_EComm::canUserCheckOut($session, $cartDetails); if ($canPurchase == "0") { //The user can checkout //Create a new transaction and fill it with all the details that the user has enetered $userDetails = UserDetails::getUserDetailsBasedOnUserId($session->getUser()); $shippingAddress = $userDetails->getAddress('shipping_address'); $billingAddress = $userDetails->getAddress('billing_address'); //Proceed to payment: //Create a transaction entity //and change the session so the user won't mess up with it //First, create a random transaction number (30 digits) $tid = Transaction::generateNewTID(); $transaction = new Transaction(); $transaction->setTid($tid); $transaction->setSession($session->getId()); $transaction->setUser($session->getUser()); $transaction->setPhone($userDetails->getPhoneNumber()); $transaction->setShippingStreet($shippingAddress->getStreetAddress()); $transaction->setShippingCity($shippingAddress->getCity()); $transaction->setShippingPostal($shippingAddress->getPostalCode()); $transaction->setShippingProvince($shippingAddress->getStateName()); $transaction->setShippingCountry($shippingAddress->getCountryName()); $transaction->setBillingStreet($billingAddress->getStreetAddress()); $transaction->setBillingCity($billingAddress->getCity()); $transaction->setBillingPostal($billingAddress->getPostalCode()); $transaction->setBillingProvince($billingAddress->getStateName()); $transaction->setBillingCountry($billingAddress->getCountryName()); $transaction->setCostSubtotal((double) $cartDetails["subTotal"]); $transaction->setCostTax((double) $cartDetails["tax"]); $transaction->setCostShipping((double) $cartDetails["shipping"]); $transaction->setCostTotal((double) $cartDetails["total"]); $transaction->setIp($session->getIpAddress()); $transaction->setShippingClass($session->getShippingClass()); $transaction->setPaymentClass($session->getPaymentClass()); $transaction->setDeliveryInstructions(@$_REQUEST["deliveryInstructions"]); $transaction->save(); $_SESSION['ECommTID'] = $tid; //Store $tid in PHP session so when the payment form is generated, we can include it there. //After creating the transaction, regenerate the session ID to prevent users from messing up with the session after proceeding to payment //The user will be assigned a new session. So, their cart will be empty. They can add new items to the cart if they want, and that will not affect their transaction $session->reGenerateSession(); } return $canPurchase; break; } }
function setWorldMap($idcont = "") { $data = $this->currentModule->data->getSourceContinentCountries($idcont); $this->debugTrace("cont : {$idcont}"); //echo "cont : $idcont <br>"; //$this->Cell(80, PDF_DEFAULT_ROW_HEIGHT, $idcont, "0", "", "L", 0); //&id_details_continent=eur ob_start(); $moduleGR = Module::factory("view_world_map"); $moduleGR->init($this->currentModule->request, null); $moduleGR->m_idDetailsCont = $idcont; $moduleGR->showAll(); $out1 = ob_get_contents(); ob_end_clean(); // Parse to get info $infoPNG = $this->_parsepngpmv("getssgraphworldmap" . $idcont . ".pngpmv", $out1); if (!is_array($infoPNG)) { $this->setTitleChapter("provenance_mappemonde", "view_source#a1"); $this->setErrorMessage($infoPNG); return; } $v_w = $infoPNG["w"]; $v_h = $infoPNG["h"]; // Verify if there is enough place to set image $heightImg = $v_h * 0.7 / PDF_COEF_MM_PX; $heightImg += PDF_DEFAULT_ROW_HEIGHT + PDF_CHAPTER_LN_SPACE + 10; if ($this->GetY() + $heightImg > PDF_DEFAULT_MAX_Y) { $this->AddPage(); } $this->setTitleChapter("provenance_mappemonde", "view_source#a1"); $xCentre = $this->getXCenter($v_w * 0.7 / PDF_COEF_MM_PX); $this->Image("ssgraphworldmap" . $idcont . ".pngpmv", $xCentre, $this->GetY(), 0, $v_h * 0.7 / PDF_COEF_MM_PX, "pngpmv", "", $out1); $this->SetY($this->GetY() + $v_h * 0.7 / PDF_COEF_MM_PX + PDF_DEFAULT_ROW_HEIGHT); $this->Image(DIR_IMG_MAPS . "/scale.png", 70, $this->GetY(), 0, 7 / PDF_COEF_MM_PX); $this->SetY($this->GetY() + 10); if ($idcont == "") { $this->setDisplayDataArray("continent", "provenance_continent", $data); } else { $this->setDisplayDataArray("country", "provenance_recappays", $data); } }
public static function getLinkables($module) { $sql = 'select module from modules where id=' . $module; $moduleName = Database::singleton()->query_fetch($sql); $module = Module::factory($moduleName['module']); $result = $module->getValidLinks(); $returnLinks = array(); foreach ($result as $link) { $returnLinks[$link['key']] = $link['value']; } return $returnLinks; }
/** * 设置显示模型 * * @param string $model */ static function setModel($model) { if (empty($model)) { $default = Module::factory(); $default->view(); } else { $temp = explode('/', trim($model, '/')); $temp[0] = ucfirst($temp[0]); $body = call_user_func(array($temp[0], 'factory')); call_user_func(array($body, $temp[1]), $temp); } }
public static function factory($id, $page='', $args=array()) { if (!$module = parent::factory($id, 'web')) { return false; } $module->init($page, $args); $module->initialize(); return $module; }
<?php include '../../include/Site.php'; include 'Mail.php'; $_REQUEST['module'] = 'Mail'; $module = Module::factory('Mail'); $module->cron();