[commits] [Wiki] changed: Doc/Dev/SharesHowtoH4

Ralf Lang lang at b1-systems.de
Mon Mar 7 21:22:59 UTC 2011


rlang  Mon, 07 Mar 2011 21:22:59 +0000

Modified page: http://wiki.horde.org/Doc/Dev/SharesHowtoH4
New Revision:  1.2
Change log:  delegate share handling to a list page. add migration example

@@ -29,26 +29,163 @@

      }
  </code>

-+++ shares administration link in Application.php menu()
++++ List of safes in Application.php menu()

-
-Next we want to add a link to the shares administration screen in the menu.
+Next we want to add a page with a list of safes (shares) in the menu.
  Go to the menu() function in Application.php

  <code>
+        $menu->add(Horde::url('safes.php'), _("Password Safes"), 'user.png');
+</code>

-        if (!empty($GLOBALS['hort_shares']) &&  
empty($GLOBALS['conf']['share']['no_sharing'])) {
-            $menu->add('#', _("_Permissions"), 'perms.png', null, '',
-             
Horde::popupJs(Horde::url($GLOBALS['registry']->get('webroot',  
'horde') . '/services/shares/edit.php', true),
-            array('params' => array('app' => 'ingo',
-                  'share' => $GLOBALS['session']->get('ingo',  
'backend/id') . ':' . $GLOBALS['registry']->getAuth()),
-                  'urlencode' => true)) . 'return false;');
+
++++ migrations script (database setup) for shares and sharesng driver tables
+Create a directory hort/migrations/ with a file 1_hort_tables.php
+
+
+<code>
+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'));
          }

-</code>
+        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');
+        }

-+++ migrations script (database setup) for shares and sharesng driver tables
+        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');
+    }
+
+}
+
+</code>



More information about the commits mailing list