/** * 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; }
################################################## # # Copyright (c) 2004-2011 OIC Group, Inc. # Written and Designed by James Hunt # # This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } $f = $db->selectObject('formbuilder_form', 'id=' . intval($_GET['form_id'])); if ($f) { if (expPermissions::check('deletedata', unserialize($f->location_data))) { $db->delete('formbuilder_' . $f->table_name, 'id=' . intval($_GET['id'])); // expHistory::back(); expHistory::returnTo('editable'); } else { echo SITE_403_HTML; } } else { echo SITE_404_HTML; }
} $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; } } } $users[] = $u; } $p[gt("User Name")] = 'username'; $p[gt("First Name")] = 'firstname'; $p[gt("Last Name")] = 'lastname'; foreach ($mod->permissions() as $key => $value) { $p[gt($value)] = $key; } if (SEF_URLS == 1) {
# # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## // Part of the Extensions category if (!defined('EXPONENT')) { exit(''); } global $router; if (expPermissions::check('extensions', expCore::makeLocation('administrationmodule'))) { // expHistory::flowSet(SYS_FLOW_PROTECTED,SYS_FLOW_ACTION); expHistory::set('manageable', $router->params); // get new bots into the database if (is_readable(BASE . 'framework/modules-1/bots/bots')) { $dh = opendir(BASE . 'framework/modules-1/bots/bots'); while (($file = readdir($dh)) !== false) { $botfile = BASE . 'framework/modules-1/bots/bots/' . $file; if (is_file($botfile) && is_readable($botfile) && substr($file, -4) == '.php') { include_once $botfile; $botname = substr($file, 0, -4); $bot = $db->selectObject('bots', "name='" . $botname . "'"); if (empty($bot)) { $botobj = new $botname(); $bot = null; $bot->name = $botname;
$old_parent = null; if (isset($_POST['id'])) { // Saving an existing content page. Read it from the database. $section = $db->selectObject('section', 'id=' . intval($_POST['id'])); if ($section) { $old_parent = $section->parent; $check_id = $section->id; } } echo $old_parent; // Update the section from the _POST data. $section = section::update($_POST, $section); if ($check_id == -1) { $check_id = $section->parent; } if ($check_id != -1 && expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $check_id))) { // make sure the SEF name is valid global $router; if (empty($section->sef_name)) { $section->sef_name = $router->encode($section->name); } if (!section::isValidName($section->sef_name)) { expValidator::failAndReturnToForm('You have invalid characters in the SEF Name field.'); } if (section::isDuplicateName($section)) { expValidator::failAndReturnToForm(gt('The name specified in the SEF Name field is a duplicate of an existing page.')); } if (isset($section->id)) { if ($section->parent != $old_parent) { // Old_parent id was different than the new parent id. Need to decrement the ranks // of the old children (after ours), and then add
# 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # # $Id: save_question.php,v 1.1 2005/04/10 23:24:02 filetreefrog Exp $ ################################################## if (!defined('EXPONENT')) { exit(''); } $question = null; if (isset($_POST['id'])) { $question = $db->selectObject('poll_question', 'id=' . $_POST['id']); if ($question) { $loc = unserialize($question->location_data); } } if (expPermissions::check('manage_question', $loc)) { $question = poll_question::update($_POST, $question); $question->location_data = serialize($loc); if ($db->countObjects('poll_question', "location_data='" . $question->location_data . "'") == 0) { $question->is_active = 1; } if (isset($question->id)) { $db->updateObject($question, 'poll_question'); } else { $db->insertObject($question, 'poll_question'); } expHistory::back(); } else { echo SITE_403_HTML; }
} $template->assign('user_form', 0); $users = array(); // users = groups $modulename = expModules::controllerExists($loc->mod) ? expModules::getControllerClassName($loc->mod) : $loc->mod; //$modclass = $loc->mod; $modclass = $modulename; $mod = new $modclass(); $perms = $mod->permissions($loc->int); foreach (group::getAllGroups() as $g) { foreach ($perms as $perm => $name) { $var = 'perms_' . $perm; if (expPermissions::checkGroup($g, $perm, $loc, true)) { $g->{$perm} = 1; } else { if (expPermissions::checkGroup($g, $perm, $loc)) { $g->{$perm} = 2; } else { $g->{$perm} = 0; } } } $users[] = $g; } $p[gt("Group")] = 'username'; foreach ($mod->permissions() as $key => $value) { $p[gt($value)] = $key; } if (SEF_URLS == 1) { $page = new expPaginator(array('limit' => isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 20, 'controller' => $router->params['controller'], 'action' => $router->params['action'], 'records' => $users, 'order' => 'name', 'dir' => 'ASC', 'columns' => $p)); } else {
# You should have received a copy of the GNU # General Public License along with Exponent; if # not, write to: # # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # # $Id: order_switch.php,v 1.1 2005/04/10 23:24:02 filetreefrog Exp $ ################################################## if (!defined('EXPONENT')) { exit(''); } $question = null; if (isset($_GET['qid'])) { $question = $db->selectObject('poll_question', 'id=' . $_GET['qid']); if ($question) { $loc = unserialize($question->location_data); } } if ($question) { if (expPermissions::check('manage_answer', $loc)) { $db->switchValues('poll_answer', 'rank', $_GET['a'], $_GET['b'], 'question_id=' . $question->id); expHistory::back(); } else { echo SITE_403_HTML; } } else { echo SITE_404_HTML; }
public function update_memberships() { global $user, $db; //$memb = $db->selectObject('groupmembership','member_id='.$user->id.' AND group_id='.$this->params['id'].' AND is_admin=1'); $group = $db->selectObject('group', 'id=' . intval($this->params['id'])); $db->delete('groupmembership', 'group_id=' . $group->id); $memb = null; $memb->group_id = $group->id; if ($this->params['memdata'] != "") { foreach ($this->params['memdata'] as $u => $str) { $memb->member_id = $u; $memb->is_admin = $str['is_admin']; $db->insertObject($memb, 'groupmembership'); } } expPermissions::triggerRefresh(); expHistory::back(); }
# This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } global $router, $section; if (expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $section))) { global $user; expHistory::set('manageable', $router->params); $template = new template('navigationmodule', '_manager', $loc); $template->assign('sections', navigationmodule::levelTemplate(0, 0)); // Templates $template->assign('canManageStandalones', navigationmodule::canManageStandalones()); $template->assign('user', $user); $template->assign('canManagePagesets', $user->isAdmin()); $tpls = $db->selectObjects('section_template', 'parent=0'); $template->assign('templates', $tpls); $template->output(); } else { flash('error', SITE_403_HTML); expHistory::back(); }
# it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } $iloc = expCore::makeLocation($_GET['m'], @$_GET['s'], @$_GET['i']); // Make sure that secref refcount is indeed 0. $secref = $db->selectObject("sectionref", "module='" . $iloc->mod . "' AND source='" . $iloc->src . "' AND internal='" . $iloc->int . "'"); if ($secref && $secref->refcount == 0 && expPermissions::check("administrate", $iloc)) { // delete in location. $modclass = $iloc->mod; expSession::clearAllUsersSessionCache('containermodule'); expSession::clearAllUsersSessionCache($iloc); //FIXME: more module/controller glue code if (expModules::controllerExists($modclass)) { $mod = new $modclass($iloc->src); $mod->delete_instance(); } else { $mod = new $modclass(); $mod->deleteIn($iloc); } $db->delete("sectionref", "module='" . $iloc->mod . "' AND source='" . $iloc->src . "' AND internal='" . $iloc->int . "'"); expPermissions::revokeComplete($iloc); } expHistory::back();
# # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } $item = $db->selectObject('calendar', 'id=' . intval($_GET['id'])); if ($item) { $loc = unserialize($item->location_data); $iloc = expCore::makeLocation($loc->mod, $loc->src, $item->id); if (expPermissions::check('delete', $loc) || expPermissions::check('delete', $iloc)) { $db->delete('calendar', 'id=' . $item->id); $db->delete('eventdate', 'event_id=' . $item->id); $db->delete("calendar_wf_info", "real_id=" . $_GET['id']); $db->delete("calendar_revision", "wf_original=" . $_GET['id']); //Delete search entries $db->delete('search', "ref_module='calendarmodule' AND ref_type='calendar' AND original_id=" . $item->id); expHistory::back(); } else { echo SITE_403_HTML; } } else { echo SITE_404_HTML; }
if (!defined('EXPONENT')) { exit(''); } $container = null; $iloc = null; $cloc = null; if (isset($_POST['id'])) { $container = $db->selectObject("container", "id=" . intval($_POST['id'])); } if ($container != null) { $iloc = unserialize($container->internal); $loc = unserialize($container->external); $cloc = unserialize($container->external); $cloc->int = $container->id; } if (expPermissions::check("add_module", $loc) || $iloc != null && expPermissions::check("administrate", $iloc) || $cloc != null && expPermissions::check("edit_module", $cloc)) { //eDebug($_POST,true); $container = container::update($_POST, $container, $loc); if (isset($container->id)) { $db->updateObject($container, "container"); } else { $db->insertObject($container, "container"); } if ($container->is_existing == 0) { $iloc = unserialize($container->internal); $secref = $db->selectObject("sectionref", "module='" . $iloc->mod . "' AND source='" . $iloc->src . "'"); $secref->description = isset($_POST['description']) ? $_POST['description'] : ''; $db->updateObject($secref, "sectionref", "module='" . $iloc->mod . "' AND source='" . $iloc->src . "'"); } define('SOURCE_SELECTOR', 0); define('PREVIEW_READONLY', 0);
# Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## /** @define "BASE" "../../.." */ if (!defined('EXPONENT')) { exit(''); } $f1_loc = expCore::makeLocation($_GET['sm'], $_GET['ss']); $f1 = $db->selectObject("formbuilder_form", "location_data='" . serialize($f1_loc) . "'"); $f2_loc = expCore::makeLocation($_GET['m'], $_GET['s']); $f2 = $db->selectObject("formbuilder_form", "location_data='" . serialize($f2_loc) . "'"); if ($f1 && $f2) { if (expPermissions::check("editform", unserialize($f2->location_data))) { $controls = $db->selectObjects("formbuilder_control", "form_id=" . $f1->id); $controls = expSorter::sort(array('array' => $controls, 'sortby' => 'rank', 'order' => 'ASC')); foreach ($controls as $control) { $count = 0; $name = $control->name; $rank = $db->max("formbuilder_control", "rank", "form_id", "form_id=" . $f2->id); //insure that we have a unique name; while ($db->countObjects("formbuilder_control", "form_id=" . $f2->id . " and name='" . $name . "'")) { $count++; $name = $control->name . $count; } $control->name = $name; unset($control->id); $control->rank = ++$rank; $control->form_id = $f2->id;
//eDebug($value); $varname = $c->name; $db_data->{$varname} = $value; // $fields[$c->name] = call_user_func(array($control_type,'templateFormat'),$value,$ctl); // $emailFields[$c->name] = call_user_func(array($control_type,'templateFormat'),$emailValue,$ctl); $emailFields[$c->name] = call_user_func(array($control_type, 'templateFormat'), $value, $ctl); $captions[$c->name] = $c->caption; if ($c->name == "email") { $from = $value; } if ($c->name == "name") { $from_name = $value; } } } if (!isset($_POST['data_id']) || isset($_POST['data_id']) && expPermissions::check("editdata", unserialize($f->location_data))) { if ($f->is_saved == 1) { if (isset($_POST['data_id'])) { //if this is an edit we remove the record and insert a new one. $olddata = $db->selectObject('formbuilder_' . $f->table_name, 'id=' . intval($_POST['data_id'])); $db_data->ip = $olddata->ip; $db_data->user_id = $olddata->user_id; $db_data->timestamp = $olddata->timestamp; $db->delete('formbuilder_' . $f->table_name, 'id=' . intval($_POST['data_id'])); } else { $db_data->ip = $_SERVER['REMOTE_ADDR']; if (expSession::loggedIn()) { $db_data->user_id = $user->id; $from = $user->email; $from_name = $user->firstname . " " . $user->lastname . " (" . $user->username . ")"; } else {
################################################## # # Copyright (c) 2004-2011 OIC Group, Inc. # Written and Designed by James Hunt # # This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } if (expPermissions::check('database', expCore::makeLocation('administrationmodule'))) { $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 'start'; $exporter = isset($_REQUEST['exporter']) ? $_REQUEST['exporter'] : ''; $file = BASE . 'framework/modules-1/exporter/exporters/' . $exporter . '/' . $page . '.php'; if ($exporter != '' && is_readable($file) && is_file($file)) { include $file; } else { echo SITE_404_HTML; } } else { echo SITE_403_HTML; }
$iloc = null; if (isset($_GET['id'])) { $item = $db->selectObject('calendar', 'id=' . intval($_GET['id'])); if ($item) { if (isset($_GET['date_id'])) { $item->eventdate = $db->selectObject('eventdate', 'id=' . intval($_GET['date_id'])); } else { $item->eventdate = $db->selectObject('eventdate', 'event_id=' . $item->id); } $item->eventstart += $item->eventdate->date; $item->eventend += $item->eventdate->date; $loc = unserialize($item->location_data); $iloc = expCore::makeLocation($loc->mod, $loc->src, $item->id); } } if ($item == null && expPermissions::check('post', $loc) || $item != null && expPermissions::check('edit', $loc) || $iloc != null && expPermissions::check('edit', $iloc)) { $form = calendar::form($item); $form->meta('action', 'save'); $form->location($loc); $config = $db->selectObject('calendarmodule_config', "location_data='" . serialize($loc) . "'"); if (!$config) { $config->enable_categories = 0; $config->enable_feedback = 0; } // if (isset($config->enable_tags)) { // $cols = array(); // $tags = array(); // $cols = unserialize($config->collections); // if (count($cols) > 0) { // foreach ($cols as $col) { // $available_tags = array();
public static function login($user) { $ticket = self::getTicketString(); if (!isset($ticket)) { $ticket = self::createTicket($user); } $_SESSION[SYS_SESSION_KEY]['user'] = $user; self::updateTicket($ticket, $user); expPermissions::load($user); }
/** 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); } } }
static function show($view, $loc = null, $title = '') { global $user; global $db; $locsql = "(location_data='" . serialize($loc) . "'"; $config = $db->selectObject("calendarmodule_config", "location_data='" . serialize($loc) . "'"); if (!empty($config->aggregate)) { $locations = unserialize($config->aggregate); foreach ($locations as $source) { $tmploc = null; $tmploc->mod = 'calendarmodule'; $tmploc->src = $source; $tmploc->int = ''; $locsql .= " OR location_data='" . serialize($tmploc) . "'"; } } $locsql .= ')'; $template = new template('calendarmodule', $view, $loc); if ($title == '') { $title = $db->selectValue('container', 'title', "internal='" . serialize($loc) . "'"); } $template->assign('moduletitle', $title); $canviewapproval = false; $inapproval = false; global $user; if ($user) { $canviewapproval = expPermissions::check("approve", $loc) || expPermissions::check("manage_approval", $loc); } if ($db->countObjects("calendar", "location_data='" . serialize($loc) . "' AND approved!=1")) { foreach ($db->selectObjects("calendar", "location_data='" . serialize($loc) . "' AND approved!=1") as $c) { if ($c->poster == $user->id) { $canviewapproval = true; } } $inapproval = true; } $time = isset($_GET['time']) ? $_GET['time'] : time(); $template->assign("time", $time); $viewparams = $template->viewparams; if ($viewparams === null) { $viewparams = array("type" => "default"); } if ($viewparams['type'] == "minical") { $monthly = expDateTime::monthlyDaysTimestamp($time); $info = getdate($time); $timefirst = mktime(12, 0, 0, $info['mon'], 1, $info['year']); $now = getdate(time()); $currentday = $now['mday']; $endofmonth = date('t', $time); foreach ($monthly as $weekNum => $week) { foreach ($week as $dayNum => $day) { if ($dayNum == $now['mday']) { $currentweek = $weekNum; } if ($dayNum <= $endofmonth) { $monthly[$weekNum][$dayNum]['number'] = $monthly[$weekNum][$dayNum]['ts'] != -1 ? $db->countObjects("eventdate", $locsql . " AND date = " . $day['ts']) : -1; } } } //eDebug($monthly); $template->assign("monthly", $monthly); $template->assign("currentweek", $currentweek); $template->assign("currentday", $currentday); $template->assign("now", $timefirst); $prevmonth = mktime(0, 0, 0, date("m", $timefirst) - 1, date("d", $timefirst) + 10, date("Y", $timefirst)); $nextmonth = mktime(0, 0, 0, date("m", $timefirst) + 1, date("d", $timefirst) + 10, date("Y", $timefirst)); $template->assign("prevmonth", $prevmonth); $template->assign("thismonth", $timefirst); $template->assign("nextmonth", $nextmonth); } else { if ($viewparams['type'] == "byday") { // Remember this is the code for weekly view and monthly listview // Test your fixes on both views before submitting your changes to cvs $startperiod = 0; $totaldays = 0; if ($viewparams['range'] == "week") { $startperiod = expDateTime::startOfWeekTimestamp($time); $totaldays = 7; $template->assign("prev_timestamp3", strtotime('-21 days', $startperiod)); $template->assign("prev_timestamp2", strtotime('-14 days', $startperiod)); $template->assign("prev_timestamp", strtotime('-7 days', $startperiod)); $template->assign("next_timestamp", strtotime('+7 days', $startperiod)); $template->assign("next_timestamp2", strtotime('+14 days', $startperiod)); $template->assign("next_timestamp3", strtotime('+21 days', $startperiod)); } else { if ($viewparams['range'] == "twoweek") { $time = time(); $startperiod = expDateTime::startOfWeekTimestamp($time); $totaldays = 14; $template->assign("prev_timestamp3", strtotime('-42 days', $startperiod)); $template->assign("prev_timestamp2", strtotime('-28 days', $startperiod)); $template->assign("prev_timestamp", strtotime('-14 days', $startperiod)); $template->assign("next_timestamp", strtotime('+14 days', $startperiod)); $template->assign("next_timestamp2", strtotime('+28 days', $startperiod)); $template->assign("next_timestamp3", strtotime('+42 days', $startperiod)); } else { // range = month $startperiod = expDateTime::startOfMonthTimestamp($time); $totaldays = date('t', $time); $template->assign("prev_timestamp3", strtotime('-3 months', $startperiod)); $template->assign("prev_timestamp2", strtotime('-2 months', $startperiod)); $template->assign("prev_timestamp", strtotime('-1 months', $startperiod)); $template->assign("next_timestamp", strtotime('+1 months', $startperiod)); $template->assign("next_timestamp2", strtotime('+2 months', $startperiod)); $template->assign("next_timestamp3", strtotime('+3 months', $startperiod)); } } $days = array(); // added per Ignacio $endofmonth = date('t', $time); for ($i = 1; $i <= $totaldays; $i++) { $info = getdate($time); if ($viewparams['range'] == "week") { $start = mktime(12, 0, 0, $info['mon'], $i, $info['year']); } else { if ($viewparams['range'] == "twoweek") { $start = mktime(12, 0, 0, $info['mon'], $info['mday'] + ($i - 1), $info['year']); // $start = $startperiod + ($i*86400); } else { // range = month $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']); } } $edates = $db->selectObjects("eventdate", $locsql . " AND date = '" . $start . "'"); $days[$start] = calendarmodule::_getEventsForDates($edates); for ($j = 0; $j < count($days[$start]); $j++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $days[$start][$j]->id); $days[$start][$j]->permissions = array("administrate" => expPermissions::check("administrate", $thisloc) || expPermissions::check("administrate", $loc), "edit" => expPermissions::check("edit", $thisloc) || expPermissions::check("edit", $loc), "delete" => expPermissions::check("delete", $thisloc) || expPermissions::check("delete", $loc)); } $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC')); } $template->assign("days", $days); } else { if ($viewparams['type'] == "monthly") { $monthly = array(); $counts = array(); $info = getdate($time); $nowinfo = getdate(time()); if ($info['mon'] != $nowinfo['mon']) { $nowinfo['mday'] = -10; } // Grab non-day numbers only (before end of month) $week = 0; $currentweek = -1; $timefirst = mktime(12, 0, 0, $info['mon'], 1, $info['year']); $infofirst = getdate($timefirst); $monthly[$week] = array(); // initialize for non days $counts[$week] = array(); if ($infofirst['wday'] == 0 && DISPLAY_START_OF_WEEK == 1) { for ($i = -6; $i < 1 - DISPLAY_START_OF_WEEK; $i++) { $monthly[$week][$i] = array(); $counts[$week][$i] = -1; } $weekday = $infofirst['wday'] + 7; // day number in grid. if 7+, switch weeks } else { for ($i = 1 - $infofirst['wday']; $i < 1 - DISPLAY_START_OF_WEEK; $i++) { $monthly[$week][$i] = array(); $counts[$week][$i] = -1; } $weekday = $infofirst['wday']; // day number in grid. if 7+, switch weeks } // Grab day counts (deprecated, handled by the date function) // $endofmonth = expDateTime::endOfMonthDay($time); $endofmonth = date('t', $time); for ($i = 1; $i <= $endofmonth; $i++) { $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']); if ($i == $nowinfo['mday']) { $currentweek = $week; } #$monthly[$week][$i] = $db->selectObjects("calendar","location_data='".serialize($loc)."' AND (eventstart >= $start AND eventend <= " . ($start+86399) . ") AND approved!=0"); //$dates = $db->selectObjects("eventdate",$locsql." AND date = $start"); $dates = $db->selectObjects("eventdate", $locsql . " AND date = '" . $start . "'"); $monthly[$week][$i] = calendarmodule::_getEventsForDates($dates); $counts[$week][$i] = count($monthly[$week][$i]); if ($weekday >= 6 + DISPLAY_START_OF_WEEK) { $week++; $monthly[$week] = array(); // allocate an array for the next week $counts[$week] = array(); $weekday = DISPLAY_START_OF_WEEK; } else { $weekday++; } } // Grab non-day numbers only (after end of month) for ($i = 1; $weekday && $i < 8 + DISPLAY_START_OF_WEEK - $weekday; $i++) { $monthly[$week][$i + $endofmonth] = array(); $counts[$week][$i + $endofmonth] = -1; } //eDebug($monthly); $template->assign("currentweek", $currentweek); $template->assign("monthly", $monthly); $template->assign("counts", $counts); $template->assign("prevmonth3", strtotime('-3 months', $timefirst)); $template->assign("prevmonth2", strtotime('-2 months', $timefirst)); $template->assign("prevmonth", strtotime('-1 months', $timefirst)); $template->assign("nextmonth", strtotime('+1 months', $timefirst)); $template->assign("nextmonth2", strtotime('+2 months', $timefirst)); $template->assign("nextmonth3", strtotime('+3 months', $timefirst)); $template->assign("now", $timefirst); $template->assign("today", strtotime('today') - 43200); } else { if ($viewparams['type'] == "administration") { // Check perms and return if cant view if ($viewparams['type'] == "administration" && !$user) { return; } $continue = expPermissions::check("administrate", $loc) || expPermissions::check("post", $loc) || expPermissions::check("edit", $loc) || expPermissions::check("delete", $loc) || expPermissions::check("approve", $loc) || expPermissions::check("manage_approval", $loc) ? 1 : 0; $dates = $db->selectObjects("eventdate", $locsql . " AND date >= '" . expDateTime::startOfDayTimestamp(time()) . "'"); $items = calendarmodule::_getEventsForDates($dates); if (!$continue) { foreach ($items as $i) { $iloc = expCore::makeLocation($loc->mod, $loc->src, $i->id); if (expPermissions::check("edit", $iloc) || expPermissions::check("delete", $iloc) || expPermissions::check("administrate", $iloc)) { $continue = true; } } } if (!$continue) { return; } for ($i = 0; $i < count($items); $i++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array("administrate" => expPermissions::check("administrate", $thisloc) || expPermissions::check("administrate", $loc), "edit" => expPermissions::check("edit", $thisloc) || expPermissions::check("edit", $loc), "delete" => expPermissions::check("delete", $thisloc) || expPermissions::check("delete", $loc)); } $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC')); $template->assign("items", $items); } else { if ($viewparams['type'] == "default") { if (!isset($viewparams['range'])) { $viewparams['range'] = "all"; } $items = null; $dates = null; $day = expDateTime::startOfDayTimestamp(time()); $sort_asc = true; // For the getEventsForDates call $moreevents = false; switch ($viewparams['range']) { case "all": $dates = $db->selectObjects("eventdate", $locsql); break; case "upcoming": if (!empty($config->rss_limit) && $config->rss_limit > 0) { $eventlimit = " AND date <= " . ($day + $config->rss_limit * 86400); } else { $eventlimit = ""; } $dates = $db->selectObjects("eventdate", $locsql . " AND date >= " . $day . $eventlimit . " ORDER BY date ASC "); // $moreevents = count($dates) < $db->countObjects("eventdate",$locsql." AND date >= $day"); break; case "past": $dates = $db->selectObjects("eventdate", $locsql . " AND date < {$day} ORDER BY date DESC "); // $moreevents = count($dates) < $db->countObjects("eventdate",$locsql." AND date < $day"); $sort_asc = false; break; case "today": $dates = $db->selectObjects("eventdate", $locsql . " AND date = {$day}"); break; case "next": $dates = array($db->selectObject("eventdate", $locsql . " AND date >= {$day}")); break; case "month": $dates = $db->selectObjects("eventdate", $locsql . " AND date >= " . expDateTime::startOfMonthTimestamp(time()) . " AND date <= " . expDateTime::endOfMonthTimestamp(time())); break; } $items = calendarmodule::_getEventsForDates($dates, $sort_asc, isset($template->viewconfig['featured_only']) ? true : false); // Upcoming events can be configured to show a specific number of events. // The previous call gets all events in the future from today // If configured, cut the array to the configured number of events // if ($template->viewconfig['num_events']) { // switch ($viewparams['range']) { // case "upcoming": // case "past": // $moreevents = $template->viewconfig['num_events'] < count($items); // break; // } // $items = array_slice($items, 0, $template->viewconfig['num_events']); //eDebug($items); // } for ($i = 0; $i < count($items); $i++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array('administrate' => expPermissions::check('administrate', $thisloc) || expPermissions::check('administrate', $loc), 'edit' => expPermissions::check('edit', $thisloc) || expPermissions::check('edit', $loc), 'delete' => expPermissions::check('delete', $thisloc) || expPermissions::check('delete', $loc)); } //Get the image file if there is one. // for ($i = 0; $i < count($items); $i++) { // if (isset($items[$i]->file_id) && $items[$i]->file_id > 0) { // $file = $db->selectObject('file', 'id='.$items[$i]->file_id); // $items[$i]->image_path = $file->directory.'/'.$file->filename; // } // } //eDebug($items); $template->assign('items', $items); $template->assign('moreevents', $moreevents); } } } } } $template->assign('in_approval', $inapproval); $template->assign('canview_approval_link', $canviewapproval); $template->register_permissions(array('administrate', 'configure', 'post', 'edit', 'delete', 'manage_approval', 'manage_categories'), $loc); // $cats = $db->selectObjectsIndexedArray("category","location_data='".serialize($loc)."'"); // $cats = $db->selectObjectsIndexedArray("category"); // $cats[0] = null; // $cats[0]->name = '<i>'.gt('No category').'</i>'; // $cats[0]->color = "#000000"; // $template->assign("categories",$cats); if (!$config) { // $config->enable_categories = 0; $config->enable_ical = 1; } $template->assign("config", $config); if (!isset($config->enable_ical)) { $config->enable_ical = 1; } $template->assign("enable_ical", $config->enable_ical); //Get the tags that have been selected to be shown in the grouped by tag views // if (isset($config->show_tags)) { // $available_tags = unserialize($config->show_tags); // } else { // $available_tags = array(); // } // if (isset($items) && is_array($items)) { // for ($i = 0; $i < count($items); $i++) { // //Get the tags for this calendar event // $selected_tags = array(); // $tag_ids = unserialize($items[$i]->tags); // if(is_array($tag_ids)) {$selected_tags = $db->selectObjectsInArray('tags', $tag_ids, 'name');} // $items[$i]->tags = $selected_tags; // //If this module was configured to group the newsitems by tags, then we need to change the data array a bit // if (isset($config->group_by_tags) && $config->group_by_tags == true) { // $grouped_news = array(); // foreach($items[$i]->tags as $tag) { // if (in_array($tag->id, $available_tags) || count($available_tags) == 0) { // if (!isset($grouped_news[$tag->name])) { $grouped_news[$tag->name] = array();} // array_push($grouped_news[$tag->name],$items[$i]); // } // } // } // } // } $template->output(); }
# # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } //$nav = navigationmodule::levelTemplate(intval($_REQUEST['id'], 0)); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $nav = $db->selectObjects('section', 'parent=' . $id, 'rank'); $manage_all = false; if (expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $id))) { $manage_all = true; } $navcount = count($nav); for ($i = 0; $i < $navcount; $i++) { if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $nav[$i]->id))) { $nav[$i]->manage = 1; } else { $nav[$i]->manage = 0; } $nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name); } $nav[$navcount - 1]->last = true; echo expJavascript::ajaxReply(201, '', $nav);
$start = mktime(0, 0, 0, $info['mon'], $info['mday'] + $i, $info['year']); // if ( $viewparams['range'] == "week" ) { // $start = mktime(0,0,0,$info['mon'],$info['mday']+$i,$info['year']); // } else if ( $viewparams['range'] == "twoweek" ) { // $start = mktime(0,0,0,$info['mon'],$info['mday']+$i,$info['year']); // // $start = $startperiod + ($i*86400); // } else { // range = month // $start = mktime(0,0,0,$info['mon'],$i,$info['year']); // } //$edates = $db->selectObjects("eventdate",$locsql." AND date = '".$start."'"); $edates = $db->selectObjects("eventdate", $locsql . " AND date = {$start}"); $days[$start] = array(); $days[$start] = calendarmodule::_getEventsForDates($edates); for ($j = 0; $j < count($days[$start]); $j++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $days[$start][$j]->id); $days[$start][$j]->permissions = array("administrate" => expPermissions::check("administrate", $thisloc) || expPermissions::check("administrate", $loc), "edit" => expPermissions::check("edit", $thisloc) || expPermissions::check("edit", $loc), "delete" => expPermissions::check("delete", $thisloc) || expPermissions::check("delete", $loc)); } $counts[$start] = count($days[$start]); $count += count($days[$start]); $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC')); } $template->assign("days", $days); $template->assign("counts", $counts); $template->assign("start", $startperiod); $template->assign("totaldays", $totaldays); // } else if ($viewparams['type'] == "monthly") { // $monthly = array(); // $counts = array(); // $info = getdate($time); // $nowinfo = getdate(time()); // if ($info['mon'] != $nowinfo['mon']) $nowinfo['mday'] = -10;
# General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } $_GET['a'] = intval($_GET['a']); $_GET['b'] = intval($_GET['b']); $_GET['p'] = intval($_GET['p']); $a = $db->selectObject('formbuilder_control', 'form_id=' . $_GET['p'] . ' AND rank=' . $_GET['a']); $b = $db->selectObject('formbuilder_control', 'form_id=' . $_GET['p'] . ' AND rank=' . $_GET['b']); if ($a && $b) { $f = $db->selectObject('formbuilder_form', 'id=' . $a->form_id); if (expPermissions::check('editform', unserialize($f->location_data))) { $tmp = $a->rank; $a->rank = $b->rank; $b->rank = $tmp; $db->updateObject($a, 'formbuilder_control'); $db->updateObject($b, 'formbuilder_control'); // expHistory::back(); expHistory::returnTo('editable'); } else { echo SITE_403_HTML; } } else { echo SITE_404_HTML; }
# License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## /** @define "BASE" "../../../.." */ if (!defined('EXPONENT')) { exit(''); } $template = new template('formbuilder', '_data_view'); if (isset($_GET['id'])) { $_GET['id'] = intval($_GET['id']); $f = $db->selectObject("formbuilder_form", "id=" . $_GET['id']); $rpt = $db->selectObject("formbuilder_report", "form_id=" . $_GET['id']); $items = $db->selectObjects("formbuilder_" . $f->table_name); if (expPermissions::check("viewdata", unserialize($f->location_data))) { expHistory::set('editable', $_GET); $columndef = "paginate.columns = new Array("; $columns = array(); $sortfuncts = ""; if ($rpt->column_names == '') { //define some default columns... $controls = $db->selectObjects("formbuilder_control", "form_id=" . $f->id . " and is_readonly = 0 and is_static = 0"); $controls = expSorter::sort(array('array' => $controls, 'sortby' => 'rank', 'order' => 'ASC')); foreach (array_slice($controls, 0, 5) as $control) { if ($rpt->column_names != '') { $rpt->column_names .= '|!|'; } $rpt->column_names .= $control->name; } }
# # This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } if (expPermissions::check('configure', $loc)) { $config = $db->selectObject($_POST['module'] . '_config', "location_data='" . serialize($loc) . "'"); $config = call_user_func(array($_POST['module'] . '_config', 'update'), $_POST, $config); $config->location_data = serialize($loc); if (isset($config->id)) { $db->updateObject($config, $_POST['module'] . '_config'); } else { $db->insertObject($config, $_POST['module'] . '_config'); } $container = $db->selectObject('container', "internal='" . serialize($loc) . "'"); $vconfig = array(); if (isset($_POST['_viewconfig'])) { $opts = expTemplate::getViewConfigOptions($loc->mod, $container->view); foreach (array_keys($opts) as $o) { $vconfig[$o] = isset($_POST['_viewconfig'][$o]) ? $_POST['_viewconfig'][$o] : 0; }
# # This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } //if ($user->is_acting_admin == 1) { if (expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', intval($_GET['id'])))) { $section = $db->selectObject('section', 'id=' . intval($_GET['id'])); if ($section) { navigationmodule::removeLevel($section->id); $db->decrement('section', 'rank', 1, 'rank > ' . $section->rank . ' AND parent=' . $section->parent); $section->parent = -1; $db->updateObject($section, 'section'); expSession::clearAllUsersSessionCache('navigationmodule'); expHistory::back(); } else { echo SITE_403_HTML; } } else { echo SITE_404_HTML; }
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(); }
expHistory::set('editable', array("module" => "containermodule", "action" => "edit")); $container = null; $iloc = null; $cloc = null; if (isset($_GET['id'])) { $container = $db->selectObject('container', 'id=' . intval($_GET['id'])); if ($container != null) { $iloc = unserialize($container->internal); $cloc = unserialize($container->external); $cloc->int = $container->id; } } else { $container->rank = $_GET['rank']; } $loc->src = urldecode($loc->src); if (expPermissions::check('edit_module', $loc) || expPermissions::check('add_module', $loc) || $iloc != null && expPermissions::check('administrate', $iloc) || $cloc != null && expPermissions::check('delete_module', $cloc)) { # # Initialize Container, in case its null # $secref = null; if (!isset($container->id)) { $secref->description = ''; $container->view = ''; $container->internal = expCore::makeLocation(); $container->title = ''; $container->rank = $_GET['rank']; $container->is_private = 0; } else { $container->internal = unserialize($container->internal); $secref = $db->selectObject('sectionref', "module='" . $container->internal->mod . "' AND source='" . $container->internal->src . "'"); }
// Sanitize the parent parameter up here to make things more clear and straightforward. $_GET['parent'] = intval($_GET['parent']); // May have been passed a '0', indicating that we want a top-level section if ($_GET['parent'] <= 0) { // Set $parent->id to passed value, so that $parent is not null. The view will use this information // to output the appropriate messages to the user. $parent->id = $_GET['parent']; } else { // Passed a non-zero parent id - Adding a subsection. Try to read // the parent from the database. $parent = $db->selectObject('section', 'id=' . $_GET['parent']); } } // Check to see that A) a parent ID was passed in GET, and B) the id was valid if ($parent) { if (expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $parent->id))) { // For this action, all we need to do is output a basically // non-variable template the asks the user what type of page // they want to add to the site Navigation. $template = new template('navigationmodule', '_add_whichtype'); // We do, however need to know if there are any Pagesets. $template->assign('havePagesets', $db->countObjects('section_template', 'parent=0') && $parent->id >= 0); // We also need to know if there are any standalone pages. $template->assign('haveStandalone', $db->countObjects('section', 'parent=-1') && $parent->id >= 0); // Assign the parent we were passed, so that it can propagated along to the actual form action. $template->assign('parent', $parent); $template->assign('isAdministrator', $user && ($user->is_admin || $user->is_acting_admin) ? 1 : 0); $template->output(); } else { // Current user is not allowed to manage sections. Throw a 403. echo SITE_403_HTML;
static function checkForSectionalAdmins($id) { global $db; $section = $db->selectObject('section', 'id=' . $id); $branch = navigationmodule::levelTemplate($id, 0); array_unshift($branch, $section); $allusers = array(); $allgroups = array(); while ($section->parent > 0) { $ploc = expCore::makeLocation('navigationmodule', null, $section); $allusers = array_merge($allusers, $db->selectColumn('userpermission', 'uid', "permission='manage' AND module='navigationmodule' AND internal=" . $section->parent)); $allgroups = array_merge($allgroups, $db->selectColumn('grouppermission', 'gid', "permission='manage' AND module='navigationmodule' AND internal=" . $section->parent)); $section = $db->selectObject('section', 'id=' . $section->parent); } foreach ($branch as $section) { $sloc = expCore::makeLocation('navigationmodule', null, $section->id); // remove any manage permissions for this page and it's children // $db->delete('userpermission', "module='navigationmodule' AND internal=".$section->id); // $db->delete('grouppermission', "module='navigationmodule' AND internal=".$section->id); foreach ($allusers as $uid) { $u = user::getUserById($uid); expPermissions::grant($u, 'manage', $sloc); } foreach ($allgroups as $gid) { $g = group::getGroupById($gid); expPermissions::grantGroup($g, 'manage', $sloc); } } }