/** * Restores tracks on a narrative based on passed POST data * @ingroup G-0003 */ public function restore($id) { $this->require_login(); // Getting info on the narrative to edit the narrative $paths = narrative_track_data($id); // Handle exception when narrative has been modified by another admin while the current admin was on the page. Else update the last modification date and time in database $narrative = $this->narrative_model->get($id); if (FALSE && $narrative['modified'] !== $this->input->post('modified')) { $this->system_message_model->set_message('Narrative #' . $id . ' has been modified since you loaded this page. Changes are discarded and the page is refreshed so you can see the latest version of the narrative before editing.', MESSAGE_NOTICE); redirect('admin/narratives/' . $id . '/edit'); } else { $this->narrative_model->update($narrative); } // Getting files previously removed $deleted_paths = narrative_deleted_track_data($id); // Unpublishing the narrative before reprocessing $previousStatus = $this->narrative_model->unpublish($id); // Creating a new folder to move for processing $old_narrative_dir = $this->config->item('site_data_dir') . '/' . $id . '/'; $new_narrative_dir = $old_narrative_dir . $id . '/'; mkdir($new_narrative_dir, 0755); // Creating a new folder to store deleted files $new_deleted_dir = $new_narrative_dir . '/deleted/'; mkdir($new_deleted_dir, 0755); $tracks_for_restoration = $this->input->post('tracks'); if ($tracks_for_restoration) { narrative_restore_tracks($deleted_paths['tracks'], $new_narrative_dir, $tracks_for_restoration); } // Restoring desired images and moving the rest to the new deleted folder $pictures_for_restoration = $this->input->post('pics'); if ($pictures_for_restoration) { narrative_restore_pictures($deleted_paths['pictures'], $new_narrative_dir, $pictures_for_restoration); } //Moving XML file to the new folder narrative_move_xml($id, $new_narrative_dir); //Moving files from the old to the new deleted folder $old_deleted_dir = $old_narrative_dir . 'deleted/'; narrative_move_files($old_deleted_dir, $new_deleted_dir); narrative_move_files($old_narrative_dir, $new_narrative_dir); //Purging files from the uploads folder to the tmp folder to handle error of disappearing jpg narrative_purge_files($old_narrative_dir, $new_narrative_dir); //Creating new folder in tmp directory to hold the edited narrative and moving edited narrative to it $tmp_path = move_dir_to_tmp($new_narrative_dir, $id); //Deleting old narrative folder delete_dir($old_narrative_dir); //Calling processing on the new folder $this->narrative_model->process_narrative($tmp_path, $id); //Republishing the narrative before announcing success if ($previousStatus == 1) { $this->narrative_model->publish($id); } //Output success $this->system_message_model->set_message('Narrative #' . $id . ' was edited successfully.', MESSAGE_NOTICE); redirect('admin/narratives/' . $id . '/edit'); }
/** * UT-0050 * @covers ::narrative_track_data */ public function test__narrative_track_data__invalid_id() { $paths = narrative_track_data(-1); $this->assertFalse($paths); }