/** * Smarty {securelink} function plugin * * Type: function<br> * Name: securelink<br> * Purpose: create a secure link * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_securelink($params, &$smarty) { /*$loc = $smarty->getTemplateVars('__loc'); if (!isset($params['module'])) $params['module'] = $loc->mod; if (!isset($params['src'])) $params['src'] = $loc->src; if (!isset($params['int'])) $params['int'] = $loc->int; $params['expid'] = session_id(); */ $loc = $smarty->getTemplateVars('__loc'); if (!isset($params['module'])) { $params['module'] = empty($params['controller']) ? $loc->mod : $params['controller']; } if (!isset($params['src'])) { if (expModules::controllerExists($params['module'])) { $params['src'] = $loc->src; } elseif (@call_user_func(array($loc->mod, 'hasSources'))) { $params['src'] = $loc->src; } } if (!isset($params['int'])) { $params['int'] = $loc->int; } echo expCore::makeSecureLink($params); }
/** * Smarty {getchromemenu} function plugin * * Type: function<br> * Name: getchromemenu<br> * Purpose: display the chrome menu * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_getchromemenu($params, &$smarty) { global $router, $user; $cloc = $smarty->getTemplateVars('__loc'); $module = $params['module']; $list = '<ul class="container-menu">'; $list .= '<li class="container-info">' . $module->action . ' / ' . str_replace($module->action . '_', '', $module->view) . '</li>'; if (!empty($params['rank']) && expPermissions::check('order_modules', $cloc)) { $uplink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 2, 'b' => $params['rank'] - 1)); $downlink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 1, 'b' => $params['rank'])); if ($params['rank'] != 1) { //dont show this up arrow if it's the first module in a container $list .= '<li><a href="' . $uplink . '" class="mod-up">' . gt("Move Module Up") . '</a></li>'; } if (!$params['last']) { //if this is the last module in a container don't show down arrow. $list .= '<li><a href="' . $downlink . '" class="mod-down">' . gt("Move Module Down") . '</a></li>'; } } $rerank = $params['rerank']; if ($rerank == 'false') { $rerank = 0; } else { $rerank = 1; } if ($user->isAdmin()) { $userlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'userperms', '_common' => 1)); $grouplink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'groupperms', '_common' => 1)); $list .= '<li><a href="' . $userlink . '" class="user">' . gt("User Permissions") . '</a></li>'; $list .= '<li><a href="' . $grouplink . '" class="group">' . gt("Group Permissions") . '</a></li>'; } if (!empty($module->id) && expPermissions::check('edit_module', $cloc) && $module->permissions['administrate'] == 1) { $editlink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'edit', 'src' => $module->info['source'])); $list .= '<li><a href="' . $editlink . '" class="config-view">' . gt("Configure Action") . " & " . gt("View") . '</a></li>'; } if ($module->permissions['configure'] == 1) { if (expModules::controllerExists($module->info['class'])) { $configlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'configure', 'hcview' => $module->view)); $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>'; } elseif ($module->info['hasConfig']) { $configlink = $router->makeLink(array('module' => $module->info['class'], 'src' => $module->info['source'], 'action' => 'configure', '_common' => 1)); $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>'; } } if (!empty($module->id) && expPermissions::check('delete_module', $cloc)) { $deletelink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'delete', 'rerank' => $rerank)); $list .= '<li><a href="' . $deletelink . '" class="delete" onclick="alert(\'' . gt("This content is being sent to the Recycle Bin to be recovered later if you wish.") . '\')">' . gt("Remove Module") . '</a></li>'; } if (HELP_ACTIVE) { $helplink = help::makeHelpLink(expModules::getControllerName($module->info['class'])); $list .= '<li><a href="' . $helplink . '" class="helplink" target="_blank">' . gt("Get Help") . '</a></li>'; } $list .= '</ul>'; expCSS::pushToHead(array("unique" => "container-chrome", "link" => PATH_RELATIVE . "framework/modules/container/assets/css/admin-container.css")); expJavascript::pushToFoot(array("unique" => 'container-chrome', "yui3mods" => 'node', "src" => PATH_RELATIVE . "framework/core/assets/js/exp-container.js")); echo $list; }
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; }
static function update($values, $object, $loc) { global $db; // check if this is a controller or module $iscontroller = expModules::controllerExists($values['i_mod']); if (!isset($values['id'])) { // Only deal with the inc/dec stuff if adding a module. $src = ""; if (empty($values['existing_source'])) { $src = "@random" . uniqid(""); $object->is_existing = 0; $object->is_existing = 0; } else { $src = $values['existing_source']; $object->is_existing = 1; } // set the location data for the new module/controller $newInternal = expCore::makeLocation($values['modcntrol'], $src); // REFERENCES - Section and Location //$sect = $db->selectObject('section','id='.$_POST['current_section']); expCore::incrementLocationReference($newInternal, intval($_POST['current_section'])); // Rank is only updateable from the order action $object->rank = $values['rank']; // if (isset($values['rerank'])) $db->increment("container","rank",1,"external='".serialize($loc)."' AND rank >= " . $values['rank']); if (isset($values['rerank']) && $values['rerank']) { $db->increment("container", "rank", 1, "external='" . serialize($loc) . "' AND rank >= " . $values['rank']); } $object->internal = serialize($newInternal); $object->external = serialize($loc); } $object->is_private = isset($_POST['is_private']) ? 1 : 0; // UPDATE the container $object->action = isset($values['actions']) ? $values['actions'] : null; //$object->view = $iscontroller ? $values['ctlview'] : $values['view']; $object->view = $values['views']; $object->title = $values['title']; return $object; }
/** * Smarty {link} function plugin * * Type: function<br> * Name: link<br> * Purpose: create a link * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_link($params, &$smarty) { $loc = $smarty->getTemplateVars('__loc'); if ($params['parse_attrs']) { $record = $params['record']; foreach ($params['parse_attrs'] as $key => $value) { $params[$key] = $value; if ($params['showby']) { $params[$params['showby']] = $record->{$params}['showby']; unset($params['showby']); } } unset($params['parse_attrs']); unset($params['record']); } // if the module wasn't passed in we will assume it is the same as the module for this view if (!isset($params['module']) && !isset($params['controller'])) { $params['module'] = $loc->mod; } // make sure the module isn't really a controller if (expModules::controllerExists($params['module'])) { $params['controller'] = $params['module']; unset($params['module']); } // guess the src if it is not set if (!isset($params['src'])) { if (!empty($params['controller']) || @call_user_func(array($loc->mod, 'hasSources'))) { $params['src'] = $loc->src; } } // greb the int value if (!isset($params['int'])) { $params['int'] = $loc->int; } echo expCore::makeLink($params); }
/** * Return a podcast link * * @static * @param $params * @return string */ public static function makePodcastLink($params) { $link = ENABLE_SSL ? NONSSL_URL : URL_BASE; //FIXME: Hardcoded controller stuff!! if (expModules::controllerExists($params['module'])) { $link .= SCRIPT_RELATIVE . "site_rss.php" . "?"; } else { $link .= SCRIPT_RELATIVE . "rss.php" . "?"; } foreach ($params as $key => $value) { $value = chop($value); $key = chop($key); if ($value != "") { $link .= urlencode($key) . "=" . urlencode($value) . "&"; } } $link = substr($link, 0, -1); return htmlspecialchars($link, ENT_QUOTES); }
} //if (expPermissions::check('administrate',$loc)) { if ($user->isAdmin()) { global $router; if (expTemplate::getModuleViewFile($loc->mod, '_userpermissions', false) == TEMPLATE_FALLBACK_VIEW) { $template = new template('common', '_userpermissions', $loc); } else { //TODO //ADK - I hard coded the common module name into the new template declaration since the path resolver // can't seem to figure out that we are in the common module and not the module that call this action. //$template = new template($loc->mod,'_userpermissions',$loc); $template = new template('common', '_userpermissions', $loc); } $template->assign('user_form', 1); $users = array(); $modulename = expModules::controllerExists($loc->mod) ? expModules::getControllerClassName($loc->mod) : $loc->mod; $modclass = $modulename; $mod = new $modclass(); $perms = $mod->permissions($loc->int); $have_users = 0; foreach (user::getAllUsers(false) as $u) { $have_users = 1; foreach ($perms as $perm => $name) { $var = 'perms_' . $perm; if (expPermissions::checkUser($u, $perm, $loc, true)) { $u->{$perm} = 1; } else { if (expPermissions::checkUser($u, $perm, $loc)) { $u->{$perm} = 2; } else { $u->{$perm} = 0;
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); } }
static function getUserCart() { global $db, $user, $router; $sessAr = expSession::get('verify_shopper'); // initialize this users cart if they have ecomm installed. $active = $db->selectValue('modstate', 'active', 'module="storeController"'); if (!expModules::controllerExists('cart') || empty($active)) { // if ecomm is turned off, no cart. return null; } else { if (isset($router->params['controller']) && $router->params['controller'] == 'order' && ($router->params['action'] == 'verifyReturnShopper' || $router->params['action'] == 'verifyAndRestoreCart' || $router->params['action'] == 'clearCart') && (!isset($sessAr['validated']) || $sessAr['validated'] != true)) { return new order(); } else { // if ecomm is turned off, no cart. //$active = ; if (empty($active)) { return null; } $order = new order(); //initialize a new order object to use the find function from. $ticket = expSession::getTicketString(); //get this users session ticket. this is how we track anonymous users. // grab the origional referrer from the session table so that we can transfer it into the cart where it will be used for reporting purposes // sessions are temporary so we can't report on the referrer in the session table itsef because it may not be there // and we can't just get the referrer ar this point becaues the user likely navigated the site a bit and we want the origional referring site $orig_referrer = $db->selectValue('sessionticket', 'referrer', "`ticket`='" . $ticket . "'"); //see if we have a LIVE and ACTIVE session w/ cart and grab it if so $sessioncart = $order->find('first', "invoice_id='' AND sessionticket_ticket='" . $ticket . "'"); //check to see if the user is logged in, and if so grab their existing cart if (!empty($user) && $user->isLoggedIn()) { $usercart = $order->find('first', "invoice_id='' AND user_id=" . $user->id); } //eDebug($sessioncart); //eDebug($usercart); //enter here if we have NO ACTIVE SESSION CART -OR- We're awaiting a potential cart retore if (empty($sessioncart->id) || $sessAr['awaiting_choice'] == true) { if (empty($usercart->id)) { // no SESSION cart was found and user is not logged in... //let's see if they have a cart_id cookie set and we'll snag that if so //they won't have any user data, since they are "logged in" once they get to //checkout, so all we're really doing here is populating a cart for return //shoppers $cookie_cart_id = isset($_COOKIE['cid']) ? $_COOKIE['cid'] : 0; //eDebug($cookie_cart_id,true); if ($cookie_cart_id) { $tmpCart = new order($cookie_cart_id); if ($tmpCart->id != $cookie_cart_id) { //cookie set, but we gots no cart in the DB so act as if we had no cookie $cart = new order(); $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer, 'return_count' => $cart->setReturnCount($orig_referrer))); order::setCartCookie($cart); } else { $u = new user($tmpCart->user_id); //1) Was Not logged in if (empty($tmpCart->user_id)) { $cart = new order($cookie_cart_id); //update the session ticket and return count $cart->update(array('sessionticket_ticket' => $ticket, 'return_count' => $cart->setReturnCount($orig_referrer))); order::setCartCookie($cart); flash('message', gt('Welcome back')); } else { if (!empty($tmpCart->user_id)) { //check for is admin first if ($u->isActingAdmin() || $u->isAdmin()) { //no need to restore anything. $cart = new order(); $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer)); order::setCartCookie($cart); } else { if (!empty($tmpCart->user_id) && count($tmpCart->orderitem) == 0) { //silently copy tracking data from old order and continue on $cart = new order(); $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer, 'return_count' => $tmpCart->setReturnCount($orig_referrer))); order::setCartCookie($cart); flash('message', gt('Welcome back')); } else { if (!empty($tmpCart->user_id) && count($tmpCart->orderitem) > 0) { //3) Was Logged in w/ NON-?real user? account //eDebug(expUtil::right($u->username,10),true); if ($u->isTempUser()) { if (isset($sessAr['validated']) && $sessAr['validated']) { //already went through validation and we're good to go $cart = new order($sessAr['cid']); //update the session ticket and return count $cart->update(array('sessionticket_ticket' => $ticket, 'return_count' => $cart->mergeReturnCount($sessioncart->return_count), 'orig_referrer' => $sessioncart->orig_referrer)); order::setCartCookie($cart); expSession::un_set('verify_shopper'); $user = new user($cart->user_id); expSession::login($user); //Update the last login timestamp for this user. $user->updateLastLogin(); flash('message', gt('Welcome back') . ' ' . $sessAr['firstname'] . '! ' . gt('Your shopping cart has been restored - you may continue shopping or') . ' <a href="' . makelink(array("controller" => "cart", "action" => "checkout")) . '">checkout</a> ' . gt('at your convenience.')); } else { //send to verification? If user has elected to restore their cart //eDebug($_SESSION); if (isset($sessAr['awaiting_choice']) && $sessAr['awaiting_choice'] == true) { /*expSession::set('verify_shopper',array('au'=>1,'orig_path'=>$router->current_url, 'firstname'=>$u->firstname, 'cid'=>$cookie_cart_id)); redirect_to(array("controller"=>"order",'action'=>'verifyReturnShopper')); orderController::verifyReturnShopper();*/ //just give em the sessioncart $cart = $sessioncart; if (count($cart->orderitem) > 0) { //added items to current cart, so we'll assume they do not want to restore the previous at this point expSession::un_set('verify_shopper'); order::setCartCookie($cart); } else { flash('message', gt('Welcome back') . ' ' . $u->firstname . '! ' . gt('We see that you have shopped with us before.') . '<br><br><a id="submit-verify" href="' . makelink(array("controller" => "order", "action" => "verifyReturnShopper")) . '" rel="nofollow">' . gt('Click Here to Restore Your Previous Shopping Cart') . '</a><br><br><a class="exp-ecom-link" href="' . makelink(array("controller" => "order", "action" => "clearCart", "id" => $cookie_cart_id)) . '">' . gt('Click Here To Start a New Shopping Cart') . '</a>'); $sessAr['orig_path'] = $router->current_url; expSession::set('verify_shopper', $sessAr); } } else { //first time...create a default cart, issue message, set session, rinse, repeat $cart = new order(); $cart->update(array("sessionticket_ticket" => $ticket, 'return_count' => $cart->setReturnCount($orig_referrer))); expSession::set('verify_shopper', array('au' => 1, 'orig_path' => $router->current_url, 'firstname' => $u->firstname, 'cid' => $cookie_cart_id, 'awaiting_choice' => true)); //order::setCartCookie($cart); flash('message', gt('Welcome back') . ' ' . $u->firstname . '! ' . gt('We see that you have shopped with us before.') . '<br><br><a id="submit-verify" href="' . makelink(array("controller" => "order", "action" => "verifyReturnShopper")) . '" rel="nofollow">' . gt('Click Here to Restore Your Previous Shopping Cart') . '</a><br><br><a class="exp-ecom-link" href="' . makelink(array("controller" => "order", "action" => "clearCart", "id" => $cookie_cart_id)) . '">' . gt('Click Here To Start a New Shopping Cart') . '</a>'); } } } else { //prompt to login and restore, otherwise reset and start fresh //this should be all we need to do here //redirect_to(array("controller"=>"order",'action'=>'verifyReturnShopper','au'=>'0')); $cart = new order(); $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer)); order::setCartCookie($cart); flash('message', gt('Welcome back') . ' ' . $u->firstname . '! ' . gt('If you would like to pick up where you left off, click here to login and your previous shopping cart will be restored.')); } } } } } } } } else { $cart = new order(); $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer)); order::setCartCookie($cart); } } else { //user is logged in, so we grab their usercart and update the session ticket only //$usercart->update(array('sessionticket_ticket'=>$ticket, 'orig_referrer'=>$orig_referrer)); $usercart->update(array('sessionticket_ticket' => $ticket)); $cart = $usercart; } //enter here if we HAVE an ACTIVE session/cart, but the user is not logged in } elseif (!empty($sessioncart->id) && $user->id == 0) { // the user isn't logged in yet...the session cart will do for now. $cart = $sessioncart; // if we hit here we've found a session cart AND a usercart because the user just logged in // and had both...that means we need to merge them } elseif (!empty($sessioncart->id) && !empty($usercart->id)) { // if we hit here we've found a session cart and a usercart...that means we need to merge them // if it's not the same cart. if ($sessioncart->id == $usercart->id) { $cart = $sessioncart; } else { // if the old user cart had gone through any of the checkout process before, than we // will clean that data out now and start fresh. $usercart->cleanOrderitems(); //merge the current session cart with previously saved user cart. foreach ($sessioncart->orderitem as $orderitem) { $orderitem->merge(array('orders_id' => $usercart->id, 'user_id' => $user->id)); } //if session cart HAS coupon codes, delete usercart codes and copy new code to usercart, else leave be if (count($sessioncart->getOrderDiscounts())) { foreach ($usercart->getOrderDiscounts() as $od) { $od->delete(); } foreach ($sessioncart->getOrderDiscounts() as $sod) { $sod->orders_id = $usercart->id; $sod->save(); } } $cart = new order($usercart->id); $sessioncart->delete(); } order::setCartCookie($cart); expSession::un_set('verify_shopper'); // the user doesn't have a cart with his/her user id in it. this probably means they just // logged in so we need to update the cart with the new user id information. } elseif (!empty($sessioncart->id) && (empty($usercart->id) && $user->isLoggedIn())) { //$sessioncart->update(array('user_id'=>$user->id, 'orig_referrer'=>$orig_referrer)); $sessioncart->update(array('user_id' => $user->id)); $cart = $sessioncart; } $cart->item_count = 0; foreach ($cart->orderitem as $items) { if ($items->product->requiresShipping && !$items->product->no_shipping) { $cart->shipping_required = true; } if ($items->product->requiresBilling) { $cart->billing_required = true; } $cart->item_count += $items->quantity; } $cart->lastcat = expSession::get('last_ecomm_category'); $cart->total = $cart->getCartTotal(); //eDebug($cart,true); return $cart; } } }
/** 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); } } }
$view = $source_select["view"]; $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; }
static function deleteLevel($parent) { global $db; $kids = $db->selectObjects('section', 'parent=' . $parent); foreach ($kids as $kid) { navigationmodule::deleteLevel($kid->id); } $secrefs = $db->selectObjects('sectionref', 'section=' . $parent); foreach ($secrefs as $secref) { $loc = expCore::makeLocation($secref->module, $secref->source, $secref->internal); expCore::decrementLocationReference($loc, $parent); if (class_exists($secref->module)) { $modclass = $secref->module; //FIXME: more module/controller glue code if (expModules::controllerExists($modclass)) { $mod = new $modclass($iloc->src); $mod->delete_instance(); } else { $mod = new $modclass(); $mod->deleteIn($loc); } } } $db->delete('sectionref', 'section=' . $parent); $db->delete('section', 'parent=' . $parent); }
/** * Smarty {icon} function plugin * * Type: function<br> * Name: icon<br> * Purpose: create an icon type link * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_icon($params, &$smarty) { $loc = $smarty->getTemplateVars('__loc'); if (isset($params['record'])) { $record = $params['record']; $params['id'] = $record->id; } if ($record && empty($params['id'])) { $params['id'] = $record->id; } // setup the link params if (!isset($params['controller'])) { if (!isset($params['module'])) { $params['module'] = $loc->mod; } if (expModules::controllerExists($params['module'])) { $params['controller'] = expModules::getControllerName($params['module']); unset($params['module']); } } // guess the src if it is not set if (!isset($params['src'])) { if ($record) { $modloc = expUnserialize($record->location_data); $params['src'] = $modloc->src; } else { if (!empty($params['controller']) || @call_user_func(array($loc->mod, 'hasSources'))) { $params['src'] = $loc->src; } } } if (!is_object($smarty->getTemplateVars('config')) && !empty($smarty->getTemplateVars('config')->noeditagg) && $smarty->getTemplateVars('__loc')->src != $params['src']) { return; } if (!isset($params['int'])) { $params['int'] = $loc->int; } // attempt to translate the alt, text, & title if (!empty($params['alt'])) { $params['alt'] = gt($params['alt']); } if (!empty($params['text'])) { $params['text'] = gt($params['text']); } if (!empty($params['title'])) { $params['title'] = gt($params['title']); } // figure out whether to use the edit icon or text, alt tags, etc. $alt = empty($params['alt']) ? '' : $params['alt']; $class = empty($params['class']) && empty($params['img']) ? $params['action'] : $params['class']; $text = empty($params['text']) ? '' : $params['text']; $title = empty($params['title']) ? empty($text) ? ucfirst($class) . ' ' . gt('this') . ' ' . $smarty->getTemplateVars('modelname') . ' ' . gt('item') : $text : $params['title']; if (!empty($params['hash'])) { $hash = $params['hash']; unset($params['hash']); } if (empty($params['img']) && empty($params['text'])) { $img = gt(ucfirst($class)); } else { if (!empty($params['img'])) { $img = '<img src="' . ICON_RELATIVE . $params['img'] . '" title="' . $title . '" alt="' . $alt . '"' . XHTML_CLOSING . '>'; } } $linktext = $img . $text; // we need to unset these vars before we pass the params array off to makeLink unset($params['alt']); unset($params['title']); unset($params['text']); unset($params['img']); unset($params['class']); unset($params['record']); unset($params['record']); $onclick = $params['onclick']; unset($params['onclick']); //eDebug($params); if (!empty($params['action'])) { echo '<a href="' . expCore::makeLink($params) . '" title="' . $title . '" class="' . $class . '"'; if ($params['action'] == "delete" && empty($onclick)) { echo ' onclick="return confirm(\'' . gt('Are you sure you want to delete this') . ' ' . $smarty->getTemplateVars('modelname') . ' ' . gt('item') . '?\');"'; } if (!empty($onclick)) { echo ' onclick="' . $onclick . '"'; } echo '>' . $linktext . '</a>'; } else { echo $linktext; } }
/** exdoc * Looks through the database returns a list of all module class * names that exist in the system and have been turned on by * the administrator. Inactive modules will not be included. * Returns the list of active module class names. * @node Subsystems:Modules * @return array */ public static function getActiveModulesAndControllersList() { global $db; $modulestates = $db->selectObjects("modstate", "active='1'"); $mods = array(); // 1.0 modules foreach ($modulestates as $state) { if (class_exists($state->module)) { $mods[] = $state->module; } } $ctls = array(); // 2.0 modules foreach ($modulestates as $state) { if (expModules::controllerExists($state->module)) { $controller = new $state->module(); if (!empty($controller->useractions)) { $ctls[] = $state->module; } } } return array_merge($ctls, $mods); }
public function routeActionRequest() { $return_params = array('controller' => '', 'action' => '', 'url_parts' => array()); // If we have three url parts we assume they are controller->action->id, otherwise split them out into name<=>value pairs $return_params['controller'] = $this->url_parts[0]; // set the controller/module $return_params['action'] = $this->url_parts[1]; // set the action // Figure out if this is module or controller request - WE ONLY NEED THIS CODE UNTIL WE PULL OUT THE OLD MODULES if (expModules::controllerExists($return_params['controller'])) { $requestType = 'controller'; } elseif (is_dir(BASE . 'framework/modules-1/' . $return_params['controller'])) { $requestType = 'module'; } else { return false; //this is an invalid url return an let the calling function deal with it. } // now figure out the name<=>value pairs if (count($this->url_parts) == 3) { if (is_numeric($this->url_parts[2])) { $return_params['url_parts']['id'] = $this->url_parts[2]; } } else { for ($i = 2; $i < count($this->url_parts); $i++) { if ($i % 2 == 0) { $return_params['url_parts'][$this->url_parts[$i]] = isset($this->url_parts[$i + 1]) ? $this->url_parts[$i + 1] : ''; } } } // Set the module or controller - this how the actual routing happens $_REQUEST[$requestType] = $return_params['controller']; //url_parts[0]; $_GET[$requestType] = $return_params['controller']; $_POST[$requestType] = $return_params['controller']; // Set the action for this module or controller if ($_SERVER['REQUEST_METHOD'] == 'POST') { // most of the time we can just grab the action outta the POST array since this is passed as a hidden field, // but sometimes it is actually set as the action on the form itself...then we get it from the params array instead. $action = !empty($_POST['action']) ? $_POST['action'] : $this->params['action']; } else { $action = $return_params['action']; } $_REQUEST['action'] = $action; $_GET['action'] = $action; $_POST['action'] = $action; // pass off the name<=>value pairs foreach ($return_params['url_parts'] as $key => $value) { $save_value = $value; $_REQUEST[$key] = $save_value; $_GET[$key] = $save_value; } return true; }
} if ($container != null) { $iloc = unserialize($container->internal); $cloc = unserialize($container->external); $cloc->int = $container->id; if (expPermissions::check('delete_module', $loc) || expPermissions::check('delete_module', $cloc) || expPermissions::check('administrate', $iloc)) { // container::delete($container,(isset($_GET['rerank']) ? 1 : 0)); container::delete($container, isset($_GET['rerank']) ? $_GET['rerank'] : 0); $db->delete('container', 'id=' . $container->id); expSession::clearAllUsersSessionCache('containermodule'); // Check to see if its the last reference $secref = $db->selectObject('sectionref', "module='" . $iloc->mod . "' AND source='" . $iloc->src . "' AND internal='" . $iloc->int . "'"); if ($secref->refcount == 0 && expPermissions::check('administrate', $iloc) && call_user_func(array($iloc->mod, 'hasContent')) == 1) { //FIXME: module/controller glue code // remove this controllers data from the search table. if (expModules::controllerExists($iloc->mod)) { $controller = new $iloc->mod($iloc->src); $controller->delete_search(); } expHistory::back(); // eDebug(expHistory::getLastNotEditable()); // $template = new template('containermodule','_lastreferencedelete',$loc); // $template->assign('iloc',$iloc); // $template->assign('redirect',expHistory::getLastNotEditable()); // $template->output(); } else { expHistory::back(); } } else { echo SITE_403_HTML; }