public function edit() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Group = D('AuthGroup'); if (IS_POST) { if ($Group->create()) { $data = array('title' => 'A_G_T_' . I('post.id'), 'remark' => 'A_G_R_' . I('post.id'), 'status' => I('post.status') ? 1 : 0); $result = $Group->where('id=' . I('post.id'))->save($data); if ($result !== FALSE) { $info[$data['title']] = I('post.title'); $info[$data['remark']] = addcslashes(I('post.remark', '', NULL), '\'\\'); write_lang($info, 'group_title'); $this->success(L('SAVE_OK'), U('Group/index', $this->vl)); } else { $this->error(L('SAVE_ERROR')); } } else { $this->error($Group->getError()); } } else { $v = $Group->where('id=' . I('get.id'))->find(); $this->assign('v', $v); $this->display(); } }
function do_install() { global $path_to_root, $db_connections, $def_coy, $installed_extensions, $tb_pref_counter, $dflt_lang, $installed_languages; $coa = $_SESSION['inst_set']['coa']; if (install_connect_db() && db_import($path_to_root . '/sql/' . $coa, $_SESSION['inst_set'])) { $con = $_SESSION['inst_set']; $table_prefix = $con['tbpref']; $def_coy = 0; $tb_pref_counter = 0; $db_connections = array(0 => array('name' => $con['name'], 'host' => $con['host'], 'dbuser' => $con['dbuser'], 'dbpassword' => $con['dbpassword'], 'dbname' => $con['dbname'], 'tbpref' => $table_prefix)); $_SESSION['wa_current_user']->cur_con = 0; update_company_prefs(array('coy_name' => $con['name'])); $admin = get_user_by_login('admin'); update_user_prefs($admin['id'], array('language' => $con['lang'], 'password' => md5($con['pass']), 'user_id' => $con['admin'])); if (!copy($path_to_root . "/config.default.php", $path_to_root . "/config.php")) { display_error(_("Cannot save system configuration file 'config.php'.")); return false; } $err = write_config_db($table_prefix != ""); if ($err == -1) { display_error(_("Cannot open 'config_db.php' configuration file.")); return false; } else { if ($err == -2) { display_error(_("Cannot write to the 'config_db.php' configuration file.")); return false; } else { if ($err == -3) { display_error(_("Configuration file 'config_db.php' is not writable. Change its permissions so it is, then re-run installation step.")); return false; } } } // update default language if (file_exists($path_to_root . "/lang/installed_languages.inc")) { include_once $path_to_root . "/lang/installed_languages.inc"; } $dflt_lang = $_POST['lang']; write_lang(); return true; } return false; }
public function edit() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Rule = D('AuthRule'); if (IS_GET) { $map['name'] = array('like', '%/index'); $group = $Rule->where($map)->order('tid,listorder,id')->select(); $v = $Rule->where('id=' . I('get.id'))->find(); $groupname = explode('/', $v['name']); $v['group'] = $groupname[0]; $v['name'] = $groupname[1]; $this->assign('group', $group); $this->assign('v', $v); $this->display('edit'); } elseif (IS_POST) { if ($Rule->create()) { $data = array('name' => I('post.group') . '/' . I('post.name'), 'title' => 'R_' . strtoupper(I('post.group') . '_' . I('post.name')), 'condition' => $_POST['condition'], 'status' => I('post.status') ? 1 : 0); $result = $Rule->where('id=' . I('post.id'))->save($data); if ($result !== FALSE) { write_lang(array($data['title'] => I('post.title')), 'rule_title'); $this->success(L('SAVE_OK'), U('Rule/index', $this->vl)); } else { $this->error(L('SAVE_ERROR')); } } else { $this->error($Rule->getError()); } } }
public function edit() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Field = D('Field'); if (IS_POST) { $mid = I('post.mid'); settype($mid, 'integer'); $module = M('Module')->getFieldById($mid, 'name'); if ($Field->create()) { $data = array('mid' => $mid, 'field' => I('post.field'), 'name' => strtoupper($module) . '_' . strtoupper(I('post.field')), 'tips' => empty(trim(I('post.tips'))) ? '' : strtoupper($module) . '_TIPS_' . strtoupper(I('post.field')), 'required' => empty(I('post.required')) ? 0 : 1, 'minlength' => I('post.minlength'), 'maxlength' => I('post.maxlength'), 'pattern' => I('post.pattern'), 'regex' => trim(I('post.regex')), 'errormsg' => strtoupper($module) . '_ERRORMSG_' . strtoupper(I('post.field')), 'class' => I('post.class'), 'type' => I('post.type'), 'setup' => json_encode(I('post.setup'))); $fid = I('post.id'); $result = $Field->where('id=' . $fid)->save($data); if ($result !== FALSE) { $langs = array($data['name'] => trim(I('post.name')), $data['tips'] => trim(I('post.tips')), $data['errormsg'] => trim(I('post.errormsg'))); write_lang($langs, 'field_common'); if (!I('post.issystem')) { $addFieldSql = $this->execute_sql(I('post.'), 'edit'); $model = new \Think\Model(); if (is_array($addFieldSql)) { foreach ($addFieldSql as $sql) { $res = $model->execute($sql); if ($res === FALSE) { $this->error(L('SQL_ERROR')); } } } else { if ($addFieldSql) { $result = $model->execute($addFieldSql); if ($result === FALSE) { $this->error(L('SQL_ERROR')); } } } } $this->success(L('EDIT_OK'), U('Field/index', $this->vl . '&type=' . I('post.mtype') . '&mid=' . $mid)); } else { $this->error(L('EDIT_ERROR')); } } else { $this->error($Field->getError()); } } else { $vo = $Field->where('id=' . I('get.id'))->find(); $this->assign('vo', $vo); $this->display(); } }
function handle_delete($id) { global $path_to_root, $installed_languages, $dflt_lang; $lang = $installed_languages[$id]['code']; if ($installed_languages[$id]['package']) { if (!uninstall_package($installed_languages[$id]['package'])) { return; } } if ($lang == $dflt_lang) { // on delete set default to current. $dflt_lang = $_SESSION['language']->code; } unset($installed_languages[$id]); $installed_languages = array_values($installed_languages); if (!write_lang()) { return; } $dirname = "{$path_to_root}/lang/{$lang}"; if ($lang && is_dir($dirname)) { // remove nonstadard language dir flush_dir($dirname, true); rmdir($dirname); } }
function update_lang_cfg() { global $dflt_lang, $installed_languages; foreach ($installed_languages as $n => $lang) { if ($lang['code'] == 'en_GB') { $installed_languages[$n] = array('code' => 'C', 'name' => 'English', 'encoding' => 'iso-8859-1', 'path' => '', 'package' => ''); if ($dflt_lang == 'en_GB') { $dflt_lang = 'C'; } write_lang(); } } }
public function edit() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Module = D('Module'); if (IS_POST) { if ($Module->create()) { $data = array('type' => I('post.type'), 'issystem' => I('post.issystem') ? 1 : 0, 'title' => strtoupper(I('post.name')) . '_TITLE', 'name' => ucfirst(I('post.name')), 'description' => strtoupper(I('post.name')) . '_DESCRIPTION'); $befor = $Module->where('id=' . I('post.id'))->find(); $resedit = $Module->where('id=' . I('post.id'))->save($data); if ($resedit === FALSE) { $this->error(L('SAVE_ERROR_' . $data['type'])); } $arrlang = array($data['title'] => I('post.title'), $data['description'] => I('post.description')); write_lang($arrlang, 'module_info'); if ($data['name'] != $befor['name']) { $db = new \Think\Model(); $befortable = C('DB_PREFIX') . strtolower($befor['name']); $aftertable = C('DB_PREFIX') . strtolower($data['name']); $db->execute('RENAME TABLE `' . C('DB_NAME') . '`.`' . $befortable . '` TO `' . C('DB_NAME') . '`.`' . $aftertable . '`;'); $Menu = D('Menu'); $menudata = array('model' => $data['name'], 'name' => 'M_' . strtoupper($data['name']) . '_INDEX'); $menuedit = $Menu->where('model=\'' . $befor['name'] . '\'')->save($menudata); if ($menuedit === FALSE) { $this->error(L('MENU_EDIT_ERROR')); } $menulang = array($menudata['name'] => $arrlang[$data['title']]); write_lang($menulang, 'menu_common'); $Rule = D('AuthRule'); $ruledata = array('name' => $data['name'] . '/index', 'title' => 'R_' . strtoupper($data['name']) . '_INDEX'); $map['name'] = array('like', $befor['name'] . '%'); $ruleedit = $Rule->where($map)->save($ruledata); if ($ruleedit === FALSE) { $this->error(L('RULE_EDIT_ERROR')); } $rulelang = array($ruledata['title'] => $arrlang[$data['title']]); write_lang($rulelang, 'rule_title'); $modules = F('modules'); $res = array_unique($modules); $key = array_search($befor['name'], $res); if ($key !== FALSE) { $res[$key] = $data['name']; } F('modules', $res); } else { write_lang(array('M_' . strtoupper($data['name']) . '_INDEX' => $arrlang[$data['title']]), 'menu_common'); write_lang(array('R_' . strtoupper($data['name']) . '_INDEX' => $arrlang[$data['title']]), 'rule_title'); } $this->success(L('SAVE_OK'), U('Module/index', 'type=' . $data['type'] . '&' . $this->vl)); } else { $this->error($Module->getError()); } } else { $vo = $Module->where('id=' . I('get.id'))->find(); $this->assign('vo', $vo); $this->display(); } }
public function edit() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Menu = D('Menu'); if (IS_GET) { $vo = $Menu->where('id=' . I('get.id'))->find(); $map = $Menu->where('status=1')->select(); foreach ($map as $r) { $r['name'] = L($r['name']); $newmap[] = $r; } $tree = new \Common\Lib\Tree($newmap); $tree->icon = array('<span class="text-muted"> │</span>', '<span class="text-muted"> ├─</span>', '<span class="text-muted"> └─</span>'); $str = "<li data-val='\$id'>\$spacer\$name</li>"; $this->assign('pid', $vo['pid']); $this->assign('map', $tree->get_tree(0, $str)); $this->assign('vo', $vo); $this->display(); } elseif (IS_POST) { if ($Menu->create()) { $mstr = strtoupper(I('post.model')); $astr = strtoupper(I('post.action') ? I('post.action') : 'index'); $pstr = I('post.data') ? '_' . strtoupper(I('post.data')) : ''; $name = 'M_' . $mstr . '_' . $astr . $pstr; $data = array('pid' => I('post.pid'), 'name' => $name, 'icon' => I('post.icon'), 'model' => ucfirst(I('post.model')), 'action' => I('post.action') ? strtolower(I('post.action')) : 'index', 'data' => I('post.data'), 'remark' => I('post.remark'), 'status' => I('post.status') ? 1 : 0, 'listorder' => I('post.listorder')); $result = $Menu->where('id=' . I('post.id'))->save($data); if ($result !== FALSE) { $rname = I('post.realname'); write_lang(array($data['name'] => $rname[LANG_SET]), 'menu_common'); $this->success(L('SAVE_OK'), U('Menu/index', $this->vl)); } else { $this->error(L('SAVE_ERROR')); } } else { $this->error($Menu->getError()); } } }
function handle_delete() { global $path_to_root, $installed_languages; $id = $_GET['id']; $lang = $installed_languages[$id]['code']; $filename = "{$path_to_root}/lang/{$lang}/LC_MESSAGES"; if ($h = opendir($filename)) { while (($file = readdir($h)) !== false) { if (is_file("{$filename}/{$file}")) { unlink("{$filename}/{$file}"); } } closedir($h); } rmdir($filename); $filename = "{$path_to_root}/lang/{$lang}"; if ($h = opendir($filename)) { while (($file = readdir($h)) !== false) { if (is_file("{$filename}/{$file}")) { unlink("{$filename}/{$file}"); } } closedir($h); } rmdir($filename); unset($installed_languages[$id]); $conn = array_values($installed_languages); $installed_languages = $conn; //$$db_connections = array_values($db_connections); if (!write_lang()) { return; } meta_forward($_SERVER['PHP_SELF']); }