Some performance charts with the sql driver:
Note: the sqlite driver was test with an in-memory database
work in progress
Let's assume you followed the Creating your first module guide as far as it applies to horde4 and created a new horde app called "hort". Hort is an old German word for treasure as well as the place where the treasure is kept. Hort should keep safes which hold user/password pairs or other secret credentials. Those safes should be shareable among users. This is where horde_shares comes into play.
We want to add an injector for the shares API whenever the app is initialized and we want to auto-create an initial "home" share for users which do not yet own one.
protected function _init() { // Create a share instance. $GLOBALS['hort_shares'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create(); /* If the user doesn't own a safe, create one. */ if (!empty($GLOBALS['conf']['share']['auto_create']) && $GLOBALS['registry']->getAuth() && !$GLOBALS['hort_shares']->countShares($GLOBALS['registry']->getAuth())) { $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create(); $share = $GLOBALS['hort_shares']->newShare( $GLOBALS['registry']->getAuth(), strval(new Horde_Support_Randomid()), sprintf(_("Default safe of %s"), $identity->getName()) ); $GLOBALS['hort_shares']->addShare($share); } }
$menu->add(Horde::url('safes.php'), _("Password Safes"), 'user.png');
Create a directory hort/migrations/ with a file 1_hort_tables.php
class HortBaseTables extends Horde_Db_Migration_Base { /** * Upgrade. */ public function up() { $tableList = $this->tables(); $t = $this->createTable('hort_sharesng', array('primaryKey' => 'share_id')); $t->column('share_name', 'string', array('limit' => 255, 'null' => false)); $t->column('share_owner', 'string', array('limit' => 255)); $t->column('share_flags', 'integer', array('default' => 0, 'null' => false)); $t->column('perm_creator_' . Horde_Perms::SHOW, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_creator_' . Horde_Perms::READ, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_creator_' . Horde_Perms::EDIT, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_creator_' . Horde_Perms::DELETE, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_default_' . Horde_Perms::SHOW, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_default_' . Horde_Perms::READ, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_default_' . Horde_Perms::EDIT, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_default_' . Horde_Perms::DELETE, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_guest_' . Horde_Perms::SHOW, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_guest_' . Horde_Perms::READ, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_guest_' . Horde_Perms::EDIT, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_guest_' . Horde_Perms::DELETE, 'boolean', array('default' => false, 'null' => false)); $t->column('attribute_name', 'string', array('limit' => 255, 'null' => false)); $t->column('attribute_desc', 'string', array('limit' => 255)); $t->column('attribute_params', 'text'); $t->column('share_parents','text'); $t->end(); $this->addIndex('hort_sharesng', array('share_name')); $this->addIndex('hort_sharesng', array('share_owner')); $this->addIndex('hort_sharesng', array('perm_creator_' . Horde_Perms::SHOW)); $this->addIndex('hort_sharesng', array('perm_creator_' . Horde_Perms::READ)); $this->addIndex('hort_sharesng', array('perm_creator_' . Horde_Perms::EDIT)); $this->addIndex('hort_sharesng', array('perm_creator_' . Horde_Perms::DELETE)); $this->addIndex('hort_sharesng', array('perm_default_' . Horde_Perms::SHOW)); $this->addIndex('hort_sharesng', array('perm_default_' . Horde_Perms::READ)); $this->addIndex('hort_sharesng', array('perm_default_' . Horde_Perms::EDIT)); $this->addIndex('hort_sharesng', array('perm_default_' . Horde_Perms::DELETE)); $this->addIndex('hort_sharesng', array('perm_guest_' . Horde_Perms::SHOW)); $this->addIndex('hort_sharesng', array('perm_guest_' . Horde_Perms::READ)); $this->addIndex('hort_sharesng', array('perm_guest_' . Horde_Perms::EDIT)); $this->addIndex('hort_sharesng', array('perm_guest_' . Horde_Perms::DELETE)); $t = $this->createTable('hort_sharesng_groups', array('primaryKey' => false)); $t->column('share_id', 'integer', array('null' => false)); $t->column('group_uid', 'string', array('limit' => 255, 'null' => false)); $t->column('perm_' . Horde_Perms::SHOW, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_' . Horde_Perms::READ, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_' . Horde_Perms::EDIT, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_' . Horde_Perms::DELETE, 'boolean', array('default' => false, 'null' => false)); $t->end(); $this->addIndex('hort_sharesng_groups', array('share_id')); $this->addIndex('hort_sharesng_groups', array('group_uid')); $this->addIndex('hort_sharesng_groups', array('perm_' . Horde_Perms::SHOW)); $this->addIndex('hort_sharesng_groups', array('perm_' . Horde_Perms::READ)); $this->addIndex('hort_sharesng_groups', array('perm_' . Horde_Perms::EDIT)); $this->addIndex('hort_sharesng_groups', array('perm_' . Horde_Perms::DELETE)); $t = $this->createTable('hort_sharesng_users', array('primaryKey' => false)); $t->column('share_id', 'integer', array('null' => false)); $t->column('user_uid', 'string', array('limit' => 255, 'null' => false)); $t->column('perm_' . Horde_Perms::SHOW, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_' . Horde_Perms::READ, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_' . Horde_Perms::EDIT, 'boolean', array('default' => false, 'null' => false)); $t->column('perm_' . Horde_Perms::DELETE, 'boolean', array('default' => false, 'null' => false)); $t->end(); $this->addIndex('hort_sharesng_users', array('share_id')); $this->addIndex('hort_sharesng_users', array('user_uid')); $this->addIndex('hort_sharesng_users', array('perm_' . Horde_Perms::SHOW)); $this->addIndex('hort_sharesng_users', array('perm_' . Horde_Perms::READ)); $this->addIndex('hort_sharesng_users', array('perm_' . Horde_Perms::EDIT)); $this->addIndex('hort_sharesng_users', array('perm_' . Horde_Perms::DELETE)); if (!in_array('hort_shares', $tableList)) { $t = $this->createTable('hort_shares', array('primaryKey' => false)); $t->column('share_id', 'integer', array('null' => false)); $t->column('share_name', 'string', array('limit' => 255, 'null' => false)); $t->column('share_owner', 'string', array('limit' => 255, 'null' => false)); $t->column('share_flags', 'integer', array('default' => 0, 'null' => false)); $t->column('perm_creator', 'integer', array('default' => 0, 'null' => false)); $t->column('perm_default', 'integer', array('default' => 0, 'null' => false)); $t->column('perm_guest', 'integer', array('default' => 0, 'null' => false)); $t->column('attribute_name', 'string', array('limit' => 255, 'null' => false)); $t->column('attribute_desc', 'string', array('limit' => 255)); $t->primaryKey(array('share_id')); $t->end(); $this->addIndex('hort_shares', array('share_name')); $this->addIndex('hort_shares', array('share_owner')); $this->addIndex('hort_shares', array('perm_creator')); $this->addIndex('hort_shares', array('perm_default')); $this->addIndex('hort_shares', array('perm_guest')); } if (!in_array('hort_shares_groups', $tableList)) { $t = $this->createTable('hort_shares_groups'); $t->column('share_id', 'integer', array('null' => false)); $t->column('group_uid', 'string', array('limit' => 255, 'null' => false)); $t->column('perm', 'integer', array('null' => false)); $t->end(); $this->addIndex('hort_shares_groups', array('share_id')); $this->addIndex('hort_shares_groups', array('group_uid')); $this->addIndex('hort_shares_groups', 'perm'); } if (!in_array('hort_shares_users', $tableList)) { $t = $this->createTable('hort_shares_users'); $t->column('share_id', 'integer', array('null' => false)); $t->column('user_uid', 'string', array('limit' => 255, 'null' => false)); $t->column('perm', 'integer', array('null' => false)); $t->end(); $this->addIndex('hort_shares_users', array('share_id')); $this->addIndex('hort_shares_users', array('user_uid')); $this->addIndex('hort_shares_users', array('perm')); } } /** * Downgrade * */ public function down() { $this->dropTable('hort_shares'); $this->dropTable('hort_shares_groups'); $this->dropTable('hort_shares_users'); $this->dropTable('hort_sharesng'); $this->dropTable('hort_sharesng_groups'); $this->dropTable('hort_sharesng_users'); } }