Subversion Repositories DevTools

Rev

Rev 6624 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
Option explicit
Response.Expires = 0   ' always load the page, dont store
%>
<%
'=====================================================
'   _wform_change_owner_bulk.asp
'=====================================================
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/common_dbedit.asp"-->
<!--#include file="common/_popup_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
'------------ Variable Definition -------------
Dim parPvidList
Dim pvidArray
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
Set pkgInfoHash = CreateObject("Scripting.Dictionary")
parPvidList = QStrPar("pvidList")
pvidArray = Split(parPvidList,",")
'----------------------------------------------
%>
<%
Function Users_List ( )
   Users_List = _
   " SELECT usr.user_id, usr.full_name"&_
    "   FROM users usr"&_
   "  WHERE usr.IS_DISABLED IS NULL"&_
   "  ORDER BY UPPER(usr.full_name)"
End Function

'
'   Update the owner field on all packages in the pvidArray list
'        
Sub Update_Owner (NNown_id )
    Dim rsTemp, Query_String, sComments, previousOwner
    Dim pkgList
    Dim index

    '-- Get package details
    Query_String = _
    " SELECT pv.pv_id, pv.owner_id, pkg.pkg_name, pv.pkg_version"&_
    " FROM package_versions pv, packages pkg"&_
    " WHERE pv.pv_id in("& parPvidList &")"&_
    "   AND pv.pkg_id = pkg.pkg_id" &_
    "   AND pv.owner_id != " & NNown_id &_
    " ORDER by Upper(pkg.pkg_name), Upper(pv.v_ext)"

    Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
    index = 0
    While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
        
        pkgInfoHash.Add "name_" & index, rsTemp("pkg_name") &" " & rsTemp("pkg_version")
        pkgInfoHash.Add "prev_" & index, rsTemp.Fields("owner_id").Value
        pkgInfoHash.Add "pvid_" & index, rsTemp.Fields("pv_id").Value
        
        index = index+1
        rsTemp.MoveNext
    WEnd

   rsTemp.Close
   Set rsTemp = nothing

   '-- Skip if there is no actual ownership changes
   If index > 0 Then

       '-- Update database to change the owner
       objEH.TryORA ( OraSession )
       On Error Resume Next

      OraDatabase.ExecuteSQL _
         " UPDATE PACKAGE_VERSIONS pv SET "&_
         " pv.owner_id = "& NNown_id &_
         " WHERE pv.pv_id in ("& parPvidList &")"

       objEH.CatchORA ( OraSession )

       If objEH.LastOraFailed = FALSE Then
          '-- Notify new owner
          '-- Generate a single email with the list of changed packages
          index = 0
          pkgList = "You are now the owner of the following packages:<ul>"
          While pkgInfoHash.Exists( "name_" & index) 
            pkgList = pkgList & "<li>" & pkgInfoHash.Item("name_" & index) & "</li>"
            index = index+1
          Wend
          pkgList = pkgList & "</ul>"

          Call Send_Email ( "Release Manager Notification", ADMIN_EMAIL, GetUserEmail( NNown_id ), "Package Ownership notification", pkgList, NULL )

          '-- Log the changes
          index = 0
          While pkgInfoHash.Exists( "name_" & index) 
            sComments = "Changed from "& GetUsername(pkgInfoHash.Item("prev_" & index)) &" to "& GetUsername(NNown_id)
            call Log_Action ( pkgInfoHash.Item("pvid_" & index), "owner_change", sComments )

            index = index+1
          Wend

       End If
   End If
End Sub
%>
<%
'Process submition
If CBool(QStrPar("action")) AND  objAccessControl.UserLogedIn AND NiceInt(Request("own_id"),0) <> 0 Then
   Call Update_Owner ( Request("own_id") )
   Call ReloadParentWindow
   Call CloseWindow
End If
%>
<html>
<head>
<title>Release Manager</title>
<link rel="shortcut icon" href="<%=FavIcon%>"/>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="images/release_manager_style.css?ver=<%=VixVerNum%>" type="text/css">
<link rel="stylesheet" href="images/navigation.css?ver=<%=VixVerNum%>" type="text/css">
<script language="JavaScript" src="images/tipster.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/_help_tips.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
<!--#include file="_jquery_includes.asp"-->
<script type="text/javascript" charset="utf-8">
        $(document).ready(function() {
        // Tricky code ALERT
        // If we have a lot of packages to update, then we can't pass the list into the iFrame via the URL
        // The trick is:
        //      Parent: Set the list of of pvid's into a hident element
        //      iFrame: Extract the data from the parent and insert it into a hidden form field
        //              When the form is submitted, it will be POSTed and the limit is not an issue
        var pvidList = $(window.parent.document.getElementById('iframeTxData')).text();
        $('#pvidList').val(pvidList);
        $('#pvidCount').text((pvidList.split(",").length));
    });
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
<form name="chowner" method="post" action="<%=scriptName%>" class="form_tight">
  <table border="0" cellspacing="0" cellpadding="2" width="100%">
    <tr>
      <td valign="top" nowrap colspan="3" class="wform_ttl" background="images/bg_form_lightgray.gif">
        <table width="100%" border="0" cellspacing="1" cellpadding="2">
          <tr>
            <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Packages Selected</td>
            <td id='pvidCount' nowrap width="100%" background="images/bg_form_lightbluedark.gif" class="form_txt">Loading</td>
          </tr>
          <tr>
            <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Owner</td>
            <td nowrap width="100%" background="images/bg_form_lightbluedark.gif">
         <select name="own_id" class="form_item">
<%
         Dim rsUsers
         Set rsUsers = OraDatabase.DbCreateDynaset( Users_List( ), cint(0))%>
            <option value=0>- Select User -</option>
<%
         While ((NOT rsUsers.BOF) AND (NOT rsUsers.EOF))%>
                <option value="<%=rsUsers.Fields("user_id")%>"><%=rsUsers.Fields("full_name")%></option>
<%            rsUsers.MoveNext
         WEnd
         rsUsers.Close
         set rsUsers = nothing
         %>
         </select>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td align="right">
        <input id=pvidList type="hidden" name="pvidList" value="0">
        <input type="hidden" name="action" value="true">
        <input type="submit" name="btn" value="Update" class="form_btn_comp">
        <input type="reset" name="btn" value="Cancel" class="form_btn_comp" onclick="parent.closeIFrame();">
      </td>
    </tr>
  </table>
</form>
</body>
</html>
<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->