modules/org.openbravo.client.application/src-db/database/model/functions/OBUIAPP_UPDATE_ACCESS.xml
author Asier Lostalé <asier.lostale@openbravo.com>
Thu, 03 May 2012 08:50:49 +0200
changeset 16377 1e0a83f6548b
child 21540 4062022a52bd
permissions -rw-r--r--
[process] Added default security for manual roles
asier@16377
     1
<?xml version="1.0"?>
asier@16377
     2
  <database name="FUNCTION OBUIAPP_UPDATE_ACCESS">
asier@16377
     3
    <function name="OBUIAPP_UPDATE_ACCESS" type="NULL">
asier@16377
     4
      <parameter name="p_ep_instance_id" type="VARCHAR" mode="in">
asier@16377
     5
        <default/>
asier@16377
     6
      </parameter>
asier@16377
     7
      <body><![CDATA[/*************************************************************************
asier@16377
     8
* The contents of this file are subject to the Openbravo  Public  License
asier@16377
     9
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
asier@16377
    10
* Version 1.1  with a permitted attribution clause; you may not  use this
asier@16377
    11
* file except in compliance with the License. You  may  obtain  a copy of
asier@16377
    12
* the License at http://www.openbravo.com/legal/license.html
asier@16377
    13
* Software distributed under the License  is  distributed  on  an "AS IS"
asier@16377
    14
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
asier@16377
    15
* License for the specific  language  governing  rights  and  limitations
asier@16377
    16
* under the License.
asier@16377
    17
* The Original Code is Openbravo ERP.
asier@16377
    18
* The Initial Developer of the Original Code is Openbravo SLU
asier@16377
    19
* All portions are Copyright (C) 2012 Openbravo SLU
asier@16377
    20
* All Rights Reserved.
asier@16377
    21
* Contributor(s):  ______________________________________.
asier@16377
    22
************************************************************************/
asier@16377
    23
asier@16377
    24
BEGIN
asier@16377
    25
asier@16377
    26
  INSERT INTO OBUIAPP_Process_Access
asier@16377
    27
    (
asier@16377
    28
      OBUIAPP_Process_Access_ID, OBUIAPP_Process_ID, AD_Role_ID, AD_Client_ID,
asier@16377
    29
      AD_Org_ID, IsActive, Created,
asier@16377
    30
      CreatedBy, Updated, UpdatedBy
asier@16377
    31
    )
asier@16377
    32
  SELECT get_uuid(), P.OBUIAPP_Process_ID, R.AD_ROLE_ID, R.AD_CLIENT_ID,
asier@16377
    33
    R.AD_ORG_ID, 'Y', now(),
asier@16377
    34
    '0', now(), '0'
asier@16377
    35
  FROM OBUIAPP_Process P, AD_ROLE R
asier@16377
    36
  WHERE R.ISMANUAL = 'N'
asier@16377
    37
  AND P.IsActive='Y'
asier@16377
    38
    AND (
asier@16377
    39
      (R.USERLEVEL = 'S' AND P.ACCESSLEVEL IN ('4','7','6'))
asier@16377
    40
      OR
asier@16377
    41
      (R.USERLEVEL IN (' CO', ' C') AND P.ACCESSLEVEL IN ('7','6','3','1'))
asier@16377
    42
      OR
asier@16377
    43
      (R.USERLEVEL = '  O' AND P.ACCESSLEVEL IN ('3','1','7'))
asier@16377
    44
    )
asier@16377
    45
    AND NOT EXISTS (SELECT 1
asier@16377
    46
                     FROM OBUIAPP_Process_Access
asier@16377
    47
                    WHERE OBUIAPP_Process_ID = P.OBUIAPP_Process_ID
asier@16377
    48
                      AND AD_ROLE_ID = R.AD_ROLE_ID);
asier@16377
    49
END OBUIAPP_UPDATE_ACCESS
asier@16377
    50
]]></body>
asier@16377
    51
    </function>
asier@16377
    52
  </database>