/**
  * Update settings
  *
  * @param  int                   $id
  * @param SettingsRequestManager $settingRequest
  * @return
  * @internal param TempRequest|SettingsRequestManager $request
  */
 public function update($id, SettingsRequestManager $settingRequest)
 {
     $currentUser = auth()->user();
     if ($currentUser->isNotAdmin()) {
         return redirect()->back()->withResponse(['type' => 'warning', 'code' => ['message', ['message' => 'You do not have the correct privileges to view this page.']]]);
     }
     $input = $settingRequest->requestHandler->all();
     $newPublishingType = $input['publishing_type'][0]['publishing'];
     $oldIdentifier = $this->organization->reporting_org[0]['reporting_organization_identifier'];
     $settings = $this->settingsManager->getSettings($this->organization->id);
     $publishingType = $settings->publishing_type;
     $activities = $this->activityManager->getActivities($this->organization->id);
     if ($publishingType != $newPublishingType) {
         $publishedFiles = $this->activityManager->getActivityPublishedFiles(Session::get('org_id'));
         if (count($publishedFiles)) {
             $this->generateNewFiles($newPublishingType, $activities);
         }
     }
     $reportingOrgIdentifier = $input['reporting_organization_info'][0]['reporting_organization_identifier'];
     foreach ($activities as $activity) {
         $status = $activity['published_to_registry'];
         $otherIdentifier = (array) $activity->other_identifier;
         if ($status == 1 && !in_array(["reference" => $oldIdentifier, "type" => "B1", 'owner_org' => []], $otherIdentifier) && $oldIdentifier !== $reportingOrgIdentifier) {
             $otherIdentifier[] = ['reference' => $oldIdentifier, 'type' => 'B1', 'owner_org' => []];
             $this->otherIdentifierManager->update(['other_identifier' => $otherIdentifier], $activity);
         }
     }
     $result = $this->settingsManager->updateSettings($input, $this->organization, $this->settings);
     if (!$result) {
         $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Settings']]];
         return redirect()->back()->withResponse($response);
     }
     $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Settings']]];
     return redirect()->to(config('app.admin_dashboard'))->withResponse($response);
 }
 /**
  * update activity Other Identifier
  * @param OtherIdentifierRequestManager $otherIdentifierRequestManager
  * @param Request                       $request
  * @param                               $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(OtherIdentifierRequestManager $otherIdentifierRequestManager, Request $request, $id)
 {
     $activityData = $this->otherIdentifierManager->getActivityData($id);
     if (Gate::denies('ownership', $activityData)) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     $this->authorizeByRequestType($activityData, 'other_identifier');
     $input = $request->all();
     if ($this->otherIdentifierManager->update($input, $activityData)) {
         $this->activityManager->resetActivityWorkflow($id);
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Other Activity Identifier']]];
         return redirect()->to(sprintf('/activity/%s', $id))->withResponse($response);
     }
     $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Other Activity Identifier']]];
     return redirect()->back()->withInput()->withResponse($response);
 }