Skip to content

Commit

Permalink
Merge pull request Islandora#1 from Islandora/7.x
Browse files Browse the repository at this point in the history
7.x update
  • Loading branch information
qadan committed Nov 14, 2013
2 parents 4ba889e + ccf6533 commit 9855ccc
Show file tree
Hide file tree
Showing 15 changed files with 2,193 additions and 1,384 deletions.
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: php
php:
- 5.3.3
- 5.4
branches:
only:
- 7.x
env:
- FEDORA_VERSION="3.5"
- FEDORA_VERSION="3.6.2"
before_install:
- cd $HOME
- git clone -b 7.x git://github.com/Islandora/islandora.git
- git clone -b 7.x git://github.com/Islandora/islandora_solr_search.git
- export ISLANDORA_DIR=$HOME/islandora
- $HOME/islandora/tests/scripts/travis_setup.sh
- cd $HOME/drupal-*
- ln -s $TRAVIS_BUILD_DIR sites/all/modules/islandora_bookmark
- ln -s $HOME/islandora_solr_search sites/all/modules/islandora_solr_search
- drush en --yes islandora_bookmark
script:
- ant -buildfile sites/all/modules/islandora_bookmark/build.xml lint
- $ISLANDORA_DIR/tests/scripts/line_endings.sh sites/all/modules/islandora_bookmark
- drush coder-review --reviews=production,security,style,i18n,potx,sniffer islandora_bookmark
- phpcpd --names *.module,*.inc,*.test sites/all/modules/islandora_bookmark
- drush test-run --uri=http://localhost:8081 "Islandora Bookmark"
8 changes: 8 additions & 0 deletions README.txt → README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
BUILD STATUS
------------
Current build status:
[![Build Status](https://travis-ci.org/Islandora/islandora_bookmark.png?branch=7.x)](https://travis-ci.org/Islandora/islandora_bookmark)

CI Server:
http://jenkins.discoverygarden.ca

ISLANDORA BOOKMARK
==================

Expand Down
50 changes: 29 additions & 21 deletions css/islandora_bookmark.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,54 @@
* Styles for Islandora Bookmark.
*/
div.islandora-bookmark-users div.form-item {
width: 200px;
display: inline-block;
display: -moz-inline-block;
margin-right: 10px;
*display:inline;
*zoom:1;
*vertical-align: 2%;
width: 200px;
display: inline-block;
display: -moz-inline-block;
margin-right: 10px;
*display: inline;
*zoom: 1;
*vertical-align: 2%;
}

div.islandora-bookmark-listname div.form-item {
display: inline-block;
display: -moz-inline-block;
margin-right: 10px;
*display:inline;
*zoom:1;
*vertical-align: 2%;
display: inline-block;
display: -moz-inline-block;
margin-right: 10px;
*display: inline;
*zoom: 1;
*vertical-align: 2%;
}

div.islandora-bookmark-adduser div.form-item {
display: inline-block;
display: -moz-inline-block;
margin-right: 10px;
*display:inline;
*zoom:1;
*display: inline;
*zoom: 1;
*vertical-align: 2%;
}

div.islandora-bookmark-error-message {
background-image: linear-gradient(#EE5F5B, #C43C35);
background-image: linear-gradient(#ee5f5b, #c43c35);
color: white;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}

#islandora-bookmark .form-item-add-bookmarks
{
#islandora-bookmark .form-item-add-bookmarks {
display: inline-block;
margin-right: 10px;
}

#islandora-bookmark-detailed-form table .operations
{
#islandora-bookmark-detailed-form table .operations {
width: 100px;
}
}

#islandora-bookmark-rss-format {
float: right;
display: block;
clear: both;
}

#islandora-bookmark-detailed-list {
clear: both;
}
Binary file added images/rss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions includes/admin.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
*/
function islandora_bookmark_admin_settings(array $form, array &$form_state) {
$form = array(
'list_type' => array(
'#type' => 'textfield',
'#title' => t('The name of the type of list.'),
'#default_value' => variable_get('islandora_bookmark_type', 'bookmark'),
),
'overview_page_elements' => array(
'#type' => 'textfield',
'#title' => t('Bookmarks overview table'),
Expand Down Expand Up @@ -62,11 +67,13 @@ function islandora_bookmark_admin_settings_submit(array $form, array &$form_stat
case 'edit-submit':
variable_set('islandora_bookmark_overview_page_elements', $form_state['values']['overview_page_elements']);
variable_set('islandora_bookmark_detailed_page_elements', $form_state['values']['detailed_page_elements']);
variable_set('islandora_bookmark_type', $form_state['values']['list_type']);
break;

case 'edit-reset':
variable_del('islandora_bookmark_overview_page_elements');
variable_del('islandora_bookmark_detailed_page_elements');
variable_del('islandora_bookmark_type');
break;
}
}
188 changes: 62 additions & 126 deletions includes/api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,23 @@
function islandora_bookmark_get_user_owned_bookmarks() {
global $user;

$listids = array();
$bookmark_list = array();

$list_query = db_query('SELECT listid FROM {islandora_bookmark_list_names} WHERE listowner = :uid ORDER BY listid', array(':uid' => $user->uid));

foreach ($list_query as $record) {
if (!in_array($record->listid, $listids)) {
$listids[] = $record->listid;
}
}

foreach ($listids as $key => $value) {
$listpids = array();
$listusers = array();

$pid_query = db_query('SELECT pidid FROM {islandora_bookmark_list_pids} WHERE listid = :listid', array(':listid' => $value));
$list_query = db_query('SELECT DISTINCT listid FROM {islandora_bookmark_list_names} WHERE listowner = :uid ORDER BY listid', array(':uid' => $user->uid));
$listids = (array) $list_query->fetchAll(PDO::FETCH_COLUMN);

foreach ($pid_query as $record) {
$listpids[] = $record->pidid;
}

$user_query = db_query('SELECT uid FROM {islandora_bookmark_list_users} WHERE listid = :listid', array(':listid' => $value));

foreach ($user_query as $record) {
$listusers[] = $record->uid;
}

$list_record = db_query('SELECT listname, listowner from {islandora_bookmark_list_names} WHERE listid = :listid', array(':listid' => $value))->fetchObject();
$listid = $value;

$params = array(
'retrieve' => TRUE,
'user_id' => $user->uid,
'bookmark_owner' => $list_record->listowner,
'bookmark_users' => $listusers,
'bookmark_pids' => $listpids,
'bookmark_name' => $list_record->listname,
'bookmark_id' => $listid,
);
$templist = new Bookmark($params);
$bookmark_list = array();
foreach ($listids as $list_id) {
$templist = BookmarkDatabase::getList($list_id);

$bookmark_list[] = $templist;
}

// User is anon, use session as well.
if ($user->uid == 0 && !empty($_SESSION['islandora_bookmark'])) {
foreach ($_SESSION['islandora_bookmark'] as $value) {
if (isset($pid)) {
$templist = unserialize($value);
if (in_array($pid, $templist->pidList)) {
$bookmark_list[] = $templist;
}
}
else {
$bookmark_list[] = unserialize($value);
}
if (isset($_SESSION) && $user->uid == 0 && !empty($_SESSION['islandora_bookmark'])) {
foreach (array_keys($_SESSION['islandora_bookmark']) as $id) {
$bookmark_list[] = BookmarkSession::getList($id);
}
}

return $bookmark_list;
}

Expand All @@ -96,46 +55,18 @@ function islandora_bookmark_get_user_shared_bookmarks() {
foreach ($owner_query as $record) {
$owner_ids[] = $record->listid;
}
$shared_query = db_query('SELECT listid FROM {islandora_bookmark_list_users} WHERE uid = :uid ORDER BY listid', array(':uid' => $user->uid));
$shared_query = db_query('SELECT listid FROM {islandora_bookmark_list_users} WHERE uid = :uid OR uid = 0 ORDER BY listid', array(':uid' => $user->uid));

foreach ($shared_query as $record) {
$shared_ids[] = $record->listid;
}
$shared_ids = array_diff($shared_ids, $owner_ids);

foreach ($shared_ids as $key => $value) {

$listpids = array();
$listusers = array();

$pid_query = db_query('SELECT pidid FROM {islandora_bookmark_list_pids} WHERE listid = :listid', array(':listid' => $value));

foreach ($pid_query as $record) {
$listpids[] = $record->pidid;
}

$user_query = db_query('SELECT uid FROM {islandora_bookmark_list_users} WHERE listid = :listid', array(':listid' => $value));

foreach ($user_query as $record) {
$listusers[] = $record->uid;
}

$list_record = db_query('SELECT listname, listowner from {islandora_bookmark_list_names} WHERE listid = :listid', array(':listid' => $value))->fetchObject();
$listid = $value;

$params = array(
'retrieve' => TRUE,
'user_id' => $user->uid,
'bookmark_owner' => $list_record->listowner,
'bookmark_users' => $listusers,
'bookmark_pids' => $listpids,
'bookmark_name' => $list_record->listname,
'bookmark_id' => $listid,
);
$templist = new Bookmark($params);
foreach ($shared_ids as $id) {
$templist = Bookmark::getList($id);
$bookmark_list[] = $templist;
}
return $bookmark_list;
return array_filter($bookmark_list);
}

/**
Expand All @@ -146,46 +77,15 @@ function islandora_bookmark_get_user_shared_bookmarks() {
* @param int $listid
* List ID to be searched for.
*
* @return PidList
* PidList object.
* @return bool|PidList
* PidList object or FALSE if the list does not exist.
*/
function islandora_bookmark_get_bookmark_by_number($listid) {
global $user;

if (!preg_match('/session_/', $listid)) {
$listresult = db_query('SELECT listname, listowner from {islandora_bookmark_list_names} WHERE listid = :listid', array(':listid' => $listid))->fetchObject();

$userresult = db_query('SELECT uid from {islandora_bookmark_list_users} WHERE listid = :listid', array(':listid' => $listid));

$userlist = array();

foreach ($userresult as $record) {
array_push($userlist, $record->uid);
}

$pidresult = db_query('SELECT pidid from {islandora_bookmark_list_pids} WHERE listid = :listid', array(':listid' => $listid));
$pidlist = array();

foreach ($pidresult as $record) {
array_push($pidlist, $record->pidid);
}

$params = array(
'retrieve' => TRUE,
'user_id' => $user->uid,
'bookmark_owner' => $listresult->listowner,
'bookmark_name' => $listresult->listname,
'bookmark_id' => $listid,
'bookmark_users' => $userlist,
'bookmark_pids' => $pidlist,
);
$templist = new Bookmark($params);

$list = Bookmark::getList($listid);
if ($list === NULL) {
return FALSE;
}
else {
$templist = unserialize($_SESSION['islandora_bookmark'][$listid]);
}
return $templist;
return $list;
}

/**
Expand All @@ -204,18 +104,54 @@ function islandora_bookmark_get_bookmarks_visible_to_user($pid, $uid) {
// SESSION FIRST.
if ($uid == 0 && !empty($_SESSION['islandora_bookmark'])) {
foreach ($_SESSION['islandora_bookmark'] as $value) {
$templist = unserialize($value);
if (in_array($pid, $templist->pidList)) {
$lists[$templist->bookmarkId] = $templist->bookmarkId;
$templist = $value;
if (in_array($pid, $templist->getPids())) {
$lists[$templist->getId()] = $templist->getId();
}
}
}
else {
// DB.
$list_result = db_query('SELECT u.listid from {islandora_bookmark_list_users} as u INNER JOIN {islandora_bookmark_list_pids} as p ON u.listid = p.listid WHERE uid = :uid AND pidid = :pid', array(':uid' => $uid, ':pid' => $pid));
foreach ($list_result as $record) {
$lists[$record->listid] = $record->listid;
}
$q = <<<EOQ
SELECT u.listid
FROM {islandora_bookmark_list_users} as u INNER JOIN
{islandora_bookmark_list_pids} as p ON u.listid = p.listid INNER JOIN
{islandora_bookmark_list_names} as n ON u.listid = n.listid
WHERE p.pidid = :pid AND :uid IN (u.uid, n.listowner)
EOQ;
$list_result = db_query($q, array(':uid' => $uid, ':pid' => $pid))
->fetchAll(PDO::FETCH_COLUMN);
$lists += drupal_map_assoc($list_result);
}
return $lists;
}

/**
* Retrieves all the pids from the bookmark list id.
*
* @param string $value
* The listid.
*
* @return array
* An array containing listpids.
*/
function islandora_bookmark_list_pids_query($value) {
$list = Bookmark::getList($value);
return $list->getPids();
}

/**
* Retrieves all the uids from the bookmark listid, including owner.
*
* @param string $value
* The listid.
*
* @return array
* An array containing user ids.
*/
function islandora_bookmark_list_users_query($value) {
$list = Bookmark::getList($value);
$users = $list->getUsers();
$users[] = $list->bookmarkOwner;
return $users;
}
Loading

0 comments on commit 9855ccc

Please sign in to comment.