summaryrefslogtreecommitdiff
path: root/modules/system/system.module
blob: e768944e30fbda2236b9599e7bfb8284b70ea3c8 (plain)
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
<?php
// $Id$

/**
 * @file
 * Configuration system that lets administrators modify the workings of the site.
 */

/**
 * The current system version.
 */
define('VERSION', '7.0-dev');

/**
 * Core API compatibility.
 */
define('DRUPAL_CORE_COMPATIBILITY', '7.x');

/**
 * Minimum supported version of PHP.
 */
define('DRUPAL_MINIMUM_PHP',    '5.2.0');

/**
 * Minimum recommended value of PHP memory_limit.
 */
define('DRUPAL_MINIMUM_PHP_MEMORY_LIMIT',    '16M');

/**
 * Minimum supported version of MySQL, if it is used.
 */
define('DRUPAL_MINIMUM_MYSQL',  '5.0');

/**
 * Minimum supported version of PostgreSQL, if it is used.
 */
define('DRUPAL_MINIMUM_PGSQL',  '8.3');

/**
 * Maximum age of temporary files in seconds.
 */
define('DRUPAL_MAXIMUM_TEMP_FILE_AGE', 21600);

/**
 * Default interval for automatic cron executions in seconds.
 */
define('DRUPAL_CRON_DEFAULT_THRESHOLD', 10800);

/**
 * New users will be set to the default time zone at registration.
 */
define('DRUPAL_USER_TIMEZONE_DEFAULT', 0);

/**
 * New users will get an empty time zone at registration.
 */
define('DRUPAL_USER_TIMEZONE_EMPTY', 1);

/**
 * New users will select their own timezone at registration.
 */
define('DRUPAL_USER_TIMEZONE_SELECT', 2);

 /**
 * Disabled option on forms and settings
 */
define('DRUPAL_DISABLED', 0);

/**
 * Optional option on forms and settings
 */
define('DRUPAL_OPTIONAL', 1);

/**
 * Required option on forms and settings
 */
define('DRUPAL_REQUIRED', 2);

/**
 * Return only visible regions. @see system_region_list().
 */
define('REGIONS_VISIBLE', 'visible');

/**
 * Return all visible regions. @see system_region_list().
 */
define('REGIONS_ALL', 'all');


/**
 * Implement hook_help().
 */
function system_help($path, $arg) {
  global $base_url;

  switch ($path) {
    case 'admin/help#system':
      $output = '<p>' . t('The system module is at the foundation of your Drupal website, and provides basic but extensible functionality for use by other modules and themes. Some integral elements of Drupal are contained in and managed by the system module, including caching, enabling or disabling of modules and themes, preparing and displaying the administrative page, and configuring fundamental site settings. A number of key system maintenance operations are also part of the system module.') . '</p>';
      $output .= '<p>' . t('The system module provides:') . '</p>';
      $output .= '<ul><li>' . t('support for enabling and disabling <a href="@modules">modules</a>. Drupal comes packaged with a number of core modules; each module provides a discrete set of features and may be enabled depending on the needs of your site. A wide array of additional modules contributed by members of the Drupal community are available for download at the <a href="@drupal-modules">Drupal.org module page</a>.', array('@modules' => url('admin/config/modules'), '@drupal-modules' => 'http://drupal.org/project/modules')) . '</li>';
      $output .= '<li>' . t('support for enabling and disabling <a href="@themes">themes</a>, which determine the design and presentation of your site. Drupal comes packaged with several core themes and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/appearance'), '@drupal-themes' => 'http://drupal.org/project/themes')) . '</li>';
      $output .= '<li>' . t('a robust <a href="@cache-settings">caching system</a> that allows the efficient re-use of previously-constructed web pages and web page components. Drupal stores the pages requested by anonymous users in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, Drupal\'s caching system may significantly increase the speed of your site.', array('@cache-settings' => url('admin/config/development/performance'))) . '</li>';
      $output .= '<li>' . t('a set of routine administrative operations that rely on a correctly-configured <a href="@cron">cron maintenance task</a> to run automatically. A number of other modules, including the feed aggregator, and search also rely on <a href="@cron">cron maintenance tasks</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>.', array('@cron' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron')) . '</li>';
      $output .= '<li>' . t('basic configuration options for your site, including <a href="@regional-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@site-info">site name and other information</a>, and a <a href="@maintenance-mode">maintenance mode</a> for taking your site temporarily offline.', array('@regional-settings' => url('admin/config/regional/settings'), '@file-system' => url('admin/config/media/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@maintenance-mode' => url('admin/config/development/maintenance'))) . '</li></ul>';
      $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) . '</p>';
      return $output;
    case 'admin/by-module':
      return '<p>' . t('This page shows you all available administration tasks for each module.') . '</p>';
    case 'admin/appearance':
      $output = '<p>' . t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternatively, to override these settings in a specific theme, click the "configure" link for that theme. Note that different themes may have different regions available for displaying content; for consistency in presentation, you may wish to enable only one theme.') . '</p>';
      $output .= '<p>' . t('To change the appearance of your site, a number of <a href="@themes">contributed themes</a> are available.', array('@themes' => 'http://drupal.org/project/themes')) . '</p>';
      return $output;
    case 'admin/appearance/settings/' . $arg[4]:
      $reference = explode('.', $arg[4], 2);
      $theme = array_pop($reference);
      return '<p>' . t('These options control the display settings for the <code>%template</code> theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the <a href="@global">global settings</a> for this theme.', array('%template' => $theme, '@global' => url('admin/appearance/settings'))) . '</p>';
    case 'admin/appearance/settings':
      return '<p>' . t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') . '</p>';
    case 'admin/config/modules':
      $output = '<p>' . t('Modules are plugins that extend Drupal\'s core functionality. To further extend your site\'s functionality, a number of <a href="@modules">contributed modules</a> are available for download.', array('@permissions' => url('admin/config/people/permissions'), '@modules' => 'http://drupal.org/project/modules')) . '</p>';
      $output .= '<p>' . t('Module-related tasks can be located on the <a href="@by-module">administration by module page</a>. New <a href="@permissions">module-related permissions</a> may also become available as new modules are enabled.', array('@by-module' => url('admin/by-module'), '@permissions' => url('admin/config/people/permissions'))) . '</p>';
      $output .= '<p>' . t('Each time a module is updated, it is important that <a href="@update-php">update.php</a> is run. To help manage the update process, the <em>Update status</em> module, if enabled, provides <a href="@updates">information on new versions of modules (and themes)</a> as they are released. Regular review of the <a href="@updates">available updates page</a> is essential to maintaining a secure and current site.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '</p>';
      return $output;
    case 'admin/config/modules/uninstall':
      return '<p>' . t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it on the main <a href="@modules">modules page</a>. Not all modules support this feature.', array('@modules' => url('admin/config/modules'))) . '</p>';
    case 'admin/structure/block/configure':
      if ($arg[4] == 'system' && $arg[5] == 'powered-by') {
        return '<p>' . t('The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') . '</p>';
      }
      break;
    case 'admin/config/development/maintenance':
      global $user;
      if ($user->uid == 1) {
        return '<p>' . t('If you are upgrading to a newer version of Drupal or upgrading contributed modules or themes you may need to run !update-php.', array('!update-php' => l('update.php', 'update.php'))) . '</p>';
      }
    case 'admin/settings/actions':
    case 'admin/settings/actions/manage':
      $output = '<p>' . t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the trigger module, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions.') . '</p>';
      $output .= '<p>' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions can do more than simple actions; for example, send an e-mail to a specified address, or check for certain words within a piece of content. These actions need to be created and configured first before they may be used. To create an advanced action, select the action from the drop-down below and click the <em>Create</em> button.') . '</p>';
      if (module_exists('trigger')) {
        $output .= '<p>' . t('You may proceed to the <a href="@url">Triggers</a> page to assign these actions to system events.', array('@url' => url('admin/structure/trigger'))) . '</p>';
      }
      return $output;
    case 'admin/settings/actions/configure':
      return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").');
    case 'admin/settings/ip-blocking':
      return '<p>' . t('IP addresses listed here are blocked from your site before any modules are loaded. You may add IP addresses to the list, or delete existing entries.') . '</p>';
    case 'admin/reports/status':
      return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") . '</p>';
  }
}

/**
 * Implement hook_theme().
 */
function system_theme() {
  return array_merge(drupal_common_theme(), array(
    'system_themes_form' => array(
      'arguments' => array('form' => NULL),
      'file' => 'system.admin.inc',
    ),
    'system_modules_fieldset' => array(
      'arguments' => array('form' => NULL),
      'file' => 'system.admin.inc',
    ),
    'system_modules_incompatible' => array(
      'arguments' => array('message' => NULL),
      'file' => 'system.admin.inc',
    ),
    'system_modules_uninstall' => array(
      'arguments' => array('form' => NULL),
      'file' => 'system.admin.inc',
    ),
    'status_report' => array(
      'arguments' => array('requirements' => NULL),
      'file' => 'system.admin.inc',
    ),
    'admin_page' => array(
      'arguments' => array('blocks' => NULL),
      'file' => 'system.admin.inc',
    ),
    'admin_block' => array(
      'arguments' => array('block' => NULL),
      'file' => 'system.admin.inc',
    ),
    'admin_block_content' => array(
      'arguments' => array('content' => NULL),
      'file' => 'system.admin.inc',
    ),
    'system_admin_by_module' => array(
      'arguments' => array('menu_items' => NULL),
      'file' => 'system.admin.inc',
    ),
    'system_powered_by' => array(
      'arguments' => array('image_path' => NULL),
    ),
    'meta_generator_html' => array(
      'arguments' => array('version' => NULL),
    ),
    'meta_generator_header' => array(
      'arguments' => array('version' => NULL),
    ),
    'system_compact_link' => array(),
    'system_run_cron_image' => array(
      'arguments' => array('image_path' => NULL),
    ),
  ));
}

/**
 * Implement hook_permission().
 */
function system_permission() {
  return array(
    'administer site configuration' => array(
      'title' => t('Administer site configuration'),
      'description' => t('Configure site-wide settings such as module or theme administration settings.'),
    ),
    'administer actions' => array(
      'title' => t('Administer actions'),
      'description' => t('Manage the actions defined for your site.'),
    ),
    'administer files' => array(
      'title' => t('Administer files'),
      'description' => t('Manage user-uploaded files.'),
    ),
    'access administration pages' => array(
      'title' => t('Access administration pages'),
      'description' => t('View the administration panel and browse the help system.'),
    ),
    'access site reports' => array(
      'title' => t('Access site reports'),
      'description' => t('View reports from system logs and other status information.'),
    ),
    'select different theme' => array(
      'title' => t('Select different theme'),
      'description' => t('Select a theme other than the default theme set by the site administrator.'),
    ),
    'block IP addresses' => array(
      'title' => t('Block IP addresses'),
      'description' => t('Block IP addresses from accessing your site.'),
    ),
  );
}

/**
 * Implement hook_rdf_namespaces().
 */
function system_rdf_namespaces() {
  return array(
    'admin'    => 'http://webns.net/mvcb/',
    'content'  => 'http://purl.org/rss/1.0/modules/content/',
    'dc'       => 'http://purl.org/dc/elements/1.1/',
    'dcterms'  => 'http://purl.org/dc/terms/',
    'foaf'     => 'http://xmlns.com/foaf/0.1/',
    'owl'      => 'http://www.w3.org/2002/07/owl#',
    'rdf'      => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
    'rdfs'     => 'http://www.w3.org/2000/01/rdf-schema#',
    'rss'      => 'http://purl.org/rss/1.0/',
    'sioc'     => 'http://rdfs.org/sioc/ns#',
    'xsd'      => 'http://www.w3.org/2001/XMLSchema',
  );
}

/**
 * Implement hook_elements().
 */
function system_elements() {
  // Top level form
  $type['form'] = array(
    '#method' => 'post',
    '#action' => request_uri(),
    '#theme_wrappers' => array('form'),
  );

  $type['page'] = array(
    '#show_messages' => TRUE,
    '#show_blocks' => TRUE,
    '#theme' => 'page',
  );

  $type['list'] = array(
    '#title' => '',
    '#list_type' => 'ul',
    '#attributes' => array(),
    '#items' => array(),
  );

  /**
   * Input elements.
   */
  $type['submit'] = array(
    '#input' => TRUE,
    '#name' => 'op',
    '#button_type' => 'submit',
    '#executes_submit_callback' => TRUE,
    '#process' => array('ajax_process_form'),
    '#theme_wrappers' => array('button'),
  );

  $type['button'] = array(
    '#input' => TRUE,
    '#name' => 'op',
    '#button_type' => 'submit',
    '#executes_submit_callback' => FALSE,
    '#process' => array('ajax_process_form'),
    '#theme_wrappers' => array('button'),
  );

  $type['image_button'] = array(
    '#input' => TRUE,
    '#button_type' => 'submit',
    '#executes_submit_callback' => TRUE,
    '#process' => array('ajax_process_form'),
    '#return_value' => TRUE,
    '#has_garbage_value' => TRUE,
    '#src' => NULL,
    '#theme_wrappers' => array('image_button'),
  );

  $type['textfield'] = array(
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 128,
    '#autocomplete_path' => FALSE,
    '#process' => array('form_process_text_format', 'ajax_process_form'),
    '#theme' => 'textfield',
    '#theme_wrappers' => array('form_element'),
  );

  $type['password'] = array(
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 128,
    '#process' => array('ajax_process_form'),
    '#theme' => 'password',
    '#theme_wrappers' => array('form_element'),
  );

  $type['password_confirm'] = array(
    '#input' => TRUE,
    '#process' => array('form_process_password_confirm'),
    '#theme_wrappers' => array('form_element'),
  );

  $type['textarea'] = array(
    '#input' => TRUE,
    '#cols' => 60,
    '#rows' => 5,
    '#resizable' => TRUE,
    '#process' => array('form_process_text_format', 'ajax_process_form'),
    '#theme' => 'textarea',
    '#theme_wrappers' => array('form_element'),
  );

  $type['radios'] = array(
    '#input' => TRUE,
    '#process' => array('form_process_radios'),
    '#theme_wrappers' => array('radios'),
    '#pre_render' => array('form_pre_render_conditional_form_element'),
  );

  $type['radio'] = array(
    '#input' => TRUE,
    '#default_value' => NULL,
    '#process' => array('ajax_process_form'),
    '#theme' => 'radio',
    '#theme_wrappers' => array('form_element'),
    '#form_element_skip_title' => TRUE,
  );

  $type['checkboxes'] = array(
    '#input' => TRUE,
    '#tree' => TRUE,
    '#process' => array('form_process_checkboxes'),
    '#theme_wrappers' => array('checkboxes'),
    '#pre_render' => array('form_pre_render_conditional_form_element'),
  );

  $type['checkbox'] = array(
    '#input' => TRUE,
    '#return_value' => 1,
    '#process' => array('ajax_process_form'),
    '#theme' => 'checkbox',
    '#theme_wrappers' => array('form_element'),
    '#form_element_skip_title' => TRUE,
  );

  $type['select'] = array(
    '#input' => TRUE,
    '#size' => 0,
    '#multiple' => FALSE,
    '#process' => array('ajax_process_form'),
    '#theme' => 'select',
    '#theme_wrappers' => array('form_element'),
  );

  $type['weight'] = array(
    '#input' => TRUE,
    '#delta' => 10,
    '#default_value' => 0,
    '#process' => array('form_process_weight', 'ajax_process_form'),
  );

  $type['date'] = array(
    '#input' => TRUE,
    '#element_validate' => array('date_validate'),
    '#process' => array('form_process_date'),
    '#theme' => 'date',
    '#theme_wrappers' => array('form_element'),
  );

  $type['file'] = array(
    '#input' => TRUE,
    '#size' => 60,
    '#theme' => 'file',
    '#theme_wrappers' => array('form_element'),
  );

  $type['tableselect'] = array(
    '#input' => TRUE,
    '#js_select' => TRUE,
    '#multiple' => TRUE,
    '#process' => array('form_process_tableselect'),
    '#options' => array(),
    '#empty' => '',
    '#theme' => 'tableselect'
  );

  /**
   * Form structure.
   */
  $type['item'] = array(
    '#markup' => '',
    '#theme' => 'markup',
    '#theme_wrappers' => array('form_element'),
  );

  $type['hidden'] = array(
    '#input' => TRUE,
    '#process' => array('ajax_process_form'),
    '#theme' => 'hidden',
  );

  $type['value'] = array(
    '#input' => TRUE,
  );

  $type['markup'] = array(
    '#markup' => '',
    '#theme' => 'markup',
  );

  $type['fieldset'] = array(
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#value' => NULL,
    '#process' => array('form_process_fieldset', 'ajax_process_form'),
    '#pre_render' => array('form_pre_render_fieldset'),
    '#theme_wrappers' => array('fieldset'),
  );

  $type['vertical_tabs'] = array(
    '#theme_wrappers' => array('vertical_tabs'),
    '#default_tab' => '',
    '#process' => array('form_process_vertical_tabs'),
  );

  $type['token'] = array(
    '#input' => TRUE,
    '#theme' => array('hidden'),
  );

  return $type;
}

/**
 * Implement hook_menu().
 */
function system_menu() {
  $items['system/files'] = array(
    'title' => 'File download',
    'page callback' => 'file_download',
    'page arguments' => array('private'),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['system/temporary'] = array(
    'title' => 'Temporary files',
    'page callback' => 'file_download',
    'page arguments' => array('temporary'),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['system/ajax'] = array(
    'title' => 'AHAH callback',
    'page callback' => 'ajax_form_callback',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['system/timezone'] = array(
    'title' => 'Time zone',
    'page callback' => 'system_timezone',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['system/run-cron-image'] = array(
    'title' => 'Execute cron',
    'page callback' => 'system_run_cron_image',
    'access callback' => 'system_run_cron_image_access',
    'type' => MENU_CALLBACK,
  );
  $items['admin'] = array(
    'title' => 'Administer',
    'access arguments' => array('access administration pages'),
    'page callback' => 'system_main_admin_page',
    'weight' => 9,
    'menu_name' => 'management',
  );
  $items['admin/compact'] = array(
    'title' => 'Compact mode',
    'page callback' => 'system_admin_compact_page',
    'access arguments' => array('access administration pages'),
    'type' => MENU_CALLBACK,
  );
  $items['admin/by-task'] = array(
    'title' => 'By task',
    'page callback' => 'system_main_admin_page',
    'access arguments' => array('access administration pages'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['admin/by-module'] = array(
    'title' => 'By module',
    'page callback' => 'system_admin_by_module',
    'access arguments' => array('access administration pages'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
  );

  // Menu items that are basically just menu blocks.
  $items['admin/settings'] = array(
    'title' => 'Site configuration',
    'description' => 'Configure site settings.',
    'position' => 'right',
    'weight' => -2,
    'page callback' => 'system_settings_overview',
    'access callback' => 'system_admin_menu_block_access',
    'access arguments' => array('admin/settings', 'access administration pages'),
  );
  $items['admin/structure'] = array(
    'title' => 'Structure',
    'description' => 'Control how your site looks and feels.',
    'position' => 'right',
    'weight' => -8,
    'page callback' => 'system_admin_menu_block_page',
    'access callback' => 'system_admin_menu_block_access',
    'access arguments' => array('admin/structure', 'access administration pages'),
  );
  // Appearance.
  $items['admin/appearance'] = array(
    'title' => 'Appearance',
    'description' => 'Select and configure your site theme.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_themes_form'),
    'access arguments' => array('administer site configuration'),
    'position' => 'left',
    'weight' => -6,
  );
  $items['admin/appearance/select'] = array(
    'title' => 'List',
    'description' => 'Select the default theme for your site.',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -1,
  );
  $items['admin/appearance/settings'] = array(
    'title' => 'Configure',
    'page arguments' => array('system_theme_settings'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_LOCAL_TASK,
  );
  // Theme configuration subtabs.
  $items['admin/appearance/settings/global'] = array(
    'title' => 'Global settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -1,
  );

  foreach (list_themes() as $theme) {
    $items['admin/appearance/settings/' . $theme->name] = array(
      'title' => $theme->info['name'],
      'page arguments' => array('system_theme_settings', $theme->name),
      'type' => MENU_LOCAL_TASK,
      'access callback' => '_system_themes_access',
      'access arguments' => array($theme),
    );
  }

  // Configuration and modules.
  $items['admin/config'] = array(
    'title' => 'Configuration and modules',
    'page callback' => 'system_admin_config_page',
    'access arguments' => array('access administration pages'),
  );
  $items['admin/config/config'] = array(
    'title' => 'Configuration',
    'access arguments' => array('administer site configuration'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/config/modules'] = array(
    'title' => 'Modules',
    'description' => 'Enable or disable add-on modules for your site.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_modules'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );
  $items['admin/config/modules/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['admin/config/modules/list/confirm'] = array(
    'title' => 'List',
    'access arguments' => array('administer site configuration'),
    'type' => MENU_CALLBACK,
  );
  $items['admin/config/modules/uninstall'] = array(
    'title' => 'Uninstall',
    'page arguments' => array('system_modules_uninstall'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/config/modules/uninstall/confirm'] = array(
    'title' => 'Uninstall',
    'access arguments' => array('administer site configuration'),
    'type' => MENU_CALLBACK,
  );

  // Actions.
  $items['admin/settings/actions'] = array(
    'title' => 'Actions',
    'description' => 'Manage the actions defined for your site.',
    'access arguments' => array('administer actions'),
    'page callback' => 'system_actions_manage'
  );
  $items['admin/settings/actions/manage'] = array(
    'title' => 'Manage actions',
    'description' => 'Manage the actions defined for your site.',
    'page callback' => 'system_actions_manage',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -2,
  );
  $items['admin/settings/actions/configure'] = array(
    'title' => 'Configure an advanced action',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_actions_configure'),
    'access arguments' => array('administer actions'),
    'type' => MENU_CALLBACK,
  );
  $items['admin/settings/actions/delete/%actions'] = array(
    'title' => 'Delete action',
    'description' => 'Delete an action.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_actions_delete_form', 4),
    'access arguments' => array('administer actions'),
    'type' => MENU_CALLBACK,
  );
  $items['admin/settings/actions/orphan'] = array(
    'title' => 'Remove orphans',
    'page callback' => 'system_actions_remove_orphans',
    'access arguments' => array('administer actions'),
    'type' => MENU_CALLBACK,
  );

  // IP address blocking.
  $items['admin/settings/ip-blocking'] = array(
    'title' => 'IP address blocking',
    'description' => 'Manage blocked IP addresses.',
    'page callback' => 'system_ip_blocking',
    'access arguments' => array('block IP addresses'),
  );
  $items['admin/settings/ip-blocking/%'] = array(
    'title' => 'IP address blocking',
    'description' => 'Manage blocked IP addresses.',
    'page callback' => 'system_ip_blocking',
    'access arguments' => array('block IP addresses'),
    'type' => MENU_CALLBACK,
  );
  $items['admin/settings/ip-blocking/delete/%blocked_ip'] = array(
    'title' => 'Delete IP address',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_ip_blocking_delete', 4),
    'access arguments' => array('block IP addresses'),
    'type' => MENU_CALLBACK,
  );

  // Configuration.
  $items['admin/config/development'] = array(
   'title' => 'Development',
   'description' => 'Development tools.',
   'position' => 'left',
   'weight' => 10,
   'page callback' => 'system_admin_menu_block_page',
   'access callback' => 'system_admin_menu_block_access',
   'access arguments' => array('admin/config/development', 'access administration pages'),
  );
  $items['admin/config/development/maintenance'] = array(
    'title' => 'Maintenance mode',
    'description' => 'Take the site offline for maintenance or bring it back online.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_site_maintenance_mode'),
    'access arguments' => array('administer site configuration'),
  );
  $items['admin/config/development/performance'] = array(
    'title' => 'Performance',
    'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_performance_settings'),
    'access arguments' => array('administer site configuration'),
  );
  $items['admin/config/media'] = array(
   'title' => 'Media',
   'description' => 'Media tools.',
   'position' => 'left',
   'weight' => 10,
   'page callback' => 'system_admin_menu_block_page',
   'access callback' => 'system_admin_menu_block_access',
   'access arguments' => array('admin/config/media', 'access administration pages'),
  );
  $items['admin/config/media/file-system'] = array(
    'title' => 'File-system',
    'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_file_system_settings'),
    'access arguments' => array('administer site configuration'),
  );
    $items['admin/config/media/image-toolkit'] = array(
    'title' => 'Image toolkit',
    'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_image_toolkit_settings'),
    'access arguments' => array('administer site configuration'),
  );
    $items['admin/config/development/logging'] = array(
    'title' => 'Logging and errors',
    'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.",
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_logging_settings'),
    'access arguments' => array('administer site configuration'),
  );
  $items['admin/config/regional'] = array(
   'title' => 'Regional and language',
   'description' => 'Regional settings, localization and translation.',
   'position' => 'left',
   'weight' => -7,
   'page callback' => 'system_admin_menu_block_page',
   'access callback' => 'system_admin_menu_block_access',
   'access arguments' => array('admin/config/regional', 'access administration pages'),
  );
  $items['admin/config/regional/settings'] = array(
    'title' => 'Regional settings',
    'description' => "Settings for how Drupal displays date and time, as well as the system's default time zone.",
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_regional_settings'),
    'access arguments' => array('administer site configuration'),
    'weight' => -10,
  );
  $items['admin/config/regional/settings/lookup'] = array(
    'title' => 'Date and time lookup',
    'type' => MENU_CALLBACK,
    'page callback' => 'system_date_time_lookup',
    'access arguments' => array('administer site configuration'),
  );
  
  // Settings.
  $items['admin/settings/site-information'] = array(
    'title' => 'Site information',
    'description' => 'Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_site_information_settings'),
    'access arguments' => array('administer site configuration'),
  );
  $items['admin/settings/rss-publishing'] = array(
    'title' => 'RSS publishing',
    'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_rss_feeds_settings'),
    'access arguments' => array('administer site configuration'),
  );
  $items['admin/settings/clean-urls'] = array(
    'title' => 'Clean URLs',
    'description' => 'Enable or disable clean URLs for your site.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_clean_url_settings'),
    'access arguments' => array('administer site configuration'),
  );
  $items['admin/settings/clean-urls/check'] = array(
    'title' => 'Clean URL check',
    'page callback' => 'drupal_json',
    'page arguments' => array(array('status' => TRUE)),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

  // Reports.
  $items['admin/reports'] = array(
    'title' => 'Reports',
    'description' => 'View reports from system logs and other status information.',
    'page callback' => 'system_admin_menu_block_page',
    'access callback' => 'system_admin_menu_block_access',
    'access arguments' => array('admin/reports', 'access site reports'),
    'weight' => 5,
    'position' => 'left',
  );
  $items['admin/reports/status'] = array(
    'title' => 'Status report',
    'description' => "Get a status report about your site's operation and any detected problems.",
    'page callback' => 'system_status',
    'weight' => 10,
    'access arguments' => array('administer site configuration'),
  );
  $items['admin/reports/status/run-cron'] = array(
    'title' => 'Run cron',
    'page callback' => 'system_run_cron',
    'access arguments' => array('administer site configuration'),
    'type' => MENU_CALLBACK,
  );
  $items['admin/reports/status/php'] = array(
    'title' => 'PHP',
    'page callback' => 'system_php',
    'access arguments' => array('administer site configuration'),
    'type' => MENU_CALLBACK,
  );
  // Default page for batch operations.
  $items['batch'] = array(
    'page callback' => 'system_batch_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implementation of hook_library().
 */
function system_library() {
  // jQuery.
  $libraries['jquery'] = array(
    'title' => 'jQuery',
    'website' => 'http://jquery.com',
    'version' => '1.3.2',
    'js' => array(
      'misc/jquery.js' => array('weight' => JS_LIBRARY - 20),
    ),
  );

  // jQuery Form Plugin.
  $libraries['form'] = array(
    'title' => 'jQuery Form Plugin',
    'website' => 'http://malsup.com/jquery/form/',
    'version' => '2.16',
    'js' => array(
      'misc/jquery.form.js' => array(),
    ),
  );

  // Farbtastic.
  $libraries['farbtastic'] = array(
    'title' => 'Farbtastic',
    'website' => 'http://code.google.com/p/farbtastic/',
    'version' => '1.2',
    'js' => array(
      'misc/farbtastic/farbtastic.js' => array(),
    ),
    'css' => array(
      'misc/farbtastic/farbtastic.css' => array('preprocess' => FALSE),
    ),
  );

  // Cookie.
  $libraries['cookie'] = array(
    'title' => 'Cookie',
    'website' => 'http://plugins.jquery.com/project/cookie',
    'version' => '1.0',
    'js' => array(
      'misc/jquery.cookie.js' => array(),
    ),
  );

  // jQuery UI.
  $libraries['ui'] = array(
    'title' => 'jQuery UI: Core',
    'website' => 'http://jqueryui.com',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.core.js' => array('weight' => JS_LIBRARY - 10),
    ),
    'css' => array(
      'misc/ui/ui.core.css' => array(),
      'misc/ui/ui.theme.css' => array(),
    ),
  );
  $libraries['ui.accordion'] = array(
    'title' => 'jQuery UI: Accordion',
    'website' => 'http://jqueryui.com/demos/accordion/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.accordion.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.accordion.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.datepicker'] = array(
    'title' => 'jQuery UI: Date Picker',
    'website' => 'http://jqueryui.com/demos/datepicker/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.datepicker.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.datepicker.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.dialog'] = array(
    'title' => 'jQuery UI: Dialog',
    'website' => 'http://jqueryui.com/demos/dialog/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.dialog.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.dialog.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.draggable'] = array(
    'title' => 'jQuery UI: Dialog',
    'website' => 'http://jqueryui.com/demos/draggable/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.draggable.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.droppable'] = array(
    'title' => 'jQuery UI: Droppable',
    'website' => 'http://jqueryui.com/demos/droppable/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.droppable.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
      array('system', 'ui.draggable'),
    ),
  );
  $libraries['ui.progressbar'] = array(
    'title' => 'jQuery UI: Progress Bar',
    'website' => 'http://jqueryui.com/demos/progressbar/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.progressbar.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.progressbar.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.resizable'] = array(
    'title' => 'jQuery UI: Resizable',
    'website' => 'http://jqueryui.com/demos/resizable/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.resizable.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.resizable.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.selectable'] = array(
    'title' => 'jQuery UI: Selectable',
    'website' => 'http://jqueryui.com/demos/selectable/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.selectable.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.selectable.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.slider'] = array(
    'title' => 'jQuery UI: Slider',
    'website' => 'http://jqueryui.com/demos/slider/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.slider.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.slider.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.sortable'] = array(
    'title' => 'jQuery UI: Sortable',
    'website' => 'http://jqueryui.com/demos/sortable/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.sortable.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['ui.tabs'] = array(
    'title' => 'jQuery UI: Tabs',
    'website' => 'http://jqueryui.com/demos/tabs/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/ui.tabs.js' => array(),
    ),
    'css' => array(
      'misc/ui/ui.tabs.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['effects'] = array(
    'title' => 'jQuery UI: Effects',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.core.js' => array('weight' => JS_LIBRARY - 9),
    ),
    'dependencies' => array(
      array('system', 'ui'),
    ),
  );
  $libraries['effects.blind'] = array(
    'title' => 'jQuery UI: Effects Blind',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.blind.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.bounce'] = array(
    'title' => 'jQuery UI: Effects Bounce',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.bounce.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.clip'] = array(
    'title' => 'jQuery UI: Effects Clip',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.clip.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.drop'] = array(
    'title' => 'jQuery UI: Effects Drop',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.drop.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.explode'] = array(
    'title' => 'jQuery UI: Effects Explode',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.explode.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.fold'] = array(
    'title' => 'jQuery UI: Effects Fold',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.fold.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.highlight'] = array(
    'title' => 'jQuery UI: Effects Fold',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.highlight.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.pulsate'] = array(
    'title' => 'jQuery UI: Effects Pulsate',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.pulsate.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.scale'] = array(
    'title' => 'jQuery UI: Effects Pulsate',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.scale.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.shake'] = array(
    'title' => 'jQuery UI: Effects Shake',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.scale.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.slide'] = array(
    'title' => 'jQuery UI: Effects Slide',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.slide.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );
  $libraries['effects.transfer'] = array(
    'title' => 'jQuery UI: Effects Transfer',
    'website' => 'http://jqueryui.com/demos/effect/',
    'version' => '1.7.2',
    'js' => array(
      'misc/ui/effects.transfer.js' => array(),
    ),
    'dependencies' => array(
      array('system', 'effects'),
    ),
  );

  return $libraries;
}

/**
 * Implement hook_stream_wrappers().
 */
function system_stream_wrappers() {
  return array(
    'public' => array(
      'name' => t('Public files'),
      'class' => 'DrupalPublicStreamWrapper',
      'description' => t('Public local files served by the webserver.'),
    ),
    'private' => array(
      'name' => t('Private files'),
      'class' => 'DrupalPrivateStreamWrapper',
      'description' => t('Private local files served by Drupal.'),
    ),
    'temporary' => array(
      'name' => t('Temporary files'),
      'class' => 'DrupalTemporaryStreamWrapper',
      'description' => t('Temporary local files for upload and previews.'),
    )
  );
}

/**
 * Retrieve a blocked IP address from the database.
 *
 * @param $iid integer
 *   The ID of the blocked IP address to retrieve.
 *
 * @return
 *   The blocked IP address from the database as an array.
 */
function blocked_ip_load($iid) {
  return db_query("SELECT * FROM {blocked_ips} WHERE iid = :iid", array(':iid' => $iid))->fetchAssoc();
}

/**
 * Menu item access callback - only admin or enabled themes can be accessed.
 */
function _system_themes_access($theme) {
  return user_access('administer site configuration') && ($theme->status || $theme->name == variable_get('admin_theme', 0));
}

/**
 * Menu item access callback - hides empty system settings overview pages.
 *
 * @param $path
 *   The path of the menu item to check for child menu entries.
 * @param $string
 *   The permission, such as "administer nodes", being checked for.
 * @return
 *   Boolean TRUE if the current user has the requested permission and the
 *   current menu item has children.
 */
function system_admin_menu_block_access($path, $permission) {
  if (!user_access($permission)) {
    return FALSE;
  }
  $content = system_admin_menu_block(array('path' => $path));
  return !empty($content);
}

/**
 * Implement hook_filetransfer_backends().
 */
function system_filetransfer_backends() {
  $backends = array();

  //This is the default, will be available on most systems
  if (function_exists('ftp_connect')) {
    $backends['ftp_extension'] = array(
      'title' => t('FTP'),
      'class' => 'FileTransferFTPExtension',
      'settings_form' => 'system_filetransfer_backend_form_ftp',
      'weight' => 0,
    );
  }
  
  if (ini_get('allow_url_fopen')) {
    $backends['ftp_wrapper'] = array(
      'title' => t('FTP using file streams'),
      'class' => 'FileTransferFTPWrapper',
      'settings_form' => 'system_filetransfer_backend_form_ftp',
      'weight' => 10,
    );
  }
  
  // SSH2 lib connection is only available if the proper PHP extension is
  // installed.
  if (function_exists('ssh2_connect')) {
    $backends['ssh'] = array(
      'title' => t('SSH'),
      'class' => 'FileTransferSSH',
      'settings_form' => 'system_filetransfer_backend_form_ssh',
      'weight' => 20,
    );
  }
  return $backends;
}

/**
 *  Helper function to return a form for configuring a filetransfer backend.
 *
 * @param string $filetransfer_backend_name
 *   The name of the backend to return a form for.
 *
 * @param string $defaults
 *   An associative array of settings to pre-populate the form with.
 */
function system_get_filetransfer_settings_form($filetransfer_backend_name, $defaults) {
  $available_backends = module_invoke_all('filetransfer_backends');
  $form = call_user_func($available_backends[$filetransfer_backend_name]['settings_form']);
  
  foreach ($form as $name => &$element) {
    if (isset($defaults[$name])) {
      $element['#default_value'] = $defaults[$name];
    }
  }
  return $form;
}

/**
 * Returns the form to configure the filetransfer class for FTP
 */
function system_filetransfer_backend_form_ftp() {
  $form = _system_filetransfer_backend_form_common();
  $form['port']['#default_value'] = 21;
  return $form;
}

/**
 * Returns the form to configure the filetransfer class for SSH
 */
function system_filetransfer_backend_form_ssh() {
  $form = _system_filetransfer_backend_form_common();
  $form['port']['#default_value'] = 22;
  return $form;
}

/**
 * Helper function because SSH and FTP backends share the same elements
 */
function _system_filetransfer_backend_form_common() {
  $form = array();
  
  $form['hostname'] = array (
    '#type' => 'textfield',
    '#title' => t('Host'),
    '#default_value' => 'localhost',
  );
  
  $form['port'] = array (
    '#type' => 'textfield',
    '#title' => t('Port'),
    '#default_value' => NULL,
  );
  
  $form['username'] = array (
    '#type' => 'textfield',
    '#title' => t('Username'),
  );
  
  $form['password'] = array (
    '#type' => 'password',
    '#title' => t('Password'),
    '#description' => t('This is not saved in the database and is only used to test the connection'),
  );
  
  return $form;
}

/**
 * Implement hook_init().
 */
function system_init() {
  // Use the administrative theme if the user is looking at a page in the admin/* path.
  if (arg(0) == 'admin' || (variable_get('node_admin_theme', '0') && arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit'))) {
    global $custom_theme;
    $custom_theme = variable_get('admin_theme', 0);
    drupal_add_css(drupal_get_path('module', 'system') . '/admin.css', array('weight' => CSS_SYSTEM));
  }

  // Add the CSS for this module.
  drupal_add_css(drupal_get_path('module', 'system') . '/defaults.css', array('weight' => CSS_SYSTEM));
  drupal_add_css(drupal_get_path('module', 'system') . '/system.css', array('weight' => CSS_SYSTEM));
  drupal_add_css(drupal_get_path('module', 'system') . '/system-menus.css', array('weight' => CSS_SYSTEM));


  // Ignore slave database servers for this request.
  //
  // In Drupal's distributed database structure, new data is written to the master
  // and then propagated to the slave servers.  This means there is a lag
  // between when data is written to the master and when it is available on the slave.
  // At these times, we will want to avoid using a slave server temporarily.
  // For example, if a user posts a new node then we want to disable the slave
  // server for that user temporarily to allow the slave server to catch up.
  // That way, that user will see their changes immediately while for other
  // users we still get the benefits of having a slave server, just with slightly
  // stale data.  Code that wants to disable the slave server should use the
  // db_set_ignore_slave() function to set $_SESSION['ignore_slave_server'] to
  // the timestamp after which the slave can be re-enabled.
  if (isset($_SESSION['ignore_slave_server'])) {
    if ($_SESSION['ignore_slave_server'] >= REQUEST_TIME) {
      Database::ignoreTarget('default', 'slave');
    }
    else {
      unset($_SESSION['ignore_slave_server']);
    }
  }
}

/**
 * Implement MODULE_preprocess_HOOK().
 */
function system_preprocess_page(&$variables) {
  // Get the major version
  list($version, ) = explode('.', VERSION);

  // Emit the META tag in the HTML HEAD section
  theme('meta_generator_html', $version);

  // Emit the HTTP Header too
  theme('meta_generator_header', $version);

  $variables['head'] = drupal_get_html_head();
}

/**
 * Implement hook_user_form().
 */
function system_user_form(&$edit, $account, $category) {
  if ($category == 'account') {
    if (variable_get('configurable_timezones', 1)) {
      system_user_timezone($edit, $form);
    }
    return $form;
  }
}

/**
 * Implement hook_user_register().
 */
function system_user_register(&$edit, $account, $category) {
  if (variable_get('configurable_timezones', 1)) {
    $form = array();
    if (variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) {
      system_user_timezone($edit, $form);
    }
    else {
      $form['account']['timezone'] = array(
        '#type' => 'hidden',
        '#value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) ? '' : variable_get('date_default_timezone', ''),
      );
    }
    return $form;
  }
}

/**
 * Implement hook_user_login().
 */
function system_user_login(&$edit, $account) {
  // If the user has a NULL time zone, notify them to set a time zone.
  if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
    drupal_set_message(t('Please configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
  }
}

/**
 * Add the time zone field to the user edit and register forms.
 */
function system_user_timezone(&$edit, &$form) {
  global $user;
  $form['timezone'] = array(
    '#type' => 'fieldset',
    '#title' => t('Locale settings'),
    '#weight' => 6,
    '#collapsible' => TRUE,
  );
  $form['timezone']['timezone'] = array(
    '#type' => 'select',
    '#title' => t('Time zone'),
    '#default_value' => $edit['timezone'] ? $edit['timezone'] : ($edit['uid'] == $user->uid ? variable_get('date_default_timezone', '') : ''),
    '#options' => system_time_zones(($edit['uid'] != $user->uid)),
    '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
  );
  if (!$edit['timezone'] && $edit['uid'] == $user->uid) {
    $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Please confirm the selection and click save.');
    $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
    drupal_add_js('misc/timezone.js');
  }
}

/**
 * Implement hook_block_list().
 */
function system_block_list() {
  $blocks['main'] = array(
    'info' => t('Main page content'),
     // Cached elsewhere.
    'cache' => BLOCK_NO_CACHE,
  );
  $blocks['powered-by'] = array(
    'info' => t('Powered by Drupal'),
    'weight' => '10',
    'cache' => BLOCK_NO_CACHE,
  );
  $blocks['help'] = array(
    'info' => t('System help'),
    'weight' => '5',
  );
  // System-defined menu blocks.
  foreach (menu_list_system_menus() as $menu_name => $title) {
    $blocks[$menu_name]['info'] = t($title);
    // Menu blocks can't be cached because each menu item can have
    // a custom access callback. menu.inc manages its own caching.
    $blocks[$menu_name]['cache'] = BLOCK_NO_CACHE;
  }
  return $blocks;
}

/**
 * Implement hook_block_configure().
 */
function system_block_configure($delta = '') {
  if ($delta == 'powered-by') {
    $image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png';
    drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
    // Compile a list of fields to show
    $form['wrapper']['color'] = array(
      '#type' => 'select',
      '#title' => t('Badge color'),
      '#default_value' => variable_get('drupal_badge_color', 'powered-blue'),
      '#options' => array('powered-black' => t('Black'), 'powered-blue' => t('Blue'), 'powered-gray' => t('Gray')),
    );
    $form['wrapper']['size'] = array(
      '#type' => 'select',
      '#title' => t('Badge size'),
      '#default_value' => variable_get('drupal_badge_size', '80x15'),
      '#options' => array('80x15' => t('Small'), '88x31' => t('Medium'), '135x42' => t('Large')),
    );
    $form['wrapper']['preview'] = array(
      '#type' => 'item',
      '#title' => 'Preview',
      '#markup' => theme('image', $image_path, t('Powered by Drupal, an open source content management system'), t('Powered by Drupal, an open source content management system'), array('class' => array('powered-by-preview')), FALSE),
    );
    return $form;
  }
}

/**
 * Implement hook_block_save().
 */
function system_block_save($delta = '', $edit = NULL) {
  if ($delta == 'powered-by') {
    $image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png';
    variable_set('drupal_badge_color', $edit['color']);
    variable_set('drupal_badge_size', $edit['size']);
  }
}

/**
 * Implement hook_block_view().
 *
 * Generate a block with a promotional link to Drupal.org and
 * all system menu blocks.
 */
function system_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'main':
      $block['subject'] = NULL;
      $block['content'] = drupal_set_page_content();
      return $block;
    case 'powered-by':
      $image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png';
      $block['subject'] = NULL;
      $block['content'] = theme('system_powered_by', $image_path);
      return $block;
    case 'help':
      $block['subject'] = NULL;
      $block['content'] = menu_get_active_help();
      return $block;
    default:
      // All system menu blocks.
      $system_menus = menu_list_system_menus();
      if (isset($system_menus[$delta])) {
        $block['subject'] = t($system_menus[$delta]);
        $block['content'] = menu_tree($delta);
        return $block;
      }
      break;
  }
}

/**
 * Provide a single block on the administration overview page.
 *
 * @param $item
 *   The menu item to be displayed.
 */
function system_admin_menu_block($item) {
  $cache = &drupal_static(__FUNCTION__, array());
  if (!isset($item['mlid'])) {
    $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc();
  }

  if (isset($cache[$item['mlid']])) {
    return $cache[$item['mlid']];
  }

  $content = array();
  $result = db_query("
    SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
    FROM {menu_links} ml
    LEFT JOIN {menu_router} m ON ml.router_path = m.path
    WHERE ml.plid = :plid AND ml.menu_name = :name AND hidden = 0", array(':plid' => $item['mlid'], ':name' => $item['menu_name']), array('fetch' => PDO::FETCH_ASSOC));
  foreach ($result as $link) {
    _menu_link_translate($link);
    if (!$link['access']) {
      continue;
    }
    // The link 'description' either derived from the hook_menu 'description' or
    // entered by the user via menu module is saved as the title attribute.
    if (!empty($link['localized_options']['attributes']['title'])) {
      $link['description'] = $link['localized_options']['attributes']['title'];
    }
    // Prepare for sorting as in function _menu_tree_check_access().
    // The weight is offset so it is always positive, with a uniform 5-digits.
    $content[(50000 + $link['weight']) . ' ' . drupal_strtolower($link['title']) . ' ' . $link['mlid']] = $link;
  }
  ksort($content);
  $cache[$item['mlid']] = $content;
  return $content;
}

/**
 * Checks the existence of the directory specified in $form_element. This
 * function is called from the system_settings form to check both core file
 * directories (file_public_path, file_private_path, file_temporary_path).
 *
 * @param $form_element
 *   The form element containing the name of the directory to check.
 */
function system_check_directory($form_element) {
  $directory = $form_element['#value'];
  
  if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
    // If the directory does not exists and cannot be created.
    form_set_error($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
    watchdog('file system', 'The directory %directory does not exist and could not be created.', array('%directory' => $directory), WATCHDOG_ERROR);
  }

  if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {
    // If the directory is not writable and cannont be made so.
    form_set_error($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
    watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory), WATCHDOG_ERROR);
  }
  else {
    if ($form_element['#name'] == 'file_public_path') {
      // Create public .htaccess file.
      file_create_htaccess($directory, FALSE);
    }
    else {
      // Create private .htaccess file.
      file_create_htaccess($directory);
    }
  }

  return $form_element;
}

/**
 * Retrieves the current status of an array of files in the system table.
 *
 * @param $files
 *   An array of files to check.
 * @param $type
 *   The type of the files.
 */
function system_get_files_database(&$files, $type) {
  // Extract current files from database.
  $result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => $type));
  foreach ($result as $file) {
    if (isset($files[$file->name]) && is_object($files[$file->name])) {
      $file->uri = $file->filename;
      foreach ($file as $key => $value) {
        if (!isset($files[$file->name]->key)) {
          $files[$file->name]->$key = $value;
        }
      }
    }
  }
}

/**
 * Updates the records in the system table based on the files array.
 *
 * @param $files
 *   An array of files.
 * @param $type
 *   The type of the files.
 */
function system_update_files_database(&$files, $type) {
  $result = db_query("SELECT * FROM {system} WHERE type = :type", array(':type' => $type));

  // Add all files that need to be deleted to a DatabaseCondition.
  $delete = db_or();
  foreach ($result as $file) {
    if (isset($files[$file->name]) && is_object($files[$file->name])) {
      // Keep the old filename from the database in case the file has moved.
      $old_filename = $file->filename;

      $updated_fields = array();

      // Handle info specially, compare the serialized value.
      $serialized_info = serialize($files[$file->name]->info);
      if ($serialized_info != $file->info) {
        $updated_fields['info'] = $serialized_info;
      }
      unset($file->info);

      // Scan remaining fields to find only the updated values.
      foreach ($file as $key => $value) {
        if (isset($files[$file->name]->$key) && $files[$file->name]->$key != $value) {
          $updated_fields[$key] = $files[$file->name]->$key;
        }
      }

      // Update the record.
      if (count($updated_fields)) {
        db_update('system')
          ->fields($updated_fields)
          ->condition('filename', $old_filename)
          ->execute();
      }

      // Indiciate that the file exists already.
      $files[$file->name]->exists = TRUE;
    }
    else {
      // File is not found in file system, so delete record from the system table.
      $delete->condition('filename', $file->filename);
    }
  }

  if (count($delete) > 0) {
    // Delete all missing files from the system table
    db_delete('system')
      ->condition($delete)
      ->execute();
  }

  // All remaining files are not in the system table, so we need to add them.
  $query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info'));
  foreach($files as &$file) {
    if (isset($file->exists)) {
      unset($file->exists);
    }
    else {
      $query->values(array(
        'filename' => $file->uri,
        'name' => $file->name,
        'type' => $type,
        'owner' => isset($file->owner) ? $file->owner : '',
        'info' => serialize($file->info),
      ));
      $file->type = $type;
      $file->status = 0;
      $file->schema_version = -1;
    }
  }
  $query->execute();
}

/**
 * Helper function to scan and collect module .info data.
 *
 * @return
 *   An associative array of module information.
 */
function _system_get_module_data() {
  // Find modules
  $modules = drupal_system_listing('/\.module$/', 'modules', 'name', 0);

  // Include the install profile in modules that are loaded.
  $profile = drupal_get_profile();
  $modules[$profile]->name = $profile;
  $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
  $modules[$profile]->filename = $profile . '.profile';

  // Install profile hooks are always executed last.
  $modules[$profile]->weight = 1000;

  // Set defaults for module info.
  $defaults = array(
    'dependencies' => array(),
    'dependents' => array(),
    'description' => '',
    'package' => 'Other',
    'version' => NULL,
    'php' => DRUPAL_MINIMUM_PHP,
    'files' => array(),
  );

  // Read info files for each module.
  foreach ($modules as $key => $module) {
    // Look for the info file.
    $module->info = drupal_parse_info_file(dirname($module->uri) . '/' . $module->name . '.info');

    // Skip modules that don't provide info.
    if (empty($module->info)) {
      unset($modules[$key]);
      continue;
    }

    // Merge in defaults and save.
    $modules[$key]->info = $module->info + $defaults;

    // Invoke hook_system_info_alter() to give installed modules a chance to
    // modify the data in the .info files if necessary.
    drupal_alter('system_info', $modules[$key]->info, $modules[$key]);
  }

  // The install profile is required.
  $modules[$profile]->info['required'] = TRUE;

  return $modules;
}

/**
 * Collect data about all currently available modules.
 *
 * @return
 *   Array of all available modules and their data.
 */
function system_get_module_data() {
  $modules = _system_get_module_data();
  ksort($modules);
  system_get_files_database($modules, 'module');
  system_update_files_database($modules, 'module');
  $modules = _module_build_dependencies($modules);
  return $modules;
}

/**
 * Helper function to scan and collect theme .info data and their engines.
 *
 * @return
 *   An associative array of themes information.
 */
function _system_get_theme_data() {
  $themes_info = &drupal_static(__FUNCTION__, array());

  if (empty($themes_info)) {
    // Find themes
    $themes = drupal_system_listing('/\.info$/', 'themes');
    // Find theme engines
    $engines = drupal_system_listing('/\.engine$/', 'themes/engines');

    // Set defaults for theme info.
    $defaults = array(
      'regions' => array(
        'sidebar_first' => 'Left sidebar',
        'sidebar_second' => 'Right sidebar',
        'content' => 'Content',
        'header' => 'Header',
        'footer' => 'Footer',
        'highlight' => 'Highlighted content',
        'help' => 'Help',
        'page_top' => 'Page top',
        'page_bottom' => 'Page bottom',
      ),
      'description' => '',
      'features' => array(
        'comment_user_picture',
        'comment_user_verification',
        'favicon',
        'logo',
        'name',
        'node_user_picture',
        'search',
        'slogan',
        'main_menu',
        'secondary_menu',
      ),
      'screenshot' => 'screenshot.png',
      'php' => DRUPAL_MINIMUM_PHP,
    );

    $sub_themes = array();
    // Read info files for each theme
    foreach ($themes as $key => $theme) {
      $themes[$key]->filename = $theme->uri;
      $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults;

      // Invoke hook_system_info_alter() to give installed modules a chance to
      // modify the data in the .info files if necessary.
      drupal_alter('system_info', $themes[$key]->info, $themes[$key]);

      if (!empty($themes[$key]->info['base theme'])) {
        $sub_themes[] = $key;
      }
      if (empty($themes[$key]->info['engine'])) {
        $filename = dirname($themes[$key]->uri) . '/' . $themes[$key]->name . '.theme';
        if (file_exists($filename)) {
          $themes[$key]->owner = $filename;
          $themes[$key]->prefix = $key;
        }
      }
      else {
        $engine = $themes[$key]->info['engine'];
        if (isset($engines[$engine])) {
          $themes[$key]->owner = $engines[$engine]->uri;
          $themes[$key]->prefix = $engines[$engine]->name;
          $themes[$key]->template = TRUE;
        }
      }

      // Give the stylesheets proper path information.
      $pathed_stylesheets = array();
      if (isset($themes[$key]->info['stylesheets'])) {
        foreach ($themes[$key]->info['stylesheets'] as $media => $stylesheets) {
          foreach ($stylesheets as $stylesheet) {
            $pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->uri) . '/' . $stylesheet;
          }
        }
      }
      $themes[$key]->info['stylesheets'] = $pathed_stylesheets;

      // Give the scripts proper path information.
      $scripts = array();
      if (isset($themes[$key]->info['scripts'])) {
        foreach ($themes[$key]->info['scripts'] as $script) {
          $scripts[$script] = dirname($themes[$key]->uri) . '/' . $script;
        }
      }
      $themes[$key]->info['scripts'] = $scripts;
      // Give the screenshot proper path information.
      if (!empty($themes[$key]->info['screenshot'])) {
        $themes[$key]->info['screenshot'] = dirname($themes[$key]->uri) . '/' . $themes[$key]->info['screenshot'];
      }
    }

    // Now that we've established all our master themes, go back and fill in
    // data for subthemes.
    foreach ($sub_themes as $key) {
      $themes[$key]->base_themes = system_find_base_themes($themes, $key);
      // Don't proceed if there was a problem with the root base theme.
      if (!current($themes[$key]->base_themes)) {
        continue;
      }
      $base_key = key($themes[$key]->base_themes);
      foreach (array_keys($themes[$key]->base_themes) as $base_theme) {
        $themes[$base_theme]->sub_themes[$key] = $themes[$key]->info['name'];
      }
      // Copy the 'owner' and 'engine' over if the top level theme uses a
      // theme engine.
      if (isset($themes[$base_key]->owner)) {
        if (isset($themes[$base_key]->info['engine'])) {
          $themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
          $themes[$key]->owner = $themes[$base_key]->owner;
          $themes[$key]->prefix = $themes[$base_key]->prefix;
        }
        else {
          $themes[$key]->prefix = $key;
        }
      }
    }

    $themes_info = $themes;
  }

  return $themes_info;
}

/**
 * Collect data about all currently available themes.
 *
 * @return
 *   Array of all available themes and their data.
 */
function system_get_theme_data() {
  $themes = _system_get_theme_data();
  ksort($themes);
  system_get_files_database($themes, 'theme');
  system_update_files_database($themes, 'theme');
  return $themes;
}

/**
 * Find all the base themes for the specified theme.
 *
 * Themes can inherit templates and function implementations from earlier themes.
 *
 * @param $themes
 *   An array of available themes.
 * @param $key
 *   The name of the theme whose base we are looking for.
 * @param $used_keys
 *   A recursion parameter preventing endless loops.
 * @return
 *   Returns an array of all of the theme's ancestors; the first element's value
 *   will be NULL if an error occurred.
 */
function system_find_base_themes($themes, $key, $used_keys = array()) {
  $base_key = $themes[$key]->info['base theme'];
  // Does the base theme exist?
  if (!isset($themes[$base_key])) {
    return array($base_key => NULL);
  }

  $current_base_theme = array($base_key => $themes[$base_key]->info['name']);

  // Is the base theme itself a child of another theme?
  if (isset($themes[$base_key]->info['base theme'])) {
    // Do we already know the base themes of this theme?
    if (isset($themes[$base_key]->base_themes)) {
      return $themes[$base_key]->base_themes + $current_base_theme;
    }
    // Prevent loops.
    if (!empty($used_keys[$base_key])) {
      return array($base_key => NULL);
    }
    $used_keys[$base_key] = TRUE;
    return system_find_base_themes($themes, $base_key, $used_keys) + $current_base_theme;
  }
  // If we get here, then this is our parent theme.
  return $current_base_theme;
}

/**
 * Get a list of available regions from a specified theme.
 *
 * @param $theme_key
 *   The name of a theme.
 * @param $show
 *   Possible values: REGIONS_ALL or REGIONS_VISIBLE. Visible excludes hidden
 *   regions.
 * @return
 *   An array of regions in the form $region['name'] = 'description'.
 */
function system_region_list($theme_key, $show = REGIONS_ALL) {
  $list = &drupal_static(__FUNCTION__, array());

  if (empty($list[$theme_key][$show])) {
    $info = unserialize(db_query("SELECT info FROM {system} WHERE type = :type AND name = :name", array(':type' => 'theme', ':name' => $theme_key))->fetchField());
    // If requested, suppress hidden regions. @see block_admin_display_form().
    foreach ($info['regions'] as $name => $label) {
      if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) {
        $list[$theme_key][$show][$name] = $label;
      }
    }
  }
  return $list[$theme_key][$show];
}

/**
 * Implement hook_system_info_alter().
 */
function system_system_info_alter(&$info, $file) {
  // Remove page-top from the blocks UI since it is reserved for modules to
  // populate from outside the blocks system.
  $info['regions_hidden'][] = 'page_top';
  $info['regions_hidden'][] = 'page_bottom';
}

/**
 * Get the name of the default region for a given theme.
 *
 * @param $theme
 *   The name of a theme.
 * @return
 *   A string that is the region name.
 */
function system_default_region($theme) {
  $regions = array_keys(system_region_list($theme));
  return isset($regions[0]) ? $regions[0] : '';
}

function _system_settings_form_automatic_defaults($form) {
  // Get an array of all non-property keys
  $keys = element_children($form);

  foreach ($keys as $key) {
    // If the property (key) '#default_value' exists, replace it.
    if (array_key_exists('#default_value', $form[$key])) {
      $form[$key]['#default_value'] = variable_get($key, $form[$key]['#default_value']);
    }
    else {
      // Recurse through child elements
      $form[$key] = _system_settings_form_automatic_defaults($form[$key]);
    }
  }

  return $form;
}

/**
 * Add default buttons to a form and set its prefix.
 *
 * @ingroup forms
 * @see system_settings_form_submit()
 * @param $form
 *   An associative array containing the structure of the form.
 * @param $automatic_defaults
 *   Automatically load the saved values for each field from the system variables (defaults to TRUE).
 * @return
 *   The form structure.
 */
function system_settings_form($form, $automatic_defaults = TRUE) {
  $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );

  if ($automatic_defaults) {
    $form = _system_settings_form_automatic_defaults($form);
  }

  if (!empty($_POST) && form_get_errors()) {
    drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
  }
  $form['#submit'][] = 'system_settings_form_submit';
  $form['#theme'] = 'system_settings_form';
  return $form;
}

/**
 * Execute the system_settings_form.
 *
 * If you want node type configure style handling of your checkboxes,
 * add an array_filter value to your form.
 */
function system_settings_form_submit($form, &$form_state) {
  // Exclude unnecessary elements.
  unset($form_state['values']['submit'], $form_state['values']['reset'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token'], $form_state['values']['form_build_id']);

  foreach ($form_state['values'] as $key => $value) {
    if (is_array($value) && isset($form_state['values']['array_filter'])) {
      $value = array_keys(array_filter($value));
    }
    variable_set($key, $value);
  }

  drupal_set_message(t('The configuration options have been saved.'));

  cache_clear_all();
  drupal_theme_rebuild();
}

/**
 * Helper function to sort requirements.
 */
function _system_sort_requirements($a, $b) {
  if (!isset($a['weight'])) {
    if (!isset($b['weight'])) {
      return strcmp($a['title'], $b['title']);
    }
    return -$b['weight'];
  }
  return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
}

/**
 * Output a confirmation form
 *
 * This function returns a complete form for confirming an action. A link is
 * offered to go back to the item that is being changed in case the user changes
 * his/her mind.
 *
 * If the submit handler for this form is invoked, the user successfully
 * confirmed the action. You should never directly inspect $_POST to see if an
 * action was confirmed.
 *
 * Note - if the parameters $question, $description, $yes, or $no could contain
 * any user input (such as node titles or taxonomy terms), it is the
 * responsibility of the code calling confirm_form() to sanitize them first with
 * a function like check_plain() or filter_xss().
 *
 * @ingroup forms
 * @param $form
 *   Additional elements to inject into the form, for example hidden elements.
 * @param $question
 *   The question to ask the user (e.g. "Are you sure you want to delete the
 *   block <em>foo</em>?").
 * @param $path
 *   The page to go to if the user denies the action.
 *   Can be either a drupal path, or an array with the keys 'path', 'query', 'fragment'.
 * @param $description
 *   Additional text to display (defaults to "This action cannot be undone.").
 * @param $yes
 *   A caption for the button which confirms the action (e.g. "Delete",
 *   "Replace", ...).
 * @param $no
 *   A caption for the link which denies the action (e.g. "Cancel").
 * @param $name
 *   The internal name used to refer to the confirmation item.
 * @return
 *   The form.
 */
function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
  $description = isset($description) ? $description : t('This action cannot be undone.');

  // Prepare cancel link
  $query = $fragment = NULL;
  if (is_array($path)) {
    $query = isset($path['query']) ? $path['query'] : NULL;
    $fragment = isset($path['fragment']) ? $path['fragment'] : NULL;
    $path = isset($path['path']) ? $path['path'] : NULL;
  }
  $cancel = l($no ? $no : t('Cancel'), $path, array('query' => $query, 'fragment' => $fragment));

  drupal_set_title($question, PASS_THROUGH);

  // Confirm form fails duplication check, as the form values rarely change -- so skip it.
  $form['#skip_duplicate_check'] = TRUE;

  $form['#attributes'] = array('class' => array('confirmation'));
  $form['description'] = array('#markup' => $description);
  $form[$name] = array('#type' => 'hidden', '#value' => 1);

  $form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
  $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
  $form['actions']['cancel'] = array('#markup' => $cancel);
  $form['#theme'] = 'confirm_form';
  return $form;
}

/**
 * Determine if a user is in compact mode.
 */
function system_admin_compact_mode() {
  global $user;
  return (isset($user->admin_compact_mode)) ? $user->admin_compact_mode : variable_get('admin_compact_mode', FALSE);
}

/**
 * Menu callback; Sets whether the admin menu is in compact mode or not.
 *
 * @param $mode
 *   Valid values are 'on' and 'off'.
 */
function system_admin_compact_page($mode = 'off') {
  global $user;
  user_save($user, array('admin_compact_mode' => ($mode == 'on')));
  drupal_goto(drupal_get_destination());
}

/**
 * Generate a list of tasks offered by a specified module.
 *
 * @param $module
 *   Module name.
 * @return
 *   An array of task links.
 */
function system_get_module_admin_tasks($module) {
  $items = &drupal_static(__FUNCTION__, array());

  if (empty($items)) {
    $result = db_query("
       SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
       FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.link_path LIKE 'admin/%' AND hidden >= 0 AND module = 'system' AND m.number_parts > 2", array(), array('fetch' => PDO::FETCH_ASSOC));
    foreach ($result as $item) {
      _menu_link_translate($item);
      if ($item['access']) {
        $items[$item['router_path']] = $item;
      }
    }
  }

  $admin_access = user_access('administer permissions');
  $admin_tasks = array();
  $admin_task_count = 0;
  // Check for permissions.
  if (in_array($module, module_implements('permission')) && $admin_access) {
    $admin_tasks[-1] = l(t('Configure permissions'), 'admin/config/people/permissions', array('fragment' => 'module-' . $module));
  }

  // Check for menu items that are admin links.
  if (in_array($module, module_implements('menu')) && $menu = module_invoke($module, 'menu')) {
    foreach (array_keys($menu) as $path) {
      if (isset($items[$path])) {
        $admin_tasks[$items[$path]['title'] . $admin_task_count ++] = l($items[$path]['title'], $path);
      }
    }
  }

  return $admin_tasks;
}

/**
 * Implement hook_cron().
 *
 * Remove older rows from flood and batch table. Remove old temporary files.
 */
function system_cron() {
  // Cleanup the flood.
  db_delete('flood')
    ->condition('timestamp', REQUEST_TIME - 3600, '<')
    ->execute();
  // Cleanup the batch table.
  db_delete('batch')
    ->condition('timestamp', REQUEST_TIME - 864000, '<')
    ->execute();

  // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
  // Use separate placeholders for the status to avoid a bug in some versions
  // of PHP. See http://drupal.org/node/352956
  $result = db_query('SELECT fid FROM {file} WHERE status & :permanent1 <> :permanent2 AND timestamp < :timestamp', array(
    ':permanent1' => FILE_STATUS_PERMANENT,
    ':permanent2' => FILE_STATUS_PERMANENT,
    ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
  ));
  foreach ($result as $row) {
    if ($file = file_load($row->fid)) {
      if (!file_delete($file)) {
        watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->uri), WATCHDOG_ERROR);
      }
    }
  }

  $core = array('cache', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
  $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
  foreach ($cache_tables as $table) {
    cache_clear_all(NULL, $table);
  }

  // Reset expired items in the default queue implementation table. If that's
  // not used, this will simply be a no-op.
  db_update('queue')
    ->fields(array(
      'consumer_id' => 0,
      'expire' => 0,
    ))
    ->condition('expire', REQUEST_TIME, '<')
    ->execute();
}

/**
 * Implement hook_hook_info().
 */
function system_hook_info() {
  return array(
    'system' => array(
      'cron' => array(
        'run' => array(
          'runs when' => t('When cron runs'),
        ),
      ),
    ),
  );
}

/**
 * Implement hook_action_info().
 */
function system_action_info() {
  return array(
    'system_message_action' => array(
      'type' => 'system',
      'description' => t('Display a message to the user'),
      'configurable' => TRUE,
      'hooks' => array(
        'node' => array('view', 'insert', 'update', 'delete'),
        'comment' => array('view', 'insert', 'update', 'delete'),
        'user' => array('view', 'insert', 'update', 'delete', 'login'),
        'taxonomy' => array('insert', 'update', 'delete'),
      ),
    ),
    'system_send_email_action' => array(
      'description' => t('Send e-mail'),
      'type' => 'system',
      'configurable' => TRUE,
      'hooks' => array(
        'node' => array('view', 'insert', 'update', 'delete'),
        'comment' => array('view', 'insert', 'update', 'delete'),
        'user' => array('view', 'insert', 'update', 'delete', 'login'),
        'taxonomy' => array('insert', 'update', 'delete'),
        'cron' => array('run'),
      )
    ),
    'system_block_ip_action' => array(
      'description' => t('Ban IP address of current user'),
      'type' => 'user',
      'configurable' => FALSE,
      'hooks' => array(),
    ),
    'system_goto_action' => array(
      'description' => t('Redirect to URL'),
      'type' => 'system',
      'configurable' => TRUE,
      'hooks' => array(
        'node' => array('view', 'insert', 'update', 'delete'),
        'comment' => array('view', 'insert', 'update', 'delete'),
        'user' => array('view', 'insert', 'update', 'delete', 'login'),
      )
    )
  );
}

/**
 * Menu callback. Display an overview of available and configured actions.
 */
function system_actions_manage() {
  actions_synchronize();
  $actions = actions_list();
  $actions_map = actions_actions_map($actions);
  $options = array(t('Choose an advanced action'));
  $unconfigurable = array();

  foreach ($actions_map as $key => $array) {
    if ($array['configurable']) {
      $options[$key] = $array['description'] . '...';
    }
    else {
      $unconfigurable[] = $array;
    }
  }

  $row = array();
  $instances_present = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchField();
  $header = array(
    array('data' => t('Action type'), 'field' => 'type'),
    array('data' => t('Description'), 'field' => 'description'),
    array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2')
  );
  $query = db_select('actions')->extend('PagerDefault')->extend('TableSort');
  $result = $query
    ->fields('actions')
    ->limit(50)
    ->orderByHeader($header)
    ->execute();

  foreach ($result as $action) {
    $row[] = array(
      array('data' => $action->type),
      array('data' => $action->description),
      array('data' => $action->parameters ? l(t('configure'), "admin/settings/actions/configure/$action->aid") : ''),
      array('data' => $action->parameters ? l(t('delete'), "admin/settings/actions/delete/$action->aid") : '')
    );
  }

  if ($row) {
    $pager = theme('pager', NULL);
    if (!empty($pager)) {
      $row[] = array(array('data' => $pager, 'colspan' => '3'));
    }
    $build['system_actions_header'] = array('#markup' => '<h3>' . t('Actions available to Drupal:') . '</h3>');
    $build['system_actions_table'] = array('#markup' => theme('table', $header, $row));
  }

  if ($actions_map) {
    $build['system_actions_manage_form'] = drupal_get_form('system_actions_manage_form', $options);
  }

  return $build;
}

/**
 * Define the form for the actions overview page.
 *
 * @see system_actions_manage_form_submit()
 * @ingroup forms
 * @param $form_state
 *   An associative array containing the current state of the form; not used.
 * @param $options
 *   An array of configurable actions.
 * @return
 *   Form definition.
 */
function system_actions_manage_form($form_state, $options = array()) {
  $form['parent'] = array(
    '#type' => 'fieldset',
    '#title' => t('Make a new advanced action available'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['parent']['action'] = array(
    '#type' => 'select',
    '#default_value' => '',
    '#options' => $options,
    '#description' => '',
  );
  $form['parent']['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Create'),
  );
  return $form;
}

/**
 * Process system_actions_manage form submissions.
 */
function system_actions_manage_form_submit($form, &$form_state) {
  if ($form_state['values']['action']) {
    $form_state['redirect'] = 'admin/settings/actions/configure/' . $form_state['values']['action'];
  }
}

/**
 * Menu callback. Create the form for configuration of a single action.
 *
 * We provide the "Description" field. The rest of the form
 * is provided by the action. We then provide the Save button.
 * Because we are combining unknown form elements with the action
 * configuration form, we use actions_ prefix on our elements.
 *
 * @see system_actions_configure_validate()
 * @see system_actions_configure_submit()
 * @param $action
 *   md5 hash of action ID or an integer. If it's an md5 hash, we
 *   are creating a new instance. If it's an integer, we're editing
 *   an existing instance.
 * @return
 *   Form definition.
 */
function system_actions_configure($form_state, $action = NULL) {
  if ($action === NULL) {
    drupal_goto('admin/settings/actions');
  }

  $actions_map = actions_actions_map(actions_list());
  $edit = array();

  // Numeric action denotes saved instance of a configurable action;
  // else we are creating a new action instance.
  if (is_numeric($action)) {
    $aid = $action;
    // Load stored parameter values from database.
    $data = db_query("SELECT * FROM {actions} WHERE aid = :aid", array(':aid' => $aid))->fetch();
    $edit['actions_description'] = $data->description;
    $edit['actions_type'] = $data->type;
    $function = $data->callback;
    $action = md5($data->callback);
    $params = unserialize($data->parameters);
    if ($params) {
      foreach ($params as $name => $val) {
        $edit[$name] = $val;
      }
    }
  }
  else {
    $function = $actions_map[$action]['callback'];
    $edit['actions_description'] = $actions_map[$action]['description'];
    $edit['actions_type'] = $actions_map[$action]['type'];
  }

  $form['actions_description'] = array(
    '#type' => 'textfield',
    '#title' => t('Description'),
    '#default_value' => $edit['actions_description'],
    '#maxlength' => '255',
    '#description' => t('A unique description for this advanced action. This description will be displayed in the interface of modules that integrate with actions, such as Trigger module.'),
    '#weight' => -10
  );
  $action_form = $function . '_form';
  $form = array_merge($form, $action_form($edit));
  $form['actions_type'] = array(
    '#type' => 'value',
    '#value' => $edit['actions_type'],
  );
  $form['actions_action'] = array(
    '#type' => 'hidden',
    '#value' => $action,
  );
  // $aid is set when configuring an existing action instance.
  if (isset($aid)) {
    $form['actions_aid'] = array(
      '#type' => 'hidden',
      '#value' => $aid,
    );
  }
  $form['actions_configured'] = array(
    '#type' => 'hidden',
    '#value' => '1',
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 13
  );

  return $form;
}

/**
 * Validate system_actions_configure form submissions.
 */
function system_actions_configure_validate($form, $form_state) {
  $function = actions_function_lookup($form_state['values']['actions_action']) . '_validate';
  // Hand off validation to the action.
  if (drupal_function_exists($function)) {
    $function($form, $form_state);
  }
}

/**
 * Process system_actions_configure form submissions.
 */
function system_actions_configure_submit($form, &$form_state) {
  $function = actions_function_lookup($form_state['values']['actions_action']);
  $submit_function = $function . '_submit';

  // Action will return keyed array of values to store.
  $params = $submit_function($form, $form_state);
  $aid = isset($form_state['values']['actions_aid']) ? $form_state['values']['actions_aid'] : NULL;

  actions_save($function, $form_state['values']['actions_type'], $params, $form_state['values']['actions_description'], $aid);
  drupal_set_message(t('The action has been successfully saved.'));

  $form_state['redirect'] = 'admin/settings/actions/manage';
}

/**
 * Create the form for confirmation of deleting an action.
 *
 * @ingroup forms
 * @see system_actions_delete_form_submit()
 */
function system_actions_delete_form($form_state, $action) {

  $form['aid'] = array(
    '#type' => 'hidden',
    '#value' => $action->aid,
  );
  return confirm_form($form,
    t('Are you sure you want to delete the action %action?', array('%action' => $action->description)),
    'admin/settings/actions/manage',
    t('This cannot be undone.'),
    t('Delete'), t('Cancel')
  );
}

/**
 * Process system_actions_delete form submissions.
 *
 * Post-deletion operations for action deletion.
 */
function system_actions_delete_form_submit($form, &$form_state) {
  $aid = $form_state['values']['aid'];
  $action = actions_load($aid);
  actions_delete($aid);
  $description = check_plain($action->description);
  watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $description));
  drupal_set_message(t('Action %action was deleted', array('%action' => $description)));
  $form_state['redirect'] = 'admin/settings/actions/manage';
}

/**
 * Post-deletion operations for deleting action orphans.
 *
 * @param $orphaned
 *   An array of orphaned actions.
 */
function system_action_delete_orphans_post($orphaned) {
  foreach ($orphaned as $callback) {
    drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
  }
}

/**
 * Remove actions that are in the database but not supported by any enabled module.
 */
function system_actions_remove_orphans() {
  actions_synchronize(TRUE);
  drupal_goto('admin/settings/actions/manage');
}

/**
 * Return a form definition so the Send email action can be configured.
 *
 * @see system_send_email_action_validate()
 * @see system_send_email_action_submit()
 * @param $context
 *   Default values (if we are editing an existing action instance).
 * @return
 *   Form definition.
 */
function system_send_email_action_form($context) {
  // Set default values for form.
  if (!isset($context['recipient'])) {
    $context['recipient'] = '';
  }
  if (!isset($context['subject'])) {
    $context['subject'] = '';
  }
  if (!isset($context['message'])) {
    $context['message'] = '';
  }

  $form['recipient'] = array(
    '#type' => 'textfield',
    '#title' => t('Recipient'),
    '#default_value' => $context['recipient'],
    '#maxlength' => '254',
    '#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'),
  );
  $form['subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#default_value' => $context['subject'],
    '#maxlength' => '254',
    '#description' => t('The subject of the message.'),
  );
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#default_value' => $context['message'],
    '#cols' => '80',
    '#rows' => '20',
    '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
  );
  return $form;
}

/**
 * Validate system_send_email_action form submissions.
 */
function system_send_email_action_validate($form, $form_state) {
  $form_values = $form_state['values'];
  // Validate the configuration form.
  if (!valid_email_address($form_values['recipient']) && $form_values['recipient'] != '%author') {
    // We want the literal %author placeholder to be emphasized in the error message.
    form_set_error('recipient', t('Please enter a valid email address or %author.', array('%author' => '%author')));
  }
}

/**
 * Process system_send_email_action form submissions.
 */
function system_send_email_action_submit($form, $form_state) {
  $form_values = $form_state['values'];
  // Process the HTML form to store configuration. The keyed array that
  // we return will be serialized to the database.
  $params = array(
    'recipient' => $form_values['recipient'],
    'subject'   => $form_values['subject'],
    'message'   => $form_values['message'],
  );
  return $params;
}

/**
 * Implement a configurable Drupal action. Sends an email.
 */
function system_send_email_action($object, $context) {
  if (empty($context['node'])) {
    $context['node'] = $object;
  }

  $recipient = token_replace($context['recipient'], $context);
  
  $language = user_preferred_language($account);
  $params = array('context' => $context);

  if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
    watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
  }
  else {
    watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
  }
}

/**
 * Implement hook_mail().
 */
function system_mail($key, &$message, $params) {
  $context = $params['context'];

  $subject = token_replace($context['subject'], $context);
  $body = token_replace($context['message'], $context);

  $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
  $message['body'][] = drupal_html_to_text($body);
}

function system_message_action_form($context) {
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#default_value' => isset($context['message']) ? $context['message'] : '',
    '#required' => TRUE,
    '#rows' => '8',
    '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
  );
  return $form;
}

function system_message_action_submit($form, $form_state) {
  return array('message' => $form_state['values']['message']);
}

/**
 * A configurable Drupal action. Sends a message to the current user's screen.
 */
function system_message_action(&$object, $context = array()) {
  if (empty($context['node'])) {
    $context['node'] = $object;
  }

  $context['message'] = token_replace($context['message'], $context);
  drupal_set_message($context['message']);
}

/**
 * Implement a configurable Drupal action. Redirect user to a URL.
 */
function system_goto_action_form($context) {
  $form['url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL'),
    '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like http://drupal.org.'),
    '#default_value' => isset($context['url']) ? $context['url'] : '',
    '#required' => TRUE,
  );
  return $form;
}

function system_goto_action_submit($form, $form_state) {
  return array(
    'url' => $form_state['values']['url']
  );
}

function system_goto_action($object, $context) {
  drupal_goto(token_replace($context['url'], $context));
}

/**
 * Implement a Drupal action.
 * Blocks the user's IP address.
 */
function system_block_ip_action() {
  $ip = ip_address();
  db_insert('blocked_ips')
    ->fields(array('ip' => $ip))
    ->execute();
  watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
}

/**
 * Generate an array of time zones and their local time&date.
 *
 * @param $blank
 *   If evaluates true, prepend an empty time zone option to the array.
 */
function system_time_zones($blank = NULL) {
  $zonelist = timezone_identifiers_list();
  $zones = $blank ? array('' => t('- None selected -')) : array();
  foreach ($zonelist as $zone) {
    // Because many time zones exist in PHP only for backward compatibility
    // reasons and should not be used, the list is filtered by a regular
    // expression.
    if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
      $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone)));
    }
  }
  // Sort the translated time zones alphabetically.
  asort($zones);
  return $zones;
}

/**
 * Checks whether the server is capable of issuing HTTP requests.
 *
 * The function sets the drupal_http_request_fail system variable to TRUE if
 * drupal_http_request() does not work and then the system status report page
 * will contain an error.
 *
 * @return
 *  TRUE if this installation can issue HTTP requests.
 */
function system_check_http_request() {
  // Try to get the content of the front page via drupal_http_request().
  $result = drupal_http_request(url('', array('absolute' => TRUE)));
  // We only care that we get a http response - this means that Drupal
  // can make a http request.
  $works = isset($result->code) && ($result->code >= 100) && ($result->code < 600);
  variable_set('drupal_http_request_fails', !$works);
  return $works;
}

/**
 * Menu callback; Retrieve a JSON object containing a suggested time zone name.
 */
function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
  // An abbreviation of "0" passed in the callback arguments should be
  // interpreted as the empty string.
  $abbreviation = $abbreviation ? $abbreviation : '';
  $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
  drupal_json($timezone);
}

/**
 * Format the Powered by Drupal text.
 *
 * @ingroup themeable
 */
function theme_system_powered_by($image_path) {
  $image = theme('image', $image_path, t('Powered by Drupal, an open source content management system'), t('Powered by Drupal, an open source content management system'));
  return l($image, 'http://drupal.org', array('html' => TRUE, 'absolute' => TRUE, 'external' => TRUE));
}

/**
 * Display the link to show or hide inline help descriptions.
 *
 * @ingroup themeable
 */
function theme_system_compact_link() {
  $output = '<div class="compact-link">';
  if (system_admin_compact_mode()) {
    $output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
  }
  else {
    $output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination()));
  }
  $output .= '</div>';

  return $output;
}


/**
 * Send Drupal and the major version number in the META GENERATOR HTML.
 *
 * @ingroup themeable
 */
function theme_meta_generator_html($version = VERSION) {
  drupal_add_html_head('<meta name="Generator" content="Drupal ' . $version . ' (http://drupal.org)" />');
}

/**
 * Send Drupal and the major version number in the HTTP headers.
 *
 * @ingroup themeable
 */
function theme_meta_generator_header($version = VERSION) {
  drupal_set_header('X-Generator', 'Drupal ' . $version . ' (http://drupal.org)');
}

/**
 * Implement hook_image_toolkits().
 */
function system_image_toolkits() {
  return array(
    'gd' => array(
      'title' => t('GD2 image manipulation toolkit'),
      'available' => drupal_function_exists('image_gd_check_settings') && image_gd_check_settings(),
    ),
  );
}

/**
 * Attempts to get a file using drupal_http_request and to store it locally.
 *
 * @param $url
 *   The URL of the file to grab.
 *
 * @param $destination
 *   Where the file should be saved, if a directory is provided, file is saved
 *   in that directory with its original name.  If a filename is provided,
 *   remote fileis stored to that location.  NOTE: Relative to drupal "files" directory"
 *
 * @param $overwrite boolean
 *   Defaults to TRUE, will overwrite existing files of the same name.
 *
 * @return
 *   On success the address the files was saved to, FALSE on failure.
 */
function system_retrieve_file($url, $destination = NULL, $overwrite = TRUE) {
  if (!$destination) {
    $destination = file_directory_path('temporary');
  }
  $parsed_url = parse_url($url);
  $local = is_dir(file_directory_path() . '/' . $destination) ? $destination . '/' . basename($parsed_url['path']) : $destination;
  
  if (!$overwrite && file_exists($local)) {
    drupal_set_message(t('@remote could not be saved. @local already exists', array('@remote' => $url, '@local' => $local)), 'error');
    return FALSE;
  }
  
  $result = drupal_http_request($url);
  if ($result->code != 200 || !file_save_data($result->data, $local)) {
    drupal_set_message(t('@remote could not be saved.', array('@remote' => $url)), 'error');
    return FALSE;
  }
  
  return $local;
}

/**
 * Implement hook_page_alter().
 */
function system_page_alter(&$page) {
  // Automatic cron runs.
  // @see system_run_cron_image()
  if (system_run_cron_image_access()) {
    $page['page_bottom']['run_cron'] = array(
      // Trigger cron run via AJAX.
      '#attached_js' => array(
        '(function($){ $.get(' . drupal_to_js(url('system/run-cron-image')) . '); })(jQuery);' => array('type' => 'inline', 'scope' => 'header'),
      ),
      // Trigger cron run for clients not supporting JavaScript (fall-back).
      '#markup' => theme('system_run_cron_image', 'system/run-cron-image'),
    );
  }
}

/**
 * Menu callback; executes cron via an image callback.
 *
 * This callback runs cron in a separate HTTP request to prevent "mysterious"
 * slow-downs of regular HTTP requests. It is either invoked via an AJAX request
 * (if the client's browser supports JavaScript) or by an IMG tag directly in
 * the page output (for clients not supporting JavaScript). For the latter case,
 * we need to output a transparent 1x1 image, so the browser does not render the
 * image's alternate text or a 'missing image placeholder'. The AJAX request
 * does not process the returned output.
 *
 * @see system_page_alter()
 * @see theme_system_run_cron_image()
 * @see system_run_cron_image_access()
 */
function system_run_cron_image() {
  drupal_page_is_cacheable(FALSE);

  // Output a transparent 1x1 image to the browser; required for clients not
  // supporting JavaScript.
  drupal_set_header('Content-Type', 'image/gif');
  echo "\x47\x49\x46\x38\x39\x61\x1\x0\x1\x0\x80\xff\x0\xc0\xc0\xc0\x0\x0\x0\x21\xf9\x4\x1\x0\x0\x0\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x44\x1\x0\x3b";

  // Cron threshold semaphore is used to avoid errors every time the image
  // callback is displayed when a previous cron is still running.
  $threshold_semaphore = variable_get('cron_threshold_semaphore', FALSE);
  if ($threshold_semaphore) {
    if (REQUEST_TIME - $threshold_semaphore > 3600) {
      // Either cron has been running for more than an hour or the semaphore
      // was not reset due to a database error.
      watchdog('cron', 'Cron has been running for more than an hour and is most likely stuck.', array(), WATCHDOG_ERROR);

      // Release the cron threshold semaphore.
      variable_del('cron_threshold_semaphore');
    }
  }
  else {
    // Run cron automatically if it has never run or threshold was crossed.
    $cron_last = variable_get('cron_last', NULL);
    $cron_threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD);
    if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $cron_threshold)) {
      // Lock cron threshold semaphore.
      variable_set('cron_threshold_semaphore', REQUEST_TIME);
      drupal_cron_run();
      // Release the cron threshold semaphore.
      variable_del('cron_threshold_semaphore');
    }
  }

  exit;
}

/**
 * Checks if the feature to automatically run cron is enabled.
 *
 * Also used as a menu access callback for this feature.
 *
 * @return
 *   TRUE if cron threshold is enabled, FALSE otherwise.
 *
 * @see system_run_cron_image()
 * @see system_page_alter()
 */
function system_run_cron_image_access() {
  return variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD) > 0;
}

/**
 * Display image used to run cron automatically.
 *
 * Renders an image pointing to the automatic cron run menu callback for
 * graceful degradation when Javascript is not available. The wrapping NOSCRIPT
 * tag ensures that only browsers not supporting JavaScript render the image.
 *
 * @see system_page_alter()
 * @see system_run_cron_image()
 * @ingroup themeable
 */
function theme_system_run_cron_image($image_path) {
  return '<noscript><div id="system-cron-image">' . theme('image', $image_path, '', '', array(), FALSE) . '</div></noscript>';
}