CMS  Version 3.9
SurveyComponentManager Class Reference

SurveyComponentManager - manages survey component; the class name SurveyManager is used for management of the survey feature. More...

Public Member Functions

 SurveyComponentManager ()
 

Static Public Member Functions

static enumerateContextHelpClasses ($classes)
 
static setDefaults ()
 
static enumerateDataItemClasses ($classes)
 
static deleteUser ($user)
 Respond to fired event DeleteUser. More...
 
static deleteSurvey ($survey)
 
static deleteSurveyResponse ($response)
 
static upgradeComponent ($version)
 

Detailed Description

SurveyComponentManager - manages survey component; the class name SurveyManager is used for management of the survey feature.

Author
janice

Definition at line 46 of file survey_component_manager.inc.

Member Function Documentation

◆ deleteSurvey()

static SurveyComponentManager::deleteSurvey (   $survey)
static

Definition at line 129 of file survey_component_manager.inc.

130  {
131  $survey_id = $survey->survey_id;
132  $questions = $survey->Questions();
133 
134  $tx = new DataTransaction();
135 
136  try
137  {
138  $xref = new SurveyQuestionXref();
139  $xref->joinTransaction($tx);
140  $xref->delete("WHERE survey_id={$survey_id}");
141 
142  $responses = $survey->Responses();
143 
144  if(count($responses))
145  {
146  foreach($responses as $response)
147  {
148  $response->joinTransaction($tx);
150  }
151  }
152 
153  $tx->commit();
154  }
155  catch(Exception $e)
156  {
157  $tx->rollback();
158  throw $e;
159  }
160 
161  // Delete any questions that are now not linked to any survey
162  foreach($questions as $question)
163  {
164  $count = Query::create(SurveyQuestionXref, "WHERE survey_question_id=:survey_question_id")
165  ->bind(":survey_question_id", $question->survey_question_id)
166  ->executeValue("COUNT(1)");
167 
168  if($count == 0)
169  {
170  $question->delete();
171  }
172  }
173  }
static deleteSurveyResponse($response)
$survey_id
if(! $survey_id) $survey
$question
if(! $user) if(! $response_id) $response

◆ deleteSurveyResponse()

static SurveyComponentManager::deleteSurveyResponse (   $response)
static

Definition at line 175 of file survey_component_manager.inc.

176  {
177  $tx = new DataTransaction();
178 
179  try
180  {
181  $response->joinTransaction($tx);
182 
183  $answer = new SurveyAnswer();
184  $answer->joinTransaction($tx);
185  $answer->delete("WHERE response_id={$response->response_id}");
186 
187  $tx->commit();
188  }
189  catch(Exception $e)
190  {
191  $tx->rollback();
192  throw $e;
193  }
194  }

◆ deleteUser()

static SurveyComponentManager::deleteUser (   $user)
static

Respond to fired event DeleteUser.

Delete any records in this component that have dependencies on user object.

Parameters
obj$user- class SiteUser or custom user class

Definition at line 97 of file survey_component_manager.inc.

98  {
99  $pk = $user->getPrimaryKey();
100  $user_id = $user->$pk;
101 
102  trace("Component survey is deleting objects dependent on user_id {$user_id}", 3);
103 
104  $tx = new DataTransaction();
105 
106  try
107  {
108  $surveys = Query::create(Survey, "WHERE user_id=:user_id")
109  ->bind(":user_id", $user_id)
110  ->execute();
111 
112  foreach($surveys as $survey)
113  {
114  $survey->joinTransaction($tx);
116  }
117 
118  $tx->commit();
119  }
120  catch(Exception $e)
121  {
122  $tx->rollback();
123  throw $e;
124  }
125 
126  return $user;
127  }
$user_id
global $user

◆ enumerateContextHelpClasses()

static SurveyComponentManager::enumerateContextHelpClasses (   $classes)
static

Definition at line 53 of file survey_component_manager.inc.

54  {
55  $classes[] = "SurveyAnswer";
56  $classes[] = "SurveyQuestion";
57  $classes[] = "SurveyResponse";
58  $classes[] = "Survey";
59 
60  return $classes;
61  }

◆ enumerateDataItemClasses()

static SurveyComponentManager::enumerateDataItemClasses (   $classes)
static

Definition at line 79 of file survey_component_manager.inc.

80  {
81  $classes[] = "SurveyAnswer";
82  $classes[] = "SurveyQuestion";
83  $classes[] = "SurveyResponse";
84  $classes[] = "Survey";
85  $classes[] = "SurveyQuestionXref";
86 
87  return $classes;
88  }

◆ setDefaults()

static SurveyComponentManager::setDefaults ( )
static

Definition at line 63 of file survey_component_manager.inc.

64  {
65  trace("SurveyManager::setDefaults", 3);
66 
67  global $config;
68 
69  Settings::setDefaultValue("survey", "sender_email", "", "String", "The email address that will appear as the sender of the survey email", "Survey Emails");
70  Settings::setDefaultValue("survey", "email_subject", "Survey from ". $config["http_host"], "String", "The default or standard subject line for survey emails", "Survey Emails");
71  Settings::setDefaultValue("survey", "message_footer", "<br><br>Click the link below to access the survey:<br>[survey_link]<br><br>or go to<br>[survey_intro_link], click on [survey_title], and enter your access token [token] at the prompt.<br>", "Text", "The text to be included below the main
72  message in all surveys, providing users with a link to response.
73  The text within brackets represent codes that will be filled in with data
74  from the survey record when the survey is sent.", "Survey Emails");
75  Settings::setDefaultValue("survey", "interactive_graphs", false, Boolean, "Show interactive SVG graphs on the report screens, rather than static images");
76 
77  }
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
global $config
Definition: import.inc:4

◆ SurveyComponentManager()

SurveyComponentManager::SurveyComponentManager ( )

Definition at line 48 of file survey_component_manager.inc.

49  {
50 
51  }

◆ upgradeComponent()

static SurveyComponentManager::upgradeComponent (   $version)
static

Definition at line 196 of file survey_component_manager.inc.

197  {
198  $mgr = new SurveyUpgradeManager();
199  $mgr->upgrade($version);
200  }

The documentation for this class was generated from the following file: