Esempio n. 1
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;
 }
Esempio n. 2
0
 function __construct($module, $view = null, $loc = null, $caching = false, $type = null)
 {
     $type = !isset($type) ? 'modules' : $type;
     //parent::__construct("modules", $module, $view);
     parent::__construct($type, $module, $view);
     $this->viewparams = expTemplate::getViewParams($this->viewfile);
     if ($loc == null) {
         $loc = expCore::makeLocation($module);
     }
     $this->tpl->assign("__loc", $loc);
     $this->tpl->assign("__name", $module);
     // View Config
     global $db;
     $container_key = serialize($loc);
     $cache = expSession::getCacheValue('containermodule');
     if (isset($cache[$container_key])) {
         $container = $cache[$container_key];
     } else {
         $container = $db->selectObject("container", "internal='" . $container_key . "'");
         $cache[$container_key] = $container;
     }
     $this->viewconfig = $container && isset($container->view_data) && $container->view_data != "" ? unserialize($container->view_data) : array();
     $this->tpl->assign("__viewconfig", $this->viewconfig);
 }
Esempio n. 3
0
##################################################
/** @define "BASE" "../../../.." */
if (!defined('EXPONENT')) {
    exit('');
}
$f = null;
if (isset($_POST['id'])) {
    $f = $db->selectObject('formbuilder_form', 'id=' . intval($_POST['id']));
}
if (expPermissions::check('editform', unserialize($f->location_data))) {
    $f = formbuilder_form::update($_POST, $f);
    $f->table_name = formbuilder_form::updateTable($f);
    if (isset($f->id)) {
        $db->updateObject($f, 'formbuilder_form');
    } else {
        $f->location_data = serialize(expCore::makeLocation($_POST['m'], $_POST['s'], $_POST['i']));
        $f->id = $db->insertObject($f, 'formbuilder_form');
        //Create Default Report;
        $rpt->name = gt('Default Report');
        $rpt->description = gt('This is the auto generated default report. Leave the report definition blank to use the default "all fields" report.');
        $rpt->location_data = $f->location_data;
        $rpt->text = '';
        $rpt->column_names = '';
        $rpt->form_id = $f->id;
        $db->insertObject($rpt, 'formbuilder_report');
    }
    //Delete All addresses as we will be rebuilding it.
    $db->delete('formbuilder_address', 'form_id=' . $f->id);
    $data->group_id = 0;
    $data->user_id = 0;
    $data->email = '';
Esempio n. 4
0
 function copyContent($oloc, $nloc, $section = 0)
 {
     global $db;
     foreach ($db->selectObjects('container', "external='" . serialize($oloc) . "'") as $c) {
         unset($c->id);
         $c->external = serialize($nloc);
         if (!$c->is_existing == 1) {
             // Copy over content to a new source
             $oldinternal = unserialize($c->internal);
             $iloc = expCore::makeLocation($oldinternal->mod, '@random' . uniqid(''));
             $c->internal = serialize($iloc);
             $db->insertObject($c, 'container');
             // Now copy over content
             if (call_user_func(array($oldinternal->mod, 'hasContent')) == true) {
                 call_user_func(array($oldinternal->mod, 'copyContent'), $oldinternal, $iloc);
                 // Incrementors!
                 expCore::incrementLocationReference($iloc, $section);
                 // SECTION
             }
         } else {
             $db->insertObject($c, 'container');
             expCore::incrementLocationReference($iloc, $section);
             // SECTION
         }
     }
 }
Esempio n. 5
0
$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
Esempio n. 6
0
 /**
  * @param null $src
  * @param array $params
  * @return expController
  *
  */
 function __construct($src = null, $params = array())
 {
     // setup some basic information about this class
     $this->classinfo = new ReflectionClass($this);
     $this->classname = $this->classinfo->getName();
     $this->baseclassname = substr($this->classinfo->getName(), 0, -10);
     $this->filepath = __realpath($this->classinfo->getFileName());
     // figure out which "module" we belong to and setup view path information
     $controllerpath = explode('/', $this->filepath);
     $this->module_name = $controllerpath[count($controllerpath) - 2];
     // set up the path to this module view files
     array_pop($controllerpath);
     $controllerpath[count($controllerpath) - 1] = 'views';
     array_push($controllerpath, $this->baseclassname);
     $this->relative_viewpath = implode('/', array_slice($controllerpath, -3, 3));
     $this->viewpath = BASE . 'framework/modules/' . $this->relative_viewpath;
     //grab the path to the module's assets
     array_pop($controllerpath);
     $controllerpath[count($controllerpath) - 1] = 'assets';
     $this->asset_path = PATH_RELATIVE . 'framework/' . implode('/', array_slice($controllerpath, -3, 3)) . "/";
     // figure out which model we're using and setup some info about it
     if (empty($this->basemodel_name)) {
         $this->basemodel_name = get_model_for_controller($this->classname);
     }
     $modelname = $this->basemodel_name;
     if (class_exists($modelname)) {
         $this->{$modelname} = new $modelname(null, false, false);
         $this->model_table = $this->{$modelname}->tablename;
     } else {
         $this->basemodel_name = 'expRecord';
         $this->{$modelname} = new expRecord(null, false, false);
         $this->model_table = null;
     }
     // set the location data
     $this->loc = expCore::makeLocation($this->baseclassname, $src, null);
     // get this controllers config data if there is any
     $config = new expConfig($this->loc);
     $this->config = $config->config;
     $this->params = $params;
 }
Esempio n. 7
0
    exit('');
}
$item = null;
$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);
Esempio n. 8
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('');
}
$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);
    }
Esempio n. 9
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('');
}
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();
}
Esempio n. 10
0
 /** exdoc
  * Checks to see if the given group has been given a specific permission on a location.
  * Returns true if the permission is granted, false if it is not.
  *
  * @param Group $group The group to check
  * @param string $permission The name of the permission to check
  * @param Object $location The location to check on.
  * @param bool $explicitOnly
  *
  * @return bool
  *
  * @node Subsystems:expPermissions
  */
 public static function checkGroup($group, $permission, $location, $explicitOnly = false)
 {
     global $db, $module_scope;
     if ($group == null) {
         return false;
     }
     // check for explicit group permission
     $explicit = $db->selectObject("grouppermission", "gid=" . $group->id . " AND module='" . $location->mod . "' AND source='" . $location->src . "' AND internal='" . $location->int . "' AND permission='{$permission}'");
     if ($explicitOnly || $explicit) {
         return !empty($explicit);
     }
     // exit recursive calls for globally scoped modules
     $module_scope['error'] = false;
     if (!empty($module_scope[$location->src][$location->mod]->scope)) {
         // is this the main container?
         $rLoc = $db->selectObject("sectionref", "source='" . $location->src . "' AND module='" . $location->mod . "'");
         if (!empty($rLoc) && $rLoc->refcount == 1000 && $module_scope[$location->src][$location->mod]->scope == 'global') {
             $module_scope['error'] = true;
             return false;
         }
     }
     // check for inherited container permission
     $perms = array();
     $perms[] = $permission;
     // account for old-style container perms
     $perms[] = 'administrate';
     if ($permission == 'post' || $permission == 'create') {
         $perms[] = 'add_module';
     } elseif ($permission == 'edit') {
         $perms[] = 'add_module';
         $perms[] = 'edit_module';
     } elseif ($permission == 'delete') {
         $perms[] = 'delete_module';
     } elseif ($permission == 'configure') {
         $perms[] = 'order_modules';
     }
     foreach ($perms as $perm) {
         $tmpLoc->mod = $location->mod;
         $tmpLoc->src = $location->src;
         $tmpLoc->int = $location->int;
         $tmpLoc->mod = !strpos($tmpLoc->mod, "Controller") && !strpos($tmpLoc->mod, "module") ? $tmpLoc->mod . "Controller" : $tmpLoc->mod;
         $cLoc = expUnserialize($db->selectValue('container', 'external', 'internal=\'' . serialize($tmpLoc) . '\''));
         if (!empty($cLoc) && $db->selectObject("grouppermission", "gid=" . $group->id . " AND module='" . $cLoc->mod . "' AND source='" . $cLoc->src . "' AND internal='" . $cLoc->int . "' AND permission='{$perm}'")) {
             return true;
         }
         if (!empty($cLoc)) {
             if (self::checkGroup($group, $perm, $cLoc)) {
                 return true;
             }
         }
     }
     if (@$module_scope['error'] == true) {
         $module_scope['error'] = false;
         return false;
     }
     // if this is the global sidebar, then exit since we don't care about page permissions
     $module_scope['error'] = false;
     if (!empty($module_scope[$location->src][$location->mod]->scope)) {
         // is this the main container?
         $rLoc = $db->selectObject("sectionref", "source='" . $location->src . "' AND module='" . $location->mod . "'");
         if (!empty($rLoc) && $rLoc->refcount == 1000 && @$module_scope[$location->src][$location->mod]->scope == 'global') {
             $module_scope['error'] = true;
             return false;
         }
     }
     // check for inherited 'manage' permission from its page
     if ($location->mod != 'navigationmodule') {
         $tmpLoc->mod = $location->mod;
         $tmpLoc->src = $location->src;
         $tmpLoc->int = $location->int;
         $tmpLoc->mod = !strpos($tmpLoc->mod, "Controller") && !strpos($tmpLoc->mod, "module") ? $tmpLoc->mod . "Controller" : $tmpLoc->mod;
         foreach ($db->selectObjects('sectionref', "is_original=1 AND module='" . $tmpLoc->mod . "' AND source='" . $tmpLoc->src . "'") as $secref) {
             if (self::checkGroup($group, 'manage', expCore::makeLocation('navigationmodule', '', $secref->section))) {
                 return true;
             }
         }
     } else {
         // check for recursive inherited page permission
         $page = $db->selectObject("section", "id=" . $location->int);
         if (!empty($page->parent)) {
             // first check for specific 'view' permission
             if (self::checkGroup($group, $permission, expCore::makeLocation('navigationmodule', '', $page->parent))) {
                 return true;
             }
             // otherwise check for 'super' permission
             if (self::checkGroup($group, 'manage', expCore::makeLocation('navigationmodule', '', $page->parent))) {
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 11
0
# 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
#
##################################################
/** @define "BASE" "." */
define('SCRIPT_EXP_RELATIVE', '');
define('SCRIPT_FILENAME', 'popup.php');
ob_start();
// Initialize the Exponent Framework
require_once 'exponent.php';
$loc = expCore::makeLocation(isset($_GET['module']) ? $_GET['module'] : '', isset($_GET['src']) ? $_GET['src'] : '', isset($_GET['int']) ? $_GET['int'] : '');
if (expTheme::inAction()) {
    expTheme::runAction();
} else {
    if (isset($_GET['module']) && isset($_GET['view'])) {
        //	expHistory::flowSet(SYS_FLOW_PUBLIC,SYS_FLOW_SECTIONAL);
        expHistory::set('viewable', $router->params);
        $mod = new $_GET['module']();
        $mod->show($_GET['view'], $loc, isset($_GET['title']) ? $_GET['title'] : '');
    }
}
$str = ob_get_contents();
ob_end_clean();
$template = new standalonetemplate('popup_' . (isset($_GET['template']) ? $_GET['template'] : 'general'));
$template->assign('output', $str);
$template->output();
Esempio n. 12
0
# 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
#
##################################################
/** @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;
Esempio n. 13
0
 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);
         }
     }
 }
Esempio n. 14
0
        $tmploc->int = '';
        $locsql .= " OR location_data='" . serialize($tmploc) . "'";
    }
}
$locsql .= ')';
if (isset($config->rss_limit) && $config->rss_limit > 0) {
    $rsslimit = " AND date <= " . strtotime('+' . $config->rss_limit . ' days', time());
} else {
    $rsslimit = "";
}
$dates = $db->selectObjects("eventdate", $locsql . " AND date >= " . expDateTime::startOfDayTimestamp(time()) . $rsslimit);
$all_events = calendarmodule::_getEventsForDates($dates);
$viewing_tag = $db->selectObject('tags', "id=" . intval($_REQUEST['id']));
$events = array();
for ($i = 0; $i < count($all_events); $i++) {
    $ploc = expCore::makeLocation($loc->mod, $loc->src, $all_events[$i]->id);
    $not_there = true;
    $tags = unserialize($all_events[$i]->tags);
    $selected_tags = $db->selectObjectsInArray('tags', $tags);
    //eDebug($selected_tags);
    for ($j = 0; $j < count($tags); $j++) {
        if ($tags[$j] == intval($_REQUEST['id'])) {
            $not_there = false;
        }
    }
    if ($not_there == false) {
        $event = $all_events[$i];
        $event->selected_tags = $selected_tags;
        $event->permissions = array("administrate" => expPermissions::check("administrate", $ploc) || expPermissions::check("administrate", $loc), "edit" => expPermissions::check("edit", $ploc) || expPermissions::check("edit", $loc), "delete" => expPermissions::check("delete", $ploc) || expPermissions::check("delete", $loc));
        array_push($events, $event);
    }
Esempio n. 15
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;
}
Esempio n. 16
0
 public function manage_group_memberships()
 {
     global $db, $user;
     expHistory::set('manageable', $this->params);
     $memb = $db->selectObject('groupmembership', 'member_id=' . $user->id . ' AND group_id=' . $this->params['id'] . ' AND is_admin=1');
     $perm_level = 0;
     if ($memb) {
         $perm_level = 1;
     }
     if (expPermissions::check('user_management', expCore::makeLocation('administrationmodule'))) {
         $perm_level = 2;
     }
     $group = $db->selectObject('group', 'id=' . $this->params['id']);
     $users = user::getAllUsers(0);
     $members = array();
     $admins = array();
     foreach ($db->selectObjects('groupmembership', 'group_id=' . $group->id) as $m) {
         $members[] = $m->member_id;
         if ($m->is_admin == 1) {
             $admins[] = $m->member_id;
         }
     }
     for ($i = 0; $i < count($users); $i++) {
         if (in_array($users[$i]->id, $members)) {
             $users[$i]->is_member = 1;
         } else {
             $users[$i]->is_member = 0;
         }
         if (in_array($users[$i]->id, $admins)) {
             $users[$i]->is_admin = 1;
         } else {
             $users[$i]->is_admin = 0;
         }
     }
     //$limit = empty($this->config['limit']) ? 10 : $this->config['limit'];
     $order = empty($this->config['order']) ? 'username' : $this->config['order'];
     $page = new expPaginator(array('records' => $users, 'where' => 1, 'limit' => 9999, 'order' => $order, 'controller' => $this->baseclassname, 'action' => $this->params['action'], 'columns' => array('Username' => 'username', 'First Name' => 'firstname', 'Last Name' => 'lastname', 'Is Member' => 'is_member', 'Is Admin' => 'is_admin')));
     assign_to_template(array('page' => $page, 'group' => $group, 'users' => $users, 'canAdd' => count($members) < count($users) ? 1 : 0, 'hasMember' => count($members) > 0 ? 1 : 0, 'perm_level' => $perm_level));
 }
Esempio n. 17
0
        $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 . "'");
    }
    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);
Esempio n. 18
0
##################################################
#
# 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;
}
Esempio n. 19
0
$view = "_sourcePicker";
$clickable_mods = null;
// Show all
$dest = null;
if (expSession::is_set("source_select") && defined('SOURCE_SELECTOR')) {
    $source_select = expSession::get("source_select");
    $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 {
Esempio n. 20
0
 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();
 }
Esempio n. 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);
         }
     }
 }
Esempio n. 22
0
 function show($view, $loc = null)
 {
     global $db;
     // require_once(BASE."framework/core/subsystems/forms/baseform.php");
     // require_once(BASE."framework/core/subsystems/forms/form.php");
     if (defined('PREVIEW_READONLY') && !defined('SELECTOR')) {
         // Pass
     } else {
         $f = null;
         $f = $db->selectObject("formbuilder_form", "location_data='" . serialize($loc) . "'");
         if (!$f) {
             //Create a form if it's missing...
             $f->name = "New Form";
             $f->description = "";
             $f->location_data = serialize($loc);
             $f->table_name = "";
             $f->is_email = 0;
             $f->is_saved = 0;
             $f->submitbtn = gt('Submit');
             $f->resetbtn = gt('Reset');
             $f->response = gt('Your form has been submitted');
             $f->subject = gt('Submitted form from site');
             $frmid = $db->insertObject($f, "formbuilder_form");
             //Create Default Report;
             $rpt->name = gt('Default Report');
             $rpt->description = "";
             $rpt->location_data = $f->location_data;
             $rpt->text = "";
             $rpt->column_names = "";
             $rpt->form_id = $frmid;
             $db->insertObject($rpt, "formbuilder_report");
             $f->id = $frmid;
         }
         $floc = unserialize($f->location_data);
         $controls = $db->selectObjects("formbuilder_control", "form_id=" . $f->id);
         $controls = expSorter::sort(array('array' => $controls, 'sortby' => 'rank', 'order' => 'ASC'));
         $form = new form();
         $data = expSession::get('formmodule_data_' . $f->id);
         foreach ($controls as $c) {
             $ctl = unserialize($c->data);
             $ctl->_id = $c->id;
             $ctl->_readonly = $c->is_readonly;
             if (!empty($data[$c->name])) {
                 $ctl->default = $data[$c->name];
             }
             $form->register($c->name, $c->caption, $ctl);
         }
         $form->register("submit", "", new buttongroupcontrol($f->submitbtn, $f->resetbtn, ""));
         //$form->meta("action","submit_form");
         $form->meta("action", "confirm_form");
         $form->meta("m", $floc->mod);
         $form->meta("s", $floc->src);
         $form->meta("i", $floc->int);
         $form->meta("id", $f->id);
         $formmsg = '';
         $form->location(expCore::makeLocation("formbuilder", $floc->src, $floc->int));
         if (count($controls) == 0) {
             $form->controls['submit']->disabled = true;
             $formmsg .= gt('This form is blank. Select "Edit Form" to add input fields.') . '<br>';
         }
         if ($f->is_saved == 0 && $f->is_email == 0) {
             $form->controls['submit']->disabled = true;
             $formmsg .= gt('There are no actions assigned to this form. Select "Edit Form Settings" then select "Email Form" and/or "Save to Database".');
         }
         $count = $db->countObjects("formbuilder_" . $f->table_name);
         $template = new template("formmodule", $view, $loc);
         $template->assign("moduletitle", $f->name);
         $template->assign("description", $f->description);
         if ($formmsg) {
             flash('notice', $formmsg);
         }
         $template->assign("form_html", $form->toHTML($f->id));
         $template->assign("form", $f);
         $template->assign("count", $count);
         $template->register_permissions(array("administrate", "editform", "editformsettings", "editreport", "viewdata", "editdata", "deletedata"), $loc);
         $template->output();
     }
 }
Esempio n. 23
0
#
# 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);
Esempio n. 24
0
# 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
#
##################################################
/** @define "BASE" "../../../.." */
if (!defined('EXPONENT')) {
    exit('');
}
// id & date_id set if single event, else
//   src & time (opt?) set for longer list/month, etc...
if (isset($_GET['date_id']) || isset($_GET['src'])) {
    $loc = expCore::makeLocation('calendarmodule', $_GET['src'], '');
    $locsql = "(location_data='" . serialize($loc) . "'";
    $config = $db->selectObject("calendarmodule_config", "location_data='" . serialize($loc) . "'");
    if (!$config) {
        $config->enable_ical = 1;
    }
    if ($config->enable_ical) {
        if (isset($_GET['date_id'])) {
            // get single specific event only
            $dates = array($db->selectObject("eventdate", "id=" . intval($_GET['date_id'])));
            $Filename = "Event-" . $_GET['date_id'];
        } else {
            if (!empty($config->aggregate)) {
                $locations = unserialize($config->aggregate);
                foreach ($locations as $source) {
                    $tmploc = null;
Esempio n. 25
0
#
# 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;
Esempio n. 26
0
for ($i = 0; $i < $totaldays; $i++) {
    $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());
Esempio n. 27
0
    // 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;
Esempio n. 28
0
        $locsql .= " OR location_data='" . serialize($tmploc) . "'";
    }
}
$locsql .= ')';
for ($i = 0; $i < 7; $i++) {
    $start = mktime(0, 0, 0, $startinfo['mon'], $startinfo['mday'] + $i, $startinfo['year']);
    $days[$start] = array();
    //	$dates = $db->selectObjects("eventdate","location_data='".serialize($loc)."' AND date = $start");
    $dates = $db->selectObjects("eventdate", $locsql . " AND date = {$start}");
    for ($j = 0; $j < count($dates); $j++) {
        $o = $db->selectObject("calendar", "id=" . $dates[$j]->event_id);
        if ($o != null) {
            $o->eventdate = $dates[$j];
            $o->eventstart += $o->eventdate->date;
            $o->eventend += $o->eventdate->date;
            $thisloc = expCore::makeLocation($loc->mod, $loc->src, $o->id);
            $o->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.
            if (isset($o->file_id) && $o->file_id > 0) {
                $file = $db->selectObject('file', 'id=' . $o->file_id);
                $o->image_path = $file->directory . '/' . $file->filename;
            }
            $days[$start][] = $o;
        }
    }
    $counts[$start] = count($days[$start]);
}
$template->register_permissions(array("post", "edit", "delete", "administrate", "manage_approval"), $loc);
if (!$config) {
    $config->enable_categories = 0;
    $config->enable_ical = 1;