Exemple #1
0
 /**
  * Removes all uploads associated with the current response, deletes all response value
  * entries and removes the response.
  *
  * @return bool
  */
 public function Delete($survey_id = 0)
 {
     // deleting the actual survey images folder if there are any..
     if (!empty($survey_id)) {
         $dir = TEMP_DIRECTORY . DIRECTORY_SEPARATOR . $survey_id . DIRECTORY_SEPARATOR . $this->id;
         if (is_dir($dir)) {
             $dir = new IEM_FileSystem_Directory($dir);
             $dir->delete();
         }
     }
     // remove all response values associated to this response
     $this->db->Query("\r\n\t\t\t\tDELETE FROM " . $this->Db->TablePrefix . self::RESPONSEVALUE_TABLE_NAME . "\r\n\t\t\t\tWHERE surveys_response_id = " . $this->id);
     // delete the response
     $this->db->Query("\r\n\t\t\t\tDELETE FROM " . $this->Db->TablePrefix . self::RESPONSE_TABLE_NAME . "\r\n\t\t\t\tWHERE id = " . $this->id);
 }
Exemple #2
0
 /**
  * Removes all uploads associated with the current response, deletes all response value
  * entries and removes the response.
  *
  * @return bool
  */
 public function Delete($survey_id = 0)
 {
     // delete any files being uploaded..
     if (!empty($survey_id)) {
         //survey ID
         $dir = TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'surveys' . DIRECTORY_SEPARATOR . $survey_id . DIRECTORY_SEPARATOR . $this->id;
         if (is_dir($dir)) {
             $dir = new IEM_FileSystem_Directory($dir);
             $dir->delete();
         }
     }
     // remove all response values associated to this response
     $this->Db->Query("\n\t\t\t\tDELETE FROM " . $this->Db->TablePrefix . self::RESPONSEVALUE_TABLE_NAME . "\n\t\t\t\tWHERE surveys_response_id = " . $this->id);
     // delete the response
     $this->Db->Query("\n\t\t\t\tDELETE FROM " . $this->Db->TablePrefix . self::RESPONSE_TABLE_NAME . "\n\t\t\t\tWHERE id = " . $this->id);
     return true;
 }
Exemple #3
0
 /**
  * Deletes a surveys, together with its Widgets and Fields
  *
  * @param Int $surveyid The surveyid to delete
  *
  * @return Void Returns nothing
  */
 public function Delete($surveyid)
 {
     $surveyid = (int) $surveyid;
     $prefix = $this->Db->TablePrefix;
     // First Delete all Widgets Associated with the form,
     $widgets = $this->getWidgets($surveyid);
     foreach ($widgets as $key => $widget) {
         // for each widget delete all the fields related ..
         $query = "DELETE FROM {$prefix}surveys_fields WHERE surveys_widget_id = {$widget['id']}";
         $this->Db->Query($query);
     }
     // Delete the actual widget,
     $query = "DELETE FROM {$prefix}surveys_widgets WHERE surveys_id = {$surveyid}";
     $this->Db->Query($query);
     // Lastly delete the actual suvey
     $query = "DELETE FROM {$prefix}surveys WHERE id = {$surveyid}";
     $this->Db->Query($query);
     // Delete all the responses and response value as well..
     $query = "DELETE sr, srv\n\t\t\t\t  FROM {$prefix}surveys_response as sr, {$prefix}surveys_response_value as srv\n\t\t\t\t  WHERE sr.id = srv.surveys_response_id and\n\t\t\t\t  sr.surveys_id = {$surveyid}";
     // Delete all the files uploaded from the survey folders..
     $survey_images_dir = TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'surveys' . DIRECTORY_SEPARATOR . $surveyid;
     if (is_dir($survey_images_dir)) {
         // Delete using our library file
         $dir = new IEM_FileSystem_Directory($survey_images_dir);
         $dir->delete();
     }
     $this->Db->Query($query);
 }