CODE STYLE Format
Change format
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* CalendarDefinition.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
|
||||
@@ -20,9 +21,12 @@ require_once 'classes/model/CalendarAssignments.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class CalendarDefinition extends BaseCalendarDefinition {
|
||||
class CalendarDefinition extends BaseCalendarDefinition
|
||||
{
|
||||
public $calendarLog = '';
|
||||
function getCalendarList($onlyActive = false, $arrayMode = false) {
|
||||
|
||||
public function getCalendarList ($onlyActive = false, $arrayMode = false)
|
||||
{
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->clearSelectColumns();
|
||||
|
||||
@@ -35,9 +39,11 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
// $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') ");
|
||||
$Criteria->addAsColumn( 'DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '" . G::LoadTranslation( 'ID_DELETE' ) . "' ELSE '' END " );
|
||||
// Note: This list doesn't show deleted items (STATUS = DELETED)
|
||||
if ($onlyActive) { // Show only active. Used on assignment lists
|
||||
if ($onlyActive) {
|
||||
// Show only active. Used on assignment lists
|
||||
$Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL );
|
||||
} else { // Show Active and Inactive calendars. USed in main list
|
||||
} else {
|
||||
// Show Active and Inactive calendars. USed in main list
|
||||
$Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE","INACTIVE"), CRITERIA::IN );
|
||||
}
|
||||
|
||||
@@ -63,14 +69,13 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
}
|
||||
//Added by qennix
|
||||
//Gets criteria for listing
|
||||
function getCalendarCriterias($filter, $start, $limit){
|
||||
public function getCalendarCriterias ($filter, $start, $limit)
|
||||
{
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->clearSelectColumns();
|
||||
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
|
||||
if ($filter != '') {
|
||||
$Criteria->add(
|
||||
$Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr(
|
||||
$Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE)));
|
||||
$Criteria->add( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) );
|
||||
}
|
||||
$Criteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL );
|
||||
|
||||
@@ -82,9 +87,7 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
|
||||
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS );
|
||||
if ($filter != '') {
|
||||
$oCriteria->add(
|
||||
$oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr(
|
||||
$oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE)));
|
||||
$oCriteria->add( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) );
|
||||
}
|
||||
$oCriteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL );
|
||||
$oCriteria->setLimit( $limit );
|
||||
@@ -95,7 +98,9 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
$criterias['LIST'] = $oCriteria;
|
||||
return $criterias;
|
||||
}
|
||||
function getCalendarInfo($CalendarUid) {
|
||||
|
||||
public function getCalendarInfo ($CalendarUid)
|
||||
{
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
|
||||
|
||||
@@ -131,20 +136,18 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
$CalendarBusinessHoursObj = new CalendarBusinessHours();
|
||||
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid );
|
||||
$fields['BUSINESS_DAY'] = $CalendarBusinessHours;
|
||||
|
||||
$CalendarHolidaysObj = new CalendarHolidays();
|
||||
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid );
|
||||
$fields['HOLIDAY'] = $CalendarHolidays;
|
||||
$fields=$this->validateCalendarInfo($fields, $defaultCalendar); //********************
|
||||
|
||||
$fields = $this->validateCalendarInfo( $fields, $defaultCalendar );
|
||||
//********************
|
||||
return $fields;
|
||||
|
||||
}
|
||||
//for edit
|
||||
function getCalendarInfoE($CalendarUid) {
|
||||
public function getCalendarInfoE ($CalendarUid)
|
||||
{
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
|
||||
|
||||
$defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001";
|
||||
$defaultCalendar['CALENDAR_NAME'] = "Default";
|
||||
$defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" );
|
||||
@@ -177,18 +180,16 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
$CalendarBusinessHoursObj = new CalendarBusinessHours();
|
||||
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid );
|
||||
$fields['BUSINESS_DAY'] = $CalendarBusinessHours;
|
||||
|
||||
$CalendarHolidaysObj = new CalendarHolidays();
|
||||
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid );
|
||||
$fields['HOLIDAY'] = $CalendarHolidays;
|
||||
// $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //********************
|
||||
|
||||
return $fields;
|
||||
|
||||
}
|
||||
//end for edit
|
||||
|
||||
function validateCalendarInfo($fields,$defaultCalendar){
|
||||
public function validateCalendarInfo ($fields, $defaultCalendar)
|
||||
{
|
||||
try {
|
||||
//Validate if Working days are Correct
|
||||
//Minimun 3 ?
|
||||
@@ -221,7 +222,6 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
throw (new Exception( "Not all working days have their correspondent business day" ));
|
||||
}
|
||||
//Validate Holidays
|
||||
|
||||
return $fields;
|
||||
} catch (Exception $e) {
|
||||
//print $e->getMessage();
|
||||
@@ -231,9 +231,10 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
return $defaultCalendar;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function saveCalendarInfo($aData) {
|
||||
|
||||
public function saveCalendarInfo ($aData)
|
||||
{
|
||||
$CalendarUid = $aData['CALENDAR_UID'];
|
||||
$CalendarName = $aData['CALENDAR_NAME'];
|
||||
$CalendarDescription = $aData['CALENDAR_DESCRIPTION'];
|
||||
@@ -253,7 +254,6 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
}
|
||||
$tr->setCalendarUid( $CalendarUid );
|
||||
$tr->setCalendarName( $CalendarName );
|
||||
|
||||
$tr->setCalendarUpdateDate( 'now' );
|
||||
$tr->setCalendarDescription( $CalendarDescription );
|
||||
$tr->setCalendarStatus( $CalendarStatus );
|
||||
@@ -271,7 +271,6 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
$objData['CALENDAR_UID'] = $CalendarUid;
|
||||
$CalendarBusinessHoursObj->saveCalendarBusinessHours( $objData );
|
||||
}
|
||||
|
||||
//Holiday Save code.
|
||||
//First Delete all current records
|
||||
$CalendarHolidayObj = new CalendarHolidays();
|
||||
@@ -293,18 +292,14 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
|
||||
|
||||
|
||||
//to do: uniform coderror structures for all classes
|
||||
|
||||
|
||||
//if ( $res['codError'] < 0 ) {
|
||||
// G::SendMessageText ( $res['message'] , 'error' );
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
function deleteCalendar($CalendarUid) {
|
||||
|
||||
public function deleteCalendar ($CalendarUid)
|
||||
{
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
|
||||
|
||||
@@ -323,7 +318,6 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
if ($tr->validate()) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save();
|
||||
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
@@ -335,24 +329,18 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
|
||||
|
||||
|
||||
//to do: uniform coderror structures for all classes
|
||||
|
||||
|
||||
//if ( $res['codError'] < 0 ) {
|
||||
// G::SendMessageText ( $res['message'] , 'error' );
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
function getCalendarFor($userUid, $proUid, $tasUid, $sw_validate=true) {
|
||||
$Criteria = new Criteria ( 'workflow' );
|
||||
|
||||
public function getCalendarFor ($userUid, $proUid, $tasUid, $sw_validate = true)
|
||||
{
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
//Default Calendar
|
||||
$calendarUid = "00000000000000000000000000000001";
|
||||
$calendarOwner = "DEFAULT";
|
||||
|
||||
//Load User,Task and Process calendars (if exist)
|
||||
$Criteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID );
|
||||
$Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_UID );
|
||||
@@ -374,6 +362,7 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
if (isset( $calendarArray['USER'] )) {
|
||||
$calendarUid = $calendarArray['USER'];
|
||||
$calendarOwner = "USER";
|
||||
@@ -396,13 +385,13 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
return $calendarDefinition;
|
||||
}
|
||||
|
||||
function assignCalendarTo($objectUid, $calendarUid, $objectType) {
|
||||
public function assignCalendarTo ($objectUid, $calendarUid, $objectType)
|
||||
{
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarAssignmentsPeer::retrieveByPK( $objectUid );
|
||||
if ($calendarUid != "") {
|
||||
if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) {
|
||||
$tr = new CalendarAssignments();
|
||||
|
||||
}
|
||||
$tr->setObjectUid( $objectUid );
|
||||
$tr->setCalendarUid( $calendarUid );
|
||||
@@ -411,7 +400,6 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
if ($tr->validate()) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save();
|
||||
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
@@ -421,16 +409,17 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
}
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
} else { //Delete record
|
||||
} else {
|
||||
//Delete record
|
||||
if ((is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) {
|
||||
$tr->delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//Added by Qennix
|
||||
//Counts all users,task,process by calendar
|
||||
function getAllCounterByCalendar($type){
|
||||
public function getAllCounterByCalendar ($type)
|
||||
{
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID );
|
||||
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
|
||||
@@ -446,7 +435,7 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
return $aCounter;
|
||||
}
|
||||
|
||||
function loadByCalendarName($calendarName)
|
||||
public function loadByCalendarName ($calendarName)
|
||||
{
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
|
||||
@@ -459,9 +448,8 @@ class CalendarDefinition extends BaseCalendarDefinition {
|
||||
$oDataset = calendarDefinitionPeer::doSelectRS( $Criteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
|
||||
return $oDataset->getRow();
|
||||
}
|
||||
} // CalendarDefinition
|
||||
|
||||
}
|
||||
// CalendarDefinition
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Content.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -37,8 +38,8 @@ require_once 'classes/model/om/BaseContent.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Content extends BaseContent {
|
||||
|
||||
class Content extends BaseContent
|
||||
{
|
||||
public $langs;
|
||||
public $rowsProcessed;
|
||||
public $rowsInserted;
|
||||
@@ -50,15 +51,17 @@ class Content extends BaseContent {
|
||||
* @param string $sUID
|
||||
* @return variant
|
||||
*/
|
||||
function load($ConCategory, $ConParent, $ConId, $ConLang) {
|
||||
public function load ($ConCategory, $ConParent, $ConId, $ConLang)
|
||||
{
|
||||
$content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
if (is_null( $content )) {
|
||||
//we dont find any value for this field and language in CONTENT table
|
||||
//we dont find any value for this field and language in CONTENT table;
|
||||
$ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
} else {
|
||||
//krumo($content);
|
||||
$ConValue = $content->getConValue();
|
||||
if ($ConValue == "") { //try to find a valid translation
|
||||
if ($ConValue == "") {
|
||||
//try to find a valid translation
|
||||
$ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
}
|
||||
}
|
||||
@@ -72,7 +75,8 @@ class Content extends BaseContent {
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
function getDefaultContentLang($ConCategory, $ConParent, $ConId, $destConLang) {
|
||||
public function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang)
|
||||
{
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
|
||||
@@ -85,7 +89,6 @@ class Content extends BaseContent {
|
||||
$Criteria->add( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL );
|
||||
$Criteria->add( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL );
|
||||
$Criteria->add( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL );
|
||||
|
||||
$Criteria->add( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL );
|
||||
|
||||
$rs = ContentPeer::doSelectRS( $Criteria );
|
||||
@@ -94,7 +97,6 @@ class Content extends BaseContent {
|
||||
|
||||
if (is_array( $row = $rs->getRow() )) {
|
||||
$defaultLang = $row['CON_LANG'];
|
||||
|
||||
} else {
|
||||
$defaultLang = "";
|
||||
}
|
||||
@@ -109,7 +111,8 @@ class Content extends BaseContent {
|
||||
* @return string
|
||||
* if the row doesn't exist, it will be created automatically, even the default 'en' language
|
||||
*/
|
||||
function autoLoadSave($ConCategory, $ConParent, $ConId, $destConLang) {
|
||||
public function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang)
|
||||
{
|
||||
//search in 'en' language, the default language
|
||||
$content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, 'en' );
|
||||
|
||||
@@ -119,10 +122,12 @@ class Content extends BaseContent {
|
||||
}
|
||||
|
||||
//to do: review if the $destConLang is a valid language/
|
||||
if (is_null ( $content ))
|
||||
$ConValue = ''; //we dont find any value for this field and language in CONTENT table
|
||||
else
|
||||
if (is_null( $content )) {
|
||||
$ConValue = '';
|
||||
//we dont find any value for this field and language in CONTENT table
|
||||
} else {
|
||||
$ConValue = $content->getConValue();
|
||||
}
|
||||
|
||||
try {
|
||||
$con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $destConLang );
|
||||
@@ -153,7 +158,8 @@ class Content extends BaseContent {
|
||||
* @param string $ConValue
|
||||
* @return variant
|
||||
*/
|
||||
function addContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
|
||||
public function addContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
|
||||
{
|
||||
try {
|
||||
if ($ConLang != 'en') {
|
||||
$baseLangContent = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, 'en' );
|
||||
@@ -167,12 +173,14 @@ class Content extends BaseContent {
|
||||
if (is_null( $con )) {
|
||||
$con = new Content();
|
||||
} else {
|
||||
if ($con->getConParent () == $ConParent && $con->getConCategory () == $ConCategory && $con->getConValue () == $ConValue && $con->getConLang () == $ConLang && $con->getConId () == $ConId)
|
||||
if ($con->getConParent() == $ConParent && $con->getConCategory() == $ConCategory && $con->getConValue() == $ConValue && $con->getConLang() == $ConLang && $con->getConId() == $ConId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$con->setConCategory( $ConCategory );
|
||||
if ($con->getConParent () != $ConParent)
|
||||
if ($con->getConParent() != $ConParent) {
|
||||
$con->setConParent( $ConParent );
|
||||
}
|
||||
$con->setConId( $ConId );
|
||||
$con->setConLang( $ConLang );
|
||||
$con->setConValue( $ConValue );
|
||||
@@ -197,7 +205,8 @@ class Content extends BaseContent {
|
||||
* @param string $ConValue
|
||||
* @return variant
|
||||
*/
|
||||
function insertContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
|
||||
public function insertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
|
||||
{
|
||||
try {
|
||||
$con = new Content();
|
||||
$con->setConCategory( $ConCategory );
|
||||
@@ -226,7 +235,8 @@ class Content extends BaseContent {
|
||||
* @param string $ConValue
|
||||
* @return variant
|
||||
*/
|
||||
function removeContent($ConCategory, $ConParent, $ConId) {
|
||||
public function removeContent ($ConCategory, $ConParent, $ConId)
|
||||
{
|
||||
try {
|
||||
$c = new Criteria();
|
||||
$c->add( ContentPeer::CON_CATEGORY, $ConCategory );
|
||||
@@ -256,7 +266,7 @@ class Content extends BaseContent {
|
||||
* @param string $ConValue
|
||||
* @return boolean true or false
|
||||
*/
|
||||
function Exists ($ConCategory, $ConParent, $ConId, $ConLang)
|
||||
public function Exists ($ConCategory, $ConParent, $ConId, $ConLang)
|
||||
{
|
||||
try {
|
||||
$oPro = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
@@ -265,8 +275,7 @@ class Content extends BaseContent {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
@@ -276,7 +285,7 @@ class Content extends BaseContent {
|
||||
*
|
||||
* @param array $langs
|
||||
*/
|
||||
function regenerateContent($langs, $workSpace=SYS_SYS)
|
||||
public function regenerateContent ($langs, $workSpace = SYS_SYS)
|
||||
{
|
||||
//Search the language
|
||||
$key = array_search( 'en', $langs );
|
||||
@@ -330,8 +339,7 @@ class Content extends BaseContent {
|
||||
$workSpace = new workspaceTools( $workSpace );
|
||||
$workSpace->getDBInfo();
|
||||
|
||||
$link = mysql_pconnect($workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass)
|
||||
or die ("Could not connect");
|
||||
$link = mysql_pconnect( $workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass ) or die( "Could not connect" );
|
||||
|
||||
mysql_select_db( $workSpace->dbName, $link );
|
||||
mysql_query( "SET NAMES 'utf8';" );
|
||||
@@ -339,11 +347,10 @@ class Content extends BaseContent {
|
||||
$result = mysql_unbuffered_query( $sql, $link );
|
||||
$list = array ();
|
||||
$default = array ();
|
||||
$sw = array('CON_ID'=>'','CON_CATEGORY'=>'','CON_PARENT'=>'');
|
||||
$sw = array ('CON_ID' => '','CON_CATEGORY' => '','CON_PARENT' => ''
|
||||
);
|
||||
while ($row = mysql_fetch_assoc( $result )) {
|
||||
if ($sw['CON_ID'] == $row['CON_ID'] &&
|
||||
$sw['CON_CATEGORY'] == $row['CON_CATEGORY'] &&
|
||||
$sw['CON_PARENT'] == $row['CON_PARENT']) {
|
||||
if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) {
|
||||
$list[] = $row;
|
||||
} else {
|
||||
$this->rowsClustered ++;
|
||||
@@ -375,7 +382,6 @@ class Content extends BaseContent {
|
||||
}
|
||||
mysql_free_result( $result );
|
||||
$total = $this->rowsProcessed + $this->rowsInserted;
|
||||
|
||||
$connection = Propel::getConnection( 'workflow' );
|
||||
$statement = $connection->prepareStatement( "INSERT INTO CONTENT
|
||||
SELECT CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE
|
||||
@@ -394,7 +400,7 @@ class Content extends BaseContent {
|
||||
}
|
||||
}
|
||||
|
||||
function checkLanguage($content, $default)
|
||||
public function checkLanguage ($content, $default)
|
||||
{
|
||||
if (count( $content ) > 0) {
|
||||
$langs = $this->langs;
|
||||
@@ -406,18 +412,13 @@ class Content extends BaseContent {
|
||||
}
|
||||
foreach ($langsAsoc as $key => $value) {
|
||||
$this->rowsInserted ++;
|
||||
$this->fastInsertContent(
|
||||
$default['CON_CATEGORY'],
|
||||
$default['CON_PARENT'],
|
||||
$default['CON_ID'],
|
||||
$value,
|
||||
$default['CON_VALUE']
|
||||
);
|
||||
$this->fastInsertContent( $default['CON_CATEGORY'], $default['CON_PARENT'], $default['CON_ID'], $value, $default['CON_VALUE'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
|
||||
public function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
|
||||
{
|
||||
$ConValue = mysql_real_escape_string( $ConValue );
|
||||
$connection = Propel::getConnection( 'workflow' );
|
||||
$statement = $connection->prepareStatement( "INSERT INTO CONTENT_BACKUP (
|
||||
@@ -426,7 +427,8 @@ class Content extends BaseContent {
|
||||
$statement->executeQuery();
|
||||
}
|
||||
|
||||
function removeLanguageContent($lanId) {
|
||||
public function removeLanguageContent ($lanId)
|
||||
{
|
||||
try {
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
|
||||
@@ -444,9 +446,9 @@ class Content extends BaseContent {
|
||||
while (is_array( $row )) {
|
||||
$content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId );
|
||||
|
||||
if( $content !== null )
|
||||
if ($content !== null) {
|
||||
$content->delete();
|
||||
|
||||
}
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
}
|
||||
@@ -457,8 +459,11 @@ class Content extends BaseContent {
|
||||
}
|
||||
//Added by Enrique at Feb 9th,2011
|
||||
//Gets all Role Names by Role
|
||||
function getAllContentsByRole($sys_lang=SYS_LANG){
|
||||
if (!isset($sys_lang)) $sys_lang = 'en';
|
||||
public function getAllContentsByRole ($sys_lang = SYS_LANG)
|
||||
{
|
||||
if (! isset( $sys_lang )) {
|
||||
$sys_lang = 'en';
|
||||
}
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->clearSelectColumns();
|
||||
$oCriteria->addSelectColumn( ContentPeer::CON_ID );
|
||||
@@ -475,5 +480,6 @@ class Content extends BaseContent {
|
||||
}
|
||||
return $aRoles;
|
||||
}
|
||||
}
|
||||
// Content
|
||||
|
||||
} // Content
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Translation.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -26,7 +27,6 @@
|
||||
|
||||
require_once 'classes/model/om/BaseTranslation.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'TRANSLATION' table.
|
||||
*
|
||||
@@ -38,18 +38,21 @@ require_once 'classes/model/om/BaseTranslation.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Translation extends BaseTranslation {
|
||||
class Translation extends BaseTranslation
|
||||
{
|
||||
|
||||
public static $meta;
|
||||
public static $localeSeparator = '-';
|
||||
|
||||
private $envFilePath;
|
||||
|
||||
function __construct(){
|
||||
public function __construct ()
|
||||
{
|
||||
$this->envFilePath = PATH_DATA . "META-INF" . PATH_SEP . "translations.env";
|
||||
}
|
||||
|
||||
function getAllCriteria(){
|
||||
public function getAllCriteria ()
|
||||
{
|
||||
|
||||
//SELECT * from TRANSLATION WHERE TRN_LANG = 'en' order by TRN_CATEGORY, TRN_ID
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
@@ -59,10 +62,12 @@ class Translation extends BaseTranslation {
|
||||
$oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE );
|
||||
//$c->add(TranslationPeer::TRN_LANG, 'en');
|
||||
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
|
||||
function getAll($lang='en', $start=null, $limit=null, $search=null, $dateFrom=null, $dateTo=null){
|
||||
public function getAll ($lang = 'en', $start = null, $limit = null, $search = null, $dateFrom = null, $dateTo = null)
|
||||
{
|
||||
$totalCount = 0;
|
||||
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
@@ -76,29 +81,14 @@ class Translation extends BaseTranslation {
|
||||
//$oCriteria->addAscendingOrderByColumn ( 'TRN_CATEGORY' );
|
||||
$oCriteria->addAscendingOrderByColumn( 'TRN_ID' );
|
||||
|
||||
|
||||
if ($search) {
|
||||
$oCriteria->add(
|
||||
$oCriteria->getNewCriterion(
|
||||
TranslationPeer::TRN_ID,
|
||||
"%$search%", Criteria::LIKE
|
||||
)->addOr($oCriteria->getNewCriterion(
|
||||
TranslationPeer::TRN_VALUE,
|
||||
"%$search%", Criteria::LIKE
|
||||
))
|
||||
);
|
||||
$oCriteria->add( $oCriteria->getNewCriterion( TranslationPeer::TRN_ID, "%$search%", Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( TranslationPeer::TRN_VALUE, "%$search%", Criteria::LIKE ) ) );
|
||||
}
|
||||
// for date filter
|
||||
if (($dateFrom) && ($dateTo)) {
|
||||
$oCriteria->add(
|
||||
$oCriteria->getNewCriterion(
|
||||
TranslationPeer::TRN_UPDATE_DATE,
|
||||
"$dateFrom", Criteria::GREATER_EQUAL//LESS_EQUAL
|
||||
)->addAnd($oCriteria->getNewCriterion(
|
||||
TranslationPeer::TRN_UPDATE_DATE,
|
||||
"$dateTo", Criteria::LESS_EQUAL//GREATER_EQUAL
|
||||
))
|
||||
);
|
||||
$oCriteria->add( $oCriteria->getNewCriterion( TranslationPeer::TRN_UPDATE_DATE, "$dateFrom", Criteria::GREATER_EQUAL ) //LESS_EQUAL
|
||||
->addAnd( $oCriteria->getNewCriterion( TranslationPeer::TRN_UPDATE_DATE, "$dateTo", Criteria::LESS_EQUAL ) //GREATER_EQUAL
|
||||
) );
|
||||
}
|
||||
// end filter
|
||||
$c = clone $oCriteria;
|
||||
@@ -108,14 +98,16 @@ class Translation extends BaseTranslation {
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
if( is_array($aRow) )
|
||||
if (is_array( $aRow )) {
|
||||
$totalCount = $aRow[0];
|
||||
|
||||
if($start)
|
||||
}
|
||||
if ($start) {
|
||||
$oCriteria->setOffset( $start );
|
||||
if($limit) //&& !isset($seach) && !isset($search))
|
||||
}
|
||||
if ($limit) {
|
||||
//&& !isset($seach) && !isset($search))
|
||||
$oCriteria->setLimit( $limit );
|
||||
|
||||
}
|
||||
$rs = TranslationPeer::doSelectRS( $oCriteria );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rows = Array ();
|
||||
@@ -129,19 +121,19 @@ class Translation extends BaseTranslation {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/* Load strings from a Database .
|
||||
* @author Fernando Ontiveros <fernando@colosa.com>
|
||||
* @parameter $languageId (es|en|...).
|
||||
*/
|
||||
|
||||
function generateFileTranslation ($languageId = '') {
|
||||
public function generateFileTranslation ($languageId = '')
|
||||
{
|
||||
$translation = Array ();
|
||||
$translationJS = Array ();
|
||||
|
||||
if ($languageId === '')
|
||||
if ($languageId === '') {
|
||||
$languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
|
||||
}
|
||||
$c = new Criteria();
|
||||
$c->add( TranslationPeer::TRN_LANG, $languageId );
|
||||
$c->addAscendingOrderByColumn( 'TRN_CATEGORY' );
|
||||
@@ -162,12 +154,12 @@ class Translation extends BaseTranslation {
|
||||
|
||||
try {
|
||||
|
||||
if( ! is_dir(dirname($cacheFile)) )
|
||||
if (! is_dir( dirname( $cacheFile ) )) {
|
||||
G::mk_dir( dirname( $cacheFile ) );
|
||||
|
||||
if( ! is_dir(dirname($cacheFileJS)) )
|
||||
}
|
||||
if (! is_dir( dirname( $cacheFileJS ) )) {
|
||||
G::mk_dir( dirname( $cacheFileJS ) );
|
||||
|
||||
}
|
||||
$f = fopen( $cacheFile, 'w+' );
|
||||
fwrite( $f, "<?php\n" );
|
||||
fwrite( $f, '$translation =' . 'unserialize(\'' . addcslashes( serialize( $translation ), '\\\'' ) . "');\n" );
|
||||
@@ -196,7 +188,8 @@ class Translation extends BaseTranslation {
|
||||
* rowsAffected 0,1 the number of rows affected
|
||||
* message message error.
|
||||
*/
|
||||
function addTranslation ( $category, $id, $languageId, $value ) {
|
||||
public function addTranslation ($category, $id, $languageId, $value)
|
||||
{
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = TranslationPeer::retrieveByPK( $category, $id, $languageId );
|
||||
if (! (is_object( $tr ) && get_class( $tr ) == 'Translation')) {
|
||||
@@ -211,8 +204,7 @@ class Translation extends BaseTranslation {
|
||||
if ($tr->validate()) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $tr->getValidationFailures();
|
||||
@@ -225,14 +217,15 @@ class Translation extends BaseTranslation {
|
||||
//to do: uniform coderror structures for all classes
|
||||
}
|
||||
|
||||
function remove($sCategory, $sId, $sLang) {
|
||||
public function remove ($sCategory, $sId, $sLang)
|
||||
{
|
||||
$oTranslation = TranslationPeer::retrieveByPK( $sCategory, $sId, $sLang );
|
||||
if ((is_object( $oTranslation ) && get_class( $oTranslation ) == 'Translation')) {
|
||||
$oTranslation->delete();
|
||||
}
|
||||
}
|
||||
|
||||
function addTranslationEnvironment($locale, $headers, $numRecords)
|
||||
public function addTranslationEnvironment ($locale, $headers, $numRecords)
|
||||
{
|
||||
$filePath = $this->envFilePath;
|
||||
$environments = Array ();
|
||||
@@ -257,11 +250,10 @@ class Translation extends BaseTranslation {
|
||||
$environments[$locale]['__INTERNATIONAL__'] = $environment;
|
||||
}
|
||||
|
||||
|
||||
file_put_contents( $filePath, serialize( $environments ) );
|
||||
}
|
||||
|
||||
function removeTranslationEnvironment($locale)
|
||||
public function removeTranslationEnvironment ($locale)
|
||||
{
|
||||
$filePath = $this->envFilePath;
|
||||
if (strpos( $locale, self::$localeSeparator ) !== false) {
|
||||
@@ -274,7 +266,7 @@ class Translation extends BaseTranslation {
|
||||
if (file_exists( $filePath )) {
|
||||
$environments = unserialize( file_get_contents( $filePath ) );
|
||||
if (! isset( $environments[$LAN_ID][$IC_UID] )) {
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
unset( $environments[$LAN_ID][$IC_UID] );
|
||||
@@ -289,22 +281,23 @@ class Translation extends BaseTranslation {
|
||||
}
|
||||
}
|
||||
|
||||
function getTranslationEnvironments(){
|
||||
public function getTranslationEnvironments ()
|
||||
{
|
||||
$filePath = $this->envFilePath;
|
||||
$envs = Array ();
|
||||
|
||||
if (! file_exists( $filePath )) {
|
||||
//the transaltions table file doesn't exist, then build it
|
||||
|
||||
if( ! is_dir(dirname($this->envFilePath)) )
|
||||
G::mk_dir(dirname($this->envFilePath));
|
||||
|
||||
if (! is_dir( dirname( $this->envFilePath ) )) {
|
||||
G::mk_dir( dirname( $this->envFilePath ) );
|
||||
}
|
||||
$translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP;
|
||||
$basePOFile = $translationsPath . 'english' . PATH_SEP . 'processmaker.en.po';
|
||||
|
||||
$params = self::getInfoFromPOFile( $basePOFile );
|
||||
$this->addTranslationEnvironment( $params['LOCALE'], $params['HEADERS'], $params['COUNT'] );
|
||||
|
||||
//getting more lanuguage translations
|
||||
$files = glob( $translationsPath . "*.po" );
|
||||
foreach ($files as $file) {
|
||||
@@ -323,7 +316,8 @@ class Translation extends BaseTranslation {
|
||||
|
||||
return $environments;
|
||||
|
||||
/*G::LoadSystem('dbMaintenance');
|
||||
/*
|
||||
G::LoadSystem('dbMaintenance');
|
||||
$o = new DataBaseMaintenance('localhost', 'root', 'atopml2005');
|
||||
$o->connect('wf_os');
|
||||
$r = $o->query('select * from ISO_COUNTRY');
|
||||
@@ -342,7 +336,8 @@ class Translation extends BaseTranslation {
|
||||
*/
|
||||
}
|
||||
|
||||
function getInfoFromPOFile($file){
|
||||
public function getInfoFromPOFile ($file)
|
||||
{
|
||||
G::loadClass( 'i18n_po' );
|
||||
$POFile = new i18n_PO( $file );
|
||||
$POFile->readInit();
|
||||
@@ -377,11 +372,11 @@ class Translation extends BaseTranslation {
|
||||
} catch (Exception $e) {
|
||||
$countItems = '-';
|
||||
}
|
||||
|
||||
return Array ('LOCALE' => $LOCALE,'HEADERS' => $POHeaders,'COUNT' => $countItems);
|
||||
}
|
||||
|
||||
function getTranslationEnvironment($locale){
|
||||
public function getTranslationEnvironment ($locale)
|
||||
{
|
||||
$filePath = $this->envFilePath;
|
||||
$environments = Array ();
|
||||
|
||||
@@ -397,13 +392,15 @@ class Translation extends BaseTranslation {
|
||||
$IC_UID = '__INTERNATIONAL__';
|
||||
}
|
||||
|
||||
if( isset($environments[$LAN_ID][$IC_UID]) )
|
||||
if (isset( $environments[$LAN_ID][$IC_UID] )) {
|
||||
return $environments[$LAN_ID][$IC_UID];
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function saveTranslationEnvironment($locale, $data){
|
||||
public function saveTranslationEnvironment ($locale, $data)
|
||||
{
|
||||
$filePath = $this->envFilePath;
|
||||
$environments = Array ();
|
||||
|
||||
@@ -423,39 +420,36 @@ class Translation extends BaseTranslation {
|
||||
file_put_contents( $filePath, serialize( $environments ) );
|
||||
}
|
||||
|
||||
function getTranslationMeta(){
|
||||
public function getTranslationMeta ()
|
||||
{
|
||||
$translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP;
|
||||
$translationsTable = unserialize( file_get_contents( $translationsPath . 'pmos-translations.meta' ) );
|
||||
return $translationsTable;
|
||||
}
|
||||
|
||||
function getTranslationMetaByCountryName($IC_NAME){
|
||||
public function getTranslationMetaByCountryName ($IC_NAME)
|
||||
{
|
||||
$translationsTable = self::getTranslationMeta();
|
||||
|
||||
foreach ($translationsTable['ISO_COUNTRY'] as $row) {
|
||||
if( $row['IC_NAME'] == $IC_NAME )
|
||||
if ($row['IC_NAME'] == $IC_NAME) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTranslationMetaByLanguageName($LAN_NAME){
|
||||
public function getTranslationMetaByLanguageName ($LAN_NAME)
|
||||
{
|
||||
$translationsTable = self::getTranslationMeta();
|
||||
|
||||
foreach ($translationsTable['LANGUAGE'] as $row) {
|
||||
if( $row['LAN_NAME'] == $LAN_NAME )
|
||||
if ($row['LAN_NAME'] == $LAN_NAME) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // Translation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
// Translation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user