/**
  * Add a Github repository
  *
  * @return void
  * @return null
  **/
 function add()
 {
     if (!GithubRepository::canAdd($this->logged_user, $this->active_project)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $repository_data = $this->request->post('repository');
     if (!is_array($repository_data)) {
         $repository_data = array('visibility' => $this->active_project->getDefaultVisibility());
     }
     // if
     if ($this->request->isSubmitted()) {
         $repository_data['name'] = trim($repository_data['name']) == '' ? $repository_data['url'] : $repository_data['name'];
         $this->active_repository->setAttributes($repository_data);
         $this->active_repository->setBody(clean(array_var($repository_data, 'url', null)));
         $this->active_repository->setProjectId($this->active_project->getId());
         $this->active_repository->setCreatedBy($this->logged_user);
         $this->active_repository->setState(STATE_VISIBLE);
         $result = $this->active_repository->testRepositoryConnection();
         if ($result === true) {
             $save = $this->active_repository->save();
             if ($save && !is_error($save)) {
                 flash_success(lang('Project repository ":name" has been added successfully'), array('name' => $this->active_repository->getName()));
                 $this->redirectToUrl(github_module_url($this->active_project));
             } else {
                 $save->errors['-- any --'] = $save->errors['body'];
                 $this->smarty->assign('errors', $save);
             }
             //if
         } else {
             $errors = new ValidationErrors();
             $errors->addError(lang('Failed to connect to repository: :message', array('message' => $result)));
             $this->smarty->assign('errors', $errors);
         }
         // if
     }
     // if
     $this->smarty->assign(array('repository_data' => $repository_data));
 }
 /**
  * Fetch details of a specific commit
  *
  * @return void
  * @author Chris Conover
  **/
 function getCommitFilePaths($hash)
 {
     $cache_key = 'github_commit_filepaths-' . $hash;
     $cache_duration = 60 * 10;
     // 10 minutes
     if (!is_null($cache_val = cache_get($cache_key)) && $cache_val[1] > time() - $cache_duration) {
         return $cache_val[0];
     } else {
         if (($url_info = $this->userRepoFromUrl()) !== False) {
             $request_url = sprintf(GithubRepository::$API_URLS['COMMIT'], $url_info['user'], $url_info['repo'], $hash);
             if (is_object($response = GithubRepository::githubAPIRequest($request_url))) {
                 $file_paths = array('added' => array(), 'modified' => array(), 'removed' => array());
                 foreach ($response->commit->modified as $mod) {
                     array_push($file_paths['modified'], $mod->filename);
                 }
                 foreach ($response->commit->added as $mod) {
                     array_push($file_paths['added'], $mod);
                 }
                 foreach ($response->commit->removed as $mod) {
                     array_push($file_paths['removed'], $mod);
                 }
                 cache_set($cache_key, array($file_paths, time()));
                 return $file_paths;
             } else {
                 $error = $response;
             }
         }
         return $error;
     }
 }
Esempio n. 3
0
<h3>Site Admin etc</h3>

<p>
<a href = "admin_faq.php">Add/edit/delete FAQ items</a><br>
<a href = 'admin_ancestors.php'>Add/edit/delete ancestors</a><br>
<a href = 'admin_groups.php'>Add/edit/delete groups</a><br>
<a href = 'admin_locations.php'>Add/edit/delete locations</a><br>
</p>

<p>
<?php 
include '../inc/version.php';
include '../inc/git.php';
$current_version = BitsandVersion::get();
$git = new GithubRepository('PeteAUK/bitsand');
$git_version = $git->getLatestTag();
if (!$git->connected()) {
    ?>
Unable to connect with Git Repository, please ensure the server has CURL available.<br/>
<?php 
} elseif (!BitsandVersion::under($git_version)) {
    ?>
You are running on the latest version of Bitsand (v<?php 
    echo $current_version;
    ?>
)<br/>
<?php 
} elseif ($git->gitControlled()) {
    ?>
There is a newer version of Bitsand available: v<?php 
Esempio n. 4
0
 +---------------------------------------------------------------------------*/
include '../inc/inc_head_db.php';
include '../inc/inc_admin.php';
include '../inc/inc_head_html.php';
?>
<script src="../inc/sorttable.js" type="text/javascript"></script>

<h1><?php 
echo TITLE;
?>
 - Update Core</h1>

<?php 
include '../inc/version.php';
include '../inc/git.php';
$git = new GithubRepository('PeteAUK/bitsand');
$git_version = $git->getLatestTag();
$success = false;
if (BitsandVersion::under($git_version)) {
    if ($git->gitControlled()) {
        ?>
<p>Your installation of Bitsand is version controlled using Git.  Please execute the following command to update to the latest version:</p>
<code>git pull origin master --tag v<?php 
        echo $git->getLatestTag(false);
        ?>
</code>
<?php 
    } else {
        if ($git->update($git_version)) {
            ?>
<p class="success">Success: Bitsand has been successfully updated</p>