Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xml-rpc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
xml-rpc
Commits
4fae617d
Commit
4fae617d
authored
Feb 01, 2010
by
po34devklaus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-- cleaned up - moved gtd stuff to intranet-gtd-dashboard
parent
4928f64a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
185 deletions
+0
-185
xml-rpc-procs.tcl
tcl/xml-rpc-procs.tcl
+0
-185
No files found.
tcl/xml-rpc-procs.tcl
View file @
4fae617d
...
@@ -21,191 +21,6 @@ ad_library {
...
@@ -21,191 +21,6 @@ ad_library {
namespace
eval xmlrpc-rest
{}
namespace
eval xmlrpc-rest
{}
ad_register_proc GET /intranet-xmlrpc/rest/* xmlrpc-rest::dispatchRest
ad_register_proc POST /intranet-xmlrpc/rest/* xmlrpc-rest::dispatchRest
ad_proc -public xmlrpc-rest::dispatchRest
{}
{
@return dispatches REST requests
@author Klaus Hofeditz
}
{
set user_id
[
ad_maybe_redirect_for_registration
]
set urlpieces
[
ns_conn urlv
]
set path
[
lrange
$urlpieces
2
[
llength
$urlpieces
]]
set url_query
[
ns_conn query
]
set header_vars
[
ns_conn form
]
set var_list
[
ad_ns_set_keys
$header
_vars
]
switch
[
lindex
$urlpieces
2
]
{
companies
{
return
[
xmlrpc-rest::handle_rest_company
[
ns_conn method
]
$path
$url
_query
$user
_id
]
}
timesheet
{
doc_return 200
"text/plain"
[
xmlrpc-rest::handle_rest_timesheet
[
ns_conn method
]
$path
$url
_query
$user
_id
]
}
projects
{
doc_return 200
"text/plain"
[
xmlrpc-rest::handle_rest_project
[
ns_conn method
]
$path
$url
_query
$user
_id
]
}
action_items
{
doc_return 200
"text/plain"
[
xmlrpc-rest::handle_action_items
[
ns_conn method
]
$path
$url
_query
$user
_id
]
}
default
{
ad_return_complaint 1
"ressource not available"
}
}
}
ad_proc -public xmlrpc-rest::handle_rest_timesheet
{
method path url_query user_id
}
{
handles timesheet actions
}
{
# doc_return 200
"text/plain"
[
lindex
$path
1
]
# doc_return 200
"text/plain"
"
$method
$path
$url
_query
$param
"
set query_list
[
split
$url
_query &
]
foreach sub_list
$query
_list
{
set query_item
[
split
$sub
_list =
]
if
{
"scope"
==
[
lindex
$query
_item 0
]
}
{
set scope
[
lindex
$query
_item 1
]
}
else
if
{
"hours"
==
[
lindex
$query
_item 0
]
}
{
set hours
[
lindex
$query
_item 1
]
}
else
if
{
"hours_curr"
==
[
lindex
$query
_item 0
]
}
{
set hours_curr
[
lindex
$query
_item 1
]
}
}
set task_id
[
lindex
$path
1
]
if
{
"GET"
==$method
}
{
if
{
"today"
==$scope
}
{
doc_return 200
"text/plain"
[
db_string get_view_id
"select hours from im_hours where day::date = now()::date and project_id=
$task
_id"
-default 0
]
}
}
else
if
{
"POST"
==$method
}
{
if
{
"0"
!=$hours_curr
}
{
db_dml update
"update im_hours set hours =
$hours
where day::date = now()::date and project_id=
$task
_id"
}
else
{
set default_currency
[
ad_parameter -package_id
[
im_package_cost_id
]
"DefaultCurrency"
""
"EUR"
]
set billing_rate 0
set billing_currency
""
db_0or1row get_billing_rate
"
select hourly_cost as billing_rate,
currency as billing_currency
from im_employees
where employee_id =
$user
_id
"
if
{
""
==
$billing
_currency
}
{
set billing_currency
$default
_currency
}
set day_julian
[
db_string sysdate_as_julian
"select to_char(sysdate,'J') from dual"
]
db_dml hours_insert
"
insert into im_hours (
user_id, project_id,
day, hours,
billing_rate, billing_currency
) values (
$user
_id,
$task
_id,
to_date(:day_julian,'J'),
$hours
,
:billing_rate, :billing_currency
)"
}
}
}
ad_proc -public xmlrpc-rest::handle_action_items
{
method path url_query user_id
}
{
@return project list / task list
}
{
set header_vars
[
ns_conn form
]
set var_list
[
ad_ns_set_keys
$header
_vars
]
ad_ns_set_to_tcl_vars
$header
_vars
if
{
""
!=
$item
_list
}
{
return
[
gtd-dashboard::write_gtd_list
$item
_list
$user
_id
]
}
else
{
return
"error: not items found"
}
}
ad_proc -public xmlrpc-rest::render_json
{
object_list search_string
}
{
@tkes a list of objects returns them as a json structure
}
{
#
set output
"
\{\"
ResultSet
\"
:
\n\{\n\"
Result
\"
:
\[\n
"
# set output "\[\n"
foreach sub_list
$object
_list
{
if
{
[
llength
$sub
_list
]
}
{
if
{
0 !=
[
llength
[
lindex
$sub
_list 0
]]
}
{
if
{
""
!=
$search
_string
}
{
if
{
[
string
first
[
string
tolower
$search
_string
]
[
string
tolower
[
lindex
$sub
_list 0
]]]
!= -1
}
{
append output
"
\{\"
Object
\"
:
\"
"
append output
[
string
map
{
 
;
""
}
[
lindex
$sub
_list 0
]
]
append output
"
\"
"
append output
",
\"
ObjectId
\"
:"
append output
[
string
map
{
 
;
""
}
[
lindex
$sub
_list 1
]
]
# append output [lindex $sub_list 1
]
append output
"
\}
,"
}
}
else
{
append output
"
\{\"
Object
\"
:
\"
"
append output
[
string
map
{
 
;
""
}
[
lindex
$sub
_list 0
]
]
append output
"
\"\}
,"
}
}
}
}
set output
"
[
string
range
$output
0
[
expr
[
string
length
$output
]
-2
]]
"
append output
"
\]\}\n\}
"
# append output "\n\
]
"
}
ad_proc -public xmlrpc-rest::handle_rest_project
{
method path url_query user_id
}
{
@return project list / task list
}
{
set query_list
[
split
$url
_query &
]
# find searchstring, object type, project_id
foreach sub_list
$query
_list
{
set query_item
[
split
$sub
_list =
]
if
{
"search_string"
==
[
lindex
$query
_item 0
]
}
{
set search_string
[
lindex
$query
_item 1
]
}
# project or task?
if
{
"object_type"
==
[
lindex
$query
_item 0
]
}
{
set object_type
[
lindex
$query
_item 1
]
}
if
{
"project_id"
==
[
lindex
$query
_item 0
]
}
{
set project_id
[
lindex
$query
_item 1
]
}
# last id used in <li> element
if
{
"last_id"
==
[
lindex
$query
_item 0
]
}
{
set last_id
[
lindex
$query
_item 1
]
}
# location
if
{
"location"
==
[
lindex
$query
_item 0
]
}
{
set location
[
lindex
$query
_item 1
]
}
}
# set project_id 27971
# Getting list of objects
switch
$object
_type
{
project
{
set object_list
[
im_project_list -exclude_subprojects_p 0 -exclude_status_id
[
im_project_status_closed
]
-project_id 0
]
set output
[
xmlrpc-rest::render_json
$object
_list
$search
_string
]
}
task
{
set output
[
gtd-dashboard::render_output
[
im_gtd_task_list -restrict_to_project_id
$project
_id
]
task_table
$last
_id ts
$location
]
}
default
{
set
output
"Object Type not found"
}
}
return
$output
}
# setup nsv array to hold procs that are registered for xml-rpc access
# setup nsv array to hold procs that are registered for xml-rpc access
nsv_array set xmlrpc_procs
[
list
]
nsv_array set xmlrpc_procs
[
list
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment