Ejemplo n.º 1
0
 function getPlanState($workflowID, $formName)
 {
     $table = 'workflowState';
     $where = 'workflowid=' . $workflowID;
     $field = 'state';
     $workflowPlan = dbs::selrecord($field, $table, $where, false, 2);
     return unserialize(stripslashes($workflowPlan[0]));
 }
Ejemplo n.º 2
0
 function addArchiveWorkflowUnit($workflowID)
 {
     $table = 'workflowArchive';
     $archiveValues = array();
     $archiveValues['workflowid'] = $workflowID;
     $archiveValues['timestamp'] = dbs::selattribute('timestamp', 'workflow', 'workflowId=' . $workflowID);
     $archiveValues['plan'] = addslashes(serialize(graphPlanDatabaseAccess::getPlanGraphList($workflowID)));
     //$planValues['state'] = addslashes(serialize($plans));
     dbs::irrecord($table, $archiveValues, false);
 }
Ejemplo n.º 3
0
 function updateDatabases($xmlPackage, $workflowId, $formData, $goal)
 {
     global $db;
     $db = connect($xmlPackage->getDb());
     debug::message("connect to db:" . $xmlPackage->getDb() . '<br>');
     $newDataItem = new coreWorkflowDataPacket($workflowId, array());
     $tables = $xmlPackage->getTables();
     if (sizeof($tables) > 0) {
         //For each table
         for ($tableIndex = 0; $tableIndex < sizeof($tables); $tableIndex++) {
             $table = $tables[$tableIndex]->getTableName();
             $valsArray['workflowId'] = $workflowId;
             $fields = $tables[$tableIndex]->getDbFields();
             //The fields specificed
             for ($index = 0; $index < sizeof($fields); $index++) {
                 $field = $fields[$index];
                 $valsArray[$field] = addslashes($formData[$field]);
             }
             //Does this workflow item already exist in the table
             $sql_query = "workflowId='{$workflowId}'";
             if (dbpear::numRecords($table, "{$sql_query}")) {
                 $keyName = dbs::getprimarykey($table);
                 $keyValue = dbpear::selAttribute($keyName, $table, $sql_query);
                 dbs::updaterecord($table, $valsArray, $keyName, $keyValue);
             } else {
                 dbs::irrecord($table, $valsArray, false);
             }
             $db = connect('iWFMS');
         }
         $xmlParser = new XMLtoArray("jobSpecification.xml");
         $xmlTree = $xmlParser->process();
         //Package the xml data
         $xmlPackage = xmlPackage::package($xmlTree);
         if (!$goal) {
             //We are not at the goal node
             //Display the data as HTML
             xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item');
         } else {
             //We are at the goal node
             xmlPackage::displayArchiveItem($xmlPackage, $workflowId, 'workflowArchive', 'Current archived workflow item', 'archive');
         }
     } else {
         $xmlParser = new XMLtoArray("jobSpecification.xml");
         $xmlTree = $xmlParser->process();
         //Package the xml data
         $xmlPackage = xmlPackage::package($xmlTree);
         //Display the data as HTML
         xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item');
     }
 }
Ejemplo n.º 4
0
 function getallmembers($groupid)
 {
     $field = 'members';
     $resultsarray = array();
     if (is_array($groupid)) {
         foreach ($groupid as $group) {
             $result = dbs::selrecord($field, 'groups', 'groupid=' . $group, '0', '1');
             $memberlist = arrays::array_explode($result[$field], ',');
             if ($memberslist) {
                 array_merge($resultsarray, $memberlist);
             }
         }
     } else {
         $result = dbs::selrecord($field, 'groups', 'groupid=' . $groupid, '0', '1');
         $resultsarray = arrays::array_explode($result[$field], ',');
     }
     return $resultsarray;
 }
Ejemplo n.º 5
0
 /**
  * @return Boolean
  * @param String $mode
  * @param String $username
  * @param String $password
  * @desc Checks the users password and if valid adds their username to the session
  */
 function authenticateLogin($mode, $username, $password)
 {
     if ($mode == 'login') {
         // encode password to check against what's stored in the db
         //$password = dbs::passencdec($password,$salt,'1');
         // query database to authenticate user - check username / password combo
         $result = dbs::selrecord('*', 'users', "username = '******' and password = '******'", '0', '1');
         // check if an entry exists in the db
         if (sizeof($result)) {
             // password/username authenticated - register the user session
             $_SESSION['valid_user'] = $result[0]['username'];
             $_SESSION['authentic_user'] = true;
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 6
0
function dbmanagement_simple($table, $key, &$keyvalue, &$mode, $process, $vals)
{
    global $sql_debug;
    if ($process == 'delete') {
        // Delete the record from table
        dbs::delrecord($table, $key, $keyvalue);
        $mesg = DELETED;
        $mode = 'preview';
    } elseif ($process == 'add' || $process == 'edit') {
        // generate table column field names
        $cols = dbs::genfieldnames($table, '0');
        if (!empty($keyvalue)) {
            /*
            this is an existing record 
            adjust the columns and values parts of the replace sql statement
            */
            $cols = "`" . $key . "`, " . $cols;
            $vals = "'" . $keyvalue . "', " . $vals;
            $request = "REPLACE";
        } else {
            // this is a new record so set the insert sql statement
            $request = "INSERT";
        }
        // run the sql for the live database
        echo $cols;
        echo $vals;
        dbs::irrecord($request, $table, $cols, $vals);
        $mesg = SAVED;
        // get the primary key for the previously inserted record
        if (empty($keyvalue)) {
            $row = dbs::getlast();
            $keyvalue = $row[0];
        }
        // set return mode
        $mode = "edit";
    }
    return $mesg;
}
Ejemplo n.º 7
0
    $result = dbs::selrecord('*', $table, $sql, 'name ASC LIMIT ' . $start . ',' . $end, '0');
    $final = dbs::numrecords($result);
} else {
    $check = dbs::selrecord('*', $table, '0', '0', '0');
    $count = dbs::numrecords($check);
    $result = dbs::selrecord('*', $table, '0', 'name ASC LIMIT ' . $start . ',' . $end, '0');
    $final = dbs::numrecords($result);
}
if ($count > 0) {
    hr(2);
    ?>
<tr>
<td class="bodybold">GROUPNAME</td><td class="bodybold" align="right">ACTIONS</td>
</tr>
<?php 
    while ($row = dbs::fetchrecord($result)) {
        hr(2);
        ?>
<tr>
<td valign="top" class="bodybold" title="ID: <?php 
        echo $row[$key];
        ?>
"><?php 
        echo $row[$identifier];
        ?>
</td>
<td align="right" valign="top" class="body"><span class="edit"><a class="whitelink" href="<?php 
        echo $pageref;
        ?>
?<?php 
        echo $key;
Ejemplo n.º 8
0
function saveCachePlans($planGraphList, $workflowKey, $modelId)
{
    $planValuesCollection = array();
    $planWorkflowValuesCollection = array();
    $planValues = array();
    $planWorkflowValues = array();
    for ($index = 0; $index < sizeof($planGraphList); $index++) {
        $plan = addslashes(serialize($planGraphList[$index]));
        $planValues['modelId'] = $modelId;
        $planValues['plan'] = $plan;
        array_push($planValuesCollection, $planValues);
        //dbs::irrecord('workflowcachingstore',$planValues, false);
        $planWorkflowValues['workflowid'] = $workflowKey;
        $planWorkflowValues['plan'] = $plan;
        array_push($planWorkflowValuesCollection, $planWorkflowValues);
        //dbs::irrecord('plans',$planWorkflowValues, false);
    }
    dbs::irrecordArray('plans', $planWorkflowValuesCollection, false);
    dbs::irrecordArray('workflowcachingstore', $planValuesCollection, false);
}
Ejemplo n.º 9
0
<?php

if (${$key} != 'new') {
    // it's an existing record so pull the details from the db
    $row = dbs::selrecord('*', $table, $key . '=' . ${$key}, '0', '1');
    //print_r($row);
}
?>

<table border="0" cellspacing="1" cellpadding="1" width="100%">
<tr>
	<td class="bodybold" colspan="2"><a href="<?php 
echo $pageref;
?>
">Groups</a>
	<?php 
if (${$key} != 'new') {
    // this is not a new record
    echo " ~ " . string::up($row[$identifier]);
}
?>

	</td>
</tr>

<?php 
hr(2);
if (isset($mesg)) {
    html_displaymesg($mesg, 2);
}
?>
Ejemplo n.º 10
0
function displayWorkflow($workflowID)
{
    $data['text1'] = dbs::selrecord('text1', 'text1', 'workflowid=' . $workflowID, 0, 3);
    $data['text2'] = dbs::selrecord('text2', 'text2', 'workflowid=' . $workflowID, 0, 3);
    html_display($data, $workflowID);
}
Ejemplo n.º 11
0
 function displayArchiveItem($xmlPackage, $workflowId, $table, $title, $mode)
 {
     global $db;
     $workflowIDs = array($workflowId);
     $workflowTimestamp = dbs::selrecord('timestamp', $table, 'workflowId=' . $workflowId, 0, 3);
     $db = connect($xmlPackage->getDb());
     debug::message("connect to db:" . $xmlPackage->getDb());
     workflowDisplayHTML::archiveTableHead($xmlPackage->getDisplayFields(), "", $title);
     xmlPackage::__testDatabaseFields($workflowIDs, $workflowTimestamp, $xmlPackage, $mode);
     //workflowDisplayHTML::tableMainOpen();
     workflowDisplayHTML::tableMainClose();
     $db = connect('iWFMS');
 }
Ejemplo n.º 12
0
<?php

include '../includes/config/database.php';
include_once '../includes/library/library_db_mysql.php';
include_once '../includes/library/library_arrays.php';
$table = 'text1';
$field = 'text1';
$key = 'text1id';
$updatearray['workflowId'] = 1;
$updatearray[$field] = ${$field};
dbs::irrecord($table, $updatearray, false);
dbs::updaterecord($table, $updatearray, $key, $keyvalue);
header("Location: ../mockup/index.php");
Ejemplo n.º 13
0
 /**
  * @return String
  * @param String $table
  * @desc return the primary key of table
  */
 function getprimarykey($table)
 {
     $result = dbs::selrecord('*', $table, '0', '0', '0');
     $i = 0;
     while ($i < mysql_num_fields($result)) {
         $meta = mysql_fetch_field($result);
         if (!$meta) {
             errors::errorMessage("No information available<br />\n");
             mysql_free_result($result);
             return false;
         }
         //multiple_key: $meta->multiple_key
         //primary_key:  $meta->primary_key
         //unique_key:   $meta->unique_key
         if (!$meta->multiple_key && $meta->primary_key) {
             $primkey = $meta->name;
             mysql_free_result($result);
             return $primkey;
         } elseif ($meta->multiple_key) {
             errors::errorMessage('Support for multiple keys is not setup');
         }
         $i++;
     }
 }
Ejemplo n.º 14
0
 /**
  * @return unknown
  * @param unknown $name
  * @param unknown $dbfield
  * @param unknown $current
  * @param unknown $datasource
  * @param unknown $populate
  * @param unknown $where
  * @param unknown $orderby
  * @desc get the data for multiple radio buttons
  */
 function getdata_radiobtns($name, $dbfield, $current, $datasource, $populate, $where, $orderby)
 {
     if (!is_array($datasource)) {
         // populate values from a database table
         //$datasource = table
         //$populate = display
         $default = true;
         // first item assumed default
         $index = 0;
         $radios = dbs::selrecord($dbfield . ',' . $populate, $datasource, $where, $orderby, '0');
         while ($radio = dbs::fetchrecord($radios)) {
             $result[$index]['radiobtn'] = formdata::getdata_radiobtn($name, $current, $radio[$dbfield], $radio[$populate], $default);
             $default = false;
             $index++;
         }
     } else {
         // populate values from an array
         if (sizeof($datasource) != 0) {
             $default = true;
             // first item assumed default
             $index = 0;
             foreach ($datasource as $populateitem) {
                 $result[$index]['radiobtn'] = formdata::getdata_radiobtn($name, $current, $populateitem, $populate[$index], $default);
                 $default = false;
                 $index++;
             }
         } else {
             $result = false;
         }
     }
     return $result;
 }
Ejemplo n.º 15
0
 function testDatabaseInsertDelete()
 {
     $this->assertFalse(dbs::irrecord('', array(), false));
     $this->assertFalse(dbs::irrecord('table', array(), false));
 }
Ejemplo n.º 16
0
$root = "../";
$pageref = "admin_groups.php";
$sql_debug = true;
include_once '../includes/commonPages/system_header.php';
// Database setup variables
$table = "groups";
$key = "groupid";
$identifier = "name";
$mesg = '';
if ($process) {
    switch ($process) {
        case 'delete':
            dbs::delrecord($table, $key, ${$key});
            $mesg = 'Deleted!';
            break;
        case 'add':
            $vals['name'] = $name;
            $vals['members'] = $groupmembers;
            dbs::irrecord($table, $vals, false);
            $mesg = 'Added!';
            break;
    }
}
if (!isset($mode) || $mode == 'preview') {
    // show preview page
    include_once 'preview/' . str_replace('.php', '', $pageref) . '_preview.php';
} elseif ($mode == 'add' || $mode == 'edit') {
    // show edit page
    include_once 'edit/' . str_replace('.php', '', $pageref) . '_edit.php';
}
include_once '../includes/commonPages/system_footer.php';