From ca1fcc8173818c6e47cf4d33efc8bddd1c8145cb Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 13 Sep 2010 21:15:05 +0200 Subject: [PATCH] Adding changes from production server. Pls, stop making changes live. Hrmpf. --- css/style.css | 662 +++- inside/ActionParser.php | 2 +- inside/Categories.php | 68 +- inside/MemberCard.php | 219 ++ inside/MembershipActivationCode.php | 186 + inside/MembershipCard.php | 219 ++ inside/Page.php | 32 +- inside/Payment.php | 7 +- inside/User.php | 3094 +++++++++-------- inside/ajax.php | 8 +- inside/checkZip.php | 2 +- inside/credentials.php | 39 + inside/domain/DomainObject.php | 64 + inside/domain/HelperFactory.php | 51 + inside/domain/Membership.php | 68 + inside/domain/MembershipCard.php | 75 + inside/domain/ObjectWatcher.php | 112 + inside/domain/User.php | 150 + inside/domain/UserAddress.php | 39 + inside/domain/UserPhone.php | 38 + inside/domain/UserUpdate.php | 58 + inside/images/products/20.jpg | Bin 0 -> 10387 bytes inside/index.php | 2 +- inside/mapper/Collection.php | 85 + inside/mapper/Mapper.php | 94 + inside/mapper/MembershipCardCollection.php | 14 + inside/mapper/MembershipCardMapper.php | 86 + inside/mapper/MembershipCollection.php | 14 + inside/mapper/MembershipMapper.php | 105 + inside/mapper/UserAddressCollection.php | 14 + inside/mapper/UserAddressMapper.php | 93 + inside/mapper/UserCollection.php | 14 + inside/mapper/UserMapper.php | 108 + inside/mapper/UserUpdateCollection.php | 14 + inside/mapper/UserUpdateMapper.php | 96 + inside/membershipcard.php | 58 + inside/membershipcard_db.php | 101 + inside/pos.php | 2 +- inside/screen.css.backup | 700 ++++ inside/testdomain.php | 51 + inside/tmp | 406 +++ vaktliste/App/Base/ApplicationRegistry.php | 144 +- vaktliste/App/Base/Registry.php | 14 +- vaktliste/App/Base/RequestRegistry.php | 78 +- vaktliste/App/Base/SessionRegistry.php | 110 +- vaktliste/App/Calendar/Calendar.php | 151 + vaktliste/App/Command/AddShift.php | 120 +- vaktliste/App/Command/Command.php | 80 +- vaktliste/App/Command/CommandHelper.php | 24 +- vaktliste/App/Command/DefaultCommand.php | 48 +- vaktliste/App/Command/GetShift.php | 37 + vaktliste/App/Command/Login.php | 52 +- vaktliste/App/Command/Logout.php | 28 +- vaktliste/App/Command/ViewCalendar.php | 53 + vaktliste/App/Controller/AccessManager.php | 70 +- vaktliste/App/Controller/AppController.php | 230 +- .../App/Controller/ApplicationHelper.php | 228 +- vaktliste/App/Controller/Controller.php | 68 +- vaktliste/App/Controller/ControllerMap.php | 82 +- vaktliste/App/Controller/Request.php | 148 +- vaktliste/App/Domain/Division.php | 94 +- vaktliste/App/Domain/DomainObject.php | 124 +- vaktliste/App/Domain/Group.php | 140 +- vaktliste/App/Domain/HelperFactory.php | 135 +- vaktliste/App/Domain/Location.php | 54 +- vaktliste/App/Domain/ObjectWatcher.php | 222 +- vaktliste/App/Domain/User.php | 338 +- vaktliste/App/Domain/UserPhone.php | 74 +- vaktliste/App/Domain/WorkSalaryType.php | 74 +- vaktliste/App/Domain/WorkShift.php | 282 +- vaktliste/App/Domain/WorkShiftUpdate.php | 114 +- vaktliste/App/Domain/WorkShiftWorker.php | 152 +- vaktliste/App/Mapper/Collection.php | 172 +- vaktliste/App/Mapper/DivisionCollection.php | 28 +- vaktliste/App/Mapper/DivisionMapper.php | 184 +- vaktliste/App/Mapper/DomainObjectFactory.php | 12 +- vaktliste/App/Mapper/GroupCollection.php | 28 +- vaktliste/App/Mapper/GroupMapper.php | 236 +- vaktliste/App/Mapper/LocationCollection.php | 28 +- vaktliste/App/Mapper/LocationMapper.php | 160 +- vaktliste/App/Mapper/Mapper.php | 196 +- vaktliste/App/Mapper/UserCollection.php | 26 +- vaktliste/App/Mapper/UserMapper.php | 250 +- vaktliste/App/Mapper/UserObjectFactory.php | 9 + .../App/Mapper/WorkSalaryTypeCollection.php | 28 +- vaktliste/App/Mapper/WorkSalaryTypeMapper.php | 168 +- vaktliste/App/Mapper/WorkShiftCollection.php | 28 +- vaktliste/App/Mapper/WorkShiftMapper.php | 278 +- .../App/Mapper/WorkShiftUpdateCollection.php | 26 +- .../App/Mapper/WorkShiftUpdateMapper.php | 216 +- .../App/Mapper/WorkShiftWorkerCollection.php | 28 +- .../App/Mapper/WorkShiftWorkerMapper.php | 244 +- vaktliste/App/View/Common/footer.php | 12 +- vaktliste/App/View/Common/header.php | 194 +- vaktliste/App/View/Common/menu.php | 74 +- vaktliste/App/View/ViewHelper.php | 20 +- vaktliste/App/View/calendar.php | 137 +- vaktliste/App/View/home.php | 79 + vaktliste/App/View/login.php | 96 +- vaktliste/App/View/test.php | 26 +- vaktliste/App/View/view-shift.php | 89 + vaktliste/App/View/welcome.php | 40 +- vaktliste/Calendar.php | 36 + vaktliste/index.php | 118 +- 104 files changed, 9231 insertions(+), 4853 deletions(-) create mode 100644 inside/MemberCard.php create mode 100644 inside/MembershipActivationCode.php create mode 100644 inside/MembershipCard.php create mode 100644 inside/credentials.php create mode 100644 inside/domain/DomainObject.php create mode 100644 inside/domain/HelperFactory.php create mode 100644 inside/domain/Membership.php create mode 100644 inside/domain/MembershipCard.php create mode 100644 inside/domain/ObjectWatcher.php create mode 100644 inside/domain/User.php create mode 100644 inside/domain/UserAddress.php create mode 100644 inside/domain/UserPhone.php create mode 100644 inside/domain/UserUpdate.php create mode 100644 inside/images/products/20.jpg create mode 100644 inside/mapper/Collection.php create mode 100644 inside/mapper/Mapper.php create mode 100644 inside/mapper/MembershipCardCollection.php create mode 100644 inside/mapper/MembershipCardMapper.php create mode 100644 inside/mapper/MembershipCollection.php create mode 100644 inside/mapper/MembershipMapper.php create mode 100644 inside/mapper/UserAddressCollection.php create mode 100644 inside/mapper/UserAddressMapper.php create mode 100644 inside/mapper/UserCollection.php create mode 100644 inside/mapper/UserMapper.php create mode 100644 inside/mapper/UserUpdateCollection.php create mode 100644 inside/mapper/UserUpdateMapper.php create mode 100644 inside/membershipcard.php create mode 100644 inside/membershipcard_db.php create mode 100644 inside/screen.css.backup create mode 100644 inside/testdomain.php create mode 100644 inside/tmp create mode 100644 vaktliste/App/Calendar/Calendar.php create mode 100644 vaktliste/App/Command/GetShift.php create mode 100644 vaktliste/App/Command/ViewCalendar.php create mode 100644 vaktliste/App/Mapper/UserObjectFactory.php create mode 100644 vaktliste/App/View/home.php create mode 100644 vaktliste/App/View/view-shift.php diff --git a/css/style.css b/css/style.css index 2d38361..61b9619 100644 --- a/css/style.css +++ b/css/style.css @@ -1,137 +1,571 @@ -table - { - width: 100%; - border-collapse: collapse; - background-color: white; - color: black; - font: 10pt verdana, arial; - margin-bottom: 25%; /* %, px, em, ex ? */ - } +@import 'css/reset.css'; +@import 'css/rebuild.css'; +@import 'css/wp-css'; -tr.subhead - { - background-color: #cccccc; - } -th - { - padding: 0 3%; - } +/** + * Structure + */ -th.alt - { - background-color: black; - color: white; - padding: 3% 3% 2%; - } +/* Layout */ +/*#wrapper */ +#header .site-title, +#header #menu ul ul, +#main { + width:1000px; + margin:auto; + position:relative; +} +#main { + margin-top:-20px; +} +#content { + float:left; + margin:50px 0; + width:1000px; + background: #ffffff; + position:relative; +} -td - { - padding: 0 3%; - } +.page-medlemmer .column, +.home .column { + width:400px; + margin:0; + padding:50px; + float:left; +} -tr.alt - { - background-color: #eeeeee; - } +.hentry, +#program { + margin:0; + width: 518px; + overflow:hidden; + background:#ffffff; + margin-bottom: 30px; +} -h1 - { - font: 24pt verdana, arial; - margin: 0; - } +.single .hentry { + float:left; + width: 500px; + margin:50px; +} -h2 - { - font: 18pt verdana, arial; - margin: 0; - } +.page-medlemmer .hentry { + width:1000px; + margin:0; +} -h3 - { - font: 12pt verdana, arial; - margin: 0; - } +.page-medlemmer .hentry h1 { + margin:40px 50px 0; +} -th a - { - color: #00008b; - font: 8pt verdana, arial; - } +#primary.sidebar,#secondary.sidebar { + width:300px; + float:left; + padding:30px 50px; +} +* html #primary { + left: 20px; + position: relative; +} +.program-teaser { + width:1000px; + margin:auto; +} +/* end layout */ -a - { - color: #00008b; - text-decoration: none; - } +/* Header */ +body.dns { + background:#efefef; +} +/*body.dns */ +#header { + background:#191919 url('img/header-210x.png') repeat-x bottom; +} +#header { + height:155px; + margin-bottom:10px; + overflow:hidden; + position:relative; +} +.site-title { + z-index:999 +} +.site-title a { + background: url('img/bannerindex-400.png') no-repeat -20px 0; + display:block; + height:63px; + margin-top:20px; + text-indent:-9999px; + width:400px; +} +#menu { + position:absolute; + bottom:35px; + width:100%; +/* padding-left:23%;*/ +} +#menu > ul { + width:960px; + margin:auto; +} +#menu ul,#menu li { + list-style-type:none; +} +#menu li{ + float:left; + margin-right:10px; +} +#menu li a{ + display:block; + height:22px; + padding:5px 13px 3px; + text-decoration:none; + color: #f5f5f5; +} +#menu ul div { + bottom:-25px; + left:0; + position:absolute; + margin:0; + width:100%; + border-top:none; +} +#menu ul ul li a { + padding-top:1px; + color:#222222; +} -a:hover - { - color: #00008b; - text-decoration: underline; - } +#menu > ul > li { + -moz-border-radius-topleft:8px; + -moz-border-radius-topright:8px; + -webkit-border-top-left-radius:8px; +} -div.outer - { - width: 90%; - margin: 15%; - } +#menu li div { + display:none; + height:25px; +} +#menu li.current div { + display:block; +} +#menu li:hover div { + display:block; + background:url('img/gradient-200x.png') repeat-x 0 -204px; + z-index:9; +} -table.viewmenu td - { - background-color: #006699; - color: white; - padding: 0 5%; - } +#menu li#forside-meny, +#menu li#forside-meny div { + background:yellow; +} -table.viewmenu td.end - { - padding: 0; - } +#menu li#program-meny, +#menu li#program-meny div { + background:#945FB9; +} +#menu li#informasjon-meny, +#menu li#informasjon-meny div { + background:#D83E00; +} +#menu li#medlem-meny, +#menu li#medlem-meny div { + background:#094f71; +} +#menu li#forum-meny, +#menu li#forum-meny div { + background:#187105; +} +#menu li#inside-meny, +#menu li#inside-meny div { + background: #9D2F2F; +} +#menu li#kontakt-meny, +#menu li#kontakt-meny div { + background: #444444; +} -table.viewmenu a - { - color: white; - font: 8pt verdana, arial; - } +#header .aapningstider { +font-size:12px; +left:50%; +margin-left:366px; +overflow:hidden; +position:absolute; +top:10px; +width:134px; +} -table.viewmenu a:hover - { - color: white; - font: 8pt verdana, arial; - } +/* Header slutt */ -a.tinylink - { - color: #00008b; - font: 8pt verdana, arial; - text-decoration: underline; - } +/* Hoveddel */ -a.link - { - color: #00008b; - text-decoration: underline; - } +.join a { + background:transparent url(img/sirkel.png) repeat scroll -30px -24px; + color:#2D6372; + display:block; + font-family:Georgia,serif; + font-size:34px; + font-style:italic; + height:129px; + left:-40px; + line-height:1; + padding-left:30px; + padding-top:50px; + position:absolute; + top:-40px; + width:148px; +} -div.buffer - { - padding-top: 7%; - padding-bottom: 17%; - } +.home .hentry { + width:100%; + padding:0; + margin:0 0 40px; + border:none; +} -.small - { - font: 8pt verdana, arial; - } +.info h3 { + margin:0 0 -3px 0; +} -table td - { - padding-right: 20%; - } +.info ul { + background:#B8E2ED none repeat scroll 0 0; + list-style-type:none; + margin:0 0 3em; + padding-bottom:10px; +} +.info ul li { + padding:10px; +} +.info ul li.alt { + background:transparent url(img/transparent-list-bottom.png) repeat scroll center bottom; + left:-10px; + padding:10px 20px 12px; + position:relative; + width:380px; +} +.single .info ul li.alt { + width:280px; +} +.info ul .term { + float:left; + font-weight:bold; +} +.home .info ul .term { + width:50px; +} +.home .info ul .definition { + padding-left:50px; +} +.single .info ul .term { + width:60px; +} +.single .info ul .definition { + padding-left:60px; +} -table td.nopad - { - padding-right: 5%; - } +.home #nyheter img { + width:93px; + height:133px; + float:left; + margin-right:20px; +} + +.hentry, .sidebar,#program { + margin-top:15px; +} +.entry-meta { + margin: -12px 0 12px; +} +.vedlegg { + float:right; + margin:0 0 3px 10px; + max-width:300px; +} +.caption { + color:#333333; + font-size:14px; + line-height:1; + margin-bottom:2em; + text-align:center; +} +#vedlegg-2 .caption { + margin-bottom:0.5em; +} + +#campaign1, #campaign2 { + width:400px; + height:160px; + background:black; + margin: 40px 0; +} + +#internal-ad-single-bottom { + width:500px; + height:150px; + background:black; + margin-bottom:30px; +} + +#external-ad-single-bottom { + width:500px; + height:300px; + background:black; +} + +/* Hoveddel slutt */ + +/* Sidebar */ +.sidebar ul { + list-style-type:none; + margin-left:0; +} +.sidebar .widget { + margin-bottom:30px; +} + +.events.widget li.event { + margin:0 0 40px; +} + +/* Sidebar slutt */ + +/* Footer */ + +#footer { + background-color:black; + clear:both; + padding-top:20px; + overflow:auto; +} +.program { + margin:auto; + overflow:auto; + width:1000px; +} +.program-teaser .hentry { + float:left; + height:207px; + margin:10px; + padding:16px; + position:relative; + width:150px; +} +.program-teaser .hentry.program-1, +.program-teaser .hentry.program-6 { + margin-left:0; +} +.program-teaser .hentry.program-5, +.program-teaser .hentry.program-10 { + margin-right:0; +} +.program-teaser .entry-title { + font-size:22px; +} +.program-teaser .hentry img { + display:block; + margin:auto; + width:150px; + height:150px; + position:absolute; + bottom:16px; +} + +#footer .credits { + clear:both; + float:right; + margin-right:10px; + font-size:14px; +} + +/* Footer slutt */ + +/** + * Typography + */ +body, input, textarea { + font: 14px Helvetica,Arial,sans-serif; + line-height:1.5em; + color:#333333; +} +th,#menu,.entry-meta,.sidebar { + font-family:"Helvetica neue",Helvetica,Tahoma,Verdana,Arial,sans-serif; +} +.info ul { + font-family:"Century Gothic","Avant Garde","Avant Garde Gothic",sans-serif; +} + +p, ul, ol, dd, pre { + margin-bottom:1.5em; +} +pre, code { + font:14px Monaco, monospace; + line-height:1.3; +} +a,a:visited { + text-decoration:none; + color: #888; +} +a:hover { + text-decoration:underline; +} +abbr { + border-bottom: 1px dotted; +} + +h1 { + font-family: Helvetica,Arial,sans-serif; + font-style:normal; + color: black; + color: black !important; +} + +h2,h3,h4,h5,h6 { + font-family: Georgia, serif; + font-style: italic; +} + +h1,h2,h3,h4,h5,h6, +.entry-title a { + clear:none; + /*color:#b8e2ed;*/ + color:#9dcbdb; + margin-bottom:0.5em; + text-decoration:none; + line-height:1; +} + +.entry-title { + font-size: 34px; +} +.entry-title a:hover { + border-bottom: 1px solid #888; +} +h1 { + font-size:34px; +} +h2 { + font-size:25px; +} +h3 { + font-size:23px; +} +h4 { + font-size:20px; +} +h5 { + font-size:18px; +} +h6 { + font-size:16px; +} +.home h3 { + font-size:28px; +} +.home .entry-title, +.home .entry-title a { + font-size:18px; + color:#d83e00; +} + +.entry-meta { + font-size:12px; +} + +#nyheter { + font-size:15px; +} + +/*.sidebar h3 { +margin-bottom:0.1em; +font-size:14px; +}*/ +.sidebar { + font-size:12px; +} + +/* Lists */ +.entry-content ul, +.entry-content ol { + padding:0; +} +.entry-content ul ul, +.entry-content ol ol, +.entry-content ul ol, +.entry-content ol ul { + padding-left:20px; +} +.entry-content ul { + list-style: circle inside; +} +.entry-content ul ul { + list-style: disc inside; +} +.entry-content ul ul ul { + list-style: square inside; +} +.entry-content ul ul ul ul { + list-style: circle inside; +} +.entry-content ul ul ul ul ul { + list-style: disc inside; +} +.entry-content ul ul ul ul ul ul { + list-style: square inside; +} +.entry-content ol { + list-style: decimal inside; +} +.entry-content ol ol { + list-style: upper-roman inside; +} +.entry-content ol ol ol { + list-style: lower-roman inside; +} +.entry-content ol ol ol ol { + list-style: decimal inside; +} +.entry-content ol ol ol ol ol { + list-style: upper-roman inside; +} +.entry-content ol ol ol ol ol ol { + list-style: lower-roman inside; +} + +/* Quotes */ +.entry-content blockquote { + margin: 1em 2em; + font-style:italic; + background:#eeeeee; + margin:1em 2em; + padding:1px 19px; +} +.entry-content blockquote blockquote { + border:1px solid #000000; +} +.entry-content cite { + font-style:italic; +} + +/* Images */ +img { + max-width:100%; +} +.entry-content img { + margin: 0 0 10px; +} +.entry-content img.alignright { + margin: 0 0 10px 10px; +} +.entry-content img.alignleft { + margin: 0 10px 10px 0; +} + +/****************************** + * Styles for inividual pages * + *****************************/ +h2.jobb { + background:#eeeeee; + margin-top:0.5em; + padding:10px 10px 5px; +} diff --git a/inside/ActionParser.php b/inside/ActionParser.php index 976eae4..4d43a3c 100644 --- a/inside/ActionParser.php +++ b/inside/ActionParser.php @@ -1296,4 +1296,4 @@ class ActionParser { } } -?> \ No newline at end of file +?> diff --git a/inside/Categories.php b/inside/Categories.php index cc64d82..255889e 100644 --- a/inside/Categories.php +++ b/inside/Categories.php @@ -1,35 +1,35 @@ -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; - } - -} +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; + } + +} ?> \ No newline at end of file diff --git a/inside/MemberCard.php b/inside/MemberCard.php new file mode 100644 index 0000000..786b30f --- /dev/null +++ b/inside/MemberCard.php @@ -0,0 +1,219 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } catch (Exception $e) { + throw new Exception("Database connection error: ". getDSN()); + } + } + + $this->selectStmt = self::$PDO->prepare( + "SELECT * FROM din_membercard WHERE id=?"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT * FROM din_membercard WHERE userId=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_membercard (userId, ordered, produced, delivered, active) VALUES (?, ?, ?, ?, ?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_membercard SET + userId=?, + ordered=?, + produced=?, + delivered=?, + active=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_membercard WHERE id=?"); + + $this->active = 0; + + $this->new = true; + $this->updated = false; + $this->delete = false; + } + + function findByUserId($userId) { + $this->findByUserIdStmt->execute(array($userId)); + + $array = $this->findByUserIdStmt->fetch(); + $this->findByUserIdStmt->closeCursor(); + if (!is_array($array)) { + return false; + } + if (!isset($array['id'])) { + return false; + } + + $this->setId($array['id']); + $this->setUserId($array['userId']); + if (!is_null($array['ordered'])) { + $this->setOrdered(new DateTime($array['ordered'])); + } + if (!is_null($array['produced'])) { + $this->setProduced(new DateTime($array['produced'])); + } + if (!is_null($array['delivered'])) { + $this->setDelivered(new DateTime($array['delivered'])); + } + $this->setActive($array['active']); + + $this->updated = false; + $this->new = false; + return true; + } + + private function doInsert() { + $this->insertStmt->bindValue(1, $this->getUserId()); + + if (!is_null($this->getOrdered())) { + $this->insertStmt->bindValue(2, $this->getOrdered()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(2, null); + } + + if (!is_null($this->getProduced())) { + $this->insertStmt->bindValue(3, $this->getProduced()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(3, null); + } + + if (!is_null($this->getDelivered())) { + $this->insertStmt->bindValue(4, $this->getDelivered()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(4, null); + } + + $this->insertStmt->bindValue(5, $this->getActive()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + + $this->updated = false; + $this->new = false; + } + + private function doUpdate() { + $this->updateStmt->bindValue(1, $this->getUserId()); + + if (!is_null($this->getOrdered())) { + $this->updateStmt->bindValue(2, $this->getOrdered()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(2, null); + } + + if (!is_null($this->getProduced())) { + $this->updateStmt->bindValue(3, $this->getProduced()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(3, null); + } + + if (!is_null($this->getDelivered())) { + $this->updateStmt->bindValue(4, $this->getDelivered()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(4, null); + } + + $this->updateStmt->bindValue(5, $this->getActive()); + + $this->updateStmt->bindValue(6, $this->getId()); + + $this->updateStmt->execute(); + + $this->updated = false; + $this->new = false; + } + + private function doDelete() { + $values = array($this->getId()); + $this->deleteStmt->execute($values); + } + + function store() { + if ($this->delete) { + $this->doDelete(); + } elseif ($this->new && $this->updated) { + $this->doInsert(); + } elseif ($this->updated) { + $this->doUpdate(); + } + } + + function getId() { + return $this->id; + } + + function setId($id) { + $this->id = $id; + $this->updated = true; + } + + function getUserId() { + return $this->userId; + } + + function setUserId($userId) { + $this->userId = $userId; + $this->updated = true; + } + + function getOrdered() { + return $this->ordered; + } + + function setOrdered(DateTime $ordered) { + $this->ordered = $ordered; + $this->updated = true; + } + + function getProduced() { + return $this->produced; + } + + function setProduced(DateTime $produced) { + $this->produced = $produced; + $this->updated = true; + } + + function getDelivered() { + return $this->delivered; + } + + function setDelivered(DateTime $delivered) { + $this->delivered = $delivered; + $this->updated = true; + } + + function getActive() { + return $this->active; + } + + function setActive($active) { + $this->active = $active; + $this->updated = true; + } +} + +?> \ No newline at end of file diff --git a/inside/MembershipActivationCode.php b/inside/MembershipActivationCode.php new file mode 100644 index 0000000..6e28af8 --- /dev/null +++ b/inside/MembershipActivationCode.php @@ -0,0 +1,186 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } catch (Exception $e) { + throw new Exception("Database connection error: ". getDSN()); + } + } + + $this->selectStmt = self::$PDO->prepare( + "SELECT * FROM din_membership_activationcode WHERE id=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_membership_activationcode (userId, ordered, used) VALUES (?, ?, ?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_membership_activationcode SET + userId=?, + ordered=?, + used=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_membership_activationcode WHERE id=?"); + + $this->new = true; + $this->updated = false; + $this->delete = false; + } + + function findById($id) { + $this->selectStmt->execute(array($id)); + + $array = $this->findByIdStmt->fetch(); + $this->findByIdStmt->closeCursor(); + if (!is_array($array)) { + return false; + } + if (!isset($array['id'])) { + return false; + } + + $this->setId($array['id']); + $this->setUserId($array['userId']); + if (!is_null($array['ordered'])) { + $this->setOrdered(new DateTime($array['ordered'])); + } + if (!is_null($array['used'])) { + $this->setUsed(new DateTime($array['used'])); + } + + // generate code from id + $this->setCode(substr(crypt(trim($this->getId()), 1813), 2, 6)); + + $this->updated = false; + $this->new = false; + return true; + } + + private function doInsert() { + $this->insertStmt->bindValue(1, $this->getUserId()); + + if (!is_null($this->getOrdered())) { + $this->insertStmt->bindValue(2, $this->getOrdered()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(2, null); + } + + if (!is_null($this->getUsed())) { + $this->insertStmt->bindValue(3, $this->getUsed()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(3, null); + } + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + + $this->updated = false; + $this->new = false; + } + + private function doUpdate() { + $this->updateStmt->bindValue(1, $this->getUserId()); + + if (!is_null($this->getOrdered())) { + $this->updateStmt->bindValue(2, $this->getOrdered()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(2, null); + } + + if (!is_null($this->getUsed())) { + $this->updateStmt->bindValue(3, $this->getUsed()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(3, null); + } + + $this->updateStmt->bindValue(6, $this->getId()); + + $this->updateStmt->execute(); + + $this->updated = false; + $this->new = false; + } + + private function doDelete() { + $values = array($this->getId()); + $this->deleteStmt->execute($values); + } + + function store() { + if ($this->delete) { + $this->doDelete(); + } elseif ($this->new && $this->updated) { + $this->doInsert(); + } elseif ($this->updated) { + $this->doUpdate(); + } + } + + function getId() { + return $this->id; + } + + function setId($id) { + $this->id = $id; + $this->updated = true; + } + + function getUserId() { + return $this->userId; + } + + function setUserId($userId) { + $this->userId = $userId; + $this->updated = true; + } + + function getCode() { + return $this->code; + } + + function setCode($code) { + $this->code = $code; + $this->updated = true; + } + + function getOrdered() { + return $this->ordered; + } + + function setOrdered(DateTime $ordered) { + $this->ordered = $ordered; + $this->updated = true; + } + + function getUsed() { + return $this->used; + } + + function setUsed(DateTime $used) { + $this->used = $used; + $this->updated = true; + } +} + +?> \ No newline at end of file diff --git a/inside/MembershipCard.php b/inside/MembershipCard.php new file mode 100644 index 0000000..90f83e4 --- /dev/null +++ b/inside/MembershipCard.php @@ -0,0 +1,219 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } catch (Exception $e) { + throw new Exception("Database connection error: ". getDSN()); + } + } + + $this->selectStmt = self::$PDO->prepare( + "SELECT * FROM din_membershipcard WHERE id=?"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT * FROM din_membershipcard WHERE userId=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_membershipcard (userId, ordered, produced, delivered, active) VALUES (?, ?, ?, ?, ?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_membershipcard SET + userId=?, + ordered=?, + produced=?, + delivered=?, + active=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_membershipcard WHERE id=?"); + + $this->active = 0; + + $this->new = true; + $this->updated = false; + $this->delete = false; + } + + function findByUserId($userId) { + $this->findByUserIdStmt->execute(array($userId)); + + $array = $this->findByUserIdStmt->fetch(); + $this->findByUserIdStmt->closeCursor(); + if (!is_array($array)) { + return false; + } + if (!isset($array['id'])) { + return false; + } + + $this->setId($array['id']); + $this->setUserId($array['userId']); + if (!is_null($array['ordered'])) { + $this->setOrdered(new DateTime($array['ordered'])); + } + if (!is_null($array['produced'])) { + $this->setProduced(new DateTime($array['produced'])); + } + if (!is_null($array['delivered'])) { + $this->setDelivered(new DateTime($array['delivered'])); + } + $this->setActive($array['active']); + + $this->updated = false; + $this->new = false; + return true; + } + + private function doInsert() { + $this->insertStmt->bindValue(1, $this->getUserId()); + + if (!is_null($this->getOrdered())) { + $this->insertStmt->bindValue(2, $this->getOrdered()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(2, null); + } + + if (!is_null($this->getProduced())) { + $this->insertStmt->bindValue(3, $this->getProduced()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(3, null); + } + + if (!is_null($this->getDelivered())) { + $this->insertStmt->bindValue(4, $this->getDelivered()->format(self::DATETIME_FORMAT)); + } else { + $this->insertStmt->bindValue(4, null); + } + + $this->insertStmt->bindValue(5, $this->getActive()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + + $this->updated = false; + $this->new = false; + } + + private function doUpdate() { + $this->updateStmt->bindValue(1, $this->getUserId()); + + if (!is_null($this->getOrdered())) { + $this->updateStmt->bindValue(2, $this->getOrdered()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(2, null); + } + + if (!is_null($this->getProduced())) { + $this->updateStmt->bindValue(3, $this->getProduced()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(3, null); + } + + if (!is_null($this->getDelivered())) { + $this->updateStmt->bindValue(4, $this->getDelivered()->format(self::DATETIME_FORMAT)); + } else { + $this->updateStmt->bindValue(4, null); + } + + $this->updateStmt->bindValue(5, $this->getActive()); + + $this->updateStmt->bindValue(6, $this->getId()); + + $this->updateStmt->execute(); + + $this->updated = false; + $this->new = false; + } + + private function doDelete() { + $values = array($this->getId()); + $this->deleteStmt->execute($values); + } + + function store() { + if ($this->delete) { + $this->doDelete(); + } elseif ($this->new && $this->updated) { + $this->doInsert(); + } elseif ($this->updated) { + $this->doUpdate(); + } + } + + function getId() { + return $this->id; + } + + function setId($id) { + $this->id = $id; + $this->updated = true; + } + + function getUserId() { + return $this->userId; + } + + function setUserId($userId) { + $this->userId = $userId; + $this->updated = true; + } + + function getOrdered() { + return $this->ordered; + } + + function setOrdered(DateTime $ordered) { + $this->ordered = $ordered; + $this->updated = true; + } + + function getProduced() { + return $this->produced; + } + + function setProduced(DateTime $produced) { + $this->produced = $produced; + $this->updated = true; + } + + function getDelivered() { + return $this->delivered; + } + + function setDelivered(DateTime $delivered) { + $this->delivered = $delivered; + $this->updated = true; + } + + function getActive() { + return $this->active; + } + + function setActive($active) { + $this->active = $active; + $this->updated = true; + } +} + +?> \ No newline at end of file diff --git a/inside/Page.php b/inside/Page.php index b04bcc0..43ddda1 100644 --- a/inside/Page.php +++ b/inside/Page.php @@ -532,22 +532,6 @@ possibly include it instead? --Thomas Misund, 26. Oct 2009 - -users->fetchRow(DB_FETCHMODE_OBJECT)){ $user = new User($row->id); print ""; - print "
"; - print ""; - print "getId() . "\" />"; print "getId() . "_cardno\">". $user->cardno . "\n"; print "id . "\">" . $user->getName() . ""; print ""; @@ -3250,6 +3231,9 @@ Teksten under er hentet fra kunnskapsdatabasen. Du st print "" . $user->getLastSticker() . ""; print ""; + print ""; + print ""; + print "getId() . "\" />"; if ($user->hasExpired()) { if (!$user->getCardProduced()) { print "forny (produser kort)"; @@ -3280,16 +3264,20 @@ Teksten under er hentet fra kunnskapsdatabasen. Du st print "-"; } } + print "
"; print ""; print ""; + print "
"; + print ""; + print "getId() . "\" />"; if ($user->getCardDelivered()) { - print ""; + print ""; print ""; } + print "
"; print ""; - print ""; print ""; } print ""; @@ -3322,4 +3310,4 @@ Teksten under er hentet fra kunnskapsdatabasen. Du st } -?> +?> \ No newline at end of file diff --git a/inside/Payment.php b/inside/Payment.php index e6f644d..3de855e 100644 --- a/inside/Payment.php +++ b/inside/Payment.php @@ -73,6 +73,7 @@ class Payment { $description, $returnURL) ) { $orderRef = $this->payex->getOrderRef(); // get the orderRef $this->payex->redirect($orderRef); // redirect the user + mysql_query("INSERT INTO `din_transaction_check`(`order_id`,`inserted`,`order_ref`) VALUES('$orderID', NOW(), '$orderRef')"); } else { echo 'Initialize() failed.
'; echo 'Code: '.$this->payex->getcode().' '; @@ -83,7 +84,7 @@ class Payment { public function completeTransaction($orderRef, $transaction_id) { if ( $this->payex->Complete($orderRef) ) { - + #file_put_contents('tmp', var_export("\n\n" . time() . "\n\n" . $this->payex->Check($orderRef) . "\n\nTransaction:" . $this->payex->getTransactionStatus() ."\n",true) . "\n\n", FILE_APPEND); /* Transaction statuses (defined in payex_defines.php): 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture @@ -95,7 +96,6 @@ class Payment { 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."); @@ -104,6 +104,7 @@ class Payment { $this->user_email = $user->email; } $this->_sendConfirmationMail($transaction_id); + mysql_query("UPDATE `din_transaction_check` SET `order_ref2` = '$orderRef' WHERE `order_id`='{$transaction->id}' LIMIT 1"); return true; }else { notify("Betalingen er ikke riktig gjennomført. Vennligst ta kontakt med support om du tror dette skyldes en feil."); @@ -135,4 +136,4 @@ class Payment { } } -?> \ No newline at end of file +?> diff --git a/inside/User.php b/inside/User.php index 8ab43db..92bdf79 100644 --- a/inside/User.php +++ b/inside/User.php @@ -1,1546 +1,1550 @@ -__construct($id, $data); - } - - public function __construct($id, $data = NULL) { - $conn = & DB :: connect(getDSN()); - if (DB :: isError($conn)) { - print ("error: " . $conn->toString()); - exit (); - } else { - $this->conn = $conn; - } - - $action = scriptParam("action"); - $this->id = $id; - - if ($id == NULL) { //New user - if ($data == NULL) { - error("User: No data supplied."); - $this->id = -1; - return false; - } else { - $this->username = stripcslashes($data['username']); - if (strlen($data['password1']) < 4) { - notify("Passordet må være minst 4 tegn."); - $this->id = -1; - return false; - } else { - if ($data['password1'] != $data['password2']) { - notify("Passordene var ikke like."); - $this->id = -1; - return false; - } else { - $this->password = $data['password1']; - if (!isAdmin()) { - switch (checkForumUsername($data['username'], $this->password)) { - case "wrong-password" : - notify("Brukernavnet er allerede i bruk på forumet. " . "Om du selv har dette brukernavnet må du oppgi " . "riktig passord."); - $this->id = -1; - return false; - } - } - } - } - - $this->addresstype = isset ($data['addresstype']) ? "int" : "no"; - - if (isDate($data['birthdate'])) { - $this->birthdate = $data['birthdate']; - } else { - notify("Ugyldig fødselsdato: " . $data['birthdate']); - $this->id = -1; - return false; - } - - if (isset ($data['active'])) { - $this->division_id_request = $data['division']; - } else { - $this->division_id_request = NULL; - } - if (isset ($data['group'])) { - $this->group_id = $data['group_id']; - } else { - $this->group_id = NULL; - } - } - } else { //ID set, existing user - if ($data != NULL) { - // Update existing user - $this->addresstype = isset ($data['addresstype']) ? "int" : "no"; - } else { - //Retrieve data from backend for display or other actions - if ($data = $this->_retrieveData()) { - $this->username = stripcslashes($data['username']); - $this->cardno = $data['cardno']; - $this->expires = $data['expires']; - $this->division_id_request = $data['division_id_request']; - $this->lastSticker = $data['lastSticker']; - $this->addresstype = $data['addresstype']; - } else { - // not successful - return false; - } - } - - $this->birthdate = $data['birthdate']; - $this->cardProduced = $data['cardProduced']; - $this->cardDelivered = $data['cardDelivered']; - $this->validAddress = $data['valid_address']; - } - - //Common initializations - $this->firstname = stripcslashes($data['firstname']); - $this->lastname = stripcslashes($data['lastname']); - if (empty ($data['street'])) { - $data['street'] = "-"; - } - $this->street = stripcslashes($data['street']); - if (empty ($data['zipcode'])) { - $data['zipcode'] = "-"; - } - $this->zipcode = $data['zipcode']; - if ($this->addresstype == "no") { - if ($action != "register-user") { - if (empty ($data['postarea'])) { - $data['postarea'] = "-"; - } - $this->postarea = $data['postarea']; - } - } else { - $this->city = $data['city']; - $this->state = $data['state']; - $this->country = $data['country']; - } - if ($data['phonenumber'] == "00000000" || $data['phonenumber'] == "") { - $data['phonenumber'] = "-"; - } - $this->phonenumber = $data['phonenumber']; - $this->email = $data['email']; - $this->placeOfStudy = $data['placeOfStudy']; - return true; - } - - public function store() { - if (!$this->_validate()) { - return false; - } - $action = scriptParam("action"); - if ($action == "register-user") { - - $this->conn->autoCommit(false); - $this->id = getNextId("din_user"); - $sql = sprintf("INSERT INTO din_user " . - " (id, username, password, firstname, " . - " lastname, addresstype, email, birthdate, " . - " placeOfStudy, division_id_request) " . "VALUES " . " (%s, %s, PASSWORD(%s), %s, %s, %s, %s, " . " %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->username), $this->conn->quoteSmart($this->password), $this->conn->quoteSmart($this->firstname), $this->conn->quoteSmart($this->lastname), $this->conn->quoteSmart($this->addresstype), $this->conn->quoteSmart($this->email), $this->conn->quoteSmart($this->birthdate), $this->conn->quoteSmart($this->placeOfStudy), $this->conn->quoteSmart(($this->division_id_request == NULL) ? NULL : $this->division_id_request)); - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - if ($result->getCode() == -5) { - $err = $this->_findConstraintViolation(); - notify("Denne epostadressen eller brukernavnet er allerede registrert."); - $GLOBALS['extraScriptParams']['page'] = "register-user"; //Swap page - } else { - error("New user: " . $result->toString()); - notify("Problem under registrering av ny bruker."); - } - return false; - } - if ($this->addresstype == "no") { - $sql = sprintf("INSERT INTO din_useraddressno " . - " (user_id, street, zipcode) " . - "VALUES " . - " (%s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode)); - } else { - $sql = sprintf("INSERT INTO din_useraddressint " . " (user_id, street, zipcode, city, state, country) " . "VALUES " . " (%s, %s, %s, %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode), $this->conn->quoteSmart($this->city), $this->conn->quoteSmart($this->state), $this->conn->quoteSmart($this->country)); - } - - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - $this->conn->rollback(); - if ($result->getCode() == -3) { - error("Ugyldig postnummer." . $result->toString()); - notify("Ugyldig postnummer."); - } else { - error("New user (address): " . $result->toString()); - } - return false; - } - - // Mark address as valid - $this->setAddressStatus(1); - - $sql = sprintf("INSERT INTO din_userphonenumber VALUES (%s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->phonenumber)); - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - $this->conn->rollback(); - error("New user (phonenumber): " . $result->toString()); - return false; - } - - //Group relationships - $groupRel = new UserGroupRelationship($this->id, 1); - $groupRel->store(); - if ($this->group_id > 1) { - $groupRel = new UserGroupRelationship($this->id, $this->group_id); - $groupRel->store(); - } - - //Register cardnumber as used - if ($this->cardno != NULL) { - if (!$this->_registerUsedCardno($this->cardno)) { - notify("Kortnummeret er allerede registrert."); - $this->conn->rollback(); - return false; - } - } - - //Logging - $sql = sprintf("INSERT INTO din_userupdate " . "VALUES (NULL, NOW(), %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart("User registered."), $this->conn->quoteSmart((getCurrentUser() == 0) ? $this->id : getCurrentUser())); - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - $this->conn->rollback(); - error("New user (userUpdate): " . $result->toString()); - return false; - } else { - if ($this->conn->commit()) { - $GLOBALS['extraScriptParams']['userid'] = $this->id; - if (loggedIn()) { - notify("Ny bruker er registrert"); - } else { - notify("Din bruker er registrert."); - send_welcome_mail($this); - $GLOBALS['extraScriptParams']['page'] = "register-membership"; - } - return true; - } else { - $this->conn->rollback(); - } - } - - } else { //Update - $this->conn->autoCommit(false); - $sql = "UPDATE din_user SET " . - "firstname = " . $this->conn->quoteSmart($this->firstname) . - ", lastname = " . $this->conn->quoteSmart($this->lastname) . - ", addresstype = " . $this->conn->quoteSmart($this->addresstype) . - ", email = " . $this->conn->quoteSmart($this->email == "" ? NULL : $this->email) . - ", birthdate = " . $this->conn->quoteSmart($this->birthdate) . - ", placeOfStudy = " . $this->conn->quoteSmart($this->placeOfStudy) . - ", cardProduced = " . $this->conn->quoteSmart($this->cardProduced) . - ", cardDelivered = " . $this->conn->quoteSmart($this->cardDelivered) . - " WHERE id = " . $this->conn->quoteSmart($this->id); - - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("Update user: " . $result->toString()); - notify("Feil under oppdatering av kontaktinfo."); - return false; - } - - // Slett adressen hvis den kun består av en x. - // Brukeren får da en mail med informasjon om å oppdatere adressen sin. - if (substr($this->street, 0, 1) == 'x') { - $link = substr($this->street, 2); - if ($this->_deleteAddress($link)) { - notify("Adresse slettet."); - } - } else { - if ($this->addresstype == "no") { - $sql = sprintf("REPLACE INTO din_useraddressno VALUES (%s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode)); - } else { - $sql = sprintf("REPLACE INTO din_useraddressint VALUES (%s, %s, %s, %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode), $this->conn->quoteSmart($this->city), $this->conn->quoteSmart($this->state), $this->conn->quoteSmart($this->country)); - } - - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - $this->conn->rollback(); - if ($result->getCode() == -3) { - notify("Ugyldig postnummer! Endringer er ikke lagret."); - } else { - notify("Feil med adressen. Endringer er ikke lagret."); - error("New user (address): " . $result->toString()); - } - return false; - } - - // ugly fix ... set address manual if the user is admin - if (isAdmin()) { - $this->setAddressStatus($this->validAddress); - } else { - // mark address as valid - $this->setAddressStatus(1); - } - } - $sql = "DELETE FROM din_userphonenumber WHERE user_id = $this->id"; - $this->conn->query($sql); - $sql = sprintf("INSERT INTO din_userphonenumber VALUES (%s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->phonenumber)); - - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("New user (phonenumber): " . $result->toString()); - return false; - } - - if ($result = $this->conn->commit()) { - $this->_registerUpdate("Brukerinformasjon oppdatert"); - notify("Brukerinformasjon oppdatert."); - } else { - error("User rollback; " . $result->toString()); - $this->conn->rollback(); - } - } - } - - public function _validate() { - $valid = true; - if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $this->email)) { - notify("Ugyldig format på epostadresse."); - $valid = false; - } - return $valid; - } - - public function _retrieveData() { - $sql = "SELECT u.*, up.number AS phonenumber " . "FROM din_user u LEFT JOIN din_userphonenumber up " . "ON u.id = up.user_id " . "WHERE u.id = $this->id"; - $result = & $this->conn->query($sql); - if (DB :: isError($result) != true) { - if ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC)) { - if ($row['addresstype'] == "no") { - $sql = "SELECT ua.street, ua.zipcode, pn.poststed AS postarea " . "FROM din_useraddressno ua, postnummer pn " . "WHERE ua.user_id = $this->id " . "AND ua.zipcode = pn.postnummer"; - } else { - $sql = "SELECT street, zipcode, city, state, country " . "FROM din_useraddressint " . "WHERE user_id = $this->id"; - } - $result = & $this->conn->query($sql); - if (DB :: isError($result) != true) { - if ($row2 = & $result->fetchRow(DB_FETCHMODE_ASSOC)) { - $row = $row + $row2; - } - return $row; - } else { - error("Users: " . $result->toString()); - return false; - } - } else { - error("Users: invalid userid"); - return false; - } - } - } - - // Fetch the postarea of a given zipcode - public function getPostarea ($zipcode = null) { // = $this->zipcode) { - if ($zipcode == null) $zipcode = $this->zipcode; - - $sql = "SELECT poststed AS postarea FROM postnummer WHERE postnummer=\"$zipcode\""; - $result = & $this->conn->query($sql); - if (DB :: isError($result) != true) { - $row = & $result->fetchRow(DB_FETCHMODE_ASSOC); - return $row["postarea"]; - } - return false; - } - - public function getId () { - return $this->id; - } - - public function getLastSticker () { - if ($this->lastSticker > 0) { - return $this->lastSticker; - } - return null; - } - - public function changeUsername($username, $password) { - switch (checkForumUsername($username, $password)) { - case "wrong-password" : - notify("Brukernavnet er allerede i bruk på forumet. " . "Om du selv har dette brukernavnet må du oppgi " . "riktig passord."); - return false; - - case "not-used" : - case "auth-ok" : - $sql = "UPDATE din_user SET " . " username = '$username' " . "WHERE " . " id = $this->id"; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - if ($result->getCode() == -5) { - $err = $this->_findConstraintViolation(); - error("Change username: $err already registered."); - notify("Brukernavnet er opptatt."); - $GLOBALS['extraScriptParams']['page'] = "change-username"; //Swap page - } else { - error("Change username: " . $result->toString()); - notify("Problem under endring av brukernavn."); - } - return false; - } else { - $this->_registerUpdate("Brukernavn endret til $username"); - notify("Brukernavn endret."); - } - } - } - - public function getRegistered() { - $sql = "SELECT uu.date FROM din_user u, din_userupdate uu - WHERE uu.user_id_updated=u.id AND u.id = $this->id - ORDER BY uu.date ASC LIMIT 1"; - $result = & $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("Get user registered: " . $result->toString()); - return false; - } - - if ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { - return $row->date; - } - - } - - public function getLastUpdate() { - $sql = "SELECT uu.date FROM din_user u, din_userupdate uu - WHERE uu.user_id_updated=u.id AND u.id = $this->id - ORDER BY uu.date DESC LIMIT 1"; - $result = & $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("Get user last update: " . $result->toString()); - return false; - } - - if ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { - return $row->date; - } - } - - public function getOrderId() { - $sql = "SELECT id FROM din_order " . - "WHERE user_id = $this->id " . - "AND order_status_id < 3 " . - "ORDER BY timestamp DESC LIMIT 1"; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - return null; - } - - if ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)) { - return $row->id; - }else { - return null; - } - } - - public function getName() { - return trim($this->firstname.' '.$this->lastname); - } - - public function getContactInfo() { - $c = "$this->firstname $this->lastname\n"; - $c .= "$this->phonenumber\n"; - $c .= "$this->email"; - return $c; - } - - public function _findConstraintViolation() { - $sql = "SELECT id FROM din_user WHERE id = $this->id"; - $result = $this->conn->query($sql); - if ($result->numRows() > 0) { - return "id"; - } - $sql = "SELECT id FROM din_user WHERE username = '$this->username'"; - $result = $this->conn->query($sql); - if ($result->numRows() > 0) { - return "brukernavnet"; - } - } - - public function displayGroups() { - $sql = "SELECT g.id, g.name " . "FROM din_group g, din_usergrouprelationship ugr " . "WHERE ugr.user_id = $this->id " . "AND ugr.group_id = g.id " . "ORDER BY g.name ASC "; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("Vis gruppemedlemskap: " . $result->toString()); - notify("Informasjon om gruppemedlemskap utilgjengelig."); - return false; - } - - print (""); - print (""); - while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { - print (""); - if ($row->id != 1) { - displayOptionsMenuTable(Array ( - "user_id" => $this->id, - "group_id" => $row->id - ), USERGROUPRELATIONSHIP, "usergrouprelationship", "view-edit-options-usergrouprelationship", NULL, "display-user"); - } else { - print (""); - } - print (""); - } - print ("
Grupper brukeren er medlem av
$row->name
"); - } - - public function displayOrders($status = 1) { - $sql = "SELECT id FROM din_order WHERE user_id = $this->id AND order_status_id = $status"; - $result = & $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("Display orders: " . $result->toString()); - return false; - } - - if ($result->numRows() == 0) { - print ("

Ingen handlekurver funnet"); - return false; - } - while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { - $order = new Order($row->id); - $edit = true; - $order->displayShortList($edit); - } - - } - - public function registerMembership($cardno) { - if ($this->cardno != NULL) { - notify("Du har prøvd å registrere nytt medlemskort, selv om du allerede har et registrert medlemskort. Vennligst kontakt administrator om du tror dette er en feil."); - return false; - } - $sql = "SELECT id " . "FROM din_user " . "WHERE cardno = $cardno"; - $result = $this->conn->query($sql); - if (DB :: isError($result) != true) { - if ($result->numRows() > 0) { - notify("Kortnummeret er allerede i bruk. Vennligst kontrollér nummeret."); - return false; - } - - $expires = $this->getExpiryDate(); - - $sql = "UPDATE din_user SET " . " cardno = $cardno, " . " expires = '$expires' " . "WHERE " . " id = $this->id"; - $result = $this->conn->query($sql); - if (DB :: isError($result) != true) { - $this->_registerUpdate("Medlemskap registrert."); - $sql = "INSERT INTO din_usedcardno VALUES ( " . " $cardno, NOW())"; - $result = $this->conn->query($sql); - return true; - } else { - error($result->toString()); - notify("En ukjent feil oppstod. Vennligst kontakt administrator."); - } - } else { - error($result->toString()); - notify("En ukjent feil oppstod. Vennligst kontakt administrator."); - } - } - - function registerMembershipPayex() { - return $this->grantCardno("payex"); - } - - public function renewMembership($cardno) { - $expires = $this->getExpiryDate(); - if ($expires <= $this->expires) { - notify("Du har allerede gyldig medlemskap for dette året."); - return false; - } - $this->conn->autoCommit(false); - if ($this->_registerUsedCardno($cardno) == true) { - $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error($result->toString()); - return false; - } - $this->_registerUpdate("Medlemskap fornyet."); - if ($result = $this->conn->commit()) { - return true; - } else { - notify("Problemer med registrering av fornyet medlemskap"); - error("Kortnummer: " . $result->toString()); - return false; - } - } else { - notify("En ukjent feil oppstod. Vennligst kontakt administrator."); - } - } - - public function renewMembershipPayex() { - $expires = $this->getExpiryDate(); - if ($expires <= $this->expires) { - notify("Du har allerede gyldig medlemskap for dette året."); - return false; - } - $this->conn->autoCommit(false); - $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error($result->toString()); - return false; - } - $this->_registerUpdate("Medlemskap fornyet med Payex."); - if ($result = $this->conn->commit()) { - notify("Medlemskap fornyet."); - return true; - } else { - notify("Problemer med registrering av fornyet medlemskap"); - error("Kortnummer: " . $result->toString()); - return false; - } - } - - public function renewMembershipEurobate() { - $expires = $this->getExpiryDate(); - if ($expires <= $this->expires) { - // har allerede gyldig medlemskap - return false; - } - $this->conn->autoCommit(false); - $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; - $result = $this->conn->query($sql); - if (DB::isError($result) == true) { - return false; - } - $this->_registerUpdate("Medlemskap fornyet med SMS."); - if ($result = $this->conn->commit()) { - return true; - } else { - return false; - } - } - - /** - * Bankbetaling med KID - */ - public function renewMembershipBankpayment() { - if (false and $this->isHonorMember()) { - notify($this->id . ", " . $this->getName() . " er livsvarig medlem. Medlemskapet vil ikke bli oppdater."); - return false; - } else { - $expires = $this->getExpiryDate(); - if ($expires <= $this->expires) { - $newexpires = date("Y-m-d", strtotime("+1 year", strtotime($expires))); - notify($this->id . ", " . $this->getName() . " har allerede gyldig medlemskap for dette året. Har utløpsdato " . $this->expires . ", men ny ble prøvd satt til " . $expires . ". Personen vil få satt ny utløpsdate på medlemskapet til " . $newexpires); - $expires = $newexpires; - } - $this->conn->autoCommit(false); - $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; - - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error($result->toString()); - return false; - } - - if ($result = $this->conn->commit()) { - // send mail to the user - $this->sendRenewedMembershipRegisteredNotifyMail(); - - $this->_registerUpdate("Medlemskap fornyet med KID-betaling til bank."); - notify($this->id . ", " . $this->getName() . ": medlemskap fornyet fram til " . $expires . "."); - return true; - } else { - notify($this->id . ", " . $this->getName() . ": Problemer med registrering av fornyet medlemskap"); - error("Kortnummer: " . $result->toString()); - return false; - } - } - } - - /* Order new membercard if old one is lost */ - public function renewMembercardPayex() { - $expires = $this->getExpiryDate(); - if ($expires > $this->expires) { - notify("Du har ikke gyldig medlemskap for dette året."); - return false; - } - $this->conn->autoCommit(false); - $sql = "UPDATE din_user SET cardProduced='0', cardDelivered='0' WHERE id = " . $this->id; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error($result->toString()); - return false; - } - $this->_registerUpdate("Nytt medlemskort bestilt med Payex."); - if ($result = $this->conn->commit()) { - notify("Medlemskortet er lagt i produksjonskøen."); - return true; - } else { - notify("Problemer med registrering av bestillingen."); - error("Kortnummer: " . $result->toString()); - return false; - } - } - - public static function delete($id) { - $conn = db_connect(); - $sql = "DELETE FROM din_user WHERE id = $id LIMIT 1"; - $result = $conn->query($sql); - if (DB :: isError($result) != true) { - notify("Bruker slettet."); - } else { - error($result->toString()); - } - } - - public function updateExpiry($newDate) { - if ($newDate == 'lifetime') { - $sql = "UPDATE din_user SET expires = NULL WHERE id = $this->id LIMIT 1"; - } else { - $sql = "UPDATE din_user SET expires = '$newDate-12-31' WHERE id = $this->id LIMIT 1"; - } - $conn = db_connect(); - $result = $this->conn->query($sql); - if (DB :: isError($result) != true) { - $this->_registerUpdate("Utløpsdato oppdatert til " . $newDate); - notify("Utløpsdato oppdatert."); - } else { - error($result->toString()); - } - } - - public function updateLastSticker($newDate) { - $sql = "UPDATE din_user SET lastSticker = '$newDate' WHERE id = $this->id LIMIT 1"; - $result = $this->conn->query($sql); - if (DB :: isError($result) != true) { - $this->_registerUpdate("Oppdatert oblat til " . $newDate); - $this->lastSticker = $newDate; - notify("Oblat oppdatert til " . $this->getLastSticker() . " for " . $this->getName() . "."); - - // Assume that a letter is sent to the registered address. - // We mark the address as valid, and will update it as invalid if the letter is not delivered - $this->setAddressStatus(1); - } else { - error($result->toString()); - } - } - - public function displayList() { - print "\n"; - print " " . $this->cardno . "\n"; - print " "; - if ($this->hasExpired()) { - print 'nei'; - } else { - print 'ja'; - } - print "\n"; - - print " id . "\" title=\"mer informasjon om " . - $this->firstname . " " . $this->lastname . "\">" . - $this->firstname . "\n"; - - print "" . $this->lastname . "\n"; - - print "" . prepareForHTML($this->email) . "\n"; - - print ""; - print $this->phonenumber; - if ($this->phonenumber != "-") { - print "phonenumber . "\" " . - "title=\"ring til " . $this->firstname . " " . $this->lastname . "\">"; - print "\"ringfirstname . " " . $this->lastname . "\" />"; - print ""; - } - print "\n"; - - print ""; - $this->_printGroups(", "); - print "\n"; - - print "\n"; - } - - public function displayDivReqList() { - if ($this->division_id_request != NULL) { - $div = new Division($this->division_id_request); - } else { - return false; - } - - print "\n"; - - print " id . "\" title=\"mer informasjon om " . $this->firstname . " " . $this->lastname . "\">"; - print $this->firstname; - print "\n"; - - print "" . $this->lastname . "\n"; - - print "" . prepareForHTML($this->email) . "\n"; - - print "" . $div->name . "\n"; - - print "" . $this->getRegistered() . "\n"; - - print ""; - print "

id . "\" method=\"post\">"; - print "
"; - print ""; - print ""; - print ""; - print "
"; - print "
"; - print "\n"; - - print "\n"; - } - - public function isMember() { - if ($this->cardno == NULL) { - return false; - } else { - return true; - } - } - - public function isActive() { - $sql = "SELECT group_id " . "FROM din_usergrouprelationship " . "WHERE user_id = $this->id "; - $result = $this->conn->query($sql); - - if (DB :: isError($result) == true) { - error("isActive: " . $result->toString()); - return false; - } - if ($result->numRows() > 1) { - return true; - } else { - return false; - } - } - - public function getNumProductsBought($product_id = 0) { - $sql = "SELECT SUM(oi.quantity) AS num FROM din_user u, din_order o, din_order_item oi " . - "WHERE o.user_id = u.id AND oi.order_id = o.id AND oi.product_id = 2 AND o.order_status_id = 4 AND u.id = $this->id"; - $result = $this->conn->query($sql); - - if (DB :: isError($result) == true) { - error("isActive: " . $result->toString()); - return 0; - } - if ($row = & $result->fetchRow(DB_FETCHMODE_ORDERED)) { - return $row[0]; - } else { - return false; - } - } - - public function hasExpired() { - if ($this->expires == NULL) { - return false; - } else - if ($this->expires > date("Y-m-d")) { - return false; - } else { - return true; - } - } - - public function getCardProduced() { - return $this->cardProduced; - } - - public function setCardProduced($produced) { - if ($produced) { - $sql = "UPDATE din_user SET cardProduced=1 WHERE id=$this->id"; - $desc = "medlemskort produsert"; - $this->cardProduced = 1; - } else { - $sql = "UPDATE din_user SET cardProduced=0, cardDelivered=0 WHERE id=$this->id"; - $desc = "mangler medlemskort"; - $this->cardProduced = 0; - } - $result = $this->conn->query($sql); - - if (DB :: isError($result) != true) { - $this->_registerUpdate("Medlemskortstatus endret til $desc"); - notify("Medlemskortstatus for " . $this->firstname . " " . $this->lastname . " er endret til " . $desc . ""); - } - } - - public function getCardDelivered() { - return $this->cardDelivered; - } - - public function setCardDelivered($delivered) { - if ($delivered) { - $sql = "UPDATE din_user SET cardDelivered=1 WHERE id=$this->id"; - $desc = "medlemskort utlevert"; - $this->cardDelivered = 1; - } else { - $sql = "UPDATE din_user SET cardDelivered=0 WHERE id=$this->id"; - $desc = "medlemskort ikke utlevert"; - $this->cardDelivered = 0; - } - $result = $this->conn->query($sql); - - if (DB :: isError($result) != true) { - $this->_registerUpdate("Medlemskortstatus endret til $desc"); - notify("Medlemskortstatus for " . $this->firstname . " " . $this->lastname . " er endret til " . $desc . ""); - } - } - - public function hasCardSticker() { - if ($this->getLastSticker() >= date("Y", strtotime($this->expires))) { - return true; - } - } - - public function getExpiryDate() { - if (date("Y-m-d") > date("Y-11-15")) { - return date("Y", strtotime("+1 year")) . "-12-31"; - } else { - return date("Y") . "-12-31"; - } - } - - public function _registerUsedCardno($cardno) { - $sql = "INSERT INTO din_usedcardno VALUES ( " . " $cardno, NOW())"; - $result = $this->conn->query($sql); - if (DB :: isError($result) != true) { - return true; - } else { - error("Registrér kortnummer: " . $result->toString()); - notify("Kortnummeret er allerede registrert."); - } - } - - public function grantCardno($src = NULL) { - $sql = "SELECT value FROM din_settings " . "WHERE name = 'next_online_cardno'"; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("grantCardno: " . $result->toString()); - return false; - } - if ($row = & $result->fetchRow(DB_FETCHMODE_ORDERED)) { - $cardno = $row[0]; - } - - $expires = $this->getExpiryDate($cardno); - $sql = "UPDATE din_user SET " . " cardno = $cardno, " . " expires = '$expires' " . "WHERE " . " id = $this->id"; - $result = $this->conn->query($sql); - if (DB :: isError($result) != true) { - $this->cardno = $cardno; - $this->expires = $expires; - notify("$this->firstname $this->lastname er tildelt medlemskortnummer $cardno"); - $this->_registerUpdate("Bruker tildelt kortnummer. $src"); - - $sql = "UPDATE din_settings SET value = value + 1 WHERE name = 'next_online_cardno'"; - $this->_registerUsedCardno($cardno); - $result = $this->conn->query($sql); - return true; - } else { - error("Registrér kortnummer: " . $result->toString()); - notify("Problemer med registrering av kortnummer."); - return false; - } - } - - /** - * changes validity status of users address - * values can be: - * 0 - not valid address - * 1 - valid address - * 2 - status of address unknown - * - * @param integer $value - * @return boolean - **/ - public function setAddressStatus($value) { - // check for valid input value - if (is_numeric($value) && $value >= 0 && $value <=2) { - $sql = "UPDATE din_user SET " . - "valid_address = '$value' " . - "WHERE " . - "id = $this->id"; - $result = $this->conn->query($sql); - - if (DB :: isError($result) != true) { - $this->validAddress = $value; - - switch ($value) { - case 1: - $valuetext = "gyldig"; break; - case 2: - $valuetext = "ukjent"; break; - default: - $valuetext = "ugyldig"; break; - } - // store update - $this->_registerUpdate("Adressestatus satt til $valuetext."); - - // done - return true; - } else { - notify("Problemer med registreringen av adressestatus"); - return false; - } - } else { - notify("Ugyldig adressestatusverdi: " . $value); - return false; - } - return false; - } - - public function getAddressStatus() { - switch ($this->validAddress) { - case 1: - return "gyldig"; break; - case 2: - return "ukjent"; break; - default: - return "ugyldig"; break; - } - } - - public function isHonorMember () { - if ($this->expires == NULL) return true; - return false; - } - - public function setCardno($value) { - $sql = "UPDATE din_user SET cardno = $value " . - "WHERE id = $this->id"; - $result = $this->conn->query($sql); - - if (DB :: isError($result) != true) { - $value = ($value == "NULL") ? "NULL" : $value; - $this->_registerUpdate("Medlemskortnummer endret til $value"); - notify("Medlemskortnummer for $this->firstname $this->lastname er endret til $value"); - } - } - - public function setExpires($value) { - $sql = "UPDATE din_user SET expires = '$value' " . - "WHERE id = $this->id"; - $result = $this->conn->query($sql); - - if (DB :: isError($result) != true) { - $this->_registerUpdate("Utløpsdato endret til $value"); - notify("Utløpsdato for $this->firstname $this->lastname er endret til $value"); - } - } - - public function updateDivisionRequest($value) { - if (empty ($value)) { - notify("Ugyldig verdi."); - return false; - } - if ($this->division_id_request != NULL) { - $div = new Division($this->division_id_request); - } - $sql = "UPDATE din_user SET " . " division_id_request = NULL " . "WHERE " . " id = $this->id"; - $result = $this->conn->query($sql); - if (DB :: isError($result) != true) { - if ($value == "reject") { - $this->_registerUpdate("Aktivforespørsel avvist"); - notify("Forespørsel fra $this->firstname $this->lastname om å bli registrert som aktiv i $div->name er avslått."); - } else { - if ($value == "accept") { - $ugr = new UserGroupRelationship($this->id, 2); - $ugr->store(); - $group_id = $div->getNoAdminGroup(); - if ($group_id != NULL) { - $ugr2 = new UserGroupRelationship($this->id, $group_id); - $ugr2->store(); - } - $this->_registerUpdate("Aktivforespørsel godkjent"); - notify("Forespørsel fra $this->firstname $this->lastname om å bli registrert som aktiv i $div->name er godkjent."); - } - } - } else { - error("user-div-req: " . $result->toString()); - notify("Behandling av forespørsel ble ikke utført."); - } - } - - public function _printGroups($sep) { - $sql = "SELECT g.id, g.name " . "FROM din_group g, din_usergrouprelationship ugr " . "WHERE ugr.user_id = $this->id " . "AND ugr.group_id = g.id " . "ORDER BY g.name ASC "; - $result = $this->conn->query($sql); - - if (DB :: isError($result) != true) { - if ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { - print ($row->name); - } - while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { - print ($sep . $row->name); - } - return true; - } else { - error("Vis gruppemedlemskap: " . $result->toString()); - notify("Informasjon om gruppemedlemskap utilgjengelig."); - } - } - - public function _deleteAddress($link = null) { - if ($this->addresstype == 'no') { - $sql = "DELETE FROM din_useraddressno WHERE user_id = $this->id"; - } else { - $sql = "DELETE FROM din_useraddressint WHERE user_id = $this->id"; - } - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - error("User delete address: " . $result->toString()); - return false; - } else { - $this->setAddressStatus(0); - $this->_sendWrongAddressMail($link); - $this->_registerUpdate('Adresse slettet.'); - return true; - } - } - - public function displayExpiryListSingle() { - print "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - - $this->displayExpiryList(); - - print "
idkortnrfornavnetternavnutløpsårendre tiloblatendre til
\n"; - } - - public function writeExpiryListFile($expiry = NULL) { - print $this->id . ";"; - print $this->cardno . ";"; - print $this->firstname .";"; - print $this->lastname . ";"; - print strip_nl($this->street) . ";"; - print $this->zipcode . ";"; - print $this->postarea . ";"; - print $this->getAddressStatus() . ";"; - print $this->email . ";"; - print $this->phonenumber . ";"; - print $this->birthdate . ";"; - print $this->expires . ";"; - print $this->lastSticker . ";"; - print $this->getRegistered() . ";"; - print $this->getLastUpdate(); - print "\r\n"; - } - - public function displayExpiryList($expiry = NULL) { - //$card = $this->getMembershipCard(); - - print "\n"; - print " " . $this->id . "\n"; - - print " id . "_cardno\">"; - //if (!is_null($card)) print $card->getId(); - print $this->cardno; - print "\n"; - - print " id . "\" title=\"mer informasjon om " . $this->firstname . " " . $this->lastname . "\">" . $this->firstname . "\n"; - print " " . $this->lastname . "\n"; - - print " "; - if ($this->cardno == null) { - // User hasn't ordered a card - print "
id . "_cardno_form\" action=\"javascript: grantCardNumber('" . $this->id . "')\" " . "method=\"post\">"; - print "\n"; - print "\n"; - print "
"; - } elseif (!$this->getCardProduced()) { - // User's card has been produced, but has not been delivered yet - print "
id . "_cardproduced_form\" " . "action=\"javascript: setCardProduced('" . $this->id . "')\" " . "method=\"post\">"; - print "\n"; - print "\n"; - print "
"; - } elseif (!$this->getCardDelivered()) { - // User's card has been produced, but has not been delivered yet - print "
id . "_carddelivered_form\" " . "action=\"javascript: setCardDelivered('" . $this->id . "')\" " . "method=\"post\">"; - print "\n"; - print "\n"; - print "
"; - - } else { - // User has a membercard - //print "kort mistet?"; - } - print " \n"; - - print " id . "_expires\">"; - if ($this->expires == '0000-00-00') { - print "0"; - } else { - if ($this->expires == NULL) { - print "livsvarig"; - } else { - print (date("Y", strtotime($this->expires))); - } - } - print " \n"; - - print " "; - print "
"; - if ($this->cardno != NULL) { - print "
id . "')\" method=\"get\">"; - print "\n"; - print "\n"; - print "\n"; - print "
"; - } - print "
"; - print "\n"; - - print "id . "_laststicker\">"; - print $this->getLastSticker(); - print "\n"; - - print " "; - if ($this->cardno != NULL) { - print "
id . "')\" method=\"post\">"; - print "
"; - print ""; - print ""; - print ""; - print "
"; - print "
"; - } - print "\n"; - - print " " . $this->getRegistered() . "\n"; - print " " . $this->getLastUpdate(); "\n"; - print "\n"; - } - - public function _registerUpdate($message) { - $sql = "INSERT INTO din_userupdate VALUES (" . - "NULL, " . - "NOW( ), " . - $this->id . ", " . - $this->conn->quoteSmart($message) . ", " . - ((getCurrentUser() == 0) ? $this->id : getCurrentUser()) . - ")"; - $result = $this->conn->query($sql); - if (DB :: isError($result) == true) { - $this->conn->rollback(); - error("Database error (User::_registerUpdate()): " . $result->toString()); - return false; - } else { - $this->conn->commit(); - } - } - - public function displayUpdates() { - $sql = "SELECT d.*, CONCAT(d1.firstname, ' ', d1.lastname) AS updater " . "FROM din_userupdate d, din_user d1 " . "WHERE user_id_updated = $this->id " . "AND d.user_id_updated_by=d1.id ORDER BY date DESC"; - - $result = & $this->conn->query($sql); - if (DB :: isError($result) != true) { - print ""; - print ""; - - while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { - print ""; - } - print "
Liste over endringer
" . formatDatetimeYearShort($row->date) . "$row->comment $row->updater
"; - } else { - error("Users: " . $result->toString()); - } - } - - public function resetPassword() { - $newPassword = generatePassword(); - $sql = "UPDATE din_user SET " . " password = PASSWORD('$newPassword'), " . " passwordReset = 1 " . "WHERE" . " id = $userid"; - $result = $conn->query($sql); - if (DB :: isError($result) == true) { - error("ResetPassword: " . $result->toString()); - notify("Tjenesten er midlertidig utilgjengelig, vennligst forsøk igjen senere."); - return false; - } else { - $this->_registerUpdate('Brukernavn og nytt passord sendt til bruker.'); - return true; - } - } - - public function _sendPassword() { - $sendto = $this->email; - $subject = "Brukernavn og passord for Studentersamfundet Inside"; - $message = "Hei, $this->firstname $this->lastname!\n " . "\n" . "\nHer er din innloggingsinformasjon til Studentersamfundets medlemsider. " . "\n" . "\nDitt brukernavn er: $row->username" . "\nDitt passord er: $newPassword" . "\n" . "\nNår du logger på vil du bli bedt om å endre passord til noe som er lettere å huske." . "\n" . "\nhttps://www.studentersamfundet.no/inside" . "\n" . "\nmvh" . "\n\nDet Norske Studentersamfund."; - $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; - if (mail($sendto, $subject, $message, $headers)) { - notify("Nytt brukernavn og passord er sendt til din registrerte epostadresse. Bruk skjemaet under for å logge deg inn."); - } else { - notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . - "webansvarlig."); - } - } - - // Send mail with notification of card delivery - public function sendCardOrderedNotifyMail() { - $sendto = $this->email; - - $subject = "Medlemskapet ditt er aktivert"; - $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . - "\n\n" . - "Vi har registrert at du har aktivert medlemskapet ditt i Det Norske Studentersamfund. " . - "Du vil motta en e-post når medlemskortet ditt er produsert og klart til å hentes i billettluka på studentersamfundet. \n" . - "\n" . - "For mer informasjon om hva som skjer på Det Norske Studentersamfund, gå inn på vår nettside: http://www.studentersamfundet.no/ .\n" . - "\n" . - "Er det noe du lurer på kan du bare svare på denne eposten, så svarer vi så fort vi klarer.\n". - "\n\n" . - "Bli aktiv i dag!\n" . - "www.studentersamfundet.no/bliaktiv\n" . - "\n\n" . - "Mvh\n\n" . - "Medlemskapsordningen\n" . - "medlemskap@studentersamfundet.no\n" . - "Det Norske Studentersamfund\n\n"; - - $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; - - if (!mail($sendto, $subject, $message, $headers)) { - notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); - } - } - - // Send mail with notification of card delivery - public function sendCardProducedNotifyMail() { - $sendto = $this->email; - - $subject = "Medlemskortet ditt er produsert"; - $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . - "\n\n" . - "Vi har nå produsert medlemskortet ditt i Det Norske Studentersamfund. " . - "Det ligger nå klart til avhenting i billettluka på Studentersamfundet og kan hentes der i billettlukas åpningstid. \n" . - "\n" . - "For mer informasjon om hva som skjer på Det Norske Studentersamfund, gå inn på vår nettside: http://www.studentersamfundet.no/ .\n" . - "\n" . - "Er det noe du lurer på kan du bare svare på denne eposten, så svarer vi så fort vi klarer.\n". - "\n\n" . - "Bli aktiv i dag!\n" . - "www.studentersamfundet.no/bliaktiv\n" . - "\n\n" . - "Mvh\n\n" . - "Medlemskapsordningen\n" . - "medlemskap@studentersamfundet.no\n" . - "Det Norske Studentersamfund\n\n"; - - $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; - - if (!mail($sendto, $subject, $message, $headers)) { - notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); - } - } - - // Send mail with notification of card delivery - public function sendRenewedMembershipRegisteredNotifyMail () { - $sendto = $this->email; - - $subject = "Medlemsskapet ditt i Det Norske Studentersamfund er registrert som fornyet"; - $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . - "\n\n" . - "Vi har registrert at du har fornyet medlemsskapet ditt i Det Norske Studentersamfund. " . - "Medlemsoblat som viser at du har medlemskap kan hetes i billettluka på Studentersamfundet i billettlukas åpningstid. Ta med medlemskortet ditt. \n" . - "Hvis du har mistet medlemskortet ditt kan du få ordnet nytt kort i billettluka også, eller bestille det fra nettbutikken.\n". - "\n" . - "For mer informasjon om hva som skjer på Det Norske Studentersamfund, gå inn på vår nettside: http://www.studentersamfundet.no/ .\n" . - "\n" . - "Er det noe du lurer på kan du bare svare på denne eposten, så svarer vi så fort vi klarer.\n". - "\n\n" . - "Bli aktiv i dag!\n" . - "www.studentersamfundet.no/bliaktiv\n" . - "\n\n" . - "Mvh\n\n" . - "Medlemskapsordningen\n" . - "medlemskap@studentersamfundet.no\n" . - "Det Norske Studentersamfund\n\n"; - - $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; - - if (!mail($sendto, $subject, $message, $headers)) { - notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); - } - } - - public function sendNewAddressMail ($newstreet, $newzipcode) { - $sendto = $this->email; - - $subject = "Du er registrert med feil postadresse"; - $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . - "\n\n" . - "Vi har sendt ut en postsending til deg, og fått beskjed fra posten " . - "om at du har flyttet fra \"" . - $this->street . ", " . $this->zipcode . " " . $this->postarea . - "\" til \"" . - $newstreet . ", " . $newzipcode . " " . $this->getPostarea($newzipcode) . - "\".\n" . - "Brevet er vidresendt til denne nye adressen. " . - "Hvis du ikke har mottatt dette brevet, eller ikke har flyttet kan " . - "du logge inn på våre medlemsider og oppdatere din adresse. " . - "Logg inn på denne siden: " . - "https://www.studentersamfundet.no/inside - ditt brukernavn er " . - "\"" . $this->username . "\".\n" . - "\n" . - "Hvis du ikke har mottat medlemskortet vil vi at du svarer på denne " . - "e-posten etter du har oppdatert din adresse og ber om å få tilsendt " . - "nytt medlemskort.\n" . - "\n\n\n" . - "Mvh\n\n" . - "Medlemskapsordningen\n" . - "medlemskap@studentersamfundet.no\n" . - "Det Norske Studentersamfund\n\n"; - - $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; - - if (mail($sendto, $subject, $message, $headers)) { - notify("Melding om ny adresse er sendt til $this->email"); - } else { - notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); - } - } - - public function _sendWrongAddressMail($link = null) { - $sendto = $this->email; - $linkMessage = ""; - if ($link) { - $linkMessage = "Brevet vi har forsøkt å sende kan du også " . - "lese på nett fra denne adressen:\n$link\n\n"; - } - $subject = "Postforsendelse er ikke kommet frem til addressen din"; - $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . - "\n\n" . - "Vi har sendt ut en postsending til deg, og fått beskjed fra Posten ". - "om at du var ukjent på din oppgitte adresse. \n" . - "Vi sendte brevet til følgende adresse: \"" . $this->street . ", " . - $this->zipcode . " " . $this->postarea . "\". " . - "På grunn av tilbakemeldingen om at du er ukjent på adressen ". - "er brevet så blitt makulert av Posten, på oppdrag av oss." . - "\n" . - $linkMessage . - "\n" . - "Hvis du ikke har mottat medlemskortet eller oblatet ditt er det " . - "mest sannsynlig det som var i denne postforsendelsen. Hvis du fortsatt " . - "bor på adressen over, eller har meldt flytting fra denne adressen må " . - "du klage til Posten, enten på telefon 810 00 710, eller gjennom skjemaet " . - "du finner på denne siden: http://www.posten.no/Kundeservice .\n" . - "Be om svar på epost og videresend denne til medlemskap@studentersamfundet.no " . - "så sender vi deg et nytt medlemskort kostnadsfritt. \n" . - "\n". - "Hvis du derimot har oppgitt feil adresse, eller har flyttet uten å " . - "melde flytting må du logge inn på våre medlemsider, oppdatere adressen " . - "din og bestille nytt kort i nettbutikken. Da vil du automatisk få tilsendt " . - "nytt kort. Vi må ta 35 kroner for å dekke våre kostnader. " . - "Våre medlemsider finner du på https://www.studentersamfundet.no/inside/ ." . - "Ditt brukernavn er \"" . $this->username . "\". \n". - "\n\n\n" . - "Mvh\n\n" . - "Medlemskapsordningen\n" . - "medlemskap@studentersamfundet.no\n" . - "Det Norske Studentersamfund\n\n"; - - $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; - - if (mail($sendto, $subject, $message, $headers)) { - notify("Melding om ugyldig adresse er sendt til $this->email"); - } else { - notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); - } - } - - /* - * Print the status of the user's membership - * return: string - */ - public function membershipStatus() { - //print "'" . $this->expires . "','" . $this->hasCard . "'"; - if ($this->expires == "0000-00-00") - return "Du har ikke registrert medlemskap."; - elseif ($this->expires == "") - return "Du har livsvarig medlemskap."; - elseif (strtotime($this->expires) < strtotime("now")) - return "Du har ikke registrert gyldig medlemskap i år (medlemskapet ditt gikk ut " . date("d.m.Y", strtotime($this->expires)) . ")."; - elseif (strtotime($this->expires) > strtotime("now")) { - if ($this->getCardDelivered()) { - if ($this->lastSticker < date("Y", strtotime($this->expires))) { - return "Du har aktivert medlemskapet ditt, og du kan hente oblat til å klistre på medlemskortet ditt i bilettluka på Det Norske Studentersamfund."; - } else { - return "Du har gyldig medlemskap (gyldig til " . date("d. m. Y", strtotime($this->expires)) . ")."; - } - } elseif ($this->getCardProduced()) { - return "Medlemskapet ditt for " . date("Y", strtotime($this->expires)) . " er registrert, og medlemskortet ditt ligger klar til henting i billettluka på Det Norske Studentersamfund."; - } else { - return "Medlemskapet ditt er registrert, og medlemskortet ditt for " . date("Y", strtotime($this->expires)) . " produseres."; - } - } - - return "Ukjent medlemskapsstatus"; - } - - function setMembershipCard($membershipCard) { - if (!is_null($this->membershipCard)) { - return false; - } - - $membershipCard->setUserId($this->id); - $this->membershipCard = $membershipCard; - } - - function getMembershipCard() { - if (is_null($this->membershipCard)) { - $this->membershipCard = new MembershipCard(); - if (!$this->membershipCard->findByUserId($this->id)) { - $this->membershipCard = null; - } - } - return $this->membershipCard; - } -} +__construct($id, $data); + } + + public function __construct($id, $data = NULL) { + $conn = & DB :: connect(getDSN()); + if (DB :: isError($conn)) { + print ("error: " . $conn->toString()); + exit (); + } else { + $this->conn = $conn; + } + + $action = scriptParam("action"); + $this->id = $id; + + if ($id == NULL) { //New user + if ($data == NULL) { + error("User: No data supplied."); + $this->id = -1; + return false; + } else { + $this->username = stripcslashes($data['username']); + if (strlen($data['password1']) < 4) { + notify("Passordet må være minst 4 tegn."); + $this->id = -1; + return false; + } else { + if ($data['password1'] != $data['password2']) { + notify("Passordene var ikke like."); + $this->id = -1; + return false; + } else { + $this->password = $data['password1']; + if (!isAdmin()) { + switch (checkForumUsername($data['username'], $this->password)) { + case "wrong-password" : + notify("Brukernavnet er allerede i bruk på forumet. " . "Om du selv har dette brukernavnet må du oppgi " . "riktig passord."); + $this->id = -1; + return false; + } + } + } + } + + $this->addresstype = isset ($data['addresstype']) ? "int" : "no"; + + if (isDate($data['birthdate'])) { + $this->birthdate = $data['birthdate']; + } else { + notify("Ugyldig fødselsdato: " . $data['birthdate']); + $this->id = -1; + return false; + } + + if (isset ($data['active'])) { + $this->division_id_request = $data['division']; + } else { + $this->division_id_request = NULL; + } + if (isset ($data['group'])) { + $this->group_id = $data['group_id']; + } else { + $this->group_id = NULL; + } + } + } else { //ID set, existing user + if ($data != NULL) { + // Update existing user + $this->addresstype = isset ($data['addresstype']) ? "int" : "no"; + } else { + //Retrieve data from backend for display or other actions + if ($data = $this->_retrieveData()) { + $this->username = stripcslashes($data['username']); + $this->cardno = $data['cardno']; + $this->expires = $data['expires']; + $this->division_id_request = $data['division_id_request']; + $this->lastSticker = $data['lastSticker']; + $this->addresstype = $data['addresstype']; + } else { + // not successful + return false; + } + } + + $this->birthdate = $data['birthdate']; + $this->cardProduced = $data['cardProduced']; + $this->cardDelivered = $data['cardDelivered']; + $this->validAddress = $data['valid_address']; + } + + //Common initializations + $this->firstname = stripcslashes($data['firstname']); + $this->lastname = stripcslashes($data['lastname']); + if (empty ($data['street'])) { + $data['street'] = "-"; + } + $this->street = stripcslashes($data['street']); + if (empty ($data['zipcode'])) { + $data['zipcode'] = "-"; + } + $this->zipcode = $data['zipcode']; + if ($this->addresstype == "no") { + if ($action != "register-user") { + if (empty ($data['postarea'])) { + $data['postarea'] = "-"; + } + $this->postarea = $data['postarea']; + } + } else { + $this->city = $data['city']; + $this->state = $data['state']; + $this->country = $data['country']; + } + if ($data['phonenumber'] == "00000000" || $data['phonenumber'] == "") { + $data['phonenumber'] = "-"; + } + $this->phonenumber = $data['phonenumber']; + $this->email = $data['email']; + $this->placeOfStudy = $data['placeOfStudy']; + return true; + } + + public function store() { + if (!$this->_validate()) { + return false; + } + $action = scriptParam("action"); + if ($action == "register-user") { + + $this->conn->autoCommit(false); + $this->id = getNextId("din_user"); + $sql = sprintf("INSERT INTO din_user " . + " (id, username, password, firstname, " . + " lastname, addresstype, email, birthdate, " . + " placeOfStudy, division_id_request) " . "VALUES " . " (%s, %s, PASSWORD(%s), %s, %s, %s, %s, " . " %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->username), $this->conn->quoteSmart($this->password), $this->conn->quoteSmart($this->firstname), $this->conn->quoteSmart($this->lastname), $this->conn->quoteSmart($this->addresstype), $this->conn->quoteSmart($this->email), $this->conn->quoteSmart($this->birthdate), $this->conn->quoteSmart($this->placeOfStudy), $this->conn->quoteSmart(($this->division_id_request == NULL) ? NULL : $this->division_id_request)); + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + if ($result->getCode() == -5) { + $err = $this->_findConstraintViolation(); + notify("Denne epostadressen eller brukernavnet er allerede registrert."); + $GLOBALS['extraScriptParams']['page'] = "register-user"; //Swap page + } else { + error("New user: " . $result->toString()); + notify("Problem under registrering av ny bruker."); + } + return false; + } + if ($this->addresstype == "no") { + $sql = sprintf("INSERT INTO din_useraddressno " . + " (user_id, street, zipcode) " . + "VALUES " . + " (%s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode)); + } else { + $sql = sprintf("INSERT INTO din_useraddressint " . " (user_id, street, zipcode, city, state, country) " . "VALUES " . " (%s, %s, %s, %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode), $this->conn->quoteSmart($this->city), $this->conn->quoteSmart($this->state), $this->conn->quoteSmart($this->country)); + } + + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + $this->conn->rollback(); + if ($result->getCode() == -3) { + error("Ugyldig postnummer." . $result->toString()); + notify("Ugyldig postnummer."); + } else { + error("New user (address): " . $result->toString()); + } + return false; + } + + // Mark address as valid + $this->setAddressStatus(1); + + $sql = sprintf("INSERT INTO din_userphonenumber VALUES (%s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->phonenumber)); + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + $this->conn->rollback(); + error("New user (phonenumber): " . $result->toString()); + return false; + } + + //Group relationships + $groupRel = new UserGroupRelationship($this->id, 1); + $groupRel->store(); + if ($this->group_id > 1) { + $groupRel = new UserGroupRelationship($this->id, $this->group_id); + $groupRel->store(); + } + + //Register cardnumber as used + if ($this->cardno != NULL) { + if (!$this->_registerUsedCardno($this->cardno)) { + notify("Kortnummeret er allerede registrert."); + $this->conn->rollback(); + return false; + } + } + + //Logging + $sql = sprintf("INSERT INTO din_userupdate " . "VALUES (NULL, NOW(), %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart("User registered."), $this->conn->quoteSmart((getCurrentUser() == 0) ? $this->id : getCurrentUser())); + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + $this->conn->rollback(); + error("New user (userUpdate): " . $result->toString()); + return false; + } else { + if ($this->conn->commit()) { + $GLOBALS['extraScriptParams']['userid'] = $this->id; + if (loggedIn()) { + notify("Ny bruker er registrert"); + } else { + notify("Din bruker er registrert."); + send_welcome_mail($this); + $GLOBALS['extraScriptParams']['page'] = "register-membership"; + } + return true; + } else { + $this->conn->rollback(); + } + } + + } else { //Update + $this->conn->autoCommit(false); + $sql = "UPDATE din_user SET " . + "firstname = " . $this->conn->quoteSmart($this->firstname) . + ", lastname = " . $this->conn->quoteSmart($this->lastname) . + ", addresstype = " . $this->conn->quoteSmart($this->addresstype) . + ", email = " . $this->conn->quoteSmart($this->email == "" ? NULL : $this->email) . + ", birthdate = " . $this->conn->quoteSmart($this->birthdate) . + ", placeOfStudy = " . $this->conn->quoteSmart($this->placeOfStudy) . + ", cardProduced = " . $this->conn->quoteSmart($this->cardProduced) . + ", cardDelivered = " . $this->conn->quoteSmart($this->cardDelivered) . + " WHERE id = " . $this->conn->quoteSmart($this->id); + + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("Update user: " . $result->toString()); + notify("Feil under oppdatering av kontaktinfo."); + return false; + } + + // Slett adressen hvis den kun består av en x. + // Brukeren får da en mail med informasjon om å oppdatere adressen sin. + if (substr($this->street, 0, 1) == 'x') { + $link = substr($this->street, 2); + if ($this->_deleteAddress($link)) { + notify("Adresse slettet."); + } + } else { + if ($this->addresstype == "no") { + $sql = sprintf("REPLACE INTO din_useraddressno VALUES (%s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode)); + } else { + $sql = sprintf("REPLACE INTO din_useraddressint VALUES (%s, %s, %s, %s, %s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->street), $this->conn->quoteSmart($this->zipcode), $this->conn->quoteSmart($this->city), $this->conn->quoteSmart($this->state), $this->conn->quoteSmart($this->country)); + } + + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + $this->conn->rollback(); + if ($result->getCode() == -3) { + notify("Ugyldig postnummer! Endringer er ikke lagret."); + } else { + notify("Feil med adressen. Endringer er ikke lagret."); + error("New user (address): " . $result->toString()); + } + return false; + } + + // ugly fix ... set address manual if the user is admin + if (isAdmin()) { + $this->setAddressStatus($this->validAddress); + } else { + // mark address as valid + $this->setAddressStatus(1); + } + } + $sql = "DELETE FROM din_userphonenumber WHERE user_id = $this->id"; + $this->conn->query($sql); + $sql = sprintf("INSERT INTO din_userphonenumber VALUES (%s, %s)", $this->conn->quoteSmart($this->id), $this->conn->quoteSmart($this->phonenumber)); + + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("New user (phonenumber): " . $result->toString()); + return false; + } + + if ($result = $this->conn->commit()) { + $this->_registerUpdate("Brukerinformasjon oppdatert"); + notify("Brukerinformasjon oppdatert."); + } else { + error("User rollback; " . $result->toString()); + $this->conn->rollback(); + } + } + } + + public function _validate() { + $valid = true; + if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $this->email)) { + notify("Ugyldig format på epostadresse."); + $valid = false; + } + return $valid; + } + + public function _retrieveData() { + $sql = "SELECT u.*, up.number AS phonenumber " . "FROM din_user u LEFT JOIN din_userphonenumber up " . "ON u.id = up.user_id " . "WHERE u.id = $this->id"; + $result = & $this->conn->query($sql); + if (DB :: isError($result) != true) { + if ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC)) { + if ($row['addresstype'] == "no") { + $sql = "SELECT ua.street, ua.zipcode, pn.poststed AS postarea " . "FROM din_useraddressno ua, postnummer pn " . "WHERE ua.user_id = $this->id " . "AND ua.zipcode = pn.postnummer"; + } else { + $sql = "SELECT street, zipcode, city, state, country " . "FROM din_useraddressint " . "WHERE user_id = $this->id"; + } + $result = & $this->conn->query($sql); + if (DB :: isError($result) != true) { + if ($row2 = & $result->fetchRow(DB_FETCHMODE_ASSOC)) { + $row = $row + $row2; + } + return $row; + } else { + error("Users: " . $result->toString()); + return false; + } + } else { + error("Users: invalid userid"); + return false; + } + } + } + + // Fetch the postarea of a given zipcode + public function getPostarea ($zipcode = null) { // = $this->zipcode) { + if ($zipcode == null) $zipcode = $this->zipcode; + + $sql = "SELECT poststed AS postarea FROM postnummer WHERE postnummer=\"$zipcode\""; + $result = & $this->conn->query($sql); + if (DB :: isError($result) != true) { + $row = & $result->fetchRow(DB_FETCHMODE_ASSOC); + return $row["postarea"]; + } + return false; + } + + public function getId () { + return $this->id; + } + + public function getLastSticker () { + if ($this->lastSticker > 0) { + return $this->lastSticker; + } + return null; + } + + public function changeUsername($username, $password) { + switch (checkForumUsername($username, $password)) { + case "wrong-password" : + notify("Brukernavnet er allerede i bruk på forumet. " . "Om du selv har dette brukernavnet må du oppgi " . "riktig passord."); + return false; + + case "not-used" : + case "auth-ok" : + $sql = "UPDATE din_user SET " . " username = '$username' " . "WHERE " . " id = $this->id"; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + if ($result->getCode() == -5) { + $err = $this->_findConstraintViolation(); + error("Change username: $err already registered."); + notify("Brukernavnet er opptatt."); + $GLOBALS['extraScriptParams']['page'] = "change-username"; //Swap page + } else { + error("Change username: " . $result->toString()); + notify("Problem under endring av brukernavn."); + } + return false; + } else { + $this->_registerUpdate("Brukernavn endret til $username"); + notify("Brukernavn endret."); + } + } + } + + public function getRegistered() { + $sql = "SELECT uu.date FROM din_user u, din_userupdate uu + WHERE uu.user_id_updated=u.id AND u.id = $this->id + ORDER BY uu.date ASC LIMIT 1"; + $result = & $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("Get user registered: " . $result->toString()); + return false; + } + + if ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { + return $row->date; + } + + } + + public function getLastUpdate() { + $sql = "SELECT uu.date FROM din_user u, din_userupdate uu + WHERE uu.user_id_updated=u.id AND u.id = $this->id + ORDER BY uu.date DESC LIMIT 1"; + $result = & $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("Get user last update: " . $result->toString()); + return false; + } + + if ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { + return $row->date; + } + } + + public function getOrderId() { + $sql = "SELECT id FROM din_order " . + "WHERE user_id = $this->id " . + "AND order_status_id < 3 " . + "ORDER BY timestamp DESC LIMIT 1"; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + return null; + } + + if ($row =& $result->fetchRow(DB_FETCHMODE_OBJECT)) { + return $row->id; + }else { + return null; + } + } + + public function getName() { + return trim($this->firstname.' '.$this->lastname); + } + + public function getContactInfo() { + $c = "$this->firstname $this->lastname\n"; + $c .= "$this->phonenumber\n"; + $c .= "$this->email"; + return $c; + } + + public function _findConstraintViolation() { + $sql = "SELECT id FROM din_user WHERE id = $this->id"; + $result = $this->conn->query($sql); + if ($result->numRows() > 0) { + return "id"; + } + $sql = "SELECT id FROM din_user WHERE username = '$this->username'"; + $result = $this->conn->query($sql); + if ($result->numRows() > 0) { + return "brukernavnet"; + } + } + + public function displayGroups() { + $sql = "SELECT g.id, g.name " . "FROM din_group g, din_usergrouprelationship ugr " . "WHERE ugr.user_id = $this->id " . "AND ugr.group_id = g.id " . "ORDER BY g.name ASC "; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("Vis gruppemedlemskap: " . $result->toString()); + notify("Informasjon om gruppemedlemskap utilgjengelig."); + return false; + } + + print (""); + print (""); + while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { + print (""); + if ($row->id != 1) { + displayOptionsMenuTable(Array ( + "user_id" => $this->id, + "group_id" => $row->id + ), USERGROUPRELATIONSHIP, "usergrouprelationship", "view-edit-options-usergrouprelationship", NULL, "display-user"); + } else { + print (""); + } + print (""); + } + print ("
Grupper brukeren er medlem av
$row->name
"); + } + + public function displayOrders($status = 1) { + $sql = "SELECT id FROM din_order WHERE user_id = $this->id AND order_status_id = $status"; + $result = & $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("Display orders: " . $result->toString()); + return false; + } + + if ($result->numRows() == 0) { + print ("

Ingen handlekurver funnet"); + return false; + } + while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { + $order = new Order($row->id); + $edit = true; + $order->displayShortList($edit); + } + + } + + public function registerMembership($cardno) { + // check that the activation code is valid + $sql = "SELECT id FROM din_user WHERE cardno=$cardno"; + $result = $this->conn->query($sql); + if (DB :: isError($result) != true) { + if ($result->numRows() > 0) { + notify("Kortnummeret er allerede i bruk. Vennligst kontrollér nummeret."); + return false; + } + } else { + error($result->toString()); + notify("En ukjent feil oppstod. Vennligst kontakt administrator."); + } + + // register cardno as used + $sql = "INSERT INTO din_usedcardno VALUES ($this->cardno, NOW())"; + $result = $this->conn->query($sql); + + if ($this->cardno == null) { + // user doesn't have a previous card number, set his cardno to current cardno + $this->cardno = $cardno; + } + + $expires = $this->getExpiryDate(); + + $sql = "UPDATE din_user SET cardno=" . $this->cardno . ", expires = '$expires' WHERE id=" . $this->id; + $result = $this->conn->query($sql); + if (DB::isError($result) != true) { + $this->_registerUpdate("Medlemskap registrert."); + return true; + } else { + error($result->toString()); + notify("En ukjent feil oppstod. Vennligst kontakt administrator."); + } + } + + function registerMembershipPayex() { + return $this->grantCardno("payex"); + } + + public function renewMembership($cardno) { + $expires = $this->getExpiryDate(); + if ($expires <= $this->expires) { + notify("Du har allerede gyldig medlemskap for dette året."); + return false; + } + $this->conn->autoCommit(false); + if ($this->_registerUsedCardno($cardno) == true) { + $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error($result->toString()); + return false; + } + $this->_registerUpdate("Medlemskap fornyet."); + if ($result = $this->conn->commit()) { + return true; + } else { + notify("Problemer med registrering av fornyet medlemskap"); + error("Kortnummer: " . $result->toString()); + return false; + } + } else { + notify("En ukjent feil oppstod. Vennligst kontakt administrator."); + } + } + + public function renewMembershipPayex() { + $expires = $this->getExpiryDate(); + if ($expires <= $this->expires) { + notify("Du har allerede gyldig medlemskap for dette året."); + return false; + } + $this->conn->autoCommit(false); + $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error($result->toString()); + return false; + } + $this->_registerUpdate("Medlemskap fornyet med Payex."); + if ($result = $this->conn->commit()) { + notify("Medlemskap fornyet."); + return true; + } else { + notify("Problemer med registrering av fornyet medlemskap"); + error("Kortnummer: " . $result->toString()); + return false; + } + } + + public function renewMembershipEurobate() { + $expires = $this->getExpiryDate(); + if ($expires <= $this->expires) { + // har allerede gyldig medlemskap + return false; + } + $this->conn->autoCommit(false); + $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; + $result = $this->conn->query($sql); + if (DB::isError($result) == true) { + return false; + } + $this->_registerUpdate("Medlemskap fornyet med SMS."); + if ($result = $this->conn->commit()) { + return true; + } else { + return false; + } + } + + /** + * Bankbetaling med KID + */ + public function renewMembershipBankpayment() { + if (false and $this->isHonorMember()) { + notify($this->id . ", " . $this->getName() . " er livsvarig medlem. Medlemskapet vil ikke bli oppdater."); + return false; + } else { + $expires = $this->getExpiryDate(); + if ($expires <= $this->expires) { + $newexpires = date("Y-m-d", strtotime("+1 year", strtotime($expires))); + notify($this->id . ", " . $this->getName() . " har allerede gyldig medlemskap for dette året. Har utløpsdato " . $this->expires . ", men ny ble prøvd satt til " . $expires . ". Personen vil få satt ny utløpsdate på medlemskapet til " . $newexpires); + $expires = $newexpires; + } + $this->conn->autoCommit(false); + $sql = "UPDATE din_user SET " . " expires = '$expires' " . "WHERE " . " id = $this->id"; + + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error($result->toString()); + return false; + } + + if ($result = $this->conn->commit()) { + // send mail to the user + $this->sendRenewedMembershipRegisteredNotifyMail(); + + $this->_registerUpdate("Medlemskap fornyet med KID-betaling til bank."); + notify($this->id . ", " . $this->getName() . ": medlemskap fornyet fram til " . $expires . "."); + return true; + } else { + notify($this->id . ", " . $this->getName() . ": Problemer med registrering av fornyet medlemskap"); + error("Kortnummer: " . $result->toString()); + return false; + } + } + } + + /* Order new membercard if old one is lost */ + public function renewMembercardPayex() { + $expires = $this->getExpiryDate(); + if ($expires > $this->expires) { + notify("Du har ikke gyldig medlemskap for dette året."); + return false; + } + $this->conn->autoCommit(false); + $sql = "UPDATE din_user SET cardProduced='0', cardDelivered='0' WHERE id = " . $this->id; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error($result->toString()); + return false; + } + $this->_registerUpdate("Nytt medlemskort bestilt med Payex."); + if ($result = $this->conn->commit()) { + notify("Medlemskortet er lagt i produksjonskøen."); + return true; + } else { + notify("Problemer med registrering av bestillingen."); + error("Kortnummer: " . $result->toString()); + return false; + } + } + + public static function delete($id) { + $conn = db_connect(); + $sql = "DELETE FROM din_user WHERE id = $id LIMIT 1"; + $result = $conn->query($sql); + if (DB :: isError($result) != true) { + notify("Bruker slettet."); + } else { + error($result->toString()); + } + } + + public function updateExpiry($newDate) { + if ($newDate == 'lifetime') { + $sql = "UPDATE din_user SET expires = NULL WHERE id = $this->id LIMIT 1"; + } else { + $sql = "UPDATE din_user SET expires = '$newDate-12-31' WHERE id = $this->id LIMIT 1"; + } + $conn = db_connect(); + $result = $this->conn->query($sql); + if (DB :: isError($result) != true) { + $this->_registerUpdate("Utløpsdato oppdatert til " . $newDate); + notify("Utløpsdato oppdatert."); + } else { + error($result->toString()); + } + } + + public function updateLastSticker($newDate) { + $sql = "UPDATE din_user SET lastSticker = '$newDate' WHERE id = $this->id LIMIT 1"; + $result = $this->conn->query($sql); + if (DB :: isError($result) != true) { + $this->_registerUpdate("Oppdatert oblat til " . $newDate); + $this->lastSticker = $newDate; + notify("Oblat oppdatert til " . $this->getLastSticker() . " for " . $this->getName() . "."); + + // Assume that a letter is sent to the registered address. + // We mark the address as valid, and will update it as invalid if the letter is not delivered + $this->setAddressStatus(1); + } else { + error($result->toString()); + } + } + + public function displayList() { + print "\n"; + print " " . $this->cardno . "\n"; + print " "; + if ($this->hasExpired()) { + print 'nei'; + } else { + print 'ja'; + } + print "\n"; + + print " id . "\" title=\"mer informasjon om " . + $this->firstname . " " . $this->lastname . "\">" . + $this->firstname . "\n"; + + print "" . $this->lastname . "\n"; + + print "" . prepareForHTML($this->email) . "\n"; + + print ""; + print $this->phonenumber; + if ($this->phonenumber != "-") { + print "phonenumber . "\" " . + "title=\"ring til " . $this->firstname . " " . $this->lastname . "\">"; + print "\"ringfirstname . " " . $this->lastname . "\" />"; + print ""; + } + print "\n"; + + print ""; + $this->_printGroups(", "); + print "\n"; + + print "\n"; + } + + public function displayDivReqList() { + if ($this->division_id_request != NULL) { + $div = new Division($this->division_id_request); + } else { + return false; + } + + print "\n"; + + print " id . "\" title=\"mer informasjon om " . $this->firstname . " " . $this->lastname . "\">"; + print $this->firstname; + print "\n"; + + print "" . $this->lastname . "\n"; + + print "" . prepareForHTML($this->email) . "\n"; + + print "" . $div->name . "\n"; + + print "" . $this->getRegistered() . "\n"; + + print ""; + print "

id . "\" method=\"post\">"; + print "
"; + print ""; + print ""; + print ""; + print "
"; + print "
"; + print "\n"; + + print "\n"; + } + + public function isMember() { + if ($this->cardno == NULL) { + return false; + } else { + return true; + } + } + + public function isActive() { + $sql = "SELECT group_id " . "FROM din_usergrouprelationship " . "WHERE user_id = $this->id "; + $result = $this->conn->query($sql); + + if (DB :: isError($result) == true) { + error("isActive: " . $result->toString()); + return false; + } + if ($result->numRows() > 1) { + return true; + } else { + return false; + } + } + + public function getNumProductsBought($product_id = 0) { + $sql = "SELECT SUM(oi.quantity) AS num FROM din_user u, din_order o, din_order_item oi " . + "WHERE o.user_id = u.id AND oi.order_id = o.id AND oi.product_id = 2 AND o.order_status_id = 4 AND u.id = $this->id"; + $result = $this->conn->query($sql); + + if (DB :: isError($result) == true) { + error("isActive: " . $result->toString()); + return 0; + } + if ($row = & $result->fetchRow(DB_FETCHMODE_ORDERED)) { + return $row[0]; + } else { + return false; + } + } + + public function hasExpired() { + if ($this->expires == NULL) { + return false; + } else + if ($this->expires > date("Y-m-d")) { + return false; + } else { + return true; + } + } + + public function getCardProduced() { + return $this->cardProduced; + } + + public function setCardProduced($produced) { + if ($produced) { + $sql = "UPDATE din_user SET cardProduced=1 WHERE id=$this->id"; + $desc = "medlemskort produsert"; + $this->cardProduced = 1; + } else { + $sql = "UPDATE din_user SET cardProduced=0, cardDelivered=0 WHERE id=$this->id"; + $desc = "mangler medlemskort"; + $this->cardProduced = 0; + } + $result = $this->conn->query($sql); + + if (DB :: isError($result) != true) { + $this->_registerUpdate("Medlemskortstatus endret til $desc"); + notify("Medlemskortstatus for " . $this->firstname . " " . $this->lastname . " er endret til " . $desc . ""); + } + } + + public function getCardDelivered() { + return $this->cardDelivered; + } + + public function setCardDelivered($delivered) { + if ($delivered) { + $sql = "UPDATE din_user SET cardDelivered=1 WHERE id=$this->id"; + $desc = "medlemskort utlevert"; + $this->cardDelivered = 1; + } else { + $sql = "UPDATE din_user SET cardDelivered=0 WHERE id=$this->id"; + $desc = "medlemskort ikke utlevert"; + $this->cardDelivered = 0; + } + $result = $this->conn->query($sql); + + if (DB :: isError($result) != true) { + $this->_registerUpdate("Medlemskortstatus endret til $desc"); + notify("Medlemskortstatus for " . $this->firstname . " " . $this->lastname . " er endret til " . $desc . ""); + } + } + + public function hasCardSticker() { + if ($this->getLastSticker() >= date("Y", strtotime($this->expires))) { + return true; + } + } + + public function getExpiryDate() { + if (date("Y-m-d") > date("Y-11-15")) { + return date("Y", strtotime("+1 year")) . "-12-31"; + } else { + return date("Y") . "-12-31"; + } + } + + public function _registerUsedCardno($cardno) { + $sql = "INSERT INTO din_usedcardno VALUES ( " . " $cardno, NOW())"; + $result = $this->conn->query($sql); + if (DB :: isError($result) != true) { + return true; + } else { + error("Registrér kortnummer: " . $result->toString()); + notify("Kortnummeret er allerede registrert."); + } + } + + public function grantCardno($src = NULL) { + $sql = "SELECT value FROM din_settings " . "WHERE name = 'next_online_cardno'"; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("grantCardno: " . $result->toString()); + return false; + } + if ($row = & $result->fetchRow(DB_FETCHMODE_ORDERED)) { + $cardno = $row[0]; + } + + $expires = $this->getExpiryDate($cardno); + $sql = "UPDATE din_user SET " . " cardno = $cardno, " . " expires = '$expires' " . "WHERE " . " id = $this->id"; + $result = $this->conn->query($sql); + if (DB :: isError($result) != true) { + $this->cardno = $cardno; + $this->expires = $expires; + notify("$this->firstname $this->lastname er tildelt medlemskortnummer $cardno"); + $this->_registerUpdate("Bruker tildelt kortnummer. $src"); + + $sql = "UPDATE din_settings SET value = value + 1 WHERE name = 'next_online_cardno'"; + $this->_registerUsedCardno($cardno); + $result = $this->conn->query($sql); + return true; + } else { + error("Registrér kortnummer: " . $result->toString()); + notify("Problemer med registrering av kortnummer."); + return false; + } + } + + /** + * changes validity status of users address + * values can be: + * 0 - not valid address + * 1 - valid address + * 2 - status of address unknown + * + * @param integer $value + * @return boolean + **/ + public function setAddressStatus($value) { + // check for valid input value + if (is_numeric($value) && $value >= 0 && $value <=2) { + $sql = "UPDATE din_user SET " . + "valid_address = '$value' " . + "WHERE " . + "id = $this->id"; + $result = $this->conn->query($sql); + + if (DB :: isError($result) != true) { + $this->validAddress = $value; + + switch ($value) { + case 1: + $valuetext = "gyldig"; break; + case 2: + $valuetext = "ukjent"; break; + default: + $valuetext = "ugyldig"; break; + } + // store update + $this->_registerUpdate("Adressestatus satt til $valuetext."); + + // done + return true; + } else { + notify("Problemer med registreringen av adressestatus"); + return false; + } + } else { + notify("Ugyldig adressestatusverdi: " . $value); + return false; + } + return false; + } + + public function getAddressStatus() { + switch ($this->validAddress) { + case 1: + return "gyldig"; break; + case 2: + return "ukjent"; break; + default: + return "ugyldig"; break; + } + } + + public function isHonorMember () { + if ($this->expires == NULL) return true; + return false; + } + + public function setCardno($value) { + $sql = "UPDATE din_user SET cardno = $value " . + "WHERE id = $this->id"; + $result = $this->conn->query($sql); + + if (DB :: isError($result) != true) { + $value = ($value == "NULL") ? "NULL" : $value; + $this->_registerUpdate("Medlemskortnummer endret til $value"); + notify("Medlemskortnummer for $this->firstname $this->lastname er endret til $value"); + } + } + + public function setExpires($value) { + $sql = "UPDATE din_user SET expires = '$value' " . + "WHERE id = $this->id"; + $result = $this->conn->query($sql); + + if (DB :: isError($result) != true) { + $this->_registerUpdate("Utløpsdato endret til $value"); + notify("Utløpsdato for $this->firstname $this->lastname er endret til $value"); + } + } + + public function updateDivisionRequest($value) { + if (empty ($value)) { + notify("Ugyldig verdi."); + return false; + } + if ($this->division_id_request != NULL) { + $div = new Division($this->division_id_request); + } + $sql = "UPDATE din_user SET " . " division_id_request = NULL " . "WHERE " . " id = $this->id"; + $result = $this->conn->query($sql); + if (DB :: isError($result) != true) { + if ($value == "reject") { + $this->_registerUpdate("Aktivforespørsel avvist"); + notify("Forespørsel fra $this->firstname $this->lastname om å bli registrert som aktiv i $div->name er avslått."); + } else { + if ($value == "accept") { + $ugr = new UserGroupRelationship($this->id, 2); + $ugr->store(); + $group_id = $div->getNoAdminGroup(); + if ($group_id != NULL) { + $ugr2 = new UserGroupRelationship($this->id, $group_id); + $ugr2->store(); + } + $this->_registerUpdate("Aktivforespørsel godkjent"); + notify("Forespørsel fra $this->firstname $this->lastname om å bli registrert som aktiv i $div->name er godkjent."); + } + } + } else { + error("user-div-req: " . $result->toString()); + notify("Behandling av forespørsel ble ikke utført."); + } + } + + public function _printGroups($sep) { + $sql = "SELECT g.id, g.name " . "FROM din_group g, din_usergrouprelationship ugr " . "WHERE ugr.user_id = $this->id " . "AND ugr.group_id = g.id " . "ORDER BY g.name ASC "; + $result = $this->conn->query($sql); + + if (DB :: isError($result) != true) { + if ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { + print ($row->name); + } + while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { + print ($sep . $row->name); + } + return true; + } else { + error("Vis gruppemedlemskap: " . $result->toString()); + notify("Informasjon om gruppemedlemskap utilgjengelig."); + } + } + + public function _deleteAddress($link = null) { + if ($this->addresstype == 'no') { + $sql = "DELETE FROM din_useraddressno WHERE user_id = $this->id"; + } else { + $sql = "DELETE FROM din_useraddressint WHERE user_id = $this->id"; + } + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + error("User delete address: " . $result->toString()); + return false; + } else { + $this->setAddressStatus(0); + $this->_sendWrongAddressMail($link); + $this->_registerUpdate('Adresse slettet.'); + return true; + } + } + + public function displayExpiryListSingle() { + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + $this->displayExpiryList(); + + print "
idkortnrfornavnetternavnutløpsårendre tiloblatendre til
\n"; + } + + public function writeExpiryListFile($expiry = NULL) { + print $this->id . ";"; + print $this->cardno . ";"; + print $this->firstname .";"; + print $this->lastname . ";"; + print strip_nl($this->street) . ";"; + print $this->zipcode . ";"; + print $this->postarea . ";"; + print $this->getAddressStatus() . ";"; + print $this->email . ";"; + print $this->phonenumber . ";"; + print $this->birthdate . ";"; + print $this->expires . ";"; + print $this->lastSticker . ";"; + print $this->getRegistered() . ";"; + print $this->getLastUpdate(); + print "\r\n"; + } + + public function displayExpiryList($expiry = NULL) { + //$card = $this->getMembershipCard(); + + print "\n"; + print " " . $this->id . "\n"; + + print " id . "_cardno\">"; + //if (!is_null($card)) print $card->getId(); + print $this->cardno; + print "\n"; + + print " id . "\" title=\"mer informasjon om " . $this->firstname . " " . $this->lastname . "\">" . $this->firstname . "\n"; + print " " . $this->lastname . "\n"; + + print " "; + if ($this->cardno == null) { + // User hasn't ordered a card + print "
id . "_cardno_form\" action=\"javascript: grantCardNumber('" . $this->id . "')\" " . "method=\"post\">"; + print "\n"; + print "\n"; + print "
"; + } elseif (!$this->getCardProduced()) { + // User's card has been produced, but has not been delivered yet + print "
id . "_cardproduced_form\" " . "action=\"javascript: setCardProduced('" . $this->id . "')\" " . "method=\"post\">"; + print "\n"; + print "\n"; + print "
"; + } elseif (!$this->getCardDelivered()) { + // User's card has been produced, but has not been delivered yet + print "
id . "_carddelivered_form\" " . "action=\"javascript: setCardDelivered('" . $this->id . "')\" " . "method=\"post\">"; + print "\n"; + print "\n"; + print "
"; + + } else { + // User has a membercard + //print "kort mistet?"; + } + print " \n"; + + print " id . "_expires\">"; + if ($this->expires == '0000-00-00') { + print "0"; + } else { + if ($this->expires == NULL) { + print "livsvarig"; + } else { + print (date("Y", strtotime($this->expires))); + } + } + print " \n"; + + print " "; + print "
"; + if ($this->cardno != NULL) { + print "
id . "')\" method=\"get\">"; + print "\n"; + print "\n"; + print "\n"; + print "
"; + } + print "
"; + print "\n"; + + print "id . "_laststicker\">"; + print $this->getLastSticker(); + print "\n"; + + print " "; + if ($this->cardno != NULL) { + print "
id . "')\" method=\"post\">"; + print "
"; + print ""; + print ""; + print ""; + print "
"; + print "
"; + } + print "\n"; + + print " " . $this->getRegistered() . "\n"; + print " " . $this->getLastUpdate(); "\n"; + print "\n"; + } + + public function _registerUpdate($message) { + $sql = "INSERT INTO din_userupdate VALUES (" . + "NULL, " . + "NOW( ), " . + $this->id . ", " . + $this->conn->quoteSmart($message) . ", " . + ((getCurrentUser() == 0) ? $this->id : getCurrentUser()) . + ")"; + $result = $this->conn->query($sql); + if (DB :: isError($result) == true) { + $this->conn->rollback(); + error("Database error (User::_registerUpdate()): " . $result->toString()); + return false; + } else { + $this->conn->commit(); + } + } + + public function displayUpdates() { + $sql = "SELECT d.*, CONCAT(d1.firstname, ' ', d1.lastname) AS updater " . "FROM din_userupdate d, din_user d1 " . "WHERE user_id_updated = $this->id " . "AND d.user_id_updated_by=d1.id ORDER BY date DESC"; + + $result = & $this->conn->query($sql); + if (DB :: isError($result) != true) { + print ""; + print ""; + + while ($row = & $result->fetchRow(DB_FETCHMODE_OBJECT)) { + print ""; + } + print "
Liste over endringer
" . formatDatetimeYearShort($row->date) . "$row->comment $row->updater
"; + } else { + error("Users: " . $result->toString()); + } + } + + public function resetPassword() { + $newPassword = generatePassword(); + $sql = "UPDATE din_user SET " . " password = PASSWORD('$newPassword'), " . " passwordReset = 1 " . "WHERE" . " id = $userid"; + $result = $conn->query($sql); + if (DB :: isError($result) == true) { + error("ResetPassword: " . $result->toString()); + notify("Tjenesten er midlertidig utilgjengelig, vennligst forsøk igjen senere."); + return false; + } else { + $this->_registerUpdate('Brukernavn og nytt passord sendt til bruker.'); + return true; + } + } + + public function _sendPassword() { + $sendto = $this->email; + $subject = "Brukernavn og passord for Studentersamfundet Inside"; + $message = "Hei, $this->firstname $this->lastname!\n " . "\n" . "\nHer er din innloggingsinformasjon til Studentersamfundets medlemsider. " . "\n" . "\nDitt brukernavn er: $row->username" . "\nDitt passord er: $newPassword" . "\n" . "\nNår du logger på vil du bli bedt om å endre passord til noe som er lettere å huske." . "\n" . "\nhttps://www.studentersamfundet.no/inside" . "\n" . "\nmvh" . "\n\nDet Norske Studentersamfund."; + $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; + if (mail($sendto, $subject, $message, $headers)) { + notify("Nytt brukernavn og passord er sendt til din registrerte epostadresse. Bruk skjemaet under for å logge deg inn."); + } else { + notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . + "webansvarlig."); + } + } + + // Send mail with notification of card delivery + public function sendCardOrderedNotifyMail() { + $sendto = $this->email; + + $subject = "Medlemskapet ditt er aktivert"; + $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . + "\n\n" . + "Vi har registrert at du har aktivert medlemskapet ditt i Det Norske Studentersamfund. " . + "Du vil motta en e-post når medlemskortet ditt er produsert og klart til å hentes i billettluka på studentersamfundet. \n" . + "\n" . + "For mer informasjon om hva som skjer på Det Norske Studentersamfund, gå inn på vår nettside: http://www.studentersamfundet.no/ .\n" . + "\n" . + "Er det noe du lurer på kan du bare svare på denne eposten, så svarer vi så fort vi klarer.\n". + "\n\n" . + "Bli aktiv i dag!\n" . + "www.studentersamfundet.no/bliaktiv\n" . + "\n\n" . + "Mvh\n\n" . + "Medlemskapsordningen\n" . + "medlemskap@studentersamfundet.no\n" . + "Det Norske Studentersamfund\n\n"; + + $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; + + if (!mail($sendto, $subject, $message, $headers)) { + notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); + } + } + + // Send mail with notification of card delivery + public function sendCardProducedNotifyMail() { + $sendto = $this->email; + + $subject = "Medlemskortet ditt er produsert"; + $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . + "\n\n" . + "Vi har nå produsert medlemskortet ditt i Det Norske Studentersamfund. " . + "Det ligger nå klart til avhenting i billettluka på Studentersamfundet og kan hentes der i billettlukas åpningstid. \n" . + "\n" . + "For mer informasjon om hva som skjer på Det Norske Studentersamfund, gå inn på vår nettside: http://www.studentersamfundet.no/ .\n" . + "\n" . + "Er det noe du lurer på kan du bare svare på denne eposten, så svarer vi så fort vi klarer.\n". + "\n\n" . + "Bli aktiv i dag!\n" . + "www.studentersamfundet.no/bliaktiv\n" . + "\n\n" . + "Mvh\n\n" . + "Medlemskapsordningen\n" . + "medlemskap@studentersamfundet.no\n" . + "Det Norske Studentersamfund\n\n"; + + $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; + + if (!mail($sendto, $subject, $message, $headers)) { + notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); + } + } + + // Send mail with notification of card delivery + public function sendRenewedMembershipRegisteredNotifyMail () { + $sendto = $this->email; + + $subject = "Medlemsskapet ditt i Det Norske Studentersamfund er registrert som fornyet"; + $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . + "\n\n" . + "Vi har registrert at du har fornyet medlemsskapet ditt i Det Norske Studentersamfund. " . + "Medlemsoblat som viser at du har medlemskap kan hetes i billettluka på Studentersamfundet i billettlukas åpningstid. Ta med medlemskortet ditt. \n" . + "Hvis du har mistet medlemskortet ditt kan du få ordnet nytt kort i billettluka også, eller bestille det fra nettbutikken.\n". + "\n" . + "For mer informasjon om hva som skjer på Det Norske Studentersamfund, gå inn på vår nettside: http://www.studentersamfundet.no/ .\n" . + "\n" . + "Er det noe du lurer på kan du bare svare på denne eposten, så svarer vi så fort vi klarer.\n". + "\n\n" . + "Bli aktiv i dag!\n" . + "www.studentersamfundet.no/bliaktiv\n" . + "\n\n" . + "Mvh\n\n" . + "Medlemskapsordningen\n" . + "medlemskap@studentersamfundet.no\n" . + "Det Norske Studentersamfund\n\n"; + + $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; + + if (!mail($sendto, $subject, $message, $headers)) { + notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); + } + } + + public function sendNewAddressMail ($newstreet, $newzipcode) { + $sendto = $this->email; + + $subject = "Du er registrert med feil postadresse"; + $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . + "\n\n" . + "Vi har sendt ut en postsending til deg, og fått beskjed fra posten " . + "om at du har flyttet fra \"" . + $this->street . ", " . $this->zipcode . " " . $this->postarea . + "\" til \"" . + $newstreet . ", " . $newzipcode . " " . $this->getPostarea($newzipcode) . + "\".\n" . + "Brevet er vidresendt til denne nye adressen. " . + "Hvis du ikke har mottatt dette brevet, eller ikke har flyttet kan " . + "du logge inn på våre medlemsider og oppdatere din adresse. " . + "Logg inn på denne siden: " . + "https://www.studentersamfundet.no/inside - ditt brukernavn er " . + "\"" . $this->username . "\".\n" . + "\n" . + "Hvis du ikke har mottat medlemskortet vil vi at du svarer på denne " . + "e-posten etter du har oppdatert din adresse og ber om å få tilsendt " . + "nytt medlemskort.\n" . + "\n\n\n" . + "Mvh\n\n" . + "Medlemskapsordningen\n" . + "medlemskap@studentersamfundet.no\n" . + "Det Norske Studentersamfund\n\n"; + + $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; + + if (mail($sendto, $subject, $message, $headers)) { + notify("Melding om ny adresse er sendt til $this->email"); + } else { + notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); + } + } + + public function _sendWrongAddressMail($link = null) { + $sendto = $this->email; + $linkMessage = ""; + if ($link) { + $linkMessage = "Brevet vi har forsøkt å sende kan du også " . + "lese på nett fra denne adressen:\n$link\n\n"; + } + $subject = "Postforsendelse er ikke kommet frem til addressen din"; + $message = "Hei, " . $this->firstname . " " . $this->lastname . "!" . + "\n\n" . + "Vi har sendt ut en postsending til deg, og fått beskjed fra Posten ". + "om at du var ukjent på din oppgitte adresse. \n" . + "Vi sendte brevet til følgende adresse: \"" . $this->street . ", " . + $this->zipcode . " " . $this->postarea . "\". " . + "På grunn av tilbakemeldingen om at du er ukjent på adressen ". + "er brevet så blitt makulert av Posten, på oppdrag av oss." . + "\n" . + $linkMessage . + "\n" . + "Hvis du ikke har mottat medlemskortet eller oblatet ditt er det " . + "mest sannsynlig det som var i denne postforsendelsen. Hvis du fortsatt " . + "bor på adressen over, eller har meldt flytting fra denne adressen må " . + "du klage til Posten, enten på telefon 810 00 710, eller gjennom skjemaet " . + "du finner på denne siden: http://www.posten.no/Kundeservice .\n" . + "Be om svar på epost og videresend denne til medlemskap@studentersamfundet.no " . + "så sender vi deg et nytt medlemskort kostnadsfritt. \n" . + "\n". + "Hvis du derimot har oppgitt feil adresse, eller har flyttet uten å " . + "melde flytting må du logge inn på våre medlemsider, oppdatere adressen " . + "din og bestille nytt kort i nettbutikken. Da vil du automatisk få tilsendt " . + "nytt kort. Vi må ta 35 kroner for å dekke våre kostnader. " . + "Våre medlemsider finner du på https://www.studentersamfundet.no/inside/ ." . + "Ditt brukernavn er \"" . $this->username . "\". \n". + "\n\n\n" . + "Mvh\n\n" . + "Medlemskapsordningen\n" . + "medlemskap@studentersamfundet.no\n" . + "Det Norske Studentersamfund\n\n"; + + $headers = 'From: Det Norske Studentersamfund ' . "\r\n"; + + if (mail($sendto, $subject, $message, $headers)) { + notify("Melding om ugyldig adresse er sendt til $this->email"); + } else { + notify("Det oppstod en feil under sending av epost. Vennligst kontakt" . "webansvarlig."); + } + } + + /* + * Print the status of the user's membership + * return: string + */ + public function membershipStatus() { + //print "'" . $this->expires . "','" . $this->hasCard . "'"; + if ($this->expires == "0000-00-00") + return "Du har ikke registrert medlemskap."; + elseif ($this->expires == "") + return "Du har livsvarig medlemskap."; + elseif (strtotime($this->expires) < strtotime("now")) + return "Du har ikke registrert gyldig medlemskap i år (medlemskapet ditt gikk ut " . date("d.m.Y", strtotime($this->expires)) . ")."; + elseif (strtotime($this->expires) > strtotime("now")) { + if ($this->getCardDelivered()) { + if ($this->lastSticker < date("Y", strtotime($this->expires))) { + return "Du har aktivert medlemskapet ditt, og du kan hente oblat til å klistre på medlemskortet ditt i bilettluka på Det Norske Studentersamfund."; + } else { + return "Du har gyldig medlemskap (gyldig til " . date("d. m. Y", strtotime($this->expires)) . ")."; + } + } elseif ($this->getCardProduced()) { + return "Medlemskapet ditt for " . date("Y", strtotime($this->expires)) . " er registrert, og medlemskortet ditt ligger klar til henting i billettluka på Det Norske Studentersamfund."; + } else { + return "Medlemskapet ditt er registrert, og medlemskortet ditt for " . date("Y", strtotime($this->expires)) . " produseres."; + } + } + + return "Ukjent medlemskapsstatus"; + } + + function setMembershipCard($membershipCard) { + if (!is_null($this->membershipCard)) { + return false; + } + + $membershipCard->setUserId($this->id); + $this->membershipCard = $membershipCard; + } + + function getMembershipCard() { + if (is_null($this->membershipCard)) { + $this->membershipCard = new MembershipCard(); + if (!$this->membershipCard->findByUserId($this->id)) { + $this->membershipCard = null; + } + } + return $this->membershipCard; + } +} ?> \ No newline at end of file diff --git a/inside/ajax.php b/inside/ajax.php index 2d2a973..85ddf96 100644 --- a/inside/ajax.php +++ b/inside/ajax.php @@ -7,10 +7,10 @@ print(''); $conn = db_connect(); -$action = mysql_real_escape_string($_REQUEST['action']); +$action = $_REQUEST['action']; if ($action == 'checkZip'){ - $zip = mysql_real_escape_string($_REQUEST['zip']); + $zip = $_REQUEST['zip']; if ($zip != "") { $sql = "SELECT poststed AS postarea FROM din_postnummer @@ -72,7 +72,7 @@ if ($action == 'checkZip'){ printRemoveCatXML($type); }else if ($action == 'checkUsername') { - $username = mysql_real_escape_string($_REQUEST['username']); + $username = $_REQUEST['username']; $conn = db_connect("forum"); $sql = sprintf("SELECT user_id FROM phpbb_users u "."WHERE username_clean = '%s' ", strtolower($username)); $result = & $conn->query($sql); @@ -114,4 +114,4 @@ function printRemoveCatXML($type){ +?> \ No newline at end of file diff --git a/inside/checkZip.php b/inside/checkZip.php index 0af01ee..85a0d99 100644 --- a/inside/checkZip.php +++ b/inside/checkZip.php @@ -7,7 +7,7 @@ header("Content-type: application/xml"); $conn = db_connect(); - $zip = mysql_real_escape_string($_REQUEST['zip']); + $zip = $_REQUEST['zip']; $sql = "SELECT poststed AS postarea FROM din_postnummer diff --git a/inside/credentials.php b/inside/credentials.php new file mode 100644 index 0000000..6c20c81 --- /dev/null +++ b/inside/credentials.php @@ -0,0 +1,39 @@ + $driver .":dbname=".$db_name.";host=".$host_name, + "username" => $user_name, + "password" => $password + ); + } + } elseif ($host == "forum") { + /*$host_name = "localhost"; + $driver = "mysql"; + $user_name = "forum2"; + $password = "e9bAlSu1oI"; + $db_name = "phpbb1";*/ + $host_name = "localhost"; + $driver = "mysql"; + $user_name = "glium337_phpbb"; + $password = "n0ffn0ff"; + $db_name = "glium337_phpbb"; + } + + return "$driver://$user_name:$password@$host_name/$db_name"; +} +?> \ No newline at end of file diff --git a/inside/domain/DomainObject.php b/inside/domain/DomainObject.php new file mode 100644 index 0000000..fa1fa27 --- /dev/null +++ b/inside/domain/DomainObject.php @@ -0,0 +1,64 @@ +markNew(); + } else { + $this->id = $id; + } + } + + // Unit of Work pattern - not implemented yet + function markNew() { + domain_ObjectWatcher::addNew($this); + } + + function markDeleted() { + domain_ObjectWatcher::addDelete($this); + } + + function markDirty() { + domain_ObjectWatcher::addDirty($this); + } + + function markClean() { + domain_ObjectWatcher::addClean($this); + } + + function setId($id) { + $this->id = $id; + } + + function getId() { + return $this->id; + } + + function collection() { + return self::getCollection(get_class($this)); + } + + static function getCollection($type) { + return domain_HelperFactory::getCollection($type); + } + + function finder() { + return self::getFinder(get_class($this)); + } + + static function getFinder($type) { + return domain_HelperFactory::getFinder($type); + } + +} + +?> \ No newline at end of file diff --git a/inside/domain/HelperFactory.php b/inside/domain/HelperFactory.php new file mode 100644 index 0000000..9694620 --- /dev/null +++ b/inside/domain/HelperFactory.php @@ -0,0 +1,51 @@ + \ No newline at end of file diff --git a/inside/domain/Membership.php b/inside/domain/Membership.php new file mode 100644 index 0000000..4901db0 --- /dev/null +++ b/inside/domain/Membership.php @@ -0,0 +1,68 @@ +user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setCard(domain_MembershipCard $card) { + $this->card = $card; + $this->markDirty(); + } + + function getCard() { + return $this->card; + } + + function setCreated(DateTime $created) { + $this->created = $created; + $this->markDirty(); + } + + function getCreated() { + return $this->created; + } + + function setStarts(DateTime $starts) { + $this->starts = $starts; + $this->markDirty(); + } + + function getStarts() { + return $this->starts; + } + + function setExpires($expires) { + $this->expires = $expires; + $this->markDirty(); + } + + function getExpires() { + return $this->expires; + } + +} + +?> \ No newline at end of file diff --git a/inside/domain/MembershipCard.php b/inside/domain/MembershipCard.php new file mode 100644 index 0000000..fa4a9c2 --- /dev/null +++ b/inside/domain/MembershipCard.php @@ -0,0 +1,75 @@ +user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setCreated(DateTime $created) { + $this->created = $created; + $this->markDirty(); + } + + function getCreated() { + return $this->created; + } + + function setProduced(DateTime $produced) { + $this->produced = $produced; + $this->markDirty(); + } + + function getProduced() { + return $this->produced; + } + + function setLastSticker($laststicker) { + $this->lastSticker = $laststicker; + $this->markDirty(); + } + + function getLastSticker() { + return $this->lastSticker; + } + + function getStickers() { +// if (is_null($this->stickers)) { +// $this->stickers = self::getFinder("domain_MembershipCardSticker")->findByCardId($this->getId()); +// } +// return $this->stickers; + return null; + } + + function getMemberships() { + if (is_null($this->memberships)) { + $this->memberships = self::getFinder("domain_Membership")->findByCardId($this->getId()); + } + return $this->memberships; + } + +} + +?> diff --git a/inside/domain/ObjectWatcher.php b/inside/domain/ObjectWatcher.php new file mode 100644 index 0000000..83b9c22 --- /dev/null +++ b/inside/domain/ObjectWatcher.php @@ -0,0 +1,112 @@ +getId(); + return $key; + } + + static function add(domain_DomainObject $obj) { + $inst = self::instance(); + $inst->all[$inst->globalKey($obj)] = $obj; + } + + static function exists($classname, $id) { + $inst = self::instance(); + $key = "$classname.$id"; + if (isset($inst->all[$key])) { + return $inst->all[$key]; + } + return null; + } + + static function addDirty(domain_DomainObject $obj) { + $inst = self::instance(); + // verify that the updated object is an object allready in the database + if (!in_array($obj, $inst->new, true)) { + $inst->dirty[$inst->globalKey($obj)] = $obj; + } + } + + static function addNew(domain_DomainObject $obj) { + $inst = self::instance(); + // we don't yet have an id + $inst->new[] = $obj; + } + + /* + * Mark object as clean, changes will not be stored to database + */ + static function addClean(domain_DomainObject $obj) { + $inst = self::instance(); + + unset($inst->dirty[$inst->globalKey($obj)]); + + // check if the object is in the new array, and remove it from it + if (in_array($obj, $inst->new, true)) { + $pruned=array(); + foreach ($inst->new as $newobj) { + if (!($newobj === $obj)) { + $pruned[] = $newobj; + } + } + $inst->new = $pruned; + } + } + + static function addDelete(domain_DomainObject $obj) { + $inst = self::instance(); + + unset($inst->dirty[$inst->globalKey($obj)]); + + if (in_array($obj, $inst->new, true)) { + $pruned=array(); + foreach ($inst->new as $newobj) { + if (!($newobj === $obj)) { + $pruned[] = $newobj; + } + } + $inst->new = $pruned; + } + + $inst->delete[] = $obj; + } + + function performOperations() { + foreach ($this->dirty as $key=>$obj) { + $obj->finder()->update($obj); + } + foreach ($this->new as $key=>$obj) { + $obj->finder()->insert($obj); + } + foreach ($this->delete as $key=>$obj) { + //$obj->finder()->delete($obj); + } + $this->dirty = array(); + $this->new = array(); + $this->delete = array(); + } +} + +?> \ No newline at end of file diff --git a/inside/domain/User.php b/inside/domain/User.php new file mode 100644 index 0000000..0044d30 --- /dev/null +++ b/inside/domain/User.php @@ -0,0 +1,150 @@ +username = $username_s; + $this->markDirty(); + } + + function getUsername() { + return $this->username; + } + + function setPassword($password_s) { + $this->password = $password_s; + $this->markDirty(); + } + + function getPassword() { + return $this->password; + } + + function setFirstname($firstname_s) { + $this->firstname = $firstname_s; + $this->markDirty(); + } + + function getFirstname() { + return $this->firstname; + } + + function setLastname($lastname_s) { + $this->lastname = $lastname_s; + $this->markDirty(); + } + + function getLastname() { + return $this->lastname; + } + + function setValidaddress($validaddress_i) { + $this->validaddress = $validaddress_i; + $this->markDirty(); + } + + function getValidaddress() { + return $this->validaddress; + } + + function setEmail($email_s) { + $this->email = $email_s; + $this->markDirty(); + } + + function getEmail() { + return $this->email; + } + + function setBirthdate($birthdate_d) { + $this->birthdate = $birthdate_d; + $this->markDirty(); + } + + function getBirthdate() { + return $this->birthdate; + } + + function setPlaceOfStudy($placeofstudy_i) { + $this->placeOfStudy = $placeofstudy_i; + $this->markDirty(); + } + + function getPlaceOfStudy() { + return $this->placeOfStudy; + } + + function setPasswordreset($passwordreset_i) { + $this->passwordreset = $passwordreset_i; + $this->markDirty(); + } + + function getPasswordreset() { + return $this->passwordreset; + } + + function setDivisionIdRequest($divisionidrequest_i) { + $this->divisionIdRequest = $divisionidrequest_i; + $this->markDirty(); + } + + function getDivisionIdRequest() { + return $this->divisionIdRequest; + } + + function getUpdates() { + if (is_null($this->updates)) { + $this->updates = self::getFinder("domain_UserUpdate")->findByUserId($this->getId()); + } + return $this->updates; + } + + function getAddress() { + if (is_null($this->address)) { + $this->address = self::getFinder("domain_UserAddress")->findByUserId($this->getId()); + } + return $this->address; + } + + function getMemberships() { + if (is_null($this->memberships)) { + $this->memberships = self::getFinder("domain_Membership")->findByUserId($this->getId()); + } + return $this->memberships; + } + + function getCards() { + if (is_null($this->cards)) { + $this->cards = self::getFinder("domain_MembershipCard")->findByUserId($this->getId()); + } + return $this->cards; + } +} + +?> \ No newline at end of file diff --git a/inside/domain/UserAddress.php b/inside/domain/UserAddress.php new file mode 100644 index 0000000..d85ce08 --- /dev/null +++ b/inside/domain/UserAddress.php @@ -0,0 +1,39 @@ +user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setAddress($address) { + $this->phone = $address; + $this->markDirty(); + } + + function getAddress() { + return $this->address; + } + +} + +?> \ No newline at end of file diff --git a/inside/domain/UserPhone.php b/inside/domain/UserPhone.php new file mode 100644 index 0000000..14b548d --- /dev/null +++ b/inside/domain/UserPhone.php @@ -0,0 +1,38 @@ +user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setPhone($phone) { + $this->phone = $phone; + $this->markDirty(); + } + + function getPhone() { + return $this->phone; + } + +} + +?> \ No newline at end of file diff --git a/inside/domain/UserUpdate.php b/inside/domain/UserUpdate.php new file mode 100644 index 0000000..9c98165 --- /dev/null +++ b/inside/domain/UserUpdate.php @@ -0,0 +1,58 @@ +date = $date_d; + $this->markDirty(); + } + + function getDate() { + return $this->date; + } + + function setMessage($message_s) { + $this->message = $message_s; + $this->markDirty(); + } + + function getMessage() { + return $this->message; + } + + function setUser($user) { + $this->user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setUpdatedBy($updatedBy) { + $this->updatedBy = $updatedBy; + $this->markDirty(); + } + + function getUpdatedBy() { + return $this->updatedBy; + } + +} + +?> \ No newline at end of file diff --git a/inside/images/products/20.jpg b/inside/images/products/20.jpg new file mode 100644 index 0000000000000000000000000000000000000000..31933f366478085069bad1af43b93de54cc90dbe GIT binary patch literal 10387 zcmbW7Wl$VI)1Vh!AZP-?9fA{F7YGpC-5r9vFBTv`*esC6A!u+}2!Ra}EWt@&aakn5 z;skfUyx(_qS9QPcuBT@HOxILBH9b8&-Sas2xB?(mS5{L7U|;|M82=jJ@c|&MsIMe% zsG~2%-vGB6e(Q%4% z@d^lvh=?$9NXkeEf%t_*g#NP#20lJM;S)kCA|fgwW;$k}|7UsZ29V)lFaZX!FjxSX zWEfav7>~UG#($7F82=@J|0x)lSlBqYKsqyS6|EG$fHEF2tc?0?!3|KDd8Ue948PVa0f?3JpIf^v93bgzf!e@Clw%Qc=^ezu@5H;uaAV6PJ*b zQhcqXtfH!>ZeVC+Y+`C=?%?S3#@WTy%|9S8C^#e(9Q!UVKH+^LBsDEPBQq;IC--wn zX<2ziWmWap#wNtK=9bpBpFO>O{R4wT!xNKJ(=)Sk^QhG|^!mo;*7nZs@yY4g`Niec z_04~{FaTKpjrDK*Z?OM^i|ij4CN?$}Ht;`O7?{ETIu;o=4znQcQ+Yk0o$oUip=dmE z1z2&z4}4Z({UZu{zj1=+Y$B`d$Nxe5FS7qTu$ccZvi}A4zqwEVLM)7bn}QEgz3(RMjS_4hWipm3fz?$g?4xJESVkNnywgmDx);q^CT6PF7nQ5i_ROGX0q76 z#%ULOj0p=W)NRBAm`<%1?Jz|hMqi1prPBZ_|9$W?3@-R8N- zX8}e!>NO;u8>H-*6vf_hpYrsff}VU%~L-(gXfj{x&OA?TK7mr_6p zA)|L06AmWViR^k|arI3e^Q$~&FF_{8rSm(knN<1_CqI9dWZK(b^Km+xc;gekh3WfV zBm3t?pQsW=GKF}me!maH*B&9T$NX?9n!r1 z-VDksbFn<9W-}7>n_1K2bsP{%2h`j69&rCnI%#GUHOO3#$dq^{j9+p8evUqgy!_by{=Q#}phqtDR@ce0Ivi`PbKq zG#C_aBn}LOkAz9YWftQ6rG#Ytalsnm_N$g8D%2b|yST|1X&35+mO1tB_sGa_R{L~r zy%e|a%UjSZO%jfdEi|v4`P!J3|IW4mK2wr(GLlj&CXg!vHK$qU-v&wQkMalXqw`yEa;+5ULncjKM3Y` z+t;$38j-F{55DgfiT9V{I5_w8qq|?|_>&D^nWIQ7Pr0fFy~22q=sJ52PmnOj>7Jxwa^_R{?#JEY{Zb6CwKY?V%F9a%@~`=&gYdb?9azg{@ zL$ZEZ2R*LV4x%01int0Sd({iIJ=HRFj#DB^(s08{8&A}VxpiTa!oIaXV)y4stW4Nc zOUrH&=WP6oW0x}|FeC$!ojZCI9R?UxVX(iscW?QoE10pUQ!PqpE^1YFygM`v7fgZBN%K=ao?gqkp9*x{8?$Ga?0p7x5?6kEOX&x zGmdEOnMse}#C~GT5>Cn$Em2YH7*MJgTeg0cW#et~;SnJ3Hl6>a-8d+_W%|4o?3HhF zV)M{pl}_pN`6Iq3<);^G5)=_8uH9!97C%{`Bs1~X76s`zNcyXc5HFDS7p#nL?+L>S zwES%Iz|)TaQmgx}Udl_!!O%Ib3pyi=nfA8S_D`}sPe`2A1y3lM=wJ}#1;p2G-&u)@ zm*&Z9Siavl$A*Lj2p~chG60Gv#;*F7U;Ko(8ruZ86>6EXy|Etw&xwV#o6<8*9M_cY zUHiFe55?L>NT0-+8P*#dUQJCd@D4K`s7sOUnUCze3B7W0-Df)AUwZCwK$JeAS@{Iy zB&n-RQYqt>rno63lGMV4Dxm^^btiuTpT5k-m9_g(IkKDev&4C9s!Rq}`cN~16m{Oz z5`JIgESt|+8}@66>S+%vh2pdGVep;)P%nG#5O$qTDw#{%hC(RM-Y?UrmofWx?oeuS2;T{2L< z`?BItS1M(+-qeLAv)%`0@v2*l7~K!7|5BP>{+F@kXJ6Af=gv*UW?9rjf+u@-b8jkd zgeubQu$>Wnh^Af0$p~0*vPxB9{mAy_wiStSB{~xl-1DuIZnFKok7HD>neQ*gqk8GC zEX^-d=aPqZR$6uRzlGUWOF*``)_ppPRuE7k1HE}&(_*2)!Wxy+&s#$iL58py=XdRW zN1cWAy~PK`aj#1xxxsIvFnNMPPScVRZNVyX2Gk}V8D#(*x4cBe?s+92WxePtv!n>_ zfD}=3D_`R=KZ!$CXTdjOw3q0ujx#D`NeCJ%(}3l1*K*aBHJ^Q#3Y=fViM z!_u&4U-H%R5fb}-%v^M!&yv}OOQOc9^n2ugh}HRvmN>IMaW)+{SCC&mgksDQCrH-r z7N7#+ja==`KGLPzzmm%cL z?xl!nem>bM;2CjfjoG9&3up>8U6c$ z2feM#xMl(mNx8IyX8&d$2yS*+Mz|$j1+v$rgg1<)jj&J}EyUP#$;E*&-)VZ=;;$2) z8rv(Z2(Z#OOcb(Ta%nXD3{hUg2YJCzD76aS=im9UPcmKO$H)aZVyH-EYNj9u?;?#h zg?2J$8OgkhyC$D+TD+gp5DUdq!4x1M#TZ2HS;wv>@q4oNWVVGLcB-1>1pxB)@1zWW z?2fIs!4?M))k{V9b7kM5q#--{<}VK(0W?#oN|ti!-)ZuaxxYdMYK{q`Rh`AX$)1yT zlKc`$cmyztZpps9lCQc-u=+lI_MwGpQK(UoYoQ5U5QSllup{0xE0KA=riZ-k{TGoL z5qS&Pb?>MjT$&4Y6UL3M;Fp}OG>Q`^b$-)6rkMX(NSs_5ouOx#hNR!!V7yrM`U! zEBZrbJifU^9Y4*oKxm-WVg$y&IPCc`TPN+fzDPXkq?<&hfGY}Iz2w(f(sku;t!Ev( z62YT+EO5)dKi`~-b6Z_RO&WOJnZdtjk9Ka|)B3z)%?er2g*`cdis;u+NbAVdd_+8R zZ99X1b~EU4)KE6|Z5ITlV%$q_)-PQl^pev)t9j#;>V*ng4*m&=9*^kQE&t$6QR^wt z0#R<32o2uv1`!ex-)(_r#aOD%m39MlOP9aSHP?+)$}|py`f!j+H5qu~^YVrcvcmpM z84tuhFteQ|Nn68MS|0(%%{GDTGRZ*M#=|>=O>-(H)p|{US9yH90TERjvuW&tJX0{W>Sm{g`lc}>)~gNf0K32>KTnp7OgJg^aq}#`i^0oGewH_BnIcI-e`X2&c`>( zGS+pk9pJ&?aHg+HTlCafI%kzUtJ>damY1Rx`0<(G5#TDx#i9QzM(|9s91-{PC%^g3 zidiw%sLOk0hcPc!>WkV`lZMh`3RbOQ3$mVP@Gq{&gT;O3$Rm1Jj!AefMe6k8U|~dd zl>A6wC;bF(pv|I&U-w7Vq%1ix3Bbird2@{SXEjYcaZEF#P2CkR&Yn)b^#F_w^<83{ z{RBf}yL4_hyuxVI;+r&CF2a*CJ??#vI2+jL`_5)tKF-t=;K$xlI5tub(fONIn3IAEYmN`#CfQ&PtCCfA=1 z@}c0J!$ra0ViCt!XfF5fx3;Gvz^`=+4bS5?75@Vk28Y^&xQN6^^?SBYk ztDnZ+@eK2z9)S5M>)P0AB=z0YBOp#1BW(3D9^RB6xjSHP=)Tl~FvB&P1fd&PCpt)s zjyiLyTu&@&pFH_;%?9=4UTQN4)FN20`bwsio-gZCu9%RNpg`hQQ??fzM44D}^){|e zj;~`=AWQb`ja)PMR|X$-moT`bw;s+q!7(LrujFX)Dah!x(Y0xT-~JBNmbmnM?JIGH z-|QzZBiPLsyQJ8~pbN&~j?;c?+~#8utw7*`C>tYNY|_==2>0JijCtS1ctOrp>nKZ zW$?R!-6_s7TAEKbb@1cc`#HI%UZrsG4H)c1o6*$O9=mI>7dW=q^ z86sKw=CqN1Cg~n8gINhQ!}&D+_r_EoW0iImvM}F+$|wc7GR@Th_JZpBPh&v18Os7`6ghpg~-6nr) zLZ2H&S`-W{HyXRnGe^%nqYKshCO}Ic>9E{lwczJG?kDdz@nPG7cTyQPxTz$MFv|Xd zCDS-&wDfcW_3-2aD~rWfYWgx*;xf28`V6^YCMe9-XL*4HMT&}8lzbB)YB?28R1Plm z)|vP^w^O5Sw8N=nR#Da9TB}jaKHZV$`yoYK&`NpzFPf-%SJ;p(=MdvovotzY7NNR0 z;2MUPD-zoZi`!RxLK(f3Exk74wIp!_7}Zk6XlH-_&B zouOwpQ~B&B>*t>fOb&gOgvF9EAzVb@t!@a<`~z0%*q-Yw5&k1!tfn6)jIvvt(R-HV z9P(md{L`IlkxYX@5pqMTYtmEHowBj>J;*~aZ8`!^cG}L+Ihk9@U}uELvT4){X~;m= z@-Q&76_`Yhs4Er@Z!Drl4Kzj%$oTH%qU-Fk20D2P4%N)ap0dSDW&*A2S^wgCmZ#a|q67^fehI$^&{@`J)_D>?qClcuqGW()I zfZewIft(bSa4nHTN59e}UWm_pB$C1LC1W9j;c5bR1d$qJ_P3+q@rJ}JqK|%|XFFq4 zk@gGM(5)v%FC7=R332EOVN>_3xd_^wvEe{-#Orb+fR_iB0_JX-#eQc+2&h z6TI#-(I7R#+6iH=;PpI=*)d`q6>nEhdT5o9`l%!#lnsM?E3Z!Su8-s`;A~&-#Wxit zJguRr+-Vr8+KxJSGwWj*0g>7S)81IFCDe}#SIVG;XHBx*}b5=7iN6`%OVBJ?v4uUij2cs9*4#9M3PW#B&8 zO7T``jc&+^%C9&DTiho58LWA6wi=tC*gpmQ&efRGO=%;Y5{H&&v!52LKFZIHoi>Zw z^n?$qSHSA(?CPKA|9kWZaH3{TRXy%V=X~=jY%7Rc?!EbMn)wEpN4>|^+YG^_zJ?r& zk18CjvDPJPDNoEoAQPNr5YSJ7w@^Z`?<5f01Qzm3e#S!-7Fsvx)%#^_c~hL3+197k zW)lc^mSGu3aG9%X1o(%HlGyXuC_f-GZz!fbmqQW>###4y!$`wmJ7#-{MbEhRC2*DW z@$|!v=cXJPN?`le!5vz2H_ZeRyK3imNj9V^WqdnUf*fQeX*qMx3N?uV6saX;^sPv= zTB`*oW2&^jTB~6YcLt3qr+8TN)eS}6b1q-<)l5k%MTy;KAlTtscU``W=(d<2EV=lq zWJs3O-OgAU5{I+3>H$~6Dh^bclTT5vu|UuEVvKD2B-1;KpAE(AhQWL0>gqEpVhrz= ztlb(O>Z5YF>`Ba%lKoNX0V3l=gF9vgCAL7sOYJT=AJyTtF0-TzP^9W1q?F^dfubBZIdIu zzkgbo&G3%It>HNc;Xeh1ScV2&60Z^$dPl!F$1WNA7#G6kfc;SdJyY8LE%WEDhHFCy z-i8h~DIV)w3<+AhqNlh3mn_az3AO$Hw7_3gSz2#454|G~I=-0!R=*JF2t6w{yfKJo zb38Apf02!Gs0NKXuj&qO68L%VLdIx38l`Tua+)hYnartOAyY}Z7?q|ZaXuY|fkBMAZMky(9gyID9PCAZLb|O&Fc)pn=V;;4+i?vwXzm3PiB(l`PCou)tw8E* zL_oIt$O^dtA}L;U&TM$kSZUQY(HtVVCHmuzzVp_(#{zrQd`8U{bR(v+{qy@5Kh-_` zU+<3xqGs|W$-8}#aES*|r+SiH(rleE zdF3}OBfr(+@>xNwUQPfAa+qnqWeY?2bBVjSB){4PZ^e4EH#f99T4elb6%daB4Bl1a z{tJ1%PG0~sj&m(%6K0EPlna#HdpDChZkNA zL`G@OdNP7Da#oEh@0(@LB^p<2C}R#{B{@LgK4vfjG$jiJXYi7g7hkjzn6I7egaX}qx{sqoXDyo`Q=W{&_g zT;FGi2N%bbj#L@%2BOW!kOX?|Rv#dk@(3{EX8crK?mTv^qnOJ1rfOHUhb{1P{ED8w zbU`pgdOX+CzN7K9`w-%T78#$&lf0S4TJCbbUAhrN*y;#cvirD zJ=uK}r1vIMmP@>x`KxMA=6pdcwsTSaYi%9%(-i1Ms(8Gow?nXjrw>+~2d*);|K2DM z&G=??C#`v6u;jB!N{w_O(k!jF-4VUia#gG+a5#6w^0W8c!Ya-Ik+!PTPUzs-!qFBB zJ}*hWyL|bWg#qdlO+CVR*{(8gl)J1>>{gt;5@aPFi)xg%{-9Wkzt|cJn;Z5NxD?Grb*HI zL}naTW0&LSYmp8ECrl>ntH@`&V6n`x_vlmNKYZCF>BPOk)wu;_mAj*!}X zs{IRqWxl`AUN;Q+yhLX5t`4=+Z^A|#)qNcG1(JRY(Z%je?#;AXDR~u5Evg>UmJ@t! z#ZDW#cN^)fXDDJ9?^k`9{+2;FZp8PSFmE}ZBqD*1e0hJMySB5@vWvTasqLE$gA{qYkc~F5FK$>XOvt-8+#CyK?i^a^w6T zNW0uj7q_l#HsnS-o7Nfp2N2=f$qqids!q(&mlPLo@2tTL8W4p)+OZg=D#nzF}3 z=yHh!BIPoq%8SXJKb#}6?uCvHF(UFXq$g+etH2Y5t`#elE3!^yrS?0-M zbvjfARuoCo>1{^ughFAjhARgE5kXsjf zEDUD*>^AiEHu!e+LQSB_0>$!{$w4rq>BtPW*~w+z7ZIPX(cNMQx+ph#*j=bMwn2w0~dY=moxk zsf`7f+H333-RS$cvcem{23ZI9ZlJV&?pHn~6%6Tu%nDgfO4Pisu$CdSM;TS^$B|jj zg|JtVp8DK&`Ij0Z6(7xGOd*vT? zahL#RYaOz%Bim|w+BIe}Y`O)F;Mp#WkxD>?KjAC(&Yjqw#Xd8}NZ8B81^W!qbII@P z#UtH(yZ~!3mq_1#_hDnM{JiFRQ=bN0i_si;N}N97_`{7HM$BOtWp0dabLTNIUM zU2$xqk8kHtUbSgPI4YABeN#BmUdte}H`=Ry(r_-RBx?>@8gwd$%gT=k(D^QZk>O~S z5~o_(EJIg-YpG(-suZ2Hl}Tn`t_jK_bQ3SFbvl5kw=GFS<<13XXk@s7@Jx30grBQ4 zx)2UL)IZ+Sj3(AG4~ohV?i9S9%#QBEl$MJZ`;6|3w-@5uU+R4Kv1PkK7|Uf_bq^K=0^GabPzd

IW?vj0 zzF}vR1bRgMonCj|v+DXOeb^AL)SxwIk)Dcmn86lVqzjw`tOVY>-nNXqBAFrx0f8s@ zo^Iv+OYB>BJyb)*8DftrMV}zPPV(0+lnM$zD3om{v3zo6?Y;A_`j?pu`FW${QOfoz z;TvV_&E^-QmW2YP*OtFnrNyig?R8p5K;rtqRcpii1!vTF0voxBJl&gOFYc&tLylN| zmpb699;8>RlQlpJF(5TdB1=^*I! z29M(O>%^sP$~eoC2v(FjgDhN*-M z&;%6$_#9p62BnKMT<_j{#k^H7GC9;Ac3zZ=aidE~mZYphj_%h|UM!r*;Y%LGOl$7o zuz?f0Q1k&~Q87L_7p0b-a-;cAbIOyM@4Uz(Imm~+25*3`6aL08RT8=>tRjiV$a2ihh zCSRaaFza0!u2Bbt46^6HL;smmoO7Cm^)nsuK64+L(m&UjZlCMMGhEH{3Ss+0OuMS+ TWk{S2AcC{re4tperformAction(); $p = new Page(); $p->display(); -?> \ No newline at end of file +?> diff --git a/inside/mapper/Collection.php b/inside/mapper/Collection.php new file mode 100644 index 0000000..6d5b067 --- /dev/null +++ b/inside/mapper/Collection.php @@ -0,0 +1,85 @@ +rewind(); + $this->raw = $raw; + $this->total = count($raw); + } + $this->mapper = $mapper; + } + + /** + * Add an object to the collection + **/ + function add(domain_DomainObject $object) { + $class = $this->targetClass(); + if (!($object instanceof $class)) { + throw new Exception("This is a {$class} collection"); + } + $this->notifyAccess(); + $this->objects[$this->total] = $object; + $this->total++; + } + + abstract function targetClass(); + + protected function notifyAccess() { + // something is coming here.. + } + + private function getRow($num) { + $this->notifyAccess(); + if ($num >= $this->total || $num < 0) { + return null; + } + if (isset($this->objects[$num])) { + return $this->objects[$num]; + } + if (isset($this->raw[$num])) { + // object has not been created yet + $this->objects[$num]=$this->mapper->createObject($this->raw[$num]); + return $this->objects[$num]; + } + } + + public function rewind() { + $this->pointer = 0; + } + + public function current() { + return $this->getRow($this->pointer); + } + + public function key() { + return $this->pointer; + } + + public function next() { + $row = $this->getRow($this->pointer); + if ($row) { + $this->pointer++; + } + return $row; + } + + public function valid() { + return (!is_null($this->current())); + } +} +?> \ No newline at end of file diff --git a/inside/mapper/Mapper.php b/inside/mapper/Mapper.php new file mode 100644 index 0000000..1438d61 --- /dev/null +++ b/inside/mapper/Mapper.php @@ -0,0 +1,94 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } catch (Exception $e) { + throw new Exception("Database connection error: ". getDSN()); + } + } + } + + function find($id) { + // check if object allready has been fetch from database + $old = $this->getFromMap($id); + if ($old) { + return $old; + } + + // get object from database + $this->selectStmt()->execute(array($id)); + $array = $this->selectStmt()->fetch(); + $this->selectStmt()->closeCursor(); + if (!is_array($array)) { + return null; + } + if (!isset($array['id'])) { + return null; + } + $object = $this->createObject($array); + return $object; + } + + function findAll() { + $this->selectAllStmt()->execute(array()); + return $this->getCollection( $this->selectAllStmt()->fetchAll( PDO::FETCH_ASSOC ) ); + } + + function createObject($array) { + $old = $this->getFromMap($array['id']); + if ($old) { return $old; } + + // construct object + $obj = $this->doCreateObject($array); + + // add object to object watcher map + $this->addToMap($obj); + $obj->markClean(); + return $obj; + } + + function insert(domain_DomainObject $obj) { + $this->doInsert($obj); + $this->addToMap($obj); + } + + function delete(domain_DomainObject $obj) { + $this->doDelete($obj); + //$this->removeFromMap($obj); + } + + private function getFromMap($id) { + return domain_ObjectWatcher::exists($this->targetClass(), $id); + } + + private function addToMap(domain_DomainObject $obj) { + return domain_ObjectWatcher::add($obj); + } + + abstract function update(domain_DomainObject $object); + protected abstract function doCreateObject(array $array); + protected abstract function doInsert(domain_DomainObject $object); + protected abstract function doDelete(domain_DomainObject $object); + protected abstract function targetClass(); + protected abstract function selectStmt(); + protected abstract function selectAllStmt(); + protected abstract function deleteStmt(); + abstract function getCollection(array $raw); +} +?> \ No newline at end of file diff --git a/inside/mapper/MembershipCardCollection.php b/inside/mapper/MembershipCardCollection.php new file mode 100644 index 0000000..1002074 --- /dev/null +++ b/inside/mapper/MembershipCardCollection.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/inside/mapper/MembershipCardMapper.php b/inside/mapper/MembershipCardMapper.php new file mode 100644 index 0000000..12d33cf --- /dev/null +++ b/inside/mapper/MembershipCardMapper.php @@ -0,0 +1,86 @@ +selectStmt = self::$PDO->prepare( + "SELECT c.id as id, u.id as userId, u.hasCard, u.lastSticker, c.date as created FROM din_usedcardno c LEFT JOIN din_user u ON c.id = u.cardno WHERE c.id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT u.id as userId, u.cardno as id, u.hasCard, u.lastSticker, c.date as created FROM din_user u LEFT JOIN din_usedcardno c ON u.cardno = c.id"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT c.id as id, u.id as userId, u.hasCard, u.lastSticker, c.date as created FROM din_usedcardno c LEFT JOIN din_user u ON c.id = u.cardno WHERE u.id=?"); +// $this->updateStmt = self::$PDO->prepare( +// "UPDATE din_user SET +// cardno=?, +// expires=?, +// WHERE id=?"); +// $this->insertStmt = self::$PDO->prepare( +// "INSERT INTO din_user ( +// expires +// ) values (?)"); +// $this->deleteStmt = self::$PDO->prepare( +// "DELETE FROM din_user WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new domain_MembershipCard($array["id"]); + + $user_mapper = new mapper_UserMapper(); + $obj->setUser($user_mapper->find($array["userId"])); + + $obj->setCreated(new DateTime($array["created"])); + if ($array["hasCard"]) $obj->setProduced(new DateTime()); // set produced date to now if card has been produced + $obj->setLastSticker($array["lastSticker"]); + return $obj; + } + + protected function doInsert(domain_DomainObject $object) { + } + + function update(domain_DomainObject $object) { + } + + protected function doDelete(domain_DomainObject $object) { + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + //return $this->deleteStmt; + } + + function findByUserId($userid) { + $this->findByUserIdStmt->execute(array($userid)); + return new mapper_MembershipCardCollection($this->findByUserIdStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new mapper_MembershipCardCollection($raw, $this); + } + + protected function targetClass() { + return "domain_MembershipCard"; + } +} + +?> \ No newline at end of file diff --git a/inside/mapper/MembershipCollection.php b/inside/mapper/MembershipCollection.php new file mode 100644 index 0000000..a3353e8 --- /dev/null +++ b/inside/mapper/MembershipCollection.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/inside/mapper/MembershipMapper.php b/inside/mapper/MembershipMapper.php new file mode 100644 index 0000000..a982dc2 --- /dev/null +++ b/inside/mapper/MembershipMapper.php @@ -0,0 +1,105 @@ +selectStmt = self::$PDO->prepare( + "SELECT u.id as userId, u.cardno, u.expires FROM din_user u WHERE u.id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT u.id as userId, u.cardno, u.expires FROM din_user u"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_user SET + cardno=?, + expires=?, + WHERE id=?"); +// $this->insertStmt = self::$PDO->prepare( +// "UPDATE din_user ( +// cardno, username, password, firstname, lastname, addresstype, valid_address, email, birthdate, placeOfStudy, passwordReset, division_id_request +// ) values (?)"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_user WHERE id=?"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT u.id as userId, u.cardno, u.expires FROM din_user u WHERE u.id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new domain_Membership($array["userId"]); + + $user_mapper = new mapper_UserMapper(); + $obj->setUser($user_mapper->find($array["userId"])); + + $card_mapper = new mapper_MembershipCardMapper(); + $obj->setCard($card_mapper->find($array["cardno"])); + + $obj->setCreated(new DateTime("-9999-12-31")); + $obj->setStarts(new DateTime("-9999-12-31")); + $obj->setExpires(new DateTime($array["expires"])); + return $obj; + } + + protected function doInsert(domain_DomainObject $object) { +// $values = array($object->getUsername()); +// //$this->insertStmt->execute($values); +// $id = self::$PDO->lastInsertId(); +// $object->setId($id); + } + + function update(domain_DomainObject $object) { + $values = array( + $object->getCard()->getId(), + $object->getExpires(), + $object->getId() + ); + print_r($values); + //$this->updateStmt->execute($values); + } + + protected function doDelete(domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + //return $this->deleteStmt; + } + + function findByUserId($userid) { + $this->findByUserIdStmt->execute(array($userid)); + return new mapper_MembershipCollection($this->findByUserIdStmt->fetchAll(), $this); + } + + function findByCardId($userid) { + //$this->findByCardIdStmt->execute(array($userid)); + //return new mapper_UserUpdateCollection($this->findByUserIdStmt->fetchAll(), $this); + $this->selectStmt->execute(array($userid)); + return new mapper_MembershipCollection($this->selectStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new mapper_MembershipCollection($raw, $this); + } + + protected function targetClass() { + return "domain_Membership"; + } +} + +?> \ No newline at end of file diff --git a/inside/mapper/UserAddressCollection.php b/inside/mapper/UserAddressCollection.php new file mode 100644 index 0000000..7a0296a --- /dev/null +++ b/inside/mapper/UserAddressCollection.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/inside/mapper/UserAddressMapper.php b/inside/mapper/UserAddressMapper.php new file mode 100644 index 0000000..ca04010 --- /dev/null +++ b/inside/mapper/UserAddressMapper.php @@ -0,0 +1,93 @@ +selectStmt = self::$PDO->prepare( + "SELECT user_id, street, zipcode FROM din_useraddressno WHERE user_id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT user_id, street, zipcode FROM din_useraddressno"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_useraddressno SET + street=?, + zipcode=?, + WHERE user_id=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_useraddressno ( + user_id, street, zipcode + ) values (?, ?, ?)"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_useraddressno WHERE user_id=?"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT user_id, street, zipcode FROM din_useraddressno WHERE user_id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new domain_Membership($array["user_id"]); + + $user_mapper = new mapper_UserMapper(); + $obj->setUser($user_mapper->find($array["user_id"])); + + $obj->setStreet($array["street"]); + $obj->setZipCode($array["zipcode"]); + return $obj; + } + + protected function doInsert(domain_DomainObject $object) { + $values = array($object->getUser()->getId(), $object->getStreet(), $object->getZipCode()); + $this->insertStmt->execute($values); + $id = self::$PDO->lastInsertId(); + $object->setId($id); + } + + function update(domain_DomainObject $object) { + $values = array( + $object->getStreet(), + $object->getZipCode(), + $object->getId() + ); + $this->updateStmt->execute($values); + } + + protected function doDelete(domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function findByUserId($userid) { + $this->findByUserIdStmt->execute(array($userid)); + return new mapper_UserAddressCollection($this->findByUserIdStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new mapper_UserAddressCollection($raw, $this); + } + + protected function targetClass() { + return "domain_UserAddress"; + } +} + +?> \ No newline at end of file diff --git a/inside/mapper/UserCollection.php b/inside/mapper/UserCollection.php new file mode 100644 index 0000000..f86a276 --- /dev/null +++ b/inside/mapper/UserCollection.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/inside/mapper/UserMapper.php b/inside/mapper/UserMapper.php new file mode 100644 index 0000000..f08d7cc --- /dev/null +++ b/inside/mapper/UserMapper.php @@ -0,0 +1,108 @@ +selectStmt = self::$PDO->prepare( + "SELECT * FROM din_user WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM din_user"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_user SET + username=?, + password=?, + firstname=?, + lastname=?, + addresstype='no', + valid_address=?, + email=?, + birthdate=?, + placeOfStudy=?, + passwordReset=?, + division_id_request=? + WHERE id=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_user ( + username + ) values (?)"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_user WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new domain_User($array["id"]); + $obj->setUsername($array["username"]); + $obj->setPassword($array["password"]); + $obj->setFirstname($array["firstname"]); + $obj->setLastname($array["lastname"]); + $obj->setValidaddress($array["valid_address"]); + $obj->setEmail($array["email"]); + $obj->setBirthdate($array["birthdate"]); + $obj->setPlaceOfStudy($array["placeOfStudy"]); + $obj->setPasswordreset($array["passwordReset"]); + $obj->setDivisionIdRequest($array["division_id_request"]); + return $obj; + } + + protected function doInsert(domain_DomainObject $object) { + $values = array($object->getUsername()); + //$this->insertStmt->execute($values); + $id = self::$PDO->lastInsertId(); + $object->setId($id); + } + + function update(domain_DomainObject $object) { + $values = array( + $object->getUsername(), + $object->getPassword(), + $object->getFirstname(), + $object->getLastname(), + $object->getValidAddress(), + $object->getEmail(), + $object->getBirthdate(), + $object->getPlaceOfStudy(), + $object->getPasswordreset(), + $object->getDivisionIdRequest(), + $object->getId() + ); + print_r($values); + //$this->updateStmt->execute($values); + } + + protected function doDelete(domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function getCollection(array $raw) { + return new mapper_UserCollection($raw, $this); + } + + protected function targetClass() { + return "domain_User"; + } +} + +?> \ No newline at end of file diff --git a/inside/mapper/UserUpdateCollection.php b/inside/mapper/UserUpdateCollection.php new file mode 100644 index 0000000..97f3234 --- /dev/null +++ b/inside/mapper/UserUpdateCollection.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/inside/mapper/UserUpdateMapper.php b/inside/mapper/UserUpdateMapper.php new file mode 100644 index 0000000..5b35c93 --- /dev/null +++ b/inside/mapper/UserUpdateMapper.php @@ -0,0 +1,96 @@ +selectStmt = self::$PDO->prepare( + "SELECT * FROM din_userupdate WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM din_userupdate"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT * FROM din_userupdate WHERE user_id_updated=?"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_userupdate SET + date=?, + user_id_updated=?, + comment=?, + user_id_updated_by=? + WHERE id=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_userupdate ( + date, user_id_updated, comment, user_id_updated_by + ) values (?,?,?,?)"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_userupdate WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new domain_UserUpdate($array["id"]); + $obj->setDate($array["date"]); + $obj->setUser($array["user_id_updated"]); + $obj->setMessage($array["comment"]); + $obj->setUpdatedBy($array["user_id_updated_By"]); + return $obj; + } + + protected function doInsert(domain_DomainObject $object) { + $values = array($object->getUsername()); + //$this->insertStmt->execute($values); + $id = self::$PDO->lastInsertId(); + $object->setId($id); + } + + function update(domain_DomainObject $object) { + $values = array( + $object->getDate(), + $object->getUser(), + $object->getMessage(), + $object->getUpdatedBy(), + $object->getId() + ); + print_r($values); + $this->updateStmt->execute($values); + } + + protected function doDelete(domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt(); + } + + function findByUserId($userid) { + $this->findByUserIdStmt->execute(array($userid)); + return new mapper_UserUpdateCollection($this->findByUserIdStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new mapper_UserCollection($raw, $this); + } + + protected function targetClass() { + return "domain_UserUpdate"; + } +} + +?> \ No newline at end of file diff --git a/inside/membershipcard.php b/inside/membershipcard.php new file mode 100644 index 0000000..3e00c02 --- /dev/null +++ b/inside/membershipcard.php @@ -0,0 +1,58 @@ +toString()); + exit (); +} + +$i = 0; +$u = 0; + +$sql = "SELECT u.id, u.cardno, u.hasCard, uc.date, u.expires FROM din_user u LEFT JOIN din_usedcardno uc ON u.cardno = uc.id ORDER BY u.cardno"; +$result = & $conn->query($sql); +if (DB :: isError($result) != true) { + while($row = & $result->fetchRow(DB_FETCHMODE_ASSOC)) { + if ($row["cardno"] > 0) { + $ins_stmt = "INSERT INTO din_membershipcard (id, userId, ordered, produced, delivered, active) VALUES ("; + $ins_stmt .= $row["cardno"] . ", "; + $ins_stmt .= $row["id"] . ", "; + if ($row["date"]) { + $ins_stmt .= "\"" . $row["date"] . "\", "; + } else { + $ins_stmt .= "\"2005-12-28 16:28:31\", "; + } + + if ($row["hasCard"] == 1) { + if ($row["date"]) { + $ins_stmt .= "\"" . $row["date"] . "\", "; + } else { + $ins_stmt .= "\"2005-12-28 16:28:31\", "; + } + } else { + $ins_stmt .= "NULL, "; + } + + if ($row["hasCard"] == 1) { + if ($row["date"]) { + $ins_stmt .= "\"" . $row["date"] . "\", "; + } else { + $ins_stmt .= "\"2005-12-28 16:28:31\", "; + } + } else { + $ins_stmt .= "NULL, "; + } + $ins_stmt .= $row["hasCard"]; + $ins_stmt .= ")"; + + //print $ins_stmt . "\n"; + //$conn->query($ins_stmt); + $i++; + } + } +} + +print "\n\nInsert $i rows\nUpdated $u rows"; \ No newline at end of file diff --git a/inside/membershipcard_db.php b/inside/membershipcard_db.php new file mode 100644 index 0000000..e56adc7 --- /dev/null +++ b/inside/membershipcard_db.php @@ -0,0 +1,101 @@ +toString()); + exit (); +} + +$i = 0; +$u = 0; + +$user = new User(735); + +$card = $user->getMembershipCard(); + +//print_r($card); + +if (is_null($card)) { + print "User is missing card!\n\n"; + print "Creating card ..\n"; + $newcard = new MembershipCard(); + $newcard->setOrdered(new DateTime()); + $user->setMembershipCard($newcard); + $card = $user->getMembershipCard(); + $card->store(); +} + +print "User " . $user->getName() . " has the following card: \n"; +print "Card id " . $card->getId() . "\n"; +if (!is_null($card->getOrdered())) { + print "Ordered " . $card->getOrdered()->format(DateTime::RFC1123) . "\n"; +} +if (!is_null($card->getProduced())) { + print "Produced " . $card->getProduced()->format(DateTime::RFC1123) . "\n"; +} +if (!is_null($card->getDelivered())) { + print "Delivered " . $card->getDelivered()->format(DateTime::RFC1123) . "\n"; +} +print "Active " . $card->getActive() . "\n"; + +$produced = new DateTime(); +$produced->modify("+1 month"); +$card->setProduced($produced); + +print "New time: " . $card->getProduced()->format('U') . "\n"; + +$card->setActive(false); + +$card->store(); + +print_r($card); + +return true; + +$sql = "SELECT u.id, u.cardno, u.hasCard, uc.date, u.expires FROM din_user u LEFT JOIN din_usedcardno uc ON u.cardno = uc.id ORDER BY u.cardno"; +$result = & $conn->query($sql); +if (DB :: isError($result) != true) { + while($row = & $result->fetchRow(DB_FETCHMODE_ASSOC)) { + if ($row["cardno"] > 0) { + $ins_stmt = "INSERT INTO din_membershipcard (id, userId, ordered, produced, delivered, active) VALUES ("; + $ins_stmt .= $row["cardno"] . ", "; + $ins_stmt .= $row["id"] . ", "; + if ($row["date"]) { + $ins_stmt .= "\"" . $row["date"] . "\", "; + } else { + $ins_stmt .= "\"2005-12-28 16:28:31\", "; + } + + if ($row["hasCard"] == 1) { + if ($row["date"]) { + $ins_stmt .= "\"" . $row["date"] . "\", "; + } else { + $ins_stmt .= "\"2005-12-28 16:28:31\", "; + } + } else { + $ins_stmt .= "NULL, "; + } + + if ($row["hasCard"] == 1) { + if ($row["date"]) { + $ins_stmt .= "\"" . $row["date"] . "\", "; + } else { + $ins_stmt .= "\"2005-12-28 16:28:31\", "; + } + } else { + $ins_stmt .= "NULL, "; + } + $ins_stmt .= $row["hasCard"]; + $ins_stmt .= ")"; + + //print $ins_stmt . "\n"; + //$conn->query($ins_stmt); + $i++; + } + } +} + +print "\n\nInsert $i rows\nUpdated $u rows"; \ No newline at end of file diff --git a/inside/pos.php b/inside/pos.php index 5777f83..9d3b0f5 100644 --- a/inside/pos.php +++ b/inside/pos.php @@ -8,7 +8,7 @@ header("Content-type: application/xml"); $conn = db_connect(); - $posId = mysql_real_escape_string($_REQUEST['positionid']); + $posId = $_REQUEST['positionid']; $sql = "SELECT name, text FROM din_position diff --git a/inside/screen.css.backup b/inside/screen.css.backup new file mode 100644 index 0000000..f6fada4 --- /dev/null +++ b/inside/screen.css.backup @@ -0,0 +1,700 @@ +/** + * text: #000 (black) + * background: #FFF (white) + * light-fill: #EEE + * conrast-fill: #DDD + * passive-cell: #AAA + * border: #CCC + * link: #00D + * + **/ +/* =general +*********************************************************************/ + +html, body { + margin: 0; + padding: 5px; + font-size: .905em; + line-height: 1.5em; + font-family: arial, sans-serif; +} + +img { + border: none; + display: block; +} + +td img { + display: inline; +} + +.mceEditor img { + display: inline; +} + +p { + margin: 0 0 5px 0; + padding: 0; +} + +em { + font-style: italic; +} + +strong, p.strong { + font-weight: bolder; +} + + +/* =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, span.button, label.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 { + display: none; +} + +a.contact { + background: url("graphics/user_go.png") no-repeat right; + padding-right: 20px; +} +/* =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; + margin: 2px 0; +} + +form .title { + font-size: 16px; + font-weight: bold; +} + +textarea:focus, input:focus { + background: #FFD; +} + +.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; +} + +.formHelp { + cursor: help; +} + +.formHelpMessage { + background: #FFD; + border: 1px solid black; + font-size: 11px; + padding: 3px 3px 3px 20px; + max-width: 300px; +} + +.helpMessageClose { + border: 1px solid black; + position: absolute; + top: 2px; + left: 2px; + padding: 0 2px; + line-height: 1em; + cursor: pointer; + background: red; + color: white; + 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.phone { + white-space: nowrap; +} + +td.date { + white-space: nowrap; +} + +td.is_member{ + text-align: center; +} + +tr.table-footer td { + font-weight: bold; + text-align: center; +} + +table.calendar { + width: 98%; + margin: 0 auto; + font-size: .85em; +} + +.calendar td { + padding: 0; + margin: 0; +} + +td.passive { + background: #AAA; +} + +td.weekNumber { + background: #DDD; + text-align: center; + vertical-align: middle; + font-weight: bold; +} + +div.calendar-event, label.calendar-event.button { + background: #CCC; +} + +div.calendar-concert, label.calendar-concert.button { + background: #DDD; +} + +.calendar td div { + padding: 2px 1px; + margin: 1px; + 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 { + float: left; + background-color: #EEE; + border: 1px solid #CCC; + -moz-border-radius: 8px; + color: #000; + width: 170px; + margin: 5px 0 15px 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 #CCC; +} + +.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; + background: #DDD; + color: #000; +} + +/* =content +*********************************************************************/ +#content { + padding: 0px; + margin: 5px 0 15px 207px; +} + +div.text-column { + max-width: 600px; +} + +* html div.text-column { + width: 600px; +} + +div.article_images { + float: right; + margin: 0px 0px 3px 3px; + width: 200px; +} +div.article_images div { + border: 1px dotted #ccc; +} +/*div.primary_image { + float: right; + margin: 0px 0px 3px 3px; + width: 200px; + border: 1px dotted #ccc; +} +*/ +span.caption { + font-size: 11px; + font-style: italic; +} + +/*div.extra_image { + float: left; + margin: 0px 3px 3px 0px; + width: 200px; + border: 1px dotted #ccc; +}*/ + +p.date { + font-style: italic; +} + +p.date:first-letter { + text-transform: uppercase; +} + +p.subtitle { + font-style: italic; +} + +p.intro { + font-weight: bold; + font-style: italic; +} + +div.messages, div.errors { + margin: 0 0 5px 0; + padding: 3px; + background: #000; + color: #FFF; + border: 1px solid #CCC; +} + +div.messages ul, div.erros ul { + margin: 0 0 0 35px; + padding: 0; + font-weight: bold; +} + +div.timeData { + border: 1px solid #CCC; + background: #EEE; + padding: 1px; +} + +div.optionsMenu { + margin: 5px 0; +} + +div.product { + border: 1px solid black; + margin: 5px; + padding: 5px; + cursor: pointer; +} + +div.product_images { + float: right; +} + +tr.barshift-full td { + background: #AAA; + font-style: italic; +} + +td.worker-status { + text-align: center; + font-weight: bold; +} + +div.calendar-barshift { + border: 1px solid #CCC; +} + +div.calendar-barshift.full { + border: 1px solid #CCC; + background: #DDD; +} + +div.calendar-barshift h4 { + text-align: left; + white-space: nowrap; +} + +div.calendar-barshift ul { + margin: 0; + padding: 0; + list-style: none; +} + +.calendar-register-me { + border: 1px solid black; + padding: 1px; + width: 50%; + color: black; + margin: 0px; + display: block; + text-align: center; + background: #DDD; +} + +div.calendar-barshift li { + white-space: nowrap; + margin: 0; + padding: 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; +} + +.clear-right { + clear: right; +} +/* =footer +*********************************************************************/ +#footer { + clear: both; + text-align: center; + background: #EEE; + border: 1px solid #CCC; + -moz-border-radius: 8px; + color: #000; + margin-top: 0px; +} + + + +/* =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; +} diff --git a/inside/testdomain.php b/inside/testdomain.php new file mode 100644 index 0000000..0d3c39d --- /dev/null +++ b/inside/testdomain.php @@ -0,0 +1,51 @@ +collection(); +for ($i = 13048; $i <= 13048; $i++) { + if ($user = domain_DomainObject::getFinder("domain_User")->find($i)) { + $users->add($user); + } +} + +foreach ($users as $user) { + print_r($user); + $user->getUpdates();; + $user->getMemberships(); + $user->getCards(); + $user->getAddress(); + + print_r($user); + //print "\n" . $user->getMemberships()->current()->getStarts()->format("Y-m-d"); +} +//$userMapper->update($user); + +// perform database modifications +domain_ObjectWatcher::instance()->performOperations(); +?> \ No newline at end of file diff --git a/inside/tmp b/inside/tmp new file mode 100644 index 0000000..e30c1f3 --- /dev/null +++ b/inside/tmp @@ -0,0 +1,406 @@ + + + +1282505719 + +array ( + 'CompleteResult' => '

e094adb6c5424befa5252d12c0b7405c2010-08-22 19:35:18
OKOKOK00d3ae9d6518434e00a3c8086a265bab72607656802366Handlevogn #2002VISA20000False0Handlevogn #2002f72de24c-a91f-4211-9890-6aecd84c098c3DSecureYfalse', +) +tmp +true + + +1282510849 + +array ( + 'CompleteResult' => '
5059ac4ca04a4937a8dcbbfee00a2c7f2010-08-22 21:00:48
OKOKOK0032081b3de82f4aaf89acdf35358c7963607728332367Handlevogn #2003VISA20000False0Handlevogn #20036a66af56-1726-4ac3-83fe-d10e7cd68e6c3DSecureYfalse
', +) +tmp +true + + +1282510871 + +array ( + 'CompleteResult' => '
eb391672a83e4deb9d24dc9e730f342e2010-08-22 21:01:08
OKOKOK0032081b3de82f4aaf89acdf35358c7963607728332367Handlevogn #2003VISA20000True0Handlevogn #20036a66af56-1726-4ac3-83fe-d10e7cd68e6c3DSecureYfalse
', +) +tmp +true + + +1282550541 + +array ( + 'CompleteResult' => '
5e6e90a77b344de499cff2cf158ac9232010-08-23 08:02:22
OKOKOK00d46018b98b8e44acb529d964d692fac0607876852369Handlevogn #2005VISA3500False0Handlevogn #2005e2c6be94-b9d6-4eed-b4ba-7a32dc3c6cbd3DSecureYfalse
', +) +tmp +true + + +1282573529 + +array ( + 'CompleteResult' => '
15ea32953976409d8b78d8b6b27eb27e2010-08-23 14:25:31
OKOKOK00ec2df9c96297424d85cd0d47b2f9fcbf608193152370Handlevogn #2006VISA20000False0Handlevogn #20063022deee-1692-456c-9ff3-78fd85716e5b3DSecureYfalse
', +) +tmp +true + + +1282586080 + +array ( + 'CompleteResult' => '
d61d4c5295e64446abf7805e8c91ceed2010-08-23 17:54:40
OKOKOK007534a641ae95457dbe9a069d1725af50608405812371Handlevogn #2007VISA20000False0Handlevogn #2007c2f14ad4-a4e4-43e1-b80d-d62ae09b96df3DSecureYfalse
', +) +tmp +true + + +1282648956 + +array ( + 'CompleteResult' => '
bb5c74d22efc47a79d44bc89895eb9af2010-08-24 11:22:36
OKOKOK00d46f1ca0ab2b4c26a1ddad6882d02305608945602372Handlevogn #2008VISA20000False0Handlevogn #20089c4a0b07-f679-4b8b-8611-0ea840c72f093DSecureYfalse
', +) +tmp +true + + +1282685139 + +array ( + 'CompleteResult' => '
74cbe5f35ba34bb2815c1a9f8dceddc72010-08-24 21:25:41
OKOKOK00f7eddf4a4f8b4f7ca079c416a1fbf969609474082373Handlevogn #2009VISA20000False0Handlevogn #20096eeea499-04e6-4954-8c75-12b94dab4b4b3DSecureYfalse
', +) +tmp +true + + +1282686581 + +array ( + 'CompleteResult' => '
a350bc437aaa40ee9ebbe1534a613bdd2010-08-24 21:49:43
OKOKOK007823b391ec3446fda9338ab72d95a7fb609482862374Handlevogn #2010VISA3500False0Handlevogn #201098520b06-2ab1-4e4f-b36c-fcf426c141d23DSecureYfalse
', +) +tmp +true + + +1282723867 + +array ( + 'CompleteResult' => '
ac8d5a17f4e842f1859ca72000f8a0792010-08-25 08:11:13
OKOKOK001499c1b3b24f4a93b1a90c026dcead92609644402375Handlevogn #2011VISA3500False0Handlevogn #2011b6c74b29-824c-4c23-9a9c-9579ff8a8a433DSecureYfalse
', +) +tmp +true + + +1282727829 + +array ( + 'CompleteResult' => '
7de3cea0e77546d7b2db172cd177d27c2010-08-25 09:17:18
OKOKOK0005921260da7d4abfbe17597dc9071de4609691402376Handlevogn #2012VISA20000False0Handlevogn #2012eb369acd-4e1f-4754-8102-dd546e6a6feb3DSecureYfalse
', +) +tmp +true + + +1282738005 + +array ( + 'CompleteResult' => '
120f08aca0924528a8b0b0bc5edcbd962010-08-25 12:06:52
OKOKOK00861db9cc775c45e38c42551663f5d79c609848962377Handlevogn #2013VISA20000False0Handlevogn #2013e997ba84-47c3-4859-854a-3c459e29a7da3DSecureYfalse
', +) +tmp +true + + +1282741121 + +array ( + 'CompleteResult' => '
01e6efaf9e71412198f69a8083bcf2302010-08-25 12:58:48
OKOKOK00fe07cfa6713b4f3c90e09b4cdb493131609890052378Handlevogn #2014VISA20000False0Handlevogn #201423dc2914-dfac-465a-ab6e-c696f85f24f43DSecureYfalse
', +) +tmp +true + + +1282811261 + +array ( + 'CompleteResult' => '
098af6566668442fa046e855b17276c92010-08-26 08:27:47
OKOKOK0070ffe0dd5a874285a65a8ebf893c358d610504502381Handlevogn #2018VISA3500False0Handlevogn #2018a6f06651-0be5-4026-aae0-825bdbb821083DSecureYfalse
', +) +tmp +true + + +1282843511 + +array ( + 'CompleteResult' => '
2c5567978ed947d8b2f9f6553c6409b12010-08-26 17:25:18
OKOKOK007cf90d1bbd87417f8fcedc4a2e184f83610924572382Handlevogn #2019VISA20000False0Handlevogn #20196899f446-ad7a-4402-a2a0-2b09a9c7f395NoneNfalse
', +) +tmp +true + + +1282850785 + +array ( + 'CompleteResult' => '
653042fdedc14c42b7bd7eabf7dfe01e2010-08-26 19:26:30
OKOKOK002e07a26fa6f24f7685658c2e43193adc611028702383Handlevogn #2020VISA20000False0Handlevogn #2020afef68d3-32fb-4500-ae17-5f1b3edc00ed3DSecureYfalse
', +) +tmp +true + + +1282853724 + +array ( + 'CompleteResult' => '
51ffa9cbafbb4fe98cafb909deece26c2010-08-26 20:15:29
OKOKOK00a772cf01b0d948c4af68b2ec90030381611072102384Handlevogn #2021VISA3500False0Handlevogn #2021a9dce6eb-7fa0-4fc8-bb9a-5f67eb6f104e3DSecureYfalse
', +) +tmp +true + + +1282857116 + +array ( + 'CompleteResult' => '
42aeca023601405db1dc54f58cd50e9e2010-08-26 21:12:05
OKOKOK5093b181e86a454028b660364a7d4681db611117882385Handlevogn #2022VISA20000FalseOperationCancelledbyCustomerAccomplish3rdPartyUSER_CANCELED0Handlevogn #2022CreditCard_Errorfdb400b7-ab13-4dbf-922b-cc2e29c34807Nfalse
', +) +tmp +true + + +1282934047 + +array ( + 'CompleteResult' => '
5e6d107f6cb34f6784d94aee2dfcb3df2010-08-27 18:34:12
OKOKOK0055085049016649fbad8b2c9f656b7fe4611739172387Handlevogn #2023VISA20000False0Handlevogn #20239e8db6da-82f6-40d7-a6ea-b4e31923adc43DSecureYfalse
', +) +tmp +true + + +1283020700 + +array ( + 'CompleteResult' => '
7d005970e5ec4aec958e4ba5a0fc040b2010-08-28 18:38:24
OKOKOK00df0747b89f0e4d5b913e1a7bdb60830a612301172395Handlevogn #2022VISA20000False0Handlevogn #2022fdb400b7-ab13-4dbf-922b-cc2e29c348073DSecureYfalse
', +) +tmp +true + + +1283025954 + +array ( + 'CompleteResult' => '
a1a3c6dec393475eaac30071241158fa2010-08-28 20:05:57
OKOKOK00359191c81f7945509e87b3b7dd3bae1c612340782396Handlevogn #2024VISA20000False0Handlevogn #2024bfc2af58-e859-4bf7-83ce-18987986f8213DSecureYfalse
', +) +tmp +true + + +1283093789 + +array ( + 'CompleteResult' => '
e4746b3aba0c4b79b42c8310839356162010-08-29 14:56:31
OKOKOK505a671425a02c4262a9e0205761711c96612751802397Handlevogn #2029VISA20000FalseOperationCancelledbyCustomerAccomplish3rdPartyUSER_CANCELED0Handlevogn #2029CreditCard_Errorcfab921c-ac1d-4384-b35a-e0f58dfc1b0cNfalse
', +) +tmp +true + + +1283094793 + +array ( + 'CompleteResult' => '
8695a6799e77436b81c6dbc774331a1c2010-08-29 15:13:16
OKOKOK00110de966de874459bd3009aca71c4c45612765202398Handlevogn #2029VISA20000False0Handlevogn #2029cfab921c-ac1d-4384-b35a-e0f58dfc1b0c3DSecureYfalse
', +) +tmp +true + + +1283117421 + +array ( + 'CompleteResult' => '
993852cbe06646e1ba7aa6d65f83edaf2010-08-29 21:30:23
OKOKOK001bc5196f457749c08f17f3a05e465848613090332399Handlevogn #2030VISA20000False0Handlevogn #20300b203ce0-a937-45f8-ae2b-83e54e193accNoneNfalse
', +) +tmp +true + + +1283153028 + +array ( + 'CompleteResult' => '
8442d00e3ad943319741b81938b6fe942010-08-30 07:23:50
OKOKOK001c390bdad9754c42ba483f127b5dc4c3613218312400Handlevogn #2031VISA3500False0Handlevogn #2031a75352b3-de7c-4c28-ae47-f07d95b9a3a13DSecureYfalse
', +) +tmp +true + + +1283167111 + +array ( + 'CompleteResult' => '
74571323d258454dac69d37dd475c6d42010-08-30 11:18:33
OKOKOK009c20e11f4c554dc9b18cbedacad511d2613452312401Handlevogn #2032VISA3500False0Handlevogn #203236b5e281-5871-48af-93e0-a8a7fd3a68133DSecureYfalse
', +) +tmp +true + + +1283203827 + +array ( + 'CompleteResult' => '
aca416f295a34a1da3f4520ac2abf18a2010-08-30 21:30:27
OKOKOK00d0e2b3cc44dc4edfbe0f3addc2ace202614057092402Handlevogn #2033VISA20000False0Handlevogn #203394e42dc4-fff7-407d-ae24-3fad8452930a3DSecureYfalse
', +) +tmp +true + + +1283259775 + +array ( + 'CompleteResult' => '
a0039ebc8ae5478d90009856d5ac04a72010-08-31 13:02:56
OKOKOK00a699c98f29e84864bcdb071bac7f6a66614561582403Handlevogn #2035VISA20000False0Handlevogn #2035f8386f65-3ce3-4330-ac6e-2f0b7f387f4d3DSecureYfalse
', +) +tmp +true + + +1283278469 + +array ( + 'CompleteResult' => '
e711fb50999f4899898f6f75f272a8352010-08-31 18:14:28
OKOKOK00a35a9a1024bc4966aa1e24c568bf0000614847302404Handlevogn #2036VISA20000False0Handlevogn #203654c5a40d-a96f-4a52-824b-20ed0cd69a9d3DSecureYfalse
', +) +tmp +true + + +1283279270 + +array ( + 'CompleteResult' => '
100ce69d7fcf41ce8b66e1699102b4082010-08-31 18:27:50
OKOKOK004d151e1ec8904eb9825079e33f2b7744614860472405Handlevogn #2037VISA3500False0Handlevogn #2037bb6affe3-a56c-4158-aeeb-2cdb10267f763DSecureYfalse
', +) +tmp +true + + +1283428309 + +array ( + 'CompleteResult' => '
a357b465ea754680be4bbce35353839b2010-09-02 11:51:53
OKOKOK007f040adde7984ddaa0928b6459181f20616435522408Handlevogn #2040VISA20000False0Handlevogn #204083874db6-6775-470f-9333-a4e791dce01a3DSecureYfalse
', +) +tmp +true + + +1283460713 + +array ( + 'CompleteResult' => '
33f73cd7d75f467b8717e31703633b652010-09-02 20:51:58
OKOKOK00f1b084d30c7f44f296b9447a2fd2c4f9616870752409Handlevogn #2042VISA20000False0Handlevogn #2042e9d5c828-7ef8-4182-b6c8-67bbf68d5bb83DSecureYfalse
', +) +tmp +true + + +1283609260 + +array ( + 'CompleteResult' => '
2b36c602d6bf4127bd7017c7a099d5492010-09-04 14:07:44
OKOKOK00b2c16494d2ea430892e31f434e14ba1c618045742411Handlevogn #2044VISA20000False0Handlevogn #20448fd040fa-def4-489a-875c-6338467b19b43DSecureYfalse
', +) +tmp +true + + +1283766055 + +array ( + 'CompleteResult' => '
3af5a2d27767442ba33adb8ac1f3c84b2010-09-06 09:40:57
OKOKOK0034a5797f62584eddab3c9ec5a1624e48619074982413Handlevogn #2046VISA20000False0Handlevogn #2046041d5df3-a4c5-4a65-905d-5f3c28e17d1b3DSecureYfalse
', +) +tmp +true + + +1283798299 + +array ( + 'CompleteResult' => '
1ec0343876dc458ca1282911faca83892010-09-06 18:38:19
OKOKOK00fdd1407dbe064a2d8425a2103b247a12619607162414Handlevogn #2047VISA20000False0Handlevogn #2047c977e9e0-46c1-4bb6-a99d-d7588d169ab63DSecureYfalse
', +) +tmp +true + + +1283809157 + +array ( + 'CompleteResult' => '
d2a435fddacb457ca32701a33ce795be2010-09-06 21:39:18
OKOKOK007a682ca187d8437c88fd3483567d014e619755182415Handlevogn #2048VISA20000False0Handlevogn #2048712bc131-5df9-4367-a974-4d7956e893bbNoneNfalse
', +) +tmp +true + + +1283876520 + +array ( + 'CompleteResult' => '
f9c5be5413c342eca866e225727ca46d2010-09-07 16:22:00
OKOKOK00b232458c8bb849a1879231398ba0d642620424442419Handlevogn #2051VISA20000False0Handlevogn #20513603891b-812e-4dff-95ec-01e86843df9f3DSecureYfalse
', +) +tmp +true + + +1283946296 + +array ( + 'CompleteResult' => '
ff5a4ea5dbef433db472e9f0b903d92f2010-09-08 11:45:03
OKOKOK00c44f0d4906174ee59a8c01024cc93d9e621049872420Handlevogn #2052VISA3500False0Handlevogn #20524fc830ad-8395-42ab-9d0e-d005234d9e4c3DSecureYfalse
', +) +tmp +true + + +1284033493 + +array ( + 'CompleteResult' => '
c24ed26cc7dd4d1db9b3dea3424f259e2010-09-09 11:58:18
OKOKOK008c2a0c43dbb449298b37ef24d4773744621903382421Handlevogn #2053VISA20000False0Handlevogn #2053dbe87dd5-8189-42b7-b317-5aecddd35ff33DSecureYfalse
', +) +tmp +true + + +1284033988 + +array ( + 'CompleteResult' => '
d100ea7dc3fd498d9fb264382b88f7a42010-09-09 12:06:35
OKOKOK008eb9f1f45e914427af632ceb17d87f19621909452422Handlevogn #2054VISA20000False0Handlevogn #205471021cb2-f31c-4cea-952a-895ebe1d412a3DSecureYfalse
', +) +tmp +true + + +1284054550 + +array ( + 'CompleteResult' => '
a20586f809104f1799f3b275501c3b402010-09-09 17:49:19
OKOKOK00123aa4cddab74a36a601dd8888bb668a622195222423Handlevogn #2055VISA20000False0Handlevogn #2055e5088860-1cf8-4a5a-9261-1975d97a4bbb3DSecureYfalse
', +) +tmp +true + + +1284062934 + +array ( + 'CompleteResult' => '
67f80ba8cb154580b4dc395cea66765d2010-09-09 20:09:02
OKOKOK50274437709fd7441f8c89ef1a52a8796f622306902424Handlevogn #2057VISA20000FalsePaymentRefusedByFinancialInstitutionAccomplish3rdPartyREJECTED_BY_ACQUIRER_INSUFFICIENT_FUNDS0Handlevogn #2057CreditCard_Error736dcb50-c6ed-4375-b18f-6e968991b1e23DSecureYfalse
', +) +tmp +true + + +1284118506 + +array ( + 'CompleteResult' => '
c5dd9b00c2884a6080733d666263e70c2010-09-10 11:35:12
OKOKOK002dcd272e05b54b57b236a399bb7521ca622696642425Handlevogn #2058VISA20000False0Handlevogn #2058fd21cab2-d40a-4688-a38c-c82e68b49e9e3DSecureYfalse
', +) +tmp +true + + +1284123934 + +array ( + 'CompleteResult' => '
28a7b71a982f444291d3e1b79074f9982010-09-10 13:05:39
OKOKOK00ab508d6f7fc8449daf4ab95eff70bc06622797552426Handlevogn #2059VISA20000False0Handlevogn #2059be0c0aa6-5205-44b7-8f2e-c986710e012e3DSecureYfalse
', +) +tmp +true + + +1284282203 + +array ( + 'CompleteResult' => '
9d823c70fafa40a98d20003119b5aeff2010-09-12 09:03:27
OKOKOK00edc6cb6b514f4c8482de2266ac4f55d7623803032427Handlevogn #2061VISA20000False0Handlevogn #2061c3871cdf-4f0a-4b17-9eef-5a84cfd2cb623DSecureYfalse
', +) +tmp +true \ No newline at end of file diff --git a/vaktliste/App/Base/ApplicationRegistry.php b/vaktliste/App/Base/ApplicationRegistry.php index 2fea639..413117f 100644 --- a/vaktliste/App/Base/ApplicationRegistry.php +++ b/vaktliste/App/Base/ApplicationRegistry.php @@ -1,73 +1,73 @@ -values[$key])) { - return $this->values[$key]; - } - return null; - } - - protected function set($key, $val) { - $this->values[$key] = $val; - // storage ... - return $this->values[$key]; - } - - static function getDSN() { - return self::instance()->get('dsn'); - } - - - static function setDSN( $dsn ) { - return self::instance()->set('dsn', $dsn); - } - - static function getControllerMap() { - return self::instance()->get('controllerMap'); - } - - static function setControllerMap(App_Controller_ControllerMap $map ) { - return self::instance()->set('controllerMap', $map); - } - - static function getApplicationController() { - return self::instance()->get('applicationController'); - } - - static function setApplicationController(App_Controller_AppController $appCtrl) { - return self::instance()->set('applicationController', $appCtrl); - } - - static function getAccessManager() { - return self::instance()->get('accessManager'); - } - - static function setAccessManager(App_Controller_AccessManager $manager) { - return self::instance()->set('accessManager', $manager); - } - - static function getPageTitle() { - return self::instance()->get('pagetitle'); - } - - static function setPageTitle( $pagetitle ) { - return self::instance()->set('pagetitle', $pagetitle); - } - +values[$key])) { + return $this->values[$key]; + } + return null; + } + + protected function set($key, $val) { + $this->values[$key] = $val; + // storage ... + return $this->values[$key]; + } + + static function getDSN() { + return self::instance()->get('dsn'); + } + + + static function setDSN( $dsn ) { + return self::instance()->set('dsn', $dsn); + } + + static function getControllerMap() { + return self::instance()->get('controllerMap'); + } + + static function setControllerMap(App_Controller_ControllerMap $map ) { + return self::instance()->set('controllerMap', $map); + } + + static function getApplicationController() { + return self::instance()->get('applicationController'); + } + + static function setApplicationController(App_Controller_AppController $appCtrl) { + return self::instance()->set('applicationController', $appCtrl); + } + + static function getAccessManager() { + return self::instance()->get('accessManager'); + } + + static function setAccessManager(App_Controller_AccessManager $manager) { + return self::instance()->set('accessManager', $manager); + } + + static function getPageTitle() { + return self::instance()->get('pagetitle'); + } + + static function setPageTitle( $pagetitle ) { + return self::instance()->set('pagetitle', $pagetitle); + } + } \ No newline at end of file diff --git a/vaktliste/App/Base/Registry.php b/vaktliste/App/Base/Registry.php index a901b77..9768c23 100644 --- a/vaktliste/App/Base/Registry.php +++ b/vaktliste/App/Base/Registry.php @@ -1,8 +1,8 @@ - \ No newline at end of file diff --git a/vaktliste/App/Base/RequestRegistry.php b/vaktliste/App/Base/RequestRegistry.php index 69d0ad2..adfe871 100644 --- a/vaktliste/App/Base/RequestRegistry.php +++ b/vaktliste/App/Base/RequestRegistry.php @@ -1,40 +1,40 @@ -values[$key])) { - return $this->values[$key]; - } - return null; - } - - protected function set($key, $value) { - $this->values[$key] = $value; - } - - static function getRequest() { - return self::instance()->get('request'); - } - - static function setRequest(App_Controller_Request $request) { - return self::instance()->set('request', $request); - } -} - +values[$key])) { + return $this->values[$key]; + } + return null; + } + + protected function set($key, $value) { + $this->values[$key] = $value; + } + + static function getRequest() { + return self::instance()->get('request'); + } + + static function setRequest(App_Controller_Request $request) { + return self::instance()->set('request', $request); + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Base/SessionRegistry.php b/vaktliste/App/Base/SessionRegistry.php index 51423a9..852cc3d 100644 --- a/vaktliste/App/Base/SessionRegistry.php +++ b/vaktliste/App/Base/SessionRegistry.php @@ -1,56 +1,56 @@ -get('userid'))) { - //return self::instance()->get('userid'); - } - // check session from old inside - if (isset($_SESSION['valid-user'])) { - self::instance()->set('userid', $_SESSION['valid-user']); - } - return self::instance()->get('userid'); - } - - static function setUserId($userid) { - if (is_null($userid)) { - unset($_SESSION['valid-user']); - self::instance()->set('userid', null); - } else { - // update old inside as well - $_SESSION['valid-user'] = $userid; - self::instance()->set('userid', $userid); - } - } - -} - +get('userid'))) { + //return self::instance()->get('userid'); + } + // check session from old inside + if (isset($_SESSION['valid-user'])) { + self::instance()->set('userid', $_SESSION['valid-user']); + } + return self::instance()->get('userid'); + } + + static function setUserId($userid) { + if (is_null($userid)) { + unset($_SESSION['valid-user']); + self::instance()->set('userid', null); + } else { + // update old inside as well + $_SESSION['valid-user'] = $userid; + self::instance()->set('userid', $userid); + } + } + +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Calendar/Calendar.php b/vaktliste/App/Calendar/Calendar.php new file mode 100644 index 0000000..ed7a3b3 --- /dev/null +++ b/vaktliste/App/Calendar/Calendar.php @@ -0,0 +1,151 @@ +fillCalendar($date); + } + + function fillCalendar(DateTime $date) { + $this->date = $date; + + // set startofmonth to first day of month + $this->startOfMonth = new DateTime("2000-01-01"); + $this->startOfMonth->setDate($date->format('Y'), $date->format('m'), 1); + + // set endofmonth to last day of month + $this->endOfMonth = new DateTime("2000-01-01"); + $this->endOfMonth->setDate($date->format('Y'), $date->format('m'), $date->format('t')); + $this->month = new App_Calendar_Month($this->startOfMonth); + + // fill month with weeks + $startofweek = new DateTime("2000-01-01"); + $startofweek->setISODate($this->startOfMonth->format('o'), $this->startOfMonth->format('W')); // gets the week number + $startofweek->setTime(0, 0); + while ($startofweek <= $this->endOfMonth) { + $week = new App_Calendar_Week(new DateTime($startofweek->format('Y-m-d'))); + for ($i = 1; $i <= 7; $i++) { + $startofday = new DateTime("2000-01-01"); + $startofday->setISODate($startofweek->format('o'), $startofweek->format('W'), $i); + $day = new App_Calendar_Day($startofday); + $week->addDay($day); + } + $this->month->addWeek($week); + + // add seven days to startofweek + $startofweek->setISODate($startofweek->format('o'), $startofweek->format('W'), 8); + } + } + + function getMonth() { + return $this->month; + } + + function isInMonth(App_Calendar_Day $day) { + if (($day->getDate() >= $this->startOfMonth) && ($day->getDate() <= $this->endOfMonth)) { + return true; + } + return false; + } +} + +/** + * Calendar month class + * + * @version 0.1 + */ + +class App_Calendar_Month { + private $month; + private $weeks = array(); + + function __construct(DateTime $month) { + $this->month = $month; + } + + function getMonth() { + return $this->month; + } + + function setMonthName($name) { + $this->monthName = $name; + } + + function getMonthName() { + return $this->monthName; + } + + function addWeek(App_Calendar_Week $week) { + $this->weeks[] = $week; + } + + function getWeeks() { + return $this->weeks; + } +} + +/** + * Calendar week class + * + * @version 0.1 + */ + +class App_Calendar_Week { + private $week; + private $days = array(); + + function __construct($week) { + $this->week = $week; + } + + function getWeek() { + return $this->week; + } + + function addDay(App_Calendar_Day $day) { + $this->days[] = $day; + } + + function getDays() { + return $this->days; + } +} + +/** + * Calendar day class + * + * @version 0.1 + */ + +class App_Calendar_Day { + private $date; + private $shifts = array(); + + function __construct(DateTime $date) { + $this->date = $date; + } + + function getDate() { + return $this->date; + } + + function addShift(App_Domain_WorkShift $shift) { + $this->shifts[] = $shift; + } + + function getShifts() { + return $this->shifts; + } +} + +?> \ No newline at end of file diff --git a/vaktliste/App/Command/AddShift.php b/vaktliste/App/Command/AddShift.php index 7ae98f1..7ece8fe 100644 --- a/vaktliste/App/Command/AddShift.php +++ b/vaktliste/App/Command/AddShift.php @@ -1,42 +1,80 @@ -getProperty("title"); - $starts = $request->getProperty("starts"); - $ends = $request->getProperty("ends"); - $numworkers = $request->getProperty("numworkers"); - $location = $request->getProperty("location"); - $group = 97; // CNS bar - $salaryType = 3; // CNS bar - - if (empty($title)) { - $request->addFeedback("Tittel må oppgis."); - return self::statuses('CMD_INSUFFICIENT_DATA'); - } - - if (empty($starts)) { - $request->addFeedback("Starttid må oppgis."); - return self::statuses('CMD_INSUFFICIENT_DATA'); - } - - if (empty($ends)) { - $request->addFeedback("Sluttid må oppgis."); - return self::statuses('CMD_INSUFFICIENT_DATA'); - } - - if (empty($numworkers)) { - $request->addFeedback("Antall må oppgis."); - return self::statuses('CMD_INSUFFICIENT_DATA'); - } - - return self::statuses('CMD_OK'); - } - -} - +getProperty("title"); + $starts = $request->getProperty("starts_date") . " " . $request->getProperty("starts_time"); + $ends = $request->getProperty("ends_date") . " " . $request->getProperty("ends_time"); + $num_workers = $request->getProperty("num_workers"); + $comment = $request->getProperty("comment"); + + $request->setProperty("location", 4); // glassbaren + $groupid = 97; // CNS bar + $salaryType = 3; + + $locations = App_Domain_Location::getFinder("App_Domain_Location")->findAll(); + $location = App_Domain_location::getFinder("App_Domain_Location")->find($request->getProperty("location")); + + $request->setObject("locations", $locations); + + if (is_null($request->getProperty("title"))) { + // no user data given yet, show add shift page + $request->setProperty("starts_date", date("j/n/Y")); + $request->setProperty("starts_time", date("H:i")); + $request->setProperty("ends_date", date("j/n/Y")); + $request->setProperty("ends_time", date("H:i")); + return self::statuses('CMD_DEFAULT'); + } + + if (empty($title)) { + $request->addFeedback("Tittel må oppgis."); + return self::statuses('CMD_INSUFFICIENT_DATA'); + } + + if (empty($starts)) { + $request->addFeedback("Starttid må oppgis."); + return self::statuses('CMD_INSUFFICIENT_DATA'); + } else { + // change dd/mm/yyyy to dd.mm.yyyy to be on a valid date format + $starts = str_replace("/", ".", $starts); + } + + if (empty($ends)) { + $request->addFeedback("Sluttid må oppgis."); + return self::statuses('CMD_INSUFFICIENT_DATA'); + } else { + // change dd/mm/yyyy to dd.mm.yyyy to be on a valid date format + $ends = str_replace("/", ".", $ends); + } + + if (empty($num_workers)) { + $request->addFeedback("Antall må oppgis."); + return self::statuses('CMD_INSUFFICIENT_DATA'); + } + + $salary_type_object = App_Domain_DomainObject::getFinder("App_Domain_WorkSalaryType")->find($salaryType); + $group = App_Domain_DomainObject::getFinder("App_Domain_Group")->find($groupid); + + $shift = new App_Domain_WorkShift(); + $shift->setTitle($title); + $shift->setStarts(new DateTime($starts)); + $shift->setEnds(new DateTime($ends)); + $shift->setActive(true); + $shift->setComment($comment); + $shift->setLocked(false); + $shift->setAutoAssignWorkers(false); + $shift->setNumWorkers($num_workers); + $shift->setGroup($group); + $shift->setSalaryType($salary_type_object); + $shift->setLocation($location); + + return self::statuses('CMD_OK'); + } + +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Command/Command.php b/vaktliste/App/Command/Command.php index 7feb7ec..1a3d7d3 100644 --- a/vaktliste/App/Command/Command.php +++ b/vaktliste/App/Command/Command.php @@ -1,41 +1,41 @@ - 0, - 'CMD_OK' => 1, - 'CMD_ERROR' => 2, - 'CMD_INSUFFICIENT_DATA' => 3 - ); - - private $status = 0; - - //private $currentUser = null; - - final function __construct() {} - - function execute(App_Controller_Request $request) { - // check if visitor is logged in - //$this->currentUser = App_Base_SessionRegistry::getCurrentUser(); - - // execute command - $this->status = $this->doExecute($request); - $request->setCommand($this); - } - - function getStatus() { - return $this->status; - } - - static function statuses ($str = 'CMD_DEFAULT') { - if (empty($str)) $str = 'CMD_DEFAULT'; - // convert string into a status number - return self::$STATUS_STRINGS[$str]; - } - - //abstract protected function validate(App_Controller_Request $request); - abstract function doExecute(App_Controller_Request $request); -} - + 0, + 'CMD_OK' => 1, + 'CMD_ERROR' => 2, + 'CMD_INSUFFICIENT_DATA' => 3 + ); + + private $status = 0; + + //private $currentUser = null; + + final function __construct() {} + + function execute(App_Controller_Request $request) { + // check if visitor is logged in + //$this->currentUser = App_Base_SessionRegistry::getCurrentUser(); + + // execute command + $this->status = $this->doExecute($request); + $request->setCommand($this); + } + + function getStatus() { + return $this->status; + } + + static function statuses ($str = 'CMD_DEFAULT') { + if (empty($str)) $str = 'CMD_DEFAULT'; + // convert string into a status number + return self::$STATUS_STRINGS[$str]; + } + + //abstract protected function validate(App_Controller_Request $request); + abstract function doExecute(App_Controller_Request $request); +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Command/CommandHelper.php b/vaktliste/App/Command/CommandHelper.php index c9f202a..6a2f941 100644 --- a/vaktliste/App/Command/CommandHelper.php +++ b/vaktliste/App/Command/CommandHelper.php @@ -1,12 +1,12 @@ -find(App_Base_SessionRegistry::getUserId()); - } - return null; - } -} - -?> +find(App_Base_SessionRegistry::getUserId()); + } + return null; + } +} + +?> diff --git a/vaktliste/App/Command/DefaultCommand.php b/vaktliste/App/Command/DefaultCommand.php index e8d4101..b48e33e 100644 --- a/vaktliste/App/Command/DefaultCommand.php +++ b/vaktliste/App/Command/DefaultCommand.php @@ -1,24 +1,24 @@ -setObject('currentUser', $user); - return self::statuses('CMD_OK'); - } -// if ($request->getProperty("p") == "login") { -// $request->addFeedback( "you are logged in" ); -// return self::statuses('CMD_OK'); -// } - return self::statuses('CMD_DEFAULT'); - } -} +setObject('currentUser', $user); + return self::statuses('CMD_OK'); + } +// if ($request->getProperty("p") == "login") { +// $request->addFeedback( "you are logged in" ); +// return self::statuses('CMD_OK'); +// } + return self::statuses('CMD_DEFAULT'); + } +} diff --git a/vaktliste/App/Command/GetShift.php b/vaktliste/App/Command/GetShift.php new file mode 100644 index 0000000..491a45c --- /dev/null +++ b/vaktliste/App/Command/GetShift.php @@ -0,0 +1,37 @@ +getProperty("shift"))) { + $request->addFeedback("Skift må oppgis"); + return self::statuses('CMD_INSUFFICIENT_DATA'); + } + + $shift = App_Domain_WorkShift::getFinder("App_Domain_WorkShift")->find($request->getProperty("shift")); + + if (is_null($shift)) { + $request->addFeedback("Fant ikke skiftet"); + return self::statuses('CMD_ERROR'); + } + + $request->setProperty("starts_date", $shift->getStarts()->format("j/n/Y")); + $request->setProperty("starts_time", $shift->getStarts()->format("H:i")); + $request->setProperty("ends_date", $shift->getEnds()->format("j/n/Y")); + $request->setProperty("ends_time", $shift->getEnds()->format("H:i")); + $request->setProperty("title", $shift->getTitle()); + $request->setProperty("num_workers", $shift->getNumWorkers()); + $request->setProperty("location", $shift->getLocation()->getId()); + + $locations = App_Domain_Location::getFinder("App_Domain_Location")->findAll(); + $request->setObject("locations", $locations); + + return self::statuses('CMD_OK'); + } + +} + +?> \ No newline at end of file diff --git a/vaktliste/App/Command/Login.php b/vaktliste/App/Command/Login.php index c093614..c2aa01a 100644 --- a/vaktliste/App/Command/Login.php +++ b/vaktliste/App/Command/Login.php @@ -1,27 +1,27 @@ -getProperty("username"); - $password = $request->getProperty("password"); - if (empty($username) || empty($password)) { - $request->addFeedback("Både brukernavn og passord må oppgis."); - return self::statuses('CMD_INSUFFICIENT_DATA'); - } - - $manager = App_Base_ApplicationRegistry::getAccessManager(); - $user = $manager->login($username, $password); - if (is_null($user)) { - $request->addFeedback("Ugyldig brukernavn eller passord."); - return self::statuses('CMD_ERROR'); - } - App_Base_SessionRegistry::setUserId($user->getId()); - return self::statuses('CMD_OK'); - } -} - +getProperty("username"); + $password = $request->getProperty("password"); + if (empty($username) || empty($password)) { + $request->addFeedback("Både brukernavn og passord må oppgis."); + return self::statuses('CMD_INSUFFICIENT_DATA'); + } + + $manager = App_Base_ApplicationRegistry::getAccessManager(); + $user = $manager->login($username, $password); + if (is_null($user)) { + $request->addFeedback("Ugyldig brukernavn eller passord."); + return self::statuses('CMD_ERROR'); + } + App_Base_SessionRegistry::setUserId($user->getId()); + return self::statuses('CMD_OK'); + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Command/Logout.php b/vaktliste/App/Command/Logout.php index 3b841ed..7b28182 100644 --- a/vaktliste/App/Command/Logout.php +++ b/vaktliste/App/Command/Logout.php @@ -1,15 +1,15 @@ -addFeedback("Du er logget ut"); - App_Base_SessionRegistry::setUserId(null); - return self::statuses('CMD_DEFAULT'); - } -} - +addFeedback("Du er logget ut"); + App_Base_SessionRegistry::setUserId(null); + return self::statuses('CMD_DEFAULT'); + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Command/ViewCalendar.php b/vaktliste/App/Command/ViewCalendar.php new file mode 100644 index 0000000..5a7fe47 --- /dev/null +++ b/vaktliste/App/Command/ViewCalendar.php @@ -0,0 +1,53 @@ +getProperty("month"))) { + // no month given, show current month + $calendar = new App_Calendar_Calendar(new DateTime()); + } else { + $calendar = new App_Calendar_Calendar(new DateTime($request->getProperty("month")."-01")); + } + + // Set month name + $calendar->getMonth()->setMonthName($calendar->getMonth()->getMonth()->format("F")); + + // Add shifts to calendar + $shifts = App_Domain_Location::getFinder("App_Domain_WorkShift")->findAll(); + $shifts->rewind(); + + // initialization + $shift = $shifts->next(); + + foreach ($calendar->getMonth()->getWeeks() as $week) { + foreach ($week->getDays() as $day) { + // end of day in PHP 5.2.0 + $dayends = clone $day->getDate(); + $dayends->modify("+1 day"); + + while ($shifts->valid() && ($shift->getStarts() < $dayends)) { + //while ($shifts->valid() && ($shift->getStarts() < $day->getDate()->add(new DateInterval('P1D'))) { // Requires PHP >= 5.3.0 + + // Skip shifts that starts before current day + if ($shift->getStarts() >= $day->getDate()) { + $day->addShift($shift); + } + + // go to next shift + $shift = $shifts->next(); + } + } + } + + $request->setObject('calendar', $calendar); + + return self::statuses('CMD_DEFAULT'); + } + +} + +?> \ No newline at end of file diff --git a/vaktliste/App/Controller/AccessManager.php b/vaktliste/App/Controller/AccessManager.php index fd77a60..ed736bc 100644 --- a/vaktliste/App/Controller/AccessManager.php +++ b/vaktliste/App/Controller/AccessManager.php @@ -1,35 +1,37 @@ -error; - } - - function setError($msg) { - $this->error = $msg; - } - - function login($username, $password) { - return App_Domain_DomainObject::getFinder(App_Domain_HelperFactory::USER)->findByLogin($username, $password); - } - - function logout() { - if (!is_null(App_Base_SessionRegistry::getUserId())) { - // do something, i.e. logging ? - } - return true; - } - - function getCommandAccess($cmd) { - if (!is_null(App_Base_SessionRegistry::getUserId())) { - return true; - } - return false; - } - +error; + } + + function setError($msg) { + $this->error = $msg; + } + + function login($username, $password) { + return App_Domain_DomainObject::getFinder(App_Domain_HelperFactory::USER)->findByLogin($username, $password); + } + + function logout() { + if (!is_null(App_Base_SessionRegistry::getUserId())) { + // do something, i.e. logging ? + } + return true; + } + + function getCommandAccess($cmd) { + // Do the user has access to the specified command ? + // Currently not implemented, return true if user is logged in + if (!is_null(App_Base_SessionRegistry::getUserId())) { + return true; + } + return false; + } + } \ No newline at end of file diff --git a/vaktliste/App/Controller/AppController.php b/vaktliste/App/Controller/AppController.php index 5423627..5d37881 100644 --- a/vaktliste/App/Controller/AppController.php +++ b/vaktliste/App/Controller/AppController.php @@ -1,116 +1,116 @@ -controllerMap = $map; - if (!self::$base_cmd) { - self::$base_cmd = new ReflectionClass("App_Command_Command"); - self::$default_cmd = new App_Command_DefaultCommand(); - } - } - - function getView(App_Controller_Request $request) { - $view = $this->getResource($request, "View"); - return $view; - } - - function getForward(App_Controller_Request $request) { - $forward = $this->getResource($request, "Forward"); - if ($forward) { - $request->setProperty("cmd", $forward); - } - return $forward; - } - - private function getResource(App_Controller_Request $request, $res) { - // get the previous command and its execution status - $cmd_str = $request->getProperty("cmd"); - $previous = $request->getLastCommand(); - $status = $previous->getStatus(); - if (!$status) { - $status = 0; - } - - $acquire = "get$res"; - // find resource for previous command and its status - $resource = $this->controllerMap->$acquire($cmd_str, $status); - // alternatively find resource for command and status 0 - if (!$resource) { - $resource = $this->controllerMap->$acquire($cmd_str, 0); - } - // or command 'default' and command status - if (!$resource) { - $resource = $this->controllerMap->$acquire('default', $status); - } - // all else has failed get resource for 'default', status 0 - if (!$resource) { - $resource = $this->controllerMap->$acquire('default', 0); - } - return $resource; - } - - function getCommand(App_Controller_Request $request) { - $previous = $request->getLastCommand(); - if (!$previous) { - // this is first command for this request - $cmd = $request->getProperty("cmd"); - if (!$cmd) { - // no command property - using default - $request->setProperty("cmd", "default"); - return self::$default_cmd; - } - } else { - // a command has been run already in this request - $cmd = $this->getForward($request); - if (!$cmd) { - return null; - } - } - - // we now have a command name in $cmd - turn it into a Command object - $cmd_obj = $this->resolveCommand($cmd); - if (!$cmd_obj) { - throw new Exception("Couldn't resolve '$cmd'"); - } - - // Count the number of times the class has been accessed and check for circular forwarding - $cmd_class = get_class($cmd_obj); - if (isset($this->invoked[$cmd_class])) { - $this->invoked[$cmd_class]++; - } else { - $this->invoked[$cmd_class] = 1; - } - - if ($this->invoked[$cmd_class] > 1) { - throw new Exception("Circular forwarding"); - } - - // return the Command object - return $cmd_obj; - } - - function resolveCommand($cmd) { - $sep = "/"; - $cmd = str_replace(array(".", $sep), "", $cmd); - $classroot = $this->controllerMap->getClassroot($cmd); - $filepath = "App{$sep}Command{$sep}{$classroot}.php"; - $classname = "App_Command_{$classroot}"; - if (file_exists($filepath)) { - @require_once("$filepath"); - if (class_exists($classname)) { - $cmd_class = new ReflectionClass($classname); - if ($cmd_class->isSubClassOf( self::$base_cmd )) { - return $cmd_class->newInstance(); - } - } - } - return null; - } -} - +controllerMap = $map; + if (!self::$base_cmd) { + self::$base_cmd = new ReflectionClass("App_Command_Command"); + self::$default_cmd = new App_Command_DefaultCommand(); + } + } + + function getView(App_Controller_Request $request) { + $view = $this->getResource($request, "View"); + return $view; + } + + function getForward(App_Controller_Request $request) { + $forward = $this->getResource($request, "Forward"); + if ($forward) { + $request->setProperty("cmd", $forward); + } + return $forward; + } + + private function getResource(App_Controller_Request $request, $res) { + // get the previous command and its execution status + $cmd_str = $request->getProperty("cmd"); + $previous = $request->getLastCommand(); + $status = $previous->getStatus(); + if (!$status) { + $status = 0; + } + + $acquire = "get$res"; + // find resource for previous command and its status + $resource = $this->controllerMap->$acquire($cmd_str, $status); + // alternatively find resource for command and status 0 + if (!$resource) { + $resource = $this->controllerMap->$acquire($cmd_str, 0); + } + // or command 'default' and command status + if (!$resource) { + $resource = $this->controllerMap->$acquire('default', $status); + } + // all else has failed get resource for 'default', status 0 + if (!$resource) { + $resource = $this->controllerMap->$acquire('default', 0); + } + return $resource; + } + + function getCommand(App_Controller_Request $request) { + $previous = $request->getLastCommand(); + if (!$previous) { + // this is first command for this request + $cmd = $request->getProperty("cmd"); + if (!$cmd) { + // no command property - using default + $request->setProperty("cmd", "default"); + return self::$default_cmd; + } + } else { + // a command has been run already in this request + $cmd = $this->getForward($request); + if (!$cmd) { + return null; + } + } + + // we now have a command name in $cmd - turn it into a Command object + $cmd_obj = $this->resolveCommand($cmd); + if (!$cmd_obj) { + throw new Exception("Couldn't resolve '$cmd'"); + } + + // Count the number of times the class has been accessed and check for circular forwarding + $cmd_class = get_class($cmd_obj); + if (isset($this->invoked[$cmd_class])) { + $this->invoked[$cmd_class]++; + } else { + $this->invoked[$cmd_class] = 1; + } + + if ($this->invoked[$cmd_class] > 1) { + throw new Exception("Circular forwarding"); + } + + // return the Command object + return $cmd_obj; + } + + function resolveCommand($cmd) { + $sep = "/"; + $cmd = str_replace(array(".", $sep), "", $cmd); + $classroot = $this->controllerMap->getClassroot($cmd); + $filepath = "App{$sep}Command{$sep}{$classroot}.php"; + $classname = "App_Command_{$classroot}"; + if (file_exists($filepath)) { + @require_once("$filepath"); + if (class_exists($classname)) { + $cmd_class = new ReflectionClass($classname); + if ($cmd_class->isSubClassOf( self::$base_cmd )) { + return $cmd_class->newInstance(); + } + } + } + return null; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Controller/ApplicationHelper.php b/vaktliste/App/Controller/ApplicationHelper.php index 58a2922..dd4547d 100644 --- a/vaktliste/App/Controller/ApplicationHelper.php +++ b/vaktliste/App/Controller/ApplicationHelper.php @@ -1,110 +1,120 @@ -getOptions(); - - App_Base_SessionRegistry::instance(); - } - - private function getOptions() { - // $this->ensure( file_exists( $this->config ), "Could not find options file" ); - // $options = @SimpleXml_load_file( $this->config ); - // $this->ensure( $options instanceof SimpleXMLElement, "Could not resolve options file" ); - // $dsn = (string)$options->dsn; - include("../inside/credentials.php"); - $dsn = getDSN("PDO"); - $this->ensure($dsn, "No DSN found"); - App_Base_ApplicationRegistry::setDSN($dsn); - - $map = new App_Controller_ControllerMap(); - //foreach ($options->control->view as $default_view) { - // $stat_str = trim($default_view['status']); - // $status = App_Command_Command::statuses($stat_str); - // $map->addView('default', $status, (string)$default_view); - //} - //foreach ( $options->control->command as $command_view ) { - // $command = trim((string)$command_view['name'] ); - // if ( $command_view->classalias ) { - // $classroot = trim((string)$command_view->classalias['name']); - // $map->addClassroot( $command, $classroot ); - // } - // if ( $command_view->view ) { - // $view = trim((string)$command_view->view); - // $forward = trim((string)$command_view->forward); - // $map->addView( $command, 0, $view ); - // if ( $forward ) { - // $map->addForward( $command, 0, $forward ); - // } - // foreach( $command_view->status as $command_view_status ) { - // $view = trim((string)$command_view_status->view); - // $forward = trim((string)$command_view_status->forward); - // $stat_str = trim($command_view_status['value']); - // $status = App_Command_Command::statuses( $stat_str ); - // if ( $view ) { - // $map->addView( $command, $status, $view ); - // } - // if ( $forward ) { - // $map->addForward( $command, $status, $forward ); - // } - // } - // } - //} - - // Default view - $status = App_Command_Command::statuses(); - $map->addView("default", $status, "login"); - $status = App_Command_Command::statuses("CMD_OK"); - $map->addView("default", $status, "calendar"); - $status = App_Command_Command::statuses("CMD_ERROR"); - $map->addView("default", $status, "error"); - - $map->addClassroot("login", "Login"); - $status = App_Command_Command::statuses(); - $map->addView("login", $status, "login"); - $status = App_Command_Command::statuses("CMD_OK"); - $map->addView("login", $status, "calendar"); - - $map->addClassroot("logout", "Logout"); - //$map->addClassroot("logout", "Logout"); - - App_Base_ApplicationRegistry::setControllerMap($map); - - $appCtrl = new App_Controller_AppController(App_Base_ApplicationRegistry::getControllerMap()); - App_Base_ApplicationRegistry::setApplicationController($appCtrl); - - $manager = new App_Controller_AccessManager(); - App_Base_ApplicationRegistry::setAccessManager($manager); - - $pageTitle = "Det Norske Studentersamfund - vaktliste"; - App_Base_ApplicationRegistry::setPageTitle($pageTitle); - - } - - - - - private function ensure ($expr, $message) { - if (!$expr) { - throw new Exception($message); - } - } -} - +getOptions(); + + App_Base_SessionRegistry::instance(); + } + + private function getOptions() { + // $this->ensure( file_exists( $this->config ), "Could not find options file" ); + // $options = @SimpleXml_load_file( $this->config ); + // $this->ensure( $options instanceof SimpleXMLElement, "Could not resolve options file" ); + // $dsn = (string)$options->dsn; + include("../inside/credentials.php"); + $dsn = getDSN("PDO"); + $this->ensure($dsn, "No DSN found"); + App_Base_ApplicationRegistry::setDSN($dsn); + + $map = new App_Controller_ControllerMap(); + //foreach ($options->control->view as $default_view) { + // $stat_str = trim($default_view['status']); + // $status = App_Command_Command::statuses($stat_str); + // $map->addView('default', $status, (string)$default_view); + //} + //foreach ( $options->control->command as $command_view ) { + // $command = trim((string)$command_view['name'] ); + // if ( $command_view->classalias ) { + // $classroot = trim((string)$command_view->classalias['name']); + // $map->addClassroot( $command, $classroot ); + // } + // if ( $command_view->view ) { + // $view = trim((string)$command_view->view); + // $forward = trim((string)$command_view->forward); + // $map->addView( $command, 0, $view ); + // if ( $forward ) { + // $map->addForward( $command, 0, $forward ); + // } + // foreach( $command_view->status as $command_view_status ) { + // $view = trim((string)$command_view_status->view); + // $forward = trim((string)$command_view_status->forward); + // $stat_str = trim($command_view_status['value']); + // $status = App_Command_Command::statuses( $stat_str ); + // if ( $view ) { + // $map->addView( $command, $status, $view ); + // } + // if ( $forward ) { + // $map->addForward( $command, $status, $forward ); + // } + // } + // } + //} + + // Default view + $status = App_Command_Command::statuses(); + $map->addView("default", $status, "login"); + $status = App_Command_Command::statuses("CMD_OK"); + //$map->addView("default", $status, ""); + $status = App_Command_Command::statuses("CMD_ERROR"); + $map->addView("default", $status, "error"); + + $map->addClassroot("login", "Login"); + $status = App_Command_Command::statuses(); + $map->addView("login", $status, "login"); + $status = App_Command_Command::statuses("CMD_OK"); + $map->addForward("login", $status, "view-calendar"); + + $map->addClassroot("logout", "Logout"); + //$map->addClassroot("logout", "Logout"); + + $map->addClassroot("add-shift", "AddShift"); + $status = App_Command_Command::statuses(); + $map->addView("add-shift", $status, "view-shift"); + $status = App_Command_Command::statuses("CMD_OK"); + $map->addForward("add-shift", $status, "view-calendar"); + + $map->addClassroot("view-shift", "GetShift"); + $map->addView("view-shift", App_Command_Command::statuses(), "view-shift"); + + $map->addClassroot("view-calendar", "ViewCalendar"); + $status = App_Command_Command::statuses(); + $map->addView("view-calendar", $status, "calendar"); + + App_Base_ApplicationRegistry::setControllerMap($map); + + $appCtrl = new App_Controller_AppController(App_Base_ApplicationRegistry::getControllerMap()); + App_Base_ApplicationRegistry::setApplicationController($appCtrl); + + $manager = new App_Controller_AccessManager(); + App_Base_ApplicationRegistry::setAccessManager($manager); + + $pageTitle = "Det Norske Studentersamfund - vaktliste"; + App_Base_ApplicationRegistry::setPageTitle($pageTitle); + + } + + private function ensure ($expr, $message) { + if (!$expr) { + throw new Exception($message); + } + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Controller/Controller.php b/vaktliste/App/Controller/Controller.php index 3fc6c3d..ff5cc3a 100644 --- a/vaktliste/App/Controller/Controller.php +++ b/vaktliste/App/Controller/Controller.php @@ -1,34 +1,36 @@ -init(); - $instance->handleRequest(); - } - - public function init() { - $this->applicationHelper = App_Controller_ApplicationHelper::instance(); - $this->applicationHelper->init(); - } - - public function handleRequest() { - $request = new App_Controller_Request(); - $app_c = App_Base_ApplicationRegistry::getApplicationController(); - while ($cmd = $app_c->getCommand($request)) { - $cmd->execute($request); - } - $this->invokeView($app_c->getView($request)); - } - - function invokeView($target) { - include("App/View/$target.php"); - exit; - } -} - +init(); + $instance->handleRequest(); + } + + public function init() { + $this->applicationHelper = App_Controller_ApplicationHelper::instance(); + $this->applicationHelper->init(); + } + + public function handleRequest() { + $request = new App_Controller_Request(); + $app_c = App_Base_ApplicationRegistry::getApplicationController(); + while ($cmd = $app_c->getCommand($request)) { + $cmd->execute($request); + } + // store modifications to database + App_Domain_ObjectWatcher::instance()->performOperations(); + $this->invokeView($app_c->getView($request)); + } + + function invokeView($target) { + include("App/View/$target.php"); + exit; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Controller/ControllerMap.php b/vaktliste/App/Controller/ControllerMap.php index bf29a8c..69ee803 100644 --- a/vaktliste/App/Controller/ControllerMap.php +++ b/vaktliste/App/Controller/ControllerMap.php @@ -1,42 +1,42 @@ -classrootMap[$command] = $classroot; - } - - function getClassroot ($command) { - if (isset ($this->classrootMap[$command])) { - return $this->classrootMap[$command]; - } - return $command; - } - - function addView ($command = "default", $status = 0, $view) { - $this->viewMap[$command][$status] = $view; - } - - function getView ($command, $status) { - if (isset ($this->viewMap[$command][$status])) { - return $this->viewMap[$command][$status]; - } - return null; - } - - function addForward ($command, $status = 0, $newCommand) { - $this->forwardMap[$command][$status] = $newCommand; - } - - function getForward ($command, $status) { - if (isset ($this->forwardMap[$command][$status])) { - return $this->forwardMap[$command][$status]; - } - return null; - } -} - +classrootMap[$command] = $classroot; + } + + function getClassroot ($command) { + if (isset ($this->classrootMap[$command])) { + return $this->classrootMap[$command]; + } + return $command; + } + + function addView ($command = "default", $status = 0, $view) { + $this->viewMap[$command][$status] = $view; + } + + function getView ($command, $status) { + if (isset ($this->viewMap[$command][$status])) { + return $this->viewMap[$command][$status]; + } + return null; + } + + function addForward ($command, $status = 0, $newCommand) { + $this->forwardMap[$command][$status] = $newCommand; + } + + function getForward ($command, $status) { + if (isset ($this->forwardMap[$command][$status])) { + return $this->forwardMap[$command][$status]; + } + return null; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Controller/Request.php b/vaktliste/App/Controller/Request.php index 6d9e036..0b9ef01 100644 --- a/vaktliste/App/Controller/Request.php +++ b/vaktliste/App/Controller/Request.php @@ -1,75 +1,75 @@ -init(); - App_Base_RequestRegistry::setRequest($this); - } - - function init() { - if (isset($_SERVER['REQUEST_METHOD'])) { - if ($_SERVER['REQUEST_METHOD']) { - $this->properties = $_REQUEST; - return; - } - } - - foreach($_SERVER['argv'] as $arg) { - if (strpos($arg, '=')) { - list($key, $val) = explode("=", $arg); - $this->setProperty($key, $val); - } - } - } - - function getProperty($key) { - if (isset ($this->properties[$key])) { - return $this->properties[$key]; - } - return null; - } - - function setProperty($key, $val) { - $this->properties[$key] = $val; - } - - function addFeedback($msg) { - array_push($this->feedback, $msg); - } - - function getFeedback() { - return $this->feedback; - } - - function getFeedbackString ($separator="\n") { - return implode($separator, $this->feedback); - } - - function setObject( $name, $object ) { - $this->objects[$name] = $object; - } - - function getObject( $name ) { - if ( isset( $this->objects[$name] ) ) { - return $this->objects[$name]; - } - return null; - } - - function setCommand (App_Command_Command $cmd) { - return $this->command = $cmd; - } - - function getLastCommand () { - return $this->command; - } -} +init(); + App_Base_RequestRegistry::setRequest($this); + } + + function init() { + if (isset($_SERVER['REQUEST_METHOD'])) { + if ($_SERVER['REQUEST_METHOD']) { + $this->properties = $_REQUEST; + return; + } + } + + foreach($_SERVER['argv'] as $arg) { + if (strpos($arg, '=')) { + list($key, $val) = explode("=", $arg); + $this->setProperty($key, $val); + } + } + } + + function getProperty($key) { + if (isset ($this->properties[$key])) { + return $this->properties[$key]; + } + return null; + } + + function setProperty($key, $val) { + $this->properties[$key] = $val; + } + + function addFeedback($msg) { + array_push($this->feedback, $msg); + } + + function getFeedback() { + return $this->feedback; + } + + function getFeedbackString($separator="\n") { + return implode($separator, $this->feedback); + } + + function setObject($name, $object) { + $this->objects[$name] = $object; + } + + function getObject($name) { + if ( isset( $this->objects[$name] ) ) { + return $this->objects[$name]; + } + return null; + } + + function setCommand (App_Command_Command $cmd) { + return $this->command = $cmd; + } + + function getLastCommand () { + return $this->command; + } +} ?> \ No newline at end of file diff --git a/vaktliste/App/Domain/Division.php b/vaktliste/App/Domain/Division.php index 3522413..25dac9e 100644 --- a/vaktliste/App/Domain/Division.php +++ b/vaktliste/App/Domain/Division.php @@ -1,47 +1,47 @@ -name = $name; - $this->markDirty(); - } - - function getName() { - return $this->name; - } - - function setNiceName($niceName) { - $this->niceName = $niceName; - $this->markDirty(); - } - - function getNiceName() { - return $this->niceName; - } - - function setHidden($hidden) { - $this->hidden = $hidden; - $this->markDirty(); - } - - function getHidden() { - return $this->hidden; - } - -} - -?> +name = $name; + $this->markDirty(); + } + + function getName() { + return $this->name; + } + + function setNiceName($niceName) { + $this->niceName = $niceName; + $this->markDirty(); + } + + function getNiceName() { + return $this->niceName; + } + + function setHidden($hidden) { + $this->hidden = $hidden; + $this->markDirty(); + } + + function getHidden() { + return $this->hidden; + } + +} + +?> diff --git a/vaktliste/App/Domain/DomainObject.php b/vaktliste/App/Domain/DomainObject.php index a6526cb..f0e081c 100644 --- a/vaktliste/App/Domain/DomainObject.php +++ b/vaktliste/App/Domain/DomainObject.php @@ -1,63 +1,63 @@ -markNew(); - } else { - $this->id = $id; - } - } - - function markNew() { - App_Domain_ObjectWatcher::addNew($this); - } - - function markDeleted() { - App_Domain_ObjectWatcher::addDelete($this); - } - - function markDirty() { - App_Domain_ObjectWatcher::addDirty($this); - } - - function markClean() { - App_Domain_ObjectWatcher::addClean($this); - } - - function setId($id) { - $this->id = $id; - } - - function getId() { - return $this->id; - } - - function collection() { - return self::getCollection(get_class($this)); - } - - static function getCollection($type) { - return App_Domain_HelperFactory::getCollection($type); - } - - function finder() { - return self::getFinder(get_class($this)); - } - - static function getFinder($type) { - return App_Domain_HelperFactory::getFinder($type); - } - -} - +markNew(); + } else { + $this->id = $id; + } + } + + function markNew() { + App_Domain_ObjectWatcher::addNew($this); + } + + function markDeleted() { + App_Domain_ObjectWatcher::addDelete($this); + } + + function markDirty() { + App_Domain_ObjectWatcher::addDirty($this); + } + + function markClean() { + App_Domain_ObjectWatcher::addClean($this); + } + + function setId($id) { + $this->id = $id; + } + + function getId() { + return $this->id; + } + + function collection() { + return self::getCollection(get_class($this)); + } + + static function getCollection($type) { + return App_Domain_HelperFactory::getCollection($type); + } + + function finder() { + return self::getFinder(get_class($this)); + } + + static function getFinder($type) { + return App_Domain_HelperFactory::getFinder($type); + } + +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Domain/Group.php b/vaktliste/App/Domain/Group.php index c531ec4..9f8344f 100644 --- a/vaktliste/App/Domain/Group.php +++ b/vaktliste/App/Domain/Group.php @@ -1,67 +1,73 @@ -name = $name; - $this->markDirty(); - } - - function getName() { - return $this->name; - } - - function setText($text) { - $this->text = $text; - $this->markDirty(); - } - - function getText() { - return $this->text; - } - - function setDivision(App_Domain_Division $division) { - $this->division = $division; - $this->markDirty(); - } - - function getDivision() { - return $this->division; - } - - function setAdmin($admin) { - $this->admin = $admin; - $this->markDirty(); - } - - function getAdmin() { - return $this->admin; - } - - function setMailinglist($mailinglist) { - $this->mailinglist = $mailinglist; - $this->markDirty(); - } - - function getMailinglist() { - return $this->mailinglist; - } - -} - -?> +name = $name; + $this->markDirty(); + } + + function getName() { + return $this->name; + } + + function setText($text) { + $this->text = $text; + $this->markDirty(); + } + + function getText() { + return $this->text; + } + + function setDivision($division) { + // check if division is an instance of App_Domain_Division + if (!is_null($division)) { + if (!($division instanceof App_Domain_Division)) { + throw new Exception("Division must be an instance of division class or null"); + } + } + $this->division = $division; + $this->markDirty(); + } + + function getDivision() { + return $this->division; + } + + function setAdmin($admin) { + $this->admin = $admin; + $this->markDirty(); + } + + function getAdmin() { + return $this->admin; + } + + function setMailinglist($mailinglist) { + $this->mailinglist = $mailinglist; + $this->markDirty(); + } + + function getMailinglist() { + return $this->mailinglist; + } + +} + +?> diff --git a/vaktliste/App/Domain/HelperFactory.php b/vaktliste/App/Domain/HelperFactory.php index f65a8b0..3ad50c1 100644 --- a/vaktliste/App/Domain/HelperFactory.php +++ b/vaktliste/App/Domain/HelperFactory.php @@ -1,66 +1,71 @@ - \ No newline at end of file diff --git a/vaktliste/App/Domain/Location.php b/vaktliste/App/Domain/Location.php index 97e9090..e27cc6f 100644 --- a/vaktliste/App/Domain/Location.php +++ b/vaktliste/App/Domain/Location.php @@ -1,27 +1,27 @@ -name = $name; - $this->markDirty(); - } - - function getName() { - return $this->name; - } - -} - -?> +name = $name; + $this->markDirty(); + } + + function getName() { + return $this->name; + } + +} + +?> diff --git a/vaktliste/App/Domain/ObjectWatcher.php b/vaktliste/App/Domain/ObjectWatcher.php index 85e26f5..951399f 100644 --- a/vaktliste/App/Domain/ObjectWatcher.php +++ b/vaktliste/App/Domain/ObjectWatcher.php @@ -1,112 +1,112 @@ -getId(); - return $key; - } - - static function add(App_Domain_DomainObject $obj) { - $inst = self::instance(); - $inst->all[$inst->globalKey($obj)] = $obj; - } - - static function exists($classname, $id) { - $inst = self::instance(); - $key = "$classname.$id"; - if (isset($inst->all[$key])) { - return $inst->all[$key]; - } - return null; - } - - static function addDirty(App_Domain_DomainObject $obj) { - $inst = self::instance(); - // verify that the updated object is an object allready in the database - if (!in_array($obj, $inst->new, true)) { - $inst->dirty[$inst->globalKey($obj)] = $obj; - } - } - - static function addNew(App_Domain_DomainObject $obj) { - $inst = self::instance(); - // we don't yet have an id - $inst->new[] = $obj; - } - - /* - * Mark object as clean, changes will not be stored to database - */ - static function addClean(App_Domain_DomainObject $obj) { - $inst = self::instance(); - - unset($inst->dirty[$inst->globalKey($obj)]); - - // check if the object is in the new array, and remove it from it - if (in_array($obj, $inst->new, true)) { - $pruned=array(); - foreach ($inst->new as $newobj) { - if (!($newobj === $obj)) { - $pruned[] = $newobj; - } - } - $inst->new = $pruned; - } - } - - static function addDelete(App_Domain_DomainObject $obj) { - $inst = self::instance(); - - unset($inst->dirty[$inst->globalKey($obj)]); - - if (in_array($obj, $inst->new, true)) { - $pruned=array(); - foreach ($inst->new as $newobj) { - if (!($newobj === $obj)) { - $pruned[] = $newobj; - } - } - $inst->new = $pruned; - } - - $inst->delete[] = $obj; - } - - function performOperations() { - foreach ($this->dirty as $key=>$obj) { - $obj->finder()->update($obj); - } - foreach ($this->new as $key=>$obj) { - $obj->finder()->insert($obj); - } - foreach ($this->delete as $key=>$obj) { - //$obj->finder()->delete($obj); - } - $this->dirty = array(); - $this->new = array(); - $this->delete = array(); - } -} - +getId(); + return $key; + } + + static function add(App_Domain_DomainObject $obj) { + $inst = self::instance(); + $inst->all[$inst->globalKey($obj)] = $obj; + } + + static function exists($classname, $id) { + $inst = self::instance(); + $key = "$classname.$id"; + if (isset($inst->all[$key])) { + return $inst->all[$key]; + } + return null; + } + + static function addDirty(App_Domain_DomainObject $obj) { + $inst = self::instance(); + // verify that the updated object is an object allready in the database + if (!in_array($obj, $inst->new, true)) { + $inst->dirty[$inst->globalKey($obj)] = $obj; + } + } + + static function addNew(App_Domain_DomainObject $obj) { + $inst = self::instance(); + // we don't yet have an id + $inst->new[] = $obj; + } + + /* + * Mark object as clean, changes will not be stored to database + */ + static function addClean(App_Domain_DomainObject $obj) { + $inst = self::instance(); + + unset($inst->dirty[$inst->globalKey($obj)]); + + // check if the object is in the new array, and remove it from it + if (in_array($obj, $inst->new, true)) { + $pruned=array(); + foreach ($inst->new as $newobj) { + if (!($newobj === $obj)) { + $pruned[] = $newobj; + } + } + $inst->new = $pruned; + } + } + + static function addDelete(App_Domain_DomainObject $obj) { + $inst = self::instance(); + + unset($inst->dirty[$inst->globalKey($obj)]); + + if (in_array($obj, $inst->new, true)) { + $pruned=array(); + foreach ($inst->new as $newobj) { + if (!($newobj === $obj)) { + $pruned[] = $newobj; + } + } + $inst->new = $pruned; + } + + $inst->delete[] = $obj; + } + + function performOperations() { + foreach ($this->dirty as $key=>$obj) { + $obj->finder()->update($obj); + } + foreach ($this->new as $key=>$obj) { + $obj->finder()->insert($obj); + } + foreach ($this->delete as $key=>$obj) { + //$obj->finder()->delete($obj); + } + $this->dirty = array(); + $this->new = array(); + $this->delete = array(); + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Domain/User.php b/vaktliste/App/Domain/User.php index de18858..40f04b3 100644 --- a/vaktliste/App/Domain/User.php +++ b/vaktliste/App/Domain/User.php @@ -1,170 +1,170 @@ -username = $username_s; - $this->markDirty(); - } - - function getUsername() { - return $this->username; - } - - function setPassword($password_s) { - $this->password = $password_s; - $this->markDirty(); - } - - function getPassword() { - return $this->password; - } - - function setFirstname($firstname_s) { - $this->firstname = $firstname_s; - $this->markDirty(); - } - - function getFirstname() { - return $this->firstname; - } - - function setLastname($lastname_s) { - $this->lastname = $lastname_s; - $this->markDirty(); - } - - function getLastname() { - return $this->lastname; - } - - function getName($separator = " ") { - return $this->getFirstname() . $separator . $this->getLastname(); - } - - function setValidaddress($validaddress_i) { - $this->validaddress = $validaddress_i; - $this->markDirty(); - } - - function getValidaddress() { - return $this->validaddress; - } - - function setEmail($email_s) { - $this->email = $email_s; - $this->markDirty(); - } - - function getEmail() { - return $this->email; - } - - function setBirthdate($birthdate_d) { - $this->birthdate = $birthdate_d; - $this->markDirty(); - } - - function getBirthdate() { - return $this->birthdate; - } - - function setPlaceOfStudy($placeofstudy_i) { - $this->placeOfStudy = $placeofstudy_i; - $this->markDirty(); - } - - function getPlaceOfStudy() { - return $this->placeOfStudy; - } - - function setPasswordreset($passwordreset_i) { - $this->passwordreset = $passwordreset_i; - $this->markDirty(); - } - - function getPasswordreset() { - return $this->passwordreset; - } - - function setDivisionIdRequest($divisionidrequest_i) { - $this->divisionIdRequest = $divisionidrequest_i; - $this->markDirty(); - } - - function getDivisionIdRequest() { - return $this->divisionIdRequest; - } - - function getUpdates() { - if (is_null($this->updates)) { - $this->updates = self::getFinder("App_Domain_UserUpdate")->findByUserId($this->getId()); - } - return $this->updates; - } - - function getAddress() { - if (is_null($this->address)) { - $this->address = self::getFinder("App_Domain_UserAddress")->findByUserId($this->getId()); - } - return $this->address; - } - - function getMemberships() { - if (is_null($this->memberships)) { - $this->memberships = self::getFinder("App_Domain_Membership")->findByUserId($this->getId()); - } - return $this->memberships; - } - - function getCards() { - if (is_null($this->cards)) { - $this->cards = self::getFinder("App_Domain_MembershipCard")->findByUserId($this->getId()); - } - return $this->cards; - } - - function getWorkShifts() { - if (is_null($this->workShifts)) { - $this->workShifts = self::getFinder("App_Domain_WorkShiftWorkers")->findByUserId($this->getId()); - } - return $this->workShifts; - } - - function getGroups() { - if (is_null($this->groups)) { - $this->groups = self::getFinder("App_Domain_Groups")->findByUserId($this->getId()); - } - return $this->groups; - } - -} - +username = $username_s; + $this->markDirty(); + } + + function getUsername() { + return $this->username; + } + + function setPassword($password_s) { + $this->password = $password_s; + $this->markDirty(); + } + + function getPassword() { + return $this->password; + } + + function setFirstname($firstname_s) { + $this->firstname = $firstname_s; + $this->markDirty(); + } + + function getFirstname() { + return $this->firstname; + } + + function setLastname($lastname_s) { + $this->lastname = $lastname_s; + $this->markDirty(); + } + + function getLastname() { + return $this->lastname; + } + + function getName($separator = " ") { + return $this->getFirstname() . $separator . $this->getLastname(); + } + + function setValidaddress($validaddress_i) { + $this->validaddress = $validaddress_i; + $this->markDirty(); + } + + function getValidaddress() { + return $this->validaddress; + } + + function setEmail($email_s) { + $this->email = $email_s; + $this->markDirty(); + } + + function getEmail() { + return $this->email; + } + + function setBirthdate($birthdate_d) { + $this->birthdate = $birthdate_d; + $this->markDirty(); + } + + function getBirthdate() { + return $this->birthdate; + } + + function setPlaceOfStudy($placeofstudy_i) { + $this->placeOfStudy = $placeofstudy_i; + $this->markDirty(); + } + + function getPlaceOfStudy() { + return $this->placeOfStudy; + } + + function setPasswordreset($passwordreset_i) { + $this->passwordreset = $passwordreset_i; + $this->markDirty(); + } + + function getPasswordreset() { + return $this->passwordreset; + } + + function setDivisionIdRequest($divisionidrequest_i) { + $this->divisionIdRequest = $divisionidrequest_i; + $this->markDirty(); + } + + function getDivisionIdRequest() { + return $this->divisionIdRequest; + } + + function getUpdates() { + if (is_null($this->updates)) { + $this->updates = self::getFinder("App_Domain_UserUpdate")->findByUserId($this->getId()); + } + return $this->updates; + } + + function getAddress() { + if (is_null($this->address)) { + $this->address = self::getFinder("App_Domain_UserAddress")->findByUserId($this->getId()); + } + return $this->address; + } + + function getMemberships() { + if (is_null($this->memberships)) { + $this->memberships = self::getFinder("App_Domain_Membership")->findByUserId($this->getId()); + } + return $this->memberships; + } + + function getCards() { + if (is_null($this->cards)) { + $this->cards = self::getFinder("App_Domain_MembershipCard")->findByUserId($this->getId()); + } + return $this->cards; + } + + function getWorkShifts() { + if (is_null($this->workShifts)) { + $this->workShifts = self::getFinder("App_Domain_WorkShiftWorkers")->findByUserId($this->getId()); + } + return $this->workShifts; + } + + function getGroups() { + if (is_null($this->groups)) { + $this->groups = self::getFinder("App_Domain_Groups")->findByUserId($this->getId()); + } + return $this->groups; + } + +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Domain/UserPhone.php b/vaktliste/App/Domain/UserPhone.php index e77f332..8673eec 100644 --- a/vaktliste/App/Domain/UserPhone.php +++ b/vaktliste/App/Domain/UserPhone.php @@ -1,38 +1,38 @@ -user = $user; - $this->markDirty(); - } - - function getUser() { - return $this->user; - } - - function setPhone($phone) { - $this->phone = $phone; - $this->markDirty(); - } - - function getPhone() { - return $this->phone; - } - -} - +user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setPhone($phone) { + $this->phone = $phone; + $this->markDirty(); + } + + function getPhone() { + return $this->phone; + } + +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Domain/WorkSalaryType.php b/vaktliste/App/Domain/WorkSalaryType.php index d8e4202..8d6eed7 100644 --- a/vaktliste/App/Domain/WorkSalaryType.php +++ b/vaktliste/App/Domain/WorkSalaryType.php @@ -1,37 +1,37 @@ -title = $title; - $this->markDirty(); - } - - function getTitle() { - return $this->title; - } - - function setHourlyRate($hourlyRate) { - $this->hourlyRate = $hourlyRate; - $this->markDirty(); - } - - function getHourlyRate() { - return $this->hourlyRate; - } - -} - -?> +title = $title; + $this->markDirty(); + } + + function getTitle() { + return $this->title; + } + + function setHourlyRate($hourlyRate) { + $this->hourlyRate = $hourlyRate; + $this->markDirty(); + } + + function getHourlyRate() { + return $this->hourlyRate; + } + +} + +?> diff --git a/vaktliste/App/Domain/WorkShift.php b/vaktliste/App/Domain/WorkShift.php index 7245dd0..d5955b3 100644 --- a/vaktliste/App/Domain/WorkShift.php +++ b/vaktliste/App/Domain/WorkShift.php @@ -1,142 +1,142 @@ -starts = $starts; - $this->markDirty(); - } - - function getStarts() { - return $this->starts; - } - - function setEnds(DateTime $ends) { - $this->ends = $ends; - $this->markDirty(); - } - - function getEnds() { - return $this->ends; - } - - function setGroup(App_Domain_Group $group) { - $this->group = $group; - $this->markDirty(); - } - - function getGroup() { - return $this->group; - } - - function setLocation(App_Domain_Location $location) { - $this->location = $location; - $this->markDirty(); - } - - function getLocation() { - return $this->location; - } - - function setActive($active) { - $this->active = $active; - $this->markDirty(); - } - - function getActive() { - return $this->active; - } - - function setTitle($title) { - $this->title = $title; - $this->markDirty(); - } - - function getTitle() { - return $this->title; - } - - function setComment($comment) { - $this->comment = $comment; - $this->markDirty(); - } - - function getComment() { - return $this->comment; - } - - function setNumWorkers($numWorkers) { - $this->numWorkers = $numWorkers; - $this->markDirty(); - } - - function getNumWorkers() { - return $this->numWorkers; - } - - function setLocked($locked) { - $this->locked = $locked; - $this->markDirty(); - } - - function getLocked() { - return $this->locked; - } - - function setAutoassignWorkers($autoassignWorkers) { - $this->autoassignWorkers = $autoassignWorkers; - $this->markDirty(); - } - - function getAutoassignWorkers() { - return $this->autoassignWorkers; - } - - function setSalaryType(App_Domain_WorkSalaryType $salaryType) { - $this->salaryType = $salaryType; - $this->markDirty(); - } - - function getSalaryType() { - return $this->salaryType; - } - - function getWorkers() { - if (is_null($this->workers)) { - $this->workers = self::getFinder("App_Domain_WorkShiftWorkers")->findByShiftId($this->getId()); - } - return $this->workers; - } - - function getUpdates() { - if (is_null($this->updates)) { - $this->updates = self::getFinder("App_Domain_WorkShiftUpdates")->findByShiftId($this->getId()); - } - return $this->updates; - } - +starts = $starts; + $this->markDirty(); + } + + function getStarts() { + return $this->starts; + } + + function setEnds(DateTime $ends) { + $this->ends = $ends; + $this->markDirty(); + } + + function getEnds() { + return $this->ends; + } + + function setGroup(App_Domain_Group $group) { + $this->group = $group; + $this->markDirty(); + } + + function getGroup() { + return $this->group; + } + + function setLocation(App_Domain_Location $location) { + $this->location = $location; + $this->markDirty(); + } + + function getLocation() { + return $this->location; + } + + function setActive($active) { + $this->active = $active; + $this->markDirty(); + } + + function getActive() { + return $this->active; + } + + function setTitle($title) { + $this->title = $title; + $this->markDirty(); + } + + function getTitle() { + return $this->title; + } + + function setComment($comment) { + $this->comment = $comment; + $this->markDirty(); + } + + function getComment() { + return $this->comment; + } + + function setNumWorkers($numWorkers) { + $this->numWorkers = $numWorkers; + $this->markDirty(); + } + + function getNumWorkers() { + return $this->numWorkers; + } + + function setLocked($locked) { + $this->locked = $locked; + $this->markDirty(); + } + + function getLocked() { + return $this->locked; + } + + function setAutoassignWorkers($autoassignWorkers) { + $this->autoassignWorkers = $autoassignWorkers; + $this->markDirty(); + } + + function getAutoassignWorkers() { + return $this->autoassignWorkers; + } + + function setSalaryType(App_Domain_WorkSalaryType $salaryType) { + $this->salaryType = $salaryType; + $this->markDirty(); + } + + function getSalaryType() { + return $this->salaryType; + } + + function getWorkers() { + if (is_null($this->workers)) { + $this->workers = self::getFinder("App_Domain_WorkShiftWorkers")->findByShiftId($this->getId()); + } + return $this->workers; + } + + function getUpdates() { + if (is_null($this->updates)) { + $this->updates = self::getFinder("App_Domain_WorkShiftUpdates")->findByShiftId($this->getId()); + } + return $this->updates; + } + } \ No newline at end of file diff --git a/vaktliste/App/Domain/WorkShiftUpdate.php b/vaktliste/App/Domain/WorkShiftUpdate.php index eb4ea78..a29b72c 100644 --- a/vaktliste/App/Domain/WorkShiftUpdate.php +++ b/vaktliste/App/Domain/WorkShiftUpdate.php @@ -1,57 +1,57 @@ -shift = $shift; - $this->markDirty(); - } - - function getShift() { - return $this->shift; - } - - function setUpdateTime(DateTime $time) { - $this->updateTime = $time; - $this->markDirty(); - } - - function getUpdateTime() { - return $this->updateTime; - } - - function setUser(App_Domain_User $user) { - $this->user = $user; - $this->markDirty(); - } - - function getUser() { - return $this->user; - } - - function setUpdateText($updateText) { - $this->updateText = $updateText; - $this->markDirty(); - } - - function getUpdateText() { - return $this->updateText; - } - -} - -?> +shift = $shift; + $this->markDirty(); + } + + function getShift() { + return $this->shift; + } + + function setUpdateTime(DateTime $time) { + $this->updateTime = $time; + $this->markDirty(); + } + + function getUpdateTime() { + return $this->updateTime; + } + + function setUser(App_Domain_User $user) { + $this->user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setUpdateText($updateText) { + $this->updateText = $updateText; + $this->markDirty(); + } + + function getUpdateText() { + return $this->updateText; + } + +} + +?> diff --git a/vaktliste/App/Domain/WorkShiftWorker.php b/vaktliste/App/Domain/WorkShiftWorker.php index db2f13a..8659be8 100644 --- a/vaktliste/App/Domain/WorkShiftWorker.php +++ b/vaktliste/App/Domain/WorkShiftWorker.php @@ -1,76 +1,76 @@ -shift = $shift; - $this->markDirty(); - } - - function getShift() { - return $this->shift; - } - - function setUser(App_Domain_User $user) { - $this->user = $user; - $this->markDirty(); - } - - function getUser() { - return $this->user; - } - - function setAssigned($assigned) { - $this->assigned = $assigned; - $this->markDirty(); - } - - function getAssigned () { - return $this->assigned; - } - - function setNoShow($noShow) { - $this->noShow = $noShow; - $this->markDirty(); - } - - function getNoShow() { - return $this->noShow; - } - - function setUserComment($comment) { - $this->userComment = $comment; - $this->markDirty(); - } - - function getUserComment() { - return $this->userComment; - } - - function setEmployerComment($comment) { - $this->employerComment = $comment; - $this->markDirty(); - } - - function getEmployerComment() { - return $this->employerComment; - } -} - -?> +shift = $shift; + $this->markDirty(); + } + + function getShift() { + return $this->shift; + } + + function setUser(App_Domain_User $user) { + $this->user = $user; + $this->markDirty(); + } + + function getUser() { + return $this->user; + } + + function setAssigned($assigned) { + $this->assigned = $assigned; + $this->markDirty(); + } + + function getAssigned () { + return $this->assigned; + } + + function setNoShow($noShow) { + $this->noShow = $noShow; + $this->markDirty(); + } + + function getNoShow() { + return $this->noShow; + } + + function setUserComment($comment) { + $this->userComment = $comment; + $this->markDirty(); + } + + function getUserComment() { + return $this->userComment; + } + + function setEmployerComment($comment) { + $this->employerComment = $comment; + $this->markDirty(); + } + + function getEmployerComment() { + return $this->employerComment; + } +} + +?> diff --git a/vaktliste/App/Mapper/Collection.php b/vaktliste/App/Mapper/Collection.php index 1fdef3c..3fbd7d8 100644 --- a/vaktliste/App/Mapper/Collection.php +++ b/vaktliste/App/Mapper/Collection.php @@ -1,87 +1,87 @@ -rewind(); - $this->raw = $raw; - $this->total = count($raw); - } - $this->mapper = $mapper; - } - - /** - * Add an object to the collection - **/ - function add(App_Domain_DomainObject $object) { - $class = $this->targetClass(); - if (!($object instanceof $class)) { - throw new Exception("This is a {$class} collection"); - } - $this->notifyAccess(); - $this->objects[$this->total] = $object; - $this->total++; - } - - abstract function targetClass(); - - protected function notifyAccess() { - // something is coming here.. - } - - private function getRow($num) { - $this->notifyAccess(); - if ($num >= $this->total || $num < 0) { - return null; - } - if (isset($this->objects[$num])) { - return $this->objects[$num]; - } - if (isset($this->raw[$num])) { - // object has not been created yet - $this->objects[$num]=$this->mapper->createObject($this->raw[$num]); - return $this->objects[$num]; - } - } - - public function rewind() { - $this->pointer = 0; - } - - public function current() { - return $this->getRow($this->pointer); - } - - public function key() { - return $this->pointer; - } - - public function next() { - $row = $this->getRow($this->pointer); - if ($row) { - $this->pointer++; - } - return $row; - } - - public function valid() { - return (!is_null($this->current())); - } - -} - +rewind(); + $this->raw = $raw; + $this->total = count($raw); + } + $this->mapper = $mapper; + } + + /** + * Add an object to the collection + **/ + function add(App_Domain_DomainObject $object) { + $class = $this->targetClass(); + if (!($object instanceof $class)) { + throw new Exception("This is a {$class} collection"); + } + $this->notifyAccess(); + $this->objects[$this->total] = $object; + $this->total++; + } + + abstract function targetClass(); + + protected function notifyAccess() { + // something is coming here.. + } + + private function getRow($num) { + $this->notifyAccess(); + if ($num >= $this->total || $num < 0) { + return null; + } + if (isset($this->objects[$num])) { + return $this->objects[$num]; + } + if (isset($this->raw[$num])) { + // object has not been created yet + $this->objects[$num]=$this->mapper->createObject($this->raw[$num]); + return $this->objects[$num]; + } + } + + public function rewind() { + $this->pointer = 0; + } + + public function current() { + return $this->getRow($this->pointer); + } + + public function key() { + return $this->pointer; + } + + public function next() { + $row = $this->getRow($this->pointer); + if ($row) { + $this->pointer++; + } + return $row; + } + + public function valid() { + return (!is_null($this->current())); + } + +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/DivisionCollection.php b/vaktliste/App/Mapper/DivisionCollection.php index 97c4085..88c7755 100644 --- a/vaktliste/App/Mapper/DivisionCollection.php +++ b/vaktliste/App/Mapper/DivisionCollection.php @@ -1,15 +1,15 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/DivisionMapper.php b/vaktliste/App/Mapper/DivisionMapper.php index d3b64de..e4fadfa 100644 --- a/vaktliste/App/Mapper/DivisionMapper.php +++ b/vaktliste/App/Mapper/DivisionMapper.php @@ -1,93 +1,93 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM din_group WHERE id=?"); - $this->findByGroupIdStmt = self::$PDO->prepare( - "SELECT * FROM din_division INNER JOIN din_group ON din_division.id = din_group.division_id WHERE din_group.id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM din_division"); - $this->insertStmt = self::$PDO->prepare( - "INSERT INTO din_division ( - name, - nicename, - hidden - ) values (?)"); - $this->updateStmt = self::$PDO->prepare( - "UPDATE din_division SET - name=?, - nicename=?, - hidden=? - WHERE id=?"); - $this->deleteStmt = self::$PDO->prepare( - "DELETE FROM din_division WHERE id=?"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_Division($array["id"]); - - $obj->setName($array["name"]); - $obj->setNiceName($array["nicename"]); - $obj->setHidden($array["hidden"]); - - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getName()); - $this->insertStmt->bindValue(2, $object->getNiceName()); - $this->insertStmt->bindValue(3, $object->getHidden()); - - $this->insertStmt->execute(); - $id = self::$PDO->lastInsertId(); - $this->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getName()); - $this->insertStmt->bindValue(2, $object->getNiceName()); - $this->insertStmt->bindValue(3, $object->getHidden()); - $this->updateStmt->bindValue(4, $object->getId()); - - $this->updateStmt->execute(); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - $this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - return $this->deleteStmt; - } - - function getCollection(array $raw) { - return new App_Mapper_DivsionCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_Division"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM din_group WHERE id=?"); + $this->findByGroupIdStmt = self::$PDO->prepare( + "SELECT * FROM din_division INNER JOIN din_group ON din_division.id = din_group.division_id WHERE din_group.id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM din_division"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_division ( + name, + nicename, + hidden + ) values (?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_division SET + name=?, + nicename=?, + hidden=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_division WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_Division($array["id"]); + + $obj->setName($array["name"]); + $obj->setNiceName($array["nicename"]); + $obj->setHidden($array["hidden"]); + + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getName()); + $this->insertStmt->bindValue(2, $object->getNiceName()); + $this->insertStmt->bindValue(3, $object->getHidden()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getName()); + $this->insertStmt->bindValue(2, $object->getNiceName()); + $this->insertStmt->bindValue(3, $object->getHidden()); + $this->updateStmt->bindValue(4, $object->getId()); + + $this->updateStmt->execute(); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function getCollection(array $raw) { + return new App_Mapper_DivsionCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_Division"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/DomainObjectFactory.php b/vaktliste/App/Mapper/DomainObjectFactory.php index 99bbf44..8219487 100644 --- a/vaktliste/App/Mapper/DomainObjectFactory.php +++ b/vaktliste/App/Mapper/DomainObjectFactory.php @@ -1,7 +1,7 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/GroupCollection.php b/vaktliste/App/Mapper/GroupCollection.php index 57850fd..9135243 100644 --- a/vaktliste/App/Mapper/GroupCollection.php +++ b/vaktliste/App/Mapper/GroupCollection.php @@ -1,15 +1,15 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/GroupMapper.php b/vaktliste/App/Mapper/GroupMapper.php index fd73920..c82087b 100644 --- a/vaktliste/App/Mapper/GroupMapper.php +++ b/vaktliste/App/Mapper/GroupMapper.php @@ -1,119 +1,119 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM din_group WHERE id=?"); - $this->findByDivisionIdStmt = self::$PDO->prepare( - "SELECT * FROM din_group WHERE division_id=?"); - $this->findByUserIdStmt = self::$PDO->prepare( - "SELECT * FROM din_group INNER JOIN din_usergrouprelationship ON din_group.id = din_usergrouprelationship.group_id WHERE din_usergrouprelationship.user_id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM din_group"); - $this->insertStmt = self::$PDO->prepare( - "INSERT INTO din_group ( - name, - text, - division_id, - admin, - mailinglist - ) values (?)"); - $this->updateStmt = self::$PDO->prepare( - "UPDATE din_group SET - name=?, - text=?, - division_id=?, - admin=?, - mailinglist=? - WHERE id=?"); - $this->deleteStmt = self::$PDO->prepare( - "DELETE FROM din_group WHERE id=?"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_Group($array["id"]); - - $obj->setName($array["name"]); - $obj->setText($array["text"]); - $obj->setAdmin($array["admin"]); - $obj->setMailinglist($array["mailinglist"]); - - // find division and create division object - $division_mapper = new App_Domain_DivisionMapper(); - $division = $division_mapper->find($array["division_id"]); - $obj->setDivision($division); - - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getName()); - $this->insertStmt->bindValue(2, $object->getText()); - $this->insertStmt->bindValue(3, $object->getDivision()->getId()); - $this->insertStmt->bindValue(4, $object->getAdmin()); - $this->insertStmt->bindValue(5, $object->getMailinglist()); - - $this->insertStmt->execute(); - $id = self::$PDO->lastInsertId(); - $this->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getName()); - $this->insertStmt->bindValue(2, $object->getText()); - $this->insertStmt->bindValue(3, $object->getDivision()->getId()); - $this->insertStmt->bindValue(4, $object->getAdmin()); - $this->insertStmt->bindValue(5, $object->getMailinglist()); - $this->updateStmt->bindValue(6, $object->getId()); - - $this->updateStmt->execute(); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - $this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - return $this->deleteStmt; - } - - function findByDivisionId($division_id) { - $this->findByDivisionIdStmt->execute(array($division_id)); - return new App_Mapper_WorkShiftCollection($this->findByDivisionIdStmt->fetchAll(), $this); - } - - function findByUserId($user_id) { - $this->findByUserIdStmt->execute(array($user_id)); - return new App_Mapper_GroupCollection($this->findByUserIdStmt->fetchAll(), $this); - } - - function getCollection(array $raw) { - return new App_Mapper_GroupCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_Group"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM din_group WHERE id=?"); + $this->findByDivisionIdStmt = self::$PDO->prepare( + "SELECT * FROM din_group WHERE division_id=?"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT * FROM din_group INNER JOIN din_usergrouprelationship ON din_group.id = din_usergrouprelationship.group_id WHERE din_usergrouprelationship.user_id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM din_group"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO din_group ( + name, + text, + division_id, + admin, + mailinglist + ) values (?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE din_group SET + name=?, + text=?, + division_id=?, + admin=?, + mailinglist=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM din_group WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_Group($array["id"]); + + $obj->setName($array["name"]); + $obj->setText($array["text"]); + $obj->setAdmin($array["admin"]); + $obj->setMailinglist($array["mailinglist"]); + + // find division and create division object + $division_mapper = new App_Mapper_DivisionMapper(); + $division = $division_mapper->find($array["division_id"]); + $obj->setDivision($division); + + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getName()); + $this->insertStmt->bindValue(2, $object->getText()); + $this->insertStmt->bindValue(3, $object->getDivision()->getId()); + $this->insertStmt->bindValue(4, $object->getAdmin()); + $this->insertStmt->bindValue(5, $object->getMailinglist()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getName()); + $this->insertStmt->bindValue(2, $object->getText()); + $this->insertStmt->bindValue(3, $object->getDivision()->getId()); + $this->insertStmt->bindValue(4, $object->getAdmin()); + $this->insertStmt->bindValue(5, $object->getMailinglist()); + $this->updateStmt->bindValue(6, $object->getId()); + + $this->updateStmt->execute(); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function findByDivisionId($division_id) { + $this->findByDivisionIdStmt->execute(array($division_id)); + return new App_Mapper_WorkShiftCollection($this->findByDivisionIdStmt->fetchAll(), $this); + } + + function findByUserId($user_id) { + $this->findByUserIdStmt->execute(array($user_id)); + return new App_Mapper_GroupCollection($this->findByUserIdStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new App_Mapper_GroupCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_Group"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/LocationCollection.php b/vaktliste/App/Mapper/LocationCollection.php index cca9f8b..b3690ce 100644 --- a/vaktliste/App/Mapper/LocationCollection.php +++ b/vaktliste/App/Mapper/LocationCollection.php @@ -1,15 +1,15 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/LocationMapper.php b/vaktliste/App/Mapper/LocationMapper.php index 0f1ff55..7fce5cc 100644 --- a/vaktliste/App/Mapper/LocationMapper.php +++ b/vaktliste/App/Mapper/LocationMapper.php @@ -1,81 +1,81 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM lokaler WHERE id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM lokaler"); - $this->insertStmt = self::$PDO->prepare( - "INSERT INTO lokaler ( - navn - ) values (?)"); - $this->updateStmt = self::$PDO->prepare( - "UPDATE lokaler SET - navn=? - WHERE id=?"); - $this->deleteStmt = self::$PDO->prepare( - "DELETE FROM lokaler WHERE id=?"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_Location($array["id"]); - - $obj->setName($array["navn"]); - - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getName()); - - $this->insertStmt->execute(); - $id = self::$PDO->lastInsertId(); - $this->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getName()); - $this->updateStmt->bindValue(2, $object->getId()); - - $this->updateStmt->execute(); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - $this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - return $this->deleteStmt; - } - - function getCollection(array $raw) { - return new App_Mapper_LocationCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_Location"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM lokaler WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM lokaler"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO lokaler ( + navn + ) values (?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE lokaler SET + navn=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM lokaler WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_Location($array["id"]); + + $obj->setName($array["navn"]); + + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getName()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getName()); + $this->updateStmt->bindValue(2, $object->getId()); + + $this->updateStmt->execute(); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function getCollection(array $raw) { + return new App_Mapper_LocationCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_Location"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/Mapper.php b/vaktliste/App/Mapper/Mapper.php index 9d38b03..4d472d5 100644 --- a/vaktliste/App/Mapper/Mapper.php +++ b/vaktliste/App/Mapper/Mapper.php @@ -1,99 +1,99 @@ -getDSN("PDO"); - if (is_null($dsn)) { - throw new Exception("No DSN"); - } - try { - self::$PDO = new PDO($dsn["dsn"], $dsn["username"], $dsn["password"]); - self::$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } catch (Exception $e) { - throw new Exception("Database connection error: ". getDSN()); - } - } - } - - private function getFromMap($id) { - return App_Domain_ObjectWatcher::exists($this->targetClass(), $id); - } - - private function addToMap(App_Domain_DomainObject $obj) { - return App_Domain_ObjectWatcher::add($obj); - } - - function find($id) { - // check if object allready has been fetch from database - $old = $this->getFromMap($id); - if ($old) { - return $old; - } - - // get object from database - $this->selectStmt()->execute(array($id)); - $array = $this->selectStmt()->fetch(); - $this->selectStmt()->closeCursor(); - if (!is_array($array)) { - return null; - } - if (!isset($array['id'])) { - return null; - } - $object = $this->createObject($array); - $object->markClean(); - return $object; - } - - function findAll() { - $this->selectAllStmt()->execute(array()); - return $this->getCollection( $this->selectAllStmt()->fetchAll( PDO::FETCH_ASSOC ) ); - } - - function createObject($array) { - $old = $this->getFromMap($array['id']); - if ($old) { return $old; } - - // construct object - $obj = $this->doCreateObject($array); - - // add object to object watcher map - $this->addToMap($obj); - $obj->markClean(); - return $obj; - } - - function insert(App_Domain_DomainObject $obj) { - $this->doInsert($obj); - $this->addToMap($obj); - $obj->markClean(); - } - - function delete(App_Domain_DomainObject $obj) { - $this->doDelete($obj); - //$this->removeFromMap($obj); - } - - abstract function update(App_Domain_DomainObject $object); - protected abstract function doCreateObject(array $array); - protected abstract function doInsert(App_Domain_DomainObject $object); - protected abstract function doDelete(App_Domain_DomainObject $object); - protected abstract function targetClass(); - protected abstract function selectStmt(); - protected abstract function selectAllStmt(); - protected abstract function deleteStmt(); - abstract function getCollection(array $raw); -} - +getDSN("PDO"); + if (is_null($dsn)) { + throw new Exception("No DSN"); + } + try { + self::$PDO = new PDO($dsn["dsn"], $dsn["username"], $dsn["password"]); + self::$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } catch (Exception $e) { + throw new Exception("Database connection error: ". getDSN()); + } + } + } + + private function getFromMap($id) { + return App_Domain_ObjectWatcher::exists($this->targetClass(), $id); + } + + private function addToMap(App_Domain_DomainObject $obj) { + return App_Domain_ObjectWatcher::add($obj); + } + + function find($id) { + // check if object allready has been fetch from database + $old = $this->getFromMap($id); + if ($old) { + return $old; + } + + // get object from database + $this->selectStmt()->execute(array($id)); + $array = $this->selectStmt()->fetch(); + $this->selectStmt()->closeCursor(); + if (!is_array($array)) { + return null; + } + if (!isset($array['id'])) { + return null; + } + $object = $this->createObject($array); + $object->markClean(); + return $object; + } + + function findAll() { + $this->selectAllStmt()->execute(array()); + return $this->getCollection( $this->selectAllStmt()->fetchAll( PDO::FETCH_ASSOC ) ); + } + + function createObject($array) { + $old = $this->getFromMap($array['id']); + if ($old) { return $old; } + + // construct object + $obj = $this->doCreateObject($array); + + // add object to object watcher map + $this->addToMap($obj); + $obj->markClean(); + return $obj; + } + + function insert(App_Domain_DomainObject $obj) { + $this->doInsert($obj); + $this->addToMap($obj); + $obj->markClean(); + } + + function delete(App_Domain_DomainObject $obj) { + $this->doDelete($obj); + //$this->removeFromMap($obj); + } + + abstract function update(App_Domain_DomainObject $object); + protected abstract function doCreateObject(array $array); + protected abstract function doInsert(App_Domain_DomainObject $object); + protected abstract function doDelete(App_Domain_DomainObject $object); + protected abstract function targetClass(); + protected abstract function selectStmt(); + protected abstract function selectAllStmt(); + protected abstract function deleteStmt(); + abstract function getCollection(array $raw); +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/UserCollection.php b/vaktliste/App/Mapper/UserCollection.php index 2c3143d..dbb0f4b 100644 --- a/vaktliste/App/Mapper/UserCollection.php +++ b/vaktliste/App/Mapper/UserCollection.php @@ -1,14 +1,14 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/UserMapper.php b/vaktliste/App/Mapper/UserMapper.php index ef058c4..3f9f6cf 100644 --- a/vaktliste/App/Mapper/UserMapper.php +++ b/vaktliste/App/Mapper/UserMapper.php @@ -1,126 +1,126 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM din_user WHERE id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM din_user"); - //$this->updateStmt = self::$PDO->prepare( - // "UPDATE din_user SET - // username=?, - // password=?, - // firstname=?, - // lastname=?, - // addresstype='no', - // valid_address=?, - // email=?, - // birthdate=?, - // placeOfStudy=?, - // passwordReset=?, - // division_id_request=? - // WHERE id=?"); - //$this->insertStmt = self::$PDO->prepare( - // "INSERT INTO din_user ( - // cardno, username, password, firstname, lastname, addresstype, valid_address, email, birthdate, placeOfStudy, passwordReset, division_id_request - // ) values (?)"); - //$this->deleteStmt = self::$PDO->prepare( - // "DELETE FROM din_user WHERE id=?"); - $this->findByLoginStmt = self::$PDO->prepare( - "SELECT * FROM din_user WHERE username=? AND ( password=PASSWORD(?) or password=OLD_PASSWORD(?) )"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_User($array["id"]); - $obj->setUsername($array["username"]); - $obj->setPassword($array["password"]); - $obj->setFirstname($array["firstname"]); - $obj->setLastname($array["lastname"]); - $obj->setValidaddress($array["valid_address"]); - $obj->setEmail($array["email"]); - $obj->setBirthdate($array["birthdate"]); - $obj->setPlaceOfStudy($array["placeOfStudy"]); - $obj->setPasswordreset($array["passwordReset"]); - $obj->setDivisionIdRequest($array["division_id_request"]); - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $values = array($object->getUsername()); - throw new Excepetion("UserMapper::doInsert() failure: UserMapper is read only!"); - //$this->insertStmt->execute($values); - //$id = self::$PDO->lastInsertId(); - //$object->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $values = array( - $object->getUsername(), - $object->getPassword(), - $object->getFirstname(), - $object->getLastname(), - $object->getValidAddress(), - $object->getEmail(), - $object->getBirthdate(), - $object->getPlaceOfStudy(), - $object->getPasswordreset(), - $object->getDivisionIdRequest(), - $object->getId() - ); - throw new Excepetion("UserMapper:update() failure: UserMapper is read only!"); - //$this->updateStmt->execute($values); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - throw new Excepetion("UserMapper::doDelete() failure: UserMapper is read only!"); - //$this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - throw new Excepetion("UserMapper::deleteStmt() failure: UserMapper is read only!"); - //return $this->deleteStmt; - } - - function findByLogin($username, $password) { - $this->findByLoginStmt->execute(array($username, $password, $password)); - $array = $this->findByLoginStmt->fetch(); - $this->findByLoginStmt->closeCursor(); - if (!is_array($array)) { - return null; - } - if (!isset($array['id'])) { - return null; - } - return $this->createObject($array); - } - - function getCollection(array $raw) { - return new App_Mapper_UserCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_User"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM din_user WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM din_user"); + //$this->updateStmt = self::$PDO->prepare( + // "UPDATE din_user SET + // username=?, + // password=?, + // firstname=?, + // lastname=?, + // addresstype='no', + // valid_address=?, + // email=?, + // birthdate=?, + // placeOfStudy=?, + // passwordReset=?, + // division_id_request=? + // WHERE id=?"); + //$this->insertStmt = self::$PDO->prepare( + // "INSERT INTO din_user ( + // cardno, username, password, firstname, lastname, addresstype, valid_address, email, birthdate, placeOfStudy, passwordReset, division_id_request + // ) values (?)"); + //$this->deleteStmt = self::$PDO->prepare( + // "DELETE FROM din_user WHERE id=?"); + $this->findByLoginStmt = self::$PDO->prepare( + "SELECT * FROM din_user WHERE username=? AND ( password=PASSWORD(?) or password=OLD_PASSWORD(?) )"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_User($array["id"]); + $obj->setUsername($array["username"]); + $obj->setPassword($array["password"]); + $obj->setFirstname($array["firstname"]); + $obj->setLastname($array["lastname"]); + $obj->setValidaddress($array["valid_address"]); + $obj->setEmail($array["email"]); + $obj->setBirthdate($array["birthdate"]); + $obj->setPlaceOfStudy($array["placeOfStudy"]); + $obj->setPasswordreset($array["passwordReset"]); + $obj->setDivisionIdRequest($array["division_id_request"]); + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $values = array($object->getUsername()); + throw new Excepetion("UserMapper::doInsert() failure: UserMapper is read only!"); + //$this->insertStmt->execute($values); + //$id = self::$PDO->lastInsertId(); + //$object->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $values = array( + $object->getUsername(), + $object->getPassword(), + $object->getFirstname(), + $object->getLastname(), + $object->getValidAddress(), + $object->getEmail(), + $object->getBirthdate(), + $object->getPlaceOfStudy(), + $object->getPasswordreset(), + $object->getDivisionIdRequest(), + $object->getId() + ); + throw new Excepetion("UserMapper:update() failure: UserMapper is read only!"); + //$this->updateStmt->execute($values); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + throw new Excepetion("UserMapper::doDelete() failure: UserMapper is read only!"); + //$this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + throw new Excepetion("UserMapper::deleteStmt() failure: UserMapper is read only!"); + //return $this->deleteStmt; + } + + function findByLogin($username, $password) { + $this->findByLoginStmt->execute(array($username, $password, $password)); + $array = $this->findByLoginStmt->fetch(); + $this->findByLoginStmt->closeCursor(); + if (!is_array($array)) { + return null; + } + if (!isset($array['id'])) { + return null; + } + return $this->createObject($array); + } + + function getCollection(array $raw) { + return new App_Mapper_UserCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_User"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/UserObjectFactory.php b/vaktliste/App/Mapper/UserObjectFactory.php new file mode 100644 index 0000000..a339e53 --- /dev/null +++ b/vaktliste/App/Mapper/UserObjectFactory.php @@ -0,0 +1,9 @@ +setname($array['name']); + return $obj; + } +} \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkSalaryTypeCollection.php b/vaktliste/App/Mapper/WorkSalaryTypeCollection.php index 2085441..cac4131 100644 --- a/vaktliste/App/Mapper/WorkSalaryTypeCollection.php +++ b/vaktliste/App/Mapper/WorkSalaryTypeCollection.php @@ -1,15 +1,15 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkSalaryTypeMapper.php b/vaktliste/App/Mapper/WorkSalaryTypeMapper.php index 2ad95a9..7c709a1 100644 --- a/vaktliste/App/Mapper/WorkSalaryTypeMapper.php +++ b/vaktliste/App/Mapper/WorkSalaryTypeMapper.php @@ -1,85 +1,85 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM work_salarytype WHERE id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM work_salarytype"); - $this->insertStmt = self::$PDO->prepare( - "INSERT INTO work_salarytype ( - title, hourly_rate - ) values (?, ?)"); - $this->updateStmt = self::$PDO->prepare( - "UPDATE work_salarytype SET - title=?, - hourly_rate=? - WHERE id=?"); - $this->deleteStmt = self::$PDO->prepare( - "DELETE FROM work_salarytype WHERE id=?"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_WorkSalaryType($array["id"]); - - $obj->setTitle($array["title"]); - $obj->setHourlyRate($array["hourly_rate"]); - - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getTitle()); - $this->insertStmt->bindValue(2, $object->getHourlyRate()); - - $this->insertStmt->execute(); - $id = self::$PDO->lastInsertId(); - $this->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getTitle()); - $this->insertStmt->bindValue(2, $object->getHourlyRate()); - $this->updateStmt->bindValue(3, $object->getId()); - - $this->updateStmt->execute(); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - $this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - return $this->deleteStmt; - } - - function getCollection(array $raw) { - return new App_Mapper_WorkSalaryTypeCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_WorkSalaryType"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM work_salarytype WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM work_salarytype"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO work_salarytype ( + title, hourly_rate + ) values (?, ?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE work_salarytype SET + title=?, + hourly_rate=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM work_salarytype WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_WorkSalaryType($array["id"]); + + $obj->setTitle($array["title"]); + $obj->setHourlyRate($array["hourly_rate"]); + + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getTitle()); + $this->insertStmt->bindValue(2, $object->getHourlyRate()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getTitle()); + $this->insertStmt->bindValue(2, $object->getHourlyRate()); + $this->updateStmt->bindValue(3, $object->getId()); + + $this->updateStmt->execute(); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function getCollection(array $raw) { + return new App_Mapper_WorkSalaryTypeCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_WorkSalaryType"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkShiftCollection.php b/vaktliste/App/Mapper/WorkShiftCollection.php index e63a5a5..19510f3 100644 --- a/vaktliste/App/Mapper/WorkShiftCollection.php +++ b/vaktliste/App/Mapper/WorkShiftCollection.php @@ -1,15 +1,15 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkShiftMapper.php b/vaktliste/App/Mapper/WorkShiftMapper.php index 8c102d6..0b39b11 100644 --- a/vaktliste/App/Mapper/WorkShiftMapper.php +++ b/vaktliste/App/Mapper/WorkShiftMapper.php @@ -1,140 +1,140 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM work_shift WHERE id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM work_shift"); - $this->findByGroupIdStmt = self::$PDO->prepare( - "SELECT * FROM work_shift WHERE group_id=?"); - $this->updateStmt = self::$PDO->prepare( - "UPDATE work_shift SET - starts=?, - ends=?, - group_id=?, - location_id=?, - active=?, - title=?, - comment=?, - num_workers=?, - locked=?, - autoassign_workers=?, - salarytype_id=? - WHERE id=?"); - $this->insertStmt = self::$PDO->prepare( - "INSERT INTO work_shift ( - starts, ends, group_id, location_id, active, title, comment, num_workers, locked, autoassign_workers, salarytype_id - ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - $this->deleteStmt = self::$PDO->prepare( - "DELETE FROM work_shift WHERE id=?"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_WorkShift($array["id"]); - - $obj->setStarts(new DateTime($array["starts"])); - $obj->setEnds(new DateTime($array["ends"])); - $obj->setActive($array["active"]); - $obj->setTitle($array["title"]); - $obj->setComment($array["comment"]); - $obj->setNumWorkers($array["num_workers"]); - $obj->setLocked($array["locked"]); - $obj->setAutoAssignWorkers($array["autoassign_workers"]); - - // find group and create division object - $group_mapper = new App_Domain_GroupMapper(); - $group = $group_mapper->find($array["group_id"]); - $obj->setGroup($group); - - // find location and create location object - $location_mapper = new App_Domain_LocationMapper(); - $location = $location_mapper->find($array["location_id"]); - $obj->setLocation($location); - - // find salary type and create salary type object - $salarytype_mapper = new App_Domain_WorkSalaryTypeMapper(); - $salarytype = $salarytype_mapper->find($array["slarytype_id"]); - $obj->setSalaryType($salarytype); - - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getStarts()->format(self::DATETIME_FORMAT)); - $this->insertStmt->bindValue(2, $object->getEnds()->format(self::DATETIME_FORMAT)); - $this->insertStmt->bindValue(3, $object->getGroup()->getId()); - $this->insertStmt->bindValue(4, $object->getLocation()->getId()); - $this->insertStmt->bindValue(5, $object->getActive()); - $this->insertStmt->bindValue(6, $object->getTitle()); - $this->insertStmt->bindValue(7, $object->getComment()); - $this->insertStmt->bindValue(8, $object->getNumWorkers()); - $this->insertStmt->bindValue(9, $object->getLocked()); - $this->insertStmt->bindValue(10, $object->getAutoAssignWorkers()); - $this->insertStmt->bindValue(11, $object->getSalaryType()->getId()); - - $this->insertStmt->execute(); - $id = self::$PDO->lastInsertId(); - $this->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $this->updateStmt->bindValue(1, $object->getStarts()->format(self::DATETIME_FORMAT)); - $this->updateStmt->bindValue(2, $object->getEnds()->format(self::DATETIME_FORMAT)); - $this->updateStmt->bindValue(3, $object->getGroup()->getId()); - $this->updateStmt->bindValue(4, $object->getLocation()->getId()); - $this->updateStmt->bindValue(5, $object->getActive()); - $this->updateStmt->bindValue(6, $object->getTitle()); - $this->updateStmt->bindValue(7, $object->getComment()); - $this->updateStmt->bindValue(8, $object->getNumWorkers()); - $this->updateStmt->bindValue(9, $object->getLocked()); - $this->updateStmt->bindValue(10, $object->getAutoAssignWorkers()); - $this->updateStmt->bindValue(11, $object->getSalaryType()->getId()); - $this->updateStmt->bindValue(12, $object->getId()); - - $this->updateStmt->execute(); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - $this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - return $this->deleteStmt; - } - - function findByGroupId($group_id) { - $this->findByGroupIdStmt->execute(array($group_id)); - return new App_Mapper_WorkShiftCollection($this->findByGroupIdStmt->fetchAll(), $this); - } - - function getCollection(array $raw) { - return new App_Mapper_WorkShiftCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_WorkShift"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM work_shift WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM work_shift ORDER BY starts"); + $this->findByGroupIdStmt = self::$PDO->prepare( + "SELECT * FROM work_shift WHERE group_id=?"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE work_shift SET + starts=?, + ends=?, + group_id=?, + location_id=?, + active=?, + title=?, + comment=?, + num_workers=?, + locked=?, + autoassign_workers=?, + salarytype_id=? + WHERE id=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO work_shift ( + starts, ends, group_id, location_id, active, title, comment, num_workers, locked, autoassign_workers, salarytype_id + ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM work_shift WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_WorkShift($array["id"]); + + $obj->setStarts(new DateTime($array["starts"])); + $obj->setEnds(new DateTime($array["ends"])); + $obj->setActive($array["active"]); + $obj->setTitle($array["title"]); + $obj->setComment($array["comment"]); + $obj->setNumWorkers($array["num_workers"]); + $obj->setLocked($array["locked"]); + $obj->setAutoAssignWorkers($array["autoassign_workers"]); + + // find group and create division object + $group_mapper = new App_Mapper_GroupMapper(); + $group = $group_mapper->find($array["group_id"]); + $obj->setGroup($group); + + // find location and create location object + $location_mapper = new App_Mapper_LocationMapper(); + $location = $location_mapper->find($array["location_id"]); + $obj->setLocation($location); + + // find salary type and create salary type object + $salarytype_mapper = new App_Mapper_WorkSalaryTypeMapper(); + $salarytype = $salarytype_mapper->find($array["salarytype_id"]); + $obj->setSalaryType($salarytype); + + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getStarts()->format(self::DATETIME_FORMAT)); + $this->insertStmt->bindValue(2, $object->getEnds()->format(self::DATETIME_FORMAT)); + $this->insertStmt->bindValue(3, $object->getGroup()->getId()); + $this->insertStmt->bindValue(4, $object->getLocation()->getId()); + $this->insertStmt->bindValue(5, $object->getActive()); + $this->insertStmt->bindValue(6, $object->getTitle()); + $this->insertStmt->bindValue(7, $object->getComment()); + $this->insertStmt->bindValue(8, $object->getNumWorkers()); + $this->insertStmt->bindValue(9, $object->getLocked()); + $this->insertStmt->bindValue(10, $object->getAutoAssignWorkers()); + $this->insertStmt->bindValue(11, $object->getSalaryType()->getId()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $object->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $this->updateStmt->bindValue(1, $object->getStarts()->format(self::DATETIME_FORMAT)); + $this->updateStmt->bindValue(2, $object->getEnds()->format(self::DATETIME_FORMAT)); + $this->updateStmt->bindValue(3, $object->getGroup()->getId()); + $this->updateStmt->bindValue(4, $object->getLocation()->getId()); + $this->updateStmt->bindValue(5, $object->getActive()); + $this->updateStmt->bindValue(6, $object->getTitle()); + $this->updateStmt->bindValue(7, $object->getComment()); + $this->updateStmt->bindValue(8, $object->getNumWorkers()); + $this->updateStmt->bindValue(9, $object->getLocked()); + $this->updateStmt->bindValue(10, $object->getAutoAssignWorkers()); + $this->updateStmt->bindValue(11, $object->getSalaryType()->getId()); + $this->updateStmt->bindValue(12, $object->getId()); + + $this->updateStmt->execute(); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function findByGroupId($group_id) { + $this->findByGroupIdStmt->execute(array($group_id)); + return new App_Mapper_WorkShiftCollection($this->findByGroupIdStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new App_Mapper_WorkShiftCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_WorkShift"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkShiftUpdateCollection.php b/vaktliste/App/Mapper/WorkShiftUpdateCollection.php index 43a3801..d06d96c 100644 --- a/vaktliste/App/Mapper/WorkShiftUpdateCollection.php +++ b/vaktliste/App/Mapper/WorkShiftUpdateCollection.php @@ -1,14 +1,14 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkShiftUpdateMapper.php b/vaktliste/App/Mapper/WorkShiftUpdateMapper.php index 8a0ff8b..fa0098f 100644 --- a/vaktliste/App/Mapper/WorkShiftUpdateMapper.php +++ b/vaktliste/App/Mapper/WorkShiftUpdateMapper.php @@ -1,109 +1,109 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM work_shiftupdate WHERE id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM work_shiftupdate"); - $this->findByShiftIdStmt = self::$PDO->prepare( - "SELECT * FROM work_shiftupdate WHERE shift_id=?"); - $this->updateStmt = self::$PDO->prepare( - "UPDATE work_shiftupdate SET - shift_id=?, - update_time=?, - user_id=?, - update_text=? - WHERE id=?"); - $this->insertStmt = self::$PDO->prepare( - "INSERT INTO work_shiftupdate ( - shift_id, update_time, user_id, update_text - ) values (?, ?, ?, ?)"); - $this->deleteStmt = self::$PDO->prepare( - "DELETE FROM work_shiftupdate WHERE id=?"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_WorkShiftUpdate($array["id"]); - - // find shift and create workshift object - $shift_mapper = new App_Mapper_WorkShiftMapper(); - $shift = $shift_mapper->find($array["shift_id"]); - $obj->setShift($shift); - - $obj->setUpdateTime(new DateTime($array["update_time"])); - - // find user and create user object - $user_mapper = new App_Domain_User(); - $user = $user_mapper->find($array["user_id"]); - $obj->setUser($user); - - $obj->setUpdateText($array["text"]); - - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getShift()->getId()); - $this->insertStmt->bindValue(2, $object->getUpdateTime()->format(self::DATETIME_FORMAT)); - $this->insertStmt->bindValue(3, $object->getUser()->getId()); - $this->insertStmt->bindValue(4, $object->getUpdateText()); - - $this->insertStmt->execute(); - $id = self::$PDO->lastInsertId(); - $this->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getShift()->getId()); - $this->insertStmt->bindValue(2, $object->getUpdateTime()->format(self::DATETIME_FORMAT)); - $this->insertStmt->bindValue(3, $object->getUser()->getId()); - $this->insertStmt->bindValue(4, $object->getUpdateText()); - $this->updateStmt->bindValue(5, $object->getId()); - - $this->updateStmt->execute(); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - $this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - return $this->deleteStmt; - } - - function findByShiftId($shift_id) { - $this->findByShiftIdStmt->execute(array($shift_id)); - return new App_Mapper_WorkShiftUpdateCollection($this->findByShiftIdStmt->fetchAll(), $this); - } - - function getCollection(array $raw) { - return new App_Mapper_WorkShiftUpdateCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_WorkShiftUpdate"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM work_shiftupdate WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM work_shiftupdate"); + $this->findByShiftIdStmt = self::$PDO->prepare( + "SELECT * FROM work_shiftupdate WHERE shift_id=?"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE work_shiftupdate SET + shift_id=?, + update_time=?, + user_id=?, + update_text=? + WHERE id=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO work_shiftupdate ( + shift_id, update_time, user_id, update_text + ) values (?, ?, ?, ?)"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM work_shiftupdate WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_WorkShiftUpdate($array["id"]); + + // find shift and create workshift object + $shift_mapper = new App_Mapper_WorkShiftMapper(); + $shift = $shift_mapper->find($array["shift_id"]); + $obj->setShift($shift); + + $obj->setUpdateTime(new DateTime($array["update_time"])); + + // find user and create user object + $user_mapper = new App_Domain_User(); + $user = $user_mapper->find($array["user_id"]); + $obj->setUser($user); + + $obj->setUpdateText($array["text"]); + + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getShift()->getId()); + $this->insertStmt->bindValue(2, $object->getUpdateTime()->format(self::DATETIME_FORMAT)); + $this->insertStmt->bindValue(3, $object->getUser()->getId()); + $this->insertStmt->bindValue(4, $object->getUpdateText()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getShift()->getId()); + $this->insertStmt->bindValue(2, $object->getUpdateTime()->format(self::DATETIME_FORMAT)); + $this->insertStmt->bindValue(3, $object->getUser()->getId()); + $this->insertStmt->bindValue(4, $object->getUpdateText()); + $this->updateStmt->bindValue(5, $object->getId()); + + $this->updateStmt->execute(); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function findByShiftId($shift_id) { + $this->findByShiftIdStmt->execute(array($shift_id)); + return new App_Mapper_WorkShiftUpdateCollection($this->findByShiftIdStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new App_Mapper_WorkShiftUpdateCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_WorkShiftUpdate"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkShiftWorkerCollection.php b/vaktliste/App/Mapper/WorkShiftWorkerCollection.php index 074d759..811066f 100644 --- a/vaktliste/App/Mapper/WorkShiftWorkerCollection.php +++ b/vaktliste/App/Mapper/WorkShiftWorkerCollection.php @@ -1,15 +1,15 @@ - \ No newline at end of file diff --git a/vaktliste/App/Mapper/WorkShiftWorkerMapper.php b/vaktliste/App/Mapper/WorkShiftWorkerMapper.php index ec83588..9466365 100644 --- a/vaktliste/App/Mapper/WorkShiftWorkerMapper.php +++ b/vaktliste/App/Mapper/WorkShiftWorkerMapper.php @@ -1,123 +1,123 @@ -selectStmt = self::$PDO->prepare( - "SELECT * FROM work_shiftworker WHERE id=?"); - $this->selectAllStmt = self::$PDO->prepare( - "SELECT * FROM work_shiftworker"); - $this->findByShiftIdStmt = self::$PDO->prepare( - "SELECT * FROM work_shiftworker WHERE shift_id=?"); - $this->findByUserIdStmt = self::$PDO->prepare( - "SELECT * FROM work_shiftworker WHERE user_id=?"); - $this->insertStmt = self::$PDO->prepare( - "INSERT INTO work_shiftworker ( - shift_id, user_id, assigned, no_show, user_comment, employer_comment - ) values (?, ?, ?, ?, ?, ?)"); - $this->updateStmt = self::$PDO->prepare( - "UPDATE work_shiftworker SET - shift_id=?, - user_id=?, - assigned=?, - no_show=?, - user_comment=?, - employer_comment=? - WHERE id=?"); - $this->deleteStmt = self::$PDO->prepare( - "DELETE FROM work_shiftworker WHERE id=?"); - } - - protected function doCreateObject(array $array) { - $obj = new App_Domain_WorkShiftWorker($array["id"]); - - // find shift and create workshift object - $shift_mapper = new App_Mapper_WorkShiftMapper(); - $shift = $shift_mapper->find($array["shift_id"]); - $obj->setShift($shift); - - // find user and create user object - $user_mapper = new App_Domain_User(); - $user = $user_mapper->find($array["user_id"]); - $obj->setUser($user); - - $obj->setAssigned($array["assigned"]); - $obj->setNoShow($array["no_show"]); - $obj->setUserComment($array["user_comment"]); - $obj->setEmployerComment($array["employer_comment"]); - - return $obj; - } - - protected function doInsert(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getShift()->getId()); - $this->insertStmt->bindValue(2, $object->getUser()->getId()); - $this->insertStmt->bindValue(3, $object->getAssigned()); - $this->insertStmt->bindValue(4, $object->getNoShow()); - $this->insertStmt->bindValue(5, $object->getUserComment()); - $this->insertStmt->bindValue(6, $object->getEmployerComment()); - - $this->insertStmt->execute(); - $id = self::$PDO->lastInsertId(); - $this->setId($id); - } - - function update(App_Domain_DomainObject $object) { - $this->insertStmt->bindValue(1, $object->getShift()->getId()); - $this->insertStmt->bindValue(2, $object->getUser()->getId()); - $this->insertStmt->bindValue(3, $object->getAssigned()); - $this->insertStmt->bindValue(4, $object->getNoShow()); - $this->insertStmt->bindValue(5, $object->getUserComment()); - $this->insertStmt->bindValue(6, $object->getEmployerComment()); - $this->updateStmt->bindValue(7, $object->getId()); - - $this->updateStmt->execute(); - } - - protected function doDelete(App_Domain_DomainObject $object) { - $values = array($object->getId()); - $this->deleteStmt->execute($values); - } - - function selectStmt() { - return $this->selectStmt; - } - - function selectAllStmt() { - return $this->selectAllStmt; - } - - function deleteStmt() { - return $this->deleteStmt; - } - - function findByShiftId($shift_id) { - $this->findByShiftIdStmt->execute(array($shift_id)); - return new App_Mapper_WorkShiftWorkerCollection($this->findByShiftIdStmt->fetchAll(), $this); - } - - function findByUserId($user_id) { - $this->findByUserIdStmt->execute(array($user_id)); - return new App_Mapper_WorkShiftWorkerCollection($this->findByUserIdStmt->fetchAll(), $this); - } - - function getCollection(array $raw) { - return new App_Mapper_WorkShiftWorkerCollection($raw, $this); - } - - protected function targetClass() { - return "App_Domain_WorkShiftWorker"; - } -} - +selectStmt = self::$PDO->prepare( + "SELECT * FROM work_shiftworker WHERE id=?"); + $this->selectAllStmt = self::$PDO->prepare( + "SELECT * FROM work_shiftworker"); + $this->findByShiftIdStmt = self::$PDO->prepare( + "SELECT * FROM work_shiftworker WHERE shift_id=?"); + $this->findByUserIdStmt = self::$PDO->prepare( + "SELECT * FROM work_shiftworker WHERE user_id=?"); + $this->insertStmt = self::$PDO->prepare( + "INSERT INTO work_shiftworker ( + shift_id, user_id, assigned, no_show, user_comment, employer_comment + ) values (?, ?, ?, ?, ?, ?)"); + $this->updateStmt = self::$PDO->prepare( + "UPDATE work_shiftworker SET + shift_id=?, + user_id=?, + assigned=?, + no_show=?, + user_comment=?, + employer_comment=? + WHERE id=?"); + $this->deleteStmt = self::$PDO->prepare( + "DELETE FROM work_shiftworker WHERE id=?"); + } + + protected function doCreateObject(array $array) { + $obj = new App_Domain_WorkShiftWorker($array["id"]); + + // find shift and create workshift object + $shift_mapper = new App_Mapper_WorkShiftMapper(); + $shift = $shift_mapper->find($array["shift_id"]); + $obj->setShift($shift); + + // find user and create user object + $user_mapper = new App_Domain_User(); + $user = $user_mapper->find($array["user_id"]); + $obj->setUser($user); + + $obj->setAssigned($array["assigned"]); + $obj->setNoShow($array["no_show"]); + $obj->setUserComment($array["user_comment"]); + $obj->setEmployerComment($array["employer_comment"]); + + return $obj; + } + + protected function doInsert(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getShift()->getId()); + $this->insertStmt->bindValue(2, $object->getUser()->getId()); + $this->insertStmt->bindValue(3, $object->getAssigned()); + $this->insertStmt->bindValue(4, $object->getNoShow()); + $this->insertStmt->bindValue(5, $object->getUserComment()); + $this->insertStmt->bindValue(6, $object->getEmployerComment()); + + $this->insertStmt->execute(); + $id = self::$PDO->lastInsertId(); + $this->setId($id); + } + + function update(App_Domain_DomainObject $object) { + $this->insertStmt->bindValue(1, $object->getShift()->getId()); + $this->insertStmt->bindValue(2, $object->getUser()->getId()); + $this->insertStmt->bindValue(3, $object->getAssigned()); + $this->insertStmt->bindValue(4, $object->getNoShow()); + $this->insertStmt->bindValue(5, $object->getUserComment()); + $this->insertStmt->bindValue(6, $object->getEmployerComment()); + $this->updateStmt->bindValue(7, $object->getId()); + + $this->updateStmt->execute(); + } + + protected function doDelete(App_Domain_DomainObject $object) { + $values = array($object->getId()); + $this->deleteStmt->execute($values); + } + + function selectStmt() { + return $this->selectStmt; + } + + function selectAllStmt() { + return $this->selectAllStmt; + } + + function deleteStmt() { + return $this->deleteStmt; + } + + function findByShiftId($shift_id) { + $this->findByShiftIdStmt->execute(array($shift_id)); + return new App_Mapper_WorkShiftWorkerCollection($this->findByShiftIdStmt->fetchAll(), $this); + } + + function findByUserId($user_id) { + $this->findByUserIdStmt->execute(array($user_id)); + return new App_Mapper_WorkShiftWorkerCollection($this->findByUserIdStmt->fetchAll(), $this); + } + + function getCollection(array $raw) { + return new App_Mapper_WorkShiftWorkerCollection($raw, $this); + } + + protected function targetClass() { + return "App_Domain_WorkShiftWorker"; + } +} + ?> \ No newline at end of file diff --git a/vaktliste/App/View/Common/footer.php b/vaktliste/App/View/Common/footer.php index c3c1f9c..053a5ea 100644 --- a/vaktliste/App/View/Common/footer.php +++ b/vaktliste/App/View/Common/footer.php @@ -1,7 +1,7 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/vaktliste/App/View/Common/header.php b/vaktliste/App/View/Common/header.php index 03b642e..8911cf8 100644 --- a/vaktliste/App/View/Common/header.php +++ b/vaktliste/App/View/Common/header.php @@ -1,98 +1,98 @@ - - - - - - - - <?php print App_Base_ApplicationRegistry::getPageTitle(); ?> - - - -
- - -
- + + + + + + + + <?php print App_Base_ApplicationRegistry::getPageTitle(); ?> + + + +
+ + +
+
\ No newline at end of file diff --git a/vaktliste/App/View/Common/menu.php b/vaktliste/App/View/Common/menu.php index c57e6f7..fd4ba7d 100644 --- a/vaktliste/App/View/Common/menu.php +++ b/vaktliste/App/View/Common/menu.php @@ -1,38 +1,38 @@ - - -