Exemplo n.º 1
0
function publications_treeapi_getancestors($args)
{
    // Expand the arguments.
    extract($args);
    // Database.
    $dbconn =& xarDBGetConn();
    if ($id != 0) {
        // Insert point is a real item.
        $query = "SELECT \n                    parent.{$idname}\n                  FROM \n                    {$tablename} AS node, \n                    {$tablename} AS parent \n                  WHERE \n                    node.xar_left BETWEEN parent.xar_left AND parent.xar_right \n                    AND \n                    node.{$idname} = ? \n                  ORDER BY \n                    parent.xar_left";
        if (isset($rootonly) && $rootonly == true) {
            $query .= " ASC LIMIT 1";
        }
        $result = $dbconn->execute($query, array((int) $id));
        $ancestors = array();
        // return results in order from root to leaf
        while (!$result->EOF) {
            list($pid) = $result->fields;
            $ancestors[] = $pid;
            $result->MoveNext();
        }
        if (count($ancestors) > 0) {
            return $ancestors;
        } else {
            return;
        }
    } else {
        // Insert point is the virtual root, return it
        return array(0);
    }
}
Exemplo n.º 2
0
function publications_treeapi_getsiblings($args)
{
    // Expand the arguments.
    extract($args);
    // Database.
    $dbconn =& xarDBGetConn();
    if ($id != 0) {
        // Insert point is a real item.
        $query = "SELECT \n                    parent.{$idname}\n                  FROM \n                    {$tablename} AS node, \n                    {$tablename} AS parent \n                  WHERE \n                    parent.xar_parent = node.xar_parent\n                    AND \n                    node.{$idname} = ?";
        if (!isset($includeself) || $includeself != true) {
            $query .= " AND parent.{$idname} != ?";
        }
        $query .= " ORDER BY parent.xar_left";
        $siblings = array();
        // return results in proper order
        while (!$result->EOF) {
            list($pid) = $result->fields;
            $siblings[] = $pid;
            $result->MoveNext();
        }
        if (count($siblings) > 0) {
            return $siblings;
        } else {
            return;
        }
    } else {
        // Insert point is the virtual root.
        // Virtual root has no siblings
        if (isset($includeself) && $includeself == true) {
            return array(0);
        } else {
            return;
        }
    }
}
Exemplo n.º 3
0
function publications_treeapi_getparent($args)
{
    // Expand the arguments.
    extract($args);
    // Database.
    $dbconn =& xarDBGetConn();
    if ($id != 0) {
        // Insert point is a real item.
        $query = 'SELECT xar_parent' . ' FROM ' . $tablename . ' WHERE ' . $idname . ' = ?';
        $result = $dbconn->execute($query, array((int) $id));
        if (!$result->EOF) {
            list($parent) = $result->fields;
            $return = array((int) $parent);
        } else {
            // Item not found.
            // TODO: raise error.
            return;
        }
    } else {
        // Insert point is the virtual root.
        $return = array(0);
    }
}
Exemplo n.º 4
0
function publications_treeapi_getprevsibling($args)
{
    // Expand the arguments.
    extract($args);
    // Database.
    $dbconn =& xarDBGetConn();
    if ($id != 0) {
        // Insert point is a real item.
        $query = "SELECT \n                    parent.{$idname}\n                  FROM \n                    {$tablename} AS node, \n                    {$tablename} AS parent \n                  WHERE \n                    parent.xar_right = node.xar_left - 1\n                    AND \n                    node.{$idname} = ?";
        // return result
        if (!$result->EOF) {
            list($pid) = $result->fields;
        }
        if (isset($pid)) {
            return $pid;
        } else {
            return;
        }
    } else {
        // Insert point is the virtual root.
        // Virtual root has no siblings
        return;
    }
}
Exemplo n.º 5
0
    //define('GALAXIA_LOGFILE', GALAXIA_LIBRARY . '/log/pm.log');
    define('GALAXIA_LOGFILE', '');
}
// Directory containing the GraphViz 'dot' and 'neato' programs, in case
// your webserver can't find them via its PATH environment variable
if (!defined('GRAPHVIZ_BIN_DIR')) {
    define('GRAPHVIZ_BIN_DIR', '');
    //define('GRAPHVIZ_BIN_DIR', 'd:/wintools/ATT/GraphViz/bin');
}
/**
 * Xaraya-specific adaptations
 */
// Database handler
global $dbGalaxia;
if (!isset($dbGalaxia)) {
    list($dbGalaxia) = xarDBGetConn();
}
// Specify how error messages should be shown (for use in compiler and activity code)
if (!function_exists('galaxia_show_error')) {
    function galaxia_show_error($msg)
    {
        // TODO: clean this up
        trigger_error(xarML($msg), E_USER_ERROR);
    }
}
// Specify how to execute a non-interactive activity (for use in src/API/Instance.php)
if (!function_exists('galaxia_execute_activity')) {
    function galaxia_execute_activity($activity_id = 0, $iid = 0, $auto = 1)
    {
        $result = xarModAPIFunc('workflow', 'user', 'run_activity', array('activity_id' => $activity_id, 'iid' => $iid, 'auto' => $auto));
        if (empty($result)) {
Exemplo n.º 6
0
    define('GALAXIA_LOGFILE', '');
}
// Directory containing the GraphViz 'dot' and 'neato' programs, in case
// your webserver can't find them via its PATH environment variable
if (!defined('GRAPHVIZ_BIN_DIR')) {
    define('GRAPHVIZ_BIN_DIR', '');
    //define('GRAPHVIZ_BIN_DIR', 'd:/wintools/ATT/GraphViz/bin');
}
/**
 * Xaraya-specific adaptations
 */
// Database handler
global $dbGalaxia;
if (!isset($dbGalaxia)) {
    // Note that we do NOT assign by reference here, because we do want a copy
    $dbGalaxia = xarDBGetConn();
    // Set the fetch mode to assoc by default (needed by lib/Galaxia)
    $oldmode = $dbGalaxia->SetFetchMode(ADODB_FETCH_ASSOC);
}
// Specify how error messages should be shown (for use in compiler and activity code)
if (!function_exists('galaxia_show_error')) {
    function galaxia_show_error($msg)
    {
        // TODO: clean this up
        trigger_error(xarML($msg), E_USER_ERROR);
    }
}
// Specify how to execute a non-interactive activity (for use in src/API/Instance.php)
if (!function_exists('galaxia_execute_activity')) {
    function galaxia_execute_activity($activityId = 0, $iid = 0, $auto = 1)
    {