diff --git a/README.md b/README.md index e2445e6..e9ced6b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,33 @@ # Background -Place this app in **owncloud/apps/** + +This is an application for owncloud who allows users to register some parameters in a database with an very simple interface. + +For now there are the following parameters : +name, age, gender, address, english profil, english type, english exposure, english detail, maori profil, maori type, maori exposure, maori detail, nz time + +## Installation + +Download the background repository and place this in **owncloud/apps/** + +Warning : The name of the repository HAVE TO be background !! + +## How to change parameters of the database ? + +To do somes modifications on the databases you have to manage with : + +/background/db/backgroundinfo.php + +/background/controller/pagecontroller.php (*function create*) + +/background/controller/settingcontroller.php (*functions getUserValue and setBackground*) + +## How to implement new parameters on users interface ? + +To implement new parameters on users interface you have to manage with : + +/background/js/script.js (to control and save) + +/background/templates/part.content.php (view part) ## Publish to App Store @@ -12,4 +40,10 @@ The archive is located in build/artifacts/appstore and can then be uploaded to t ## Running tests After [Installing PHPUnit](http://phpunit.de/getting-started.html) run: - phpunit -c phpunit.xml \ No newline at end of file + phpunit -c phpunit.xml + +## More + +To have more informations on how you can manage this application, let's see the [Owncloud Developer Manual](https://doc.owncloud.org/server/latest/developer_manual/app/index.html)... + +If you are in trouble with the interface, you can find some help [here](https://www.w3schools.com/html/default.asp) ! diff --git a/appinfo/info.xml b/appinfo/info.xml index a74a9f8..ba2ca73 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -2,10 +2,10 @@ background Background - My first ownCloud app + Application which allows to register informations on the users link to the use of recorder VoNZ application AGPL - Shawn - 0.0.1 + Shawn, A.Daugieras + 0.0.2 Background tool diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php index 8bd9908..8f171d6 100644 --- a/controller/pagecontroller.php +++ b/controller/pagecontroller.php @@ -5,8 +5,8 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Shawn - * @copyright Shawn 2016 + * @author Shawn , A.Daugieras + * @copyright Shawn,Daugieras 2017 */ namespace OCA\Background\Controller; @@ -18,15 +18,20 @@ use OCP\AppFramework\Controller; use OCP\IUserSession; +use OCA\Background\db\backgroundinfo; +use OCA\Background\db\backgroundinfomapper; + class PageController extends Controller { + private $mapper; private $userId; private $config; - public function __construct($AppName, IRequest $request, IConfig $config, $UserId){ + public function __construct($AppName, IRequest $request, backgroundinfomapper $mapper, IConfig $config, $UserId){ parent::__construct($AppName, $request); $this->config = $config; - $this->userId = $UserId; + $this->userId = $userId; + $this->mapper = $mapper; } /** @@ -43,4 +48,25 @@ public function index() { $params = ['user' => $this->userId]; return new TemplateResponse('background', 'main', $params); // templates/main.php } + + public function create($name, $age, $gender, $addr, $eprofil, $etype, $eexposure, $edetail, $mprofil, $mtype, $mexposure, $mdetail, $nztime) { + $background = new backgroundinfo(); + $background->setName($name); + $background->setAge($age); + $background->setGender($gender); + $background->setAddr($addr); + $background->setEprofil($eprofil); + $background->setEtype($etype); + $background->setEexposure($eexposure); + $background->setEdetail($edetail); + $background->setMprofil($mprofil); + $background->setMtype($mtype); + $background->setMexposure($mexposure); + $background->setMdetail($mdetail); + $background->setNztime($nztime); + +//For each new variable add a line at this function : $background->setVariableName($variableName); + + return new DataResponse($this->mapper->insert($background)); + } } diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 14d9f3c..0f1d0b9 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -5,8 +5,8 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Shawn - * @copyright Shawn 2016 + * @author Shawn , A.Daugieras + * @copyright Shawn,Daugieras 2017 */ namespace OCA\Background\Controller; @@ -40,7 +40,20 @@ public function getUserValue() { $params = ['name' => $this->getItem('name'), 'age' => $this->getItem('age'), 'gender' => $this->getItem('gender'), - 'addr' => $this->getItem('addr')]; + 'addr' => $this->getItem('addr'), + 'eprofil' => $this->getItem('eprofil'), + 'etype' => $this->getItem('etype'), + 'eexposure' => $this->getItem('eexposure'), + 'edetail' => $this->getItem('edetail'), + 'mprofil' => $this->getItem('mprofil'), + 'mtype' => $this->getItem('mtype'), + 'mexposure' => $this->getItem('mexposure'), + 'mdetail' => $this->getItem('mdetail'), + 'nztime' => $this->getItem('nztime'), + +//For each new varaible add a new line at this function : 'variableName' => $this->getItem('variableName'), + + ]; return new TemplateResponse('background', 'main', $params); } @@ -61,11 +74,23 @@ protected function updateItem($key, $value){ * @NoAdminRequired * @NoCSRFRequired */ - public function setBackground($name, $age, $gender, $addr) { + public function setBackground($name, $age, $gender, $addr, $eprofil, $etype, $eexposure, $edetail, $mprofil, $mtype, $mexposure, $mdetail, $nztime) { $this->updateItem('name', $name); $this->updateItem('age', $age); $this->updateItem('gender', $gender); $this->updateItem('addr', $addr); + $this->updateItem('eprofil', $eprofil); + $this->updateItem('etype', $etype); + $this->updateItem('eexposure', $eexposure); + $this->updateItem('edetail', $edetail); + $this->updateItem('mprofil', $mprofil); + $this->updateItem('mtype', $mtype); + $this->updateItem('mexposure', $mexposure); + $this->updateItem('mdetail', $mdetail); + $this->updateItem('nztime', $nztime); + +//For each new varaible add a new line at this function : $this->updateItem('variableName', $variableName); + return $this->getUserValue(); // templates/main.php } } diff --git a/db/backgroundinfo.php b/db/backgroundinfo.php index 35acd47..74c3683 100644 --- a/db/backgroundinfo.php +++ b/db/backgroundinfo.php @@ -1,16 +1,29 @@ addType('age', 'integer'); + $this->addType('nztime','integer'); + //If types of new variables are different from text specify their types here } } ?> diff --git a/db/backgroundinfomapper.php b/db/backgroundinfomapper.php index e6a1f31..c79329c 100644 --- a/db/backgroundinfomapper.php +++ b/db/backgroundinfomapper.php @@ -7,17 +7,17 @@ class BackgroundInforMapper extends Mapper { public function __construct(IDBConnection $db){ - parent::__construct($db, 'background_infor'); + parent::__construct($db,'background','\OCA\Background\Db\backgroundinfo'); } public function find($id){ - $sql = 'select * from *PERFIX*background_infor '. - 'where id = ?'; + $sql = 'SELECT * FROM *PREFIX*background '. + 'WHERE id = ?'; return $this->findEntity($sql, [$id]); } public function findAll($limit=null, $offset=null){ - $sql = 'select * from *PREFIX*background_infor'; + $sql = 'SELECT * FROM *PREFIX*background'; return $this->findEntities($sql, $limit, $offset); } } diff --git a/js/script.js b/js/script.js index c1eebf8..3f93616 100644 --- a/js/script.js +++ b/js/script.js @@ -4,68 +4,69 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Shawn - * @copyright Shawn 2016 + * @author Shawn , A.Daugieras + * @copyright Shawn,Daugieras 2017 */ (function ($, OC) { $(document).ready(function () { + + //allows to go on a other page (show one page and hide the two others) + $("#next").click(function(e){ + e.preventDefault(); + $('#Generaldata').addClass('hidden'); + $('#Maoriprofil').addClass('hidden'); + $('#Englishprofil').removeClass('hidden'); + }); + + $("#previous2").click(function(e){ + e.preventDefault(); + $('#Generaldata').removeClass('hidden'); + $('#Maoriprofil').addClass('hidden'); + $('#Englishprofil').addClass('hidden'); + }); + + $("#next2").click(function(e){ + e.preventDefault(); + $('#Generaldata').addClass('hidden'); + $('#Maoriprofil').removeClass('hidden'); + $('#Englishprofil').addClass('hidden'); + }); + + $("#previous3").click(function(e){ + e.preventDefault(); + $('#Generaldata').addClass('hidden'); + $('#Maoriprofil').addClass('hidden'); + $('#Englishprofil').removeClass('hidden'); + }); + function saveSettings() { - //OC.msg.startSaving('#activity_notifications_msg'); var post = $('#background').serialize(); var result = '#' + $(this).attr('name') + '-status'; $.post(OC.generateUrl('/apps/background/settings'), post) - .done(function() { - //alert( "second success" ); + .done(function() {; $(result).text("Saved!"); }) - .fail(function(xhr, textStatus, errorThrown) { + .fail(function() { $(result).text("Error!"); - //alert(xhr.responseText + "\n" + errorThrown); }) .always(function() { - //alert( "finished" ); }); } var $activityNotifications = $('#background'); + //savesetting when users add informations from input, select or textarea $activityNotifications.find('input').change(saveSettings); $activityNotifications.find('select').change(saveSettings); - -// $( "#name" ).change(function saveSettings() { -// alert( "Data Saved: " + $(this).attr('name') + $(this).val()); -// var jason = $.ajax({ -// cache: false, -// async: true, -// dataType : 'json', -// type: "POST", -// url: OC.generateUrl('/apps/background/settings'), -// data: "key=" + $(this).attr('name') -// + "&value=" + $(this).val(), -// success: function(msg){ -// alert( "Data Saved: " + msg + $(this).attr('name') + $(this).val()); -// }, -// error: function(jqXHR, textStatus, errorThrown){ -// console.log(errorThrown); -// console.log(jqXHR); -// } -// }); -// -// alert( "Data: " + jason); -// -//// var post = {key: $(this).attr('name'), value: $(this).val()}; -//// -//// $.post(OC.generateUrl('/apps/background/settings'), post) -//// .done(function() { -//// alert( "second success" ); -//// }) -//// .fail(function(xhr, textStatus, errorThrown) { -//// alert(xhr.responseText + "\n" + errorThrown); -//// }) -//// .always(function() { -//// alert( "finished" ); -//// }); -// }); + $activityNotifications.find('#edetail').change(saveSettings); + $activityNotifications.find('#mdetail').change(saveSettings); + +/* If you add new varaible and use a textarea you have to add this line : + + $activityNotifications.find('#textareId').change(saveSettings); + +*/ }); + })(jQuery, OC); diff --git a/templates/part.content.php b/templates/part.content.php index 2c88fc4..f8444c0 100644 --- a/templates/part.content.php +++ b/templates/part.content.php @@ -1,36 +1,222 @@
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+ +
+
+ + + +
+ + diff --git a/templates/part.navigation.php b/templates/part.navigation.php index 2432c1c..e5e8e5b 100644 --- a/templates/part.navigation.php +++ b/templates/part.navigation.php @@ -1,10 +1,7 @@ -