Merged in release/3.5.0 (pull request #7389)

Release/3.5.0

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2020-07-03 18:55:56 +00:00
committed by Julio Cesar Laura Avendaño
46 changed files with 5486 additions and 396 deletions

View File

@@ -882,7 +882,7 @@ class ActionsByEmailCoreClass extends PMPlugin
}
}
$obj = new PmDynaform($dynUid);
$obj = new PmDynaform(["CURRENT_DYNAFORM" => $dynUid]);
$this->addItemAbeProperties(['CURRENT_DYNAFORM' => $dynUid]);
$file = $obj->printPmDynaformAbe($this->getTaskAbeProperties());
$html = $file;

View File

@@ -22,6 +22,7 @@ class PmDynaform
private $lastQueryError = null;
private $propertiesToExclude = [];
private $sysSys = null;
private $fieldsAppData;
public $credentials = null;
public $displayMode = null;
public $fields = null;
@@ -91,6 +92,7 @@ class PmDynaform
if (is_array($this->fields) && !isset($this->fields["APP_UID"])) {
$this->fields["APP_UID"] = null;
}
$this->fieldsAppData = isset($this->fields["APP_DATA"]) ? $this->fields["APP_DATA"] : [];
//todo: compatibility checkbox
if ($this->record !== null && isset($this->record["DYN_CONTENT"]) && $this->record["DYN_CONTENT"] !== "") {
@@ -338,7 +340,7 @@ class PmDynaform
}
}
}
$sql = G::replaceDataField($json->sql, $dtFields, 'mysql', false);
$sql = $this->replaceDataField($json->sql, $dtFields);
if ($value === "suggest") {
$sql = $this->prepareSuggestSql($sql, $json);
}
@@ -686,6 +688,8 @@ class PmDynaform
$json->dataGridEnvironment = "onDataGridEnvironment";
if (isset($this->fields["APP_DATA"])) {
$dataGridEnvironment = $this->fields["APP_DATA"];
//Grids only access the global variables of 'ProcessMaker', other variables are removed.
$this->fields["APP_DATA"] = Cases::getGlobalVariables($this->fields["APP_DATA"]);
//restore AppData with dataVariable definition, only for columns control
foreach ($columnsDataVariable as $dge) {
if (isset($dataGridEnvironment[$dge])) {
@@ -833,7 +837,12 @@ class PmDynaform
}
}
private function getValuesDependentFields($json)
/**
* Get the values of the dependent references.
* @param object $json
* @return array
*/
private function getValuesDependentFields($json): array
{
if (!isset($this->record["DYN_CONTENT"])) {
return array();
@@ -848,7 +857,7 @@ class PmDynaform
}
if (isset($json->dbConnection) && isset($json->sql)) {
$result = array();
preg_match_all('/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $json->sql, $result, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
preg_match_all('/\@(?:([\@\%\#\=\?\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $json->sql, $result, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
$variables = isset($result[2]) ? $result[2] : array();
foreach ($variables as $key => $value) {
//Prevents an infinite cycle. If the name of the variable is used within its own dependent.
@@ -863,7 +872,7 @@ class PmDynaform
}
}
if ($json->dbConnection !== "" && $json->dbConnection !== "none" && $json->sql !== "") {
$sql = G::replaceDataField($json->sql, $data, 'mysql', false);
$sql = $this->replaceDataField($json->sql, $data);
$dt = $this->getCacheQueryData($json->dbConnection, $sql, $json->type);
$row = isset($dt[0]) ? $dt[0] : [];
$index = $json->variable === "" ? $json->id : $json->variable;
@@ -1780,12 +1789,11 @@ class PmDynaform
* @param string $dynUid
* @param string $fieldId
* @param string $proUid
*
* @param array $and
* @return object
*
* @see \ProcessMaker\BusinessModel\Variable::executeSqlControl()
*/
public function searchField($dynUid, $fieldId, $proUid = null)
*/
public function searchField($dynUid, $fieldId, $proUid = null, array $and = [])
{
//get pro_uid if empty
if (empty($proUid)) {
@@ -1828,8 +1836,8 @@ class PmDynaform
}
}
}
return $this->jsonsf($json, $fieldId);
$this->completeAdditionalHelpInformationOnControls($json);
return $this->jsonsf($json, $fieldId, "id", $and);
}
public function searchFieldByName($dyn_uid, $name)
@@ -1846,19 +1854,92 @@ class PmDynaform
return $this->jsonsf($json, $name, "name");
}
private function jsonsf(&$json, $id, $for = "id")
/**
* Replace data field with custom variables.
* @param string $sql
* @param array $data
* @return string
*/
private function replaceDataField(string $sql, array $data): string
{
$textParse = '';
$dbEngine = 'mysql';
$start = 0;
$prefix = '\?';
$pattern = '/\@(?:([' . $prefix . 'Qq\!])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+|\-\>([a-zA-Z\_]\w*))?/';
$result = preg_match_all($pattern, $sql, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
for ($r = 0; $result !== false && $r < $result; $r++) {
$dataGlobal = array_merge($this->fieldsAppData, $data);
if (!isset($dataGlobal[$match[2][$r][0]])) {
$dataGlobal[$match[2][$r][0]] = '';
}
if (!is_array($dataGlobal[$match[2][$r][0]])) {
$textParse = $textParse . substr($sql, $start, $match[0][$r][1] - $start);
$start = $match[0][$r][1] + strlen($match[0][$r][0]);
if (($match[1][$r][0] == '?') && (isset($dataGlobal[$match[2][$r][0]]))) {
$textParse = $textParse . $dataGlobal[$match[2][$r][0]];
continue;
}
}
}
$textParse = $textParse . substr($sql, $start);
$sqlResult = G::replaceDataField($textParse, $data, $dbEngine, false);
return $sqlResult;
}
/**
* complete additional help information on controls.
* @param object $json
*/
private function completeAdditionalHelpInformationOnControls(&$json)
{
foreach ($json as $key => $value) {
$sw1 = is_array($value);
$sw2 = is_object($value);
if ($sw1 || $sw2) {
$val = $this->jsonsf($value, $id, $for);
$this->completeAdditionalHelpInformationOnControls($value);
}
if (!$sw1 && !$sw2) {
if ($key === "type" && ($value === "grid")) {
foreach ($json->columns as $column) {
$column->gridName = $json->id;
}
}
}
}
}
/**
* Gets an element within an object that represents the dynaform. Search is
* done by 'id', 'property' and additional filters.
* @param object $json
* @param string $id
* @param string $for
* @param array $and
* @return mixed
*/
private function jsonsf(&$json, string $id, string $for = "id", array $and = [])
{
foreach ($json as $key => $value) {
$sw1 = is_array($value);
$sw2 = is_object($value);
if ($sw1 || $sw2) {
$val = $this->jsonsf($value, $id, $for, $and);
if ($val !== null) {
return $val;
}
}
if (!$sw1 && !$sw2) {
if ($key === $for && $id === $value) {
$filter = empty($and);
foreach ($and as $keyAnd => $valueAnd) {
$filter = isset($json->{$keyAnd}) && $json->{$keyAnd} === $valueAnd;
if ($filter === false) {
break;
}
}
if ($key === $for && $id === $value && $filter) {
return $json;
}
}

View File

@@ -468,12 +468,13 @@ function evaluateFunction($aGrid, $sExpresion)
* stantard deviation, variance, percentile, count, count distinct
*
* @name PMFTotalCalculation
* @label PMFTotalCalculation Function
* @label PMF TotalCalculation
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFTotalCalculation.28.29
* @param array | $grid | Grid | The input grid.
* @param array | $grid | Grid | The input grid
* @param string (32) | $field | Name of field | The name of the field.
* @param string (32) | $function | Operation.
* @return int|float|array | $result | Result | Result according of the function
* @param string (32) | $function | Operation | More information about the type of calculations can be found in https://wiki.processmaker.com/3.2/ProcessMaker_Functions
*
* @return mixed | $result | Result | Result according of the operation
*
*/
function PMFTotalCalculation($grid, $field, $function)
@@ -3019,13 +3020,13 @@ function PMFUnpauseCase ($caseUid, $delIndex, $userUid)
* @param string(32) | $taskUid | ID of the task | The unique ID of the task.
* @param string(32) | $userUid | ID user | The unique ID of the user who will add note case.
* @param string | $note | Note of the case | Note of the case.
* @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case.
* @param int | $sendMail = 0 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case.
* @param array | $files | Array of files | An array of files (full paths) to be attached to the case notes.
*
* @return int | $result | Result of the add a case note | Returns 1 if the note has been added to the case.; otherwise, returns 0 if an error occurred.
*
*/
function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1, $files = [])
function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 0, $files = [])
{
$ws = new WsBase();
$result = $ws->addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail, $files);

View File

@@ -0,0 +1,19 @@
<?php
require_once 'classes/model/om/BaseScheduler.php';
/**
* Skeleton subclass for representing a row from the 'SCHEDULER' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class Scheduler extends BaseScheduler {
} // Scheduler

View File

@@ -0,0 +1,23 @@
<?php
// include base peer class
require_once 'classes/model/om/BaseSchedulerPeer.php';
// include object class
include_once 'classes/model/Scheduler.php';
/**
* Skeleton subclass for performing query and update operations on the 'SCHEDULER' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class SchedulerPeer extends BaseSchedulerPeer {
} // SchedulerPeer

View File

@@ -0,0 +1,102 @@
<?php
require_once 'propel/map/MapBuilder.php';
include_once 'creole/CreoleTypes.php';
/**
* This class adds structure of 'SCHEDULER' table to 'workflow' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package workflow.classes.model.map
*/
class SchedulerMapBuilder
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'classes.model.map.SchedulerMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('workflow');
$tMap = $this->dbMap->addTable('SCHEDULER');
$tMap->setPhpName('Scheduler');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'string', CreoleTypes::BIGINT, true, 20);
$tMap->addColumn('TITLE', 'Title', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('STARTINGTIME', 'Startingtime', 'string', CreoleTypes::VARCHAR, false, 100);
$tMap->addColumn('ENDINGTIME', 'Endingtime', 'string', CreoleTypes::VARCHAR, false, 100);
$tMap->addColumn('EVERYON', 'Everyon', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('INTERVAL', 'Interval', 'string', CreoleTypes::VARCHAR, false, 10);
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('EXPRESSION', 'Expression', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('BODY', 'Body', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('TYPE', 'Type', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('CATEGORY', 'Category', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('SYSTEM', 'System', 'int', CreoleTypes::TINYINT, false, 3);
$tMap->addColumn('TIMEZONE', 'Timezone', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('ENABLE', 'Enable', 'int', CreoleTypes::TINYINT, false, 3);
$tMap->addColumn('CREATION_DATE', 'CreationDate', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('LAST_UPDATE', 'LastUpdate', 'int', CreoleTypes::TIMESTAMP, false, null);
} // doBuild()
} // SchedulerMapBuilder

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,644 @@
<?php
require_once 'propel/util/BasePeer.php';
// The object class -- needed for instanceof checks in this class.
// actual class may be a subclass -- as returned by SchedulerPeer::getOMClass()
include_once 'classes/model/Scheduler.php';
/**
* Base static class for performing query and update operations on the 'SCHEDULER' table.
*
*
*
* @package workflow.classes.model.om
*/
abstract class BaseSchedulerPeer
{
/** the default database name for this class */
const DATABASE_NAME = 'workflow';
/** the table name for this class */
const TABLE_NAME = 'SCHEDULER';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'classes.model.Scheduler';
/** The total number of columns. */
const NUM_COLUMNS = 16;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'SCHEDULER.ID';
/** the column name for the TITLE field */
const TITLE = 'SCHEDULER.TITLE';
/** the column name for the STARTINGTIME field */
const STARTINGTIME = 'SCHEDULER.STARTINGTIME';
/** the column name for the ENDINGTIME field */
const ENDINGTIME = 'SCHEDULER.ENDINGTIME';
/** the column name for the EVERYON field */
const EVERYON = 'SCHEDULER.EVERYON';
/** the column name for the INTERVAL field */
const INTERVAL = 'SCHEDULER.INTERVAL';
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'SCHEDULER.DESCRIPTION';
/** the column name for the EXPRESSION field */
const EXPRESSION = 'SCHEDULER.EXPRESSION';
/** the column name for the BODY field */
const BODY = 'SCHEDULER.BODY';
/** the column name for the TYPE field */
const TYPE = 'SCHEDULER.TYPE';
/** the column name for the CATEGORY field */
const CATEGORY = 'SCHEDULER.CATEGORY';
/** the column name for the SYSTEM field */
const SYSTEM = 'SCHEDULER.SYSTEM';
/** the column name for the TIMEZONE field */
const TIMEZONE = 'SCHEDULER.TIMEZONE';
/** the column name for the ENABLE field */
const ENABLE = 'SCHEDULER.ENABLE';
/** the column name for the CREATION_DATE field */
const CREATION_DATE = 'SCHEDULER.CREATION_DATE';
/** the column name for the LAST_UPDATE field */
const LAST_UPDATE = 'SCHEDULER.LAST_UPDATE';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Startingtime', 'Endingtime', 'Everyon', 'Interval', 'Description', 'Expression', 'Body', 'Type', 'Category', 'System', 'Timezone', 'Enable', 'CreationDate', 'LastUpdate', ),
BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID, SchedulerPeer::TITLE, SchedulerPeer::STARTINGTIME, SchedulerPeer::ENDINGTIME, SchedulerPeer::EVERYON, SchedulerPeer::INTERVAL, SchedulerPeer::DESCRIPTION, SchedulerPeer::EXPRESSION, SchedulerPeer::BODY, SchedulerPeer::TYPE, SchedulerPeer::CATEGORY, SchedulerPeer::SYSTEM, SchedulerPeer::TIMEZONE, SchedulerPeer::ENABLE, SchedulerPeer::CREATION_DATE, SchedulerPeer::LAST_UPDATE, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'startingTime', 'endingTime', 'everyOn', 'interval', 'description', 'expression', 'body', 'type', 'category', 'system', 'timezone', 'enable', 'creation_date', 'last_update', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Startingtime' => 2, 'Endingtime' => 3, 'Everyon' => 4, 'Interval' => 5, 'Description' => 6, 'Expression' => 7, 'Body' => 8, 'Type' => 9, 'Category' => 10, 'System' => 11, 'Timezone' => 12, 'Enable' => 13, 'CreationDate' => 14, 'LastUpdate' => 15, ),
BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID => 0, SchedulerPeer::TITLE => 1, SchedulerPeer::STARTINGTIME => 2, SchedulerPeer::ENDINGTIME => 3, SchedulerPeer::EVERYON => 4, SchedulerPeer::INTERVAL => 5, SchedulerPeer::DESCRIPTION => 6, SchedulerPeer::EXPRESSION => 7, SchedulerPeer::BODY => 8, SchedulerPeer::TYPE => 9, SchedulerPeer::CATEGORY => 10, SchedulerPeer::SYSTEM => 11, SchedulerPeer::TIMEZONE => 12, SchedulerPeer::ENABLE => 13, SchedulerPeer::CREATION_DATE => 14, SchedulerPeer::LAST_UPDATE => 15, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'startingTime' => 2, 'endingTime' => 3, 'everyOn' => 4, 'interval' => 5, 'description' => 6, 'expression' => 7, 'body' => 8, 'type' => 9, 'category' => 10, 'system' => 11, 'timezone' => 12, 'enable' => 13, 'creation_date' => 14, 'last_update' => 15, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
);
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
include_once 'classes/model/map/SchedulerMapBuilder.php';
return BasePeer::getMapBuilder('classes.model.map.SchedulerMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = SchedulerPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. SchedulerPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(SchedulerPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(SchedulerPeer::ID);
$criteria->addSelectColumn(SchedulerPeer::TITLE);
$criteria->addSelectColumn(SchedulerPeer::STARTINGTIME);
$criteria->addSelectColumn(SchedulerPeer::ENDINGTIME);
$criteria->addSelectColumn(SchedulerPeer::EVERYON);
$criteria->addSelectColumn(SchedulerPeer::INTERVAL);
$criteria->addSelectColumn(SchedulerPeer::DESCRIPTION);
$criteria->addSelectColumn(SchedulerPeer::EXPRESSION);
$criteria->addSelectColumn(SchedulerPeer::BODY);
$criteria->addSelectColumn(SchedulerPeer::TYPE);
$criteria->addSelectColumn(SchedulerPeer::CATEGORY);
$criteria->addSelectColumn(SchedulerPeer::SYSTEM);
$criteria->addSelectColumn(SchedulerPeer::TIMEZONE);
$criteria->addSelectColumn(SchedulerPeer::ENABLE);
$criteria->addSelectColumn(SchedulerPeer::CREATION_DATE);
$criteria->addSelectColumn(SchedulerPeer::LAST_UPDATE);
}
const COUNT = 'COUNT(SCHEDULER.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT SCHEDULER.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(SchedulerPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(SchedulerPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach ($criteria->getGroupByColumns() as $column) {
$criteria->addSelectColumn($column);
}
$rs = SchedulerPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return Scheduler
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = SchedulerPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return SchedulerPeer::populateObjects(SchedulerPeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
SchedulerPeer::addSelectColumns($criteria);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
return BasePeer::doSelect($criteria, $con);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = SchedulerPeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while ($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = $obj;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return SchedulerPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a Scheduler or Criteria object.
*
* @param mixed $values Criteria or Scheduler object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from Scheduler object
}
//$criteria->remove(SchedulerPeer::ID); // remove pkey col since this table uses auto-increment
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a Scheduler or Criteria object.
*
* @param mixed $values Criteria or Scheduler object containing data create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(SchedulerPeer::ID);
$selectCriteria->add(SchedulerPeer::ID, $criteria->remove(SchedulerPeer::ID), $comparison);
} else {
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
/**
* Method to DELETE all rows from the SCHEDULER table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDeleteAll(SchedulerPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a Scheduler or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or Scheduler object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
* This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(SchedulerPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof Scheduler) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(SchedulerPeer::ID, (array) $values, Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Validates all modified columns of given Scheduler object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param Scheduler $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(Scheduler $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(SchedulerPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(SchedulerPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(SchedulerPeer::DATABASE_NAME, SchedulerPeer::TABLE_NAME, $columns);
}
/**
* Retrieve a single object by pkey.
*
* @param mixed $pk the primary key.
* @param Connection $con the connection to use
* @return Scheduler
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(SchedulerPeer::DATABASE_NAME);
$criteria->add(SchedulerPeer::ID, $pk);
$v = SchedulerPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(SchedulerPeer::ID, $pks, Criteria::IN);
$objs = SchedulerPeer::doSelect($criteria, $con);
}
return $objs;
}
}
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseSchedulerPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
require_once 'classes/model/map/SchedulerMapBuilder.php';
Propel::registerMapBuilder('classes.model.map.SchedulerMapBuilder');
}