Translations of this page?:

Here's a little hack to allow command-line interaction with our favorite Web Office Suite. It works by executing PHP in the Unix Shell.

Ideal for narrowband on-the-road-interaction from anything that can run SSH. Like, my mobile Phone!

first little attempt only shows a somewhat formatted list of tasks, sorted by tag. To come: Creating new Tasks, marking tasks complete. If Easter then still isn't over, perhaps I'll do something for Contacts & Notes next.

e.g.

PHP OGOO.PHP -u wolf -t tel -w 6

will dump all tasks for me tagged as “tel” from my private workspace…

the output looks like this:

user>id tag description text of the task (workspace name-id)

parameters: -u username -t tag (currently supports filtering for one tag only) -w workspace (must supply the workspace number. The number can be found in the dump at the end of each line.

oh, please be aware that this might pose a severe security risk. Use only if you know what you are doing. I'm absolutely not responsible.

uses a command-line parser function by Tyler Hall found here.

copy the following code as ogoo.php into your Feng Office root dir, or wherever.

''#!/usr/local/bin/php -q
 
<?php
$dbhost = '127.0.0.1:3306';
$dbuser = 'root';
$dbpass = '********'; // insert your password here
 
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
 
$dbname = 'opengoo'; // insert your DB name here
mysql_select_db($dbname);
 
$argv[0]=="ogoo" ? $nl="\n" : $nl="<br>";
 
$a= new Args();
 
$a->flag('u') ? $user = "User:".$a->flag('u') : $user="Any User" ;
$a->flag('u') ? $userfilter = "AND `og_users`.`username` = '".$a->flag('u')."'" : $userfilter="" ;
 
$a->flag('t') ? $tag = "Tag:". $a->flag('t') : $tag="No Tag";
$a->flag('t') ? $tagfilter = "AND `og_tags`.`tag` = '". $a->flag('t')."'" : $tagfilter="";
 
$a->flag('w') ? $tag = "Workspace:". $a->flag('w') : $tag="All Workspaces";
$a->flag('w') ? $wsfilter ="AND `og_projects`.`id` = ".$a->flag('w')  : $wsfilter="" ;
 
// parameters for Tasks
// tag=xxxx due=yyyymmdd  ws="workspace Name"
 
print ("connect...success".$nl);
 
$result=mysql_query("SELECT `og_project_tasks`.`id` AS `taskID`, `og_tags`.`tag`, `og_project_tasks`.`title`, `og_project_tasks`.`assigned_to_user_id`, `og_users`.`username`, `og_projects`.`name`, `og_projects`.`id` FROM `opengoo`.`og_tags` AS `og_tags`, `opengoo`.`og_project_tasks` AS `og_project_tasks`, `opengoo`.`og_users` AS `og_users`, `opengoo`.`og_projects` AS `og_projects` WHERE `og_tags`.`rel_object_id` = `og_project_tasks`.`id` AND `og_users`.`id` = `og_project_tasks`.`assigned_to_user_id` AND `og_project_tasks`.`project_id` = `og_projects`.`id` ".$userfilter.$tagfilter." AND `og_tags`.`rel_object_manager` = 'ProjectTasks' AND `og_project_tasks`.`trashed_by_id` = 0 AND `og_project_tasks`.`completed_by_id` = 0 ".$wsfilter." ORDER BY `og_tags`.`tag` ASC");
 
 
// store the record of the "example" table into $row
$i=0;
while($row = mysql_fetch_array( $result )){
	$i++;
	print ($row['username'].">".$row['taskID']."\t".$row['tag']."\t".$row['title']." (".$row['name']."-".$row['id'].")".$nl);
};
print ($nl.$user."/".$tag."/".$i." tasks in this list.");
 
//--------------------------------------------------------------------------------------------------------
 
    // A quick and dirty command line argument parser. Written in about
    // an hour, so you might want to take this with a grain of salt or two.
    //
    // Single letter options should be prefixed with a single
    // dash and can be grouped together. Examples:
    //
    // cmd -a
    // cmd -ab
    //
    // Values can be assigned to single letter options like so:
    //
    // cmd -a foo (a will be set to foo.)
    //
    // cmd -a foo -b (a will be set to foo.)
    //
    // cmd -ab foo (a and b will simply be set to true. foo is only listed as an argument.)
    //
    // You can also use the double-dash syntax. Examples:
    //
    // cmd --value
    //
    // cmd --value foo (value is set to foo)
    //
    // cmd --value=foo (value is set to foo)
    //
    // Single dash and double dash syntax may be mixed.
    //
    // Trailing arguments are treated as such. Examples:
    //
    // cmd -abc foo bar (foo and bar are listed as arguments)
    //
    // cmd -a foo -b bar charlie (only bar and charlie are arguments)
 
 
    class Args
    {
        private $flags;
        public $args;
 
        public function __construct()
        {
            $this->flags = array();
            $this->args  = array();
 
            $argv = $GLOBALS['argv'];
            array_shift($argv);
 
            for($i = 0; $i < count($argv); $i++)
            {
                $str = $argv[$i];
 
                // --foo
                if(strlen($str) > 2 && substr($str, 0, 2) == '--')
                {
					$str = substr($str, 2);
                    $parts = explode('=', $str);
                    $this->flags[$parts[0]] = true;
 
                    // Does not have an =, so choose the next arg as its value
                    if(count($parts) == 1 && isset($argv[$i + 1]) && preg_match('/^--?.+/', $argv[$i + 1]) == 0)
                    {
                        $this->flags[$parts[0]] = $argv[$i + 1];
                    }
                    elseif(count($parts) == 2) // Has a =, so pick the second piece
                    {
                        $this->flags[$parts[0]] = $parts[1];
                    }
                }
                elseif(strlen($str) == 2 && $str[0] == '-') // -a
                {
                    $this->flags[$str[1]] = true;
                    if(isset($argv[$i + 1]) && preg_match('/^--?.+/', $argv[$i + 1]) == 0)
                        $this->flags[$str[1]] = $argv[$i + 1];
                }
                elseif(strlen($str) > 1 && $str[0] == '-') // -abcdef
                {
                    for($j = 1; $j < strlen($str); $j++)
                        $this->flags[$str[$j]] = true;
                }
            }
 
            for($i = count($argv) - 1; $i >= 0; $i--)
            {
                if(preg_match('/^--?.+/', $argv[$i]) == 0)
                    $this->args[] = $argv[$i];
                else
                    break;
            }
 
            $this->args = array_reverse($this->args);
        }
 
        public function flag($name)
        {
            return isset($this->flags[$name]) ? $this->flags[$name] : false;
        }
    }
 
 
 
 
?>

by — max wolf 2009-04-17 15:49

Discussion

PLEASE NOTE: Comments to the wiki should only contain suggestions and questions that help us to improve the manual (and not the software). These comments will be deleted as soon as the information has been integrated into the manual.

Posts that do not contribute to the DOCUMENTATION of the project will be DELETED.

Ask QUESTIONS on the product here.
Report BUGS here.
Propose NEW FEATURES here.


Enter your comment
 
shell_access.txt · Last modified: 2013-02-27 18:06 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported


Terms of Service | Privacy and Security policies | Copyright © 2018 fengoffice.com