public function index() { if (FabriqModules::module('roles')->requiresPermission('administer menus', 'sitemenus')) { $menus = FabriqModules::new_model('sitemenus', 'Menus'); $menus->getAll(); FabriqModules::set_var('sitemenus', 'menus', $menus); Fabriq::title('Manage menus'); Fabriq::fabriq_ui_on(); FabriqModules::add_js('users', 'jquery.validate.min'); FabriqLibs::js_lib('jquery.tmpl.min', 'jquery/plugins'); FabriqModules::add_js('sitemenus', 'sitemenus.index'); FabriqModules::add_css('sitemenus', 'sitemenus'); } }
public function manage() { if (FabriqModules::module('roles')->requiresPermission('manage modules', $this->name)) { Fabriq::title('Admin | Manage modules'); FabriqModules::add_js($this->name, $this->name); Fabriq::fabriq_ui_on(); $modules = new Modules(); $modules->getAll(); // get and install any new modules $available = $this->scan_modules(); $toRegister = $this->to_register($modules, $available); foreach ($toRegister as $register) { FabriqModules::register_module($register); } // update modules collection $modules = new Modules(); $modules->getAll(); FabriqModules::set_var($this->name, 'modules', $modules); } }
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'); } } }
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'); }