original_string: public function copyDashboardToUser($idDashboard, $copyToUser, $dashboardName = '')
      {
          Piwik::checkUserHasSomeAdminAccess();
  
          // get users only returns users of sites the current user has at least admin access to
          $users = Request::processRequest('UsersManager.getUsers');
          $userFound = false;
          foreach ($users as $user) {
              if ($user['login'] === $copyToUser) {
                  $userFound = true;
                  break;
              }
          }
  
          if (!$userFound) {
              throw new \Exception(sprintf('Cannot copy dashboard to user %s, user not found.', $copyToUser));
          }
  
          $login  = Piwik::getCurrentUserLogin();
          $layout = $this->dashboard->getLayoutForUser($login, $idDashboard);
  
          if ($layout !== false) {
              return $this->model->createNewDashboardForUser($copyToUser, $dashboardName, $layout);
          }
  
          throw new \Exception('Dashboard not found');
      }
code: public function copyDashboardToUser($idDashboard, $copyToUser, $dashboardName = '')
      {
          Piwik::checkUserHasSomeAdminAccess();
  
          // get users only returns users of sites the current user has at least admin access to
          $users = Request::processRequest('UsersManager.getUsers');
          $userFound = false;
          foreach ($users as $user) {
              if ($user['login'] === $copyToUser) {
                  $userFound = true;
                  break;
              }
          }
  
          if (!$userFound) {
              throw new \Exception(sprintf('Cannot copy dashboard to user %s, user not found.', $copyToUser));
          }
  
          $login  = Piwik::getCurrentUserLogin();
          $layout = $this->dashboard->getLayoutForUser($login, $idDashboard);
  
          if ($layout !== false) {
              return $this->model->createNewDashboardForUser($copyToUser, $dashboardName, $layout);
          }
  
          throw new \Exception('Dashboard not found');
      }
code_tokens: public function copyDashboardToUser ( $ idDashboard , $ copyToUser , $ dashboardName = '' ) { Piwik :: checkUserHasSomeAdminAccess ( ) ; // get users only returns users of sites the current user has at least admin access to $ users = Request :: processRequest ( 'UsersManager.getUsers' ) ; $ userFound = false ; foreach ( $ users as $ user ) { if ( $ user [ 'login' ] === $ copyToUser ) { $ userFound = true ; break ; } } if ( ! $ userFound ) { throw new \ Exception ( sprintf ( 'Cannot copy dashboard to user %s, user not found.' , $ copyToUser ) ) ; } $ login = Piwik :: getCurrentUserLogin ( ) ; $ layout = $ this -> dashboard -> getLayoutForUser ( $ login , $ idDashboard ) ; if ( $ layout !== false ) { return $ this -> model -> createNewDashboardForUser ( $ copyToUser , $ dashboardName , $ layout ) ; } throw new \ Exception ( 'Dashboard not found' ) ; }
docstring: Copy a dashboard of current user to another user
  
  Note: current user needs super user access
  
  @param int $idDashboard Id of the dashboard that should be copied
  @param string $copyToUser User the dashboard should be copied to
  @param string $dashboardName Name of the new dashboard (defaults to 'Dashboard of {user}')
  @return int id of the new dashboard
  @throws \Exception if an error occurs, or dashboard can't be found
docstring_tokens: Copy a dashboard of current user to another user