| 1 |
// $Id$
|
| 2 |
|
| 3 |
=============
|
| 4 |
== Summary ==
|
| 5 |
=============
|
| 6 |
|
| 7 |
This module allows users to add images ("decos") to their profiles. Images are
|
| 8 |
imported from popular image hosting services. Users with the correct permission
|
| 9 |
levels can add decos to the system, buy them for their profile with Userpoints,
|
| 10 |
flag them as inappropriate, edit them, send them to others, or moderate them.
|
| 11 |
Administrators can also mass import decos with relaxed settings.
|
| 12 |
|
| 13 |
One block is provided. On user pages, it displays the relevant user's decos. On
|
| 14 |
other pages, it displays the current user's decos. Decos also show up on users'
|
| 15 |
profiles.
|
| 16 |
|
| 17 |
Decos are not nodes, and never will be, and so are not indexed. However, they
|
| 18 |
are searchable from the gallery page. When decos are added they can be put into
|
| 19 |
categories for more accurate searching. Admin can choose to preset categories
|
| 20 |
or allow users to choose their own.
|
| 21 |
|
| 22 |
This module integrates with activity.module and depends on userpoints.module.
|
| 23 |
It also integrates with trigger.module.
|
| 24 |
|
| 25 |
==============
|
| 26 |
== Settings ==
|
| 27 |
==============
|
| 28 |
|
| 29 |
Most of User Deco's settings should be self-explanatory. However, a common
|
| 30 |
request is the ability for administrators to moderate all decos before they show
|
| 31 |
up to the public.
|
| 32 |
|
| 33 |
To do this, admin should enable auto-flagging on the settings page, and set the
|
| 34 |
number of flags before decos are hidden to one. If you do this, you will
|
| 35 |
probably not want to give the "flag user_decos" permission to non-admin.
|
| 36 |
|
| 37 |
=====================
|
| 38 |
== Development/API ==
|
| 39 |
=====================
|
| 40 |
|
| 41 |
This module's code is heavily documented and generally styled in the Drupal Way,
|
| 42 |
for any developers that would like to take a look.
|
| 43 |
|
| 44 |
For anyone who doesn't want to delve that deeply, this module provides a robust
|
| 45 |
API that you can use to take advantage of its functionality from anywhere you
|
| 46 |
can use PHP. For more information, see the function descriptions in the module
|
| 47 |
file itself.
|
| 48 |
|
| 49 |
==Theme Functions==
|
| 50 |
theme('user_deco_arrange', $uid)
|
| 51 |
Displays a list of decos belonging to the relevant user.
|
| 52 |
theme('user_deco_gallery', $type='gallery', $option='recpop')
|
| 53 |
Displays a list of decos with relevant links. $type can be one of 'gallery,'
|
| 54 |
'mine,' 'added,' 'flagged,' and 'custom.' It determines the style of the
|
| 55 |
result. $option is only relevant with 'gallery' and 'custom' types. With
|
| 56 |
'gallery' it can be 'recency,' 'popularity,' or 'recpop' (recent popularity)
|
| 57 |
and determines the order of the results. With 'custom' it is an array of deco
|
| 58 |
objects like user_deco_get_decos returns.
|
| 59 |
theme('user_deco_unit', $deco, $type='gallery', $instance = 1)
|
| 60 |
Displays a deco with relevant links. $deco is a deco object and $type is the
|
| 61 |
same as above. If the gallery type is 'received,' $instance is the number of
|
| 62 |
times the deco has already been rendered, so that we can show the correct
|
| 63 |
sender.
|
| 64 |
theme('user_deco_image', $deco, $show_user_count=FALSE)
|
| 65 |
Displays the image for a deco. $deco is a deco object. $show_user_count is a
|
| 66 |
boolean that determines whether to show the number of users using the deco in
|
| 67 |
the title attribute.
|
| 68 |
|
| 69 |
==Module Functions==
|
| 70 |
user_deco_get_decos($uid=0, $option='recpop', $hide_private = TRUE)
|
| 71 |
Returns an array of deco objects. If $uid is zero all decos are returned and
|
| 72 |
$option specifies how they should be ordered ('popularity,' 'recency,'
|
| 73 |
'recpop' [recent popularity] or 'flag_count'). Otherwise the returned decos
|
| 74 |
belong to the specified user and $option determines whether to return decos
|
| 75 |
that were bought or added by the relevant user ('bought' or 'added'). If $uid
|
| 76 |
is zero and $option is not 'flag_count,' $hide_private controls whether only
|
| 77 |
public decos or all decos are returned.
|
| 78 |
user_deco_load($did)
|
| 79 |
Returns a deco object containing the did, price, url, title, author, private
|
| 80 |
status, and flag_count. $did is the deco ID.
|
| 81 |
user_count_decos($uid=0, $distinct=FALSE)
|
| 82 |
Returns the number of decos a user has. $distinct is a boolean: if TRUE, each
|
| 83 |
deco counts only once, even if the user has bought it multiple times. If
|
| 84 |
FALSE, all decos are counted, including duplicates.
|
| 85 |
user_deco_decoapi($deco, $operation, $uid=0)
|
| 86 |
Allows arbitrary actions to be performed on (existing) decos. $deco is a deco
|
| 87 |
object or a deco ID. $operation can be one of 'buy,' 'clear,' 'delete,'
|
| 88 |
'flag,' and 'remove.' $uid is the user who performed the action but is
|
| 89 |
irrelevant for 'clear' and 'delete' operations. Returns the URL to which the
|
| 90 |
user would be most likely to be redirected after the operation, or FALSE if an
|
| 91 |
incorrect operation is specified.
|
| 92 |
|
| 93 |
==Hooks==
|
| 94 |
hook_user_deco_links_before($deco, $type)
|
| 95 |
Allows adding links or text under decos when they are displayed using
|
| 96 |
theme('user_deco_unit') as in galleries. These links are displayed before
|
| 97 |
other links. Modules implementing this hook should return an array of strings
|
| 98 |
(links) with numeric keys.
|
| 99 |
hook_user_deco_links_after($deco, $type)
|
| 100 |
Works the same as hook_user_deco_links_before except that the links appear
|
| 101 |
after other links.
|
| 102 |
|
| 103 |
==Helper Functions==
|
| 104 |
User Deco uses several "helper" functions that are not considered part of the
|
| 105 |
API, but might still be useful to you. If you think you might need them, take a
|
| 106 |
look at the module file; functions are grouped in labeled sections, so they
|
| 107 |
should be easy to find. Only advanced developers should use these functions!
|
| 108 |
They can be dangerous, and usually the API provides a better way to do what you
|
| 109 |
want.
|
| 110 |
|
| 111 |
==================
|
| 112 |
== Installation ==
|
| 113 |
==================
|
| 114 |
|
| 115 |
1. Install this module as usual (FTP the files to sites/all/modules, enable
|
| 116 |
at admin/build/modules). See http://drupal.org/node/176044 for help.
|
| 117 |
|
| 118 |
2. Go to admin/settings/user_deco and adjust the settings as needed.
|
| 119 |
|
| 120 |
3. Go to admin/user/access#module-user_deco and set the permissions there.
|
| 121 |
|
| 122 |
4. Go to admin/build/block and put the block in the regions you want them.
|
| 123 |
|
| 124 |
5. Still on admin/build/block, configure the settings for the block.
|
| 125 |
|
| 126 |
6. Go to admin/build/menu and add any of the user_deco pages to your menus.
|
| 127 |
|
| 128 |
7. Go to admin/settings/userpoints and adjust the amount of userpoints you
|
| 129 |
want users to receive for adding decos.
|
| 130 |
|
| 131 |
8. If you are using the Activity module, go to admin/settings/activity and
|
| 132 |
adjust the settings for User Deco there as you wish. If you do not save
|
| 133 |
the page, activity integration will not work at all, even if you did not
|
| 134 |
change any settings.
|
| 135 |
|
| 136 |
|
| 137 |
===========
|
| 138 |
== Links ==
|
| 139 |
===========
|
| 140 |
|
| 141 |
Visit the module page for more information.
|
| 142 |
|
| 143 |
Module Page: http://drupal.org/project/user_deco
|
| 144 |
Userpoints: http://drupal.org/project/userpoints
|
| 145 |
Activity: http://drupal.org/project/activity
|
| 146 |
|
| 147 |
Enable Module: http://example.com/?q=admin/build/modules
|
| 148 |
Settings Page: http://example.com/?q=admin/settings/user_deco
|
| 149 |
Set Permissions: http://example.com?q=admin/user/access#module-user_deco
|
| 150 |
Enable Block: http://example.com/?q=admin/build/block
|
| 151 |
Menu Page: http://example.com?q=admin/build/menu
|
| 152 |
Userpoints Settings: http://example.com?q=admin/settings/userpoints
|
| 153 |
Activity Settings: http://example.com?q=admin/settings/activity
|
| 154 |
|
| 155 |
User Deco Gallery: http://example.com?q=user_deco
|