/** * Smarty {comments} function plugin * * Type: function<br> * Name: comments<br> * Purpose: Get comments * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_comments($params, &$smarty) { $hideform = empty($params['hideform']) ? false : true; $hidecomments = empty($params['hidecomments']) ? false : true; $title = empty($params['title']) ? 'Comments' : $params['title']; $formtitle = empty($params['formtitle']) ? 'Leave a comment' : $params['formtitle']; /* The global constants can be overriden by passing appropriate params */ $require_login = empty($params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $params['require_login']; $require_approval = empty($params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $params['require_approval']; $require_notification = empty($params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $params['require_notification']; $notification_email = empty($params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $params['notification_email']; renderAction(array('controller' => 'expComment', 'action' => 'getComments', 'content_id' => $params['content_id'], 'content_type' => $params['content_type'], 'hideform' => $hideform, 'hidecomments' => $hidecomments, 'title' => $title, 'formtitle' => $formtitle, 'config' => $smarty->getTemplateVars('config'), 'require_login' => $require_login, 'require_approval' => $require_approval, 'require_notification' => $require_notification, 'notification_email' => $notification_email)); }
/** * Smarty {simplenote} function plugin * * Type: function<br> * Name: simplenote<br> * Purpose: Include the SimpleNote Attachable Item on the page.<br> * * @example {simplenote content_type="product" content_id=$record->id} * * @param array $params * @param mixed $smarty */ function smarty_function_simplenote($params, &$smarty) { $hideform = empty($params['hideform']) ? false : true; $hidenotes = empty($params['hidenotes']) ? false : true; $title = empty($params['title']) ? 'Notes' : $params['title']; $formtitle = empty($params['formtitle']) ? 'Add a Note' : $params['formtitle']; $tab = empty($params['tab']) ? '' : $params['tab']; /* The global constants can be overriden by passing appropriate params */ $require_login = empty($params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $params['require_login']; $require_approval = empty($params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $params['require_approval']; $require_notification = empty($params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $params['require_notification']; $notification_email = empty($params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $params['notification_email']; renderAction(array('controller' => 'expSimpleNote', 'action' => 'getNotes', 'content_id' => $params['content_id'], 'content_type' => $params['content_type'], 'hideform' => $hideform, 'hidecomments' => $hidenotes, 'title' => $title, 'formtitle' => $formtitle, 'require_login' => $require_login, 'require_approval' => $require_approval, 'require_notification' => $require_notification, 'notification_email' => $notification_email, 'tab' => $tab)); }
function smarty_function_chainbytags($params, &$smarty) { if (empty($params['controller'])) { return false; } // we're expecting these to come in as an array of expTags $tags = array(); foreach ($params['tags'] as $tag) { $tags[] = $tag->id; } $view = isset($params['view']) ? $params['view'] : 'showall'; $action = isset($params['action']) ? $params['action'] : 'showByTags'; $model = isset($params['model']) ? $params['model'] : ''; echo renderAction(array('controller' => $params['controller'], 'action' => $action, 'view' => $view, 'tags' => $tags, 'model' => $model)); }
public function moduleOrphans($module) { global $db; $orphans = $db->selectObjects($this->table, 'refcount = 0 AND source!=\'\' AND module=\'' . $module . '\''); //foreach ($orphans as $orphan) { for ($i = 0; $i < count($orphans); $i++) { if (expModules::controllerExists($module)) { $orphans[$i]->html = renderAction(array('controller' => $module, 'action' => 'showall', 'src' => $orphans[$i]->source, "no_output" => true)); } else { $mod = new $module(); ob_start(); $mod->show("Default", $loc); //FIXME $loc is not set $orphans[$i]->html = ob_get_contents(); ob_end_clean(); } } return $orphans; }
public function process() { global $db, $order, $user; //eDebug($order,true); if (!$user->isLoggedIn() && empty($this->params['nologin'])) { flash('message', gt("It appears that your session has expired. Please log in to continue the checkout process.")); expHistory::back(); //expHistory::redirecto_login(makeLink(array('module'=>'cart','action'=>'checkout'), 'secure')); } // if this error hits then something went horribly wrong or the user has tried to hit this // action themselves before the cart was ready or is refreshing the page after they've confirmed the // order. if (empty($order->orderitem)) { flash('error', gt('There are no items in your cart.')); } if (!expQueue::isQueueEmpty('error')) { redirect_to(array('controller' => 'store', 'action' => 'showall')); } // set the gift comments $order->update($this->params); // get the biling & shipping info $shipping = new shipping(); $billing = new billing(); // finalize the total to bill $order->calculateGrandTotal(); //eDebug($order,true); $invNum = $order->getInvoiceNumber(); // call the billing calculators process method - this will handle saving the billing options to the database. $result = $billing->calculator->process($billing->billingmethod, expSession::get('billing_options'), $this->params, $invNum); if (empty($result->errorCode)) { // if ($result->errorCode === "0" || $result->errorCode === 0) // { // save out the cart total to the database $billing->billingmethod->update(array('billing_cost' => $order->grand_total)); // set the invoice number and purchase date in the order table..this finializes the order //$invoice_num = $db->max('orders', 'invoice_id') + 1; //if ($invoice_num < ecomconfig::getConfig('starting_invoice_number')) $invoice_num += ecomconfig::getConfig('starting_invoice_number'); // get the first order status and set it for this order $order->update(array('invoice_id' => $invNum, 'purchased' => time(), 'updated' => time(), 'comment' => serialize($comment))); //$order->setDefaultStatus(); --FJD? //$order->setDefaultOrderType(); --FJD? $order->refresh(); // run each items process callback function foreach ($order->orderitem as $item) { $product = new $item->product_type($item->product_id); $product->process($item, $order->order_type->affects_inventory); } $billing->calculator->postProcess($order, $this->params); orderController::clearCartCookie(); } else { flash('error', gt('An error was encountered while processing your transaction.') . '<br /><br />' . $result->message); expHistory::back(); //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); } $billinginfo = $billing->calculator->userView(unserialize($billing->billingmethod->billing_options)); if (!DEVELOPMENT) { // send email invoices to the admins & users if needed if ($order->order_type->emails_customer) { $invoice = renderAction(array('controller' => 'order', 'action' => 'email', 'id' => $order->id)); } } else { flash('message', gt('Development on, skipping email sending.')); } //assign_to_template(array('order'=>$order, 'billing'=>$billing, 'shipping'=>$shipping, 'result'=>$result, 'billinginfo'=>$billinginfo)); flash('message', gt('Your order has been submitted.')); redirect_to(array('controller' => 'order', 'action' => 'myOrder', 'id' => $order->id, 'tc' => 1)); }
static function wrapOutput($modclass, $view, $loc = null, $title = '') { global $db; if (defined('SOURCE_SELECTOR') && strtolower($modclass) != 'containermodule') { $container = null; $mod = new $modclass(); ob_start(); if (expModules::controllerExists($modclass)) { $action = $db->selectValue('container', 'action', "internal='" . serialize($loc) . "'"); renderAction(array('controller' => $modclass, 'action' => $action, 'view' => $view)); } else { $mod->show($view, $loc, $title); } $container->output = ob_get_contents(); ob_end_clean(); $source_select = expSession::get('source_select'); $c_view = $source_select['view']; $c_module = $source_select['module']; $clickable_mods = $source_select['showmodules']; if (!is_array($clickable_mods)) { $clickable_mods = null; } $dest = $source_select['dest']; $template = new template($c_module, $c_view, $loc); if ($dest) { $template->assign('dest', $dest); } $container->info = array('module' => $mod->name(), 'source' => $loc->src, 'hasContent' => $mod->hasContent(), 'hasSources' => $mod->hasSources(), 'hasViews' => $mod->hasViews(), 'class' => $modclass, 'clickable' => $clickable_mods == null || in_array($modclass, $clickable_mods)); $template->assign('container', $container); $template->output(); } else { call_user_func(array($modclass, 'show'), $view, $loc, $title); } }
/** exdoc * Calls the necessary methods to show a specific module * * @param string $module The classname of the module to display * @param string $view The name of the view to display the module with * @param string $title The title of the module (support is view-dependent) * @param string $source The source of the module. * @param bool $pickable Whether or not the module is pickable in the Source Picker. * @param null $section * @param bool $hide_menu * @param array $params * @return * @node Subsystems:Theme */ public static function showModule($module, $view = "Default", $title = "", $source = null, $pickable = false, $section = null, $hide_menu = false, $params = array()) { if (!AUTHORIZED_SECTION && $module != 'navigationmodule' && $module != 'loginController') { return; } global $db, $sectionObj, $module_scope; // Ensure that we have a section //FJD - changed to $sectionObj if ($sectionObj == null) { $section_id = expSession::get('last_section'); if ($section_id == null) { $section_id = SITE_DEFAULT_SECTION; } $sectionObj = $db->selectObject('section', 'id=' . $section_id); //$section->id = $section_id; } if ($module == "loginController" && defined('PREVIEW_READONLY') && PREVIEW_READONLY == 1) { return; } // if (expSession::is_set("themeopt_override")) { // $config = expSession::get("themeopt_override"); // if (in_array($module,$config['ignore_mods'])) return; // } $loc = expCore::makeLocation($module, $source . ""); if (empty($module_scope[$source][$module]->scope)) { $module_scope[$source][$module]->scope = 'global'; } // make sure we've added this module to the sectionref table if ($db->selectObject("sectionref", "module='{$module}' AND source='" . $loc->src . "'") == null) { $secref = null; $secref->module = $module; $secref->source = $loc->src; $secref->internal = ""; $secref->refcount = 1000; if ($sectionObj != null) { $secref->section = $sectionObj->id; } $secref->is_original = 1; $db->insertObject($secref, 'sectionref'); } $iscontroller = expModules::controllerExists($module); if (defined('SELECTOR') && call_user_func(array($module, "hasSources"))) { containermodule::wrapOutput($module, $view, $loc, $title); } else { if (is_callable(array($module, "show")) || $iscontroller) { // FIXME: we are checking here for a new MVC style controller or an old school module. We only need to perform // this check until we get the old modules all gone...until then we have the check and a lot of code duplication // in the if blocks below...oh well, that's life. if (!$iscontroller) { if (!$hide_menu && $loc->mod != "containermodule" && (call_user_func(array($module, "hasSources")) || $db->tableExists($loc->mod . "_config"))) { $container->permissions = array('administrate' => expPermissions::check('administrate', $loc) ? 1 : 0, 'configure' => expPermissions::check('configure', $loc) ? 1 : 0); if ($container->permissions['administrate'] || $container->permissions['configure']) { $container->randomizer = mt_rand(1, ceil(microtime(1))); $container->view = $view; $container->info['class'] = $loc->mod; $container->info['module'] = call_user_func(array($module, "name")); $container->info['source'] = $loc->src; $container->info['hasConfig'] = $db->tableExists($loc->mod . "_config"); $template = new template('containermodule', '_hardcoded_module_menu', $loc); $template->assign('container', $container); $template->output(); } } } else { // if we hit here we're dealing with a controller...not a module if (!$hide_menu) { $controller = expModules::getController($module); $container->permissions = array('administrate' => expPermissions::check('administrate', $loc) ? 1 : 0, 'configure' => expPermissions::check('configure', $loc) ? 1 : 0); if ($container->permissions['administrate'] || $container->permissions['configure']) { $container->randomizer = mt_rand(1, ceil(microtime(1))); $container->view = $view; $container->action = $params['action']; $container->info['class'] = $loc->mod; $container->info['module'] = $controller->displayname(); $container->info['source'] = $loc->src; $container->info['hasConfig'] = true; $template = new template('containermodule', '_hardcoded_module_menu', $loc); $template->assign('container', $container); $template->output(); } } } if ($iscontroller) { $params['src'] = $loc->src; $params['controller'] = $module; $params['view'] = $view; $params['moduletitle'] = $title; if (empty($params['action'])) { $params['action'] = $view; } renderAction($params); } else { call_user_func(array($module, "show"), $view, $loc, $title); } } else { echo sprintf(gt('The module "%s" was not found in the system.'), $module); } } }
$module = $source_select["module"]; $clickable_mods = $source_select["showmodules"]; $dest = $source_select['dest']; } expSession::clearAllUsersSessionCache('containermodule'); $orphans = array(); foreach ($db->selectObjects("sectionref", "module='" . preg_replace('/[^A-Za-z0-9_]/', '', $_GET['module']) . "' AND refcount=0") as $orphan) { $obj = null; $loc = expCore::makeLocation($orphan->module, $orphan->source, $orphan->internal); if (class_exists($orphan->module)) { $modclass = $orphan->module; $mod = new $modclass(); if (class_exists($modclass)) { ob_start(); if (expModules::controllerExists($modclass)) { renderAction(array('controller' => $modclass, 'action' => 'showall', 'src' => $orphan->source)); } else { $mod->show("Default", $loc); } $obj->output = ob_get_contents(); ob_end_clean(); } $obj->info = array("module" => $mod->name(), "source" => $orphan->source, "hasContent" => $mod->hasContent(), "hasSources" => $mod->hasSources(), "hasViews" => $mod->hasViews(), "class" => $modclass, "clickable" => $clickable_mods == null || in_array($modclass, $clickable_mods) ? 1 : 0); } else { $obj->output = sprintf(gt('The module "%s" was not found in the system'), $orphan->module); $containers[$i]->info = array("module" => "Unknown:" . $location->mod, "source" => $orphan->source, "hasContent" => 0, "hasSources" => 0, "hasViews" => 0, "class" => $modclass, "clickable" => false); } $obj->moduleLocation = $loc; $orphans[] = $obj; } $template = new template("containermodule", "Default");
function emailCustomer() { //eDebug($this->params,true); global $db, $template, $user; if (empty($this->params['id'])) { expHistory::back(); } // get the order $order = new order($this->params['id']); // Save the message for future use if that is what the user wanted. if (!empty($this->params['save_message'])) { $message->body = $this->params['email_message']; $db->insertObject($message, 'order_status_messages'); } $email_addys[] = explode(',', $this->params['to_addresses']); //$order->billingmethod[0]->email; //eDebug($email_addy,true); if (!empty($email_addys[0])) { assign_to_template(array('message' => $this->params['email_message'])); $html = $template->render(); if ($this->params['include_invoice']) { $html .= '<br><hr><br>'; $html .= renderAction(array('controller' => 'order', 'action' => 'show', 'view' => 'email_invoice', 'id' => $this->params['id'], 'printerfriendly' => '1', 'no_output' => 'true')); } else { $html .= ecomconfig::getConfig('footer'); } //eDebug($html,true); if (isset($this->params['from_address'])) { if ($this->params['from_address'] == 'other') { $from = $this->params['other_from_address']; } else { $from = $this->params['from_address']; } } else { $from = ecomconfig::getConfig('from_address'); } if (isset($this->params['email_subject'])) { $email_subject = $this->params['email_subject']; } else { $email_subject = 'Message from ' . ecomconfig::getConfig('storename') . ' about your order (#' . $order->invoice_id . ')'; } $mail = new expMail(); //FIXME Unless you need each mail sent separately, you can now set 'to'=>$email_addys and let expMail send a single email to all addresses foreach ($email_addys as $email_addy) { $mail->quickSend(array('html_message' => $html, 'text_message' => str_replace("<br>", "\r\n", $template->render()), 'to' => $email_addy, 'from' => $from, 'subject' => $email_subject)); } $emailed_to = implode(',', $email_addys); $note = new expSimpleNote(); $note->body = "<strong>[action]: Emailed message to " . $emailed_to . ":</strong><br><br>" . $this->params['email_message']; $note->approved = 1; $note->name = $user->firstname . " " . $user->lastname; $note->email = $user->email; $note->save(); $note->refresh(); $noteObj->expsimplenote_id = $note->id; $noteObj->content_id = $order->id; $noteObj->content_type = 'order'; $db->insertObject($noteObj, 'content_expSimpleNote'); //eDebug($note,true); } else { flash('error', gt('The email address was NOT sent. An email address count not be found for this customer')); expHistory::back(); } flash('message', gt('Email sent.')); expHistory::back(); }
function hotspot($source = null) { if (!empty($source)) { global $sectionObj; //FIXME there is NO 'page' object and section has not _construct method $page = new section($sectionObj->id); $modules = $page->getModulesBySource($source); //FIXME there is no getModulesBySource method anywhere //eDebug($modules);exit(); foreach ($modules as $module) { renderAction(array('controller' => $module->type, 'action' => $module->action, 'instance' => $module->id)); } } }