Skip to content

Commit

Permalink
Current Media Upload Feature - Copyright Notice
Browse files Browse the repository at this point in the history
  • Loading branch information
ykorvel committed Dec 5, 2012
1 parent ae538df commit 8c236ba
Show file tree
Hide file tree
Showing 14 changed files with 377 additions and 155 deletions.
1 change: 1 addition & 0 deletions www/application/classes/controller/filemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function action_index() {

$this->templateData['files_size'] = DB_ORM::model('map_element')->sizeFormat($fileInfo['size']);
$this->templateData['files_count'] = $fileInfo['count'];
$this->templateData['media_copyright'] = Kohana::$config->load('media_upload_copyright');

$fileView = View::factory('labyrinth/file/view');
$fileView->set('templateData', $this->templateData);
Expand Down
120 changes: 120 additions & 0 deletions www/application/classes/controller/systemmanager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php
/**
* Open Labyrinth [ http://www.openlabyrinth.ca ]
*
* Open Labyrinth 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 3 of the License, or
* (at your option) any later version.
*
* Open Labyrinth 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 Open Labyrinth. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2012 Open Labyrinth. All Rights Reserved.
*
*/
defined('SYSPATH') or die('No direct script access.');

class Controller_SystemManager extends Controller_Base {

public function before() {
parent::before();

if(Auth::instance()->get_user()->type->name != 'superuser') {
Request::initial()->redirect(URL::base());
}

unset($this->templateData['right']);
$this->template->set('templateData', $this->templateData);
}

public function action_index(){
$this->templateData['token'] = Security::token();
$this->templateData['email_config'] = Kohana::$config->load('email');
$viewPasswordReset = View::factory('systemmanager/passwordReset');
$viewPasswordReset->set('templateData', $this->templateData);
$this->templateData['tabsName'][0] = __('Password recovery settings');
$this->templateData['tabs'][0] = $viewPasswordReset;

$this->templateData['media_copyright'] = Kohana::$config->load('media_upload_copyright');
$viewCopyright = View::factory('systemmanager/mediaUploadCopyright');
$viewCopyright->set('templateData', $this->templateData);
$this->templateData['tabsName'][1] = __('Media Upload - Copyright Notice');
$this->templateData['tabs'][1] = $viewCopyright;

$view = View::factory('systemmanager/view');
$view->set('templateData', $this->templateData);

$this->templateData['center'] = $view;
$this->template->set('templateData', $this->templateData);
}

public function action_updatePasswordResetSettings(){
if ($_POST){
if (Security::check($_POST['token'])){
unset($_POST['token']);
$string = 'return array (';
foreach($_POST as $key => $value){
$value = str_replace('"', '\"', $value);
$string .= '"'.$key.'" => "'.$value.'", ';
}
$string .= ');';

$content = '';
$handle = fopen(DOCROOT.'application/config/email.php', 'r');
while (($buffer = fgets($handle)) !== false) {
$content .= $buffer;
}

$position = strpos($content, 'return array');
$header = substr($content, 0, $position);

file_put_contents(DOCROOT.'application/config/email.php', $header.$string);

Request::initial()->redirect(URL::base().'systemManager');
}else{
Request::initial()->redirect(URL::base());
}
}else{
Request::initial()->redirect(URL::base());
}
}

public function action_updateMediaUploadCopyright(){
if ($_POST){
if (Security::check($_POST['token'])){
unset($_POST['token']);
$string = 'return array (';
foreach($_POST as $key => $value){
$value = str_replace('"', '\"', $value);
$string .= '"'.$key.'" => "'.$value.'", ';
}
$string .= ');';

$content = '';
$handle = fopen(DOCROOT.'application/config/media_upload_copyright.php', 'r');
while (($buffer = fgets($handle)) !== false) {
$content .= $buffer;
}

$position = strpos($content, 'return array');
$header = substr($content, 0, $position);

file_put_contents(DOCROOT.'application/config/media_upload_copyright.php', $header.$string);

Request::initial()->redirect(URL::base().'systemManager#tabs-1');
}else{
Request::initial()->redirect(URL::base());
}
}else{
Request::initial()->redirect(URL::base());
}
}
}

?>
41 changes: 0 additions & 41 deletions www/application/classes/controller/usermanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,47 +200,6 @@ public function action_removeMember() {
DB_ORM::model('user_group')->remove((int)$groupId, (int)$userId);
Request::initial()->redirect(URL::base().'usermanager/editGroup/'.$groupId);
}

public function action_passwordResetSettings(){
$this->templateData['token'] = Security::token();
$this->templateData['email_config'] = Kohana::$config->load('email');
$view = View::factory('usermanager/passwordReset');
$view->set('templateData', $this->templateData);

$this->templateData['center'] = $view;
$this->template->set('templateData', $this->templateData);
}

public function action_updatePasswordResetSettings(){
if ($_POST){
if (Security::check($_POST['token'])){
unset($_POST['token']);
$string = 'return array (';
foreach($_POST as $key => $value){
$value = str_replace('"', '\"', $value);
$string .= '"'.$key.'" => "'.$value.'", ';
}
$string .= ');';

$content = '';
$handle = fopen(DOCROOT.'application/config/email.php', 'r');
while (($buffer = fgets($handle)) !== false) {
$content .= $buffer;
}

$position = strpos($content, 'return array');
$header = substr($content, 0, $position);

file_put_contents(DOCROOT.'application/config/email.php', $header.$string);

Request::initial()->redirect(URL::base().'usermanager/passwordResetSettings/');
}else{
Request::initial()->redirect(URL::base());
}
}else{
Request::initial()->redirect(URL::base());
}
}
}

?>
18 changes: 11 additions & 7 deletions www/application/classes/model/leap/map/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,18 @@ public function deleteFile($fileId) {
}

public function getFilesSize($filesArray) {
$totalsize = 0;
foreach($filesArray as $file){
$totalsize += filesize(DOCROOT.$file->path);
}
$totalsize = 0;
$total['size'] = 0;
$total['count'] = 0;
if (count($filesArray) > 0){
foreach($filesArray as $file){
$totalsize += filesize(DOCROOT.$file->path);
}

$total['size'] = $totalsize;
$total['count'] = count($filesArray);
return $total;
$total['size'] = $totalsize;
$total['count'] = count($filesArray);
}
return $total;
}

public function sizeFormat($size)
Expand Down
23 changes: 23 additions & 0 deletions www/application/config/media_upload_copyright.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Open Labyrinth [ http://www.openlabyrinth.ca ]
*
* Open Labyrinth 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 3 of the License, or
* (at your option) any later version.
*
* Open Labyrinth 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 Open Labyrinth. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2012 Open Labyrinth. All Rights Reserved.
*
*/
defined('SYSPATH') or die('No direct access allowed.');

return array ("title" => "General statement", "copyright_message" => "I acknowledge that I own the copyright to the digital media I upload, or that I have obtained the written permission of the copyright owner, or am using an digital media with an appropriate Creative Commons license.", );
4 changes: 2 additions & 2 deletions www/application/views/adminMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
<td nowrap=""><a href="<?php echo URL::base(); ?>dictionaryManager"><img src="<?php echo URL::base(); ?>images/remotel.jpg" border="0" alt=""></a></td>
<td nowrap=""><p><a href="<?php echo URL::base(); ?>dictionaryManager"><strong><?php echo __('manage dictionary'); ?></strong></a></p></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td nowrap=""><a href="<?php echo URL::base(); ?>usermanager/passwordResetSettings"><img src="<?php echo URL::base(); ?>images/remotel.jpg" border="0" alt=""></a></td>
<td nowrap=""><p><a href="<?php echo URL::base(); ?>usermanager/passwordResetSettings"><strong><?php echo __('password recovery settings'); ?></strong></a></p></td>
<td nowrap=""><a href="<?php echo URL::base(); ?>systemManager"><img src="<?php echo URL::base(); ?>images/remotel.jpg" border="0" alt=""></a></td>
<td nowrap=""><p><a href="<?php echo URL::base(); ?>systemManager"><strong><?php echo __('system settings'); ?></strong></a></p></td>
</tr>
<?php } ?>
</table>
7 changes: 5 additions & 2 deletions www/application/views/labyrinth/file/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,21 @@

<p><?php echo __('upload a file to Labyrinth'); ?> "<?php echo $templateData['map']->name; ?>"</p>

<form method="POST" enctype="multipart/form-data" action="<?php echo URL::base().'fileManager/uploadFile/'.$templateData['map']->id; ?>">
<form method="POST" id="upload-form" enctype="multipart/form-data" action="<?php echo URL::base().'fileManager/uploadFile/'.$templateData['map']->id; ?>">
<table width="100%" border="0" cellspacing="6">
<tr>
<td nowrap=""><p><?php echo __('select file to upload'); ?></p></td>
<td align="center">
<input type="FILE" size="50" name="filename"></td>
<td>
<input type="submit" name="Submit" value="<?php echo __('submit'); ?>">
<input id="opener" type="button" name="Submit" value="<?php echo __('submit'); ?>">
</td>
</tr>
</table>
</form>
<div id="dialog-confirm" title="<?php echo $templateData['media_copyright']['title']; ?>">
<div class="dialog-box"><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span><?php echo $templateData['media_copyright']['copyright_message']; ?></div>
</div>
<hr>
<p>JPEG (.jpg + .jpeg), GIF (.gif), PNG (.png), Acrobat PDF (.pdf), Shockwave Flash (.swf), Microsoft Word, (.doc), Microsoft Excel (.xls), Microsoft PowerPoint (.ppt), Rich Text Format (.rtf), Quicktime Video (.mov), MPEG-4 Video (.mp4), Windows Media (.wmv), Real Stream (.ram), Real Stream (.rpm), Flash video, (.flv), MP3 audio (.mp3), WAV audio (.wav), AAC (m4a) audio (.m4a)</p>
</td>
Expand Down
49 changes: 49 additions & 0 deletions www/application/views/systemmanager/mediaUploadCopyright.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Open Labyrinth [ http://www.openlabyrinth.ca ]
*
* Open Labyrinth 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 3 of the License, or
* (at your option) any later version.
*
* Open Labyrinth 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 Open Labyrinth. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2012 Open Labyrinth. All Rights Reserved.
*
*/
?>
<form action="<?php echo URL::base().'systemManager/updateMediaUploadCopyright/'; ?>" method="post">
<table>
<tr>
<td align="left">
<p><?php echo __('Title: '); ?></p>
</td>
<td align="left">
<p><input size="50" type="text" name="title" value="<?php echo $templateData['media_copyright']['title']; ?>" /></p>
</td>
</tr>
<tr>
<td align="left">
<p><?php echo __('Copyright message: '); ?></p>
</td>
<td align="left">
<p>
<textarea style="width:320px; height:130px;" name="copyright_message"><?php echo $templateData['media_copyright']['copyright_message']; ?></textarea>
</p>
</td>
</tr>
<tr>
<td colspan="2" align="left">
<input type="Submit" value="<?php echo __('Submit'); ?>">
</td>
</tr>
</table>
<input type="hidden" name="token" value="<?php echo $templateData['token']; ?>" />
</form>
Loading

0 comments on commit 8c236ba

Please sign in to comment.