Пример #1
0
 /**
  * Team detail page: edit/delete functionality. With the UI to add package and user to a team.
  *
  * It is the central place for a team object.
  */
 public function teamDetailAction()
 {
     $id = $this->_request->getParam('id');
     $team = new Object_Team($id);
     $teamId = $team->getId();
     if (empty($teamId)) {
         // No team defined, redirect to list.
         $this->_redirect('/admin/client/team');
         return false;
     }
     $form = new Form_Admin_Client_Team(false, array('team' => $team));
     // Check for team update
     if ($this->_request->isPost()) {
         $params = $this->_request->getPost();
         if ($form->isValid($params)) {
             // Update team if necessary
             $form->updateTeam($team);
             $form->setTeam($team);
         } else {
             $form->populate($params);
         }
     }
     $this->view->team = $team;
     $this->view->client = new Object_Client($team->client_id);
     $this->view->form = $form;
     // Team packages and users
     $this->view->teamPackages = Repo_TeamPackage::getInstance()->getTeamPackages($teamId);
     $this->view->teamUsers = Repo_TeamUser::getInstance()->getTeamUsers($teamId);
     $this->view->teamTeams = Repo_TeamTeam::getInstance()->getTeamChildren($teamId);
 }
Пример #2
0
 /**
  * Get all the titles a user is entitled, including package, team package, individual titles.
  *
  */
 public function getAllTitles()
 {
     $allPackages = array();
     $packages = Repo_UserPackage::getInstance()->getUserPackages($this->getId());
     foreach ($packages as $_package) {
         if (!isset($allPackages[$_package->id])) {
             $allPackages[$_package->id] = $_package;
         }
     }
     $teams = Repo_TeamUser::getInstance()->getUserTeams($this->getId());
     foreach ($teams as $_team) {
         $_teamId = $_team->id;
         $_packages = Repo_TeamPackage::getInstance()->getTeamPackages($_teamId);
         foreach ($_packages as $_package) {
             if (!isset($allPackages[$_package->id])) {
                 $allPackages[$_package->id] = $_package;
             }
         }
     }
     // OK get the titles for each package
     $allTitles = array();
     foreach ($allPackages as $_packageId => $_package) {
         $_titles = Repo_PackageTitle::getInstance()->getPackageTitles($_packageId);
         foreach ($_titles as $_title) {
             if (!isset($allTitles[$_title->id])) {
                 $allTitles[$_title->id] = $_title;
             }
         }
     }
     return $allTitles;
 }