Example #1
0
 /**
  * Establecer variables para los interfaces que muestran datos
  */
 private function setShowData()
 {
     $this->view->assign('showHistory', ($this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY) && Acl::checkUserAccess(Acl::ACTION_ACC_VIEW_HISTORY) && ($this->view->isModified || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY));
     $this->view->assign('showDetails', $this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY || $this->_action == Acl::ACTION_ACC_DELETE);
     $this->view->assign('showPass', $this->_action == Acl::ACTION_ACC_NEW || $this->_action == Acl::ACTION_ACC_COPY);
     $this->view->assign('showFiles', ($this->_action == Acl::ACTION_ACC_EDIT || $this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY) && (\SP\Util::fileIsEnabled() && Acl::checkUserAccess(Acl::ACTION_ACC_FILES)));
     $this->view->assign('showViewPass', ($this->_action == Acl::ACTION_ACC_VIEW || $this->_action == Acl::ACTION_ACC_VIEW_HISTORY) && (Acl::checkAccountAccess(Acl::ACTION_ACC_VIEW_PASS, $this->_account->getAccountDataForACL()) && Acl::checkUserAccess(Acl::ACTION_ACC_VIEW_PASS)));
     $this->view->assign('showSave', $this->_action == Acl::ACTION_ACC_EDIT || $this->_action == Acl::ACTION_ACC_NEW || $this->_action == Acl::ACTION_ACC_COPY);
     $this->view->assign('showEdit', $this->_action == Acl::ACTION_ACC_VIEW && Acl::checkAccountAccess(Acl::ACTION_ACC_EDIT, $this->_account->getAccountDataForACL()) && Acl::checkUserAccess(Acl::ACTION_ACC_EDIT) && !$this->_account->getAccountIsHistory());
     $this->view->assign('showEditPass', $this->_action == Acl::ACTION_ACC_EDIT || $this->_action == Acl::ACTION_ACC_VIEW && Acl::checkAccountAccess(Acl::ACTION_ACC_EDIT_PASS, $this->_account->getAccountDataForACL()) && Acl::checkUserAccess(Acl::ACTION_ACC_EDIT_PASS) && !$this->_account->getAccountIsHistory());
     $this->view->assign('showDelete', $this->_action == Acl::ACTION_ACC_DELETE || $this->_action == Acl::ACTION_ACC_EDIT && Acl::checkAccountAccess(Acl::ACTION_ACC_DELETE, $this->_account->getAccountDataForACL()) && Acl::checkUserAccess(Acl::ACTION_ACC_DELETE));
     $this->view->assign('showRestore', $this->_action == Acl::ACTION_ACC_VIEW_HISTORY && Acl::checkAccountAccess(Acl::ACTION_ACC_EDIT, $this->_account->getAccountDataForACL($this->_account->getAccountParentId())) && Acl::checkUserAccess(Acl::ACTION_ACC_EDIT));
 }
Example #2
0
 /**
  * Devuelve una respuesta en formato JSON con el estado y el mensaje.
  *
  * @param string $data Los datos a devolver
  * @return bool
  * @throws SPException
  */
 private function wrapJSON($data)
 {
     $arrStrFrom = array("\\", '"', "'");
     $arrStrTo = array("\\", '\\"', "\\'");
     if (is_array($data) || is_object($data)) {
         array_walk($data, function (&$value) use($arrStrFrom, $arrStrTo) {
             if (is_object($value)) {
                 foreach ($value as &$attribute) {
                     str_replace($arrStrFrom, $arrStrTo, $attribute);
                 }
                 return $value;
             } else {
                 return str_replace($arrStrFrom, $arrStrTo, $value);
             }
         });
     } else {
         $data = str_replace($arrStrFrom, $arrStrTo, $data);
     }
     $json = json_encode(array('action' => Acl::getActionName($this->_actionId, true), 'data' => $data));
     if ($json === false) {
         throw new SPException(SPException::SP_CRITICAL, sprintf('%s : %s', _('Error de codificación'), json_last_error_msg()));
     }
     return $json;
 }
Example #3
0
 /**
  * Procesar los resultados de la búsqueda y crear la variable que contiene los datos de cada cuenta
  * a mostrar.
  *
  * @param &$results array Con los resultados de la búsqueda
  */
 private function processSearchResults(&$results)
 {
     // Variables para la barra de navegación
     $this->view->assign('firstPage', ceil(($this->view->limitStart + 1) / $this->view->limitCount));
     $this->view->assign('lastPage', ceil(\SP\AccountSearch::$queryNumRows / $this->view->limitCount));
     $this->view->assign('totalRows', \SP\AccountSearch::$queryNumRows);
     $this->view->assign('filterOn', $this->_filterOn);
     $limitLast = \SP\AccountSearch::$queryNumRows % $this->view->limitCount == 0 ? \SP\AccountSearch::$queryNumRows - $this->view->limitCount : floor(\SP\AccountSearch::$queryNumRows / $this->view->limitCount) * $this->view->limitCount;
     $this->view->assign('pagerOnnClick', array('first' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ', 0,1)', 'last' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ',' . $limitLast . ',1)', 'prev' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ',' . ($this->view->limitStart - $this->view->limitCount) . ',1)', 'next' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ',' . ($this->view->limitStart + $this->view->limitCount) . ',1)'));
     $accountLink = Session::getUserPreferences()->isAccountLink();
     $topNavbar = Session::getUserPreferences()->isTopNavbar();
     $optionalActions = Session::getUserPreferences()->isOptionalActions();
     // Variables de configuración
     $this->view->assign('accountLink', is_null($accountLink) ? \SP\Config::getValue('account_link', 0) : $accountLink);
     $this->view->assign('topNavbar', $topNavbar);
     $this->view->assign('optionalActions', $optionalActions);
     $this->view->assign('requestEnabled', \SP\Util::mailrequestIsEnabled());
     $this->view->assign('isDemoMode', \SP\Util::demoIsEnabled());
     $maxTextLength = \SP\Util::resultsCardsIsEnabled() ? 40 : 60;
     $wikiEnabled = \SP\Util::wikiIsEnabled();
     if ($wikiEnabled) {
         $wikiSearchUrl = \SP\Config::getValue('wiki_searchurl', false);
         $this->view->assign('wikiFilter', explode(',', \SP\Config::getValue('wiki_filter')));
         $this->view->assign('wikiPageUrl', \SP\Config::getValue('wiki_pageurl'));
     }
     $this->setSortFields();
     $objAccount = new \SP\Account();
     foreach ($results as $account) {
         $objAccount->setAccountId($account->account_id);
         $objAccount->setAccountUserId($account->account_userId);
         $objAccount->setAccountUserGroupId($account->account_userGroupId);
         $objAccount->setAccountOtherUserEdit($account->account_otherUserEdit);
         $objAccount->setAccountOtherGroupEdit($account->account_otherGroupEdit);
         // Obtener los datos de la cuenta para aplicar las ACL
         $accountAclData = $objAccount->getAccountDataForACL();
         // Establecer los permisos de acceso
         $accView = \SP\Acl::checkAccountAccess(self::ACTION_ACC_VIEW, $accountAclData) && \SP\Acl::checkUserAccess(self::ACTION_ACC_VIEW);
         $accViewPass = \SP\Acl::checkAccountAccess(self::ACTION_ACC_VIEW_PASS, $accountAclData) && \SP\Acl::checkUserAccess(self::ACTION_ACC_VIEW_PASS);
         $accEdit = \SP\Acl::checkAccountAccess(self::ACTION_ACC_EDIT, $accountAclData) && \SP\Acl::checkUserAccess(self::ACTION_ACC_EDIT);
         $accCopy = \SP\Acl::checkAccountAccess(self::ACTION_ACC_COPY, $accountAclData) && \SP\Acl::checkUserAccess(self::ACTION_ACC_COPY);
         $accDel = \SP\Acl::checkAccountAccess(self::ACTION_ACC_DELETE, $accountAclData) && \SP\Acl::checkUserAccess(self::ACTION_ACC_DELETE);
         $show = $accView || $accViewPass || $accEdit || $accCopy || $accDel;
         // Obtenemos datos si el usuario tiene acceso a los datos de la cuenta
         if ($show) {
             $secondaryGroups = \SP\Groups::getGroupsNameForAccount($account->account_id);
             $secondaryUsers = UserAccounts::getUsersNameForAccount($account->account_id);
             $secondaryAccesses = '<em>(G) ' . $account->usergroup_name . '*</em><br>';
             if ($secondaryGroups) {
                 foreach ($secondaryGroups as $group) {
                     $secondaryAccesses .= '<em>(G) ' . $group . '</em><br>';
                 }
             }
             if ($secondaryUsers) {
                 foreach ($secondaryUsers as $user) {
                     $secondaryAccesses .= '<em>(U) ' . $user . '</em><br>';
                 }
             }
             $accountNotes = '';
             if ($account->account_notes) {
                 $accountNotes = strlen($account->account_notes) > 300 ? substr($account->account_notes, 0, 300) . "..." : $account->account_notes;
                 $accountNotes = nl2br(wordwrap(htmlspecialchars($accountNotes), 50, '<br>', true));
             }
         }
         // Variable $accounts de la plantilla utilizada para obtener los datos de las cuentas
         $this->view->append('accounts', array('id' => $account->account_id, 'name' => $account->account_name, 'login' => \SP\Html::truncate($account->account_login, $maxTextLength), 'category_name' => $account->category_name, 'customer_name' => \SP\Html::truncate($account->customer_name, $maxTextLength), 'customer_link' => $wikiEnabled ? $wikiSearchUrl . $account->customer_name : '', 'color' => $this->pickAccountColor($account->account_customerId), 'url' => $account->account_url, 'url_short' => \SP\Html::truncate($account->account_url, $maxTextLength), 'url_islink' => preg_match("#^https?://.*#i", $account->account_url) ? true : false, 'notes' => $accountNotes, 'accesses' => isset($secondaryAccesses) ? $secondaryAccesses : '', 'numFiles' => \SP\Util::fileIsEnabled() ? $account->num_files : 0, 'show' => $show, 'showView' => $accView, 'showViewPass' => $accViewPass, 'showEdit' => $accEdit, 'showCopy' => $accCopy, 'showDel' => $accDel));
     }
 }
Example #4
0
 /**
  * Devuelver un array de acciones posibles para los tokens
  *
  * @return array
  */
 public static function getTokenActions()
 {
     $actions = array(ActionsInterface::ACTION_ACC_SEARCH => Acl::getActionName(ActionsInterface::ACTION_ACC_SEARCH), ActionsInterface::ACTION_ACC_VIEW => Acl::getActionName(ActionsInterface::ACTION_ACC_VIEW), ActionsInterface::ACTION_ACC_VIEW_PASS => Acl::getActionName(ActionsInterface::ACTION_ACC_VIEW_PASS), ActionsInterface::ACTION_ACC_DELETE => Acl::getActionName(ActionsInterface::ACTION_ACC_DELETE), ActionsInterface::ACTION_CFG_BACKUP => Acl::getActionName(ActionsInterface::ACTION_CFG_BACKUP), ActionsInterface::ACTION_CFG_EXPORT => Acl::getActionName(ActionsInterface::ACTION_CFG_EXPORT));
     return $actions;
 }