function do_edit_save($aid, $params) { $uid = false; if (array_key_exists('id', $params)) { $uid = $params['id']; $pass = trim($params['password']); unset($params['password']); cf\api\admin\doAction($aid, $params); if ($pass) { cf\User::setPassword($uid, $pass); } } else { $uid = cf\User::register($params['login'], $params['password'], $params['name'], $params['email'], $params['descr']); } if (cf\param::exist('roles')) { $roles = array_keys(cf\param::get('roles')); cf\execQuery('DELETE FROM cf_user_roles WHERE user_id=:uid', array('uid' => $uid)); $q = cf\createQuery('INSERT INTO cf_user_roles (user_id,role_id) VALUES(:userId,:roleId)'); $q->setParam('userId', $uid); foreach ($roles as $rid) { $q->setParam('roleId', $rid); $q->execute(); } } }
$db = new cf\Database('mysql:host=' . cf\Config::host, cf\Config::user, cf\Config::pass, 'utf8'); $q = new cf\Query($db); $q->exec("\r\n\t\t\tDROP DATABASE IF EXISTS {$dbName};\r\n\t\t\tCREATE DATABASE {$dbName} DEFAULT CHARACTER SET utf8;\r\n\t\t\tUSE {$dbName};\r\n\t\t"); } require_once dirname(__FILE__) . '/../db.php'; require_once dirname(__FILE__) . '/../user.php'; if (array_key_exists('modules', $_POST)) { foreach ($_POST['modules'] as $module) { $sqlFiles[] = $module; } } foreach ($sqlFiles as $f) { $sql = 'SET storage_engine=MYISAM;' . file_get_contents(dirname(__FILE__) . "/{$f}.sql"); cf\execQuery($sql); } cf\User::register('admin', 'admin', 'Admin'); cf\execQuery("\r\n\t\tINSERT INTO cf_roles (id,name) VALUES('admin','Администраторы');\r\n\t\tINSERT INTO cf_user_roles (role_id,user_id) VALUES('admin',1);\r\n\t\tINSERT INTO cf_role_view_grants (view_id, role_id, can_read) VALUES (NULL,'admin',1);\r\n\t\tINSERT INTO cf_role_action_grants (action_id, role_id, can_execute) VALUES (NULL,'admin',1);\r\n\t"); if ($_REQUEST['run_install_sql']) { cf\execQuery('SET storage_engine=MYISAM;' . file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/install.sql')); } if ($_REQUEST['run_install_php']) { require_once $_SERVER['DOCUMENT_ROOT'] . '/install.php'; } } else { if (array_key_exists('cf_install_db', $_SESSION)) { $dbName = $_SESSION['cf_install_db']; } if (array_key_exists('cf_install_create_db', $_SESSION)) { $createDB = (bool) $_SESSION['cf_install_create_db']; } if (array_key_exists('cf_install_host', $_SESSION)) {