예제 #1
0
 public function editAction()
 {
     // 		$ddl_faq_category = Zend_Registry::get('ddl_faq_category');
     //		$this->view->ddl_faq_category = $ddl_faq_category;
     $faqs = new Application_Model_Faqs();
     $ddl_faq_category = $faqs->fetchCategoryItems(1);
     $this->view->ddl_faq_category = $ddl_faq_category;
     $faqid = $this->request->getParam('id');
     if ($faqid) {
         $faqObj = new Application_Model_Faqs();
         $faqdetails = $faqObj->getformDetails($faqid);
         if (count($faqdetails) == 0) {
             $this->_redirector->gotoUrl('/faq/index/');
         }
         $this->view->category = $faqdetails[0]['category'];
         $this->view->faq_question = $faqdetails[0]['faq_question'];
         $this->view->faq_answer = $faqdetails[0]['faq_answer'];
         if ($this->request->isPost()) {
             $faqid = $this->request->getParam('id');
             if (!empty($faqid)) {
                 $userid = $this->user->getId();
                 $faqArray = array();
                 $faqArray = array("category" => $this->request->getParam('category'), "faq_question" => $this->request->getParam('questions'), "faq_answer" => $this->request->getParam('answer'), "modified_by" => $userid);
                 $faqUpdate = $faqObj->updateFormValues($faqid, $faqArray);
                 $this->_redirect('faq/');
             } else {
                 $message['type'] = "error";
                 $message['body'] = "Please Enter all Values.";
             }
         }
     } else {
         $this->_redirector->gotoUrl('/faq/');
     }
 }
예제 #2
0
 public function addAction()
 {
     //
     // 		$ddl_support_type = Zend_Registry::get('ddl_support_type');
     //		$this->view->ddl_support_type = $ddl_support_type;
     $faqs = new Application_Model_Faqs();
     $ddl_support_type = $faqs->fetchCategoryItems(3);
     $this->view->ddl_support_type = $ddl_support_type;
     $error = null;
     $status = null;
     $uname = $this->user->username();
     $this->view->uname = $uname;
     if ($this->request->isPost()) {
         $support = new Application_Model_Support();
         $userid = $this->user->getId();
         $supportArray = array();
         $supportArray = array("name" => trim($this->request->name), "email" => trim($this->request->email), "contactnumber" => trim($this->request->contactnumber), "support_type" => trim($this->request->support_type), "subject" => trim($this->request->subject), "status_type" => trim($this->request->status_type), "message" => trim($this->request->message), "created_by" => $userid);
         //echo '<pre>dgdfgdf';print_r($this->request->getParam('name'));
         //echo '<pre>';print_r($supportArray);
         //echo '<pre>';print_r($_FILES);die;
         if ($support->add($userid, $supportArray)) {
             $status = 'Support Added';
         } else {
             $error = 'Support Error: ' . $support->getError() . mysql_error();
         }
         $bodyText = "New Support:\n\r";
         $bodyText .= "Name: " . $this->request->name . "\n\r";
         $bodyText .= "Contact Number: " . $this->request->contactnumber . "\n\r";
         $bodyText .= "Support Type: " . $this->request->support_type . "\n\r";
         $bodyText .= "Subject: " . $this->request->subject . "\n\r";
         $bodyText .= "Status: " . $this->request->status_type . "\n\r";
         $bodyText .= "Message: " . $this->request->message . "\n\r";
         $bodyText .= "Regards\n\r";
         $bodyText .= "Textmunication.com\n\r";
         $mail = new Zend_Mail();
         $mail->setBodyText($bodyText);
         $mail->setFrom($this->request->email, $this->request->name);
         $mail->addTo('*****@*****.**', 'Textmunication.com');
         //$mail->addTo('*****@*****.**', 'Textmunication.com');
         //$mail->addCc('*****@*****.**', 'Wais Asefi');
         $mail->setSubject('New Support');
         if (isset($_FILES['uploaded_files'])) {
             foreach ($_FILES['uploaded_files']['name'] as $key => $value) {
                 if (is_uploaded_file($_FILES['uploaded_files']['tmp_name'][$key]) && $_FILES['uploaded_files']['error'][$key] == 0 && $_FILES['uploaded_files']['size'][$key] < 1048576) {
                     $filename = $_FILES['uploaded_files']['name'][$key];
                     //$id = $this->user->getId();
                     //$filetype = $_FILES['uploaded_files']['size'][$key];
                     $lastid = $support->supportId($userid);
                     //echo '<pre>';print_r($_FILES);die;
                     $lastidValue = $lastid[0]['last'];
                     $filename = $lastidValue . '-' . $filename;
                     if (move_uploaded_file($_FILES['uploaded_files']['tmp_name'][$key], '../public/uploads/' . $filename)) {
                         $support = new Application_Model_Support();
                         //$userid = $this->user->getId();
                         $supportattach = $filename;
                         if ($support->supportAttach($supportattach, $lastidValue)) {
                             $at = $mail->createAttachment(file_get_contents('../public/uploads/' . $supportattach));
                             $at->filename = $supportattach;
                             $status = 'Support Added';
                         } else {
                             $error = 'Support Error: ' . $support->getError() . mysql_error();
                         }
                     } else {
                         $error = 'The file was not moved.';
                     }
                 } else {
                     $error = 'The file was not uploaded size greater then 1MB.';
                 }
             }
         }
         if ($mail->send()) {
             $status = 'Support Added and mail Sent';
         }
         $this->view->status = $status;
         $this->view->error = $error;
         //$action = 'list';
         //return $this->_forward('list',null,null,array(null));
         return $this->_redirect('support/list');
     }
 }
예제 #3
0
 public function addAction()
 {
     //		$ddl_video_category = Zend_Registry::get('ddl_video_category');
     //		$this->view->ddl_video_category = $ddl_video_category;
     $faqs = new Application_Model_Faqs();
     $ddl_video_category = $faqs->fetchCategoryItems(2);
     $this->view->ddl_video_category = $ddl_video_category;
     if ($this->request->isPost()) {
         $videos = new Application_Model_Videos();
         $userid = $this->user->getId();
         $actiontype = $this->request->getParam('actiontype');
         if ($actiontype == 'upload') {
             $target_path = '../public/videos/';
             $id = $this->user->getId();
             $filename = $this->request->getParam('category') . '-' . $_FILES['video_name']['name'];
             $target_path = $target_path . basename($filename);
             $videosArray = array();
             $videosArray = array("category" => $this->request->getParam('category'), "video_title" => $this->request->getParam('video_title'), "video_description" => $this->request->getParam('video_description'), "video_name" => $filename, "modified_by" => $userid);
             $error = "";
             if ($_FILES['video_name']['type'] == 'video/mp4') {
                 if (move_uploaded_file($_FILES['video_name']['tmp_name'], $target_path)) {
                     if ($videos->add($userid, $videosArray)) {
                         $message = 'Video Added.';
                     } else {
                         $error = 'Video error: ' . $videos->getError();
                     }
                 } else {
                     $error = 'There was an error uploading the file, please try again!';
                 }
             } else {
                 $error = 'Video format not supported..!';
             }
         }
         if (empty($error)) {
             return $this->_redirect('videos/index');
         } else {
             $this->view->error = $error;
             $this->view->video_title = $this->request->getParam('video_title');
             $this->view->video_description = $this->request->getParam('video_description');
             $this->view->category = $this->request->getParam('category');
         }
     }
 }