-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUnlockItem.aspx
202 lines (184 loc) · 7.51 KB
/
UnlockItem.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="Sitecore.Data" %>
<%@ Import Namespace="Sitecore.Data.Items" %>
<%@ Import Namespace="Sitecore.Globalization" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Lock/Unlock Children</title>
<style>
body {
font-family: verdana, arial, sans-serif;
}
table.table-style-three {
font-family: verdana, arial, sans-serif;
font-size: 11px;
color: #333333;
border-width: 1px;
border-color: #3A3A3A;
border-collapse: collapse;
}
table.table-style-three th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #FFA6A6;
background-color: #D56A6A;
color: #ffffff;
}
table.table-style-three tr:hover td {
cursor: pointer;
}
table.table-style-three tr:nth-child(even) td {
background-color: #F7CFCF;
}
table.table-style-three td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #FFA6A6;
background-color: #ffffff;
}
</style>
<script language="CS" runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (Sitecore.Context.User.IsAuthenticated == false)
{
Response.Redirect("login.aspx?returnUrl=UnlockItem.aspx");
}
}
protected void btnLockAll_Click(object sender, EventArgs e)
{
int i = 0;
try
{
foreach (ListItem lang in chkLang.Items)
{
if (lang.Selected)
{
Database db = Database.GetDatabase("master");
Item item = db.GetItem(txtID.Text, Language.Parse(lang.Value));
if (item.Access.CanWriteLanguage() && (!item.Locking.IsLocked()))
{
item.Editing.BeginEdit();
item.Locking.Lock();
item.Editing.EndEdit();
i++;
}
foreach (Item child in item.Axes.GetDescendants())
{
if (child.Access.CanWriteLanguage() && (!child.Locking.IsLocked()))
{
child.Editing.BeginEdit();
child.Locking.Lock();
child.Editing.EndEdit();
i++;
}
}
}
}
}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}
lblMessage.Text = "Locked total " + i + " item(s)";
}
protected void btnUnLockAll_Click(object sender, EventArgs e)
{
int i = 0;
try
{
foreach (ListItem lang in chkLang.Items)
{
if (lang.Selected)
{
Database db = Database.GetDatabase("master");
Item item = db.GetItem(txtID.Text, Language.Parse(lang.Value));
if (item.Access.CanWriteLanguage() && item.Locking.IsLocked())
{
item.Editing.BeginEdit();
item.Locking.Unlock();
item.Editing.EndEdit();
i++;
}
foreach (Item child in item.Axes.GetDescendants())
{
if (child.Access.CanWriteLanguage() && child.Locking.IsLocked())
{
child.Editing.BeginEdit();
child.Locking.Unlock();
child.Editing.EndEdit();
i++;
}
}
}
}
}
catch (Exception ex)
{
lblMessage.Text = ex.ToString();
}
lblMessage.Text = "Unlocked total " + i + " item(s)";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h2>Lock/Unlock Bulk Items</h2>
<table class="table-style-three">
<tr>
<td colspan="2" style="vertical-align: top">
Parent Item Path: <asp:TextBox ID="txtID" Width="400px" runat="server"></asp:TextBox></td>
<td style="vertical-align: top">
<asp:CheckBoxList ID="chkLang" runat="server">
<asp:ListItem Value="en">English</asp:ListItem>
<asp:ListItem Value="ar">Arabic</asp:ListItem>
<asp:ListItem Value="az">Azeri</asp:ListItem>
<asp:ListItem Value="cs">Czech</asp:ListItem>
<asp:ListItem Value="de">German</asp:ListItem>
<asp:ListItem Value="es">Spanish</asp:ListItem>
<asp:ListItem Value="fr">French</asp:ListItem>
<asp:ListItem Value="id">Indonesian</asp:ListItem>
<asp:ListItem Value="it">Italian</asp:ListItem>
<asp:ListItem Value="ja">Japanese</asp:ListItem>
<asp:ListItem Value="ko">Korean</asp:ListItem>
<asp:ListItem Value="nl">Dutch</asp:ListItem>
<asp:ListItem Value="pl">Polish</asp:ListItem>
<asp:ListItem Value="pt">Portuguese</asp:ListItem>
<asp:ListItem Value="ru">Russian</asp:ListItem>
<asp:ListItem Value="sv">Swedish</asp:ListItem>
<asp:ListItem Value="uk">Ukrainian</asp:ListItem>
<asp:ListItem Value="zh-CN">Chinese</asp:ListItem>
<asp:ListItem Value="hu">Hungarian</asp:ListItem>
<asp:ListItem Value="da">Danish</asp:ListItem>
<asp:ListItem Value="ro">Romanian</asp:ListItem>
<asp:ListItem Value="no">Norwegian</asp:ListItem>
<asp:ListItem Value="fi">Finnish</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnLockAll" runat="server" Text="Lock All" OnClick="btnLockAll_Click" /></td>
<td colspan="2">
<asp:Button ID="btnUnlockAll" runat="server" Text="Unlock All" OnClick="btnUnLockAll_Click" /></td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>