You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(8) |
Apr
(27) |
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
(13) |
Oct
(3) |
Nov
(5) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(12) |
Jun
(75) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(3) |
Nov
(1) |
Dec
|
2008 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <an...@us...> - 2009-08-20 22:10:31
|
Revision: 375 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=375&view=rev Author: anarcat Date: 2009-08-20 22:10:19 +0000 (Thu, 20 Aug 2009) Log Message: ----------- more porting to 0.9 Modified Paths: -------------- trunk/phptimetracker/gozerbot/ttracker.py Modified: trunk/phptimetracker/gozerbot/ttracker.py =================================================================== --- trunk/phptimetracker/gozerbot/ttracker.py 2009-08-20 22:02:17 UTC (rev 374) +++ trunk/phptimetracker/gozerbot/ttracker.py 2009-08-20 22:10:19 UTC (rev 375) @@ -28,7 +28,7 @@ from myplugs.timetracker.REST import Timetracker -plughelp.add('timetracker', 'start/stop punch in timetracker and communicate with timetracker') +plughelp.add('ttracker', 'start/stop punch in timetracker and communicate with timetracker') cfg = PersistConfig() cfg.define('timetracker', '') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-08-20 22:02:25
|
Revision: 374 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=374&view=rev Author: anarcat Date: 2009-08-20 22:02:17 +0000 (Thu, 20 Aug 2009) Log Message: ----------- more porting to 0.9 Modified Paths: -------------- trunk/phptimetracker/gozerbot/ttracker.py Modified: trunk/phptimetracker/gozerbot/ttracker.py =================================================================== --- trunk/phptimetracker/gozerbot/ttracker.py 2009-08-20 21:43:28 UTC (rev 373) +++ trunk/phptimetracker/gozerbot/ttracker.py 2009-08-20 22:02:17 UTC (rev 374) @@ -22,7 +22,7 @@ from gozerbot.datadir import datadir from gozerbot.plughelp import plughelp from gozerbot.persist.persistconfig import PersistConfig -from gozerbot.thr import start_new_thread +from gozerbot.threads.thr import start_new_thread import time, os, sys import xmlrpclib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-08-20 21:43:36
|
Revision: 373 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=373&view=rev Author: anarcat Date: 2009-08-20 21:43:28 +0000 (Thu, 20 Aug 2009) Log Message: ----------- fix comment headers Modified Paths: -------------- trunk/phptimetracker/gozerbot/__init__.py trunk/phptimetracker/gozerbot/ttracker.py Modified: trunk/phptimetracker/gozerbot/__init__.py =================================================================== --- trunk/phptimetracker/gozerbot/__init__.py 2009-08-20 21:34:56 UTC (rev 372) +++ trunk/phptimetracker/gozerbot/__init__.py 2009-08-20 21:43:28 UTC (rev 373) @@ -1,18 +1,4 @@ -# plugs/timetracker.py -# -# to install this plugin, you need to decompress the phptimetracker -# archive in the myplugs directory an move/copy/link this file in the -# myplugs directory. Example: -# -# % ls -ald myplugs/*time* -# drwxr-xr-x 11 anarcat koumbot 1024 Jun 28 13:43 myplugs/phptimetracker -# lrwxr-xr-x 1 anarcat koumbot 32 Jun 1 15:25 myplugs/timetracker.py -> phptimetracker/gozerbotplugin.py -# -# then load the plugin in the bot using the load command and follow the -# inline help -# -# note that your timetracker username passwords are stored in clear -# text on the server +# just a stub so that this loads properly in gozerbot """ communicate with the timetracker """ Modified: trunk/phptimetracker/gozerbot/ttracker.py =================================================================== --- trunk/phptimetracker/gozerbot/ttracker.py 2009-08-20 21:34:56 UTC (rev 372) +++ trunk/phptimetracker/gozerbot/ttracker.py 2009-08-20 21:43:28 UTC (rev 373) @@ -1,30 +1,27 @@ # plugs/timetracker.py # -# to install this plugin, you need to decompress the phptimetracker -# archive in the myplugs directory an move/copy/link this file in the -# myplugs directory. Example: +# to install this plugin, you need to checkout the gozerbot subdirectory in a +# subdir of the myplugs directory. Example # -# % ls -ald myplugs/*time* -# drwxr-xr-x 11 anarcat koumbot 1024 Jun 28 13:43 myplugs/phptimetracker -# lrwxr-xr-x 1 anarcat koumbot 32 Jun 1 15:25 myplugs/timetracker.py -> phptimetracker/gozerbotplugin.py -# -# then load the plugin in the bot using the load command and follow the -# inline help +# svn co https://phptimetracker.svn.sourceforge.net/svnroot/phptimetracker/trunk/phptimetracker/gozerbot/ timetracker # -# note that your timetracker username passwords are stored in clear -# text on the server +# then load the plugin in the bot using the load command and follow the inline +# help +# +# note that your timetracker username passwords are stored in clear text on the +# server """ communicate with the timetracker """ from gozerbot.generic import elapsedstring -from gozerbot.persist import Persist +from gozerbot.persist.persist import Persist from gozerbot.users import users from gozerbot.commands import cmnds from gozerbot.aliases import aliasset from gozerbot.examples import examples from gozerbot.datadir import datadir from gozerbot.plughelp import plughelp -from gozerbot.persistconfig import PersistConfig +from gozerbot.persist.persistconfig import PersistConfig from gozerbot.thr import start_new_thread import time, os, sys import xmlrpclib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-08-20 21:35:06
|
Revision: 372 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=372&view=rev Author: anarcat Date: 2009-08-20 21:34:56 +0000 (Thu, 20 Aug 2009) Log Message: ----------- try to port to 0.9 Modified Paths: -------------- trunk/phptimetracker/gozerbot/__init__.py Added Paths: ----------- trunk/phptimetracker/gozerbot/ttracker.py Modified: trunk/phptimetracker/gozerbot/__init__.py =================================================================== --- trunk/phptimetracker/gozerbot/__init__.py 2009-08-20 21:33:36 UTC (rev 371) +++ trunk/phptimetracker/gozerbot/__init__.py 2009-08-20 21:34:56 UTC (rev 372) @@ -18,197 +18,5 @@ __copyright__ = 'this file is in the public domain' __author__ = 'Antoine Beaupre (an...@ko...)' - -from gozerbot.generic import elapsedstring -from gozerbot.persist import Persist -from gozerbot.users import users -from gozerbot.commands import cmnds -from gozerbot.aliases import aliasset -from gozerbot.examples import examples -from gozerbot.datadir import datadir -from gozerbot.plughelp import plughelp -from gozerbot.persistconfig import PersistConfig -from gozerbot.thr import start_new_thread -import time, os, sys -import xmlrpclib - -from myplugs.timetracker.REST import Timetracker - -plughelp.add('timetracker', 'start/stop punch in timetracker and communicate with timetracker') - -cfg = PersistConfig() -cfg.define('timetracker', '') -cfg.define('kproject_site', '') -cfg.define('kproject_key', '') - -# The work times -punches = Persist(datadir + os.sep + 'punches') -timeauth = Persist(datadir + os.sep + 'timeauth') - -if not punches.data: - punches.data = {} - -if not timeauth.data: - timeauth.data = {} - -def timetrack_kproject(ievent, command, username): - url = cfg.get('kproject_site') - key = cfg.get('kproject_key') - if url == '' or key == '': - ievent.reply('You must configure the url of kproject before use it') - return - server = xmlrpclib.Server(url + "/xmlrpc.php") - try: - status = server.kproject.command(key, username, command) - if type(status) == list: - for i in status: - ievent.reply('kproject: ' + str(i)) - else: - ievent.reply('kproject: ' + str(status)) - except: - pass - # failed silently for now - #ievent.reply('There is a problem with kproject: ' + command + '\n' + str(sys.exc_info()[1])) - -def timetrack_checkauth(ievent): - # Get the user - username = users.getname(ievent.userhost) - # Check data construction - if username != None and not timeauth.data.has_key(username): - ievent.reply('not authenticated with the timetracker, use tt-login <username> <password> to authenticate') - username = False - return username - -def handle_timeauth(bot, ievent): - """ authenticate with the timetracker """ - nick = users.getname(ievent.userhost) - if nick == None: - return - if len(ievent.args) < 2: - ievent.reply("missing argument") - return - username = ievent.args[0] - password = ievent.args[1] - conn = Timetracker(cfg.get('timetracker'), username, password) - status = conn.login() - if status == 200: - ievent.reply("login sucessful") - timeauth.data[nick] = (username, password) - timeauth.save() - elif status == 401: - ievent.reply("login failed: wrong username or password") - else: - ievent.reply("login failed: unknown error code %d" % status) - -def handle_timelogout(bot, ievent): - username = timetrack_checkauth(ievent) - if not username: - return - del timeauth.data[username] - ievent.reply("forgotten all about you") - -def handle_timestart(bot, ievent): - """ store work start time """ - username = timetrack_checkauth(ievent) - if not username: - return - - # notify kproject - start_new_thread(timetrack_kproject, (ievent, "!pi %s" % (" ".join(ievent.args)), users.getname(ievent.userhost))) - - if len(ievent.args) < 1: - ievent.reply("missing project id") - return - comment = None - if len(ievent.args) > 1: - comment = " ".join(ievent.args[1:]) - - conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) - try: - pid = str(int(ievent.args[0])) - pname = str(pid) - except ValueError: - projects = conn.project_list(ievent.args[0]) - if len(projects) > 1: - ievent.reply('%d projects found matching %s, refine your search. matching projects: %s' % (len(projects), ievent.args[0], pretty_projects(projects))) - return - elif len(projects) < 1: - ievent.reply('no project found matching %s, try again' % ievent.args[0]) - return - else: - project = projects.popitem() - pid = project[0] - pname = "#%s %s" % (project) - - status = conn.punch_in(pid, comment) - if status: - try: - oldcomment = status[2] - except IndexError: - oldcomment = 'no comment' - try: - ievent.reply("punched in project %s (%s) and punched out, worked %s on %s (%s)" % (pname, comment, elapsedstring(status[1]), status[0], oldcomment)) - except IndexError: - ievent.reply("punched in project %s (%s) and punched out of previous project" % (pname, comment)) - else: - ievent.reply("punched in project %s (%s)" % (pname, comment)) - -# Handle a workstop -def handle_timestop(bot, ievent): - """ punch out timetracker """ - username = timetrack_checkauth(ievent) - if not username: - return - comment = None - if len(ievent.args) >= 1: - comment = " ".join(ievent.args[0:]) - conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) - - timetrack_kproject(ievent, "!po %s" % (comment), users.getname(ievent.userhost)) - status = conn.punch_out(comment) - if status: - ievent.reply("punched out of project %s, worked %s (%s)" % (status[0], elapsedstring(status[1]), status[2])) - if len(status) > 3: - if len(status) > 4: - ievent.reply("worked %s this week in %s punches" % (status[3], status[4])) - else: - ievent.reply("worked %s this week" % status[3]) - else: - ievent.reply("not punched in") - -def handle_projectlist(bot, ievent): - username = timetrack_checkauth(ievent) - if not username: - return - if len(ievent.args) < 1: - ievent.reply("missing project id") - return - ievent.reply("fetching project list...") - conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) - projects = conn.project_list(ievent.args[0]) - if len(projects) > 1: - ievent.reply("%d projects found, matching projects: %s" % (len(projects), pretty_projects(projects))) - elif len(projects) == 1: - ievent.reply("project found: %s" % (pretty_projects(projects))) - elif len(projects) < 1: - ievent.reply('no project found matching %s, try again' % ievent.args[0]) - -def pretty_projects(projects): - return ", ".join(map(lambda x: "%s: %s" % x,projects.iteritems())) - -cmnds.add('tt-logout', handle_timelogout, 'USER') -examples.add('tt-logout', 'forget timetracker credentials', 'tt-logout') -cmnds.add('tt-login', handle_timeauth, 'USER') -examples.add('tt-login', 'authenticate with the timetracker, note that this stores your credentials, in clear text, on the bot disk', 'tt-login username password') -cmnds.add('tt-punchin', handle_timestart, 'USER') -examples.add('tt-punchin', 'punch in timetracker', 'tt-punchin project comment') -aliasset('punch', 'tt-punchin') -aliasset('punchin', 'tt-punchin') -cmnds.add('tt-punchout', handle_timestop, 'USER') -examples.add('tt-punchout', 'punch out timetracker', 'tt-punchout') -aliasset('punchout', 'tt-punchout') -aliasset('depunch', 'tt-punchout') -aliasset('depunche', 'tt-punchout') -cmnds.add('tt-projectlist', handle_projectlist, 'USER') -examples.add('tt-projectlist', 'list projects from the timetracker', 'tt-projectlist pattern') -aliasset('projectlist', 'tt-projectlist') +__plugs__ = ['ttracker', ] +__all__ = ['ttracker', ] Copied: trunk/phptimetracker/gozerbot/ttracker.py (from rev 371, trunk/phptimetracker/gozerbot/__init__.py) =================================================================== --- trunk/phptimetracker/gozerbot/ttracker.py (rev 0) +++ trunk/phptimetracker/gozerbot/ttracker.py 2009-08-20 21:34:56 UTC (rev 372) @@ -0,0 +1,211 @@ +# plugs/timetracker.py +# +# to install this plugin, you need to decompress the phptimetracker +# archive in the myplugs directory an move/copy/link this file in the +# myplugs directory. Example: +# +# % ls -ald myplugs/*time* +# drwxr-xr-x 11 anarcat koumbot 1024 Jun 28 13:43 myplugs/phptimetracker +# lrwxr-xr-x 1 anarcat koumbot 32 Jun 1 15:25 myplugs/timetracker.py -> phptimetracker/gozerbotplugin.py +# +# then load the plugin in the bot using the load command and follow the +# inline help +# +# note that your timetracker username passwords are stored in clear +# text on the server + +""" communicate with the timetracker """ + +from gozerbot.generic import elapsedstring +from gozerbot.persist import Persist +from gozerbot.users import users +from gozerbot.commands import cmnds +from gozerbot.aliases import aliasset +from gozerbot.examples import examples +from gozerbot.datadir import datadir +from gozerbot.plughelp import plughelp +from gozerbot.persistconfig import PersistConfig +from gozerbot.thr import start_new_thread +import time, os, sys +import xmlrpclib + +from myplugs.timetracker.REST import Timetracker + +plughelp.add('timetracker', 'start/stop punch in timetracker and communicate with timetracker') + +cfg = PersistConfig() +cfg.define('timetracker', '') +cfg.define('kproject_site', '') +cfg.define('kproject_key', '') + +# The work times +punches = Persist(datadir + os.sep + 'punches') +timeauth = Persist(datadir + os.sep + 'timeauth') + +if not punches.data: + punches.data = {} + +if not timeauth.data: + timeauth.data = {} + +def timetrack_kproject(ievent, command, username): + url = cfg.get('kproject_site') + key = cfg.get('kproject_key') + if url == '' or key == '': + ievent.reply('You must configure the url of kproject before use it') + return + server = xmlrpclib.Server(url + "/xmlrpc.php") + try: + status = server.kproject.command(key, username, command) + if type(status) == list: + for i in status: + ievent.reply('kproject: ' + str(i)) + else: + ievent.reply('kproject: ' + str(status)) + except: + pass + # failed silently for now + #ievent.reply('There is a problem with kproject: ' + command + '\n' + str(sys.exc_info()[1])) + +def timetrack_checkauth(ievent): + # Get the user + username = users.getname(ievent.userhost) + # Check data construction + if username != None and not timeauth.data.has_key(username): + ievent.reply('not authenticated with the timetracker, use tt-login <username> <password> to authenticate') + username = False + return username + +def handle_timeauth(bot, ievent): + """ authenticate with the timetracker """ + nick = users.getname(ievent.userhost) + if nick == None: + return + if len(ievent.args) < 2: + ievent.reply("missing argument") + return + username = ievent.args[0] + password = ievent.args[1] + conn = Timetracker(cfg.get('timetracker'), username, password) + status = conn.login() + if status == 200: + ievent.reply("login sucessful") + timeauth.data[nick] = (username, password) + timeauth.save() + elif status == 401: + ievent.reply("login failed: wrong username or password") + else: + ievent.reply("login failed: unknown error code %d" % status) + +def handle_timelogout(bot, ievent): + username = timetrack_checkauth(ievent) + if not username: + return + del timeauth.data[username] + ievent.reply("forgotten all about you") + +def handle_timestart(bot, ievent): + """ store work start time """ + username = timetrack_checkauth(ievent) + if not username: + return + + # notify kproject + start_new_thread(timetrack_kproject, (ievent, "!pi %s" % (" ".join(ievent.args)), users.getname(ievent.userhost))) + + if len(ievent.args) < 1: + ievent.reply("missing project id") + return + comment = None + if len(ievent.args) > 1: + comment = " ".join(ievent.args[1:]) + + conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) + try: + pid = str(int(ievent.args[0])) + pname = str(pid) + except ValueError: + projects = conn.project_list(ievent.args[0]) + if len(projects) > 1: + ievent.reply('%d projects found matching %s, refine your search. matching projects: %s' % (len(projects), ievent.args[0], pretty_projects(projects))) + return + elif len(projects) < 1: + ievent.reply('no project found matching %s, try again' % ievent.args[0]) + return + else: + project = projects.popitem() + pid = project[0] + pname = "#%s %s" % (project) + + status = conn.punch_in(pid, comment) + if status: + try: + oldcomment = status[2] + except IndexError: + oldcomment = 'no comment' + try: + ievent.reply("punched in project %s (%s) and punched out, worked %s on %s (%s)" % (pname, comment, elapsedstring(status[1]), status[0], oldcomment)) + except IndexError: + ievent.reply("punched in project %s (%s) and punched out of previous project" % (pname, comment)) + else: + ievent.reply("punched in project %s (%s)" % (pname, comment)) + +# Handle a workstop +def handle_timestop(bot, ievent): + """ punch out timetracker """ + username = timetrack_checkauth(ievent) + if not username: + return + comment = None + if len(ievent.args) >= 1: + comment = " ".join(ievent.args[0:]) + conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) + + timetrack_kproject(ievent, "!po %s" % (comment), users.getname(ievent.userhost)) + status = conn.punch_out(comment) + if status: + ievent.reply("punched out of project %s, worked %s (%s)" % (status[0], elapsedstring(status[1]), status[2])) + if len(status) > 3: + if len(status) > 4: + ievent.reply("worked %s this week in %s punches" % (status[3], status[4])) + else: + ievent.reply("worked %s this week" % status[3]) + else: + ievent.reply("not punched in") + +def handle_projectlist(bot, ievent): + username = timetrack_checkauth(ievent) + if not username: + return + if len(ievent.args) < 1: + ievent.reply("missing project id") + return + ievent.reply("fetching project list...") + conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) + projects = conn.project_list(ievent.args[0]) + if len(projects) > 1: + ievent.reply("%d projects found, matching projects: %s" % (len(projects), pretty_projects(projects))) + elif len(projects) == 1: + ievent.reply("project found: %s" % (pretty_projects(projects))) + elif len(projects) < 1: + ievent.reply('no project found matching %s, try again' % ievent.args[0]) + +def pretty_projects(projects): + return ", ".join(map(lambda x: "%s: %s" % x,projects.iteritems())) + +cmnds.add('tt-logout', handle_timelogout, 'USER') +examples.add('tt-logout', 'forget timetracker credentials', 'tt-logout') +cmnds.add('tt-login', handle_timeauth, 'USER') +examples.add('tt-login', 'authenticate with the timetracker, note that this stores your credentials, in clear text, on the bot disk', 'tt-login username password') +cmnds.add('tt-punchin', handle_timestart, 'USER') +examples.add('tt-punchin', 'punch in timetracker', 'tt-punchin project comment') +aliasset('punch', 'tt-punchin') +aliasset('punchin', 'tt-punchin') +cmnds.add('tt-punchout', handle_timestop, 'USER') +examples.add('tt-punchout', 'punch out timetracker', 'tt-punchout') +aliasset('punchout', 'tt-punchout') +aliasset('depunch', 'tt-punchout') +aliasset('depunche', 'tt-punchout') +cmnds.add('tt-projectlist', handle_projectlist, 'USER') +examples.add('tt-projectlist', 'list projects from the timetracker', 'tt-projectlist pattern') +aliasset('projectlist', 'tt-projectlist') Property changes on: trunk/phptimetracker/gozerbot/ttracker.py ___________________________________________________________________ Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-08-20 21:33:44
|
Revision: 371 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=371&view=rev Author: anarcat Date: 2009-08-20 21:33:36 +0000 (Thu, 20 Aug 2009) Log Message: ----------- kproject support code by patrick hetu Modified Paths: -------------- trunk/phptimetracker/gozerbot/__init__.py Modified: trunk/phptimetracker/gozerbot/__init__.py =================================================================== --- trunk/phptimetracker/gozerbot/__init__.py 2009-01-23 21:31:13 UTC (rev 370) +++ trunk/phptimetracker/gozerbot/__init__.py 2009-08-20 21:33:36 UTC (rev 371) @@ -28,13 +28,18 @@ from gozerbot.datadir import datadir from gozerbot.plughelp import plughelp from gozerbot.persistconfig import PersistConfig -import time, os +from gozerbot.thr import start_new_thread +import time, os, sys +import xmlrpclib + from myplugs.timetracker.REST import Timetracker plughelp.add('timetracker', 'start/stop punch in timetracker and communicate with timetracker') cfg = PersistConfig() cfg.define('timetracker', '') +cfg.define('kproject_site', '') +cfg.define('kproject_key', '') # The work times punches = Persist(datadir + os.sep + 'punches') @@ -46,6 +51,25 @@ if not timeauth.data: timeauth.data = {} +def timetrack_kproject(ievent, command, username): + url = cfg.get('kproject_site') + key = cfg.get('kproject_key') + if url == '' or key == '': + ievent.reply('You must configure the url of kproject before use it') + return + server = xmlrpclib.Server(url + "/xmlrpc.php") + try: + status = server.kproject.command(key, username, command) + if type(status) == list: + for i in status: + ievent.reply('kproject: ' + str(i)) + else: + ievent.reply('kproject: ' + str(status)) + except: + pass + # failed silently for now + #ievent.reply('There is a problem with kproject: ' + command + '\n' + str(sys.exc_info()[1])) + def timetrack_checkauth(ievent): # Get the user username = users.getname(ievent.userhost) @@ -88,6 +112,10 @@ username = timetrack_checkauth(ievent) if not username: return + + # notify kproject + start_new_thread(timetrack_kproject, (ievent, "!pi %s" % (" ".join(ievent.args)), users.getname(ievent.userhost))) + if len(ievent.args) < 1: ievent.reply("missing project id") return @@ -135,6 +163,8 @@ if len(ievent.args) >= 1: comment = " ".join(ievent.args[0:]) conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) + + timetrack_kproject(ievent, "!po %s" % (comment), users.getname(ievent.userhost)) status = conn.punch_out(comment) if status: ievent.reply("punched out of project %s, worked %s (%s)" % (status[0], elapsedstring(status[1]), status[2])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-01-23 22:23:05
|
Revision: 370 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=370&view=rev Author: anarcat Date: 2009-01-23 21:31:13 +0000 (Fri, 23 Jan 2009) Log Message: ----------- readd gozerbot plugin to the phptimetracker since it seems it's nowhere else Added Paths: ----------- trunk/phptimetracker/gozerbot/REST.py trunk/phptimetracker/gozerbot/__init__.py trunk/phptimetracker/gozerbot/client.py Added: trunk/phptimetracker/gozerbot/REST.py =================================================================== --- trunk/phptimetracker/gozerbot/REST.py (rev 0) +++ trunk/phptimetracker/gozerbot/REST.py 2009-01-23 21:31:13 UTC (rev 370) @@ -0,0 +1,96 @@ +import httplib +import urlparse +import urllib +import base64 + +class Connection: + def __init__(self, baseurl, username, password): + self.baseurl = baseurl + self.username = username + self.password = password + self.headers = {} + self.debug = False + + def get(self, resource, args = None): + return self.request(resource, 'get', args) + + def post(self, resource, args = None): + self.headers['Content-Type'] = 'application/x-www-form-urlencoded' + return self.request(resource, 'post', args) + + def request(self, resource, method = "get", args = None): + url = urlparse.urlparse(self.baseurl + resource) + body = None + params = None + path = url[2] + + if self.username and self.password: + encoded = base64.encodestring("%s:%s" % (self.username, self.password))[:-1] + self.headers["Authorization"] = "Basic %s" % encoded + + if args: + if method == 'get': + path += "?" + urllib.urlencode(args) + else: + body = urllib.urlencode(args) + + if self.debug: + print path + print repr(self.headers) + print body + if url[1][:5] == 'https': + conn = httplib.HTTPConnection(url[1]) + else: + conn = httplib.HTTPSConnection(url[1]) + + req = conn.request(method.upper(), "/" + path, body, self.headers) + + resp = conn.getresponse() + if self.debug: + print resp.getheaders() + return resp + +class Timetracker (Connection): + charset = 'latin1' + + def login(self): + """ try to login with the provided crenditals + returns the HTTP status code (200 for success, 401 for failure, + others for other failures) + """ + return self.get('/php/bin/login.php').status + + def punch_out(self, comment = None): + """ punch out of the timetracker + returns a list of project id, punch time and comment or None if no + punch was defined. comment, if empty, will not be included. + """ + args = {'punch_out' : 'punch out', 'REST' : 1} + if comment: + args['comment'] = comment + + resp = self.post('/php/bin/project_punch.php', args).read().split("\n") + if len(resp) < 2 and resp[0] == '': + resp = None + return resp + + def punch_in(self, project, comment = None): + args = {'punch_'+project : 'punch in', 'REST' : 1} + if comment: + args['comment'] = comment + resp = self.post('/php/bin/project_punch.php', args).read().split("\n") + if len(resp) < 2 and resp[0] == '': + resp = None + return resp + + def project_list(self, project, all = 0): + args = {'project' : project, 'REST' : 1, 'all' : all} + res = self.get('/php/bin/project_list.php', args).read().split("\n") + projects = {} + for line in res: + try: + (id, project) = line.decode(self.charset).split("\t") + except ValueError: + continue + projects[id] = project + return projects Added: trunk/phptimetracker/gozerbot/__init__.py =================================================================== --- trunk/phptimetracker/gozerbot/__init__.py (rev 0) +++ trunk/phptimetracker/gozerbot/__init__.py 2009-01-23 21:31:13 UTC (rev 370) @@ -0,0 +1,184 @@ +# plugs/timetracker.py +# +# to install this plugin, you need to decompress the phptimetracker +# archive in the myplugs directory an move/copy/link this file in the +# myplugs directory. Example: +# +# % ls -ald myplugs/*time* +# drwxr-xr-x 11 anarcat koumbot 1024 Jun 28 13:43 myplugs/phptimetracker +# lrwxr-xr-x 1 anarcat koumbot 32 Jun 1 15:25 myplugs/timetracker.py -> phptimetracker/gozerbotplugin.py +# +# then load the plugin in the bot using the load command and follow the +# inline help +# +# note that your timetracker username passwords are stored in clear +# text on the server + +""" communicate with the timetracker """ + +__copyright__ = 'this file is in the public domain' +__author__ = 'Antoine Beaupre (an...@ko...)' + +from gozerbot.generic import elapsedstring +from gozerbot.persist import Persist +from gozerbot.users import users +from gozerbot.commands import cmnds +from gozerbot.aliases import aliasset +from gozerbot.examples import examples +from gozerbot.datadir import datadir +from gozerbot.plughelp import plughelp +from gozerbot.persistconfig import PersistConfig +import time, os +from myplugs.timetracker.REST import Timetracker + +plughelp.add('timetracker', 'start/stop punch in timetracker and communicate with timetracker') + +cfg = PersistConfig() +cfg.define('timetracker', '') + +# The work times +punches = Persist(datadir + os.sep + 'punches') +timeauth = Persist(datadir + os.sep + 'timeauth') + +if not punches.data: + punches.data = {} + +if not timeauth.data: + timeauth.data = {} + +def timetrack_checkauth(ievent): + # Get the user + username = users.getname(ievent.userhost) + # Check data construction + if username != None and not timeauth.data.has_key(username): + ievent.reply('not authenticated with the timetracker, use tt-login <username> <password> to authenticate') + username = False + return username + +def handle_timeauth(bot, ievent): + """ authenticate with the timetracker """ + nick = users.getname(ievent.userhost) + if nick == None: + return + if len(ievent.args) < 2: + ievent.reply("missing argument") + return + username = ievent.args[0] + password = ievent.args[1] + conn = Timetracker(cfg.get('timetracker'), username, password) + status = conn.login() + if status == 200: + ievent.reply("login sucessful") + timeauth.data[nick] = (username, password) + timeauth.save() + elif status == 401: + ievent.reply("login failed: wrong username or password") + else: + ievent.reply("login failed: unknown error code %d" % status) + +def handle_timelogout(bot, ievent): + username = timetrack_checkauth(ievent) + if not username: + return + del timeauth.data[username] + ievent.reply("forgotten all about you") + +def handle_timestart(bot, ievent): + """ store work start time """ + username = timetrack_checkauth(ievent) + if not username: + return + if len(ievent.args) < 1: + ievent.reply("missing project id") + return + comment = None + if len(ievent.args) > 1: + comment = " ".join(ievent.args[1:]) + + conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) + try: + pid = str(int(ievent.args[0])) + pname = str(pid) + except ValueError: + projects = conn.project_list(ievent.args[0]) + if len(projects) > 1: + ievent.reply('%d projects found matching %s, refine your search. matching projects: %s' % (len(projects), ievent.args[0], pretty_projects(projects))) + return + elif len(projects) < 1: + ievent.reply('no project found matching %s, try again' % ievent.args[0]) + return + else: + project = projects.popitem() + pid = project[0] + pname = "#%s %s" % (project) + + status = conn.punch_in(pid, comment) + if status: + try: + oldcomment = status[2] + except IndexError: + oldcomment = 'no comment' + try: + ievent.reply("punched in project %s (%s) and punched out, worked %s on %s (%s)" % (pname, comment, elapsedstring(status[1]), status[0], oldcomment)) + except IndexError: + ievent.reply("punched in project %s (%s) and punched out of previous project" % (pname, comment)) + else: + ievent.reply("punched in project %s (%s)" % (pname, comment)) + +# Handle a workstop +def handle_timestop(bot, ievent): + """ punch out timetracker """ + username = timetrack_checkauth(ievent) + if not username: + return + comment = None + if len(ievent.args) >= 1: + comment = " ".join(ievent.args[0:]) + conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) + status = conn.punch_out(comment) + if status: + ievent.reply("punched out of project %s, worked %s (%s)" % (status[0], elapsedstring(status[1]), status[2])) + if len(status) > 3: + if len(status) > 4: + ievent.reply("worked %s this week in %s punches" % (status[3], status[4])) + else: + ievent.reply("worked %s this week" % status[3]) + else: + ievent.reply("not punched in") + +def handle_projectlist(bot, ievent): + username = timetrack_checkauth(ievent) + if not username: + return + if len(ievent.args) < 1: + ievent.reply("missing project id") + return + ievent.reply("fetching project list...") + conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) + projects = conn.project_list(ievent.args[0]) + if len(projects) > 1: + ievent.reply("%d projects found, matching projects: %s" % (len(projects), pretty_projects(projects))) + elif len(projects) == 1: + ievent.reply("project found: %s" % (pretty_projects(projects))) + elif len(projects) < 1: + ievent.reply('no project found matching %s, try again' % ievent.args[0]) + +def pretty_projects(projects): + return ", ".join(map(lambda x: "%s: %s" % x,projects.iteritems())) + +cmnds.add('tt-logout', handle_timelogout, 'USER') +examples.add('tt-logout', 'forget timetracker credentials', 'tt-logout') +cmnds.add('tt-login', handle_timeauth, 'USER') +examples.add('tt-login', 'authenticate with the timetracker, note that this stores your credentials, in clear text, on the bot disk', 'tt-login username password') +cmnds.add('tt-punchin', handle_timestart, 'USER') +examples.add('tt-punchin', 'punch in timetracker', 'tt-punchin project comment') +aliasset('punch', 'tt-punchin') +aliasset('punchin', 'tt-punchin') +cmnds.add('tt-punchout', handle_timestop, 'USER') +examples.add('tt-punchout', 'punch out timetracker', 'tt-punchout') +aliasset('punchout', 'tt-punchout') +aliasset('depunch', 'tt-punchout') +aliasset('depunche', 'tt-punchout') +cmnds.add('tt-projectlist', handle_projectlist, 'USER') +examples.add('tt-projectlist', 'list projects from the timetracker', 'tt-projectlist pattern') +aliasset('projectlist', 'tt-projectlist') Added: trunk/phptimetracker/gozerbot/client.py =================================================================== --- trunk/phptimetracker/gozerbot/client.py (rev 0) +++ trunk/phptimetracker/gozerbot/client.py 2009-01-23 21:31:13 UTC (rev 370) @@ -0,0 +1,8 @@ +#! /usr/bin/python + +from REST import Timetracker + +if __name__ == "__main__": + conn = Timetracker('http://localhost/phptimetracker', 'anarcat', 'test') + #conn.debug = True + print repr(conn.project_list('timetracker', 1)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-01-23 21:24:37
|
Revision: 369 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=369&view=rev Author: anarcat Date: 2009-01-23 21:24:35 +0000 (Fri, 23 Jan 2009) Log Message: ----------- directory for the gozerbot plugin Added Paths: ----------- trunk/phptimetracker/gozerbot/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-01-23 21:23:09
|
Revision: 368 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=368&view=rev Author: anarcat Date: 2009-01-23 21:22:59 +0000 (Fri, 23 Jan 2009) Log Message: ----------- remove useless & Modified Paths: -------------- trunk/phptimetracker/php/language.php Modified: trunk/phptimetracker/php/language.php =================================================================== --- trunk/phptimetracker/php/language.php 2009-01-23 21:22:39 UTC (rev 367) +++ trunk/phptimetracker/php/language.php 2009-01-23 21:22:59 UTC (rev 368) @@ -44,7 +44,7 @@ * @params $str the string to translate * @return the translated string */ -function &translate() { +function translate() { global $lang; $args = func_get_args(); $str =& $args[0]; @@ -59,8 +59,8 @@ * * @uses translate() */ -function &__($str) { - $args =& func_get_args(); +function __($str) { + $args = func_get_args(); return call_user_func_array('translate', $args); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-01-23 21:22:42
|
Revision: 367 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=367&view=rev Author: anarcat Date: 2009-01-23 21:22:39 +0000 (Fri, 23 Jan 2009) Log Message: ----------- include ttconf properly Modified Paths: -------------- trunk/phptimetracker/php/ecdStd.inc.php Modified: trunk/phptimetracker/php/ecdStd.inc.php =================================================================== --- trunk/phptimetracker/php/ecdStd.inc.php 2009-01-23 21:21:32 UTC (rev 366) +++ trunk/phptimetracker/php/ecdStd.inc.php 2009-01-23 21:22:39 UTC (rev 367) @@ -32,7 +32,7 @@ require_once('Customer.php'); require_once('Project.php'); require_once('language.php'); -include_once('../includes/tt_conf.php'); +include_once(dirname(__FILE__).'/tt_conf.php'); /** * Provide standard display functions. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2009-01-23 21:21:37
|
Revision: 366 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=366&view=rev Author: anarcat Date: 2009-01-23 21:21:32 +0000 (Fri, 23 Jan 2009) Log Message: ----------- also report the time worked this week in the REST punchout interface Modified Paths: -------------- trunk/phptimetracker/php/bin/project_punch.php Modified: trunk/phptimetracker/php/bin/project_punch.php =================================================================== --- trunk/phptimetracker/php/bin/project_punch.php 2008-02-10 00:27:30 UTC (rev 365) +++ trunk/phptimetracker/php/bin/project_punch.php 2009-01-23 21:21:32 UTC (rev 366) @@ -75,6 +75,42 @@ $punch = $user->punch_out(); if ($_POST['REST'] && is_array($punch)) { print join("\n", $punch); + + # XXX: copy-paste from index.php to get time worked this week + require_once(dirname(__FILE__).'/../ecdStd.inc.php'); + $dfrom = new Date(); + $dto = new Date(); + // find beginning of week (sunday, 0) + while ($dfrom->getDayOfWeek()) { + $dfrom = $dfrom->getPrevDay(); + } + // find end of weekd (sunday, 0 -1s) + while ($dto->getDayOfWeek()) { + $dto = $dto->getNextDay(); + } + $dto->subtractSeconds(1); + $from = new ecdDate($dfrom->getTime(), 'unixtimestamp'); + $to = new ecdDate($dto->getTime(), 'unixtimestamp'); + $bounds = array($from->unixtimestamp(), $to->unixtimestamp()); + $select = "SUM(delta) as time, COUNT(delta) as punches"; + $a = TimeAuth::instance(); + $where = "p.customer = '" . addslashes(ecdStd::current_customer()) . "' AND "; + $where .= "UNIX_TIMESTAMP(timeentry.start) >= " . $bounds[0] . " AND UNIX_TIMESTAMP(timeentry.start) <= " . $bounds[1] + . ' AND '; + $mywhere = "timeentry.user = '" . $a->getAuthData('id') . "'"; + $join = " INNER JOIN `project` AS p ON p.id = timeentry.project "; + $track = new TimeEntry($where . $mywhere, null, null, + null, /* order by */ + $select, $join); + if ($track->next()) { + $time = ecdDate::how_much_time_str($track->get('time'), HOURS); + $punches = $track->get('punches'); + } else { + $time = 0; + $punches = 0; + } + print "\n$time\n"; + print "$punches\n"; } } @@ -88,5 +124,3 @@ $user = user_obj(); $user->punch_out(false); } - -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-02-10 00:27:24
|
Revision: 365 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=365&view=rev Author: anarcat Date: 2008-02-09 16:27:30 -0800 (Sat, 09 Feb 2008) Log Message: ----------- make tags clickable, don't suppress dots, add time controls Modified Paths: -------------- trunk/phptimetracker/php/test/test_tags.php Modified: trunk/phptimetracker/php/test/test_tags.php =================================================================== --- trunk/phptimetracker/php/test/test_tags.php 2008-02-09 21:12:17 UTC (rev 364) +++ trunk/phptimetracker/php/test/test_tags.php 2008-02-10 00:27:30 UTC (rev 365) @@ -27,7 +27,7 @@ require_once('../TimeEntry.php'); require_once('../ecdForms.inc.php'); require_once('../ecdDate.inc.php'); -require_once('../ecdStd.inc.php'); +@require_once('../ecdStd.inc.php'); ?><link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css"><? @@ -40,11 +40,7 @@ print "<form>"; print form_checkbox('options', 'projects_too', 'Include projects as tags', $_GET); print ecdStd::user_listbox(null, 'user', $_GET); -print form_submit(); -print "</form>"; -if (!form_submitted($_GET)) exit(); - if ($_GET['options'] && in_array('projects_too', $_GET['options'])) { # hack: add the project name as a tag $select = 'CONCAT(comment, " ", name) as tags,delta'; @@ -54,16 +50,133 @@ $join = null; } +// avoid sql injection +$where = ""; + if ($_GET['user']) { - $user = 'user = ' . $_GET['user']; + $where = 'user = ' . $_GET['user'] . ' AND '; } else { - $user = '1'; + $where = '1 AND '; } -$hours = new TimeEntry("$user GROUP BY comment", null, null, null, $select, $join); +/* XXX: another awful copy paste, this time from rapports.php */ +?> + <div id="calendar_container"> + <?php +print __("Period: ") . form_select('period', $_GET['period'], array('range' => _('Range'), 'day' => _('Day'), 'week' => _('Week'), 'month' => _('Month'), 'year' => _('Year')), false, false, array('onChange' => 'change(this)')); ?> +<div id="calendar_a"> + <?php + $from = new ecdDate($_GET['from'], 'datetime'); + $to = new ecdDate($_GET['to'], 'datetime'); + +$date = new Date($from->unixtimestamp()); +print ecdDate::calendar_str($date, 0, null, 'from'); +?> +</div> <!-- end of calendar_a --> +<?php + +if ($_GET['period'] == 'range' || !$_GET['period']) { +?> +<div id="calendar_b"> +<?php +print ecdDate::calendar_str(new Date($to->unixtimestamp()), 0, null, 'to'); +?> + </div> <!-- end of calendar_b --> + <? + } +?> +</div> <!-- end of calendar container --> + + + </div> <!-- end of side div --> + <div id="result"> +<?php + switch ($_GET['period']) { + case 'range': + default: + break; + case 'day': + $dfrom = new Date($date); + $dfrom->setHour(0); + $dfrom->setMinute(0); + $dfrom->setSecond(0); + $dto = new Date($dfrom); + $dto->setHour(23); + $dto->setMinute(59); + $dto->setSecond(59); + $from = new ecdDate($dfrom->getTime(), 'unixtimestamp'); + $to = new ecdDate($dto->getTime(), 'unixtimestamp'); + break; + case 'month': + $dfrom = new Date($date); + $dto = new Date($date); + $dfrom->setDay(1); + $dto->setDay(1); + if ($dto->getMonth() == 12) { + $mth = 1; + $dto->setYear($dto->getYear() + 1); + } else { + $mth = $dto->getMonth() + 1; + } + $dto->setMonth($mth); + $dto->subtractSeconds(1); + $from = new ecdDate($dfrom->getTime(), 'unixtimestamp'); + $to = new ecdDate($dto->getTime(), 'unixtimestamp'); + break; + case 'week': + $dfrom = new Date($date); + $dto = new Date($date); + // find beginning of week (sunday, 0) + while ($dfrom->getDayOfWeek()) { + $dfrom = $dfrom->getPrevDay(); + } + // find end of weekd (sunday, 0 -1s) + while ($dto->getDayOfWeek()) { + $dto = $dto->getNextDay(); + } + $dto->subtractSeconds(1); + $from = new ecdDate($dfrom->getTime(), 'unixtimestamp'); + $to = new ecdDate($dto->getTime(), 'unixtimestamp'); + + break; + case 'year': + $date->setMonth(1); + $date->setDay(1); + $dfrom = new Date($date); + $dto = new Date($date); + $dto->setYear($dto->getYear()+1); + $dto->subtractSeconds(1); + $from = new ecdDate($dfrom->getTime(), 'unixtimestamp'); + $to = new ecdDate($dto->getTime(), 'unixtimestamp'); + break; + } + $bounds = array($from->unixtimestamp(), $to->unixtimestamp()); + +/* XXX: copy paste from Projec::listTimeEntries() */ +if (!is_null($bounds)) { + $st = new ecdDate($bounds[0], 'unixtimestamp'); + $end = new ecdDate($bounds[1], 'unixtimestamp'); + $where .= + "`start` >= '" .$st->datetime()."' AND ". + "`start` <= '".$end->datetime()."' AND "; +} + +/* XXX: end copy-paste */ + +$where .= "1 GROUP BY comment"; +print form_submit(); +print "</form>"; + +if (!form_submitted($_GET)) exit(); + +?> +<h3><?=__('Tags utilis\xE9s du %s au %s', $from->getShortDate(sane_lang()). " " . $from->heure, $to->getShortDate(sane_lang()) . " " . $to->heure)?></h3> +<?php + +$hours = new TimeEntry($where, null, null, null, $select, $join); $tags = array(); while ($hours->next()) { - $comment = strtolower(preg_replace('/[#,.+-><()]/', ' ', $hours->get('tags'))); + $comment = strtolower(preg_replace('/[#,+><()]/', ' ', $hours->get('tags'))); $comments = explode(' ', $comment); foreach ($comments as $comment) { if (!in_array($comment, $blacklist) && strlen($comment) > 1) { @@ -79,7 +192,7 @@ print "<table>"; foreach ($tags as $tag => $time) { - print "<tr><td>" . substr($tag, 0, 16) . "</td><td>" . ecdDate::how_much_time_str($time, HOURS, HOURS) . "</td></tr>"; + print '<tr><td>' . a(substr($tag, 0, 32), preg_replace('/^.*\?(.*)$/', '/rapports.php?\1', add_or_replace_get(add_or_replace_get($_SERVER['REQUEST_URI'], 'search', $tag), 'details[]', 1)) ) . "</td><td>" . ecdDate::how_much_time_str($time, HOURS, HOURS) . "</td></tr>"; } print "</table>"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-02-09 21:12:14
|
Revision: 364 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=364&view=rev Author: anarcat Date: 2008-02-09 13:12:17 -0800 (Sat, 09 Feb 2008) Log Message: ----------- fix warning Modified Paths: -------------- trunk/phptimetracker/php/test/test_tags.php Modified: trunk/phptimetracker/php/test/test_tags.php =================================================================== --- trunk/phptimetracker/php/test/test_tags.php 2008-02-09 21:08:23 UTC (rev 363) +++ trunk/phptimetracker/php/test/test_tags.php 2008-02-09 21:12:17 UTC (rev 364) @@ -45,7 +45,7 @@ if (!form_submitted($_GET)) exit(); -if (in_array('projects_too', $_GET['options'])) { +if ($_GET['options'] && in_array('projects_too', $_GET['options'])) { # hack: add the project name as a tag $select = 'CONCAT(comment, " ", name) as tags,delta'; $join = 'JOIN project p ON p.id = timeentry.project'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-02-09 21:08:20
|
Revision: 363 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=363&view=rev Author: anarcat Date: 2008-02-09 13:08:23 -0800 (Sat, 09 Feb 2008) Log Message: ----------- lowercase everything, allow for choosing user, don't take tags shorter than 2 chars Modified Paths: -------------- trunk/phptimetracker/php/test/test_tags.php Modified: trunk/phptimetracker/php/test/test_tags.php =================================================================== --- trunk/phptimetracker/php/test/test_tags.php 2008-02-09 20:58:56 UTC (rev 362) +++ trunk/phptimetracker/php/test/test_tags.php 2008-02-09 21:08:23 UTC (rev 363) @@ -27,20 +27,24 @@ require_once('../TimeEntry.php'); require_once('../ecdForms.inc.php'); require_once('../ecdDate.inc.php'); +require_once('../ecdStd.inc.php'); ?><link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css"><? print xml_element('p', 'Frequently used tags:'); -$blacklist = array("", "+", "de", "and", "et", "on", "to", "&", "des", "for", "du", "les", "a", "up", "the", "of", "in", "le", "la", "au", "ont", "des", "with", "without"); +$blacklist = array("de", "and", "et", "on", "to", "des", "for", "du", "les", "up", "the", "of", "in", "le", "la", "au", "ont", "des", "with", "without", "en", "dans", "pour", "avec", "sur", "at", "un", "une"); $auth = TimeAuth::instance(); print "<form>"; print form_checkbox('options', 'projects_too', 'Include projects as tags', $_GET); +print ecdStd::user_listbox(null, 'user', $_GET); print form_submit(); print "</form>"; +if (!form_submitted($_GET)) exit(); + if (in_array('projects_too', $_GET['options'])) { # hack: add the project name as a tag $select = 'CONCAT(comment, " ", name) as tags,delta'; @@ -50,13 +54,19 @@ $join = null; } -$hours = new TimeEntry('user = ' . $auth->getAuthData('id') . " GROUP BY comment", null, null, null, $select, $join); +if ($_GET['user']) { + $user = 'user = ' . $_GET['user']; +} else { + $user = '1'; +} + +$hours = new TimeEntry("$user GROUP BY comment", null, null, null, $select, $join); $tags = array(); while ($hours->next()) { - $comment = preg_replace('/[#,.+-><()]/', ' ', $hours->get('tags')); + $comment = strtolower(preg_replace('/[#,.+-><()]/', ' ', $hours->get('tags'))); $comments = explode(' ', $comment); foreach ($comments as $comment) { - if (!in_array($comment, $blacklist)) { + if (!in_array($comment, $blacklist) && strlen($comment) > 1) { if (empty($tags[$comment])) { $tags[$comment] = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-02-09 20:58:56
|
Revision: 362 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=362&view=rev Author: anarcat Date: 2008-02-09 12:58:56 -0800 (Sat, 09 Feb 2008) Log Message: ----------- fix comment cleanup, add the empty tag to the blacklist, add project name as a tag, optionnally Modified Paths: -------------- trunk/phptimetracker/php/test/test_tags.php Modified: trunk/phptimetracker/php/test/test_tags.php =================================================================== --- trunk/phptimetracker/php/test/test_tags.php 2008-02-09 20:39:03 UTC (rev 361) +++ trunk/phptimetracker/php/test/test_tags.php 2008-02-09 20:58:56 UTC (rev 362) @@ -27,21 +27,34 @@ require_once('../TimeEntry.php'); require_once('../ecdForms.inc.php'); require_once('../ecdDate.inc.php'); -require_once('../ecdErrorBuffer.inc.php'); ?><link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css"><? print xml_element('p', 'Frequently used tags:'); -$blacklist = array("+", "de", "and", "et", "on", "to", "&", "des", "for", "du", "les", "a", "up", "the", "of", "in", "le", "la", "au", "ont", "des", "with", "without"); +$blacklist = array("", "+", "de", "and", "et", "on", "to", "&", "des", "for", "du", "les", "a", "up", "the", "of", "in", "le", "la", "au", "ont", "des", "with", "without"); $auth = TimeAuth::instance(); -$hours = new TimeEntry('user = ' . $auth->getAuthData('id') . " GROUP BY comment"); +print "<form>"; +print form_checkbox('options', 'projects_too', 'Include projects as tags', $_GET); +print form_submit(); +print "</form>"; + +if (in_array('projects_too', $_GET['options'])) { + # hack: add the project name as a tag + $select = 'CONCAT(comment, " ", name) as tags,delta'; + $join = 'JOIN project p ON p.id = timeentry.project'; +} else { + $select = 'comment as tags, delta'; + $join = null; +} + +$hours = new TimeEntry('user = ' . $auth->getAuthData('id') . " GROUP BY comment", null, null, null, $select, $join); $tags = array(); while ($hours->next()) { - $comment = preg_replace('/[,.+-><()]/', '', $comment); - $comments = explode(' ', $hours->get('comment')); + $comment = preg_replace('/[#,.+-><()]/', ' ', $hours->get('tags')); + $comments = explode(' ', $comment); foreach ($comments as $comment) { if (!in_array($comment, $blacklist)) { if (empty($tags[$comment])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-02-09 20:39:05
|
Revision: 361 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=361&view=rev Author: anarcat Date: 2008-02-09 12:39:03 -0800 (Sat, 09 Feb 2008) Log Message: ----------- simple tag reporting utility Added Paths: ----------- trunk/phptimetracker/php/test/test_tags.php Added: trunk/phptimetracker/php/test/test_tags.php =================================================================== --- trunk/phptimetracker/php/test/test_tags.php (rev 0) +++ trunk/phptimetracker/php/test/test_tags.php 2008-02-09 20:39:03 UTC (rev 361) @@ -0,0 +1,63 @@ +<?php + +/********************************************************************** + * Copyright (C) 2004 The Anarcat <an...@an...> + * + * This program 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; either version 2 of the License, or + * any later version. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See also http://www.fsf.org + *********************************************************************/ + +/** + * protect this file + */ +require_once('../bin/login.php'); +require_once('../TimeEntry.php'); +require_once('../ecdForms.inc.php'); +require_once('../ecdDate.inc.php'); +require_once('../ecdErrorBuffer.inc.php'); + +?><link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css"><? + +print xml_element('p', 'Frequently used tags:'); + +$blacklist = array("+", "de", "and", "et", "on", "to", "&", "des", "for", "du", "les", "a", "up", "the", "of", "in", "le", "la", "au", "ont", "des", "with", "without"); + +$auth = TimeAuth::instance(); + +$hours = new TimeEntry('user = ' . $auth->getAuthData('id') . " GROUP BY comment"); +$tags = array(); +while ($hours->next()) { + $comment = preg_replace('/[,.+-><()]/', '', $comment); + $comments = explode(' ', $hours->get('comment')); + foreach ($comments as $comment) { + if (!in_array($comment, $blacklist)) { + if (empty($tags[$comment])) { + $tags[$comment] = 0; + } + $tags[$comment]+=$hours->get('delta');; + } + } +} + +arsort($tags); + +print "<table>"; +foreach ($tags as $tag => $time) { + print "<tr><td>" . substr($tag, 0, 16) . "</td><td>" . ecdDate::how_much_time_str($time, HOURS, HOURS) . "</td></tr>"; +} +print "</table>"; + +?> Property changes on: trunk/phptimetracker/php/test/test_tags.php ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-01-29 19:06:16
|
Revision: 360 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=360&view=rev Author: anarcat Date: 2008-01-29 11:06:14 -0800 (Tue, 29 Jan 2008) Log Message: ----------- ajouter d'autres projets a la grille horaire, reduire la taille des colonnes stupidement Modified Paths: -------------- trunk/phptimetracker/php/test/test_grille.php Modified: trunk/phptimetracker/php/test/test_grille.php =================================================================== --- trunk/phptimetracker/php/test/test_grille.php 2007-11-13 02:02:31 UTC (rev 359) +++ trunk/phptimetracker/php/test/test_grille.php 2008-01-29 19:06:14 UTC (rev 360) @@ -51,7 +51,7 @@ error_reporting(E_ALL); if (!isset($_GET['projects']) || !$_GET['projects']) { - $_GET['projects'] = 'Contrats, Pause, Projets internes, Comptabilit\xE9, Secr\xE9tariat, Vie associative, Autres, Sysadmin, Coordination, Graphisme, Vente, Webdev, Communication & Marketing'; + $_GET['projects'] = 'Contrats, Pause, Projets internes, Comptabilit\xE9, Repr\xE9sentation, Secr\xE9tariat, Vie associative, Autres, Sysadmin, Coordination, Graphisme, Vente, Webdev, Communication & Marketing, Formation interne'; } $pstrs = explode(',', $_GET['projects']); foreach ($pstrs as $project) { @@ -155,7 +155,7 @@ echo '<tr><td>User</td>'; foreach ($pstrs as $name) { - echo '<td>' . $name . '</td>'; + echo '<td>' . substr($name, 0, 8) . '</td>'; } echo '<td><strong>Total<strong></td>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-11-13 02:02:30
|
Revision: 359 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=359&view=rev Author: anarcat Date: 2007-11-12 18:02:31 -0800 (Mon, 12 Nov 2007) Log Message: ----------- add calendars and memory to forms Modified Paths: -------------- trunk/phptimetracker/php/test/test_grille.php Modified: trunk/phptimetracker/php/test/test_grille.php =================================================================== --- trunk/phptimetracker/php/test/test_grille.php 2007-10-31 22:19:38 UTC (rev 358) +++ trunk/phptimetracker/php/test/test_grille.php 2007-11-13 02:02:31 UTC (rev 359) @@ -1,3 +1,14 @@ +<?php + +require_once('../bin/login.php'); +require_once('../Project.php'); +require_once('../ecdErrorBuffer.inc.php'); +require_once('../ecdProfiler.inc.php'); +require_once('../language.php'); + +$date = new ecdDate($_GET['from'], 'datetime'); +?> + <html> <head> @@ -7,17 +18,36 @@ <link href="/css/facture_print.css" rel="stylesheet" type="text/css" media="print" /> </head> <body> +<div id="calendar_a"> + <?php + $from = new ecdDate($_GET['from'], 'datetime'); + $to = new ecdDate($_GET['to'], 'datetime'); + +$date = new Date($from->unixtimestamp()); +print ecdDate::calendar_str($date, 0, null, 'from'); +?> +</div> <!-- end of calendar_a --> +<div id="calendar_b"> +<?php +print ecdDate::calendar_str(new Date($to->unixtimestamp()), 0, null, 'to'); +?> + </div> <!-- end of calendar_b --> + <form> -<label>Projects (comma-seperated): <input type="text" name="projects"></label> -<label>Users (comma-seperated): <input type="text" name="users"></label> +<label>Projects (comma-seperated): <?php print form_input('text', 'projects', $_GET); ?></label> +<label>Users (comma-seperated): <?php print form_input('text', 'users', $_GET);?></label> +Average on:<ul> +<?php foreach (array('minutes', 'hours', 'days', 'weeks') as $avg) { +print '<li>'.form_radio('average', $avg, $avg, $_GET).'</li>'; +} +?></ul><?php +print form_hidden('from', $_GET); +print form_hidden('to', $_GET); +?> <input type="submit"> </form> <?php -require_once('../bin/login.php'); -require_once('../Project.php'); -require_once('../ecdErrorBuffer.inc.php'); -require_once('../ecdProfiler.inc.php'); error_reporting(E_ALL); if (!isset($_GET['projects']) || !$_GET['projects']) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-10-31 22:19:36
|
Revision: 358 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=358&view=rev Author: anarcat Date: 2007-10-31 15:19:38 -0700 (Wed, 31 Oct 2007) Log Message: ----------- make it clearer which times are concerned Modified Paths: -------------- trunk/phptimetracker/rapports.php Modified: trunk/phptimetracker/rapports.php =================================================================== --- trunk/phptimetracker/rapports.php 2007-10-18 20:00:38 UTC (rev 357) +++ trunk/phptimetracker/rapports.php 2007-10-31 22:19:38 UTC (rev 358) @@ -254,7 +254,7 @@ $bounds = array($from->unixtimestamp(), $to->unixtimestamp()); ?> - <h3><?=__('Temps du %s au %s', $from->getShortDate(sane_lang()), $to->getShortDate(sane_lang()))?></h3> + <h3><?=__('Temps du %s au %s', $from->getShortDate(sane_lang()). " " . $from->heure, $to->getShortDate(sane_lang()) . " " . $to->heure)?></h3> <table width="100%"> <tr class="header"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-10-18 20:00:37
|
Revision: 357 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=357&view=rev Author: anarcat Date: 2007-10-18 13:00:38 -0700 (Thu, 18 Oct 2007) Log Message: ----------- remove gozerbot plugin from distribution, it's now available from http://hg.koumbit.net/gozerplugs Removed Paths: ------------- trunk/phptimetracker/REST/ trunk/phptimetracker/__init__.py trunk/phptimetracker/client.py trunk/phptimetracker/gozerbotplugin.py Deleted: trunk/phptimetracker/__init__.py =================================================================== Deleted: trunk/phptimetracker/client.py =================================================================== --- trunk/phptimetracker/client.py 2007-10-17 02:16:48 UTC (rev 356) +++ trunk/phptimetracker/client.py 2007-10-18 20:00:38 UTC (rev 357) @@ -1,8 +0,0 @@ -#! /usr/bin/python - -from REST import Timetracker - -if __name__ == "__main__": - conn = Timetracker('http://localhost/phptimetracker', 'anarcat', 'test') - #conn.debug = True - print repr(conn.project_list('timetracker', 1)) Deleted: trunk/phptimetracker/gozerbotplugin.py =================================================================== --- trunk/phptimetracker/gozerbotplugin.py 2007-10-17 02:16:48 UTC (rev 356) +++ trunk/phptimetracker/gozerbotplugin.py 2007-10-18 20:00:38 UTC (rev 357) @@ -1,179 +0,0 @@ -# plugs/timetracker.py -# -# to install this plugin, you need to decompress the phptimetracker -# archive in the myplugs directory an move/copy/link this file in the -# myplugs directory. Example: -# -# % ls -ald myplugs/*time* -# drwxr-xr-x 11 anarcat koumbot 1024 Jun 28 13:43 myplugs/phptimetracker -# lrwxr-xr-x 1 anarcat koumbot 32 Jun 1 15:25 myplugs/timetracker.py -> phptimetracker/gozerbotplugin.py -# -# then load the plugin in the bot using the load command and follow the -# inline help -# -# note that your timetracker username passwords are stored in clear -# text on the server - -""" communicate with the timetracker """ - -__copyright__ = 'this file is in the public domain' -__author__ = 'Antoine Beaupre (an...@ko...)' - -from gozerbot.generic import elapsedstring -from gozerbot.persist import Persist -from gozerbot.users import users -from gozerbot.commands import cmnds -from gozerbot.aliases import aliasset -from gozerbot.examples import examples -from gozerbot.datadir import datadir -from gozerbot.plughelp import plughelp -from gozerbot.persistconfig import PersistConfig -import time, os -from myplugs.phptimetracker.REST import Timetracker - -plughelp.add('timetracker', 'start/stop punch in timetracker and communicate with timetracker') - -cfg = PersistConfig() -cfg.define('timetracker', '') - -# The work times -punches = Persist(datadir + os.sep + 'punches') -timeauth = Persist(datadir + os.sep + 'timeauth') - -if not punches.data: - punches.data = {} - -if not timeauth.data: - timeauth.data = {} - -def timetrack_checkauth(ievent): - # Get the user - username = users.getname(ievent.userhost) - # Check data construction - if username != None and not timeauth.data.has_key(username): - ievent.reply('not authenticated with the timetracker, use tt-login <username> <password> to authenticate') - username = False - return username - -def handle_timeauth(bot, ievent): - """ authenticate with the timetracker """ - nick = users.getname(ievent.userhost) - if nick == None: - return - if len(ievent.args) < 2: - ievent.reply("missing argument") - return - username = ievent.args[0] - password = ievent.args[1] - conn = Timetracker(cfg.get('timetracker'), username, password) - status = conn.login() - if status == 200: - ievent.reply("login sucessful") - timeauth.data[nick] = (username, password) - timeauth.save() - elif status == 401: - ievent.reply("login failed: wrong username or password") - else: - ievent.reply("login failed: unknown error code %d" % status) - -def handle_timelogout(bot, ievent): - username = timetrack_checkauth(ievent) - if not username: - return - del timeauth.data[username] - ievent.reply("forgotten all about you") - -def handle_timestart(bot, ievent): - """ store work start time """ - username = timetrack_checkauth(ievent) - if not username: - return - if len(ievent.args) < 1: - ievent.reply("missing project id") - return - comment = None - if len(ievent.args) > 1: - comment = " ".join(ievent.args[1:]) - - conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) - try: - pid = str(int(ievent.args[0])) - pname = str(pid) - except ValueError: - projects = conn.project_list(ievent.args[0]) - if len(projects) > 1: - ievent.reply('%d projects found matching %s, refine your search. matching projects: %s' % (len(projects), ievent.args[0], pretty_projects(projects))) - return - elif len(projects) < 1: - ievent.reply('no project found matching %s, try again' % ievent.args[0]) - return - else: - project = projects.popitem() - pid = project[0] - pname = "#%s %s" % (project) - - status = conn.punch_in(pid, comment) - if status: - try: - oldcomment = status[2] - except IndexError: - oldcomment = 'no comment' - try: - ievent.reply("punched in project %s (%s) and punched out, worked %s on %s (%s)" % (pname, comment, elapsedstring(status[1]), status[0], oldcomment)) - except IndexError: - ievent.reply("punched in project %s (%s) and punched out of previous project" % (pname, comment)) - else: - ievent.reply("punched in project %s (%s)" % (pname, comment)) - -# Handle a workstop -def handle_timestop(bot, ievent): - """ punch out timetracker """ - username = timetrack_checkauth(ievent) - if not username: - return - comment = None - if len(ievent.args) >= 1: - comment = " ".join(ievent.args[0:]) - conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) - status = conn.punch_out(comment) - if status: - ievent.reply("punched out of project %s, worked %s (%s)" % (status[0], elapsedstring(status[1]), status[2])) - else: - ievent.reply("not punched in") - -def handle_projectlist(bot, ievent): - username = timetrack_checkauth(ievent) - if not username: - return - if len(ievent.args) < 1: - ievent.reply("missing project id") - return - ievent.reply("fetching project list...") - conn = Timetracker(cfg.get('timetracker'), timeauth.data[username][0], timeauth.data[username][1]) - projects = conn.project_list(ievent.args[0]) - if len(projects) > 1: - ievent.reply("%d projects found, matching projects: %s" % (len(projects), pretty_projects(projects))) - elif len(projects) == 1: - ievent.reply("project found: %s" % (pretty_projects(projects))) - elif len(projects) < 1: - ievent.reply('no project found matching %s, try again' % ievent.args[0]) - -def pretty_projects(projects): - return ", ".join(map(lambda x: "%s: %s" % x,projects.iteritems())) - -cmnds.add('tt-logout', handle_timelogout, 'USER') -examples.add('tt-logout', 'forget timetracker credentials', 'tt-logout') -cmnds.add('tt-login', handle_timeauth, 'USER') -examples.add('tt-login', 'authenticate with the timetracker, note that this stores your credentials, in clear text, on the bot disk', 'tt-login username password') -cmnds.add('tt-punchin', handle_timestart, 'USER') -examples.add('tt-punchin', 'punch in timetracker', 'tt-punchin project comment') -aliasset('punch', 'tt-punchin') -aliasset('punchin', 'tt-punchin') -cmnds.add('tt-punchout', handle_timestop, 'USER') -examples.add('tt-punchout', 'punch out timetracker', 'tt-punchout') -aliasset('punchout', 'tt-punchout') -aliasset('depunch', 'tt-punchout') -aliasset('depunche', 'tt-punchout') -cmnds.add('tt-projectlist', handle_projectlist, 'USER') -examples.add('tt-projectlist', 'list projects from the timetracker', 'tt-projectlist pattern') -aliasset('projectlist', 'tt-projectlist') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-10-18 03:03:52
|
Revision: 356 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=356&view=rev Author: anarcat Date: 2007-10-16 19:16:48 -0700 (Tue, 16 Oct 2007) Log Message: ----------- rely on current date for little stats Modified Paths: -------------- trunk/phptimetracker/index.php Modified: trunk/phptimetracker/index.php =================================================================== --- trunk/phptimetracker/index.php 2007-09-21 22:30:35 UTC (rev 355) +++ trunk/phptimetracker/index.php 2007-10-17 02:16:48 UTC (rev 356) @@ -132,8 +132,8 @@ <li>My punches above 6h this <a href="rapports.php?duration_min=720&details[]=1&period=week">week</a> | <a href="rapports.php?duration_min=720&details[]=1&period=month">month</a> | <a href="rapports.php?duration_min=720&details[]=1&period=year">year</a> (good for finding runaway punches).</li> <li>Time worked by all workers this <a href="rapports.php?period=week&user=0&summary%5B%5D=1">week</a> | <a href="rapports.php?period=month&user=0&summary%5B%5D=1">month</a> | <a href="rapports.php?period=year&user=0&summary%5B%5D=1">year</a>.</li> <?php - $dfrom = new Date(); - $dto = new Date(); + $dfrom = new Date($_GET['date']); + $dto = new Date($_GET['date']); // find beginning of week (sunday, 0) while ($dfrom->getDayOfWeek()) { $dfrom = $dfrom->getPrevDay(); @@ -164,7 +164,7 @@ } ?> - <li>Time I spent on Koumbit this week: <a href="rapports.php?period=week"><?= $time ?> (<?= $punches ?> punches)</a></li> + <li>Time I spent on Koumbit during the week starting <?php print $from->getLongDate('en') ?>: <a href="rapports.php?period=week"><?= $time ?> (<?= $punches ?> punches)</a></li> <?php $track = new TimeEntry($where . '1', null, null, null, /* order by */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-09-21 22:36:57
|
Revision: 355 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=355&view=rev Author: anarcat Date: 2007-09-21 15:30:35 -0700 (Fri, 21 Sep 2007) Log Message: ----------- allow for computing averages over weeks/months/etc Modified Paths: -------------- trunk/phptimetracker/php/test/test_grille.php Modified: trunk/phptimetracker/php/test/test_grille.php =================================================================== --- trunk/phptimetracker/php/test/test_grille.php 2007-09-12 01:02:02 UTC (rev 354) +++ trunk/phptimetracker/php/test/test_grille.php 2007-09-21 22:30:35 UTC (rev 355) @@ -45,6 +45,43 @@ $to = new ecdDate($_GET['to'], 'datetime'); $bounds = array($from->unixtimestamp(), $to->unixtimestamp()); +$delta = $bounds[1] - $bounds[0]; /* in seconds */ +$minutes_delta = $delta / MINUTES; +$hours_delta = $delta / HOURS; +$days_delta = $delta / DAYS; +$weeks_delta = $delta / WEEKS; + +print "period represents: <ul>"; +print "<li>$minutes_delta minutes</li>"; +print "<li>$hours_delta hours</li>"; +print "<li>$days_delta days</li>"; +print "<li>$weeks_delta weeks</li>"; +print "</ul>"; + +$average = 0; + +switch ($_GET['average'] ) { + case "minutes": + $average = MINUTES; + break; + case "hours": + $average = HOURS; + break; + case "days": + $average = DAYS; + break; + case "weeks": + $average = WEEKS; + break; +} + +if ($average) { + $avg_count = round(( $delta / $average )); + print "averaging on $avg_count " . $_GET['average']; +} else { + $avg_count = 1; +} + function get_time($user, $project, $bounds = null) { $where = "p.path LIKE '" . $project . "%' AND `user` = " . $user . ' AND '; @@ -97,7 +134,7 @@ echo '<tr><td>' . $username . '</td>'; $user_time = 0; foreach ($projects as $name => $path) { - $time = get_time($uid, $path, $bounds); + $time = round(get_time($uid, $path, $bounds) / $avg_count); $project_time[$name] += $time; $user_time += $time; echo '<td>' . ($time ? ecdDate::how_much_time_str($time, HOURS, 60*MINUTES) : "" ) . '</td>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-09-12 01:02:03
|
Revision: 354 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=354&view=rev Author: anarcat Date: 2007-09-11 18:02:02 -0700 (Tue, 11 Sep 2007) Log Message: ----------- remove a few zeros Modified Paths: -------------- trunk/phptimetracker/php/test/test_grille.php Modified: trunk/phptimetracker/php/test/test_grille.php =================================================================== --- trunk/phptimetracker/php/test/test_grille.php 2007-09-12 00:54:31 UTC (rev 353) +++ trunk/phptimetracker/php/test/test_grille.php 2007-09-12 01:02:02 UTC (rev 354) @@ -100,14 +100,14 @@ $time = get_time($uid, $path, $bounds); $project_time[$name] += $time; $user_time += $time; - echo '<td>' . ecdDate::how_much_time_str($time, HOURS, 60*MINUTES) . '</td>'; + echo '<td>' . ($time ? ecdDate::how_much_time_str($time, HOURS, 60*MINUTES) : "" ) . '</td>'; } - echo '<td>' . ecdDate::how_much_time_str($user_time, HOURS, 60*MINUTES) . '</td>'; + echo '<td>' . ($user_time ? ecdDate::how_much_time_str($user_time, HOURS, 60*MINUTES) : "") . '</td>'; $grand_total += $user_time; echo '</tr>'; } echo '<tr><td><strong>Grand total</strong></td>'; foreach ($project_time as $name => $time) { - print '<td><strong>' . ecdDate::how_much_time_str($time, HOURS, 60*MINUTES) . '</strong></td>'; + print '<td><strong>' . ( $time ? ecdDate::how_much_time_str($time, HOURS, 60*MINUTES) : "") . '</strong></td>'; } -echo '<td><strong>' . ecdDate::how_much_time_str($grand_total, HOURS, 60*MINUTES) . '</strong></td></tr></table>'; +echo '<td><strong>' . ( $grand_total ? ecdDate::how_much_time_str($grand_total, HOURS, 60*MINUTES) : "") . '</strong></td></tr></table>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-09-12 00:54:28
|
Revision: 353 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=353&view=rev Author: anarcat Date: 2007-09-11 17:54:31 -0700 (Tue, 11 Sep 2007) Log Message: ----------- nicer Modified Paths: -------------- trunk/phptimetracker/php/test/test_grille.php Modified: trunk/phptimetracker/php/test/test_grille.php =================================================================== --- trunk/phptimetracker/php/test/test_grille.php 2007-09-12 00:47:52 UTC (rev 352) +++ trunk/phptimetracker/php/test/test_grille.php 2007-09-12 00:54:31 UTC (rev 353) @@ -100,14 +100,14 @@ $time = get_time($uid, $path, $bounds); $project_time[$name] += $time; $user_time += $time; - echo '<td>' . ecdDate::how_much_time_str($time, HOURS, HOURS) . '</td>'; + echo '<td>' . ecdDate::how_much_time_str($time, HOURS, 60*MINUTES) . '</td>'; } - echo '<td>' . ecdDate::how_much_time_str($user_time, HOURS, HOURS) . '</td>'; + echo '<td>' . ecdDate::how_much_time_str($user_time, HOURS, 60*MINUTES) . '</td>'; $grand_total += $user_time; echo '</tr>'; } echo '<tr><td><strong>Grand total</strong></td>'; foreach ($project_time as $name => $time) { - print '<td><strong>' . ecdDate::how_much_time_str($time, HOURS, HOURS) . '</strong></td>'; + print '<td><strong>' . ecdDate::how_much_time_str($time, HOURS, 60*MINUTES) . '</strong></td>'; } -echo '<td><strong>' . ecdDate::how_much_time_str($grand_total, HOURS, HOURS) . '</strong></td></tr></table>'; +echo '<td><strong>' . ecdDate::how_much_time_str($grand_total, HOURS, 60*MINUTES) . '</strong></td></tr></table>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-09-12 00:47:53
|
Revision: 352 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=352&view=rev Author: anarcat Date: 2007-09-11 17:47:52 -0700 (Tue, 11 Sep 2007) Log Message: ----------- add totals, fix calculations, default to all subtree, etc Modified Paths: -------------- trunk/phptimetracker/php/test/test_grille.php Modified: trunk/phptimetracker/php/test/test_grille.php =================================================================== --- trunk/phptimetracker/php/test/test_grille.php 2007-09-12 00:31:06 UTC (rev 351) +++ trunk/phptimetracker/php/test/test_grille.php 2007-09-12 00:47:52 UTC (rev 352) @@ -21,16 +21,13 @@ error_reporting(E_ALL); if (!isset($_GET['projects']) || !$_GET['projects']) { - $_GET['projects'] = 'Contrats%, Pause, Projets%, Comptabilit\xE9, Secr\xE9tariat, Vie associative, Autres, Sysadmin, Coordination, Graphisme, Vente, Webdev, communication&marketing'; + $_GET['projects'] = 'Contrats, Pause, Projets internes, Comptabilit\xE9, Secr\xE9tariat, Vie associative, Autres, Sysadmin, Coordination, Graphisme, Vente, Webdev, Communication & Marketing'; } $pstrs = explode(',', $_GET['projects']); foreach ($pstrs as $project) { - $p = new Project("`name` LIKE '" . trim(str_replace('%', '', $project)) . "'"); + $p = new Project("`name` LIKE '" . trim($project) . "'"); if ($p->next()) { $projects[$project] = $p->get('path'); - if (strstr($project, '%')) { - $projects[$project] .= '%'; - } } } @@ -49,7 +46,7 @@ $bounds = array($from->unixtimestamp(), $to->unixtimestamp()); function get_time($user, $project, $bounds = null) { - $where = "p.path LIKE '" . $project . "' AND `user` = " . $user . ' AND '; + $where = "p.path LIKE '" . $project . "%' AND `user` = " . $user . ' AND '; if (!is_null($bounds)) { $st = new ecdDate($bounds[0], 'unixtimestamp'); @@ -58,7 +55,7 @@ "`start` >= '" .$st->datetime()."' AND ". "`start` <= '".$end->datetime()."' AND "; } - $where .= '1 GROUP BY `project`'; + $where .= '1'; $join = " INNER JOIN `project` AS p ON p.id = timeentry.project "; $select = 'SUM(delta) as time'; $track = new TimeEntry($where, null, null, null, @@ -93,11 +90,24 @@ foreach ($pstrs as $name) { echo '<td>' . $name . '</td>'; } +echo '<td><strong>Total<strong></td>'; +$grand_total = 0; foreach ($users as $uid => $username) { - echo '<tr><td>' . $uid . ": " . $username . '</td>'; + echo '<tr><td>' . $username . '</td>'; + $user_time = 0; foreach ($projects as $name => $path) { - echo '<td>' . ecdDate::how_much_time_str(get_time($uid, $path, $bounds), HOURS, 60*MINUTES) . '</td>'; + $time = get_time($uid, $path, $bounds); + $project_time[$name] += $time; + $user_time += $time; + echo '<td>' . ecdDate::how_much_time_str($time, HOURS, HOURS) . '</td>'; } + echo '<td>' . ecdDate::how_much_time_str($user_time, HOURS, HOURS) . '</td>'; + $grand_total += $user_time; echo '</tr>'; } +echo '<tr><td><strong>Grand total</strong></td>'; +foreach ($project_time as $name => $time) { + print '<td><strong>' . ecdDate::how_much_time_str($time, HOURS, HOURS) . '</strong></td>'; +} +echo '<td><strong>' . ecdDate::how_much_time_str($grand_total, HOURS, HOURS) . '</strong></td></tr></table>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-09-12 00:31:05
|
Revision: 351 http://phptimetracker.svn.sourceforge.net/phptimetracker/?rev=351&view=rev Author: anarcat Date: 2007-09-11 17:31:06 -0700 (Tue, 11 Sep 2007) Log Message: ----------- add grille horaire evaluation test Added Paths: ----------- trunk/phptimetracker/php/test/test_grille.php Added: trunk/phptimetracker/php/test/test_grille.php =================================================================== --- trunk/phptimetracker/php/test/test_grille.php (rev 0) +++ trunk/phptimetracker/php/test/test_grille.php 2007-09-12 00:31:06 UTC (rev 351) @@ -0,0 +1,103 @@ +<html> + + <head> + <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> + <link href="/css/espresso_timesheet.css" rel="stylesheet" type="text/css" media="screen" /> + <link href="/css/plain.css" rel="alternate stylesheet" type="text/css" media="screen" title="plain" /> + <link href="/css/facture_print.css" rel="stylesheet" type="text/css" media="print" /> + </head> +<body> +<form> +<label>Projects (comma-seperated): <input type="text" name="projects"></label> +<label>Users (comma-seperated): <input type="text" name="users"></label> +<input type="submit"> +</form> +<?php + +require_once('../bin/login.php'); +require_once('../Project.php'); +require_once('../ecdErrorBuffer.inc.php'); +require_once('../ecdProfiler.inc.php'); +error_reporting(E_ALL); + +if (!isset($_GET['projects']) || !$_GET['projects']) { + $_GET['projects'] = 'Contrats%, Pause, Projets%, Comptabilit\xE9, Secr\xE9tariat, Vie associative, Autres, Sysadmin, Coordination, Graphisme, Vente, Webdev, communication&marketing'; +} +$pstrs = explode(',', $_GET['projects']); +foreach ($pstrs as $project) { + $p = new Project("`name` LIKE '" . trim(str_replace('%', '', $project)) . "'"); + if ($p->next()) { + $projects[$project] = $p->get('path'); + if (strstr($project, '%')) { + $projects[$project] .= '%'; + } + } +} + +/* get all the subprojects of R\xF4les too */ +/* $p = new Project(array('name' => 'R\xF4les')); +if ($p->next()) { + $path = $p->get('path'); + $p = new Project("`path` LIKE '" . $path . "%' AND LENGTH(`path`) = " . 2*KEYLENGTH); + while($p->next()) { + $projects[$p->get('id')] = $p->get('name'); + } +} */ + +$from = new ecdDate($_GET['from'], 'datetime'); +$to = new ecdDate($_GET['to'], 'datetime'); + $bounds = array($from->unixtimestamp(), $to->unixtimestamp()); + +function get_time($user, $project, $bounds = null) { + $where = "p.path LIKE '" . $project . "' AND `user` = " . $user . ' AND '; + + if (!is_null($bounds)) { + $st = new ecdDate($bounds[0], 'unixtimestamp'); + $end = new ecdDate($bounds[1], 'unixtimestamp'); + $where .= + "`start` >= '" .$st->datetime()."' AND ". + "`start` <= '".$end->datetime()."' AND "; + } + $where .= '1 GROUP BY `project`'; + $join = " INNER JOIN `project` AS p ON p.id = timeentry.project "; + $select = 'SUM(delta) as time'; + $track = new TimeEntry($where, null, null, null, + $select, + $join); + if ($track->next()) { + $time = $track->get('time'); + } else { + $time = 0; + } + return $time; +} +$users = array(); +if (!isset($_GET['users']) || !$_GET['users']) { + $user = new User(); + while ($user->next()) { + $users[$user->get('id')] = $user->get('username'); + } +} else { + $ustrs = explode(',', $_GET['users']); + foreach ($ustrs as $user) { + $p = new User(array('username' => trim($user))); + if ($p->next()) { + $users[$p->get('id')] = $user; + } + } +} + +echo '<table>'; +echo '<tr><td>User</td>'; + +foreach ($pstrs as $name) { + echo '<td>' . $name . '</td>'; +} + +foreach ($users as $uid => $username) { + echo '<tr><td>' . $uid . ": " . $username . '</td>'; + foreach ($projects as $name => $path) { + echo '<td>' . ecdDate::how_much_time_str(get_time($uid, $path, $bounds), HOURS, 60*MINUTES) . '</td>'; + } + echo '</tr>'; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |