/**
  * Check repository access and add repository help on history page
  * @return void
  */
 function history()
 {
     //ProjectGitolite::delete_commits($this->active_repository->getId());
     /*         * $this->wireframe->actions->add('branches', lang('Branches'), '#', array(
               'subitems' => self::ac_gitolite_get_branches(),
               'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE),
               'id'=> 'branches_list'
               ));
     
               $this->wireframe->actions->add('tags', lang('Tags'), '#', array(
               'subitems' => self::ac_gitolite_get_tags(),
               'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE),
               'id'=> 'tags_list'
               ));
              */
     $repo_id = array_var($_GET, 'project_source_repository_id');
     //project objects id
     $project = $this->active_project;
     $repository = $this->active_repository;
     $repo_details = ProjectGitolite::get_repo_details($repo_id);
     if (is_array($repo_details) && count($repo_details) > 0) {
         //if ( $this->logged_user->isAdministrator () || $this->logged_user->isProjectManager () || $project->isLeader ( $this->logged_user ) ) {
         $this->wireframe->actions->add('manage_access', lang('Manage Access'), Router::assemble('edit_git_repository', array('project_slug' => $project->getSlug(), 'project_source_repository_id' => $repo_id)), array('id' => 'update_access_levels', 'onclick' => new FlyoutFormCallback("access_updated", array('width' => 'narrow')), 'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE)));
         //} //if
     }
     /*  Commented FTP section
          $this->wireframe->actions->add('add_ftp', 'FTP Connectiions', Router::assemble('add_ftp_conn',array('project_slug' => $this->active_project->getSlug(),
          'project_source_repository_id' => $repo_id)), array(
          'onclick' => new FlyoutFormCallback('ftps_updated', array('width' => '1100')),
          'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE))
          );
         */
     $this->wireframe->actions->add('add_hooks', 'Hooks', Router::assemble('add_hooks_git', array('project_slug' => $this->active_project->getSlug(), 'project_source_repository_id' => $repo_id)), array('onclick' => new FlyoutFormCallback('urls_updated', array('width' => '900')), 'icon' => AngieApplication::getPreferedInterface() == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE) : AngieApplication::getImageUrl('icons/16X16-git.png', AC_GITOLITE_MODULE, AngieApplication::INTERFACE_PHONE)));
     $repo_path = $repository->getRepositoryPathUrl();
     $repo_fk = $repository->getId();
     $chk_gitolite = ProjectGitolite::is_gitolite_repo($repo_fk);
     if (is_array($chk_gitolite) && sizeof($chk_gitolite) > 0 && $chk_gitolite['chk_gitolite'] > 0) {
         $settings = GitoliteAdmin::get_admin_settings();
         $clone_url = $settings['git_clone_url'] . $this->active_repository->getName() . ".git";
         $permissions = @unserialize($chk_gitolite['permissions']);
         if ($permissions !== false || $permissions === 'b:0;') {
             $permissions_array = $permissions;
         } else {
             $permissions_array = array();
         }
         if (array_key_exists($this->logged_user->getId(), $permissions_array) && $permissions_array[$this->logged_user->getId()] > 1 || $this->logged_user->isAdministrator() || $this->logged_user->isProjectManager() || $this->active_project->isLeader($this->logged_user)) {
             $body = "<h2>Git Global Setup</h2>";
             $body .= "<code>";
             $body .= "git config --global user.name '" . $this->logged_user->getDisplayName() . "'" . "<br>";
             $body .= "git config --global user.email '" . $this->logged_user->getEmail() . "'" . "<br>";
             $body .= "</code>";
             $body .= "<h2>Create Repository:</h2>";
             $body .= "<code>";
             $body .= "mkdir " . $this->active_repository->getName() . "<br>";
             $body .= "cd " . $this->active_repository->getName() . "<br>";
             $body .= "git init" . "<br>";
             $body .= "touch README" . "<br>";
             $body .= "git add README" . "<br>";
             $body .= "git commit -m 'first commit'" . "<br>";
             $body .= "git remote add origin " . $clone_url . "<br>";
             $body .= "git push -u origin master" . "<br>";
             $body .= "</code>";
             $body .= "<h2>Existing Git Repo?</h2>";
             $body .= "<code>";
             $body .= "cd existing_git_repo" . "<br>";
             $body .= "git remote add origin " . $clone_url . "<br>";
             $body .= "git push -u origin master";
             $body .= "</code>";
             $body_text = $body;
         } else {
             $this->response->forbidden();
         }
     } else {
         $body_text = $repository->getFieldValue("repository_path_url");
     }
     parent::history();
     $this->response->assign(array('body_text' => $body_text, 'repo_path' => $repo_path, 'clone_url' => $clone_url));
 }