| 1 | <?php /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 2; -*- |
|---|
| 2 | |
|---|
| 3 | */ |
|---|
| 4 | |
|---|
| 5 | require_once('class.dkg.person.php'); |
|---|
| 6 | |
|---|
| 7 | if (!class_exists('JPDD_Organization')) { |
|---|
| 8 | |
|---|
| 9 | class JPDD_Organization extends DKG_Row { |
|---|
| 10 | |
|---|
| 11 | function getCreatePrivilege() { |
|---|
| 12 | return array('Edit Organizations'); |
|---|
| 13 | } |
|---|
| 14 | function getEditPrivilege() { |
|---|
| 15 | return array('Edit Organizations'); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | function getFormInnards() { |
|---|
| 19 | return '<div> |
|---|
| 20 | <label>Name:<br/><input type="text" name="title" value="'.$this->getTitle(true).'"/></label><br/> |
|---|
| 21 | <label>Description<br/><textarea name="description" rows="20" cols="80">'.$this->getDescription(true).'</textarea></label> |
|---|
| 22 | </div>'; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | function applyPostForm() { |
|---|
| 26 | $this->_title = $_POST['title']; |
|---|
| 27 | $this->_description = $_POST['description']; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | function handleCreation() { |
|---|
| 31 | global $jpdd; |
|---|
| 32 | $this->applyPostForm(); |
|---|
| 33 | $res = $jpdd->executeSQL('INSERT INTO '.$this->getSingletonTable().' (title, description) VALUES ('. |
|---|
| 34 | $jpdd->stringOrDefault($this->_title).', '. |
|---|
| 35 | $jpdd->stringOrDefault($this->_description).')', false); |
|---|
| 36 | if (false === $res) { |
|---|
| 37 | return false; |
|---|
| 38 | } else { |
|---|
| 39 | $this->JPDD_Organization(array('data' => $jpdd->getSingletonFromSQL('SELECT * from '.$this->getSingletonTable().' WHERE id = currval(\''.$this->getSingletonTable().'_id_seq\')'))); |
|---|
| 40 | return true; |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | function handleEdit() { |
|---|
| 45 | global $jpdd; |
|---|
| 46 | $this->applyPostForm(); |
|---|
| 47 | $ret = $jpdd->executeSQL('UPDATE '.$this->getSingletonTable().' SET '. |
|---|
| 48 | 'title = '.$jpdd->stringOrDefault($this->getTitle()).', '. |
|---|
| 49 | 'description = '.$jpdd->stringOrDefault($this->getDescription()).' '. |
|---|
| 50 | 'WHERE id = '.$this->getID()); |
|---|
| 51 | if (false === $res) { |
|---|
| 52 | return false; |
|---|
| 53 | } else { |
|---|
| 54 | $this->JPDD_Organization(array('id' => $this->getID())); |
|---|
| 55 | return true; |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | function getDetailInnards() { |
|---|
| 60 | $ret = ''; |
|---|
| 61 | |
|---|
| 62 | // FIXME: maybe show all affiliated people? |
|---|
| 63 | |
|---|
| 64 | return $ret; |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | } |
|---|