Skip to content

Commit 10ce758

Browse files
committed
Customize Terms of Service and Privacy Policy per install and per book
1 parent f3e6f4b commit 10ce758

File tree

7 files changed

+49
-5
lines changed

7 files changed

+49
-5
lines changed

system/application/config/scalar_store.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ CREATE TABLE IF NOT EXISTS `scalar_db_books` (
2020
`editions` TEXT DEFAULT NULL,
2121
`user` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
2222
`created` datetime NOT NULL,
23+
`terms_of_service` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
24+
`privacy_policy` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
2325
PRIMARY KEY (`book_id`)
2426
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2527

system/application/config/scalar_store_utf8mb4.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ CREATE TABLE IF NOT EXISTS `scalar_db_books` (
2020
`editions` text COLLATE utf8mb4_general_ci DEFAULT NULL,
2121
`user` varchar(64) COLLATE utf8mb4_general_ci NOT NULL,
2222
`created` datetime NOT NULL,
23+
`terms_of_service` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
24+
`privacy_policy` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
2325
PRIMARY KEY (`book_id`)
2426
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
2527

system/application/models/book_model.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ public function add($array=array(), $captcha=true) {
530530
if (isset($array['scope']) && !empty($array['scope'])) $data['scope'] = $array['scope'];
531531
if (isset($array['publisher']) && !empty($array['publisher'])) $data['publisher'] = $array['publisher'];
532532
if (isset($array['publisher_thumbnail']) && !empty($array['publisher_thumbnail'])) $data['publisher_thumbnail'] = $array['publisher_thumbnail'];
533+
if (isset($array['terms_of_service']) && !empty($array['terms_of_service'])) $data['terms_of_service'] = $array['terms_of_service'];
534+
if (isset($array['privacy_policy']) && !empty($array['privacy_policy'])) $data['privacy_policy'] = $array['privacy_policy'];
533535

534536
try {
535537
$this->getStorage($data['slug'])->setUp();

system/application/views/arbors/html5_RDFa/wrapper.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
if (isset($book->editorial_is_on) && $book->editorial_is_on) $editorial = true;
1616
if (!empty($book->publisher)) $publisher = $book->publisher;
1717
if (!empty($book->publisher_thumbnail)) $publisher_thumbnail = $book->publisher_thumbnail;
18+
if (!empty($book->terms_of_service)) {
19+
$terms_of_service = $book->terms_of_service;
20+
} else if (!empty($this->config->item('terms_of_service'))) {
21+
$terms_of_service = $this->config->item('terms_of_service');
22+
}
23+
if (!empty($book->privacy_policy)) {
24+
$privacy_policy = $book->privacy_policy;
25+
} else if (!empty($this->config->item('privacy_policy'))) {
26+
$privacy_policy = $this->config->item('privacy_policy');
27+
}
1828
}
1929
if (isset($page->versions) && isset($page->versions[$page->version_index]->has_paths) && !empty($page->versions[$page->version_index]->has_paths)) {
2030
$path_index = $page->versions[$page->version_index]->requested_path_index;
@@ -117,6 +127,12 @@ function print_rdf($rdf, $tabs=0, $ns=array(), $hide=array(), $aria=false, $forc
117127
<? if (!empty($primary_role)): ?>
118128
<link id="primary_role" rel="scalar:primary_role" href="<?=$primary_role?>" />
119129
<? endif ?>
130+
<? if (!empty($terms_of_service)): ?>
131+
<link id="terms_of_service" rel="dcterms:accessRights" href="<?=$terms_of_service?>" />
132+
<? endif ?>
133+
<? if (!empty($privacy_policy)): ?>
134+
<link id="privacy_policy" rel="dcterms:accessRights" href="<?=$privacy_policy?>" />
135+
<? endif ?>
120136
<? if (isset($use_proxy) && $use_proxy): ?>
121137
<link id="use_proxy" href="true" />
122138
<link id="proxy_url" href="<?=base_url().$book->slug.'/proxy'?>" />

system/application/views/melons/cantaloupe/js/scalarpage.jquery.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,10 @@
14201420
}
14211421
$par.append('<a href="http://scalar.usc.edu/scalar"><img src="' + page.options.root_url + '/images/scalar_logo_small.png" width="18" height="16" alt="Scalar logo"/></a>');
14221422
$par.append(' Powered by <a href="http://scalar.usc.edu/scalar">Scalar</a> (<a href="https://github.com/anvc/scalar">' + $('link#scalar_version').attr('href').trim() + '</a>) | ');
1423-
$par.append('<a href="http://scalar.usc.edu/terms-of-service/">Terms of Service</a> | ');
1424-
$par.append('<a href="http://scalar.usc.edu/privacy-policy/">Privacy Policy</a> | ');
1423+
var termsOfService = $('link#terms_of_service').attr('href')
1424+
if (termsOfService) $par.append('<a href="' + termsOfService + '">Terms of Service</a> | ');
1425+
var privacyPolicy = $('link#privacy_policy').attr('href')
1426+
if (privacyPolicy) $par.append('<a href="' + privacyPolicy + '">Privacy Policy</a> | ');
14251427
$par.append('<a href="http://scalar.usc.edu/contact/">Scalar Feedback</a>');
14261428
},
14271429

system/application/views/melons/honeydew/footer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
// Publisher and license
6262
echo '<span class="poweredby">'."\n";
6363
if (!empty($book->publisher)) echo 'Published by '.$book->publisher.'. ';
64-
echo 'Powered by <a href="http://scalar.usc.edu">Scalar</a>.<br /><a href="http://scalar.usc.edu/terms-of-service/">Terms of Service</a> | <a href="http://scalar.usc.edu/privacy-policy/">Privacy Policy</a> | <a href="http://scalar.usc.edu/contact/">Scalar Feedback</a>';
64+
echo 'Powered by <a href="http://scalar.usc.edu">Scalar</a>.<br />';
65+
if (!empty($book->terms_of_service)) echo '<a href="'.$book->terms_of_service.'">Terms of Service</a> | ';
66+
if (!empty($book->privacy_policy)) echo '<a href="'.$book->privacy_policy.'">Privacy Policy</a> | ';
67+
echo '<a href="http://scalar.usc.edu/contact/">Scalar Feedback</a>';
6568
echo "</span>\n";
6669

6770
echo "</div>\n"; // logo wrapper

system/application/views/modules/dashboot/props.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,14 @@ function select_versions() {
374374
</div>
375375
</div>
376376
<div class="form-group">
377-
<label for="publisher" class="col-sm-2 control-label">Publisher credit</label>
377+
<label for="publisher" class="col-sm-2 control-label">Publisher Credit</label>
378378
<div class="col-sm-10">
379379
<input type="text" class="form-control" id="publisher" name="publisher" value="<?=htmlspecialchars($book->publisher)?>">
380380
<small>Any HTML hyperlink included here will also be applied to the publisher logo</small>
381381
</div>
382382
</div>
383383
<div class="form-group">
384-
<label for="upload_publisher_thumb" class="col-sm-2 control-label">Publisher logo</label>
384+
<label for="upload_publisher_thumb" class="col-sm-2 control-label">Publisher Logo</label>
385385
<div class="col-sm-4">
386386
<div class="input-group">
387387
<input type="hidden" name="publisher_thumbnail" value="<?=$book->publisher_thumbnail?>" />
@@ -408,6 +408,23 @@ function select_versions() {
408408
</div>
409409
</div>
410410
</div>
411+
412+
<div class="form-group">
413+
<label for="publisher" class="col-sm-2 control-label">Terms of Service</label>
414+
<div class="col-sm-10">
415+
<input type="text" class="form-control" id="terms_of_service" name="terms_of_service" value="<?=htmlspecialchars($book->terms_of_service)?>">
416+
<small>Enter the URL to your Terms of Service</small>
417+
</div>
418+
</div>
419+
420+
<div class="form-group">
421+
<label for="publisher" class="col-sm-2 control-label">Privacy Policy</label>
422+
<div class="col-sm-10">
423+
<input type="text" class="form-control" id="privacy_policy" name="privacy_policy" value="<?=htmlspecialchars($book->privacy_policy)?>">
424+
<small>Enter the URL to your Privacy Policy</small>
425+
</div>
426+
</div>
427+
411428
<div class="page-header"></div>
412429
<div class="form-group">
413430
<div class="col-sm-12">

0 commit comments

Comments
 (0)