/** * App detail page: edit/delete functionality. With the UI to add package and user to an app. * * It is the central place for an app object. */ public function appDetailAction() { $id = $this->_request->getParam('id'); $app = new Object_App($id); $appId = $app->getId(); if (empty($appId)) { // Not defined, redirect to list. $this->_redirect('/admin/client/app'); return false; } $form = new Form_Admin_Client_App(false, array('object' => $app)); // Check for package update if ($this->_request->isPost()) { $params = $this->_request->getPost(); if ($form->isValid($params)) { // Update package if necessary $form->updateObject($app); $form->setObject($app); } else { $form->populate($params); } } $this->view->app = $app; $this->view->client = new Object_Client($app->client_id); $this->view->form = $form; // Package titles and libraries $this->view->appPackages = Repo_AppPackage::getInstance()->getAppPackages($appId); $this->view->appUsers = Repo_AppUser::getInstance()->getAppUsers($appId); }
/** * Save user apps. * * @param array $apps A array of team ids. * @return boolean */ public function saveApps($apps) { // Remove all existing records Repo_AppUser::getInstance()->deleteAllUserApps($this->getId()); // Add one by one if (!is_array($apps) || empty($apps)) { return false; } foreach ($apps as $_aId) { Repo_AppUser::getInstance()->addNew($_aId, $this->getId()); } return true; }