Explorar o código

Fix PHP error + Add option to update WPCLI + Composer (#4039)

* Fix php error

* Add an option to update if allready exists

* Add them as optional flags
Jaap Marcus %!s(int64=2) %!d(string=hai) anos
pai
achega
28212e1610
Modificáronse 3 ficheiros con 15 adicións e 3 borrados
  1. 6 1
      bin/v-add-user-composer
  2. 6 1
      bin/v-add-user-wp-cli
  3. 3 1
      web/templates/pages/list_web.php

+ 6 - 1
bin/v-add-user-composer

@@ -14,6 +14,7 @@
 # Argument definition
 user=$1
 version=${2-2}
+update=$3
 
 if [ -z "$HESTIA" ]; then
 	HESTIA="/usr/local/hestia"
@@ -31,7 +32,7 @@ source_conf "$HESTIA/conf/hestia.conf"
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '1' "$#" 'USER [VERSION]'
+check_args '1' "$#" 'USER [VERSION] [UPDATE]'
 is_format_valid 'user'
 is_number_format_valid "$version" "version"
 is_object_valid 'user' 'USER' "$user"
@@ -50,6 +51,10 @@ COMPOSER_DIR="$HOMEDIR/$user/.composer"
 COMPOSER_BIN="$COMPOSER_DIR/composer"
 
 if [ -f "$COMPOSER_BIN" ]; then
+	if [ -f "$update" ]; then
+		user_exec $COMPOSER_BIN selfupdate
+		exit
+	fi
 	echo "Composer already available"
 	exit
 fi

+ 6 - 1
bin/v-add-user-wp-cli

@@ -12,6 +12,7 @@
 
 # Argument definition
 user=$1
+update=$2
 
 if [ -z "$HESTIA" ]; then
 	HESTIA="/usr/local/hestia"
@@ -28,7 +29,7 @@ source_conf "$HESTIA/conf/hestia.conf"
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '1' "$#" 'USER'
+check_args '1' "$#" 'USER [UPDATE]'
 is_format_valid 'user'
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
@@ -44,6 +45,10 @@ WPCLI_DIR="/home/$user/.wp-cli"
 WPCLI_BIN="$WPCLI_DIR/wp"
 
 if [ -f "$WPCLI_BIN" ]; then
+	if [ -f "$update" ]; then
+		user_exec $WPCLI_BIN cli update --yes
+		exit
+	fi
 	check_result "$E_EXISTS" "For user name '$user' WP-CLI already available!"
 	exit
 fi

+ 3 - 1
web/templates/pages/list_web.php

@@ -44,7 +44,9 @@
 							<?php } ?>
 							<option value="suspend"><?= _("Suspend") ?></option>
 							<option value="unsuspend"><?= _("Unsuspend") ?></option>
-							<option value="purge"><?= _('Purge Nginx Cache');?></option>
+							<?php if (($_SESSION['PROXY_SYSTEM'] == 'nginx') || ($_SESSION['WEB_SYSTEM'] == 'nginx')){?>}
+								<option value="purge"><?= _('Purge Nginx Cache');?></option>
+							<? } ?>
 							<option value="delete"><?= _("Delete") ?></option>
 						</select>
 						<button type="submit" class="toolbar-input-submit" title="<?= _("Apply to selected") ?>">