Пример #1
0
 public function show($entry)
 {
     if (FabriqModules::module('roles')->requiresPermission('view blog posts', 'blog')) {
         $blog = FabriqModules::new_model('blog', 'Blogs');
         if (!$entry || !is_numeric($entry)) {
             $blog->find(PathMap::arg(2));
         } else {
             $blog->find($entry);
         }
         if ($blog->title != '' && ($blog->locked == 0 || FabriqModules::module('roles')->requiresPermission('update blog posts', 'blog'))) {
             Fabriq::title('Blog - ' . $blog->title);
             $user = FabriqModules::new_model('users', 'Users');
             $user->find($blog->user);
             $blog->user = $user;
             $taxonomyEnabled = FabriqModules::enabled('taxonomy');
             FabriqModules::set_var('blog', 'taxonomyEnabled', $taxonomyEnabled);
             FabriqModules::set_var('blog', 'blog', $blog);
             $isAdmin = FabriqModules::module('roles')->userHasPermission('update blog posts', 'blog');
             FabriqModules::set_var('blog', 'isAdmin', $isAdmin);
         } else {
             FabriqModules::set_var('blog', 'notFound', true);
             Fabriq::title('Blog entry not found');
         }
     }
 }
Пример #2
0
 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');
 }
Пример #3
0
 public function listItems($listMenu, $clear = false)
 {
     $menu = FabriqModules::new_model('sitemenus', 'Menus');
     $menu->getMenuByName($listMenu);
     $menu->buildMenu();
     FabriqModules::set_var('sitemenus', 'listMenu', $menu);
     FabriqModules::set_var('sitemenus', 'clear', $clear);
 }
Пример #4
0
 public function noPermission()
 {
     global $_FAPP;
     Fabriq::title('Access denied');
     FabriqModules::set_var('roles', 'controller', $_FAPP['cdefault']);
     FabriqModules::set_var('roles', 'action', $_FAPP['adefault']);
 }
 /**
  * Fetch the list of updates
  */
 public function fetchUpdates()
 {
     if (FabriqModules::module('roles')->hasRole('administrator')) {
         global $db;
         Fabriq::title('Fabriq Updates');
         // get the currently installed version
         $query = "SELECT version FROM fabriq_config ORDER BY installed DESC, version DESC LIMIT 1";
         $db->query($query);
         $data = mysqli_fetch_array($db->result);
         $installedVersion = $data['version'];
         FabriqModules::set_var('fabriqinstall', 'installedVersion', $installedVersion);
         // get the list of updates from the site
         try {
             $versions = json_decode(file_get_contents('http://fabriqframework.com/changelog/json'), TRUE);
             $available = array();
             $upToDate = false;
             if (is_array($versions) && count($versions) > 0) {
                 foreach ($versions as $version => $info) {
                     if ($version > $installedVersion) {
                         $available[$version] = $info;
                     }
                 }
                 if (count($available) == 0) {
                     $upToDate = true;
                 }
                 FabriqModules::set_var('fabriqinstall', 'available', $available);
                 FabriqModules::set_var('fabriqinstall', 'connected', true);
             } else {
                 FabriqModules::set_var('fabriqinstall', 'connected', false);
             }
             FabriqModules::set_var('fabriqinstall', 'upToDate', $upToDate);
         } catch (Exception $e) {
             FabriqModules::set_var('fabriqinstall', 'connected', false);
         }
     }
 }
 public function js()
 {
     $apikey = new ModuleConfigs();
     $apikey->getConfig('googleanalytics', 'apikey');
     FabriqModules::set_var('googleanalytics', 'apikey', $apikey->val);
 }
Пример #7
0
 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);
 }
 public function configure()
 {
     Fabriq::render('view');
     $module = new Modules(PathMap::arg(2));
     $install_file = "modules/{$module->module}/{$module->module}.install.php";
     if (file_exists('sites/' . FabriqStack::site() . "/{$install_file}")) {
         $install_file = 'sites/' . FabriqStack::site() . "/{$install_file}";
     } else {
         if (!file_exists($install_file)) {
             throw new Exception("Module {$module->module} install file could not be found");
         }
     }
     require_once $install_file;
     eval("\$installer = new {$module->module}_install();");
     $installer->configure();
     FabriqModules::set_var($this->name, 'module', $module);
 }