* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
\OCP\User::checkLoggedIn();
\OCP\App::checkAppEnabled('collaboration');
OCP\App::setActiveNavigationEntry('collaboration');
OCP\Util::addScript('collaboration', 'project_details');
OCP\Util::addStyle('collaboration', 'tabs');
OCP\Util::addStyle('collaboration', 'content_header');
OCP\Util::addStyle('collaboration', 'project_details');
if (isset($_POST['pid']) && OC_Collaboration_Project::isMemberWorkingOnProject(OC_User::getUser(), $_POST['pid'])) {
    $tpl = new OCP\Template("collaboration", "project_details", "user");
    $details = OC_Collaboration_Project::readProject($_POST['pid']);
    if (isset($details['pid'])) {
        $tpl->assign('project_details', $details);
        if (isset($_POST['msg'])) {
            $tpl->assign('msg', $_POST['msg']);
        }
        $tpl->printPage();
    } else {
        goToDashboard();
    }
} else {
    goToDashboard();
}
function goToDashboard()
{
    header('Location: ' . \OCP\Util::linkToRoute('collaboration_route', array('rel_path' => 'dashboard')));
\OCP\User::checkLoggedIn();
\OCP\App::checkAppEnabled('collaboration');
OCP\App::setActiveNavigationEntry('collaboration');
OCP\Util::addScript('collaboration', 'update_project');
OCP\Util::addStyle('collaboration', 'content_header');
OCP\Util::addStyle('collaboration', 'tabs');
OCP\Util::addStyle('collaboration', 'update_project');
$l = OC_L10N::get('collaboration');
$bol = OC_Collaboration_Project::isAdmin();
if ($bol == true) {
    $tpl = new OCP\Template('collaboration', 'update_project', 'user');
    if (isset($_POST['pid'])) {
        $tpl->assign('title', $l->t('Update Project'));
        $tpl->assign('submit_btn_name', $l->t('Update'));
        $tpl->assign('pid', $_POST['pid']);
        $tpl->assign('project_details', OC_Collaboration_Project::readProject($_POST['pid']));
    } else {
        $tpl->assign('title', $l->t('Create Project'));
        $tpl->assign('submit_btn_name', $l->t('Create'));
    }
    $tpl->printPage();
} else {
    /*
    	Use this if you don't want to redirect
    	OCP\Util::addScript('collaboration', 'display_message');
    
    	$tpl = new OCP\Template('collaboration', 'display_message', 'user');
    	$tpl->assign('title', 'Permission denied');
    	$tpl->assign('msg', 'Sorry, you must have admin rights, to create a project.');
    	$tpl->printPage();
    */