public function topost($id) { $post = Post::find($id); if ($post) { switch ($post->taxonomy_id) { case 1: $uri = Post::getFullURI($post->id, true); return Redirect::to($uri); case 2: $feed = FeedPost::where('post_id', $post->id)->first(); if ($feed) { $page = Post::where('feed_id', $feed->feed_id)->first(); if ($page) { $viewmods = WebAPL\Template::getViewMethodList('page'); $uri = Post::getFullURI($page->id, true); if (isset($viewmods[$page->view_mod]['support_item']) && $viewmods[$page->view_mod]['support_item']) { $plang = PostLang::where('post_id', $post->id)->where('lang_id', \WebAPL\Language::getId())->first(); if ($plang) { $url = $uri . "?item=" . $plang->uri; } else { $url = $uri; } } else { $url = $uri; } return Redirect::to($url); } else { throw new Exception("Not found page, post #{$id}"); } } else { throw new Exception("Not found feed, post #{$id}"); } break; default: throw new Exception("Not found taxonomy, post #{$id}"); break; } } else { throw new Exception("Post not found #{$id}"); } }
public static function removeLang($lang_id) { PostLang::where('lang_id', $lang_id)->delete(); }
public function postDelete() { $id = Input::get('id'); $post = Post::find($id); if ($post->is_trash == 1) { PostLang::where('post_id', $id)->delete(); FeedFieldValue::where('post_id', $id)->delete(); Files::dropMultiple('post_cover', $id); Files::dropMultiple('doc_post_lang', $id); Files::dropMultiple('doc_post', $id); $post->delete(); Log::warning("Drop post #{$id}"); } return Redirect::to('feed'); }
public function getEmpty() { return ['no no no']; // BAD EMPTY FUNCTION // delete posts $posts = Post::where('taxonomy_id', 2)->get(); foreach ($posts as $post) { PostLang::where('post_id', $post->id)->delete(); Files::dropMultiple('post_cover', $post->id); Files::dropMultiple('doc_post', $post->id); Files::dropMultiple('doc_post_lang', $post->id); $post->delete(); } DB::table('apl_feed_field_value')->truncate(); DB::table('apl_feed_post')->truncate(); DB::table(PostLang::getTableName())->update(array('text' => '')); // delete acte $actes = DB::table('apl_acte')->get(); foreach ($actes as $act) { Files::dropMultiple('actelocale', $act->id); } DB::table('apl_acte')->truncate(); // calendar DB::table('apl_calendar_group')->truncate(); DB::table('apl_calendar_item')->truncate(); DB::table('apl_calendar_item_lang')->truncate(); DB::table('apl_calendar_post')->truncate(); // complaint DB::table('apl_complaint')->truncate(); // firechat DB::table('apl_firechat')->truncate(); // gallery $galls = DB::table('apl_gallery')->get(); foreach ($galls as $gal) { Files::dropMultiple('gallery', $gal->id); } DB::table('apl_gallery')->truncate(); DB::table('apl_gallery_post')->truncate(); // reqs $reqs = DB::table('apl_job_requests')->get(); foreach ($reqs as $req) { if ($req->cv_path && file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $req->cv_path)) { @unlink($_SERVER['DOCUMENT_ROOT'] . '/' . $req->cv_path); } } DB::table('apl_job_requests')->truncate(); // logs DB::table('apl_logs')->truncate(); // newsletter DB::table('apl_newsletter')->truncate(); // persons $persons = DB::table('apl_person')->get(); foreach ($persons as $person) { Files::dropMultiple('person', $person->id); Files::dropMultiple('person_chat', $person->id); } DB::table('apl_person_audience')->truncate(); DB::table('apl_person')->truncate(); DB::table('apl_person_lang')->truncate(); DB::table('apl_person_rel')->truncate(); // polls DB::table('apl_poll')->truncate(); DB::table('apl_poll_answer')->truncate(); DB::table('apl_poll_answer_lang')->truncate(); DB::table('apl_poll_question')->truncate(); DB::table('apl_poll_votes')->truncate(); // pagefiles $pagefiles = DB::table('apl_file')->where('module_name', 'article_cover')->get(); foreach ($pagefiles as $pf) { Files::drop($pf->id); } DB::table('apl_file')->where('module_name', 'page')->delete(); // othfiles $files = DB::table('apl_file')->where('module_name', 'article_cover')->get(); foreach ($files as $file) { Files::drop($file->id); } DB::table('apl_file')->where('module_name', 'article_cover')->delete(); $files = DB::table('apl_file')->where('module_name', 'doc_post_lang')->get(); foreach ($files as $file) { Files::drop($file->id); } DB::table('apl_file')->where('module_name', 'doc_post_lang')->delete(); $files = DB::table('apl_file')->where('module_name', 'test')->get(); foreach ($files as $file) { Files::drop($file->id); } DB::table('apl_file')->where('module_name', 'test')->delete(); $files = DB::table('apl_file')->where('module_name', 'person')->get(); foreach ($files as $file) { Files::drop($file->id); } DB::table('apl_file')->where('module_name', 'person')->delete(); $files = DB::table('apl_file')->where('module_name', 'rewwe')->get(); foreach ($files as $file) { Files::drop($file->id); } DB::table('apl_file')->where('module_name', 'rewwe')->delete(); return ['executed']; }
public function getExport() { $buffer = ""; $pages = Post::where('taxonomy_id', 1)->get(); foreach ($pages as $page) { $langs = PostLang::where('post_id', $page->id)->get(); foreach ($langs as $plang) { $langname = WebAPL\Language::getItem($plang->lang_id)->name; $buffer .= "{$plang->id},{$langname},\"{$plang->title}\"\n"; } $buffer .= "\n"; } header('Content-Encoding: UTF-8'); header('Content-type: text/csv; charset=UTF-8'); header('Content-Disposition: attachment; filename=Customers_Export.csv'); echo ""; // UTF-8 BOM return $buffer; }
public function save_post_cal_attach() { $id = Input::get('post_id'); $count = \CalendarModel::where('post_id', $id)->count(); if ($count == 0) { $post = Post::find($id); $calendar = new \CalendarModel(); $calendar->post_id = $id; $calendar->event_date = $post->created_at; $field = \FeedFieldValue::join(\FeedField::getTableName(), \FeedField::getField('id'), '=', \FeedFieldValue::getField('feed_field_id'))->where(['post_id' => $id, \FeedField::getField('fkey') => 'hours'])->first(); if ($field) { $calendar->period = $field->value; } $calendar->save(); $postLangs = \PostLang::where('post_id', $id)->get(); foreach ($postLangs as $postLang) { $calendarLang = new CalendarLangModel(); $calendarLang->calendar_item_id = $calendar->id; $calendarLang->title = $postLang->title; $calendarLang->lang_id = $postLang->lang_id; $calendarLang->save(); } } else { $calendar = CalendarModel::where('post_id', $id)->get(); foreach ($calendar as $item) { CalendarLangModel::where('calendar_item_id', $item->id)->delete(); } CalendarModel::where('post_id', $id)->delete(); } }
public function sendarticle() { $post_id = Input::get('id'); $post = \PostLang::where('post_id', $post_id)->first(); if ($post) { $data['post'] = $post; $data['post_url'] = url("/../" . \WebAPL\Language::ext() . "/topost/" . $post_id); Template::viewModule($this->module_name, function () use($data, $post) { $newsletterUsers = \NewsletterModel::where('enabled', 1)->get(); foreach ($newsletterUsers as $user) { if (filter_var($user->email, FILTER_VALIDATE_EMAIL)) { $data['user'] = $user; $data['unsubscribe_link'] = url("/../newsletter/unsubscribe/{$user->hash}"); Mail::send('views.emails.post', $data, function ($message) use($post, $user) { $message->from("noreply@{$_SERVER['SERVER_NAME']}", 'WebLPA'); $message->subject($post->title . " :: NEWSLETTER"); $message->to($user->email); }); } } }); } }