Esempio n. 1
0
 public function install()
 {
     $mod = new Modules();
     $mod->getModuleByName('users');
     $perms = array('administer users', 'ban users', 'enable users');
     $perm_ids = FabriqModules::register_perms($mod->id, $perms);
     global $db;
     $sql = "CREATE TABLE IF NOT EXISTS `fabmod_users_users` (\n\t\t\t`id` INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`display` VARCHAR(24) NOT NULL,\n\t\t\t`email` VARCHAR(100) NOT NULL,\n\t\t\t`encpwd` VARCHAR(100) NOT NULL,\n\t\t\t`status` INT(4) NOT NULL DEFAULT 0,\n\t\t\t`banned` TINYINT(1) NOT NULL DEFAULT 0,\n\t\t\t`forcepwdreset` TINYINT(1) NOT NULL DEFAULT 0,\n\t\t\t`created` DATETIME NOT NULL,\n\t\t\t`updated` DATETIME NOT NULL,\n\t\t\tPRIMARY KEY (`id`)\n\t\t) ENGINE=INNODB;";
     $db->query($sql);
     $sql = "CREATE TABLE IF NOT EXISTS `fabmod_users_roles` (\n\t\t\t`id` INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`user` INT(11) NOT NULL,\n\t\t\t`role` INT(11) NOT NULL,\n\t\t\t`created` DATETIME NOT NULL,\n\t\t\t`updated` DATETIME NOT NULL,\n\t\t\tPRIMARY KEY (`id`),\n\t\t\tCONSTRAINT `fk_users_user` FOREIGN KEY (`user`) REFERENCES `fabmod_users_users`(`id`) ON DELETE CASCADE,\n\t\t\tCONSTRAINT `fk_users_role` FOREIGN KEY (`role`) REFERENCES `fabmod_roles_roles`(`id`) ON DELETE CASCADE\n\t\t) ENGINE=INNODB;";
     $db->query($sql);
     // map paths
     $pathmap =& FabriqModules::module('pathmap');
     $pathmap->register_path('users/index', 'users', 'index', 'module');
     $pathmap->register_path('users/index/!#', 'users', 'index', 'module', null, 2);
     $pathmap->register_path('users/login', 'users', 'login', 'module');
     $pathmap->register_path('users/login/!#', 'users', 'login', 'module', null, 2);
     $pathmap->register_path('users/logout', 'users', 'logout', 'module');
     $pathmap->register_path('users/forgotpassword', 'users', 'forgotpassword', 'module');
     $pathmap->register_path('users/create', 'users', 'create', 'module');
     $pathmap->register_path('users/update/!#', 'users', 'update', 'module', null, 2);
     $pathmap->register_path('users/enable', 'users', 'enable', 'module');
     $pathmap->register_path('users/ban', 'users', 'ban', 'module');
     $pathmap->register_path('users/register', 'users', 'register', 'module');
     $pathmap->register_path('users/checkDisplay', 'users', 'checkDisplay', 'module');
     $pathmap->register_path('users/checkEmail', 'users', 'checkEmail', 'module');
     $pathmap->register_path('users/changePassword/!#', 'users', 'changePassword', 'module', null, 2);
     $pathmap->register_path('users/myAccount', 'users', 'myAccount', 'module');
     $pathmap->register_path('users/updateAccount', 'users', 'updateAccount', 'module');
     $pathmap->register_path('users/getRoles', 'users', 'getRoles', 'module');
     // set module as installed
     $mod->installed = 1;
     $mod->update();
 }
 public function install()
 {
     $mod = new Modules();
     $mod->getModuleByName('fabriqmodules');
     $perms = array('manage modules');
     $perm_ids = FabriqModules::register_perms($mod->id, $perms);
     // map paths
     $pathmap =& FabriqModules::module('pathmap');
     $pathmap->register_path('fabriqmodules', 'fabriqmodules', 'manage', 'module');
     $pathmap->register_path('fabriqmodules/manage', 'fabriqmodules', 'manage', 'module');
     $pathmap->register_path('fabriqmodules/configure/!#', 'fabriqmodules', 'configure', 'module', null, 2);
     $pathmap->register_path('fabriqmodules/disable/!#', 'fabriqmodules', 'disable', 'module', null, 2);
     $pathmap->register_path('fabriqmodules/enable/!#', 'fabriqmodules', 'enable', 'module', null, 2);
     $pathmap->register_path('fabriqmodules/install/!#', 'fabriqmodules', 'install', 'module', null, 2);
     $pathmap->register_path('fabriqmodules/uninstall/!#', 'fabriqmodules', 'uninstall', 'module', null, 2);
     // give administrators the ability to manage modules
     $adminPerm = FabriqModules::new_model('roles', 'ModulePerms');
     $adminPerm->permission = $perm_ids[0];
     $adminRole = FabriqModules::new_model('roles', 'Roles');
     $adminRole->getRole('administrator');
     $adminPerm->role = $adminRole->id;
     $adminPerm->id = $adminPerm->create();
     // set module as installed
     $mod->installed = 1;
     $mod->update();
 }
Esempio n. 3
0
 public function install()
 {
     $mod = new Modules();
     $mod->getModuleByName('roles');
     $perms = array('create roles', 'update roles', 'delete roles', 'manage roles');
     $perm_ids = FabriqModules::register_perms($mod->id, $perms);
     global $db;
     $sql = "CREATE TABLE IF NOT EXISTS `fabmod_roles_roles` (\n\t\t\t`id` INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`role` VARCHAR(100) NOT NULL,\n\t\t\t`enabled` TINYINT(1) NOT NULL DEFAULT 1,\n\t\t\t`created` DATETIME NOT NULL,\n\t\t\t`updated` DATETIME NOT NULL,\n\t\t\tPRIMARY KEY (`id`)\n\t\t) ENGINE=INNODB;";
     $db->query($sql);
     $sql = "CREATE TABLE IF NOT EXISTS `fabmod_roles_moduleperms` (\n\t\t\t`id` INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`permission` INT(11) NOT NULL,\n\t\t\t`role` INT(11) NOT NULL,\n\t\t\t`created` DATETIME NOT NULL,\n\t\t\t`updated` DATETIME NOT NULL,\n\t\t\tPRIMARY KEY (`id`),\n\t\t\tCONSTRAINT `fk_moduleperms_permission` FOREIGN KEY (`permission`) REFERENCES fabmods_perms(id) ON DELETE CASCADE,\n\t\t\tCONSTRAINT `fk_moduleperms_role` FOREIGN KEY (`role`) REFERENCES fabmod_roles_roles(id) ON DELETE CASCADE\n\t\t) ENGINE=INNODB;";
     $db->query($sql);
     // create base roles
     $role = FabriqModules::new_model('roles', 'Roles');
     $role->role = "unauthenticated";
     $role->enabled = 1;
     $role->id = $role->create();
     $role = FabriqModules::new_model('roles', 'Roles');
     $role->role = "authenticated";
     $role->enabled = 1;
     $role->id = $role->create();
     $role = FabriqModules::new_model('roles', 'Roles');
     $role->role = "administrator";
     $role->enabled = 1;
     $role->id = $role->create();
     // map paths
     $pathmap =& FabriqModules::module('pathmap');
     $pathmap->register_path('fabriqadmin/roles/manage', 'roles', 'index', 'module');
     $pathmap->register_path('fabriqadmin/roles/create', 'roles', 'create', 'module');
     $pathmap->register_path('fabriqadmin/roles/perms', 'roles', 'perms', 'module');
     // set module as installed
     $mod->installed = 1;
     $mod->update();
 }
Esempio n. 4
0
 public function getAll($page = 0, $limit = 10)
 {
     global $db;
     $go = $page * $limit;
     if (FabriqModules::module('roles')->userHasPermission('update blog posts', 'roles')) {
         $query = "SELECT * FROM {$this->db_table} ORDER BY created DESC LIMIT ?, ?";
         $this->fill($db->prepare_select($query, $this->fields(), array($go, $limit)));
     } else {
         $query = "SELECT * FROM {$this->db_table} WHERE locked = ? ORDER BY created DESC LIMIT ?, ?";
         $this->fill($db->prepare_select($query, $this->fields(), array(0, $go, $limit)));
     }
     $found = array();
     for ($i = 0; $i < $this->count(); $i++) {
         // get user details
         if (!array_key_exists($this[$i]->user, $found)) {
             $user = FabriqModules::new_model('users', 'Users');
             $user->find($this[$i]->user);
             $found[$this[$i]->user] = $user;
             $this[$i]->user = $user;
         }
         // look for a custom url
         $this[$i]->customPath = FabriqModules::new_model('pathmap', 'Paths');
         $this[$i]->customPath->get_by_details('blog', 'show', $this[$i]->id);
     }
     // get terms if the module is enabled
     if (FabriqModules::enabled('taxonomy')) {
         for ($i = 0; $i < $this->count(); $i++) {
             $this[$i]->terms = FabriqModules::new_model('taxonomy', 'Terms');
             $this[$i]->terms->getMappedTerms($this->db_table, $this[$i]->id);
         }
     }
 }
 public function uninstall()
 {
     $mod = new Modules();
     $mod->getModuleByName('blog');
     // remove perms
     FabriqModules::remove_perms($mod->id);
     // remove paths
     $pathmap =& FabriqModules::module('pathmap');
     $pathmap->remove_path('blog');
     $pathmap->remove_path('blog/create');
     $pathmap->remove_path('blog/update/!#');
     $pathmap->remove_path('blog/destroy/!#');
     $pathmap->remove_path('blog/show/!#');
     // delete database table
     global $db;
     $sql = "DROP TABLE `fabmod_blog_blogs`;";
     $db->query($sql);
     // uninstall any terms
     if (FabriqModules::enabled('taxonomy')) {
         FabriqModules::module('taxonomy')->uninstallMaps('fabmod_blog_blogs');
     }
     // set module as not installed
     $mod->installed = 0;
     $mod->update();
 }
 public function uninstall()
 {
     $mod = new Modules();
     $mod->getModuleByName('sitemenus');
     // remove perms
     FabriqModules::remove_perms($mod->id);
     // remove paths
     $pathmap =& FabriqModules::module('pathmap');
     $pathmap->remove_path('sitemenus');
     $pathmap->remove_path('sitemenus/index');
     $pathmap->remove_path('sitemenus/create');
     $pathmap->remove_path('sitemenus/update/!#');
     $pathmap->remove_path('sitemenus/destroy/!#');
     $pathmap->remove_path('sitemenus/items/index/!#');
     $pathmap->remove_path('sitemenus/items/create/!#');
     $pathmap->remove_path('sitemenus/items/update/!#');
     $pathmap->remove_path('sitemenus/items/destroy/!#');
     // delete database table
     global $db;
     $sql = "DROP TABLE `fabmod_sitemenus_menus`;";
     $db->query($sql);
     $sql = "DROP TABLE `fabmod_sitemenus_menuitems`;";
     $db->query($sql);
     // set module as not installed
     $mod->installed = 0;
     $mod->update();
 }
Esempio n. 7
0
 /**
  * Build this menu
  */
 public function buildMenu()
 {
     $this->items = FabriqModules::new_model('sitemenus', 'MenuItems')->getMenuItems($this->id);
     // flesh out all of the menu children
     for ($i = 0; $i < count($this->items); $i++) {
         $this->getItemChildren($this->items[$i]);
     }
 }
 /**
  * Get the items for a given menu
  * @param int $menu
  */
 public function getMenuItems($menu)
 {
     global $db;
     $query = "SELECT *\n\t\t\tFROM `{$this->db_table}`\n\t\t\tWHERE `menu` = ?\n\t\t\tAND (`parentItem` IS NULL OR `parentItem` = '')\n\t\t\tORDER BY `weight`, `itemName`;";
     $data = $db->prepare_select($query, $this->fields(), array($menu));
     $items = array();
     for ($i = 0; $i < count($data); $i++) {
         $items[$i] = FabriqModules::new_model('sitemenus', 'MenuItems');
         $items[$i]->fill(array($data[$i]));
     }
     return $items;
 }
 public function update_2_3_1()
 {
     // update the path(s) for the fabriqupdate module to point to the proper actions
     $pathmap =& FabriqModules::module('pathmap');
     $pathmap->remove_path('fabriqupdates');
     $pathmap->register_path('fabriqupdates', 'fabriqinstall', 'fetchUpdates', 'module');
     // update the module version number
     $mod = new Modules();
     $mod->getModuleByName('fabriqinstall');
     $mod->versioninstalled = '2.3.1';
     $mod->update();
 }
Esempio n. 10
0
 public function update_2_1_1()
 {
     // update the module version number
     $mod = new Modules();
     $mod->getModuleByName('pathmap');
     $mod->versioninstalled = '2.1.1';
     $mod->update();
     // map paths
     $pathmap =& FabriqModules::module('pathmap');
     $pathmap->register_path('403', 'pathmap', '_403', 'module');
     $pathmap->register_path('404', 'pathmap', '_404', 'module');
     $pathmap->register_path('500', 'pathmap', '_500', 'module');
 }
Esempio n. 11
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');
         }
     }
 }
Esempio n. 12
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);
 }
Esempio n. 13
0
 /**
  * Process everything the queue
  */
 public static function processQueue()
 {
     if (!count(self::$queue)) {
         return false;
     }
     $next = FabriqStack::dequeue();
     while ($next->controller == '') {
         if (!count(self::$queue)) {
             return false;
         }
         FabriqStack::processQueue();
     }
     self::$processing = $next;
     switch ($next->type) {
         case 'module':
             $module =& FabriqModules::module($next->controller);
             call_user_func_array(array($module, $next->action), $next->extra);
             if (Fabriq::render() != 'none' && FabriqModules::has_permission() && !FabriqModules::stopMappedRender()) {
                 FabriqTemplates::renderToBody($next);
             }
             break;
         case 'controller':
         default:
             PathMap::controller($next->controller);
             PathMap::action($next->action);
             $file = "app/controllers/{$next->controller}.controller.php";
             if (file_exists('sites/' . FabriqStack::site() . "/{$file}")) {
                 require_once 'sites/' . FabriqStack::site() . "/{$file}";
             } else {
                 require_once $file;
             }
             $c = "{$next->controller}_controller";
             $controller = new $c();
             $a = str_replace('.', '_', $next->action);
             if (!$controller->hasMethod($a)) {
                 FabriqStack::error(404);
             }
             call_user_func(array($controller, $a));
             FabriqTemplates::renderToBody($next);
             break;
     }
     if (count(self::$queue)) {
         FabriqStack::processQueue();
     }
 }
 public function js()
 {
     $apikey = new ModuleConfigs();
     $apikey->getConfig('googleanalytics', 'apikey');
     FabriqModules::set_var('googleanalytics', 'apikey', $apikey->val);
 }
Esempio n. 15
0
    require_once 'sites/' . FabriqStack::site() . '/app/PathMap.class.php';
} else {
    require_once 'app/PathMap.class.php';
}
// query variable
$q = explode('/', $_GET['q']);
if (trim($q[0]) == '') {
    array_shift($q);
}
// initialize database
if ($installed) {
    $db = new Database($_FDB['default']);
    // get module handlers
    FabriqModules::get_handlers();
    // check fabriqinstall
    FabriqModules::fabriqinstallReady();
} else {
    $_FAPP = array();
    $_FAPP['templates']['default'] = 'fabriqinstall';
    $appPath = '/';
    $aPath = substr($_SERVER['REQUEST_URI'], 1);
    $aPath = str_replace('index.php?q=', '', $aPath);
    $aPath = explode('/', $aPath);
    $i = 0;
    while ($aPath[$i] != 'fabriqinstall' && $i < count($aPath)) {
        $appPath .= $aPath[$i] . '/';
        $i++;
    }
    $_FAPP['url'] = "http://{$_SERVER['HTTP_HOST']}";
    $_FAPP['apppath'] = str_replace('//', '/', $appPath);
}
Esempio n. 16
0
	<div style="padding: 2px;">
		<label for="body">Body:</label><br />
		<textarea name="body" style="width: 100%; height: 300px;"><?php 
    echo $blog->body;
    ?>
</textarea>
	</div>
	<div style="padding: 2px;">
		<input type="checkbox" name="locked" value="1"<?php 
    if ($blog->locked == 1) {
        echo " checked=\"checked\"";
    }
    ?>
 />
		<label for="locked"> Locked</label>
		<div style="font-size: 9pt; color: #999;"><strong>NOTE: locked blog entries can only be seen by administrators.</strong></div>
	</div>
<?php 
    if ($pathmapEnabled) {
        echo FabriqModules::render_now('pathmap', 'update');
    }
    if ($taxonomyEnabled) {
        echo FabriqModules::render_now('taxonomy', 'termsList');
    }
    ?>
	<div style="padding: 2px;">
		<input type="submit" name="submit" value="Update blog entry" />
	</div>
</form>
<?php 
}
Esempio n. 17
0
 public function getRoles()
 {
     Fabriq::render('none');
     header('Content-type:application/json');
     if (FabriqModules::module('roles')->requiresPermission('administer users', $this->name)) {
         $r = FabriqModules::new_model('roles', 'Roles');
         $r->getAll();
         $roles = array();
         for ($i = 0; $i < $r->count(); $i++) {
             if ($r[$i]->role != 'unauthenticated' && $r[$i]->role != 'authenticated') {
                 $roles[] = $r[$i];
             }
         }
         echo json_encode(array('roles' => $roles));
     } else {
         echo json_encode(array('notLoggedIn' => true));
     }
 }
Esempio n. 18
0
 public function register_vars($controller, $action, $modpage = 'page')
 {
     $vars = array('pathmap_controller' => $controller, 'pathmap_action' => $action, 'pathmap_modpage' => $modpage);
     FabriqModules::set_vars($this->name, $vars);
 }
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '<?php 
echo FabriqModules::get_var('googleanalytics', 'apikey');
?>
']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
 /**
  * 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);
         }
     }
 }
Esempio n. 21
0
 public function noPermission()
 {
     global $_FAPP;
     Fabriq::title('Access denied');
     FabriqModules::set_var('roles', 'controller', $_FAPP['cdefault']);
     FabriqModules::set_var('roles', 'action', $_FAPP['adefault']);
 }
Esempio n. 22
0
<?php

$found = FabriqModules::get_var('sitemenus', 'found');
?>
<h1><?php 
echo Fabriq::title();
?>
</h1>
<?php 
if ($found) {
    ?>
<p>
	<a href="<?php 
    echo PathMap::build_path('sitemenus', 'index');
    ?>
">Return to menu list</a> |
	<a href="<?php 
    echo PathMap::build_path('sitemenus', 'items', 'create', $menu->id);
    ?>
">Add menu item</a>
</p>
<p><?php 
    echo $menu->description;
    ?>
</p>
<?php 
    if (count($menu->items) > 0) {
        ?>
<ul>
	<?php 
        for ($i = 0; $i < count($menu->items); $i++) {
 /**
  * Check that the fabriqinstall module is installed
  */
 public static function fabriqinstallReady()
 {
     // check that the fabriqinstall module is installed
     if (!FabriqModules::installed('fabriqinstall')) {
         FabriqModules::register_module('fabriqinstall');
         FabriqModules::install('fabriqinstall');
         $module = new Modules();
         $module->getModuleByName('fabriqinstall');
         $module->enabled = 1;
         $module->update();
         Messaging::message('Installed fabriqinstall module', 'success');
     }
 }
Esempio n. 24
0
			<td style="width: 85px; padding: 5px; text-align: center;" class="fabriqmodules-config-col">
			<?php 
        if ($module->hasconfigs == 1 && $module->installed == 1) {
            ?>
				<button type="button" id="config-button-<?php 
            echo $module->id;
            ?>
" onclick="FabriqModules.configurationForm(<?php 
            echo $module->id;
            ?>
);">configure</button>
			<?php 
        } else {
            ?>
				&nbsp;
			<?php 
        }
        ?>
			</td>
		</tr>
<?php 
    }
    ?>
	</tbody>
</table>
<?php 
} else {
    FabriqModules::module('roles')->noPermission();
    FabriqModules::render('roles', 'noPermission');
    FabriqModules::has_permission(false);
}
Esempio n. 25
0
<?php

/**
 * @file Module display file - DO NOT EDIT
 * @author Will Steinmetz
 * This view is used whenever a page's content is rendered
 * completely by one or more modules
 * 
 * Copyright (c)2010, Ralivue.com
 * Licensed under the BSD license.
 * http://fabriqframework.com/license
 */
echo FabriqModules::body();
 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);
 }