Initial import
No files matched your search
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Action {
|
||||
|
||||
var $id;
|
||||
var $name;
|
||||
var $text;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Action($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($this->id == NULL){//New action
|
||||
if ($data == NULL){
|
||||
error("Action: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->name = $data['name'];
|
||||
$this->text = $data['text'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$action = scriptParam("action");
|
||||
if ($action == "register-action"){
|
||||
$this->id = getNextId("din_action");
|
||||
$sql = sprintf("INSERT INTO din_action VALUES " .
|
||||
" (%s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("New action registered and stored.");
|
||||
$sql = "INSERT INTO din_actiongrouprelationship VALUES
|
||||
($this->id, 3)";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Action granted to administrator group.");
|
||||
}else {
|
||||
error("Grant action: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("New action: " . $result->toString());
|
||||
}
|
||||
|
||||
}else {//Update
|
||||
$sql = sprintf("UPDATE din_action SET
|
||||
name = %s,
|
||||
text = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Action updated.");
|
||||
}else {
|
||||
error("Update action: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT a.*
|
||||
FROM din_action a
|
||||
WHERE a.id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}else {
|
||||
error("Actions: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
|
||||
$sql = "DELETE FROM din_action
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result =& $conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("Action: " . $result->toString());
|
||||
}else {
|
||||
notify("Action deleted.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function display(){
|
||||
displayOptionsMenu($this->id, "action");
|
||||
?>
|
||||
<h3><?php print "$this->name"; ?></h3>
|
||||
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=display-action&actionid=<?php print $this->id; ?>"><?php print $this->name; ?></a></td>
|
||||
<td><?php print prepareForHTML($this->text); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, ACTION, "action", "view-edit-options-action"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class ActionGroupRelationship {
|
||||
|
||||
var $action_id;
|
||||
var $action_name;
|
||||
var $group_id;
|
||||
var $group_name;
|
||||
|
||||
var $conn;
|
||||
|
||||
function ActionGroupRelationship($action_id = NULL, $group_id = NULL){
|
||||
$this->__construct($action_id, $group_id);
|
||||
}
|
||||
public function __construct($action_id = NULL, $group_id = NULL){
|
||||
$this->conn =& DB_connect();
|
||||
|
||||
$this->action_id = $action_id;
|
||||
$this->group_id = $group_id;
|
||||
$action = scriptParam("action");
|
||||
|
||||
if ($action == "register-actiongrouprelationship" || $action == "update-group"){
|
||||
|
||||
}else {
|
||||
$data = $this->_retrieveData();
|
||||
$this->action_name = $data['action_name'];
|
||||
$this->group_name = $data['group_name'];
|
||||
}
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$sql = sprintf("INSERT INTO din_actiongrouprelationship
|
||||
(action_id, group_id)
|
||||
VALUES
|
||||
(%s, %s)",
|
||||
$this->conn->quoteSmart($this->action_id),
|
||||
$this->conn->quoteSmart($this->group_id)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if (scriptParam("action") == "register-actiongrouprelationship"){
|
||||
notify("New actiongrouprelationship registered and stored.");
|
||||
}
|
||||
}else {
|
||||
error("New action: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT a.name AS action_name, g.name AS group_name
|
||||
FROM din_actiongrouprelationship agr, din_action a, din_group g
|
||||
WHERE agr.action_id = $this->action_id
|
||||
AND agr.group_id = $this->group_id
|
||||
AND agr.action_id = a.id
|
||||
AND agr.group_id = g.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("ActionGroupRelationships: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$sql = "DELETE FROM din_actiongrouprelationship
|
||||
WHERE action_id = $this->action_id
|
||||
AND group_id = $this->group_id
|
||||
LIMIT 1";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("ActionGroupRelationship deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td><?php print "$this->action_name"; ?></td>
|
||||
<td><?php print "$this->group_name"; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
class ActionGroupRelationships {
|
||||
var $relations;
|
||||
var $conn;
|
||||
|
||||
function ActionGroupRelationships(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
error("ActionGroupRelationships: " . $conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
}
|
||||
|
||||
public function getJoinedList($group_id, $type = "array", $exclude = 1){
|
||||
$exclude_statement = "";
|
||||
if (is_array($exclude)) {
|
||||
foreach ($exclude as $e) {
|
||||
if ($e != 0) {
|
||||
$exclude_statement .= "AND a.id NOT IN (SELECT action_id FROM din_actiongrouprelationship agr WHERE agr.group_id = $e)\n";
|
||||
}
|
||||
}
|
||||
}else {
|
||||
$exclude_statement = "AND a.id NOT IN (SELECT action_id FROM din_actiongrouprelationship agr WHERE agr.group_id = $exclude)";
|
||||
}
|
||||
|
||||
$sql = "SELECT agr.group_id, a.id AS action_id, a.name AS action_name
|
||||
FROM din_group g, din_action a LEFT JOIN din_actiongrouprelationship agr
|
||||
ON a.id = agr.action_id
|
||||
AND agr.group_id = $group_id
|
||||
WHERE g.id = $group_id
|
||||
$exclude_statement
|
||||
ORDER BY a.name";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$list = Array();
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$list["names"][] = $row->action_id;
|
||||
$list["labels"][] = $row->action_name;
|
||||
$list["checked"][] = ($row->group_id == NULL) ? false : true;
|
||||
}
|
||||
return $list;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
$sql = "SELECT action_id, group_id
|
||||
FROM din_actiongrouprelationship";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->relations = $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return $this->relations;
|
||||
}
|
||||
|
||||
public function displayList($limit = 25){
|
||||
$this->getList();
|
||||
if ($this->relations->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="actiongrouprelationgships">
|
||||
<tr>
|
||||
<th>handling</th>
|
||||
<th>gruppe</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->relations->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$rel = new ActionGroupRelationship($row->action_id, $row->group_id);
|
||||
$rel->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen forhold registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class Actions {
|
||||
var $actions;
|
||||
var $conn;
|
||||
|
||||
function Actions(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
error("Actions: " . $conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
$sql = "SELECT id, name
|
||||
FROM din_action
|
||||
ORDER BY name ASC";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->actions = $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
return $this->actions;
|
||||
}
|
||||
|
||||
public function displayList($limit = 25){
|
||||
if ($this->actions->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="actions">
|
||||
<tr>
|
||||
<th>handling</th>
|
||||
<th>beskrivelse</th>
|
||||
<th colspan="2"> </th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->actions->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$action = new Action($row->id);
|
||||
$action->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen handlinger registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Article {
|
||||
|
||||
public $id;
|
||||
public $title;
|
||||
public $intro;
|
||||
public $text;
|
||||
public $attachment1;
|
||||
public $caption1;
|
||||
public $attachment2;
|
||||
public $caption2;
|
||||
public $date;
|
||||
public $author;
|
||||
public $updated_by;
|
||||
public $updated_at;
|
||||
public $expires;
|
||||
|
||||
|
||||
public $conn;
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New article
|
||||
if ($data == NULL){
|
||||
error('Article: No data supplied.');
|
||||
}else {
|
||||
$this->author = getCurrentUserName();
|
||||
$this->updated_by = getCurrentUserName();
|
||||
|
||||
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
$this->updated_by = getCurrentUserName();
|
||||
|
||||
//primary attachment
|
||||
if($_FILES['attachment1']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['attachment1'], 'nyheter');
|
||||
rename_file($temp_name, $this->id, 'nyheter');
|
||||
$this->attachment1 = $this->id.substr($temp_name, -4);
|
||||
}else {
|
||||
$this->attachment1 = 0;
|
||||
}
|
||||
|
||||
//secondary attachment
|
||||
if($_FILES['attachment2']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['attachment2'], 'nyheter');
|
||||
rename_file($temp_name, $this->id.'_2', 'nyheter');
|
||||
$this->attachment2 = $this->id.'_2'.substr($temp_name, -4);
|
||||
}else {
|
||||
$this->attachment2 = 0;
|
||||
}
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->date = $data['date'];
|
||||
$this->attachment1 = $data['attachment1'];
|
||||
$this->attachment2 = $data['attachment2'];
|
||||
$this->author = $data['author'];
|
||||
$this->updated_by = $data['updated_by'];
|
||||
$this->updated_at = $data['updated_at'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->title = $data['title'];
|
||||
$this->intro = stripcslashes($data['intro']);
|
||||
$this->text = stripcslashes($data['text']);
|
||||
$this->caption1 = $data['caption1'];
|
||||
$this->caption2 = $data['caption2'];
|
||||
$this->expires = $data['expires'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("nyhet");
|
||||
$sql = "INSERT INTO nyhet VALUES " .
|
||||
" (%s, %s, %s, %s, '', %s, '', %s, NOW(), %s, %s, NOW(), %s)";
|
||||
$sql = sprintf($sql,
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->intro),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->caption1),
|
||||
$this->conn->quoteSmart($this->caption2),
|
||||
$this->conn->quoteSmart($this->author),
|
||||
$this->conn->quoteSmart($this->updated_by),
|
||||
$this->conn->quoteSmart($this->expires)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
|
||||
//primary attachment
|
||||
if($_FILES['attachment1']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['attachment1'], 'nyheter');
|
||||
rename_file($temp_name, $this->id, 'nyheter');
|
||||
$this->attachment1 = $this->id.substr($temp_name, -4);
|
||||
}else {
|
||||
$this->attachment1 = 0;
|
||||
}
|
||||
|
||||
//secondary attachment
|
||||
if($_FILES['attachment2']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['attachment2'], 'nyheter');
|
||||
rename_file($temp_name, $this->id.'_2', 'nyheter');
|
||||
$this->attachment2 = $this->id.'_2'.substr($temp_name, -4);
|
||||
}else {
|
||||
$this->attachment2 = 0;
|
||||
}
|
||||
$this->_storeFilenames();
|
||||
|
||||
$GLOBALS['extraScriptParams']['articleid'] = $this->id;
|
||||
notify("Nyhet er lagret.");
|
||||
}else {
|
||||
error("New article: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE nyhet SET
|
||||
tittel = %s,
|
||||
ingress = %s,
|
||||
tekst = %s,
|
||||
utgar = %s,
|
||||
caption1 = %s,
|
||||
caption2 = %s,
|
||||
sistEndretAv = %s,
|
||||
sistEndret = NOW()
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->intro),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->expires),
|
||||
$this->conn->quoteSmart($this->caption1),
|
||||
$this->conn->quoteSmart($this->caption2),
|
||||
$this->conn->quoteSmart($this->updated_by),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Nyhet oppdatert.");
|
||||
$this->_storeFilenames();
|
||||
}else {
|
||||
error("New event: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT " .
|
||||
" tittel AS title, ".
|
||||
" ingress AS intro, ".
|
||||
" tekst AS text, ".
|
||||
" vedlegg AS attachment1, ".
|
||||
" caption1, ".
|
||||
" vedlegg2 AS attachment2, ".
|
||||
" caption2, ".
|
||||
" dato AS date, ".
|
||||
" forfatter AS author, ".
|
||||
" sistEndretAv AS updated_by, ".
|
||||
" sistEndret AS updated_at, ".
|
||||
" utgar AS expires " .
|
||||
"FROM nyhet WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Articles: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM nyhet
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Nyhet slettet.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, ARTICLE, "article", "view-edit-options-article");
|
||||
|
||||
print('<div class="article_images">');
|
||||
if ($this->attachment1 != 0){
|
||||
print('<div class="primary_image">');
|
||||
print('<img src="http://www.studentersamfundet.no/imageResize.php?pic=bilder/nyheter/'.$this->attachment1.'&maxwidth=200" alt="" />');
|
||||
print('<span class="caption">'.$this->caption1.'</span>');
|
||||
print('</div>');
|
||||
}
|
||||
|
||||
if ($this->attachment2 != 0){
|
||||
print('<div class="extra_image">');
|
||||
print('<img src="http://www.studentersamfundet.no/imageResize.php?pic=bilder/nyheter/'.$this->attachment2.'&maxwidth=200" alt="" />');
|
||||
print('<span class="caption">'.$this->caption2.'</span>');
|
||||
print('</div>');
|
||||
}
|
||||
print('</div>');
|
||||
|
||||
|
||||
//$text = str_replace("[img2]", $this->_text_insert_attachment($this->attachment2, $this->caption2), $this->text);
|
||||
$text = str_replace('[img2]', '', $this->text);
|
||||
|
||||
?>
|
||||
<h3><?php print $this->title; ?></h3>
|
||||
<p class="date"><?php print formatDate($this->date); ?></p>
|
||||
|
||||
<p class="intro"><?php print prepareForHTML($this->intro); ?></p>
|
||||
<p class="text"><?php print $text; ?></p>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=display-article&articleid=<?php print $this->id; ?>"><?php print $this->title; ?></a></td>
|
||||
<td><?php print prepareForHTML($this->intro); ?></td>
|
||||
<td><?php print $this->author; ?></td>
|
||||
<td class="date"><?php print formatDate($this->date, "td"); ?></td>
|
||||
<td class="date"><?php print formatDate($this->expires, "td"); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, ARTICLE, "article", "view-edit-options-article"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
private function _text_insert_attachment($file, $caption) {
|
||||
$string = "";
|
||||
if (!empty($file)){
|
||||
$string .= '<div class="extra_image">
|
||||
<img class="nyhet" src="http://www.studentersamfundet.no/imageResize.php?pic=bilder/nyheter/'.$file.'&maxwidth=200" alt=" " />';
|
||||
if (!empty($caption)){
|
||||
$string .= '<span class="caption">'.$caption.'</span>';
|
||||
}
|
||||
$string .= "</div>\n";
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
private function _storeFilenames() {
|
||||
if ($this->attachment1 != 0) {
|
||||
$sql = "UPDATE nyhet SET vedlegg = '$this->attachment1' WHERE id = $this->id";
|
||||
$result = $this->conn->query($sql);
|
||||
}
|
||||
if ($this->attachment2 != 0) {
|
||||
$sql = "UPDATE nyhet SET vedlegg2 = '$this->attachment2' WHERE id = $this->id";
|
||||
$result = $this->conn->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Articles {
|
||||
private $conn;
|
||||
private $list;
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function displayList($limit = 25){
|
||||
$sql = "SELECT id
|
||||
FROM nyhet
|
||||
ORDER BY dato DESC LIMIT $limit";
|
||||
if ($this->conn == false){
|
||||
return false;
|
||||
}
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
print("<p>Antall treff: ".$result->numRows()."</p>");
|
||||
?>
|
||||
<table class="sortable" id="articlelist">
|
||||
<tr>
|
||||
<th>tittel</th>
|
||||
<th>intro</th>
|
||||
<th>forfatter</th>
|
||||
<th>publisert</th>
|
||||
<th>utgår</th>
|
||||
<?php if(checkAuth("view-edit-options-article")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$article = new Article($row['id']);
|
||||
$article->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen nyheter er registrert.</p>");
|
||||
}
|
||||
}else {
|
||||
error("Articles: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,442 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class BarShift {
|
||||
|
||||
var $id;
|
||||
var $date;
|
||||
var $location_id;
|
||||
var $location_name;
|
||||
var $start;
|
||||
var $end;
|
||||
var $num_workers;
|
||||
var $sum_workers;
|
||||
var $title;
|
||||
var $eventcategory_title;
|
||||
|
||||
var $conn;
|
||||
|
||||
function BarShift($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New BarShift
|
||||
if ($data == NULL){
|
||||
error("BarShift: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->location_name = $data['location_name'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->date = $data['date'];
|
||||
$this->start = formatTime($data['start']);
|
||||
$this->end = formatTime($data['end']);
|
||||
$this->location_id = $data['location_id'];
|
||||
$this->title = $data['title'];
|
||||
$this->num_workers = (is_numeric($data['num_workers']))? $data['num_workers'] : 0;
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_barshift");
|
||||
$sql = sprintf("INSERT INTO din_barshift
|
||||
(id, date, location_id, start, end, num_workers, title)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->date),
|
||||
$this->conn->quoteSmart($this->location_id),
|
||||
$this->conn->quoteSmart($this->start),
|
||||
$this->conn->quoteSmart($this->end),
|
||||
$this->conn->quoteSmart($this->num_workers),
|
||||
$this->conn->quoteSmart($this->title)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['barshiftid'] = $this->id;
|
||||
$sql = sprintf("INSERT INTO din_barshiftupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart(scriptParam('barshiftid')),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Bar shift registered.")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Ny barvakt er registert.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Bar Shift: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Bar Shift: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Bar Shift: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_barshift SET
|
||||
date = %s,
|
||||
location_id = %s,
|
||||
start = %s,
|
||||
end = %s,
|
||||
num_workers = %s," .
|
||||
" title = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->date),
|
||||
$this->conn->quoteSmart($this->location_id),
|
||||
$this->conn->quoteSmart($this->start),
|
||||
$this->conn->quoteSmart($this->end),
|
||||
$this->conn->quoteSmart($this->num_workers),
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$sql = sprintf("INSERT INTO din_barshiftupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Bar shift updated.")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Barvakt oppdatert.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New BarShift: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update BarShift: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update BarShift: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function repeat($data){
|
||||
$frequency = $data['frequency'];
|
||||
$count = $data['count'];
|
||||
for ($i = 0; $i < $count; $i++){
|
||||
$id = getNextId("din_barshift");
|
||||
$date = get_repeat_date($this->date, $i + 1, $frequency);
|
||||
$sql = sprintf("INSERT INTO din_barshift
|
||||
(id, date, location_id, start, end, num_workers, title)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($id),
|
||||
$this->conn->quoteSmart($date),
|
||||
$this->conn->quoteSmart($this->location_id),
|
||||
$this->conn->quoteSmart($this->start),
|
||||
$this->conn->quoteSmart($this->end),
|
||||
$this->conn->quoteSmart($this->num_workers),
|
||||
$this->conn->quoteSmart($this->title)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$sql = sprintf("INSERT INTO din_barshiftupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart($id),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Bar shift registered (repeat).")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Barvakt repetert.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New BarShift: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New BarShift: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("New BarShift: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function copy($data){
|
||||
$id = getNextId("din_barshift");
|
||||
$sql = sprintf("INSERT INTO din_barshift
|
||||
(id, date, location_id, start, end, num_workers, title)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($id),
|
||||
$this->conn->quoteSmart($data['new-date']),
|
||||
$this->conn->quoteSmart($this->location_id),
|
||||
$this->conn->quoteSmart($this->start),
|
||||
$this->conn->quoteSmart($this->end),
|
||||
$this->conn->quoteSmart($this->num_workers),
|
||||
$this->conn->quoteSmart($this->title)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$sql = sprintf("INSERT INTO din_barshiftupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart($id),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Bar shift registered (copy).")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Barvakt kopiert.");
|
||||
$GLOBALS['extraScriptParams']['barshiftid'] = $id;
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New BarShift: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
notify("Problemer med kopiering av barvakt.");
|
||||
error("New BarShift: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT b.*, l.navn AS location_name
|
||||
FROM din_barshift b, lokaler l " .
|
||||
"WHERE b.id = $this->id
|
||||
AND b.location_id = l.id";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("BarShifts: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_barshift
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Barvakt slettet.");
|
||||
if (scriptParam("barshift-overview") != "") {
|
||||
$GLOBALS['extraScriptParams']['page'] = scriptParam("barshift-overview");
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
notify("Barvakten kan ikke slettes. Dette er en feil. Vennligst rapporter problemet med skjemaet under:");
|
||||
reportBug("delete-barshift");
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, BARSHIFT, "barshift", "view-edit-options-barshift");
|
||||
?>
|
||||
<h3><?php print $this->title." - ". $this->location_name; ?></h3>
|
||||
<p><?php print formatDate($this->date); ?></p>
|
||||
<p><?php print $this->start." - ".$this->end; ?></p>
|
||||
<p><?php print $this->_getSumWorkers()." av ".$this->num_workers." vakter er dekket."; ?></p>
|
||||
<?php
|
||||
if (checkAuth("perform-register-barshiftworker")){
|
||||
$users = new Users();
|
||||
$userList = $users->getList(13);//13 == Tappetårnet
|
||||
|
||||
$userid = scriptParam("userid");
|
||||
if ($userid != ""){
|
||||
$cur = $userid;
|
||||
}else {
|
||||
$cur = getCurrentUser();
|
||||
}
|
||||
|
||||
$title = "register bar shift worker";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=register-barshiftworker&page=display-barshift";
|
||||
$fields = Array(Array("label" => "barshiftidid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "barshiftid", "value" => "$this->id")),
|
||||
Array("label" => "sett opp", "type" => "select",
|
||||
"attributes" => Array("name" => "userid", "values" => $userList,
|
||||
"currentValue" => $cur))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
}
|
||||
|
||||
$this->_displayWorkerList();
|
||||
|
||||
if (checkAuth("view-register-barshift")){
|
||||
?><p>Repetisjon og kopiering kopierer bare informasjon om vakten, ikke de som er satt opp på vakt.</p><?php
|
||||
$freqOptions = Array(Array("id" => "daily", "title" => "daglig"),
|
||||
Array("id" => "weekly", "title" => "ukentlig"),
|
||||
Array("id" => "biweekly", "title" => "annenhver uke"),
|
||||
Array("id" => "monthlyDate", "title" => "månedlig"),
|
||||
Array("id" => "annual", "title" => "årlig")
|
||||
);
|
||||
|
||||
$title = "repeat bar shift";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=repeat-barshift&page=display-barshift";
|
||||
$fields = Array(Array("label" => "barshiftidid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "barshiftid", "value" => "$this->id")),
|
||||
Array("label" => "gjenta vakt", "type" => "select",
|
||||
"attributes" => Array("name" => "frequency", "values" => $freqOptions,
|
||||
"value" => $freqOptions[0])),
|
||||
Array("label" => "antall ganger", "type" => "text",
|
||||
"attributes" => Array("name" => "count", "size" => 3, "maxlength" => 3,
|
||||
"value" => 0))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
|
||||
|
||||
$title = "copy bar shift";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=copy-barshift&page=display-barshift";
|
||||
$fields = Array(Array("label" => "barshiftid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "barshiftid", "value" => "$this->id")),
|
||||
Array("label" => "kopier til", "type" => "date",
|
||||
"attributes" => Array("name" => "new-date", "value" => "$this->date"))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
$workers = $this->_getSumWorkers();
|
||||
|
||||
?>
|
||||
<tr <?php if ($workers >= $this->num_workers) print 'class="barshift-full"'; ?>>
|
||||
<td><a href="index.php?page=display-barshift&barshiftid=<?php print $this->id; ?>"><?php print $this->title; ?></a></td>
|
||||
<td><?php print $this->location_name; ?></td>
|
||||
<td><?php print formatDate($this->date, "td"); ?></td>
|
||||
<td><?php print formatTime($this->start); ?></td>
|
||||
<td><?php print formatTime($this->end); ?></td>
|
||||
<td class="worker-status"><?php print $workers."/".$this->num_workers; ?></td>
|
||||
<?php if(checkAuth("view-edit-options-barshift")){
|
||||
displayOptionsMenuTable($this->id, BARSHIFT, "barshift", "view-edit-options-barshift");
|
||||
} ?>
|
||||
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayCalendar($year, $month){
|
||||
$workers = $this->_getSumWorkers();
|
||||
if ($this->barShiftIsFull()){
|
||||
$full = "full";
|
||||
}else {
|
||||
$full = "not-full";
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="calendar-barshift <?php print $full; ?>">
|
||||
<h4><?php print $this->start." - ".$this->end." (".$this->_getSumWorkers()."/".$this->num_workers.")";?></h4>
|
||||
<h4 class="calendar-title"><a href="index.php?page=display-barshift&barshiftid=<?php print $this->id; ?>">
|
||||
<?php print $this->title." - ".$this->location_name; ?>
|
||||
</a>
|
||||
<!--<?php displayOptionsMenuCalendar($this->id, BARSHIFT, "barshift", "view-edit-options-barshift", "$year$month"); ?>-->
|
||||
</h4>
|
||||
<?php
|
||||
$bsw = new BarShiftWorkers();
|
||||
$bsw->displayCalendarListByBarshift($this->id);
|
||||
|
||||
if (!$this->_getIsUserWorking(getCurrentUser())){?>
|
||||
<a class="calendar-register-me" href="index.php?action=register-barshiftworker-self&page=display-barshifts-calendar&barshiftid=<?php print $this->id; ?>">
|
||||
sett opp meg!
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function _displayWorkerList(){
|
||||
$bsw = new BarShiftWorkers();
|
||||
$bsw->displayListByBarshift($this->id);
|
||||
}
|
||||
|
||||
|
||||
public
|
||||
function _getSumWorkers(){
|
||||
if (!empty($this->sum_workers)) {
|
||||
return $this->sum_workers;
|
||||
}
|
||||
$sql = "SELECT COUNT(*) AS workers " .
|
||||
"FROM din_barshiftworker " .
|
||||
"WHERE barshift_id = $this->id";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$this->sum_workers = $row->workers;
|
||||
return $row->workers;
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _getIsUserWorking($user_id){
|
||||
$sql = "SELECT user_id " .
|
||||
"FROM din_barshiftworker " .
|
||||
"WHERE barshift_id = $this->id " .
|
||||
"AND user_id = $user_id";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public
|
||||
function barShiftIsFull(){
|
||||
if ($this->_getSumWorkers() >= $this->num_workers) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class BarShiftWorker {
|
||||
|
||||
var $barshift_id;
|
||||
var $barshift_title;
|
||||
var $user_id;
|
||||
var $user_name;
|
||||
var $registered;
|
||||
|
||||
var $conn;
|
||||
|
||||
function BarShiftWorker($barshift_id = NULL, $user_id = NULL){
|
||||
$this->__construct($barshift_id, $user_id);
|
||||
}
|
||||
public function __construct($barshift_id = NULL, $user_id = NULL){
|
||||
$this->conn = DB_connect();
|
||||
|
||||
$this->barshift_id = $barshift_id;
|
||||
$this->user_id = $user_id;
|
||||
$action = scriptParam("action");
|
||||
|
||||
if ($action == "register-barshiftworker"){
|
||||
|
||||
}else {
|
||||
$data = $this->_retrieveData();
|
||||
$this->barshift_title= $data['barshift_title'];
|
||||
$this->user_name = $data['user_name'];
|
||||
$this->registered = $data['registered'];
|
||||
}
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$action = scriptParam("action");
|
||||
if ($action == "register-barshiftworker"){
|
||||
$sql = sprintf("INSERT INTO din_barshiftworker
|
||||
(barshift_id, user_id, registered)
|
||||
VALUES
|
||||
(%s, %s, NOW())",
|
||||
$this->conn->quoteSmart($this->barshift_id),
|
||||
$this->conn->quoteSmart($this->user_id)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Barvakt er registrert.");
|
||||
}else {
|
||||
$user = new User($this->user_id);
|
||||
notify("$user->firstname $user->lastname er allerede satt opp på denne vakten.");
|
||||
error("New barshiftworker: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT bsw.*, b.title AS barshift_title, CONCAT(u.firstname, ' ', u.lastname) AS user_name
|
||||
FROM din_barshiftworker bsw, din_barshift b, din_user u
|
||||
WHERE bsw.barshift_id = $this->barshift_id
|
||||
AND bsw.user_id = $this->user_id
|
||||
AND bsw.barshift_id = b.id
|
||||
AND bsw.user_id = u.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("BarShiftWorkers: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function delete($barshift_id, $user_id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_barshiftworker
|
||||
WHERE barshift_id = $barshift_id
|
||||
AND user_id = $user_id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Oppsatt barvakt slettet.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td><?php print $this->barshift_name; ?></td>
|
||||
<td><?php print $this->user_name; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
class BarShiftWorkers {
|
||||
var $relations;
|
||||
var $conn;
|
||||
|
||||
function BarShiftWorkers(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = DB_connect();
|
||||
}
|
||||
|
||||
public
|
||||
function _getListByUser($user_id){
|
||||
$sql = "SELECT * FROM din_barshiftworker " .
|
||||
"WHERE user_id = $user_id";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("BarShiftWorkers: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _getListByBarShift($barshift_id){
|
||||
$sql = "SELECT * FROM din_barshiftworker " .
|
||||
"WHERE barshift_id = $barshift_id";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("BarShiftWorkers: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function displayListByUser($user_id){
|
||||
$list = $this->_getListByUser($user_id);
|
||||
|
||||
if ($result->numRows() > 0){
|
||||
$user = new User($user_id);
|
||||
?>
|
||||
<h2>Vakter for <?php print $user->firstname." ".$user->lastname; ?></h2>
|
||||
<table class="sortable" id="barshiftworkerlist">
|
||||
<tr>
|
||||
<th>tittel</th>
|
||||
<th>sted</th>
|
||||
<th>dato</th>
|
||||
<th>start</th>
|
||||
<th>slutt</th>
|
||||
<th>ledige</th>
|
||||
<?php if(checkAuth("view-edit-options-barshift")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $list->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$barshift = new BarShift($row['id']);
|
||||
$barshift->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen vakter registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function displayListByBarShift($barshift_id){
|
||||
$list = $this->_getListByBarShift($barshift_id);
|
||||
|
||||
if ($list->numRows() > 0){
|
||||
?>
|
||||
<p>På jobb:</p>
|
||||
<table class="sortable" id="barshiftworkerlist">
|
||||
<tr>
|
||||
<th>navn</th>
|
||||
<th>telefon</th>
|
||||
<th>registrert</th>
|
||||
<?php if(checkAuth("view-edit-options-barshiftworker")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $list->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$user = new User($row->user_id);
|
||||
?>
|
||||
<tr>
|
||||
<td><?php print $user->firstname." ".$user->lastname; ?></td>
|
||||
<td><?php print formatPhone($user->phonenumber); ?></td>
|
||||
<td><?php print formatDatetimeShort($row->registered); ?></td>
|
||||
<?php if (checkAuth("view-edit-options-barshiftworker")){
|
||||
displayOptionsMenuTable(Array("barshift_id" => $barshift_id, "user_id" => $user->id), BARSHIFTWORKER, "barshiftworker", "view-edit-options-barshiftworker", false, "barshift");
|
||||
}?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
print(" </table>");
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function displayCalendarListByBarShift($barshift_id){
|
||||
$list = $this->_getListByBarShift($barshift_id);
|
||||
|
||||
if ($list->numRows() > 0){
|
||||
print('<ul class="barshift-workers">');
|
||||
while ($row =& $list->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$user = new User($row->user_id);
|
||||
print "<li>".$user->firstname." ".$user->lastname." - ".formatPhone($user->phonenumber)."</li>";
|
||||
}
|
||||
print("</ul>");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
class BarShifts {
|
||||
var $conn;
|
||||
|
||||
function BarShifts(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getListMonth($year, $month){
|
||||
$nextMonth = date("Y-m", strtotime("+1 month", strtotime("$year-$month-01")));
|
||||
$sql = "SELECT id, title, DAYOFMONTH(date) AS date, num_workers
|
||||
FROM din_barshift
|
||||
WHERE date >= '$year-$month-01'
|
||||
AND date < '$nextMonth-01'
|
||||
ORDER BY date, start ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("BarShifts: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList($selection = "0000-00-00"){
|
||||
$sql = "SELECT id FROM din_barshift
|
||||
WHERE date >= $selection
|
||||
ORDER BY date, start ASC";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
?>
|
||||
<p>Antall vakter: <?php print $result->numRows(); ?></p>
|
||||
<table class="sortable" id="barshiftlist">
|
||||
<tr>
|
||||
<th>tittel</th>
|
||||
<th>sted</th>
|
||||
<th>dato</th>
|
||||
<th>start</th>
|
||||
<th>slutt</th>
|
||||
<th>status</th>
|
||||
<?php if(checkAuth("view-edit-options-barshift")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$barshift = new BarShift($row['id']);
|
||||
$barshift->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen vakter registrert.</p>");
|
||||
}
|
||||
}else {
|
||||
error("BarShifts: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
class BugReport {
|
||||
var $id;
|
||||
var $title;
|
||||
var $comment;
|
||||
var $date;
|
||||
var $type;
|
||||
var $filename;
|
||||
var $query;
|
||||
var $referer;
|
||||
var $useragent;
|
||||
var $user_id;
|
||||
var $active;
|
||||
var $status_comment;
|
||||
|
||||
function BugReport($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New job
|
||||
if ($data == NULL){
|
||||
error("Bugreport: No data supplied.");
|
||||
}else {
|
||||
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->date = $data['date'];
|
||||
$this->active = $data['active'];
|
||||
$this->status_comment = stripcslashes($data['status_comment']);
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->title = stripcslashes($data['title']);
|
||||
$this->comment = $data['comment'];
|
||||
$this->type = $data['type'];
|
||||
$this->filename = $data['filename'];
|
||||
$this->query = $data['query'];
|
||||
$this->referer = $data['referer'];
|
||||
$this->useragent = $data['useragent'];
|
||||
$this->user_id = $data['user_id'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_bugreport");
|
||||
$sql = sprintf("INSERT INTO din_bugreport VALUES
|
||||
(%s, NOW(), %s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->type),
|
||||
$this->conn->quoteSmart($this->filename),
|
||||
$this->conn->quoteSmart($this->query),
|
||||
$this->conn->quoteSmart($this->referer),
|
||||
$this->conn->quoteSmart($this->useragent),
|
||||
$this->conn->quoteSmart($this->user_id),
|
||||
$this->conn->quoteSmart($this->comment),
|
||||
$this->conn->quoteSmart($this->title)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['bugreportid'] = $this->id;
|
||||
if ($this->conn->commit()){
|
||||
notify("Feilmelding er registrert.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New bug report: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New bug report: " . $result->toString());
|
||||
}
|
||||
} else {
|
||||
$sql = sprintf("UPDATE din_bugreport SET
|
||||
title = %s,
|
||||
comment = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->comment),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Feilmelding oppdatert.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("Update bug report: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update bug report: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function setStatus($data) {
|
||||
$sql = sprintf("UPDATE din_bugreport SET
|
||||
active = %s,
|
||||
status_comment = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($data['active']),
|
||||
$this->conn->quoteSmart($data['status_comment']),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) == true){
|
||||
error("Bug report-status: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_bugreport dc
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Bug report: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_bugreport
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Feilmelding slettet.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function displayList(){
|
||||
$user = new User($this->user_id);
|
||||
?>
|
||||
<tr id="bugreport<?php print $this->id; ?>">
|
||||
<td><a href="index.php?page=display-bugreport&bugreportid=<?php print $this->id; ?>"><?php print $this->title; ?></a></td>
|
||||
<td><?php print prepareForHTML($this->comment); ?></td>
|
||||
<td><?php print "$user->firstname $user->lastname"; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function display(){
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php displayOptionsMenu($this->id, BUGREPORT, "bugreport", "view-edit-options-bugreport", false);
|
||||
?>
|
||||
<h3>Feilmelding: <?php print $this->title; ?></h3>
|
||||
<h4>Kommentar:</h4>
|
||||
<p><?php print prepareForHTML($this->comment); ?></p>
|
||||
<p><strong>Registrert:</strong> <?php print $this->date; ?></p>
|
||||
<p><strong>Fil:</strong> <?php print $this->filename; ?></p>
|
||||
<p><strong>Query:</strong> <?php print $this->query ;?></p>
|
||||
<p><strong>URL:</strong> <?php print $this->referer ;?></p>
|
||||
<p><strong>Nettleser:</strong> <?php print $this->useragent ;?></p>
|
||||
<?php
|
||||
$user = new User($this->user_id);
|
||||
?>
|
||||
<p><strong>Bruker:</strong> <a href="index.php?page=display-user&userid=<?php print $this->user_id; ?>"
|
||||
title="mer informasjon om <?php print $user->firstname.' '.$user->lastname; ?>">
|
||||
<?php print "$user->firstname $user->lastname";?></p></a>
|
||||
|
||||
<?php
|
||||
$statuses = Array(Array("id" => 0, "title" => "avsluttet"),
|
||||
Array("id" => 1, "title" => "åpen")
|
||||
);
|
||||
|
||||
|
||||
$title = "status på feilmeldingen";
|
||||
$id = "bugreport-comment";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=update-bugreport-status&page=display-bugreport";
|
||||
$fields = Array();
|
||||
|
||||
$fields[] = Array("label" => "bugreportid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "bugreportid", "value" => $this->id));
|
||||
|
||||
$fields[] = Array("label" => "status", "type" => "select",
|
||||
"attributes" => Array("name" => "active", "values" => $statuses,
|
||||
"currentValue" => $this->active));
|
||||
|
||||
$fields[] = Array("label" => "kommentar", "type" => "textarea",
|
||||
"attributes" => Array("name" => "status_comment",
|
||||
"value" => $this->status_comment,
|
||||
"rows" => 7, "cols" => 50));
|
||||
|
||||
$form = new Form($title, $enctype, $method, $action, $fields, $id);
|
||||
$form->display();
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
class BugReports {
|
||||
var $bugs;
|
||||
var $conn;
|
||||
|
||||
function BugReports($selection = "all"){
|
||||
$this->__construct($selection);
|
||||
}
|
||||
|
||||
function __construct($selection = "all"){
|
||||
$this->conn =& db_connect();
|
||||
|
||||
switch ($selection) {
|
||||
case "all":
|
||||
$cond = "";
|
||||
break;
|
||||
|
||||
case "new":
|
||||
$cond = "WHERE active = 1";
|
||||
break;
|
||||
|
||||
case "old":
|
||||
$cond = "WHERE active != 1";
|
||||
|
||||
default:
|
||||
$cond = "";
|
||||
}
|
||||
$sql = "SELECT id FROM din_bugreport $cond";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->bugs = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function getList(){
|
||||
return $this->bugs;
|
||||
}
|
||||
|
||||
public
|
||||
function displayList(){
|
||||
?>
|
||||
<table id="bugreports" class="sortable">
|
||||
<tr>
|
||||
<th>title</th>
|
||||
<th>comment</th>
|
||||
<th>user</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->bugs->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$bug = new BugReport($row->id);
|
||||
$bug->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
Class Calendar {
|
||||
var $type;
|
||||
|
||||
function Calendar($type){
|
||||
$this->__construct($type);
|
||||
}
|
||||
|
||||
public function __construct($type){
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function display($year, $month){
|
||||
$previousYear = $year -1 . $month;
|
||||
$previousMonth = date("Ym", strtotime("-1 month", strtotime("$year-$month-01")));
|
||||
$nextMonth = date("Ym", strtotime("+1 month", strtotime("$year-$month-01")));
|
||||
$nextYear = $year +1 . $month;
|
||||
|
||||
$fDate = "$year-$month-01";
|
||||
switch ($this->type){
|
||||
case 'events':
|
||||
$events = new Events();
|
||||
$list = $events->getListMonth($year, $month);
|
||||
break;
|
||||
|
||||
case 'concerts':
|
||||
$concerts = new Concerts();
|
||||
$list = $concerts->getListMonth($year, $month);
|
||||
break;
|
||||
|
||||
case 'all':
|
||||
$endMonth = date("Y-m", strtotime("+1 month", strtotime("$year-$month-01")));
|
||||
$sql = "SELECT id, name, DAYOFMONTH(time) AS date, 'event' AS type, time
|
||||
FROM din_event
|
||||
WHERE time >= '$year-$month-01'
|
||||
AND time < '$endMonth-01'
|
||||
UNION " .
|
||||
"SELECT id, tittel AS name, DAYOFMONTH(tid) AS date, 'concert' AS type, tid AS time
|
||||
FROM program
|
||||
WHERE tid >= '$year-$month-01'
|
||||
AND tid < '$endMonth-01'
|
||||
ORDER BY time ASC";
|
||||
$conn = db_connect();
|
||||
$list =& $conn->query($sql);
|
||||
break;
|
||||
|
||||
case 'barshifts':
|
||||
$barshifts = new BarShifts();
|
||||
$list = $barshifts->getListMonth($year, $month);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$dayOfWeek = date("w", strtotime("$year-$month-01"));
|
||||
if ($dayOfWeek == "0"){
|
||||
$dayOfWeek = 7;
|
||||
}
|
||||
$lastDayOfMonth = date("t", strtotime("$year-$month-01"));
|
||||
$weekNumber = date("W", strtotime("$year-$month-01"));
|
||||
|
||||
?>
|
||||
<div id="calHeader">
|
||||
<div id="previous">
|
||||
<a href="index.php?section=<?php print $this->type; ?>&page=display-<?php print $this->type; ?>-calendar&month=<?php print $previousYear; ?>">
|
||||
<<</a>
|
||||
<a href="index.php?section=<?php print $this->type; ?>&page=display-<?php print $this->type; ?>-calendar&month=<?php print $previousMonth; ?>">
|
||||
<</a>
|
||||
</div>
|
||||
<div id="next">
|
||||
<a href="index.php?section=<?php print $this->type; ?>&page=display-<?php print $this->type; ?>-calendar&month=<?php print $nextMonth; ?>">
|
||||
></a>
|
||||
<a href="index.php?section=<?php print $this->type; ?>&page=display-<?php print $this->type; ?>-calendar&month=<?php print $nextYear; ?>">
|
||||
>></a>
|
||||
</div>
|
||||
<h2><?php print(strftime("%B - %Y", strtotime($fDate))); ?></h2>
|
||||
</div>
|
||||
<?php $this->_displayCalendarOptions(); ?>
|
||||
<table class="calendar">
|
||||
<tr>
|
||||
<th>Uke</th>
|
||||
<th>Mandag</th>
|
||||
<th>Tirsdag</th>
|
||||
<th>Onsdag</th>
|
||||
<th>Torsdag</th>
|
||||
<th>Fredag</th>
|
||||
<th>Lørdag</th>
|
||||
<th>Søndag</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="weekNumber"><?php print $weekNumber; ?></td>
|
||||
<?php
|
||||
|
||||
$i = 1;
|
||||
$date = 1;
|
||||
$diff = $dayOfWeek;
|
||||
while ($i++ < $dayOfWeek){
|
||||
$offset = --$diff;
|
||||
printPassiveDay(date("d", strtotime("$year-$month-01 -$offset days")));
|
||||
}
|
||||
$row = $list->fetchRow(DB_FETCHMODE_ORDERED);
|
||||
while ($date <= $lastDayOfMonth){
|
||||
printOpenActiveDay($date);
|
||||
while ($row != NULL && $row[2] == $date){
|
||||
switch ($this->type){
|
||||
case 'events':
|
||||
?>
|
||||
<div>
|
||||
<a href="index.php?section=<?php print $this->type; ?>&page=display-event&eventid=<?php print $row[0]; ?>">
|
||||
<?php print $row[1]; ?>
|
||||
</a>
|
||||
<!--<?php displayOptionsMenuCalendar($row[0], EVENT, "event", "view-edit-options-event", "$year$month"); ?>-->
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
case 'concerts':
|
||||
?>
|
||||
<div>
|
||||
<a href="index.php?section=<?php print $this->type; ?>&page=display-concert&concertid=<?php print $row[0]; ?>">
|
||||
<?php print $row[1]; ?>
|
||||
</a>
|
||||
<!--<?php displayOptionsMenuCalendar($row[0], CONCERT, "concert", "view-edit-options-concert", "$year$month"); ?>-->
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
case 'all':
|
||||
?>
|
||||
<div class="calendar-<?php print $row[3]; ?>">
|
||||
<a href="index.php?section=<?php print $this->type; ?>&page=display-<?php print $row[3]."&".$row[3]."id=".$row[0]; ?>">
|
||||
<?php print $row[1]; ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
case 'barshifts':
|
||||
$barshift = new BarShift($row[0]);
|
||||
$barshift->displayCalendar($year, $month);
|
||||
break;
|
||||
|
||||
}
|
||||
$row = $list->fetchRow(DB_FETCHMODE_ORDERED);
|
||||
}
|
||||
printCloseActiveDay();
|
||||
$date++;
|
||||
if ($i++ % 7 == 1){
|
||||
$weekNumber = date("W", strtotime("$year-$month-$date"));
|
||||
print("</tr><tr><td class=\"weekNumber\">".$weekNumber."</td>");
|
||||
}
|
||||
}
|
||||
|
||||
$date = 1;
|
||||
while ($i++ % 7 != 1){
|
||||
printPassiveDay($date++);
|
||||
}
|
||||
printPassiveDay($date++);
|
||||
|
||||
?>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function _displayCalendarOptions(){
|
||||
switch ($this->type){
|
||||
case 'events':
|
||||
break;
|
||||
|
||||
case 'concerts':
|
||||
break;
|
||||
|
||||
case 'all':
|
||||
?>
|
||||
<div>
|
||||
<label class="calendar-event button" ><input type="checkbox" id="calendar-toggle-events"
|
||||
onclick="toggleElements('div', 'calendar-event', this);"
|
||||
checked="checked" />
|
||||
interne arrangementer</label><br />
|
||||
<label class="calendar-concert button"><input type="checkbox" id="calendar-toggle-concerts"
|
||||
onclick="toggleElements('div', 'calendar-concert', this);"
|
||||
checked="checked" />
|
||||
åpne arrangementer</label>
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'barshifts':
|
||||
?>
|
||||
<div>
|
||||
<label class="calendar-barshifworker button" ><input type="checkbox" id="calendar-toggle-barshiftworkers"
|
||||
onchange="toggleElements('ul', 'barshift-workers', this);"
|
||||
checked="checked" />
|
||||
vis personell</label><br />
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
define("ARTIST", "1");
|
||||
define("SHOW", "2");
|
||||
|
||||
class Categories {
|
||||
var $categories;
|
||||
var $conn;
|
||||
|
||||
function Categories(){
|
||||
Categories::__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
error("Categories: " . $conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
$sql = "SELECT id, title FROM tf_article_category";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->categories = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategories(){
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,646 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Concert {
|
||||
|
||||
var $id;
|
||||
var $name;
|
||||
var $intro;
|
||||
var $text;
|
||||
var $name_en;
|
||||
var $intro_en;
|
||||
var $text_en;
|
||||
var $concertcategory_id;
|
||||
var $host_id;
|
||||
var $host_name;
|
||||
var $user_id_responsible;
|
||||
var $user_name_responsible;
|
||||
var $user_phone_responsible;
|
||||
var $user_email_responsible;
|
||||
var $time;
|
||||
var $venue_id;
|
||||
var $venue_name;
|
||||
var $comment;
|
||||
var $priceNormal;
|
||||
var $priceConcession;
|
||||
var $picture;
|
||||
var $links;
|
||||
var $ticketLink;
|
||||
var $facebookLink;
|
||||
var $user_name_ext_contact;
|
||||
var $user_phone_ext_contact;
|
||||
var $user_email_ext_contact;
|
||||
var $user_role_ext_contact;
|
||||
var $needPosters;
|
||||
var $viewWeekprogram;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Concert($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect("dns");
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New concert
|
||||
if ($data == NULL){
|
||||
notify("Concert: No data supplied.");
|
||||
} else {
|
||||
if (isset ($data['user_id_responsible'])) {
|
||||
$this->user_id_responsible = $data['user_id_responsible'];
|
||||
|
||||
if ($user = new User($this->user_id_responsible)) {
|
||||
$this->user_name_responsible = $user->firstname . " " . $user->lastname;
|
||||
$this->user_phone_responsible = $user->phonenumber;
|
||||
$this->user_email_responsible = $user->email;
|
||||
}
|
||||
}
|
||||
$this->links = $data['links'];
|
||||
}
|
||||
}else {//ID set, existing concert
|
||||
if ($data != NULL){//UPDATE
|
||||
if($_FILES['userfile']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['userfile'], "program");
|
||||
rename_file($temp_name, $this->id, "program");
|
||||
$this->picture = $this->id.substr($temp_name, -4);
|
||||
} else {
|
||||
$this->picture = $data['picture'];;
|
||||
}
|
||||
$this->links = $data['links'];
|
||||
}else {//RETRIEVE
|
||||
$data = $this->_retrieveData();
|
||||
$this->venue_name = $data['venue_name'];
|
||||
$this->host_name = $data['host_name'];
|
||||
$this->picture = $data['picture'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->name = stripslashes($data['name']);
|
||||
$this->intro = stripslashes($data['intro']);
|
||||
$this->text = stripslashes($data['text']);
|
||||
$this->name_en = stripslashes($data['name_en']);
|
||||
$this->intro_en = stripslashes($data['intro_en']);
|
||||
$this->text_en = stripslashes($data['text_en']);
|
||||
$this->host_id = $data['host_id'];
|
||||
$this->time = substr($data['time'], 0, 16);
|
||||
$this->concertcategory_id = $data['concertcategory_id'];
|
||||
$this->venue_id = $data['venue_id'];
|
||||
$this->comment = stripslashes($data['comment']);
|
||||
$this->priceNormal = $data['priceNormal'];
|
||||
$this->priceConcession = $data['priceConcession'];
|
||||
$this->ticketLink = $data['ticketLink'];
|
||||
$this->facebookLink = $data['facebookLink'];
|
||||
$this->user_name_ext_contact = $data['user_name_ext_contact'];
|
||||
$this->user_phone_ext_contact = $data['user_phone_ext_contact'];
|
||||
$this->user_email_ext_contact = $data['user_email_ext_contact'];
|
||||
$this->user_role_ext_contact = $data['user_role_ext_contact'];
|
||||
|
||||
if (isset($data['viewWeekprogram'])) {
|
||||
$this->viewWeekprogram = $data['viewWeekprogram'];
|
||||
} else {
|
||||
$this->viewWeekprogram = 1;
|
||||
}
|
||||
|
||||
if (isset($data['needPosters'])) {
|
||||
$this->needPosters = ($data['needPosters'] == 'poster-true')? 'Ja' : 'Nei';
|
||||
} else {
|
||||
$this->needPosters = 'Nei';
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function store(){
|
||||
if ($this->id == NULL){
|
||||
if (!$this->_validate()){
|
||||
$GLOBALS['extraScriptParams']['page'] = "register-concert";
|
||||
return false;
|
||||
}
|
||||
$this->id = getNextId("program");
|
||||
if($_FILES['userfile']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['userfile'], "program");
|
||||
rename_file($temp_name, $this->id, "program");
|
||||
$this->picture = $this->id.substr($temp_name, -4);
|
||||
} else {
|
||||
$this->picture = "0";
|
||||
}
|
||||
$sql = sprintf("INSERT INTO program
|
||||
(id, tittel, tittel_en, ingress, ingress_en, type, arr, tid, tekst, tekst_en, kommentar,
|
||||
sted, vpris, mpris, billett, ansv, ansv_tlf, ansv_epost,
|
||||
ekst_navn, ekst_tlf, ekst_epost, ekst_rolle, plakat_behov, vedlegg, linker, facebook, visUkeprogram)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, '%s')",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->name_en),
|
||||
$this->conn->quoteSmart($this->intro),
|
||||
$this->conn->quoteSmart($this->intro_en),
|
||||
$this->conn->quoteSmart($this->concertcategory_id),
|
||||
$this->conn->quoteSmart($this->host_id),
|
||||
$this->conn->quoteSmart($this->time),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->text_en),
|
||||
$this->conn->quoteSmart($this->comment),
|
||||
$this->conn->quoteSmart($this->venue_id),
|
||||
$this->conn->quoteSmart($this->priceNormal),
|
||||
$this->conn->quoteSmart($this->priceConcession),
|
||||
$this->conn->quoteSmart($this->ticketLink),
|
||||
$this->conn->quoteSmart($this->user_name_responsible),
|
||||
$this->conn->quoteSmart($this->user_phone_responsible),
|
||||
$this->conn->quoteSmart($this->user_email_responsible),
|
||||
$this->conn->quoteSmart($this->user_name_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_phone_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_email_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_role_ext_contact),
|
||||
$this->conn->quoteSmart($this->needPosters),
|
||||
$this->conn->quoteSmart($this->picture),
|
||||
$this->conn->quoteSmart($this->links),
|
||||
$this->conn->quoteSmart($this->facebookLink),
|
||||
"1"
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Nytt arrangement er registrert.");
|
||||
$GLOBALS['extraScriptParams']['concertid'] = $this->id;
|
||||
}else {
|
||||
error("New concert: " . $result->toString());
|
||||
notify("Problemer med registrering av konsert.");
|
||||
}
|
||||
} else {
|
||||
if (!$this->_validate()){
|
||||
$GLOBALS['extraScriptParams']['page'] = "edit-concert";
|
||||
return false;
|
||||
}
|
||||
$sql = sprintf("UPDATE program SET
|
||||
tittel = %s,
|
||||
tittel_en = %s,
|
||||
ingress = %s,
|
||||
ingress_en = %s,
|
||||
type = %s,
|
||||
arr = %s,
|
||||
tid = %s,
|
||||
tekst = %s,
|
||||
tekst_en = %s,
|
||||
kommentar = %s,
|
||||
sted = %s,
|
||||
vpris = %s,
|
||||
mpris = %s,
|
||||
billett = %s,
|
||||
facebook = %s,
|
||||
ansv = %s,
|
||||
ansv_tlf = %s,
|
||||
ansv_epost = %s,
|
||||
ekst_navn = %s,
|
||||
ekst_tlf = %s,
|
||||
ekst_epost = %s,
|
||||
ekst_rolle = %s,
|
||||
plakat_behov = %s,
|
||||
linker = %s,
|
||||
vedlegg = %s,
|
||||
visUkeprogram = '%s'
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->name_en),
|
||||
$this->conn->quoteSmart($this->intro),
|
||||
$this->conn->quoteSmart($this->intro_en),
|
||||
$this->conn->quoteSmart($this->concertcategory_id),
|
||||
$this->conn->quoteSmart($this->host_id),
|
||||
$this->conn->quoteSmart($this->time),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->text_en),
|
||||
$this->conn->quoteSmart($this->comment),
|
||||
$this->conn->quoteSmart($this->venue_id),
|
||||
$this->conn->quoteSmart($this->priceNormal),
|
||||
$this->conn->quoteSmart($this->priceConcession),
|
||||
$this->conn->quoteSmart($this->ticketLink),
|
||||
$this->conn->quoteSmart($this->facebookLink),
|
||||
$this->conn->quoteSmart($this->user_name_responsible),
|
||||
$this->conn->quoteSmart($this->user_phone_responsible),
|
||||
$this->conn->quoteSmart($this->user_email_responsible),
|
||||
$this->conn->quoteSmart($this->user_name_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_phone_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_email_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_role_ext_contact),
|
||||
$this->conn->quoteSmart($this->needPosters),
|
||||
$this->conn->quoteSmart($this->links),
|
||||
$this->conn->quoteSmart($this->picture),
|
||||
$this->viewWeekprogram,
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Arrangement oppdatert.");
|
||||
}else {
|
||||
error("Update concert: " . $result->toString());
|
||||
notify("Problemer med oppdatering av arrangement.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _validate(){
|
||||
$valid = true;
|
||||
if($this->name == '') {
|
||||
notify("Tittel må angis.");
|
||||
$valid = false;
|
||||
}
|
||||
if($this->intro == '') {
|
||||
notify("Ingress må angis.");
|
||||
$valid = false;
|
||||
}
|
||||
if (date("Y", strtotime($this->time)) < 2000){
|
||||
notify("Ugyldig årstall.");
|
||||
$valid = false;
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
|
||||
public function repeat($data){
|
||||
$frequency = $data['frequency'];
|
||||
$count = $data['count'];
|
||||
for ($i = 0; $i < $count; $i++){
|
||||
$date = get_repeat_date($this->time, $i + 1, $frequency);
|
||||
$sql = sprintf("INSERT INTO program
|
||||
(id, tittel, tittel_en, ingress, ingress_en, type, arr, tid, tekst, tekst_en, kommentar,
|
||||
sted, vpris, mpris, billett, ansv, ansv_tlf, ansv_epost,
|
||||
ekst_navn, ekst_tlf, ekst_epost, ekst_rolle, plakat_behov, vedlegg, linker)
|
||||
VALUES
|
||||
(NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->name_en),
|
||||
$this->conn->quoteSmart($this->intro),
|
||||
$this->conn->quoteSmart($this->intro_en),
|
||||
$this->conn->quoteSmart($this->concertcategory_id),
|
||||
$this->conn->quoteSmart($this->host_id),
|
||||
$this->conn->quoteSmart($date),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->text_en),
|
||||
$this->conn->quoteSmart($this->comment),
|
||||
$this->conn->quoteSmart($this->venue_id),
|
||||
$this->conn->quoteSmart($this->priceNormal),
|
||||
$this->conn->quoteSmart($this->priceConcession),
|
||||
$this->conn->quoteSmart($this->ticketLink),
|
||||
$this->conn->quoteSmart($this->user_name_responsible),
|
||||
$this->conn->quoteSmart($this->user_phone_responsible),
|
||||
$this->conn->quoteSmart($this->user_email_responsible),
|
||||
$this->conn->quoteSmart($this->user_name_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_phone_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_email_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_role_ext_contact),
|
||||
$this->conn->quoteSmart($this->needPosters),
|
||||
$this->conn->quoteSmart($this->picture),
|
||||
$this->conn->quoteSmart($this->getLinks())
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Repetisjon av arrangement registrert.");
|
||||
}else {
|
||||
error("New concert: " . $result->toString());
|
||||
notify("Arrangementet lot seg ikke repetere.");
|
||||
reportBug("arrangement");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function copy($data){
|
||||
$id = getNextId("program");
|
||||
$sql = sprintf("INSERT INTO program
|
||||
(id, tittel, tittel_en, ingress, ingress_en, type, arr, tid, tekst, tekst_en, kommentar,
|
||||
sted, vpris, mpris, billett, ansv, ansv_tlf, ansv_epost,
|
||||
ekst_navn, ekst_tlf, ekst_epost, ekst_rolle, plakat_behov, vedlegg, linker)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->name_en),
|
||||
$this->conn->quoteSmart($this->intro),
|
||||
$this->conn->quoteSmart($this->intro_en),
|
||||
$this->conn->quoteSmart($this->concertcategory_id),
|
||||
$this->conn->quoteSmart($this->host_id),
|
||||
$this->conn->quoteSmart(scriptParam("newDate")),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->text_en),
|
||||
$this->conn->quoteSmart($this->comment),
|
||||
$this->conn->quoteSmart($this->venue_id),
|
||||
$this->conn->quoteSmart($this->priceNormal),
|
||||
$this->conn->quoteSmart($this->priceConcession),
|
||||
$this->conn->quoteSmart($this->ticketLink),
|
||||
$this->conn->quoteSmart($this->user_name_responsible),
|
||||
$this->conn->quoteSmart($this->user_phone_responsible),
|
||||
$this->conn->quoteSmart($this->user_email_responsible),
|
||||
$this->conn->quoteSmart($this->user_name_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_phone_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_email_ext_contact),
|
||||
$this->conn->quoteSmart($this->user_role_ext_contact),
|
||||
$this->conn->quoteSmart($this->needPosters),
|
||||
$this->conn->quoteSmart($this->picture),
|
||||
$this->conn->quoteSmart($this->getLinks())
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Arrangement kopiert.");
|
||||
$GLOBALS['extraScriptParams']['concertid'] = $id;
|
||||
}else {
|
||||
error("New concert: " . $result->toString());
|
||||
notify("Problemer med kopiering av arrangement.");
|
||||
reportBug("arrangement");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT
|
||||
c.tittel AS name,
|
||||
c.tittel_en AS name_en,
|
||||
c.ingress AS intro,
|
||||
c.ingress_en AS intro_en,
|
||||
c.tekst AS text,
|
||||
c.tekst_en AS text_en,
|
||||
c.type AS concertcategory_id,
|
||||
c.arr AS host_id,
|
||||
d.name AS host_name,
|
||||
c.tid AS time,
|
||||
c.sted AS venue_id,
|
||||
v.navn AS venue_name,
|
||||
c.kommentar AS comment,
|
||||
c.billett AS ticketLink,
|
||||
c.facebook AS facebookLink,
|
||||
c.vpris AS priceNormal,
|
||||
c.mpris AS priceConcession,
|
||||
c.vedlegg AS picture,
|
||||
c.ekst_navn AS user_name_ext_contact,
|
||||
c.ekst_tlf AS user_phone_ext_contact,
|
||||
c.ekst_epost AS user_email_ext_contact,
|
||||
c.ekst_rolle AS user_role_ext_contact,
|
||||
c.plakat_behov AS needPosters,
|
||||
c.visUkeprogram AS viewWeekprogram
|
||||
FROM program c, lokaler v, din_division d
|
||||
WHERE c.id = $this->id
|
||||
AND c.sted = v.id
|
||||
AND c.arr = d.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}else {
|
||||
notify("Ingen arrangementsdata er registrert.");
|
||||
notify($sql);
|
||||
error($this->id);
|
||||
}
|
||||
}else {
|
||||
error("Concerts: " . $result->toString());
|
||||
notify("Problemer med henting av arrangementsdata.");
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM program
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Arrangement slettet.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
notify("Feil under sletteing av arrangement.");
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
//$this->_markAsRead();
|
||||
$links = $this->getLinks("DB");
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, CONCERT, "concert", "view-edit-options-concert");
|
||||
|
||||
if ($this->picture != 0){
|
||||
print('<div class="primary_image"><img src="http://www.studentersamfundet.no/imageResize.php?pic=bilder/program/'.$this->picture.'&maxwidth=200\" alt=\"pressebilde\" /></div>');
|
||||
}
|
||||
?> <h3><?php print $this->name; ?></h3>
|
||||
<p class="date"><?php print formatDatetime($this->time); ?>, <?php print $this->venue_name; ?></p>
|
||||
<p class="intro"><?php print prepareForHTML($this->intro); ?></p>
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
|
||||
<?php
|
||||
if ($links != ''){
|
||||
?>
|
||||
<h4>relevante linker:</h4>
|
||||
<p><?php print prepareForHTML($links); ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<p>
|
||||
<strong>Billettpris:</strong> <?php print $this->priceNormal; ?>,-
|
||||
</p>
|
||||
<p>
|
||||
<strong>Medlemspris:</strong> <?php print $this->priceConcession; ?>,-
|
||||
</p>
|
||||
<p>
|
||||
<strong>Arrangør:</strong>
|
||||
<a href="index.php?page=display-division&divisionid=<?php print $this->host_id; ?>">
|
||||
<?php print $this->host_name; ?>
|
||||
</a>
|
||||
</p>
|
||||
<div class="clear-right"> </div>
|
||||
</div>
|
||||
<?php
|
||||
if (checkAuth("view-edit-options-concert") || checkResponsible()){
|
||||
|
||||
$this->_displayReport();
|
||||
|
||||
$freqOptions = Array(Array("id" => "daily", "title" => "daglig"),
|
||||
Array("id" => "weekly", "title" => "ukentlig"),
|
||||
Array("id" => "biweekly", "title" => "annenhver uke"),
|
||||
Array("id" => "monthlyDate", "title" => "månedlig"),
|
||||
Array("id" => "annual", "title" => "årlig")
|
||||
);
|
||||
|
||||
$title = "repeat concert";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=repeat-concert&page=display-concerts";
|
||||
$fields = Array(Array("label" => "concertid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "concertid", "value" => "$this->id")),
|
||||
Array("label" => "gjenta aktivitet", "type" => "select",
|
||||
"attributes" => Array("name" => "frequency", "values" => $freqOptions,
|
||||
"value" => $freqOptions[0])),
|
||||
Array("label" => "antall ganger", "type" => "text",
|
||||
"attributes" => Array("name" => "count", "size" => 3, "maxlength" => 3,
|
||||
"value" => 0))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
|
||||
|
||||
$title = "copy concert";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=copy-concert&page=display-concert";
|
||||
$fields = Array(Array("label" => "concertid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "concertid", "value" => "$this->id")),
|
||||
Array("label" => "kopier til", "type" => "datetime",
|
||||
"attributes" => Array("name" => "newDate", "value" => "$this->time"))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
}
|
||||
?>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
//$read = $this->_readByCurrentUser();
|
||||
?>
|
||||
<tr>
|
||||
<td><a class="<?php //($read == true) ? print('read'): print('unread'); ?>" href="index.php?page=display-concert&concertid=<?php print $this->id; ?>"><?php print $this->name; ?></a></td>
|
||||
<td><?php print $this->concertcategory_id; ?></td>
|
||||
<td><?php print $this->venue_name; ?></td>
|
||||
<td><?php print $this->host_name; ?></td>
|
||||
<td class="date"><?php print formatDatetime($this->time, "td"); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, CONCERT, "concert", "view-edit-options-concert"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function _displayReport() {
|
||||
?>
|
||||
<span class="button" onclick="toggleDisplay('report-form-<?php print $this->id; ?>'); toggleText(this, 'vis arrangementsrapport', 'skjul arrangementsrapport');">vis arrangementsrapport</span>
|
||||
<div id="report-form-<?php print $this->id; ?>" style="display: none;">
|
||||
<?php
|
||||
$sql = "SELECT id FROM din_concert_report WHERE concert_id = $this->id";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("Concert Report: " . $result->toString());
|
||||
}else {
|
||||
if ($result->numRows() != 1) {
|
||||
|
||||
$title = "registrér arrangementsrapport";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=register-concertreport&page=display-concert";
|
||||
$fields = Array();
|
||||
|
||||
$fields[] = Array("label" => "concertid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "concertid", "value" => "$this->id"));
|
||||
|
||||
$fields[] = Array("label" => "besøkende", "type" => "text",
|
||||
"attributes" => Array("name" => "visitors","size" => 4,
|
||||
"maxlength" => 4,
|
||||
"value" => (isset($data['visitors'])) ? $data['visitors'] : ""));
|
||||
$fields[] = Array("label" => "resultat", "type" => "text",
|
||||
"attributes" => Array("name" => "result","size" => 7,
|
||||
"maxlength" => 8,
|
||||
"value" => (isset($data['result'])) ? $data['result'] : ""));
|
||||
$fields[] = Array("label" => "markedsføring", "type" => "textarea",
|
||||
"attributes" => Array("name" => "marketing_comment", "cols" => 70,
|
||||
"rows" => 15, "class" => "mceEditor"));
|
||||
|
||||
$fields[] = Array("label" => "produksjon", "type" => "textarea",
|
||||
"attributes" => Array("name" => "production_comment", "cols" => 70,
|
||||
"rows" => 15, "class" => "mceEditor"));
|
||||
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display();
|
||||
|
||||
}else {
|
||||
$row =& $result->fetchRow(DB_FETCHMODE_ORDERED);
|
||||
$report_id = $row[0];
|
||||
$report = new ConcertReport($report_id);
|
||||
$report->display();
|
||||
}
|
||||
print("</div>");
|
||||
}
|
||||
}
|
||||
|
||||
public function getLinks($type = "text"){
|
||||
$sql = "SELECT linker AS url FROM program WHERE id = $this->id";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$row =& $result->fetchRow(DB_FETCHMODE_ORDERED);
|
||||
return $row[0];
|
||||
}else {
|
||||
error("Linker: " . $result->toString());
|
||||
}
|
||||
|
||||
$sql = "SELECT url FROM program_linker
|
||||
WHERE parent_id = $this->id";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($type == "DB"){
|
||||
return $result;
|
||||
}else if ($type == "text"){
|
||||
$a = "";
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ORDERED)){
|
||||
$a .= $row[0]."\r\n";
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
}else {
|
||||
error("Linker: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function _markAsRead(){
|
||||
if ($this->_readByCurrentUser() == true){
|
||||
return;
|
||||
}
|
||||
|
||||
$user = getCurrentUser();
|
||||
if ($user == false){
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = sprintf("INSERT INTO din_concertread VALUES
|
||||
(%s, %s, NOW())",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($user)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
notify($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function _readByCurrentUser(){
|
||||
$user = getCurrentUser();
|
||||
if ($user == false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = sprintf("SELECT id FROM din_concertread
|
||||
WHERE id = %s
|
||||
AND userId = %s",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($user)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if($result->numRows() > 0){
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class ConcertCategories {
|
||||
var $categories;
|
||||
|
||||
function ConcertCategories(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
if (isset($_SESSION['concert']['categories'])){
|
||||
$this->categories = $_SESSION['concert']['categories'];
|
||||
}else {
|
||||
$this->categories = getEnumValues("type", "program", "dns");
|
||||
$_SESSION['concert']['categories'] = $this->categories;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategories(){
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class ConcertReport {
|
||||
|
||||
var $id;
|
||||
var $concert_id;
|
||||
var $visitors;
|
||||
var $marketing_comment;
|
||||
var $production_comment;
|
||||
var $result;
|
||||
|
||||
var $conn;
|
||||
|
||||
function ConcertReport($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect("dns");
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New concert
|
||||
if ($data == NULL){
|
||||
notify("ConcertReport: No data supplied.");
|
||||
}else {
|
||||
$this->concert_id = $data['concertid'];
|
||||
|
||||
}
|
||||
}else {//ID set, existing concert
|
||||
if ($data != NULL){//UPDATE
|
||||
|
||||
}else {//RETRIEVE
|
||||
$data = $this->_retrieveData();
|
||||
$this->concert_id = $data['concert_id'];
|
||||
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->visitors = $data['visitors'];
|
||||
$this->marketing_comment = stripslashes($data['marketing_comment']);
|
||||
$this->production_comment = stripslashes($data['production_comment']);
|
||||
$this->result = $data['result'];
|
||||
}
|
||||
|
||||
public
|
||||
function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_concert_report");
|
||||
|
||||
$sql = sprintf("INSERT INTO din_concert_report
|
||||
(id, concert_id, visitors, marketing_comment, production_comment,
|
||||
result)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->concert_id),
|
||||
$this->conn->quoteSmart($this->visitors),
|
||||
$this->conn->quoteSmart($this->marketing_comment),
|
||||
$this->conn->quoteSmart($this->production_comment),
|
||||
$this->conn->quoteSmart($this->result)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("New ConcertReport: " . $result->toString());
|
||||
notify("Problemer med registrering av arrangementsrapport.");
|
||||
return false;
|
||||
}else {
|
||||
notify("Ny arrangementsrapport er registrert.");
|
||||
$GLOBALS['extraScriptParams']['concertreportid'] = $this->id;
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_concert_report SET
|
||||
visitors = %s,
|
||||
marketing_comment = %s,
|
||||
production_comment = %s,
|
||||
result = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->visitors),
|
||||
$this->conn->quoteSmart($this->marketing_comment),
|
||||
$this->conn->quoteSmart($this->production_comment),
|
||||
$this->conn->quoteSmart($this->result),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("Update ConcertReport: " . $result->toString());
|
||||
notify("Problemer med oppdatering av arrangementsrapport.");
|
||||
}else {
|
||||
notify("Arrangementsrapport oppdatert.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_concert_report cr
|
||||
WHERE cr.id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}else {
|
||||
//notify("Ingen rapportdata er registrert.");
|
||||
}
|
||||
}else {
|
||||
error("ConcertReports: " . $result->toString());
|
||||
notify("Problemer med henting av arrangementsrapport.");
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_concert_report
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Arrangementsrapport slettet.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
notify("Feil under sletting av arrangementsrapport.");
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="text-column">
|
||||
<h3>Arrangementsrapport</h3>
|
||||
<?php
|
||||
displayOptionsMenu($this->id, CONCERTREPORT, "concertreport", "view-edit-options-concertreport", true, "display-concert");
|
||||
?>
|
||||
<p>
|
||||
<strong>Besøkende:</strong> <?php print $this->visitors; ?>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Resultat:</strong> <?php print $this->result; ?>
|
||||
</p>
|
||||
<h4>Om markedsføringen</h4>
|
||||
<p><?php print prepareForHTML($this->marketing_comment); ?></p>
|
||||
<h4>Om produksjonen</h4>
|
||||
<p><?php print prepareForHTML($this->production_comment); ?></p>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
class Concerts {
|
||||
var $conn;
|
||||
|
||||
function Concerts(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getList($start_date, $picture = false){
|
||||
if ($picture) {
|
||||
$condition = "AND vedlegg != '0'";
|
||||
}else {
|
||||
$condition = "";
|
||||
}
|
||||
$sql = "SELECT id
|
||||
FROM program
|
||||
WHERE tid >= '$start_date' " .
|
||||
"$condition
|
||||
ORDER BY tid ASC";
|
||||
if ($this->conn == false){
|
||||
return false;
|
||||
}
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("Concerts: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getListWeek($start, $end){
|
||||
|
||||
$sql = "SELECT id
|
||||
FROM program
|
||||
WHERE tid >= '$start' " .
|
||||
"AND tid <= '$end'
|
||||
ORDER BY tid ASC";
|
||||
if ($this->conn == false){
|
||||
return false;
|
||||
}
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("Concerts: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getListMonth($year, $month){
|
||||
$nextMonth = date("Y-m", strtotime("+1 month", strtotime("$year-$month-01")));
|
||||
$sql = "SELECT id, tittel, DAYOFMONTH(tid) AS date
|
||||
FROM program
|
||||
WHERE tid >= '$year-$month-01'
|
||||
AND tid < '$nextMonth-01'
|
||||
ORDER BY tid ASC";
|
||||
if ($this->conn == false){
|
||||
return false;
|
||||
}
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("Concerts: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getListSelection($start, $end, $type){
|
||||
if ($type == "Billett") {
|
||||
$condition = "AND billett != '' ";
|
||||
}else {
|
||||
$condition = "AND type = '$type' ";
|
||||
}
|
||||
|
||||
$sql = "SELECT id
|
||||
FROM program
|
||||
WHERE tid >= '$start' " .
|
||||
"AND tid <= '$end' " .
|
||||
"$condition " .
|
||||
"AND vedlegg != '0'
|
||||
ORDER BY tid ASC";
|
||||
if ($this->conn == false){
|
||||
return false;
|
||||
}
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("Concerts: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function displayList($selection = "0000-00-00"){
|
||||
$sql = "SELECT id AS concertId FROM program
|
||||
WHERE tid > $selection
|
||||
ORDER BY tid ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
print("<p>Antall treff: ".$result->numRows()."</p>");
|
||||
?>
|
||||
<table class="sortable" id="concertlist">
|
||||
<tr>
|
||||
<th>tittel</th>
|
||||
<th>type</th>
|
||||
<th>sted</th>
|
||||
<th>arrangør</th>
|
||||
<th>dato</th>
|
||||
<?php if(checkAuth("view-edit-options-concert")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$concert = new Concert($row['concertId']);
|
||||
$concert->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen arrangementer er registrert.</p>");
|
||||
}
|
||||
}else {
|
||||
error("Concerts: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Division {
|
||||
|
||||
var $id;
|
||||
var $name;
|
||||
var $text;
|
||||
var $phone;
|
||||
var $email;
|
||||
var $office;
|
||||
var $user_id_contact;
|
||||
var $name_contact;
|
||||
var $url;
|
||||
var $divisioncategory_id;
|
||||
var $divisioncategory_title;
|
||||
var $picture;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Division($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New division
|
||||
if ($data == NULL){
|
||||
error("Division: No data supplied.");
|
||||
}else {
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
if($_FILES['userfile']['error'] != 4){
|
||||
$temp_name = new_file($_FILES, "foreninger");
|
||||
rename_file($temp_name, $this->id, "foreninger");
|
||||
$this->picture = $this->conn->quoteSmart($this->id.substr($temp_name, -4));
|
||||
}else {
|
||||
$this->picture = "picture";
|
||||
}
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->name_contact = $data['name_contact'];
|
||||
$this->divisioncategory_title = $data['divisioncategory_title'];
|
||||
$this->picture = $data['picture'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->name = $data['name'];
|
||||
$this->text = $data['text'];
|
||||
$this->phone = $data['phone'];
|
||||
$this->email = $data['email'];
|
||||
$this->office = $data['office'];
|
||||
$this->user_id_contact = $data['user_id_contact'];
|
||||
$this->url = $data['url'];
|
||||
$this->divisioncategory_id = $data['divisioncategory_id'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$sql = sprintf("INSERT INTO din_division
|
||||
(id, name, text, phone, email, office,
|
||||
user_id_contact, url, divisioncategory_id)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->phone),
|
||||
$this->conn->quoteSmart($this->email),
|
||||
$this->conn->quoteSmart($this->office),
|
||||
$this->conn->quoteSmart($this->user_id_contact),
|
||||
$this->conn->quoteSmart($this->url),
|
||||
$this->conn->quoteSmart($this->divisioncategory_id)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("New division registered and stored.");
|
||||
}else {
|
||||
error("New division: " . $result->toString());
|
||||
}
|
||||
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_division SET
|
||||
name = %s,
|
||||
text = %s,
|
||||
phone = %s,
|
||||
email = %s,
|
||||
office = %s,
|
||||
user_id_contact = %s,
|
||||
url = %s,
|
||||
divisioncategory_id = %s, " .
|
||||
"picture = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->phone),
|
||||
$this->conn->quoteSmart($this->email),
|
||||
$this->conn->quoteSmart($this->office),
|
||||
$this->conn->quoteSmart($this->user_id_contact),
|
||||
$this->conn->quoteSmart($this->url),
|
||||
$this->conn->quoteSmart($this->divisioncategory_id),
|
||||
$this->picture,
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Forening oppdatert.");
|
||||
}else {
|
||||
error("Update division: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT d.*, CONCAT(u.firstname, ' ', u.lastname) AS name_contact,
|
||||
dc.title AS divisioncategory_title
|
||||
FROM din_division d, din_user u, din_divisioncategory dc
|
||||
WHERE d.id = $this->id
|
||||
AND d.user_id_contact = u.id
|
||||
AND d.divisioncategory_id = dc.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$row['text'] = stripslashes($row['text']);
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Division: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_division
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($conn->affectedRows() > 0){
|
||||
notify("Foreningen er slettet.");
|
||||
}else {
|
||||
notify("Ugyldig foreningsid, ingen handling utført.");
|
||||
}
|
||||
}else {
|
||||
if ($result->getCode() == -3){
|
||||
notify("Det er brukergrupper knyttet til denne foreningen. Disse må slettes først.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function getNoAdminGroup(){
|
||||
$sql = "SELECT d.id AS group_id FROM din_group d, din_division dd " .
|
||||
"WHERE d.division_id=dd.id " .
|
||||
"AND dd.id = $this->id " .
|
||||
"AND d.admin = 0 " .
|
||||
"LIMIT 1";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
return $row->group_id;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
error("no-admin-group: " . $result->toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, DIVISION, "division", "view-edit-options-division");
|
||||
|
||||
if ($this->picture != 0){
|
||||
print("<img src=\"imageResize.php?pic=http://www.studentersamfundet.no/bilder/foreninger/".$this->picture."&maxwidth=200\" alt=\"\" />");
|
||||
}
|
||||
|
||||
?>
|
||||
<h3><?php print $this->name; ?></h3>
|
||||
<p class="subtitle"><?php print $this->divisioncategory_title; ?></p>
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
<p><strong>Telefon:</strong> <?php print formatPhone($this->phone); ?></p>
|
||||
<p><strong>Epost:</strong> <?php print $this->email; ?></p>
|
||||
<p><strong>Hjemmeside:</strong> <?php print $this->url; ?></p>
|
||||
<p><strong>Kontornummer:</strong> <?php print $this->office; ?></p>
|
||||
<p><strong>Kontaktperson:</strong>
|
||||
<a href="index.php?section=users&page=display-user&userid=<?php print $this->user_id_contact; ?>"><?php print $this->name_contact; ?></a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=display-division&divisionid=<?php print $this->id; ?>"><?php print $this->name; ?></a></td>
|
||||
<td><?php print $this->phone; ?></td>
|
||||
<td><?php print $this->email; ?></td>
|
||||
<td><a class="contact" href="index.php?page=display-user&userid=<?php print $this->user_id_contact; ?>"
|
||||
title="mer informasjon om <?php print $this->name_contact; ?>"
|
||||
><?php print $this->name_contact; ?>
|
||||
</a></td>
|
||||
<?php displayOptionsMenuTable($this->id, DIVISION, "division", "view-edit-options-division"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class DivisionCategories {
|
||||
var $categories;
|
||||
var $conn;
|
||||
|
||||
function DivisionCategories(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$sql = "SELECT id, title FROM din_divisioncategory";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->categories = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategories(){
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<table class="sortable" id="division-cat-list">
|
||||
<tr>
|
||||
<th colspan="2">foreningstyper</th>
|
||||
<?php if(checkAuth("view-edit-options-divisioncategory")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->categories->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$divisionCat = new DivisionCategory($row['id']);
|
||||
$divisionCat->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
class Divisions {
|
||||
var $conn;
|
||||
|
||||
function Divisions() {
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
if (isAdmin(getCurrentUser()) || checkAuth("all-divisions")){
|
||||
$sql = "SELECT d.id, d.name " .
|
||||
"FROM din_division d";
|
||||
}else if (loggedIn()){
|
||||
$sql = sprintf("SELECT d.id, d.name " .
|
||||
"FROM din_division d, din_usergrouprelationship ugr, din_group g ".
|
||||
"WHERE g.division_id = d.id " .
|
||||
"AND g.admin = 1 " .
|
||||
"AND ugr.group_id = g.id " .
|
||||
"AND ugr.user_id = %s",
|
||||
getCurrentUser());
|
||||
}else {
|
||||
$sql = sprintf("SELECT d.id, d.name " .
|
||||
"FROM din_division d " .
|
||||
"WHERE d.hidden != 1 " .
|
||||
"ORDER BY d.name");
|
||||
}
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
} else {
|
||||
error("Divisions: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function getListAll(){
|
||||
$sql = "SELECT d.id, d.name " .
|
||||
"FROM din_division d";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
} else {
|
||||
error("Divisions: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function getListAllWithPositions(){
|
||||
$sql = "SELECT d.id, CONCAT(d.name, ' (', COUNT(p.id), ')') AS name " .
|
||||
"FROM din_division d LEFT JOIN din_position p " .
|
||||
"ON p.division_id = d.id " .
|
||||
"GROUP BY d.id " .
|
||||
"ORDER BY d.name";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
} else {
|
||||
error("Divisions: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
$sql = "SELECT id FROM din_division
|
||||
ORDER BY name ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
|
||||
displayOptionsMenu($row['id'], "division");
|
||||
$division = new Division($row['id']);
|
||||
$division->display();
|
||||
}
|
||||
}else {
|
||||
error("Divisions: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
$sql = "SELECT id FROM din_division
|
||||
ORDER BY name ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){?>
|
||||
<table class="sortable" id="divisionlist">
|
||||
<tr>
|
||||
<th>forening</th>
|
||||
<th>telefon</th>
|
||||
<th>epost</th>
|
||||
<th>kontaktperson</th>
|
||||
<?php if(checkAuth("view-edit-options-division")){
|
||||
?><th colspan="2"></th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$division = new Division($row['id']);
|
||||
$division->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
error("Divisions: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
class Document {
|
||||
var $id;
|
||||
var $type;
|
||||
var $name;
|
||||
var $size;
|
||||
var $date;
|
||||
var $documentcategory_id;
|
||||
var $tags;
|
||||
var $documentcategory_title;
|
||||
|
||||
var $documentData;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Document($id = NULL, $documentData = NULL){
|
||||
$this->__construct($id, $documentData);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $documentData = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
if ($id != NULL){
|
||||
$this->id = $id;
|
||||
if ($data = $this->_retrieveData()){
|
||||
$this->type = $data->type;
|
||||
$this->name = $data->name;
|
||||
$this->size = $data->size;
|
||||
$this->date = $data->date;
|
||||
$this->tags = $data->tags;
|
||||
$this->documentcategory_id = $data->documentcategory_id;
|
||||
$this->documentcategory_title = $data->documentcategory_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function store($files){
|
||||
if ($files != NULL){
|
||||
$SrcPathFile = $_FILES["file"]["tmp_name"];
|
||||
$SrcFileType = $_FILES["file"]["type"];
|
||||
$DstFileName = $_FILES["file"]["name"];
|
||||
|
||||
clearstatcache();
|
||||
|
||||
// File Processing
|
||||
if (file_exists($SrcPathFile)) {
|
||||
// Insert into file table
|
||||
$fileid = getNextId("din_document");
|
||||
$sql = sprintf("INSERT INTO din_document
|
||||
(id, type, name, size, date, documentcategory_id, tags)
|
||||
VALUES (%s, %s, %s, %s, NOW(), %s, %s)",
|
||||
$this->conn->quoteSmart($fileid),
|
||||
$this->conn->quoteSmart($SrcFileType),
|
||||
$this->conn->quoteSmart($DstFileName),
|
||||
$this->conn->quoteSmart(filesize($SrcPathFile)),
|
||||
$this->conn->quoteSmart(scriptParam("documentcategoryid")),
|
||||
$this->conn->quoteSmart(strtolower(scriptParam("tags"))));
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("Document: " . $result->toString());
|
||||
}else {
|
||||
// Insert into the filedata table
|
||||
$fp = fopen($SrcPathFile, "rb");
|
||||
while (!feof($fp)) {
|
||||
// Make the data mysql insert safe
|
||||
$binarydata = fread($fp, 65535);
|
||||
$sql = sprintf("INSERT INTO din_documentdata (document_id, data) VALUES (%s, %s)",
|
||||
$this->conn->quoteSmart($fileid),
|
||||
$this->conn->quoteSmart($binarydata)
|
||||
);
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("Document: " . $result->toString());
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
notify("Document uploaded!");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
error("Document: no file supplied");
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT d.*, dc.title AS documentcategory_title
|
||||
FROM din_document d, din_documentcategory dc
|
||||
WHERE d.id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
return $row;
|
||||
}else {
|
||||
error("Document: document not found.");
|
||||
}
|
||||
}else {
|
||||
error("Document: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function update($data){
|
||||
$conn = db_connect();
|
||||
|
||||
if (isset($data['documentid'])){
|
||||
$sql = sprintf("UPDATE din_document SET
|
||||
name = %s,
|
||||
documentcategory_id = %s,
|
||||
date = NOW(), " .
|
||||
"tags = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$conn->quoteSmart($data['name'] . $data['tag']),
|
||||
$conn->quoteSmart($data['documentcategory_id']),
|
||||
$conn->quoteSmart(strtolower($data['tags'])),
|
||||
$conn->quoteSmart($data['documentid'])
|
||||
);
|
||||
$result =& $conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("Document: " . $result->toString());
|
||||
}else {
|
||||
notify("Document updated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
|
||||
$sql = "DELETE FROM din_document
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result =& $conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error("Document: " . $result->toString());
|
||||
}else {
|
||||
notify("Document deleted.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
class DocumentCategories {
|
||||
var $categories;
|
||||
var $conn;
|
||||
|
||||
function DocumentCategories(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
error("DocumentCategories: " . $conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
$sql = "SELECT id, title FROM din_documentcategory ORDER BY title ASC";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->categories = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<table id="document-cat-list">
|
||||
<tr>
|
||||
<th colspan="2">dokumenttyper</th>
|
||||
<?php if(checkAuth("view-edit-options-documentCategory")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->categories->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$docCat = new DocumentCategory($row['id']);
|
||||
$docCat->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
class DocumentCategory {
|
||||
var $id;
|
||||
var $title;
|
||||
var $text;
|
||||
var $conn;
|
||||
|
||||
function DocumentCategory($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New event
|
||||
if ($data == NULL){
|
||||
error("DocumentCategory: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->title = $data['title'];
|
||||
$this->text = $data['text'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId('din_documentcategory');
|
||||
$sql = sprintf("INSERT INTO din_documentcategory VALUES
|
||||
(%s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart(scriptParam("title")),
|
||||
$this->conn->quoteSmart(scriptParam("text"))
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['documentcategoryid'] = $this->id;
|
||||
if ($this->conn->commit()){
|
||||
notify("New Document Category registered and stored.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Document Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Document Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_documentcategory SET
|
||||
title = %s,
|
||||
text = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Document Category updated.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Document Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update Document Category: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_documentcategory dc
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Document category: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_documentcategory
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Document category deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
|
||||
?>
|
||||
<tr id="documentcategory<?php print $this->id; ?>">
|
||||
<td><?php print $this->title; ?></td>
|
||||
<td><?php print prepareForHTML($this->text); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, DOCCAT,
|
||||
"documentcategory", "view-edit-options-documentCategory"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
class Documents {
|
||||
var $conn;
|
||||
|
||||
function Documents(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public
|
||||
function display($limit = 5, $selection = "0000-00-00"){
|
||||
|
||||
$sql = "SELECT id FROM din_document
|
||||
ORDER BY date DESC
|
||||
WHERE date > $selection
|
||||
LIMIT $limit";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
|
||||
displayOptionsMenu($row['id'], "document");
|
||||
$document = new Document($row['id']);
|
||||
$document->display();
|
||||
}
|
||||
|
||||
}else {
|
||||
error("Documents: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function displayList($category = 0){
|
||||
if ($category > 0){
|
||||
$cat_condition = "AND d.documentcategory_id = $category";
|
||||
}else {
|
||||
$cat_condition = "";
|
||||
}
|
||||
$sql = "SELECT d.*, dc.title AS category
|
||||
FROM din_document d, din_documentcategory dc
|
||||
WHERE d.documentcategory_id = dc.id " .
|
||||
"$cat_condition " .
|
||||
"ORDER BY name ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="documentlist">
|
||||
<tr>
|
||||
<th>tittel</th>
|
||||
<th>kategori</th>
|
||||
<th>tags</th>
|
||||
<th>endret</th>
|
||||
<th>størrelse</th>
|
||||
<?php if(checkAuth("view-edit-options-document")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){?>
|
||||
<tr>
|
||||
<td><a href="file.php?id=<?php print $row->id; ?>"><?php print $row->name; ?></a></td>
|
||||
<td><?php print $row->category; ?></td>
|
||||
<td><?php print $this->_tags_to_links($row->tags); ?></td>
|
||||
<td><?php print formatDate($row->date, "td"); ?></td>
|
||||
<td><?php printf("%.2f KB", $row->size/1024); ?></td>
|
||||
<?php displayOptionsMenuTable($row->id, DOCUMENT, "document", "view-edit-options-document"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen dokumenter registrert.</p>");
|
||||
}
|
||||
}else {
|
||||
error("Documents: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public
|
||||
function displayListTag($tag = NULL){
|
||||
if ($tag == NULL){
|
||||
return false;
|
||||
}
|
||||
$sql = "SELECT d.*, dc.title AS category
|
||||
FROM din_document d, din_documentcategory dc
|
||||
WHERE d.documentcategory_id = dc.id " .
|
||||
"AND tags LIKE '%$tag%' " .
|
||||
"ORDER BY name ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="documentlist">
|
||||
<tr>
|
||||
<th>tittel</th>
|
||||
<th>kategori</th>
|
||||
<th>tags</th>
|
||||
<th>endret</th>
|
||||
<th>størrelse</th>
|
||||
<?php if(checkAuth("view-edit-options-document")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){?>
|
||||
<tr>
|
||||
<td><a href="file.php?id=<?php print $row->id; ?>"><?php print $row->name; ?></a></td>
|
||||
<td><?php print $row->category; ?></td>
|
||||
<td><?php print $this->_tags_to_links($row->tags); ?></td>
|
||||
<td><?php print formatDate($row->date, "td"); ?></td>
|
||||
<td><?php printf("%.2f KB", $row->size/1024); ?></td>
|
||||
<?php displayOptionsMenuTable($row->id, DOCUMENT, "document", "view-edit-options-document"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen dokumenter registrert.</p>");
|
||||
}
|
||||
}else {
|
||||
error("Documents: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function _tags_to_links($tags){
|
||||
$tags = explode(" ", $tags);
|
||||
$tag_list = "";
|
||||
foreach ($tags as $tag){
|
||||
$tag_list .= "<a href=\"index.php?page=display-documents&documenttag=$tag\">$tag</a> ";
|
||||
}
|
||||
return $tag_list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
$errors = Array();
|
||||
$err_counter = 0;
|
||||
|
||||
class Errors {
|
||||
var $displayed;
|
||||
|
||||
public function addError($msg){
|
||||
if ($GLOBALS['beginHTML'] == true){
|
||||
Errors::display($msg);
|
||||
}else {
|
||||
$GLOBALS['errors'][$GLOBALS['err_counter']++] = "$msg";
|
||||
}
|
||||
}
|
||||
|
||||
public function display($msg = NULL){
|
||||
if ($_SESSION['show-errors'] == true || isAdmin()){
|
||||
?>
|
||||
<div class="errors">
|
||||
<h3>Feilmeldinger</h3>
|
||||
<ul>
|
||||
<?php
|
||||
$GLOBALS['beginHTML'] = true;
|
||||
if ($msg != NULL){
|
||||
print("<li>$msg</li>\n");
|
||||
}else {
|
||||
foreach ($GLOBALS['errors'] as $e){
|
||||
print("<li>$e</li>\n");
|
||||
}
|
||||
}?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,388 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Event {
|
||||
|
||||
var $id;
|
||||
var $name;
|
||||
var $text;
|
||||
var $time;
|
||||
var $location;
|
||||
var $eventcategory_id;
|
||||
var $eventcategory_title;
|
||||
var $user_id_responsible;
|
||||
var $name_responsible;
|
||||
var $targetGroup;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Event($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New event
|
||||
if ($data == NULL){
|
||||
error("Event: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->eventcategory_title = $data['eventcategory_title'];
|
||||
$this->name_responsible = $data['name_responsible'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->name = $data['name'];
|
||||
$this->text = $data['text'];
|
||||
$this->time = substr($data['time'], 0, 16);
|
||||
$this->location = $data['location'];
|
||||
$this->eventcategory_id = $data['eventcategory_id'];
|
||||
$this->user_id_responsible = $data['user_id_responsible'];
|
||||
$this->targetGroup = $data['targetGroup'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_event");
|
||||
$sql = sprintf("INSERT INTO din_event
|
||||
(id, name, text, time, location, eventcategory_id, user_id_responsible, targetGroup)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->time),
|
||||
$this->conn->quoteSmart($this->location),
|
||||
$this->conn->quoteSmart($this->eventcategory_id),
|
||||
$this->conn->quoteSmart($this->user_id_responsible),
|
||||
$this->conn->quoteSmart($this->targetGroup)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['eventid'] = $this->id;
|
||||
$sql = sprintf("INSERT INTO din_eventupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart(scriptParam('eventid')),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Event registered.")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("New event registered and stored.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New event: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New event: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New event: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_event SET
|
||||
name = %s,
|
||||
text = %s,
|
||||
time = %s,
|
||||
location = %s,
|
||||
eventcategory_id = %s,
|
||||
user_id_responsible = %s,
|
||||
targetGroup = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->time),
|
||||
$this->conn->quoteSmart($this->location),
|
||||
$this->conn->quoteSmart($this->eventcategory_id),
|
||||
$this->conn->quoteSmart($this->user_id_responsible),
|
||||
$this->conn->quoteSmart($this->targetGroup),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$sql = sprintf("INSERT INTO din_eventupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Event updated.")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Event updated.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New event: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update event: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update event: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function repeat($data){
|
||||
$frequency = $data['frequency'];
|
||||
$count = $data['count'];
|
||||
for ($i = 0; $i < $count; $i++){
|
||||
$date = get_repeat_date($this->time, $i + 1, $frequency);
|
||||
$sql = sprintf("INSERT INTO din_event
|
||||
(id, name, text, time, location, eventcategory_id, user_id_responsible, targetGroup)
|
||||
VALUES
|
||||
(NULL, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($date),
|
||||
$this->conn->quoteSmart($this->location),
|
||||
$this->conn->quoteSmart($this->eventcategory_id),
|
||||
$this->conn->quoteSmart($this->user_id_responsible),
|
||||
$this->conn->quoteSmart($this->targetGroup)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Event repeated.");
|
||||
}else {
|
||||
error("New event: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function copy($data){
|
||||
$id = getNextId("din_event");
|
||||
$sql = sprintf("INSERT INTO din_event
|
||||
(id, name, text, time, location, eventcategory_id, user_id_responsible, targetGroup)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($data['newDate']),
|
||||
$this->conn->quoteSmart($this->location),
|
||||
$this->conn->quoteSmart($this->eventcategory_id),
|
||||
$this->conn->quoteSmart($this->user_id_responsible),
|
||||
$this->conn->quoteSmart($this->targetGroup)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Aktivitet kopiert.");
|
||||
$GLOBALS['extraScriptParams']['eventid'] = $id;
|
||||
}else {
|
||||
notify("Problemer med kopiering av aktivitet.");
|
||||
error("New event: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT e.*, ec.title AS eventcategory_title,
|
||||
CONCAT(u.firstName, ' ', u.lastName) AS name_responsible
|
||||
FROM din_eventcategory ec, din_event e LEFT JOIN din_user u
|
||||
ON e.user_id_responsible = u.id
|
||||
WHERE e.id = $this->id
|
||||
AND e.eventcategory_id = ec.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Events: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_event
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Event deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
$this->_markAsRead();
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, EVENT, "event", "view-edit-options-event");
|
||||
?>
|
||||
<h3><?php print $this->name; ?></h3>
|
||||
<p class="date"><?php print formatDatetime($this->time); ?></p>
|
||||
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
|
||||
<h4>Deltakere:</h4>
|
||||
<p><?php print prepareForHTML($this->targetGroup); ?></p>
|
||||
<h4>Arrangementsansvarlig:</h4>
|
||||
<p><?php print prepareForHTML($this->name_responsible); ?></p>
|
||||
<h4>Sted:</h4>
|
||||
<p><?php print $this->location; ?></p>
|
||||
<?php
|
||||
if (checkAuth("view-register-event")){
|
||||
|
||||
$freqOptions = Array(Array("id" => "daily", "title" => "daglig"),
|
||||
Array("id" => "weekly", "title" => "ukentlig"),
|
||||
Array("id" => "biweekly", "title" => "annenhver uke"),
|
||||
Array("id" => "monthlyDate", "title" => "månedlig"),
|
||||
Array("id" => "annual", "title" => "årlig")
|
||||
);
|
||||
|
||||
$title = "repeat event";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=repeat-event&page=display-events";
|
||||
$fields = Array(Array("label" => "eventid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "eventid", "value" => "$this->id")),
|
||||
Array("label" => "gjenta aktivitet", "type" => "select",
|
||||
"attributes" => Array("name" => "frequency", "values" => $freqOptions,
|
||||
"value" => $freqOptions[0])),
|
||||
Array("label" => "antall ganger", "type" => "text",
|
||||
"attributes" => Array("name" => "count", "size" => 3, "maxlength" => 3,
|
||||
"value" => 0))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
|
||||
|
||||
$title = "copy event";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=copy-event&page=display-event";
|
||||
$fields = Array(Array("label" => "eventid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "eventid", "value" => "$this->id")),
|
||||
Array("label" => "kopier til", "type" => "datetime",
|
||||
"attributes" => Array("name" => "newDate", "value" => "$this->time"))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
}
|
||||
|
||||
//display comments
|
||||
$comments = new EventComments();
|
||||
$list = $comments->getList($this->id);
|
||||
if ($list->numRows() > 0){
|
||||
?>
|
||||
<div class="comments">
|
||||
<h3>kommentarer og spørsmål:</h3>
|
||||
<?php
|
||||
while ($row =& $list->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$comment = new EventComment($row->id);
|
||||
$comment->display();
|
||||
}?>
|
||||
</div>
|
||||
<?php }
|
||||
?>
|
||||
<?php
|
||||
//register new comment
|
||||
$title = "legg inn kommentar eller spørsmål";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=register-eventcomment&page=display-event";
|
||||
$fields = Array(Array("label" => "eventid", "type" => "hidden",
|
||||
"attributes" => Array("name" => "event_id", "value" => "$this->id")),
|
||||
Array("label" => "tittel", "type" => "text",
|
||||
"attributes" => Array("name" => "title", "size" => 50, "maxlength" => 50)),
|
||||
Array("label" => "tekst", "type" => "textarea",
|
||||
"attributes" => Array("name" => "text", "cols" => 70, "rows" => 6))
|
||||
);
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display();
|
||||
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
$read = $this->_readByCurrentUser();
|
||||
?>
|
||||
<tr>
|
||||
<td class="<?php ($read == true) ? print('read'): print('unread'); ?>">
|
||||
<?php ($read == true) ? print(''): print('*'); ?></td>
|
||||
<td><a class="<?php ($read == true) ? print('read'): print('unread'); ?>" href="index.php?page=display-event&eventid=<?php print $this->id; ?>"><?php print $this->name; ?></a></td>
|
||||
<td><?php print $this->eventcategory_title; ?></td>
|
||||
<td><?php print prepareForHTML($this->name_responsible); ?></td>
|
||||
<td><?php print formatDatetime($this->time, "td"); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, EVENT, "event", "view-edit-options-event"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function _markAsRead(){
|
||||
if ($this->_readByCurrentUser() == true){
|
||||
return;
|
||||
}
|
||||
|
||||
$user = getCurrentUser();
|
||||
if ($user == false){
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = sprintf("INSERT INTO din_eventread VALUES
|
||||
(%s, %s, NOW())",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($user)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Event marked as read.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function _readByCurrentUser(){
|
||||
$user = getCurrentUser();
|
||||
if ($user == false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = sprintf("SELECT event_id FROM din_eventread
|
||||
WHERE event_id = %s
|
||||
AND user_id = %s",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($user)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if($result->numRows() > 0){
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class EventCategories {
|
||||
var $categories;
|
||||
var $conn;
|
||||
|
||||
function EventCategories(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$sql = "SELECT id, title FROM din_eventcategory";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->categories = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategories(){
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<table id="event-cat-list">
|
||||
<tr>
|
||||
<th colspan="2">aktivitetstyper</th>
|
||||
<?php if(checkAuth("view-edit-options-eventCategory")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->categories->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$eventCat = new EventCategory($row['id']);
|
||||
$eventCat->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
class EventCategory {
|
||||
var $id;
|
||||
var $title;
|
||||
var $text;
|
||||
var $conn;
|
||||
|
||||
function EventCategory($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New event
|
||||
if ($data == NULL){
|
||||
error("EventCategory: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->title = $data['title'];
|
||||
$this->text = $data['text'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_eventcategory");
|
||||
$sql = sprintf("INSERT INTO din_eventcategory VALUES
|
||||
(%s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart(scriptParam("title")),
|
||||
$this->conn->quoteSmart(scriptParam("text"))
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['eventcategoryid'] = $this->id;
|
||||
if ($this->conn->commit()){
|
||||
notify("New Event Category registered and stored.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Event Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Event Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_eventcategory SET
|
||||
title = %s,
|
||||
text = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Event Category updated.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Event Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update Event Category: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_eventcategory dc
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Event category: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_eventcategory
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Event category deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
|
||||
?>
|
||||
<tr id="eventcategory<?php print $this->id; ?>">
|
||||
<td><?php print $this->title; ?></td>
|
||||
<td><?php print prepareForHTML($this->text); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, EVENTCAT,
|
||||
"eventcategory", "view-edit-options-eventcategory"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class EventComment {
|
||||
|
||||
var $id;
|
||||
var $event_id;
|
||||
var $title;
|
||||
var $text;
|
||||
var $user_id_author;
|
||||
var $name_author;
|
||||
var $date;
|
||||
|
||||
var $conn;
|
||||
|
||||
function EventComment($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New eventComment
|
||||
if ($data == NULL){
|
||||
error("EventComment: No data supplied.");
|
||||
}else {
|
||||
$this->user_id_author = getCurrentUser();
|
||||
$this->date = NULL;
|
||||
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->user_id_author = $data['user_id_author'];
|
||||
$this->name_author = $data['name_author'];
|
||||
$this->date = substr($data['date'], 0, 16);
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->title = $data['title'];
|
||||
$this->text = $data['text'];
|
||||
$this->event_id = $data['event_id'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$sql = sprintf("INSERT INTO din_eventcomment
|
||||
(id, event_id, title,
|
||||
text, user_id_author, date)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, NOW())",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->event_id),
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->user_id_author)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['eventid'] = $this->event_id;
|
||||
if ($this->conn->commit()){
|
||||
notify("New eventComment registered and stored.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New eventComment: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New eventComment: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_eventcomment SET
|
||||
title = %s,
|
||||
text = %s,
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("EventComment updated.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New eventComment: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update eventComment: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT ec.*, CONCAT(u.firstname, ' ', u.lastname) AS name_author
|
||||
FROM din_eventcomment ec, din_user u
|
||||
WHERE ec.id = $this->id
|
||||
AND ec.user_id_author = u.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("EventComments: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_eventcomment
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("EventComment deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="comment">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, EVENTCOMMENT, "eventcomment", "view-edit-options-eventcomment");
|
||||
?>
|
||||
<div class="comment-meta">
|
||||
<h4>Lagt inn av:</h4>
|
||||
<p><?php print $this->name_author; ?></p>
|
||||
<p class="date"><?php print formatDatetimeShort($this->date); ?></p>
|
||||
</div>
|
||||
<div class="comment-main">
|
||||
<h3><?php print $this->title; ?></h3>
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class EventComments {
|
||||
var $conn;
|
||||
|
||||
function EventComments(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getList($eventId){
|
||||
$sql = "SELECT id
|
||||
FROM din_eventcomment
|
||||
WHERE event_id = $eventId
|
||||
ORDER BY date ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("Eventcomments: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
class Events {
|
||||
var $conn;
|
||||
|
||||
function Events(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getListMonth($year, $month){
|
||||
$nextMonth = date("Y-m", strtotime("+1 month", strtotime("$year-$month-01")));
|
||||
$sql = "SELECT id, name, DAYOFMONTH(time) AS date
|
||||
FROM din_event
|
||||
WHERE time >= '$year-$month-01'
|
||||
AND time < '$nextMonth-01'
|
||||
ORDER BY time ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("Events: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList($selection = "0000-00-00"){
|
||||
$sql = "SELECT id FROM din_event
|
||||
WHERE time > $selection
|
||||
ORDER BY time ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="eventlist">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>tittel</th>
|
||||
<th>type</th>
|
||||
<th>ansvarlig</th>
|
||||
<th>dato</th>
|
||||
<?php if(checkAuth("view-edit-options-event")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$event = new Event($row['id']);
|
||||
$event->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen aktiviteter registrert.</p>");
|
||||
}
|
||||
}else {
|
||||
error("Events: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,613 @@
|
||||
<?php
|
||||
|
||||
class Form {
|
||||
|
||||
var $id;
|
||||
var $title;
|
||||
var $enctype;
|
||||
var $method;
|
||||
var $action;
|
||||
var $fields;
|
||||
var $readonly;
|
||||
|
||||
function Form($title, $enctype, $method, $action, $fields, $id = NULL, $readonly = false){
|
||||
$this->__construct($title, $enctype, $method, $action, $fields, $id, $readonly);
|
||||
}
|
||||
|
||||
function __construct($title, $enctype, $method, $action, $fields, $id = NULL, $readonly = false){
|
||||
$this->id = $id;
|
||||
$this->title = $title;
|
||||
$this->enctype = $enctype;
|
||||
$this->fields = $fields;
|
||||
$this->method = $method;
|
||||
$this->action = $action;
|
||||
$this->readonly = $readonly;
|
||||
}
|
||||
|
||||
function display($type = NULL){?>
|
||||
<div class="contentElem">
|
||||
<?php
|
||||
|
||||
if ($type == NULL){
|
||||
if (isset($_SESSION['formtype'])){
|
||||
$type = $_SESSION['formtype'];
|
||||
}else {
|
||||
$type = "table";
|
||||
}
|
||||
$pos = strpos($_SERVER['REQUEST_URI'], "action");
|
||||
if ($pos === false){?>
|
||||
<!--<a class="button" href="index.php?action=switch-formtype&section=customize">bytt skjemastil</a>-->
|
||||
|
||||
<?php }
|
||||
}
|
||||
if ($type == "table"){
|
||||
?>
|
||||
<form <?php ($this->id != NULL) ? print "id=\"$this->id\"" : print ""?> <?php ($this->enctype != NULL) ? print "enctype=\"$this->enctype\"" : print ""?> method="<?php print $this->method; ?>" action="<?php print $this->action; ?>">
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="2"><?php print $this->title; ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($this->fields as $row){
|
||||
if ($row['type'] == 'hidden'){?>
|
||||
<tr style="display: none"><?php
|
||||
}else {?>
|
||||
<tr>
|
||||
<?php } ?>
|
||||
<td class="label"><?php
|
||||
if (!($row['type'] == "radio" || $row['type'] == "checkbox" )){
|
||||
?><label for="<?php print $row['attributes']['name']; ?>"><?php
|
||||
}
|
||||
print $row['label'];
|
||||
if (!($row['type'] == "radio" || $row['type'] == "checkbox" )){?>
|
||||
</label><?php } ?></td>
|
||||
<td><?php $this->_displayFormField($row['type'], $row['attributes']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><?php
|
||||
if ($this->readonly == true){
|
||||
$attributes['disabled'] = true;
|
||||
}else {
|
||||
$attributes['disabled'] = false;
|
||||
}
|
||||
$this->_displayFormField('submit', $attributes); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}else if ($type == "fieldset"){
|
||||
?>
|
||||
<form <?php ($this->id != NULL) ? print "id=\"$this->id\"" : print ""?> <?php ($this->enctype != NULL) ? print "enctype=\"$this->enctype\"" : print ""?> method="<?php print $this->method; ?>" action="<?php print $this->action; ?>">
|
||||
<fieldset>
|
||||
<legend><?php print $this->title; ?></legend>
|
||||
<?php
|
||||
foreach ($this->fields as $row){
|
||||
if ($row['type'] != 'hidden'){?>
|
||||
<div>
|
||||
<div>
|
||||
<?php
|
||||
if (!($row['type'] == "radio" || $row['type'] == "checkbox" )){
|
||||
?><label for="<?php print $row['attributes']['name']; ?>"><?php
|
||||
}
|
||||
print $row['label'];
|
||||
if (!($row['type'] == "radio" || $row['type'] == "checkbox" )){
|
||||
?></label><?php } ?> <br />
|
||||
<?php
|
||||
} $this->_displayFormField($row['type'], $row['attributes']);
|
||||
if ($row['type'] != 'hidden'){?>
|
||||
|
||||
</div></div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php $this->_displayFormField('submit'); ?>
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
}else if ($type == "horizontal"){
|
||||
?>
|
||||
<form <?php ($this->id != NULL) ? print "id=\"$this->id\"" : print ""?> <?php ($this->enctype != NULL) ? print "enctype=\"$this->enctype\"" : print ""?> method="<?php print $this->method; ?>" action="<?php print $this->action; ?>">
|
||||
<div class="horizontal-form">
|
||||
|
||||
<?php //print $this->title; ?>
|
||||
<?php
|
||||
foreach ($this->fields as $row){
|
||||
if ($row['type'] != 'hidden'){?>
|
||||
<label><?php print $row['label']; ?></label>
|
||||
<?php
|
||||
} $this->_displayFormField($row['type'], $row['attributes']);
|
||||
if ($row['type'] != 'hidden'){?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php $this->_displayFormField('submit'); ?>
|
||||
</div>
|
||||
</form>
|
||||
<?php }?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
public
|
||||
function _displayFormField($type, $attributes = NULL){
|
||||
if (isset($attributes['comment'])){
|
||||
print("<div>".$attributes['comment']."</div>\n");
|
||||
}
|
||||
|
||||
switch ($type){
|
||||
|
||||
case "text":
|
||||
$this->_displayText($attributes);
|
||||
break;
|
||||
|
||||
case "password":
|
||||
$this->_displayPassword($attributes);
|
||||
break;
|
||||
|
||||
case "datetime":
|
||||
$this->_displayDatetime($attributes);
|
||||
break;
|
||||
|
||||
case "date":
|
||||
$this->_displayDate($attributes);
|
||||
break;
|
||||
|
||||
case "time":
|
||||
$this->_displayTime($attributes);
|
||||
break;
|
||||
|
||||
case "hidden":
|
||||
$this->_displayHidden($attributes);
|
||||
break;
|
||||
|
||||
case "file":
|
||||
$this->_displayFile($attributes);
|
||||
break;
|
||||
|
||||
case "textarea":
|
||||
$this->_displayTextarea($attributes);
|
||||
break;
|
||||
|
||||
case "select":
|
||||
$this->_displaySelect($attributes);
|
||||
break;
|
||||
|
||||
case "radio":
|
||||
$this->_displayRadio($attributes);
|
||||
break;
|
||||
|
||||
case "checkbox":
|
||||
$this->_displayCheckbox($attributes);
|
||||
break;
|
||||
|
||||
case "checkbox-list":
|
||||
$this->_displayCheckboxList($attributes);
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
$this->_displayComment($attributes);
|
||||
break;
|
||||
|
||||
case "multilist":
|
||||
$this->_displayMultilist($attributes);
|
||||
break;
|
||||
|
||||
case "submit":
|
||||
$this->_displaySubmit($attributes);
|
||||
break;
|
||||
|
||||
case "cart_product":
|
||||
$this->_displayCartProduct($attributes);
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($attributes['help'])) {
|
||||
print("<span class=\"formHelp\" onclick=\"formFieldShowHelp(event, this, '$attributes[help]')\"> hjelp? </span>");
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _displayText($attributes) {
|
||||
if (isset($attributes['readonly']) && $attributes['readonly'] == true){
|
||||
print("<div id=\"$attributes[name]\">");
|
||||
if (isset($attributes['value'])){
|
||||
print($attributes['value']);
|
||||
}
|
||||
print("</div>");
|
||||
return;
|
||||
}
|
||||
print("<input type=\"text\"");
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\"");
|
||||
print(" id=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['readonly']) && $attributes['readonly'] == true){
|
||||
print(" readonly=\"readonly\"");
|
||||
if (isset($attributes['class'])){
|
||||
$attributes['class'] .= " readonly";
|
||||
}else {
|
||||
$attributes['class'] = "readonly";
|
||||
}
|
||||
}
|
||||
if (isset($attributes['class'])){
|
||||
print(" class=\"$attributes[class]\"");
|
||||
}
|
||||
if (isset($attributes['onchange'])){
|
||||
print(" onchange=\"$attributes[onchange]\"");
|
||||
}
|
||||
if (isset($attributes['onblur'])){
|
||||
print(" onblur=\"$attributes[onblur]\"");
|
||||
}
|
||||
if (isset($attributes['size'])){
|
||||
print(" size=\"$attributes[size]\"");
|
||||
}
|
||||
if (isset($attributes['maxlength'])){
|
||||
print(" maxlength=\"$attributes[maxlength]\"");
|
||||
}
|
||||
if (isset($attributes['value'])){
|
||||
print(" value=\"$attributes[value]\"");
|
||||
}
|
||||
print(" />");
|
||||
if (isset($attributes['tag'])){
|
||||
print("<input type=\"hidden\" name=\"tag\" value=\"$attributes[tag]\" />");
|
||||
print($attributes['tag']);
|
||||
}
|
||||
if (isset($attributes['repeatable'])){
|
||||
print("<a href=\"javascript: repeatElement('$attributes[name]'); \">ny link</a>");
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _displayPassword($attributes) {
|
||||
print("<input type=\"password\"");
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\"");
|
||||
print(" id=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['class'])){
|
||||
print(" cols=\"$attributes[class]\"");
|
||||
}
|
||||
if (isset($attributes['size'])){
|
||||
print(" size=\"$attributes[size]\"");
|
||||
}
|
||||
if (isset($attributes['maxlength'])){
|
||||
print(" maxlength=\"$attributes[maxlength]\"");
|
||||
}
|
||||
print(" />");
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function _displayDatetime($attributes) {
|
||||
print("<input type=\"text\"");
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\"");
|
||||
print(" id=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['readonly']) && $attributes['readonly'] == true){
|
||||
print(" readonly=\"readonly\"");
|
||||
if (isset($attributes['class'])){
|
||||
$attributes['class'] .= " readonly";
|
||||
}else {
|
||||
$attributes['class'] = "readonly";
|
||||
}
|
||||
}
|
||||
if (isset($attributes['class'])){
|
||||
print(" cols=\"$attributes[class]\"");
|
||||
}
|
||||
print(" size=\"18\"");
|
||||
print(" maxlength=\"16\"");
|
||||
if (isset($attributes['value'])){
|
||||
print(" value=\"$attributes[value]\"");
|
||||
}else {
|
||||
print(" value=\"". date("Y-m-d H:i") ."\"");
|
||||
}
|
||||
|
||||
print('onblur="validateDatetime(\'' . $attributes['name'] . '\');"');
|
||||
print(" /> (yyyy-mm-dd hh:mm)");
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function _displayDate($attributes) {
|
||||
print("<input type=\"text\"");
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\"");
|
||||
print(" id=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['readonly']) && $attributes['readonly'] == true){
|
||||
print(" readonly=\"readonly\"");
|
||||
if (isset($attributes['class'])){
|
||||
$attributes['class'] .= " readonly";
|
||||
}else {
|
||||
$attributes['class'] = "readonly";
|
||||
}
|
||||
}
|
||||
if (isset($attributes['class'])){
|
||||
print(" class=\"$attributes[class]\"");
|
||||
}
|
||||
print(" size=\"12\"");
|
||||
print(" maxlength=\"10\"");
|
||||
if (isset($attributes['value'])){
|
||||
print(" value=\"$attributes[value]\"");
|
||||
}else {
|
||||
print(" value=\"". date("Y-m-d") ."\"");
|
||||
}
|
||||
|
||||
print('onblur="validateDate(\'' . $attributes['name'] . '\');"');
|
||||
print(" /> (yyyy-mm-dd)");
|
||||
}
|
||||
|
||||
public
|
||||
function _displayTime($attributes) {
|
||||
print("<input type=\"text\"");
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\"");
|
||||
print(" id=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['readonly']) && $attributes['readonly'] == true){
|
||||
print(" readonly=\"readonly\"");
|
||||
if (isset($attributes['class'])){
|
||||
$attributes['class'] .= " readonly";
|
||||
}else {
|
||||
$attributes['class'] = "readonly";
|
||||
}
|
||||
}
|
||||
if (isset($attributes['class'])){
|
||||
print(" cols=\"$attributes[class]\"");
|
||||
}
|
||||
print(" size=\"4\"");
|
||||
print(" maxlength=\"5\"");
|
||||
if (isset($attributes['value'])){
|
||||
print(" value=\"$attributes[value]\"");
|
||||
}else {
|
||||
print(" value=\"". date("H:i") ."\"");
|
||||
}
|
||||
|
||||
print('onblur="validateTime(\'' . $attributes['name'] . '\');"');
|
||||
print(" /> (hh:mm)");
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function _displayHidden($attributes) {
|
||||
print("<input type=\"hidden\"");
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\" id=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['value'])){
|
||||
print(" value=\"$attributes[value]\"");
|
||||
}
|
||||
print(" />");
|
||||
}
|
||||
|
||||
public
|
||||
function _displayRadio($attributes) {
|
||||
for ($i = 0; $i < count($attributes['values']); $i++){
|
||||
$value = $attributes['values'][$i];
|
||||
$label = $attributes['labels'][$i];
|
||||
if (isset($attributes['value']) && $attributes['value'] == $value){
|
||||
print("
|
||||
<input type=\"radio\" name=\"$attributes[name]\" id=\"$value\" value=\"$value\" checked=\"checked\" /><label for=\"$value\">$label</label>\n");
|
||||
}else {
|
||||
print("
|
||||
<input type=\"radio\" name=\"$attributes[name]\" id=\"$value\" value=\"$value\" /><label for=\"$value\">$label</label>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _displayCheckbox($attributes) {
|
||||
$name = $attributes['name'];
|
||||
$label = $attributes['label'];
|
||||
$checked = $attributes['checked'];
|
||||
if ($checked == true){
|
||||
print("<label for=\"$name\"><input type=\"checkbox\" name=\"$name\" id=\"$name\" checked=\"checked\" />$label</label><br />\n");
|
||||
}else {
|
||||
print("<label for=\"$name\"><input type=\"checkbox\" name=\"$name\" id=\"$name\" />$label</label><br />\n");
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _displayCheckboxList($attributes) {
|
||||
$list = $attributes['options'];
|
||||
$name_prefix = $attributes['name'];
|
||||
for ($i = 0; $i < sizeof($list['names']); $i++) {
|
||||
$name = $name_prefix.$list['names'][$i];
|
||||
$label = $list['labels'][$i];
|
||||
$checked = $list['checked'][$i];
|
||||
if ($checked == true){
|
||||
print("<label for=\"$name\"><input type=\"checkbox\" name=\"$name\" id=\"$name\" checked=\"checked\" />$label</label><br />\n");
|
||||
}else {
|
||||
print("<label for=\"$name\"><input type=\"checkbox\" name=\"$name\" id=\"$name\" />$label</label><br />\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _displayMultilist($attributes) {
|
||||
?>
|
||||
<div id="multilist" class="multilist disabled">
|
||||
<div id="notice">
|
||||
|
||||
</div>
|
||||
<ul id="finder">
|
||||
<?php
|
||||
|
||||
$currentDiv = NULL;
|
||||
while ($row =& $attributes['values']->fetchRow(DB_FETCHMODE_ORDERED)){
|
||||
if ($currentDiv != $row[0]){
|
||||
if ($currentDiv != NULL){
|
||||
print("</ul>\n");
|
||||
print("</li>\n");
|
||||
}
|
||||
$currentDiv = $row[0];
|
||||
print("<li>$row[1]\n");
|
||||
print("<ul>\n");
|
||||
}
|
||||
?>
|
||||
<li><a href="javascript: makeRequest('pos.php?positionid=<?php print $row[2]; ?>');"><?php print $row[3]; ?></a></li>
|
||||
<?php
|
||||
}
|
||||
print("</ul>\n</li>\n");
|
||||
?>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function _displayComment($attributes) {
|
||||
print($attributes['value']);
|
||||
}
|
||||
|
||||
public
|
||||
function _displaySelect($attributes) {
|
||||
print("<select name=\"$attributes[name]\" id=\"$attributes[name]\"");
|
||||
if (isset($attributes['disabled']) && $attributes['disabled'] == true){
|
||||
print(" disabled=\"$attributes[disabled]\"");
|
||||
}
|
||||
print(">");
|
||||
if (is_array($attributes['values'])){
|
||||
foreach ($attributes['values'] as $row){
|
||||
$value_id = $row['id'];
|
||||
$value = $row['title'];
|
||||
if (isset($attributes['currentValue']) && $attributes['currentValue'] == $value_id){
|
||||
print("
|
||||
<option value=\"$value_id\" selected=\"selected\">$value</option>");
|
||||
}else {
|
||||
print("
|
||||
<option value=\"$value_id\">$value</option>");
|
||||
}
|
||||
}
|
||||
}else if (is_a($attributes['values'], /* instanceof*/ "DB_Result")){//DB
|
||||
if (isset($attributes['nullPossible']) && $attributes['nullPossible'] == true){
|
||||
if ($attributes['currentValue'] == NULL){
|
||||
print("
|
||||
<option value=\"\" selected=\"selected\">ingen</option>");
|
||||
}else {
|
||||
print("
|
||||
<option value=\"\">ingen</option>");
|
||||
}
|
||||
|
||||
}
|
||||
while($row =& $attributes['values']->fetchRow(DB_FETCHMODE_ORDERED)){
|
||||
$value_id = $row[0];
|
||||
$value = $row[1];
|
||||
if (isset($attributes['currentValue']) && $attributes['currentValue'] == $value_id){
|
||||
print("
|
||||
<option value=\"$value_id\" selected=\"selected\">$value</option>");
|
||||
}else {
|
||||
print("
|
||||
<option value=\"$value_id\">$value</option>");
|
||||
}
|
||||
}
|
||||
}
|
||||
print("</select>\n");
|
||||
}
|
||||
|
||||
public
|
||||
function _displayFile($attributes) {
|
||||
print("<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"2000000\" />");
|
||||
print("<input type=\"file\"");
|
||||
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['size'])){
|
||||
print(" size=\"$attributes[size]\"");
|
||||
}
|
||||
print(" />");
|
||||
}
|
||||
|
||||
public
|
||||
function _displayTextarea($attributes) {
|
||||
print("<textarea");
|
||||
if (isset($attributes['name'])){
|
||||
print(" name=\"$attributes[name]\"");
|
||||
print(" id=\"$attributes[name]\"");
|
||||
}
|
||||
if (isset($attributes['readonly']) && $attributes['readonly'] == true){
|
||||
print(" readonly=\"readonly\"");
|
||||
if (isset($attributes['class'])){
|
||||
$attributes['class'] .= " readonly";
|
||||
}else {
|
||||
$attributes['class'] = "readonly";
|
||||
}
|
||||
}
|
||||
if (isset($attributes['class'])){
|
||||
print(" class=\"$attributes[class]\"");
|
||||
}
|
||||
if (isset($attributes['cols'])){
|
||||
print(" cols=\"$attributes[cols]\"");
|
||||
}
|
||||
if (isset($attributes['rows'])){
|
||||
print(" rows=\"$attributes[rows]\"");
|
||||
}
|
||||
//Uses javascript to validate length of textarea. Also displays current length
|
||||
if (isset($attributes['maxlength'])){
|
||||
print('onblur="validateSize(\'' . $attributes['name'] . '\', ' . $attributes['maxlength'] . ');"');
|
||||
print('onkeydown="textCounter(\'' . $attributes['name'] . '\', \'' . $attributes['name'] . 'Counter\', ' . $attributes['maxlength'].');"');
|
||||
print('onkeyup="textCounter(\'' . $attributes['name'] . '\', \'' . $attributes['name'] . 'Counter\', ' . $attributes['maxlength'].');"');
|
||||
}
|
||||
print(">");
|
||||
if (isset($attributes['value'])){
|
||||
print($attributes['value']);
|
||||
}
|
||||
print("</textarea>");
|
||||
if (isset($attributes['maxlength']) &&
|
||||
!isset($attributes['nocounter'])){?>
|
||||
<input class="readonly counter" readonly="readonly" type="text" size="4" id="<?php print $attributes['name']; ?>Counter" value="<?php print $attributes['maxlength']; ?>" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _displaySubmit($attributes) {
|
||||
print("<input type=\"submit\" value=\"Submit\" class=\"submit\"");
|
||||
if ($attributes['disabled'] == true){
|
||||
print(" disabled=\"disabled\"");
|
||||
}
|
||||
print(" />");
|
||||
}
|
||||
|
||||
public
|
||||
function _displayCartProduct($attributes) {
|
||||
$id_att = Array("name" => "product_id", "value" => $attributes['product_id']);
|
||||
$id_type = "hidden";
|
||||
$this->_displayFormField($id_type, $id_att);
|
||||
|
||||
$order_id_att = Array("name" => "order_id", "value" => $attributes['order_id']);
|
||||
$order_type = "hidden";
|
||||
$this->_displayFormField($order_type, $order_id_att);
|
||||
|
||||
$qty_type = "text";
|
||||
$qty_att = Array("name" => "quantity", "size" => 1, "value" => 1);
|
||||
print("legg ");
|
||||
$this->_displayFormField($qty_type, $qty_att);
|
||||
print(" stk i handlekurv<br />");
|
||||
if ($attributes['allow_comment'] == 1) {
|
||||
print("kommentar til denne bestillingen:<br />");
|
||||
$comment_type = "textarea";
|
||||
$comment_att = Array("name" => "comment", "rows" => 2, "cols" => 60);
|
||||
$this->_displayFormField($comment_type, $comment_att);
|
||||
print("<br />");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Group {
|
||||
|
||||
var $id;
|
||||
var $name;
|
||||
var $text;
|
||||
var $division_id;
|
||||
var $admin;
|
||||
var $mailinglist;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Group($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
print("error: ".$conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($this->id == NULL){//New group
|
||||
if ($data == NULL){
|
||||
error("Group: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->name = $data['name'];
|
||||
$this->text = ($data['text']) ? $data['text'] : "...";
|
||||
$this->division_id = ($data['division_id'] == "") ? NULL : $data['division_id'];
|
||||
$this->admin = $data['admin'];
|
||||
$this->mailinglist = $data['mailinglist'];
|
||||
}
|
||||
|
||||
public function store($actions = NULL){
|
||||
$action = scriptParam("action");
|
||||
if ($action == "register-group"){
|
||||
$sql = sprintf("INSERT INTO din_group
|
||||
(name, text, division_id, admin, mailinglist)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->division_id),
|
||||
$this->conn->quoteSmart($this->admin),
|
||||
$this->conn->quoteSmart($this->mailinglist)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("New group registered and stored.");
|
||||
}else {
|
||||
error("New group: " . $result->toString());
|
||||
}
|
||||
|
||||
}else {//Update
|
||||
$sql = sprintf("UPDATE din_group SET
|
||||
name = %s,
|
||||
text = %s,
|
||||
division_id = %s,
|
||||
admin = %s,
|
||||
mailinglist = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->division_id),
|
||||
$this->conn->quoteSmart($this->admin),
|
||||
$this->conn->quoteSmart($this->mailinglist),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
|
||||
//actions
|
||||
$sql = "DELETE FROM din_actiongrouprelationship " .
|
||||
"WHERE group_id = $this->id";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$keys = array_keys($actions);
|
||||
foreach ($keys as $a) {
|
||||
$prefix = substr($a, 0, 7);
|
||||
$value = substr($a, 7);
|
||||
if ($prefix == "actions") {
|
||||
$agr = new ActionGroupRelationship($value, $this->id);
|
||||
$agr->store();
|
||||
}
|
||||
}
|
||||
}else {
|
||||
error("ActionGroup-delete: " . $result->toString());
|
||||
}
|
||||
notify("Group updated.");
|
||||
}else {
|
||||
error("Update group: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT g.*
|
||||
FROM din_group g
|
||||
WHERE g.id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}else {
|
||||
error("Groups: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_group WHERE id = $id LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Group deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
displayOptionsMenu($this->id, GROUP, "group");
|
||||
?>
|
||||
<h3><?php print "$this->name"; ?></h3>
|
||||
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=display-group&groupid=<?php print $this->id; ?>"
|
||||
title="<?php print $this->text; ?>">
|
||||
<?php print $this->name; ?>
|
||||
</a></td>
|
||||
<td><a href="index.php?page=display-users&groupid=<?php print $this->id;?>"><?php print $this->_getGroupMemberCount(); ?></a></td>
|
||||
<?php displayOptionsMenuTable($this->id, GROUP, "group", "view-edit-options-group"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function _getGroupMemberCount(){
|
||||
$sql = "SELECT COUNT(*) FROM din_usergrouprelationship
|
||||
WHERE group_id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ORDERED)){
|
||||
return $row[0];
|
||||
}else {
|
||||
error("Count groupmembers: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function isAdmin(){
|
||||
return $this->admin;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Groups {
|
||||
var $groups;
|
||||
var $conn;
|
||||
|
||||
function Groups($restriction = NULL) {
|
||||
$this->__construct($restriction);
|
||||
}
|
||||
|
||||
function __construct($restriction = NULL){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
error("Groups: " . $conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
if (!checkAuth("view-protected-users")){
|
||||
$condition = "AND id != 1";
|
||||
}else {
|
||||
$condition = "";
|
||||
}
|
||||
if (isAdmin() == true || checkAuth("view-protected-users")){
|
||||
$sql = "SELECT id, name FROM din_group";
|
||||
}else if ($restriction == "admin-only"){
|
||||
$sql = sprintf("SELECT DISTINCT g.id, g.name FROM din_group g, din_group g2, din_division d, din_usergrouprelationship ugr " .
|
||||
"WHERE g.division_id = d.id " .
|
||||
"AND g2.division_id = d.id " .
|
||||
"AND ugr.group_id = g2.id " .
|
||||
"AND g2.admin = 1 " .
|
||||
"AND ugr.user_id = %s " .
|
||||
"ORDER BY name",
|
||||
getCurrentUser());
|
||||
}else {
|
||||
$sql = "SELECT id, name " .
|
||||
"FROM din_group " .
|
||||
"WHERE id != 1 " .
|
||||
"ORDER BY name";
|
||||
}
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->groups = $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
return $this->groups;
|
||||
}
|
||||
|
||||
public function displayList($limit = 25){
|
||||
if ($this->groups->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="groups">
|
||||
<tr>
|
||||
<th>gruppenavn</th>
|
||||
<th>medlemmer</th>
|
||||
<th colspan="2"> </th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->groups->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$group = new Group($row->id);
|
||||
$group->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen grupper registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Job {
|
||||
|
||||
var $id;
|
||||
var $name;
|
||||
var $text;
|
||||
var $jobcategory_id;
|
||||
var $jobcategory_title;
|
||||
var $contactInfo;
|
||||
var $registered;
|
||||
var $user_id_registered;
|
||||
var $published;
|
||||
var $expires;
|
||||
|
||||
var $position_id;
|
||||
|
||||
|
||||
var $conn;
|
||||
|
||||
function Job($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New job
|
||||
if ($data == NULL){
|
||||
error("Job: No data supplied.");
|
||||
}else {
|
||||
$this->registered = date("Y-m-d H:i:s");
|
||||
$this->user_id_registered = getCurrentUser();
|
||||
$this->published = date("Y-m-d H:i:s");
|
||||
$this->position_id = (isset($data['positionid'])) ? $data['positionid'] : 0;
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
if ($data == NULL){
|
||||
notify("Stillingen du søkte er ikke tilgjengelig. Bruk skjemaet under om du vil rapportere problemet.");
|
||||
displayBugReportForm("job");
|
||||
$this->id = NULL;
|
||||
}
|
||||
$this->jobcategory_title = $data['jobcategory_title'];
|
||||
$this->registered = $data['registered'];
|
||||
$this->user_id_registered = $data['user_id_registered'];
|
||||
$this->published = $data['published'];
|
||||
$this->position_id = (isset($data['position_id'])) ? $data['position_id'] : 0;
|
||||
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->name = stripcslashes($data['name']);
|
||||
$this->text = stripcslashes($data['text']);
|
||||
$this->jobcategory_id = $data['jobcategory_id'];
|
||||
$this->contactInfo = $data['contactInfo'];
|
||||
$this->expires = $data['expires'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_job");
|
||||
$sql = sprintf("INSERT INTO din_job
|
||||
(id, name, text, jobcategory_id, contactInfo,
|
||||
registered, user_id_registered, published,
|
||||
expires, position_id)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->jobcategory_id),
|
||||
$this->conn->quoteSmart($this->contactInfo),
|
||||
$this->conn->quoteSmart($this->registered),
|
||||
$this->conn->quoteSmart($this->user_id_registered),
|
||||
$this->conn->quoteSmart($this->published),
|
||||
$this->conn->quoteSmart($this->expires),
|
||||
$this->conn->quoteSmart($this->position_id)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['jobid'] = $this->id;
|
||||
|
||||
$sql = sprintf("INSERT INTO din_jobupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Job registered.")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("New job registered and stored.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New jobb: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New job: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("New job: " . $result->toString());
|
||||
}
|
||||
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_job SET
|
||||
name = %s,
|
||||
text = %s,
|
||||
jobcategory_id = %s,
|
||||
contactInfo = %s,
|
||||
expires = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->jobcategory_id),
|
||||
$this->conn->quoteSmart($this->contactInfo),
|
||||
$this->conn->quoteSmart($this->expires),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$sql = sprintf("INSERT INTO din_jobupdate
|
||||
VALUES (NULL, NOW(), %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart(getCurrentUser()),
|
||||
$this->conn->quoteSmart("Job updated.")
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Job updated.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("Update job: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("Update job: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("Update job: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT j.*, jc.title AS jobcategory_title
|
||||
FROM din_job j, din_jobcategory jc
|
||||
WHERE j.id = $this->id
|
||||
AND j.jobcategory_id = jc.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Jobs: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_job
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Job deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
if ($this->id == NULL){
|
||||
return false;
|
||||
}
|
||||
$this->_markAsRead();
|
||||
?>
|
||||
<div class="text-column">
|
||||
<div class="timeData">
|
||||
<strong>Publisert:</strong> <?php print formatDate($this->published); ?>
|
||||
<strong>Utgår:</strong> <?php print formatDate($this->expires); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
displayOptionsMenu($this->id, JOB, "job", "view-edit-options-job");
|
||||
?>
|
||||
<h3><?php print $this->name; ?></h3>
|
||||
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
<h4>kontaktinfo:</h4>
|
||||
<p><?php print prepareForHTML($this->contactInfo); ?></p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
$read = $this->_readByCurrentUser();
|
||||
$division = $this->_getLinkedToPosDivName();
|
||||
?>
|
||||
<tr>
|
||||
<td class="<?php ($read == true) ? print('read'): print('unread'); ?>">
|
||||
<?php ($read == true) ? print(''): print('*'); ?></td>
|
||||
<td><a class="<?php ($read == true) ? print('read'): print('unread'); ?>" href="index.php?page=display-job&jobid=<?php print $this->id; ?>"><?php print $this->name; ?></a></td>
|
||||
<td><?php print $this->jobcategory_title; ?></td>
|
||||
<td><?php print $division; ?></td>
|
||||
<td class="date"><?php print formatDatetime($this->published, "td"); ?></td>
|
||||
<td class="date"><?php print formatDatetime($this->expires, "td"); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, JOB, "job", "view-edit-options-job"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function _getLinkedToPosDivName(){
|
||||
if ($this->position_id > 0){
|
||||
$sql = "SELECT d.name
|
||||
FROM din_position p, din_division d
|
||||
WHERE $this->position_id = p.id
|
||||
AND p.division_id = d.id";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
notify("Job: " . $result->toString());
|
||||
return "utilgjengelig";
|
||||
}else {
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ORDERED)){
|
||||
return $row[0];
|
||||
}else {
|
||||
return "utilgjengelig";
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return "uspesifisert";
|
||||
}
|
||||
}
|
||||
|
||||
public function _markAsRead(){
|
||||
if ($this->_readByCurrentUser() == true){
|
||||
return;
|
||||
}
|
||||
|
||||
$user = getCurrentUser();
|
||||
if ($user == false){
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = sprintf("INSERT INTO din_jobread VALUES
|
||||
(%s, %s, NOW())",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($user)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Job marked as read.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function _readByCurrentUser(){
|
||||
$user = getCurrentUser();
|
||||
if ($user == false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = sprintf("SELECT job_id FROM din_jobread
|
||||
WHERE job_id = %s
|
||||
AND user_id = %s",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($user)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if($result->numRows() > 0){
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class JobCategories {
|
||||
var $categories;
|
||||
var $conn;
|
||||
|
||||
function JobCategories(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
error("JobCategories: " . $conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
$sql = "SELECT id, title FROM din_jobcategory";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->categories = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategories(){
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<table id="job-cat-list">
|
||||
<tr>
|
||||
<th colspan="2">stillingstyper</th>
|
||||
<?php if(checkAuth("view-edit-options-jobCategory")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->categories->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$jobCat = new JobCategory($row['id']);
|
||||
$jobCat->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
class JobCategory {
|
||||
var $id;
|
||||
var $title;
|
||||
var $text;
|
||||
var $conn;
|
||||
|
||||
function JobCategory($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New job
|
||||
if ($data == NULL){
|
||||
error("JobCategory: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->title = $data['title'];
|
||||
$this->text = $data['text'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$this->conn->autoCommit(false);
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId('din_jobcategory');
|
||||
$sql = sprintf("INSERT INTO din_jobcategory VALUES
|
||||
(%s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart(scriptParam("title")),
|
||||
$this->conn->quoteSmart(scriptParam("text"))
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$GLOBALS['extraScriptParams']['jobcategoryid'] = $this->id;
|
||||
if ($this->conn->commit()){
|
||||
notify("New Job Category registered and stored.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Job Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Job Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_jobcategory SET
|
||||
title = %s,
|
||||
text = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($this->conn->commit()){
|
||||
notify("Job Category updated.");
|
||||
}else {
|
||||
$this->conn->rollback();
|
||||
error("New Job Category: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
error("Update Job Category: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_jobcategory dc
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Job category: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_jobcategory
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Job category deleted.");
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
|
||||
?>
|
||||
<tr id="jobcategory<?php print $this->id; ?>">
|
||||
<td><?php print $this->title; ?></td>
|
||||
<td><?php print prepareForHTML($this->text); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, JOBCAT,
|
||||
"jobcategory", "view-edit-options-jobcategory"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
class Jobs {
|
||||
var $conn;
|
||||
|
||||
function Jobs($selection = "0000-00-00"){
|
||||
$this->__construct($selection);
|
||||
}
|
||||
|
||||
function __construct($selection = "0000-00-00"){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function display($selection = "0000-00-00"){
|
||||
$sql = "SELECT id FROM din_job
|
||||
ORDER BY published DESC
|
||||
WHERE expires > $selection";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
displayOptionsMenu($row['id'], "job");
|
||||
$job = new Job($row['id']);
|
||||
$job->display();
|
||||
}
|
||||
}else {
|
||||
print("Ingen stillinger er registrert.");
|
||||
}
|
||||
}else {
|
||||
error("Jobs: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function displayList($selection = "0000-00-00"){
|
||||
$sql = "SELECT id FROM din_job
|
||||
WHERE expires > $selection
|
||||
ORDER BY published DESC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() > 0){?>
|
||||
<p>Antall treff: <?php print $result->numRows(); ?> </p>
|
||||
<table class="sortable" id="joblist">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>tittel</th>
|
||||
<th>type</th>
|
||||
<th>forening</th>
|
||||
<th>publisert</th>
|
||||
<th>utgår</th>
|
||||
<?php if(checkAuth("view-edit-options-job")){
|
||||
?><th colspan="2"></th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
}else {
|
||||
print("Ingen stillinger er registrert.");
|
||||
}
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$job = new Job($row['id']);
|
||||
$job->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
error("Jobs: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class Locations {
|
||||
var $locations;
|
||||
var $conn;
|
||||
|
||||
function Locations(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect("dns");
|
||||
$sql = "SELECT id AS locationId, navn AS locationTitle
|
||||
FROM lokaler
|
||||
ORDER BY navn ASC";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->locations = $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
return $this->locations;
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<table class="sortable" id="location-list">
|
||||
<tr>
|
||||
<th colspan="2">lokaler</th>
|
||||
<?php if(checkAuth("view-edit-options-locations")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->locations->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$loc = new Location($row['locationId']);
|
||||
$loc->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
$messages = Array();
|
||||
$msg_counter = 0;
|
||||
|
||||
class Messages {
|
||||
|
||||
public function addMSG($msg){
|
||||
if ($GLOBALS['beginHTML'] == true){
|
||||
Messages::display($msg);
|
||||
}else {
|
||||
$GLOBALS['messages'][$GLOBALS['msg_counter']++] = "$msg";
|
||||
}
|
||||
}
|
||||
|
||||
public function display($msg = NULL){?>
|
||||
<div class="messages">
|
||||
<h3>Beskjeder</h3>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
$GLOBALS['beginHTML'] = true;
|
||||
if ($msg != NULL){
|
||||
print("<li>$msg</li>\n");
|
||||
}else {
|
||||
foreach ($GLOBALS['messages'] as $e){
|
||||
print("<li>$e</li>\n");
|
||||
}
|
||||
}?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
class Navigation {
|
||||
|
||||
public
|
||||
function display(){
|
||||
?>
|
||||
<div id="nav">
|
||||
|
||||
<a class="skip-nav" href="#content">hopp til innhold</a>
|
||||
<ul id="navList">
|
||||
<?php
|
||||
if(checkAuth("view-menu-quick")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="quickSwitch" class="switch">personlig</a>
|
||||
<ul id="quickMenu" class="menu">
|
||||
<li><a href="index.php?page=display-current-user">oppdatér brukerinformasjon</a></li>
|
||||
<li><a href="index.php?page=change-username">endre brukernavn</a></li>
|
||||
<?php if (!isMember(getCurrentUser())){?>
|
||||
<li><a href="index.php?page=register-membership">kjøp/registrér medlemskap</a></li>
|
||||
<?php }else if (membershipExpired(getCurrentUser())){?>
|
||||
<li><a href="index.php?page=register-membership">aktiver medlemskap</a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-messages")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="messagesSwitch" class="switch">meldinger</a>
|
||||
<ul id="messagesMenu" class="menu">
|
||||
<li><a href="index.php?page=display-messages">vis meldinger</a></li>
|
||||
<li><a href="index.php?page=display-bugreports">vis feilmeldinger</a></li>
|
||||
<li>ny melding</li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-jobs")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="jobsSwitch" class="switch">ledige stillinger</a>
|
||||
<ul id="jobsMenu" class="menu">
|
||||
<li><a href="index.php?page=display-jobs">vis ledige</a></li>
|
||||
<?php if(isAdmin()){
|
||||
?><li><a href="index.php?page=register-job">registrér stilling</a></li>
|
||||
<?php }
|
||||
?> <li><a href="index.php?page=display-jobs-archive">arkiv</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-barshifts")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="barshiftsSwitch" class="switch">tappetårnets vaktliste</a>
|
||||
<ul id="barshiftsMenu" class="menu">
|
||||
<li><a href="index.php?page=display-barshifts">vis kommende</a></li>
|
||||
<li><a href="index.php?page=display-barshifts-calendar">vis kalender</a></li>
|
||||
<?php if(checkAuth("view-register-barshift")){
|
||||
?><li><a href="index.php?page=register-barshift">registrér vakt</a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-events")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="eventsSwitch" class="switch">møter/kurs/internfester</a>
|
||||
<ul id="eventsMenu" class="menu">
|
||||
<li><a href="index.php?page=display-events-calendar">kalender</a></li>
|
||||
<li><a href="index.php?page=display-events">kommende aktiviteter</a></li>
|
||||
<?php if(checkAuth("view-register-event")){
|
||||
?><li><a href="index.php?page=register-event">registrér aktivitet</a></li>
|
||||
<?php }
|
||||
?> <li><a href="index.php?page=display-all-calendar">kombolender</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-concerts")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="concertsSwitch" class="switch">konserter/program</a>
|
||||
<ul id="concertsMenu" class="menu">
|
||||
<li><a href="index.php?page=display-concerts-calendar">kalender</a></li>
|
||||
<li><a href="index.php?page=display-concerts">kommende program</a></li>
|
||||
<?php if(checkAuth("view-register-concert")){
|
||||
?><li><a href="index.php?page=register-concert">registrér arrangement</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-week-program")){
|
||||
?><li><a href="index.php?page=week-program">ukesprogram</a></li>
|
||||
<li><a href="index.php?page=program-selection">programutvalg</a></li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-divisions")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="divisionsSwitch" class="switch">foreninger</a>
|
||||
<ul id="divisionsMenu" class="menu">
|
||||
<li><a href="index.php?page=display-divisions">vis foreninger</a></li>
|
||||
<?php if(checkAuth("view-register-division")){
|
||||
?><li><a href="index.php?page=register-division">registrér forening</a></li>
|
||||
<?php }
|
||||
?> <li><a href="index.php?page=display-positions">vis stillingsbeskrivelser</a></li>
|
||||
<?php if(checkAuth("view-register-position")){
|
||||
?><li><a href="index.php?page=register-position">registrér stillingsbeskrivelse</a></li>
|
||||
<?php }
|
||||
?> </ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-documents")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="documentsSwitch" class="switch">dokumenter</a>
|
||||
<ul id="documentsMenu" class="menu">
|
||||
<li><a href="index.php?page=display-documents">vis dokumenter</a></li>
|
||||
<?php if(checkAuth("view-upload-document")){
|
||||
?><li><a href="index.php?page=upload-document">last opp nytt</a></li>
|
||||
<?php } ?> </ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-users")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="usersSwitch" class="switch">medlemmer</a>
|
||||
<ul id="usersMenu" class="menu">
|
||||
<li><a href="index.php?page=display-users">vis medlemmer</a></li>
|
||||
<?php if(checkAuth("view-register-user")){
|
||||
?><li><a href="index.php?page=register-user">registrér medlem</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-display-user-expiries")){
|
||||
?><li><a href="index.php?page=display-user-expiries">administrér utløpsdatoer</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-register-membership-bankpayment")){
|
||||
?><li><a href="index.php?page=register-membership-bankpayment">registrer bankbetalinger</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-register-user-ea-update")){
|
||||
?><li><a href="index.php?page=register-user-ea-update">registrer EA oppdatering</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-display-division-requests")){
|
||||
?><li><a href="index.php?page=display-division-requests">vis aktivforespørseler</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-register-usergrouprelationship")){
|
||||
?><li><a href="index.php?page=register-usergrouprelationship">registrér gruppemedlemskap</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-display-usergrouprelationships")){
|
||||
?><li><a href="index.php?page=display-usergrouprelationships">slett gruppemedlemskap</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-display-users-study-place")){
|
||||
?><li><a href="index.php?page=display-users-study-place">vis studieplass-statistikk</a></li>
|
||||
<?php }
|
||||
?> <?php if(checkAuth("view-payex-testpage")){
|
||||
?><li><a href="index.php?page=payex-form">payex testside</a></li>
|
||||
<?php }
|
||||
?> </ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-access")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="accessSwitch" class="switch">administrering av tilgang</a>
|
||||
<ul id="accessMenu" class="menu">
|
||||
<li><a href="index.php?page=display-groups">vis grupper</a></li>
|
||||
<li><a href="index.php?page=register-group">registrér gruppe</a></li>
|
||||
<li><a href="index.php?page=display-actions">vis handlinger</a></li>
|
||||
<li><a href="index.php?page=register-action">registrér handling</a></li>
|
||||
<li><a href="index.php?page=display-actiongrouprelationships">vis forhold</a></li>
|
||||
<li><a href="index.php?page=register-actiongrouprelationship">registrér forhold</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
|
||||
<?php
|
||||
if(checkAuth("view-menu-webpages")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="webpagesSwitch" class="switch">administrér nettsider</a>
|
||||
<ul id="webpagesMenu" class="menu">
|
||||
<li><a href="index.php?page=display-articles">vis nyheter</a></li>
|
||||
<li><a href="index.php?page=register-article">registrér nyhet</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php
|
||||
if(checkAuth("view-menu-settings")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="settingsSwitch" class="switch">innstillinger</a>
|
||||
<ul id="settingsMenu" class="menu">
|
||||
<li><a href="index.php?action=switch-formtype&section=settings">bytt skjemastil</a></li>
|
||||
<li><a href="index.php?action=switch-tinymce-theme&section=settings">bytt RT-editor</a></li>
|
||||
<li><a href="index.php?page=register-documentcategory">dokumenttyper</a></li>
|
||||
<li><a href="index.php?page=register-eventcategory">aktitivitetstyper</a></li>
|
||||
<li><a href="index.php?page=register-jobcategory">stillingstyper</a></li>
|
||||
<li><a href="index.php?page=register-product">produkter for salg</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }
|
||||
|
||||
if (isAdmin()) {
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="smsSwitch" class="switch">SMS</a>
|
||||
<ul id="smsMenu" class="menu">
|
||||
<li><a href="?page=display-sms-log">Vis logg for SMS-tjeneste</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
if(isAdmin()){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="samarbeidspartnereSwitch" class="switch">samarbeidspartnere</a>
|
||||
<ul id="samarbeidspartnereMenu" class="menu">
|
||||
<li><a href="#">rediger partnere</a></li>
|
||||
<li><a href="#">godkjenne plasser</a></li>
|
||||
<li><a href="#">vis oversikt</a></li>
|
||||
<li><a href="#">rediger e-post</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
if(checkAuth("view-menu-webshop")){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="webshopSwitch" class="switch">nettbutikk</a>
|
||||
<ul id="webshopMenu" class="menu">
|
||||
<li><a href="index.php?page=display-webshop">vis produkter</a></li>
|
||||
<li><a href="index.php?page=display-carts">vis handlekurver</a></li>
|
||||
<?php if (checkAuth('view-display-sales')) {?>
|
||||
<li><a href="index.php?page=display-sales">vis solgte produkter</a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (loggedIn()){
|
||||
?>
|
||||
<li class="menulist">
|
||||
<a href="#" id="linksSwitch" class="switch">andre sider</a>
|
||||
<ul id="linksMenu" class="menu">
|
||||
<li><a href="http://www.studentersamfundet.no/index.php">studentersamfundet.no</a></li>
|
||||
<li><a href="http://www.studentersamfundet.no/forum/index.php">forum</a></li>
|
||||
<?php
|
||||
if (isActive()) {
|
||||
?>
|
||||
<li><a href="http://www.studentersamfundet.no/coppermine/index.php">bildegalleri</a></li>
|
||||
<li><a href="http://www.studentersamfundet.no/info/index.php">infovræl</a></li>
|
||||
<li><a href="http://booking.studentersamfundet.no/">bookingsystemet</a></li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
if (loggedIn()){
|
||||
?><a href="index.php?action=log-out">logg ut</a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class nordea {
|
||||
|
||||
var $id;
|
||||
var $firstname;
|
||||
var $lastname;
|
||||
var $email;
|
||||
var $phonenumber;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Nordea($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New Nordea-lead
|
||||
if ($data == NULL){
|
||||
error("Nordea-lead: No data supplied.");
|
||||
}
|
||||
}else {//ID set, existing lead
|
||||
if ($data != NULL){//Update existing lead
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->firstname = $data['firstname'];
|
||||
$this->lastname = $data['lastname'];
|
||||
$this->email = $data['email'];
|
||||
$this->phonenumber = $data['phonenumber'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$sql = sprintf("INSERT INTO din_nordea
|
||||
(id, firstname, lastname, email, phonenumber)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->firstname),
|
||||
$this->conn->quoteSmart($this->lastname),
|
||||
$this->conn->quoteSmart($this->email),
|
||||
$this->conn->quoteSmart($this->phonenumber)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Ønske om å bli kontakt av Nordea er registrert.");
|
||||
$sendto = "student@nordea.no";
|
||||
$subject = "Nytt lead fra Studentersamfundet";
|
||||
$message = "Dette er en autogenerert epost som blir sendt hver gang et nytt medlem har haket av for ønske om å bli kontaktet av Nordea. Denne personen har nettopp kjøpt medlemskap i Studentersamfundet og registrert seg på nettsidene våre." .
|
||||
"\n" .
|
||||
"\nEt nytt lead er registrert:" .
|
||||
"\n" .
|
||||
"\n$this->firstname $this->lastname" .
|
||||
"\n" .
|
||||
"\nEpost: $this->email".
|
||||
"\nTelefon: $this->phonenumber" .
|
||||
"\n" .
|
||||
"\nmvh" .
|
||||
"\nStudentersamfundet";
|
||||
$headers = 'From: nordea@studentersamfundet.no'."\r\n";
|
||||
$headers .= 'Cc: support@studentersamfundet.no'."\r\n";
|
||||
mail($sendto, $subject, $message, $headers);
|
||||
|
||||
}else {
|
||||
error("New nordea: " . $result->toString());
|
||||
notify("Problemer med å registrere Nordealead.");
|
||||
}
|
||||
|
||||
}else {
|
||||
//Not finished
|
||||
$sql = sprintf("UPDATE din_nordea SET
|
||||
name = %s,
|
||||
text = %s,
|
||||
phone = %s,
|
||||
email = %s,
|
||||
office = %s,
|
||||
user_id_contact = %s,
|
||||
url = %s,
|
||||
nordeacategory_id = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->phone),
|
||||
$this->conn->quoteSmart($this->email),
|
||||
$this->conn->quoteSmart($this->office),
|
||||
$this->conn->quoteSmart($this->user_id_contact),
|
||||
$this->conn->quoteSmart($this->url),
|
||||
$this->conn->quoteSmart($this->nordeacategory_id),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
// $result = $this->conn->query($sql);
|
||||
// if (DB::isError($result) != true){
|
||||
// notify("Nordea-lead oppdatert.");
|
||||
// }else {
|
||||
// error("Update nordea lead: " . $result->toString());
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_nordea
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$row['text'] = stripslashes($row['text']);
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("nordea: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_nordea
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($conn->affectedRows() > 0){
|
||||
notify("Nordea-lead slettet.");
|
||||
}else {
|
||||
notify("Ugyldig lead-id, ingen handling utført.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Order {
|
||||
|
||||
var $id;
|
||||
var $user_id;
|
||||
var $timestamp;
|
||||
var $order_status_id;
|
||||
var $order_status_value;
|
||||
var $comment;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Order($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){// Order
|
||||
$this->order_status_id = 1;//New empty order created
|
||||
$this->comment = "Order created.";
|
||||
$this->user_id = getCurrentUser();
|
||||
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->user_id = $data['user_id'];
|
||||
$this->timestamp = $data['timestamp'];
|
||||
$this->order_status_id = $data['order_status_id'];
|
||||
$this->order_status_value = $data['order_status_value'];
|
||||
$this->comment = $data['comment'];
|
||||
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
}
|
||||
|
||||
public
|
||||
function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_order");
|
||||
$sql = sprintf("INSERT INTO din_order
|
||||
(id, user_id, timestamp, comment)
|
||||
VALUES
|
||||
(%s, %s, NOW(), %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->user_id),
|
||||
$this->conn->quoteSmart($this->comment)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Ny ordre lagret.");
|
||||
}else {
|
||||
error("New order: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function setStatus($value) {
|
||||
$sql = "UPDATE din_order SET
|
||||
order_status_id = $value
|
||||
WHERE " .
|
||||
" id = $this->id";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Orderstatus oppdatert ($value)");
|
||||
}else {
|
||||
error("Set status - order: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function addOrderItem($data) {
|
||||
$data['order_id'] = $this->id;
|
||||
$data['discount'] = 0;
|
||||
$item = new OrderItem(NULL, $data);
|
||||
$item->store();
|
||||
return true;
|
||||
//$this->_updateTotalPrice();
|
||||
}
|
||||
|
||||
public
|
||||
function _updateTotalPrice(){
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function _retrieveData(){
|
||||
$sql = "SELECT o.*, os.value AS order_status_value
|
||||
FROM din_order o, din_order_status os
|
||||
WHERE o.id = $this->id " .
|
||||
"AND o.order_status_id = os.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Order: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
/*static*/
|
||||
function delete($id){
|
||||
$order = new Order($id);
|
||||
$order->setStatus(5);
|
||||
}
|
||||
|
||||
public
|
||||
function getItems() {
|
||||
$sql = "SELECT oi.id " .
|
||||
"FROM din_order_item oi " .
|
||||
"WHERE oi.order_id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public
|
||||
function calculateTotalAmount() {
|
||||
$items = $this->getItems();
|
||||
$amount = 0;
|
||||
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
$product = new Product($item->product_id);
|
||||
$amount = $amount + $item->quantity * $product->price;
|
||||
}
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public
|
||||
function display(){
|
||||
$items = $this->getItems();
|
||||
?>
|
||||
<div class="text-column">
|
||||
<h3>Din handlekurv</h3>
|
||||
<?php
|
||||
if (DB::isError($items) != true){
|
||||
if ($items->numRows() > 0){?>
|
||||
|
||||
<form action="index.php?page=display-cart" method="post" id="update-order-<?php print $this->id; ?>">
|
||||
<div><input type="hidden" name="action" value="update-cart" /></div>
|
||||
|
||||
<table class="sortable" id="cartcontent">
|
||||
<tr>
|
||||
<th>vare</th>
|
||||
<th>pris</th>
|
||||
<th>antall</th>
|
||||
</tr>
|
||||
<?php
|
||||
}else {
|
||||
print("Ingen varer er registrert.");
|
||||
}
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
$item->displayList();
|
||||
}
|
||||
?>
|
||||
<tr class="table-footer">
|
||||
<td>Sum:</td>
|
||||
<td colspan="2"><?php print formatPrice($this->calculateTotalAmount()); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Har du gjort endringer? <span class="button" onclick="document.getElementById('update-order-<?php print $this->id; ?>').submit();">oppdatér</span></p>
|
||||
</form>
|
||||
<p>Handle mer? <a class="button" href="index.php?page=display-webshop">tilbake til produkter</a></p>
|
||||
|
||||
<form action="index.php?action=cart-checkout" method="post">
|
||||
<div>
|
||||
<input type="hidden" name="order_id" value="<?php print $this->id; ?>" />
|
||||
<input type="hidden" name="transaction_id_string" value="<?php print createTransactionId(); ?>" /></div>
|
||||
<p>Er du ferdig? <a class="button" href="index.php?action=cart-checkout&order_id=<?php print $this->id; ?>&transaction_id_string=<?php print createTransactionId(); ?>">gå til betaling</a></p>
|
||||
</form>
|
||||
<?php
|
||||
}else {
|
||||
error("Items: " . $result->toString());
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function displayShortList($edit = false){
|
||||
$items = $this->getItems();
|
||||
?>
|
||||
<div class="text-column">
|
||||
<h3>Handlekurv #<?php print $this->id; ?></h3>
|
||||
<?php
|
||||
if (DB::isError($items) != true){
|
||||
?>
|
||||
<table class="sortable" id="cartcontent">
|
||||
<tr>
|
||||
<th>vare</th>
|
||||
<th>pris</th>
|
||||
<th>antall</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
$item->displayShortList();
|
||||
}
|
||||
?>
|
||||
<tr class="table-footer">
|
||||
<td>Sum:</td>
|
||||
<td colspan="2"><?php print formatPrice($this->calculateTotalAmount()); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Ordrestatus: <strong><?php print $this->order_status_value; ?></strong>
|
||||
<?php if ($edit && $this->order_status_id < 3) { ?>
|
||||
<p>
|
||||
<a class="button" href="index.php?page=display-cart&order_id=<?php print $this->id; ?>">rediger ordre</a>
|
||||
<a class="button" href="index.php?page=display-carts&action=delete-order&order_id=<?php print $this->id; ?>">slett ordre</a>
|
||||
<a class="button" href="index.php?action=cart-checkout&order_id=<?php print $this->id; ?>&transaction_id_string=<?php print createTransactionId(); ?>">gå til betaling</a>
|
||||
</p>
|
||||
<?php }
|
||||
}else {
|
||||
error("Items: " . $result->toString());
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function getConfirmationText() {
|
||||
$items = $this->getItems();
|
||||
$text = "";
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
$text .= $item->getConfirmationText();
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
public
|
||||
function displayConfirmation(){
|
||||
$items = $this->getItems();
|
||||
?>
|
||||
<?php
|
||||
if (DB::isError($items) != true){
|
||||
if ($items->numRows() > 0){?>
|
||||
|
||||
<table class="sortable" id="cartcontent">
|
||||
<tr>
|
||||
<th>vare</th>
|
||||
<th>pris</th>
|
||||
<th>antall</th>
|
||||
</tr>
|
||||
<?php
|
||||
}else {
|
||||
print("Ingen varer er registrert.");
|
||||
}
|
||||
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
$item->displayShortList();
|
||||
}
|
||||
?>
|
||||
<tr class="table-footer">
|
||||
<td>Sum:</td>
|
||||
<td colspan="2"><?php print formatPrice($this->calculateTotalAmount()); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}else {
|
||||
error("Items: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function performOperations() {
|
||||
$items = $this->getItems();
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
|
||||
if ($item->product_id == 1) {
|
||||
// new membership
|
||||
$user = new User($this->user_id);
|
||||
$cardno = $user->cardno;
|
||||
if ($cardno == NULL) {
|
||||
if (!$user->registerMembershipPayex()){
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(!$user->renewMembershipPayex()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif ($item->product_id == 12) {
|
||||
// send new membercard
|
||||
$user = new User($this->user_id);
|
||||
if (!$user->renewMembercardPayex()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class OrderItem {
|
||||
|
||||
var $id;
|
||||
var $product_id;
|
||||
var $quantity;
|
||||
var $order_id;
|
||||
var $discount;
|
||||
var $comment;
|
||||
|
||||
var $conn;
|
||||
|
||||
function OrderItem($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){// OrderItem
|
||||
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->product_id = $data['product_id'];
|
||||
$this->quantity = $data['quantity'];
|
||||
$this->order_id = $data['order_id'];
|
||||
$this->discount = $data['discount'];
|
||||
$this->comment = isset($data['comment']) ? $data['comment'] : '';
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_order_item");
|
||||
$sql = sprintf("INSERT INTO din_order_item
|
||||
(id, product_id, quantity, order_id, discount, comment)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->product_id),
|
||||
$this->conn->quoteSmart($this->quantity),
|
||||
$this->conn->quoteSmart($this->order_id),
|
||||
$this->conn->quoteSmart($this->discount),
|
||||
$this->conn->quoteSmart($this->comment)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Nytt ordreelement lagret.");
|
||||
}else {
|
||||
error("New order_item: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_order_item t
|
||||
WHERE t.id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("OrderItem: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function setQuantity($value) {
|
||||
$sql = "UPDATE din_order_item SET
|
||||
quantity = $value
|
||||
WHERE " .
|
||||
" id = $this->id";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Orderstatus oppdatert ($value)");
|
||||
}else {
|
||||
error("Set quantity - order_item: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function setComment($value) {
|
||||
$sql = "UPDATE din_order_item SET
|
||||
comment = '$value'
|
||||
WHERE " .
|
||||
" id = $this->id";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Orderstatus oppdatert ($value)");
|
||||
}else {
|
||||
error("Set comment - order_item: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
/*static*/
|
||||
function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_order_item
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($conn->affectedRows() > 0){
|
||||
//notify("Varen er slettet fra handlekurven.");
|
||||
}else {
|
||||
//notify("Ugyldig order_itemid, ingen handling utført.");
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
$product = new Product($this->product_id);
|
||||
?>
|
||||
<div class="text-column">
|
||||
<h3>Ordrebekreftelse</h3>
|
||||
<p>Ditt kjøp er gjennomført. På kontoutskriften din vil det stå Payex AS.</p>
|
||||
<p>Ordren har referansen #<?php print $this->id;?>.</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>produkt</th><th>pris</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?php print $product->title; ?></strong><br /><?php print $product->description; ?></td><td><?php print formatPrice($this->price); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>Du vil få tilsendt medlemskort i posten i løpet av 6-12 dager.</p>
|
||||
<p>Om du allerede har medlemskort vil du kun få tilsendt nytt oblat for inneværende år.</p>
|
||||
<p>For spørsmål vedrørende medlemskapet eller transaksjonen kan du kontakte <a href="mailto:support@studentersamfundet.no">support@studentersamfundet.no</a>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function displayList(){
|
||||
$product = new Product($this->product_id);
|
||||
?>
|
||||
<tr>
|
||||
<td><strong><?php print $product->title; ?></strong><br />
|
||||
<?php print prepareForHTML($product->description); ?><br />
|
||||
<?php if ($product->allow_comment == 1) { ?>
|
||||
<strong>Kommentar:</strong><br />
|
||||
<textarea name="ordercomment<?php print $this->id; ?>" cols="50" rows="2"><?php print prepareForHTML($this->comment); ?></textarea>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td><?php print formatPrice($product->price); ?></td>
|
||||
<td><input type="text" name="orderitem<?php print $this->id; ?>" size="2" value="<?php print $this->quantity; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function displayShortList(){
|
||||
$product = new Product($this->product_id);
|
||||
?>
|
||||
<tr>
|
||||
<td><?php print $product->title; ?></td>
|
||||
<td><?php print formatPrice($product->price); ?></td>
|
||||
<td><?php print $this->quantity; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function getConfirmationText() {
|
||||
$product = new Product($this->product_id);
|
||||
$text = $this->quantity . " " . $product->title . " á " . formatPrice($product->price) . "\n";
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class OrderStatuses {
|
||||
var $id;
|
||||
var $value;
|
||||
var $conn;
|
||||
|
||||
function OrderStatuses() {
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn =& db_connect();
|
||||
}
|
||||
|
||||
public
|
||||
function getList(){
|
||||
$sql = "SELECT * FROM din_order_status";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Payment {
|
||||
|
||||
var $id;
|
||||
var $user_email;
|
||||
var $payex;
|
||||
|
||||
public
|
||||
function __construct() {
|
||||
$this->initPayex();
|
||||
}
|
||||
|
||||
private function initPayex() {
|
||||
//From setupexample
|
||||
define('PAYEX_PXPARTNER_WSDL', 'https://external.payex.com/pxorder/pxpartner.asmx?WSDL');
|
||||
define('PAYEX_PXPRINT_WSDL', 'https://external.payex.com/pxorder/pxprint.asmx?WSDL');
|
||||
define('PAYEX_PXDEPOSIT_WSDL', 'https://external.payex.com/pxorder/pxdeposit.asmx?WSDL');
|
||||
define('PAYEX_PXACCOUNT_WSDL', 'https://external.payex.com/pxorder/pxaccount.asmx?WSDL');
|
||||
define('PAYEX_PXORDER_WSDL', 'https://external.payex.com/pxorder/pxorder.asmx?WSDL');
|
||||
define('PAYEX_PXCLIENT_WSDL', 'https://external.payex.com/pxclient/pxclient.asmx?WSDL');
|
||||
define('PAYEX_PXMERCHANT_WSDL', 'https://external.payex.com/pxmerchant/pxmerchant.asmx?WSDL');
|
||||
define('PAYEX_PXSUBSCRIPTION_WSDL', 'https://external.payex.com/pxsubscription/pxsubscription.asmx?WSDL');
|
||||
define('PAYEX_PXAGREEMENT_WSDL', 'https://external.payex.com/pxagreement/pxagreement.asmx?WSDL');
|
||||
|
||||
define('PAYEX_PXORDER_URL', 'https://account.payex.com/pxorder.asp'); // url to redirect user to
|
||||
define('PAYEX_ACCOUNTNUMBER', 20180218); // payex merchant account number
|
||||
define('PAYEX_ENCRYPTIONKEY', 'vy8wMAvJjvW4RaCEWJFf'); // payex encryption key
|
||||
// end setup
|
||||
require_once ('../payex2/payex_pxorder.php'); // Include the Payex PxOrder implementation
|
||||
$this->payex = new PayexPxOrder(); // Make an instance of the PayexPxOrder class
|
||||
|
||||
$this->user_email = false;
|
||||
|
||||
}
|
||||
|
||||
public function executeRedirect($transaction_id_string, $order_id){
|
||||
//init order
|
||||
$order = new Order($order_id);
|
||||
$this->amount = $order->calculateTotalAmount();
|
||||
if (Transaction :: isFreeIdString($transaction_id_string)) {
|
||||
$trans_data = Array("id_string" => $transaction_id_string,
|
||||
"user_id" => getCurrentUser(),
|
||||
"order_id" => $order_id,
|
||||
"status" => "PENDING",
|
||||
"amount" => $this->amount);
|
||||
$transaction = new Transaction(NULL, $trans_data);
|
||||
$transaction->store();
|
||||
$transaction_id = $transaction->id;
|
||||
}else {
|
||||
notify("Transaksjonen er allerede forsøkt gjennomført. Dette skyldes sannsynligvis at du har trykket to ganger på 'submit'-knappen.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// set the parameters for Initialize
|
||||
$purchaseOperation = 'SALE'; // 1-phased transaction
|
||||
$orderID = $transaction->id; //Order id, generated from database
|
||||
$productNumber = 'Handlevogn #'.$order->id; //Order id
|
||||
$price = $this->amount * 100;
|
||||
$priceArgList = 'VISA=%s,MC=%s'; // No CPA, VISA, MasterCard, SMS
|
||||
$priceArgList = sprintf($priceArgList, $price, $price);
|
||||
$description = "Kjøp fra Studentersamfundet.no";
|
||||
$returnURL = 'https://www.studentersamfundet.no/inside/index.php?action=transaction-return&transactionid='.$transaction_id; // ReturnURL
|
||||
|
||||
// Run Initialize. Check return-value
|
||||
if ( $this->payex->InitializeBasic(
|
||||
$purchaseOperation, $orderID, $productNumber, $priceArgList,
|
||||
$description, $returnURL) ) {
|
||||
$orderRef = $this->payex->getOrderRef(); // get the orderRef
|
||||
$this->payex->redirect($orderRef); // redirect the user
|
||||
} else {
|
||||
echo 'Initialize() failed.<br>';
|
||||
echo 'Code: '.$this->payex->getcode().' ';
|
||||
echo 'Description: '. $this->payex->getdescription().'<br>';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function completeTransaction($orderRef, $transaction_id) {
|
||||
if ( $this->payex->Complete($orderRef) ) {
|
||||
|
||||
/*
|
||||
Transaction statuses (defined in payex_defines.php):
|
||||
0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture
|
||||
*/
|
||||
//notify($this->payex->getTransactionStatus());
|
||||
if (!($this->payex->getTransactionStatus() == PAYEX_TRANSACTIONSTATUS_SALE ||
|
||||
$this->payex->getTransactionStatus() == PAYEX_TRANSACTIONSTATUS_CAPTURE) )
|
||||
{
|
||||
notify("Betalingen er ikke riktig gjennomført. Vennligst ta kontakt med support om du tror dette skyldes en feil.");
|
||||
return false;
|
||||
}
|
||||
|
||||
$transaction = new Transaction($transaction_id);
|
||||
$transaction->setStatus("OK");
|
||||
notify("Betalingen er gjennomført. En kvittering er blitt sendt til din registrerte epostadresse.");
|
||||
if (!$this->user_email) { // get user mail from current user
|
||||
$user = new User(getCurrentUser());
|
||||
$this->user_email = $user->email;
|
||||
}
|
||||
$this->_sendConfirmationMail($transaction_id);
|
||||
return true;
|
||||
}else {
|
||||
notify("Betalingen er ikke riktig gjennomført. Vennligst ta kontakt med support om du tror dette skyldes en feil.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function setUserEmail ($newmail) {
|
||||
$this->user_email = $newmail;
|
||||
}
|
||||
|
||||
public function _sendConfirmationMail ($transaction_id) {
|
||||
$sendto = $this->user_email;
|
||||
$transaction = new Transaction($transaction_id);
|
||||
$order = new Order($transaction->order_id);
|
||||
$subject = "=?iso8859-1?Q?[$transaction->id] Kvittering for kj=F8p p=E5 studentersamfundet.no?=";
|
||||
$message = "Hei!\n\n" .
|
||||
"Du har nettopp gjennomført et kjøp på studentersamfundet.no. Transaksjonen har referansen $transaction->id.\n\n" .
|
||||
"Du har kjøpt:\n" .
|
||||
$order->getConfirmationText()."\n" .
|
||||
"Prisen for dette er NOK $transaction->amount,-\n" .
|
||||
"Beløpet er blitt belastet ditt VISA-kort. På kontoutskriften vil det stå Payex AS.\n\n" .
|
||||
"For spørsmål angående dette kan du svare på denne eposten. Se forøvrig http://www.studentersamfundet.no/kontakt.php for ytterligere kontaktinformasjon.\n\n" .
|
||||
"Med vennlig hilsen\n" .
|
||||
"Det Norske Studentersamfund\n\n";
|
||||
$headers = "From: Det Norske Studentersamfund <support@studentersamfundet.no>\r\n";
|
||||
|
||||
mail($sendto, $subject, $message, $headers);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Payment {
|
||||
|
||||
var $id;
|
||||
var $conn;
|
||||
var $user_email;
|
||||
var $status;
|
||||
var $transaction_id;
|
||||
|
||||
function Payment($id = NULL, $data = NULL) {
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public
|
||||
function __construct($id = NULL, $data = NULL) {
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
$this->status = "FAILURE";
|
||||
|
||||
$product = new Product($data['productid']);
|
||||
if (Transaction :: isFreeIdString($data['transactionid'])) {
|
||||
$trans_data = Array("id_string" => $data['transactionid'],
|
||||
"user_id" => getCurrentUser(),
|
||||
"product_id" => $product->id,
|
||||
"status" => "PENDING");
|
||||
$transaction = new Transaction(NULL, $trans_data);
|
||||
$transaction->store();
|
||||
}else {
|
||||
notify("Transaksjonen er allerede gjennomført. Dette skyldes sannsynligvis at du har trykket to ganger på 'submit'-knappen.");
|
||||
return;
|
||||
}
|
||||
|
||||
$amount = $product->price * 100;
|
||||
|
||||
require_once ('../payex/payex_pxorder.php'); // Include the Payex PxOrder implementation
|
||||
|
||||
$payex = new PayexPxOrder(); // Make an instance of the PayexPxOrder class
|
||||
|
||||
$enc_key = PAYEX_ENCRYPTIONKEY;
|
||||
|
||||
$accountNumber = PAYEX_ACCOUNTNUMBER; //Our merchant id
|
||||
$purchaseOperation = "SALE"; //Type of pruchase, always SALE
|
||||
$orderID = $transaction->id; //Order id, generated from database
|
||||
|
||||
$productNumber = $product->id; //Product id
|
||||
$priceArgList = "VISA=$amount"; //Price list, as of now only VISA is supported
|
||||
$descripion = $product->description;
|
||||
$returnURL = "https://www.studentersamfundet.no/inside/index.php?page=payex-form";
|
||||
|
||||
$payex->InitializeBasic($purchaseOperation, $orderID, $productNumber, $priceArgList, $descripion, $returnURL);
|
||||
|
||||
if ($payex->code == 'OK') {
|
||||
//notify("Kontakt med betalingsserver er etablert.");
|
||||
}else {
|
||||
notify("Problemer med å oppnå kontakt med betalingsserver, vennligst prøv igjen senere.");
|
||||
return;
|
||||
}
|
||||
|
||||
$orderRef = $payex->orderRef;
|
||||
$userType = PAYEX_USERTYPE_EMAIL;
|
||||
$user = new User(getCurrentUser());
|
||||
$userRef = $user->email;
|
||||
$cardNumber = $data['cardNumber']; //test: "4925000000000004";
|
||||
$cardNumberExpireMonth = $data['cardNumberExpireMonth']; //test: "08";
|
||||
$cardNumberExpireYear = $data['cardNumberExpireYear']; //test: "08";
|
||||
$cardNumberCVC = $data['cardNumberCVC']; //test: "123";
|
||||
|
||||
//SaleCC for direct creditcard
|
||||
$payex->SaleCC($orderRef, $userType, $userRef, $cardNumber, $cardNumberExpireMonth, $cardNumberExpireYear, $cardNumberCVC);
|
||||
|
||||
if ($payex->code == 'OK') {
|
||||
$this->status = "OK";
|
||||
$this->transaction_id = $transaction->id;
|
||||
$transaction->setStatus("OK");
|
||||
notify("Betalingen er gjennomført. En kvittering er blitt sendt til din registrerte epostadresse.");
|
||||
$this->user_email = $userRef;
|
||||
$this->_sendConfirmationMail();
|
||||
}else {
|
||||
$transaction->setStatus("FAILURE");
|
||||
error("Teknisk kode: " . $payex->getCode() . " - ". $payex->getDescription());
|
||||
notify("Problemer med betaling. Vennligst påse at du har tastet inn riktig VISA-informasjon.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _sendConfirmationMail () {
|
||||
$sendto = $this->user_email;
|
||||
$transaction = new Transaction($this->transaction_id);
|
||||
$product = new Product($transaction->product_id);
|
||||
$subject = "[$transaction->id]Kvittering for kjøp på studentersamfundet.no";
|
||||
$message = "Hei!\n\n" .
|
||||
"Du har nettopp gjennomført et kjøp på studentersamfundet.no. Ordren har referansen $transaction->id.\n\n" .
|
||||
"Du har kjøpt:\n" .
|
||||
"$product->title\n" .
|
||||
"$product->description\n\n" .
|
||||
"Prisen for dette er NOK $product->price,-\n" .
|
||||
"Beløpet er blitt belastet ditt VISA-kort. På kontoutskriften vil det stå Payex AS.\n\n" .
|
||||
"For spørsmål angående dette kan du svare på denne eposten. Se forøvrig http://www.studentersamfundet.no/kontakt.php for ytterligere kontaktinformasjon.\n\n";
|
||||
$headers = 'From: Det Norske Studentersamfund <support@studentersamfundet.no>'."\r\n";
|
||||
mail($sendto, $subject, $message, $headers);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
class PlacesOfStudy {
|
||||
var $users;
|
||||
var $conn;
|
||||
|
||||
function PlacesOfStudy(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = DB_connect("dns");
|
||||
|
||||
$minId = 1;
|
||||
if (loggedIn()){
|
||||
$user = new User(getCurrentUser());
|
||||
if ($user->placeOfStudy == 1){
|
||||
$minId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT id, navn AS name " .
|
||||
"FROM studiesteder " .
|
||||
"WHERE id > $minId " .
|
||||
"ORDER BY name ASC";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->users = $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
public function displayList($limit = 25){
|
||||
if ($this->users->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="userlist">
|
||||
<tr>
|
||||
<th>id</th>
|
||||
<th>navn</th>
|
||||
<th colspan="2"> </th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->users->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=display-user&userid=<?php print $row->userId; ?>">
|
||||
<?php print $row->userId; ?></a></td>
|
||||
<td><a href="index.php?page=display-user&userid=<?php print $row->userId; ?>">
|
||||
<?php print $row->name; ?></a></td>
|
||||
<?php displayOptionsMenuTable($row->userId, "user"); ?>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen medlemmer registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Position {
|
||||
|
||||
var $id;
|
||||
var $name;
|
||||
var $text;
|
||||
var $division_id;
|
||||
var $division_name;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Position($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New position
|
||||
if ($data == NULL){
|
||||
error("Position: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->division_name = $data['division_name'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->name = $data['name'];
|
||||
$this->text = $data['text'];
|
||||
$this->division_id = $data['division_id'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$sql = sprintf("INSERT INTO din_position
|
||||
(id, name, text, division_id)
|
||||
VALUES
|
||||
(%s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->division_id)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Stillingen <strong>$this->name</strong> er registrert.");
|
||||
}else {
|
||||
error("New position: " . $result->toString());
|
||||
}
|
||||
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_position SET
|
||||
name = %s,
|
||||
text = %s,
|
||||
division_id = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->division_id),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify(POSITION . " " . UPDATED);
|
||||
}else {
|
||||
error("Update position: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT p.*, d.name AS division_name
|
||||
FROM din_position p, din_division d
|
||||
WHERE p.id = $this->id
|
||||
AND p.division_id = d.id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Position: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_position
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//if ($result->affectedRows() > 0){
|
||||
notify("Position deleted.");
|
||||
// }else {
|
||||
//notify("Position: invalid id.");
|
||||
// }
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
$ads = $this->_getCurrentAds();
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, POSITION, "position", "view-edit-options-position");
|
||||
?>
|
||||
<h3><?php print $this->name; ?> i <?php print $this->division_name; ?></h3>
|
||||
|
||||
<p><?php print prepareForHTML($this->text); ?></p>
|
||||
<?php
|
||||
if ($ads->numRows() > 0){?>
|
||||
<h4>Denne stillingen er for øyeblikket utlyst:</h4>
|
||||
<ul>
|
||||
<?php
|
||||
while ($row =& $ads->fetchRow(DB_FETCHMODE_OBJECT)){?>
|
||||
<li>
|
||||
<a href="index.php?page=display-job&jobid=<?php print $row->id; ?>">
|
||||
Søknadsfrist <?php print(formatDatetime($row->expires)); ?></a>
|
||||
</li>
|
||||
<?php
|
||||
}?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=display-division&divisionid=<?php print $this->division_id; ?>"><?php print $this->division_name; ?></a></td>
|
||||
<td><a href="index.php?page=display-position&positionid=<?php print $this->id; ?>"><?php print $this->name; ?></a></td>
|
||||
<?php displayOptionsMenuTable($this->id, POSITION, "position", "view-edit-options-position"); ?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function _getCurrentAds(){
|
||||
$sql = "SELECT j.id, j.expires
|
||||
FROM din_job j
|
||||
WHERE j.position_id = $this->id
|
||||
AND j.expires > NOW()";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
}else {
|
||||
error("Position: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
class Positions {
|
||||
var $conn;
|
||||
|
||||
function Positions() {
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getList($division = NULL){
|
||||
if ($division != NULL){
|
||||
$condition = "AND p.division_id = $division";
|
||||
}else {
|
||||
$condition = "";
|
||||
}
|
||||
$sql = "SELECT d.id AS divId, d.name AS divName, p.id AS positionId, p.name AS positionName " .
|
||||
"FROM din_position p, din_division d " .
|
||||
"WHERE p.division_id = d.id " .
|
||||
"$condition" .
|
||||
"ORDER BY d.name ASC";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
} else {
|
||||
error("Positions: " . $result->toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getPositionsAsArray(){
|
||||
if ($list = $this->getPositions()){
|
||||
$pos = Array();
|
||||
while ($row =& $list->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$div = $row['divId'];
|
||||
|
||||
$pos[] = Array("id" => $row['positionId'],
|
||||
"title" => $row['positionName'],
|
||||
"parent" => $row['positionDivId']);
|
||||
}
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList($division){
|
||||
$sql = "SELECT p.id FROM din_position p, din_division d " .
|
||||
"WHERE p.division_id = d.id " .
|
||||
"AND p.division_id = $division " .
|
||||
"ORDER BY d.name ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if($result->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="positionlist">
|
||||
<tr>
|
||||
<th>forening</th>
|
||||
<th>stilling</th>
|
||||
<?php if(checkAuth("view-edit-options-position")){
|
||||
?><th colspan="2"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$position = new Position($row['id']);
|
||||
$position->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {?>
|
||||
<p>Ingen stillingsbeskrivelser er registrert ennå.</p>
|
||||
<?php
|
||||
}
|
||||
}else {
|
||||
error("Positions: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Product {
|
||||
|
||||
var $id;
|
||||
var $title;
|
||||
var $description;
|
||||
var $price;
|
||||
var $allow_comment;
|
||||
var $display_in_shop;
|
||||
var $picture;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Product($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New division
|
||||
if ($data == NULL){
|
||||
error("Product: No data supplied.");
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
if($_FILES['userfile']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['userfile'], 'products');
|
||||
rename_file($temp_name, $this->id, 'products');
|
||||
$this->picture = $this->id.substr($temp_name, -4);
|
||||
}else {
|
||||
$this->picture = 0;
|
||||
}
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->picture = $data['picture'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->title = $data['title'];
|
||||
$this->description = $data['description'];
|
||||
$this->price = $data['price'];
|
||||
$this->allow_comment = $data['allow_comment'];
|
||||
$this->display_in_shop = $data['display_in_shop'];
|
||||
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_product");
|
||||
$sql = sprintf("INSERT INTO din_product
|
||||
(id, title, description, price, allow_comment, display_in_shop)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->description),
|
||||
$this->conn->quoteSmart($this->price),
|
||||
$this->conn->quoteSmart($this->allow_comment),
|
||||
$this->conn->quoteSmart($this->display_in_shop)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if($_FILES['userfile']['error'] != 4){
|
||||
$temp_name = new_file($_FILES['userfile'], 'products');
|
||||
rename_file($temp_name, $this->id, 'products');
|
||||
$this->picture = $this->id.substr($temp_name, -4);
|
||||
}else {
|
||||
$this->picture = 0;
|
||||
}
|
||||
|
||||
$this->_storeFilenames();
|
||||
notify("Nytt produkt lagret.");
|
||||
}else {
|
||||
error("New product: " . $result->toString());
|
||||
}
|
||||
|
||||
}else {
|
||||
$sql = sprintf("UPDATE din_product SET
|
||||
title = %s,
|
||||
description = %s,
|
||||
price = %s,
|
||||
allow_comment = %s,
|
||||
display_in_shop = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->title),
|
||||
$this->conn->quoteSmart($this->description),
|
||||
$this->conn->quoteSmart($this->price),
|
||||
$this->conn->quoteSmart($this->allow_comment),
|
||||
$this->conn->quoteSmart($this->display_in_shop),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->_storeFilenames();
|
||||
notify("Produkt oppdatert.");
|
||||
}else {
|
||||
notify("Problemer med lagring av produkt. Ingen endringer utført.");
|
||||
error("Update product: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _storeFilenames() {
|
||||
if ($this->picture != 0) {
|
||||
$sql = "UPDATE din_product ";
|
||||
$sql .= "SET picture = '$this->picture' ";
|
||||
$sql .= "WHERE id = $this->id";
|
||||
$result = $this->conn->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT * ";
|
||||
$sql .= "FROM din_product p ";
|
||||
$sql .= "WHERE p.id = $this->id";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true) {
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)) {
|
||||
return $row;
|
||||
}
|
||||
} else {
|
||||
error("Product: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_product ";
|
||||
$sql .= "WHERE id = $id ";
|
||||
$sql .= "LIMIT 1";
|
||||
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true) {
|
||||
if ($conn->affectedRows() > 0) {
|
||||
notify("Produktet er slettet.");
|
||||
} else {
|
||||
notify("Ugyldig produktid, ingen handling utført.");
|
||||
}
|
||||
} else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
// return number of sold items
|
||||
public function getNumSold() {
|
||||
$sql = "SELECT SUM(oi.quantity) AS num ";
|
||||
$sql .= "FROM din_product p, din_order_item oi, din_order o ";
|
||||
$sql .= "WHERE oi.product_id = p.id AND oi.order_id = o.id AND o.order_status_id = 4 AND p.id = $this->id";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true) {
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)) {
|
||||
if ($row['num'] > 0) return $row['num'];
|
||||
else return 0;
|
||||
}
|
||||
} else {
|
||||
error("Product: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
// is it in shop ?
|
||||
public function getDisplay() {
|
||||
if ($this->display_in_shop) return "Ja";
|
||||
return "Nei";
|
||||
}
|
||||
|
||||
// return number of items not marked as delivered
|
||||
public function getNumNew(){
|
||||
$sql = "SELECT COUNT(*) AS num ";
|
||||
$sql .= "FROM din_product p, din_order_item oi, din_order o ";
|
||||
$sql .= "WHERE oi.product_id = p.id AND oi.order_id = o.id AND o.order_status_id = 4 AND p.id = $this->id AND order_deliverystatus_id='0'";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true) {
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)) {
|
||||
return $row['num'];
|
||||
}
|
||||
} else {
|
||||
error("Product: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="product">
|
||||
<?php
|
||||
if ($this->picture != 0){
|
||||
print('<div class="product_images">');
|
||||
print('<img src="imageResize.php?pic=images/products/'.$this->picture.'&maxwidth=200" alt="" />');
|
||||
print('</div>');
|
||||
}
|
||||
?>
|
||||
<h4><?php print $this->title; ?></h4>
|
||||
<p><?php print prepareForHTML($this->description); ?></p>
|
||||
<p><strong>Pris:</strong> <?php print formatPrice($this->price); ?></p>
|
||||
<div class="clear-right"></div>
|
||||
<?php
|
||||
|
||||
|
||||
$order_id = scriptParam("order_id");
|
||||
if (!is_numeric($order_id )){
|
||||
$order_id = NULL;
|
||||
}
|
||||
|
||||
$title = "legg i handlekurv";
|
||||
$enctype = NULL;
|
||||
$method = "post";
|
||||
$action = "index.php?action=cart-add-product&page=display-cart";
|
||||
$fields = Array();
|
||||
|
||||
$fields[] = Array("label" => "", "type" => "cart_product",
|
||||
"attributes" => Array("name" => "cart_product", "product_id" => $this->id, "order_id" => $order_id, "allow_comment" => $this->allow_comment));
|
||||
$form = new Form($title, $enctype, $method, $action, $fields);
|
||||
$form->display("horizontal");
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayListShop(){
|
||||
?>
|
||||
<div class="product" onclick="window.location='index.php?page=display-product&productid=<?php print $this->id; ?>'">
|
||||
<?php
|
||||
if ($this->picture != 0){
|
||||
print('<div class="product_images">');
|
||||
print('<img src="imageResize.php?pic=images/products/'.$this->picture.'&maxheight=100" alt="" />');
|
||||
print('</div>');
|
||||
}
|
||||
?>
|
||||
<h4><?php print $this->title; ?></h4>
|
||||
<p><strong>Pris:</strong> <?php print formatPrice($this->price); ?></p>
|
||||
<div class="clear-right"></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
if (checkAuth('view-edit-product')) {
|
||||
$page = 'edit-product';
|
||||
}else {
|
||||
$page = 'display-sales-item';
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=<?php print $page; ?>&productid=<?php print $this->id; ?>"><?php print $this->title; ?></a></td>
|
||||
<td><?php print prepareForHTML($this->description); ?></td>
|
||||
<td><?php print formatPrice($this->price); ?></td>
|
||||
<td align="center"><?php print $this->getDisplay();?></td>
|
||||
<td align="right"><?php print $this->getNumSold(); ?></td>
|
||||
<td align="right"><?php print $this->getNumNew(); ?></td>
|
||||
<?php displayOptionsMenuTable($this->id, PRODUCT, "product", "view-edit-options-product"); ?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayBuyers() {
|
||||
$sql = "SELECT o.id AS order_id, u.id, oi.quantity, t.timestamp, oi.comment, o.order_deliverystatus_id
|
||||
FROM din_user u, din_product p, din_order o, din_order_item oi, din_transaction t
|
||||
WHERE u.id = o.user_id
|
||||
AND oi.order_id = o.id
|
||||
AND oi.product_id = p.id
|
||||
AND o.order_status_id = 4 AND t.order_id = o.id
|
||||
AND t.status = 'OK' " .
|
||||
"AND p.id = $this->id";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) == true){
|
||||
notify('Liste over kjøpere er ikke tilgjengelig.');
|
||||
error('List buyers: ' . $result->toString());
|
||||
}
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>kjøper</th>
|
||||
<th>antall</th>
|
||||
<th>status</th>
|
||||
<th>endre status</th>
|
||||
<th>dato</th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$user = new User($row['id']);
|
||||
?>
|
||||
<tr>
|
||||
<td><?php print $row['order_id']; ?></td>
|
||||
<td><a href="index.php?page=display-user&userid=<?php print $user->id; ?>"><?php print $user->getName(); ?></a><br />
|
||||
<?php print prepareForHTML($row['comment']); ?></td>
|
||||
<td><?php print $row['quantity']; ?></td>
|
||||
<td id="order_<?php print $row['order_id']?>_deliverystatus"><?php
|
||||
if ($row['order_deliverystatus_id'] == '1') {
|
||||
print 'levert';
|
||||
} else {
|
||||
print 'ikke levert';
|
||||
}
|
||||
?></td>
|
||||
<td>
|
||||
<form id="order_<?php print $row['order_id']?>_update_form" action="javascript: setOrderDeliveryStatus('<?php print $row['order_id']; ?>')" method="get">
|
||||
<input type="hidden" name="action" value="update-order-deliverystate" />
|
||||
<select name="newDeliveryStatus_<?php print $row['order_id']; ?>" id="newDeliveryStatus_<?php print $row['order_id']; ?>">
|
||||
<option value="0">ikke levert</option>
|
||||
<option value="1" selected>levert</option>
|
||||
</select>
|
||||
<input type="submit" value="endre" />
|
||||
</form>
|
||||
</td>
|
||||
<td class="date"><?php print formatDatetimeYearShort($row['timestamp']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
class Products {
|
||||
var $conn;
|
||||
|
||||
function Products() {
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
$sql = "SELECT p.id, p.title " .
|
||||
"FROM din_product d";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
} else {
|
||||
error("Products: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
$sql = "SELECT id FROM din_product
|
||||
ORDER BY title ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
|
||||
displayOptionsMenu($row['id'], "product");
|
||||
$product = new Product($row['id']);
|
||||
$product->display();
|
||||
}
|
||||
}else {
|
||||
error("Products: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
$sql = "SELECT id FROM din_product
|
||||
ORDER BY display_in_shop DESC, title ASC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){?>
|
||||
<table class="sortable" id="productlist">
|
||||
<tr>
|
||||
<th>produktnavn</th>
|
||||
<th>beskrivelse</th>
|
||||
<th>pris</th>
|
||||
<th>aktiv</th>
|
||||
<th>solgt</th>
|
||||
<th>nye</th>
|
||||
<?php if(checkAuth("view-edit-options-product")){
|
||||
?><th colspan="2"></th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$product = new Product($row['id']);
|
||||
$product->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
} else {
|
||||
error("Products: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function displayShopProducts(){
|
||||
$sql = "SELECT id FROM din_product WHERE display_in_shop = 1
|
||||
ORDER BY id DESC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){?>
|
||||
<div class="text-column">
|
||||
<h2>Produkter tilgjengelig for kjøp:</h2>
|
||||
<?php
|
||||
|
||||
// Vis varen medlemskap hvis brukeren ikke har gyldig medlemskap
|
||||
if (membershipExpired(getCurrentUser())){
|
||||
$product = new Product(1);
|
||||
$product->displayListShop();
|
||||
} else {
|
||||
$product = new Product(12);
|
||||
$product->displayListShop();
|
||||
}
|
||||
|
||||
// List opp produkter
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$product = new Product($row['id']);
|
||||
$product->displayListShop();
|
||||
}
|
||||
|
||||
?></div><?php
|
||||
} else {
|
||||
error("Products: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class ProgramSelection {
|
||||
|
||||
var $id;
|
||||
var $pretext;
|
||||
var $start;
|
||||
var $end;
|
||||
var $type;
|
||||
|
||||
var $conn;
|
||||
|
||||
function ProgramSelection($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New ProgramSelection
|
||||
if ($data == NULL){
|
||||
error("ProgramSelection: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
|
||||
//Common initializations
|
||||
$this->start = $data['start'];
|
||||
$this->end = $data['end'];
|
||||
$this->pretext = ($data['pretext'] == NULL)? '' : $data['pretext'];
|
||||
$this->type = $data['type'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$sql = sprintf("INSERT INTO programselection
|
||||
(id, pretext, start, end, type)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->pretext),
|
||||
$this->conn->quoteSmart($this->start),
|
||||
$this->conn->quoteSmart($this->end),
|
||||
$this->conn->quoteSmart($this->type)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Programutvalg er registrert.");
|
||||
}else {
|
||||
error("New ProgramSelection: " . $result->toString());
|
||||
}
|
||||
}else {
|
||||
$sql = sprintf("UPDATE programselection SET " .
|
||||
" pretext = %s, " .
|
||||
" start = %s, " .
|
||||
" end = %s, " .
|
||||
" type = %s " .
|
||||
"WHERE " .
|
||||
" id = %s",
|
||||
$this->conn->quoteSmart($this->pretext),
|
||||
$this->conn->quoteSmart($this->start),
|
||||
$this->conn->quoteSmart($this->end),
|
||||
$this->conn->quoteSmart($this->type),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Programutvalg er oppdatert.");
|
||||
}else {
|
||||
error("Update ProgramSelection: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM programselection
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("ProgramSelection: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM programselection
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//if ($result->affectedRows() > 0){
|
||||
notify("ProgramSelection deleted.");
|
||||
// }else {
|
||||
//notify("ProgramSelection: invalid id.");
|
||||
// }
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, PROGRAMSELECTION, "program selection", "view-edit-options-programselection");
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td>#<?php print $this->id; ?></td>
|
||||
<td><?php print $this->start;?></td>
|
||||
<td><?php print $this->end;?></td>
|
||||
<td><?php print $this->type;?></td>
|
||||
<td><a href="index.php?page=edit-program-selection&programselectionid=<?php print $this->id;?>">endre</a></td>
|
||||
<td><a href="programutvalg.php?id=<?php print $this->id; ?>&mode=view">vis html</a></td>
|
||||
<td><a href="programutvalgtekst.php?id=<?php print $this->id; ?>">vis tekst</a></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
class ProgramsSelection {
|
||||
var $conn;
|
||||
|
||||
function ProgramsSelection($limit = 5) {
|
||||
$this->__construct($limit);
|
||||
}
|
||||
|
||||
function __construct($limit = 5){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function display(){
|
||||
$sql = "SELECT id FROM programselection
|
||||
ORDER BY id DESC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$programselection = new ProgramSelection($row->id);
|
||||
$programselection->display();
|
||||
}
|
||||
}else {
|
||||
error("ProgramsSelection: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
$sql = "SELECT id FROM programselection " .
|
||||
"ORDER BY id DESC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if($result->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="programselectionlist">
|
||||
<tr>
|
||||
<th>id</th>
|
||||
<th>fra</th>
|
||||
<th>til</th>
|
||||
<th>type</th>
|
||||
<th colspan="3"> </th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$programselection = new ProgramSelection($row->id);
|
||||
$programselection->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {?>
|
||||
<p>Ingen programutvalg er registrert ennå.</p>
|
||||
<?php
|
||||
}
|
||||
}else {
|
||||
error("ProgramsSelection: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class Transaction {
|
||||
|
||||
var $id;
|
||||
var $id_string;
|
||||
var $user_id;
|
||||
var $order_id;
|
||||
var $timestamp;
|
||||
var $status;
|
||||
var $amount;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Transaction($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){// Transaction
|
||||
if ($data == NULL){
|
||||
error("Transaction: No data supplied.");
|
||||
return;
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->timestamp = $data['timestamp'];
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->id_string = $data['id_string'];
|
||||
$this->user_id = $data['user_id'];
|
||||
$this->order_id = $data['order_id'];
|
||||
$this->status = $data['status'];
|
||||
$this->amount = $data['amount'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_transaction");
|
||||
$sql = sprintf("INSERT INTO din_transaction
|
||||
(id, id_string, user_id, order_id, timestamp, status, amount)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, NOW(), %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->id_string),
|
||||
$this->conn->quoteSmart($this->user_id),
|
||||
$this->conn->quoteSmart($this->order_id),
|
||||
$this->conn->quoteSmart($this->status),
|
||||
$this->conn->quoteSmart($this->amount)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Ny transaksjon lagret.");
|
||||
}else {
|
||||
error("New transaction: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function setStatus($value) {
|
||||
$sql = "UPDATE din_transaction SET
|
||||
status = '$value'
|
||||
WHERE " .
|
||||
" id = $this->id";
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Transaksjonsstatus oppdatert ($value)");
|
||||
}else {
|
||||
error("Set status - transaction: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_transaction t
|
||||
WHERE t.id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("Transaction: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
/*static*/
|
||||
function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_transaction
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($conn->affectedRows() > 0){
|
||||
notify("Transaksjonen er slettet.");
|
||||
}else {
|
||||
notify("Ugyldig transaksjonsid, ingen handling utført.");
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
/*static*/
|
||||
function isFreeIdString($string) {
|
||||
$conn = db_connect();
|
||||
$sql = "SELECT id FROM din_transaction
|
||||
WHERE id_string = '$string'";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($result->numRows() == 0){
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public
|
||||
function displayConfirmation() {
|
||||
$order = new Order($this->order_id);
|
||||
?>
|
||||
<h3>Følgende bestilling er registrert og belastet ditt VISA-kort:</h3>
|
||||
<p>Transaksjonen har referansen <strong><?php print $this->id; ?></strong>.</p>
|
||||
<?php
|
||||
$order->displayConfirmation();
|
||||
?>
|
||||
|
||||
<p>På kontoutskriften vil det stå Payex AS.</p>
|
||||
<p>For spørsmål angående dette kan du kontakte <a href="mailto:support@studentersamfundet.no">support@studentersamfundet.no</a>.</p>
|
||||
<p>Se forøvrig <a href="http://www.studentersamfundet.no/kontakt.php">våre kontaktsider</a> for ytterligere kontaktinformasjon.</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class UserGroupRelationship {
|
||||
|
||||
var $user_id;
|
||||
var $user_name;
|
||||
var $group_id;
|
||||
var $group_name;
|
||||
|
||||
var $conn;
|
||||
|
||||
function UserGroupRelationship($user_id = NULL, $group_id = NULL) {
|
||||
$this->__construct($user_id, $group_id);
|
||||
}
|
||||
|
||||
public
|
||||
function __construct($user_id = NULL, $group_id = NULL) {
|
||||
|
||||
$conn = & DB :: connect(getDSN());
|
||||
if (DB :: isError($conn)) {
|
||||
print ("error: ".$conn->toString());
|
||||
exit ();
|
||||
} else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
$this->user_id = $user_id;
|
||||
$this->group_id = $group_id;
|
||||
$action = scriptParam("action");
|
||||
|
||||
$data = $this->_retrieveData();
|
||||
$this->user_name = $data['username'];
|
||||
$this->group_name = $data['name'];
|
||||
}
|
||||
|
||||
public
|
||||
function store() {
|
||||
$sql = sprintf("INSERT INTO din_usergrouprelationship "." (user_id, group_id) "."VALUES "." (%s, %s)", $this->conn->quoteSmart($this->user_id), $this->conn->quoteSmart($this->group_id));
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB :: isError($result) != true) {
|
||||
$user = new User($this->user_id);
|
||||
$group = new Group($this->group_id);
|
||||
notify("Bruker <strong>$user->firstname $user->lastname</strong>"." registrert i gruppen <strong>$group->name</strong>.");
|
||||
$this->_checkActive();
|
||||
$this->_checkMod();
|
||||
subscribe_mailinglist($this->user_id, $this->group_id);
|
||||
} else
|
||||
if ($result->getCode() == -5) {
|
||||
notify("<strong>$this->user_name</strong> er allerede medlem i gruppen <strong>$this->group_name</strong>.");
|
||||
} else {
|
||||
notify("Problem med registrering av gruppemedlemskap.");
|
||||
error("Register user in group: ".$result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _retrieveData() {
|
||||
$sql = "SELECT CONCAT(u.firstname, ' ', u.lastname) AS username, g.name
|
||||
FROM din_usergrouprelationship ugr, din_user u, din_group g
|
||||
WHERE ugr.user_id = $this->user_id
|
||||
AND ugr.group_id = $this->group_id
|
||||
AND ugr.user_id = u.id
|
||||
AND ugr.group_id = g.id";
|
||||
$result = & $this->conn->query($sql);
|
||||
if (DB :: isError($result) != true) {
|
||||
if ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC)) {
|
||||
return $row;
|
||||
}
|
||||
} else {
|
||||
error("UserGroupRelationships: ".$result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function delete($user_id, $group_id) {
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_usergrouprelationship
|
||||
WHERE user_id = $user_id
|
||||
AND group_id = $group_id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB :: isError($result) != true) {
|
||||
notify("Gruppemedlemskap slettet.");
|
||||
unsubscribe_mailinglist($user_id, $group_id);
|
||||
|
||||
//Update moderator status
|
||||
$group = new Group($group_id);
|
||||
if ($group->admin == 1) {
|
||||
$sql = "SELECT * "."FROM din_group g, din_usergrouprelationship ugr "."WHERE ugr.user_id = $user_id "."AND ugr.group_id = g.id "."AND g.admin = 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB :: isError($result) != true) {
|
||||
if ($result->numRows() == 0) {
|
||||
UserGroupRelationship :: delete($user_id, 61);
|
||||
}
|
||||
} else {
|
||||
error("UserGroupRelationships - admin: ".$result->toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function displayList() {
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="index.php?page=display-user&userid=<?php print $this->user_id; ?>"><?php print $this->user_name; ?></a></td>
|
||||
<td><?php print "$this->group_name"; ?></td>
|
||||
<?php
|
||||
|
||||
|
||||
if ($this->group_id != 1) {
|
||||
displayOptionsMenuTable(Array("user_id" => $this->user_id, "group_id" => $this->group_id), USERGROUPRELATIONSHIP, "usergrouprelationship", "view-edit-options-usergrouprelationship", false);
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function _checkActive() {
|
||||
if ($this->group_id > 2) {
|
||||
$sql = "SELECT * "."FROM din_usergrouprelationship ugr "."WHERE ugr.user_id = $this->user_id "."AND ugr.group_id = 2";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB :: isError($result) != true) {
|
||||
if ($result->numRows() == 0) {
|
||||
$newRel = new UserGroupRelationship($this->user_id, 2);
|
||||
$newRel->store();
|
||||
}
|
||||
} else {
|
||||
error("UserGroupRelationships - admin: ".$result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function _checkMod() {
|
||||
$group = new Group($this->group_id);
|
||||
if ($group->admin == 1) {
|
||||
$sql = "SELECT * "."FROM din_usergrouprelationship ugr "."WHERE ugr.user_id = $this->user_id "."AND ugr.group_id = 61";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB :: isError($result) != true) {
|
||||
if ($result->numRows() == 0) {
|
||||
$newRel = new UserGroupRelationship($this->user_id, 61);
|
||||
$newRel->store();
|
||||
}
|
||||
} else {
|
||||
error("UserGroupRelationships - admin: ".$result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
class UserGroupRelationships {
|
||||
var $relations;
|
||||
var $conn;
|
||||
|
||||
function UserGroupRelationships(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function __construct(){
|
||||
$conn =& DB::connect(getDSN());
|
||||
if (DB::isError($conn)){
|
||||
error("UserGroupRelationships: " . $conn->toString());
|
||||
exit();
|
||||
}else {
|
||||
$this->conn = $conn;
|
||||
}
|
||||
}
|
||||
|
||||
public function getJoinedList($group_id, $type = "array"){
|
||||
$sql = "SELECT ugr.group_id, g.name, u.id, u.username
|
||||
FROM din_group g, din_user a LEFT JOIN din_usergrouprelationship ugr
|
||||
ON u.user_id = ugr.user_id
|
||||
AND ugr.group_id = $group_id
|
||||
WHERE g.id = $group_id
|
||||
ORDER BY u.firstname, u.lastname";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$list = Array();
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$list["names"][] = $row->user_id;
|
||||
$list["labels"][] = $row->userName;
|
||||
$list["checked"][] = ($row->group_id == NULL) ? false : true;
|
||||
}
|
||||
return $list;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function getList($group, $limit){
|
||||
$sql = "SELECT user_id, group_id
|
||||
FROM din_usergrouprelationship
|
||||
WHERE group_id = $group
|
||||
LIMIT $limit";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->relations = $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return $this->relations;
|
||||
}
|
||||
|
||||
public function displayList($group = 2, $limit = 25){
|
||||
$this->getList($group, $limit);
|
||||
if ($this->relations->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="usergrouprelationgships">
|
||||
<tr>
|
||||
<th>medlem</th>
|
||||
<th>gruppe</th>
|
||||
<?php if(checkAuth("view-edit-options-usergrouprelationship") && $group != 1){
|
||||
?><th></th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->relations->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$rel = new UserGroupRelationship($row->user_id, $row->group_id);
|
||||
$rel->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen gruppemedlemmer er registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,557 @@
|
||||
<?php
|
||||
|
||||
class Users {
|
||||
var $users;
|
||||
var $conn;
|
||||
|
||||
function Users(){
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function __construct(){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getList($selection = 2, $limit = -1, $search = false, $addressStatus = -1){
|
||||
if ($limit > 0){
|
||||
$limit = "LIMIT $limit";
|
||||
}else {
|
||||
$limit = "";
|
||||
}
|
||||
// If addressstatus != -1, limit to a certain value of valid_address field
|
||||
if (!isset($addressStatus)) $addressStatus = -1;
|
||||
if ($addressStatus == 10) {
|
||||
$sqladdresslimit = "AND u.valid_address > 0 ";
|
||||
} elseif ($addressStatus >= 0) {
|
||||
$sqladdresslimit = "AND u.valid_address = $addressStatus ";
|
||||
} else {
|
||||
$sqladdresslimit = "";
|
||||
}
|
||||
|
||||
if ($search != true){
|
||||
if ($selection < 0){
|
||||
$sql = "SELECT DISTINCT u.id, concat(u.firstName, ' ', u.lastName) AS name " .
|
||||
"FROM din_user u LEFT JOIN din_usergrouprelationship ugr " .
|
||||
"ON u.id = ugr.user_id " .
|
||||
"AND ugr.group_id = ABS($selection) " .
|
||||
"WHERE ugr.user_id IS NULL " .
|
||||
$sqladdresslimit .
|
||||
"ORDER BY name ASC " .
|
||||
"$limit";
|
||||
}else {
|
||||
$sql = "SELECT DISTINCT u.id, concat(u.firstName, ' ', u.lastName) AS name " .
|
||||
"FROM din_user u, din_usergrouprelationship ugr " .
|
||||
"WHERE u.id != 0 " .
|
||||
"AND u.id = ugr.user_id " .
|
||||
"AND ugr.group_id = $selection " .
|
||||
$sqladdresslimit .
|
||||
"ORDER BY name ASC " .
|
||||
"$limit";
|
||||
}
|
||||
}else {
|
||||
$selection = strtoupper($selection);
|
||||
if (is_numeric($selection)){
|
||||
$sql = "SELECT DISTINCT u.id
|
||||
FROM din_user u
|
||||
WHERE u.cardno = $selection";
|
||||
}else {
|
||||
// Add wildcards around and between words
|
||||
$selection = "%" . str_replace(" ", "% %", $selection) . "%";
|
||||
|
||||
$sql = "SELECT DISTINCT u.id
|
||||
FROM din_user u
|
||||
WHERE CONCAT(UPPER(u.firstName), ' ', UPPER(u.lastName)) LIKE '$selection'
|
||||
OR CONCAT(UPPER(u.firstName), ' ', UPPER(u.lastName)) LIKE '$selection'
|
||||
OR UPPER(u.username) LIKE '$selection'
|
||||
OR UPPER(u.email) LIKE '$selection'
|
||||
$sqladdresslimit
|
||||
ORDER BY u.firstname, u.lastname ASC
|
||||
$limit";
|
||||
}
|
||||
}
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->users = $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
public
|
||||
function displayExpiryList($selection = 2, $limit = 25, $expiry = '0000-00-00', $format = "screen"){
|
||||
switch ($expiry){
|
||||
case 'lifetime':
|
||||
$expression = "expires IS NULL";
|
||||
break;
|
||||
case '0000-00-00':
|
||||
$expression = "expires = '0000-00-00'";
|
||||
break;
|
||||
case 'expired':
|
||||
$expression ="expires > '0000-00-00' AND expires < NOW()";
|
||||
break;
|
||||
case 'valid':
|
||||
$expression ="expires > NOW()";
|
||||
break;
|
||||
case 'no-cardno':
|
||||
$expression = "u.cardno IS NULL";
|
||||
break;
|
||||
case 'no-card':
|
||||
$expression = "u.hasCard = 0 AND u.cardno IS NOT NULL";
|
||||
break;
|
||||
case 'no-sticker':
|
||||
$expression = "u.hasCard = 1 AND u.expires > NOW() AND u.lastSticker < YEAR(u.expires)";
|
||||
break;
|
||||
case 'all':
|
||||
$expression = '1';
|
||||
break;
|
||||
}
|
||||
$sql = "SELECT u.id
|
||||
FROM din_user u, din_usergrouprelationship ugr
|
||||
WHERE $expression
|
||||
AND u.id = ugr.user_id
|
||||
AND ugr.group_id = $selection
|
||||
LIMIT $limit";
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) == true) {
|
||||
error($result->toString());
|
||||
return false;
|
||||
}
|
||||
if ($format == "screen"){
|
||||
if ($result->numRows() > 0){
|
||||
?>
|
||||
<p>Antall treff: <?php print($result->numRows()); ?></p>
|
||||
<table class="sortable" id="userlist">
|
||||
<tr>
|
||||
<th>id</th>
|
||||
<th>kortnr</th>
|
||||
<th>fornavn</th>
|
||||
<th>etternavn</th>
|
||||
<th>utløpsår</th>
|
||||
<th><?php print(($expiry == "no-card")? "mangler medlemskort" : "endre til"); ?></th>
|
||||
<th>oblat</th>
|
||||
<th>endre til</th>
|
||||
<th>registrert</th>
|
||||
<th>sist endret</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$user = new User($row->id);
|
||||
$user->displayExpiryList($expiry);
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen medlemmer registrert.</p>");
|
||||
}
|
||||
}else if ($format == "file"){
|
||||
if ($result->numRows() > 0) {
|
||||
header('Content-type: text/plain');
|
||||
header('Content-Disposition: attachment; filename="brukerliste.txt"');
|
||||
print "id;cardno;firstname;lastname;street;zipcode;postarea;addressStatus;";
|
||||
print "email;phoneno;birthdate;expires;lastSticker;registered;lastUpdate\r\n";
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$user = new User($row->id);
|
||||
$user->writeExpiryListFile($expiry);
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
notify("Ingen medlemmer registrert");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function displayExpiryListSearch($search){
|
||||
|
||||
$selection = strtoupper($search);
|
||||
if (is_numeric($selection)){
|
||||
$sql = "SELECT DISTINCT u.id
|
||||
FROM din_user u
|
||||
WHERE u.cardno = $selection " .
|
||||
"OR u.id = $selection";
|
||||
}else {
|
||||
$sql = "SELECT DISTINCT u.id
|
||||
FROM din_user u
|
||||
WHERE CONCAT(UPPER(u.firstName), ' ', UPPER(u.lastName), ' ', UPPER(u.username), ' ', UPPER(u.email)) LIKE '%$selection%'
|
||||
ORDER BY u.firstname, u.lastname ASC";
|
||||
}
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
error($result->toString());
|
||||
return false;
|
||||
}
|
||||
if ($result->numRows() > 0){
|
||||
?>
|
||||
<p>Antall treff: <?php print($result->numRows()); ?></p>
|
||||
<table class="sortable" id="userlist">
|
||||
<tr>
|
||||
<th>id</th>
|
||||
<th>kortnr</th>
|
||||
<th>fornavn</th>
|
||||
<th>etternavn</th>
|
||||
<th>utløpsår</th>
|
||||
<th>endre til</th>
|
||||
<th>oblat</th>
|
||||
<th>endre til</th>
|
||||
<th>registrert</th>
|
||||
<th>sist endret</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$user = new User($row->id);
|
||||
$user->displayExpiryList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen medlemmer registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function displayList($selection = 2, $limit = 25, $search = false, $addressStatus = -1){
|
||||
$this->getList($selection, $limit, $search, $addressStatus);
|
||||
if ($this->users->numRows() > 0){
|
||||
?>
|
||||
<p>Antall treff: <?php print($this->users->numRows()); ?></p>
|
||||
<table class="sortable" id="userlist">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>medlem</th>
|
||||
<th>fornavn</th>
|
||||
<th>etternavn</th>
|
||||
<th>epost</th>
|
||||
<th>telefon</th>
|
||||
<th>grupper</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->users->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$user = new User($row->id);
|
||||
$user->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen medlemmer funnet innenfor valgte søk.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
public function getDivisionRequestList(){
|
||||
if (isAdmin()){
|
||||
$sql = "SELECT d.id " .
|
||||
"FROM din_user d, din_division dd " .
|
||||
"WHERE d.division_id_request IS NOT NULL " .
|
||||
"AND dd.id=d.division_id_request";
|
||||
}else {
|
||||
$currentUser = getCurrentUser();
|
||||
$sql = "SELECT udr.id
|
||||
FROM din_group g, din_user u, din_usergrouprelationship ugr, din_division d, din_user udr
|
||||
WHERE u.id = ugr.user_id
|
||||
AND ugr.group_id = g.id
|
||||
AND u.id = $currentUser
|
||||
AND g.admin = 1
|
||||
AND g.division_id = d.id
|
||||
AND udr.division_id_request = d.id";
|
||||
}
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
$this->users = $result;
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
|
||||
public function displayDivisionRequests(){
|
||||
$this->getDivisionRequestList();
|
||||
if ($this->users->numRows() > 0){
|
||||
?>
|
||||
<p>Disse medlemmene har haket av for at de var aktive i din forening da de registrerte seg. Sjekk om dette stemmer. Dersom du ikke tror de er aktive kan du gjerne kontakte dem og høre om de vil bli aktive!</p>
|
||||
<p>Antall treff: <?php print($this->users->numRows()); ?></p>
|
||||
<table class="sortable" id="divreqlist">
|
||||
<tr>
|
||||
<th>fornavn</th>
|
||||
<th>etternavn</th>
|
||||
<th>epost</th>
|
||||
<th>forening</th>
|
||||
<th>bruker registrert</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $this->users->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$user = new User($row->id);
|
||||
$user->displayDivReqList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {
|
||||
print("<p>Ingen forespørseler registrert.</p>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of users with study place affiliations
|
||||
*
|
||||
* @param none
|
||||
* @return mixed array
|
||||
**/
|
||||
public function getUsersStudyPlaceList($year = null) {
|
||||
if ($year) {
|
||||
$user = new User(1);
|
||||
$sql = "SELECT s.navn AS studyPlace, COUNT(*) AS count FROM din_user u INNER JOIN studiesteder s ON u.placeOfStudy=s.id WHERE u.expires='" . $user->getExpiryDate() . "' GROUP BY placeOfStudy ORDER BY studyPlace";
|
||||
} else {
|
||||
$sql = "SELECT s.navn AS studyPlace, COUNT(*) AS count FROM din_user u INNER JOIN studiesteder s ON u.placeOfStudy=s.id GROUP BY placeOfStudy ORDER BY studyPlace";
|
||||
}
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true) {
|
||||
$this->usersStudyPlaceList = $result;
|
||||
} else {
|
||||
error($result->toString());
|
||||
}
|
||||
return $this->usersStudyPlaceList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get max number of users for one study place affiliations
|
||||
*
|
||||
* @param none
|
||||
* @return mixed array
|
||||
**/
|
||||
public function getMaxUsersStudyPlace($year = null) {
|
||||
if ($year) {
|
||||
$user = new User(1);
|
||||
$sql = "SELECT COUNT(*) AS count FROM din_user WHERE expires='" . $user->getExpiryDate() . "' GROUP BY placeOfStudy ORDER BY count DESC LIMIT 1";
|
||||
} else {
|
||||
$sql = "SELECT COUNT(*) AS count FROM din_user GROUP BY placeOfStudy ORDER BY count DESC LIMIT 1";
|
||||
}
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true) {
|
||||
$this->usersStudyPlaceMax = $result->fetchRow(DB_FETCHMODE_OBJECT);
|
||||
$this->usersStudyPlaceMax = $this->usersStudyPlaceMax->count;
|
||||
} else {
|
||||
error($result->toString());
|
||||
}
|
||||
return $this->usersStudyPlaceMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* List number of users with study place affiliations
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
**/
|
||||
public function displayUsersStudyPlaceList() {
|
||||
if (isset($_GET['year'])) $year = $_GET['year'];
|
||||
else $year = null;
|
||||
if (!isset($this->usersStudyPlaceList)) $this->getUsersStudyPlaceList($year);
|
||||
|
||||
print "<h2>Oversikt over hvor medlemmene har registrert at de studerer</h2>\n";
|
||||
|
||||
print "<p>";
|
||||
print "<a href=\"" . $_SERVER["PHP_SELF"] . "?page=" . $_GET["page"] . "\">Vis alle</a> | ";
|
||||
print "<a href=\"" . $_SERVER["PHP_SELF"] . "?page=" . $_GET["page"] . "&year=current\">inneværende år</a>";
|
||||
print "</p>";
|
||||
|
||||
if ($year) {
|
||||
print "<p>Viser oversikt over studiestuder for alle som har betalt medlemskap i nåværende år.</p>";
|
||||
} else {
|
||||
print "<p>Viser alle medlemmer som noensinne har registrert seg.</p>";
|
||||
}
|
||||
|
||||
$n = 0;
|
||||
if ($this->usersStudyPlaceList->numRows() > 0) {
|
||||
$scalefactor = 600/($this->getMaxUsersStudyPlace($year));
|
||||
print "<table class=\"sortable\" id=\"usersstudyplacelist\">";
|
||||
print "<tr>";
|
||||
print "<th>Studiested</th>";
|
||||
print "<th colspan=\"2\">Antall</th>";
|
||||
print "</tr>\n";
|
||||
|
||||
while ($row =& $this->usersStudyPlaceList->fetchRow(DB_FETCHMODE_OBJECT)) {
|
||||
print "<tr>";
|
||||
print "<td>" . $row->studyPlace . "</td>";
|
||||
print "<td align=\"right\">" . $row->count . "</td>";
|
||||
print "<td><img src=\"graphics/bar.png\" height=\"10\" width=\"" . ($row->count)*$scalefactor . "\"></td>";
|
||||
print "</tr>\n";
|
||||
$n += $row->count;
|
||||
}
|
||||
print "<tr><td><b>Sum</b></td><td>$n</td><td></td></tr>\n";
|
||||
print "</table>";
|
||||
} else {
|
||||
print "<p>Det er ingen registrerte medlemmer i valgt periode.</p>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import membership payments from file recieved from our bank
|
||||
**/
|
||||
public function parseMembershipPaymentsFromBank ($bankfile) {
|
||||
$payment_lines = split("\n", $bankfile);
|
||||
|
||||
$i = 1;
|
||||
$n = 0;
|
||||
|
||||
if (isset($_POST["parseonly"])) {
|
||||
print "<h3>Resultater av fil-analysen</h3>\n";
|
||||
print "<p>For å registrere medlemskapene i databasen, gå nederst på denne siden.</p>\n";
|
||||
}
|
||||
|
||||
// read each line
|
||||
foreach ($payment_lines as $payment_line) {
|
||||
$payment_line = rtrim($payment_line);
|
||||
|
||||
if (substr($payment_line,6,2) == "30") {
|
||||
// KID betaling
|
||||
$n++;
|
||||
$payment = array();
|
||||
$payment["date"] = mktime(0,0,0, substr($payment_line,17,2),
|
||||
substr($payment_line,15,2),
|
||||
substr($payment_line,19,2));
|
||||
$payment["amount"] = intval(substr($payment_line,40,7)) . "," . substr($payment_line,47,2);
|
||||
$payment["info"] = substr($payment_line,49,25);
|
||||
$payment["zeroes"] = substr($payment_line,49,4);
|
||||
$payment["kundenr"] = intval(substr($payment_line,53,10));
|
||||
$payment["fakturanr"] = intval(substr($payment_line,63,10));
|
||||
$payment["CRC"] = substr($payment_line,73,1);
|
||||
|
||||
$payment_user = new User($payment["kundenr"]);
|
||||
|
||||
if (isset($_POST["parseonly"])) {
|
||||
print "Fant KID-betaling på linje " . $i . ". Beløp " . $payment["amount"] . " ble betalt inn " . date("d.m.Y", $payment["date"]) . "<br />\n";
|
||||
print "Medlemsnr: " . $payment["kundenr"] . ", ". $payment_user->getName() . ", fakturanr: " . $payment["fakturanr"] . ", kontrollsiffer: " . $payment["CRC"] . ".<br />\n";
|
||||
if ($payment_user->isHonorMember()) {
|
||||
print "<font color=\"red\">" . $payment_user->getName() . " er livsvarig medlem.</font><br />\n";
|
||||
} elseif ($payment_user->isMember()) {
|
||||
print "<font color=\"red\">" . $payment_user->getName() . " er allerede medlem. Medlemsskapet vil bli satt til å være gyldig i ett år ekstra.</font><br />\n";
|
||||
}
|
||||
print "<br />\n";
|
||||
} else {
|
||||
$payment_user->renewMembershipBankpayment();
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
print "<br />Fant totalt $n betalinger i filen.<br />";
|
||||
if ($n > 0) {
|
||||
if (isset($_POST["parseonly"])) {
|
||||
print "<b>Oppdateringen av medlemskapene er ikke lagret.</b> For å lagre oppdateringen må du velge å ikke analysere filen uten å oppdatere medlemskapsdatabasen nederst på denne siden.<br />\n";
|
||||
} else {
|
||||
print "<b>Databasen er oppdatert med nytt medlemskap på personene.</b><br />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update addresses from a CSV file recieved through EA
|
||||
*
|
||||
* @param string eafile
|
||||
* @return boolean
|
||||
**/
|
||||
public function parseEAfile ($eafile) {
|
||||
$ealines = split("\n", $eafile);
|
||||
|
||||
// read each line
|
||||
foreach ($ealines as $line) {
|
||||
$line = rtrim($line);
|
||||
//$line = utf8_decode($line);
|
||||
//print $line;
|
||||
$eaentry = split(";", $line);
|
||||
|
||||
// reset variables
|
||||
$address = "";
|
||||
$postno = "";
|
||||
$city = "";
|
||||
$country = "";
|
||||
$valid_address = 0;
|
||||
|
||||
if (is_numeric($eaentry[0])) {
|
||||
$user = @new User($eaentry[0]);
|
||||
if ($user->_retrieveData()) {
|
||||
// parse from different address caretgories
|
||||
switch ($eaentry[1]) {
|
||||
case "GV":
|
||||
print "Gate/vei";
|
||||
$address = $eaentry[2];
|
||||
if (strlen($eaentry[3]) > 0) $address .= " " . ereg_replace("^0*", "", $eaentry[3]);
|
||||
if (strlen($eaentry[4]) > 0) $address .= " " . $eaentry[4];
|
||||
if (strlen($eaentry[5]) > 0) $address .= ", oppg. " . $eaentry[5];
|
||||
$postno = $eaentry[10];
|
||||
$valid_address = 1;
|
||||
break;
|
||||
case "ST":
|
||||
print "Stedsnavn";
|
||||
$address = $eaentry[7];
|
||||
$postno = $eaentry[10];
|
||||
$valid_address = 1;
|
||||
break;
|
||||
case "PB":
|
||||
print "Postboks";
|
||||
$address = "Pb. " . $eaentry[6];
|
||||
if (strlen($eaentry[7]) > 0) $address .= " " . $eaentry[7];
|
||||
$postno = $eaentry[10];
|
||||
$valid_address = 1;
|
||||
break;
|
||||
case "SB":
|
||||
print "Serviceboks";
|
||||
$address = "Serviceboks " . $eaentry[6];
|
||||
if (strlen($eaentry[7]) > 0) $address .= " " . $eaentry[7];
|
||||
$postno = $eaentry[10];
|
||||
$valid_address = 1;
|
||||
break;
|
||||
case "PS":
|
||||
print "Postnummer";
|
||||
$postno = $eaentry[10];
|
||||
$valid_address = 1;
|
||||
break;
|
||||
case "UT":
|
||||
print "Utenlandsk adresse";
|
||||
$address = $eaentry[8];
|
||||
if (strlen($eaentry[9]) > 0) $address .= "\n" . $eaentry[9];
|
||||
$postno = $eaentry[10];
|
||||
$city = $eaentry[11];
|
||||
$country = $eaentry[12];
|
||||
$valid_address = 1;
|
||||
break;
|
||||
default:
|
||||
print "Retur: " . $eaentry[13];
|
||||
// mark address as invalid;
|
||||
$valid_address = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// update address if new address data exists
|
||||
if (strlen($address . $postno) > 0) {
|
||||
if ($eaentry[1] == "UT") { // foreign address
|
||||
$user->_registerUpdate("EA-oppdatering, gammel adresse: " . $user->street . ", " . $user->zipcode . " " . $user->city . ", " . $user->country);
|
||||
$user->addresstype = "int";
|
||||
$user->street = $address;
|
||||
$user->zipcode = $postno;
|
||||
$user->city = $city;
|
||||
$user->state = "";
|
||||
$user->country = $country;
|
||||
$user->setAddressStatus($valid_address);
|
||||
$user->store();
|
||||
} else { // norwegian address
|
||||
$user->sendNewAddressMail($address, $postno);
|
||||
$user->_registerUpdate("EA-oppdatering, gammel adresse: " . $user->street . ", " . $user->zipcode . " " . $user->postarea);
|
||||
$user->addresstype = "no";
|
||||
$user->street = $address;
|
||||
$user->zipcode = $postno;
|
||||
$user->setAddressStatus($valid_address);
|
||||
$user->store();
|
||||
}
|
||||
} else {
|
||||
$user->_registerUpdate("EA-oppdatering, gammel adresse: " . $user->street . ", " . $user->zipcode . " " . $user->city . " satt som ugyldig");
|
||||
$user->setAddressStatus($valid_address);
|
||||
$user->_sendWrongAddressMail();
|
||||
print "<i>Gammel adresse markert ugyldig.</i><br />\n";
|
||||
}
|
||||
} else {
|
||||
error("Ugyldig bruker-id " . $eaentry[0] . ", addressen ble ikke importert");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class WeekProgram {
|
||||
|
||||
var $id;
|
||||
var $week;
|
||||
var $year;
|
||||
var $gig1;
|
||||
var $gig2;
|
||||
var $gig3;
|
||||
var $pretext;
|
||||
var $posttext;
|
||||
|
||||
var $conn;
|
||||
|
||||
function WeekProgram($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New WeekProgram
|
||||
if ($data == NULL){
|
||||
error("WeekProgram: No data supplied.");
|
||||
}else {
|
||||
//All relevant values are common
|
||||
}
|
||||
}else {//ID set, existing article
|
||||
if ($data != NULL){//Update existing article
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
$this->gig1 = $data['gig1'];
|
||||
$this->gig2 = $data['gig2'];
|
||||
$this->gig3 = $data['gig3'];
|
||||
$this->pretext = ($data['pretext'] == NULL)? '' : $data['pretext'];
|
||||
$this->posttext = ($data['posttext'] == NULL)? '' : $data['posttext'];
|
||||
}
|
||||
}
|
||||
|
||||
//Common initializations
|
||||
$this->week = $data['week'];
|
||||
$this->year = $data['year'];
|
||||
}
|
||||
|
||||
public
|
||||
function store(){
|
||||
if ($this->id == NULL){
|
||||
$sql = sprintf("INSERT INTO weekprogram
|
||||
(id, week, year)
|
||||
VALUES
|
||||
(%s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->week),
|
||||
$this->conn->quoteSmart($this->year)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Ukesprogram er registrert.");
|
||||
}else {
|
||||
error("New WeekProgram: " . $result->toString());
|
||||
notify("Program for denne uken finnes allerede.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM weekprogram
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("WeekProgram: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM weekprogram
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//if ($result->affectedRows() > 0){
|
||||
notify("WeekProgram deleted.");
|
||||
// }else {
|
||||
//notify("WeekProgram: invalid id.");
|
||||
// }
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
?>
|
||||
<div class="text-column">
|
||||
<?php
|
||||
displayOptionsMenu($this->id, WEEKPROGRAM, "weekprogram", "view-edit-options-weekprogram");
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
?>
|
||||
<tr>
|
||||
<td>Uke <?php print $this->week . " - " . $this->year; ?></td>
|
||||
<td><?php print $this->_firstDay();?></td>
|
||||
<td><?php print $this->_lastDay();?></td>
|
||||
<td><a href="ukesprogram.php?id=<?php print $this->id; ?>&mode=view" target="_blank">vis</a></td>
|
||||
<td><a href="ukesprogram.php?id=<?php print $this->id; ?>&mode=edit" target="_blank">endre</a></td>
|
||||
<td><a href="ukesprogramtekst.php?id=<?php print $this->id; ?>" target="_blank">tekst</a></td>
|
||||
<td><a href="ukesprogramprint.php?id=<?php print $this->id; ?>" target="_blank">print</a></td>
|
||||
<td><a href="ukesprogramuniversitas.php?id=<?php print $this->id; ?>" target="_blank">universitas (onsdag - onsdag)</a></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
function _firstDay(){
|
||||
$week = $this->week - 1;
|
||||
return date("d. M", strtotime("+$week week", strtotime("monday", strtotime(" 1 jan $this->year"))));
|
||||
}
|
||||
|
||||
public
|
||||
function _lastDay(){
|
||||
$week = $this->week;
|
||||
return date("d. M", strtotime("last sunday", strtotime("+$week week", strtotime("monday", strtotime(" 1 jan $this->year")))));
|
||||
//return date("d. M", strtotime("+$week week", strtotime("sunday", strtotime(" 1$this->year"))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
class WeekPrograms {
|
||||
var $conn;
|
||||
|
||||
function WeekPrograms($limit = 5) {
|
||||
$this->__construct($limit);
|
||||
}
|
||||
|
||||
function __construct($limit = 5){
|
||||
$this->conn = db_connect();
|
||||
}
|
||||
|
||||
public function getList($division = NULL){
|
||||
if ($division != NULL){
|
||||
$condition = "AND p.division_id = $division";
|
||||
}else {
|
||||
$condition = "";
|
||||
}
|
||||
$sql = "SELECT d.id AS divId, d.name AS divName, p.id AS positionId, p.name AS weekprogramName " .
|
||||
"FROM weekprogram p, din_division d " .
|
||||
"WHERE p.division_id = d.id " .
|
||||
"$condition" .
|
||||
"ORDER BY d.name ASC";
|
||||
|
||||
$result =& $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
return $result;
|
||||
} else {
|
||||
error("WeekPrograms: " . $result->toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getWeekProgramsAsArray(){
|
||||
if ($list = $this->getWeekPrograms()){
|
||||
$pos = Array();
|
||||
while ($row =& $list->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$div = $row['divId'];
|
||||
|
||||
$pos[] = Array("id" => $row['weekprogramId'],
|
||||
"title" => $row['weekprogramName'],
|
||||
"parent" => $row['weekprogramDivId']);
|
||||
}
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function display(){
|
||||
$sql = "SELECT id FROM weekprogram
|
||||
ORDER BY year DESC, week DESC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$weekprogram = new WeekProgram($row->id);
|
||||
$weekprogram->display();
|
||||
}
|
||||
}else {
|
||||
error("WeekPrograms: " . $result->toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
$sql = "SELECT id FROM weekprogram " .
|
||||
"ORDER BY year DESC, week DESC";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if($result->numRows() > 0){
|
||||
?>
|
||||
<table class="sortable" id="weekprogramlist">
|
||||
<tr>
|
||||
<th>uke</th>
|
||||
<th>fra</th>
|
||||
<th>til</th>
|
||||
<?php if(checkAuth("view-options-weekprogram")){
|
||||
?><th colspan="5"> </th><?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$weekprogram = new WeekProgram($row->id);
|
||||
$weekprogram->displayList();
|
||||
}
|
||||
print(" </table>");
|
||||
}else {?>
|
||||
<p>Ingen ukesprogram er registrert ennå.</p>
|
||||
<?php
|
||||
}
|
||||
}else {
|
||||
error("WeekPrograms: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,80 @@
|
||||
function makeCatRequest(url) {
|
||||
if(window.XMLHttpRequest){
|
||||
request = new XMLHttpRequest();
|
||||
}
|
||||
else if(window.ActiveXObject){
|
||||
request = new ActiveXObject("MSXML2.XMLHTTP");
|
||||
}
|
||||
sendCatRequest(url);
|
||||
}
|
||||
|
||||
function sendCatRequest(url){
|
||||
request.onreadystatechange = catOnResponse;
|
||||
request.open("GET", url, true);
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
function checkCatReadyState(obj){
|
||||
if(obj.readyState == 0) { document.getElementById('statusField').innerHTML = "Sender forespørsel..."; }
|
||||
if(obj.readyState == 1) { document.getElementById('statusField').innerHTML = "Henter data..."; }
|
||||
if(obj.readyState == 2) { document.getElementById('statusField').innerHTML = "Laster data..."; }
|
||||
if(obj.readyState == 3) { document.getElementById('statusField').innerHTML = "Data lastet ferdig..."; }
|
||||
if(obj.readyState == 4) {
|
||||
if(obj.status == 200) {
|
||||
return true;
|
||||
}else if(obj.status == 404) {
|
||||
// Add a custom message or redirect the user to another page
|
||||
document.getElementById('statusField').innerHTML = "File not found";
|
||||
}else {
|
||||
document.getElementById('statusField').innerHTML = "There was a problem retrieving the XML.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function catOnResponse() {
|
||||
if(checkCatReadyState(request)){
|
||||
//alert(request.responseXML);
|
||||
//alert(request.responseText);
|
||||
var response = request.responseXML.documentElement;
|
||||
var type = response.getElementsByTagName('actiontype')[0].firstChild.data;
|
||||
var cat_type = response.getElementsByTagName('cat-type')[0].firstChild.data;
|
||||
if (response.getElementsByTagName('id')[0].firstChild != null){
|
||||
var id = response.getElementsByTagName('id')[0].firstChild.data;
|
||||
}else {
|
||||
document.getElementById('statusField').innerHTML = "Kategorien finnes fra før.";
|
||||
return;
|
||||
}
|
||||
var table = document.getElementById(cat_type + '-cat-list');
|
||||
|
||||
if (type == 'add'){
|
||||
var title = response.getElementsByTagName('title')[0].firstChild.data;
|
||||
document.getElementById('statusField').innerHTML = "Kategorien " + title + " er lagt til. Om den ikke vises over, forsøk å laste siden på nytt (F5)";
|
||||
var text = response.getElementsByTagName('text')[0].firstChild.data;
|
||||
var edit_href = response.getElementsByTagName('edit-href')[0].firstChild.data;
|
||||
var edit_text = response.getElementsByTagName('edit-text')[0].firstChild.data;
|
||||
var delete_href = response.getElementsByTagName('delete-href')[0].firstChild.data;
|
||||
var delete_text = response.getElementsByTagName('delete-text')[0].firstChild.data;
|
||||
var r = document.createElement("tr");
|
||||
r.setAttribute('id', cat_type +'category' + id);
|
||||
r.insertCell(0);
|
||||
r.cells[0].appendChild(document.createTextNode(title));
|
||||
r.insertCell(1);
|
||||
r.cells[1].appendChild(document.createTextNode(text));
|
||||
r.insertCell(2);
|
||||
var aEdit = document.createElement("a");
|
||||
aEdit.setAttribute('href', edit_href);
|
||||
aEdit.appendChild(document.createTextNode(edit_text));
|
||||
r.cells[2].appendChild(aEdit);
|
||||
r.insertCell(3);
|
||||
var aDelete = document.createElement("a");
|
||||
aDelete.setAttribute('href', delete_href);
|
||||
aDelete.appendChild(document.createTextNode(delete_text));
|
||||
r.cells[3].appendChild(aDelete);
|
||||
table.tBodies[0].appendChild(r);
|
||||
}else if (type == 'remove'){
|
||||
document.getElementById('statusField').innerHTML = "Kategori slettet.";
|
||||
var r = document.getElementById(cat_type + 'category' + id);
|
||||
table.tBodies[0].removeChild(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
function makeRequest(url) {
|
||||
if(window.XMLHttpRequest) {
|
||||
request = new XMLHttpRequest();
|
||||
}else if(window.ActiveXObject){
|
||||
request = new ActiveXObject("MSXML2.XMLHTTP");
|
||||
}
|
||||
sendRequest(url);
|
||||
}
|
||||
|
||||
function sendRequest(url) {
|
||||
request.onreadystatechange = onResponse;
|
||||
request.open("GET", url, true);
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
function checkReadyState(obj) {
|
||||
if(obj.readyState == 0) { document.getElementById('notice').innerHTML = "Sender foresp?rsel..."; }
|
||||
if(obj.readyState == 1) { document.getElementById('notice').innerHTML = "Henter data..."; }
|
||||
if(obj.readyState == 2) { document.getElementById('notice').innerHTML = "Laster data..."; }
|
||||
if(obj.readyState == 3) { document.getElementById('notice').innerHTML = "Data lastet ferdig..."; }
|
||||
if(obj.readyState == 4) {
|
||||
if(obj.status == 200) {
|
||||
return true;
|
||||
}else if(obj.status == 404) {
|
||||
// Add a custom message or redirect the user to another page
|
||||
document.getElementById('notice').innerHTML = "File not found";
|
||||
}else {
|
||||
document.getElementById('notice').innerHTML = "There was a problem retrieving the XML.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onResponse(){
|
||||
if(checkReadyState(request)){
|
||||
//alert(request.responseXML);
|
||||
//alert(request.responseText);
|
||||
var response = request.responseXML.documentElement;
|
||||
var posId = response.getElementsByTagName('positionid')[0].firstChild.data;
|
||||
var title = response.getElementsByTagName('title')[0].firstChild.data;
|
||||
var text = response.getElementsByTagName('text')[0].firstChild.data;
|
||||
document.getElementById('positionid').value = posId;
|
||||
document.getElementById('name').value = title;
|
||||
document.getElementById('text').value = text;
|
||||
tinyMCE.updateContent('text');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
function makeUsernameRequest(url) {
|
||||
if(window.XMLHttpRequest){
|
||||
request = new XMLHttpRequest();
|
||||
}
|
||||
else if(window.ActiveXObject){
|
||||
request = new ActiveXObject("MSXML2.XMLHTTP");
|
||||
}
|
||||
sendUsernameRequest(url);
|
||||
}
|
||||
|
||||
function sendUsernameRequest(url){
|
||||
request.onreadystatechange = usernameOnResponse;
|
||||
request.open("GET", url, true);
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
function checkUsernameReadyState(obj){
|
||||
if(obj.readyState == 4) {
|
||||
if(obj.status == 200){
|
||||
return true;
|
||||
}
|
||||
else if(obj.status == 404){
|
||||
// Add a custom message or redirect the user to another page
|
||||
alert("error checking username");
|
||||
}else{
|
||||
alert("There was a problem retrieving the XML.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function usernameOnResponse() {
|
||||
if(checkUsernameReadyState(request)){
|
||||
//alert(request.responseXML);
|
||||
//alert(request.responseText);
|
||||
var response = request.responseXML.documentElement;
|
||||
var status = response.getElementsByTagName('status')[0].firstChild.data;
|
||||
if (status == "false") {
|
||||
alert("Dette brukernavnet er i bruk på forumet.\n\nOm du har denne brukeren på forumet, kan du bruke samme brukernavn også på Inside.\n\nFor å bekrefte at dette er ditt brukernavn må du skrive inn samme passord som du har på forumet.\n\nOm dette ikke er ditt brukernavn må du velge et annet.\n\nBåde brukernavn og passord kan endres senere.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
function makeZipRequest(url) {
|
||||
if(window.XMLHttpRequest){
|
||||
request = new XMLHttpRequest();
|
||||
}
|
||||
else if(window.ActiveXObject){
|
||||
request = new ActiveXObject("MSXML2.XMLHTTP");
|
||||
}
|
||||
sendZipRequest(url);
|
||||
}
|
||||
|
||||
function sendZipRequest(url){
|
||||
request.onreadystatechange = zipOnResponse;
|
||||
request.open("GET", url, true);
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
function checkZipReadyState(obj){
|
||||
if(obj.readyState == 0) { document.getElementById('postarea').innerHTML = "Sender foresp?rsel..."; }
|
||||
if(obj.readyState == 1) { document.getElementById('postarea').innerHTML = "Henter data..."; }
|
||||
if(obj.readyState == 2) { document.getElementById('postarea').innerHTML = "Laster data..."; }
|
||||
if(obj.readyState == 3) { document.getElementById('postarea').innerHTML = "Data lastet ferdig..."; }
|
||||
if(obj.readyState == 4) {
|
||||
if(obj.status == 200){
|
||||
return true;
|
||||
}
|
||||
else if(obj.status == 404){
|
||||
// Add a custom message or redirect the user to another page
|
||||
document.getElementById('postarea').innerHTML = "File not found";
|
||||
}else{
|
||||
document.getElementById('postarea').innerHTML = "There was a problem retrieving the XML.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function zipOnResponse() {
|
||||
if(checkZipReadyState(request)){
|
||||
//alert(request.responseXML);
|
||||
//alert(request.responseText);
|
||||
var response = request.responseXML.documentElement;
|
||||
var postarea = response.getElementsByTagName('postarea')[0].firstChild.data;
|
||||
document.getElementById('postarea').innerHTML = postarea;
|
||||
if (postarea == "ugyldig postnummer"){
|
||||
document.getElementById("zipcode").focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
function requestConcertInfo(callerid, target, programid) {
|
||||
var iId = document.getElementById(callerid).value;
|
||||
var pattern = /\d+/;
|
||||
var match = pattern.exec(callerid);
|
||||
var gigNo = parseInt(match[0]);
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
oXmlHttp.open("get", "getconcertinfo.php?gigid=" + iId + "&store=" + gigNo + "&programid=" + programid, true);
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4){
|
||||
if (oXmlHttp.status == 200) {
|
||||
displayConcertInfo(oXmlHttp.responseText, target);
|
||||
}else {
|
||||
displayConcertInfo("An error occured: " + oXmlHttp.statusText, target);
|
||||
}
|
||||
}
|
||||
};
|
||||
oXmlHttp.send(null);
|
||||
}
|
||||
|
||||
function grantCardNumber(userid) {
|
||||
var form = document.getElementById("user_"+userid+"_cardno_form");
|
||||
form.style.display = "none";
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
var sURL = "grantcardno.php?userid=" + userid;
|
||||
oXmlHttp.open("get", sURL, true);
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4){
|
||||
if (oXmlHttp.status == 200) {
|
||||
//alert(oXmlHttp.responseXML);
|
||||
//alert(oXmlHttp.responseText);
|
||||
var response = oXmlHttp.responseXML.documentElement;
|
||||
var cardno = response.getElementsByTagName('cardno')[0].firstChild.data;
|
||||
var expires = response.getElementsByTagName('expires')[0].firstChild.data;
|
||||
document.getElementById('user_'+userid+'_cardno').innerHTML = cardno;
|
||||
document.getElementById('user_'+userid+'_expires').innerHTML = expires;
|
||||
|
||||
form.parentNode.innerHTML = "Kortnummer "+cardno+" er tildelt";
|
||||
}else {
|
||||
alert("An error occured: " + oXmlHttp.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
oXmlHttp.send(null);
|
||||
}
|
||||
|
||||
function setHasCard(userid) {
|
||||
var form = document.getElementById("user_"+userid+"_hascard_form");
|
||||
form.style.display = "none";
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
var sURL = "sethascard.php?userid=" + userid;
|
||||
oXmlHttp.open("get", sURL, true);
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4){
|
||||
if (oXmlHttp.status == 200) {
|
||||
//alert(oXmlHttp.responseXML);
|
||||
//alert(oXmlHttp.responseText);
|
||||
var response = oXmlHttp.responseXML.documentElement;
|
||||
var lastSticker = response.getElementsByTagName('laststicker')[0].firstChild.data;
|
||||
document.getElementById('user_'+userid+'_laststicker').innerHTML = lastSticker;
|
||||
|
||||
form.parentNode.innerHTML = "Medlemskort er produsert";
|
||||
}else {
|
||||
alert("An error occured: " + oXmlHttp.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
oXmlHttp.send(null);
|
||||
}
|
||||
|
||||
function updateUserExpiry(userid) {
|
||||
var input = document.getElementById("newExpiryDate_"+userid);
|
||||
var value = input.value;
|
||||
var v = document.getElementById("user_"+userid+"_expires");
|
||||
v.innerHTML = value;
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
var sURL = "updateuserexpiry.php?userid=" + userid + "&value="+value;
|
||||
oXmlHttp.open("get", sURL, true);
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4){
|
||||
if (oXmlHttp.status == 200) {
|
||||
//alert(oXmlHttp.responseXML);
|
||||
//alert(oXmlHttp.responseText);
|
||||
//var response = oXmlHttp.responseXML.documentElement;
|
||||
}else {
|
||||
alert("An error occured: " + oXmlHttp.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
oXmlHttp.send(null);
|
||||
}
|
||||
|
||||
function updateLastSticker(userid) {
|
||||
var input = document.getElementById("newStickerDate_"+userid);
|
||||
var value = input.value;
|
||||
var v = document.getElementById("user_"+userid+"_laststicker");
|
||||
v.innerHTML = value;
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
var sURL = "updatelaststicker.php?userid=" + userid + "&value="+value;
|
||||
oXmlHttp.open("get", sURL, true);
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4){
|
||||
if (oXmlHttp.status == 200) {
|
||||
//alert(oXmlHttp.responseXML);
|
||||
//alert(oXmlHttp.responseText);
|
||||
//var response = oXmlHttp.responseXML.documentElement;
|
||||
}else {
|
||||
alert("An error occured: " + oXmlHttp.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
oXmlHttp.send(null);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* set order status to delivered
|
||||
***********************************/
|
||||
function setOrderDeliveryStatus(orderid) {
|
||||
var form = document.getElementById("order_"+orderid+"_update_form");
|
||||
form.style.display = "none";
|
||||
var input = document.getElementById("newDeliveryStatus_"+orderid);
|
||||
var value = input.value;
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
var sURL = "setorderdelivery.php?orderid=" + orderid + "&newstatusid=" + value;
|
||||
oXmlHttp.open("get", sURL, true);
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4) {
|
||||
if (oXmlHttp.status == 200) {
|
||||
//alert(oXmlHttp.responseXML);
|
||||
//alert(oXmlHttp.responseText);
|
||||
var response = oXmlHttp.responseXML.documentElement;
|
||||
var status = response.getElementsByTagName('deliverystatus')[0].firstChild.data;
|
||||
|
||||
if (status == 1) {
|
||||
document.getElementById('order_'+orderid+'_deliverystatus').innerHTML = "levert";
|
||||
form.parentNode.innerHTML = "Orderen er levert";
|
||||
} else {
|
||||
document.getElementById('order_'+orderid+'_deliverystatus').innerHTML = "ikke levert";
|
||||
form.parentNode.innerHTML = "Orderen er ikke levert";
|
||||
}
|
||||
} else {
|
||||
alert("An error occured: " + oXmlHttp.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
oXmlHttp.send(null);
|
||||
}
|
||||
|
||||
function setWeekText(sText, iId, sType) {
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
sText = escape(sText);
|
||||
var sURL = "setweekprogramtext.php?wid=" + iId + "&text=" + sText + "&type=" + sType;
|
||||
oXmlHttp.open("get", sURL, true);
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4){
|
||||
if (oXmlHttp.status == 200) {
|
||||
//alert(oXmlHttp.responseText);
|
||||
}else {
|
||||
alert("An error occured: " + oXmlHttp.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
oXmlHttp.send(null);
|
||||
}
|
||||
|
||||
function displayConcertInfo(sText, target) {
|
||||
var divConcertInfo = document.getElementById(target);
|
||||
divConcertInfo.innerHTML = sText;
|
||||
}
|
||||
|
||||
function saveResult(sMessage) {
|
||||
var divStatus = document.getElementById("divStatus");
|
||||
divStatus.innerHTML = "Request completed: " + sMessage;
|
||||
}
|
||||
|
||||
function getRequestBody(oForm) {
|
||||
var aParams = new Array();
|
||||
|
||||
for (var i = 0; i < oForm.elements.length; i++){
|
||||
var sParam = encodeURIComponent(oForm.elements[i].name);
|
||||
sParam += "=";
|
||||
sParam += encodeURIComponent(oForm.elements[i].value);
|
||||
aParams.push(sParam);
|
||||
}
|
||||
return aParams.join("&");
|
||||
}
|
||||
|
||||
function sendRequest() {
|
||||
var oForm = document.forms[0];
|
||||
var sBody = getRequestBody(oForm);
|
||||
|
||||
var oXmlHttp = zXmlHttp.createRequest();
|
||||
oXmlHttp.open("post", oForm.action, true);
|
||||
oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
oXmlHttp.onreadystatechange = function() {
|
||||
if (oXmlHttp.readyState == 4){
|
||||
if (oXmlHttp.status == 200) {
|
||||
saveResult(oXmlHttp.responseText);
|
||||
}else {
|
||||
saveResult("An error occured: " + oXmlHttp.statusText);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
oXmlHttp.send(sBody);
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
require_once "functions.php";
|
||||
require_once "includes.php";
|
||||
header("Content-type: application/xml");
|
||||
|
||||
print('<?xml version="1.0" encoding="ISO-8859-1"?'.'>');
|
||||
|
||||
$conn = db_connect();
|
||||
|
||||
$action = $_REQUEST['action'];
|
||||
if ($action == 'checkZip'){
|
||||
|
||||
$zip = $_REQUEST['zip'];
|
||||
if ($zip != "") {
|
||||
$sql = "SELECT poststed AS postarea
|
||||
FROM din_postnummer
|
||||
WHERE postnummer = $zip";
|
||||
|
||||
$result = $conn->query($sql);
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
$zip = $row->postarea;
|
||||
}else {
|
||||
$zip = "ugyldig postnummer";
|
||||
}
|
||||
}else {
|
||||
$zip = "ugyldig postnummer";
|
||||
}
|
||||
?>
|
||||
<postinfo>
|
||||
<postarea><?php print $zip; ?></postarea>
|
||||
</postinfo>
|
||||
<?php
|
||||
}else if ($action == 'register-documentcategory'){
|
||||
$ap = new ActionParser();
|
||||
$ap->performAction();
|
||||
$cat = new DocumentCategory(scriptParam("documentcategoryid"));
|
||||
$type = "document";
|
||||
|
||||
printAddCatXML($type, $cat);
|
||||
|
||||
}else if ($action == 'delete-documentcategory'){
|
||||
$ap = new ActionParser();
|
||||
$ap->performAction();
|
||||
$type = "document";
|
||||
printRemoveCatXML($type);
|
||||
|
||||
}else if ($action == 'register-eventcategory'){
|
||||
$ap = new ActionParser();
|
||||
$ap->performAction();
|
||||
$cat = new EventCategory(scriptParam("eventcategoryid"));
|
||||
$type = "event";
|
||||
|
||||
printAddCatXML($type, $cat);
|
||||
|
||||
}else if ($action == 'delete-eventcategory'){
|
||||
$ap = new ActionParser();
|
||||
$ap->performAction();
|
||||
$type = "event";
|
||||
printRemoveCatXML($type);
|
||||
|
||||
}else if ($action == 'register-jobcategory'){
|
||||
$ap = new ActionParser();
|
||||
$ap->performAction();
|
||||
$cat = new JobCategory(scriptParam("jobcategoryid"));
|
||||
$type = "job";
|
||||
printAddCatXML($type, $cat);
|
||||
|
||||
}else if ($action == 'delete-jobcategory'){
|
||||
$ap = new ActionParser();
|
||||
$ap->performAction();
|
||||
$type = "job";
|
||||
printRemoveCatXML($type);
|
||||
|
||||
}else if ($action == 'checkUsername') {
|
||||
$username = $_REQUEST['username'];
|
||||
$conn = db_connect("forum");
|
||||
$sql = sprintf("SELECT user_id FROM phpbb_users u "."WHERE username = '%s' ", $username);
|
||||
$result = & $conn->query($sql);
|
||||
if ($result->numRows() == 0) {
|
||||
$status = "true";
|
||||
}else {
|
||||
$status = "false";
|
||||
}
|
||||
?><username>
|
||||
<status><?php print $status; ?></status>
|
||||
</username>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function printAddCatXML($type, $cat){
|
||||
?>
|
||||
<category>
|
||||
<actiontype>add</actiontype>
|
||||
<cat-type><?php print $type; ?></cat-type>
|
||||
<id><?php print $cat->id; ?></id>
|
||||
<title><?php print $cat->title; ?></title>
|
||||
<text><?php print $cat->text; ?></text>
|
||||
<edit-href><?php print getEditLink($cat->id, $type."category"); ?></edit-href>
|
||||
<edit-text><?php print getEditText($type."category"); ?></edit-text>
|
||||
<delete-href><?php print getDeleteLink($cat->id, $type."category"); ?></delete-href>
|
||||
<delete-text><?php print getDeleteText($type."category"); ?></delete-text>
|
||||
</category>
|
||||
<?php
|
||||
}
|
||||
|
||||
function printRemoveCatXML($type){
|
||||
?>
|
||||
<category>
|
||||
<actiontype>remove</actiontype>
|
||||
<cat-type><?php print $type; ?></cat-type>
|
||||
<id><?php print scriptParam($type."categoryid"); ?></id>
|
||||
</category>
|
||||
<?php
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once "functions.php";
|
||||
require_once "includes.php";
|
||||
header("Content-type: application/xml");
|
||||
|
||||
print('<?xml version="1.0" encoding="ISO-8859-1"?'.'>');
|
||||
|
||||
$conn = db_connect();
|
||||
|
||||
$zip = $_REQUEST['zip'];
|
||||
|
||||
$sql = "SELECT poststed AS postarea
|
||||
FROM din_postnummer
|
||||
WHERE postnummer = $zip";
|
||||
|
||||
$result = $conn->query($sql);
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)){
|
||||
?><postinfo>
|
||||
<postarea><?php print $row->postarea; ?></postarea>
|
||||
</postinfo>
|
||||
<?php
|
||||
}else {
|
||||
?><postinfo>
|
||||
<postarea>ugyldig postnummer</postarea>
|
||||
</postinfo>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// Retrieve the data source name for connecting to the MySQL server and
|
||||
// selecting the sampdb database using our top-secret name and password
|
||||
|
||||
// To use the original MySQL module, $driver should be "mysql".
|
||||
// To use the "MySQL improved" module, $driver should be "mysqli".
|
||||
// This function is bloated to be able to use the same version on different servers.
|
||||
function getDSN($host = "default") {
|
||||
if ($host == "default" || $host == "dns") {
|
||||
$host_name = "localhost";
|
||||
$driver = "mysql";
|
||||
$user_name = "USERNAME";
|
||||
$password = "PASSWORD";
|
||||
$db_name = "DATABASE";
|
||||
}
|
||||
else
|
||||
if ($host == "forum") {
|
||||
$host_name = "localhost";
|
||||
$driver = "mysql";
|
||||
$user_name = "USERNAME";
|
||||
$password = "PASSWORD";
|
||||
$db_name = "DATABASE";
|
||||
}
|
||||
|
||||
return "$driver://$user_name:$password@$host_name/$db_name";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
require_once "includes.php";
|
||||
|
||||
|
||||
$conn =& DB_connect();
|
||||
|
||||
$id = $_GET['id'];
|
||||
|
||||
$nodelist = array();
|
||||
|
||||
// Pull file meta-data
|
||||
$sql = "SELECT * FROM din_document WHERE id = $id";
|
||||
$result =& $conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
print("Document: " . $result->toString());
|
||||
}
|
||||
|
||||
if ($result->numRows() != 1) {
|
||||
print("Not a valid file id!");
|
||||
}
|
||||
|
||||
$FileObj = $result->fetchRow(DB_FETCHMODE_OBJECT);
|
||||
// Pull the list of file inodes
|
||||
$sql = "SELECT id FROM din_documentdata
|
||||
WHERE document_id = $id
|
||||
ORDER BY id";
|
||||
$result =& $conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
print("Document: " . $result->toString());
|
||||
}
|
||||
|
||||
while ($cur = $result->fetchRow(DB_FETCHMODE_OBJECT)) {
|
||||
$nodelist[] = $cur->id;
|
||||
}
|
||||
|
||||
// Send down the header to the client
|
||||
header("Pragma: public");
|
||||
header("Cache-Control: cache, must-revalidate");
|
||||
header("Expires: 0");
|
||||
header("Content-Type: $FileObj->type");
|
||||
header("Content-Length: " . $FileObj->size);
|
||||
$FileObj->name = utf8_encode($FileObj->name);
|
||||
header("Content-Disposition: attachment; filename=\"$FileObj->name\"");
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
|
||||
// Loop thru and stream the nodes 1 by 1
|
||||
for ($i = 0 ; $i < count($nodelist) ; $i++) {
|
||||
$sql = "SELECT data FROM din_documentdata WHERE id = $nodelist[$i]";
|
||||
$result =& $conn->query($sql);
|
||||
if (DB::isError($result) == true){
|
||||
print("Document: " . $result->toString());
|
||||
} else {
|
||||
$DataObj =& $result->fetchRow(DB_FETCHMODE_OBJECT);
|
||||
print $DataObj->data;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* ul2finder
|
||||
* written by Christian Heilmann (http://icant.co.uk)
|
||||
* turns the nested list with the ID "finder" into a dynamic list
|
||||
* uses the CSS classes defined in the variables
|
||||
*/
|
||||
function ul2finder()
|
||||
{
|
||||
// Define variables used and classes to be applied/removed
|
||||
var i,uls,als,finder;
|
||||
var parentClass='parent';
|
||||
var showClass='shown';
|
||||
var hideClass='hidden';
|
||||
var openClass='open';
|
||||
|
||||
// check if our finder list exists, if not, stop all activities
|
||||
finder=document.getElementById('finder');
|
||||
if(!finder){return;}
|
||||
|
||||
// add the class domenabled to the body
|
||||
cssjs('add',document.body,'domenabled')
|
||||
|
||||
// loop through all lists inside finder, position and hide them
|
||||
// by applying the class hidden
|
||||
uls=document.getElementById('finder').getElementsByTagName('ul');
|
||||
for(i=0;i<uls.length;i++)
|
||||
{
|
||||
cssjs('add',uls[i],hideClass);
|
||||
}
|
||||
|
||||
// loop through all links of inside finder
|
||||
lis=document.getElementById('finder').getElementsByTagName('li');
|
||||
for(i=0;i<lis.length;i++)
|
||||
{
|
||||
// if the li containing the link has no nested list, skip this one
|
||||
if(!lis[i].getElementsByTagName('ul')[0])
|
||||
{
|
||||
|
||||
continue;
|
||||
}
|
||||
var newa=document.createElement('a');
|
||||
newa.href='#';
|
||||
newa.appendChild(document.createTextNode(lis[i].firstChild.nodeValue));
|
||||
lis[i].replaceChild(newa,lis[i].firstChild);
|
||||
// otherwise apply the parent class
|
||||
cssjs('add',newa,parentClass);
|
||||
|
||||
// if the user clicks on the link
|
||||
lis[i].getElementsByTagName('a')[0].onclick=function()
|
||||
{
|
||||
// loop through all lists inside finder
|
||||
for(var i=0;i<uls.length;i++)
|
||||
{
|
||||
// avoid the list connected to this link
|
||||
var found=false;
|
||||
for(j=0;j<uls[i].getElementsByTagName('ul').length;j++)
|
||||
{
|
||||
if(uls[i].getElementsByTagName('ul')[j] ==
|
||||
this.parentNode.getElementsByTagName('ul')[0])
|
||||
{
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// and hide all others
|
||||
if(!found)
|
||||
{
|
||||
cssjs('add',uls[i],hideClass)
|
||||
cssjs('remove',uls[i],showClass)
|
||||
cssjs('remove',uls[i].parentNode.getElementsByTagName('a')[0],openClass)
|
||||
cssjs('add',uls[i].parentNode.getElementsByTagName('a')[0],parentClass)
|
||||
}
|
||||
}
|
||||
// change the current link from parent to open
|
||||
cssjs('swap',this,parentClass,openClass)
|
||||
// show the current nested list
|
||||
cssjs('add',this.parentNode.getElementsByTagName('ul')[0],showClass)
|
||||
|
||||
// don't follow the real HREF of the link
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* cssjs
|
||||
* written by Christian Heilmann (http://icant.co.uk)
|
||||
* eases the dynamic application of CSS classes via DOM
|
||||
* parameters: action a, object o and class names c1 and c2 (c2 optional)
|
||||
* actions: swap exchanges c1 and c2 in object o
|
||||
* add adds class c1 to object o
|
||||
* remove removes class c1 from object o
|
||||
* check tests if class c1 is applied to object o
|
||||
* example: cssjs('swap',document.getElementById('foo'),'bar','baz');
|
||||
*/
|
||||
function cssjs(a,o,c1,c2) {
|
||||
switch (a){
|
||||
case 'swap':
|
||||
o.className = !cssjs('check',o,c1) ? o.className.replace(c2,c1) : o.className.replace(c1,c2);
|
||||
break;
|
||||
case 'add':
|
||||
if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
|
||||
break;
|
||||
case 'remove':
|
||||
var rep=o.className.match(' '+c1)?' '+c1:c1;
|
||||
o.className=o.className.replace(rep,'');
|
||||
break;
|
||||
case 'check':
|
||||
return new RegExp('\\b'+c1+'\\b').test(o.className)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if the browser supports DOM, and start the script if it does.
|
||||
if(document.getElementById && document.createTextNode){
|
||||
window.onload=ul2finder;
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
function initializeUsersForm(){
|
||||
var username = document.getElementById("username");
|
||||
var city = document.getElementById("city");
|
||||
var state = document.getElementById("state");
|
||||
var country = document.getElementById("country");
|
||||
var postarea = document.getElementById("postarea");
|
||||
|
||||
var division = document.getElementById("division");
|
||||
var group = document.getElementById("group_id");
|
||||
|
||||
var checkType = document.getElementById("addresstype");
|
||||
|
||||
checkType.onclick = function() {
|
||||
if (checkType.checked){
|
||||
city.parentNode.parentNode.style.display = "";
|
||||
state.parentNode.parentNode.style.display = "";
|
||||
country.parentNode.parentNode.style.display = "";
|
||||
postarea.parentNode.parentNode.style.display = "none";
|
||||
}else {
|
||||
city.parentNode.parentNode.style.display = "none";
|
||||
state.parentNode.parentNode.style.display = "none";
|
||||
country.parentNode.parentNode.style.display = "none";
|
||||
postarea.parentNode.parentNode.style.display = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (checkType.getAttribute("checked") == "checked"){
|
||||
city.parentNode.parentNode.style.display = "";
|
||||
state.parentNode.parentNode.style.display = "";
|
||||
country.parentNode.parentNode.style.display = "";
|
||||
postarea.parentNode.parentNode.style.display = "none";
|
||||
}else {
|
||||
city.parentNode.parentNode.style.display = "none";
|
||||
state.parentNode.parentNode.style.display = "none";
|
||||
country.parentNode.parentNode.style.display = "none";
|
||||
}
|
||||
|
||||
//division
|
||||
if (division != null){
|
||||
var checkDiv = document.getElementById("active");
|
||||
|
||||
checkDiv.onclick = function() {
|
||||
if (checkDiv.checked) {
|
||||
division.parentNode.parentNode.style.display = "";
|
||||
}else {
|
||||
division.parentNode.parentNode.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
if (checkDiv.checked){
|
||||
division.parentNode.parentNode.style.display = "";
|
||||
}else {
|
||||
division.parentNode.parentNode.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
//groups
|
||||
if (group != null){
|
||||
var checkGroup = document.getElementById("group");
|
||||
|
||||
checkGroup.onclick = function() {
|
||||
if (checkGroup.checked) {
|
||||
group.parentNode.parentNode.style.display = "";
|
||||
}else {
|
||||
group.parentNode.parentNode.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
if (checkGroup.checked){
|
||||
group.parentNode.parentNode.style.display = "";
|
||||
}else {
|
||||
group.parentNode.parentNode.style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function initializeJobForm(elem){
|
||||
var radioOn = document.getElementById("job-true");
|
||||
var radioOff = document.getElementById("job-false");
|
||||
var div = document.getElementById(elem);
|
||||
|
||||
radioOn.onclick = function() {
|
||||
cssjs('remove', div, 'disabled');
|
||||
}
|
||||
|
||||
radioOff.onclick = function() {
|
||||
cssjs('add', div, 'disabled');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function repeatElement(id){
|
||||
var element = document.getElementById(id);
|
||||
alert('repeat ' + element + "\nDenne funksjonen kommer snart!");
|
||||
}
|
||||
|
||||
function validateSize(id, size){
|
||||
var element = document.getElementById(id);
|
||||
if (element.value.length > size){
|
||||
alert("Max "+size+" characters!");
|
||||
element.focus();
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function validateDatetime(id){
|
||||
var element = document.getElementById(id);
|
||||
var date = element.value;
|
||||
|
||||
var reg = /^(19|20\d{2})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|[3][01])\s(([01][0-9]|[2][0-3]):[0-5][0-9])$/g;
|
||||
var found = date.match(reg);
|
||||
if (found != null){
|
||||
return true;
|
||||
}else {
|
||||
alert("Ugyldig tidsformat!\n\nAngi tid som yyyy-mm-dd hh:mm\n\n" +
|
||||
"F. eks.: 2005-10-02 18:13\n\nVennligst ogs? p?se at verdiene er gyldige.");
|
||||
element.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function validateDate(id){
|
||||
var element = document.getElementById(id);
|
||||
var date = element.value;
|
||||
|
||||
if (date.length == 8) {
|
||||
date = date.substr(0, 4) + "-" + date.substr(4, 2) + "-" + date.substr(6, 2);
|
||||
element.value = date;
|
||||
}
|
||||
|
||||
var reg = /^((19|20)\d{2})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|[3][01])$/g;
|
||||
var found = date.match(reg);
|
||||
if (found != null){
|
||||
return true;
|
||||
}else {
|
||||
alert("Ugyldig tidsformat!\n\nAngi tid som yyyy-mm-dd\n\n" +
|
||||
"F. eks.: 2005-10-02\n\nVennligst ogs? p?se at verdiene er gyldige.");
|
||||
element.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function validateTime(id){
|
||||
var element = document.getElementById(id);
|
||||
var time = element.value;
|
||||
var error = false;
|
||||
|
||||
if (time.length == 1) {
|
||||
if (isNaN(time)){
|
||||
error = true;
|
||||
}else {
|
||||
time = "0" + time + ":00";
|
||||
element.value = time;
|
||||
}
|
||||
}else if (time.length == 2) {
|
||||
if (isNaN(time) || time >= 24){
|
||||
error = true;
|
||||
}else {
|
||||
time = time + ":00";
|
||||
element.value = time;
|
||||
}
|
||||
}else if (time.length == 4) {
|
||||
if (isNaN(time)){
|
||||
error = true;
|
||||
}else {
|
||||
if (time.substr(2, 2) > 59){
|
||||
time = time.substr(0,2) + "59";
|
||||
}
|
||||
time = time.substr(0, 2) + ":" + time.substr(2, 2);
|
||||
element.value = time;
|
||||
|
||||
}
|
||||
}else if (time.length == 5) {
|
||||
if (isNaN(time.substr(0, 2)) || isNaN(time.substr(3, 2))){
|
||||
error = true;
|
||||
}else {
|
||||
if (time.substr(3, 2) > 59){
|
||||
time = time.substr(0,2) + ":59";
|
||||
}
|
||||
time = time.substr(0, 2) + ":" + time.substr(3, 2);
|
||||
element.value = time;
|
||||
}
|
||||
}else {
|
||||
error = true;
|
||||
}
|
||||
|
||||
if (!error){
|
||||
return true;
|
||||
}else {
|
||||
alert("Ugyldig tidsformat!\n\nAngi tid som hh:mm\n\n" +
|
||||
"F. eks.: 18:13\n\nVennligst også påse at verdiene er gyldige.");
|
||||
element.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function validateEmpty(id, tekst){
|
||||
var element = document.getElementById(id);
|
||||
if (element.value.length == 0){
|
||||
alert(tekst+" must be filled in!");
|
||||
element.focus();
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function validateAllFieldsNotEmpty(id){
|
||||
var fields = document.getElementById(id).getElementsByTagName('input');
|
||||
var errorMsg = '';
|
||||
for (var i = 0; i < fields.length; i++){
|
||||
if (fields[i].value == ''){
|
||||
errorMsg += fields[i].getAttribute('name') + " m? angis\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMsg != ''){
|
||||
alert(errorMsg);
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function checkUsername(username){
|
||||
makeUsernameRequest("ajax.php?action=checkUsername&username=" + username);
|
||||
}
|
||||
|
||||
function checkZip(zipCode){
|
||||
var t = document.getElementById("addresstype").checked;
|
||||
if (t){
|
||||
return true;
|
||||
}else {
|
||||
var z = zipCode.value;
|
||||
makeZipRequest("ajax.php?action=checkZip&zip=" + z);
|
||||
}
|
||||
}
|
||||
|
||||
function addCategory(type){
|
||||
var title = document.getElementById("title").value;
|
||||
var text = document.getElementById("text").value;
|
||||
var url = "ajax.php?action=register-" + type + "category&title=" + title + "&text=" + text;
|
||||
makeCatRequest(url);
|
||||
}
|
||||
|
||||
function deleteObject(type, id){
|
||||
var url = "ajax.php?action=delete-" + type + "&" + type + "id=" + id;
|
||||
makeCatRequest(url);
|
||||
}
|
||||
|
||||
function textCounter(field, id, maxlimit) {
|
||||
var c = document.getElementById(id);
|
||||
var f = document.getElementById(field);
|
||||
if (c != null){
|
||||
c.value = maxlimit - f.value.length;
|
||||
}
|
||||
}
|
||||
|
||||
function validateURL(element){
|
||||
var str = element.value;
|
||||
if (element.value.substr(0, 7) == "http://"){
|
||||
//alert("URL skal ikke starte med 'http://'!");
|
||||
element.value = element.value.substr(7, element.value.length);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleDisplay(id){
|
||||
var element = document.getElementById(id);
|
||||
if (element.style.display == "none"){
|
||||
element.style.display = '';//default
|
||||
}else {
|
||||
element.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleDisplayObject(element){
|
||||
if (element.style.display == "none"){
|
||||
element.style.display = '';//default
|
||||
}else {
|
||||
element.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleElements(tag, className, caller) {
|
||||
if (caller.checked) {
|
||||
var value = "";
|
||||
}else {
|
||||
var value = "none";
|
||||
}
|
||||
var elements = document.getElementsByTagName(tag);
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
if (elements[i].className == className) {
|
||||
elements[i].style.display = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleText(oObject, tA, tB) {
|
||||
if (oObject.innerHTML == tA) {
|
||||
oObject.innerHTML = tB;
|
||||
}else {
|
||||
oObject.innerHTML = tA;
|
||||
}
|
||||
}
|
||||
|
||||
function formFieldShowHelp(oEvent, oField, tMessage) {
|
||||
|
||||
var oTd = oField.parentNode;
|
||||
oTd.style.position = "relative";
|
||||
var oDiv = document.createElement("div");
|
||||
oDiv.innerHTML = tMessage + '<div class="helpMessageClose" onclick="toggleDisplayObject(this.parentNode)">X</div>';
|
||||
oDiv.className = "formHelpMessage";
|
||||
if (oEvent.pageY) {
|
||||
var iTop = oEvent.pageY - 10;
|
||||
var iLeft = oEvent.pageX - 10;
|
||||
oDiv.style.position = "absolute";
|
||||
oDiv.style.top = iTop+"px";
|
||||
oDiv.style.left = iLeft+"px";
|
||||
}else {
|
||||
oDiv.style.position = "relative";
|
||||
}
|
||||
|
||||
oTd.appendChild(oDiv);
|
||||
}
|
||||
|
||||
function formFieldHideHelp(oField) {
|
||||
var oTd = oField.parentNode;
|
||||
oTd.removeChild(oTd.lastChild);
|
||||
}
|
||||
|
||||
function ajaxFindUser(oField) {
|
||||
var divParent = oField.parentNode;
|
||||
divParent.style.position = "relative";
|
||||
var oDiv = document.createElement("div");
|
||||
|
||||
oDiv.innerHTML = oField.value + '<div class="helpMessageClose" onclick="toggleDisplayObject(this.parentNode)">X</div>';
|
||||
oDiv.className = "formHelpMessage";
|
||||
oDiv.style.position = "absolute";
|
||||
oDiv.style.top = "27px";
|
||||
oDiv.style.left = "100px";
|
||||
|
||||
divParent.appendChild(oDiv);
|
||||
}
|
||||
|
||||
function StringBuffer() {
|
||||
this.__strings__ = new Array;
|
||||
}
|
||||
|
||||
StringBuffer.prototype.append = function(str){
|
||||
this.__strings__.push(str);
|
||||
};
|
||||
|
||||
StringBuffer.prototype.toString = function(){
|
||||
return this.__strings__.join("");
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
require_once "includes.php";
|
||||
|
||||
$gigid = scriptParam("gigid");
|
||||
|
||||
$gig = new Concert($gigid);
|
||||
$store = scriptParam("store");
|
||||
$programid = scriptParam("programid");
|
||||
|
||||
|
||||
if ($store > 0){
|
||||
$sql = "UPDATE weekprogram SET " .
|
||||
" gig$store = $gigid " .
|
||||
"WHERE " .
|
||||
" id = $programid";
|
||||
$conn = db_connect();
|
||||
$result =& $conn->query($sql);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div style="text-align: center;">
|
||||
<img src="http://www.studentersamfundet.no/imageResize.php?pic=bilder/program/<?php print $gig->picture;?>&maxwidth=150" alt="" />
|
||||
</div>
|
||||
<h2 style="margin: 0px 3px; font-size: 14px;"><?php print htmlentities($gig->name); ?></h2>
|
||||
<p style="margin: 0px 3px; font-style: italic;"><?php print strftime("%A %d. %B, %H:%M", strtotime($gig->time)); ?></p>
|
||||
<p style="margin: 5px 3px 0;"><?php print stripslashes($gig->intro); ?></p>
|
||||
<p style="margin: 5px 3px;"><a href="http://www.studentersamfundet.no/vis.php?ID=<?php print $gig->id; ?>">Les mer»</a></p>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
header("Content-type: application/xml");
|
||||
print('<?xml version="1.0" encoding="ISO-8859-1"?'.'>');
|
||||
|
||||
require_once "includes.php";
|
||||
|
||||
$userid = $_GET["userid"];
|
||||
|
||||
$user = new User($userid);
|
||||
$user->grantCardno();
|
||||
|
||||
?>
|
||||
<user>
|
||||
<cardno><?php print $user->cardno; ?></cardno>
|
||||
<expires><?php print date("Y", strtotime($user->expires)); ?></expires>
|
||||
</user>
|
||||
|
After Width: | Height: | Size: 185 B |
|
After Width: | Height: | Size: 788 B |
|
After Width: | Height: | Size: 655 B |
|
After Width: | Height: | Size: 901 B |
|
After Width: | Height: | Size: 601 B |
|
After Width: | Height: | Size: 984 B |
|
After Width: | Height: | Size: 174 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 177 B |
|
After Width: | Height: | Size: 269 B |
|
After Width: | Height: | Size: 537 B |
|
After Width: | Height: | Size: 915 B |
@@ -0,0 +1,526 @@
|
||||
/* =general
|
||||
*********************************************************************/
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
line-height: 1.5em;
|
||||
font-family: arial, sans-serif;
|
||||
}
|
||||
|
||||
img {
|
||||
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 5px 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
strong, p.strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* =links
|
||||
*********************************************************************/
|
||||
|
||||
a {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
color: #00D;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #00D;
|
||||
}
|
||||
|
||||
th a {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
th a:visited {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.optionsMenu a, a.button {
|
||||
border: 1px solid #CCC;
|
||||
background: #DDD;
|
||||
padding: 1px 5px;
|
||||
margin: 3px 0;
|
||||
letter-spacing: 1px;
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
a.read {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
a.unread {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a.skip-nav {
|
||||
}
|
||||
|
||||
/* =lists
|
||||
*********************************************************************/
|
||||
|
||||
ul {
|
||||
|
||||
}
|
||||
|
||||
li {
|
||||
|
||||
}
|
||||
|
||||
ul.linker, .linker li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* =forms
|
||||
*********************************************************************/
|
||||
|
||||
form {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
textarea, input {
|
||||
font-family: arial, sans-serif;
|
||||
line-height: 1.2em;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.readonly {
|
||||
background: inherit;
|
||||
border: none;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
width: 90%;
|
||||
max-width: 600px;
|
||||
padding: 15px;
|
||||
border: 3px solid #CCC;
|
||||
}
|
||||
|
||||
fieldset label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
legend {
|
||||
font-weight: bold;
|
||||
padding: 0 5px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
fieldset input, fieldset select, fieldset textarea {
|
||||
margin: 0 15px;
|
||||
}
|
||||
|
||||
input.submit {
|
||||
margin: 0px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
div.horizontal-form {
|
||||
padding: 3px;
|
||||
margin: 5px 0;
|
||||
background: #EEE;
|
||||
border: 1px solid #CCC;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.delete {
|
||||
text-align: right;
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
||||
/* =tables
|
||||
*********************************************************************/
|
||||
|
||||
table {
|
||||
margin: 5px 0;
|
||||
padding: 0;
|
||||
border: 1px solid #CCC;
|
||||
}
|
||||
|
||||
th {
|
||||
padding: 0 5px;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
letter-spacing: 2px;
|
||||
background: #DDD;
|
||||
}
|
||||
|
||||
tr {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: top;
|
||||
padding: 0px 5px;
|
||||
background: #EEE;
|
||||
}
|
||||
|
||||
td.label {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.number {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.date {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
table.calendar {
|
||||
width: 98%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.calendar td {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
td.passive {
|
||||
background: #AAA;
|
||||
}
|
||||
|
||||
td.weekNumber {
|
||||
background: #DDD;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.calendar td div {
|
||||
padding: 2px 1px;
|
||||
margin: 1px;
|
||||
font-size: 0.9em;
|
||||
line-height: 1em;
|
||||
border-bottom: 1px dotted #000;
|
||||
}
|
||||
|
||||
td h4 {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
th a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
table.sortable tr:hover td {
|
||||
background: #DDD;
|
||||
}
|
||||
|
||||
td.unread {
|
||||
text-align: center;
|
||||
font-size: 1.8em;
|
||||
line-height: 0.1em;
|
||||
padding: 15px 5px 0px 3px;
|
||||
}
|
||||
|
||||
|
||||
/* =headings
|
||||
*********************************************************************/
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size:1.2em;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
}
|
||||
/* =header
|
||||
*********************************************************************/
|
||||
#header {
|
||||
background-color: #EEE;
|
||||
border: 1px solid #CCC;
|
||||
-moz-border-radius: 8px;
|
||||
color: #000;
|
||||
text-align: center;
|
||||
letter-spacing: 3px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#header h1 a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* =navigation
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
#nav {
|
||||
background-color: #EEE;
|
||||
border: 1px solid #CCC;
|
||||
-moz-border-radius: 8px;
|
||||
color: #000;
|
||||
margin: 5px 0;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
#navList {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
li.menulist {
|
||||
background: url(graphics/minus.png) no-repeat 3px 0.3em;
|
||||
line-height: 1.2em;
|
||||
list-style: none outside;
|
||||
margin: 0px 0 10px;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.jsenabled li.menulist {
|
||||
background: url(graphics/plus.png) no-repeat 3px 0.3em;
|
||||
}
|
||||
|
||||
.jsenabled .menu, .jsenabled .submenu {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menu, .submenu {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.menu li, .submenu li {
|
||||
background: #EEE;
|
||||
list-style: none outside;
|
||||
margin: 3px 5px;
|
||||
padding: 0px 3px;
|
||||
border: 1px dotted #AAA;
|
||||
}
|
||||
|
||||
.menu li:hover, .submenu li:hover {
|
||||
background: #DDD;
|
||||
}
|
||||
|
||||
#nav li a {
|
||||
color: black;
|
||||
}
|
||||
|
||||
a.switch {
|
||||
background-color: transparent;
|
||||
color: #000;
|
||||
font-size: .9em;
|
||||
line-height: 1em;
|
||||
padding-left: 5px;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
a.switch:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.menu li a, .submenu li a {
|
||||
display: block;
|
||||
background-color: transparent;
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.menu li a:hover, submenu li a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
span.key {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#calHeader {
|
||||
width: 400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#previous {
|
||||
float: left;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#next {
|
||||
float: right;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#previous a, #next a {
|
||||
border: 1px solid #CCC;
|
||||
font-weight: bold;
|
||||
padding: 0 5px;
|
||||
margin: 0px;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
/* =content
|
||||
*********************************************************************/
|
||||
#content {
|
||||
padding: 0px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
div.text-column {
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
* html div.text-column {
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
|
||||
.concert img {
|
||||
float: right;
|
||||
margin: 0px 0px 3px 3px;
|
||||
}
|
||||
|
||||
|
||||
p.date {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
p.date:first-letter {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
|
||||
p.intro {
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.messages, div.errors {
|
||||
margin: 0 0 5px 0;
|
||||
padding: 0;
|
||||
background: #EEE;
|
||||
border: 1px solid #CCC;
|
||||
}
|
||||
|
||||
div.timeData {
|
||||
border: 1px solid #CCC;
|
||||
background: #EEE;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
div.optionsMenu {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
div.comments {
|
||||
border-top: 2px solid #CCC;
|
||||
|
||||
}
|
||||
|
||||
div.comment {
|
||||
border-top: 2px solid #CCC;
|
||||
padding: 5px 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
div.comment-meta {
|
||||
position: absolute;
|
||||
|
||||
}
|
||||
|
||||
div.comment-main {
|
||||
margin-left: 150px;
|
||||
min-height: 60px;
|
||||
border-left: 2px dotted #CCC;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
* html div.comment-main {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
/* =footer
|
||||
*********************************************************************/
|
||||
#footer {
|
||||
clear: both;
|
||||
text-align: center;
|
||||
background: #EEE;
|
||||
border: 1px solid #CCC;
|
||||
-moz-border-radius: 8px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* =extras
|
||||
*********************************************************************/
|
||||
.domenabled ul#finder, .domenabled ul#finder li, .domenabled ul#finder ul {
|
||||
list-style-type:none;
|
||||
margin: 5px 0;
|
||||
padding:0;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.domenabled ul#finder ul.hidden {
|
||||
display: none;
|
||||
}
|
||||
.domenabled ul#finder ul.shown {
|
||||
margin: 3px 25px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.domenabled ul#finder li a {
|
||||
}
|
||||
|
||||
.domenabled #finder a.open {
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.domenabled #finder a.parent {
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
||||
.domenabled div.disabled {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/*
|
||||
*This simple script is written by Gunnar Lium (post@gunnarlium.com).
|
||||
*
|
||||
*Usage: <img src="imageResize.php?pic=source.type&maxwidth=xxx>
|
||||
*Replace source.type with the relevant imagesource and xxx with desired maxwidth.
|
||||
*
|
||||
*This script supports .gif, .jpg and .png formats, but further extensions should be
|
||||
*quite easy to implement.
|
||||
*
|
||||
*Please feel free to modify and use this script at your own leisure!
|
||||
*
|
||||
*Update 18/03-05: Added support for transparent gifs/pngs.
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
// Filename and new maxwidth from GET
|
||||
$filename = $_GET['pic'];
|
||||
if (isset($_GET['maxwidth'])){
|
||||
$maxwidth = $_GET['maxwidth'];
|
||||
}
|
||||
if (isset($_GET['maxheight'])){
|
||||
$maxheight = $_GET['maxheight'];
|
||||
}
|
||||
|
||||
//Quality setting for jpegs, if not supplied as argument, default value is used (75);
|
||||
if (isset($_GET['quality'])){
|
||||
$quality = $_GET['quality'];
|
||||
}else {
|
||||
$quality = 75;
|
||||
}
|
||||
|
||||
list($width, $height, $format) = getimagesize($filename);
|
||||
|
||||
// Define content type and load source
|
||||
switch ($format){
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
header('Content-type: image/gif');
|
||||
$source = imagecreatefromgif($filename);
|
||||
break;
|
||||
case 2:
|
||||
header('Content-type: image/jpeg');
|
||||
$source = imagecreatefromjpeg($filename);
|
||||
break;
|
||||
case 3:
|
||||
header('Content-type: image/png');
|
||||
$source = imagecreatefrompng($filename);
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($maxwidth) && isset($maxheight)){
|
||||
// Get new sizes
|
||||
if ($width < $maxwidth){
|
||||
$newwidth = $width;
|
||||
$newheight = $height;
|
||||
}else {
|
||||
$div = $maxwidth/$width;
|
||||
$newwidth = $width * $div;
|
||||
$newheight = $height * $div;
|
||||
}
|
||||
if ($newheight > $maxheight){
|
||||
$div = $maxheight/$newheight;
|
||||
$newwidth = $newwidth * $div;
|
||||
$newheight = $newheight * $div;
|
||||
}
|
||||
}else if (isset($maxwidth)){
|
||||
// Get new sizes
|
||||
if ($width < $maxwidth){
|
||||
$newwidth = $width;
|
||||
$newheight = $height;
|
||||
}else {
|
||||
$div = $maxwidth/$width;
|
||||
$newwidth = $width * $div;
|
||||
$newheight = $height * $div;
|
||||
}
|
||||
}else if (isset($maxheight)){
|
||||
// Get new sizes
|
||||
if ($height < $maxheight){
|
||||
$newwidth = $width;
|
||||
$newheight = $height;
|
||||
}else {
|
||||
$div = $maxheight/$height;
|
||||
$newwidth = $width * $div;
|
||||
$newheight = $height * $div;
|
||||
}
|
||||
}
|
||||
|
||||
// Load new image
|
||||
if ($format != 2){
|
||||
$newimage = imagecreate($newwidth, $newheight);
|
||||
$color = ImageColorAllocate($newimage, 255, 255, 255);
|
||||
imagefill($newimage, 0, 0, $color);
|
||||
}else {
|
||||
$newimage = imagecreatetruecolor($newwidth, $newheight);
|
||||
}
|
||||
// Resize image
|
||||
imagecopyresized($newimage, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
||||
|
||||
// Output image
|
||||
switch ($format){
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
imagegif($newimage);
|
||||
break;
|
||||
case 2:
|
||||
imagejpeg($newimage, "", $quality);
|
||||
break;
|
||||
case 3:
|
||||
imagepng($newimage);
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 32 KiB |