Changeset 342 for trunk/app/controllers/ecourses_controller.php
- Timestamp:
- 03/25/08 01:03:27 (8 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/ecourses_controller.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/ecourses_controller.php
r340 r342 36 36 $this->layout = 'admin'; 37 37 38 39 38 $conditions = array("user_id"=>$this->Auth->user('id')); 40 39 $fields = array('id', 'title', 'access', 'status', 'description'); 41 40 $order = "Ecourse.title DESC"; 42 41 43 42 $this->set('data', $this->Ecourse->findAll($conditions, $fields, $order)); 44 43 } … … 67 66 $this->set('data', $this->Ecourse->find($conditions, $fields)); 68 67 } 69 70 public function admin_add()71 {72 $this->layout = 'admin';73 74 if (!empty($this->data['Ecourse']))75 {76 $this->Sanitize = new Sanitize;77 78 $this->Sanitize->clean($this->data["Ecourse"]);79 80 $this->data['Ecourse']['user_id'] = $this->Auth->user('id');81 82 $this->Ecourse->create();83 84 if ($this->Ecourse->save($this->data['Ecourse']))85 {86 $this->msgFlash('Course saved', '/admin/ecourses/listing');87 }88 }89 else90 {91 92 $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title"));93 94 $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang"));95 96 }97 }98 68 99 69 public function admin_change($id, $status) … … 112 82 } 113 83 } 84 public function admin_add() 85 { 86 $this->layout = 'admin'; 87 88 $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 89 90 $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 91 92 if (!empty($this->data['Ecourse'])) 93 { 94 $this->Sanitize = new Sanitize; 95 96 $this->Sanitize->clean($this->data["Ecourse"]); 97 98 $this->data['Ecourse']['user_id'] = $this->Auth->user('id'); 99 100 $this->Ecourse->create(); 101 102 if ($this->Ecourse->save($this->data['Ecourse'])) 103 { 104 $this->msgFlash('Course saved', '/admin/ecourses/listing'); 105 } 106 } 107 } 114 108 115 109 public function admin_edit($id = null) 116 110 { 117 118 if (empty($this->data['Ecourse'])) 111 $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 112 113 $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 114 115 if ( empty($this->data['Ecourse']) ) 119 116 { 120 117 $this->layout = 'admin'; … … 124 121 $this->Subject = new Subject; 125 122 126 $this->set('subjects', $this->Ecourse->Subject->generateList(null, 'title'));127 128 $this->set('langs', $this->Ecourse->Lang->generateList(null, 'lang', null, '{n}.Lang.id', '{n}.Lang.lang'));129 130 123 $this->data = $this->Ecourse->read(); 124 131 125 } 132 126 else … … 135 129 136 130 $this->Sanitize->html($this->data["Ecourse"]['description']); 137 131 138 132 if ($this->Ecourse->save($this->data['Ecourse'])) 139 133 {
