diff --git a/inc/SP/Controller/AccountsMgmtC.class.php b/inc/SP/Controller/AccountsMgmtC.class.php index 4427196b..f8befa77 100644 --- a/inc/SP/Controller/AccountsMgmtC.class.php +++ b/inc/SP/Controller/AccountsMgmtC.class.php @@ -26,6 +26,11 @@ namespace SP\Controller; use SP\Core\ActionsInterface; +use SP\Html\DataGrid\DataGridAction; +use SP\Html\DataGrid\DataGridData; +use SP\Html\DataGrid\DataGridHeader; +use SP\Html\DataGrid\DataGridIcon; +use SP\Html\DataGrid\DataGridTab; use SP\Http\Request; use SP\Mgmt\Category; use SP\Mgmt\Customer; @@ -53,6 +58,19 @@ class AccountsMgmtC extends Controller implements ActionsInterface * @var int */ private $_module = 0; + /** + * @var DataGridIcon + */ + private $_iconAdd; + /** + * @var DataGridIcon + */ + private $_iconEdit; + /** + * @var DataGridIcon + */ + private $_iconDelete; + /** * Constructor @@ -64,7 +82,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface parent::__construct($template); $this->view->assign('isDemo', Checks::demoIsEnabled()); - $this->view->assign('sk', SessionUtil::getSessionKey()); + $this->view->assign('sk', SessionUtil::getSessionKey(true)); + + $this->setIcons(); } /** @@ -78,52 +98,57 @@ class AccountsMgmtC extends Controller implements ActionsInterface return; } - $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(self::ACTION_MGM_CATEGORIES_NEW); + $GridActionNew->setName(_('Nueva Categoría')); + $GridActionNew->setIcon($this->_iconAdd); + $GridActionNew->setSkip(true); + $GridActionNew->setIsNew(true); + $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionNew->setOnClickArgs('this'); + $GridActionNew->setOnClickArgs(self::ACTION_MGM_CATEGORIES_NEW); + $GridActionNew->setOnClickArgs($this->view->sk); - $categoriesTableProp = array( - 'tblId' => 'tblCategories', - 'header' => '', - 'tblHeaders' => array(_('Nombre'), _('Descripción')), - 'tblRowSrc' => array('category_name', 'category_description'), - 'tblRowSrcId' => 'category_id', - 'onCloseAction' => self::ACTION_MGM, - 'actions' => array( - 'new' => array( - 'id' => self::ACTION_MGM_CATEGORIES_NEW, - 'title' => _('Nueva Categoría'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_CATEGORIES_NEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/new.png', - 'icon' => 'add', - 'skip' => true - ), - 'edit' => array( - 'id' => self::ACTION_MGM_CATEGORIES_EDIT, - 'title' => _('Editar Categoría'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_CATEGORIES_EDIT . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/edit.png', - 'icon' => 'mode_edit' - ), - 'del' => array( - 'id' => self::ACTION_MGM_CATEGORIES_DELETE, - 'title' => _('Eliminar Categoría'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_MGM_CATEGORIES_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ) - ) - ); + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(self::ACTION_MGM_CATEGORIES_EDIT); + $GridActionEdit->setName(_('Editar Categoría')); + $GridActionEdit->setIcon($this->_iconEdit); + $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionEdit->setOnClickArgs('this'); + $GridActionEdit->setOnClickArgs(self::ACTION_MGM_CATEGORIES_EDIT); + $GridActionEdit->setOnClickArgs($this->view->sk); - $categoriesTableProp['cellWidth'] = floor(65 / count($categoriesTableProp['tblHeaders'])); + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_MGM_CATEGORIES_DELETE); + $GridActionDel->setName(_('Eliminar Categoría')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_MGM_CATEGORIES_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', - array( - 'title' => _('Gestión de Categorías'), - 'query' => Category::getCategories(), - 'props' => $categoriesTableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5)) - ); + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Nombre')); + $GridHeaders->addHeader(_('Descripción')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('category_id'); + $GridData->addDataRowSource('category_name'); + $GridData->addDataRowSource('category_description'); + $GridData->setData(Category::getCategories()); + + $Grid = new DataGridTab(); + $Grid->setId('tblCategories'); + $Grid->setDataActions($GridActionNew); + $Grid->setDataActions($GridActionEdit); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Gestión de Categorías')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** @@ -137,50 +162,57 @@ class AccountsMgmtC extends Controller implements ActionsInterface return; } - $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(self::ACTION_MGM_CUSTOMERS_NEW); + $GridActionNew->setName(_('Nuevo Cliente')); + $GridActionNew->setIcon($this->_iconAdd); + $GridActionNew->setSkip(true); + $GridActionNew->setIsNew(true); + $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionNew->setOnClickArgs('this'); + $GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_NEW); + $GridActionNew->setOnClickArgs($this->view->sk); - $customersTableProp = array( - 'tblId' => 'tblCustomers', - 'header' => '', - 'tblHeaders' => array(_('Nombre'), _('Descripción')), - 'tblRowSrc' => array('customer_name', 'customer_description'), - 'tblRowSrcId' => 'customer_id', - 'onCloseAction' => self::ACTION_MGM, - 'actions' => array( - 'new' => array( - 'id' => self::ACTION_MGM_CUSTOMERS_NEW, - 'title' => _('Nuevo Cliente'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_CUSTOMERS_NEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/new.png', - 'skip' => true - ), - 'edit' => array( - 'id' => self::ACTION_MGM_CUSTOMERS_EDIT, - 'title' => _('Editar Cliente'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_CUSTOMERS_EDIT . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/edit.png', - 'icon' => 'mode_edit' - ), - 'del' => array( - 'id' => self::ACTION_MGM_CUSTOMERS_DELETE, - 'title' => _('Eliminar Cliente'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_MGM_CUSTOMERS_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ) - ) - ); + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(self::ACTION_MGM_CUSTOMERS_EDIT); + $GridActionEdit->setName(_('Editar Cliente')); + $GridActionEdit->setIcon($this->_iconEdit); + $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionEdit->setOnClickArgs('this'); + $GridActionEdit->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_EDIT); + $GridActionEdit->setOnClickArgs($this->view->sk); - $customersTableProp['cellWidth'] = floor(65 / count($customersTableProp['tblHeaders'])); + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_MGM_CUSTOMERS_DELETE); + $GridActionDel->setName(_('Eliminar Cliente')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', array( - 'title' => _('Gestión de Clientes'), - 'query' => Customer::getCustomers(), - 'props' => $customersTableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5)) - ); + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Nombre')); + $GridHeaders->addHeader(_('Descripción')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('customer_id'); + $GridData->addDataRowSource('customer_name'); + $GridData->addDataRowSource('customer_description'); + $GridData->setData(Customer::getCustomers()); + + $Grid = new DataGridTab(); + $Grid->setId('tblCustomers'); + $Grid->setDataActions($GridActionNew); + $Grid->setDataActions($GridActionEdit); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Gestión de Clientes')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** @@ -188,9 +220,7 @@ class AccountsMgmtC extends Controller implements ActionsInterface */ public function useTabs() { - $this->view->addTemplate('tabs-start'); - $this->view->addTemplate('mgmttabs'); - $this->view->addTemplate('tabs-end'); + $this->view->addTemplate('datatabs-grid'); $this->view->assign('tabs', array()); $this->view->assign('activeTab', 0); @@ -265,50 +295,59 @@ class AccountsMgmtC extends Controller implements ActionsInterface return; } - $this->view->assign('sk', SessionUtil::getSessionKey(true)); + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(self::ACTION_MGM_CUSTOMFIELDS_NEW); + $GridActionNew->setName(_('Nuevo Campo')); + $GridActionNew->setIcon($this->_iconAdd); + $GridActionNew->setSkip(true); + $GridActionNew->setIsNew(true); + $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionNew->setOnClickArgs('this'); + $GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_NEW); + $GridActionNew->setOnClickArgs($this->view->sk); - $tableProp = array( - 'tblId' => 'tblCustomFields', - 'header' => '', - 'tblHeaders' => array(_('Módulo'), _('Nombre'), _('Tipo')), - 'tblRowSrc' => array('module', 'name', 'typeName'), - 'tblRowSrcId' => 'id', - 'onCloseAction' => self::ACTION_MGM, - 'actions' => array( - 'new' => array( - 'id' => self::ACTION_MGM_CUSTOMFIELDS_NEW, - 'title' => _('Nuevo Campo'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_CUSTOMFIELDS_NEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/new.png', - 'skip' => true - ), - 'edit' => array( - 'id' => self::ACTION_MGM_CUSTOMFIELDS_EDIT, - 'title' => _('Editar Campo'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_CUSTOMFIELDS_EDIT . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/edit.png', - 'icon' => 'mode_edit' - ), - 'del' => array( - 'id' => self::ACTION_MGM_CUSTOMFIELDS_DELETE, - 'title' => _('Eliminar Campo'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_MGM_CUSTOMFIELDS_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ) - ) - ); + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(self::ACTION_MGM_CUSTOMFIELDS_EDIT); + $GridActionEdit->setName(_('Editar Campo')); + $GridActionEdit->setIcon($this->_iconEdit); + $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionEdit->setOnClickArgs('this'); + $GridActionEdit->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_EDIT); + $GridActionEdit->setOnClickArgs($this->view->sk); - $tableProp['cellWidth'] = floor(65 / count($tableProp['tblHeaders'])); + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_MGM_CUSTOMFIELDS_DELETE); + $GridActionDel->setName(_('Eliminar Campo')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', array( - 'title' => _('Campos Personalizados'), - 'query' => CustomFieldDef::getCustomFields(), - 'props' => $tableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5)) - ); + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Módulo')); + $GridHeaders->addHeader(_('Nombre')); + $GridHeaders->addHeader(_('Tipo')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('id'); + $GridData->addDataRowSource('module'); + $GridData->addDataRowSource('name'); + $GridData->addDataRowSource('typeName'); + $GridData->setData(CustomFieldDef::getCustomFields()); + + $Grid = new DataGridTab(); + $Grid->setId('tblCustomFields'); + $Grid->setDataActions($GridActionNew); + $Grid->setDataActions($GridActionEdit); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Campos Personalizados')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** @@ -319,9 +358,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface $this->view->addTemplate('customfields'); $customField = CustomFieldDef::getCustomFields($this->view->itemId, true); - $field = unserialize($customField->customfielddef_field); + $field = (is_object($customField)) ? unserialize($customField->customfielddef_field) : null; - if (get_class($field) === '__PHP_Incomplete_Class') { + if (is_object($field) && get_class($field) === '__PHP_Incomplete_Class') { $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field); } @@ -331,4 +370,14 @@ class AccountsMgmtC extends Controller implements ActionsInterface $this->view->assign('types', CustomFieldDef::getFieldsTypes()); $this->view->assign('modules', CustomFieldDef::getFieldsModules()); } + + /** + * Establecer los iconos utilizados en el DataGrid + */ + private function setIcons() + { + $this->_iconAdd = new DataGridIcon('add', 'imgs/new.png', 'fg-blue80'); + $this->_iconEdit = new DataGridIcon('mode_edit', 'imgs/edit.png', 'fg-orange80'); + $this->_iconDelete = new DataGridIcon('delete', 'imgs/delete.png', 'fg-red80'); + } } diff --git a/inc/SP/Controller/UsersMgmtC.class.php b/inc/SP/Controller/UsersMgmtC.class.php index 3bebfa48..6c18408c 100644 --- a/inc/SP/Controller/UsersMgmtC.class.php +++ b/inc/SP/Controller/UsersMgmtC.class.php @@ -27,9 +27,13 @@ namespace SP\Controller; use SP\Api\ApiTokens; use SP\Core\ActionsInterface; +use SP\Html\DataGrid\DataGridAction; +use SP\Html\DataGrid\DataGridData; +use SP\Html\DataGrid\DataGridHeader; +use SP\Html\DataGrid\DataGridIcon; +use SP\Html\DataGrid\DataGridTab; use SP\Mgmt\PublicLinkUtil; use SP\Mgmt\CustomFields; -use SP\Storage\DB; use SP\Mgmt\User\Groups; use SP\Log\Log; use SP\Mgmt\User\Profile; @@ -39,7 +43,6 @@ use SP\Core\Template; use SP\Mgmt\User\UserUtil; use SP\Storage\DBUtil; use SP\Util\Checks; -use SP\Util\Util; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); @@ -58,6 +61,22 @@ class UsersMgmtC extends Controller implements ActionsInterface * @var int */ private $_module = 0; + /** + * @var DataGridIcon + */ + private $_iconAdd; + /** + * @var DataGridIcon + */ + private $_iconView; + /** + * @var DataGridIcon + */ + private $_iconEdit; + /** + * @var DataGridIcon + */ + private $_iconDelete; /** * Constructor @@ -69,7 +88,20 @@ class UsersMgmtC extends Controller implements ActionsInterface parent::__construct($template); $this->view->assign('isDemo', Checks::demoIsEnabled()); - $this->view->assign('sk', SessionUtil::getSessionKey()); + $this->view->assign('sk', SessionUtil::getSessionKey(true)); + + $this->setIcons(); + } + + /** + * Establecer los iconos utilizados en el DataGrid + */ + private function setIcons() + { + $this->_iconAdd = new DataGridIcon('add', 'imgs/new.png', 'fg-blue80'); + $this->_iconView = new DataGridIcon('visibility', 'imgs/view.png', 'fg-blue80'); + $this->_iconEdit = new DataGridIcon('mode_edit', 'imgs/edit.png', 'fg-orange80'); + $this->_iconDelete = new DataGridIcon('delete', 'imgs/delete.png', 'fg-red80'); } /** @@ -79,98 +111,91 @@ class UsersMgmtC extends Controller implements ActionsInterface { $this->setAction(self::ACTION_USR_USERS); - $this->view->assign('sk', SessionUtil::getSessionKey(true)); - if (!$this->checkAccess()) { return; } - $arrUsersTableProp = array( - 'tblId' => 'tblUsers', - 'header' => '', - 'tblHeaders' => array( - _('Nombre'), - _('Login'), - _('Perfil'), - _('Grupo'), - _('Propiedades')), - 'tblRowSrc' => array( - 'user_name', - 'user_login', - 'userprofile_name', - 'usergroup_name', - 'images' => array( - 'user_isAdminApp' => array( - 'img_file' => 'check_blue.png', - 'img_title' => _('Admin Aplicación'), - 'icon' => 'star'), - 'user_isAdminAcc' => array( - 'img_file' => 'check_orange.png', - 'img_title' => _('Admin Cuentas'), - 'icon' => 'star_half'), - 'user_isLdap' => array( - 'img_file' => 'ldap.png', - 'img_title' => _('Usuario de LDAP'), - 'icon' => 'business'), - 'user_isDisabled' => array( - 'img_file' => 'disabled.png', - 'img_title' => _('Deshabilitado'), - 'icon' => 'error') - ) - ), - 'tblRowSrcId' => 'user_id', - 'onCloseAction' => self::ACTION_USR, - 'actions' => array( - 'new' => array( - 'id' => self::ACTION_USR_USERS_NEW, - 'title' => _('Nuevo Usuario'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_USERS_NEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/new.png', - 'icon' => 'add', - 'skip' => true - ), - 'view' => array( - 'id' => self::ACTION_USR_USERS_VIEW, - 'title' => _('Ver Detalles de Usuario'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_USERS_VIEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/view.png', - 'icon' => 'visibility' - ), - 'edit' => array( - 'id' => self::ACTION_USR_USERS_EDIT, - 'title' => _('Editar Usuario'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_USERS_EDIT . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/edit.png', - 'icon' => 'mode_edit' - ), - 'pass' => array( - 'id' => self::ACTION_USR_USERS_EDITPASS, - 'title' => _('Cambiar Clave de Usuario'), - 'onclick' => 'sysPassUtil.Common.usrUpdPass(this,' . self::ACTION_USR_USERS_EDITPASS . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/key.png', - 'icon' => 'lock_outline' - ), - 'del' => array( - 'id' => self::ACTION_USR_USERS_DELETE, - 'title' => _('Eliminar Usuario'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_USR_USERS_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ), - ) - ); + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(self::ACTION_USR_USERS_NEW); + $GridActionNew->setName(_('Nuevo Usuario')); + $GridActionNew->setIcon($this->_iconAdd); + $GridActionNew->setSkip(true); + $GridActionNew->setIsNew(true); + $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionNew->setOnClickArgs('this'); + $GridActionNew->setOnClickArgs(self::ACTION_USR_USERS_NEW); + $GridActionNew->setOnClickArgs($this->view->sk); - $arrUsersTableProp['cellWidth'] = floor(65 / count($arrUsersTableProp['tblHeaders'])); + $GridActionView = new DataGridAction(); + $GridActionView->setId(self::ACTION_USR_USERS_VIEW); + $GridActionView->setName(_('Ver Detalles de Usuario')); + $GridActionView->setIcon($this->_iconView); + $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionView->setOnClickArgs('this'); + $GridActionView->setOnClickArgs(self::ACTION_USR_USERS_VIEW); + $GridActionView->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', array( - 'title' => _('Gestión de Usuarios'), - 'query' => UserUtil::getUsers(), - 'props' => $arrUsersTableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5)) - ); + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(self::ACTION_USR_USERS_EDIT); + $GridActionEdit->setName(_('Editar Usuario')); + $GridActionEdit->setIcon($this->_iconEdit); + $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionEdit->setOnClickArgs('this'); + $GridActionEdit->setOnClickArgs(self::ACTION_USR_USERS_EDIT); + $GridActionEdit->setOnClickArgs($this->view->sk); + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_USR_USERS_DELETE); + $GridActionDel->setName(_('Eliminar Usuario')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_USR_USERS_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); + + $GridActionEditPass = new DataGridAction(); + $GridActionEditPass->setId(self::ACTION_USR_USERS_EDITPASS); + $GridActionEditPass->setName(_('Cambiar Clave de Usuario')); + $GridActionEditPass->setIcon(new DataGridIcon('lock_outline', 'imgs/pass.png', 'fg-orange80')); + $GridActionEditPass->setOnClickFunction('sysPassUtil.Common.usrUpdPass'); + $GridActionEditPass->setOnClickArgs('this'); + $GridActionEditPass->setOnClickArgs(self::ACTION_USR_USERS_EDITPASS); + $GridActionEditPass->setOnClickArgs($this->view->sk); + $GridActionEditPass->setFilterRowSource('user_isLdap'); + + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Nombre')); + $GridHeaders->addHeader(_('Login')); + $GridHeaders->addHeader(_('Perfil')); + $GridHeaders->addHeader(_('Grupo')); + $GridHeaders->addHeader(_('Propiedades')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('user_id'); + $GridData->addDataRowSource('user_name'); + $GridData->addDataRowSource('user_login'); + $GridData->addDataRowSource('userprofile_name'); + $GridData->addDataRowSource('usergroup_name'); + $GridData->addDataRowSourceWithIcon('user_isAdminApp', new DataGridIcon('star', 'check_blue.png', null, _('Admin Cuentas'))); + $GridData->addDataRowSourceWithIcon('user_isAdminAcc', new DataGridIcon('star_half', 'check_orange.png', null, _('Admin Cuentas'))); + $GridData->addDataRowSourceWithIcon('user_isLdap', new DataGridIcon('business', 'ldap.png', null, _('Usuario de LDAP'))); + $GridData->addDataRowSourceWithIcon('user_isDisabled', new DataGridIcon('error', 'disabled.png', null, _('Deshabilitado'))); + $GridData->setData(UserUtil::getUsers()); + + $Grid = new DataGridTab(); + $Grid->setId('tblUsers'); + $Grid->setDataActions($GridActionNew); + $Grid->setDataActions($GridActionView); + $Grid->setDataActions($GridActionEdit); + $Grid->setDataActions($GridActionEditPass); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Gestión de Usuarios')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** @@ -180,55 +205,61 @@ class UsersMgmtC extends Controller implements ActionsInterface { $this->setAction(self::ACTION_USR_GROUPS); - $this->view->assign('sk', SessionUtil::getSessionKey(true)); - if (!$this->checkAccess()) { return; } - $arrGroupsTableProp = array( - 'tblId' => 'tblGroups', - 'header' => '', - 'tblHeaders' => array(_('Nombre'), _('Descripción')), - 'tblRowSrc' => array('usergroup_name', 'usergroup_description'), - 'tblRowSrcId' => 'usergroup_id', - 'onCloseAction' => self::ACTION_USR, - 'actions' => array( - 'new' => array( - 'id' => self::ACTION_USR_GROUPS_NEW, - 'title' => _('Nuevo Grupo'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_GROUPS_NEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/new.png', - 'icon' => 'add', - 'skip' => true - ), - 'edit' => array( - 'id' => self::ACTION_USR_GROUPS_EDIT, - 'title' => _('Editar Grupo'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_GROUPS_EDIT . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/edit.png', - 'icon' => 'mode_edit' - ), - 'del' => array( - 'id' => self::ACTION_USR_GROUPS_DELETE, - 'title' => _('Eliminar Grupo'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_USR_GROUPS_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ) - ) - ); + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(self::ACTION_USR_GROUPS_NEW); + $GridActionNew->setName(_('Nuevo Grupo')); + $GridActionNew->setIcon($this->_iconAdd); + $GridActionNew->setSkip(true); + $GridActionNew->setIsNew(true); + $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionNew->setOnClickArgs('this'); + $GridActionNew->setOnClickArgs(self::ACTION_USR_GROUPS_NEW); + $GridActionNew->setOnClickArgs($this->view->sk); - $arrGroupsTableProp['cellWidth'] = floor(65 / count($arrGroupsTableProp['tblHeaders'])); + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(self::ACTION_USR_GROUPS_EDIT); + $GridActionEdit->setName(_('Editar Grupo')); + $GridActionEdit->setIcon($this->_iconEdit); + $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionEdit->setOnClickArgs('this'); + $GridActionEdit->setOnClickArgs(self::ACTION_USR_GROUPS_EDIT); + $GridActionEdit->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', array( - 'title' => _('Gestión de Grupos'), - 'query' => Groups::getGroups(), - 'props' => $arrGroupsTableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5)) - ); + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_USR_GROUPS_DELETE); + $GridActionDel->setName(_('Eliminar Grupo')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_USR_GROUPS_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); + + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Nombre')); + $GridHeaders->addHeader(_('Descripción')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('usergroup_id'); + $GridData->addDataRowSource('usergroup_name'); + $GridData->addDataRowSource('usergroup_description'); + $GridData->setData(Groups::getGroups()); + + $Grid = new DataGridTab(); + $Grid->setId('tblGroups'); + $Grid->setDataActions($GridActionNew); + $Grid->setDataActions($GridActionEdit); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Gestión de Grupos')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** @@ -238,63 +269,69 @@ class UsersMgmtC extends Controller implements ActionsInterface { $this->setAction(self::ACTION_USR_PROFILES); - $this->view->assign('sk', SessionUtil::getSessionKey(true)); - if (!$this->checkAccess()) { return; } - $arrProfilesTableProp = array( - 'tblId' => 'tblProfiles', - 'header' => '', - 'tblHeaders' => array(_('Nombre')), - 'tblRowSrc' => array('userprofile_name'), - 'tblRowSrcId' => 'userprofile_id', - 'onCloseAction' => self::ACTION_USR, - 'actions' => array( - 'new' => array( - 'id' => self::ACTION_USR_PROFILES_NEW, - 'title' => _('Nuevo Perfil'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_PROFILES_NEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/new.png', - 'icon' => 'add', - 'skip' => true - ), - 'view' => array( - 'id' => self::ACTION_USR_PROFILES_VIEW, - 'title' => _('Ver Detalles de Perfil'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_PROFILES_VIEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/view.png', - 'icon' => 'visibility' - ), - 'edit' => array( - 'id' => self::ACTION_USR_PROFILES_EDIT, - 'title' => _('Editar Perfil'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_USR_PROFILES_EDIT . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/edit.png', - 'icon' => 'mode_edit' - ), - 'del' => array( - 'id' => self::ACTION_USR_PROFILES_DELETE, - 'title' => _('Eliminar Perfil'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_USR_PROFILES_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ) - ) - ); + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(self::ACTION_USR_PROFILES_NEW); + $GridActionNew->setName(_('Nuevo Perfil')); + $GridActionNew->setIcon($this->_iconAdd); + $GridActionNew->setSkip(true); + $GridActionNew->setIsNew(true); + $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionNew->setOnClickArgs('this'); + $GridActionNew->setOnClickArgs(self::ACTION_USR_PROFILES_NEW); + $GridActionNew->setOnClickArgs($this->view->sk); - $arrProfilesTableProp['cellWidth'] = floor(65 / count($arrProfilesTableProp['tblHeaders'])); + $GridActionView = new DataGridAction(); + $GridActionView->setId(self::ACTION_USR_PROFILES_VIEW); + $GridActionView->setName(_('Ver Detalles de Perfil')); + $GridActionView->setIcon($this->_iconView); + $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionView->setOnClickArgs('this'); + $GridActionView->setOnClickArgs(self::ACTION_USR_PROFILES_VIEW); + $GridActionView->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', array( - 'title' => _('Gestión de Perfiles'), - 'query' => Profile::getProfiles(), - 'props' => $arrProfilesTableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5) - ) - ); + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(self::ACTION_USR_PROFILES_EDIT); + $GridActionEdit->setName(_('Editar Perfil')); + $GridActionEdit->setIcon($this->_iconEdit); + $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionEdit->setOnClickArgs('this'); + $GridActionEdit->setOnClickArgs(self::ACTION_USR_PROFILES_EDIT); + $GridActionEdit->setOnClickArgs($this->view->sk); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_USR_PROFILES_DELETE); + $GridActionDel->setName(_('Eliminar Perfil')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_USR_PROFILES_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); + + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Nombre')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('userprofile_id'); + $GridData->addDataRowSource('userprofile_name'); + $GridData->setData(Profile::getProfiles()); + + $Grid = new DataGridTab(); + $Grid->setId('tblProfiles'); + $Grid->setDataActions($GridActionNew); + $Grid->setDataActions($GridActionView); + $Grid->setDataActions($GridActionEdit); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Gestión de Perfiles')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** @@ -302,9 +339,7 @@ class UsersMgmtC extends Controller implements ActionsInterface */ public function useTabs() { - $this->view->addTemplate('tabs-start'); - $this->view->addTemplate('mgmttabs'); - $this->view->addTemplate('tabs-end'); + $this->view->addTemplate('datatabs-grid'); $this->view->assign('tabs', array()); $this->view->assign('activeTab', 0); @@ -328,6 +363,19 @@ class UsersMgmtC extends Controller implements ActionsInterface $this->getCustomFieldsForItem(); } + /** + * Obtener la lista de campos personalizados y sus valores + */ + private function getCustomFieldsForItem() + { + // Se comprueba que hayan campos con valores para el elemento actual + if ($this->view->itemId && CustomFields::checkCustomFieldExists($this->_module, $this->view->itemId)) { + $this->view->assign('customFields', CustomFields::getCustomFieldsData($this->_module, $this->view->itemId)); + } else { + $this->view->assign('customFields', CustomFields::getCustomFieldsForModule($this->_module)); + } + } + /** * Obtener los datos para la ficha de grupo */ @@ -391,56 +439,67 @@ class UsersMgmtC extends Controller implements ActionsInterface return; } - $tokensTableProp = array( - 'tblId' => 'tblTokens', - 'header' => '', - 'tblHeaders' => array(_('Usuario'), _('Acción')), - 'tblRowSrc' => array('user_login', 'authtoken_actionId'), - 'tblRowSrcId' => 'authtoken_id', - 'onCloseAction' => self::ACTION_MGM_APITOKENS, - 'actions' => array( - 'new' => array( - 'id' => self::ACTION_MGM_APITOKENS_NEW, - 'title' => _('Nueva Autorización'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_APITOKENS_NEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/new.png', - 'icon' => 'add', - 'skip' => true - ), - 'view' => array( - 'id' => self::ACTION_MGM_APITOKENS_VIEW, - 'title' => _('Ver token de Autorización'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_APITOKENS_VIEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/view.png', - 'icon' => 'visibility' - ), - 'edit' => array( - 'id' => self::ACTION_MGM_APITOKENS_EDIT, - 'title' => _('Editar Autorización'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_APITOKENS_EDIT . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/edit.png', - 'icon' => 'mode_edit' - ), - 'del' => array( - 'id' => self::ACTION_MGM_APITOKENS_DELETE, - 'title' => _('Eliminar Autorización'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_MGM_APITOKENS_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ) - ) - ); + $GridActionNew = new DataGridAction(); + $GridActionNew->setId(self::ACTION_MGM_APITOKENS_NEW); + $GridActionNew->setName(_('Nueva Autorización')); + $GridActionNew->setIcon($this->_iconAdd); + $GridActionNew->setSkip(true); + $GridActionNew->setIsNew(true); + $GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionNew->setOnClickArgs('this'); + $GridActionNew->setOnClickArgs(self::ACTION_MGM_APITOKENS_NEW); + $GridActionNew->setOnClickArgs($this->view->sk); - $tokensTableProp['cellWidth'] = floor(65 / count($tokensTableProp['tblHeaders'])); + $GridActionView = new DataGridAction(); + $GridActionView->setId(self::ACTION_MGM_APITOKENS_VIEW); + $GridActionView->setName(_('Ver token de Autorización')); + $GridActionView->setIcon($this->_iconView); + $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionView->setOnClickArgs('this'); + $GridActionView->setOnClickArgs(self::ACTION_MGM_APITOKENS_VIEW); + $GridActionView->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', array( - 'title' => _('Gestión de Autorizaciones API'), - 'query' => ApiTokens::getTokens(), - 'props' => $tokensTableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5)) - ); + $GridActionEdit = new DataGridAction(); + $GridActionEdit->setId(self::ACTION_MGM_APITOKENS_EDIT); + $GridActionEdit->setName(_('Editar Autorización')); + $GridActionEdit->setIcon($this->_iconEdit); + $GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionEdit->setOnClickArgs('this'); + $GridActionEdit->setOnClickArgs(self::ACTION_MGM_APITOKENS_EDIT); + $GridActionEdit->setOnClickArgs($this->view->sk); + + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_MGM_APITOKENS_DELETE); + $GridActionDel->setName(_('Eliminar Autorización')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_MGM_APITOKENS_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); + + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Usuario')); + $GridHeaders->addHeader(_('Acción')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('authtoken_id'); + $GridData->addDataRowSource('user_login'); + $GridData->addDataRowSource('authtoken_actionId'); + $GridData->setData(ApiTokens::getTokens()); + + $Grid = new DataGridTab(); + $Grid->setId('tblTokens'); + $Grid->setDataActions($GridActionNew); + $Grid->setDataActions($GridActionView); + $Grid->setDataActions($GridActionEdit); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Gestión de Autorizaciones API')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** @@ -463,19 +522,6 @@ class UsersMgmtC extends Controller implements ActionsInterface } } - /** - * Obtener la lista de campos personalizados y sus valores - */ - private function getCustomFieldsForItem() - { - // Se comprueba que hayan campos con valores para el elemento actual - if ($this->view->itemId && CustomFields::checkCustomFieldExists($this->_module, $this->view->itemId)) { - $this->view->assign('customFields', CustomFields::getCustomFieldsData($this->_module, $this->view->itemId)); - } else { - $this->view->assign('customFields', CustomFields::getCustomFieldsForModule($this->_module)); - } - } - /** * Obtener los datos para la pestaña de tokens de API */ @@ -487,48 +533,63 @@ class UsersMgmtC extends Controller implements ActionsInterface return; } - $linksTableProp = array( - 'tblId' => 'tblLinks', - 'header' => '', - 'tblHeaders' => array(_('Cuenta'), _('Fecha Creación'), _('Fecha Caducidad'), _('Usuario'), _('Notificar'), _('Visitas')), - 'tblRowSrc' => array('publicLink_account', 'publicLink_dateAdd', 'publicLink_dateExpire', 'publicLink_user', 'publicLink_notify', 'publicLink_views'), - 'tblRowSrcId' => 'publicLink_id', - 'onCloseAction' => self::ACTION_MGM_PUBLICLINKS, - 'actions' => array( - 'view' => array( - 'id' => self::ACTION_MGM_PUBLICLINKS_VIEW, - 'title' => _('Ver Enlace'), - 'onclick' => 'sysPassUtil.Common.appMgmtData(this,' . self::ACTION_MGM_PUBLICLINKS_VIEW . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/view.png', - 'icon' => 'visibility' - ), - 'refresh' => array( - 'id' => self::ACTION_MGM_PUBLICLINKS_VIEW, - 'title' => _('Renovar Enlace'), - 'onclick' => 'sysPassUtil.Common.linksMgmtRefresh(this,' . self::ACTION_MGM_PUBLICLINKS_REFRESH . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/view.png', - 'icon' => 'refresh' - ), - 'del' => array( - 'id' => self::ACTION_MGM_PUBLICLINKS_DELETE, - 'title' => _('Eliminar Enlace'), - 'onclick' => 'sysPassUtil.Common.appMgmtDelete(this,' . self::ACTION_MGM_PUBLICLINKS_DELETE . ',\'' . $this->view->sk . '\')', - 'img' => 'imgs/delete.png', - 'icon' => 'delete', - 'isdelete' => true - ) - ) - ); + $GridActionView = new DataGridAction(); + $GridActionView->setId(self::ACTION_MGM_PUBLICLINKS_VIEW); + $GridActionView->setName(_('Ver Enlace')); + $GridActionView->setIcon($this->_iconView); + $GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData'); + $GridActionView->setOnClickArgs('this'); + $GridActionView->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_VIEW); + $GridActionView->setOnClickArgs($this->view->sk); - $linksTableProp['cellWidth'] = floor(65 / count($linksTableProp['tblHeaders'])); + $GridActionRefresh = new DataGridAction(); + $GridActionRefresh->setId(self::ACTION_MGM_PUBLICLINKS_REFRESH); + $GridActionRefresh->setName(_('Renovar Enlace')); + $GridActionRefresh->setIcon(new DataGridIcon('refresh', 'imgs/view.png', 'fg-green80')); + $GridActionRefresh->setOnClickFunction('sysPassUtil.Common.linksMgmtRefresh'); + $GridActionRefresh->setOnClickArgs('this'); + $GridActionRefresh->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_REFRESH); + $GridActionRefresh->setOnClickArgs($this->view->sk); - $this->view->append( - 'tabs', array( - 'title' => _('Gestión de Enlaces'), - 'query' => PublicLinkUtil::getLinks(), - 'props' => $linksTableProp, - 'time' => round(microtime() - $this->view->queryTimeStart, 5)) - ); + $GridActionDel = new DataGridAction(); + $GridActionDel->setId(self::ACTION_MGM_PUBLICLINKS_DELETE); + $GridActionDel->setName(_('Eliminar Enlace')); + $GridActionDel->setIcon($this->_iconDelete); + $GridActionDel->setIsDelete(true); + $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete'); + $GridActionDel->setOnClickArgs('this'); + $GridActionDel->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_DELETE); + $GridActionDel->setOnClickArgs($this->view->sk); + + $GridHeaders = new DataGridHeader(); + $GridHeaders->addHeader(_('Cuenta')); + $GridHeaders->addHeader(_('Fecha Creación')); + $GridHeaders->addHeader(_('Fecha Caducidad')); + $GridHeaders->addHeader(_('Usuario')); + $GridHeaders->addHeader(_('Notificar')); + $GridHeaders->addHeader(_('Visitas')); + + $GridData = new DataGridData(); + $GridData->setDataRowSourceId('publicLink_id'); + $GridData->addDataRowSource('publicLink_account'); + $GridData->addDataRowSource('publicLink_dateAdd'); + $GridData->addDataRowSource('publicLink_dateExpire'); + $GridData->addDataRowSource('publicLink_user'); + $GridData->addDataRowSource('publicLink_notify'); + $GridData->addDataRowSource('publicLink_views'); + $GridData->setData(PublicLinkUtil::getLinks()); + + $Grid = new DataGridTab(); + $Grid->setId('tblLinks'); + $Grid->setDataActions($GridActionView); + $Grid->setDataActions($GridActionRefresh); + $Grid->setDataActions($GridActionDel); + $Grid->setHeader($GridHeaders); + $Grid->setData($GridData); + $Grid->setTitle(_('Gestión de Enlaces')); + $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5)); + + $this->view->append('tabs', $Grid); } /** diff --git a/inc/SP/Html/DataGrid/DataGrid.class.php b/inc/SP/Html/DataGrid/DataGrid.class.php new file mode 100644 index 00000000..5fffe081 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGrid.class.php @@ -0,0 +1,36 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGrid para crear una matriz de datos + * + * @package SP\Html\DataGrid + */ +class DataGrid extends DataGridBase +{ + +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridAction.class.php b/inc/SP/Html/DataGrid/DataGridAction.class.php new file mode 100644 index 00000000..cf9f2768 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridAction.class.php @@ -0,0 +1,36 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridAction para crear una acción para cada elemento de la matriz de datos + * + * @package SP\Html\DataGrid + */ +class DataGridAction extends DataGridActionBase +{ + +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridActionBase.class.php b/inc/SP/Html/DataGrid/DataGridActionBase.class.php new file mode 100644 index 00000000..9d58c663 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridActionBase.class.php @@ -0,0 +1,252 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridAction para crear una acción para cada elemento de la matriz de datos + * + * @package SP\Html\DataGrid + */ +abstract class DataGridActionBase implements DataGridActionInterface +{ + /** + * El nombre de la acción + * + * @var string + */ + private $_name = ''; + /** + * El título de la acción + * + * @var string + */ + private $_title = ''; + /** + * El id de la acción + * + * @var int + */ + private $_id = 0; + /** + * La función javascript del evento OnClick + * @var string + */ + private $_onClickFunction = ''; + /** + * Los argumentos de la función OnClick + * + * @var array + */ + private $_onClickArgs = array(); + /** + * El icono de la acción + * + * @var DataGridIcon + */ + private $_icon = null; + /** + * Si es una acción de eliminar elementos + * + * @var bool + */ + private $_isDelete = false; + /** + * Si se debe de omitir para los elementos del listado + * + * @var bool + */ + private $_isSkip = false; + /** + * Si es una acción para crear elementos + * + * @var bool + */ + private $_isNew = false; + /** + * La columna de origen de datos que condiciona esta acción + * + * @var string + */ + private $_filterRowSource = ''; + + /** + * @return string + */ + public function getName() + { + return $this->_name; + } + + /** + * @param $name string + */ + public function setName($name) + { + $this->_name = $name; + } + + /** + * @return string + */ + public function getId() + { + return $this->_id; + } + + /** + * @param int $id + */ + public function setId($id) + { + $this->_id = $id; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->_title; + } + + /** + * @param $title string + */ + public function setTitle($title) + { + $this->_title = $title; + } + + /** + * @param $function string + */ + public function setOnClickFunction($function) + { + $this->_onClickFunction = $function; + } + + /** + * @param $args string + */ + public function setOnClickArgs($args) + { + $this->_onClickArgs[] = $args; + } + + /** + * @return string + */ + public function getOnClick() + { + $args = array(); + + foreach ($this->_onClickArgs as $arg) { + $args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg; + } + + return $this->_onClickFunction . '(' . implode(',', $args) . ')'; + } + + /** + * @return DataGridIcon + */ + public function getIcon() + { + return $this->_icon; + } + + /** + * @param $icon DataGridIcon + */ + public function setIcon($icon) + { + $this->_icon = $icon; + } + + /** + * @param $skip bool + */ + public function setSkip($skip) + { + $this->_isSkip = $skip; + } + + /** + * @return bool + */ + public function isSkip() + { + return $this->_isSkip; + } + + /** + * @param $delete bool + */ + public function setIsDelete($delete) + { + $this->_isDelete = $delete; + } + + /** + * @return bool + */ + public function isDelete() + { + return $this->_isDelete; + } + + /** + * @param bool $new + */ + public function setIsNew($new) + { + $this->_isNew = $new; + } + + /** + * @return bool + */ + public function isNew() + { + return $this->_isNew; + } + + /** + * @param $rowSource string + */ + public function setFilterRowSource($rowSource) + { + $this->_filterRowSource = $rowSource; + } + + /** + * @return string + */ + public function getFilterRowSource() + { + return $this->_filterRowSource; + } +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridActionInterface.class.php b/inc/SP/Html/DataGrid/DataGridActionInterface.class.php new file mode 100644 index 00000000..e6230f5d --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridActionInterface.class.php @@ -0,0 +1,129 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Interface DataGridActionInterface + * + * @package SP\Html\DataGrid + */ +interface DataGridActionInterface +{ + /** + * @param $name string + */ + public function setName($name); + + /** + * @return string + */ + public function getName(); + + /** + * @param int $id + */ + public function setId($id); + + /** + * @return string + */ + public function getId(); + + /** + * @param $title string + */ + public function setTitle($title); + + /** + * @return string + */ + public function getTitle(); + + /** + * @param $function string + */ + public function setOnClickFunction($function); + + /** + * @param $args string + */ + public function setOnClickArgs($args); + + /** + * @return string + */ + public function getOnClick(); + + /** + * @param $icon string + */ + public function setIcon($icon); + + /** + * @return string + */ + public function getIcon(); + + /** + * @param $skip bool + */ + public function setSkip($skip); + + /** + * @return bool + */ + public function isSkip(); + + /** + * @param $delete bool + */ + public function setIsDelete($delete); + + /** + * @return bool + */ + public function isDelete(); + + /** + * @param $new bool + */ + public function setIsNew($new); + + /** + * @return bool + */ + public function isNew(); + + /** + * @param $rowSource string + */ + public function setFilterRowSource($rowSource); + + /** + * @return string + */ + public function getFilterRowSource(); +} diff --git a/inc/SP/Html/DataGrid/DataGridBase.class.php b/inc/SP/Html/DataGrid/DataGridBase.class.php new file mode 100644 index 00000000..005a1672 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridBase.class.php @@ -0,0 +1,160 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +use SP\Core\ActionsInterface; +use SplObjectStorage; + +/** + * Class DataGridBase para crear una matriz de datos + * + * @package SP\Html\DataGrid + */ +abstract class DataGridBase implements DataGridInterface +{ + /** + * El id de la matriz + * + * @var string + */ + private $_id = ''; + /** + * La cabecera de la matriz + * + * @var DataGridHeader + */ + private $_header; + /** + * Los datos de la matriz + * + * @var DataGridData + */ + private $_data; + /** + * Las acciones asociadas a los elementos de la matriz + * + * @var DataGridAction[] + */ + private $_actions = null; + /** + * La acción a realizar al cerrar la matriz + * + * @var int + */ + private $_onCloseAction = 0; + + /** + * @return int + */ + public function getOnCloseAction() + { + return $this->_onCloseAction; + } + + /** + * @param ActionsInterface $action + */ + public function setOnCloseAction(ActionsInterface $action) + { + $this->_onCloseAction = $action; + } + + /** + * @return string + */ + public function getId() + { + return $this->_id; + } + + /** + * @param $id string + */ + public function setId($id) + { + $this->_id = $id; + } + + /** + * @return DataGridHeader + */ + public function getHeader() + { + return $this->_header; + } + + /** + * @param DataGridHeader $header + */ + public function setHeader(DataGridHeader $header) + { + $this->_header = $header; + } + + /** + * @return DataGridData + */ + public function getData() + { + return $this->_data; + } + + /** + * @param DataGridData $data + */ + public function setData(DataGridData $data) + { + $this->_data = $data; + } + + /** + * @param DataGridAction $action + */ + public function setDataActions(DataGridAction $action) + { + if (is_null($this->_actions)) { + $this->_actions = new SplObjectStorage(); + } + + $this->_actions->attach($action); + } + + /** + * @return DataGridAction[] + */ + public function getDataActions() + { + return $this->_actions; + } + + /** + * @return mixed + */ + public function getGrid() + { + // TODO: Implement getGrid() method. + } +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridData.class.php b/inc/SP/Html/DataGrid/DataGridData.class.php new file mode 100644 index 00000000..551a5218 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridData.class.php @@ -0,0 +1,36 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridData para establecer el origen de datos de la matriz + * + * @package SP\Html\DataGrid + */ +class DataGridData extends DataGridDataBase +{ + +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridDataBase.class.php b/inc/SP/Html/DataGrid/DataGridDataBase.class.php new file mode 100644 index 00000000..ba8fc2d0 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridDataBase.class.php @@ -0,0 +1,110 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridDataBase para establecer el origen de datos de la matriz + * + * @package SP\Html\DataGrid + */ +abstract class DataGridDataBase implements DataGridDataInterface +{ + /** + * Los datos de la matriz + * + * @var array + */ + private $_data = array(); + /** + * Las columnas a mostrar de los datos obtenidos + * + * @var array + */ + private $_sources = array(); + /** + * La columna que identifica cada elemento de los datos de la matriz + * + * @var int + */ + private $_sourceId = 0; + + /** + * @param $source string + */ + public function addDataRowSource($source) + { + $this->_sources[] = $source; + } + + /** + * @param $id string + */ + public function setDataRowSourceId($id) + { + $this->_sourceId = $id; + } + + /** + * @return array + */ + public function getDataRowSources() + { + return $this->_sources; + } + + /** + * @return string + */ + public function getDataRowSourceId() + { + return $this->_sourceId; + } + + /** + * @return array + */ + public function getData() + { + return $this->_data; + } + + /** + * @param $data array + */ + public function setData(array $data) + { + $this->_data = $data; + } + + /** + * @param string $source + * @param DatagridIcon $icon + */ + public function addDataRowSourceWithIcon($source, $icon) + { + $this->_sources[] = array($source, $icon); + } +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridDataInterface.class.php b/inc/SP/Html/DataGrid/DataGridDataInterface.class.php new file mode 100644 index 00000000..4d4eb9e7 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridDataInterface.class.php @@ -0,0 +1,71 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Interface DataGridDataInterface + * + * @package SP\Html\DataGrid + */ +interface DataGridDataInterface +{ + /** + * @param $source string + */ + public function addDataRowSource($source); + + /** + * @return array + */ + public function getDataRowSources(); + + /** + * @param $id string + */ + public function setDataRowSourceId($id); + + /** + * @return string + */ + public function getDataRowSourceId(); + + /** + * @param $data array + */ + public function setData(array $data); + + /** + * @return array + */ + public function getData(); + + /** + * @param $source string + * @param $icon DatagridIcon + * @return + */ + public function addDataRowSourceWithIcon($source, $icon); +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridHeader.class.php b/inc/SP/Html/DataGrid/DataGridHeader.class.php new file mode 100644 index 00000000..ec201c93 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridHeader.class.php @@ -0,0 +1,36 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridHeader para establecer las cabeceras de la matriz + * + * @package SP\Html\DataGrid + */ +class DataGridHeader extends DataGridHeaderBase +{ + +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridHeaderBase.class.php b/inc/SP/Html/DataGrid/DataGridHeaderBase.class.php new file mode 100644 index 00000000..2f72ae43 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridHeaderBase.class.php @@ -0,0 +1,74 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridHeaderBase para establecer las cabeceras de la matriz + * + * @package SP\Html\DataGrid + */ +abstract class DataGridHeaderBase implements DataGridHeaderInterface +{ + /** + * Las cabeceras que identifican las columnas de datos + * + * @var array + */ + private $_headers = array(); + /** + * El ancho de las columnas + * + * @var int + */ + private $_width = 0; + + /** + * @param $header string + */ + public function addHeader($header) + { + $this->_headers[] = $header; + + $numHeaders = count($this->_headers); + $this->_width = ($numHeaders > 0) ? floor(65 / $numHeaders) : 65; + } + + /** + * @return int + */ + public function getWidth() + { + return $this->_width; + } + + /** + * @return array + */ + public function getHeaders() + { + return $this->_headers; + } +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridHeaderInterface.class.php b/inc/SP/Html/DataGrid/DataGridHeaderInterface.class.php new file mode 100644 index 00000000..74418258 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridHeaderInterface.class.php @@ -0,0 +1,44 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Interface DataGridHeader + * + * @package SP\Html\DataGrid + */ +interface DataGridHeaderInterface +{ + /** + * @param $header string + */ + public function addHeader($header); + + /** + * @return array + */ + public function getHeaders(); +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridIcon.class.php b/inc/SP/Html/DataGrid/DataGridIcon.class.php new file mode 100644 index 00000000..ec77302a --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridIcon.class.php @@ -0,0 +1,48 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridIcon para crear los iconos de la matriz + * + * @package SP\Html\DataGrid + */ +class DataGridIcon extends DataGridIconBase +{ + /** + * @param string $icon + * @param string $image + * @param string $class + * @param string $title + */ + public function __construct($icon, $image, $class = null, $title = null) + { + $this->setIcon($icon); + $this->setImage($image); + $this->setClass($class); + $this->setTitle($title); + } +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridIconBase.class.php b/inc/SP/Html/DataGrid/DataGridIconBase.class.php new file mode 100644 index 00000000..61df29a1 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridIconBase.class.php @@ -0,0 +1,123 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridIconBase para crear los iconos de la matriz + * + * @package SP\Html\DataGrid + */ +abstract class DataGridIconBase implements DataGridIconInterface +{ + /** + * El icono a utilizar en la etiqueta (según tema visual) + * + * @var string + */ + private $_icon = ''; + /** + * Imagen a utilizar en el icono (según tema visual) + * + * @var string + */ + private $_image = ''; + /** + * Título del icono + * + * @var string + */ + private $_title = ''; + /** + * Clase CSS del icono + * + * @var string + */ + private $_class = ''; + + /** + * @return string + */ + public function getIcon() + { + return $this->_icon; + } + + /** + * @param $icon + */ + public function setIcon($icon) + { + $this->_icon = $icon; + } + + /** + * @return string + */ + public function getImage() + { + return $this->_image; + } + + /** + * @param $image + */ + public function setImage($image) + { + $this->_image = $image; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->_title; + } + + /** + * @param $title + */ + public function setTitle($title) + { + $this->_title = $title; + } + + /** + * @param $class + */ + public function setClass($class) + { + $this->_class = $class; + } + + /** + * @return string + */ + public function getClass() + { + return $this->_class; + } +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridIconInterface.class.php b/inc/SP/Html/DataGrid/DataGridIconInterface.class.php new file mode 100644 index 00000000..54287a4d --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridIconInterface.class.php @@ -0,0 +1,74 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Interface DataGridIconInterface + * + * @package SP\Html\DataGrid + */ +interface DataGridIconInterface +{ + /** + * @param $icon + */ + public function setIcon($icon); + + /** + * @return string + */ + public function getIcon(); + + /** + * @param $image + */ + public function setImage($image); + + /** + * @return string + */ + public function getImage(); + + /** + * @param $title + */ + public function setTitle($title); + + /** + * @return string + */ + public function getTitle(); + + /** + * @param $class + */ + public function setClass($class); + + /** + * @return string + */ + public function getClass(); +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridInterface.class.php b/inc/SP/Html/DataGrid/DataGridInterface.class.php new file mode 100644 index 00000000..52359589 --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridInterface.class.php @@ -0,0 +1,86 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +use SP\Core\ActionsInterface; + +/** + * Interface DataGridInterface + * + * @package SP\Html\DataGrid + */ +interface DataGridInterface +{ + /** + * @param $id string + */ + public function setId($id); + + /** + * @return string + */ + public function getId(); + + /** + * @param DataGridHeader $header + */ + public function setHeader(DataGridHeader $header); + + /** + * @return DataGridHeader + */ + public function getHeader(); + + /** + * @param DataGridData $data + */ + public function setData(DataGridData $data); + + /** + * @return DataGridData + */ + public function getData(); + + /** + * @param DataGridAction $action + */ + public function setDataActions(DataGridAction $action); + + /** + * @return DataGridAction + */ + public function getDataActions(); + + /** + * @return mixed + */ + public function getGrid(); + + /** + * @param ActionsInterface $action + */ + public function setOnCloseAction(ActionsInterface $action); +} \ No newline at end of file diff --git a/inc/SP/Html/DataGrid/DataGridTab.class.php b/inc/SP/Html/DataGrid/DataGridTab.class.php new file mode 100644 index 00000000..2da3c05c --- /dev/null +++ b/inc/SP/Html/DataGrid/DataGridTab.class.php @@ -0,0 +1,80 @@ +. + * + */ + +namespace SP\Html\DataGrid; + +/** + * Class DataGridTab para crear una matriz de datos a usar en pestañas + * + * @package SP\Html\DataGrid + */ +class DataGridTab extends DataGridBase +{ + /** + * Título de la pestaña + * + * @var string + */ + private $_title = ''; + /** + * Tiempo de ejecución + * + * @var int + */ + private $_time = 0; + + /** + * @param $title string + */ + public function setTitle($title) + { + $this->_title = $title; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->_title; + } + + /** + * @return int + */ + public function getTime() + { + return $this->_time; + } + + /** + * @param int $time + */ + public function setTime($time) + { + $this->_time = $time; + } +} + diff --git a/inc/SP/Html/Html.class.php b/inc/SP/Html/Html.class.php index cfac7e5a..b3def0f4 100644 --- a/inc/SP/Html/Html.class.php +++ b/inc/SP/Html/Html.class.php @@ -45,7 +45,7 @@ class Html } if (is_array($data)) { - array_walk_recursive($data, '\SP\Html::sanitize'); + array_walk_recursive($data, '\SP\Html\Html::sanitize'); } else { $data = strip_tags($data); diff --git a/inc/themes/material-blue/datatabs-grid.inc b/inc/themes/material-blue/datatabs-grid.inc new file mode 100644 index 00000000..47426584 --- /dev/null +++ b/inc/themes/material-blue/datatabs-grid.inc @@ -0,0 +1,113 @@ + +
+ + + $tab): + /** + * @var $tab SP\Html\DataGrid\DataGridTab + */ + ?> +
+
+
    + getDataActions() as $action): ?> + isNew()): ?> +
  • + +
  • + + +
  • + +
  • +
+
+ +
+
    + getHeader()->getHeaders() as $header): ?> +
  • + +
+
+ +
+ getData()->getData() as $item): ?> +
    + getData()->getDataRowSources() as $rowSrc): ?> + + $rowSrc[0] == 1): ?> +
  • + + getIcon(); ?> + +
  • + + +
  • + $rowSrc)) ? $item->$rowSrc : ' '; // Fix height ?> +
  • + + + +
  • + getDataActions() as $action): ?> + isSkip()): ?> + getFilterRowSource() && $item->{$action->getFilterRowSource()} == 1): continue; endif; ?> + getIcon()->getIcon(); ?> + + +
  • +
+ +
+ + +
+ +
+ + diff --git a/inc/themes/material-blue/upgrade.inc b/inc/themes/material-blue/upgrade.inc index 69edbe44..a7962968 100644 --- a/inc/themes/material-blue/upgrade.inc +++ b/inc/themes/material-blue/upgrade.inc @@ -1,7 +1,7 @@