Пример #1
0
/**
 * 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);
}
Пример #2
0
 public static function spider()
 {
     global $db;
     $db->delete('search');
     $searchable_mods = array();
     $unsearchable_mod = array();
     foreach (expModules::modules_list() as $mod) {
         $name = @call_user_func(array($mod, 'name'));
         if (class_exists($mod) && is_callable(array($mod, 'spiderContent'))) {
             if (call_user_func(array($mod, 'spiderContent'))) {
                 $mods[$name] = 1;
             }
         } else {
             //$mods[$name] = 0;
         }
     }
     foreach (expModules::listControllers() as $ctlname => $ctl) {
         $controller = new $ctlname();
         if (method_exists($controller, 'isSearchable') && $controller->isSearchable()) {
             $mods[$controller->name()] = $controller->addContentToSearch();
         } else {
             //$mods[$controller->name()] = 0;
         }
     }
     uksort($mods, 'strnatcasecmp');
     assign_to_template(array('mods' => $mods));
 }
/**
 * 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") . " &amp; " . 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;
}
Пример #4
0
 public function getFeedItems()
 {
     require_once BASE . 'external/feedcreator.class.php';
     // get all the feeds available to this expRss object
     $feeds = $this->getFeeds();
     $items = array();
     // loop over and build out a master list of rss items
     foreach ($feeds as $feed) {
         $controllername = expModules::getControllerClassname($feed->module);
         $controller = new $controllername($feed->src);
         $controller->loc = makeLocation($feed->module, $feed->src);
         $items = array_merge($items, $controller->getRSSContent());
     }
     return $items;
 }
Пример #5
0
 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;
 }
Пример #6
0
 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;
 }
Пример #7
0
 function __construct($params)
 {
     global $db;
     if (!empty($params['values'])) {
         foreach ($params['values'] as $key => $var) {
             $this->values[$key] = $var->id;
         }
     }
     $this->menu = !empty($params['menu']) ? "true" : "false";
     $this->object = $params['nodes'];
     $this->addable = (bool) $params['addable'];
     $this->draggable = $params['draggable'];
     $this->checkable = $params['checkable'];
     $this->expandonstart = empty($params['expandonstart']) ? "false" : "true";
     // setup the controller for this..if it wasn't passed in we'll default to expTag
     $this->controller_classname = expModules::getControllerClassName(isset($params['controller']) ? $params['controller'] : 'expTag');
     $this->controller = new $this->controller_classname();
     // check if a model name was passed in..if not we'll guess it from the controller
     $this->modelname = isset($params['model']) ? $params['model'] : $this->controller->basemodel_name;
     $this->model = new $this->modelname();
     // get all the tags.
     $this->tags = $this->model->getFullTree();
     // eDebug($this->controller_classname);
 }
Пример #8
0
/**
 * 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);
}
Пример #9
0
 function configure()
 {
     expHistory::set('editable', $this->params);
     // little bit of trickery so that that categories can have their own configs
     $this->loc->src = "@globalstoresettings";
     $config = new expConfig($this->loc);
     $this->config = $config->config;
     $pullable_modules = expModules::listInstalledControllers($this->classname, $this->loc);
     $views = get_config_templates($this, $this->loc);
     $gc = new geoCountry();
     $countries = $gc->find('all');
     $gr = new geoRegion();
     $regions = $gr->find('all');
     assign_to_template(array('config' => $this->config, 'pullable_modules' => $pullable_modules, 'views' => $views, 'countries' => $countries, 'regions' => $regions));
 }
Пример #10
0
    $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;
}
Пример #11
0
/**
 * 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;
    }
}
Пример #12
0
 /**
  * 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);
 }
Пример #13
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);
     }
 }
Пример #14
0
 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;
         }
     }
 }
/**
 * Smarty {getcontrollername} modifier plugin
 *
 * Type:     modifier<br>
 * Name:     getcontrollername<br>
 * Purpose:  Return the module name for this module
 * 
 * @param string $str
 * @return string
 */
function smarty_modifier_getcontrollername($str)
{
    return expModules::getControllerName($str);
}
Пример #16
0
 * @version 2.0.0
 */
// Initialize the exponent environment
require_once 'exponent_bootstrap.php';
// Initialize the MVC framework - for objects we need loaded now
require_once BASE . 'framework/core/expFramework.php';
// Initialize the Sessions subsystem
expSession::initialize();
// Initialize the Theme subsystem
expTheme::initialize();
// Initialize the language subsystem
expLang::loadLang();
// Initialize the Database subsystem
$db = expDatabase::connect(DB_USER, DB_PASS, DB_HOST . ':' . DB_PORT, DB_NAME);
// Initialize the Modules subsystem & Create the list of available/active controllers
$available_controllers = expModules::initializeControllers();
//original position
//$available_controllers = array();
//$available_controllers = initializeControllers();
//foreach ($db->selectObjects('modstate',1) as $mod) {
//	if (!empty($mod->path)) $available_controllers[$mod->module] = $mod->path;  //FIXME test location
//}
// Initialize the History (Flow) subsystem.
$history = new expHistory();
//<--This is the new flow subsystem
// Initialize the javascript subsystem
if (expJavascript::inAjaxAction()) {
    set_error_handler('handleErrors');
}
// Validate the session and populate the $user variable
if ($db->havedb) {
Пример #17
0
 public function beforeSave()
 {
     $this->module = expModules::getControllerName($this->module);
     parent::beforeSave();
 }
Пример #18
0
 /** 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);
 }
Пример #19
0
 function manage()
 {
     $controllers = expModules::listActiveControllers();
     $old_school_mods = expModules::listActiveOSMods();
     assign_to_template(array('controllers' => $controllers, 'old_school_mods' => $old_school_mods));
 }
Пример #20
0
 public function setHistory($url_type, $params)
 {
     global $router;
     // if the history gets bigger than 10 then we will trim it.
     $size = empty($this->history[$url_type]) ? 0 : count($this->history[$url_type]);
     if ($size > 10) {
         array_shift($this->history[$url_type]);
         $size = $size - 1;
     }
     // if we're in an action, we'll only set history if the action we're trying to set
     // matches the action the we're in...otherwise if we're on a page we check to make sure
     // the page we're trying to set isn't the same as the last one we just set.  This will keep
     // page refreshes the controllers on the same page from loading up the viewable array with a
     // bunch of identical entries
     $url = '';
     if (stristr($router->current_url, 'EXPONENT.')) {
         return false;
     }
     if (expTheme::inAction()) {
         // we don't want to save history for these action...it screws up the flow when logging in
         if (!isset($router->params['action']) || $router->params['action'] == 'loginredirect' || $router->params['action'] == 'logout') {
             return false;
         }
         // figure out the module/controller names
         $router_name = isset($router->params['controller']) ? $router->params['controller'] : $router->params['module'];
         $params_name = isset($params['controller']) ? $params['controller'] : $params['module'];
         // make sure the controller action is the one specified via the URL
         if (expModules::getControllerName($router_name) == expModules::getControllerName($params_name) && $router->params['action'] == $params['action']) {
             $url = array('url_type' => $router->url_type, 'params' => $router->params);
         }
     } else {
         //if we hit here it should be a page, not an action
         $url = array('url_type' => $router->url_type, 'params' => $router->params);
     }
     if (!empty($url)) {
         $diff = array();
         // if this url is the exact same as the last for this type we won't save it..that way refresh won't fill up our history
         if ($size > 0) {
             $diff = array_diff_assoc($router->params, $this->history[$url_type][$size - 1]['params']);
         }
         if (!empty($diff) || $size == 0) {
             $this->history[$url_type][] = $url;
         }
         // save the "lasts" information
         $this->history['lasts']['type'] = $url_type;
         if ($url_type != 'editable') {
             $this->history['lasts']['not_editable'] = $url_type;
         }
     }
     expSession::set('history', $this->history);
 }
Пример #21
0
 /** 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);
         }
     }
 }
Пример #22
0
 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;
 }
 function configure()
 {
     expHistory::set('editable', $this->params);
     // little bit of trickery so that that categories can have their own configs
     $this->loc->src = "@store-" . $this->params['id'];
     $config = new expConfig($this->loc);
     $this->config = $config->config;
     $pullable_modules = expModules::listInstalledControllers($this->classname, $this->loc);
     $views = get_config_templates($this, $this->loc);
     assign_to_template(array('config' => $this->config, 'pullable_modules' => $pullable_modules, 'views' => $views));
 }
Пример #24
0
 public static function makeHelpLink($module)
 {
     // make sure the module name is in the right format.
     $module = expModules::getControllerName($module);
     // figure out which version we're on
     $full_version = EXPONENT_VERSION_MAJOR . '.' . EXPONENT_VERSION_MINOR . '.' . EXPONENT_VERSION_REVISION . EXPONENT_VERSION_TYPE;
     $link = HELP_URL;
     $link .= 'docs';
     $link .= '/' . $full_version;
     $link .= '/' . $module;
     return $link;
 }
Пример #25
0
 /**
  * generic config action
  */
 function configure()
 {
     expHistory::set('editable', $this->params);
     $pullable_modules = expModules::listInstalledControllers($this->classname, $this->loc);
     $views = get_config_templates($this, $this->loc);
     $page = new expPaginator(array('records' => $pullable_modules, 'limit' => count($pullable_modules), 'order' => 'section', 'columns' => array('Title' => 'title', 'Page' => 'section')));
     assign_to_template(array('config' => $this->config, 'pullable_modules' => $pullable_modules, 'page' => $page, 'views' => $views));
 }
Пример #26
0
     $container->internal = unserialize($container->internal);
     $secref = $db->selectObject('sectionref', "module='" . $container->internal->mod . "' AND source='" . $container->internal->src . "'");
 }
 expSession::clearAllUsersSessionCache('containermodule');
 $template = new template('containermodule', '_form_edit', $loc);
 //	$template->assign('rerank', (isset($_GET['rerank']) ? 1 : 0) );
 $template->assign('rerank', isset($_GET['rerank']) ? $_GET['rerank'] : 0);
 $template->assign('container', $container);
 $template->assign('locref', $secref);
 $template->assign('is_edit', isset($container->id) ? 1 : 0);
 $template->assign('can_activate_modules', $user->is_acting_admin);
 $template->assign('current_section', expSession::get('last_section'));
 $haveclass = false;
 $mods = array();
 //$modules_list = (isset($container->id) ? expModules::modules_list() : exponent_modules_listActive());
 $modules_list = expModules::getActiveModulesAndControllersList();
 if (!count($modules_list)) {
     // No active modules
     $template->assign('nomodules', 1);
 } else {
     $template->assign('nomodules', 0);
 }
 //sort($modules_list);
 $js_init = '<script type="text/javascript">';
 foreach ($modules_list as $moduleclass) {
     $module = new $moduleclass();
     $mod = null;
     // Get basic module meta info
     $mod->name = $module->name();
     $mod->author = $module->author();
     $mod->description = $module->description();
Пример #27
0
}
//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;
Пример #28
0
 public function getSearchResults($terms, $readonly = 0)
 {
     global $db, $user;
     // get the search terms
     //$terms = $this->params['search_string'];
     if (SAVE_SEARCH_QUERIES && $readonly == 0) {
         if (INCLUDE_ANONYMOUS_SEARCH == 1 || $user->id != 0) {
             $queryObj = new stdClass();
             $queryObj->user_id = $user->id;
             $queryObj->query = $terms;
             $queryObj->timestamp = time();
             $db->insertObject($queryObj, 'search_queries');
         }
     }
     //setup the sql query
     /*$sql  = "SELECT *, MATCH (s.title,s.body) AGAINST ('".$terms."') as score from ".DB_TABLE_PREFIX."_search as s ";
     		$sql .= "LEFT OUTER JOIN ".DB_TABLE_PREFIX."_product p ON s.original_id = p.id WHERE MATCH(title,body) against ('".$terms."' IN BOOLEAN MODE)";
     		
             SELECT *, MATCH (s.title,s.body) AGAINST ('army combat uniform') as score from exponent_search as s 
             LEFT OUTER JOIN exponent_product p ON s.original_id = p.id WHERE MATCH(s.title,s.body) against ('army combat uniform' IN BOOLEAN MODE)*/
     $sql = "SELECT *, MATCH (s.title,s.body) AGAINST ('" . $terms . "*') as score from " . DB_TABLE_PREFIX . "_search as s ";
     $sql .= "WHERE MATCH(title,body) against ('" . $terms . "*' IN BOOLEAN MODE) ";
     // look up the records.
     //eDebug($sql);
     $records = $db->selectObjectsBySql($sql);
     //eDebug($records);
     //FIXME: The page count is off when have to not show
     // search results due to permissions...not sure what to do about that.
     $recs = $records;
     for ($i = 0; $i < count($records); $i++) {
         if ($records[$i]->ref_type == 'product') {
             $score = $records[$i]->score;
             if (!product::canView($records[$i]->original_id)) {
                 unset($recs[$i]);
             }
             /*else 
               {
                   $records[$i] = new product($records[$i]->original_id);
                   $records[$i]->score = $score;   
               }*/
         } else {
             if ($records[$i]->ref_type == 'section') {
                 $section = $db->selectObject('section', 'id=' . $records[$i]->original_id);
                 if (empty($section) || !navigationmodule::canView($section)) {
                     unset($recs[$i]);
                     //$records[$i]->canview = false;
                 }
             } else {
                 $rloc = unserialize($records[$i]->location_data);
                 if (!empty($rloc)) {
                     $sectionref = $db->selectObject("sectionref", "module='" . expModules::getControllerClassName($rloc->mod) . "' AND source='" . $rloc->src . "'");
                     if (!empty($sectionref)) {
                         $section = $db->selectObject("section", "id=" . $sectionref->section);
                         if (empty($section) || !navigationmodule::canView($section)) {
                             unset($recs[$i]);
                             //$records[$i]->canview = false;
                         }
                     }
                 }
             }
         }
     }
     return $recs;
 }
Пример #29
0
 function form($object)
 {
     global $db;
     $tag_collections = $db->selectObjects("tag_collections");
     foreach ($tag_collections as $tag_collections => $collection) {
         $tc_list[$collection->id] = $collection->name;
     }
     //eDebug($all_calendars);
     $form = new form();
     if (!isset($object->id)) {
         // $object->enable_categories = 0;
         $object->enable_feedback = 0;
         $object->reminder_notify = serialize(array());
         $object->email_title_reminder = "Calendar Reminder";
         $object->email_from_reminder = "Calendar Manager";
         $object->email_address_reminder = "calendar@" . HOSTNAME;
         $object->email_reply_reminder = "calendar@" . HOSTNAME;
         $object->email_showdetail = 0;
         $object->email_signature = "--\nThanks, Webmaster";
         $object->aggregate = array();
         $object->enable_rss = false;
         $object->enable_ical = true;
         $object->feed_title = "";
         $object->feed_desc = "";
         $object->rss_limit = 365;
         $object->rss_cachetime = 60;
         // $object->enable_tags = false;
         // $object->collections = array();
         // $object->group_by_tags = false;
         // $object->show_tags = array();
     } else {
         $form->meta('id', $object->id);
         // $cols = unserialize($object->collections);
         // $object->collections = array();
         // $available_tags = array();
         // if (!empty($cols)) {
         // foreach ($cols as $col_id) {
         // $collection = $db->selectObject('tag_collections', 'id='.$col_id);
         // $object->collections[$collection->id] = $collection->name;
         // //while we're here we will get the list of available tags.
         // $tmp_tags = $db->selectObjects('tags', 'collection_id='.$col_id);
         // foreach ($tmp_tags as $tag) {
         // $available_tags[$tag->id] = $tag->name;
         // }
         // }
         // }
         // //Get the tags the user chose to show in the group by views
         // $stags = unserialize($object->show_tags);
         // $object->show_tags = array();
         // //			if (is_array($stags)) {
         // if (!empty($stags)) {
         // foreach ($stags as $stag_id) {
         // $show_tag = $db->selectObject('tags', 'id='.$stag_id);
         // $object->show_tags[$show_tag->id] = $show_tag->name;
         // }
         // }
     }
     // setup the listbuilder arrays for calendar aggregation.
     $loc = unserialize($object->location_data);
     $calendars = expModules::listInstalledControllers('calendarmodule');
     $saved_aggregates = empty($object->aggregate) ? array() : unserialize($object->aggregate);
     $all_calendars = array();
     $selected_calendars = array();
     foreach ($calendars as $src => $cal) {
         $calendar_name = (empty($cal->title) ? 'Untitled' : $cal->title) . ' on page ' . $cal->section;
         if ($src != $loc->src) {
             if (in_array($src, $saved_aggregates)) {
                 $selected_calendars[$src] = $calendar_name;
             } else {
                 $all_calendars[$src] = $calendar_name;
             }
         }
     }
     // setup the config form
     $form->register(null, '', new htmlcontrol('<h3>' . gt('General Configuration') . '</h3><hr size="1" />'));
     // $form->register('enable_categories',gt('Enable Categories'),new checkboxcontrol($object->enable_categories,true));
     $form->register('enable_feedback', gt('Enable Feedback'), new checkboxcontrol($object->enable_feedback, true));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('Events Reminder Email') . '</h3><hr size="1" />'));
     // Get original style user lists
     // $selected_users = array();
     // foreach(unserialize($object->reminder_notify) as $i) {
     // $selected_users[$i] = $db->selectValue('user', 'firstname', 'id='.$i) . ' ' . $db->selectValue('user', 'lastname', 'id='.$i) . ' (' . $db->selectValue('user', 'username', 'id='.$i) . ')';
     // }
     // $userlist = array();
     // $list = user::getAllUsers();
     // foreach ($list as $i) {
     // if(!array_key_exists($i->id, $selected_users)) {
     // $userlist[$i->id] = $i->firstname . ' ' . $i->lastname . ' (' . $i->username . ')';
     // }
     // }
     // $form->register('reminder_notify',gt('Who should be reminded of events?'),new listbuildercontrol($selected_users, $userlist));
     // Get User list
     $defaults = array();
     $userlist = array();
     $users = user::getAllUsers();
     foreach ($db->selectObjects('calendar_reminder_address', 'calendar_id=' . $object->id . ' and user_id != 0') as $address) {
         $locuser = user::getUserById($address->user_id);
         $defaults[$locuser->id] = $locuser->firstname . ' ' . $locuser->lastname . ' (' . $locuser->username . ')';
     }
     foreach ($users as $locuser) {
         if (!array_key_exists($locuser->id, $defaults)) {
             $userlist[$locuser->id] = $locuser->firstname . ' ' . $locuser->lastname . ' (' . $locuser->username . ')';
         }
     }
     $form->register('users', gt('Users'), new listbuildercontrol($defaults, $userlist));
     // Get Group list
     $defaults = array();
     $grouplist = array();
     $groups = group::getAllGroups();
     if ($groups != null) {
         foreach ($db->selectObjects('calendar_reminder_address', 'calendar_id=' . $object->id . ' and group_id != 0') as $address) {
             $group = group::getGroupById($address->group_id);
             $defaults[$group->id] = $group->name;
         }
         foreach ($groups as $group) {
             if (!array_key_exists($group->id, $defaults)) {
                 $grouplist[$group->id] = $group->name;
             }
         }
         $form->register('groups', gt('Groups'), new listbuildercontrol($defaults, $grouplist));
     }
     // Get Freeform list
     $defaults = array();
     foreach ($db->selectObjects('calendar_reminder_address', 'calendar_id=' . $object->id . " and email != ''") as $address) {
         $defaults[$address->email] = $address->email;
     }
     $form->register('addresses', gt('Other Addresses'), new listbuildercontrol($defaults, null));
     $form->register('email_title_reminder', gt('Message Subject Prefix'), new textcontrol($object->email_title_reminder, 45));
     $form->register('email_from_reminder', gt('From (Display)'), new textcontrol($object->email_from_reminder, 45));
     $form->register('email_address_reminder', gt('From (Email)'), new textcontrol($object->email_address_reminder, 45));
     $form->register('email_reply_reminder', gt('Reply-to'), new textcontrol($object->email_reply_reminder, 45));
     $form->register('email_showdetail', gt('Show detail in message?'), new checkboxcontrol($object->email_showdetail));
     $form->register('email_signature', gt('Email Signature'), new texteditorcontrol($object->email_signature, 5, 30));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('Merge Calendars') . '</h3><hr size="1" />'));
     $form->register('aggregate', gt('Pull Events from These Other Calendars'), new listbuildercontrol($selected_calendars, $all_calendars));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('RSS/iCalendar Configuration') . '</h3><hr size="1" />'));
     $form->register('enable_rss', gt('Enable RSS'), new checkboxcontrol($object->enable_rss));
     $form->register('enable_ical', gt('Enable iCalendar'), new checkboxcontrol($object->enable_ical));
     $form->register('feed_title', gt('Title for this RSS feed'), new textcontrol($object->feed_title, 35, false, 75));
     $form->register('feed_desc', gt('Description for this RSS feed'), new texteditorcontrol($object->feed_desc));
     $form->register('rss_cachetime', gt('Recommended RSS/iCal feed update interval in minutes (1440 = 1 day)'), new textcontrol($object->rss_cachetime));
     $form->register('rss_limit', gt('Maximum days of RSS/iCal items to publish (0 = all)'), new textcontrol($object->rss_limit));
     // $form->register(null,'',new htmlcontrol('<h3>'.gt('Tagging').'</h3><hr size="1" />'));
     // $form->register('enable_tags',gt('Enable Tags'), new checkboxcontrol($object->enable_tags));
     // $form->register('collections',gt('Tag Collections'),new listbuildercontrol($object->collections,$tc_list));
     // $form->register('group_by_tags',gt('Filter events by tags'), new checkboxcontrol($object->group_by_tags));
     // $form->register(null,'',new htmlcontrol(gt('Tags to show')));
     // $form->register('show_tags','',new listbuildercontrol($object->show_tags,$available_tags));
     $form->register('submit', '', new buttongroupcontrol(gt('Save'), '', gt('Cancel')));
     return $form;
 }
Пример #30
0
 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);
 }