/** * * @param string $SessionID * @param string $StreamName * @param string $Keywords * @return string */ public function CreateStream($SessionID, $StreamName, $Keywords) { //streamName is video title, keywords is the description for the video //check if the $SessionID is valid then create a record in the video table with stream id, Session ID age must be no longer than 2 hours //returns the stream id //validate and filer input $data = array('sessionid' => $SessionID, 'title' => $StreamName, 'description' => $Keywords); $filters = array('sessionid' => array('HtmlEntities', 'StringTrim', 'StripTags'), 'title' => array('HtmlEntities', 'StringTrim', 'StripTags'), 'description' => array('HtmlEntities', 'StringTrim', 'StripTags')); //@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$" //$validators = array('title' => array('StringLength(50)'), 'description' => array('StringLength(50)'), //'sessionid' => array( 'NotEmpty')); $input = new Zend_Filter_Input($filters, null); $input->setData($data); if ($input->isValid()) { //age should be less than 2 hours $q = Doctrine_Query::create()->from('Webteam_Model_Session r')->where('r.SessionID = ?', $input->sessionid); $result = $q->fetchArray(); $UserName = $result[0]['UserName']; if (count($result) >= 1) { $record = new Webteam_Model_Video(); $record->StreamID = uniqid(); $record->Title = $input->title; $record->Description = $input->description; $record->UserName = $UserName; $record->save(); return $record->StreamID; } else { return 'INVALID_SESSIONID'; } } else { return 'INVALID_PARAMETERS'; } }
public function createAction() { $form = new Webteam_Form_VideoCreate(); $this->view->form = $form; //test for valid input // if valid, populate model //assign default values for some fields // save to database if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $item = new Webteam_Model_Video(); $item->fromArray($form->getValues()); $item->save(); $id = $item->VideoID; $this->_helper->getHelper('FlashMessenger')->addMessage('Your submission has been accepted as video #' . $id); $this->_redirect('/catalog/video/success'); } } }