Beispiel #1
0
 function edit_questions()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $itemid = CJFunctions::get_active_menu_id();
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
     } else {
         $app = JFactory::getApplication();
         $id = $app->input->getInt('id', 0);
         if (!$id) {
             CJFunctions::throw_error(JText::_('MSG_UNAUTHORIZED'), 401);
         } else {
             if (!$this->authorize_survey($id)) {
                 $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $survey_itemid, false), JText::_('MSG_UNAUTHORIZED'));
             } else {
                 $view = $this->getView('form', 'html');
                 $model = $this->getModel('survey');
                 $view->setModel($model, true);
                 $view->assign('action', 'questions');
                 $view->display();
             }
         }
     }
 }
Beispiel #2
0
 public function get_my_responses()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $itemid = CJFunctions::get_active_menu_id();
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
     } else {
         $model = $this->getModel('survey');
         $view = $this->getView('user', 'html');
         $view->setModel($model, true);
         $view->assign('action', 'responses');
         $view->display('responses');
     }
 }
Beispiel #3
0
 public function get_invite_page()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $itemid = CJFunctions::get_active_menu_id();
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
     } else {
         $app = JFactory::getApplication();
         $model = $this->getModel('survey');
         $usermodel = $this->getModel('users');
         $survey_id = $app->input->getInt('id', 0);
         if (($user->authorise('core.create', S_APP_NAME) || $user->authorise('core.manage', S_APP_NAME)) && $model->authorize_survey($survey_id)) {
             $view = $this->getView('invite', 'html');
             $view->setModel($model, true);
             $view->setModel($usermodel, false);
             $view->display();
         }
     }
 }
Beispiel #4
0
 function edit_questions()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $itemid = CJFunctions::get_active_menu_id();
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=surveys' . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
     } else {
         $app = JFactory::getApplication();
         $id = $app->input->getInt('id', 0);
         if (!$id || !$user->authorise('core.edit', S_APP_NAME) && !$user->authorise('core.manage', S_APP_NAME)) {
             CJFunctions::throw_error(JText::_('MSG_UNAUTHORIZED'), 401);
         } else {
             $view = $this->getView('form', 'html');
             $model = JModelLegacy::getInstance('survey', 'CommunitySurveysModel');
             $view->setModel($model, true);
             $view->assign('action', 'questions');
             $view->display();
         }
     }
 }
Beispiel #5
0
 function get_all_surveys()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $itemid = CJFunctions::get_active_menu_id();
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey&task=all' . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
     } else {
         if ($user->authorise('core.manage', S_APP_NAME)) {
             $view = $this->getView('survey', 'html');
             $model = $this->getModel('survey');
             $users_model = $this->getModel('users');
             $categories_model = $this->getModel('categories');
             $view->setModel($model, true);
             $view->setModel($users_model, false);
             $view->setModel($categories_model, false);
             $view->assign('action', 'all_surveys');
             $view->display();
         } else {
             CJFunctions::throw_error(JText::_('MSG_UNAUTHORIZED'), 401);
         }
     }
 }
Beispiel #6
0
 function download_pdf_report()
 {
     $itemid = CJFunctions::get_active_menu_id();
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $surveyId = $app->input->getInt('id', 0);
     $params = JComponentHelper::getParams(S_APP_NAME);
     if ($user->guest) {
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=dashboard&id=' . $surveyId . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
         return;
     }
     if (!$user->authorise('core.create', S_APP_NAME) && !$user->authorise('core.manage', S_APP_NAME)) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid), JText::_('MSG_UNAUTHORIZED'));
         return;
     }
     if (!$surveyId) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid), JText::_('MSG_UNAUTHORIZED'));
         return;
     }
     $cids = $app->input->post->getArray(array('cid' => 'array'));
     JArrayHelper::toInteger($cids['cid']);
     if (empty($cids['cid'])) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=responses&id=' . $surveyId . $itemid, false), JText::_('MSG_SELECT_ITEMS_TO_CONTINUE'));
         return;
     }
     $model = $this->getModel('survey');
     $pdfData = $model->get_reponse_data_for_csv($surveyId, $cids['cid']);
     if (empty($pdfData)) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=dashboard&id=' . $surveyId . $itemid), JText::_('MSG_ERROR_PROCESSING') . $model->getError());
         return;
     }
     // All validations done, write data now
     require_once JPATH_COMPONENT_SITE . '/helpers/reports.php';
     $generator = new SurveyReports();
     $fileName = 'survey_' . $surveyId . '_' . date('dmYHis') . '.pdf';
     $generator->generatePdfReport($pdfData, 'D', $params, $fileName);
     jexit();
 }