aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-11 20:08:54 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-11 20:08:54 -0400
commit913d07a4a7d9494e0617baa048be4a5857792e44 (patch)
treea8c31969e0fa7807f1e6b40e7c8a30985f99a6b3
parentb40d8070f35695008d122a685f1dfc9cc32adfbe (diff)
parent1fb21b781f47a4e0f8931bd703b589398ecf18e6 (diff)
downloadvolse-hubzilla-913d07a4a7d9494e0617baa048be4a5857792e44.tar.gz
volse-hubzilla-913d07a4a7d9494e0617baa048be4a5857792e44.tar.bz2
volse-hubzilla-913d07a4a7d9494e0617baa048be4a5857792e44.zip
Merge remote-tracking branch 'upstream/dev' into chat-notify
-rw-r--r--Zotlabs/Module/Admin.php151
-rwxr-xr-xview/tpl/acl_selector.tpl40
-rwxr-xr-xview/tpl/admin_plugins.tpl6
3 files changed, 111 insertions, 86 deletions
diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php
index 94482b39d..e77cf0fc7 100644
--- a/Zotlabs/Module/Admin.php
+++ b/Zotlabs/Module/Admin.php
@@ -1726,131 +1726,157 @@ class Admin extends \Zotlabs\Web\Controller {
}
function admin_page_plugins_post($action) {
- switch($action) {
+ switch ($action) {
case 'updaterepo':
- if(array_key_exists('repoName', $_REQUEST)) {
+ if (array_key_exists('repoName', $_REQUEST)) {
$repoName = $_REQUEST['repoName'];
} else {
json_return_and_die(array('message' => 'No repo name provided.', 'success' => false));
}
- $repoDir = __DIR__ . '/../../store/git/sys/extend/addon/'.$repoName;
- if(!is_dir($repoDir)) {
+ $repoDir = __DIR__ . '/../../store/git/sys/extend/addon/' . $repoName;
+ if (!is_dir($repoDir)) {
+ logger('Repo directory does not exist: ' . $repoDir);
json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false));
- }
+ }
+ if (!is_writable($repoDir)) {
+ logger('Repo directory not writable to web server: ' . $repoDir);
+ json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false));
+ }
$git = new GitRepo('sys', null, false, $repoName, $repoDir);
try {
- if($git->pull()) {
+ if ($git->pull()) {
json_return_and_die(array('message' => 'Repo updated.', 'success' => true));
} else {
json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));
}
- } catch(\PHPGit\Exception\GitException $e) {
+ } catch (\PHPGit\Exception\GitException $e) {
json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));
}
case 'removerepo':
- if(array_key_exists('repoName', $_REQUEST)) {
+ if (array_key_exists('repoName', $_REQUEST)) {
$repoName = $_REQUEST['repoName'];
} else {
json_return_and_die(array('message' => 'No repo name provided.', 'success' => false));
}
- $repoDir = __DIR__ . '/../../store/git/sys/extend/addon/'.$repoName;
- if(!is_dir($repoDir)) {
+ $repoDir = __DIR__ . '/../../store/git/sys/extend/addon/' . $repoName;
+ if (!is_dir($repoDir)) {
+ logger('Repo directory does not exist: ' . $repoDir);
json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false));
}
+ if (!is_writable($repoDir)) {
+ logger('Repo directory not writable to web server: ' . $repoDir);
+ json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false));
+ }
// TODO: remove directory and unlink /addon/files
- if(rrmdir($repoDir)) {
+ if (rrmdir($repoDir)) {
json_return_and_die(array('message' => 'Repo deleted.', 'success' => true));
} else {
json_return_and_die(array('message' => 'Error deleting addon repo.', 'success' => false));
}
- case 'installrepo':
+ case 'installrepo':
require_once('library/markdown.php');
- if(array_key_exists('repoURL',$_REQUEST)) {
- require __DIR__ . '/../../library/PHPGit.autoload.php'; // Load PHPGit dependencies
+ if (array_key_exists('repoURL', $_REQUEST)) {
+ require __DIR__ . '/../../library/PHPGit.autoload.php'; // Load PHPGit dependencies
$repoURL = $_REQUEST['repoURL'];
$extendDir = __DIR__ . '/../../store/git/sys/extend';
- $addonDir = $extendDir.'/addon';
- if(!file_exists($extendDir)) {
- if(!mkdir($extendDir, 0770, true)) {
+ $addonDir = $extendDir . '/addon';
+ if (!file_exists($extendDir)) {
+ if (!mkdir($extendDir, 0770, true)) {
logger('Error creating extend folder: ' . $extendDir);
json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false));
} else {
- if(!symlink(__DIR__ . '/../../extend/addon', $addonDir)) {
+ if (!symlink(__DIR__ . '/../../extend/addon', $addonDir)) {
logger('Error creating symlink to addon folder: ' . $addonDir);
json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false));
}
}
}
+ if (!is_writable($extendDir)) {
+ logger('Directory not writable to web server: ' . $extendDir);
+ json_return_and_die(array('message' => 'Directory not writable to web server.', 'success' => false));
+ }
$repoName = null;
- if(array_key_exists('repoName',$_REQUEST) && $_REQUEST['repoName'] !== '') {
- $repoName = $_REQUEST['repoName'];
+ if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') {
+ $repoName = $_REQUEST['repoName'];
} else {
$repoName = GitRepo::getRepoNameFromURL($repoURL);
- }
- if(!$repoName) {
+ }
+ if (!$repoName) {
logger('Invalid git repo');
json_return_and_die(array('message' => 'Invalid git repo', 'success' => false));
}
- $repoDir = $addonDir.'/'.$repoName;
- $tempAddonDir = __DIR__ . '/../../store/git/sys/temp/' . $repoName;
+ $repoDir = $addonDir . '/' . $repoName;
+ $tempRepoBaseDir = __DIR__ . '/../../store/git/sys/temp/';
+ $tempAddonDir = $tempRepoBaseDir . $repoName;
+
+ if (!is_writable($addonDir) || !is_writable($tempAddonDir)) {
+ logger('Temp repo directory or /extend/addon not writable to web server: ' . $tempAddonDir);
+ json_return_and_die(array('message' => 'Temp repo directory not writable to web server.', 'success' => false));
+ }
rename($tempAddonDir, $repoDir);
-
+
+ if (!is_writable(realpath(__DIR__ . '/../../addon/'))) {
+ logger('/addon directory not writable to web server: ' . $tempAddonDir);
+ json_return_and_die(array('message' => '/addon directory not writable to web server.', 'success' => false));
+ }
$files = array_diff(scandir($repoDir), array('.', '..'));
- logger('files: ' . json_encode($files));
- foreach ($files as $file)
- {
- if(is_dir($repoDir.'/'.$file) && $file !== '.git') {
- $source = '../extend/addon/'.$repoName.'/'.$file;
- $target = realpath(__DIR__ . '/../../addon/').'/'.$file;
- unlink($target);
- if(!symlink($source, $target)) {
- logger('Error linking addons to /addon');
- json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false));
- }
+ foreach ($files as $file) {
+ if (is_dir($repoDir . '/' . $file) && $file !== '.git') {
+ $source = '../extend/addon/' . $repoName . '/' . $file;
+ $target = realpath(__DIR__ . '/../../addon/') . '/' . $file;
+ unlink($target);
+ if (!symlink($source, $target)) {
+ logger('Error linking addons to /addon');
+ json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false));
}
+ }
}
- $git = new GitRepo('sys', $repoURL, false, $repoName, $repoDir);
+ $git = new GitRepo('sys', $repoURL, false, $repoName, $repoDir);
$repo = $git->probeRepo();
- json_return_and_die(array('repo'=> $repo, 'message' => '', 'success' => true));
+ json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true));
}
- case 'addrepo':
+ case 'addrepo':
require_once('library/markdown.php');
- if(array_key_exists('repoURL',$_REQUEST)) {
- require __DIR__ . '/../../library/PHPGit.autoload.php'; // Load PHPGit dependencies
+ if (array_key_exists('repoURL', $_REQUEST)) {
+ require __DIR__ . '/../../library/PHPGit.autoload.php'; // Load PHPGit dependencies
$repoURL = $_REQUEST['repoURL'];
$extendDir = __DIR__ . '/../../store/git/sys/extend';
- $addonDir = $extendDir.'/addon';
+ $addonDir = $extendDir . '/addon';
$tempAddonDir = __DIR__ . '/../../store/git/sys/temp';
- if(!file_exists($extendDir)) {
- if(!mkdir($extendDir, 0770, true)) {
+ if (!file_exists($extendDir)) {
+ if (!mkdir($extendDir, 0770, true)) {
logger('Error creating extend folder: ' . $extendDir);
json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false));
} else {
- if(!symlink(__DIR__ . '/../../extend/addon', $addonDir)) {
+ if (!symlink(__DIR__ . '/../../extend/addon', $addonDir)) {
logger('Error creating symlink to addon folder: ' . $addonDir);
json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false));
}
}
}
$repoName = null;
- if(array_key_exists('repoName',$_REQUEST) && $_REQUEST['repoName'] !== '') {
- $repoName = $_REQUEST['repoName'];
+ if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') {
+ $repoName = $_REQUEST['repoName'];
} else {
$repoName = GitRepo::getRepoNameFromURL($repoURL);
- }
- if(!$repoName) {
+ }
+ if (!$repoName) {
logger('Invalid git repo');
json_return_and_die(array('message' => 'Invalid git repo: ' . $repoName, 'success' => false));
}
- $repoDir = $tempAddonDir.'/'.$repoName;
+ $repoDir = $tempAddonDir . '/' . $repoName;
+ if (!is_writable($tempAddonDir)) {
+ logger('Temporary directory for new addon repo is not writable to web server: ' . $tempAddonDir);
+ json_return_and_die(array('message' => 'Temporary directory for new addon repo is not writable to web server.', 'success' => false));
+ }
// clone the repo if new automatically
- $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
-
+ $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
+
$remotes = $git->git->remote();
$fetchURL = $remotes['origin']['fetch'];
- if($fetchURL !== $git->url) {
- if(rrmdir($repoDir)) {
- $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
+ if ($fetchURL !== $git->url) {
+ if (rrmdir($repoDir)) {
+ $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir);
} else {
json_return_and_die(array('message' => 'Error deleting existing addon repo.', 'success' => false));
}
@@ -1858,14 +1884,13 @@ class Admin extends \Zotlabs\Web\Controller {
$repo = $git->probeRepo();
$repo['readme'] = $repo['manifest'] = null;
foreach ($git->git->tree('master') as $object) {
- if ($object['type'] == 'blob' && (strtolower($object['file']) === 'readme.md' || strtolower($object['file']) === 'readme')) {
- $repo['readme'] = Markdown($git->git->cat->blob($object['hash']));
- } else if ($object['type'] == 'blob' && strtolower($object['file']) === 'manifest.json') {
- $repo['manifest'] = $git->git->cat->blob($object['hash']);
- }
+ if ($object['type'] == 'blob' && (strtolower($object['file']) === 'readme.md' || strtolower($object['file']) === 'readme')) {
+ $repo['readme'] = Markdown($git->git->cat->blob($object['hash']));
+ } else if ($object['type'] == 'blob' && strtolower($object['file']) === 'manifest.json') {
+ $repo['manifest'] = $git->git->cat->blob($object['hash']);
+ }
}
- json_return_and_die(array('repo'=> $repo, 'message' => '', 'success' => true));
-
+ json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true));
} else {
json_return_and_die(array('message' => 'No repo URL provided', 'success' => false));
}
@@ -1874,7 +1899,7 @@ class Admin extends \Zotlabs\Web\Controller {
break;
}
}
-
+
function admin_page_profs_post(&$a) {
if(array_key_exists('basic',$_REQUEST)) {
diff --git a/view/tpl/acl_selector.tpl b/view/tpl/acl_selector.tpl
index 050417257..0e9562157 100755
--- a/view/tpl/acl_selector.tpl
+++ b/view/tpl/acl_selector.tpl
@@ -10,7 +10,7 @@
</div>
<div class="section-content-wrapper">
{{if $aclModalDesc}}
- <div id="acl-dialog-description" class="section-content-info-wrapper">{{$aclModalDesc}}</div>
+ <div id="acl-dialog-description" class="section-content-info-wrapper">{{$aclModalDesc}}</div>
{{/if}}
{{if $jotnets}}
<div class="jotnets-wrapper" role="tab" id="jotnets-wrapper">
@@ -23,34 +23,34 @@
{{/if}}
<div id="acl-wrapper">
<div id="acl-radiowrapper-showall" class="radio">
- <label>
- <input id="acl-showall" type="radio" name="optionsRadios" value="option1" checked>
- {{if $showallIcon}}<i class="fa {{$showallIcon}}"></i>{{/if}}
- <span id="acl-showall-caption">{{$showall}}</span>
- </label>
- {{if $showallOrigin}}
- &nbsp;<a id="acl-info-icon" role="button" tabindex="0" class="fa fa-info-circle" data-trigger="focus" data-toggle="popover" data-placement="top" data-content="{{$showallOrigin}}"></a>
- {{/if}}
+ <label>
+ <input id="acl-showall" type="radio" name="optionsRadios" value="option1" checked>
+ {{if $showallIcon}}
+ <i class="fa {{$showallIcon}}"></i>
+ {{/if}}
+ <span id="acl-showall-caption">{{$showall}}</span>
+ </label>
+ {{if $showallOrigin}}
+ &nbsp;<a id="acl-info-icon" role="button" tabindex="0" class="fa fa-info-circle" data-trigger="focus" data-toggle="popover" data-placement="top" data-content="{{$showallOrigin}}"></a>
+ {{/if}}
</div>
<div id="acl-radiowrapper-showlimited" class="radio">
<label>
<input id="acl-showlimited" type="radio" name="optionsRadios" style="readonly" value="option2">
<span id=acl-showlimited-caption>{{$showlimited}}</span>
- </label>
- <div id="acl-list">
- <div id="acl-search-wrapper">
- <input type="text" id="acl-search" placeholder="&#xf002; {{$search}}">
- </div>
- <div id="acl-list-content-wrapper">
- <div id=acl-showlimited-description>{{$showlimitedDesc}}</div>
- <div id="acl-list-content"></div>
- </div>
+ </label>
+ </div>
+ <div id="acl-list">
+ <div id="acl-search-wrapper">
+ <input type="text" id="acl-search" placeholder="&#xf002; {{$search}}">
+ </div>
+ <div id="acl-list-content-wrapper">
+ <div id=acl-showlimited-description>{{$showlimitedDesc}}</div>
+ <div id="acl-list-content"></div>
</div>
</div>
-
<span id="acl-fields"></span>
</div>
-
<div class="acl-list-item" rel="acl-template" style="display:none">
<img data-src="{0}"><p>{1}</p>
<button class="acl-button-hide btn btn-xs btn-default"><i class="fa fa-times"></i> {{$hide}}</button>
diff --git a/view/tpl/admin_plugins.tpl b/view/tpl/admin_plugins.tpl
index 186cb052d..f21a3057e 100755
--- a/view/tpl/admin_plugins.tpl
+++ b/view/tpl/admin_plugins.tpl
@@ -15,7 +15,7 @@
</div>
<div class="clear"></div>
<div class="section-content-info-wrapper">
- <h3>Installed Addon Repositories</h3>
+ <h3>Installed Plugin Repositories</h3>
{{foreach $addonrepos as $repo}}
<!-- <div class="section-content-tools-wrapper"> -->
<div style="margin-left: 30%; margin-right: 30%;">
@@ -123,7 +123,7 @@
"/admin/plugins/updaterepo", {repoName: repoName},
function(response) {
if (response.success) {
- window.console.log('Addon repo'+repoName+'successfully updated :' + response['message']);
+ window.console.log('Addon repo '+repoName+' successfully updated :' + response['message']);
alert('Addon repo updated.');
} else {
window.console.log('Error updating repo :' + response['message']);
@@ -146,7 +146,7 @@
"/admin/plugins/removerepo", {repoName: repoName},
function(response) {
if (response.success) {
- window.console.log('Addon repo'+repoName+'successfully removed :' + response['message']);
+ window.console.log('Addon repo '+repoName+' successfully removed :' + response['message']);
if(confirm('Repo deleted. Click OK to refresh page.')) {
location.reload();
}