Esempio n. 1
0
        }
        ?>
								<span class="pull-right tooltip-hover btn-move-question margin-right-10" title="<?php 
        echo JText::_('LBL_MOVE_TO_PAGE');
        ?>
">
									<i class="fa fa-share"></i>
								</span>
								<span class="pull-right tooltip-hover btn-delete-question margin-right-10" title="<?php 
        echo JText::_('LBL_DELETE_QUESTION');
        ?>
">
									<i class="fa fa-trash-o"></i>
								</span>
								<i class="<?php 
        echo SurveyHelper::get_question_icon($question->question_type);
        ?>
"></i>&nbsp;<span class="qn-title"><?php 
        echo $this->escape($question->title);
        ?>
</span>
							</a>
						</div>
						<div id="qn-<?php 
        echo $question->id;
        ?>
" class="accordion-body collapse">
							<div class="accordion-inner">
								<form class="question-form" action="<?php 
        echo JRoute::_('index.php?option=' . S_APP_NAME . '&view=form&task=save_qn&id=' . $this->item->id . $itemid);
        ?>
Esempio n. 2
0
 private function finalize_response($survey, $response_id, $redirect = true)
 {
     $user = JFactory::getUser();
     $itemid = CJFunctions::get_active_menu_id();
     $model = $this->getModel('survey');
     $app = JFactory::getApplication();
     if ($model->finalize_response($survey->id, $response_id)) {
         $params = JComponentHelper::getParams(S_APP_NAME);
         $userdisplayname = $params->get('user_display_name', 'name');
         SurveyHelper::award_points($params, $survey->created_by, 2, $response_id, JText::sprintf('TXT_RESPONDED_SURVEY', $survey->username, $survey->title));
         SurveyHelper::award_points($params, $user->id, 3, $response_id, JText::sprintf('TXT_RESPONDED_SURVEY', $user->{$userdisplayname}, $survey->title));
         $menuid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=survey');
         $link = $survey->private_survey == 1 ? $survey->title : JHtml::link(JRoute::_('index.php?option=' . S_APP_NAME . '&view=response&task=take_survey&id=' . $survey->id . ":" . $survey->alias . $menuid), $survey->title);
         CJFunctions::stream_activity($params->get('activity_stream_type', 'none'), $user->id, array('command' => 'com_communitysurveys.response', 'component' => S_APP_NAME, 'title' => JText::sprintf('TXT_RESPONDED_SURVEY', '{actor}', $link), 'description' => $survey->introtext, 'length' => $params->get('stream_character_limit', 256), 'icon' => 'components/' . S_APP_NAME . '/assets/images/icon-16-surveys.png', 'group' => 'Surveys'));
         if ($survey->notification == 1 && $params->get('new_response_notification', 1) == 1) {
             $from = $app->getCfg('mailfrom');
             $fromname = $app->getCfg('fromname');
             $link = JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=dashboard&id=' . $survey->id . ':' . $survey->alias . $itemid, false, -1);
             $body = '';
             if ($survey->anonymous == 1) {
                 $body = JText::sprintf('EMAIL_NEW_RESPONSE_ANONYMOUS_BODY', $survey->username, $survey->title, $link, $app->getCfg('sitename'));
             } else {
                 $body = JText::sprintf('EMAIL_NEW_RESPONSE_BODY', $survey->username, $user->username, $survey->title, $link, $app->getCfg('sitename'));
             }
             if ($params->get('embed_pdf_report', 1) == 1) {
                 // All validations done, write data now
                 require_once JPATH_COMPONENT_SITE . '/helpers/reports.php';
                 $generator = new SurveyReports();
                 $filePath = JPATH_ROOT . '/tmp/survey_' . $survey->id . '_' . date('dmYHis') . '.pdf';
                 $pdfData = $model->get_reponse_data_for_csv($survey->id, array($response_id), true);
                 $generator->generatePdfReport($pdfData, 'F', $params, $filePath);
                 CJFunctions::send_email($from, $fromname, $survey->email, JText::_('EMAIL_NEW_RESPONSE_TITLE'), $body, 1, null, null, $filePath);
             } else {
                 CJFunctions::send_email($from, $fromname, $survey->email, JText::_('EMAIL_NEW_RESPONSE_TITLE'), $body, 1, null, null);
             }
         }
         if ($redirect) {
             if (empty($survey->redirect_url)) {
                 if ($survey->public_permissions == '1' && $user->authorise('core.results', S_APP_NAME)) {
                     $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=response&task=view_result&id=' . $survey->id . ':' . $survey->alias . '&rid=' . $response_id . $itemid, false), JText::_('MSG_SURVEY_COMPLETE'));
                 } else {
                     $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=response&task=end_message&id=' . $survey->id . ':' . $survey->alias . $itemid, false), JText::_('MSG_SURVEY_COMPLETE'));
                 }
             } else {
                 $this->setRedirect($survey->redirect_url, JText::_('MSG_SURVEY_COMPLETE'));
             }
         } else {
             return true;
         }
     } else {
         $msg = S_DEBUG_ENABLED ? JText::_('MSG_ERROR_PROCESSING') . $model->getError() : JText::_('MSG_ERROR_PROCESSING');
         if ($redirect) {
             $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey&task=take_survey&id=' . $survey->id . $itemid, false), $msg);
         } else {
             return false;
         }
     }
 }