示例#1
0
 public function deleteAction()
 {
     $authorization = Zend_Auth::getInstance();
     $identity = $authorization->getIdentity();
     if ($identity->user_type == "admin") {
         $id = $this->getRequest()->getParam('id');
         if ($id) {
             $model = new Application_Model_Courses();
             $model->deleteCourse($id);
         }
         $this->redirect("courses/list");
     } else {
         $this->redirect("cources/index");
     }
 }
示例#2
0
 public function editAction()
 {
     $authorization = Zend_Auth::getInstance();
     $identity = $authorization->getIdentity();
     if ($identity->user_type == "admin") {
         $form = new Application_Form_Materials();
         $model = new Application_Model_Materials();
         $id = $this->getRequest()->getParam('id');
         $material_data = $model->getMaterialById($id);
         $course_model = new Application_Model_Courses();
         $courses = $course_model->listCourses();
         for ($i = 0; $i < count($courses); $i++) {
             $options[$courses[$i]['id']] = $courses[$i]['name'];
         }
         $form->getElement('cid')->setMultiOptions($options);
         $options = NULL;
         $type_model = new Application_Model_Materialtype();
         $types = $type_model->listTypes();
         for ($i = 0; $i < count($types); $i++) {
             $options[$types[$i]['id']] = $types[$i]['type_name'];
         }
         $form->getElement('tid')->setMultiOptions($options);
         $form->populate($material_data[0]);
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getParams())) {
                 $model = new Application_Model_Materials();
                 $model->editMaterial($form->getValues(), $id);
                 $this->redirect("/materials/list");
             }
         }
         $this->view->form = $form;
         $this->render("add");
     } else {
         $this->view->notAllwed = "The page not allowed for normal user.";
         $this->_redirect("/materials/list");
     }
 }
示例#3
0
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     if ($id) {
         $model = new Application_Model_Courses();
         $this->view->courses = $model->deleteCourse($id);
     }
     $this->render('list');
 }