You are here

README.txt in User Relationships 5

User Relationships Module
-------------------------
This module allows users to create named relationships between each other.

Relationship types are defined by the admins.

Multiple relationships are supported and can be enabled or disabled

Send comments to Jeff Smick: http://drupal.org/user/107579/contact


Requirements
------------
Drupal 5


Installation
------------
1. Copy the user_relationships folder to the appropriate Drupal directory.

2. Enable User Relationships in the "Site building -> modules" administration screen.

   Enabling the User Relationships module will trigger the creation of the database schema. 
   If you are shown error messages you may have to create the schema by hand. Please 
   see the database definition at the end of this file.

3. Create relationship types in "User Management -> User Relationships -> Add relationship"


Memcache Users
--------------

The User Relationships module uses drupal's caching API to save results across page loads. The memcache
module replaces drupal's default API with it's own implementations of cache_set, cache_get and
cache_clear_all. Unfortunately, memcache's implementation of cache_clear_all doesn't honor the third
(wildcard) parameter. If you have memcache installed, then the cache will not be properly cleared when
you delete a user or a relationship type, resulting in stale data that may persist indefinitely.

If you have memcache installed, you should implement the following two hooks in your module:

/*
 * Implementation of hook_user()
 */
function YOURMODULE_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'delete':
      if (module_exists('memcache')) {
        // memcache's implementation of cache_clear_all doesn't support wildcarding,
        // so wipe the entire user relationship cache by passing a null cache id
        dpm("Deleting a user - clearing UR cache");
        cache_clear_all(NULL, 'cache_user_relationships');
      }
      break;
  }
}

/*
 * Implementation of hook_user_relationships()
 */
function YOURMODULE_user_relationships($type, &$relationship, $category = NULL) {
  switch ($type) {
    case 'delete type':
      if (module_exists('memcache')) {
        // memcache's implementation of cache_clear_all doesn't support wildcarding,
        // so wipe the entire user relationship cache by passing a null cache id
        cache_clear_all(NULL, 'cache_user_relationships');
      }
      break;
  }
}


Developers
------------
I tried to make this module as modular as possible (is that a horrible sentence? I don't care).
This is the core to a more robust set of features that are built as addons. I tried to make it as
extensible as possible. If you need something more out of the core (and I hope that you don't), please
feel free to get in contact with me (http://drupal.org/user/107579/contact) and we can talk about it.

Take a look at the following files for more information about the API and theme-able functions provided
  user_relationships_api.inc
  user_relationships_theme.inc

The module also invokes a "user_relationships" hook passing in the following argumens:
  $type will be a string of the following
    'insert type'   before a new relationship type is created
    'update type'   before a relationship type is updated
    'delete type'   after a relationship type is deleted
    'load type'     after a relationship type is loaded (so you can add data to it if you'd like)

    'load'          after a relationship is loaded
    'insert'        after a new relationship is created
    'update'        before a relationship is updated
    'delete'        after a relationship is deleted

  $relationship either the relationship_type or relationship object
  
  $category a string currently only used when 'delete' is invoked
    'remove'        when a relationship is removed
    'cancel'        when a relationship request is cancelled
    'disapprove'    when a relationship request is disapprove


Database Schema
---------------
MySQL
=====

--
-- Table structure for table `user_relationships`
--
CREATE TABLE IF NOT EXISTS `user_relationships` (
`rid` int(10) unsigned NOT NULL default '0',
`requester_id` int(11) NOT NULL default '0',
`requestee_id` int(11) NOT NULL default '0',
`rtid` int(11) NOT NULL default '0',
`approved` tinyint(1) NOT NULL default '0',
`created_at` datetime NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`rid`),
KEY `requester_id` (`requester_id`),
KEY `requestee_id` (`requestee_id`),
KEY `rtid` (`rtid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `user_relationship_types`
--
CREATE TABLE IF NOT EXISTS `user_relationship_types` (
`rtid` int(10) unsigned NOT NULL default '0',
`name` varchar(255) NOT NULL default '',
`plural_name` varchar(255) NOT NULL default '',
`is_oneway` tinyint(1) NOT NULL default '0',
`requires_approval` tinyint(1) NOT NULL default '0',
`expires_val` int(10) unsigned NOT NULL default 0,
PRIMARY KEY (`rtid`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `cache_user_relationships`
--
CREATE TABLE IF NOT EXISTS `cache_user_relationships` (
`cid` varchar(255) NOT NULL default '',
`data` longblob,
`expire` int(11) NOT NULL default 0,
`created` int(11) NOT NULL default 0,
`headers` text,
`serialized` int(1) NOT NULL default 0,
PRIMARY KEY (`cid`),
KEY `expire` (`expire`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


Credits
-------
Written by Jeff Smick.
Written originally for and financially supported by OurChart Inc. (http://www.ourchart.com)
Thanks to the BuddyList module team for their inspiration

File

README.txt
View source
  1. User Relationships Module
  2. -------------------------
  3. This module allows users to create named relationships between each other.
  4. Relationship types are defined by the admins.
  5. Multiple relationships are supported and can be enabled or disabled
  6. Send comments to Jeff Smick: http://drupal.org/user/107579/contact
  7. Requirements
  8. ------------
  9. Drupal 5
  10. Installation
  11. ------------
  12. 1. Copy the user_relationships folder to the appropriate Drupal directory.
  13. 2. Enable User Relationships in the "Site building -> modules" administration screen.
  14. Enabling the User Relationships module will trigger the creation of the database schema.
  15. If you are shown error messages you may have to create the schema by hand. Please
  16. see the database definition at the end of this file.
  17. 3. Create relationship types in "User Management -> User Relationships -> Add relationship"
  18. Memcache Users
  19. --------------
  20. The User Relationships module uses drupal's caching API to save results across page loads. The memcache
  21. module replaces drupal's default API with it's own implementations of cache_set, cache_get and
  22. cache_clear_all. Unfortunately, memcache's implementation of cache_clear_all doesn't honor the third
  23. (wildcard) parameter. If you have memcache installed, then the cache will not be properly cleared when
  24. you delete a user or a relationship type, resulting in stale data that may persist indefinitely.
  25. If you have memcache installed, you should implement the following two hooks in your module:
  26. /*
  27. * Implementation of hook_user()
  28. */
  29. function YOURMODULE_user($op, &$edit, &$account, $category = NULL) {
  30. switch ($op) {
  31. case 'delete':
  32. if (module_exists('memcache')) {
  33. // memcache's implementation of cache_clear_all doesn't support wildcarding,
  34. // so wipe the entire user relationship cache by passing a null cache id
  35. dpm("Deleting a user - clearing UR cache");
  36. cache_clear_all(NULL, 'cache_user_relationships');
  37. }
  38. break;
  39. }
  40. }
  41. /*
  42. * Implementation of hook_user_relationships()
  43. */
  44. function YOURMODULE_user_relationships($type, &$relationship, $category = NULL) {
  45. switch ($type) {
  46. case 'delete type':
  47. if (module_exists('memcache')) {
  48. // memcache's implementation of cache_clear_all doesn't support wildcarding,
  49. // so wipe the entire user relationship cache by passing a null cache id
  50. cache_clear_all(NULL, 'cache_user_relationships');
  51. }
  52. break;
  53. }
  54. }
  55. Developers
  56. ------------
  57. I tried to make this module as modular as possible (is that a horrible sentence? I don't care).
  58. This is the core to a more robust set of features that are built as addons. I tried to make it as
  59. extensible as possible. If you need something more out of the core (and I hope that you don't), please
  60. feel free to get in contact with me (http://drupal.org/user/107579/contact) and we can talk about it.
  61. Take a look at the following files for more information about the API and theme-able functions provided
  62. user_relationships_api.inc
  63. user_relationships_theme.inc
  64. The module also invokes a "user_relationships" hook passing in the following argumens:
  65. $type will be a string of the following
  66. 'insert type' before a new relationship type is created
  67. 'update type' before a relationship type is updated
  68. 'delete type' after a relationship type is deleted
  69. 'load type' after a relationship type is loaded (so you can add data to it if you'd like)
  70. 'load' after a relationship is loaded
  71. 'insert' after a new relationship is created
  72. 'update' before a relationship is updated
  73. 'delete' after a relationship is deleted
  74. $relationship either the relationship_type or relationship object
  75. $category a string currently only used when 'delete' is invoked
  76. 'remove' when a relationship is removed
  77. 'cancel' when a relationship request is cancelled
  78. 'disapprove' when a relationship request is disapprove
  79. Database Schema
  80. ---------------
  81. MySQL
  82. =====
  83. --
  84. -- Table structure for table `user_relationships`
  85. --
  86. CREATE TABLE IF NOT EXISTS `user_relationships` (
  87. `rid` int(10) unsigned NOT NULL default '0',
  88. `requester_id` int(11) NOT NULL default '0',
  89. `requestee_id` int(11) NOT NULL default '0',
  90. `rtid` int(11) NOT NULL default '0',
  91. `approved` tinyint(1) NOT NULL default '0',
  92. `created_at` datetime NOT NULL,
  93. `updated_at` timestamp NOT NULL,
  94. PRIMARY KEY (`rid`),
  95. KEY `requester_id` (`requester_id`),
  96. KEY `requestee_id` (`requestee_id`),
  97. KEY `rtid` (`rtid`)
  98. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  99. --
  100. -- Table structure for table `user_relationship_types`
  101. --
  102. CREATE TABLE IF NOT EXISTS `user_relationship_types` (
  103. `rtid` int(10) unsigned NOT NULL default '0',
  104. `name` varchar(255) NOT NULL default '',
  105. `plural_name` varchar(255) NOT NULL default '',
  106. `is_oneway` tinyint(1) NOT NULL default '0',
  107. `requires_approval` tinyint(1) NOT NULL default '0',
  108. `expires_val` int(10) unsigned NOT NULL default 0,
  109. PRIMARY KEY (`rtid`),
  110. UNIQUE KEY `name` (`name`)
  111. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  112. --
  113. -- Table structure for table `cache_user_relationships`
  114. --
  115. CREATE TABLE IF NOT EXISTS `cache_user_relationships` (
  116. `cid` varchar(255) NOT NULL default '',
  117. `data` longblob,
  118. `expire` int(11) NOT NULL default 0,
  119. `created` int(11) NOT NULL default 0,
  120. `headers` text,
  121. `serialized` int(1) NOT NULL default 0,
  122. PRIMARY KEY (`cid`),
  123. KEY `expire` (`expire`)
  124. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  125. Credits
  126. -------
  127. Written by Jeff Smick.
  128. Written originally for and financially supported by OurChart Inc. (http://www.ourchart.com)
  129. Thanks to the BuddyList module team for their inspiration