Exemple #1
0
 public function editAction()
 {
     $authorization = Zend_Auth::getInstance();
     $identity = $authorization->getIdentity();
     if ($identity->user_type == "admin") {
         $form = new Application_Form_Course();
         $model = new Application_Model_Courses();
         $id = $this->getRequest()->getParam('id');
         $course_data = $model->getCourseById($id);
         $category_model = new Application_Model_Categories();
         $categories = $category_model->listCategories();
         for ($i = 0; $i < count($categories); $i++) {
             $options[$categories[$i]['id']] = $categories[$i]['name'];
         }
         $form->getElement('catid')->setMultiOptions($options);
         var_dump($course_data);
         $form->populate($course_data[0]);
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getParams())) {
                 $model = new Application_Model_Courses();
                 $model->editCourse($form->getValues(), $id);
                 //$this->view->identity->id
                 $this->redirect("/courses/list");
             }
         }
         $this->view->form = $form;
         $this->render("add");
     } else {
         $this->redirect("cources/index");
     }
 }
Exemple #2
0
 public function listAction()
 {
     $authorization = Zend_Auth::getInstance();
     $identity = $authorization->getIdentity();
     if ($identity) {
         $model = new Application_Model_Materials();
         $materials = $model->listMaterials();
         $course_model = new Application_Model_Courses();
         for ($i = 0; $i < count($materials); $i++) {
             $courses[$i] = $course_model->getCourseById($materials[$i]['cid'])[0]['name'];
         }
         $type_model = new Application_Model_Materialtype();
         for ($i = 0; $i < count($materials); $i++) {
             $types[$i] = $type_model->getTypeById($materials[$i]['tid'])[0]['type_name'];
         }
         //$page=$this->_getParam('page',1);
         //$paginator = Zend_Paginator::factory($courses);
         // $paginator->setItemCountPerPage(10);
         //$paginator->setCurrentPageNumber($page);
         $this->view->materials = $materials;
         $this->view->courses = $courses;
         $this->view->types = $types;
         $this->view->identity = $identity;
     } else {
         $this->_redirect("/users/login");
     }
 }
Exemple #3
0
 public function editAction()
 {
     $form = new Application_Form_Course();
     $model = new Application_Model_Courses();
     //$this->view->courses  = $model->editCourse();
     $id = $this->getRequest()->getParam('id');
     $course_data = $model->getCourseById($id);
     $form->populate($course_data);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             $model = new Application_Model_Courses();
             $model->editCourse($form->getValues(), 1);
             //$this->view->identity->id
             $this->_redirect("/courses/list");
         }
     }
     $this->view->{$form} = $form;
     $this->render('add');
 }