Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/1.2.12'

  • Loading branch information...
commit 813a5d4624019e4c26132a77f929d93855ae34ba 2 parents fb35e1d + 18d750e
@Gipetto Gipetto authored
Showing with 321 additions and 2,128 deletions.
  1. +20 −1 CHANGELOG.markdown
  2. +2 −2 INSTALL.markdown
  3. +1 −1  OpenVBX/config/constants.php
  4. +1 −1  OpenVBX/config/version.php
  5. +1 −1  OpenVBX/controllers/flows.php
  6. +1 −1  OpenVBX/controllers/iframe.php
  7. +6 −8 OpenVBX/controllers/settings/site.php
  8. +4 −4 OpenVBX/helpers/applet_helper.php
  9. +2 −2 OpenVBX/helpers/format_helper.php
  10. +3 −2 OpenVBX/libraries/AppletInstance.php
  11. +1 −1  OpenVBX/libraries/AppletUI.php
  12. +1 −1  OpenVBX/libraries/AppletUI/AppletUIWidget.php
  13. +1 −1  OpenVBX/libraries/AppletUI/AudioSpeechPickerWidget.php
  14. +0 −6 OpenVBX/libraries/Caches/Local.php
  15. +0 −49 OpenVBX/libraries/Github/Api.php
  16. +0 −60 OpenVBX/libraries/Github/Api/Commit.php
  17. +0 −230 OpenVBX/libraries/Github/Api/Issue.php
  18. +0 −79 OpenVBX/libraries/Github/Api/Object.php
  19. +0 −119 OpenVBX/libraries/Github/Api/Organization.php
  20. +0 −90 OpenVBX/libraries/Github/Api/PullRequest.php
  21. +0 −400 OpenVBX/libraries/Github/Api/Repo.php
  22. +0 −198 OpenVBX/libraries/Github/Api/User.php
  23. +0 −5 OpenVBX/libraries/Github/ApiInterface.php
  24. +0 −34 OpenVBX/libraries/Github/Autoloader.php
  25. +0 −266 OpenVBX/libraries/Github/Client.php
  26. +0 −162 OpenVBX/libraries/Github/HttpClient.php
  27. +0 −97 OpenVBX/libraries/Github/HttpClient/Curl.php
  28. +0 −73 OpenVBX/libraries/Github/HttpClient/Exception.php
  29. +0 −44 OpenVBX/libraries/Github/HttpClientInterface.php
  30. +4 −1 OpenVBX/libraries/MY_Controller.php
  31. +1 −1  OpenVBX/libraries/Services/Twilio.php
  32. 0  OpenVBX/libraries/Services/Twilio/AutoPagingIterator.php
  33. 0  OpenVBX/libraries/Services/Twilio/Capability.php
  34. 0  OpenVBX/libraries/Services/Twilio/InstanceResource.php
  35. +20 −1 OpenVBX/libraries/Services/Twilio/ListResource.php
  36. 0  OpenVBX/libraries/Services/Twilio/Page.php
  37. 0  OpenVBX/libraries/Services/Twilio/PartialApplicationHelper.php
  38. 0  OpenVBX/libraries/Services/Twilio/RequestValidator.php
  39. +22 −2 OpenVBX/libraries/Services/Twilio/Resource.php
  40. +1 −0  OpenVBX/libraries/Services/Twilio/Rest/Account.php
  41. 0  OpenVBX/libraries/Services/Twilio/Rest/Accounts.php
  42. 0  OpenVBX/libraries/Services/Twilio/Rest/Application.php
  43. 0  OpenVBX/libraries/Services/Twilio/Rest/Applications.php
  44. 0  OpenVBX/libraries/Services/Twilio/Rest/AuthorizedConnectApp.php
  45. 0  OpenVBX/libraries/Services/Twilio/Rest/AuthorizedConnectApps.php
  46. 0  OpenVBX/libraries/Services/Twilio/Rest/AvailablePhoneNumber.php
  47. 0  OpenVBX/libraries/Services/Twilio/Rest/AvailablePhoneNumbers.php
  48. 0  OpenVBX/libraries/Services/Twilio/Rest/Call.php
  49. 0  OpenVBX/libraries/Services/Twilio/Rest/Calls.php
  50. 0  OpenVBX/libraries/Services/Twilio/Rest/Conference.php
  51. 0  OpenVBX/libraries/Services/Twilio/Rest/Conferences.php
  52. 0  OpenVBX/libraries/Services/Twilio/Rest/ConnectApp.php
  53. 0  OpenVBX/libraries/Services/Twilio/Rest/ConnectApps.php
  54. 0  OpenVBX/libraries/Services/Twilio/Rest/IncomingPhoneNumber.php
  55. +23 −2 OpenVBX/libraries/Services/Twilio/Rest/IncomingPhoneNumbers.php
  56. 0  OpenVBX/libraries/Services/Twilio/Rest/Member.php
  57. +6 −0 OpenVBX/libraries/Services/Twilio/Rest/Members.php
  58. 0  OpenVBX/libraries/Services/Twilio/Rest/Notification.php
  59. 0  OpenVBX/libraries/Services/Twilio/Rest/Notifications.php
  60. 0  OpenVBX/libraries/Services/Twilio/Rest/OutgoingCallerId.php
  61. 0  OpenVBX/libraries/Services/Twilio/Rest/OutgoingCallerIds.php
  62. 0  OpenVBX/libraries/Services/Twilio/Rest/Participant.php
  63. 0  OpenVBX/libraries/Services/Twilio/Rest/Participants.php
  64. 0  OpenVBX/libraries/Services/Twilio/Rest/Queue.php
  65. 0  OpenVBX/libraries/Services/Twilio/Rest/Queues.php
  66. 0  OpenVBX/libraries/Services/Twilio/Rest/Recording.php
  67. 0  OpenVBX/libraries/Services/Twilio/Rest/Recordings.php
  68. 0  OpenVBX/libraries/Services/Twilio/Rest/Sandbox.php
  69. 0  OpenVBX/libraries/Services/Twilio/Rest/ShortCode.php
  70. +5 −1 OpenVBX/libraries/Services/Twilio/Rest/ShortCodes.php
  71. 0  OpenVBX/libraries/Services/Twilio/Rest/SmsMessage.php
  72. 0  OpenVBX/libraries/Services/Twilio/Rest/SmsMessages.php
  73. 0  OpenVBX/libraries/Services/Twilio/Rest/Transcription.php
  74. 0  OpenVBX/libraries/Services/Twilio/Rest/Transcriptions.php
  75. 0  OpenVBX/libraries/Services/Twilio/Rest/UsageRecord.php
  76. 0  OpenVBX/libraries/Services/Twilio/Rest/UsageRecords.php
  77. 0  OpenVBX/libraries/Services/Twilio/Rest/UsageTrigger.php
  78. 0  OpenVBX/libraries/Services/Twilio/Rest/UsageTriggers.php
  79. 0  OpenVBX/libraries/Services/Twilio/RestException.php
  80. 0  OpenVBX/libraries/Services/Twilio/TimeRangeResource.php
  81. 0  OpenVBX/libraries/Services/Twilio/TinyHttp.php
  82. +5 −7 OpenVBX/libraries/Services/Twilio/Twiml.php
  83. 0  OpenVBX/libraries/Services/Twilio/UsageResource.php
  84. 0  OpenVBX/libraries/Services/cacert.pem
  85. +1 −1  OpenVBX/libraries/User_Controller.php
  86. +88 −0 OpenVBX/libraries/VBX_Github_Client.php
  87. +1 −1  OpenVBX/libraries/twilio.php
  88. +3 −68 OpenVBX/models/vbx_incoming_numbers.php
  89. +1 −25 OpenVBX/views/settings/site-system-config.php
  90. +2 −2 README.markdown
  91. +72 −72 assets/j/messages.js
  92. +7 −2 assets/j/pickers.js
  93. +6 −0 assets/j/plugins/buttonista.js
  94. +1 −0  assets/j/plugins/call-and-sms-dialogs.js
  95. +1 −1  openvbx.sql
  96. +1 −1  plugins/standard/applets/dial/ui.php
  97. +2 −2 updates/45.php
  98. +1 −0  updates/77.sql
  99. +2 −0  updates/78.sql
  100. +1 −0  updates/79.sql
View
21 CHANGELOG.markdown
@@ -1,5 +1,24 @@
# OpenVBX Change Log
+## Next
+
+- Fix cache table `value` field to be `mediumblob` instead of `text`. Fixes an issue where large lists of phone numbers (300+) would overflow the value field and corrupt the cached data.
+- Fix exception with latest versions of PHP when a default timezone is not set.
+- Fix Github API request for upgrade version check to use Github API V3.
+- Removing Sandbox number access. Sandbox numbers are no longer supported by Twilio.
+ - Also fixes an issue when loading phone number lists where looking for the pin attribute would cause a series of unecessary api calls.
+- Updating Twilio PHP library to fix issue with special characters in TwiML output.
+- Fix issue with double-encoded entities that manifested in flow editor. Use the `double_encode` flag in `htmlspecialchars` to protect against it happening.
+ - Minimum PHP version bumped to 5.2.3 to accommodate the double encode flag.
+
+
+## OpenVBX 1.2.11
+
+- Fix character counting on message detail page. Props to @walker.
+- Add focus to inputs on certain dialogs and pickers. Props to @walker.
+- Bump Twilio JS to 1.1 for WebRTC support.
+
+
## OpenVBX 1.2.10
- Fix improper exception pass through that would show the wrong error message to a user when updating settings.
@@ -295,4 +314,4 @@
- Fix for Error when changing the phone number on an existing user
- Added restriction for OpenVBX iphone app to 0.90
- Fix for user password reset in OpenVBX
-- For for problem with URLs containing double slashes in url generator
+- For for problem with URLs containing double slashes in url generator
View
4 INSTALL.markdown
@@ -9,7 +9,7 @@ Installing OpenVBX is quick and easy, just follow this five step guide to get up
* Web Server
* MySQL 5+
-* PHP 5.2+
+* PHP 5.2.3+
* [Twilio Account](https://www.twilio.com/try-twilio)
@@ -87,7 +87,7 @@ This page provides detailed information for each step of the OpenVBX install pro
OpenVBX requires the software listed below. It is all available for free and is open source. OpenVBX is supported and should run on all major linux distributions. OpenVBX may run on other platforms (namely Windows) but is currently unsupported.
-1. **PHP version:** We recommend PHP 5.2 or higher
+1. **PHP version:** We recommend PHP 5.2.3 or higher
1. **CURL support:** OpenVBX requires CURL. If you don't meet this requirement, install the CURL module.
1. **Apache version:** We recommend Apache version 2.2+. Earlier versions and other web servers may work, but are currently unsupported.
1. **MySQL support:** We require MySQL version 5+.
View
2  OpenVBX/config/constants.php
@@ -1,6 +1,6 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-define('MIN_PHP_VERSION', '5.2');
+define('MIN_PHP_VERSION', '5.2.3');
/*
|--------------------------------------------------------------------------
View
2  OpenVBX/config/version.php
@@ -1,3 +1,3 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-$config['version'] = '1.2.10';
+$config['version'] = '1.2.12';
View
2  OpenVBX/controllers/flows.php
@@ -277,7 +277,7 @@ private function flow_editor($id = 0, $type = 'voice')
{
$flow_data = get_object_vars($flow_obj);
}
-
+
// add start instance if it's not there
if(!isset($flow_data['start']))
{
View
2  OpenVBX/controllers/iframe.php
@@ -42,7 +42,7 @@ function index() {
'site_title' => 'OpenVBX',
'iframe_url' => site_url('/messages'),
'users' => $this->get_users(),
- 'twilio_js' => $this->twilio_js_baseurl.'/libs/twiliojs/1.0/'.$this->twilio_js_file,
+ 'twilio_js' => $this->twilio_js_baseurl.'/libs/twiliojs/1.1/'.$this->twilio_js_file,
'client_capability' => null
));
View
14 OpenVBX/controllers/settings/site.php
@@ -772,21 +772,19 @@ public function get_latest_tag()
}
try {
- include_once(APPPATH.'libraries/Github/Autoloader.php');
- Github_Autoloader::register();
-
- $gh = new Github_Client;
- $tags = $gh->getRepoApi()->getRepoTags('twilio', 'openvbx');
-
+ include_once(APPPATH . 'libraries/VBX_Github_Client.php');
+ $gh = new VBX_Github_Client;
+ $tags = $gh->getTags();
+
$latest = false;
-
+
if (is_array($tags) && count($tags) > 0)
{
$list = array_keys($tags);
usort($list, array($this, 'version_sort'));
$latest = array_pop($list);
}
-
+
$this->api_cache->set('latest_version', $latest, 'Site', $this->tenant->id);
}
catch (Exception $e) {
View
8 OpenVBX/helpers/applet_helper.php
@@ -46,8 +46,8 @@ function applet_dropdown($name = '', $options = array(), $selected = array(), $e
{
$key = (string) $key;
- $key = htmlspecialchars($key);
- $val = htmlspecialchars($val);
+ $key = htmlspecialchars($key, ENT_COMPAT, 'UTF-8', false);
+ $val = htmlspecialchars($val, ENT_COMPAT, 'UTF-8', false);
if (is_array($val))
{
@@ -55,8 +55,8 @@ function applet_dropdown($name = '', $options = array(), $selected = array(), $e
foreach ($val as $optgroup_key => $optgroup_val)
{
- $optgroup_key = htmlspecialchars($optgroup_key);
- $optgroup_val = htmlspecialchars($optgroup_val);
+ $optgroup_key = htmlspecialchars($optgroup_key, ENT_COMPAT, 'UTF-8', false);
+ $optgroup_val = htmlspecialchars($optgroup_val, ENT_COMPAT, 'UTF-8', false);
$sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
View
4 OpenVBX/helpers/format_helper.php
@@ -233,7 +233,7 @@ function html($data)
{
if(is_string($data))
{
- return htmlspecialchars($data);
+ return htmlspecialchars($data, ENT_COMPAT, 'UTF-8', false);
}
if(is_array($data))
@@ -242,7 +242,7 @@ function html($data)
{
if(is_string($val))
{
- $data[$key] = htmlspecialchars($val);
+ $data[$key] = htmlspecialchars($val, ENT_COMPAT, 'UTF-8', false);
}
else if(is_array($val))
{
View
5 OpenVBX/libraries/AppletInstance.php
@@ -109,11 +109,12 @@ public static function getValue($name, $default = '')
if(is_null($list))
{
- return html($default);
+ return $default;
}
- return html($list);
+ return $list;
}
+
return isset(self::$instance->$name)? self::$instance->$name : $default;
}
public static function getDropZoneValue($name = 'dropZone')
View
2  OpenVBX/libraries/AppletUI.php
@@ -60,7 +60,7 @@ public static function audioSpeechPicker($name = 'audioSpeechPicker')
else if (!empty($value))
{
$mode = 'say';
- $say = htmlspecialchars($value);
+ $say = $value;
}
$widget = new AudioSpeechPickerWidget($name, $mode, $say, $play);
View
2  OpenVBX/libraries/AppletUI/AppletUIWidget.php
@@ -55,7 +55,7 @@ private function escape($data)
{
if(is_string($data))
{
- return htmlspecialchars($data);
+ return htmlspecialchars($data, ENT_COMPAT, 'UTF-8', false);
}
else if(is_array($data))
{
View
2  OpenVBX/libraries/AppletUI/AudioSpeechPickerWidget.php
@@ -87,7 +87,7 @@ public function render($data = array())
$ci->load->model('vbx_incoming_numbers');
try
{
- $numbers = $ci->vbx_incoming_numbers->get_numbers(false);
+ $numbers = $ci->vbx_incoming_numbers->get_numbers();
foreach ($numbers as $number)
{
// find the first number that has voice enabled
View
6 OpenVBX/libraries/Caches/Local.php
@@ -12,12 +12,6 @@ public function __construct($options) {
}
public function __destruct() {}
-
- public function _keyname($group)
- {
- // mash up the group with the group's generation
-
- }
public function _set($key, $data, $group, $tenant_id, $expires = null)
{
View
49 OpenVBX/libraries/Github/Api.php
@@ -1,49 +0,0 @@
-<?php
-
-/**
- * Abstract class for Github_Api classes
- *
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-abstract class Github_Api implements Github_ApiInterface
-{
- /**
- * The client
- * @var Github_Client
- */
- private $client;
-
- public function __construct(Github_Client $client)
- {
- $this->client = $client;
- }
-
- /**
- * Call any path, GET method
- * Ex: $api->get('repos/show/my-username/my-repo')
- *
- * @param string $path the GitHub path
- * @param array $parameters GET parameters
- * @param array $requestOptions reconfigure the request
- * @return array data returned
- */
- protected function get($path, array $parameters = array(), $requestOptions = array())
- {
- return $this->client->get($path, $parameters, $requestOptions);
- }
-
- /**
- * Call any path, POST method
- * Ex: $api->post('repos/show/my-username', array('email' => 'my-new-email@provider.org'))
- *
- * @param string $path the GitHub path
- * @param array $parameters POST parameters
- * @param array $requestOptions reconfigure the request
- * @return array data returned
- */
- protected function post($path, array $parameters = array(), $requestOptions = array())
- {
- return $this->client->post($path, $parameters, $requestOptions);
- }
-}
View
60 OpenVBX/libraries/Github/Api/Commit.php
@@ -1,60 +0,0 @@
-<?php
-
-/**
- * Getting information on specific commits,
- * the diffs they introduce, the files they've changed.
- *
- * @link http://develop.github.com/p/commits.html
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-class Github_Api_Commit extends Github_Api
-{
- /**
- * List commits by username, repo and branch
- * http://develop.github.com/p/commits.html#listing_commits_on_a_branch
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $branch the branch
- * @return array list of users found
- */
- public function getBranchCommits($username, $repo, $branch)
- {
- $response = $this->get('commits/list/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($branch));
-
- return $response['commits'];
- }
-
- /**
- * List commits by username, repo, branch and path
- * http://develop.github.com/p/commits.html#listing_commits_for_a_file
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $branch the branch
- * @param string $path the path
- * @return array list of users found
- */
- public function getFileCommits($username, $repo, $branch, $path)
- {
- $response = $this->get('commits/list/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($branch).'/'.urlencode($path));
-
- return $response['commits'];
- }
-
- /**
- * Show a specific commit
- * http://develop.github.com/p/commits.html#showing_a_specific_commit
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $sha the commit sha
- */
- public function getCommit($username, $repo, $sha)
- {
- $response = $this->get('commits/show/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($sha));
-
- return $response['commit'];
- }
-}
View
230 OpenVBX/libraries/Github/Api/Issue.php
@@ -1,230 +0,0 @@
-<?php
-
-/**
- * Listing issues, searching, editing and closing your projects issues.
- *
- * @link http://develop.github.com/p/issues.html
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-class Github_Api_Issue extends Github_Api
-{
- /**
- * List issues by username, repo and state
- * http://develop.github.com/p/issues.html#list_a_projects_issues
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $state the issue state, can be open or closed
- * @return array list of issues found
- */
- public function getList($username, $repo, $state = 'open')
- {
- $response = $this->get('issues/list/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($state));
-
- return $response['issues'];
- }
-
- /**
- * Search issues by username, repo, state and search term
- * http://develop.github.com/p/issues.html#list_a_projects_issues
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $state the issue state, can be open or closed
- * @param string $searchTerm the search term to filter issues by
- * @return array list of issues found
- */
- public function search($username, $repo, $state, $searchTerm)
- {
- $response = $this->get('issues/search/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($state).'/'.urlencode($searchTerm));
-
- return $response['issues'];
- }
-
- /**
- * Search issues by label
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $label the label to filter issues by
- * @return array list of issues found
- */
- public function searchLabel($username, $repo, $label)
- {
- $response = $this->get('issues/list/'.urlencode($username).'/'.urlencode($repo).'/label/'.urlencode($label));
-
- return $response['issues'];
- }
-
- /**
- * Get extended information about an issue by its username, repo and number
- * http://develop.github.com/p/issues.html#view_an_issue
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @return array information about the issue
- */
- public function show($username, $repo, $issueNumber)
- {
- $response = $this->get('issues/show/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($issueNumber));
-
- return $response['issue'];
- }
-
- /**
- * Create a new issue for the given username and repo.
- * The issue is assigned to the authenticated user. Requires authentication.
- * http://develop.github.com/p/issues.html#open_and_close_issues
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueTitle the new issue title
- * @param string $issueBody the new issue body
- * @return array information about the issue
- */
- public function open($username, $repo, $issueTitle, $issueBody)
- {
- $response = $this->post('issues/open/'.urlencode($username).'/'.urlencode($repo), array(
- 'title' => $issueTitle,
- 'body' => $issueBody
- ));
-
- return $response['issue'];
- }
-
- /**
- * Close an existing issue by username, repo and issue number. Requires authentication.
- * http://develop.github.com/p/issues.html#open_and_close_issues
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @return array information about the issue
- */
- public function close($username, $repo, $issueNumber)
- {
- $response = $this->post('issues/close/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($issueNumber));
-
- return $response['issue'];
- }
-
- /**
- * Update issue informations by username, repo and issue number. Requires authentication.
- * http://develop.github.com/p/issues.html#edit_existing_issues
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @param array $data key=>value user attributes to update.
- * key can be title or body
- * @return array information about the issue
- */
- public function update($username, $repo, $issueNumber, array $data)
- {
- $response = $this->post('issues/edit/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($issueNumber), $data);
-
- return $response['issue'];
- }
-
- /**
- * Repoen an existing issue by username, repo and issue number. Requires authentication.
- * http://develop.github.com/p/issues.html#open_and_close_issues
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @return array informations about the issue
- */
- public function reOpen($username, $repo, $issueNumber)
- {
- $response = $this->post('issues/reopen/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($issueNumber));
-
- return $response['issue'];
- }
-
- /**
- * List an issue comments by username, repo and issue number
- * http://develop.github.com/p/issues.html#list_an_issues_comments
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @return array list of issue comments
- */
- public function getComments($username, $repo, $issueNumber)
- {
- $response = $this->get('issues/comments/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($issueNumber));
-
- return $response['comments'];
- }
-
- /**
- * Add a comment to the issue by username, repo and issue number
- * http://develop.github.com/p/issues.html#comment_on_issues
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @param string $comment the comment body
- * @return array the created comment
- */
- public function addComment($username, $repo, $issueNumber, $commentBody)
- {
- $response = $this->post('issues/comment/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($issueNumber), array(
- 'comment' => $commentBody
- ));
-
- return $response['comment'];
- }
-
- /**
- * List all project labels by username and repo
- * http://develop.github.com/p/issues.html#listing_labels
- *
- * @param string $username the username
- * @param string $repo the repo
- * @return array list of project labels
- */
- public function getLabels($username, $repo)
- {
- $response = $this->get('issues/labels/'.urlencode($username).'/'.urlencode($repo));
-
- return $response['labels'];
- }
-
- /**
- * Add a label to the issue by username, repo and issue number. Requires authentication.
- * http://develop.github.com/p/issues.html#add_and_remove_labels
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @param string $labelName the label name
- * @return array list of issue labels
- */
- public function addLabel($username, $repo, $labelName, $issueNumber)
- {
- $response = $this->post('issues/label/add/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($labelName).'/'.urlencode($issueNumber));
-
- return $response['labels'];
- }
-
- /**
- * Remove a label from the issue by username, repo, issue number and label name. Requires authentication.
- * http://develop.github.com/p/issues.html#add_and_remove_labels
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $issueNumber the issue number
- * @param string $labelName the label name
- * @return array list of issue labels
- */
- public function removeLabel($username, $repo, $labelName, $issueNumber)
- {
- $response = $this->post('issues/label/remove/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($labelName).'/'.urlencode($issueNumber));
-
- return $response['labels'];
- }
-}
View
79 OpenVBX/libraries/Github/Api/Object.php
@@ -1,79 +0,0 @@
-<?php
-
-/**
- * Getting full versions of specific files and trees in your Git repositories.
- *
- * @link http://develop.github.com/p/object.html
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-class Github_Api_Object extends Github_Api
-{
- /**
- * Get a listing of the root tree of a project by the username, repo, and tree SHA
- * http://develop.github.com/p/object.html#trees
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $treeSHA the tree sha
- * @return array root tree of the project
- */
- public function showTree($username, $repo, $treeSHA)
- {
- $response = $this->get('tree/show/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($treeSHA));
-
- return $response['tree'];
- }
-
- /**
- * Lists the data blobs of a tree by tree SHA
- * http://develop.github.com/p/object.html#blobs
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $treeSHA the tree sha
- * @param string $path the path
- * @return array data blobs of tree
- */
- public function listBlobs($username, $repo, $treeSHA)
- {
- $response = $this->get('blob/all/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($treeSHA));
-
- return $response['blobs'];
- }
-
- /**
- * Get the data about a blob by tree SHA and file path.
- * http://develop.github.com/p/object.html#blobs
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $treeSHA the tree sha
- * @param string $path the path
- * @return array data blob of tree and path
- */
- public function showBlob($username, $repo, $treeSHA, $path)
- {
- $response = $this->get('blob/show/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($treeSHA).'/'.urlencode($path));
-
- return $response['blob'];
- }
-
- /**
- * Returns the raw text content of the object.
- * http://develop.github.com/p/object.html#raw_git_data
- *
- * @param string $username the username
- * @param string $repo the repo
- * @param string $objectSHA the object sha can be either a blob SHA1, a tree SHA1 or a commit SHA1
- * @return string raw text content of the blob, tree or commit object
- */
- public function getRawData($username, $repo, $objectSHA)
- {
- $response = $this->get('blob/show/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($objectSHA), array(), array(
- 'format' => 'text'
- ));
-
- return $response;
- }
-}
View
119 OpenVBX/libraries/Github/Api/Organization.php
@@ -1,119 +0,0 @@
-<?php
-
-/**
- * Searching organizations, getting organization information
- * and managing authenticated organization account information.
- *
- * @link http://develop.github.com/p/orgs.html
- * @author Antoine Berranger <antoine at ihqs dot net>
- * @license MIT License
- */
-class Github_Api_Organization extends Github_Api
-{
- const ADMIN = "admin";
- const PUSH = "push";
- const PULL = "pull";
-
- static $PERMISSIONS = array(
- self::ADMIN,
- self::PUSH,
- self::PULL
- );
-
- /**
- * Get extended information about an organization by its name
- * http://develop.github.com/p/orgs.html
- *
- * @param string $name the organization to show
- * @return array informations about the organization
- */
- public function show($name)
- {
- $response = $this->get('organizations/'.urlencode($name));
-
- return $response['organization'];
- }
-
- /**
- * List all repositories across all the organizations that you can access
- * http://develop.github.com/p/orgs.html
- *
- * @param string $name the user name
- * @return array the repositories
- */
- public function getAllRepos($name)
- {
- $response = $this->get('organizations/repositories');
-
- return $response['repositories'];
- }
-
- /**
- * List all public repositories of any other organization
- * http://develop.github.com/p/orgs.html
- *
- * @param string $name the organization name
- * @return array the repositories
- */
- public function getPublicRepos($name)
- {
- $response = $this->get('organizations/'.urlencode($name).'/public_repositories');
-
- return $response['repositories'];
- }
-
- /**
- * List all public members of that organization
- * http://develop.github.com/p/orgs.html
- *
- * @param string $name the organization name
- * @return array the members
- */
- public function getPublicMembers($name)
- {
- $response = $this->get('organizations/'.urlencode($name).'/public_members');
-
- return $response['users'];
- }
-
- /**
- * List all teams of that organization
- * http://develop.github.com/p/orgs.html
- *
- * @param string $name the organization name
- * @return array the teams
- */
- public function getTeams($name)
- {
- $response = $this->get('organizations/'.urlencode($name).'/teams');
-
- return $response['teams'];
- }
-
- /**
- * Add a team to that organization
- * http://develop.github.com/p/orgs.html
- *
- * @param string $name the organization name
- * @param string $team name of the new team
- * @param string $permission its permission [PULL|PUSH|ADMIN]
- * @param array $name (optionnal) its repositories names
- *
- * @return array the teams
- */
- public function addTeam($organization, $team, $permission, array $repositories = array())
- {
- if (!in_array($permission, self::$PERMISSIONS)) {
- throw new InvalidArgumentException("Invalid value for the permission variable");
- }
-
- $response = $this->post('organizations/'.urlencode($organization).'/teams', array(
- 'team' => $team,
- 'permission' => $permission,
- 'repo_names' => $repositories
- ));
-
- return $response['teams'];
- }
-
-}
View
90 OpenVBX/libraries/Github/Api/PullRequest.php
@@ -1,90 +0,0 @@
-<?php
-
-/**
- * API for accessing Pull Requests from your Git/Github repositories.
- *
- * @link http://develop.github.com/p/pulls.html
- * @author Nicolas Pastorino <nicolas.pastorino at gmail dot com>
- * @license MIT License
- */
-class Github_Api_PullRequest extends Github_Api
-{
- /**
- * Get a listing of a project's pull requests by the username, repo, and optionnally state.
- *
- * @link http://develop.github.com/p/pulls.html
- * @param string $username the username
- * @param string $repo the repo
- * @param string $state the state of the fetched pull requests.
- * The API seems to automatically default to 'open'
- * @return array array of pull requests for the project
- */
- public function listPullRequests($username, $repo, $state = '')
- {
- $response = $this->get('pulls/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($state));
- return $response['pulls'];
- }
-
- /**
- * Show all details of a pull request, including the discussions.
- *
- * @link http://develop.github.com/p/pulls.html
- * @param string $username the username
- * @param string $repo the repo
- * @param string $pullRequestId the ID of the pull request for which details are retrieved
- * @return array array of pull requests for the project
- */
- public function show($username, $repo, $pullRequestId)
- {
- $response = $this->get('pulls/'.urlencode($username).'/'.urlencode($repo).'/'.urlencode($pullRequestId));
- return $response['pulls'];
- }
-
- /**
- * Create a pull request
- *
- * @link http://develop.github.com/p/pulls.html
- * @param string $username the username
- * @param string $repo the repo
- * @param string $base A String of the branch or commit SHA that you want your changes to be pulled to.
- * @param string $head A String of the branch or commit SHA of your changes.
- * Typically this will be a branch. If the branch is in a fork of the original repository,
- * specify the username first: "my-user:some-branch".
- * @param string $title The String title of the Pull Request. Used in pair with $body.
- * @param string $body The String body of the Pull Request. Used in pair with $title.
- * @param int $issueId If a pull-request is related to an issue, place issue ID here. The $title-$body pair and this are mutually exclusive.
- * @return array array of pull requests for the project
- */
- public function create($username, $repo, $base, $head, $title = null, $body = null, $issueId = null)
- {
- $postParameters = array( 'pull[base]' => $base,
- 'pull[head]' => $head
- );
-
- if ( $title !== null and $body !== null ) {
- $postParameters = array_merge( $postParameters,
- array(
- 'pull[title]' => $title,
- 'pull[body]' => $body
- )
- );
- } elseif ( $issueId !== null ) {
- $postParameters = array_merge( $postParameters,
- array(
- 'pull[issue]' => $issueId
- )
- );
- } else {
- // @FIXME : Exception required here.
- return null;
- }
-
- $response = $this->post('pulls/'.urlencode($username).'/'.urlencode($repo),
- $postParameters
- );
-
- // @FIXME : Exception to be thrown when $response['error'] exists.
- // Content of error can be : "{"error":["A pull request already exists for <username>:<branch>."]}"
- return $response['pull'];
- }
-}
View
400 OpenVBX/libraries/Github/Api/Repo.php
@@ -1,400 +0,0 @@
-<?php
-
-/**
- * Searching repositories, getting repository information
- * and managing repository information for authenticated users.
- *
- * @link http://develop.github.com/p/repos.html
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-class Github_Api_Repo extends Github_Api
-{
- /**
- * Search repos by keyword
- * http://develop.github.com/p/repo.html
- *
- * @param string $query the search query
- * @param string $language takes the same values as the language drop down on http://github.com/search
- * @param int $startPage the page number
- * @return array list of repos found
- */
- public function search($query, $language = '', $startPage = 1)
- {
- $response = $this->get('repos/search/'.urlencode($query), array(
- 'language' => strtolower($language),
- 'start_page' => $startPage
- ));
-
- return $response['repositories'];
- }
-
- /**
- * Get the repositories of a user
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the username
- * @return array list of the user repos
- */
- public function getUserRepos($username)
- {
- $response = $this->get('repos/show/'.urlencode($username));
-
- return $response['repositories'];
- }
-
- /**
- * Get a list of the repositories that the authenticated user can push to
- *
- * @return array list of repositories
- */
- public function getPushableRepos()
- {
- $response = $this->get('repos/pushable');
-
- return $response['repositories'];
- }
-
- /**
- * Get extended information about a repository by its username and repo name
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array informations about the repo
- */
- public function show($username, $repo)
- {
- $response = $this->get('repos/show/'.urlencode($username).'/'.urlencode($repo));
-
- return $response['repository'];
- }
-
- /**
- * create repo
- * http://develop.github.com/p/repo.html
- *
- * @param string $name name of the repository
- * @param string $description repo description
- * @param string $homepage homepage url
- * @param bool $public 1 for public, 0 for private
- * @return array returns repo data
- */
- public function create($name, $description = '', $homepage = '', $public = true)
- {
- $response = $this->post('repos/create', array(
- 'name' => $name,
- 'description' => $description,
- 'homepage' => $homepage,
- 'public' => $public
- ));
-
- return $response['repository'];
- }
-
- /**
- * delete repo
- * http://develop.github.com/p/repo.html
- *
- * @param string $name name of the repository
- * @param string $token delete token
- * @param string $force force repository deletion
- *
- * @return string|array returns delete_token or repo status
- */
- public function delete($name, $token = null, $force = false)
- {
- if ($token === null) {
- $response = $this->post('repos/delete/'.urlencode($name));
-
- $token = $response['delete_token'];
-
- if (!$force) {
- return $token;
- }
- }
-
- $response = $this->post('repos/delete/'.urlencode($name), array(
- 'delete_token' => $token,
- ));
-
- return $response;
- }
-
- /**
- * Set information of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @param array $values the key => value pairs to post
- * @return array informations about the repo
- */
- public function setRepoInfo($username, $repo, $values)
- {
- $response = $this->post('repos/show/'.urlencode($username).'/'.urlencode($repo), array('values' => $values));
-
- return $response['repository'];
- }
-
- /**
- * Set the visibility of a repostory to public
- * http://develop.github.com/p/repo.html
- *
- * @param string $repo the name of the repo
- * @return array informations about the repo
- */
- public function setPublic($repo)
- {
- $response = $this->get('repos/set/public/'.urlencode($repo));
-
- return $response['repository'];
- }
-
- /**
- * Set the visibility of a repostory to private
- * http://develop.github.com/p/repo.html
- *
- * @param string $repo the name of the repo
- * @return array informations about the repo
- */
- public function setPrivate($repo)
- {
- $response = $this->get('repos/set/private/'.urlencode($repo));
-
- return $response['repository'];
- }
-
- /**
- * Get the list of deploy keys for a repository
- *
- * @param string $repo the name of the repo
- * @return array the list of deploy keys
- */
- public function getDeployKeys($repo)
- {
- $response = $this->get('repos/keys/'.urlencode($repo));
-
- return $response['public_keys'];
- }
-
- /**
- * Add a deploy key for a repository
- *
- * @param string $repo the name of the repo
- * @param string $title the title of the key
- * @param string $key the public key data
- * @return array the list of deploy keys
- */
- public function addDeployKey($repo, $title, $key)
- {
- $response = $this->post('repos/key/'.urlencode($repo).'/add', array(
- 'title' => $title,
- 'key' => $key
- ));
-
- return $response['public_keys'];
- }
-
- /**
- * Delete a deploy key from a repository
- *
- * @param string $repo the name of the repo
- * @param string $id the the id of the key to remove
- * @return array the list of deploy keys
- */
- public function removeDeployKey($repo, $id)
- {
- $response = $this->post('repos/key/'.urlencode($repo).'/remove', array(
- 'id' => $id,
- ));
-
- return $response['public_keys'];
- }
-
- /**
- * Get the collaborators of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array list of the repo collaborators
- */
- public function getRepoCollaborators($username, $repo)
- {
- $response = $this->get('repos/show/'.urlencode($username).'/'.urlencode($repo).'/collaborators');
-
- return $response['collaborators'];
- }
-
- /**
- * Add a collaborator to a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $repo the name of the repo
- * @param string $username the user who should be added as a collaborator
- * @return array list of the repo collaborators
- */
- public function addRepoCollaborator($repo, $username)
- {
- $response = $this->post('repos/collaborators/'.urlencode($repo).'/add/'.urlencode($username));
-
- return $response['collaborators'];
- }
-
- /**
- * Delete a collaborator from a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $repo the name of the repo
- * @param string $username the user who should be removed as a collaborator
- * @return array list of the repo collaborators
- */
- public function removeRepoCollaborator($repo, $username)
- {
- $response = $this->post('repos/collaborators/'.urlencode($repo).'/remove/'.urlencode($username));
-
- return $response['collaborators'];
- }
-
- /**
- * Make the authenticated user watch a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array informations about the repo
- */
- public function watch($username, $repo)
- {
- $response = $this->get('repos/watch/'.urlencode($username).'/'.urlencode($repo));
-
- return $response['repository'];
- }
-
- /**
- * Make the authenticated user unwatch a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array informations about the repo
- */
- public function unwatch($username, $repo)
- {
- $response = $this->get('repos/unwatch/'.urlencode($username).'/'.urlencode($repo));
-
- return $response['repository'];
- }
-
- /**
- * Make the authenticated user fork a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array informations about the newly forked repo
- */
- public function fork($username, $repo)
- {
- $response = $this->get('repos/fork/'.urlencode($username).'/'.urlencode($repo));
-
- return $response['repository'];
- }
-
- /**
- * Get the tags of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array list of the repo tags
- */
- public function getRepoTags($username, $repo)
- {
- $response = $this->get('repos/show/'.urlencode($username).'/'.urlencode($repo).'/tags');
-
- return $response['tags'];
- }
-
- /**
- * Get the branches of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the username
- * @param string $repo the name of the repo
- * @return array list of the repo branches
- */
- public function getRepoBranches($username, $repo)
- {
- $response = $this->get('repos/show/'.urlencode($username).'/'.urlencode($repo).'/branches');
-
- return $response['branches'];
- }
-
- /**
- * Get the watchers of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array list of the repo watchers
- */
- public function getRepoWatchers($username, $repo)
- {
- $response = $this->get('repos/show/'.urlencode($username).'/'.urlencode($repo).'/watchers');
-
- return $response['watchers'];
- }
-
- /**
- * Get the network (a list of forks) of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array list of the repo forks
- */
- public function getRepoNetwork($username, $repo)
- {
- $response = $this->get('repos/show/'.urlencode($username).'/'.urlencode($repo).'/network');
-
- return $response['network'];
- }
-
- /**
- * Get the language breakdown of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @return array list of the languages
- */
- public function getRepoLanguages($username, $repo)
- {
- $response = $this->get('repos/show/'.urlencode($username).'/'.urlencode($repo).'/languages');
-
- return $response['languages'];
- }
-
- /**
- * Get the contributors of a repository
- * http://develop.github.com/p/repo.html
- *
- * @param string $username the user who owns the repo
- * @param string $repo the name of the repo
- * @param boolean $includingNonGithubUsers by default, the list only shows GitHub users. You can include non-users too by setting this to true
- * @return array list of the repo contributors
- */
- public function getRepoContributors($username, $repo, $includingNonGithubUsers = false)
- {
- $url = 'repos/show/'.urlencode($username).'/'.urlencode($repo).'/contributors';
- if ($includingNonGithubUsers) {
- $url .= '/anon';
- }
- $response = $this->get($url);
-
- return $response['contributors'];
- }
-
-}
View
198 OpenVBX/libraries/Github/Api/User.php
@@ -1,198 +0,0 @@
-<?php
-
-/**
- * Searching users, getting user information
- * and managing authenticated user account information.
- *
- * @link http://develop.github.com/p/users.html
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-class Github_Api_User extends Github_Api
-{
- /**
- * Search users by username
- * http://develop.github.com/p/users.html#searching_for_users
- *
- * @param string $username the username to search
- * @return array list of users found
- */
- public function search($username)
- {
- $response = $this->get('user/search/'.urlencode($username));
-
- return $response['users'];
- }
-
- /**
- * Get extended information about a user by its username
- * http://develop.github.com/p/users.html#getting_user_information
- *
- * @param string $username the username to show
- * @return array informations about the user
- */
- public function show($username)
- {
- $response = $this->get('user/show/'.urlencode($username));
-
- return $response['user'];
- }
-
- /**
- * Update user informations. Requires authentication.
- * http://develop.github.com/p/users.html#authenticated_user_management
- *
- * @param string $username the username to update
- * @param array $data key=>value user attributes to update.
- * key can be name, email, blog, company or location
- * @return array informations about the user
- */
- public function update($username, array $data)
- {
- $response = $this->post('user/show/'.urlencode($username), array('values' => $data));
-
- return $response['user'];
- }
-
- /**
- * Request the users that a specific user is following
- * http://develop.github.com/p/users.html#following_network
- *
- * @param string $username the username
- * @return array list of followed users
- */
- public function getFollowing($username)
- {
- $response = $this->get('user/show/'.urlencode($username).'/following');
-
- return $response['users'];
- }
-
- /**
- * Request the users following a specific user
- * http://develop.github.com/p/users.html#following_network
- *
- * @param string $username the username
- * @return array list of following users
- */
- public function getFollowers($username)
- {
- $response = $this->get('user/show/'.urlencode($username).'/followers');
-
- return $response['users'];
- }
-
- /**
- * Make the authenticated user follow the specified user. Requires authentication.
- * http://develop.github.com/p/users.html#following_network
- *
- * @param string $username the username to follow
- * @return array list of followed users
- */
- public function follow($username)
- {
- $response = $this->post('user/follow/'.urlencode($username));
-
- return $response['users'];
- }
-
- /**
- * Make the authenticated user unfollow the specified user. Requires authentication.
- * http://develop.github.com/p/users.html#following_network
- *
- * @param string $username the username to unfollow
- * @return array list of followed users
- */
- public function unFollow($username)
- {
- $response = $this->post('user/unfollow/'.urlencode($username));
-
- return $response['users'];
- }
-
- /**
- * Request the repos that a specific user is watching
- * http://develop.github.com/p/users.html#watched_repos
- *
- * @param string $username the username
- * @return array list of watched repos
- */
- public function getWatchedRepos($username)
- {
- $response = $this->get('repos/watched/'.urlencode($username));
-
- return $response['repositories'];
- }
-
- /**
- * Get the authenticated user public keys. Requires authentication
- *
- * @return array list of public keys of the user
- */
- public function getKeys()
- {
- $response = $this->get('user/keys');
-
- return $response['public_keys'];
- }
-
- /**
- * Add a public key to the authenticated user. Requires authentication.
- *
- * @return array list of public keys of the user
- */
- public function addKey($title, $key)
- {
- $response = $this->post('user/key/add', array('title' => $title, 'key' => $key));
-
- return $response['public_keys'];
- }
-
- /**
- * Remove a public key from the authenticated user. Requires authentication.
- *
- * @return array list of public keys of the user
- */
- public function removeKey($id)
- {
- $response = $this->post('user/key/remove', array('id' => $id));
-
- return $response['public_keys'];
- }
-
- /**
- * Get the authenticated user emails. Requires authentication.
- *
- * @return array list of authenticated user emails
- */
- public function getEmails()
- {
- $response = $this->get('user/emails');
-
- return $response['emails'];
- }
-
- /**
- * Add an email to the authenticated user. Requires authentication.
- *
- * @return array list of authenticated user emails
- */
- public function addEmail($email)
- {
- $response = $this->post('user/email/add', array('email' => $email));
-
- return $response['emails'];
- }
-
- /**
- * Remove an email from the authenticated user. Requires authentication.
- *
- * @return array list of authenticated user emails
- */
- public function removeEmail($email)
- {
- $response = $this->post('user/email/remove', array('email' => $email));
-
- return $response['emails'];
- }
-}
View
5 OpenVBX/libraries/Github/ApiInterface.php
@@ -1,5 +0,0 @@
-<?php
-
-interface Github_ApiInterface
-{
-}
View
34 OpenVBX/libraries/Github/Autoloader.php
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * Autoloads Github classes
- */
-class Github_Autoloader
-{
- /**
- * Registers Github_Autoloader as an SPL autoloader.
- */
- static public function register()
- {
- ini_set('unserialize_callback_func', 'spl_autoload_call');
- spl_autoload_register(array(new self, 'autoload'));
- }
-
- /**
- * Handles autoloading of classes.
- *
- * @param string $class A class name.
- *
- * @return boolean Returns true if the class has been loaded
- */
- static public function autoload($class)
- {
- if (0 !== strpos($class, 'Github')) {
- return;
- }
-
- if (file_exists($file = dirname(__FILE__).'/../'.str_replace('_', '/', $class).'.php')) {
- require $file;
- }
- }
-}
View
266 OpenVBX/libraries/Github/Client.php
@@ -1,266 +0,0 @@
-<?php
-
-/**
- * Simple yet very cool PHP Github client
- *
- * @tutorial http://github.com/ornicar/php-github-api/blob/master/README.markdown
- * @version 3.2
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- *
- * Website: http://github.com/ornicar/php-github-api
- * Tickets: http://github.com/ornicar/php-github-api/issues
- */
-class Github_Client
-{
- /**
- * Constant for authentication method. Indicates the default, but deprecated
- * login with username and token in URL.
- */
- const AUTH_URL_TOKEN = 'url_token';
-
- /**
- * Constant for authentication method. Indicates the new favored login method
- * with username and password via HTTP Authentication.
- */
- const AUTH_HTTP_PASSWORD = 'http_password';
-
- /**
- * Constant for authentication method. Indicates the new login method with
- * with username and token via HTTP Authentication.
- */
- const AUTH_HTTP_TOKEN = 'http_token';
-
- /**
- * The httpClient instance used to communicate with GitHub
- *
- * @var Github_HttpClient_Interface
- */
- protected $httpClient = null;
-
- /**
- * The list of loaded API instances
- *
- * @var array
- */
- protected $apis = array();
-
- /**
- * Instanciate a new GitHub client
- *
- * @param Github_HttpClient_Interface $httpClient custom http client
- */
- public function __construct(Github_HttpClientInterface $httpClient = null)
- {
- if (null === $httpClient) {
- $this->httpClient = new Github_HttpClient_Curl();
- } else {
- $this->httpClient = $httpClient;
- }
- }
-
- /**
- * Authenticate a user for all next requests
- *
- * @param string $login GitHub username
- * @param string $secret GitHub private token or Github password if $method == AUTH_HTTP_PASSWORD
- * @param string $method One of the AUTH_* class constants
- *
- * @return null
- */
- public function authenticate($login, $secret, $method = NULL)
- {
- if (!$method) {
- $method = self::AUTH_URL_TOKEN;
- }
-
- $this->getHttpClient()
- ->setOption('auth_method', $method)
- ->setOption('login', $login)
- ->setOption('secret', $secret);
- }
-
- /**
- * Deauthenticate a user for all next requests
- *
- * @return null
- */
- public function deAuthenticate()
- {
- $this->authenticate(null, null, null);
- }
-
- /**
- * Call any path, GET method
- * Ex: $api->get('repos/show/my-username/my-repo')
- *
- * @param string $path the GitHub path
- * @param array $parameters GET parameters
- * @param array $requestOptions reconfigure the request
- * @return array data returned
- */
- public function get($path, array $parameters = array(), $requestOptions = array())
- {
- return $this->getHttpClient()->get($path, $parameters, $requestOptions);
- }
-
- /**
- * Call any path, POST method
- * Ex: $api->post('repos/show/my-username', array('email' => 'my-new-email@provider.org'))
- *
- * @param string $path the GitHub path
- * @param array $parameters POST parameters
- * @param array $requestOptions reconfigure the request
- * @return array data returned
- */
- public function post($path, array $parameters = array(), $requestOptions = array())
- {
- return $this->getHttpClient()->post($path, $parameters, $requestOptions);
- }
-
- /**
- * Get the http client.
- *
- * @return Github_HttpClient_Interface a request instance
- */
- public function getHttpClient()
- {
- return $this->httpClient;
- }
-
- /**
- * Inject another http client
- *
- * @param Github_HttpClient_Interface a httpClient instance
- *
- * @return null
- */
- public function setHttpClient(Github_HttpClient_Interface $httpClient)
- {
- $this->httpClient = $httpClient;
- }
-
- /**
- * Get the user API
- *
- * @return Github_Api_User the user API
- */
- public function getUserApi()
- {
- if (!isset($this->apis['user'])) {
- $this->apis['user'] = new Github_Api_User($this);
- }
-
- return $this->apis['user'];
- }
-
- /**
- * Get the issue API
- *
- * @return Github_Api_Issue the issue API
- */
- public function getIssueApi()
- {
- if (!isset($this->apis['issue'])) {
- $this->apis['issue'] = new Github_Api_Issue($this);
- }
-
- return $this->apis['issue'];
- }
-
- /**
- * Get the commit API
- *
- * @return Github_Api_Commit the commit API
- */
- public function getCommitApi()
- {
- if (!isset($this->apis['commit'])) {
- $this->apis['commit'] = new Github_Api_Commit($this);
- }
-
- return $this->apis['commit'];
- }
-
- /**
- * Get the repo API
- *
- * @return Github_Api_Repo the repo API
- */
- public function getRepoApi()
- {
- if (!isset($this->apis['repo'])) {
- $this->apis['repo'] = new Github_Api_Repo($this);
- }
-
- return $this->apis['repo'];
- }
-
- /**
- * Get the organization API
- *
- * @return Github_Api_Organization the object API
- */
- public function getOrganizationApi()
- {
- if (!isset($this->apis['organization'])) {
- $this->apis['organization'] = new Github_Api_Organization($this);
- }
-
- return $this->apis['organization'];
- }
-
- /**
- * Get the object API
- *
- * @return Github_Api_Object the object API
- */
- public function getObjectApi()
- {
- if (!isset($this->apis['object'])) {
- $this->apis['object'] = new Github_Api_Object($this);
- }
-
- return $this->apis['object'];
- }
-
- /**
- * Get the pull request API
- *
- * @return Github_Api_PullRequest the pull request API
- */
- public function getPullRequestApi()
- {
- if (!isset($this->apis['pullrequest'])) {
- $this->apis['pullrequest'] = new Github_Api_PullRequest($this);
- }
-
- return $this->apis['pullrequest'];
- }
-
- /**
- * Inject an API instance
- *
- * @param string $name the API name
- * @param Github_ApiInterface $api the API instance
- *
- * @return null
- */
- public function setApi($name, Github_ApiInterface $instance)
- {
- $this->apis[$name] = $instance;
-
- return $this;
- }
-
- /**
- * Get any API
- *
- * @param string $name the API name
- * @return Github_ApiInterface the API instance
- */
- public function getApi($name)
- {
- return $this->apis[$name];
- }
-}
View
162 OpenVBX/libraries/Github/HttpClient.php
@@ -1,162 +0,0 @@
-<?php
-
-/**
- * Performs requests on GitHub API. API documentation should be self-explanatory.
- *
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-abstract class Github_HttpClient implements Github_HttpClientInterface
-{
- /**
- * The http client options
- * @var array
- */
- protected $options = array(
- 'protocol' => 'http',
- 'url' => ':protocol://github.com/api/v2/:format/:path',
- 'format' => 'json',
- 'user_agent' => 'php-github-api (http://github.com/ornicar/php-github-api)',
- 'http_port' => 80,
- 'timeout' => 10,
- 'login' => null,
- 'token' => null
- );
-
- protected static $history = array();
-
- /**
- * Instanciate a new http client
- *
- * @param array $options http client options
- */
- public function __construct(array $options = array())
- {
- $this->options = array_merge($this->options, $options);
- }
-
- /**
- * Send a request to the server, receive a response
- *
- * @param string $url Request url
- * @param array $parameters Parameters
- * @param string $httpMethod HTTP method to use
- * @param array $options Request options
- *
- * @return string HTTP response
- */
- abstract protected function doRequest($url, array $parameters = array(), $httpMethod = 'GET', array $options = array());
-
- /**
- * Send a GET request
- *
- * @param string $path Request path
- * @param array $parameters GET Parameters
- * @param string $httpMethod HTTP method to use
- * @param array $options Request options
- *
- * @return array Data
- */
- public function get($path, array $parameters = array(), array $options = array())
- {
- return $this->request($path, $parameters, 'GET', $options);
- }
-
- /**
- * Send a POST request
- *
- * @param string $path Request path
- * @param array $parameters POST Parameters
- * @param string $httpMethod HTTP method to use
- * @param array $options reconfigure the request for this call only
- *
- * @return array Data
- */
- public function post($path, array $parameters = array(), array $options = array())
- {
- return $this->request($path, $parameters, 'POST', $options);
- }
-
- /**
- * Send a request to the server, receive a response,
- * decode the response and returns an associative array
- *
- * @param string $path Request API path
- * @param array $parameters Parameters
- * @param string $httpMethod HTTP method to use
- * @param array $options Request options
- *
- * @return array Data
- */
- public function request($path, array $parameters = array(), $httpMethod = 'GET', array $options = array())
- {
- $this->updateHistory();
-
- $options = array_merge($this->options, $options);
-
- // create full url
- $url = strtr($options['url'], array(
- ':protocol' => $options['protocol'],
- ':format' => $options['format'],
- ':path' => trim($path, '/')
- ));
-
- // get encoded response
- $response = $this->doRequest($url, $parameters, $httpMethod, $options);
-
- // decode response
- $response = $this->decodeResponse($response, $options);
-
- return $response;
- }
-
- /**
- * Get a JSON response and transform it to a PHP array
- *
- * @return array the response
- */
- protected function decodeResponse($response, array $options)
- {
- if ('text' === $options['format']) {
- return $response;
- } elseif ('json' === $options['format']) {
- return json_decode($response, true);
- }
-
- throw new Exception(__CLASS__.' only supports json & text format, '.$options['format'].' given.');
- }
-
- /**
- * Change an option value.
- *
- * @param string $name The option name
- * @param mixed $value The value
- *
- * @return Github_HttpClientInterface The current object instance
- */
- public function setOption($name, $value)
- {
- $this->options[$name] = $value;
-
- return $this;
- }
-
- /**
- * Records the requests times
- * When 30 request have been sent in less than a minute,
- * sleeps for two second to prevent reaching GitHub API limitation.
- *
- * @access protected
- * @return void
- */
- protected function updateHistory()
- {
- self::$history[] = time();
- if (30 === count(self::$history)) {
- if (reset(self::$history) >= (time() - 35)) {
- sleep(2);
- }
- array_shift(self::$history);
- }
- }
-}
View
97 OpenVBX/libraries/Github/HttpClient/Curl.php
@@ -1,97 +0,0 @@
-<?php
-
-/**
- * Performs requests on GitHub API. API documentation should be self-explanatory.
- *
- * @author Thibault Duplessis <thibault.duplessis at gmail dot com>
- * @license MIT License
- */
-class Github_HttpClient_Curl extends Github_HttpClient
-{
- /**
- * Send a request to the server, receive a response
- *
- * @param string $path Request url
- * @param array $parameters Parameters
- * @param string $httpMethod HTTP method to use
- * @param array $options Request options
- *
- * @return string HTTP response
- */
- public function doRequest($url, array $parameters = array(), $httpMethod = 'GET', array $options = array())
- {
- $curlOptions = array();
-
- if ($options['login']) {
- switch ($options['auth_method']) {
- case Github_Client::AUTH_HTTP_PASSWORD:
- $curlOptions += array(
- CURLOPT_USERPWD => $options['login'].':'.$options['secret'],
- );
- break;
- case Github_Client::AUTH_HTTP_TOKEN:
- $curlOptions += array(
- CURLOPT_USERPWD => $options['login'].'/token:'.$options['secret'],
- );
- break;
- case Github_Client::AUTH_URL_TOKEN:
- default:
- $parameters = array_merge(array(
- 'login' => $options['login'],
- 'token' => $options['secret']
- ), $parameters);
- break;
- }
- }
-
- if (!empty($parameters)) {
- $queryString = utf8_encode(http_build_query($parameters, '', '&'));
-
- if ('GET' === $httpMethod) {
- $url .= '?'.$queryString;
- } else {
- $curlOptions += array(
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $queryString
- );