Esempio n. 1
0
 public function addeditsequenceAction()
 {
     // The Form
     $form = new Form_SequenceForm();
     $this->view->form = $form;
     // Editing? Or new?
     $id = $this->_getParam("id");
     if (!is_null($id)) {
         $obj = Model_Quiz_Sequence::load($id);
         if (!$obj) {
             throw new Exception("Object does not exist");
         }
         $this->view->editing = true;
         // Populate Form
         $el = new Zend_Form_Element_Hidden('id');
         $el->setValue($obj->id);
         $form->addElement($el);
         $form->getElement("name")->setValue($obj->name);
         $form->getElement("permissions_group")->setValue($obj->permissions_group);
     }
     // Submitting?
     if ($this->getRequest()->isPost()) {
         //if (!$form->isValid($this->getRequest()->getPost())) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $obj = new Model_Quiz_Sequence();
             $obj->fromData($form->getValues());
             $obj->save();
             $this->_helper->redirector("sequences", "admin");
         }
     }
 }
Esempio n. 2
0
 function createSequence($name, $permissions)
 {
     $seq = new Model_Quiz_Sequence();
     $seq->name = $name;
     $seq->permissions_group = $permissions;
     $seq->save();
     return $seq;
 }