Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
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) !
6 changes: 3 additions & 3 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<info>
<id>background</id>
<name>Background</name>
<description>My first ownCloud app</description>
<description>Application which allows to register informations on the users link to the use of recorder VoNZ application</description>
<licence>AGPL</licence>
<author>Shawn</author>
<version>0.0.1</version>
<author>Shawn, A.Daugieras</author>
<version>0.0.2</version>
<namespace>Background</namespace>
<category>tool</category>
<dependencies>
Expand Down
34 changes: 30 additions & 4 deletions controller/pagecontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Shawn <syu702@aucklanduni.ac.nz>
* @copyright Shawn 2016
* @author Shawn <syu702@aucklanduni.ac.nz>, A.Daugieras <adau828@aucklanduni.ac.nz>
* @copyright Shawn,Daugieras 2017
*/

namespace OCA\Background\Controller;
Expand All @@ -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;
}

/**
Expand All @@ -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));
}
}
33 changes: 29 additions & 4 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Shawn <syu702@aucklanduni.ac.nz>
* @copyright Shawn 2016
* @author Shawn <syu702@aucklanduni.ac.nz>, A.Daugieras <adau828@aucklanduni.ac.nz>
* @copyright Shawn,Daugieras 2017
*/

namespace OCA\Background\Controller;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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
}
}
17 changes: 15 additions & 2 deletions db/backgroundinfo.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<?php
namespace OCA\Background\Db;

use OPC\AppFramework\Db\Entity;
use OCP\AppFramework\Db\Entity;

class BackgroundInfo extends Entity{
protected $name;
protected $age;
protected $gender;
protected $addr;

protected $eprofil;
protected $etype;
protected $eexposure;
protected $edetail;
protected $mprofil;
protected $mtype;
protected $mexposure;
protected $mdetail;
protected $nztime;
// Here you can add some variables


public function __construct(){
$this->addType('age', 'integer');
$this->addType('nztime','integer');
//If types of new variables are different from text specify their types here
}
}
?>
8 changes: 4 additions & 4 deletions db/backgroundinfomapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
87 changes: 44 additions & 43 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,69 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Shawn <syu702@aucklanduni.ac.nz>
* @copyright Shawn 2016
* @author Shawn <syu702@aucklanduni.ac.nz>, A.Daugieras <adau828@aucklanduni.ac.nz>
* @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);
Loading