protected function test_links($links) { $this->worker->enable_limit(self::MAX_DOWNLOAD_SIZE)->add($links)->exec(); foreach ($links as $id => $link) { $status = $this->test_result($link); if ($status === false) { continue; } Database::update('post_url', array('status' => $status, 'lastcheck' => Database::unix_to_date()), $id); if ($status == self::STATUS_UNKNOWN) { $this->create_unknown_file($link); } } $this->worker->flush(); $keys = array_keys($links); $post_ids = Database::join('post_link_url', 'plu.link_id = pl.id')->join('post_url', 'plu.url_id = pu.id')->get_vector('post_link', 'post_id', Database::array_in('pu.id', $keys), $keys); $post_ids = array_unique($post_ids); foreach ($post_ids as $post_id) { $status = new Model_Post_Status($post_id); $status->load()->calculate()->commit(); } $update_ids = Database::join('post_update_link_url', 'pulu.link_id = pul.id')->join('post_url', 'pulu.url_id = pu.id')->get_vector('post_update_link', 'update_id', Database::array_in('pu.id', $keys), $keys); $update_ids = array_unique($update_ids); foreach ($update_ids as $update_id) { $status = new Model_Post_Update_Status($update_id); $status->load()->calculate()->commit(); } }
protected function add_children() { $order = 0; $images = $this->get('image'); if (!empty($images) && is_array($images)) { foreach ($images as $image) { if (is_object($image)) { $image->set('post_id', $this->get_id()); $image->set('order', $order); $image->insert(); $order++; } } } $order = 0; $links = $this->get('link'); if (!empty($links) && is_array($links)) { foreach ($links as $link) { if (is_object($link)) { $link->set('post_id', $this->get_id()); $link->set('order', $order); $link->insert(); $order++; } } $status = new Model_Post_Status($this->get_id()); $status->load()->calculate($links)->commit(); } $order = 0; $torrents = $this->get('torrent'); if (!empty($torrents) && is_array($torrents)) { foreach ($torrents as $torrent) { if (is_object($torrent)) { $torrent->set('post_id', $this->get_id()); $torrent->set('order', $order); $torrent->insert(); $order++; } } } $order = 0; $files = $this->get('file'); if (!empty($files) && is_array($files)) { foreach ($files as $file) { if (is_object($file)) { $file->set('post_id', $this->get_id()); $file->set('order', $order); $file->insert(); $order++; } } } $order = 0; $extras = $this->get('extra'); if (!empty($extras) && is_array($extras)) { foreach ($extras as $extra) { if (is_object($extra)) { $extra->set('post_id', $this->get_id()); $extra->set('order', $order); $extra->insert(); $order++; } } } }