Changeset 698 for trunk/app/controllers
- Timestamp:
- 08/06/08 12:32:50 (4 months ago)
- Location:
- trunk/app/controllers
- Files:
-
- 2 modified
-
catglossaries_controller.php (modified) (4 diffs)
-
glossaries_controller.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/catglossaries_controller.php
r540 r698 40 40 $this->set('data', $this->Catglossary->findAll($conditions, $fields, $order)); 41 41 42 /*Edublog */42 /*Edublog stuff*/ 43 43 $this->layout = $this->Edublog->layout($user_id); 44 44 … … 63 63 } 64 64 65 66 /*** 67 ===== ADMIM METHODS ===== 68 ***/ 65 /*** ===== ADMIN METHODS ===== ***/ 69 66 public function admin_listing() 70 67 { 71 68 $this->layout = 'admin'; 72 69 73 $this->pageTitle = 'Glossaries';70 $this->pageTitle = __('Glossaries', true); 74 71 75 72 $conditions = array('Catglossary.user_id' => $this->Auth->user('id')); 76 73 77 74 $fields = array('Catglossary.id', 'Catglossary.title', 'Catglossary.description', 'Catglossary.created', 'Catglossary.status'); 78 79 $this->set('data', $this->Catglossary->findAll($conditions, $fields ));75 $order = 'Catglossary.title'; 76 $this->set('data', $this->Catglossary->findAll($conditions, $fields, $order)); 80 77 } 81 78 … … 89 86 90 87 $fields = array('Catglossary.id', 'Catglossary.title', 'Catglossary.user_id', 'Catglossary.user_id', 'User.id', 'User.username'); 91 //debug($this->Catglossary->find($conditions, $fields));exit();92 88 $this->set('data', $this->Catglossary->find($conditions, $fields)); 93 89 } … … 95 91 public function admin_add() 96 92 { 97 $this->layout = 'admin'; 98 99 // adds new classroom to database 100 if (!empty($this->data['Catglossary'])) 101 { 93 $this->layout = 'admin'; 94 95 if (!empty($this->data['Catglossary'])): 102 96 $this->Sanitize = new Sanitize; 103 97 104 $this->Sanitize->clean($this->data[ "Catglossary"]);98 $this->Sanitize->clean($this->data['Catglossary']); 105 99 106 $this->data[ "Catglossary"]["user_id"] =$this->Auth->user('id');100 $this->data['Catglossary']['user_id'] = (int) $this->Auth->user('id'); 107 101 108 $this->Catglossary->create(); 109 110 if ($this->Catglossary->save($this->data["Catglossary"])) 111 { 112 $this->msgFlash('Category Glossary saved.','/admin/catglossaries/listing'); 113 } 114 } 102 if ($this->Catglossary->save($this->data)): 103 $this->msgFlash('Category Glossary saved.','/admin/catglossaries/listing'); 104 endif; 105 endif; 115 106 } 116 107 117 public function admin_edit($ id=null)108 public function admin_edit($catglossary_id=null) 118 109 { 119 $this->layout = 'admin';110 $this->layout = 'admin'; 120 111 121 if ( empty( $this->data["Catglossary"] ) ) 122 { 123 $this->Catglossary->id = $id; 124 125 $this->data = $this->Catglossary->read(); 126 } 127 else 128 { 112 if ( empty( $this->data['Catglossary'] ) ): 113 $this->data = $this->Catglossary->read(null, $catglossary_id); 114 else: 115 129 116 $this->Sanitize = new Sanitize; 130 117 131 $this->Sanitize->html($this->data[ "Catglossary"]["title"]);118 $this->Sanitize->html($this->data['Catglossary']['title']); 132 119 133 $this->Sanitize->html($this->data[ "Catglossary"]["description"]);120 $this->Sanitize->html($this->data['Catglossary']['description']); 134 121 135 if ($this->Catglossary->save($this->data["Catglossary"])) 136 { 137 $this->msgFlash('Your category has been saved!', '/admin/catglossaries/edit/'.$this->data["Catglossary"]["id"]); 138 } 139 } 122 if ($this->Catglossary->save($this->data)): 123 $this->msgFlash(__('Data saved', true), '/admin/catglossaries/edit/'.$this->data['Catglossary']['id']); 124 endif; 125 endif; 140 126 } 141 127 142 public function admin_delete($id) 128 // change status published/draft 129 public function admin_change($status, $catglossary_id) 130 { 131 if ( !is_numeric($status) || !intval($catglossary_id) ): 132 $this->redirect('/'); 133 return false; 134 endif; 135 136 $this->data['Catglossary']['status'] = ($status == 0 ) ? 1 : 0; 137 138 $this->data['Catglossary']['id'] = (int) $catglossary_id; 139 140 if ($this->Catglossary->save($this->data, array('validate'=>false))): 141 $this->msgFlash(__('Status modified', true), '/admin/catglossaries/listing'); 142 endif; 143 } 144 145 public function admin_delete($catglossary_id) 143 146 { 144 if ($this->Catglossary->del($id)) 145 { 146 $this->msgFlash('Category deleted', '/admin/catglossaries/listing'); 147 } 147 if ($this->Catglossary->del($$catglossary_id)): 148 $this->msgFlash(__('Data removed', true), '/admin/catglossaries/listing'); 149 endif; 148 150 } 149 151 } -
trunk/app/controllers/glossaries_controller.php
r540 r698 27 27 $this->pageTitle = 'Glossaries'; 28 28 29 $user_id = $this->Glossary->User->field('id', array( "username"=>$username));29 $user_id = $this->Glossary->User->field('id', array('username'=>$username)); 30 30 31 $conditions = array( "user_id"=>$user_id, "status"=>1);31 $conditions = array('user_id'=>$user_id, 'status'=>1); 32 32 33 33 $fields = array("id", "item", "definition"); 34 34 35 $order = "item ASC";35 $order = 'item ASC'; 36 36 37 37 $this->set('data', $this->Glossary->findAll($conditions, $fields, $order)); 38 38 39 /*Edublog */39 /*Edublog stuff */ 40 40 $this->layout = $this->Edublog->layout($user_id); 41 41 … … 43 43 } 44 44 45 /*** 46 ===== ADMIM METHODS ===== 47 ***/ 45 /*** ===== ADMIM METHODS ===== ***/ 48 46 49 47 public function admin_new($catglossary_id) … … 54 52 } 55 53 56 public function admin_edit($ id = null)54 public function admin_edit($glossary_id = null) 57 55 { 58 56 $this->layout = 'admin'; 59 57 60 if (empty($this->data["Glossary"])) 61 { 62 $this->Glossary->id = $id; 63 64 $this->data = $this->Glossary->read(); 65 } 66 else 67 { 58 if (empty($this->data['Glossary'])): 59 $this->data = $this->Glossary->read(null, $glossary_id); 60 61 else: 62 68 63 $this->Sanitize = new Sanitize; 69 64 70 $this->Sanitize->clean($this->data[ "Glossary"]);65 $this->Sanitize->clean($this->data['Glossary']); 71 66 72 if ($this->Glossary->save($this->data['Glossary'])) 73 { 74 $this->msgFlash('Glossary has been updated.','/admin/catglossaries/items/'.$this->data['Glossary']['catglossary_id']); 75 } 76 } 67 if ($this->Glossary->save($this->data)): 68 $this->msgFlash(__('Data saved', true),'/admin/catglossaries/items/'.$this->data['Glossary']['catglossary_id']); 69 endif; 70 endif; 77 71 } 78 72 … … 80 74 { 81 75 $this->layout = 'admin'; 82 83 if (!empty($this->data['Glossary'])) 84 { 76 77 if (!empty($this->data['Glossary'])): 78 85 79 $this->Sanitize = new Sanitize; 86 80 87 81 $this->Sanitize->clean($this->data['Glossary']); 88 82 89 $this->data[ "Glossary"]["user_id"] =$this->Auth->user('id');83 $this->data['Glossary']['user_id'] = (int) $this->Auth->user('id'); 90 84 91 $this->Glossary->create(); 92 93 if ($this->Glossary->save($this->data["Glossary"])) 94 { 95 $this->msgFlash('Item has been saved.','/admin/catglossaries/items/'.$this->data["Glossary"]["catglossary_id"]); 96 } 97 } 85 if ($this->Glossary->save($this->data)): 86 $this->msgFlash(__('Data saved', true),'/admin/catglossaries/items/'.$this->data['Glossary']['catglossary_id']); 87 endif; 88 endif; 98 89 } 99 90 100 public function admin_delete($ id, $catglossary_id)91 public function admin_delete($glossary_id, $catglossary_id) 101 92 { 102 $this->Glossary->del($id); 103 $this->msgFlash('Glossary has been deleted.', '/admin/catglossaries/items/'.$catglossary_id); 104 } 93 if ( $this->Glossary->del($glossary_id) ): 94 $this->msgFlash(__('Data removed', true), '/admin/catglossaries/items/'.$catglossary_id); 95 endif; 96 } 105 97 } 106 98 ?>
