Пример #1
0
 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;
     }
 }
Пример #2
0
            $ti = TagImplication::find($x);
            // $can_delete = ($ti->is_pending && $ti->creator_id == User::$current->id);
            $tis[] = $ti;
        }
        if (User::is('>=40') && $can_delete) {
            foreach ($tis as $ti) {
                $ti->destroy_and_notify(User::$current, Request::$params->reason);
            }
            notice("Tag implications 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_implication", :status => "pending", :data => {"id" => x, "updater_id" => @current_user.id, "updater_ip_addr" => request.remote_ip})
                } else {
                    $ti = TagImplication::find($x);
                    $ti->approve(User::$current, Request::$remote_ip);
                }
            }
            notice("Tag implication approval jobs created");
            redirect_to('job_task#index');
        } else {
            access_denied();
        }
        break;
}
Пример #3
0
 public function execute_approve_tag_implication()
 {
     $ti = TagImplication::find($this->data->id);
     $updater_id = $this->data->updater_id;
     $updater_ip_addr = $this->data->updater_ip_addr;
     $ti->approve($updater_id, $updater_ip_addr);
 }