示例#1
0
 function delete($type, $id = 0)
 {
     if (!isAjax()) {
         $this->output->set_output(_('You can\'t delete chapters from outside the admin panel through this link.'));
         log_message("error", "Controller: series.php/remove: failed serie removal");
         return false;
     }
     $id = intval($id);
     switch ($type) {
         case "serie":
             $comic = new Comic();
             $comic->where('id', $id)->get();
             $title = $comic->name;
             if (!$comic->remove()) {
                 flash_notice('error', sprintf(_('Failed to delete the series %s.'), $title));
                 log_message("error", "Controller: series.php/remove: failed serie removal");
                 $this->output->set_output(json_encode(array('href' => site_url("admin/series/manage"))));
                 return false;
             }
             flash_notice('notice', 'The serie ' . $comic->name . ' has been removed');
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/manage"))));
             break;
         case "chapter":
             $chapter = new Chapter($id);
             $title = $chapter->chapter;
             if (!($comic = $chapter->remove())) {
                 flash_notice('error', sprintf(_('Failed to delete chapter %s.'), $chapter->comic->chapter));
                 log_message("error", "Controller: series.php/remove: failed chapter removal");
                 $this->output->set_output(json_encode(array('href' => site_url("admin/series/series/" . $comic->stub))));
                 return false;
             }
             set_notice('notice', 'Chapter deleted.');
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $comic->stub))));
             break;
         case "page":
             $page = new Page($this->input->post('id'));
             $page->get_chapter();
             $page->chapter->get_comic();
             if (!($data = $page->remove_page())) {
                 log_message("error", "Controller: series.php/remove: failed page removal");
                 return false;
             }
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $page->chapter->comic->stub . "/" . $page->chapter->id))));
             break;
         case "allpages":
             $chapter = new Chapter($id);
             $chapter->get_comic();
             if (!$chapter->remove_all_pages()) {
                 log_message("error", "Controller: series.php/remove: failed all pages removal");
                 return false;
             }
             $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $chapter->comic->stub . "/" . $chapter->id))));
             break;
     }
 }
示例#2
0
 public function import_compressed()
 {
     $chapter = new Chapter();
     if (!$chapter->add($this->input->post())) {
         log_message('error', 'import_compressed(): Couldn\'t create chapter');
         return array('error' => "Couldn't create the chapter.");
     }
     if (!is_dir($this->input->post('server_path'))) {
         $extension = pathinfo($this->input->post('server_path'), PATHINFO_EXTENSION);
     } else {
         $extension = '';
     }
     if (!$this->compressed_chapter($this->input->post('server_path'), 'file.' . $extension, $chapter->id)) {
         $chapter->remove();
         log_message('error', 'import_compressed(): Couldn\'t add the pages to the chapter');
         return array('error' => "Couldn't add the pages to the chapter.");
     }
     return array('success' => TRUE);
 }
示例#3
0
 /**
  * When missing chapters are found, this cleans up and adds new chapters
  *
  * @param int $comic_id
  * @param array $new_chapters_array 
  */
 public function _clean_comic($comic_id, $new_chapters_array)
 {
     // found, let's get all chapters for this comic
     $chapters = new Chapter();
     $chapters->where('comic_id', $comic_id)->get();
     $chapters = $chapters->all_to_array();
     foreach ($new_chapters_array as $key => $item) {
         foreach ($chapters as $k => $i) {
             if ($item["id"] == $i["id"]) {
                 if ($item["stub"] != $i["stub"] || $item["uniqid"] != $i["uniqid"]) {
                     $chapter = new Chapter($item["id"]);
                     $chapter->remove();
                     unset($chapters[$k]);
                     break;
                 }
                 unset($chapters[$k]);
                 unset($new_chapters_array[$key]);
                 break;
             }
         }
     }
     foreach ($new_chapters_array as $key => $item) {
         $chapter = new Chapter();
         $chapter->from_array($item);
         $chapter->save_as_new();
     }
     foreach ($chapters as $key => $item) {
         $chapter = new Chapter($item["id"]);
         $chapter->remove();
     }
 }
示例#4
0
	function delete($type, $id = 0) {
		if (!isAjax()) {
			echo _('You can\'t delete chapters from outside the admin panel through this link.');
			log_message("error", "Controller: comics.php/remove: failed comic removal");
			return false;
		}
		$id = intval($id);

		switch ($type) {
			case("comic"):
				$comic = new Comic();
				$comic->where('id', $id)->get();
				if (!$comic->remove()) {
					log_message("error", "Controller: comics.php/remove: failed comic removal");
					return false;
				}
				flash_notice('notice', 'The comic ' . $comic->name . ' has been removed');
				echo json_encode(array('href' => site_url("admin/comics/manage")));
				break;
			case("chapter"):
				$chapter = new Chapter($id);
				if (!$comic = $chapter->remove()) {
					log_message("error", "Controller: comics.php/remove: failed chapter removal");
					return false;
				}
				set_notice('notice', 'Chapter deleted.');
				echo json_encode(array('href' => site_url("admin/comics/comic/" . $comic->stub)));
				break;
			case("page"):
				$page = new Page($this->input->post('id'));
				$page->get_chapter();
				$comic = new Chapter($chapter->comic_id);
				if (!$data = $page->remove_page()) {
					log_message("error", "Controller: comics.php/remove: failed page removal");
					return false;
				}
				echo json_encode(array('href' => site_url("admin/comics/comic/" . $page->chapter->comic->stub . "/" . $page->chapter->id)));
				break;
			case("allpages"):
				$chapter = new Chapter($id);
				$chapter->get_comic();
				if (!$chapter->remove_all_pages()) {
					log_message("error", "Controller: comics.php/remove: failed all pages removal");
					return false;
				}
				echo json_encode(array('href' => site_url("admin/comics/comic/" . $chapter->comic->stub . "/" . $chapter->id)));
				break;
		}
	}
示例#5
0
	public function import_compressed() {

		$chapter = new Chapter();
		if (!$chapter->add($this->input->post())) {
			log_message('error', 'import_compressed(): Couldn\'t create chapter');
			return array('error' => "Couldn't create the chapter.");
		}
		$data['chapter_id'] = $chapter->id;
		$data['overwrite'] = 1;
		$data['full_path'] = $this->input->post('server_path');
		$data['raw_name'] = 'import_' . $chapter->id;
		if(!is_dir($data["full_path"]))
		$data['file_ext'] = '.'.end(explode('.', $this->input->post('server_path')));
		if (!$this->compressed_chapter($data)) {
			$chapter->remove();
			log_message('error', 'import_compressed(): Couldn\'t add the pages to the chapter');
			return array('error' => "Couldn't add the pages to the chapter.");
		}
		return array('success' => TRUE);
	}