diff --git a/install/default.php b/install/default.php index 11562d4..01b21be 100644 --- a/install/default.php +++ b/install/default.php @@ -46,5 +46,6 @@ return array( 'site_keywords' => '', 'site_description' => '', 'site_window_title' => true, - 'config_version' => 1 + 'config_version' => 1, + 'db_version' => 1 ); \ No newline at end of file diff --git a/languages/ru/dash.php b/languages/ru/dash.php index 65be7a3..24300fa 100644 --- a/languages/ru/dash.php +++ b/languages/ru/dash.php @@ -99,6 +99,7 @@ return array( 'Delete users' => 'Удалять пользователей', 'Upload files' => 'Загружать файлы', 'Delete files' => 'Удалять файлы', + 'Download files' => 'Скачивать файлы', 'View files list' => 'Просматривать список файлов', 'Upload images' => 'Загружать изображения', 'Delete images' => 'Удалять изображения', diff --git a/languages/ru/update.php b/languages/ru/update.php new file mode 100644 index 0000000..1dd404d --- /dev/null +++ b/languages/ru/update.php @@ -0,0 +1,19 @@ + 'Обновить', + 'Zira CMS update wizzard' => 'Мастер обновления Zira CMS', + 'Zira CMS is ready to update.' => 'Zira CMS готова к обновлению.', + 'Database version: %s' => 'Версия базы данных: %s', + 'Database needs to be updated to version: %s' => 'База данных должна быть обновлена до версии: %s', + 'Error' => 'Ошибка', + 'Message' => 'Сообщение', + 'Close' => 'Закрыть', + 'An error occurred' => 'Возникла ошибка', + 'Please wait...' => 'Пожалуйста, подождите...', + 'Please wait' => 'Пожалуйста, подождите', + 'Update in progress' => 'Идёт обновление', + 'Updated successfully!' => 'Успешно обновлено!', + 'An error occurred.' => 'Возникла ошибка.', + 'Database is up to date.' => 'База данных обновлена.' +); \ No newline at end of file diff --git a/update/index.php b/update/index.php new file mode 100644 index 0000000..ad0b02c --- /dev/null +++ b/update/index.php @@ -0,0 +1,219 @@ +shutdown(); + } else if (isset($error['type']) && $error['type']==E_ERROR) { + // trying to log fatal errors + $message = isset($error['message']) ? $error['message'] : 'unknown error'; + $file = isset($error['file']) ? $error['file'] : 'unknown file'; + $line = isset($error['line']) ? $error['line'] : 'unknown line'; + Zira\Log::write('Fatal error: '.$message.' in '.$file.':'.$line); + } +} +register_shutdown_function('shutdown_handler'); + +spl_autoload_extensions('.php'); +spl_autoload_register(); + +try { + \Zira\Config::setSystemDefaults($config); + unset($config); +} catch (Exception $e) { + Zira\Response::exception($e); +} + +$languages = array(); +$d=opendir(ROOT_DIR . DIRECTORY_SEPARATOR . LANGUAGES_DIR); +while(($f=readdir($d))!==false) { + if ($f=='.' || $f=='..') continue; + if (!is_dir(ROOT_DIR . DIRECTORY_SEPARATOR .LANGUAGES_DIR . DIRECTORY_SEPARATOR . $f)) continue; + $languages []= $f; +} +closedir($d); + +$language = Zira\Request::get('lang', 'ru'); +if (!in_array($language, $languages)) $language = 'en'; + +Zira\Log::init(); +Zira\Session::start(); +Zira\Db\Loader::initialize(); +Zira\Db\Db::open(); +Zira\Config::load(); +Zira\Datetime::init(); + +Zira\Locale::load($language, 'update'); +if (Zira\Locale::getLanguage() && Zira\Config::get('db_translates')) { + Zira\Locale::loadDBStrings(); +} + +$version = Zira::VERSION; +$db_version = Zira\Config::get('db_version', 0); + +$v_arr = array(); +$d = opendir(ROOT_DIR . DIRECTORY_SEPARATOR . 'update'); +while(($f = readdir($d))!==false) { + if (!is_dir(ROOT_DIR . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . $f)) continue; + if (strpos($f, 'v')!==0 || strlen($f)<=1) continue; + $v = intval(substr($f, 1)); + if ($v>0 && !in_array($v, $v_arr)) { + $v_arr []= $v; + } +} +sort($v_arr); +$db_update_version = $v_arr[count($v_arr)-1]; + +Zira\View::setTheme(DEFAULT_THEME); +Zira\View::setRenderJsStrings(false); +Zira\View::setRenderBreadcrumbs(false); +Zira\View::addDefaultAssets(); +//Zira\View::addThemeAssets(); +Zira\View::addWidget('\Zira\Widgets\Logo'); + +Zira\Helper::setAddingLanguageToUrl(false); +$html = Zira\Helper::tag_open('ul', array('id'=>'language-switcher')); +foreach($languages as $_language) { + if ($_language == $language) $class='active'; + else $class = ''; + $html .= Zira\Helper::tag_open('li'); + $html .= Zira\Helper::tag('a', Zira\Helper::html(ucfirst($_language)), array('href'=>'?lang='.Zira\Helper::html($_language), 'class'=>$class)); + $html .= Zira\Helper::tag_close('li'); +} +$html .= Zira\Helper::tag_close('ul'); +Zira\View::addHTML($html, Zira\View::VAR_HEADER); + +$step = (int)Zira\Request::post('step', 0); +if ($step>0) { + if($step <= $db_version) { + $response = array('success' => true); + } else if ($step <= $db_update_version) { + try { + Zira\Db\Db::begin(); + $path = ROOT_DIR . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . 'v' . $step . DIRECTORY_SEPARATOR . 'index.php'; + if (file_exists($path)) include($path); + Zira\Models\Option::write('db_version', $step); + Zira\Db\Db::commit(); + $response = array('success' => true); + } catch(\Exception $e) { + Zira\Db\Db::rollback(); + $response = array('error' => $e->getMessage()); + Zira\Log::write($e->getMessage()); + } + } else { + $response = array('error' => Zira\Locale::t('An error occurred.')); + } + echo json_encode($response); + Zira\Session::close(); + exit; +} + +$init_content = Zira\Helper::tag_open('div', array('id'=>'zira-update-container')); + +if ($db_version < $db_update_version) { + $init_content .= Zira\Helper::tag('p', Zira\Locale::t('Database version: %s', $db_version)). + Zira\Helper::tag('p', Zira\Locale::t('Database needs to be updated to version: %s', $db_update_version)). + Zira\Helper::tag('p', Zira\Locale::t('Zira CMS is ready to update.')). + Zira\Helper::tag_open('div', array('style'=>'margin:40px 0px 100px')). + Zira\Helper::tag('button', Zira\Locale::t('Update'), array('class'=>'btn btn-primary', 'id'=>'zira-update-start-btn')). + Zira\Helper::tag_close('div'); + + $init_js = Zira\Helper::tag_open('script',array('type'=>'text/javascript')). + 'zira_strings = {\'Error\':\''.Zira\Locale::t('Error').'\', \'Message\':\''.Zira\Locale::t('Message').'\', \'Close\':\''.Zira\Locale::t('Close').'\', \'Please wait\': \''.Zira\Locale::t('Please wait').'\', \'Updated successfully!\': \''.Zira\Locale::t('Updated successfully!').'\', \'Database is up to date.\': \''.Zira\Locale::t('Database is up to date.').'\'};'. + '(function($){'. + 'zira_update_step = '.$db_version.';'. + 'zira_update_target = '.$db_update_version.';'. + 'zira_update_start_version = zira_update_step;'. + 'zira_update = function() {'. + '$(\'#zira-update-start-btn\').attr(\'disabled\', \'disabled\');'. + 'zira_update_step++;'. + 'zira_modal_progress(\''.Zira\Locale::t('Update in progress').'\');'. + 'zira_update_request(zira_update_step);'. + '};'. + 'zira_update_request = function(step) {'. + 'if (step > zira_update_target) return;'. + '$(\'body\').css(\'cursor\',\'wait\');'. + 'var data = {\'step\': step};'. + 'zira_update_xhr=$.post(\'?lang='.Zira\Helper::html($language).'\', data, function(response){'. + 'if (!response) { zira_error(\''.Zira\Locale::t('An error occurred').'\'); return; }'. + 'if (response.error) {'. + 'zira_modal_progress_hide();'. + 'zira_error(response.error);'. + '}'. + 'if (response.success) {'. + 'var progress_total = zira_update_target - zira_update_start_version;'. + 'var progress_current = zira_update_step - zira_update_start_version;'. + 'var progress_percent = Math.floor(progress_current * 100 / progress_total);'. + 'zira_modal_progress_update(progress_percent);'. + 'if (zira_update_step < zira_update_target) {'. + 'zira_update_step++;'. + 'window.setTimeout(\'zira_update_request(zira_update_step);\',1000);'. + '} else {'. + 'zira_modal_progress_hide();'. + 'zira_message(t(\'Updated successfully!\'));'. + '$(\'#zira-update-container\').text(t(\'Database is up to date.\'));'. + '}'. + '}'. + '$(\'body\').css(\'cursor\',\'default\');'. + '}, \'json\').always(function(){'. + 'if (zira_update_xhr.status != 200) zira_error(\''.Zira\Locale::t('An error occurred').'\'+\'.\');'. + '});'. + '};'. + '$(document).ready(function(){'. + '$(\'#zira-update-start-btn\').click(zira_update);'. + '});'. + '})(jQuery);'. + Zira\Helper::tag_close('script'); +} else { + $init_content .= Zira\Helper::tag('p', Zira\Locale::t('Database is up to date.')); + + $init_js = ''; +} +$init_content .= Zira\Helper::tag_close('div'); + +$view_file = ROOT_DIR . DIRECTORY_SEPARATOR . + THEMES_DIR . DIRECTORY_SEPARATOR . + DEFAULT_THEME . DIRECTORY_SEPARATOR . + 'page.php'; + +$layout_file = ROOT_DIR . DIRECTORY_SEPARATOR . + 'update' . DIRECTORY_SEPARATOR . + 'layout.php'; + +Zira\View::addBodyBottomScript($init_js); + +Zira\View::$data = array( + Zira\View::VAR_TITLE => Zira\Locale::t('Zira CMS update wizzard'), + Zira\View::VAR_CONTENT => $init_content +); + +Zira\View::$view = $view_file; +Zira\View::$layout = $layout_file; + +Zira\View::renderLayout(); +Zira\Session::close(); \ No newline at end of file diff --git a/update/layout.php b/update/layout.php new file mode 100644 index 0000000..132cf5b --- /dev/null +++ b/update/layout.php @@ -0,0 +1,55 @@ + + + + + + + + + + +
+
+
+
+ +
+
+
+
+
+ +
+ + + + +
+ +
+
+ +
+ + + \ No newline at end of file diff --git a/update/table.php b/update/table.php new file mode 100644 index 0000000..35a959b --- /dev/null +++ b/update/table.php @@ -0,0 +1,98 @@ +_table = DB_PREFIX . $table_name; + } + + public function getFields() { + return array(); + } + + public function getKeys() { + return array(); + } + + public function getUnique() { + return array(); + } + + public function getValues() { + return array(); + } + + public function __toString() { + $primary = null; + $fields = array(); + foreach((array)$this->getFields() as $name=>$type) { + if ($type == Field::primary()) $primary = $name; + $fields[]= Db::escapeIdentifier($name).' '.$type; + } + if ($primary!==null) { + $fields[]='PRIMARY KEY ('.Db::escapeIdentifier($primary).')'; + } + foreach((array)$this->getKeys() as $name=>$keys) { + $index='KEY '.Db::escapeIdentifier($name).' ( '; + if (is_string($keys)) $index .= Db::escapeIdentifier($keys); + else if (is_array($keys)) { + for($i=0; $igetUnique() as $name=>$keys) { + $index='UNIQUE KEY '.Db::escapeIdentifier($name).' ( '; + if (is_string($keys)) $index .= Db::escapeIdentifier($keys); + else if (is_array($keys)) { + for($i=0; $i_table).' ( '; + $sql .= implode(', ', $fields); + $sql .= ' ) ENGINE='.$this->getEngine().' DEFAULT CHARSET='.$this->getCharset(); + + return $sql; + } + + public function install() { + // creating table + $query = (string)$this; + Db::query($query); + // inserting default values + foreach((array)$this->getDefaults() as $insert) { + $fields = array(); + $values = array(); + $data = array(); + foreach($insert as $field=>$value) { + $fields[]=Db::escapeIdentifier($field); + $values[]='?'; + $data[]=$value; + } + $query = 'INSERT INTO '.Db::escapeIdentifier($this->_table).' ('.implode(', ',$fields).') VALUES ('.implode(', ',$values).')'; + Db::query($query, $data); + } + } + + public function uninstall() { + $query = 'DROP TABLE IF EXISTS '.DB::escapeIdentifier($this->_table); + Db::query($query); + } +} \ No newline at end of file diff --git a/update/v1/index.php b/update/v1/index.php new file mode 100644 index 0000000..adb1206 --- /dev/null +++ b/update/v1/index.php @@ -0,0 +1,5 @@ +execute(); \ No newline at end of file diff --git a/update/v1/permission.php b/update/v1/permission.php new file mode 100644 index 0000000..ef5dadb --- /dev/null +++ b/update/v1/permission.php @@ -0,0 +1,48 @@ +_table); + } + + public function getValues() { + $superAdminPermissions = \Zira\Install\Permission::getDefaultSuperAdminPermissions(); + $adminPermissions = \Zira\Install\Permission::getDefaultAdminPermissions(); + $userPermissions = \Zira\Install\Permission::getDefaultUserPermissions(); + if (!isset($superAdminPermissions[\Zira\Permission::TO_DOWNLOAD_FILES]) || + !isset($adminPermissions[\Zira\Permission::TO_DOWNLOAD_FILES]) || + !isset($userPermissions[\Zira\Permission::TO_DOWNLOAD_FILES]) + ) return array(); + + return array( + array( + 'id' => null, + 'group_id' => \Zira\User::GROUP_SUPERADMIN, + 'module' => 'zira', + 'name' => \Zira\Permission::TO_DOWNLOAD_FILES, + 'allow' => $superAdminPermissions[\Zira\Permission::TO_DOWNLOAD_FILES] + ), + array( + 'id' => null, + 'group_id' => \Zira\User::GROUP_ADMIN, + 'module' => 'zira', + 'name' => \Zira\Permission::TO_DOWNLOAD_FILES, + 'allow' => $adminPermissions[\Zira\Permission::TO_DOWNLOAD_FILES] + ), + array( + 'id' => null, + 'group_id' => \Zira\User::GROUP_USER, + 'module' => 'zira', + 'name' => \Zira\Permission::TO_DOWNLOAD_FILES, + 'allow' => $userPermissions[\Zira\Permission::TO_DOWNLOAD_FILES] + ) + ); + } +} diff --git a/zira/db/implement/alter.php b/zira/db/implement/alter.php new file mode 100644 index 0000000..93a877c --- /dev/null +++ b/zira/db/implement/alter.php @@ -0,0 +1,57 @@ +_table = DB_PREFIX . $table_name; + } + + public function getName() { + return $this->_table; + } + + public function getFieldsToAdd() { + return array(); + } + + public function getKeysToAdd() { + return array(); + } + + public function getKeysToDrop() { + return array(); + } + + public function getUniqueToAdd() { + return array(); + } + + public function getValues() { + return array(); + } + + public function __toString() { + $fields = array(); + + foreach((array)$this->getKeysToDrop() as $name) { + $fields[]='DROP KEY '.Db::escapeIdentifier($name); + } + + foreach((array)$this->getFieldsToAdd() as $name=>$type) { + $fields[]= 'ADD '.Db::escapeIdentifier($name).' '.$type; + } + + foreach((array)$this->getKeysToAdd() as $name=>$keys) { + $index='KEY '.Db::escapeIdentifier($name).' ( '; + if (is_string($keys)) $index .= Db::escapeIdentifier($keys); + else if (is_array($keys)) { + for($i=0; $igetUniqueToAdd() as $name=>$keys) { + $index='UNIQUE KEY '.Db::escapeIdentifier($name).' ( '; + if (is_string($keys)) $index .= Db::escapeIdentifier($keys); + else if (is_array($keys)) { + for($i=0; $i_table); + $sql .= implode(', ', $fields); + + return $sql; + } + + public function execute() { + // creating query + $query = (string)$this; + Db::query($query); + // inserting new values + foreach((array)$this->getValues() as $insert) { + $fields = array(); + $values = array(); + $data = array(); + foreach($insert as $field=>$value) { + $fields[]=Db::escapeIdentifier($field); + $values[]='?'; + $data[]=$value; + } + $query = 'INSERT INTO '.Db::escapeIdentifier($this->_table).' ('.implode(', ',$fields).') VALUES ('.implode(', ',$values).')'; + Db::query($query, $data); + } + } +} \ No newline at end of file diff --git a/zira/db/mysql/collection.php b/zira/db/mysql/collection.php index 06684c6..cafe6f9 100644 --- a/zira/db/mysql/collection.php +++ b/zira/db/mysql/collection.php @@ -7,7 +7,7 @@ namespace Zira\Db\Mysql; -class Collection { +class Collection implements \Zira\Db\Implement\Collection { protected $_class; protected $_table; protected $_pk; diff --git a/zira/db/mysql/db.php b/zira/db/mysql/db.php index 5e7b45a..10fb950 100644 --- a/zira/db/mysql/db.php +++ b/zira/db/mysql/db.php @@ -9,7 +9,7 @@ namespace Zira\Db\Mysql; use PDO; -class Db { +class Db implements \Zira\Db\Implement\Db { protected static $_db; protected static $_total = 0; diff --git a/zira/db/mysql/field.php b/zira/db/mysql/field.php index 9f26d1a..df7a252 100644 --- a/zira/db/mysql/field.php +++ b/zira/db/mysql/field.php @@ -7,7 +7,7 @@ namespace Zira\Db\Mysql; -abstract class Field { +abstract class Field implements \Zira\Db\Implement\Field { const FIELD_TYPE_TINYINT = 'TINYINT(4)'; const FIELD_TYPE_TINYINT_NOT_NULL = 'TINYINT(4) NOT NULL'; const FIELD_TYPE_TINYINT_UNSIGNED = 'TINYINT(3) UNSIGNED'; diff --git a/zira/db/sqlite.alter.php b/zira/db/sqlite.alter.php new file mode 100644 index 0000000..913c119 --- /dev/null +++ b/zira/db/sqlite.alter.php @@ -0,0 +1,12 @@ +_table = DB_PREFIX . $table_name; + } + + public function getName() { + return $this->_table; + } + + public function getFieldsToAdd() { + return array(); + } + + public function getKeysToAdd() { + return array(); + } + + public function getKeysToDrop() { + return array(); + } + + public function getUniqueToAdd() { + return array(); + } + + public function getValues() { + return array(); + } + + protected function _getAddFieldSQL($name, $type) { + $sql = 'ALTER TABLE '.DB::escapeIdentifier($this->_table).' ADD '.Db::escapeIdentifier($name).' '.$type; + + if ($type == Field::FIELD_TYPE_INT_NOT_NULL) $sql .= ' DEFAULT 0'; + else if ($type == Field::FIELD_TYPE_TEXT_NOT_NULL) $sql .= ' DEFAULT \'\''; + + return $sql; + } + + protected function _getCreateIndexSQL($name, $keys, $unique = false) { + $index=' ( '; + if (is_string($keys)) $index .= Db::escapeIdentifier($keys); + else if (is_array($keys)) { + for($i=0; $i_table.'_'.$name).' ON '.DB::escapeIdentifier($this->_table).$index; + + return $sql; + } + + protected function _getDropIndexSQL($name) { + $sql ='DROP INDEX '.Db::escapeIdentifier($this->_table.'_'.$name); + + return $sql; + } + + public function createIndexes() { + foreach((array)$this->getKeysToAdd() as $name=>$keys) { + $sql = $this->_getCreateIndexSQL($name, $keys); + Db::query($sql); + } + foreach((array)$this->getUniqueToAdd() as $name=>$keys) { + $sql = $this->_getCreateIndexSQL($name, $keys, true); + Db::query($sql); + } + } + + public function dropIndexes() { + foreach((array)$this->getKeysToDrop() as $name) { + $sql = $this->_getDropIndexSQL($name); + Db::query($sql); + } + } + + public function __toString() { + $sql = ''; + foreach((array)$this->getKeysToDrop() as $name) { + $sql .= $this->_getDropIndexSQL($name).';'."\r\n"; + } + foreach((array)$this->getFieldsToAdd() as $name=>$type) { + $sql .= $this->_getAddFieldSQL($name, $type).';'."\r\n"; + } + foreach((array)$this->getKeysToAdd() as $name=>$keys) { + $sql .= $this->_getCreateIndexSQL($name, $keys).';'."\r\n"; + } + foreach((array)$this->getUniqueToAdd() as $name=>$keys) { + $sql .= $this->_getCreateIndexSQL($name, $keys, true).';'."\r\n"; + } + return $sql; + } + + public function execute() { + // dropping indexes + $this->dropIndexes(); + // adding fields + foreach((array)$this->getFieldsToAdd() as $name=>$type) { + $query = $this->_getAddFieldSQL($name, $type); + Db::query($query); + } + // creating indexes + $this->createIndexes(); + // inserting default values + foreach((array)$this->getValues() as $insert) { + $fields = array(); + $values = array(); + $data = array(); + foreach($insert as $field=>$value) { + $fields[]=Db::escapeIdentifier($field); + $values[]='?'; + $data[]=$value; + } + $query = 'INSERT INTO '.Db::escapeIdentifier($this->_table).' ('.implode(', ',$fields).') VALUES ('.implode(', ',$values).')'; + Db::query($query, $data); + } + } +} \ No newline at end of file diff --git a/zira/db/sqlite/collection.php b/zira/db/sqlite/collection.php index c994c2c..2161524 100644 --- a/zira/db/sqlite/collection.php +++ b/zira/db/sqlite/collection.php @@ -7,7 +7,7 @@ namespace Zira\Db\Sqlite; -class Collection { +class Collection implements \Zira\Db\Implement\Collection { protected $_class; protected $_table; protected $_pk; diff --git a/zira/db/sqlite/db.php b/zira/db/sqlite/db.php index 8a0052f..0e49b83 100644 --- a/zira/db/sqlite/db.php +++ b/zira/db/sqlite/db.php @@ -9,7 +9,7 @@ namespace Zira\Db\Sqlite; use PDO; -class Db { +class Db implements \Zira\Db\Implement\Db { protected static $_db; protected static $_total = 0; diff --git a/zira/db/sqlite/field.php b/zira/db/sqlite/field.php index 2734e75..6d68678 100644 --- a/zira/db/sqlite/field.php +++ b/zira/db/sqlite/field.php @@ -7,7 +7,7 @@ namespace Zira\Db\Sqlite; -abstract class Field { +abstract class Field implements \Zira\Db\Implement\Field { const FIELD_TYPE_TINYINT = 'INTEGER'; const FIELD_TYPE_TINYINT_NOT_NULL = 'INTEGER NOT NULL'; const FIELD_TYPE_INT = 'INTEGER'; diff --git a/zira/db/sqlite/table.php b/zira/db/sqlite/table.php index 406e5fa..147d68d 100644 --- a/zira/db/sqlite/table.php +++ b/zira/db/sqlite/table.php @@ -83,10 +83,10 @@ abstract class Table implements \Zira\Db\Implement\Table { public function __toString() { $sql = $this->_getCreateTableSQL().';'; foreach((array)$this->getKeys() as $name=>$keys) { - $sql .= "\r\n". $this->_getCreateIndexSQL($name, $keys); + $sql .= "\r\n". $this->_getCreateIndexSQL($name, $keys).';'; } foreach((array)$this->getUnique() as $name=>$keys) { - $sql .= "\r\n". $this->_getCreateIndexSQL($name, $keys, true); + $sql .= "\r\n". $this->_getCreateIndexSQL($name, $keys, true).';'; } return $sql; } diff --git a/zira/install/permission.php b/zira/install/permission.php index 45c12f0..c095735 100644 --- a/zira/install/permission.php +++ b/zira/install/permission.php @@ -39,7 +39,7 @@ class Permission extends Table { ); } - protected function getDefaultSuperAdminPermissions() { + public static function getDefaultSuperAdminPermissions() { return array( \Zira\Permission::TO_ACCESS_DASHBOARD => 1, \Zira\Permission::TO_EXECUTE_TASKS => 1, @@ -50,6 +50,7 @@ class Permission extends Table { \Zira\Permission::TO_DELETE_USERS => 1, \Zira\Permission::TO_UPLOAD_FILES => 1, \Zira\Permission::TO_DELETE_FILES => 1, + \Zira\Permission::TO_DOWNLOAD_FILES => 1, \Zira\Permission::TO_VIEW_FILES => 1, \Zira\Permission::TO_UPLOAD_IMAGES => 1, \Zira\Permission::TO_DELETE_IMAGES => 1, @@ -63,7 +64,7 @@ class Permission extends Table { ); } - protected function getDefaultAdminPermissions() { + public static function getDefaultAdminPermissions() { return array( \Zira\Permission::TO_ACCESS_DASHBOARD => 1, \Zira\Permission::TO_EXECUTE_TASKS => 0, @@ -74,6 +75,7 @@ class Permission extends Table { \Zira\Permission::TO_DELETE_USERS => 0, \Zira\Permission::TO_UPLOAD_FILES => 0, \Zira\Permission::TO_DELETE_FILES => 0, + \Zira\Permission::TO_DOWNLOAD_FILES => 1, \Zira\Permission::TO_VIEW_FILES => 1, \Zira\Permission::TO_UPLOAD_IMAGES => 1, \Zira\Permission::TO_DELETE_IMAGES => 1, @@ -87,7 +89,7 @@ class Permission extends Table { ); } - protected function getDefaultUserPermissions() { + public static function getDefaultUserPermissions() { return array( \Zira\Permission::TO_ACCESS_DASHBOARD => 0, \Zira\Permission::TO_EXECUTE_TASKS => 0, @@ -98,6 +100,7 @@ class Permission extends Table { \Zira\Permission::TO_DELETE_USERS => 0, \Zira\Permission::TO_UPLOAD_FILES => 0, \Zira\Permission::TO_DELETE_FILES => 0, + \Zira\Permission::TO_DOWNLOAD_FILES => 1, \Zira\Permission::TO_VIEW_FILES => 0, \Zira\Permission::TO_UPLOAD_IMAGES => 0, \Zira\Permission::TO_DELETE_IMAGES => 0, diff --git a/zira/permission.php b/zira/permission.php index b5d2571..b3f41ba 100644 --- a/zira/permission.php +++ b/zira/permission.php @@ -17,6 +17,7 @@ class Permission { const TO_DELETE_USERS = 'Delete users'; const TO_UPLOAD_FILES = 'Upload files'; const TO_DELETE_FILES = 'Delete files'; + const TO_DOWNLOAD_FILES = 'Download files'; const TO_VIEW_FILES = 'View files list'; const TO_UPLOAD_IMAGES = 'Upload images'; const TO_DELETE_IMAGES = 'Delete images'; @@ -41,6 +42,7 @@ class Permission { self::TO_DELETE_USERS, self::TO_UPLOAD_FILES, self::TO_DELETE_FILES, + self::TO_DOWNLOAD_FILES, self::TO_VIEW_FILES, self::TO_UPLOAD_IMAGES, self::TO_DELETE_IMAGES,