Add missing files and minor migration tweaks.
This commit is contained in:
		@@ -593,4 +593,7 @@ $migrate_dedup_users["yesmydear"] = "None";
 | 
				
			|||||||
$migrate_dedup_users["spacetug"] = "None";
 | 
					$migrate_dedup_users["spacetug"] = "None";
 | 
				
			||||||
$migrate_dedup_users["omegafold"] = "None";
 | 
					$migrate_dedup_users["omegafold"] = "None";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// testing
 | 
				
			||||||
 | 
					$migrate_dedup_users["blendix_rename_test_a"] = "blendix";
 | 
				
			||||||
 | 
					$migrate_dedup_users["blendix_rename_test_b"] = "blendix";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,7 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=1) {
 | 
				
			|||||||
  $assign = lookup_user(dedup_user($mtask->assign));
 | 
					  $assign = lookup_user(dedup_user($mtask->assign));
 | 
				
			||||||
  $projects = array();
 | 
					  $projects = array();
 | 
				
			||||||
  $status = ManiphestTaskStatus::STATUS_OPEN;
 | 
					  $status = ManiphestTaskStatus::STATUS_OPEN;
 | 
				
			||||||
  $description = '%%%' . html_entity_decode($mtask->description) . '%%%';
 | 
					  $description = '%%%' . str_replace("\r\n", "\n", html_entity_decode($mtask->description)) . '%%%';
 | 
				
			||||||
  $title = html_entity_decode($mtask->title);
 | 
					  $title = html_entity_decode($mtask->title);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* spam detection */
 | 
					  /* spam detection */
 | 
				
			||||||
@@ -161,7 +161,6 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=1) {
 | 
				
			|||||||
      $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED;
 | 
					      $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if($mtask->tracker == "Game Engine") {
 | 
					    else if($mtask->tracker == "Game Engine") {
 | 
				
			||||||
      $projects[] = lookup_project("BF Blender")->getPHID();
 | 
					 | 
				
			||||||
      $projects[] = lookup_project("Game Engine")->getPHID();
 | 
					      $projects[] = lookup_project("Game Engine")->getPHID();
 | 
				
			||||||
      $task_type = "Bug";
 | 
					      $task_type = "Bug";
 | 
				
			||||||
      $priority = 40;
 | 
					      $priority = 40;
 | 
				
			||||||
@@ -497,5 +496,3 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=1) {
 | 
				
			|||||||
    echo "ERROR: status out of sync, task should have been closed (" . $id . ")\n";
 | 
					    echo "ERROR: status out of sync, task should have been closed (" . $id . ")\n";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: test importing the whole range of tasks locally
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,7 +67,6 @@ function create_task($user, $id, $title, $projects, $description, $assign_user,
 | 
				
			|||||||
  $task->setTitle($title);
 | 
					  $task->setTitle($title);
 | 
				
			||||||
  $task->setProjectPHIDs($projects);
 | 
					  $task->setProjectPHIDs($projects);
 | 
				
			||||||
  $task->setCCPHIDs($ccs);
 | 
					  $task->setCCPHIDs($ccs);
 | 
				
			||||||
  // TODO when editing a task, it shows the description as edited even though it didn't really happen, why?
 | 
					 | 
				
			||||||
  $task->setDescription($description);
 | 
					  $task->setDescription($description);
 | 
				
			||||||
  $task->setPriority($priority);
 | 
					  $task->setPriority($priority);
 | 
				
			||||||
  $task->setOverrideDate($date);
 | 
					  $task->setOverrideDate($date);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,95 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					final class PhabricatorSettingsPanelChangeUsername
 | 
				
			||||||
 | 
					  extends PhabricatorSettingsPanel {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function getPanelKey() {
 | 
				
			||||||
 | 
					    return 'changeusername';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function getPanelName() {
 | 
				
			||||||
 | 
					    return pht('Change Username');
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function getPanelGroup() {
 | 
				
			||||||
 | 
					    return pht('Account Information');
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function getAlternatives($user) {
 | 
				
			||||||
 | 
					    $root = dirname(phutil_get_library_root('phabricator'));
 | 
				
			||||||
 | 
					    require $root.'/migration/dedup.php';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $alternatives = array();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    foreach($migrate_dedup_users as $from_user => $to_user) {
 | 
				
			||||||
 | 
					      if($from_user == $user->getUserName()) {
 | 
				
			||||||
 | 
					        $alternatives[$to_user] = $to_user;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      else if($to_user == $user->getUserName()) {
 | 
				
			||||||
 | 
					        $alternatives[$from_user] = $from_user;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return $alternatives;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function isEnabledForUser($user) {
 | 
				
			||||||
 | 
					    return count($this->getAlternatives($user)) > 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function processRequest(AphrontRequest $request) {
 | 
				
			||||||
 | 
					    $user = $request->getUser();
 | 
				
			||||||
 | 
					    $alternatives = $this->getAlternatives($user);
 | 
				
			||||||
 | 
					    $new_username = $request->getStr("new_username");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ($request->isFormPost()) {
 | 
				
			||||||
 | 
					      if (array_key_exists($new_username, $alternatives)) {
 | 
				
			||||||
 | 
					        id(new PhabricatorUserEditor())
 | 
				
			||||||
 | 
					          ->setActor($user)
 | 
				
			||||||
 | 
					          ->changeUsername($user, $new_username);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return id(new AphrontRedirectResponse())
 | 
				
			||||||
 | 
					          ->setURI($this->getPanelURI('?saved=true'));
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $instructions = pht(
 | 
				
			||||||
 | 
					      "Multiple of your accounts were merged into one because because Phabricator does not " .
 | 
				
			||||||
 | 
					      "support multiple accounts with the same email address. Here you can change your " .
 | 
				
			||||||
 | 
					      "account name your preferred one. For security purposes you must also enter choose " .
 | 
				
			||||||
 | 
					      "your password again (can be the same or new), for this you will receive an email.\n\n" .
 | 
				
			||||||
 | 
					      "Current username: **" . $user->getUserName() . "**.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $form = id(new AphrontFormView())
 | 
				
			||||||
 | 
					      ->setUser($user)
 | 
				
			||||||
 | 
					      ->appendRemarkupInstructions($instructions)
 | 
				
			||||||
 | 
					      ->appendChild(
 | 
				
			||||||
 | 
					        id(new AphrontFormSelectControl())
 | 
				
			||||||
 | 
					        ->setLabel(pht('Other Username'))
 | 
				
			||||||
 | 
					        ->setName("new_username")
 | 
				
			||||||
 | 
					        ->setValue($user->getUserName())
 | 
				
			||||||
 | 
					        ->setOptions($alternatives))
 | 
				
			||||||
 | 
					      ->appendChild(
 | 
				
			||||||
 | 
					        id(new AphrontFormSubmitControl())
 | 
				
			||||||
 | 
					          ->setValue(pht('Change Username')));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $error_view = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ($request->getBool('saved')) {
 | 
				
			||||||
 | 
					      $error_view = id(new AphrontErrorView())
 | 
				
			||||||
 | 
					        ->setTitle(pht('Username changed'))
 | 
				
			||||||
 | 
					        ->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
 | 
				
			||||||
 | 
					        ->setErrors(array(pht('Your username has been changed, check your mail inbox for instructions on how to reset your password.')));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $form_box = id(new PHUIObjectBoxView())
 | 
				
			||||||
 | 
					      ->setHeaderText(pht('Change Username'))
 | 
				
			||||||
 | 
					      ->setFormError($error_view)
 | 
				
			||||||
 | 
					      ->setForm($form);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return array(
 | 
				
			||||||
 | 
					      $form_box,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Reference in New Issue
	
	Block a user