mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-03 23:24:07 +01:00
* [MOD] Code refactoring
This commit is contained in:
@@ -30,8 +30,8 @@ use SP\Core\ActionsInterface;
|
||||
use SP\Core\Session;
|
||||
use SP\DataModel\UserData;
|
||||
use SP\Mgmt\Groups\GroupUsers;
|
||||
use SP\Util\ArrayUtil;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
|
||||
/**
|
||||
* Class AccountAcl
|
||||
@@ -450,7 +450,7 @@ class AccountAcl
|
||||
// o... permitir los grupos que no sean el principal del usuario?
|
||||
|| (Config::getConfig()->isAccountFullGroupAccess()
|
||||
// Comprobar si el usuario está vinculado desde los grupos secundarios de la cuenta
|
||||
&& Util::checkInObjectArray($groupsId, 'groupId', $groupId))
|
||||
&& ArrayUtil::checkInObjectArray($groupsId, 'groupId', $groupId))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ class ArrayUtil
|
||||
/**
|
||||
* Buscar un objeto en un array según el valor de una propiedad
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $array
|
||||
* @param string $property Nombre de la propiedad
|
||||
* @param string $value Valor de la propiedad
|
||||
* @param object $default Valor por defecto
|
||||
* @param string $value Valor de la propiedad
|
||||
* @param object $default Valor por defecto
|
||||
* @return false|object
|
||||
*/
|
||||
public static function searchInObject(array $array, $property, $value, $default = null)
|
||||
@@ -53,4 +53,45 @@ class ArrayUtil
|
||||
|
||||
return null !== $default ? $default : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si un valor existe en un array de objetos
|
||||
*
|
||||
* @param array $objectArray
|
||||
* @param string $method
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkInObjectArrayMethod(array $objectArray, $method, $value)
|
||||
{
|
||||
foreach ($objectArray as $object) {
|
||||
if (is_callable([$object, $method]) && $object->$method() === $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si un valor existe en un array de objetos
|
||||
*
|
||||
* @param array $objectArray
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkInObjectArray(array $objectArray, $property, $value)
|
||||
{
|
||||
foreach ($objectArray as $object) {
|
||||
if (is_object($object)
|
||||
&& isset($object->$property)
|
||||
&& $object->$property == $value
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@
|
||||
namespace SP\Util;
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Http\Request;
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,7 +74,7 @@ class Connection implements ConnectionInterface
|
||||
* Obtener un socket
|
||||
*
|
||||
* @param $type int EL tipo de socket TCP/UDP
|
||||
* @return mixed
|
||||
* @return resource
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function getSocket($type)
|
||||
@@ -96,6 +96,8 @@ class Connection implements ConnectionInterface
|
||||
}
|
||||
|
||||
stream_set_timeout($this->socket, self::SOCKET_TIMEOUT);
|
||||
|
||||
return $this->socket;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ interface ConnectionInterface
|
||||
* Obtener un socket
|
||||
*
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @return resource
|
||||
*/
|
||||
public function getSocket($type);
|
||||
|
||||
|
||||
@@ -619,44 +619,6 @@ class Util
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si un valor existe en un array de objetos
|
||||
*
|
||||
* @param array $objectArray
|
||||
* @param string $method
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkInObjectArrayMethod(array $objectArray, $method, $value)
|
||||
{
|
||||
foreach ($objectArray as $object) {
|
||||
if (is_callable([$object, $method]) && $object->$method() === $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si un valor existe en un array de objetos
|
||||
*
|
||||
* @param array $objectArray
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkInObjectArray(array $objectArray, $property, $value)
|
||||
{
|
||||
foreach ($objectArray as $object) {
|
||||
if (isset($object->$property) && $object->$property == $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bloquear la aplicación
|
||||
*
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
use SP\Util\ArrayUtil;
|
||||
|
||||
/** @var $icons \Theme\Icons */
|
||||
/** @var $group \SP\DataModel\GroupData */
|
||||
/** @var $groupUsers \SP\DataModel\GroupUsersData */
|
||||
@@ -50,7 +52,7 @@
|
||||
<option value=""><?php echo __('Seleccionar Usuarios'); ?></option>
|
||||
<?php /** @var array $users */
|
||||
foreach ($users as $user): ?>
|
||||
<?php $selected = \SP\Util\Util::checkInObjectArrayMethod($groupUsers, 'getUsertogroupUserId', $user->id) ? 'selected' : ''; ?>
|
||||
<?php $selected = ArrayUtil::checkInObjectArrayMethod($groupUsers, 'getUsertogroupUserId', $user->id) ? 'selected' : ''; ?>
|
||||
<option
|
||||
value="<?php echo $user->id; ?>" <?php echo $selected; ?>><?php echo $user->name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user