Beispiel #1
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);
 }
Beispiel #2
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;
Beispiel #3
0
 function show($view, $loc = null, $title = '')
 {
     if (empty($view)) {
         $view = "Default";
     }
     $source_select = array();
     $clickable_mods = null;
     // Show all
     $dest = null;
     $singleview = '_container';
     $singlemodule = 'containermodule';
     if (expSession::is_set('source_select') && defined('SELECTOR')) {
         $source_select = expSession::get('source_select');
         $singleview = $source_select['view'];
         $singlemodule = $source_select['module'];
         $clickable_mods = $source_select['showmodules'];
         if (!is_array($clickable_mods)) {
             $clickable_mods = null;
         }
         $dest = $source_select['dest'];
     }
     global $db, $user;
     $container = null;
     $container_key = serialize($loc);
     $cache = expSession::getCacheValue('containermodule');
     if (!isset($this) || !isset($this->_hasParent) || $this->_hasParent == 0) {
         // Top level container.
         if (!isset($cache['top'][$container_key])) {
             $container = $db->selectObject('container', "external='" . serialize(null) . "' AND internal='" . $container_key . "'");
             //if container isn't here already, then create it.
             if ($container == null) {
                 $container->external = serialize(null);
                 $container->internal = serialize($loc);
                 $container->view = $view;
                 $container->title = $title;
                 $container->id = $db->insertObject($container, 'container');
             }
             $cache['top'][$container_key] = $container;
             expSession::setCacheValue('containermodule', $cache);
         } else {
             $container = $cache['top'][$container_key];
         }
         if (!defined('PREVIEW_READONLY') || defined('SELECTOR')) {
             $view = empty($container->view) ? $view : $container->view;
         }
         $title = $container->title;
     }
     $template = new template('containermodule', $view, $loc, $cache);
     if ($dest) {
         $template->assign('dest', $dest);
     }
     $template->assign('singleview', $singleview);
     $template->assign('singlemodule', $singlemodule);
     $template->assign('top', $container);
     $containers = array();
     if (!isset($cache[$container_key])) {
         foreach ($db->selectObjects('container', "external='" . $container_key . "'") as $c) {
             if ($c->is_private == 0 || expPermissions::check('view', expCore::makeLocation($loc->mod, $loc->src, $c->id))) {
                 $containers[$c->rank] = $c;
             }
         }
         $cache[$container_key] = $containers;
         expSession::setCacheValue('containermodule', $cache);
     } else {
         $containers = $cache[$container_key];
     }
     ksort($containers);
     foreach (array_keys($containers) as $i) {
         $location = unserialize($containers[$i]->internal);
         // check to see if this is a controller or module
         $iscontroller = expModules::controllerExists($location->mod);
         $modclass = $iscontroller ? expModules::getControllerClassName($location->mod) : $location->mod;
         if (class_exists($modclass)) {
             $mod = new $modclass();
             ob_start();
             $mod->_hasParent = 1;
             if ($iscontroller) {
                 renderAction(array('controller' => $location->mod, 'action' => $containers[$i]->action, 'src' => $location->src, 'view' => $containers[$i]->view, 'moduletitle' => $containers[$i]->title));
             } else {
                 $mod->show($containers[$i]->view, $location, $containers[$i]->title);
             }
             $containers[$i]->output = trim(ob_get_contents());
             ob_end_clean();
             $containers[$i]->info = array('module' => $mod->name(), 'source' => $location->src, 'hasContent' => $mod->hasContent(), 'hasSources' => $mod->hasSources(), 'hasViews' => $mod->hasViews(), 'class' => $modclass, 'supportsWorkflow' => $mod->supportsWorkflow() ? 1 : 0, 'workflowPolicy' => '', 'workflowUsesDefault' => 0, 'clickable' => $clickable_mods == null || in_array($modclass, $clickable_mods), 'hasConfig' => $db->tableExists($modclass . "_config"));
         } else {
             $containers[$i]->output = sprintf(gt('The module "%s" was not found in the system'), $location->mod);
             $containers[$i]->info = array('module' => sprintf(gt('Unknown: %s'), $location->mod), 'source' => $location->src, 'hasContent' => 0, 'hasSources' => 0, 'hasViews' => 0, 'class' => $modclass, 'supportsWorkflow' => 0, 'workflowPolicy' => '', 'workflowUsesDefault' => 0, 'hasConfig' => $db->tableExists($modclass . "_config"), 'clickable' => 0);
         }
         $containers[$i]->moduleLocation = $location;
         $cloc = null;
         $cloc->mod = $loc->mod;
         $cloc->src = $loc->src;
         $cloc->int = $containers[$i]->id;
         $location->mod = str_replace('Controller', '', $location->mod);
         $containers[$i]->permissions = array('administrate' => expPermissions::check('administrate', $location) ? 1 : 0, 'configure' => expPermissions::check('configure', $location) ? 1 : 0);
     }
     $template->assign('user', $user);
     $template->assign('containers', $containers);
     $template->assign('hasParent', isset($this) && isset($this->_hasParent) ? 1 : 0);
     $template->register_permissions(array('administrate', 'add_module', 'edit_module', 'delete_module', 'order_modules'), $loc);
     $template->output();
 }
Beispiel #4
0
 /**
  * Entry point for displaying modules
  * Packages $params for calling showModule method
  *
  * @param array $params list of module parameters
  *
  * @return bool
  */
 public static function module($params)
 {
     global $db, $module_scope, $sectionObj;
     if (empty($params)) {
         return false;
     } elseif (isset($params['controller'])) {
         //            self::showController($params);
         //FIXME change to showModule call?
         $params['view'] = isset($params['view']) ? $params['view'] : $params['action'];
         $params['title'] = isset($params['moduletitle']) ? $params['moduletitle'] : '';
         $params['chrome'] = !isset($params['chrome']) || isset($params['chrome']) && empty($params['chrome']) ? true : false;
         $params['scope'] = isset($params['scope']) ? $params['scope'] : 'global';
         // set the controller and action to the one called via the function params
         $requestvars = isset($params['params']) ? $params['params'] : array();
         $requestvars['controller'] = $params['controller'];
         $requestvars['action'] = isset($params['action']) ? $params['action'] : null;
         $requestvars['view'] = isset($params['view']) ? $params['view'] : null;
         // figure out the scope of the module and set the source accordingly
         if ($params['scope'] == 'global') {
             $params['source'] = isset($params['source']) ? $params['source'] : null;
         } elseif ($params['scope'] == 'sectional') {
             $params['source'] = isset($params['source']) ? $params['source'] : '@section';
             $params['source'] .= $sectionObj->id;
         } elseif ($params['scope'] == 'top-sectional') {
             $params['source'] = isset($params['source']) ? $params['source'] : '@section';
             $section = $sectionObj;
             while ($section->parent > 0) {
                 $section = $db->selectObject("section", "id=" . $section->parent);
             }
             $params['source'] .= $section->id;
         }
         $module_scope[$params['source']][isset($params['module']) ? $params['module'] : $params['controller']]->scope = $params['scope'];
         self::showModule(expModules::getControllerClassName($params['controller']), $params['view'], $params['title'], $params['source'], false, null, $params['chrome'], $requestvars);
     } elseif (isset($params['module'])) {
         $moduletitle = isset($params['moduletitle']) ? $params['moduletitle'] : "";
         $source = isset($params['source']) ? $params['source'] : "";
         $chrome = isset($params['chrome']) ? $params['chrome'] : false;
         $scope = isset($params['scope']) ? $params['scope'] : "global";
         if ($scope == "global") {
             self::showModule($params['module'] . "module", $params['view'], $moduletitle, $source, false, null, $chrome);
         }
         if ($scope == "top-sectional") {
             //                self::showTopSectionalModule($params['module']."module", //module
             //                                             $params['view'], //view
             //                                             $moduletitle, // Title
             //                                             $source, // source
             //                                             false, // used to apply to source picker. does nothing now.
             //                                             $chrome // Show chrome
             //                                            );
             //FIXME change to showModule call
             if ($source == null) {
                 $source = "@section";
             }
             $last_section = expSession::get("last_section");
             $section = $db->selectObject("section", "id=" . $last_section);
             // Loop until we find the top level parent.
             while ($section->parent != 0) {
                 $section = $db->selectObject("section", "id=" . $section->parent);
             }
             $module_scope[$source . $section->id][$params['module'] . "module"]->scope = 'top-sectional';
             self::showModule($params['module'] . "module", $params['view'], $moduletitle, $source . $section->id, false, $section, $chrome);
         }
         if ($scope == "sectional") {
             //                self::showSectionalModule($params['module']."module", //module
             //                                          $params['view'], //view
             //                                          $moduletitle, // title
             //                                          $source, // source/prefix
             //                                          false, // used to apply to source picker. does nothing now.
             //                                          $chrome // Show chrome
             //                                        );
             //FIXME change to showModule call
             if ($source == null) {
                 $source = "@section";
             }
             $src = $source;
             $src .= $sectionObj->id;
             $module_scope[$src][$params['module'] . "module"]->scope = 'sectional';
             self::showModule($params['module'] . "module", $params['view'], $moduletitle, $src, false, $sectionObj->id, $chrome);
         }
     } else {
         return false;
     }
 }
Beispiel #5
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;
 }
Beispiel #6
0
 static function spiderContent($item = null)
 {
     global $db;
     //global $sections;
     global $router;
     $db->delete('search', "ref_module='navigationmodule' AND ref_type='section'");
     // this now ensures we get internal pages, instead of relying on the global $sections, which does not.
     $sections = $db->selectObjects('section', '1');
     foreach ($sections as $section) {
         $search = null;
         $search->category = 'Webpages';
         $search->ref_module = 'navigationmodule';
         $search->ref_type = 'section';
         $search->original_id = $section->id;
         $search->title = $section->name;
         //$search->view_link = $router->buildUrlByPageId($section->id);
         $link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));
         $search->view_link = $link;
         $search->body = $section->description;
         $search->keywords = $section->keywords;
         // now we're going to grab all the textmodules on this page and build the body for the page based off the content
         // of all the text module added together.
         $modnames = array('text', 'textController');
         foreach ($modnames as $mod) {
             $loc->mod = expModules::getControllerName($mod);
             $controllername = expModules::getControllerClassName($mod);
             foreach ($db->selectObjects('sectionref', "module='" . $controllername . "' AND section=" . $section->id) as $module) {
                 $loc->src = $module->source;
                 $loc->int = '';
                 $controller = new $controllername();
                 $textitems = $db->selectObjects($controller->model_table, "location_data='" . serialize($loc) . "'");
                 foreach ($textitems as $textitem) {
                     if (!empty($textitem)) {
                         $search->body .= ' ' . search::removeHTML($textitem->body) . ' ';
                         $search->keywords .= " " . $textitem->title;
                     }
                 }
             }
         }
         $db->insertObject($search, 'search');
     }
     return true;
 }
Beispiel #7
0
 public static function controllerExists($controllername = '')
 {
     global $available_controllers;
     // make sure the name is in the right format
     $controllername = expModules::getControllerClassName($controllername);
     // check for module based controllers
     if (array_key_exists($controllername, $available_controllers)) {
         if (is_readable($available_controllers[$controllername])) {
             return true;
         }
     } else {
         // check for core controllers
         if (is_readable(BASE . 'framework/core/controllers/' . expModules::getControllerClassName($controllername) . '.php')) {
             return true;
         }
     }
     // if we got here we didn't find any controllers matching the name
     return false;
 }
Beispiel #8
0
function get_action_views($ctl, $action, $human_readable)
{
    // setup the controller
    $controllerName = expModules::getControllerClassName($ctl);
    $controller = new $controllerName();
    // set path information
    //$basepath = $controller->viewpath;
    //$themepath = BASE.'themes/'.DISPLAY_THEME_REAL.'/modules/'.$controller->relative_viewpath;
    $paths = array($controller->viewpath, BASE . 'themes/' . DISPLAY_THEME . '/modules/' . $controller->relative_viewpath);
    $views = array();
    foreach ($paths as $path) {
        if (is_readable($path)) {
            $dh = opendir($path);
            while (($file = readdir($dh)) !== false) {
                if (is_readable($path . '/' . $file) && substr($file, -4) == '.tpl') {
                    $filename = substr($file, 0, -4);
                    $fileparts = explode('_', $filename);
                    if ($fileparts[0] == $action) {
                        if (count($fileparts) == 1) {
                            $views[$filename] = 'Default';
                        } else {
                            $diplayname = array_shift($fileparts);
                            //shift the action name off the array of words
                            $views[$filename] = ucwords(implode(' ', $fileparts));
                        }
                    }
                }
            }
        }
    }
    return $views;
}