first import
339
sites/all/modules/follow/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
74
sites/all/modules/follow/README.txt
Normal file
@@ -0,0 +1,74 @@
|
||||
DESCRIPTION
|
||||
********************************************************************************
|
||||
Follow adds sitewide and per user links that link to various social networking
|
||||
sites. The links reside in two blocks. The Follow Site block lists all the
|
||||
links for the site itself, and by default is visible on all pages. The Follow
|
||||
User block lists all the follow links for the user and is visible only on user
|
||||
profile pages. There is a setting in the Follow Site block to have it not
|
||||
display on user profile pages.
|
||||
|
||||
INSTALLATION
|
||||
********************************************************************************
|
||||
Enable the module at admin/build/modules, then go to user/admin/permissions to
|
||||
set which roles are allowed to edit the sitewide follow links, edit own follow
|
||||
links, edit all user follow links, or administer follow. Go to
|
||||
admin/build/blocks to enable the blocks. User follow links can be edited at
|
||||
user/%/follow, whereas sitewide follow links are at admin/build/follow
|
||||
|
||||
TWEAKAGE
|
||||
********************************************************************************
|
||||
Often you'll want to tweak the way the Follow links are displayed. The display
|
||||
of the icons and text is all controlled with CSS, so overriding in your own
|
||||
custom theme is simple. Here are a few examples:
|
||||
|
||||
To remove the text and only display icons:
|
||||
|
||||
a.follow-link {
|
||||
width: 24px;
|
||||
height: 25px;
|
||||
text-indent: -9999px;
|
||||
}
|
||||
|
||||
To remove all text and have icons sit next to each other:
|
||||
|
||||
a.follow-link {
|
||||
width: 24px;
|
||||
height: 25px;
|
||||
text-indent: -9999px;
|
||||
float: left;
|
||||
margin: 0 8px 8px 0;
|
||||
}
|
||||
|
||||
RECOMMENDED ADD ON
|
||||
********************************************************************************
|
||||
It is recommended to enable a module such as external [1] that will pop open
|
||||
the follow links in a new tab or window; target="_blank" is not used since it
|
||||
does not validate.
|
||||
|
||||
[1] http://drupal.org/project/external
|
||||
|
||||
SOCIAL NETWORKS
|
||||
********************************************************************************
|
||||
Here's a list of the currently supported social networks:
|
||||
- Facebook
|
||||
- Virb
|
||||
- MySpace
|
||||
- Twitter
|
||||
- Picasa
|
||||
- Flickr
|
||||
- YouTube
|
||||
- Vimeo
|
||||
- blip.tv
|
||||
- last.fm
|
||||
- LinkedIn
|
||||
- Delicious
|
||||
- Tumblr
|
||||
|
||||
ICONS
|
||||
********************************************************************************
|
||||
Although a few of the icons were hand made, most of them were created by either
|
||||
Eli Burford [1] or Yichi [2]. Thanks, you guys!
|
||||
|
||||
[1] http://www.blogperfume.com/social-media-icons-pack-in-3-sizes-for-download/
|
||||
[2] http://vikiworks.com/2007/06/15/social-bookmark-iconset/
|
||||
|
25
sites/all/modules/follow/follow.api.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Alter the available networks to the Follow module.
|
||||
*
|
||||
* @param $networks
|
||||
* Associative array of networks that are available.
|
||||
* @param $uid
|
||||
* The User ID of the networks to be displayed. If 0 is provided, will be the
|
||||
* networks for the website rather then an individual user.
|
||||
*/
|
||||
function hook_follow_networks_alter(&$networks, $uid = 0) {
|
||||
// Add a network.
|
||||
$networks['mailinglist'] = array(
|
||||
'title' => t('Mailing List'),
|
||||
'domain' => '',
|
||||
);
|
||||
|
||||
// Replace Twitter with Identi.ca
|
||||
unset($networks['twitter']);
|
||||
$networks['identica'] = array(
|
||||
'title' => t('Identi.ca'),
|
||||
'domain' => 'identi.ca',
|
||||
);
|
||||
}
|
65
sites/all/modules/follow/follow.css
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
a.follow-link {
|
||||
height: 30px;
|
||||
display: block;
|
||||
line-height: 26px;
|
||||
padding-left: 28px;
|
||||
background-position: 0 0;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
a.follow-link-facebook {
|
||||
background-image: url(icons/small/icon-facebook.png);
|
||||
}
|
||||
|
||||
a.follow-link-myspace {
|
||||
background-image: url(icons/small/icon-myspace.png);
|
||||
}
|
||||
|
||||
a.follow-link-virb {
|
||||
background-image: url(icons/small/icon-virb.png);
|
||||
}
|
||||
|
||||
a.follow-link-bliptv {
|
||||
background-image: url(icons/small/icon-bliptv.png);
|
||||
}
|
||||
|
||||
a.follow-link-lastfm {
|
||||
background-image: url(icons/small/icon-lastfm.png);
|
||||
}
|
||||
|
||||
a.follow-link-youtube {
|
||||
background-image: url(icons/small/icon-youtube.png);
|
||||
}
|
||||
|
||||
a.follow-link-twitter {
|
||||
background-image: url(icons/small/icon-twitter.png);
|
||||
}
|
||||
|
||||
a.follow-link-picasa {
|
||||
background-image: url(icons/small/icon-picasa.png);
|
||||
}
|
||||
|
||||
a.follow-link-flickr {
|
||||
background-image: url(icons/small/icon-flickr.png);
|
||||
}
|
||||
|
||||
a.follow-link-vimeo {
|
||||
background-image: url(icons/small/icon-vimeo.png);
|
||||
}
|
||||
|
||||
a.follow-link-linkedin {
|
||||
background-image: url(icons/small/icon-linkedin.png);
|
||||
}
|
||||
|
||||
a.follow-link-delicious {
|
||||
background-image: url(icons/small/icon-delicious.png);
|
||||
}
|
||||
|
||||
a.follow-link-tumblr {
|
||||
background-image: url(icons/small/icon-tumblr.png);
|
||||
}
|
||||
|
||||
a.follow-link-this-site {
|
||||
background-image: url(icons/small/icon-feed.png);
|
||||
}
|
10
sites/all/modules/follow/follow.info
Normal file
@@ -0,0 +1,10 @@
|
||||
name = Follow
|
||||
description = Add sitewide and per user links to social network profiles.
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-10-27
|
||||
version = "7.x-1.0-alpha1"
|
||||
core = "7.x"
|
||||
project = "follow"
|
||||
datestamp = "1319736332"
|
||||
|
109
sites/all/modules/follow/follow.install
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Follow module's install and uninstall code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function follow_install() {
|
||||
// Add a default link to this site's node RSS feed.
|
||||
db_insert('follow_links')
|
||||
->fields(array(
|
||||
'name' => 'this-site',
|
||||
'path' => 'rss.xml',
|
||||
'options' => 'a:0:{}',
|
||||
'uid' => 0,
|
||||
'weight' => 0,
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_schema().
|
||||
*/
|
||||
function follow_schema() {
|
||||
$schema['follow_links'] = array(
|
||||
'description' => 'Stores sitewide and user follow links.',
|
||||
'fields' => array(
|
||||
'lid' => array(
|
||||
'type' => 'serial',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Unique identifier for the {follow_links}.',
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => "The machine name of the {follow_links}.",
|
||||
),
|
||||
'uid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => "User's {users} uid. Sitewide {follow_links} use uid 0",
|
||||
),
|
||||
'path' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'The Drupal path or extenal URL the {follow_links} should point to.',
|
||||
),
|
||||
'options' => array(
|
||||
'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.',
|
||||
'type' => 'text',
|
||||
'translatable' => TRUE,
|
||||
'serialize' => TRUE,
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'The human readable name for the link.',
|
||||
),
|
||||
'weight' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'tiny',
|
||||
'description' => 'The weight of this {follow_links}.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('lid'),
|
||||
'unique keys' => array(
|
||||
'uid_name' => array('uid', 'name'),
|
||||
),
|
||||
);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall().
|
||||
*/
|
||||
function follow_uninstall() {
|
||||
variable_del('follow_user_block_title');
|
||||
variable_del('follow_site_block_title');
|
||||
variable_del('follow_site_block_user');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_update_last_removed().
|
||||
*/
|
||||
function follow_update_last_removed() {
|
||||
// We need to ensure that all D6 users have upgraded to the latest version of
|
||||
// Follow before upgrading to D7.
|
||||
return 6003;
|
||||
}
|
||||
|
||||
/**
|
||||
* Placeholder to ensure the correct schema version.
|
||||
*/
|
||||
function follow_update_7003() {
|
||||
|
||||
}
|
807
sites/all/modules/follow/follow.module
Normal file
@@ -0,0 +1,807 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Allows users to add links to their social network profiles.
|
||||
*/
|
||||
|
||||
define('FOLLOW_NAME', 0);
|
||||
define('FOLLOW_ME', 1);
|
||||
define('FOLLOW_US', 2);
|
||||
|
||||
/**
|
||||
* Implementation of hook_help().
|
||||
*/
|
||||
function follow_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'follow':
|
||||
case 'user/%/follow':
|
||||
case 'admin/config/services/follow':
|
||||
return t('Please copy and paste the url for your public profile or page for each service you would like to display in the block. Links need to match the domain of the service in question.');
|
||||
case 'admin/settings/follow':
|
||||
return t('Here you can set what the default titles are for the "follow" blocks. If you would like a custom title, edit the individual blocks <a href="!href">here</a>.', array('!href' => url('admin/build/block')));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_init().
|
||||
*/
|
||||
function follow_init() {
|
||||
drupal_add_css(drupal_get_path('module', 'follow') .'/follow.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
function follow_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/services/follow'] = array(
|
||||
'title' => 'Site follow links',
|
||||
'description' => 'Add sitewide follow links',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('follow_links_form'),
|
||||
'access arguments' => array('edit site follow links'),
|
||||
);
|
||||
|
||||
$items['user/%/follow'] = array(
|
||||
'title' => 'My follow links',
|
||||
'description' => 'edit follow links',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('follow_links_form', 1),
|
||||
'access callback' => 'follow_links_user_access',
|
||||
'access arguments' => array(1),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
// No settings!
|
||||
/* $items['admin/settings/follow'] = array(
|
||||
'title' => 'Follow',
|
||||
'description' => 'Administer the follow module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('follow_settings_form'),
|
||||
'access arguments' => array('administer follow'),
|
||||
); */
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for user follow links editing.
|
||||
*/
|
||||
function follow_links_user_access($uid) {
|
||||
return ((($GLOBALS['user']->uid == $uid) && user_access('edit own follow links')) || user_access('edit any user follow links')) && $uid > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_permission().
|
||||
*/
|
||||
function follow_permission() {
|
||||
return array(
|
||||
'edit own follow links' => array(
|
||||
'title' => t('Edit own follow links'),
|
||||
'description' => t(''),
|
||||
),
|
||||
'edit site follow links' => array(
|
||||
'title' => t('Edit the site-wide follow links'),
|
||||
'description' => t(''),
|
||||
),
|
||||
'edit any user follow links' => array(
|
||||
'title' => t("Edit any user's follow links"),
|
||||
'description' => t(''),
|
||||
),
|
||||
'administer follow' => array(
|
||||
'title' => t('Administer follow'),
|
||||
'description' => t(''),
|
||||
),
|
||||
'change follow link titles' => array(
|
||||
'title' => t('Change link titles'),
|
||||
'description' => t('Allows changing the text that appears in the follow links.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_theme().
|
||||
*/
|
||||
function follow_theme() {
|
||||
$items = array();
|
||||
|
||||
$items['follow_links_form'] = array(
|
||||
'render element' => 'form',
|
||||
);
|
||||
$items['follow_links'] = array(
|
||||
'variables' => array('links' => array(), 'networks' => array()),
|
||||
);
|
||||
$items['follow_link'] = array(
|
||||
'variables' => array('link' => NULL, 'title' => NULL),
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_preprocess_page().
|
||||
*/
|
||||
function follow_preprocess_page(&$variables) {
|
||||
// Expose the site follow links as a variable to the page template.
|
||||
if ($links = follow_links_load()) {
|
||||
$args = array(
|
||||
'links' => $links,
|
||||
'networks' => follow_networks_load(),
|
||||
);
|
||||
$variables['follow_site'] = theme('follow_links', $args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_block_info().
|
||||
*/
|
||||
function follow_block_info() {
|
||||
$blocks['site'] = array(
|
||||
'info' => t('Follow Site'),
|
||||
// We need to cache per role so the edit/configure links display only if user
|
||||
// has access.
|
||||
'cache' => DRUPAL_CACHE_PER_ROLE,
|
||||
);
|
||||
|
||||
$blocks['user'] = array(
|
||||
'info' => t('Follow User'),
|
||||
// Here we need to cache per user so the edit link only shows for the associated
|
||||
// account.
|
||||
'cache' => DRUPAL_CACHE_PER_USER,
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of hook_block_configure().
|
||||
*/
|
||||
function follow_block_configure($delta = '') {
|
||||
switch($delta) {
|
||||
case 'site':
|
||||
$form['follow_title'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Default block title'),
|
||||
'#default_value' => variable_get('follow_site_block_title', FOLLOW_NAME),
|
||||
'#options' => array(
|
||||
FOLLOW_NAME => t('Follow @name on', array('@name' => variable_get('site_name', 'Drupal'))),
|
||||
FOLLOW_ME => t('Follow me on'),
|
||||
FOLLOW_US => t('Follow us on'),
|
||||
),
|
||||
);
|
||||
$form['follow_user'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('User pages'),
|
||||
'#description' => t('Should this block display on user profile pages?'),
|
||||
'#default_value' => variable_get('follow_site_block_user', TRUE),
|
||||
);
|
||||
return $form;
|
||||
|
||||
case 'user':
|
||||
$form['follow_title'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Default block title'),
|
||||
'#default_value' => variable_get('follow_user_block_title', FOLLOW_NAME),
|
||||
'#options' => array(
|
||||
FOLLOW_NAME => t('Follow [username] on'),
|
||||
FOLLOW_ME => t('Follow me on'),
|
||||
),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_block_save().
|
||||
*/
|
||||
function follow_block_save($delta = '', $edit = array()) {
|
||||
variable_set('follow_'. $delta .'_block_title', $edit['follow_title']);
|
||||
if ($delta == 'site') {
|
||||
variable_set('follow_site_block_user', $edit['follow_user']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_block_view().
|
||||
*/
|
||||
function follow_block_view($delta = '') {
|
||||
switch ($delta) {
|
||||
case 'site':
|
||||
if (($content = _follow_block_content())
|
||||
&& (variable_get('follow_site_block_user', TRUE) || !(arg(0) == 'user' && is_numeric(arg(1))))) {
|
||||
return array(
|
||||
'subject' => _follow_block_subject(),
|
||||
'content' => $content,
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
$uid = arg(1);
|
||||
if (arg(0) == 'user' && is_numeric($uid) && ($content = _follow_block_content($uid))) {
|
||||
return array(
|
||||
'subject' => _follow_block_subject($uid),
|
||||
'content' => $content,
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to build the block title.
|
||||
*
|
||||
* @param $uid
|
||||
* The uid of the user account. Defaults to the site form, $uid = 0.
|
||||
*/
|
||||
function _follow_block_subject($uid = 0) {
|
||||
return follow_link_title($uid) .':';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to create a link or block title.
|
||||
*
|
||||
* @param $uid
|
||||
* The uid of the user account. Defaults to the site form, $uid = 0.
|
||||
*/
|
||||
function follow_link_title($uid = 0) {
|
||||
// Check to see if we have a valid username.
|
||||
if ($uid) {
|
||||
$setting = variable_get('follow_user_block_title', FOLLOW_NAME);
|
||||
// Special handling for usernames.
|
||||
if ($setting == FOLLOW_NAME) {
|
||||
$account = user_load($uid);
|
||||
// Set plain to TRUE for realname module support.
|
||||
return t('Follow !name on', array('!name' => theme('username', array('account' => $account))));
|
||||
}
|
||||
return t('Follow me on');
|
||||
}
|
||||
|
||||
switch(variable_get('follow_site_block_title', FOLLOW_NAME)) {
|
||||
case FOLLOW_NAME:
|
||||
return t('Follow @name on', array('@name' => variable_get('site_name', 'Drupal')));
|
||||
|
||||
case FOLLOW_ME:
|
||||
return t('Follow me on');
|
||||
|
||||
case FOLLOW_US:
|
||||
return t('Follow us on');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to build the block content display.
|
||||
*
|
||||
* @param $uid
|
||||
* The uid of the user account. Defaults to the site form, $uid = 0.
|
||||
*/
|
||||
function _follow_block_content($uid = 0) {
|
||||
$output = '';
|
||||
|
||||
if ($links = follow_links_load($uid)) {
|
||||
$output = theme('follow_links', array('links' => $links, 'networks' => follow_networks_load($uid)));
|
||||
$output .= _follow_block_config_links($uid);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function to output a list of links.
|
||||
*
|
||||
* @param $links
|
||||
* An array of follow link objects.
|
||||
* @param $networks
|
||||
* An array of network names, keys are machine names, values are visible titles.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_follow_links($variables) {
|
||||
$links = $variables['links'];
|
||||
$networks = $variables['networks'];
|
||||
$output = '<div class="follow-links clearfix">';
|
||||
|
||||
foreach($links as $link) {
|
||||
$title = !empty($link->title) ? $link->title : $networks[$link->name]['title'];
|
||||
$output .= theme('follow_link', array('link' => $link, 'title' => $title));
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function to print an individual link.
|
||||
*
|
||||
* @param $link
|
||||
* A follow link object.
|
||||
* @param $title
|
||||
* The translated title of the social network.
|
||||
*
|
||||
* @ingroup themable
|
||||
*/
|
||||
function theme_follow_link($variables) {
|
||||
$link = $variables['link'];
|
||||
$title = $variables['title'];
|
||||
$classes = array();
|
||||
$classes[] = 'follow-link';
|
||||
$classes[] = "follow-link-{$link->name}";
|
||||
$classes[] = $link->uid ? 'follow-link-user' : 'follow-link-site';
|
||||
$attributes = array(
|
||||
'class' => $classes,
|
||||
'title' => follow_link_title($link->uid) .' '. $title,
|
||||
);
|
||||
$link->options['attributes'] = $attributes;
|
||||
return l($title, $link->path, $link->options) . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a list of configuration links for users with appropriate permissions
|
||||
*
|
||||
* @param $uid
|
||||
* The uid of the user account. Defaults to the site form, $uid = 0.
|
||||
* @return
|
||||
* A string containing the links, output with theme_links().
|
||||
*/
|
||||
function _follow_block_config_links($uid) {
|
||||
$links = array();
|
||||
|
||||
if ($uid == 0 && user_access('edit site follow links')) {
|
||||
$links['follow_edit'] = array(
|
||||
'title' => t('Edit'),
|
||||
'href' => 'admin/config/services/follow',
|
||||
'query' => drupal_get_destination(),
|
||||
);
|
||||
}
|
||||
elseif (follow_links_user_access($uid)) {
|
||||
$links['follow_edit'] = array(
|
||||
'title' => t('Edit'),
|
||||
'href' => 'user/'. $uid .'/follow',
|
||||
'query' => drupal_get_destination(),
|
||||
);
|
||||
}
|
||||
|
||||
if (user_access('administer blocks')) {
|
||||
$links['follow_configure'] = array(
|
||||
'title' => t('Configure'),
|
||||
'href' => $uid ? 'admin/structure/block/configure/follow/user' : 'admin/structure/block/configure/follow/site',
|
||||
'query' => drupal_get_destination(),
|
||||
);
|
||||
}
|
||||
|
||||
return theme('links', $links, array('class' => array('links', 'inline')));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The form for editing follow links.
|
||||
*
|
||||
* @param $form_state
|
||||
* A keyed array containing the current state of the form.
|
||||
* @param $uid
|
||||
* The uid of the user account. Defaults to the site form, $uid = 0.
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function follow_links_form($form, &$form_state, $uid = 0) {
|
||||
$form = array();
|
||||
|
||||
$form['uid'] = array('#type' => 'hidden', '#value' => $uid);
|
||||
$form['follow_links']['#tree'] = TRUE;
|
||||
|
||||
$links = follow_links_load($uid);
|
||||
$networks = follow_networks_load($uid, TRUE);
|
||||
|
||||
// Put all our existing links at the top, sorted by weight.
|
||||
if (is_array($links)) {
|
||||
foreach ($links as $name => $link) {
|
||||
$title = $networks[$name]['title'];
|
||||
$form['follow_links'][$name] = _follow_links_form_link($link, $title, $uid);
|
||||
// Unset this specific network so we don't add the same one again below.
|
||||
unset($networks[$name]);
|
||||
}
|
||||
}
|
||||
// Now add all the empty ones.
|
||||
foreach ($networks as $name => $info) {
|
||||
$link = new stdClass();
|
||||
$link->name = $name;
|
||||
$form['follow_links'][$name] = _follow_links_form_link($link, $info['title'], $uid);
|
||||
}
|
||||
|
||||
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to create an individual link form element.
|
||||
*/
|
||||
function _follow_links_form_link($link, $title, $uid) {
|
||||
$elements = array();
|
||||
|
||||
$elements['name'] = array(
|
||||
'#markup' => $title,
|
||||
);
|
||||
if (isset($link->lid)) {
|
||||
$elements['lid'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $link->lid,
|
||||
);
|
||||
$elements['weight'] = array(
|
||||
'#type' => 'weight',
|
||||
'#default_value' => $link->weight,
|
||||
);
|
||||
}
|
||||
$elements['url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#follow_network' => $link->name,
|
||||
'#follow_uid' => $uid,
|
||||
'#default_value' => isset($link->url) ? $link->url : '',
|
||||
'#element_validate' => array('follow_url_validate'),
|
||||
);
|
||||
// Provide the title of the link only if the link URL is there and the user
|
||||
// has the appropriate access.
|
||||
$elements['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($link->title) ? $link->title : '',
|
||||
'#size' => 15,
|
||||
'#access' => user_access('change follow link titles') && !empty($link->url),
|
||||
);
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like drupal_http_build_query() but without urlencodings.
|
||||
*/
|
||||
function follow_build_query(array $query, $parent = '') {
|
||||
$params = array();
|
||||
|
||||
foreach ($query as $key => $value) {
|
||||
$key = ($parent ? $parent . '[' . $key . ']' : $key);
|
||||
|
||||
// Recurse into children.
|
||||
if (is_array($value)) {
|
||||
$params[] = follow_build_query($value, $key);
|
||||
}
|
||||
// If a query parameter value is NULL, only append its key.
|
||||
elseif (!isset($value)) {
|
||||
$params[] = $key;
|
||||
}
|
||||
else {
|
||||
$params[] = $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
return implode('&', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a url for use in the form.
|
||||
*/
|
||||
function follow_build_url($path, $options) {
|
||||
$url = $path;
|
||||
if (!empty($options['query'])) {
|
||||
$url .= (strpos($path, '?') !== FALSE ? '&' : '?') . follow_build_query($options['query']);
|
||||
}
|
||||
if (!empty($options['fragment'])) {
|
||||
$url .= '#' . $options['fragment'];
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a Drupal path or external link into path and options like a menu link.
|
||||
*/
|
||||
function follow_parse_url($url) {
|
||||
$parsed_url = parse_url($url);
|
||||
$defaults = array(
|
||||
'scheme' => '',
|
||||
'host' => '',
|
||||
'port' => '',
|
||||
'path' => '/',
|
||||
'query' => '',
|
||||
'fragment' => '',
|
||||
);
|
||||
$parsed_url += $defaults;
|
||||
$options = array('query' => array(), 'fragment' => $parsed_url['fragment']);
|
||||
// Parse the query string into an array.
|
||||
parse_str($parsed_url['query'], $options['query']);
|
||||
if ($parsed_url['scheme']) {
|
||||
$parsed_url['scheme'] .= '://';
|
||||
}
|
||||
// Throw away port for now.
|
||||
$path = $parsed_url['scheme'] . $parsed_url['host'] . $parsed_url['path'];
|
||||
return array('path' => $path, 'options' => $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the url field to verify it's actually a url.
|
||||
*/
|
||||
function follow_url_validate($form) {
|
||||
$url = trim($form['#value']);
|
||||
$networks = follow_networks_load($form['#follow_uid']);
|
||||
$info = $networks[$form['#follow_network']];
|
||||
$regex = follow_build_url_regex($info);
|
||||
$parsed = follow_parse_url($url);
|
||||
if($url && !preg_match($regex, $parsed['path'])) {
|
||||
if (!empty($info['domain'])) {
|
||||
$message = t('The specified url is invalid for the domain %domain. Make sure you use http://.', array('%domain' => $info['domain']));
|
||||
}
|
||||
else {
|
||||
$message = t('The specified path is invalid. Please enter a path on this site (e.g. rss.xml or taxonomy/term/1/feed).');
|
||||
}
|
||||
form_error($form, $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a regex to validate the url based on a known service url.
|
||||
*/
|
||||
function follow_build_url_regex($network_info) {
|
||||
|
||||
if (!empty($network_info['domain'])) {
|
||||
// An external link.
|
||||
return '@^https?://([a-z0-9\-_.]+\\.|)' . str_replace('.', '\\.', $network_info['domain']) . '/@i';
|
||||
}
|
||||
// An internal link should not have ':'.
|
||||
return '@^[^:]+$@';
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit handler for the follow_links_form.
|
||||
*/
|
||||
function follow_links_form_submit($form, &$form_state) {
|
||||
$values = $form_state['values'];
|
||||
$links = $values['follow_links'];
|
||||
|
||||
foreach($links as $name => $link) {
|
||||
$link = (object) $link;
|
||||
$link->url = trim($link->url);
|
||||
|
||||
// Check to see if there's actually a link
|
||||
if (empty($link->url)) {
|
||||
// If there's an lid, delete the link.
|
||||
if (isset($link->lid)) {
|
||||
follow_link_delete($link->lid);
|
||||
}
|
||||
// Continue to the next link.
|
||||
continue;
|
||||
}
|
||||
// Otherwise save the link.
|
||||
else {
|
||||
$link->uid = $values['uid'];
|
||||
$link->name = $name;
|
||||
follow_link_save($link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the drag-and-drop form.
|
||||
*
|
||||
* Arranges records in a table, and adds the css and js for draggable sorting.
|
||||
*
|
||||
* @ingroup themeable
|
||||
* @ingroup forms
|
||||
*/
|
||||
function theme_follow_links_form($variables) {
|
||||
$form = $variables['form'];
|
||||
$rows = array();
|
||||
$disabled_rows = array();
|
||||
|
||||
foreach (element_children($form['follow_links']) as $key) {
|
||||
$row = array();
|
||||
|
||||
if (isset($form['follow_links'][$key]['weight'])) {
|
||||
$row[] = drupal_render($form['follow_links'][$key]['lid']) . drupal_render($form['follow_links'][$key]['name']);
|
||||
$row[] = drupal_render($form['follow_links'][$key]['url']);
|
||||
if (user_access('change follow link titles')) {
|
||||
$row[] = drupal_render($form['follow_links'][$key]['title']);
|
||||
}
|
||||
|
||||
// Now, render the weight row.
|
||||
$form['follow_links'][$key]['weight']['#attributes']['class'][] = 'follow-links-weight';
|
||||
$row[] = drupal_render($form['follow_links'][$key]['weight']);
|
||||
|
||||
// Add the new row to our collection of rows, and give it the 'draggable' class.
|
||||
$rows[] = array(
|
||||
'data' => $row,
|
||||
'class' => array('draggable'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$disabled_rows[] = array(drupal_render($form['follow_links'][$key]['name']), drupal_render($form['follow_links'][$key]['url']));
|
||||
}
|
||||
}
|
||||
|
||||
// Render a list of header titles, and our array of rows, into a table.
|
||||
$header = array(t('Name'), t('URL'));
|
||||
if (user_access('change follow link titles')) {
|
||||
$header[] = t('Customized Name');
|
||||
}
|
||||
$header[] = t('Weight');
|
||||
$disabled_header = array(t('Name'), t('URL'));
|
||||
|
||||
$output = '';
|
||||
if (count($rows)) {
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'follow-links-weighted-form')));
|
||||
}
|
||||
if (count($disabled_rows)) {
|
||||
$output .= theme('table', array('header' => $disabled_header, 'rows' => $disabled_rows));
|
||||
}
|
||||
$output .= drupal_render_children($form);
|
||||
|
||||
drupal_add_tabledrag('follow-links-weighted-form', 'order', 'self', 'follow-links-weight');
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow settings form.
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function follow_settings_form() {
|
||||
$form = array();
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loader function for individual links.
|
||||
*
|
||||
* @param $uid
|
||||
* An int containing the uid of the user. uid 0 pulls the site follow links.
|
||||
* @return
|
||||
* A single link in array format, or FALSE if none matched the incoming ID.
|
||||
*/
|
||||
function follow_links_load($uid = 0) {
|
||||
$links = array();
|
||||
|
||||
$sql = "SELECT * FROM {follow_links} WHERE uid = :uid ORDER BY weight ASC";
|
||||
$result = db_query($sql, array(':uid' => $uid));
|
||||
|
||||
foreach ($result as $link) {
|
||||
$link->options = unserialize($link->options);
|
||||
$link->url = follow_build_url($link->path, $link->options);
|
||||
$links[$link->name] = $link;
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new link, or updates an existing one.
|
||||
*
|
||||
* @param $link
|
||||
* A link object to be saved.
|
||||
*/
|
||||
function follow_link_save($link) {
|
||||
$parsed = follow_parse_url($link->url);
|
||||
$link->path = $parsed['path'];
|
||||
$link->options = $parsed['options'];
|
||||
|
||||
if (isset($link->lid)) {
|
||||
drupal_write_record('follow_links', $link, 'lid');
|
||||
}
|
||||
else {
|
||||
drupal_write_record('follow_links', $link);
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a link, given its unique ID.
|
||||
*
|
||||
* @param $lid
|
||||
* An int containing the ID of a link.
|
||||
*/
|
||||
function follow_link_delete($lid) {
|
||||
db_delete('follow_links')
|
||||
->condition('lid', $lid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all follow networks
|
||||
*
|
||||
* @param $uid
|
||||
* The uid of the user. uid 0 pulls the site follow links.
|
||||
* @param $reset
|
||||
* Boolean. If TRUE, flushes the follow networks cache.
|
||||
*
|
||||
* @return
|
||||
* An array of network names, keys are machine names, values are visible titles.
|
||||
*/
|
||||
function follow_networks_load($uid = 0, $reset = FALSE) {
|
||||
static $networks = array();
|
||||
|
||||
// Clear cache if $reset is TRUE;
|
||||
if ($reset) {
|
||||
$networks = array();
|
||||
}
|
||||
// Return presets if the array is populated.
|
||||
if (empty($networks[$uid])) {
|
||||
// We call hook_follow_networks_alter() to allow other modules to create
|
||||
// or alter networks.
|
||||
$networks[$uid] = follow_default_networks($uid);
|
||||
drupal_alter('follow_networks', $networks, $uid);
|
||||
}
|
||||
|
||||
return $networks[$uid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default networks available.
|
||||
*
|
||||
* @return
|
||||
* An associative array, keyed by the machine name. The values are an array
|
||||
* including title of the network, along with the domain to be used for
|
||||
* input validation of the network.
|
||||
*/
|
||||
function follow_default_networks($uid) {
|
||||
$networks = array(
|
||||
'facebook' => array(
|
||||
'title' => t('Facebook'),
|
||||
'domain' => 'facebook.com',
|
||||
),
|
||||
'virb' => array(
|
||||
'title' => t('Virb'),
|
||||
'domain' => 'virb.com',
|
||||
),
|
||||
'myspace' => array(
|
||||
'title' => t('MySpace'),
|
||||
'domain' => 'myspace.com',
|
||||
),
|
||||
'twitter' => array(
|
||||
'title' => t('Twitter'),
|
||||
'domain' => 'twitter.com',
|
||||
),
|
||||
'picasa' => array(
|
||||
'title' => t('Picasa'),
|
||||
'domain' => 'picasaweb.google.com',
|
||||
),
|
||||
'flickr' => array(
|
||||
'title' => t('Flickr'),
|
||||
'domain' => 'flickr.com',
|
||||
),
|
||||
'youtube' => array(
|
||||
'title' => t('YouTube'),
|
||||
'domain' => 'youtube.com',
|
||||
),
|
||||
'vimeo' => array(
|
||||
'title' => t('Vimeo'),
|
||||
'domain' => 'vimeo.com',
|
||||
),
|
||||
'bliptv' => array(
|
||||
'title' => t('blip.tv'),
|
||||
'domain' => 'blip.tv',
|
||||
),
|
||||
'lastfm' => array(
|
||||
'title' => t('last.fm'),
|
||||
'domain' => 'last.fm',
|
||||
),
|
||||
'linkedin' => array(
|
||||
'title' => t('LinkedIn'),
|
||||
'domain' => 'linkedin.com',
|
||||
),
|
||||
'delicious' => array(
|
||||
'title' => t('Delicious'),
|
||||
'domain' => 'delicious.com',
|
||||
),
|
||||
'tumblr' => array(
|
||||
'title' => t('Tumblr'),
|
||||
'domain' => 'tumblr.com',
|
||||
),
|
||||
);
|
||||
if ($uid == 0) {
|
||||
$networks['this-site'] = array(
|
||||
'title' => t('This site (RSS)'),
|
||||
'domain' => '',
|
||||
);
|
||||
}
|
||||
return $networks;
|
||||
}
|
BIN
sites/all/modules/follow/icons/large/icon-bliptv.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sites/all/modules/follow/icons/large/icon-delicious.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sites/all/modules/follow/icons/large/icon-facebook.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
sites/all/modules/follow/icons/large/icon-feed.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sites/all/modules/follow/icons/large/icon-flickr.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sites/all/modules/follow/icons/large/icon-lastfm.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sites/all/modules/follow/icons/large/icon-linkedin.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
sites/all/modules/follow/icons/large/icon-myspace.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sites/all/modules/follow/icons/large/icon-picasa.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sites/all/modules/follow/icons/large/icon-tumblr.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
sites/all/modules/follow/icons/large/icon-twitter.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
sites/all/modules/follow/icons/large/icon-vimeo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
sites/all/modules/follow/icons/large/icon-virb.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
sites/all/modules/follow/icons/large/icon-youtube.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sites/all/modules/follow/icons/small/icon-bliptv.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sites/all/modules/follow/icons/small/icon-delicious.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sites/all/modules/follow/icons/small/icon-facebook.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
sites/all/modules/follow/icons/small/icon-feed.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sites/all/modules/follow/icons/small/icon-flickr.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
sites/all/modules/follow/icons/small/icon-lastfm.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sites/all/modules/follow/icons/small/icon-linkedin.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
sites/all/modules/follow/icons/small/icon-myspace.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
sites/all/modules/follow/icons/small/icon-picasa.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
sites/all/modules/follow/icons/small/icon-tumblr.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sites/all/modules/follow/icons/small/icon-twitter.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
sites/all/modules/follow/icons/small/icon-vimeo.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sites/all/modules/follow/icons/small/icon-virb.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
sites/all/modules/follow/icons/small/icon-youtube.png
Normal file
After Width: | Height: | Size: 1.5 KiB |