¶ VADß EThis file consists of binary data and should not be touched by hands!¶ STICKERß £-
log_enable(1);
¶ community/sql/exec_no_error.sqlß °--
-- exec_no_error.sql
--
-- $Id: exec_no_error.sql,v 1.3 2006/07/03 06:57:39 bdimitrov Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
-------------------------------------------------------------------------------
create procedure ODS.COMMUNITY.exec_no_error(in expr varchar) {
declare state, message, meta, result any;
exec(expr, state, message, vector(), 0, meta, result);
}
;¶ community/sql/install.batß ð@echo off
rem
rem $Id: install.bat,v 1.4 2006/08/14 17:23:51 virtdev Exp $
rem
rem This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
rem project.
rem
rem Copyright (C) 1998-2006 OpenLink Software
rem
rem This project is free software; you can redistribute it and/or modify it
rem under the terms of the GNU General Public License as published by the
rem Free Software Foundation; only version 2 of the License, dated June 1991.
rem
rem This program is distributed in the hope that it will be useful, but
rem WITHOUT ANY WARRANTY; without even the implied warranty of
rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
rem General Public License for more details.
rem
rem You should have received a copy of the GNU General Public License along
rem with this program; if not, write to the Free Software Foundation, Inc.,
rem 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
rem
if "%1" EQU "" goto error
if "%2" EQU "" goto error
isql -b 256 %1 dba %2 run_install.sql -i > errors.out
goto end
:error
echo.
echo Usage: %0 server dba_pwd
echo.
echo Where:
echo 'server' is the address (host:port) of the target virtuoso server
echo 'dba_pwd' is the password for the 'dba' account
echo.
:end
¶ community/sql/procedures.sqlß Z--
-- $Id: procedures.sql,v 1.18 2007/04/10 15:29:05 bdimitrov Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
USE "ODS"
;
create procedure COMMUNITY.SYS_COMMUNITY_EXEC(in params any, in lines any) {
declare _mem_model,_is_public,idx,isDav int;
declare comm_home,_wai_name,err VARCHAR;
declare home_path, template_path, css_path, p_home_path, _vspx_user varchar;
declare frozen, _vspx_user_group,_vspx_uid int;
_vspx_user_group := -1;
_vspx_uid:=-1;
_vspx_user:='';
frozen := 0;
template_path := NULL;
css_path := NULL;
p_home_path := NULL;
_wai_name := NULL;
isDav:=1;
if (isnull(strstr(registry_get('_community_path_'), '/DAV'))) isDav := 0;
idx:=locate('/index.vspx',http_path());
if(idx>0){
comm_home:=substring(http_path(),1,idx);
}else{
comm_home:=http_path();
}
declare continue handler for NOT FOUND {
declare httpmap_ci_home VARCHAR;
httpmap_ci_home:=get_keyword ('comm_home',http_map_get('options'),'');
if(httpmap_ci_home<>''){
declare continue handler for NOT FOUND {http('There is no such instance!');
return;
};
{
select WAI_MEMBER_MODEL,WAI_IS_PUBLIC,WAI_NAME into _mem_model,_is_public,_wai_name
from DB.DBA.WA_INSTANCE, SYS_COMMUNITY_INFO where CI_COMMUNITY_ID=WAI_NAME and CI_HOME = httpmap_ci_home;
}
}else{
http('There is no such instance!');
return;
};
comm_home:=httpmap_ci_home;
};
{
select WAI_MEMBER_MODEL,WAI_IS_PUBLIC,WAI_NAME into _mem_model,_is_public,_wai_name
from DB.DBA.WA_INSTANCE, SYS_COMMUNITY_INFO where CI_COMMUNITY_ID=WAI_NAME and CI_HOME = comm_home;
}
if (_mem_model is null) _mem_model := 0;
if (_is_public is null) _is_public := 0;
-- determine page name
declare page_name varchar;
page_name := get_keyword('page', params, 'index') || '.vspx';
if (page_name = '.vspx') page_name := 'index.vspx';
-- determine home_path, template_path, css_path
declare _state, _params any;
whenever not found goto comm_not_found;
select
CI_HOME,
CI_TEMPLATE,
CI_CSS
into
home_path,
template_path,
css_path
from
SYS_COMMUNITY_INFO
where
CI_HOME = comm_home;
whenever not found goto session_not_found;
select
VS_STATE
into
_state
from
DB.DBA.VSPX_SESSION
where
VS_REALM = cast(get_keyword('realm', params) as varchar) and
VS_SID = cast(get_keyword('sid', params) as varchar);
_params := deserialize(cast(_state as varchar));
if(_params <> ''){
_vspx_user := get_keyword('vspx_user', _params,'');
_vspx_user_group := (select U_GROUP from DB.DBA.SYS_USERS where U_NAME = _vspx_user);
_vspx_uid := (select U_ID from DB.DBA.SYS_USERS where U_NAME = _vspx_user);
}
session_not_found:
frozen := (select WAI_IS_FROZEN from DB.DBA.WA_INSTANCE where WAI_NAME = _wai_name);
if (_vspx_user <> 'dba' and _vspx_user <> 'dav' and _vspx_user_group <> 0)
{
if (frozen = 1)
{
declare redir varchar;
redir := (select WAI_FREEZE_REDIRECT from DB.DBA.WA_INSTANCE where WAI_NAME = _wai_name);
if (redir is null or redir = '' or redir = 'default')
{
http_request_status ('HTTP/1.1 404 Not found');
http ( concat ('',
'
',
'404 Not Found',
'', '
Not Found
',
'Resource ', http_path (page_name), ' not found.'));
return;
}
else
{
http_request_status ('HTTP/1.1 302 Found');
http_header(sprintf('Location: %s\r\n\r\n', redir));
return;
}
}
}
declare is_inst_member int;
is_inst_member:=0;
if(exists (select 1 from DB.DBA.WA_MEMBER where WAM_INST = _wai_name and WAM_USER=_vspx_uid and WAM_STATUS<3)) is_inst_member:=1;
params := vector_concat(params, vector('app_membr_mode', _mem_model, 'is_inst_member', is_inst_member,'is_public',_is_public));
params := vector_concat(params, vector('comm_home', comm_home,'comm_wainame',_wai_name));
p_home_path:=sprintf('/DAV/home/%s%s','tester1',comm_home);
-- determine full template and css path
-- css_path := COMM_MAKE_CSS_LPATH(css_path, home_path);
css_path := COMM_MAKE_CSS_LPATH(css_path, home_path, p_home_path);
if(template_path is null)
template_path := registry_get('_community_path_') || 'www-root/templates/openlink';
template_path := template_path || '/' || page_name;
-- add css_name and comm_home as additional parameters
params := vector_concat(params, vector('css_name', css_path));
-- directly invoke necessary resource
declare error_message any;
error_message := NULL;
if(isDAV){
if(not exists(select 1 from WS.WS.SYS_DAV_RES where RES_FULL_PATH = template_path)) {
-- template disposition doesn't found, use default one
template_path := registry_get('_community_path_') || 'www-root/templates/openlink' || '/' || page_name;
if(not exists(select 1 from WS.WS.SYS_DAV_RES where RES_FULL_PATH = template_path)) {
-- page was not found even in default template
error_message := sprintf('Page: \'%s\' doesn\'t exists even in default template.', page_name);
goto endproc;
}
css_path := COMM_MAKE_CSS_LPATH('');;
params := vector_concat(vector('css_name', css_path), params);
}
}else{
-- Here should be placed the Filesistem check for templates !!!
-- error_message := sprintf('Page: \'%s\' doesn\'t exists even in default template.', page_name);
;
}
-- {
-- declare vspx_dbname, vspx_user, signature varchar;
-- DB.DBA.vspx_get_user_info (vspx_dbname, vspx_user);
-- signature := DB.DBA.vspx_get_signature (vspx_dbname, vspx_user, template_path);
-- if (registry_get (template_path) <> signature)
-- {
-- declare tmpl, xt, xs, ses any;
-- whenever not found goto nft;
-- select RES_CONTENT into tmpl from WS.WS.SYS_DAV_RES where RES_FULL_PATH = template_path
-- and RES_OWNER <> http_dav_uid ();
-- xt := xtree_doc (tmpl, 256, DB.DBA.vspx_base_url (template_path));
-- xslt (XD_GET_PPATH_URL ('www-root/widgets/template_check.xsl'), xt);
-- nft:;
-- }
-- }
DB.DBA.vspx_dispatch(template_path, home_path, params, lines);
return 0;
-- errors handling
comm_not_found:
error_message := sprintf('Community ID for home directory: \'%s\' doesn\'t exists.', home_path);
goto endproc;
error_handler:
error_message := __SQL_MESSAGE;
endproc:
if(error_message) {
http_rewrite();
template_path := registry_get('_community_path_') || 'www-root/templates/openlink/errors.vspx';
params := vector_concat(params, vector('error_message', error_message));
whenever SQLSTATE '*' goto error_error_handler;
DB.DBA.vspx_dispatch(template_path, home_path, params, lines);
}
return;
error_error_handler:
http_value(__SQL_MESSAGE, 'pre');
}
;
create procedure COMMUNITY.COMM_TEMPLATE_SETTINGS(in comm_home any) {
declare template_name, css_name varchar;
template_name := NULL;
css_name := NULL;
select
CI_TEMPLATE,
CI_CSS
into
template_name,
css_name
from
SYS_COMMUNITY_INFO
where
CI_HOME = comm_home;
if(template_name is NULL or length(template_name) = 0) template_name := registry_get('_community_path_') || 'www-root/templates/openlink';
result_names(template_name, css_name);
result(template_name, css_name);
}
;
create procedure COMMUNITY.COMM_GET_ACCESS(in comm_home varchar, inout sid varchar, in realm varchar, in minutes integer default 30) {
declare _usr, _rights, _new_sid any;
_usr := ODS.COMMUNITY.COMM_GET_USER_BY_SESSION(sid, realm, minutes);
_rights := ODS.COMMUNITY.COMM_GET_USER_ACCESS(comm_home, _usr);
return _rights;
}
;
create procedure COMMUNITY.COMM_GET_USER_BY_SESSION(in sid varchar, in realm varchar, in minutes integer default 30) {
declare _last_ip, _cookie_use, _opts, _date_exp, _usr any;
_usr := NULL;
_cookie_use := 0;
whenever not found goto not_found;
select
VS_UID,
VS_EXPIRY,
deserialize(blob_to_string(VS_STATE))
into
_usr,
_date_exp,
_opts
from
DB.DBA.VSPX_SESSION
where
VS_REALM = realm and
VS_SID = sid;
if(_opts is not null) {
_cookie_use := get_keyword('cookie_use', _opts, 0);
_last_ip := get_keyword('last_ip', _opts, '');
}
if(_cookie_use = 0) {
-- take into account session expiration
if(datediff('minute', _date_exp, now()) > minutes) {
_usr := NULL;
}
}
else {
-- take into account initial ip
if(_last_ip <> http_client_ip()) {
_usr := NULL;
}
}
not_found:
return _usr;
}
;
create procedure COMMUNITY.COMM_GET_USER_ACCESS(in comm_home varchar, in usr varchar, in pwd varchar default null)
{
declare _is_public, _role, _status any;
_is_public := 0;
_role := 0;
_status := 0;
-- check if community instance exists
declare _wai_name any;
_wai_name := (select CI_COMMUNITY_ID from ODS.COMMUNITY.SYS_COMMUNITY_INFO where CI_HOME = comm_home);
if(_wai_name is null) signal('WA001', 'Application instance not found.');
-- check if community instance is public
_is_public := (select WAI_IS_PUBLIC from DB.DBA.WA_INSTANCE where WAI_NAME = _wai_name);
if(_is_public is null) _is_public := 0;
if(usr is not null)
{
--checks if the user is administrator
if(exists(select 1 from DB.DBA.SYS_USERS where U_NAME = usr and U_GROUP in (0,3)))
{
return 1;
}
if(exists(select 1 from DB.DBA.SYS_USERS where U_NAME = usr and U_DAV_ENABLE = 1 and U_IS_ROLE = 0)) {
declare _user_id any;
_user_id := (select U_ID from DB.DBA.SYS_USERS where U_NAME = usr);
-- validate password if necessary
if(pwd is not null) {
declare _real_pwd any;
_real_pwd := (select pwd_magic_calc(U_NAME, U_PASSWORD, 1) from DB.DBA.SYS_USERS where U_ID = _user_id);
if(pwd <> _real_pwd) return 0;
}
-- if it's registered user - check his role against current community
-- if several roles assigned to one user - use the best one (minimum value)
_role := (select min(WAM_MEMBER_TYPE) from DB.DBA.WA_MEMBER
where WAM_STATUS <= 2 and WAM_USER = _user_id and WAM_INST = _wai_name
and (WAM_MEMBER_SINCE < now() or WAM_MEMBER_SINCE is null) and (WAM_EXPIRES > now() or WAM_EXPIRES is null));
_status := (select WAM_STATUS from DB.DBA.WA_MEMBER where WAM_USER = _user_id
and WAM_INST = _wai_name and (WAM_MEMBER_SINCE < now() or WAM_MEMBER_SINCE is null)
and (WAM_EXPIRES > now() or WAM_EXPIRES is null));
if(_status = 1) _role := 1; -- owner
if(_role is null) _role := 0;
}
}
commit work;
-- return 0 in no access, 1 if owner, 2 if author, 3 if can read (reader or community is public);
if(_role in (1, 2)) return _role;
if(_is_public) return 3;
return _role;
}
;
create procedure COMMUNITY.COMM_CREATE_SID() {
return md5(concat(datestring(now()), http_client_ip (), http_path ()));
}
;
create procedure COMMUNITY.comm_utf2wide (inout S any )
{
declare exit handler for sqlstate '*' { return S ; } ;
return charset_recode ( S , 'UTF-8' , '_WIDE_' ) ;
}
;
create procedure COMMUNITY.COMM_GET_PPATH_URL (in f any)
{
return concat (
'virt://WS.WS.SYS_DAV_RES.RES_FULL_PATH.RES_CONTENT:',
registry_get('_community_path_'), f);
}
;
create procedure COMMUNITY.COMM_MAKE_CSS_LPATH(in ppath varchar, in home_path varchar := null, in p_home_path varchar := null) {
-- if css is not defined at all : use default one /community/public/css/default.css
if(ppath is null or length(ppath) = 0) return '/community/public/css/default.css';
-- important:
-- if it css defined in home directory : use use relative path like templates/template_name/css_name.css
-- this is to work in sub domains
declare dav_home any;
dav_home := '/DAV/home/';
if(strstr(ppath, dav_home) = 0)
{
declare comm_strid varchar;
comm_strid:=rtrim(replace(home_path,'/community/',''),'/');
-- return '/community/'||subseq(ppath, length(p_home_path));
return sprintf('/community/templates/custom/%s/default.css',comm_strid);
}
-- if it is system defined css : use absolute path like /community/www-root/templates/template_name/css_name.css
return '/community/' || subseq(ppath, strstr(ppath, 'templates/'));
}
;
create procedure COMMUNITY.COMM_DAV_COPY ( in path varchar ,
in destination varchar ,
in uid2 varchar ,
in overwrite integer ,
in file_list any := null
)
{
declare pwd1 any ;
declare _res_id , u_id2 int ;
pwd1 := ( select pwd_magic_calc ( U_NAME , U_PASSWORD , 1 ) from DB . DBA . SYS_USERS where U_NAME = 'dav' ) ;
DB . DBA . DAV_COL_CREATE ( left ( destination , strrchr ( rtrim ( destination , '/' ) , '/' ) + 1 ) , '111100100N' , uid2 , null , 'dav' , pwd1 ) ;
if ( file_list is null ){
_res_id := DB . DBA . DAV_COPY ( path , destination , overwrite , '110100100N' , uid2 , null , 'dav' , pwd1 ) ;
}else{
declare copy_list any ;
DB . DBA . DAV_DELETE ( destination , 1 , 'dav' , pwd1 ) ;
DB . DBA . DAV_COL_CREATE ( destination , '111100100N' , uid2 , null , 'dav' , pwd1 ) ;
copy_list := DB . DBA . DAV_DIR_LIST ( path , 0 , 'dav' , pwd1 ) ;
foreach ( any entry in copy_list ) do
{
declare dest_file any ;
dest_file := entry [ 10 ] ;
if ( regexp_match ( file_list , dest_file ) )
{
_res_id := DB . DBA . DAV_COPY ( path || dest_file , destination || dest_file ,
overwrite , '110100100N' , uid2 , null , 'dav' , pwd1 ) ;
if ( _res_id < 0 )
signal ( '42000' , 'Internal error: Cannot copy WebDAV resource : ' || dest_file ) ;
}
}
}
u_id2 := ( select U_ID from DB . DBA . SYS_USERS where U_NAME = uid2 ) ;
if ( _res_id > 0 ){
declare cur_type , cur_perms varchar ;
declare res_cur cursor for
select RES_PERMS , RES_TYPE from WS . WS . SYS_DAV_RES
where substring ( RES_FULL_PATH , 1 , length ( destination ) ) = destination ;
whenever not found goto next_one ;
open res_cur ( prefetch 1 , exclusive ) ;
while ( 1 ){
fetch res_cur into cur_type , cur_perms ;
update WS . WS . SYS_DAV_RES set RES_OWNER = u_id2 , RES_GROUP = null where current of res_cur ;
if ( cur_perms <> '110100100N' )
update WS . WS . SYS_DAV_RES set RES_PERMS = '110100100N' where current of res_cur ;
commit work ;
}
next_one :
close res_cur ;
}
return _res_id ;
}
;
create procedure COMMUNITY.COMM_USER_DASHBOARD_SP (in uid int, in inst_type varchar, in inst_parent_name varchar)
{
declare inst_name, title, author, url nvarchar;
declare ts datetime;
declare inst web_app;
declare h, ret any;
result_names (inst_name, title, ts, author, url);
for select WAM_INST, WAI_INST, WAM_HOME_PAGE from DB.DBA.WA_MEMBER, DB.DBA.WA_INSTANCE
where WAI_NAME = WAM_INST and WAM_USER = uid and WAM_APP_TYPE = inst_type
and WAI_NAME in (SELECT CM_MEMBER_APP from COMMUNITY_MEMBER_APP WHERE CM_COMMUNITY_ID=inst_parent_name and CM_MEMBER_DATA is null)
do
{
inst := WAI_INST;
h := udt_implements_method (inst, fix_identifier_case ('wa_dashboard_last_item'));
if (h){
ret := call (h) (inst);
if (length (ret)){
declare xp any;
ret := xtree_doc (ret);
xp := xpath_eval ('//*[title]', ret, 0);
foreach (any ret1 in xp) do
{
title := xpath_eval ('string(title/text())', ret1);
ts := xpath_eval ('string (dt/text())', ret1);
author := xpath_eval ('string (from/text())', ret1);
url := xpath_eval ('string (link/text())', ret1);
ts := cast (ts as datetime);
result (WAM_INST, title, ts, author, url);
}
}
}
}
};
create procedure COMMUNITY.COMM_COMMON_DASHBOARD_SP ( in inst_type varchar, in inst_parent_name varchar)
{
declare inst_name, title, author, url nvarchar;
declare ts datetime;
declare inst web_app;
declare h, ret any;
result_names (inst_name, title, ts, author, url);
for select WAM_INST, WAI_INST, WAM_HOME_PAGE from DB.DBA.WA_MEMBER, DB.DBA.WA_INSTANCE
where WAI_NAME = WAM_INST and WAM_APP_TYPE = inst_type
and WAI_NAME in (SELECT CM_MEMBER_APP from COMMUNITY_MEMBER_APP WHERE CM_COMMUNITY_ID=inst_parent_name and CM_MEMBER_DATA is null)
do
{
inst := WAI_INST;
h := udt_implements_method (inst, fix_identifier_case ('wa_dashboard_last_item'));
if (h){
ret := call (h) (inst);
if (length (ret)){
declare xp any;
ret := xtree_doc (ret);
xp := xpath_eval ('//*[title]', ret, 0);
foreach (any ret1 in xp) do
{
title := xpath_eval ('string(title/text())', ret1);
ts := xpath_eval ('string (dt/text())', ret1);
author := xpath_eval ('string (from/text())', ret1);
url := xpath_eval ('string (link/text())', ret1);
ts := cast (ts as datetime);
result (WAM_INST, title, ts, author, url);
}
}
}
}
};
create procedure COMMUNITY.COMM_DATE_FOR_HUMANS(in d datetime) {
declare date_part varchar;
declare time_part varchar;
declare min_diff integer;
declare day_diff integer;
day_diff := datediff ('day', d, now ());
if (day_diff < 1)
{
min_diff := datediff ('minute', d, now ());
if (min_diff = 1)
{
return ('a minute ago');
}
else if (min_diff < 1)
{
return ('less than a minute ago');
}
else if (min_diff < 60)
{
return (sprintf ('%d minutes ago', min_diff));
}
else return (sprintf ('today at %d:%02d', hour (d), minute (d)));
}
if (day_diff < 2)
{
return (sprintf ('yesterday at %d:%02d', hour (d), minute (d)));
}
return (sprintf ('%d/%d/%d %d:%02d', year (d), month (d), dayofmonth (d), hour (d), minute (d)));
}
;
create procedure COMMUNITY.COMM_GET_WA_URL ()
{
declare vhost_str, subdomain_str, domain_str ,port_str varchar;
declare wa_host, wa_lpath, wa_url varchar;
wa_url:='/ods';
vhost_str:=http_map_get('vhost');
if(vhost_str<>'*ini*')
{
if(locate('.',vhost_str)){
subdomain_str:=subseq(vhost_str,0,locate('.',vhost_str)-1);
domain_str := subseq(vhost_str,locate('.',vhost_str));
}else{
domain_str := vhost_str;
}
if(locate(':',domain_str)){
port_str := subseq(domain_str,locate(':',domain_str));
domain_str := subseq(domain_str,0,locate(':',domain_str)-1);
}
whenever not found goto nf;
{
select top 1 WD_HOST, WD_LPATH, WD_LISTEN_HOST into wa_host, wa_lpath,port_str from DB.DBA.WA_DOMAINS where WD_DOMAIN=domain_str;
}
if (locate(':',wa_host))
wa_host:=subseq(wa_host,0,locate(':',wa_host)-1);
wa_url:=sprintf('http://%s%s',wa_host,wa_lpath);
nf:
return wa_url;
}else return '/ods';
}
;
create procedure COMMUNITY.COMM_NEWINST_GET_CUSTOMOPTIONS (in option_type varchar)
{
declare res_name, res_path varchar;
result_names (res_name,res_path);
if (option_type='TEMPLATE_LIST')
{
for
-- select rtrim (WS.WS.COL_PATH (COL_ID), '/') as PATH, COL_NAME as NAME FROM WS.WS.SYS_DAV_COL
-- where WS..COL_PATH (COL_ID) like registry_get('_community_path_') || 'www-root/templates/_*'
select rtrim (WS.WS.COL_PATH (COL_ID), '/') as PATH, COL_NAME as NAME FROM WS.WS.SYS_DAV_COL
where WS..COL_PATH (COL_ID) like '/DAV/VAD/community/' || 'www-root/templates/_*'
do
{
result ( cast( NAME as varchar), cast(PATH as varchar));
}
}else if(option_type='INSTANCE_LOGOS')
{
result ( 'logo_blue','/DAV/VAD/community/www-root/public/images/lightblue/community_blank_thin550.jpg');
result ( 'logo_green','/DAV/VAD/community/www-root/public/images/xdia_nig_banner.jpg');
}else if(option_type='WELCOME_PHOTOS')
{
result ( 'welcome_blue','/DAV/VAD/community/www-root/public/images/lightblue/comm_blank_welcome.png');
result ( 'welcome_green','/DAV/VAD/community/www-root/public/images/welcome_nig_2.gif');
}else result ('','');
};
create procedure COMMUNITY.doPTSW (
in instance_name varchar,
in owner_uname varchar
)
{
declare sioc_url varchar;
sioc_url:=replace (sprintf ('%s/dataspace/%U/community/%U/sioc.rdf', 'http://'||DB.DBA.WA_GET_HOST(), owner_uname, instance_name), '+', '%2B');
for (select WAI_NAME,WAI_DESCRIPTION from DB.DBA.WA_INSTANCE where WAI_NAME = instance_name and WAI_IS_PUBLIC = 1) do {
ODS.DBA.APP_PING (WAI_NAME, coalesce (WAI_DESCRIPTION, WAI_NAME), sioc_url,'The Semantic Web.com');
}
}
;
¶ community/sql/run_install.sqlß ¸--
-- $Id: run_install.sql,v 1.3 2006/08/14 17:23:51 virtdev Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
-- ------------------------------------------------------------------------
-- install.sql
-- Main instalation script.
-- ------------------------------------------------------------------------
-- Start of instalation ---------------------------------------------------
echoln "";
echoln "Job started on " $YYYYMMDD " at " $HHMMSS;
echoln "-------------------------------------------";
echoln "";
load exec_no_error.sql;
load tables.sql;
load procedures.sql;
load wa_install.sql;
DB.DBA.community_install();
-- End --------------------------------------------------------------------
echoln "Job finished on " $YYYYMMDD " at " $HHMMSS;
echoln "-------------------------------------------";
echoln "Check file 'errors.out' in current directory";
echoln "for possible errors during installation.";
echoln "";
¶ community/sql/run_uninstall.sqlß k--
-- $Id: run_uninstall.sql,v 1.2 2006/07/03 06:57:38 bdimitrov Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
-- ------------------------------------------------------------------------
-- run-uninstall.sql
-- Main deinstalation script.
-- ------------------------------------------------------------------------
-- Start of instalation ---------------------------------------------------
echoln "";
echoln "Job started on " $YYYYMMDD " at " $HHMMSS;
echoln "-------------------------------------------";
echoln "";
load wa_uninstall.sql;
-- End --------------------------------------------------------------------
echoln "Job finished on " $YYYYMMDD " at " $HHMMSS;
echoln "-------------------------------------------";
echoln "Check file 'errors.out' in current directory";
echoln "for possible errors during installation.";
echoln "";
¶ community/sql/sioc_xd.sqlß n--
-- $Id: sioc_xd.sql,v 1.16 2007/03/16 13:36:50 mitko Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
use sioc;
create procedure fill_ods_community_sioc (in graph_iri varchar, in site_iri varchar, in _wai_name varchar := null)
{
declare iri, firi varchar;
declare deadl, cnt any;
deadl := 5;
cnt := 0;
declare exit handler for sqlstate '40001' {
if (deadl <= 0)
resignal;
rollback work;
deadl := deadl - 1;
goto l1;
};
l1:
for select CM_COMMUNITY_ID, CM_MEMBER_APP, WAI_TYPE_NAME, WAI_DESCRIPTION
from ODS.COMMUNITY.COMMUNITY_MEMBER_APP, DB.DBA.WA_INSTANCE where WAI_NAME = CM_MEMBER_APP
and ((WAI_IS_PUBLIC = 1 and _wai_name is null) or WAI_NAME = _wai_name)
do
{
firi := xd_iri (CM_COMMUNITY_ID);
iri := forum_iri (WAI_TYPE_NAME, CM_MEMBER_APP);
DB.DBA.RDF_QUAD_URI (graph_iri, iri, sioc_iri ('part_of'), firi);
DB.DBA.RDF_QUAD_URI (graph_iri, firi, sioc_iri ('has_part'), iri);
}
commit work;
};
create trigger COMMUNITY_MEMBER_APP_SIOC_I after insert on ODS.COMMUNITY.COMMUNITY_MEMBER_APP referencing new as N
{
declare iri, firi varchar;
declare graph_iri, site_iri varchar;
declare exit handler for sqlstate '*' {
sioc_log_message (__SQL_MESSAGE);
return;
};
graph_iri := get_graph ();
firi := xd_iri (N.CM_COMMUNITY_ID);
for select WAI_TYPE_NAME, WAI_NAME from DB.DBA.WA_INSTANCE where WAI_NAME = N.CM_MEMBER_APP and WAI_IS_PUBLIC = 1
do
{
iri := forum_iri (WAI_TYPE_NAME, WAI_NAME);
DB.DBA.RDF_QUAD_URI (graph_iri, iri, sioc_iri ('part_of'), firi);
DB.DBA.RDF_QUAD_URI (graph_iri, firi, sioc_iri ('has_part'), iri);
}
return;
};
create trigger COMMUNITY_MEMBER_APP_SIOC_D after delete on ODS.COMMUNITY.COMMUNITY_MEMBER_APP referencing old as O
{
declare iri, firi varchar;
declare graph_iri varchar;
declare exit handler for sqlstate '*' {
sioc_log_message (__SQL_MESSAGE);
return;
};
graph_iri := get_graph ();
firi := xd_iri (O.CM_COMMUNITY_ID);
for select WAI_TYPE_NAME, WAI_NAME from DB.DBA.WA_INSTANCE where WAI_NAME = O.CM_MEMBER_APP and WAI_IS_PUBLIC = 1
do
{
iri := forum_iri (WAI_TYPE_NAME, WAI_NAME);
delete_quad_so (graph_iri, firi, iri);
delete_quad_so (graph_iri, iri, firi);
}
return;
};
create procedure ods_community_sioc_init ()
{
declare sioc_version any;
sioc_version := registry_get ('__ods_sioc_version');
if (registry_get ('__ods_sioc_init') <> sioc_version)
return;
if (registry_get ('__ods_community_sioc_init') = sioc_version)
return;
fill_ods_community_sioc (get_graph (), get_graph ());
registry_set ('__ods_community_sioc_init', sioc_version);
return;
};
--ODS.COMMUNITY.exec_no_error('ods_community_sioc_init ()');
use DB;
use DB;
-- COMMUNITY
wa_exec_no_error ('drop view ODS_COMMUNITIES');
create view ODS_COMMUNITIES as
select
CM_COMMUNITY_ID,
cu.U_NAME as C_OWNER,
CM_MEMBER_APP,
DB.DBA.wa_type_to_app (am.WAM_APP_TYPE) as A_TYPE,
au.U_NAME as A_OWNER
from
ODS.COMMUNITY.COMMUNITY_MEMBER_APP, DB.DBA.WA_MEMBER cm, DB.DBA.WA_MEMBER am, DB.DBA.SYS_USERS cu, DB.DBA.SYS_USERS au
where CM_COMMUNITY_ID = cm.WAM_INST and cm.WAM_USER = cu.U_ID and CM_MEMBER_APP = am.WAM_INST and am.WAM_USER = au.U_ID
and cm.WAM_MEMBER_TYPE = 1 and am.WAM_MEMBER_TYPE = 1;
create procedure sioc.DBA.rdf_community_view_str ()
{
return
'
# Relation between forums and community
sioc:community_forum_iri (DB.DBA.ODS_COMMUNITIES.C_OWNER, DB.DBA.ODS_COMMUNITIES.CM_COMMUNITY_ID)
sioc:has_part
sioc:forum_iri (A_OWNER, A_TYPE, CM_MEMBER_APP) .
sioc:forum_iri (DB.DBA.ODS_COMMUNITIES.A_OWNER, DB.DBA.ODS_COMMUNITIES.A_TYPE, DB.DBA.ODS_COMMUNITIES.CM_MEMBER_APP)
sioc:part_of
sioc:community_forum_iri (C_OWNER, CM_COMMUNITY_ID) .
'
;
};
grant select on ODS_COMMUNITIES to "SPARQL";
-- END COMMUNITY
ODS_RDF_VIEW_INIT ();
¶ community/sql/tables.sqlß
)--
-- $Id: tables.sql,v 1.6 2006/08/14 17:23:51 virtdev Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
--drop table ODS.COMMUNITY.SYS_COMMUNITY_INFO;
--drop table ODS.COMMUNITY.COMMUNITY_MEMBER_APP
ODS.COMMUNITY.exec_no_error('
create table ODS.COMMUNITY.SYS_COMMUNITY_INFO (
CI_COMMUNITY_ID VARCHAR references wa_instance,
CI_OWNER INT,
CI_HOME VARCHAR,
CI_TITLE VARCHAR,
CI_TEMPLATE VARCHAR,
CI_CSS VARCHAR,
primary key (CI_COMMUNITY_ID))
')
;
ODS.COMMUNITY.exec_no_error('ALTER TABLE ODS.COMMUNITY.SYS_COMMUNITY_INFO DROP FOREIGN KEY (CI_COMMUNITY_ID) REFERENCES wa_instance')
;
ODS.COMMUNITY.exec_no_error('ALTER TABLE ODS.COMMUNITY.SYS_COMMUNITY_INFO ADD FOREIGN KEY (CI_COMMUNITY_ID) REFERENCES wa_instance ON UPDATE CASCADE ON DELETE CASCADE')
;
ODS.COMMUNITY.exec_no_error('
create table ODS.COMMUNITY.COMMUNITY_MEMBER_APP (
CM_COMMUNITY_ID VARCHAR references wa_instance,
CM_MEMBER_APP VARCHAR references wa_instance,
CM_MEMBER_DATA ANY,
primary key (CM_COMMUNITY_ID, CM_MEMBER_APP)
)
')
;
ODS.COMMUNITY.exec_no_error('ALTER TABLE ODS.COMMUNITY.COMMUNITY_MEMBER_APP DROP FOREIGN KEY (CM_COMMUNITY_ID) REFERENCES wa_instance')
;
ODS.COMMUNITY.exec_no_error('ALTER TABLE ODS.COMMUNITY.COMMUNITY_MEMBER_APP ADD FOREIGN KEY (CM_COMMUNITY_ID) REFERENCES wa_instance ON UPDATE CASCADE ON DELETE CASCADE')
;
ODS.COMMUNITY.exec_no_error('ALTER TABLE ODS.COMMUNITY.COMMUNITY_MEMBER_APP DROP FOREIGN KEY (CM_MEMBER_APP) REFERENCES wa_instance')
;
ODS.COMMUNITY.exec_no_error('ALTER TABLE ODS.COMMUNITY.COMMUNITY_MEMBER_APP ADD FOREIGN KEY (CM_MEMBER_APP) REFERENCES wa_instance ON UPDATE CASCADE ON DELETE CASCADE')
;
¶ community/sql/uninstall.batß í@echo off
rem
rem $Id: uninstall.bat,v 1.3 2006/07/03 06:57:38 bdimitrov Exp $
rem
rem This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
rem project.
rem
rem Copyright (C) 1998-2006 OpenLink Software
rem
rem This project is free software; you can redistribute it and/or modify it
rem under the terms of the GNU General Public License as published by the
rem Free Software Foundation; only version 2 of the License, dated June 1991.
rem
rem This program is distributed in the hope that it will be useful, but
rem WITHOUT ANY WARRANTY; without even the implied warranty of
rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
rem General Public License for more details.
rem
rem You should have received a copy of the GNU General Public License along
rem with this program; if not, write to the Free Software Foundation, Inc.,
rem 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
rem
if "%1" EQU "" goto error
if "%2" EQU "" goto error
isql %1 dba %2 run_uninstall.sql -i > errors.out
goto end
:error
echo.
echo Usage: %0 server dba_pwd
echo.
echo Where:
echo 'server' is the address (host:port) of the target virtuoso server
echo 'dba_pwd' is the password for the 'dba' account
echo.
:end
¶ community/sql/wa_install.sqlß aš--
-- $Id: wa_install.sql,v 1.14 2007/02/12 17:55:43 bdimitrov Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
USE "ODS"
;
insert replacing DB.DBA.WA_TYPES(WAT_NAME, WAT_DESCRIPTION, WAT_TYPE, WAT_REALM) values ('Community', 'Community', 'ODS.COMMUNITY.wa_community', 'wa')
;
COMMUNITY.exec_no_error('
delete from DB.DBA.WA_MEMBER_TYPE where WMT_APP=''Community''
')
;
insert soft DB.DBA.WA_MEMBER_TYPE (WMT_APP, WMT_NAME, WMT_ID, WMT_IS_DEFAULT) values ('Community', 'community member', 3, 1)
;
-- create new Community application in WA
COMMUNITY.exec_no_error('
create type ODS.COMMUNITY.wa_community under DB.DBA.web_app as (
comm_wainame VARCHAR,
owner INT
)
constructor method wa_community(stream any),
overriding method wa_id_string() returns any,
overriding method wa_new_inst(login varchar) returns any,
overriding method wa_front_page (stream any) returns any,
overriding method wa_home_url() returns varchar,
overriding method wa_drop_instance() returns any,
method apply_custom_settings () returns any,
method wa_vhost_options () returns any
'
)
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add attribute comm_home varchar')
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add overriding method wa_notify_member_changed(in accounter int, in otype int, in ntype int, in odata any, in ndata any, in ostatus any, in nstatus any) returns any')
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add overriding method wa_front_page_as_user(inout stream any, in user_name varchar) returns any')
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add overriding method wa_state_edit_form(stream any) returns any')
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add overriding method wa_addition_urls() returns any')
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add overriding method wa_dashboard () returns any')
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add overriding method wa_dashboard_last_item () returns any')
;
COMMUNITY.exec_no_error('alter type ODS..wa_community add overriding method apply_custom_settings (in template_path varchar, in logoimg_path varchar, in welcomeimg_path varchar) returns any')
;
create constructor method wa_community (inout stream any) for wa_community {
;
}
;
create method wa_drop_instance () for ODS.COMMUNITY.wa_community {
-- *** remove additional end points for the instance
for select HP_HOST, HP_LISTEN_HOST, HP_LPATH from DB.DBA.HTTP_PATH where
HP_PPATH = registry_get('_community_path_')||'www-root/index.vspx' and
HP_OPTIONS=serialize(vector('noinherit', 1,'comm_home',self.comm_home))
do
{
DB.DBA.VHOST_REMOVE(vhost=>HP_HOST, lhost=>HP_LISTEN_HOST, lpath=>HP_LPATH);
}
delete from ODS.COMMUNITY.COMMUNITY_MEMBER_APP WHERE CM_COMMUNITY_ID=self.wa_name;
delete from COMMUNITY.SYS_COMMUNITY_INFO WHERE CI_COMMUNITY_ID = self.wa_name;
delete from DB.DBA.WA_MEMBER where WAM_INST = self.wa_name;
delete from DB.DBA.WA_INSTANCE where WAI_NAME = self.wa_name;
}
;
create procedure COMMUNITY.community_install()
{
declare
iIsDav integer;
declare
sHost varchar;
sHost := registry_get('_community_path_');
if (cast(sHost as varchar) = '0')
sHost := '/xd/';
iIsDav := 1;
if (isnull(strstr(sHost, '/DAV')))
iIsDav := 0;
-- Add a virtual directory for community -----------------------
DB.DBA.VHOST_REMOVE(lpath => '/community');
DB.DBA.VHOST_DEFINE(lpath => '/community',
ppath => concat(sHost, 'www-root/index.vspx'),
opts => vector('noinherit', 1),
vsp_user => 'dba',
def_page => 'index.vspx',
is_dav => iIsDav,
ses_vars => 1
);
DB.DBA.VHOST_REMOVE(lpath => '/community/public');
DB.DBA.VHOST_DEFINE(lpath => '/community/public',
ppath => concat(sHost, 'www-root/public'),
vsp_user => 'dba',
is_brws => 0,
is_dav => iIsDav,
ses_vars => 1
);
DB.DBA.VHOST_REMOVE(lpath => '/community/templates');
DB.DBA.VHOST_DEFINE(lpath => '/community/templates',
ppath => concat(sHost, 'www-root/templates'),
vsp_user => 'dba',
is_brws => 0,
is_dav => iIsDav,
ses_vars => 1
);
--eliminate instances with type DB.DBA.wa_community
for select WAI_ID as _wai_id, WAI_INST as _wai_inst from DB.DBA.WA_INSTANCE WHERE WAI_TYPE_NAME = 'Community' do
{
declare _inst_type varchar;
_inst_type:=cast(udt_instance_of (_wai_inst) as varchar);
if (strstr(_inst_type,'ODS.COMMUNITY.wa_community') is NULL)
{
delete from DB.DBA.WA_INSTANCE A where A.WAI_ID=_wai_id;
}
}
}
;
-- owner makes a new community
create method wa_new_inst (in login varchar) for ODS.COMMUNITY.wa_community {
declare uid, id, _mem_model, num int;
declare descr, home, dav_folder VARCHAR;
{
declare exit handler for not found signal('WA002', 'owner does not exist');
select U_ID into uid from DB.DBA.SYS_USERS where U_NAME = login;
}
if (not exists (select 1 from COMMUNITY.SYS_COMMUNITY_INFO where CI_OWNER = uid)) {
num := 0;
}
else {
num := (select count(1) from COMMUNITY.SYS_COMMUNITY_INFO where CI_OWNER = uid);
}
home := sprintf('/community/%s_community_%d', login, num);
self.comm_wainame := self.wa_name;
self.comm_home := home||'/';
self.owner := uid;
if(self.wa_name is null or length(self.wa_name) = 0) {
signal('WA002', 'self.wa_name can not be empty');
}
insert into DB.DBA.WA_INSTANCE (WAI_NAME, WAI_TYPE_NAME, WAI_INST, WAI_DESCRIPTION, WAI_MEMBER_MODEL)
values (self.wa_name, 'Community', self, descr, _mem_model);
declare tit varchar;
declare path any;
path := registry_get('_community_path_');
declare _U_FULL_NAME, _U_E_MAIL, _U_NAME varchar;
select U_FULL_NAME, U_E_MAIL, U_NAME into _U_FULL_NAME, _U_E_MAIL, _U_NAME from DB.DBA.SYS_USERS where U_ID = uid;
if (length (_U_FULL_NAME))
tit := _U_FULL_NAME || '\'s community';
else
tit := _U_NAME || '\'s community';
insert replacing COMMUNITY.SYS_COMMUNITY_INFO (CI_COMMUNITY_ID, CI_OWNER, CI_TITLE, CI_HOME) values(self.wa_name, uid, tit, home || '/');
-- create DAV directories needed for custom templates
declare pwd any;
declare tmp,col_id int;
pwd := ( select pwd_magic_calc ( U_NAME , U_PASSWORD , 1 ) from DB.DBA.SYS_USERS where U_NAME = 'dav' ) ;
dav_folder := sprintf('/DAV/home/%s/community/',login);
col_id:=DB.DBA.DAV_SEARCH_ID (dav_folder, 'C');
if(col_id<0){
DB . DBA . DAV_COL_CREATE ( dav_folder , '111100100N' , login , 'dav' , 'dav' , pwd ) ;
};
dav_folder := sprintf('%s%s_community_%d/',dav_folder, login, num);
col_id:=DB.DBA.DAV_SEARCH_ID (dav_folder, 'C');
if(col_id<0){
DB . DBA . DAV_COL_CREATE ( dav_folder, '111100100N' , login , null , 'dav' , pwd ) ;
};
dav_folder := sprintf('%stemplates/',dav_folder, login, num);
col_id:=DB.DBA.DAV_SEARCH_ID (dav_folder, 'C');
if(col_id<0){
DB . DBA . DAV_COL_CREATE ( dav_folder, '111100100N' , login , null , 'dav' , pwd ) ;
};
dav_folder := sprintf('%scustom/',dav_folder, login, num);
col_id:=DB.DBA.DAV_SEARCH_ID (dav_folder, 'C');
if(col_id<0){
DB . DBA . DAV_COL_CREATE ( dav_folder, '111100100N' , login , null , 'dav' , pwd ) ;
};
-- end create DAV directories
declare iIsDav integer;
if (cast(path as varchar) = '0')
path := '/xd/';
iIsDav := 1;
if (isnull(strstr(path, '/DAV')))
iIsDav := 0;
-- BEGIN create vhost if custom endpoint is used
declare custom_ednpoint varchar;
custom_ednpoint:=connection_get('community_customendpoint');
if( length(custom_ednpoint)>0 and (custom_ednpoint not like '/community/%') ){
-- Add a virtual directory for community -----------------------
DB.DBA.VHOST_REMOVE(lpath => custom_ednpoint);
DB.DBA.VHOST_DEFINE(lpath => custom_ednpoint,
ppath => concat(path, 'www-root/index.vspx'),
opts => vector('noinherit', 1,'comm_home',self.comm_home),
vsp_user => 'dba',
def_page => 'index.vspx',
is_dav => iIsDav,
ses_vars => 1
);
}
-- END create vhost if custom endpoint is used
-- BEGIN create vhost for custom template
if(iIsDav){
DB.DBA.VHOST_REMOVE(lpath => sprintf('/community/templates/custom/%s_community_%d', login, num));
DB.DBA.VHOST_DEFINE(lpath => sprintf('/community/templates/custom/%s_community_%d', login, num),
ppath => rtrim ( dav_folder , '/' ),
vsp_user => 'dba',
is_brws => 0,
is_dav => iIsDav,
ses_vars => 1
);
}
-- END create vhost for custom template
-- call parent method to make wa level membership management action
return (self as DB.DBA.web_app).wa_new_inst(login);
}
;
create method wa_front_page (inout stream any) for ODS.COMMUNITY.wa_community
{
declare home, sid, vspx_user VARCHAR;
declare vspx_uid int;
select CI_HOME into home from COMMUNITY.SYS_COMMUNITY_INFO WHERE CI_COMMUNITY_ID = self.wa_name and CI_OWNER = self.owner;
if (home not like '%/' and home <> '/') home := home || '/';
if (home not like '/%' and home <> '/') home := '/'||home;
vspx_user:=connection_get ('vspx_user');
SELECT U_ID into vspx_uid FROM DB.DBA.SYS_USERS WHERE U_NAME=vspx_user;
sid := md5 (concat (datestring (now ()), http_client_ip (), http_path ()));
insert into DB.DBA.VSPX_SESSION (VS_REALM, VS_SID, VS_UID, VS_STATE, VS_EXPIRY)
values ('wa', sid, connection_get ('vspx_user'),
serialize (
vector (
'vspx_user', vspx_user,
'uid', vspx_uid,
'comm_wainame' , self.wa_name,
'comm_home' , self.comm_home,
'go_to_wa', 'yes'
)
), now());
http_request_status ('HTTP/1.1 302 Found');
http_header (sprintf('Location: %sindex.vspx?page=index&sid=%s&realm=wa\r\n', home, sid));
return;
}
;
create method wa_state_edit_form (inout stream any) for ODS..wa_community
{
declare home, sid, phome, owner_name,home_root varchar;
declare owner_uid int;
select CI_HOME, U_NAME,U_ID into home, owner_name,owner_uid from ODS..SYS_COMMUNITY_INFO, DB.DBA.SYS_USERS
where CI_COMMUNITY_ID = self.wa_name and CI_OWNER = self.owner and U_ID = CI_OWNER;
phome := registry_get('_community_path_');
if (cast(phome as varchar) = '0'){
phome := '/xd/';
};
phome:=concat(phome, 'www-root/index.vspx');
if (is_http_ctx ())
{
declare vh, lh any;
vh := http_map_get ('vhost');
lh := http_map_get ('lhost');
declare exit handler for not found
{
signal ('NOPAT', 'You do not have any virtual directory defined within current domain. Please define one.');
};
select HP_LPATH INTO home_root from DB.DBA.HTTP_PATH where HP_HOST = vh and HP_LISTEN_HOST = lh and HP_PPATH = phome;
}
sid := connection_get ('wa_sid');
-- sid:=NULL;
if (sid is null)
{
sid := md5 (concat (datestring (now ()), http_client_ip (), http_path ()));
insert into DB.DBA.VSPX_SESSION (VS_REALM, VS_SID, VS_UID, VS_STATE, VS_EXPIRY)
values ('wa', sid, owner_name,
serialize (
vector (
'vspx_user', owner_name,
'uid', owner_uid,
'comm_wainame' , self.wa_name,
'comm_home' , home,
'go_to_wa', 'yes'
)
), now());
}
http_request_status ('HTTP/1.1 302 Found');
http_header (sprintf('Location: %sindex.vspx?page=settings&sid=%s&realm=wa\r\n', home, sid));
return;
}
;
create method wa_front_page_as_user (inout stream any, in user_name varchar) for ODS..wa_community
{
declare home, sid, phome, owner_name,home_root varchar;
declare owner_uid int;
select CI_HOME, U_NAME,U_ID into home, owner_name,owner_uid from ODS..SYS_COMMUNITY_INFO, DB.DBA.SYS_USERS
where CI_COMMUNITY_ID = self.wa_name and CI_OWNER = self.owner and U_ID = CI_OWNER;
phome := registry_get('_community_path_');
if (cast(phome as varchar) = '0'){
phome := '/xd/';
};
phome:=concat(phome, 'www-root/index.vspx');
if (is_http_ctx ())
{
declare vh, lh any;
vh := http_map_get ('vhost');
lh := http_map_get ('lhost');
declare exit handler for not found
{
signal ('NOPAT', 'You do not have any virtual directory defined within current domain. Please define one.');
};
select HP_LPATH INTO home_root from DB.DBA.HTTP_PATH where HP_HOST = vh and HP_LISTEN_HOST = lh and HP_PPATH = phome;
}
-- sid := connection_get ('wa_sid');
sid:=NULL;
if (sid is null)
{
sid := md5 (concat (datestring (now ()), http_client_ip (), http_path ()));
insert into DB.DBA.VSPX_SESSION (VS_REALM, VS_SID, VS_UID, VS_STATE, VS_EXPIRY)
values ('wa', sid, owner_name,
serialize (
vector (
'vspx_user', owner_name,
'uid', owner_uid,
'comm_wainame' , self.wa_name,
'comm_home' , home,
'go_to_wa', 'yes'
)
), now());
}
http_request_status ('HTTP/1.1 302 Found');
http_header (sprintf('Location: %sindex.vspx?page=index&sid=%s&realm=wa\r\n', home, sid));
return;
}
;
create method wa_home_url () for ODS.COMMUNITY.wa_community {
declare uri varchar;
uri := null;
whenever not found goto endf;
select CI_HOME into uri from ODS.COMMUNITY.SYS_COMMUNITY_INFO where CI_COMMUNITY_ID = self.wa_name;
endf:
return uri;
}
;
create method wa_vhost_options () for ODS.COMMUNITY.wa_community
{
declare iIsDav integer;
declare sHost VARCHAR;
iIsDav := 1;
sHost := registry_get('_community_path_');
if (cast(sHost as varchar) = '0')
sHost := '/xd/';
if (isnull(strstr(sHost, '/DAV')))
iIsDav := 0;
return
vector
(
concat(sHost, 'www-root/index.vspx'), -- physical home
'index.vspx', -- default page
'dba', -- user for execution
0, -- directory browsing enabled
iIsDav, -- WebDAV repository
vector('noinherit', 1,'comm_home',self.comm_home), -- virtual directory options
null, -- post-processing function
null -- pre-processing (authentication) function
);
};
create method wa_notify_member_changed (in accounter int, in otype int, in ntype int, in odata any, in ndata any, in ostatus any, in nstatus any) for ODS.COMMUNITY.wa_community
{
(self as DB.DBA.web_app).wa_notify_member_changed (accounter,otype,ntype,odata,ndata,ostatus,nstatus);
-- tuka e miastoto na moit gluposti
if(otype is NULL and ntype is not NULL){
declare app_id,action VARCHAR;
for(SELECT CM_MEMBER_APP from COMMUNITY_MEMBER_APP WHERE CM_COMMUNITY_ID=self.wa_name and CM_MEMBER_DATA is null) do {
app_id:=CM_MEMBER_APP;
declare _wai_name, acc_type, app_type any;
_wai_name:=app_id;
declare exit handler for sqlstate '*', not found
{
self.vc_is_valid := 0;
declare _use_sys_errors, _sys_error, _error any;
dbg_obj_print (__SQL_STATE,__SQL_MESSAGE);
if (isstring (__SQL_STATE))
_sys_error := WA_RETRIEVE_MESSAGE(concat(__SQL_STATE,' ',__SQL_MESSAGE));
else
_sys_error := '';
_error := 'Due to a transient problem in the system, your join request could not be
processed at the moment. The system administrators have been notified. Please
try again later';
_use_sys_errors := (select top 1 WS_SHOW_SYSTEM_ERRORS from DB.DBA.WA_SETTINGS);
if (_use_sys_errors)
self.vc_error_message := _error || ' ' || _sys_error;
else
self.vc_error_message := _error;
rollback work;
return;
};
select WAI_TYPE_NAME into app_type from DB.DBA.WA_INSTANCE where WAI_NAME = _wai_name;
acc_type := (select max(WMT_ID) from DB.DBA.WA_MEMBER_TYPE where WMT_APP = app_type);
if(not exists(select 1 from DB.DBA.WA_MEMBER where WAM_USER=accounter and WAM_INST=_wai_name)){
insert into DB.DBA.WA_MEMBER(WAM_USER, WAM_INST, WAM_MEMBER_TYPE, WAM_STATUS)
values (accounter, _wai_name, acc_type, 2);
}
}
}
};
ODS.COMMUNITY.exec_no_error('
create trigger WA_INSTANCE_COMMUNITY_WAINAME_UP after update (WAI_NAME) on DB.DBA.WA_INSTANCE referencing old as O, new as N
{
if(O.WAI_TYPE_NAME=''Community''){
update ODS.COMMUNITY.SYS_COMMUNITY_INFO set CI_COMMUNITY_ID = N.WAI_NAME where CI_COMMUNITY_ID = O.WAI_NAME;
update ODS.COMMUNITY.COMMUNITY_MEMBER_APP set CM_COMMUNITY_ID = N.WAI_NAME where CM_COMMUNITY_ID = O.WAI_NAME;
};
}
');
--drop trigger WA_INSTANCE_COMMUNITY_WAINAME_UP;
create method wa_addition_urls () for ODS.COMMUNITY.wa_community
{
declare iIsDav integer;
declare path,dav_ownerhome,comm_strid,owner_uname varchar;
path := registry_get('_community_path_');
select A.CI_HOME,B.U_NAME into dav_ownerhome,owner_uname from ODS.COMMUNITY.SYS_COMMUNITY_INFO A LEFT JOIN DB.DBA.SYS_USERS B on CI_OWNER=U_ID where CI_COMMUNITY_ID=self.wa_name;
comm_strid := rtrim(replace(dav_ownerhome,'/community/',''),'/');
dav_ownerhome := sprintf('/DAV/home/%s/community/%s/templates/custom',owner_uname,comm_strid);
if (cast(path as varchar) = '0') path := '/xd/';
iIsDav := 1;
if (isnull(strstr(path, '/DAV'))) iIsDav := 0;
return vector(
vector(null, null, '/community/public', path || 'www-root/public', iIsDav, 0, null, null, null, null, 'dba', null, null, 1, null, null, null, 0),
vector(null, null, '/community/templates', path || 'www-root/templates', iIsDav, 0, null, null, null, null, 'dba', null, null, 1, null, null, null, 0),
vector(null, null, '/community/templates/custom/'||comm_strid,dav_ownerhome , iIsDav, 0, null, null, null, null, 'dba', null, null, 1, null, null, null, 0)
);
}
;
create method wa_dashboard () for ODS.COMMUNITY.wa_community
{
return ( select
XMLAGG(XMLELEMENT('dash-row',
XMLATTRIBUTES('normal' as "class", ODS.COMMUNITY.COMM_DATE_FOR_HUMANS(WAI_MODIFIED) as "time", WAI_NAME as "application"),
XMLELEMENT('dash-data',
XMLATTRIBUTES(sprintf('%s', WAM_HOME_PAGE, WAI_NAME) as "content")
)
)
)
from
(
select top 10 WAI_NAME, WAM_HOME_PAGE, WAI_MODIFIED
from DB.DBA.WA_MEMBER M
left join DB.DBA.WA_INSTANCE I on M.WAM_INST=I.WAI_NAME
where WAM_APP_TYPE = 'Community' and WAM_STATUS = 1 and WAM_IS_PUBLIC=1
order by WAI_MODIFIED desc
) T
);
}
;
create method wa_dashboard_last_item () for ODS.COMMUNITY.wa_community
{
declare ses any;
ses := string_output ();
http ('', ses);
for
select top 10 WAI_NAME, WAM_HOME_PAGE, WAI_MODIFIED, U_NAME, U_FULL_NAME
from DB.DBA.WA_MEMBER M
left join DB.DBA.WA_INSTANCE I on M.WAM_INST=I.WAI_NAME
left join DB.DBA.SYS_USERS U on U.U_ID=M.WAM_USER
where WAM_APP_TYPE = 'Community' and WAM_STATUS = 1 and WAM_IS_PUBLIC=1
and WAI_NAME = self.wa_name
order by WAI_MODIFIED desc
do {
declare uname, full_name , comm_link varchar;
uname := coalesce (U_NAME, '');
full_name := coalesce (coalesce (U_FULL_NAME, U_NAME), '');
comm_link:=sprintf('%s', WAM_HOME_PAGE, WAI_NAME);
http ('', ses);
http (sprintf ('
%s
', DB.DBA.date_iso8601 (WAI_MODIFIED)), ses);
http (sprintf ('', WAI_NAME), ses);
http (sprintf ('%s', WAM_HOME_PAGE), ses);
http (sprintf ('', full_name), ses);
http (sprintf ('', uname), ses);
http ('', ses);
}
http ('', ses);
return string_output_string (ses);
};
create method apply_custom_settings ( in template_path varchar, in logoimg_path varchar, in welcomeimg_path varchar) for ODS.COMMUNITY.wa_community
{
declare customtemplate_path,customtemplate_lpath varchar;
customtemplate_path:='';
customtemplate_path:=subseq(logoimg_path,0,strrchr(logoimg_path,'/'));
customtemplate_lpath:='';
select top 1 HP_LPATH into customtemplate_lpath from DB.DBA.HTTP_PATH where HP_PPATH=customtemplate_path;
declare src any;
src := (select blob_to_string (RES_CONTENT) from WS.WS.SYS_DAV_RES where RES_FULL_PATH = template_path||'/index.vspx');
declare xt, xs any;
declare exit handler for sqlstate '*'
{
dbg_obj_print(cast(now() as varchar)||' - xslt error - ',regexp_match ('[^\r\n]*', __SQL_MESSAGE));
return;
};
xt := xtree_doc (src, 256, DB.DBA.vspx_base_url (customtemplate_lpath || '/index.vspx'));
xt := xslt (ODS..COMM_GET_PPATH_URL ('www-root/widgets/apply_custom_settings.xsl'), xt, vector('custom_imgpath', customtemplate_lpath||'/','logo_img',subseq(logoimg_path,strrchr(logoimg_path,'/')+1),'welcome_img',customtemplate_lpath||'/'||subseq(welcomeimg_path,strrchr(logoimg_path,'/')+1) ));
-- xt := xslt ('file:xd\\www-root\\widgets\\apply_custom_settings.xsl', xt, vector('custom_imgpath', customtemplate_lpath||'/','logo_img',subseq(logoimg_path,strrchr(logoimg_path,'/')+1),'welcome_img',customtemplate_lpath||'/'||subseq(welcomeimg_path,strrchr(logoimg_path,'/')+1) ));
declare _stream any;
_stream := string_output();
http_value(xt,null,_stream);
DB.DBA.DAV_DELETE (customtemplate_path || '/index.vspx', 0, 'dav', 'dav');
DB.DBA.YACUTIA_DAV_RES_UPLOAD(customtemplate_path || '/index.vspx',string_output_string(_stream),'application/x-openlinksw-vspx+xml','110100100R','dav','dav');
DB.DBA.DAV_DELETE (customtemplate_path || '/default.css', 0, 'dav', 'dav');
DB.DBA.YACUTIA_DAV_COPY(template_path||'/default.css', customtemplate_path || '/default.css', 1, '110100100R','dav','dav');
update ODS.COMMUNITY.SYS_COMMUNITY_INFO
set
CI_TEMPLATE=customtemplate_path ,
CI_CSS=customtemplate_path ||'/default.css'
where
CI_COMMUNITY_ID = self.wa_name;
-- update ODS.COMMUNITY.SYS_COMMUNITY_INFO
-- set
-- CI_TEMPLATE=template_path ,
-- CI_CSS=template_path ||'/default.css'
-- where
-- CI_COMMUNITY_ID = self.wa_name;
return;
};
¶ community/sql/wa_uninstall.sqlß --
-- $Id: wa_uninstall.sql,v 1.5 2006/08/14 17:23:52 virtdev Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
USE "ODS"
;
create procedure COMMUNITY.community_uninstall()
{
for select WAI_INST from DB.DBA.WA_INSTANCE WHERE WAI_TYPE_NAME = 'Community' do
{
(WAI_INST as ODS.COMMUNITY.wa_community).wa_drop_instance();
}
}
;
community_uninstall()
;
drop procedure COMMUNITY.community_uninstall
;
DB.DBA.vhost_remove(lpath=>'/community/public')
;
DB.DBA.vhost_remove(lpath=>'/community/templates')
;
DB.DBA.vhost_remove(lpath=>'/community')
;
DELETE FROM DB.DBA.WA_MEMBER WHERE WAM_INST IN (SELECT WAI_NAME FROM DB.DBA.WA_INSTANCE WHERE WAI_TYPE_NAME = 'Community')
;
DELETE FROM DB.DBA.WA_INSTANCE WHERE WAI_TYPE_NAME = 'Community'
;
DELETE FROM DB.DBA.WA_MEMBER_TYPE WHERE WMT_APP = 'Community'
;
drop type wa_community
;
DELETE FROM DB.DBA.WA_TYPES WHERE WAT_NAME = 'Community'
;
drop table ODS.COMMUNITY.SYS_COMMUNITY_INFO
;
drop table ODS.COMMUNITY.COMMUNITY_MEMBER_APP
;
drop trigger DB.DBA.WA_INSTANCE_COMMUNITY_WAINAME_UP
;
-- Procedures
create procedure COMMUNITY._drop_procedures()
{
for (select P_NAME from DB.DBA.SYS_PROCEDURES where P_NAME like 'ODS.COMMUNITY.%') do {
if (P_NAME not in ('ODS.COMMUNITY.exec_no_error', 'ODS.COMMUNITY._drop_procedures'))
ODS.COMMUNITY.exec_no_error(sprintf('drop procedure %s', P_NAME));
}
}
;
-- dropping procedures for COMMUNITY
COMMUNITY._drop_procedures();
COMMUNITY.exec_no_error('DROP procedure ODS.COMMUNITY._drop_procedures');
COMMUNITY.exec_no_error('DROP procedure ODS.COMMUNITY.exec_no_error');
¶ community/www-root/index.vspß Ñ
¶ community/www-root/index.vspxß ~
¶ -community/www-root/public/aboutcommunity.htmlß Æ
About Us page