Changeset 3222:87247c8b44c3 for inc/admin
- Timestamp:
- 03/14/16 17:35:44 (9 years ago)
- Branch:
- default
- source:
- 350652f06ee39395452b6c9826c8624bb2e97d41
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.moduleslist.php
r3166 r3221 1702 1702 public function doActions() 1703 1703 { 1704 if (empty($_POST) || !empty($_REQUEST['conf']) || !$this->isWritablePath()) {1704 if (empty($_POST) || !empty($_REQUEST['conf'])) { 1705 1705 return null; 1706 1706 } … … 1728 1728 } 1729 1729 1730 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['activate'])) { 1731 1732 if (is_array($_POST['activate'])) { 1733 $modules = array_keys($_POST['activate']); 1734 } 1735 1736 $list = $this->modules->getDisabledModules(); 1737 if (empty($list)) { 1738 throw new Exception(__('No such theme.')); 1739 } 1740 1741 $count = 0; 1742 foreach($list as $id => $module) { 1743 1744 if (!in_array($id, $modules)) { 1745 continue; 1746 } 1747 1748 # --BEHAVIOR-- themeBeforeActivate 1749 $this->core->callBehavior('themeBeforeActivate', $id); 1750 1751 $this->modules->activateModule($id); 1752 1753 # --BEHAVIOR-- themeAfterActivate 1754 $this->core->callBehavior('themeAfterActivate', $id); 1755 1756 $count++; 1757 } 1758 1759 dcPage::addSuccessNotice( 1760 __('Theme has been successfully activated.', 'Themes have been successuflly activated.', $count) 1761 ); 1762 http::redirect($this->getURL()); 1763 } 1764 1765 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['deactivate'])) { 1766 1767 if (is_array($_POST['deactivate'])) { 1768 $modules = array_keys($_POST['deactivate']); 1769 } 1770 1771 $list = $this->modules->getModules(); 1772 if (empty($list)) { 1773 throw new Exception(__('No such theme.')); 1774 } 1775 1776 $failed = false; 1777 $count = 0; 1778 foreach($list as $id => $module) { 1779 1780 if (!in_array($id, $modules)) { 1781 continue; 1782 } 1783 1784 if (!$module['root_writable']) { 1785 $failed = true; 1786 continue; 1787 } 1788 1789 $module[$id] = $id; 1790 1791 # --BEHAVIOR-- themeBeforeDeactivate 1792 $this->core->callBehavior('themeBeforeDeactivate', $module); 1793 1794 $this->modules->deactivateModule($id); 1795 1796 # --BEHAVIOR-- themeAfterDeactivate 1797 $this->core->callBehavior('themeAfterDeactivate', $module); 1798 1799 $count++; 1800 } 1801 1802 if ($failed) { 1803 dcPage::addWarningNotice(__('Some themes have not been deactivated.')); 1804 } 1805 else { 1730 else { 1731 if (!$this->isWritablePath()) { 1732 return null; 1733 } 1734 1735 if ($this->core->auth->isSuperAdmin() && !empty($_POST['activate'])) { 1736 1737 if (is_array($_POST['activate'])) { 1738 $modules = array_keys($_POST['activate']); 1739 } 1740 1741 $list = $this->modules->getDisabledModules(); 1742 if (empty($list)) { 1743 throw new Exception(__('No such theme.')); 1744 } 1745 1746 $count = 0; 1747 foreach($list as $id => $module) { 1748 1749 if (!in_array($id, $modules)) { 1750 continue; 1751 } 1752 1753 # --BEHAVIOR-- themeBeforeActivate 1754 $this->core->callBehavior('themeBeforeActivate', $id); 1755 1756 $this->modules->activateModule($id); 1757 1758 # --BEHAVIOR-- themeAfterActivate 1759 $this->core->callBehavior('themeAfterActivate', $id); 1760 1761 $count++; 1762 } 1763 1806 1764 dcPage::addSuccessNotice( 1807 __('Theme has been successfully deactivated.', 'Themes have been successuflly deactivated.', $count)1765 __('Theme has been successfully activated.', 'Themes have been successuflly activated.', $count) 1808 1766 ); 1809 } 1810 http::redirect($this->getURL()); 1811 } 1812 1813 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['delete'])) { 1814 1815 if (is_array($_POST['delete'])) { 1816 $modules = array_keys($_POST['delete']); 1817 } 1818 1819 $list = $this->modules->getDisabledModules(); 1820 1821 $failed = false; 1822 $count = 0; 1823 foreach($modules as $id) 1824 { 1825 if (!isset($list[$id])) { 1826 1827 if (!$this->modules->moduleExists($id)) { 1828 throw new Exception(__('No such theme.')); 1829 } 1830 1831 $module = $this->modules->getModules($id); 1832 $module['id'] = $id; 1833 1834 if (!$this->isDeletablePath($module['root'])) { 1767 http::redirect($this->getURL()); 1768 } 1769 1770 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['deactivate'])) { 1771 1772 if (is_array($_POST['deactivate'])) { 1773 $modules = array_keys($_POST['deactivate']); 1774 } 1775 1776 $list = $this->modules->getModules(); 1777 if (empty($list)) { 1778 throw new Exception(__('No such theme.')); 1779 } 1780 1781 $failed = false; 1782 $count = 0; 1783 foreach($list as $id => $module) { 1784 1785 if (!in_array($id, $modules)) { 1786 continue; 1787 } 1788 1789 if (!$module['root_writable']) { 1835 1790 $failed = true; 1836 1791 continue; 1837 1792 } 1838 1793 1839 # --BEHAVIOR-- themeBeforeDelete 1840 $this->core->callBehavior('themeBeforeDelete', $module); 1841 1842 $this->modules->deleteModule($id); 1843 1844 # --BEHAVIOR-- themeAfterDelete 1845 $this->core->callBehavior('themeAfterDelete', $module); 1794 $module[$id] = $id; 1795 1796 # --BEHAVIOR-- themeBeforeDeactivate 1797 $this->core->callBehavior('themeBeforeDeactivate', $module); 1798 1799 $this->modules->deactivateModule($id); 1800 1801 # --BEHAVIOR-- themeAfterDeactivate 1802 $this->core->callBehavior('themeAfterDeactivate', $module); 1803 1804 $count++; 1805 } 1806 1807 if ($failed) { 1808 dcPage::addWarningNotice(__('Some themes have not been deactivated.')); 1846 1809 } 1847 1810 else { 1848 $this->modules->deleteModule($id, true); 1849 } 1850 1851 $count++; 1852 } 1853 1854 if (!$count && $failed) { 1855 throw new Exception(__("You don't have permissions to delete this theme.")); 1856 } 1857 elseif ($failed) { 1858 dcPage::addWarningNotice(__('Some themes have not been delete.')); 1859 } 1811 dcPage::addSuccessNotice( 1812 __('Theme has been successfully deactivated.', 'Themes have been successuflly deactivated.', $count) 1813 ); 1814 } 1815 http::redirect($this->getURL()); 1816 } 1817 1818 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['delete'])) { 1819 1820 if (is_array($_POST['delete'])) { 1821 $modules = array_keys($_POST['delete']); 1822 } 1823 1824 $list = $this->modules->getDisabledModules(); 1825 1826 $failed = false; 1827 $count = 0; 1828 foreach($modules as $id) 1829 { 1830 if (!isset($list[$id])) { 1831 1832 if (!$this->modules->moduleExists($id)) { 1833 throw new Exception(__('No such theme.')); 1834 } 1835 1836 $module = $this->modules->getModules($id); 1837 $module['id'] = $id; 1838 1839 if (!$this->isDeletablePath($module['root'])) { 1840 $failed = true; 1841 continue; 1842 } 1843 1844 # --BEHAVIOR-- themeBeforeDelete 1845 $this->core->callBehavior('themeBeforeDelete', $module); 1846 1847 $this->modules->deleteModule($id); 1848 1849 # --BEHAVIOR-- themeAfterDelete 1850 $this->core->callBehavior('themeAfterDelete', $module); 1851 } 1852 else { 1853 $this->modules->deleteModule($id, true); 1854 } 1855 1856 $count++; 1857 } 1858 1859 if (!$count && $failed) { 1860 throw new Exception(__("You don't have permissions to delete this theme.")); 1861 } 1862 elseif ($failed) { 1863 dcPage::addWarningNotice(__('Some themes have not been delete.')); 1864 } 1865 else { 1866 dcPage::addSuccessNotice( 1867 __('Theme has been successfully deleted.', 'Themes have been successuflly deleted.', $count) 1868 ); 1869 } 1870 http::redirect($this->getURL()); 1871 } 1872 1873 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['install'])) { 1874 1875 if (is_array($_POST['install'])) { 1876 $modules = array_keys($_POST['install']); 1877 } 1878 1879 $list = $this->store->get(); 1880 1881 if (empty($list)) { 1882 throw new Exception(__('No such theme.')); 1883 } 1884 1885 $count = 0; 1886 foreach($list as $id => $module) { 1887 1888 if (!in_array($id, $modules)) { 1889 continue; 1890 } 1891 1892 $dest = $this->getPath().'/'.basename($module['file']); 1893 1894 # --BEHAVIOR-- themeBeforeAdd 1895 $this->core->callBehavior('themeBeforeAdd', $module); 1896 1897 $this->store->process($module['file'], $dest); 1898 1899 # --BEHAVIOR-- themeAfterAdd 1900 $this->core->callBehavior('themeAfterAdd', $module); 1901 1902 $count++; 1903 } 1904 1905 dcPage::addSuccessNotice( 1906 __('Theme has been successfully installed.', 'Themes have been successuflly installed.', $count) 1907 ); 1908 http::redirect($this->getURL()); 1909 } 1910 1911 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['update'])) { 1912 1913 if (is_array($_POST['update'])) { 1914 $modules = array_keys($_POST['update']); 1915 } 1916 1917 $list = $this->store->get(true); 1918 if (empty($list)) { 1919 throw new Exception(__('No such theme.')); 1920 } 1921 1922 $count = 0; 1923 foreach($list as $module) { 1924 1925 if (!in_array($module['id'], $modules)) { 1926 continue; 1927 } 1928 1929 $dest = $module['root'].'/../'.basename($module['file']); 1930 1931 # --BEHAVIOR-- themeBeforeUpdate 1932 $this->core->callBehavior('themeBeforeUpdate', $module); 1933 1934 $this->store->process($module['file'], $dest); 1935 1936 # --BEHAVIOR-- themeAfterUpdate 1937 $this->core->callBehavior('themeAfterUpdate', $module); 1938 1939 $count++; 1940 } 1941 1942 $tab = $count && $count == count($list) ? '#themes' : '#update'; 1943 1944 dcPage::addSuccessNotice( 1945 __('Theme has been successfully updated.', 'Themes have been successuflly updated.', $count) 1946 ); 1947 http::redirect($this->getURL().$tab); 1948 } 1949 1950 # Manual actions 1951 elseif (!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file']) 1952 || !empty($_POST['fetch_pkg']) && !empty($_POST['pkg_url'])) 1953 { 1954 if (empty($_POST['your_pwd']) || !$this->core->auth->checkPassword($this->core->auth->crypt($_POST['your_pwd']))) { 1955 throw new Exception(__('Password verification failed')); 1956 } 1957 1958 if (!empty($_POST['upload_pkg'])) { 1959 files::uploadStatus($_FILES['pkg_file']); 1960 1961 $dest = $this->getPath().'/'.$_FILES['pkg_file']['name']; 1962 if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) { 1963 throw new Exception(__('Unable to move uploaded file.')); 1964 } 1965 } 1966 else { 1967 $url = urldecode($_POST['pkg_url']); 1968 $dest = $this->getPath().'/'.basename($url); 1969 $this->store->download($url, $dest); 1970 } 1971 1972 # --BEHAVIOR-- themeBeforeAdd 1973 $this->core->callBehavior('themeBeforeAdd', null); 1974 1975 $ret_code = $this->store->install($dest); 1976 1977 # --BEHAVIOR-- themeAfterAdd 1978 $this->core->callBehavior('themeAfterAdd', null); 1979 1980 dcPage::addSuccessNotice($ret_code == 2 ? 1981 __('Theme has been successfully updated.') : 1982 __('Theme has been successfully installed.') 1983 ); 1984 http::redirect($this->getURL().'#themes'); 1985 } 1986 1860 1987 else { 1861 dcPage::addSuccessNotice( 1862 __('Theme has been successfully deleted.', 'Themes have been successuflly deleted.', $count) 1863 ); 1864 } 1865 http::redirect($this->getURL()); 1866 } 1867 1868 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['install'])) { 1869 1870 if (is_array($_POST['install'])) { 1871 $modules = array_keys($_POST['install']); 1872 } 1873 1874 $list = $this->store->get(); 1875 1876 if (empty($list)) { 1877 throw new Exception(__('No such theme.')); 1878 } 1879 1880 $count = 0; 1881 foreach($list as $id => $module) { 1882 1883 if (!in_array($id, $modules)) { 1884 continue; 1885 } 1886 1887 $dest = $this->getPath().'/'.basename($module['file']); 1888 1889 # --BEHAVIOR-- themeBeforeAdd 1890 $this->core->callBehavior('themeBeforeAdd', $module); 1891 1892 $this->store->process($module['file'], $dest); 1893 1894 # --BEHAVIOR-- themeAfterAdd 1895 $this->core->callBehavior('themeAfterAdd', $module); 1896 1897 $count++; 1898 } 1899 1900 dcPage::addSuccessNotice( 1901 __('Theme has been successfully installed.', 'Themes have been successuflly installed.', $count) 1902 ); 1903 http::redirect($this->getURL()); 1904 } 1905 1906 elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['update'])) { 1907 1908 if (is_array($_POST['update'])) { 1909 $modules = array_keys($_POST['update']); 1910 } 1911 1912 $list = $this->store->get(true); 1913 if (empty($list)) { 1914 throw new Exception(__('No such theme.')); 1915 } 1916 1917 $count = 0; 1918 foreach($list as $module) { 1919 1920 if (!in_array($module['id'], $modules)) { 1921 continue; 1922 } 1923 1924 $dest = $module['root'].'/../'.basename($module['file']); 1925 1926 # --BEHAVIOR-- themeBeforeUpdate 1927 $this->core->callBehavior('themeBeforeUpdate', $module); 1928 1929 $this->store->process($module['file'], $dest); 1930 1931 # --BEHAVIOR-- themeAfterUpdate 1932 $this->core->callBehavior('themeAfterUpdate', $module); 1933 1934 $count++; 1935 } 1936 1937 $tab = $count && $count == count($list) ? '#themes' : '#update'; 1938 1939 dcPage::addSuccessNotice( 1940 __('Theme has been successfully updated.', 'Themes have been successuflly updated.', $count) 1941 ); 1942 http::redirect($this->getURL().$tab); 1943 } 1944 1945 # Manual actions 1946 elseif (!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file']) 1947 || !empty($_POST['fetch_pkg']) && !empty($_POST['pkg_url'])) 1948 { 1949 if (empty($_POST['your_pwd']) || !$this->core->auth->checkPassword($this->core->auth->crypt($_POST['your_pwd']))) { 1950 throw new Exception(__('Password verification failed')); 1951 } 1952 1953 if (!empty($_POST['upload_pkg'])) { 1954 files::uploadStatus($_FILES['pkg_file']); 1955 1956 $dest = $this->getPath().'/'.$_FILES['pkg_file']['name']; 1957 if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) { 1958 throw new Exception(__('Unable to move uploaded file.')); 1959 } 1960 } 1961 else { 1962 $url = urldecode($_POST['pkg_url']); 1963 $dest = $this->getPath().'/'.basename($url); 1964 $this->store->download($url, $dest); 1965 } 1966 1967 # --BEHAVIOR-- themeBeforeAdd 1968 $this->core->callBehavior('themeBeforeAdd', null); 1969 1970 $ret_code = $this->store->install($dest); 1971 1972 # --BEHAVIOR-- themeAfterAdd 1973 $this->core->callBehavior('themeAfterAdd', null); 1974 1975 dcPage::addSuccessNotice($ret_code == 2 ? 1976 __('Theme has been successfully updated.') : 1977 __('Theme has been successfully installed.') 1978 ); 1979 http::redirect($this->getURL().'#themes'); 1980 } 1981 1982 else { 1983 1984 # --BEHAVIOR-- adminModulesListDoActions 1985 $this->core->callBehavior('adminModulesListDoActions', $this, $modules, 'theme'); 1986 1988 1989 # --BEHAVIOR-- adminModulesListDoActions 1990 $this->core->callBehavior('adminModulesListDoActions', $this, $modules, 'theme'); 1991 1992 } 1987 1993 } 1988 1994
Note: See TracChangeset
for help on using the changeset viewer.