public function create() { if ($this->requiresPermission('create roles', $this->name)) { Fabriq::title('Admin | Create role'); if (isset($_POST['submit'])) { $role = FabriqModules::new_model('roles', 'Roles'); $role->role = strtolower(trim($_POST['role'])); $role->enabled = 1; if (strlen($role->role) == 0) { Messaging::message('You must specify a role'); } $r = new Roles_mm(); $r->getRole($role->role); if ($r->count() > 0) { Messaging::message('A role with that name already exists'); } if (Messaging::has_messages() == 0) { $role->id = $role->create(); } FabriqModules::set_var($this->name, 'submitted', true); FabriqModules::set_var($this->name, 'role', $role); } } }
<h1>Site configuration</h1> <?php if ($submitted && Messaging::has_messages()) { Messaging::display_messages(); } $appPath = '/'; $aPath = substr($_SERVER['REQUEST_URI'], 1); $aPath = str_replace('index.php?q=', '', $aPath); $aPath = explode('/', $aPath); $i = 0; while ($aPath[$i] != 'fabriqinstall') { $appPath .= $aPath[$i] . '/'; $i++; } if (isset($_SESSION['FAB_INSTALL_site']) && $_SESSION['FAB_INSTALL_site'] != '') { $siteConfig = unserialize($_SESSION['FAB_INSTALL_site']); $submitted = true; foreach ($siteConfig as $key => $val) { $_POST[$key] = $val; } } ?> <form method="post" action="<?php PathMap::build_path('fabriqinstall', 'install', 2); ?> "> <label for="title">Page title <span class="required-field">*</span>: </label><input type="text" id="title" name="title" size="50" tabindex="1"<?php if ($submitted) { echo ' value="' . $_POST['title'] . '"'; } ?>
if (!$found) { ?> <h1>Menu not found</h1> <p><a href="<?php echo PathMap::build_path('sitemenus', 'index'); ?> ">Return to menu list</a></p> <?php } else { ?> <h1>Create menu item</h1> <?php if (Messaging::has_messages()) { Messaging::display_messages(); } if (!$submitted || $submitted && Messaging::has_messages()) { ?> <p><a href="<?php echo PathMap::build_path('sitemenus', 'items', 'index', $menu->id); ?> ">Return to menu items list</a></p> <form method="post" action="<?php echo PathMap::build_path('sitemenus', 'items', 'create', $menu->id); ?> "> <div style="padding: 2px;"> <label for="<?php echo $moduleName; ?> _itemName"> <strong>Item name:</strong>
<h1>Manage Roles</h1> <?php if ($submitted && Messaging::has_messages('successes')) { Messaging::display_messages('successes'); } ?> <p> <a href="<?php echo PathMap::build_path('fabriqadmin', 'roles', 'create'); ?> ">Add role</a> | <a href="<?php echo PathMap::build_path('fabriqadmin', 'roles', 'perms'); ?> ">Manage permissions</a> </p> <form method="post" action="<?php PathMap::build_path('fabriqadmin', 'roles', 'manage'); ?> "> <table border="0" style="border: solid 1px #999;" cellspacing="0"> <thead> <tr> <th style="width: 300px;">Role</th> <th>Enabled</th> </tr> </thead> <tbody> <?php for ($i = 0; $i < $roles->count(); $i++) { ?>
public function update() { if (FabriqModules::module('roles')->requiresPermission('update blog posts', 'blog')) { $blog = FabriqModules::new_model('blog', 'Blogs'); $blog->find(PathMap::arg(2)); if ($blog->title != '' && ($blog->locked == 0 || FabriqModules::module('roles')->requiresPermission('update blog posts', 'blog'))) { Fabriq::title('Update blog entry'); if (file_exists('libs/javascript/tiny_mce/tiny_mce.js')) { FabriqLibs::js_lib('tiny_mce', 'tiny_mce'); FabriqLibs::js_lib('jquery.tinymce', 'tiny_mce'); FabriqModules::add_js('blog', 'blog'); } // determine if extension modules are enabled $pathmapEnabled = FabriqModules::enabled('pathmap'); FabriqModules::set_var('blog', 'pathmapEnabled', $pathmapEnabled); if ($pathmapEnabled) { FabriqModules::module('pathmap')->start_update('blog', 'show', $blog->id); FabriqModules::set_var('pathmap', 'pathmap_controller', 'blog'); FabriqModules::set_var('pathmap', 'pathmap_action', 'show'); FabriqModules::set_var('pathmap', 'pathmap_modpage', 'module'); } $taxonomyEnabled = FabriqModules::enabled('taxonomy'); FabriqModules::set_var('blog', 'taxonomyEnabled', $taxonomyEnabled); if ($taxonomyEnabled) { FabriqModules::module('taxonomy')->termsList('blog', $blog->db_table, $blog->id); } if (isset($_POST['submit'])) { $blog->title = trim($_POST['title']); $blog->body = trim($_POST['body']); $blog->locked = isset($_POST['locked']) && $_POST['locked'] == 1 ? 1 : 0; $blog->user = $_SESSION[Fabriq::siteTitle()]['FABMOD_USERS_userid']; if (strlen($blog->title) == '') { Messaging::message('Blog title is required'); } if (strlen($blog->body) == '') { Messaging::message('Blog body is required'); } if (!Messaging::has_messages()) { $blog->update(); FabriqModules::trigger_event($this->name, 'create', 'blog entry updated', $blog); // create map if needed if ($pathmapEnabled) { $_POST['pathmap_extra'] = $blog->id; $_POST['pathmap_wildcard'] = NULL; FabriqModules::module('pathmap')->update('blog', 'show', $blog->id); } // add taxonomy if available if ($taxonomyEnabled) { FabriqModules::module('taxonomy')->termsList('blog', $blog->db_table, $blog->id); } if (!Messaging::has_messages()) { header('Location: ' . PathMap::build_path('blog')); exit; } } FabriqModules::set_var('blog', 'submitted', true); } FabriqModules::set_var('blog', 'blog', $blog); } else { FabriqModules::set_var('blog', 'notFound', true); Fabriq::title('Blog entry not found'); } } }
<h1>Core module configuration</h1> <?php if (Messaging::has_messages()) { Messaging::display_messages(); } else { Messaging::display_messages('successes'); Messaging::display_messages('warnings'); } ?> <p><strong>You must create an initial user. This user will be given the administrator role. Users with administrator role can access any areas that are enabled for the role. By default, the user module is configured so that only administrators can add users. This configuration option can be changed later</strong></p> <form method="post" action="<?php echo PathMap::build_path('fabriqinstall', 'install', 4); ?> "> <div style="padding: 2px;"> <label for="display">Display name: </label> <input type="text" name="display" id="display" size="24" maxlength="24" /><br /> <span style="font-size: 8pt;">Display names may only contain charcters, number, and the underscore character between 6 and 24 characters long.</span> </div> <div style="padding: 2px;"> <label for="email">e-mail address: </label> <input type="text" name="email" id="email" size="50" maxlength="100" /><br /> <span style="font-size: 8pt;">Must be a valid e-mail address. This e-mail address will be used when necessary to contact the user.</span> </div> <div style="padding: 2px;"> <label for="pwd">Password: </label> <input type="password" name="pwd" id="pwd" size="24" /><br /> <span style="font-size: 8pt;">Passwords must be at least 8 characters long. The user will be forced to change their password after their first log in.</span> </div>
public function itemsUpdate() { if (FabriqModules::module('roles')->requiresPermission('update menus', 'sitemenus')) { $menu = FabriqModules::new_model('sitemenus', 'Menus'); $menu->find(PathMap::arg(3)); if ($menu->menuName != '') { $menuItem = FabriqModules::new_model('sitemenus', 'MenuItems'); $menuItem->find(PathMap::arg(4)); if ($menuItem->itemName != '') { Fabriq::title("Add item to menu \"{$menu->menuName}\""); $menu->buildMenu(); FabriqModules::set_var('sitemenus', 'menu', $menu); FabriqModules::set_var('sitemenus', 'found', true); FabriqModules::set_var('sitemenus', 'moduleName', $this->name); if (isset($_POST['submitted'])) { $menuItem->itemName = trim($_POST[$this->name . '_itemName']); $menuItem->path = trim($_POST[$this->name . '_path']); $menuItem->parentItem = $_POST[$this->name . '_parentItem']; $menuItem->weight = $_POST[$this->name . '_weight']; $menuItem->menu = $menu->id; $menuItem->newWindow = isset($_POST[$this->name . '_newWindow']) && $_POST[$this->name . '_newWindow'] == 1 ? 1 : 0; if (strlen($menuItem->itemName) == 0) { Messaging::message('An item name is required'); } if (strlen($menuItem->path) == 0) { $menuItem->path = NULL; } if ($menuItem->parentItem == '') { $menuItem->parentItem = NULL; } if (!Messaging::has_messages()) { $menuItem->update(); } FabriqModules::set_var('sitemenus', 'submitted', true); } FabriqModules::set_var('sitemenus', 'menuItem', $menuItem); } else { Fabriq::title("Menu item not found"); FabriqModules::set_var('sitemenus', 'found', false); } } else { Fabriq::title("Menu not found"); FabriqModules::set_var('sitemenus', 'found', false); } } }
public function updateAccount() { if (!$this->isLoggedIn()) { header('Location: ' . PathMap::build_path('users', 'login')); exit; } Fabriq::title('Update account'); $user = FabriqModules::new_model('users', 'Users'); $user->find($_SESSION[Fabriq::siteTitle()]['FABMOD_USERS_userid']); if (isset($_POST['submit'])) { $emailPattern = '/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i'; $displayPattern = '/([A-z0-9]){6,24}/'; if (!preg_match($displayPattern, $_POST['display'])) { Messaging::message("Display name is invalid"); } if (!preg_match($emailPattern, $_POST['email'])) { Messaging::message("e-mail address is invalid"); } if (!Messaging::has_messages()) { $user->display = $_POST['display']; $user->email = $_POST['email']; $user->update(); $_SESSION[Fabriq::siteTitle()]['FABMOD_USERS_displayname'] = $user->display; $_SESSION[Fabriq::siteTitle()]['FABMOD_USERS_email'] = $user->email; Messaging::message('Account has bee updated', 'success'); } FabriqModules::set_var('users', 'submitted', true); } FabriqModules::set_var('users', 'user', $user); FabriqModules::add_js('users', 'jquery.validate.min'); FabriqModules::add_js('users', 'users-updateAccount'); FabriqModules::add_css('users', 'users-admin'); }
/** * Update step2 * Apply the updates to the framework */ protected function update_step2($continue = TRUE) { Fabriq::title('Framework updates'); // get the list of updates $methods = get_class_methods('fabriqinstall_module'); $available = array(); foreach ($methods as $method) { if (substr($method, 0, 7) == 'update_' && substr($method, 0, 11) != 'update_step' || $this->version == null) { $version = str_replace('_', '.', str_replace('update_', '', $method)); if ($version > $this->version) { $available[] = $method; } } } $toInstall = array(); for ($i = 0; $i < count($available); $i++) { $toInstall[] = $this->{$available[$i]}(); } $submitted = false; if (isset($_POST['submit'])) { if (!Messaging::has_messages()) { if ($continue) { header("Location: " . PathMap::build_path('fabriqinstall', 'update', 3)); exit; } } else { $submitted = true; } } FabriqModules::set_var('fabriqinstall', 'toInstall', $toInstall); FabriqModules::set_var('fabriqinstall', 'submitted', $submitted); }
<h1>Module permissions</h1> <?php if (Messaging::has_messages('successes')) { Messaging::display_messages('successes'); } ?> <p> <a href="<?php echo PathMap::build_path('fabriqadmin', 'roles', 'manage'); ?> ">Manage roles</a> </p> <form method="post" action="<?php PathMap::build_path('fabriqadmin', 'roles', 'persm'); ?> "> <?php foreach ($modules as $module) { ?> <h3><?php echo $module->module; ?> </h3> <?php if (isset($perms->modules[$module->id])) { ?> <table> <thead> <tr> <th style="width: 300px;"> </th> <?php
public function update($controller, $action, $extra) { $map = FabriqModules::new_model('pathmap', 'Paths'); $map->get_by_details($controller, $action, $extra); if ($_POST['update_path'] == 1) { if ($_POST['destroy_path'] == 1) { $map->destroy(); } else { $map->path = $_POST[$this->name . '_path']; if (!preg_match('/^([a-zA-Z0-9_\\-\\/]{1}){1,100}$/', $map->path)) { Messaging::message('Paths can only contain letters, numbers, the underscore character, and dashes'); } if (Messaging::has_messages() == 0) { $map->update(); } } } else { if ($_POST['add_path'] == 1) { $map = FabriqModules::new_model('pathmap', 'Paths'); $map->path = $_POST[$this->name . '_path']; $map->controller = $_POST[$this->name . '_controller']; $map->action = $_POST[$this->name . '_action']; $map->modpage = $_POST[$this->name . '_modpage']; $map->extra = $_POST[$this->name . '_extra']; $map->wildcard = $_POST[$this->name . '_wildcard']; if (!preg_match('/^([a-zA-Z0-9_\\-\\/]{1}){1,100}$/', $map->path)) { Messaging::message('Paths can only contain letters, numbers, the underscore character, and dashes'); } if (Messaging::has_messages() == 0) { $map->id = $map->create(); } FabriqModules::set_var($this->name, 'submitted', true); } } FabriqModules::set_var($this->name, 'map', $map); }