$top_message = array("content" => cw_get_langvar_by_name("txt_survey_is_invalid_customer_warning"), "type" => "E"); cw_header_location("index.php?target=survey"); } $location[] = array($survey['survey']); $smarty->assign('main', "survey"); } elseif ($mode == 'view' && !empty($survey_id)) { $survey = cw_get_survey_results($survey_id); if (empty($survey) || !$survey['valid']) { $top_messsage = array('content' => cw_get_langvar_by_name('txt_survey_is_invalid_customer_warning'), 'type' => 'E'); cw_header_location("index.php?target={$target}"); } if (empty($filled_surveys) || !in_array($survey['survey_id'], $filled_surveys) || $survey['publish_results'] != 'Y' || $survey['count'] == 0) { cw_header_location('index.php?target=' . $target); } # Check count of available and unfilled surveys $avail_unfilled_surveys = cw_get_surveys_ids(true); if (!empty($avail_unfilled_surveys)) { $smarty->assign('avail_unfilled_surveys', true); } $smarty->assign('survey', $survey); $location[] = array(cw_get_langvar_by_name('lbl_survey_surveys'), 'index.php?target=' . $target); $location[] = array(cw_get_langvar_by_name('lbl_survey_results')); $smarty->assign('current_main_dir', 'addons'); $smarty->assign('current_section_dir', 'survey'); $smarty->assign('main', 'view_results'); } else { # Get surveys list $now = time(); $allow_ids = array(); if (!empty($allowed_surveys) && is_array($allowed_surveys)) { $allow_ids = cw_array_merge($allow_ids, array_values($allowed_surveys));
cw_load('surveys'); $filled_surveys =& cw_session_register('filled_surveys'); if (!isset($config['survey_sending_remainder']) || $config['survey']['survey_send_by_c_area_period'] < $config['survey_sending_remainder']) { cw_array2insert("config", array("name" => "survey_sending_remainder", "value" => $config['survey']['survey_send_by_c_area_period']), true); $config['survey_sending_remainder'] = $config['survey']['survey_send_by_c_area_period']; } if (defined("NEW_SESSION")) { $config['survey_sending_remainder']--; if ($config['survey']['survey_send_by_c_area'] && $config['survey_sending_remainder'] <= 0) { cw_send_survey_invitations_list(); $config['survey_sending_remainder'] = $config['survey']['survey_send_by_c_area_period']; } cw_array2update("config", array("value" => $config['survey_sending_remainder']), "name = 'survey_sending_remainder'"); } # Get survey for menu box $avail_surveys = cw_get_surveys_ids(false, 1); if (count($avail_surveys)) { $menu_surveys = array(); foreach ($avail_surveys as $sid) { $survey = cw_get_survey($sid); if ($survey['valid'] && !cw_check_survey_filling($sid)) { $menu_surveys[$sid] = $survey; if ($config['survey']['survey_menu_only_one'] == 'Y') { break; } } } $smarty->assign('menu_surveys', $menu_surveys); $smarty->assign('surveys_is_avail', true); }