public function update() { !is_array($this->params()->aliases) && ($this->params()->aliases = []); $ids = array_keys($this->params()->aliases); switch ($this->params()->commit) { case "Delete": $validate_all = true; foreach ($ids as $id) { $ta = TagAlias::find($id); if (!$ta->is_pending || $ta->creator_id != current_user()->id) { $validate_all = false; break; } } if (current_user()->is_mod_or_higher() || $validate_all) { foreach ($ids as $x) { if ($ta = TagAlias::find($x)) { $ta->destroy_and_notify(current_user(), $this->params()->reason); } } $this->notice("Tag aliases deleted"); $this->redirectTo("#index"); } else { $this->access_denied(); } break; case "Approve": if (current_user()->is_mod_or_higher()) { foreach ($ids as $x) { if (CONFIG()->is_job_task_active('approve_tag_alias')) { JobTask::create(['task_type' => "approve_tag_alias", 'status' => "pending", 'data' => ["id" => $x, "updater_id" => current_user()->id, "updater_ip_addr" => $this->request()->remoteIp()]]); } else { $ta = TagAlias::find($x); $ta->approve(current_user()->id, $this->request()->remoteIp()); } } $this->notice("Tag alias approval jobs created"); $this->redirectTo('job_task#index'); } else { $this->access_denied(); } break; default: $this->access_denied(); break; } }
public function update() { !is_array($this->params()->implications) && ($this->params()->implications = []); $ids = array_keys($this->params()->implications); switch ($this->params()->commit) { case "Delete": $can_delete = true; # iTODO: # 'creator_id' column isn't, apparently, filled when creating implications or aliases. foreach ($ids as $x) { $ti = TagImplication::find($x); $can_delete = $ti->is_pending && $ti->creator_id == current_user()->id; $tis[] = $ti; } if (current_user()->is_mod_or_higher() || $can_delete) { foreach ($tis as $ti) { $ti->destroy_and_notify(current_user(), $this->params()->reason); } $this->notice("Tag implications deleted"); $this->redirectTo("#index"); } else { $this->access_denied(); } break; case "Approve": if (current_user()->is_mod_or_higher()) { foreach ($ids as $x) { if (CONFIG()->is_job_task_active('approve_tag_implication')) { JobTask::create(['task_type' => "approve_tag_implication", 'status' => "pending", 'data' => ["id" => $x, "updater_id" => current_user()->id, "updater_ip_addr" => $this->request()->remoteIp()]]); } else { $ti = TagImplication::find($x); $ti->approve(current_user(), $this->request()->remoteIp()); } } $this->notice("Tag implication approval jobs created"); $this->redirectTo('job_task#index'); } else { $this->access_denied(); } break; default: $this->access_denied(); break; } }
<?php /** * These seeds are the minimum required data for proper * system funtionality. */ /** * Rows for table_data */ $queries = ['INSERT INTO `table_data` VALUES (\'posts\', 0)', 'INSERT INTO `table_data` VALUES (\'users\', 1)', 'INSERT INTO `table_data` VALUES (\'non-explicit_posts\', 0)']; foreach ($queries as $query) { Rails\ActiveRecord\ActiveRecord::connection()->executeSql($query); } /** * Job tasks rows */ JobTask::create(['task_type' => 'external_data_search', 'data_as_json' => '{}', 'status' => 'pending', 'repeat_count' => -1]); JobTask::create(['task_type' => "upload_batch_posts", 'data_as_json' => '{}', 'status' => "pending", 'repeat_count' => -1]); JobTask::create(['task_type' => "periodic_maintenance", 'data_as_json' => '{}', 'status' => "pending", 'repeat_count' => -1]);
public function up() { JobTask::create(['task_type' => "calculate_tag_subscriptions", 'data_as_json' => '{}', 'status' => "pending", 'repeat_count' => -1]); }
public function massEdit() { $this->set_title('Mass Edit Tags'); if ($this->request()->isPost()) { if (!$this->params()->start) { $this->respond_to_error("Start tag missing", ['#mass_edit'], ['status' => 424]); return; } if (CONFIG()->is_job_task_active('mass_tag_edit')) { $task = JobTask::create(['task_type' => "mass_tag_edit", 'status' => "pending", 'data' => ["start_tags" => $this->params()->start, "result_tags" => $this->params()->result, "updater_id" => $this->current_user->id, "updater_ip_addr" => $this->request()->remoteIp()]]); $this->respond_to_success("Mass tag edit job created", 'job_task#index'); } else { Tag::mass_edit($this->params()->start, $this->params()->result, current_user()->id, $this->request()->remoteIp()); } } }