コード例 #1
0
 /**
  * Set what to do when the form is 'finished'.
  *
  * @return self
  */
 protected function setAfterSaveRoute()
 {
     // Default is just go to the index
     if ($this->routeAction && $this->request->getActionName() !== $this->routeAction) {
         $this->afterSaveRouteUrl = array($this->request->getControllerKey() => 'track', $this->request->getActionKey() => $this->routeAction, \MUtil_Model::REQUEST_ID => $this->token->getTokenId());
     }
     return $this;
 }
コード例 #2
0
 /**
  * Update the token data when a Mail has been sent.
  * @param  integer $tokenId TokenId to update. If none is supplied, use the current token
  */
 public function updateToken($tokenId = false)
 {
     if (!$tokenId) {
         $tokenId = $this->token->getTokenId();
     }
     $tokenData['gto_mail_sent_num'] = new \Zend_Db_Expr('gto_mail_sent_num + 1');
     $tokenData['gto_mail_sent_date'] = \MUtil_Date::format(new \Zend_Date(), 'yyyy-MM-dd');
     $this->db->update('gems__tokens', $tokenData, $this->db->quoteInto('gto_id_token = ?', $tokenId));
 }
コード例 #3
0
 /**
  * Set what to do when the form is 'finished'.
  *
  * @return DeleteTrackTokenSnippet (continuation pattern)
  */
 protected function setAfterSaveRoute()
 {
     // Default is just go to the index
     if ($this->routeAction && $this->request->getActionName() !== $this->routeAction) {
         $tokenId = $this->_replacementTokenId ? $this->_replacementTokenId : $this->token->getTokenId();
         $this->afterSaveRouteUrl = array($this->request->getActionKey() => $this->routeAction, \MUtil_Model::REQUEST_ID => $tokenId);
     }
     return $this;
 }
コード例 #4
0
 protected function loadExport()
 {
     $this->export = $this->loader->getRespondentExport();
     if ($this->token instanceof \Gems_Tracker_Token) {
         $this->addRespondent($this->token->getPatientNumber(), $this->token->getOrganizationId());
         $this->export->addRespondentTrackFilter($this->token->getRespondentTrackId());
         $this->export->addTokenFilter($this->token->getTokenId());
     } elseif ($this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) {
         $this->addRespondent($this->respondentTrack->getPatientNumber(), $this->respondentTrack->getOrganizationId());
         $this->export->addRespondentTrackFilter($this->respondentTrack->getRespondentTrackId());
     } elseif ($this->respondent instanceof \Gems_Tracker_Respondent) {
         $this->addRespondent($this->respondent->getPatientNumber(), $this->respondent->getOrganizationId());
     }
 }
コード例 #5
0
 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $delay = $this->project->getAskDelay($this->request, $this->wasAnswered);
     $href = $this->getTokenHref($this->showToken);
     $html = $this->getHtmlSequence();
     $org = $this->showToken->getOrganization();
     $url = $href->render($this->view);
     switch ($delay) {
         case 0:
             // Redirect at once
             header('Location: ' . $url);
             exit;
         case -1:
             break;
         default:
             // Let the page load after stated interval
             $this->view->headMeta()->appendHttpEquiv('Refresh', $delay . '; url=' . $url);
     }
     $html->h3($this->_('Token'));
     if ($this->token->hasRelation()) {
         $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRelation()->getName()));
         $html->pInfo(sprintf($this->_('We kindly ask you to answer a survey about %s.'), $this->showToken->getRespondent()->getName()));
     } else {
         $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRespondentName()));
     }
     if ($this->wasAnswered) {
         $html->pInfo(sprintf($this->_('Thank you for answering the "%s" survey.'), $this->token->getSurveyName()));
         $html->pInfo($this->_('Please click the button below to answer the next survey.'));
     } else {
         if ($welcome = $org->getWelcome()) {
             $html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html'));
         }
         $html->pInfo(sprintf($this->_('Please click the button below to answer the survey for token %s.'), strtoupper($this->showToken->getTokenId())));
     }
     if ($delay > 0) {
         $html->pInfo(sprintf($this->plural('Wait one second to open the survey automatically or click on Cancel to stop.', 'Wait %d seconds to open the survey automatically or click on Cancel to stop.', $delay), $delay));
     }
     $buttonDiv = $html->buttonDiv(array('class' => 'centerAlign'));
     $buttonDiv->actionLink($href, $this->showToken->getSurveyName());
     if ($delay > 0) {
         $buttonDiv->actionLink(array('delay_cancelled' => 1), $this->_('Cancel'));
     }
     if ($next = $this->showToken->getTokenCountUnanswered()) {
         $html->pInfo(sprintf($this->plural('After this survey there is one other survey we would like you to answer.', 'After this survey there are another %d surveys we would like you to answer.', $next), $next));
     }
     if ($sig = $org->getSignature()) {
         $html->pInfo()->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html'));
     }
     return $html;
 }
コード例 #6
0
 /**
  * The place to check if the data set in the snippet is valid
  * to generate the snippet.
  *
  * When invalid data should result in an error, you can throw it
  * here but you can also perform the check in the
  * checkRegistryRequestsAnswers() function from the
  * {@see \MUtil_Registry_TargetInterface}.
  *
  * @return boolean
  */
 public function hasHtmlOutput()
 {
     if (!$this->tokenId) {
         if ($this->token) {
             $this->tokenId = $this->token->getTokenId();
         } elseif ($this->request) {
             $this->tokenId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
         }
     }
     if ($this->tokenId && !$this->token) {
         $this->token = $this->loader->getTracker()->getToken($this->tokenId);
     }
     // Output always true, returns an error message as html when anything is wrong
     return parent::hasHtmlOutput();
 }
コード例 #7
0
 /**
  * The place to check if the data set in the snippet is valid
  * to generate the snippet.
  *
  * When invalid data should result in an error, you can throw it
  * here but you can also perform the check in the
  * checkRegistryRequestsAnswers() function from the
  * {@see \MUtil_Registry_TargetInterface}.
  *
  * @return boolean
  */
 public function hasHtmlOutput()
 {
     if (!$this->tokenId) {
         if (isset($this->token)) {
             $this->tokenId = $this->token->getTokenId();
         }
     } elseif (!$this->token) {
         $this->token = $this->loader->getTracker()->getToken($this->tokenId);
     }
     // Output always true, returns an error message as html when anything is wrong
     return true;
 }
コード例 #8
0
 /**
  * Process the data and return the answers that should be changed.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenData(\Gems_Tracker_Token $token)
 {
     $result = var_export($token->getRawAnswers(), true);
     \MUtil_Echo::r($result, $token->getTokenId());
     return false;
 }
コード例 #9
0
 /**
  * Get the href for a token
  *
  * @param \Gems_Tracker_Token $token
  * @return \MUtil_Html_HrefArrayAttribute
  */
 protected function getTokenHref(\Gems_Tracker_Token $token)
 {
     /***************
      * Get the url *
      ***************/
     $params = array($this->request->getActionKey() => 'to-survey', \MUtil_Model::REQUEST_ID => $token->getTokenId(), 'RouteReset' => false);
     return new \MUtil_Html_HrefArrayAttribute($params);
 }
コード例 #10
0
 /**
  * Remove token from cache for saving memory
  *
  * @param string|\Gems_Tracker_Token $token
  * @return \Gems_Tracker (continuation pattern)
  */
 public function removeToken($token)
 {
     if ($token instanceof \Gems_Tracker_Token) {
         $tokenId = $token->getTokenId();
     } else {
         $tokenId = $token;
     }
     unset($this->_tokens[$tokenId]);
     return $this;
 }
コード例 #11
0
 /**
  * Add a one-off survey to the existing track.
  *
  * @param type $surveyId    the gsu_id of the survey to add
  * @param type $surveyData
  * @param int $userId
  * @param boolean $checkTrack Should the track be checked? Set to false when adding more then one and check manually
  * @return \Gems_Tracker_Token
  */
 public function addTokenToTrack(\Gems_Tracker_Token $token, $tokenData, $userId, $checkTrack = true)
 {
     //Now make sure the data to add is correct:
     $tokenData['gto_id_respondent_track'] = $this->_respTrackId;
     $tokenData['gto_id_organization'] = $this->_respTrackData['gr2t_id_organization'];
     $tokenData['gto_id_track'] = $this->_respTrackData['gr2t_id_track'];
     $tokenData['gto_id_respondent'] = $this->_respTrackData['gr2t_id_user'];
     $tokenData['gto_changed'] = new \MUtil_Db_Expr_CurrentTimestamp();
     $tokenData['gto_changed_by'] = $userId;
     $where = $this->db->quoteInto('gto_id_token = ?', $token->getTokenId());
     $this->db->update('gems__tokens', $tokenData, $where);
     $token->refresh();
     if ($checkTrack === true) {
         //Now refresh the track to include the survey we just added (easiest way as order may change)
         $this->getTokens(true);
         $this->checkTrackTokens($userId, $token);
         // Update the track counter
         //$this->_checkTrackCount($userId);
     }
     return $token;
 }
コード例 #12
0
 /**
  * Returns true if the survey was completed according to the source
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @param int $surveyId Gems Survey Id
  * @param string $sourceSurveyId Optional Survey Id used by source
  * @return boolean True if the token has completed
  */
 public function isCompleted(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
 {
     $result = $this->getRawTokenAnswerRow($token->getTokenId(), $surveyId);
     $completed = !empty($result);
     return $completed;
 }
コード例 #13
0
 /**
  * Returns the url that (should) start the survey for this token
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @param string $language
  * @param int $surveyId Gems Survey Id
  * @param string $sourceSurveyId Optional Survey Id used by source
  * @return string The url to start the survey
  */
 public function getTokenUrl(\Gems_Tracker_Token $token, $language, $surveyId, $sourceSurveyId)
 {
     if (null === $sourceSurveyId) {
         $sourceSurveyId = $this->_getSid($surveyId);
     }
     $tokenId = $this->_getToken($token->getTokenId());
     if ($this->_isLanguage($sourceSurveyId, $language)) {
         $langUrl = '/lang/' . $language;
     } else {
         $langUrl = '';
     }
     // <base>/index.php/survey/index/sid/834486/token/234/lang/en
     $baseurl = $this->getBaseUrl();
     $start = $baseurl . ('/' == substr($baseurl, -1) ? '' : '/');
     if (stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || ini_get('security.limit_extensions') && ini_get('security.limit_extensions') != '') {
         // Apache : index.php/
         $start .= 'index.php/';
     } else {
         $start .= 'index.php?r=';
     }
     return $start . 'survey/index/sid/' . $sourceSurveyId . '/token/' . $tokenId . $langUrl;
 }
コード例 #14
0
 /**
  * Determines if this particular token should be included
  * in the report
  *
  * @param  \Gems_Tracker_Token $token
  * @return boolean This dummy implementation always returns true
  */
 protected function _isTokenInFilter(\Gems_Tracker_Token $token)
 {
     $result = false;
     // Only if token has a success code
     if ($token->getReceptionCode()->isSuccess()) {
         $result = true;
     }
     if ($result) {
         $tokenInfo = array('code' => $token->getSurvey()->getCode(), 'surveyid' => $token->getSurveyId(), 'tokenid' => $token->getTokenId());
         // Now check if the tokenfilter is true
         if (empty($this->tokenFilter)) {
             $result = true;
         } else {
             $result = false;
             // Now read the filter and split by track code or track id
             foreach ($this->tokenFilter as $filter) {
                 $remaining = array_diff_assoc($filter, $tokenInfo);
                 if (empty($remaining)) {
                     $result = true;
                     break;
                 }
             }
         }
     }
     return $result;
 }