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 execute_approve_tag_alias() { $ta = TagAlias::find($this->data->id); $updater_id = $this->data->updater_id; $updater_ip_addr = $this->data->updater_ip_addr; $ta->approve($updater_id, $updater_ip_addr); }
$ta = TagAlias::find($x); $ta->destroy_and_notify(User::$current, Request::$params->reason); } notice("Tag aliases deleted"); redirect_to("#index"); } else { access_denied(); } break; case "Approve": if (User::is('>=40')) { foreach ($ids as $x) { // if (CONFIG::enable_asynchronous_tasks) { // JobTask.create(:task_type => "approve_tag_alias", :status => "pending", :data => {"id" => x, "updater_id" => @current_user.id, "updater_ip_addr" => request.remote_ip}) // } else { // vde($x); // DB::show_query(); $ta = TagAlias::find($x); // vde($ta); // exit; $ta->approve(User::$current->id, Request::$remote_ip); // } } notice("Tag alias approval jobs created"); #TODO: redirecting to #index instead of job_task#index as job_task doesn't yet exist. redirect_to('#index'); } else { access_denied(); } break; }