komentarji) * */ class SurveyComments { var $anketa; var $db_table = ''; public function __construct($anketa){ if($anketa == null || $anketa <= 0) return 'ID ankete ne obstaja!'; $this->anketa = $anketa; $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString(); } // Izpis komentarjev (testiranje -> komentarji) public function display_komentarji(){ // Izpisemo meni (2 zavihka na vrhu) $this->display_menu_komentarji(); // Izpisemo vsebino glede na zavihek if($_GET['a'] == 'komentarji'){ $this->display_komentarji_na_vprasanja(); } else{ $this->display_splosni_komentarji(); } } // Meni na vrhu (preklop med splosnimi in komentarji na vprasanja) private function display_menu_komentarji() { global $lang; // Prestejemo komentarje (nereseni/vsi) $comment_count = $this->testiranje_komentarji_count(); echo '
'; echo '
'; // Komentarji na vprasanja $question_comment_link = 'window.location.href=\'index.php?anketa=' . $this->anketa . '&a=' . A_KOMENTARJI_ANKETA . '\'; return false;'; echo '
'; echo $lang['srv_testiranje_komentarji_anketa_title']; echo ' (' . ($comment_count['survey_resp']['unresolved'] + $comment_count['survey_admin']['unresolved']); //nerešeni echo '/' . ($comment_count['survey_resp']['all'] + $comment_count['survey_admin']['all']) . ')'; //vsi echo '
'; // Komentarji na anketo $survey_comment_link = 'window.location.href=\'index.php?anketa=' . $this->anketa . '&a=' . A_KOMENTARJI . '\'; return false;'; echo '
'; echo $lang['srv_testiranje_komentarji_title']; echo ' (' . $comment_count['question']['unresolved']; echo '/' . $comment_count['question']['all'] . ')'; echo '
'; echo '
'; //#komentarji_list //Link na nastavitev komentarjev $d = new Dostop(); # nastavitve komentarjev if ($d->checkDostopSub('edit')) { echo '
'; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo '
'; } echo '
'; } // Izpis zavihka SPLOSNI KOMENTARJI private function display_splosni_komentarji() { global $lang; global $site_url; global $admin_type; global $global_user_id; $b = new Branching($this->anketa); $f = new Forum; $d = new Dostop(); SurveySetting::getInstance()->Init($this->anketa); $sortpostorder = SurveySetting::getInstance()->getSurveyMiscSetting('sortpostorder'); $survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment'); $survey_comment_resp = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment_resp'); $comment_count = $this->testiranje_komentarji_count(); $commentmarks = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks'); $commentmarks_who = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks_who'); $sortpostorder = ($sortpostorder == '') ? 0 : $sortpostorder; $commentmarks = ($commentmarks == '') ? 0 : $commentmarks; $commentmarks_who = ($commentmarks_who == '') ? 0 : $commentmarks_who; $rowa = SurveyInfo::getInstance()->getSurveyRow(); # VV: privzeto naj bodo samo nerešeni komentarji if (!isset($_GET['only_unresolved'])) { $_GET['only_unresolved'] = 1; } # samo nerešeni komentarji if ($commentmarks == 0) { echo '
'; echo ''; echo ''; echo '
'; } else { echo $lang['move_show'].': '; } $only_unresolved = " "; switch($_GET['only_unresolved']){ case 1: $only_unresolved = " AND ocena <= '1' "; break; case 2: $only_unresolved = " AND ocena = '0' "; break; case 3: $only_unresolved = " AND ocena = '1' "; break; case 4: $only_unresolved = " AND ocena = '2' "; break; case 5: $only_unresolved = " AND ocena = '3' "; break; default: break; } echo '
'; // Splosni komentarji urednikov - levo echo '
'; echo '
'; echo $lang['srv_admin_comment'].':'; /*Sort echo ''; echo '';*/ echo '
'; $sql = sisplet_query("SELECT * FROM post WHERE tid='$rowa[thread]' ".$only_unresolved." "); $rows = (mysqli_num_rows($sql) == 0) ? 0 : mysqli_num_rows($sql) - 1; if ($rows > 0){ $i=0; while ($row = mysqli_fetch_array($sql)) { if (($i != 0 && $sortpostorder==0) || ($i < $rows && $sortpostorder==1)) { echo '
'; echo '
'; $datetime = strtotime($row['time']); $datetime = date("d.m.Y G:i", $datetime); echo '

'.$lang['srv_comments_user'].''.$f->user($row['uid']).' ('.$datetime.')

'; if ($admin_type <= 1 || $rowa['insert_uid']==$global_user_id || $commentmarks_who==0) { echo '
'; echo '
'; if ($row['ocena']==0) { echo '

'; echo $lang['srv_comments_archive'].'

'; } else { echo '

'; echo $lang['srv_comments_unarchive'].'

'; } echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo $lang['srv_comment_delete']; echo '
'; echo '
'; //Klik izven razprith nastavitev - zapremo okno echo ''; echo '
'; //options } echo '
'; //by echo '
'; echo $row['vsebina']; echo '
'; echo '
'; echo '
'; } $i++; } } // Nimamo komentarja else{ // Ce so komentarji aktivirani if($survey_comment != ''){ echo '

'.$lang['srv_no_comments_solved'].'

'; } else{ echo '

'.$lang['srv_no_comments'].'

'; } } // Dodajanje novega komentarja echo '
'; echo ''; echo $lang['srv_survey_general_comment']; echo '
'; echo '
'; echo '
'; $ba = new BranchingAjax($this->anketa); $ba->add_comment_field(0, '1', '4', false); echo '
'; echo '
'; echo '
'; // Splosni komentarji respondentov - desno echo '
'; echo '
'; echo $lang['srv_repondent_comment'].':'; /*Sort echo ''; echo '';*/ echo '
'; $orderby = ''; $sql = sisplet_query("SELECT * FROM srv_comment_resp WHERE ank_id='$this->anketa' ".$only_unresolved." ORDER BY comment_time $orderby, id $orderby"); if (mysqli_num_rows($sql) > 0) { while ($row = mysqli_fetch_array($sql)) { echo '
'; $datetime = strtotime($row['comment_time']); $datetime = date("d.m.Y G:i", $datetime); echo '
'; if($row['usr_id'] == 0){ echo '

Respondent ('.$datetime.')

'; } else{ $sqlU = sisplet_query("SELECT name FROM users WHERE id='$row[usr_id]'"); $rowU = mysqli_fetch_array($sqlU); $user = $rowU['name']; echo '

'.$lang['srv_comments_user'].''.$user.' ('.$datetime.')

'; } if ($admin_type <= 1 || $rowa['insert_uid']==$global_user_id || $commentmarks_who==0) { echo '
'; echo '
'; if ($row['ocena']==0) { echo '

'; echo $lang['srv_comments_archive'].'

'; } else { echo '

'; echo $lang['srv_comments_unarchive'].'

'; } echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo $lang['srv_comment_delete']; echo '
'; echo '
'; //Klik izven razprith nastavitev - zapremo okno echo ''; echo '
'; //options } echo '
'; //by echo '
'; echo $row['comment']; echo '
'; echo '
'; echo '
'; } } // Nimamo komentarja else{ // Ce so komentarji aktivirani if($survey_comment_resp != ''){ echo '

'.$lang['srv_no_comments_solved'].'

'; } else{ echo '

'.$lang['srv_no_comments'].'

'; } } echo '
'; echo '
'; // div.komentarji_anketa_holder } // Izpis zavihka KOMENTARJI NA VPRASANJA private function display_komentarji_na_vprasanja() { global $lang; global $site_url; global $admin_type; global $global_user_id; $lang_admin = $lang; //$sa = new SurveyAdmin(1, $this->anketa); include_once('../../main/survey/app/global_function.php'); new \App\Controllers\SurveyController(true); save('forceShowSpremenljivka', true); $f = new Forum; $c = 0; $lang = $lang_admin; $b = new Branching($this->anketa); $d = new Dostop(); $rowi = SurveyInfo::getInstance()->getSurveyRow(); SurveySetting::getInstance()->Init($this->anketa); $question_resp_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_viewadminonly'); $question_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewadminonly'); $question_comment_viewauthor = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewauthor'); $sortpostorder = SurveySetting::getInstance()->getSurveyMiscSetting('sortpostorder'); $question_note_view = SurveySetting::getInstance()->getSurveyMiscSetting('question_note_view'); $addfieldposition = SurveySetting::getInstance()->getSurveyMiscSetting('addfieldposition'); $commentmarks = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks'); $commentmarks_who = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks_who'); $sortpostorder = ($sortpostorder == '') ? 0 : $sortpostorder; $commentmarks = ($commentmarks == '') ? 0 : $commentmarks; $commentmarks_who = ($commentmarks_who == '') ? 0 : $commentmarks_who; $question_comment_viewadminonly = ($question_comment_viewadminonly == '') ? 4 : $question_comment_viewadminonly; $question_resp_comment_viewadminonly = ($question_resp_comment_viewadminonly == '') ? 4 : $question_resp_comment_viewadminonly;; $comment_count = $this->testiranje_komentarji_count(); # VV: privzeto naj bodo samo nerešeni komentarji if (!isset($_GET['only_unresolved'])) { $_GET['only_unresolved'] = 1; } $sqlf1 = sisplet_query("SELECT p.id FROM post p WHERE p.tid='$rowi[thread]' AND p.ocena='5'"); while ($rowf1 = mysqli_fetch_array($sqlf1)) { $s = sisplet_query("SELECT * FROM views WHERE pid='$rowf1[id]' AND uid='$global_user_id'"); if (mysqli_num_rows($s) == 0) $show_survey_comment = 1; } // vsa vprasanja echo '
'; echo '
'; echo ''; echo ''; echo '
'; # samo nerešeni komentarji if ($commentmarks == 0) { echo '
'; echo ''; echo ''; echo '
'; } else { echo $lang['move_show'].': '; } echo '
'; // echo ' '.Help::display('srv_comments_only_unresolved').''; // Nov nacin kjer se sprehodimo cez branching, ker imamo lahko tudi komentarje na ife in bloke Common::getInstance()->Init($this->anketa); $branching_array = Common::getBranchingOrder(); if (count($branching_array) > 0) { $view = 1; $b = new Branching($this->anketa); echo ''; if ($c == 0) { echo '
'; echo $lang['srv_no_comments_solved']; #echo ''.$lang['srv_settings_komentarji'].''; echo '
'; } } else { echo '
'; echo $lang['srv_no_comments']; echo '
'; } echo ''; // branching echo '
'; } // Izpis ikone v navigacijskem meniju public function display_comments_icon(){ global $site_url; global $global_user_id; global $lang; $userAccess = UserAccess::getInstance($global_user_id); SurveySetting::getInstance()->Init($this->anketa); $survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment'); $question_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment'); $question_note_view = SurveySetting::getInstance()->getSurveyMiscSetting('question_note_view'); $question_resp_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment'); if ($survey_comment != '' || $question_comment != '' || $question_resp_comment == 1 || $this->testiranje_komentarji_komentarji_na_vprasanje(false) > 0) { echo '
  • '; echo '
  • '; } // ce ni komentarjev, potem prikazemo link do nastavitev komentarjev else { echo '
  • '; echo '
  • '; } } // Vrstica s komentarji pod posameznim vprasanjem v urejanju ankete public function display_vprasanje_komentarji ($spremenljivka) { global $lang; global $admin_type; global $global_user_id; SurveySetting::getInstance()->Init($this->anketa); $question_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment'); $question_resp_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment'); $question_resp_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_viewadminonly'); $question_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewadminonly'); $question_comment_viewauthor = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewauthor'); if (!($admin_type <= $question_comment && $question_comment!='') && !($question_resp_comment==1)) return; if ($_GET['a'] == 'komentarji') return; // v komentarjih tut ne izpisujemo te vrstice $tema_vsebuje = substr($lang['srv_forum_intro'], 0, 10); // da ne prikazujemo 1. default sporocila $f = new Forum; echo '
    '; // komentarji na vprasanje if ($admin_type <= $question_comment && $question_comment != '') { // GUMB Dodaj komentar echo '
    '; echo ' '; echo '
    '; // POPUP za dodaj komentar echo '
    '; echo '
    '; echo '
    '; echo ''; echo $lang['srv_add_comment']; echo '
    '; echo ''; echo '
    '; echo '
    '; $ba = new BranchingAjax($this->anketa); $ba->add_comment_field($spremenljivka, '1', '0', false, false); echo '
    '; echo '
    '; echo ' '; echo ' '; echo '
    '; echo '
    '; //comment_inline_popup // Klik izven - zapremo popup echo ''; // Poglej komentarje if ($admin_type <= $question_comment_viewadminonly || $question_comment_viewauthor==1) { // Dobimo seznam komentarjev $row = Cache::srv_spremenljivka($spremenljivka); if ($row['thread'] == 0) { $post_count = 0; } else { if ($admin_type <= $question_comment_viewadminonly) { $sqlP = sisplet_query("SELECT * FROM post WHERE tid='$row[thread]' AND vsebina NOT LIKE '%{$tema_vsebuje}%' ORDER BY time"); } elseif ($question_comment_viewauthor==1) { $sqlP = sisplet_query("SELECT * FROM post WHERE tid='$row[thread]' AND uid='$global_user_id' AND vsebina NOT LIKE '%{$tema_vsebuje}%' ORDER BY time"); } else { $sqlP = sisplet_query("SELECT * FROM post WHERE 1 = 0"); } $post_count = mysqli_num_rows($sqlP); } // GUMB za poglej komentarje echo '
    '; echo ' '; echo '
    '; // POPUP za poglej komentarje echo '
    '; echo '
    '; echo '
    '; echo ''; echo $lang['srv_admin_comment']; echo '
    '; echo ''; echo '
    '; // Izpisemo seznam komentarjev if($post_count > 0){ while($rowP = mysqli_fetch_array($sqlP)){ echo '
    '; echo '
    '; $datetime = strtotime($rowP['time']); $datetime = date("d.m.Y G:i", $datetime); echo '

    '.$f->user($rowP['uid']).' ('.$datetime.')

    '; // Razresi echo '
    '; if ($rowP['ocena']==0) { echo '

    '; echo $lang['srv_comments_archive'].'

    '; } else { echo '

    '; echo $lang['srv_comments_unarchive'].'

    '; } echo '
    '; echo '
    '; //by echo '
    '; echo $rowP['vsebina']; echo '
    '; echo '
    '; } } echo '
    '; echo ''; echo '
    '; echo '
    '; //comment_inline_popup // Klik izven - zapremo popup echo ''; } } // komentarji respondentov if (($question_resp_comment==1) AND ($admin_type <= $question_resp_comment_viewadminonly)) { // Dobimo seznam komentarjev respondentov $sqlP = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='0' AND vre_id='$spremenljivka' ORDER BY id ASC"); $post_count = mysqli_num_rows($sqlP); if ($post_count > 0) { // GUMB za komentarji respondentov echo '
    '; echo ' '; echo '
    '; // POPUP za komentarji respondentov echo '
    '; echo '
    '; echo '
    '; echo ' '; echo $lang['srv_repondent_comment']; echo '
    '; echo ' '; echo '
    '; // Izpisemo seznam komentarjev while($rowP = mysqli_fetch_array($sqlP)){ echo '
    '; // Ce smo slucajno pobrisali testne vnose, nimamo casa vnosa komentarja $sqlTime = sisplet_query("SELECT time_edit FROM srv_user WHERE id='".$rowP['usr_id']."'"); if(mysqli_num_rows($sqlTime) > 0){ $rowTime = mysqli_fetch_array($sqlTime); echo '
    '; if ( strpos($rowP['text'], '__DATE__') !== false ) { $rowP['text'] = str_replace('__DATE__', $f->datetime1($rowTime['time_edit']), $rowP['text']); $datetime = '-'; } else { $datetime = strtotime($rowTime['time_edit']); $datetime = date("d.m.Y G:i", $datetime); } echo '

    Respondent ('.$datetime.')

    '; // Razresi echo '
    '; if ($rowP['text2']==0) { echo '

    '; echo $lang['srv_comments_archive'].'

    '; } else { echo '

    '; echo $lang['srv_comments_unarchive'].'

    '; } echo '
    '; echo '
    '; //by } else{ if ( strpos($rowP['text'], '__DATE__') !== false ) { $rowP['text'] = str_replace('__DATE__', '', $rowP['text']); } } echo '
    '; echo nl2br($rowP['text']); echo '
    '; echo '
    '; } echo '
    '; echo ' '; echo '
    '; echo '
    '; //comment_inline_popup // Klik izven - zapremo popup echo ''; } echo ''; } echo '
    '; } // Vrstica s komentarji pod posameznim blokom ali ifom v urejanju ankete public function display_if_komentarji ($if_id, $block=0) { global $lang; global $admin_type; global $global_user_id; SurveySetting::getInstance()->Init($this->anketa); $question_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment'); $question_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewadminonly'); $question_comment_viewauthor = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewauthor'); if (!($admin_type <= $question_comment && $question_comment!='')) return; if ($_GET['a'] == 'komentarji') return; // v komentarjih tut ne izpisujemo te vrstice $f = new Forum; $tema_vsebuje = substr($lang['srv_forum_intro'], 0, 10); // da ne prikazujemo 1. default sporocila $type = ($block == 1) ? '6' : '5'; // komentarji na if ali blok if ($admin_type <= $question_comment && $question_comment != '') { echo '
    '; // Dobimo seznam komentarjev $row = Cache::srv_if($if_id); if ($row['thread'] == 0) { $post_count = 0; } else { if ($admin_type <= $question_comment_viewadminonly) { $sqlP = sisplet_query("SELECT * FROM post WHERE tid='$row[thread]' AND vsebina NOT LIKE '%{$tema_vsebuje}%' ORDER BY time"); } elseif ($question_comment_viewauthor==1) { $sqlP = sisplet_query("SELECT * FROM post WHERE tid='$row[thread]' AND uid='$global_user_id' AND vsebina NOT LIKE '%{$tema_vsebuje}%' ORDER BY time"); } else { $sqlP = sisplet_query("SELECT * FROM post WHERE 1 = 0"); } $post_count = mysqli_num_rows($sqlP); } // Poglej komentarje if ($admin_type <= $question_comment_viewadminonly || $question_comment_viewauthor==1) { // GUMB za poglej komentarje echo '
    '; echo ' '; echo '
    '; // POPUP za poglej komentarje echo '
    '; echo '
    '; echo '
    '; echo ''; echo $lang['srv_admin_comment']; echo '
    '; echo ''; echo '
    '; // Izpisemo seznam komentarjev if($post_count > 0){ while($rowP = mysqli_fetch_array($sqlP)){ echo '
    '; echo '
    '; $datetime = strtotime($rowP['time']); $datetime = date("d.m.Y G:i", $datetime); echo '

    '.$f->user($rowP['uid']).' ('.$datetime.')

    '; // Razresi echo '
    '; if ($rowP['ocena']==0) { echo '

    '; echo $lang['srv_comments_archive'].'

    '; } else { echo '

    '; echo $lang['srv_comments_unarchive'].'

    '; } echo '
    '; echo '
    '; //by echo '
    '; echo $rowP['vsebina']; echo '
    '; echo '
    '; } } echo '
    '; echo ''; echo '
    '; echo '
    '; //comment_inline_popup // Klik izven - zapremo popup echo ''; } // GUMB Dodaj komentar echo '
    '; echo ' '; echo '
    '; // POPUP za dodaj komentar echo '
    '; echo '
    '; echo '
    '; echo ''; echo $lang['srv_add_comment']; echo '
    '; echo ''; echo '
    '; echo '
    '; $ba = new BranchingAjax($this->anketa); $ba->add_comment_field($if_id, $type, '0', false, false); echo '
    '; echo '
    '; echo ' '; echo ' '; echo '
    '; echo '
    '; //comment_inline_popup // Klik izven - zapremo popup echo ''; echo '
    '; } } // $return pove a vrne text (true) ali samo številko (false) private function testiranje_komentarji_komentarji_na_vprasanje ($return = true) { # naenkrat preberemo vse spremenljivke, da ne delamo queryja vsakic posebej $spremenljivke = Cache::cache_all_srv_spremenljivka($this->anketa, true); $spr_id = array(); $threads = array(); $rowqr = array(); $rowqrf = array(); $rowtqa = array(); $rowtqu = array(); if ( is_array($spremenljivke) && count($spremenljivke) > 0 ) { foreach ($spremenljivke as $id=>$value) { $spr_id[] = $id; if ((int)$value['thread'] > 0) { $threads[] = $value['thread']; } } } if (count($spr_id) > 0) { #preštejemo komentarje uporabnikov na vprašanja # srv_data_text where spr_id = 0 AND vre_id IN (id-ji spremenljivk) $strqr = "SELECT count(*) FROM srv_data_text".$this->db_table." WHERE spr_id=0 AND vre_id IN (".implode(',',$spr_id).")"; $sqlqr = sisplet_query($strqr); list($rowqr) = mysqli_fetch_row($sqlqr); #končani komentarji respondentov #text2 = 2 => končan #text2 = 3 => nerelevantno $strqrf = "SELECT count(*) FROM srv_data_text".$this->db_table." WHERE spr_id=0 AND vre_id IN (".implode(',',$spr_id).") AND text2 IN (2,3)"; $sqlqrf = sisplet_query($strqrf); list($rowqrf) = mysqli_fetch_row($sqlqrf); # preštejemo if (count($threads) > 0) { # vsi komentarji na anketo $strta = "SELECT count(*) FROM post WHERE tid IN (".implode(',',$threads).") AND parent > 0"; $sqlta = sisplet_query($strta); list($rowtqa) = mysqli_fetch_row($sqlta); # nerešeni komentarji: only_unresolved => ocena <= 1 $strtu = "SELECT count(*) FROM post WHERE tid IN (".implode(',',$threads).") AND parent > 0 AND ocena IN (2,3) "; $sqltu = sisplet_query($strtu); list($rowtqu) = mysqli_fetch_row($sqltu); } } #vsi $all = (int)((int)$rowqr + (int)$rowtqa); # nerešeni $unresolved = $all - (int)((int)$rowqrf + (int)$rowtqu); if ($return) // '('.$unresolved.'/'.$all.')'; return $unresolved; else return $unresolved; } // Prestejemo vse komentarje private function testiranje_komentarji_count () { $comment_count = array(); $rowi = SurveyInfo::getInstance()->getSurveyRow(); // KOMENTARJI NA ANKETO - UREDNIK # vsi komentarji na anketo $strta = "SELECT count(*) FROM post WHERE tid='".$rowi['thread']."' AND parent > 0"; $sqlta = sisplet_query($strta); list($rowta) = mysqli_fetch_row($sqlta); # nerešeni komentarji: only_unresolved => ocena <= 1 $strtu = "SELECT count(*) FROM post WHERE tid='".$rowi['thread']."' AND parent > 0 AND ocena <= 1 "; $sqltu = sisplet_query($strtu); list($rowtu) = mysqli_fetch_row($sqltu); //(int)$rowtu.'/'.(int)$rowta; $comment_count['survey_admin']['all'] = (int)$rowta; $comment_count['survey_admin']['unresolved'] = (int)$rowtu; // KOMENTARJI NA ANKETO - RESPONDENT # vsi komentarji na anketo $strta = "SELECT count(*) FROM srv_comment_resp WHERE ank_id='".$this->anketa."'"; $sqlta = sisplet_query($strta); list($rowta) = mysqli_fetch_row($sqlta); # nerešeni komentarji: only_unresolved => ocena <= 1 $strtu = "SELECT count(*) FROM srv_comment_resp WHERE ank_id='".$this->anketa."' AND ocena <= 1 "; $sqltu = sisplet_query($strtu); list($rowtu) = mysqli_fetch_row($sqltu); //(int)$rowtu.'/'.(int)$rowta; $comment_count['survey_resp']['all'] = (int)$rowta; $comment_count['survey_resp']['unresolved'] = (int)$rowtu; // KOMENTARJI NA VPRASANJE # naenkrat preberemo vse spremenljivke, da ne delamo queryja vsakic posebej $spremenljivke = Cache::cache_all_srv_spremenljivka($this->anketa, true); $spr_id=array(); $threads=array(); if ( is_array($spremenljivke) && count($spremenljivke) > 0 ) { foreach ($spremenljivke as $id=>$value) { $spr_id[] = $id; if ((int)$value['thread'] > 0) { $threads[] = $value['thread']; } } } $rowqr = array(); $rowtqa = array(); $rowqrf = array(); $rowtqu = array(); if (count($spr_id) > 0) { #preštejemo komentarje uporabnikov na vprašanja # srv_data_text where spr_id = 0 AND vre_id IN (id-ji spremenljivk) $strqr = "SELECT count(*) FROM srv_data_text".$this->db_table." WHERE spr_id=0 AND vre_id IN (".implode(',',$spr_id).")"; $sqlqr = sisplet_query($strqr); list($rowqr) = mysqli_fetch_row($sqlqr); #končani komentarji respondentov #text2 = 2 => končan #text2 = 3 => nerelevantno $strqrf = "SELECT count(*) FROM srv_data_text".$this->db_table." WHERE spr_id=0 AND vre_id IN (".implode(',',$spr_id).") AND text2 IN (2,3)"; $sqlqrf = sisplet_query($strqrf); list($rowqrf) = mysqli_fetch_row($sqlqrf); # preštejemo if (count($threads) > 0) { # vsi komentarji na anketo $strta = "SELECT count(*) FROM post WHERE tid IN (".implode(',',$threads).") AND parent > 0"; $sqlta = sisplet_query($strta); list($rowtqa) = mysqli_fetch_row($sqlta); # nerešeni komentarji: only_unresolved => ocena <= 1 $strtu = "SELECT count(*) FROM post WHERE tid IN (".implode(',',$threads).") AND parent > 0 AND ocena IN (2,3) "; $sqltu = sisplet_query($strtu); list($rowtqu) = mysqli_fetch_row($sqltu); } } #vsi $comment_count['question']['all'] = (int)((int)$rowqr + (int)$rowtqa); $comment_count['question']['unresolved'] = $comment_count['question']['all'] - (int)((int)$rowqrf + (int)$rowtqu); // KOMENTARJI NA IF ALI BLOK # naenkrat preberemo vse ife in bloke, da ne delamo queryja vsakic posebej $ifi = Cache::cache_all_srv_if($this->anketa, true); $if_id = array(); $threads_if = array(); if ( is_array($ifi) && count($ifi) > 0 ) { foreach ($ifi as $id=>$value) { $if_id[] = $id; if ((int)$value['thread'] > 0) { $threads_if[] = $value['thread']; } } } $rowqr_if = array(); $rowtqa_if = array(); $rowqrf_if = array(); $rowtqu_if = array(); if (count($if_id) > 0) { #preštejemo komentarje uporabnikov na vprašanja # srv_data_text where if_id = 0 AND vre_id IN (id-ji spremenljivk) $strqr = "SELECT count(*) FROM srv_data_text".$this->db_table." WHERE spr_id=0 AND vre_id IN (".implode(',',$if_id).")"; $sqlqr = sisplet_query($strqr); list($rowqr_if) = mysqli_fetch_row($sqlqr); #končani komentarji respondentov #text2 = 2 => končan #text2 = 3 => nerelevantno $strqrf = "SELECT count(*) FROM srv_data_text".$this->db_table." WHERE spr_id=0 AND vre_id IN (".implode(',',$if_id).") AND text2 IN (2,3)"; $sqlqrf = sisplet_query($strqrf); list($rowqrf_if) = mysqli_fetch_row($sqlqrf); # preštejemo if (count($threads_if) > 0) { # vsi komentarji na anketo $strta = "SELECT count(*) FROM post WHERE tid IN (".implode(',',$threads_if).") AND parent > 0"; $sqlta = sisplet_query($strta); list($rowtqa_if) = mysqli_fetch_row($sqlta); # nerešeni komentarji: only_unresolved => ocena <= 1 $strtu = "SELECT count(*) FROM post WHERE tid IN (".implode(',',$threads_if).") AND parent > 0 AND ocena IN (2,3) "; $sqltu = sisplet_query($strtu); list($rowtqu_if) = mysqli_fetch_row($sqltu); } } $comment_count['question']['all'] += (int)((int)$rowqr_if + (int)$rowtqa_if); $comment_count['question']['unresolved'] += ((int)((int)$rowqr_if + (int)$rowtqa_if)) - ((int)((int)$rowqrf_if + (int)$rowtqu_if)); return $comment_count; } } ?>