0) { $this->_anketa = $anketa; } else { throw new Exception('Error: survey ID is missing. (HashUrl)'); } } catch (Exception $e) { die( $e->getMessage().' Exiting script!'); } return $this; } public function ajax() { $action = $_GET['a']; switch ($action) { case 'showLinks' : self :: showUrlLinks(); break; case 'addLink' : self :: addLink(); break; case 'saveComment' : self :: saveComment(); case 'saveRefresh' : self :: saveRefresh(); case 'saveAccessPassword' : self :: saveAccessPassword(); break; case 'deleteLink' : self :: deleteLink(); break; default: $this->showUrlLinks(); break; } } function showUrlLinks($msg=null){ global $lang, $site_url; $podstran = $_REQUEST['podstran']; $m = $_REQUEST['m']; $popUp = new PopUp(); $popUp->setId('div_survey_links'); $popUp->setHeaderText($lang['srv_public_link_title'].':'); #vsebino shranimo v buffer ob_start(); echo ''; if ($msg != null){ echo ($msg); echo '
'; } $hashUrl = new HashUrl($this->_anketa); $links = $hashUrl->getSurveyHashes(); if (count($links) == 0){ echo $lang['srv_public_link_noLink'].'
'; } echo '

'.$lang['srv_public_link_addLink'].'

'; if (count($links) > 0){ echo ''.$lang['srv_public_link_existing'].''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($links as $key => $link){ echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; } #dodamo vsebino $content = ob_get_clean(); $popUp->setContent($content); # dodamo gumb Preklici $buttonClose = new PopUpCancelButton(); $buttonClose->setCaption($lang['srv_zapri'])->setTitle($lang['srv_zapri']); $buttonClose->setFloat('right'); $popUp->addButton($buttonClose); echo $popUp; } function addLink(){ global $lang; global $global_user_id; #zaenkrat samo za podatke in par analiz $podstran = (isset($_REQUEST['podstran']) && ($_REQUEST['podstran'] == A_COLLECT_DATA || $_REQUEST['podstran'] == A_ANALYSIS )) ? $_REQUEST['podstran'] : 'data'; $m = (isset($_REQUEST['m'])) ? $_REQUEST['m'] : ''; # polovimo trenutno nastavljene profile SurveyUserSetting::getInstance()->Init($this->_anketa, $global_user_id); $this->addLinkAPI($global_user_id, $podstran, $m); $this->showUrlLinks($lang['srv_public_link_linkAdded']); } //da se lahko kreira linke tudi prek API function addLinkAPI ($user_id, $podstran, $m){ SurveyStatusProfiles :: Init($this->_anketa, $user_id); $_PROFILE_ID_STATUS = SurveyStatusProfiles :: getCurentProfileId(); SurveyVariablesProfiles::Init($this->_anketa); $_PROFILE_ID_VARIABLE = SurveyVariablesProfiles::getCurentProfileId(); SurveyConditionProfiles::Init($this->_anketa, $user_id); $_PROFILE_ID_CONDITION = SurveyConditionProfiles::getCurentProfileId(); $hashUrl = new HashUrl($this->_anketa); $newHash = $hashUrl->getNewHash(); $hashUrl->setPage($podstran); $properties = array( 'anketa'=>$this->_anketa, 'a'=>$podstran, 'm'=>$m, 'profile_id_status'=>$_PROFILE_ID_STATUS, 'profile_id_variable'=>$_PROFILE_ID_VARIABLE, 'profile_id_condition'=>$_PROFILE_ID_CONDITION ); // Ce gre za porocilo po meri dodamo se id porocila in id avtorja if($m == M_ANALYSIS_CREPORT){ $creportProfile = SurveyUserSetting :: getInstance()->getSettings('default_creport_profile'); $creportProfile = isset($creportProfile) && $creportProfile != '' ? $creportProfile : 0; $creportAuthor = SurveyUserSetting :: getInstance()->getSettings('default_creport_author'); $creportAuthor = isset($creportAuthor) && $creportAuthor != '' ? $creportAuthor : $user_id; $properties['creportProfile'] = $creportProfile; $properties['creportAuthor'] = $creportAuthor; } $hashUrl->saveProperty($newHash, $properties); } function saveComment() { $hashUrl = new HashUrl($this->_anketa); $hash = $_REQUEST['hash']; $comment = $_REQUEST['comment']; // firefox na koncu vsakega contenteditable doda
, ki ga tukaj odstranimo if (substr($comment, -4) == '
') { $comment = substr($comment, 0, -4); } $hashUrl->updateComment($hash,$comment); } function saveRefresh() { $hashUrl = new HashUrl($this->_anketa); $hash = $_REQUEST['hash']; $refresh = $_REQUEST['refresh']; $hashUrl->updateRefresh($hash,$refresh); } function saveAccessPassword() { $hashUrl = new HashUrl($this->_anketa); $hash = $_REQUEST['hash']; $pass = $_REQUEST['access_password']; // firefox na koncu vsakega contenteditable doda
, ki ga tukaj odstranimo if (substr($comment, -4) == '
') { $comment = substr($comment, 0, -4); } $hashUrl->updateAccessPassword($hash,$pass); } function deleteLink() { global $lang; $hashUrl = new HashUrl($this->_anketa); $hash = $_REQUEST['hash']; $hashUrl->deleteLink($hash); $this->showUrlLinks($lang['srv_public_link_linkDeleted']); } }