예제 #1
0
 public static function handleChangeMaintainerRequest(Project $Project)
 {
     $GLOBALS['Session']->requireAuthentication();
     if (empty($_REQUEST['username'])) {
         return static::throwError('Parameter "username" required');
     }
     if (!($Project->Maintainer = User::getByUsername($_REQUEST['username']))) {
         return static::throwError('User not found');
     }
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         return static::respond('confirm', ['question' => sprintf(_('Are you sure you want to make %s the maintainer of %s?'), htmlspecialchars($Project->Maintainer->FullName), htmlspecialchars($Project->Title))]);
     }
     $Project->save();
     return static::respond('maintainerChanged', ['data' => $Project]);
 }