Skip to content
Snippets Groups Projects
Commit 9e263a9a authored by Chris Gross's avatar Chris Gross
Browse files

daily build

parent 7b186278
No related branches found
No related tags found
No related merge requests found
Showing
with 2344 additions and 4 deletions
WCM Base 7.x-1.x, 2015-10-07
----------------------------
- WCM Base Profile: Added Private and Private files download permission modules.
- OCIO User Config: Added Private Content Viewer role.
- OCIO Media: Added schema exposed filter to media browser view, allow private uploads.
- OCIO Workbench: Added schema exposed filter to files views page.
- OCIO Permissions:
- Allow Private Content Viewer users to view private nodes and files.
- Allow non-adminstrators to unpublish content.
WCM Base 7.x-1.x, 2015-10-06
----------------------------
- OCIO Aggregator: Removed custom module from distribution.
- OCIO Landing Page: Removed twitter and aggregator panes from allowed content.
- OCIO Permissions: Granted Landing Page edit permission to editors.
WCM Base 7.x-1.x, 2015-10-02
----------------------------
......@@ -66,7 +75,7 @@ WCM Base 7.x-1.x, 2015-09-11
WCM Base 7.x-1.x, 2015-09-09
----------------------------
- WCM Base: Added telephone module as dependency.
- WCM Base Profile: Added telephone module as dependency.
- WCM User Profile: Converted phone field type from text to telephone.
- OCIO Omega Base: Fixed margins on unlinked tile panes.
......
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.
profiles/wcm_base/modules/contrib/private/icon_key.gif

230 B

name = Private
description = Allows users to mark content as private, and hide that content from visitors.
core = 7.x
package = Access control
files[] = private_handler_filter_private.inc
; Information added by Drupal.org packaging script on 2015-04-06
version = "7.x-1.2"
core = "7.x"
project = "private"
datestamp = "1428334686"
<?php
/**
* @file
* Install, update and uninstall functions for the private module.
*/
/**
* Implements hook_schema().
*/
function private_schema() {
$schema['private'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'private' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('nid'),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function private_uninstall() {
// Remove variables.
$node_types = array_keys(node_type_get_types());
foreach ($node_types as $node_type) {
variable_del('private_' . $node_type);
}
}
<?php
/**
* @file
* A tremendously simple access control module -- it allows users to mark
* individual nodes as private; users with 'access private content' perms can
* read these nodes, while others cannot.
*/
define('PRIVATE_DISABLED', 0);
define('PRIVATE_ALLOWED', 1);
define('PRIVATE_AUTOMATIC', 2);
define('PRIVATE_ALWAYS', 3);
define('PRIVATE_GRANT_ALL', 1);
/**
* Implements hook_enable().
*
* A node access module needs to force a rebuild of the node access table
* when it is enabled to ensure that things are set up.
*/
function private_enable() {
node_access_needs_rebuild(TRUE);
}
/**
* Implements hook_disable().
*
* A node access module needs to force a rebuild of the node access table
* when it is disabled to ensure that its entries are removed from the table.
*/
function private_disable() {
private_disabling(TRUE);
node_access_needs_rebuild(TRUE);
}
/**
* Simple function to make sure we don't respond with grants when disabling
* ourselves.
*/
function private_disabling($set = NULL) {
static $disabling = FALSE;
if ($set !== NULL) {
$disabling = $set;
}
return $disabling;
}
/**
* Implements hook_permission().
*
* In this example, we will use a simple permission to determine whether a user
* has access to "private" content. This permission is defined here.
*/
function private_permission() {
return array(
'mark content as private' => array(
'title' => t('Mark content as private'),
'description' => t('Make content only viewable by people with access to view private content'),
),
'access private content' => array(
'title' => t('Access private content'),
'description' => t('Access any content marked as private'),
),
'edit private content' => array(
'title' => t('Edit private content'),
'description' => t('Edit content marked as private'),
),
);
}
/**
* Implements hook_node_grants().
*
* Tell the node access system what GIDs the user belongs to for each realm.
* In this example, we are providing two realms: the example realm, which
* has just one group id (1) and the user is either a member or not depending
* upon the operation and the access permission set.
*
* We are also setting up a realm for the node author, though, to give it
* special privileges. That has 1 GID for every UID, and each user is
* automatically a member of the group where GID == UID.
*
*/
function private_node_grants($account, $op) {
// First grant a grant to the author for own content.
$grants['private_author'] = array($account->uid);
if ($op == 'view' && user_access('access private content', $account)) {
$grants['private_view'] = array(PRIVATE_GRANT_ALL);
}
if (($op == 'update' || $op == 'delete') && user_access('edit private content', $account)) {
$grants['private_edit'] = array(PRIVATE_GRANT_ALL);
}
return $grants;
}
/**
* Implements hook_node_access_records().
*
* All node access modules must implement this hook. If the module is
* interested in the privacy of the node passed in, return a list
* of node access values for each grant ID we offer.
*/
function private_node_access_records($node) {
if (private_disabling()) {
return;
}
// We only care about the node if it's been marked private. If not, it is
// treated just like any other node and we completely ignore it.
if (isset($node->private) && $node->private == 1) {
$grants = array();
$grants[] = array(
'realm' => 'private_view',
'gid' => PRIVATE_GRANT_ALL,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
$grants[] = array(
'realm' => 'private_edit',
'gid' => PRIVATE_GRANT_ALL,
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 0,
);
$grants[] = array(
'realm' => 'private_author',
'gid' => $node->uid,
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 0,
);
return $grants;
}
}
/**
* Implements hook_form_alter().
*
* This module adds a simple checkbox to the node form labeled private. If the
* checkbox is labelled, only the node author and users with 'access private content'
* privileges may see it.
*/
function private_form_alter(&$form, &$form_state, $form_id) {
if (!empty($form['#node_edit_form'])) {
$node = $form['#node'];
$default = variable_get('private_' . $node->type, PRIVATE_ALLOWED);
if ($default != PRIVATE_DISABLED || !empty($node->private)) {
if (empty($node->nid)) {
$privacy = ($default > PRIVATE_ALLOWED);
}
else {
$privacy = isset($node->private) ? $node->private : 0;
}
if (user_access('mark content as private') && $default != PRIVATE_ALWAYS) {
if (user_access('administer nodes')) {
$form['options']['private'] = array(
'#type' => 'checkbox',
'#title' => t('Make this post private'),
'#attributes' => array('title' => t('When checked, only users with proper access permissions will be able to see this post.')),
'#default_value' => $privacy,
);
}
else {
$form['private'] = array(
'#type' => 'checkbox',
'#title' => t('Make this post private'),
'#attributes' => array('title' => t('When checked, only users with proper access permissions will be able to see this post.')),
'#default_value' => $privacy,
'#weight' => 99,
);
}
}
else {
$form['private'] = array(
'#type' => 'value',
'#value' => $privacy,
);
}
}
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function private_form_node_type_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['type'])) {
$form['workflow']['private'] = array(
'#type' => 'radios',
'#title' => t('Privacy'),
'#options' => array(
PRIVATE_DISABLED => t('Disabled (always public)'),
PRIVATE_ALLOWED => t('Enabled (public by default)'),
PRIVATE_AUTOMATIC => t('Enabled (private by default)'),
PRIVATE_ALWAYS => t('Hidden (always private)'),
),
'#default_value' => variable_get('private_' . $form['#node_type']->type, PRIVATE_ALLOWED),
);
}
}
/**
* Implements hook_node_load().
*/
function private_node_load($nodes, $types) {
$result = db_query('SELECT * FROM {private} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)));
foreach ($result as $record) {
$nodes[$record->nid]->private = $record->private;
}
}
/**
* Implements hook_node_delete().
*/
function private_node_delete($node) {
db_delete('private')
->condition('nid', $node->nid)
->execute();
}
/**
* Implements hook_node_insert().
*/
function private_node_insert($node) {
private_node_update($node);
}
/**
* Implements hook_node_update().
*/
function private_node_update($node) {
if (isset($node->private)) {
db_merge('private')
->key(array('nid' => $node->nid))
->fields(array(
'nid' => $node->nid,
'private' => (int)$node->private,
))
->execute();
}
}
/**
* Implements hook_node_view().
*/
function private_node_view($node, $view_mode) {
if (isset($node->private) && $node->private == 1) {
$links['private_icon']['title'] = theme('private_node_link');
$links['private_icon']['html'] = TRUE;
$node->content['links']['private'] = array(
'#theme' => 'links__node__private',
'#links' => $links,
'#attributes' => array('class' => array('links', 'inline')),
);
}
}
/**
* Implements hook_theme().
*/
function private_theme() {
return array(
'private_node_link' => array(
'variables' => array(),
),
);
}
/**
* Custom theme function
* @see private_theme()
*/
function theme_private_node_link() {
$vars = array(
'path' => drupal_get_path('module', 'private') . '/icon_key.gif',
'width' => '16',
'height' => '16',
'alt' => t('Private'),
'title' => t('This content is private.')
);
return theme('image', $vars);
}
/**
* Implements hook_action_info().
*/
function private_action_info() {
return array(
'private_set_private_action' => array(
'type' => 'node',
'label' => t('Make post private'),
'configurable' => FALSE,
'triggers' => array(
'node_insert',
'node_update',
),
),
'private_set_public_action' => array(
'type' => 'node',
'label' => t('Make post public'),
'configurable' => FALSE,
'triggers' => array(
'node_insert',
'node_update',
),
),
);
}
/**
* Implementation of a Drupal action.
*/
function private_set_public_action(&$node, $context = array()) {
$node->private = FALSE;
$nids = array($node->nid);
private_node_mark_public($nids);
}
/**
* Implementation of a Drupal action.
*/
function private_set_private_action(&$node, $context = array()) {
$node->private = TRUE;
$nids = array($node->nid);
private_node_mark_private($nids);
}
/**
* Implements hook_node_operations().
*/
function private_node_operations() {
$operations = array(
'private_mark_as_private' => array(
'label' => t('Mark as private'),
'callback' => 'private_node_mark_private',
),
'private_mark_as_public' => array(
'label' => t('Mark as public'),
'callback' => 'private_node_mark_public',
),
);
return $operations;
}
/**
* Callback for 'Mark as private' node operation
*/
function private_node_mark_private($nids) {
foreach ($nids as $nid) {
db_merge('private')
->key(array('nid' => $nid))
->fields(array(
'nid' => $nid,
'private' => 1,
))
->execute();
}
}
/**
* Callback for 'Mark as public' node operation
*/
function private_node_mark_public($nids) {
foreach ($nids as $nid) {
db_merge('private')
->key(array('nid' => $nid))
->fields(array(
'nid' => $nid,
'private' => 0,
))
->execute();
}
}
/**
* Tell Views that we're down with it, yo.
*/
function private_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'private'),
);
}
<?php
/**
* @file
* Tests for private module.
*/
class PrivateTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Private functionality',
'description' => 'Checks behavior of Private.',
'group' => 'Examples',
);
}
/**
* Enable modules and create user with specific permissions.
*/
public function setUp() {
parent::setUp('private', 'search');
node_access_rebuild();
}
/**
* Test the "private" node access.
*
* - Create 3 users with "access content" and "create article" permissions.
* - Each user creates one private and one not private article.
* - Run cron to update search index.
* - Test that each user can view the other user's non-private article.
* - Test that each user cannot view the other user's private article.
* - Test that each user finds only appropriate (non-private + own private)
* in search results.
* - Create another user with 'view private content'.
* - Test that user 4 can view all content created above.
* - Test that user 4 can search for all content created above.
* - Test that user 4 cannot edit private content above.
* - Create another user with 'edit private content'
* - Test that user 5 can edit private content.
* - Test that user 5 can delete private content.
* - Test listings of nodes with 'node_access' tag on database search.
*/
function testNodeAccessBasic() {
$num_simple_users = 3;
$simple_users = array();
// nodes keyed by uid and nid: $nodes[$uid][$nid] = $is_private;
$nodes_by_user = array();
$titles = array(); // Titles keyed by nid
$private_nodes = array(); // Array of nids marked private.
for ($i = 0; $i < $num_simple_users; $i++) {
$simple_users[$i] = $this->drupalCreateUser(array('access content', 'create article content', 'search content'));
}
foreach ($simple_users as $web_user) {
$this->drupalLogin($web_user);
foreach (array(0 => 'Public', 1 => 'Private') as $is_private => $type) {
$edit = array(
'title' => t('@private_public Article created by @user', array('@private_public' => $type, '@user' => $web_user->name)),
);
if ($is_private) {
$edit['private'] = TRUE;
$edit['body[und][0][value]'] = 'private node';
}
else {
$edit['body[und][0][value]'] = 'public node';
}
$this->drupalPost('node/add/article', $edit, t('Save'));
debug(t('Created article with private=@private', array('@private' => $is_private)));
$this->assertText(t('Article @title has been created', array('@title' => $edit['title'])));
$nid = db_query('SELECT nid FROM {node} WHERE title = :title', array(':title' => $edit['title']))->fetchField();
$this->assertText(t('New node @nid was created and private=@private', array('@nid' => $nid, '@private' => $is_private)));
$private_status = db_query('SELECT private FROM {private} where nid = :nid', array(':nid' => $nid))->fetchField();
$this->assertTrue($is_private == $private_status, t('Node was properly set to private or not private in private table.'));
if ($is_private) {
$private_nodes[] = $nid;
}
$titles[$nid] = $edit['title'];
$nodes_by_user[$web_user->uid][$nid] = $is_private;
}
}
debug($nodes_by_user);
$this->cronRun(); // Build the search index.
foreach ($simple_users as $web_user) {
$this->drupalLogin($web_user);
// Check to see that we find the number of search results expected.
$this->checkSearchResults('Private node', 1);
// Check own nodes to see that all are readable.
foreach (array_keys($nodes_by_user) as $uid) {
// All of this user's nodes should be readable to same.
if ($uid == $web_user->uid) {
foreach ($nodes_by_user[$uid] as $nid => $is_private) {
$this->drupalGet('node/' . $nid);
$this->assertResponse(200);
$this->assertTitle($titles[$nid] . ' | Drupal', t('Correct title for node found'));
}
}
else {
// Otherwise, for other users, private nodes should get a 403,
// but we should be able to read non-private nodes.
foreach ($nodes_by_user[$uid] as $nid => $is_private) {
$this->drupalGet('node/' . $nid);
$this->assertResponse($is_private ? 403 : 200, t('Node @nid by user @uid should get a @response for this user (@web_user_uid)', array('@nid' => $nid, '@uid' => $uid, '@response' => $is_private ? 403 : 200, '@web_user_uid' => $web_user->uid)));
if (!$is_private) {
$this->assertTitle($titles[$nid] . ' | Drupal', t('Correct title for node was found'));
}
}
}
}
// Check to see that the correct nodes are shown on examples/node_access.
$this->drupalGet('examples/node_access');
$accessible = $this->xpath("//tr[contains(@class,'accessible')]");
$this->assertEqual(count($accessible), 1, t('One private item accessible'));
foreach ($accessible as $row) {
$this->assertEqual($row->td[2], $web_user->uid, t('Accessible row owned by this user'));
}
}
// Now test that a user with 'access private content' can view content.
$access_user = $this->drupalCreateUser(array('access content', 'create article content', 'access private content', 'search content'));
$this->drupalLogin($access_user);
// Check to see that we find the number of search results expected.
$this->checkSearchResults('Private node', 3);
foreach ($nodes_by_user as $uid => $private_status) {
foreach ($private_status as $nid => $is_private) {
$this->drupalGet('node/' . $nid);
$this->assertResponse(200);
}
}
// Test that a privileged user can edit and delete private content.
// This test should go last, as the nodes get deleted.
$edit_user = $this->drupalCreateUser(array('access content', 'access private content', 'edit private content'));
$this->drupalLogin($edit_user);
foreach ($private_nodes as $nid) {
$body = $this->randomName();
$edit = array('body[und][0][value]' => $body);
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
$this->assertText(t('has been updated'));
$this->drupalPost('node/' . $nid . '/edit', array(), t('Delete'));
$this->drupalPost(NULL, array(), t('Delete'));
$this->assertText(t('has been deleted'));
}
}
/**
* On the search page, search for a string and assert the expected number
* of results.
* @param $search_query
* String to search for
* @param $expected_result_count
* Expected result count
*/
function checkSearchResults($search_query, $expected_result_count) {
$this->drupalPost('search/node', array('keys' => $search_query), t('Search'));
$search_results = $this->xpath("//ol[contains(@class, 'search-results')]/li");
$this->assertEqual(count($search_results), $expected_result_count, t('Found the expected number of search results'));
}
}
<?php
/**
* @file
* Views integration functions for the private module.
*/
/**
* Implements hook_views_data().
*/
function private_views_data() {
$data = array();
$data['private']['table']['group'] = t('Content');
$data['private']['table']['join'] = array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
'private' => array(
'left_field' => 'nid',
'field' => 'nid',
),
);
$data['private']['private'] = array(
'title' => t('Private'),
'help' => t('Whether or not the node is private.'),
'field' => array(
'handler' => 'views_handler_field_boolean',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'private_handler_filter_private',
'label' => t('Private'),
'type' => 'yes-no',
),
);
return $data;
}
/**
* Implements hook_views_handlers().
*/
function private_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'private'),
),
'handlers' => array(
'private_handler_filter_private' => array(
'parent' => 'views_handler_filter_boolean_operator',
'file' => 'private_handler_filter_private.inc',
),
),
);
}
<?php
/**
* @file
* Views handlers for the private module.
*/
class private_handler_filter_private extends views_handler_filter_boolean_operator {
function construct() {
parent::construct();
$this->value_value = t('Private');
}
function query() {
$this->ensure_my_table();
$qualified_name = "$this->table_alias.$this->real_field";
$this->query->add_where_expression($this->options['group'], $qualified_name . (empty($this->value) ? " = 0 OR $qualified_name IS NULL" : ' = 1'));
}
}
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.
Private files download permission
=================================
DESCRIPTION
----------------------------
Version 1.x provided "two useful features which Drupal itself is missing: a
simple permission to allow downloading of private files by role, plus the
ability to combine both public and private downloads".
Version 2.x removes the "global" permission and implements a per-directory
by-user and by-role filter instead, to let the administrator better tweak the
whole website and increment the overall security.
Idea and code (mostly for version 1.x) were inspired by
http://www.beacon9.ca/labs/drupal-7-private-files-module.
The 2.x development was partly sponsored by Cooperativa Italiana Artisti
(http://www.cita.coop).
INSTALLATION / CONFIGURATION
----------------------------
Browse to Configuration > Media > Private files download permission (url:
/admin/config/media/private-files-download-permission). Then add or edit each
directory path you want to put under control, associating users and roles which
are allowed to download from it.
All directory paths are relative to your private file system path, but must
have a leading slash ('/'), as the private file system root itself could be put
under control.
E.g.:
Suppose your private file system path is /opt/private.
You could configure /opt/private (and all of its subdirectories) by adding a
'/' entry, while a '/test' entry would specifically refer to /opt/private/test
(and all of its subdirectories).
Please note that per-user checks may slow your site if there are plenty of
users. You can then bypass this feature by browsing to Configuration > Media >
Private files download permission > Preferences (url:
/admin/config/media/private-files-download-permission/preferences) and change
the setting accordingly.
Also configure which users and roles have access to the module configuration
under People > Permissions (url: /admin/people/permissions).
name = Private files download permission
description = Allows by-user and by-role downloads from private file system directories.
core = 7.x
package = Access control
configure = admin/config/media/private-files-download-permission
; Information added by Drupal.org packaging script on 2015-01-01
version = "7.x-2.3+7-dev"
core = "7.x"
project = "private_files_download_permission"
datestamp = "1420135983"
<?php
/**
* @file
* Installs, updates and uninstalls module variables and settings.
*
* Copyright (c) 2011-2015 by Marco Zanon (http://www.marcozanon.com)
* Released under GPLv2 license
* Idea and code inspired by http://www.beacon9.ca/labs/drupal-7-private-files-module
*/
/**
* Implements hook_schema().
*/
function private_files_download_permission_schema() {
return array(
'private_files_download_permission_directory' => array(
'description' => 'Directories whose permissions are set.',
'fields' => array(
'did' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
'bypass' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE),
),
'primary key' => array('did'),
'foreign keys' => array(),
'unique keys' => array(
'path' => array('path'),
),
'indexes' => array(),
),
'private_files_download_permission_directory_user' => array(
'description' => 'Users having per-directory download permission.',
'fields' => array(
'duid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'did' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
),
'primary key' => array('duid'),
'foreign keys' => array(
'private_files_download_permission_directory' => array(
'table' => 'private_files_download_permission_directory',
'columns' => array('did' => 'did'),
),
'private_files_download_permission_directory_user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
'unique keys' => array(),
'indexes' => array(),
),
'private_files_download_permission_directory_role' => array(
'description' => 'Roles having per-directory download permission.',
'fields' => array(
'drid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'did' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'rid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
),
'primary key' => array('drid'),
'foreign keys' => array(
'private_files_download_permission_directory' => array(
'table' => 'private_files_download_permission_directory',
'columns' => array('did' => 'did'),
),
'private_files_download_permission_directory_role' => array(
'table' => 'role',
'columns' => array('rid' => 'rid'),
),
),
'unique keys' => array(),
'indexes' => array(),
),
);
}
/**
* Implements hook_install().
*/
function private_files_download_permission_install() {
$transaction = db_transaction();
try {
// Add "real" foreign keys.
db_query('ALTER TABLE {private_files_download_permission_directory_user}
ADD CONSTRAINT {private_files_download_permission_directory_2}
FOREIGN KEY (did) REFERENCES {private_files_download_permission_directory} (did)
ON DELETE CASCADE
ON UPDATE CASCADE');
db_query('ALTER TABLE {private_files_download_permission_directory_user}
ADD CONSTRAINT {private_files_download_permission_directory_user}
FOREIGN KEY (uid) REFERENCES {users} (uid)
ON DELETE CASCADE
ON UPDATE CASCADE');
db_query('ALTER TABLE {private_files_download_permission_directory_role}
ADD CONSTRAINT {private_files_download_permission_directory}
FOREIGN KEY (did) REFERENCES {private_files_download_permission_directory} (did)
ON DELETE CASCADE
ON UPDATE CASCADE');
db_query('ALTER TABLE {private_files_download_permission_directory_role}
ADD CONSTRAINT {private_files_download_permission_directory_role}
FOREIGN KEY (rid) REFERENCES {role} (rid)
ON DELETE CASCADE
ON UPDATE CASCADE');
}
catch (Exception $e) {
$transaction->rollback();
drupal_set_message(st('An error occurred while installing the module. Please check the log for details.'), 'error');
}
// Set preferences' default values.
variable_set('private_files_download_permission_by_user_checks', TRUE);
}
/**
* Remove useless settings from version 1.x, implement new schema and add
* "real" foreign keys.
*/
function private_files_download_permission_update_7200() {
$transaction = db_transaction();
try {
// Remove useless settings from version 1.x.
foreach (user_roles() as $rid => $role_name) {
user_role_revoke_permissions($rid, array(
'download private files',
));
}
variable_del('private_files_download_permission_unprotected_subfolder');
// Implement new schema (rewritten from scratch, see https://drupal.org/node/150220).
$schema = array();
$schema['private_files_download_permission_directory'] = array(
'description' => 'Directories whose permissions are set.',
'fields' => array(
'did' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'path' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
),
'primary key' => array('did'),
'foreign keys' => array(),
'unique keys' => array(
'path' => array('path'),
),
'indexes' => array(),
);
$schema['private_files_download_permission_directory_role'] = array(
'description' => 'Roles having per-directory download permission.',
'fields' => array(
'drid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'did' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'rid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
),
'primary key' => array('drid'),
'foreign keys' => array(
'private_files_download_permission_directory' => array(
'table' => 'private_files_download_permission_directory',
'columns' => array('did' => 'did'),
),
'private_files_download_permission_directory_role' => array(
'table' => 'role',
'columns' => array('rid' => 'rid'),
),
),
'unique keys' => array(),
'indexes' => array(),
);
db_create_table('private_files_download_permission_directory', $schema['private_files_download_permission_directory']);
db_create_table('private_files_download_permission_directory_role', $schema['private_files_download_permission_directory_role']);
// Add "real" foreign keys.
db_query('ALTER TABLE {private_files_download_permission_directory_role}
ADD CONSTRAINT {private_files_download_permission_directory}
FOREIGN KEY (did) REFERENCES {private_files_download_permission_directory} (did)
ON DELETE CASCADE
ON UPDATE CASCADE');
db_query('ALTER TABLE {private_files_download_permission_directory_role}
ADD CONSTRAINT {private_files_download_permission_directory_role}
FOREIGN KEY (rid) REFERENCES {role} (rid)
ON DELETE CASCADE
ON UPDATE CASCADE');
}
catch (Exception $e) {
$transaction->rollback();
drupal_set_message(st('An error occurred while updating the module. Please check the log for details.'), 'error');
}
}
/**
* Prepare the database for by-user filtering.
*/
function private_files_download_permission_update_7201() {
$transaction = db_transaction();
try {
// Implement new table schema (rewritten from scratch, see https://drupal.org/node/150220).
$schema = array();
$schema['private_files_download_permission_directory_user'] = array(
'description' => 'Users having per-directory download permission.',
'fields' => array(
'duid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'did' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
),
'primary key' => array('duid'),
'foreign keys' => array(
'private_files_download_permission_directory' => array(
'table' => 'private_files_download_permission_directory',
'columns' => array('did' => 'did'),
),
'private_files_download_permission_directory_user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
'unique keys' => array(),
'indexes' => array(),
);
db_create_table('private_files_download_permission_directory_user', $schema['private_files_download_permission_directory_user']);
// Add "real" foreign keys.
db_query('ALTER TABLE {private_files_download_permission_directory_user}
ADD CONSTRAINT {private_files_download_permission_directory_2}
FOREIGN KEY (did) REFERENCES {private_files_download_permission_directory} (did)
ON DELETE CASCADE
ON UPDATE CASCADE');
db_query('ALTER TABLE {private_files_download_permission_directory_user}
ADD CONSTRAINT {private_files_download_permission_directory_user}
FOREIGN KEY (uid) REFERENCES {users} (uid)
ON DELETE CASCADE
ON UPDATE CASCADE');
}
catch (Exception $e) {
$transaction->rollback();
drupal_set_message(st('An error occurred while updating the module. Please check the log for details.'), 'error');
}
}
/**
* Prepare the database to handle the "bypass" option. Set preferences' default
* values.
*/
function private_files_download_permission_update_7203() {
// Update table schema.
db_add_field('private_files_download_permission_directory', 'bypass', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'initial' => 0));
// Set preferences' default values.
variable_set('private_files_download_permission_by_user_checks', TRUE);
}
/**
* Implements hook_enable().
*/
function private_files_download_permission_enable() {
// Purge directory list from cache.
drupal_static_reset('private_files_download_permission_directory_list');
}
/**
* Implements hook_uninstall().
*/
function private_files_download_permission_uninstall() {
$transaction = db_transaction();
try {
if (FALSE !== stripos(db_driver(), 'mysql')) {
// Remove "real" foreign keys (MySQL database).
db_query('ALTER TABLE {private_files_download_permission_directory_user}
DROP FOREIGN KEY {private_files_download_permission_directory_2}');
db_query('ALTER TABLE {private_files_download_permission_directory_user}
DROP FOREIGN KEY {private_files_download_permission_directory_user}');
db_query('ALTER TABLE {private_files_download_permission_directory_role}
DROP FOREIGN KEY {private_files_download_permission_directory}');
db_query('ALTER TABLE {private_files_download_permission_directory_role}
DROP FOREIGN KEY {private_files_download_permission_directory_role}');
}
else {
// Remove "real" foreign keys (non-MySQL database).
db_query('ALTER TABLE {private_files_download_permission_directory_user}
DROP CONSTRAINT IF EXISTS {private_files_download_permission_directory_2}');
db_query('ALTER TABLE {private_files_download_permission_directory_user}
DROP CONSTRAINT IF EXISTS {private_files_download_permission_directory_user}');
db_query('ALTER TABLE {private_files_download_permission_directory_role}
DROP CONSTRAINT IF EXISTS {private_files_download_permission_directory}');
db_query('ALTER TABLE {private_files_download_permission_directory_role}
DROP CONSTRAINT IF EXISTS {private_files_download_permission_directory_role}');
}
}
catch (Exception $e) {
$transaction->rollback();
drupal_set_message(st('An error occurred while removing the module. Please check the log for details.'), 'error');
}
// Remove preferences.
variable_del('private_files_download_permission_by_user_checks');
// Purge directory list from cache.
drupal_static_reset('private_files_download_permission_directory_list');
}
......@@ -31,4 +31,5 @@ features[variable][] = menu_parent_basic_page
features[variable][] = node_options_basic_page
features[variable][] = node_preview_basic_page
features[variable][] = node_submitted_basic_page
features[variable][] = private_basic_page
features[variable][] = workbench_moderation_default_state_basic_page
......@@ -98,6 +98,13 @@ function ocio_basic_page_strongarm() {
$strongarm->value = 0;
$export['node_submitted_basic_page'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'private_basic_page';
$strongarm->value = '1';
$export['private_basic_page'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
......
......@@ -27,6 +27,7 @@ features[variable][] = node_options_book_page
features[variable][] = node_preview_book_page
features[variable][] = node_submitted_book_page
features[variable][] = panelizer_defaults_node_book_page
features[variable][] = private_book_page
features[variable][] = simplify_nodes_book_page
features[variable][] = webform_node_book_page
features[variable][] = workbench_moderation_default_state_book_page
......
......@@ -14,7 +14,7 @@ function ocio_book_strongarm() {
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'additional_settings__active_tab_book_page';
$strongarm->value = 'edit-menu';
$strongarm->value = 'edit-submission';
$export['additional_settings__active_tab_book_page'] = $strongarm;
$strongarm = new stdClass();
......@@ -185,6 +185,13 @@ function ocio_book_strongarm() {
);
$export['panelizer_defaults_node_book_page'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'private_book_page';
$strongarm->value = '1';
$export['private_book_page'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
......
......@@ -24,8 +24,8 @@ features[variable][] = menu_parent_calendar_entry
features[variable][] = node_options_calendar_entry
features[variable][] = node_preview_calendar_entry
features[variable][] = node_submitted_calendar_entry
features[variable][] = private_calendar_entry
features[views_view][] = calendar
features_exclude[dependencies][date] = date
features_exclude[dependencies][features] = features
features_exclude[dependencies][ctools] = ctools
mtime = 1424705231
......@@ -68,5 +68,12 @@ function ocio_calendar_strongarm() {
$strongarm->value = 1;
$export['node_submitted_calendar_entry'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'private_calendar_entry';
$strongarm->value = '1';
$export['private_calendar_entry'] = $strongarm;
return $export;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment