| 1 |
==============================================================================
|
| 2 |
FRIENDLIST
|
| 3 |
==============================================================================
|
| 4 |
|
| 5 |
Description: Friendlist is a powerful module to manage user relationships.
|
| 6 |
Maintainer: mercmobily
|
| 7 |
Co-Maintainer: mariusooms
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
.----------------------------------------------------------------------------.
|
| 12 |
| - Contents - |
|
| 13 |
'----------------------------------------------------------------------------'
|
| 14 |
|
| 15 |
SECTION 1 Introduction
|
| 16 |
SECTION 1.1 Relations
|
| 17 |
SECTION 1.2 Statuses
|
| 18 |
--------------------------------------------------------------
|
| 19 |
SECTION 2 Theming and UI functions
|
| 20 |
--------------------------------------------------------------
|
| 21 |
SECTION 3 Module dependency
|
| 22 |
--------------------------------------------------------------
|
| 23 |
SECTION 4 Views Integration
|
| 24 |
SECTION 4.1 Default Views
|
| 25 |
SECTION 4.2 Views Tutorial - From scratch
|
| 26 |
SECTION 4.3 Views Tutorial - Picture support
|
| 27 |
SECTION 4.4 Views Tutorial - Friend feed logged in user
|
| 28 |
--------------------------------------------------------------
|
| 29 |
SECTION 5 Rules Integration
|
| 30 |
SECTION 5.1 Default Rules
|
| 31 |
SECTION 5.2 Rules Tutorial - From scratch
|
| 32 |
SECTION 5.3 Rules Tutorial - Two way without confirmation
|
| 33 |
--------------------------------------------------------------
|
| 34 |
SECTION 6 Styling friendlist
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
.----------------------------------------------------------------------------.
|
| 39 |
| - SECTION 1: Introduction - |
|
| 40 |
'----------------------------------------------------------------------------'
|
| 41 |
|
| 42 |
Friendlist is a powerful module to manage user relationships, but friendlist
|
| 43 |
doesn't just manage friends: using the Friendlist UI module, you can define as
|
| 44 |
many relation types as you like. Relations can be one way or two way, and can
|
| 45 |
be active or inactive. The module comes preset with two types of relations,
|
| 46 |
"friend" and "fan", which are set to active by default.
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
.----------------------------------------------------------------------------.
|
| 51 |
| - SECTION 1.1: Relations - |
|
| 52 |
'----------------------------------------------------------------------------'
|
| 53 |
|
| 54 |
There are two types of relationships:
|
| 55 |
|
| 56 |
* One way
|
| 57 |
* Two way
|
| 58 |
|
| 59 |
A one way relation is one that can exist without being mutual. No confirmation
|
| 60 |
or approval is needed or possible.
|
| 61 |
|
| 62 |
In database terms, only one record exists for each one way relation.
|
| 63 |
|
| 64 |
A two way relations need to be mutual in order to be complete. For example, in
|
| 65 |
order for two people to be friends, user 1 needs to be friends with friends 2,
|
| 66 |
and vice versa. If mutuality is not there, there will be an expectation from
|
| 67 |
the other user to either accept or refuse the request.
|
| 68 |
|
| 69 |
In database terms, a mutual relation will have two records: one from user 1 to
|
| 70 |
user 2, and one from user 2 to user 1. On the other hand, a refused
|
| 71 |
relationship will have one record only: user 1 to user 2. The record will also
|
| 72 |
have a "disregarded" flag, which basically means "the other user has
|
| 73 |
declined". If the "disregarded" flag is not there, then the relation is
|
| 74 |
considered "pending".
|
| 75 |
|
| 76 |
Assume that user 1 is the requester, and user 2 is the requestee. user 1 wants
|
| 77 |
to be friends with user 2. A row gets created in the database, but that's not
|
| 78 |
enough: in order for the friendship to be mutual, user 2 needs ALSO to become
|
| 79 |
friends with user 1. user 2 at this point has two options:
|
| 80 |
|
| 81 |
- Disregard user 1's request. This will add a disregarded_time field to user
|
| 82 |
1's request. User 1 won't be able to send new requests either, and (MOST
|
| 83 |
importantly) won't be able to delete the denied request to user 2.
|
| 84 |
- Accept user 1's request. If this happens, effectively user 1 is now friends
|
| 85 |
with user 2, and vice versa.
|
| 86 |
|
| 87 |
This has the following implications:
|
| 88 |
|
| 89 |
- As already stated earlier, if user 1 has a disregarded friendship with user
|
| 90 |
2, then user 1 is _stuck_ with it. This record is important to make sure
|
| 91 |
that user 1 doesn't send more requests to user 2, prevent abuse.
|
| 92 |
- If user 2 decides LATER to become friends with user 1, then the friendship
|
| 93 |
can be established right away. The friendship becomes mutual AND the
|
| 94 |
disregarded field in user 1's record gets reset.
|
| 95 |
- If user 1 decides to STOP being friends with user 2, a disregarded flag will
|
| 96 |
be set on user 2's request for being friends with him. This will prevent
|
| 97 |
user 2 from sending further requests.
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
.----------------------------------------------------------------------------.
|
| 102 |
| - SECTION 1.2: Statuses - |
|
| 103 |
'----------------------------------------------------------------------------'
|
| 104 |
|
| 105 |
Statuses are a very, very crucial part of Friendlist. Statuses is what make
|
| 106 |
friendlist immensely powerful and unique (compared to other relation modules).
|
| 107 |
Here is a list of possible statuses, taken from the module's developers'
|
| 108 |
documentation:
|
| 109 |
|
| 110 |
------------------------------------------------------------------------------
|
| 111 |
* --- IF THE RELATIONSHIP TYPE IS ONE WAY:
|
| 112 |
* OW_NONE : Inactive. On both sides.
|
| 113 |
* OW_1_TO_2 : Active. Relation $requester -> requestee
|
| 114 |
* OW_2_TO_1 : Active. Relation $requestee -> requester
|
| 115 |
* OW_BOTH : Active. Relation $requester -> requestee AND vice-versa
|
| 116 |
*
|
| 117 |
* --- IF THE RELATIONSHIP TYPE IS TWO WAY:
|
| 118 |
* TW_NONE : Inactive. On both sides.
|
| 119 |
* TW_1_TO_2_P : Inactive. $requester requested, $requestee didn't disregard
|
| 120 |
* TW_1_TO_2_D : Inactive. $requester requested, $requestee disregarded
|
| 121 |
* TW_2_TO_1_P : Inactive. $requestee requested, $requester didn't disregard
|
| 122 |
* TW_2_TO_1_D : Inactive. $requestee requested, $requester disregarded
|
| 123 |
* TW_BOTH : Active. TWO WAY. They are each others "friends".
|
| 124 |
------------------------------------------------------------------------------
|
| 125 |
|
| 126 |
While it's not important that you know the name of each status, it is
|
| 127 |
important that you know they exist as this will help you deal with Views,
|
| 128 |
Rules, etc, as these statutes dictate the actions you can take.
|
| 129 |
|
| 130 |
Remember that a status is always considered from one user to the other. So, if
|
| 131 |
you have two users, Oscar and Tom, and you check the status of their two way
|
| 132 |
relationship:
|
| 133 |
|
| 134 |
* If Oscar -> Tom is TW_1_TO_2_P, then Tom -> Oscar will be TW_2_TO_1_P.
|
| 135 |
* If their relationship is established, then the status is always TW_BOTH.
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
.----------------------------------------------------------------------------.
|
| 140 |
| - SECTION 2: Theming and UI functions - |
|
| 141 |
'----------------------------------------------------------------------------'
|
| 142 |
|
| 143 |
Friendlist comes with FriendList UI, a powerful module that lets you actually
|
| 144 |
_do_ things with it. This module has two functions you will probably find
|
| 145 |
useful as a user/themer:
|
| 146 |
|
| 147 |
/**
|
| 148 |
* function friendlist_ui_get_link($op, $account, $rtid)
|
| 149 |
*
|
| 150 |
* In friendlist, a friend can be added or deleted. This function
|
| 151 |
* will return the right link (with the right text!) to add or delete
|
| 152 |
* a user
|
| 153 |
*
|
| 154 |
* @param $op
|
| 155 |
* It could be 'add' or 'delete', depending on what type of link you
|
| 156 |
* want
|
| 157 |
* @param $account
|
| 158 |
* The user object (or id) you want the links for
|
| 159 |
* @param $rtid
|
| 160 |
* The relation type id you want the links for
|
| 161 |
*
|
| 162 |
* @return
|
| 163 |
* The link ready to be used.
|
| 164 |
*/
|
| 165 |
|
| 166 |
|
| 167 |
/**
|
| 168 |
* function friendlist_ui_user_links($account)
|
| 169 |
*
|
| 170 |
* An HTML-formatted list of links for EVERY relation type for
|
| 171 |
* the user. This function is used by the hook_user() hook
|
| 172 |
* to show links about the user.
|
| 173 |
*
|
| 174 |
* @param $account
|
| 175 |
* The user object (or id) you want the links for
|
| 176 |
*
|
| 177 |
* @return
|
| 178 |
* HTML items, formatted with theme_item_list
|
| 179 |
*/
|
| 180 |
|
| 181 |
Especially the second one can be placed anywhere you like, and it will give
|
| 182 |
you the list of every action for any relation type. It's what the module
|
| 183 |
itself uses for the user profile pages.
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
.----------------------------------------------------------------------------.
|
| 188 |
| - SECTION 3: Module Integration and Dependency - |
|
| 189 |
'----------------------------------------------------------------------------'
|
| 190 |
|
| 191 |
Friendlist uses several other modules. The idea is to not reinvent the wheel,
|
| 192 |
but harness the power of other modules. This has several advantages.
|
| 193 |
|
| 194 |
For one, it creates consistency for the friendlist module as this prevents
|
| 195 |
it in becoming a mash-up of code. It also helps the module stay specific
|
| 196 |
in using other other modules which have an equal specific function. Some
|
| 197 |
modules it depends on, while other modules add a specific functionality.
|
| 198 |
|
| 199 |
Dependent:
|
| 200 |
Views - http://drupal.org/project/views (Friendlist Blocks and Pages)
|
| 201 |
Rules - http://drupal.org/project/rules (Friendlist Notifications)
|
| 202 |
|
| 203 |
Not dependent, but strongly advised:
|
| 204 |
Token - http://drupal.org/project/token (Token support Rules and Activity_log)
|
| 205 |
|
| 206 |
Integrated:
|
| 207 |
Activity Log - http://drupal.org/project/activity_log (Activity Stream)
|
| 208 |
Popups - http://drupal.org/project/popups (Instant modal message support)
|
| 209 |
CCK Field Privacy - http://drupal.org/project/cck_field_privacy
|
| 210 |
Profile Privacy - http://drupal.org/project/profile_privacy (Pending)
|
| 211 |
|
| 212 |
NOTE: Some of these modules have not released official version yet and
|
| 213 |
require dev installs. They all have been tested and are fully functional.
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
.----------------------------------------------------------------------------.
|
| 218 |
| - SECTION 4: Views Integration - |
|
| 219 |
'----------------------------------------------------------------------------'
|
| 220 |
|
| 221 |
Views is a very powerful and flexible module to create custom pages and blocks
|
| 222 |
that list content according to a specific database query. Because Views can be
|
| 223 |
intimidating at first you can the reference below for additional help or you
|
| 224 |
can install the advanced help module module.
|
| 225 |
|
| 226 |
http://views-help.doc.logrus.com/
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
.----------------------------------------------------------------------------.
|
| 231 |
| - SECTION 4.1: Default Views - |
|
| 232 |
'----------------------------------------------------------------------------'
|
| 233 |
|
| 234 |
The module comes with 4 pre-configured views, which should get most users up
|
| 235 |
and running. You can always use the pre-configured views as a guide when
|
| 236 |
creating your own views. They are named:
|
| 237 |
|
| 238 |
- friendlist_manage_oneway
|
| 239 |
- friendlist_public_oneway
|
| 240 |
- friendlist_manage_twoway
|
| 241 |
- friendlist_public_twoway
|
| 242 |
|
| 243 |
- friendlist_manage_oneway
|
| 244 |
This view consists of one page display only. It deals with all connections
|
| 245 |
the user has made to other users with the available actions. The default
|
| 246 |
path of this view is /connections/manage/oneway. It is only accessible by
|
| 247 |
the logged in user.
|
| 248 |
|
| 249 |
- friendlist_public_oneway
|
| 250 |
This view consists of two block displays and two page displays. One pair of
|
| 251 |
block and page display deal with the connections the current user has
|
| 252 |
established. We refer to these as "following" connections. The second pair
|
| 253 |
of block and page display deals with connections others have made to the
|
| 254 |
current user. We refer to these as "follower" connections. Each block
|
| 255 |
display has a 'more' link that links to the users list of all following and
|
| 256 |
follower connections.
|
| 257 |
|
| 258 |
- friendlist_manage_twoway
|
| 259 |
This view consists of three page displays. One for managing all TW_Both
|
| 260 |
relationships. One for dealing with TW_1_TO_2_P relations from the requestee
|
| 261 |
and another page for dealing with TW_1_TO_2_P from the requester. Their
|
| 262 |
paths are respectively, /connections/manage/twoway, /connections/send and
|
| 263 |
/connections/received. They are only accessible by the logged in user.
|
| 264 |
|
| 265 |
- friendlist_public_twoway
|
| 266 |
This view consists of one block display and one page display. They both deal
|
| 267 |
with TW_BOTH relations and show the latest mutual connections in relation to
|
| 268 |
to the current user. The block display has a 'more' link that links to the
|
| 269 |
users list of all mutual connections.
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
.----------------------------------------------------------------------------.
|
| 274 |
| - SECTION 4.2: Views Tutorial - From scratch - |
|
| 275 |
'----------------------------------------------------------------------------'
|
| 276 |
|
| 277 |
*** Creating a "Relations between users" type view ***
|
| 278 |
|
| 279 |
______________________________________________________________________________
|
| 280 |
|
| 281 |
The scenario:
|
| 282 |
Create a single view page that shows your established twoway connections, with
|
| 283 |
action links to manage your relations list.
|
| 284 |
______________________________________________________________________________
|
| 285 |
|
| 286 |
STEP 1 - Add view:
|
| 287 |
Select 'Add' from the views menu. Give the view a name, description and tag.
|
| 288 |
IMPORTANT! For the view type, select "Relations between users" and click Next.
|
| 289 |
|
| 290 |
You now arrive at the edit screen for the added view. The view screen is made
|
| 291 |
up out of many different sections, they are named:
|
| 292 |
- Display menu
|
| 293 |
- View settings
|
| 294 |
- Basic settings
|
| 295 |
- Block settings (visible when adding a block)
|
| 296 |
- Page settings (visible when adding a page)
|
| 297 |
- Relationships
|
| 298 |
- Arguments
|
| 299 |
- Fields
|
| 300 |
- Sort criteria
|
| 301 |
- Filters
|
| 302 |
- Live preview
|
| 303 |
|
| 304 |
It is best to work your way down through these sections as they are listed in
|
| 305 |
a logical order.
|
| 306 |
______________________________________________________________________________
|
| 307 |
|
| 308 |
STEP 2 - Display menu:
|
| 309 |
Start by adding a page display. You will now have an additional display apart
|
| 310 |
from Defaults. Each display can have unique settings by clicking the provided
|
| 311 |
override button when changing a particular setting.
|
| 312 |
______________________________________________________________________________
|
| 313 |
|
| 314 |
STEP 3 - View settings:
|
| 315 |
Go through each setting and change it to your liking. For our example table
|
| 316 |
works best for "Style".
|
| 317 |
______________________________________________________________________________
|
| 318 |
|
| 319 |
STEP 4 - Page settings:
|
| 320 |
Click path and change the path to a suitable structure, e.g. relation/manage.
|
| 321 |
Update. Next click "No menu", select "Normal menu entry" and give it a title.
|
| 322 |
Update.
|
| 323 |
______________________________________________________________________________
|
| 324 |
|
| 325 |
STEP 5 - Relationships:
|
| 326 |
Click the + icon, this brings up the available relation groups. Select both
|
| 327 |
options "Relations: Requestee user" and "Relations: Requesting user". Add.
|
| 328 |
Views will ask you to give a Label for each relation. You can leave the
|
| 329 |
default suggestion. Update both.
|
| 330 |
______________________________________________________________________________
|
| 331 |
|
| 332 |
STEP 6 - Arguments:
|
| 333 |
We can actually skip this for our tutorial. Arguments become especially useful
|
| 334 |
for friendlist when using blocks in terms for visibility.
|
| 335 |
______________________________________________________________________________
|
| 336 |
|
| 337 |
STEP 7 - FIELDS:
|
| 338 |
Click the + icon, select Statuses from Groups and check "Statuses: Status".
|
| 339 |
You can use the default Label. Update. At this point the "Live preview" will
|
| 340 |
actually start to show some information if you have made some connections
|
| 341 |
between users. Click the + icon and add "User: Name" from the User Group menu.
|
| 342 |
Add. Relationship should be "Requestee". Update. Click the + icon and select
|
| 343 |
"Relations: Action from logged in user to requestee" under the Relations
|
| 344 |
Group. Add. Name the label Actions. Note: Don't pay to much attention to Live
|
| 345 |
preview, just take note of its behavior.
|
| 346 |
______________________________________________________________________________
|
| 347 |
|
| 348 |
STEP 8 - Sort Criteria:
|
| 349 |
This is a useful section to sort your data. We can skip this. Also, because we
|
| 350 |
use a table you have all kinds of sort options by clicking the cog icon next
|
| 351 |
to table under the "Basic settings" section.
|
| 352 |
______________________________________________________________________________
|
| 353 |
|
| 354 |
STEP 9 - Filters:
|
| 355 |
Click the + icon and select "Relations: Requester user is the currently logged
|
| 356 |
in user" from the Relations Group. Add. Check "is the logged user". Update.
|
| 357 |
Click the + icon and select "Statuses: Status" from the Status Group. Add. Set
|
| 358 |
settings to "Is one of" - "TW_BOTH". Update.
|
| 359 |
______________________________________________________________________________
|
| 360 |
|
| 361 |
STEP 10 - Live preview:
|
| 362 |
At this point you can check the Live preview and should return all the
|
| 363 |
established TW_BOTH connections the logged user has made together with the
|
| 364 |
available actions in a table format.
|
| 365 |
______________________________________________________________________________
|
| 366 |
|
| 367 |
|
| 368 |
That's it...and this is only scratching the surface of things you can do.
|
| 369 |
Customize the basics to your liking by adding send messages, time stamps when
|
| 370 |
the relation was created, custom core profile fields, user pictures, sort
|
| 371 |
options, role specific restrictions, header and footer information, add more
|
| 372 |
blocks and pages. The list goes on and on! The best advice we can give is
|
| 373 |
practice, practice, practice so you get to know your management system.
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
.----------------------------------------------------------------------------.
|
| 378 |
| - SECTION 4.3: Views Tutorial - Picture support - |
|
| 379 |
'----------------------------------------------------------------------------'
|
| 380 |
|
| 381 |
[TODO]
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
.----------------------------------------------------------------------------.
|
| 386 |
| - SECTION 4.4: Views Tutorial - Friend feed logged in user - |
|
| 387 |
'----------------------------------------------------------------------------'
|
| 388 |
|
| 389 |
[TODO]
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
.----------------------------------------------------------------------------.
|
| 394 |
| - SECTION 5: Rules Integration - |
|
| 395 |
'----------------------------------------------------------------------------'
|
| 396 |
|
| 397 |
The module is fully integrated with Rules. Rules is a replacement with more
|
| 398 |
features for the trigger module in core and the successor of the workflow-ng
|
| 399 |
module. Friendlist uses it for all notifications to and from users.
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
.----------------------------------------------------------------------------.
|
| 404 |
| - SECTION 5.1: Default Rules - |
|
| 405 |
'----------------------------------------------------------------------------'
|
| 406 |
|
| 407 |
The default rules included with friendlist are:
|
| 408 |
|
| 409 |
* Friendlist - Notify recipient: Now added
|
| 410 |
* Friendlist - Notify initiator: Remove
|
| 411 |
* Friendlist - Notify requester: Request send
|
| 412 |
* Friendlist - Notify requestee: Request send
|
| 413 |
* Friendlist - Notify requester: Request accepted
|
| 414 |
* Friendlist - Notify requestee: Request accepted
|
| 415 |
* Friendlist - Notify requester: Request cancelled
|
| 416 |
* Friendlist - Notify requestee: Request cancelled
|
| 417 |
* Friendlist - Notify requester: Request declined
|
| 418 |
* Friendlist - Notify requestee: Request declined
|
| 419 |
* Friendlist - Notify requester: Relation deleted
|
| 420 |
* Friendlist - Notify requestee: Relation deleted
|
| 421 |
|
| 422 |
We will be adding more rules to this list as friendlist continues its
|
| 423 |
expansion with features.
|
| 424 |
|
| 425 |
Note that each rules uses the site wide email as the sender email. You can set
|
| 426 |
this at admin/settings/site-information. This is to ensure that the users
|
| 427 |
email stays hidden. If your users emails are public, you can easily change
|
| 428 |
each rule to reflect this if you wish.
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
.----------------------------------------------------------------------------.
|
| 433 |
| - SECTION 5.2: Rules Tutorial - From scratch - |
|
| 434 |
'----------------------------------------------------------------------------'
|
| 435 |
|
| 436 |
Every rules as the same ingredients and involves a three step process. Where
|
| 437 |
each step has multiple configuration options.
|
| 438 |
|
| 439 |
Step 1 involves creating the rule and its specific event.
|
| 440 |
Step 2 involves setting the conditions for the rule.
|
| 441 |
Step 3 involves adding actions that will be taken when the conditions are met.
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
.----------------------------------------------------------------------------.
|
| 446 |
| - SECTION 5.3: Rules Tutorial - Two way without confirmation - |
|
| 447 |
'----------------------------------------------------------------------------'
|
| 448 |
|
| 449 |
[TODO]
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
.----------------------------------------------------------------------------.
|
| 454 |
| - SECTION 6: Styling friendlist - |
|
| 455 |
'----------------------------------------------------------------------------'
|
| 456 |
|
| 457 |
Styling is easy with a little bit of css knowledge. Below is an example of how
|
| 458 |
to style the available links of friendlist. You can just copy and paste this
|
| 459 |
code in to your style-sheet. Make sure you adjust the link classes, image
|
| 460 |
dimensions and image path. This technique can easily be applied to other areas
|
| 461 |
like replacing the relation name with an icon.
|
| 462 |
|
| 463 |
/* set li to block and specify width and height of your replacement image */
|
| 464 |
|
| 465 |
ul.friendlist-user-links-multiple li {
|
| 466 |
display: block;
|
| 467 |
height: 25px;
|
| 468 |
width: 150px;
|
| 469 |
}
|
| 470 |
|
| 471 |
/* The class of the link. Use text-indent to hide text. */
|
| 472 |
|
| 473 |
ul.friendlist-user-links-multiple li a.(replace with link class) {
|
| 474 |
display: block;
|
| 475 |
height: 25px;
|
| 476 |
text-indent: -9999px;
|
| 477 |
background: url(path/to/your/images/image.gif) no-repeat left bottom;
|
| 478 |
}
|
| 479 |
|
| 480 |
/* On hover the background will move from 'left bottom' to 'left top' */
|
| 481 |
|
| 482 |
ul.friendlist-user-links-multiple li a.(replace with link class):hover {
|
| 483 |
background-position: left top;
|
| 484 |
}
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|