Merge remote branch 'upstream/master' into BUG-6947
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* class.calendar.php
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
@@ -13,11 +14,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -27,207 +28,205 @@
|
||||
* @name calendar
|
||||
* created 2010-03-22
|
||||
*
|
||||
* @author Hugo Loza <hugo@colosa.com> 2010-03-22 *
|
||||
* @author Hugo Loza <hugo@colosa.com> 2010-03-22 *
|
||||
*/
|
||||
|
||||
require_once ( "classes/model/CalendarDefinition.php" );
|
||||
|
||||
|
||||
require_once ("classes/model/CalendarDefinition.php");
|
||||
|
||||
/**
|
||||
* A Calendar object where it is defined Working Days, Business Hours and Holidays
|
||||
* A Calendar is applied to a User, Process or Task
|
||||
* Extends CalendarDefinition.
|
||||
*
|
||||
*
|
||||
* @author Hugo Loza <hugo@colosa.com> 2010-03-22
|
||||
* @uses CalendarDefinition
|
||||
* @package workflow.engine.classes
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
*/
|
||||
class calendar extends CalendarDefinition
|
||||
{
|
||||
/**
|
||||
* @param string(32) $userUid
|
||||
* @param string(32) $proUid
|
||||
* @param string(32) $tasUid
|
||||
*/
|
||||
function calendar($userUid = NULL, $proUid = NULL, $tasUid = NULL)
|
||||
{
|
||||
$this->userUid = $userUid;
|
||||
$this->proUid = $proUid;
|
||||
$this->tasUid = $tasUid;
|
||||
$this->calendarLog = "";
|
||||
$this->setupCalendar($userUid,$proUid,$tasUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Small function used to add important information about the calcs and actions
|
||||
* to the log (that log will be saved)
|
||||
*
|
||||
* @name addCalendarLog
|
||||
* @param text $msg
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function addCalendarLog($msg)
|
||||
{
|
||||
$this->calendarLog .= "\n".date("D M j G:i:s T Y").": " . $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* setupCalendar is used to generate a valid instance of calendar using $userUid, $proUid and $tasUid
|
||||
* to find a valid calendar. If there is no valid calendar then use the Default
|
||||
*
|
||||
* @name setupCalendar
|
||||
* @param string(32) $userUid
|
||||
* @param string(32) $proUid
|
||||
* @param string(32) $tasUid
|
||||
* @return void
|
||||
*/
|
||||
function setupCalendar($userUid,$proUid,$tasUid)
|
||||
{
|
||||
$calendarDefinition = $this->getCalendarFor($userUid,$proUid,$tasUid);
|
||||
$this->calendarUid = $calendarDefinition['CALENDAR_UID'];
|
||||
$this->calendarDefinition = $calendarDefinition;
|
||||
}
|
||||
/**
|
||||
* getnextValidBusinessHoursrange is used recursivily to find a valid BusinessHour
|
||||
* for the given $date and $time. This function use all the exeptions defined for
|
||||
* Working days, Business Hours and Holidays.
|
||||
*
|
||||
* @author Hugo Loza <hugo@colosa.com>
|
||||
* @name getNextValidBusinessHoursRange
|
||||
* @param date $date
|
||||
* @param time $time
|
||||
*
|
||||
* @var array $businessHoursA Object with all the infromation about the valid Business Hours found
|
||||
* $return array('DATE'=>$date,'TIME'=>$time,'BUSINESS_HOURS'=>$businessHoursA)
|
||||
*/
|
||||
function getNextValidBusinessHoursRange($date, $time)
|
||||
{
|
||||
$this->addCalendarLog("================= Start : $date,$time ================");
|
||||
|
||||
//First Validate if is a valid date
|
||||
$sw_valid_date = false;
|
||||
$sw_date_changed = false;
|
||||
while (!$sw_valid_date) {
|
||||
$dateArray = explode("-",$date);
|
||||
$hour = 0;
|
||||
$minute = 0;
|
||||
$second = 0;
|
||||
$month = $dateArray[1];
|
||||
$day = $dateArray[2];
|
||||
$year = $dateArray[0];
|
||||
$weekDay = date("w",mktime($hour,$minute,$second,$month,$day,$year));
|
||||
$weekDayLabel = date("l",mktime($hour,$minute,$second,$month,$day,$year));
|
||||
$dateInt = mktime($hour,$minute,$second,$month,$day,$year);
|
||||
|
||||
|
||||
$this->addCalendarLog("**** $weekDayLabel ($weekDay) * $date");
|
||||
$sw_week_day = false;
|
||||
$sw_not_holiday = true;
|
||||
|
||||
|
||||
if(in_array($weekDay,$this->calendarDefinition['CALENDAR_WORK_DAYS_A'])){
|
||||
$sw_week_day = true;
|
||||
}
|
||||
if(!$sw_week_day){
|
||||
$this->addCalendarLog("Valid working Dates: ".$this->calendarDefinition['CALENDAR_WORK_DAYS_A']);
|
||||
$this->addCalendarLog("- Non working Day");
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->calendarDefinition['HOLIDAY'] as $key => $holiday) {
|
||||
//Normalize Holiday date to SAME year of date
|
||||
|
||||
$holidayStartA = explode(" ",$holiday['CALENDAR_HOLIDAY_START']);
|
||||
$holidayStartA = explode("-",$holidayStartA[0]);
|
||||
|
||||
$normalizedHolidayStart = date("Y-m-d",mktime($hour,$minute,$second,$holidayStartA[1],$holidayStartA[2],$year));
|
||||
$normalizedHolidayStartInt = mktime($hour,$minute,$second,$holidayStartA[1],$holidayStartA[2],$year);
|
||||
|
||||
$holidayEndA = explode(" ",$holiday['CALENDAR_HOLIDAY_END']);
|
||||
$holidayEndA = explode("-",$holidayEndA[0]);
|
||||
$normalizedHolidayEnd = date("Y-m-d",mktime($hour,$minute,$second,$holidayEndA[1],$holidayEndA[2],$year));
|
||||
$normalizedHolidayEndInt = mktime($hour,$minute,$second,$holidayEndA[1],$holidayEndA[2],$year);
|
||||
$sw_not_holiday_aux = true;
|
||||
if( $dateInt >= $normalizedHolidayStartInt && $dateInt <= $normalizedHolidayEndInt ){
|
||||
$sw_not_holiday = false;
|
||||
$sw_not_holiday_aux = false;
|
||||
}
|
||||
if(!$sw_not_holiday_aux){
|
||||
$this->addCalendarLog("It is a holiday -> ".$holiday['CALENDAR_HOLIDAY_NAME']." ($normalizedHolidayStart - $normalizedHolidayEnd)");
|
||||
}
|
||||
}
|
||||
$sw_valid_date=$sw_week_day && $sw_not_holiday;
|
||||
|
||||
if(!$sw_valid_date){//Go to next day
|
||||
$date=date("Y-m-d",mktime($hour,$minute+1,$second,$month,$day+1,$year));
|
||||
$sw_date_changed=true;
|
||||
}else{
|
||||
$this->addCalendarLog("FOUND VALID DATE -> $date");
|
||||
/**
|
||||
*
|
||||
* @param string(32) $userUid
|
||||
* @param string(32) $proUid
|
||||
* @param string(32) $tasUid
|
||||
*/
|
||||
function calendar ($userUid = NULL, $proUid = NULL, $tasUid = NULL)
|
||||
{
|
||||
$this->userUid = $userUid;
|
||||
$this->proUid = $proUid;
|
||||
$this->tasUid = $tasUid;
|
||||
$this->calendarLog = "";
|
||||
$this->setupCalendar( $userUid, $proUid, $tasUid );
|
||||
}
|
||||
|
||||
|
||||
//We got a valid day, now get the valid Business Hours
|
||||
//Here Need to find a rule to get the most nea
|
||||
$businessHoursA=array();
|
||||
$prevHour="00:00";
|
||||
|
||||
if($sw_date_changed){// If date has changed then Use the first available period
|
||||
$time="00:01";
|
||||
}
|
||||
|
||||
foreach($this->calendarDefinition['BUSINESS_DAY'] as $keyBH => $businessHours){
|
||||
|
||||
// First the period may correspond to ALL or to the current week day
|
||||
if(($businessHours['CALENDAR_BUSINESS_DAY']==7)||($businessHours['CALENDAR_BUSINESS_DAY']==$weekDay)){
|
||||
$this->addCalendarLog("Validating ($time/$prevHour) From: ".$businessHours['CALENDAR_BUSINESS_START']." to ".$businessHours['CALENDAR_BUSINESS_END']);
|
||||
|
||||
//Prev Hour
|
||||
$prevHourA = explode(":",$prevHour);
|
||||
$prevHourSeconds = ($prevHourA[0]*60*60)+($prevHour[1]*60);
|
||||
|
||||
$calendarBusinessStartA = explode(":",$businessHours['CALENDAR_BUSINESS_START']);
|
||||
$calendarBusinessStartSeconds = ($calendarBusinessStartA[0]*60*60)+($calendarBusinessStartA[1]*60);
|
||||
|
||||
$calendarBusinessEndA = explode(":",$businessHours['CALENDAR_BUSINESS_END']);
|
||||
$calendarBusinessEndSeconds = ($calendarBusinessEndA[0]*60*60)+($calendarBusinessEndA[1]*60);
|
||||
|
||||
$timeAuxA = explode(":",$time);
|
||||
$timeAuxSeconds = ($timeAuxA[0]*60*60)+($timeAuxA[1]*60);
|
||||
|
||||
if(($timeAuxSeconds>=$prevHourSeconds)&&($timeAuxSeconds<$calendarBusinessEndSeconds)){
|
||||
$this->addCalendarLog("*** FOUND VALID BUSINESS HOUR ".$businessHours['CALENDAR_BUSINESS_START']." - ".$businessHours['CALENDAR_BUSINESS_END']);
|
||||
|
||||
if($timeAuxSeconds<$calendarBusinessStartSeconds){//Out of range then assign first hour
|
||||
$this->addCalendarLog("Set to default start hour to: ".$businessHours['CALENDAR_BUSINESS_START']);
|
||||
$time = $businessHours['CALENDAR_BUSINESS_START'];
|
||||
}
|
||||
$prevHour = $businessHours['CALENDAR_BUSINESS_END'];
|
||||
$businessHoursA = $businessHours;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Small function used to add important information about the calcs and actions
|
||||
* to the log (that log will be saved)
|
||||
*
|
||||
* @name addCalendarLog
|
||||
* @param text $msg
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function addCalendarLog ($msg)
|
||||
{
|
||||
$this->calendarLog .= "\n" . date( "D M j G:i:s T Y" ) . ": " . $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* setupCalendar is used to generate a valid instance of calendar using $userUid, $proUid and $tasUid
|
||||
* to find a valid calendar.
|
||||
* If there is no valid calendar then use the Default
|
||||
*
|
||||
* @name setupCalendar
|
||||
* @param string(32) $userUid
|
||||
* @param string(32) $proUid
|
||||
* @param string(32) $tasUid
|
||||
* @return void
|
||||
*/
|
||||
function setupCalendar ($userUid, $proUid, $tasUid)
|
||||
{
|
||||
$calendarDefinition = $this->getCalendarFor( $userUid, $proUid, $tasUid );
|
||||
$this->calendarUid = $calendarDefinition['CALENDAR_UID'];
|
||||
$this->calendarDefinition = $calendarDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* getnextValidBusinessHoursrange is used recursivily to find a valid BusinessHour
|
||||
* for the given $date and $time.
|
||||
* This function use all the exeptions defined for
|
||||
* Working days, Business Hours and Holidays.
|
||||
*
|
||||
* @author Hugo Loza <hugo@colosa.com>
|
||||
* @name getNextValidBusinessHoursRange
|
||||
* @param date $date
|
||||
* @param time $time
|
||||
*
|
||||
* @var array $businessHoursA Object with all the infromation about the valid Business Hours found
|
||||
* $return array('DATE'=>$date,'TIME'=>$time,'BUSINESS_HOURS'=>$businessHoursA)
|
||||
*/
|
||||
function getNextValidBusinessHoursRange ($date, $time)
|
||||
{
|
||||
$this->addCalendarLog( "================= Start : $date,$time ================" );
|
||||
|
||||
//First Validate if is a valid date
|
||||
$sw_valid_date = false;
|
||||
$sw_date_changed = false;
|
||||
while (! $sw_valid_date) {
|
||||
$dateArray = explode( "-", $date );
|
||||
$hour = 0;
|
||||
$minute = 0;
|
||||
$second = 0;
|
||||
$month = $dateArray[1];
|
||||
$day = $dateArray[2];
|
||||
$year = $dateArray[0];
|
||||
$weekDay = date( "w", mktime( $hour, $minute, $second, $month, $day, $year ) );
|
||||
$weekDayLabel = date( "l", mktime( $hour, $minute, $second, $month, $day, $year ) );
|
||||
$dateInt = mktime( $hour, $minute, $second, $month, $day, $year );
|
||||
|
||||
$this->addCalendarLog( "**** $weekDayLabel ($weekDay) * $date" );
|
||||
$sw_week_day = false;
|
||||
$sw_not_holiday = true;
|
||||
|
||||
if (in_array( $weekDay, $this->calendarDefinition['CALENDAR_WORK_DAYS_A'] )) {
|
||||
$sw_week_day = true;
|
||||
}
|
||||
if (! $sw_week_day) {
|
||||
$this->addCalendarLog( "Valid working Dates: " . $this->calendarDefinition['CALENDAR_WORK_DAYS_A'] );
|
||||
$this->addCalendarLog( "- Non working Day" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($businessHoursA)){
|
||||
$this->addCalendarLog("> No Valid Business Hour found for current date, go to next");
|
||||
$date = date("Y-m-d", mktime($hour,$minute+1,$second,$month,$day+1,$year));
|
||||
$sw_date_changed = true;
|
||||
$sw_valid_date = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$return['DATE'] = $date;
|
||||
$return['TIME'] = $time;
|
||||
$return['BUSINESS_HOURS'] = $businessHoursA;
|
||||
|
||||
return $return;
|
||||
foreach ($this->calendarDefinition['HOLIDAY'] as $key => $holiday) {
|
||||
//Normalize Holiday date to SAME year of date
|
||||
|
||||
|
||||
$holidayStartA = explode( " ", $holiday['CALENDAR_HOLIDAY_START'] );
|
||||
$holidayStartA = explode( "-", $holidayStartA[0] );
|
||||
|
||||
$normalizedHolidayStart = date( "Y-m-d", mktime( $hour, $minute, $second, $holidayStartA[1], $holidayStartA[2], $year ) );
|
||||
$normalizedHolidayStartInt = mktime( $hour, $minute, $second, $holidayStartA[1], $holidayStartA[2], $year );
|
||||
|
||||
$holidayEndA = explode( " ", $holiday['CALENDAR_HOLIDAY_END'] );
|
||||
$holidayEndA = explode( "-", $holidayEndA[0] );
|
||||
$normalizedHolidayEnd = date( "Y-m-d", mktime( $hour, $minute, $second, $holidayEndA[1], $holidayEndA[2], $year ) );
|
||||
$normalizedHolidayEndInt = mktime( $hour, $minute, $second, $holidayEndA[1], $holidayEndA[2], $year );
|
||||
$sw_not_holiday_aux = true;
|
||||
if ($dateInt >= $normalizedHolidayStartInt && $dateInt <= $normalizedHolidayEndInt) {
|
||||
$sw_not_holiday = false;
|
||||
$sw_not_holiday_aux = false;
|
||||
}
|
||||
if (! $sw_not_holiday_aux) {
|
||||
$this->addCalendarLog( "It is a holiday -> " . $holiday['CALENDAR_HOLIDAY_NAME'] . " ($normalizedHolidayStart - $normalizedHolidayEnd)" );
|
||||
}
|
||||
}
|
||||
$sw_valid_date = $sw_week_day && $sw_not_holiday;
|
||||
|
||||
if (! $sw_valid_date) { //Go to next day
|
||||
$date = date( "Y-m-d", mktime( $hour, $minute + 1, $second, $month, $day + 1, $year ) );
|
||||
$sw_date_changed = true;
|
||||
} else {
|
||||
$this->addCalendarLog( "FOUND VALID DATE -> $date" );
|
||||
|
||||
//We got a valid day, now get the valid Business Hours
|
||||
//Here Need to find a rule to get the most nea
|
||||
$businessHoursA = array ();
|
||||
$prevHour = "00:00";
|
||||
|
||||
if ($sw_date_changed) { // If date has changed then Use the first available period
|
||||
$time = "00:01";
|
||||
}
|
||||
|
||||
foreach ($this->calendarDefinition['BUSINESS_DAY'] as $keyBH => $businessHours) {
|
||||
|
||||
// First the period may correspond to ALL or to the current week day
|
||||
if (($businessHours['CALENDAR_BUSINESS_DAY'] == 7) || ($businessHours['CALENDAR_BUSINESS_DAY'] == $weekDay)) {
|
||||
$this->addCalendarLog( "Validating ($time/$prevHour) From: " . $businessHours['CALENDAR_BUSINESS_START'] . " to " . $businessHours['CALENDAR_BUSINESS_END'] );
|
||||
|
||||
//Prev Hour
|
||||
$prevHourA = explode( ":", $prevHour );
|
||||
$prevHourSeconds = ($prevHourA[0] * 60 * 60) + ($prevHour[1] * 60);
|
||||
|
||||
$calendarBusinessStartA = explode( ":", $businessHours['CALENDAR_BUSINESS_START'] );
|
||||
$calendarBusinessStartSeconds = ($calendarBusinessStartA[0] * 60 * 60) + ($calendarBusinessStartA[1] * 60);
|
||||
|
||||
$calendarBusinessEndA = explode( ":", $businessHours['CALENDAR_BUSINESS_END'] );
|
||||
$calendarBusinessEndSeconds = ($calendarBusinessEndA[0] * 60 * 60) + ($calendarBusinessEndA[1] * 60);
|
||||
|
||||
$timeAuxA = explode( ":", $time );
|
||||
$timeAuxSeconds = ($timeAuxA[0] * 60 * 60) + ($timeAuxA[1] * 60);
|
||||
|
||||
if (($timeAuxSeconds >= $prevHourSeconds) && ($timeAuxSeconds < $calendarBusinessEndSeconds)) {
|
||||
$this->addCalendarLog( "*** FOUND VALID BUSINESS HOUR " . $businessHours['CALENDAR_BUSINESS_START'] . " - " . $businessHours['CALENDAR_BUSINESS_END'] );
|
||||
|
||||
if ($timeAuxSeconds < $calendarBusinessStartSeconds) { //Out of range then assign first hour
|
||||
$this->addCalendarLog( "Set to default start hour to: " . $businessHours['CALENDAR_BUSINESS_START'] );
|
||||
$time = $businessHours['CALENDAR_BUSINESS_START'];
|
||||
}
|
||||
$prevHour = $businessHours['CALENDAR_BUSINESS_END'];
|
||||
$businessHoursA = $businessHours;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty( $businessHoursA )) {
|
||||
$this->addCalendarLog( "> No Valid Business Hour found for current date, go to next" );
|
||||
$date = date( "Y-m-d", mktime( $hour, $minute + 1, $second, $month, $day + 1, $year ) );
|
||||
$sw_date_changed = true;
|
||||
$sw_valid_date = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$return['DATE'] = $date;
|
||||
$return['TIME'] = $time;
|
||||
$return['BUSINESS_HOURS'] = $businessHoursA;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.cli.php
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2011 Colosa Inc.
|
||||
@@ -13,11 +15,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -26,297 +28,313 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
class CLI {
|
||||
public static $tasks = array();
|
||||
public static $currentTask = NULL;
|
||||
class CLI
|
||||
{
|
||||
public static $tasks = array ();
|
||||
public static $currentTask = NULL;
|
||||
|
||||
/**
|
||||
* Adds a new task defined by it's name. All other task functions will
|
||||
* remember the current task defined here.
|
||||
*
|
||||
* @param string $name name of the task, used in the command-line
|
||||
*/
|
||||
public static function taskName($name) {
|
||||
self::$currentTask = $name;
|
||||
self::$tasks[$name] = array(
|
||||
'name' => $name,
|
||||
'description' => NULL,
|
||||
'args' => array(),
|
||||
'function' => NULL,
|
||||
'opt' => array('short' => '', 'long' => array(), 'descriptions' => array())
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Adds a new task defined by it's name.
|
||||
* All other task functions will
|
||||
* remember the current task defined here.
|
||||
*
|
||||
* @param string $name name of the task, used in the command-line
|
||||
*/
|
||||
public static function taskName ($name)
|
||||
{
|
||||
self::$currentTask = $name;
|
||||
self::$tasks[$name] = array ('name' => $name,'description' => NULL,'args' => array (),'function' => NULL,'opt' => array ('short' => '','long' => array (),'descriptions' => array ()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a description to the current task. The description should contain a
|
||||
* one-line description of the command and a few lines of text with more
|
||||
* information.
|
||||
*
|
||||
* @param string $description task description
|
||||
*/
|
||||
public static function taskDescription($description) {
|
||||
assert(self::$currentTask !== NULL);
|
||||
self::$tasks[self::$currentTask]["description"] = $description;
|
||||
}
|
||||
/**
|
||||
* Adds a description to the current task.
|
||||
* The description should contain a
|
||||
* one-line description of the command and a few lines of text with more
|
||||
* information.
|
||||
*
|
||||
* @param string $description task description
|
||||
*/
|
||||
public static function taskDescription ($description)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
self::$tasks[self::$currentTask]["description"] = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an argument to the current task. The options will affect how it is
|
||||
* displayed in the help command. Optional will put [] in the argument and
|
||||
* multiple will put ... in the end. Arguments are displayed together with
|
||||
* the task name in the help command.
|
||||
*
|
||||
* @param string $name argument name
|
||||
*/
|
||||
public static function taskArg($name, $optional = true, $multiple = false) {
|
||||
assert(self::$currentTask !== NULL);
|
||||
self::$tasks[self::$currentTask]["args"][$name] = array(
|
||||
'optional' => $optional,
|
||||
'multiple' => $multiple
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Adds an argument to the current task.
|
||||
* The options will affect how it is
|
||||
* displayed in the help command. Optional will put [] in the argument and
|
||||
* multiple will put ... in the end. Arguments are displayed together with
|
||||
* the task name in the help command.
|
||||
*
|
||||
* @param string $name argument name
|
||||
*/
|
||||
public static function taskArg ($name, $optional = true, $multiple = false)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
self::$tasks[self::$currentTask]["args"][$name] = array ('optional' => $optional,'multiple' => $multiple
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines short and long options as used by getopt to the current task.
|
||||
*
|
||||
* @param string $short short options
|
||||
* @param array $long long options
|
||||
*/
|
||||
public static function taskOpt($name, $description, $short, $long = NULL) {
|
||||
assert(self::$currentTask !== NULL);
|
||||
$opts = self::$tasks[self::$currentTask]["opt"];
|
||||
if ($short)
|
||||
$opts['short'] .= $short;
|
||||
if ($long)
|
||||
$opts['long'][] = $long;
|
||||
$opts['descriptions'][$name] = array('short' => $short, 'long' => $long,
|
||||
'description' => $description);
|
||||
self::$tasks[self::$currentTask]["opt"] = $opts;
|
||||
}
|
||||
/**
|
||||
* Defines short and long options as used by getopt to the current task.
|
||||
*
|
||||
* @param string $short short options
|
||||
* @param array $long long options
|
||||
*/
|
||||
public static function taskOpt ($name, $description, $short, $long = NULL)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
$opts = self::$tasks[self::$currentTask]["opt"];
|
||||
if ($short)
|
||||
$opts['short'] .= $short;
|
||||
if ($long)
|
||||
$opts['long'][] = $long;
|
||||
$opts['descriptions'][$name] = array ('short' => $short,'long' => $long,'description' => $description
|
||||
);
|
||||
self::$tasks[self::$currentTask]["opt"] = $opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the function to run for the current task.
|
||||
*
|
||||
* @param callback $function function to run
|
||||
*/
|
||||
public static function taskRun($function) {
|
||||
assert(self::$currentTask !== NULL);
|
||||
self::$tasks[self::$currentTask]["function"] = $function;
|
||||
}
|
||||
/**
|
||||
* Defines the function to run for the current task.
|
||||
*
|
||||
* @param callback $function function to run
|
||||
*/
|
||||
public static function taskRun ($function)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
self::$tasks[self::$currentTask]["function"] = $function;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the help instructions.
|
||||
*
|
||||
* @param array $args if defined, the task name should be argument 0
|
||||
* @param array $opts options as returned by getopt
|
||||
*/
|
||||
public static function help($args, $opts = NULL) {
|
||||
global $argv;
|
||||
$scriptName = $argv[0];
|
||||
if (is_array($args))
|
||||
$taskName = $args[0];
|
||||
else
|
||||
$taskName = $args;
|
||||
/**
|
||||
* Displays the help instructions.
|
||||
*
|
||||
* @param array $args if defined, the task name should be argument 0
|
||||
* @param array $opts options as returned by getopt
|
||||
*/
|
||||
public static function help ($args, $opts = NULL)
|
||||
{
|
||||
global $argv;
|
||||
$scriptName = $argv[0];
|
||||
if (is_array( $args ))
|
||||
$taskName = $args[0];
|
||||
else
|
||||
$taskName = $args;
|
||||
|
||||
if (!$taskName) {
|
||||
echo "usage: $scriptName <task> [options] [args]\n";
|
||||
echo "Type '$scriptName help <task-name>' for help on a specific task\n";
|
||||
echo "\nAvailable tasks:\n";
|
||||
$tasks = array();
|
||||
ksort(self::$tasks);
|
||||
foreach (self::$tasks as $name => $data) {
|
||||
$description = explode("\n", $data['description']);
|
||||
$tasks[] = " $name";
|
||||
}
|
||||
$tasks = join("\n", $tasks);
|
||||
echo $tasks . "\n\n";
|
||||
} else {
|
||||
$valid_args = array();
|
||||
foreach(self::$tasks[$taskName]['args'] as $arg => $data) {
|
||||
$arg = strtoupper($arg);
|
||||
if ($data['multiple'])
|
||||
$arg = "$arg...";
|
||||
if ($data['optional'])
|
||||
$arg = "[$arg]";
|
||||
$valid_args[] = $arg;
|
||||
}
|
||||
$valid_args = join(" ", $valid_args);
|
||||
$description = explode("\n", self::$tasks[$taskName]['description']);
|
||||
$taskDescription = trim(array_shift($description));
|
||||
$description = trim(implode("\n", $description));
|
||||
$message = <<< EOT
|
||||
if (! $taskName) {
|
||||
echo "usage: $scriptName <task> [options] [args]\n";
|
||||
echo "Type '$scriptName help <task-name>' for help on a specific task\n";
|
||||
echo "\nAvailable tasks:\n";
|
||||
$tasks = array ();
|
||||
ksort( self::$tasks );
|
||||
foreach (self::$tasks as $name => $data) {
|
||||
$description = explode( "\n", $data['description'] );
|
||||
$tasks[] = " $name";
|
||||
}
|
||||
$tasks = join( "\n", $tasks );
|
||||
echo $tasks . "\n\n";
|
||||
} else {
|
||||
$valid_args = array ();
|
||||
foreach (self::$tasks[$taskName]['args'] as $arg => $data) {
|
||||
$arg = strtoupper( $arg );
|
||||
if ($data['multiple'])
|
||||
$arg = "$arg...";
|
||||
if ($data['optional'])
|
||||
$arg = "[$arg]";
|
||||
$valid_args[] = $arg;
|
||||
}
|
||||
$valid_args = join( " ", $valid_args );
|
||||
$description = explode( "\n", self::$tasks[$taskName]['description'] );
|
||||
$taskDescription = trim( array_shift( $description ) );
|
||||
$description = trim( implode( "\n", $description ) );
|
||||
$message = <<< EOT
|
||||
$taskName: {$taskDescription}
|
||||
Usage: $scriptName $taskName $valid_args
|
||||
|
||||
$description
|
||||
|
||||
EOT;
|
||||
$valid_options = array();
|
||||
foreach(self::$tasks[$taskName]['opt']['descriptions'] as $opt => $data) {
|
||||
$optString = array();
|
||||
if ($data['short'])
|
||||
$optString[] = "-{$data['short']}";
|
||||
if ($data['long'])
|
||||
$optString[] = "--{$data['long']}";
|
||||
$valid_options[] = " " . join(", ", $optString) . "\n\t" . wordwrap($data['description'], 70, "\n\t");
|
||||
}
|
||||
$valid_options = join("\n", $valid_options);
|
||||
if ($valid_options) {
|
||||
$message .= <<< EOT
|
||||
$valid_options = array ();
|
||||
foreach (self::$tasks[$taskName]['opt']['descriptions'] as $opt => $data) {
|
||||
$optString = array ();
|
||||
if ($data['short'])
|
||||
$optString[] = "-{$data['short']}";
|
||||
if ($data['long'])
|
||||
$optString[] = "--{$data['long']}";
|
||||
$valid_options[] = " " . join( ", ", $optString ) . "\n\t" . wordwrap( $data['description'], 70, "\n\t" );
|
||||
}
|
||||
$valid_options = join( "\n", $valid_options );
|
||||
if ($valid_options) {
|
||||
$message .= <<< EOT
|
||||
|
||||
Options:
|
||||
|
||||
|
||||
$valid_options
|
||||
|
||||
EOT;
|
||||
}
|
||||
echo $message . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the CLI task, which will check which command is specified and run it.
|
||||
*/
|
||||
public static function run() {
|
||||
CLI::taskName("help");
|
||||
CLI::taskRun(array('self', 'help'));
|
||||
global $argv;
|
||||
$args = $argv;
|
||||
$cliname = array_shift($args);
|
||||
$taskName = array_shift($args);
|
||||
while ($taskName{0} == '-')
|
||||
$taskName = array_shift($args);
|
||||
if (!$taskName) {
|
||||
echo self::error("Specify a task from the list below.") . "\n\n";
|
||||
self::help(NULL, NULL);
|
||||
return;
|
||||
}
|
||||
$taskData = NULL;
|
||||
foreach (self::$tasks as $name => $data) {
|
||||
if (strcasecmp($name, $taskName) === 0) {
|
||||
$taskData = $data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$taskData) {
|
||||
echo self::error("Command not found: '$taskName'") . "\n\n";
|
||||
self::help(NULL, NULL);
|
||||
return;
|
||||
}
|
||||
G::LoadThirdParty('pear/Console', 'Getopt');
|
||||
$short = "h" . $taskData['opt']['short'];
|
||||
$long = array_merge(array("help"), $taskData['opt']['long']);
|
||||
$getopt = Console_GetOpt::getopt2($args, $short, $long);
|
||||
if (!is_array($getopt)) {
|
||||
echo self::error("Invalid options (" . $getopt->getMessage() . ")") . "\n\n";
|
||||
self::help($taskName);
|
||||
return;
|
||||
}
|
||||
list($options, $arguments) = $getopt;
|
||||
foreach ($taskData['opt']['descriptions'] as $optName => $optDescription) {
|
||||
$short = str_replace(":", "", $optDescription['short']);
|
||||
$long = str_replace("=", "", $optDescription['long']);
|
||||
$validOpts[$short] = $optName;
|
||||
$validOpts[$long] = $optName;
|
||||
}
|
||||
$taskOpts = array();
|
||||
try {
|
||||
foreach ($options as $opt) {
|
||||
list($optName, $optArg) = $opt;
|
||||
if ($optName === "h" || $optName === "--help") {
|
||||
self::help($taskName);
|
||||
return;
|
||||
}
|
||||
echo $message . "\n";
|
||||
}
|
||||
if (strpos($optName, '--') === 0)
|
||||
$optName = substr($optName, 2);
|
||||
if (!array_key_exists($optName, $validOpts))
|
||||
throw new Exception("option not found: $optName");
|
||||
if (array_key_exists($validOpts[$optName], $taskOpts))
|
||||
throw new Exception("'$optName' specified more then once");
|
||||
$taskOpts[$validOpts[$optName]] = $optArg;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo self::error("Invalid options: " . $e->getMessage()) . "\n\n";
|
||||
self::help($taskName);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
call_user_func($taskData['function'], $arguments, $taskOpts);
|
||||
} catch (Exception $e) {
|
||||
echo self::error("\n Error executing '$taskName':\n\n {$e->getMessage()}\n") . "\n";
|
||||
|
||||
/**
|
||||
* Run the CLI task, which will check which command is specified and run it.
|
||||
*/
|
||||
public static function run ()
|
||||
{
|
||||
CLI::taskName( "help" );
|
||||
CLI::taskRun( array ('self','help'
|
||||
) );
|
||||
global $argv;
|
||||
$args = $argv;
|
||||
$cliname = array_shift( $args );
|
||||
$taskName = array_shift( $args );
|
||||
while ($taskName{0} == '-')
|
||||
$taskName = array_shift( $args );
|
||||
if (! $taskName) {
|
||||
echo self::error( "Specify a task from the list below." ) . "\n\n";
|
||||
self::help( NULL, NULL );
|
||||
return;
|
||||
}
|
||||
$taskData = NULL;
|
||||
foreach (self::$tasks as $name => $data) {
|
||||
if (strcasecmp( $name, $taskName ) === 0) {
|
||||
$taskData = $data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! $taskData) {
|
||||
echo self::error( "Command not found: '$taskName'" ) . "\n\n";
|
||||
self::help( NULL, NULL );
|
||||
return;
|
||||
}
|
||||
G::LoadThirdParty( 'pear/Console', 'Getopt' );
|
||||
$short = "h" . $taskData['opt']['short'];
|
||||
$long = array_merge( array ("help"
|
||||
), $taskData['opt']['long'] );
|
||||
$getopt = Console_GetOpt::getopt2( $args, $short, $long );
|
||||
if (! is_array( $getopt )) {
|
||||
echo self::error( "Invalid options (" . $getopt->getMessage() . ")" ) . "\n\n";
|
||||
self::help( $taskName );
|
||||
return;
|
||||
}
|
||||
list ($options, $arguments) = $getopt;
|
||||
foreach ($taskData['opt']['descriptions'] as $optName => $optDescription) {
|
||||
$short = str_replace( ":", "", $optDescription['short'] );
|
||||
$long = str_replace( "=", "", $optDescription['long'] );
|
||||
$validOpts[$short] = $optName;
|
||||
$validOpts[$long] = $optName;
|
||||
}
|
||||
$taskOpts = array ();
|
||||
try {
|
||||
foreach ($options as $opt) {
|
||||
list ($optName, $optArg) = $opt;
|
||||
if ($optName === "h" || $optName === "--help") {
|
||||
self::help( $taskName );
|
||||
return;
|
||||
}
|
||||
if (strpos( $optName, '--' ) === 0)
|
||||
$optName = substr( $optName, 2 );
|
||||
if (! array_key_exists( $optName, $validOpts ))
|
||||
throw new Exception( "option not found: $optName" );
|
||||
if (array_key_exists( $validOpts[$optName], $taskOpts ))
|
||||
throw new Exception( "'$optName' specified more then once" );
|
||||
$taskOpts[$validOpts[$optName]] = $optArg;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo self::error( "Invalid options: " . $e->getMessage() ) . "\n\n";
|
||||
self::help( $taskName );
|
||||
return;
|
||||
}
|
||||
try {
|
||||
call_user_func( $taskData['function'], $arguments, $taskOpts );
|
||||
} catch (Exception $e) {
|
||||
echo self::error( "\n Error executing '$taskName':\n\n {$e->getMessage()}\n" ) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an information colorized version of the message.
|
||||
*
|
||||
* @param string $message the message to colorize
|
||||
*/
|
||||
public static function info($message) {
|
||||
return pakeColor::colorize($message, "INFO");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a warning colorized version of the message.
|
||||
*
|
||||
* @param string $message the message to colorize
|
||||
*/
|
||||
public static function warning($message) {
|
||||
return pakeColor::colorize($message, "COMMENT");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an error colorized version of the message.
|
||||
*
|
||||
* @param string $message the message to colorize
|
||||
*/
|
||||
public static function error($message) {
|
||||
return pakeColor::colorize($message, "ERROR");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user for information.
|
||||
*
|
||||
* @param string $message the message to display
|
||||
* @return string the text typed by the user
|
||||
*/
|
||||
public static function prompt($message) {
|
||||
echo "$message";
|
||||
$handle = fopen ("php://stdin","r");
|
||||
$line = fgets($handle);
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask a question of yes or no.
|
||||
*
|
||||
* @param string $message the message to display
|
||||
* @return bool true if the user choosed no, false otherwise
|
||||
*/
|
||||
public static function question($message) {
|
||||
$input = strtolower(self::prompt("$message [Y/n] "));
|
||||
return (array_search(trim($input), array("y", "")) !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a message to the user. If filename is specified, it will setup
|
||||
* a logging file where all messages will be recorded.
|
||||
*
|
||||
* @param string $message the message to display
|
||||
* @param string $filename the log file to write messages
|
||||
*/
|
||||
public static function logging($message, $filename = NULL) {
|
||||
static $log_file = NULL;
|
||||
if (isset($filename)) {
|
||||
$log_file = fopen($filename, "a");
|
||||
fwrite($log_file, " -- " . date("c") . " " . $message . " --\n");
|
||||
} else {
|
||||
if (isset($log_file))
|
||||
fwrite($log_file, $message);
|
||||
echo $message;
|
||||
/**
|
||||
* Returns an information colorized version of the message.
|
||||
*
|
||||
* @param string $message the message to colorize
|
||||
*/
|
||||
public static function info ($message)
|
||||
{
|
||||
return pakeColor::colorize( $message, "INFO" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a warning colorized version of the message.
|
||||
*
|
||||
* @param string $message the message to colorize
|
||||
*/
|
||||
public static function warning ($message)
|
||||
{
|
||||
return pakeColor::colorize( $message, "COMMENT" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an error colorized version of the message.
|
||||
*
|
||||
* @param string $message the message to colorize
|
||||
*/
|
||||
public static function error ($message)
|
||||
{
|
||||
return pakeColor::colorize( $message, "ERROR" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user for information.
|
||||
*
|
||||
* @param string $message the message to display
|
||||
* @return string the text typed by the user
|
||||
*/
|
||||
public static function prompt ($message)
|
||||
{
|
||||
echo "$message";
|
||||
$handle = fopen( "php://stdin", "r" );
|
||||
$line = fgets( $handle );
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask a question of yes or no.
|
||||
*
|
||||
* @param string $message the message to display
|
||||
* @return bool true if the user choosed no, false otherwise
|
||||
*/
|
||||
public static function question ($message)
|
||||
{
|
||||
$input = strtolower( self::prompt( "$message [Y/n] " ) );
|
||||
return (array_search( trim( $input ), array ("y",""
|
||||
) ) !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a message to the user.
|
||||
* If filename is specified, it will setup
|
||||
* a logging file where all messages will be recorded.
|
||||
*
|
||||
* @param string $message the message to display
|
||||
* @param string $filename the log file to write messages
|
||||
*/
|
||||
public static function logging ($message, $filename = NULL)
|
||||
{
|
||||
static $log_file = NULL;
|
||||
if (isset( $filename )) {
|
||||
$log_file = fopen( $filename, "a" );
|
||||
fwrite( $log_file, " -- " . date( "c" ) . " " . $message . " --\n" );
|
||||
} else {
|
||||
if (isset( $log_file ))
|
||||
fwrite( $log_file, $message );
|
||||
echo $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* class.configuration.php
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
@@ -13,11 +14,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -31,528 +32,483 @@
|
||||
// License: LGPL, see LICENSE
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* ProcessConfiguration - ProcessConfiguration class
|
||||
* @author David S. Callizaya S.
|
||||
*
|
||||
* @author David S. Callizaya S.
|
||||
* @copyright 2007 COLOSA
|
||||
*/
|
||||
|
||||
require_once 'classes/model/Configuration.php';
|
||||
|
||||
|
||||
/**
|
||||
* Extends Configuration
|
||||
*
|
||||
*
|
||||
* @copyright 2007 COLOSA
|
||||
* @version Release: @package_version@
|
||||
* @package workflow.engine.ProcessMaker
|
||||
* @copyright 2007 COLOSA
|
||||
* @version Release: @package_version@
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
class Configurations // extends Configuration
|
||||
{
|
||||
var $aConfig = array();
|
||||
private $Configuration = null;
|
||||
private $UserConfig = null;
|
||||
var $aConfig = array ();
|
||||
private $Configuration = null;
|
||||
private $UserConfig = null;
|
||||
|
||||
/**
|
||||
* Set Configurations
|
||||
* @return void
|
||||
*/
|
||||
function Configurations()
|
||||
{
|
||||
$this->Configuration = new Configuration();
|
||||
}
|
||||
/**
|
||||
* Set Configurations
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function Configurations ()
|
||||
{
|
||||
$this->Configuration = new Configuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* arrayClone
|
||||
*
|
||||
* @param array &$object Source array
|
||||
* @param array &$cloneObject Array duplicate
|
||||
* @return void
|
||||
*/
|
||||
function arrayClone( &$object, &$cloneObject )
|
||||
{
|
||||
if (is_array($object)) {
|
||||
foreach($object as $k => $v ) {
|
||||
$cloneObject[$k] = NULL;
|
||||
$this->arrayClone( $object[$k], $cloneObject[$k] );
|
||||
}
|
||||
} else {
|
||||
if (is_object($object)) {
|
||||
/**
|
||||
* arrayClone
|
||||
*
|
||||
* @param array &$object Source array
|
||||
* @param array &$cloneObject Array duplicate
|
||||
* @return void
|
||||
*/
|
||||
function arrayClone (&$object, &$cloneObject)
|
||||
{
|
||||
if (is_array( $object )) {
|
||||
foreach ($object as $k => $v) {
|
||||
$cloneObject[$k] = NULL;
|
||||
$this->arrayClone( $object[$k], $cloneObject[$k] );
|
||||
}
|
||||
} else {
|
||||
$cloneObject=NULL;
|
||||
if (is_object( $object )) {
|
||||
} else {
|
||||
$cloneObject = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* configObject
|
||||
*
|
||||
* @param object &$object
|
||||
* @param array &$from
|
||||
* @return void
|
||||
*/
|
||||
function configObject( &$object, &$from )
|
||||
{
|
||||
if (!(is_object($object) || is_array($object)))
|
||||
return;
|
||||
/**
|
||||
* configObject
|
||||
*
|
||||
* @param object &$object
|
||||
* @param array &$from
|
||||
* @return void
|
||||
*/
|
||||
function configObject (&$object, &$from)
|
||||
{
|
||||
if (! (is_object( $object ) || is_array( $object )))
|
||||
return;
|
||||
|
||||
if (!isset($from))
|
||||
$from = &$this->aConfig;
|
||||
if (! isset( $from ))
|
||||
$from = &$this->aConfig;
|
||||
|
||||
foreach($from as $k => $v ) {
|
||||
if (isset($v) && array_key_exists($k,$object)) {
|
||||
if (is_object($v))
|
||||
throw new Exception( 'Object is not permited inside configuration array.' );
|
||||
foreach ($from as $k => $v) {
|
||||
if (isset( $v ) && array_key_exists( $k, $object )) {
|
||||
if (is_object( $v ))
|
||||
throw new Exception( 'Object is not permited inside configuration array.' );
|
||||
|
||||
if (is_object($object)) {
|
||||
if (is_array($v))
|
||||
$this->configObject($object->{$k}, $v);
|
||||
else
|
||||
$object->{$k} = $v;
|
||||
if (is_object( $object )) {
|
||||
if (is_array( $v ))
|
||||
$this->configObject( $object->{$k}, $v );
|
||||
else
|
||||
$object->{$k} = $v;
|
||||
} else {
|
||||
if (is_array( $object )) {
|
||||
if (is_array( $v ))
|
||||
$this->configObject( $object[$k], $v );
|
||||
else
|
||||
$object[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_array($object)) {
|
||||
if (is_array($v))
|
||||
$this->configObject($object[$k], $v);
|
||||
else
|
||||
$object[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loadConfig
|
||||
*
|
||||
* @param object &$object
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function loadConfig (&$object, $cfg, $obj = '', $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$this->load( $cfg, $obj, $pro, $usr, $app );
|
||||
$this->configObject( $object, $this->aConfig );
|
||||
}
|
||||
|
||||
/**
|
||||
* loadConf
|
||||
*
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function load ($cfg, $obj = '', $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$this->Fields = array ();
|
||||
|
||||
try {
|
||||
$this->Fields = $this->Configuration->load( $cfg, $obj, $pro, $usr, $app );
|
||||
} catch (Exception $e) {
|
||||
} // the configuration does not exist
|
||||
|
||||
|
||||
if (isset( $this->Fields['CFG_VALUE'] ))
|
||||
$this->aConfig = unserialize( $this->Fields['CFG_VALUE'] );
|
||||
|
||||
if (! is_array( $this->aConfig ))
|
||||
$this->aConfig = Array ();
|
||||
|
||||
return $this->aConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* saveConfig
|
||||
*
|
||||
* @param object &$object
|
||||
* @param array &$from
|
||||
* @return void
|
||||
*/
|
||||
function saveConfig ($cfg, $obj, $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$aFields = array ('CFG_UID' => $cfg,'OBJ_UID' => $obj,'PRO_UID' => $pro,'USR_UID' => $usr,'APP_UID' => $app,'CFG_VALUE' => serialize( $this->aConfig )
|
||||
);
|
||||
if ($this->Configuration->exists( $cfg, $obj, $pro, $usr, $app )) {
|
||||
$this->Configuration->update( $aFields );
|
||||
} else {
|
||||
$this->Configuration->create( $aFields );
|
||||
$this->Configuration->update( $aFields );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loadConfig
|
||||
*
|
||||
* @param object &$object
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function loadConfig(&$object, $cfg, $obj='', $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$this->load($cfg, $obj, $pro, $usr, $app);
|
||||
$this->configObject($object, $this->aConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* loadConf
|
||||
*
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function load($cfg, $obj='', $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$this->Fields = array();
|
||||
|
||||
try {
|
||||
$this->Fields = $this->Configuration->load($cfg, $obj, $pro, $usr, $app);
|
||||
}
|
||||
catch(Exception $e) {} // the configuration does not exist
|
||||
|
||||
if (isset($this->Fields['CFG_VALUE']))
|
||||
$this->aConfig = unserialize($this->Fields['CFG_VALUE']);
|
||||
|
||||
if (!is_array($this->aConfig))
|
||||
$this->aConfig = Array();
|
||||
|
||||
return $this->aConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* saveConfig
|
||||
*
|
||||
* @param object &$object
|
||||
* @param array &$from
|
||||
* @return void
|
||||
*/
|
||||
function saveConfig($cfg,$obj,$pro='',$usr='',$app='')
|
||||
{
|
||||
$aFields = array(
|
||||
'CFG_UID' => $cfg,
|
||||
'OBJ_UID' => $obj,
|
||||
'PRO_UID' => $pro,
|
||||
'USR_UID' => $usr,
|
||||
'APP_UID' => $app,
|
||||
'CFG_VALUE' => serialize($this->aConfig)
|
||||
);
|
||||
if ($this->Configuration->exists($cfg,$obj,$pro,$usr,$app)) {
|
||||
$this->Configuration->update($aFields);
|
||||
} else {
|
||||
$this->Configuration->create($aFields);
|
||||
$this->Configuration->update($aFields);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* saveObject
|
||||
*
|
||||
* @param object &$object
|
||||
* @param array &$from
|
||||
* @return void
|
||||
*/
|
||||
function saveObject(&$object,$cfg,$obj,$pro='',$usr='',$app='')
|
||||
{
|
||||
$aFields = array(
|
||||
'CFG_UID' => $cfg,
|
||||
'OBJ_UID' => $obj,
|
||||
'PRO_UID' => $pro,
|
||||
'USR_UID' => $usr,
|
||||
'APP_UID' => $app,
|
||||
'CFG_VALUE' => serialize(array(&$object))
|
||||
);
|
||||
if ($this->Configuration->exists($cfg,$obj,$pro,$usr,$app)) {
|
||||
$this->Configuration->update($aFields);
|
||||
} else {
|
||||
$this->Configuration->create($aFields);
|
||||
$this->Configuration->update($aFields);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loadObject
|
||||
* this function is deprecated, we dont know why return an object, use the function getConfiguration below
|
||||
*
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function loadObject($cfg, $obj, $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$objectContainer=array((object) array());
|
||||
$this->Fields = array();
|
||||
if ($this->Configuration->exists( $cfg, $obj, $pro, $usr, $app ))
|
||||
$this->Fields = $this->Configuration->load( $cfg, $obj, $pro, $usr, $app );
|
||||
else
|
||||
return $objectContainer[0];
|
||||
|
||||
if (isset($this->Fields['CFG_VALUE']))
|
||||
$objectContainer = unserialize($this->Fields['CFG_VALUE']);
|
||||
if (!is_array($objectContainer)||sizeof($objectContainer)!=1)
|
||||
return (object) array();
|
||||
else
|
||||
return $objectContainer[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* getConfiguration
|
||||
*
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function getConfiguration($cfg, $obj, $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
try {
|
||||
$oCfg = ConfigurationPeer::retrieveByPK( $cfg, $obj, $pro, $usr, $app );
|
||||
if (!is_null($oCfg)) {
|
||||
$row = $oCfg->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$result = unserialize($row['CFG_VALUE']);
|
||||
if ( is_array($result) && sizeof($result)==1 ) {
|
||||
$arrayKeys = Array_keys( $result );
|
||||
return $result[ $arrayKeys[0]];
|
||||
/**
|
||||
* saveObject
|
||||
*
|
||||
* @param object &$object
|
||||
* @param array &$from
|
||||
* @return void
|
||||
*/
|
||||
function saveObject (&$object, $cfg, $obj, $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$aFields = array ('CFG_UID' => $cfg,'OBJ_UID' => $obj,'PRO_UID' => $pro,'USR_UID' => $usr,'APP_UID' => $app,'CFG_VALUE' => serialize( array (&$object
|
||||
) )
|
||||
);
|
||||
if ($this->Configuration->exists( $cfg, $obj, $pro, $usr, $app )) {
|
||||
$this->Configuration->update( $aFields );
|
||||
} else {
|
||||
$this->Configuration->create( $aFields );
|
||||
$this->Configuration->update( $aFields );
|
||||
}
|
||||
else {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* loadObject
|
||||
* this function is deprecated, we dont know why return an object, use the function getConfiguration below
|
||||
*
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function loadObject ($cfg, $obj, $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
$objectContainer = array ((object) array ()
|
||||
);
|
||||
$this->Fields = array ();
|
||||
if ($this->Configuration->exists( $cfg, $obj, $pro, $usr, $app ))
|
||||
$this->Fields = $this->Configuration->load( $cfg, $obj, $pro, $usr, $app );
|
||||
else
|
||||
return $objectContainer[0];
|
||||
|
||||
if (isset( $this->Fields['CFG_VALUE'] ))
|
||||
$objectContainer = unserialize( $this->Fields['CFG_VALUE'] );
|
||||
if (! is_array( $objectContainer ) || sizeof( $objectContainer ) != 1)
|
||||
return (object) array ();
|
||||
else
|
||||
return $objectContainer[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* getConfiguration
|
||||
*
|
||||
* @param string $cfg
|
||||
* @param object $obj
|
||||
* @param string $pro
|
||||
* @param string $usr
|
||||
* @param string $app
|
||||
* @return void
|
||||
*/
|
||||
function getConfiguration ($cfg, $obj, $pro = '', $usr = '', $app = '')
|
||||
{
|
||||
try {
|
||||
$oCfg = ConfigurationPeer::retrieveByPK( $cfg, $obj, $pro, $usr, $app );
|
||||
if (! is_null( $oCfg )) {
|
||||
$row = $oCfg->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$result = unserialize( $row['CFG_VALUE'] );
|
||||
if (is_array( $result ) && sizeof( $result ) == 1) {
|
||||
$arrayKeys = Array_keys( $result );
|
||||
return $result[$arrayKeys[0]];
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
return null;
|
||||
|
||||
/**
|
||||
* usersNameFormat
|
||||
*
|
||||
* @author Enrique Ponce de Leon enrique@colosa.com
|
||||
* @param string $username
|
||||
* @param string $firstname
|
||||
* @param string $lastname
|
||||
* @return string User Name Well-Formatted
|
||||
*/
|
||||
|
||||
function usersNameFormat ($username, $firstname, $lastname)
|
||||
{
|
||||
try {
|
||||
if (! isset( $this->UserConfig ))
|
||||
$this->UserConfig = $this->getConfiguration( 'ENVIRONMENT_SETTINGS', '' );
|
||||
if (isset( $this->UserConfig['format'] )) {
|
||||
$aux = '';
|
||||
$aux = str_replace( '@userName', $username, $this->UserConfig['format'] );
|
||||
$aux = str_replace( '@firstName', $firstname, $aux );
|
||||
$aux = str_replace( '@lastName', $lastname, $aux );
|
||||
return $aux;
|
||||
} else {
|
||||
return $username;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* usersNameFormat
|
||||
* @author Enrique Ponce de Leon enrique@colosa.com
|
||||
* @param string $username
|
||||
* @param string $firstname
|
||||
* @param string $lastname
|
||||
* @return string User Name Well-Formatted
|
||||
*/
|
||||
|
||||
function usersNameFormat($username, $firstname, $lastname){
|
||||
try{
|
||||
if (!isset($this->UserConfig)) $this->UserConfig = $this->getConfiguration('ENVIRONMENT_SETTINGS', '');
|
||||
if (isset($this->UserConfig['format'])){
|
||||
$aux = '';
|
||||
$aux = str_replace('@userName', $username, $this->UserConfig['format']);
|
||||
$aux = str_replace('@firstName', $firstname, $aux);
|
||||
$aux = str_replace('@lastName', $lastname, $aux);
|
||||
return $aux;
|
||||
}else{
|
||||
return $username;
|
||||
}
|
||||
}catch(Exception $oError){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getFormats
|
||||
*
|
||||
* @author Enrique Ponce de Leon enrique@colosa.com
|
||||
* @return FORMATS array
|
||||
*/
|
||||
public function getFormats()
|
||||
public function getFormats ()
|
||||
{
|
||||
if (!isset($this->UserConfig)) {
|
||||
$this->UserConfig = $this->getConfiguration("ENVIRONMENT_SETTINGS", "");
|
||||
if (! isset( $this->UserConfig )) {
|
||||
$this->UserConfig = $this->getConfiguration( "ENVIRONMENT_SETTINGS", "" );
|
||||
}
|
||||
|
||||
//Setting defaults
|
||||
if (!isset($this->UserConfig["format"])) {
|
||||
if (! isset( $this->UserConfig["format"] )) {
|
||||
$this->UserConfig["format"] = "@lastName, @firstName (@userName)";
|
||||
}
|
||||
|
||||
if (!isset($this->UserConfig["dateFormat"])) {
|
||||
if (! isset( $this->UserConfig["dateFormat"] )) {
|
||||
$this->UserConfig["dateFormat"] = "Y-m-d H:i:s";
|
||||
}
|
||||
|
||||
if (!isset($this->UserConfig["startCaseHideProcessInf"])) {
|
||||
if (! isset( $this->UserConfig["startCaseHideProcessInf"] )) {
|
||||
$this->UserConfig["startCaseHideProcessInf"] = false;
|
||||
}
|
||||
|
||||
if (!isset($this->UserConfig["casesListDateFormat"])) {
|
||||
if (! isset( $this->UserConfig["casesListDateFormat"] )) {
|
||||
$this->UserConfig["casesListDateFormat"] = "Y-m-d H:i:s";
|
||||
}
|
||||
|
||||
if (!isset($this->UserConfig["casesListRowNumber"])) {
|
||||
if (! isset( $this->UserConfig["casesListRowNumber"] )) {
|
||||
$this->UserConfig["casesListRowNumber"] = 25;
|
||||
}
|
||||
|
||||
if (!isset($this->UserConfig["casesListRefreshTime"]) ||
|
||||
(isset($this->UserConfig["casesListRefreshTime"]) && empty($this->UserConfig["casesListRefreshTime"]))
|
||||
) {
|
||||
if (! isset( $this->UserConfig["casesListRefreshTime"] ) || (isset( $this->UserConfig["casesListRefreshTime"] ) && empty( $this->UserConfig["casesListRefreshTime"] ))) {
|
||||
$this->UserConfig["casesListRefreshTime"] = 120; //2 minutes
|
||||
}
|
||||
|
||||
$this->UserConfig["TimeZone"] = date("T");
|
||||
$this->UserConfig["TimeZone"] = date( "T" );
|
||||
|
||||
return $this->UserConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* setConfig
|
||||
*
|
||||
* @param string $route
|
||||
* @param object &$object
|
||||
* @param object &$to
|
||||
* @return void
|
||||
*/
|
||||
function setConfig( $route , &$object , &$to )
|
||||
{
|
||||
if (!isset($to))
|
||||
$to = &$this->aConfig;
|
||||
$routes = explode(',',$route);
|
||||
foreach($routes as $r) {
|
||||
$ro = explode('/',$r);
|
||||
if (count($ro)>1) {
|
||||
$rou = $ro;
|
||||
unset($rou[0]);
|
||||
if ($ro[0]==='*') {
|
||||
foreach($object as $k => $v ) {
|
||||
if (is_object($object)) {
|
||||
if (!isset($to[$k]))
|
||||
$to[$k] = array();
|
||||
$this->setConfig(implode('/',$rou),$object->{$k},$to[$k]);
|
||||
} else {
|
||||
if (is_array($object)) {
|
||||
if (!isset($to[$k]))
|
||||
$to[$k] = array();
|
||||
$this->setConfig(implode('/',$rou),$object[$k],$to[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_object($object)) {
|
||||
if (!isset($to[$ro[0]]))
|
||||
$to[$ro[0]] = array();
|
||||
$this->setConfig(implode('/',$rou),$object->{$ro[0]},$to[$ro[0]]);
|
||||
} else {
|
||||
if (is_array($object)) {
|
||||
if (!isset($to[$ro[0]]))
|
||||
$to[$ro[0]] = array();
|
||||
$this->setConfig(implode('/',$rou),$object[$ro[0]],$to[$ro[0]]);
|
||||
} else {
|
||||
$to = $object;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* setConfig
|
||||
*
|
||||
* @param string $route
|
||||
* @param object &$object
|
||||
* @param object &$to
|
||||
* @return void
|
||||
*/
|
||||
function setConfig ($route, &$object, &$to)
|
||||
{
|
||||
if (! isset( $to ))
|
||||
$to = &$this->aConfig;
|
||||
$routes = explode( ',', $route );
|
||||
foreach ($routes as $r) {
|
||||
$ro = explode( '/', $r );
|
||||
if (count( $ro ) > 1) {
|
||||
$rou = $ro;
|
||||
unset( $rou[0] );
|
||||
if ($ro[0] === '*') {
|
||||
foreach ($object as $k => $v) {
|
||||
if (is_object( $object )) {
|
||||
if (! isset( $to[$k] ))
|
||||
$to[$k] = array ();
|
||||
$this->setConfig( implode( '/', $rou ), $object->{$k}, $to[$k] );
|
||||
} else {
|
||||
if (is_array( $object )) {
|
||||
if (! isset( $to[$k] ))
|
||||
$to[$k] = array ();
|
||||
$this->setConfig( implode( '/', $rou ), $object[$k], $to[$k] );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_object( $object )) {
|
||||
if (! isset( $to[$ro[0]] ))
|
||||
$to[$ro[0]] = array ();
|
||||
$this->setConfig( implode( '/', $rou ), $object->{$ro[0]}, $to[$ro[0]] );
|
||||
} else {
|
||||
if (is_array( $object )) {
|
||||
if (! isset( $to[$ro[0]] ))
|
||||
$to[$ro[0]] = array ();
|
||||
$this->setConfig( implode( '/', $rou ), $object[$ro[0]], $to[$ro[0]] );
|
||||
} else {
|
||||
$to = $object;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if ($ro[0] === '*') {
|
||||
foreach ($object as $k => $v) {
|
||||
if (is_object( $object )) {
|
||||
if (! isset( $to[$k] ))
|
||||
$to[$k] = array ();
|
||||
$to[$k] = $object->{$k};
|
||||
} else {
|
||||
if (is_array( $object )) {
|
||||
if (! isset( $to[$k] ))
|
||||
$to[$k] = array ();
|
||||
$to[$k] = $object[$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (! isset( $to[$r] ))
|
||||
$to[$r] = array ();
|
||||
if (is_object( $object )) {
|
||||
$to[$r] = $object->{$r};
|
||||
} elseif (is_array( $object )) {
|
||||
$to[$r] = $object[$r];
|
||||
} else {
|
||||
$to[$r] = $object;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($ro[0]==='*') {
|
||||
foreach($object as $k => $v ) {
|
||||
if (is_object($object)) {
|
||||
if (!isset($to[$k]))
|
||||
$to[$k] = array();
|
||||
$to[$k] = $object->{$k};
|
||||
} else {
|
||||
if (is_array($object)) {
|
||||
if (!isset($to[$k]))
|
||||
$to[$k] = array();
|
||||
$to[$k] = $object[$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!isset($to[$r]))
|
||||
$to[$r] = array();
|
||||
if (is_object($object)) {
|
||||
$to[$r] = $object->{$r};
|
||||
} elseif (is_array($object)) {
|
||||
$to[$r] = $object[$r];
|
||||
} else {
|
||||
$to[$r] = $object;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getDateFormats(){
|
||||
$formats[] = Array(
|
||||
'id'=>'Y-m-d H:i:s', //the id , don't translate
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_1') //'Y-m-d H:i:s' i.e: '2010-11-17 10:25:07'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'d/m/Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_2') //'d/m/Y' i.e:'17/11/2010'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'m/d/Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_3')//'m/d/Y' i.e:'11/17/2010'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'Y/d/m',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_4')//'Y/d/m' i.e:'2010/17/11'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'Y/m/d',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_5')//'Y/m/d' i.e:'2010/11/17'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'F j, Y, g:i a',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_6')//'F j, Y, g:i a' i.e:'November 17, 2010, 10:45 am'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'m.d.y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_7')//'m.d.y' i.e: '11.17.10'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'j, n, Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_8')//'j, n, Y' i.e:'17,11,2010'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'D M j G:i:s T Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_9')//'D M j G:i:s T Y' i.e:'Thu Nov 17 10:48:18 BOT 2010'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'D d M, Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_10')//'D d M, Y' i.e:'Thu 17 Nov, 2010'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'D M, Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_11')//'D M, Y' i.e:'Thu Nov, 2010'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'d M, Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_12')//'d M, Y' i.e:'17 Nov, 2010'
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'d m, Y',
|
||||
'name'=>G::loadTranslation('ID_DATE_FORMAT_13')//'d m, Y' i.e:'17 11, 2010'
|
||||
);
|
||||
|
||||
return $formats;
|
||||
}
|
||||
|
||||
function getUserNameFormats(){
|
||||
$formats[] = Array(
|
||||
'id'=>'@firstName @lastName', //the id , don't translate
|
||||
'name'=>G::loadTranslation('ID_USERNAME_FORMAT_1') //label displayed, can be translated
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'@firstName @lastName (@userName)',
|
||||
'name'=>G::loadTranslation('ID_USERNAME_FORMAT_2')
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'@userName',
|
||||
'name'=>G::loadTranslation('ID_USERNAME_FORMAT_3')
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'@userName (@firstName @lastName)',
|
||||
'name'=>G::loadTranslation('ID_USERNAME_FORMAT_4')
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'@lastName @firstName',
|
||||
'name'=>G::loadTranslation('ID_USERNAME_FORMAT_5')
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'@lastName, @firstName',
|
||||
'name'=>G::loadTranslation('ID_USERNAME_FORMAT_6')
|
||||
);
|
||||
$formats[] = Array(
|
||||
'id'=>'@lastName, @firstName (@userName)',
|
||||
'name'=>G::loadTranslation('ID_USERNAME_FORMAT_7')
|
||||
);
|
||||
|
||||
return $formats;
|
||||
}
|
||||
|
||||
function getSystemDate($dateTime)
|
||||
{
|
||||
$oConf = new Configurations;
|
||||
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS','');
|
||||
$creationDateMask = isset($oConf->aConfig['dateFormat'])? $oConf->aConfig['dateFormat']: '';
|
||||
|
||||
if( $creationDateMask != '' ) {
|
||||
if( strpos($dateTime, ' ') !== false ) {
|
||||
list($date, $time) = explode(' ', $dateTime);
|
||||
list($y, $m, $d) = explode('-', $date);
|
||||
list($h, $i, $s) = explode(':', $time);
|
||||
$dateTime = date($creationDateMask, mktime($h, $i, $s, $m, $d, $y));
|
||||
} else {
|
||||
list($y, $m, $d) = explode('-', $dateTime);
|
||||
$dateTime = date($creationDateMask, mktime(0, 0, 0, $m, $d, $y));
|
||||
}
|
||||
}
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
function getDateFormats ()
|
||||
{
|
||||
$formats[] = Array ('id' => 'Y-m-d H:i:s', //the id , don't translate
|
||||
'name' => G::loadTranslation( 'ID_DATE_FORMAT_1' ) //'Y-m-d H:i:s' i.e: '2010-11-17 10:25:07'
|
||||
);
|
||||
$formats[] = Array ('id' => 'd/m/Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_2' ) //'d/m/Y' i.e:'17/11/2010'
|
||||
);
|
||||
$formats[] = Array ('id' => 'm/d/Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_3' ) //'m/d/Y' i.e:'11/17/2010'
|
||||
);
|
||||
$formats[] = Array ('id' => 'Y/d/m','name' => G::loadTranslation( 'ID_DATE_FORMAT_4' ) //'Y/d/m' i.e:'2010/17/11'
|
||||
);
|
||||
$formats[] = Array ('id' => 'Y/m/d','name' => G::loadTranslation( 'ID_DATE_FORMAT_5' ) //'Y/m/d' i.e:'2010/11/17'
|
||||
);
|
||||
$formats[] = Array ('id' => 'F j, Y, g:i a','name' => G::loadTranslation( 'ID_DATE_FORMAT_6' ) //'F j, Y, g:i a' i.e:'November 17, 2010, 10:45 am'
|
||||
);
|
||||
$formats[] = Array ('id' => 'm.d.y','name' => G::loadTranslation( 'ID_DATE_FORMAT_7' ) //'m.d.y' i.e: '11.17.10'
|
||||
);
|
||||
$formats[] = Array ('id' => 'j, n, Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_8' ) //'j, n, Y' i.e:'17,11,2010'
|
||||
);
|
||||
$formats[] = Array ('id' => 'D M j G:i:s T Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_9' ) //'D M j G:i:s T Y' i.e:'Thu Nov 17 10:48:18 BOT 2010'
|
||||
);
|
||||
$formats[] = Array ('id' => 'D d M, Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_10' ) //'D d M, Y' i.e:'Thu 17 Nov, 2010'
|
||||
);
|
||||
$formats[] = Array ('id' => 'D M, Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_11' ) //'D M, Y' i.e:'Thu Nov, 2010'
|
||||
);
|
||||
$formats[] = Array ('id' => 'd M, Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_12' ) //'d M, Y' i.e:'17 Nov, 2010'
|
||||
);
|
||||
$formats[] = Array ('id' => 'd m, Y','name' => G::loadTranslation( 'ID_DATE_FORMAT_13' ) //'d m, Y' i.e:'17 11, 2010'
|
||||
);
|
||||
|
||||
function getEnvSetting($key=null, $data=null)
|
||||
{
|
||||
$this->loadConfig($obj, 'ENVIRONMENT_SETTINGS','');
|
||||
return $formats;
|
||||
}
|
||||
|
||||
if( isset($key) ) {
|
||||
if( isset($this->aConfig[$key]) ) {
|
||||
if( isset($data) && is_array($data) )
|
||||
foreach($data as $k=>$v)
|
||||
$this->aConfig[$key] = str_replace('@'.$k, $v, $this->aConfig[$key]);
|
||||
function getUserNameFormats ()
|
||||
{
|
||||
$formats[] = Array ('id' => '@firstName @lastName', //the id , don't translate
|
||||
'name' => G::loadTranslation( 'ID_USERNAME_FORMAT_1' ) //label displayed, can be translated
|
||||
);
|
||||
$formats[] = Array ('id' => '@firstName @lastName (@userName)','name' => G::loadTranslation( 'ID_USERNAME_FORMAT_2' )
|
||||
);
|
||||
$formats[] = Array ('id' => '@userName','name' => G::loadTranslation( 'ID_USERNAME_FORMAT_3' )
|
||||
);
|
||||
$formats[] = Array ('id' => '@userName (@firstName @lastName)','name' => G::loadTranslation( 'ID_USERNAME_FORMAT_4' )
|
||||
);
|
||||
$formats[] = Array ('id' => '@lastName @firstName','name' => G::loadTranslation( 'ID_USERNAME_FORMAT_5' )
|
||||
);
|
||||
$formats[] = Array ('id' => '@lastName, @firstName','name' => G::loadTranslation( 'ID_USERNAME_FORMAT_6' )
|
||||
);
|
||||
$formats[] = Array ('id' => '@lastName, @firstName (@userName)','name' => G::loadTranslation( 'ID_USERNAME_FORMAT_7' )
|
||||
);
|
||||
|
||||
return $this->aConfig[$key];
|
||||
} else
|
||||
return '';
|
||||
} else
|
||||
return $this->aConfig;
|
||||
}
|
||||
return $formats;
|
||||
}
|
||||
|
||||
function getSystemDate ($dateTime)
|
||||
{
|
||||
$oConf = new Configurations();
|
||||
$oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
|
||||
$creationDateMask = isset( $oConf->aConfig['dateFormat'] ) ? $oConf->aConfig['dateFormat'] : '';
|
||||
|
||||
if ($creationDateMask != '') {
|
||||
if (strpos( $dateTime, ' ' ) !== false) {
|
||||
list ($date, $time) = explode( ' ', $dateTime );
|
||||
list ($y, $m, $d) = explode( '-', $date );
|
||||
list ($h, $i, $s) = explode( ':', $time );
|
||||
$dateTime = date( $creationDateMask, mktime( $h, $i, $s, $m, $d, $y ) );
|
||||
} else {
|
||||
list ($y, $m, $d) = explode( '-', $dateTime );
|
||||
$dateTime = date( $creationDateMask, mktime( 0, 0, 0, $m, $d, $y ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
|
||||
function getEnvSetting ($key = null, $data = null)
|
||||
{
|
||||
$this->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
|
||||
|
||||
if (isset( $key )) {
|
||||
if (isset( $this->aConfig[$key] )) {
|
||||
if (isset( $data ) && is_array( $data ))
|
||||
foreach ($data as $k => $v)
|
||||
$this->aConfig[$key] = str_replace( '@' . $k, $v, $this->aConfig[$key] );
|
||||
|
||||
return $this->aConfig[$key];
|
||||
} else
|
||||
return '';
|
||||
} else
|
||||
return $this->aConfig;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,236 +2,295 @@
|
||||
|
||||
require_once 'classes/interfaces/dashletInterface.php';
|
||||
|
||||
class dashletOpenVSCompleted implements DashletInterface {
|
||||
class dashletOpenVSCompleted implements DashletInterface
|
||||
{
|
||||
|
||||
const version = '1.0';
|
||||
const version = '1.0';
|
||||
|
||||
private $value;
|
||||
private $open;
|
||||
private $completed;
|
||||
private $centerLabel;
|
||||
private $redFrom;
|
||||
private $redTo;
|
||||
private $yellowFrom;
|
||||
private $yellowTo;
|
||||
private $greenFrom;
|
||||
private $greenTo;
|
||||
private $value;
|
||||
private $open;
|
||||
private $completed;
|
||||
private $centerLabel;
|
||||
private $redFrom;
|
||||
private $redTo;
|
||||
private $yellowFrom;
|
||||
private $yellowTo;
|
||||
private $greenFrom;
|
||||
private $greenTo;
|
||||
|
||||
public static function getAdditionalFields($className) {
|
||||
$additionalFields = array();
|
||||
public static function getAdditionalFields ($className)
|
||||
{
|
||||
$additionalFields = array ();
|
||||
|
||||
$contextTimeStore = new stdclass();
|
||||
$contextTimeStore->xtype = 'arraystore';
|
||||
$contextTimeStore->fields = array('id', 'value');
|
||||
$contextTimeStore->data = array(array('TODAY', 'Today'),
|
||||
array('YESTERDAY', 'Yesterday'),
|
||||
array('THIS_WEEK', 'This week'),
|
||||
array('PREVIOUS_WEEK', 'Previous Week'),
|
||||
array('THIS_MONTH', 'This Month'),
|
||||
array('PREVIOUS_MONTH', 'Previous Month'),
|
||||
array('THIS_YEAR', 'This Year'),
|
||||
array('PREVIOUS_YEAR', 'Previous Year'));
|
||||
$contextTimeStore = new stdclass();
|
||||
$contextTimeStore->xtype = 'arraystore';
|
||||
$contextTimeStore->fields = array ('id','value'
|
||||
);
|
||||
$contextTimeStore->data = array (array ('TODAY','Today'
|
||||
),array ('YESTERDAY','Yesterday'
|
||||
),array ('THIS_WEEK','This week'
|
||||
),array ('PREVIOUS_WEEK','Previous Week'
|
||||
),array ('THIS_MONTH','This Month'
|
||||
),array ('PREVIOUS_MONTH','Previous Month'
|
||||
),array ('THIS_YEAR','This Year'
|
||||
),array ('PREVIOUS_YEAR','Previous Year'
|
||||
)
|
||||
);
|
||||
|
||||
$contextTime = new stdclass();
|
||||
$contextTime->xtype = 'combo';
|
||||
$contextTime->name = 'DAS_INS_CONTEXT_TIME';
|
||||
$contextTime->fieldLabel = G::LoadTranslation('ID_PERIOD');
|
||||
$contextTime->editable = false;
|
||||
$contextTime->width = 320;
|
||||
$contextTime->store = $contextTimeStore;
|
||||
$contextTime->mode = 'local';
|
||||
$contextTime->triggerAction = 'all';
|
||||
$contextTime->valueField = 'id';
|
||||
$contextTime->displayField = 'value';
|
||||
$contextTime->value = 'TODAY';
|
||||
$additionalFields[] = $contextTime;
|
||||
$contextTime = new stdclass();
|
||||
$contextTime->xtype = 'combo';
|
||||
$contextTime->name = 'DAS_INS_CONTEXT_TIME';
|
||||
$contextTime->fieldLabel = G::LoadTranslation( 'ID_PERIOD' );
|
||||
$contextTime->editable = false;
|
||||
$contextTime->width = 320;
|
||||
$contextTime->store = $contextTimeStore;
|
||||
$contextTime->mode = 'local';
|
||||
$contextTime->triggerAction = 'all';
|
||||
$contextTime->valueField = 'id';
|
||||
$contextTime->displayField = 'value';
|
||||
$contextTime->value = 'TODAY';
|
||||
$additionalFields[] = $contextTime;
|
||||
|
||||
$redFrom = new stdclass();
|
||||
$redFrom->xtype = 'numberfield';
|
||||
$redFrom->name = 'DAS_RED_FROM';
|
||||
$redFrom->fieldLabel = G::LoadTranslation('ID_RED_STARTS_IN');
|
||||
$redFrom->width = 50;
|
||||
$redFrom->maxLength = 3;
|
||||
$redFrom->maxValue = 100;
|
||||
$redFrom->minValue = 0;
|
||||
$redFrom->allowBlank = false;
|
||||
$redFrom->value = 0;
|
||||
$additionalFields[] = $redFrom;
|
||||
$redFrom = new stdclass();
|
||||
$redFrom->xtype = 'numberfield';
|
||||
$redFrom->name = 'DAS_RED_FROM';
|
||||
$redFrom->fieldLabel = G::LoadTranslation( 'ID_RED_STARTS_IN' );
|
||||
$redFrom->width = 50;
|
||||
$redFrom->maxLength = 3;
|
||||
$redFrom->maxValue = 100;
|
||||
$redFrom->minValue = 0;
|
||||
$redFrom->allowBlank = false;
|
||||
$redFrom->value = 0;
|
||||
$additionalFields[] = $redFrom;
|
||||
|
||||
$redTo = new stdclass();
|
||||
$redTo->xtype = 'numberfield';
|
||||
$redTo->name = 'DAS_RED_TO';
|
||||
$redTo->fieldLabel = G::LoadTranslation('ID_RED_ENDS_IN');
|
||||
$redTo->width = 50;
|
||||
$redTo->maxLength = 3;
|
||||
$redTo->maxValue = 100;
|
||||
$redTo->minValue = 0;
|
||||
$redTo->allowBlank = false;
|
||||
$redTo->value = 30;
|
||||
$additionalFields[] = $redTo;
|
||||
$redTo = new stdclass();
|
||||
$redTo->xtype = 'numberfield';
|
||||
$redTo->name = 'DAS_RED_TO';
|
||||
$redTo->fieldLabel = G::LoadTranslation( 'ID_RED_ENDS_IN' );
|
||||
$redTo->width = 50;
|
||||
$redTo->maxLength = 3;
|
||||
$redTo->maxValue = 100;
|
||||
$redTo->minValue = 0;
|
||||
$redTo->allowBlank = false;
|
||||
$redTo->value = 30;
|
||||
$additionalFields[] = $redTo;
|
||||
|
||||
$yellowFrom = new stdclass();
|
||||
$yellowFrom->xtype = 'numberfield';
|
||||
$yellowFrom->name = 'DAS_YELLOW_FROM';
|
||||
$yellowFrom->fieldLabel = G::LoadTranslation('ID_YELLOW_STARTS_IN');
|
||||
$yellowFrom->width = 50;
|
||||
$yellowFrom->maxLength = 3;
|
||||
$yellowFrom->maxValue = 100;
|
||||
$yellowFrom->minValue = 0;
|
||||
$yellowFrom->allowBlank = false;
|
||||
$yellowFrom->value = 30;
|
||||
$additionalFields[] = $yellowFrom;
|
||||
$yellowFrom = new stdclass();
|
||||
$yellowFrom->xtype = 'numberfield';
|
||||
$yellowFrom->name = 'DAS_YELLOW_FROM';
|
||||
$yellowFrom->fieldLabel = G::LoadTranslation( 'ID_YELLOW_STARTS_IN' );
|
||||
$yellowFrom->width = 50;
|
||||
$yellowFrom->maxLength = 3;
|
||||
$yellowFrom->maxValue = 100;
|
||||
$yellowFrom->minValue = 0;
|
||||
$yellowFrom->allowBlank = false;
|
||||
$yellowFrom->value = 30;
|
||||
$additionalFields[] = $yellowFrom;
|
||||
|
||||
$yellowTo = new stdclass();
|
||||
$yellowTo->xtype = 'numberfield';
|
||||
$yellowTo->name = 'DAS_YELLOW_TO';
|
||||
$yellowTo->fieldLabel = G::LoadTranslation('ID_YELLOW_ENDS_IN');
|
||||
$yellowTo->width = 50;
|
||||
$yellowTo->maxLength = 3;
|
||||
$yellowTo->maxValue = 100;
|
||||
$yellowTo->minValue = 0;
|
||||
$yellowTo->allowBlank = false;
|
||||
$yellowTo->value = 50;
|
||||
$additionalFields[] = $yellowTo;
|
||||
$yellowTo = new stdclass();
|
||||
$yellowTo->xtype = 'numberfield';
|
||||
$yellowTo->name = 'DAS_YELLOW_TO';
|
||||
$yellowTo->fieldLabel = G::LoadTranslation( 'ID_YELLOW_ENDS_IN' );
|
||||
$yellowTo->width = 50;
|
||||
$yellowTo->maxLength = 3;
|
||||
$yellowTo->maxValue = 100;
|
||||
$yellowTo->minValue = 0;
|
||||
$yellowTo->allowBlank = false;
|
||||
$yellowTo->value = 50;
|
||||
$additionalFields[] = $yellowTo;
|
||||
|
||||
$greenFrom = new stdclass();
|
||||
$greenFrom->xtype = 'numberfield';
|
||||
$greenFrom->name = 'DAS_GREEN_FROM';
|
||||
$greenFrom->fieldLabel = G::LoadTranslation('ID_GREEN_STARTS_IN');
|
||||
$greenFrom->width = 50;
|
||||
$greenFrom->maxLength = 3;
|
||||
$greenFrom->maxValue = 100;
|
||||
$greenFrom->minValue = 0;
|
||||
$greenFrom->allowBlank = false;
|
||||
$greenFrom->value = 50;
|
||||
$additionalFields[] = $greenFrom;
|
||||
$greenFrom = new stdclass();
|
||||
$greenFrom->xtype = 'numberfield';
|
||||
$greenFrom->name = 'DAS_GREEN_FROM';
|
||||
$greenFrom->fieldLabel = G::LoadTranslation( 'ID_GREEN_STARTS_IN' );
|
||||
$greenFrom->width = 50;
|
||||
$greenFrom->maxLength = 3;
|
||||
$greenFrom->maxValue = 100;
|
||||
$greenFrom->minValue = 0;
|
||||
$greenFrom->allowBlank = false;
|
||||
$greenFrom->value = 50;
|
||||
$additionalFields[] = $greenFrom;
|
||||
|
||||
$greenTo = new stdclass();
|
||||
$greenTo->xtype = 'numberfield';
|
||||
$greenTo->name = 'DAS_GREEN_TO';
|
||||
$greenTo->fieldLabel = G::LoadTranslation('ID_GREEN_ENDS_IN');
|
||||
$greenTo->width = 50;
|
||||
$greenTo->maxLength = 3;
|
||||
$greenTo->maxValue = 100;
|
||||
$greenTo->minValue = 0;
|
||||
$greenTo->allowBlank = false;
|
||||
$greenTo->value = 100;
|
||||
$additionalFields[] = $greenTo;
|
||||
$greenTo = new stdclass();
|
||||
$greenTo->xtype = 'numberfield';
|
||||
$greenTo->name = 'DAS_GREEN_TO';
|
||||
$greenTo->fieldLabel = G::LoadTranslation( 'ID_GREEN_ENDS_IN' );
|
||||
$greenTo->width = 50;
|
||||
$greenTo->maxLength = 3;
|
||||
$greenTo->maxValue = 100;
|
||||
$greenTo->minValue = 0;
|
||||
$greenTo->allowBlank = false;
|
||||
$greenTo->value = 100;
|
||||
$additionalFields[] = $greenTo;
|
||||
|
||||
return $additionalFields;
|
||||
}
|
||||
|
||||
public static function getXTemplate($className) {
|
||||
return "<img src='{page}?w={width}&r={random}&DAS_INS_UID={id}'>";
|
||||
}
|
||||
|
||||
public function setup($config) {
|
||||
$this->redFrom = isset($config['DAS_RED_FROM']) ? (int) $config['DAS_RED_FROM'] : 0;
|
||||
$this->redTo = isset($config['DAS_RED_TO']) ? (int) $config['DAS_RED_TO'] : 30;
|
||||
$this->yellowFrom = isset($config['DAS_YELLOW_FROM']) ? (int) $config['DAS_YELLOW_FROM'] : 30;
|
||||
$this->yellowTo = isset($config['DAS_YELLOW_TO']) ? (int) $config['DAS_YELLOW_TO'] : 50;
|
||||
$this->greenFrom = isset($config['DAS_GREEN_FROM']) ? (int) $config['DAS_GREEN_FROM'] : 50;
|
||||
$this->greenTo = isset($config['DAS_GREEN_TO']) ? (int) $config['DAS_GREEN_TO'] : 100;
|
||||
|
||||
$thisYear = date('Y');
|
||||
$lastYear = $thisYear -1;
|
||||
$thisMonth = date('M');
|
||||
$lastMonth = date('M', strtotime( "31 days ago") );
|
||||
|
||||
$todayIni = date('Y-m-d H:i:s', strtotime( "today 00:00:00"));
|
||||
$todayEnd = date('Y-m-d H:i:s', strtotime( "today 23:59:59"));
|
||||
$yesterdayIni = date('Y-m-d H:i:s', strtotime( "yesterday 00:00:00"));
|
||||
$yesterdayEnd = date('Y-m-d H:i:s', strtotime( "yesterday 23:59:59"));
|
||||
$thisWeekIni = date('Y-m-d H:i:s', strtotime( "monday 00:00:00"));
|
||||
$thisWeekEnd = date('Y-m-d H:i:s', strtotime( "sunday 23:59:59"));
|
||||
$previousWeekIni = date('Y-m-d H:i:s', strtotime( "last monday 00:00:00"));
|
||||
$previousWeekEnd = date('Y-m-d H:i:s', strtotime( "last sunday 23:59:59"));
|
||||
|
||||
$thisMonthIni = date('Y-m-d H:i:s', strtotime( "$thisMonth 1st 00:00:00"));
|
||||
$thisMonthEnd = date('Y-m-d H:i:s', strtotime( "$thisMonth last day 23:59:59"));
|
||||
|
||||
$previousMonthIni = date('Y-m-d H:i:s', strtotime( "$lastMonth 1st 00:00:00"));
|
||||
$previousMonthEnd = date('Y-m-d H:i:s', strtotime( "$lastMonth last day 23:59:59"));
|
||||
|
||||
$thisYearIni = date('Y-m-d H:i:s', strtotime( "jan $thisYear 00:00:00"));
|
||||
$thisYearEnd = date('Y-m-d H:i:s', strtotime( "Dec 31 $thisYear 23:59:59"));
|
||||
$previousYearIni = date('Y-m-d H:i:s', strtotime( "jan $lastYear 00:00:00"));
|
||||
$previousYearEnd = date('Y-m-d H:i:s', strtotime( "Dec 31 $lastYear 23:59:59"));
|
||||
|
||||
if (!isset($config['DAS_INS_CONTEXT_TIME'])) {
|
||||
$config['DAS_INS_CONTEXT_TIME'] = 'TODAY';
|
||||
return $additionalFields;
|
||||
}
|
||||
|
||||
switch ( $config['DAS_INS_CONTEXT_TIME'] ) {
|
||||
case 'TODAY' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'YESTERDAY' : $dateIni = $yesterdayIni; $dateEnd = $yesterdayEnd; break;
|
||||
case 'THIS_WEEK' : $dateIni = $thisWeekIni; $dateEnd = $thisWeekEnd; break;
|
||||
case 'PREVIOUS_WEEK' : $dateIni = $previousWeekIni; $dateEnd = $previousWeekEnd; break;
|
||||
case 'THIS_MONTH' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'PREVIOUS_MONTH' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'THIS_QUARTER' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'PREVIOUS_QUARTER' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'THIS_YEAR' : $dateIni = $thisYearIni; $dateEnd = $thisYearEnd; break;
|
||||
case 'PREVIOUS_YEAR' : $dateIni = $previousYearIni; $dateEnd = $previousYearEnd; break;
|
||||
public static function getXTemplate ($className)
|
||||
{
|
||||
return "<img src='{page}?w={width}&r={random}&DAS_INS_UID={id}'>";
|
||||
}
|
||||
|
||||
$con = Propel::getConnection("workflow");
|
||||
$stmt = $con->createStatement();
|
||||
$sql = "select count(*) as CANT from APPLICATION where APP_STATUS in ( 'DRAFT', 'TO_DO' ) ";
|
||||
$sql .= "and APP_CREATE_DATE > '$dateIni' and APP_CREATE_DATE <= '$dateEnd' ";
|
||||
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$casesTodo = $row['CANT'];
|
||||
public function setup ($config)
|
||||
{
|
||||
$this->redFrom = isset( $config['DAS_RED_FROM'] ) ? (int) $config['DAS_RED_FROM'] : 0;
|
||||
$this->redTo = isset( $config['DAS_RED_TO'] ) ? (int) $config['DAS_RED_TO'] : 30;
|
||||
$this->yellowFrom = isset( $config['DAS_YELLOW_FROM'] ) ? (int) $config['DAS_YELLOW_FROM'] : 30;
|
||||
$this->yellowTo = isset( $config['DAS_YELLOW_TO'] ) ? (int) $config['DAS_YELLOW_TO'] : 50;
|
||||
$this->greenFrom = isset( $config['DAS_GREEN_FROM'] ) ? (int) $config['DAS_GREEN_FROM'] : 50;
|
||||
$this->greenTo = isset( $config['DAS_GREEN_TO'] ) ? (int) $config['DAS_GREEN_TO'] : 100;
|
||||
|
||||
$stmt = $con->createStatement();
|
||||
$sql = "select count(*) as CANT from APPLICATION where APP_STATUS = 'COMPLETED' ";
|
||||
$sql .= "and APP_CREATE_DATE > '$dateIni' and APP_CREATE_DATE <= '$dateEnd' ";
|
||||
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$casesCompleted = $row['CANT'];
|
||||
if ( $casesCompleted + $casesTodo != 0 ) {
|
||||
$this->value = $casesCompleted / ($casesCompleted + $casesTodo)*100;
|
||||
$thisYear = date( 'Y' );
|
||||
$lastYear = $thisYear - 1;
|
||||
$thisMonth = date( 'M' );
|
||||
$lastMonth = date( 'M', strtotime( "31 days ago" ) );
|
||||
|
||||
$todayIni = date( 'Y-m-d H:i:s', strtotime( "today 00:00:00" ) );
|
||||
$todayEnd = date( 'Y-m-d H:i:s', strtotime( "today 23:59:59" ) );
|
||||
$yesterdayIni = date( 'Y-m-d H:i:s', strtotime( "yesterday 00:00:00" ) );
|
||||
$yesterdayEnd = date( 'Y-m-d H:i:s', strtotime( "yesterday 23:59:59" ) );
|
||||
$thisWeekIni = date( 'Y-m-d H:i:s', strtotime( "monday 00:00:00" ) );
|
||||
$thisWeekEnd = date( 'Y-m-d H:i:s', strtotime( "sunday 23:59:59" ) );
|
||||
$previousWeekIni = date( 'Y-m-d H:i:s', strtotime( "last monday 00:00:00" ) );
|
||||
$previousWeekEnd = date( 'Y-m-d H:i:s', strtotime( "last sunday 23:59:59" ) );
|
||||
|
||||
$thisMonthIni = date( 'Y-m-d H:i:s', strtotime( "$thisMonth 1st 00:00:00" ) );
|
||||
$thisMonthEnd = date( 'Y-m-d H:i:s', strtotime( "$thisMonth last day 23:59:59" ) );
|
||||
|
||||
$previousMonthIni = date( 'Y-m-d H:i:s', strtotime( "$lastMonth 1st 00:00:00" ) );
|
||||
$previousMonthEnd = date( 'Y-m-d H:i:s', strtotime( "$lastMonth last day 23:59:59" ) );
|
||||
|
||||
$thisYearIni = date( 'Y-m-d H:i:s', strtotime( "jan $thisYear 00:00:00" ) );
|
||||
$thisYearEnd = date( 'Y-m-d H:i:s', strtotime( "Dec 31 $thisYear 23:59:59" ) );
|
||||
$previousYearIni = date( 'Y-m-d H:i:s', strtotime( "jan $lastYear 00:00:00" ) );
|
||||
$previousYearEnd = date( 'Y-m-d H:i:s', strtotime( "Dec 31 $lastYear 23:59:59" ) );
|
||||
|
||||
if (! isset( $config['DAS_INS_CONTEXT_TIME'] )) {
|
||||
$config['DAS_INS_CONTEXT_TIME'] = 'TODAY';
|
||||
}
|
||||
|
||||
switch ($config['DAS_INS_CONTEXT_TIME']) {
|
||||
case 'TODAY':
|
||||
$dateIni = $todayIni;
|
||||
$dateEnd = $todayEnd;
|
||||
break;
|
||||
case 'YESTERDAY':
|
||||
$dateIni = $yesterdayIni;
|
||||
$dateEnd = $yesterdayEnd;
|
||||
break;
|
||||
case 'THIS_WEEK':
|
||||
$dateIni = $thisWeekIni;
|
||||
$dateEnd = $thisWeekEnd;
|
||||
break;
|
||||
case 'PREVIOUS_WEEK':
|
||||
$dateIni = $previousWeekIni;
|
||||
$dateEnd = $previousWeekEnd;
|
||||
break;
|
||||
case 'THIS_MONTH':
|
||||
$dateIni = $todayIni;
|
||||
$dateEnd = $todayEnd;
|
||||
break;
|
||||
case 'PREVIOUS_MONTH':
|
||||
$dateIni = $todayIni;
|
||||
$dateEnd = $todayEnd;
|
||||
break;
|
||||
case 'THIS_QUARTER':
|
||||
$dateIni = $todayIni;
|
||||
$dateEnd = $todayEnd;
|
||||
break;
|
||||
case 'PREVIOUS_QUARTER':
|
||||
$dateIni = $todayIni;
|
||||
$dateEnd = $todayEnd;
|
||||
break;
|
||||
case 'THIS_YEAR':
|
||||
$dateIni = $thisYearIni;
|
||||
$dateEnd = $thisYearEnd;
|
||||
break;
|
||||
case 'PREVIOUS_YEAR':
|
||||
$dateIni = $previousYearIni;
|
||||
$dateEnd = $previousYearEnd;
|
||||
break;
|
||||
}
|
||||
|
||||
$con = Propel::getConnection( "workflow" );
|
||||
$stmt = $con->createStatement();
|
||||
$sql = "select count(*) as CANT from APPLICATION where APP_STATUS in ( 'DRAFT', 'TO_DO' ) ";
|
||||
$sql .= "and APP_CREATE_DATE > '$dateIni' and APP_CREATE_DATE <= '$dateEnd' ";
|
||||
$rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$casesTodo = $row['CANT'];
|
||||
|
||||
$stmt = $con->createStatement();
|
||||
$sql = "select count(*) as CANT from APPLICATION where APP_STATUS = 'COMPLETED' ";
|
||||
$sql .= "and APP_CREATE_DATE > '$dateIni' and APP_CREATE_DATE <= '$dateEnd' ";
|
||||
$rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$casesCompleted = $row['CANT'];
|
||||
if ($casesCompleted + $casesTodo != 0) {
|
||||
$this->value = $casesCompleted / ($casesCompleted + $casesTodo) * 100;
|
||||
} else {
|
||||
$this->value = 0;
|
||||
}
|
||||
$this->open = $casesCompleted;
|
||||
$this->completed = $casesCompleted + $casesTodo;
|
||||
switch ($config['DAS_INS_CONTEXT_TIME']) {
|
||||
case 'TODAY':
|
||||
$this->centerLabel = 'Today';
|
||||
break;
|
||||
case 'YESTERDAY':
|
||||
$this->centerLabel = 'Yesterday';
|
||||
break;
|
||||
case 'THIS_WEEK':
|
||||
$this->centerLabel = 'This week';
|
||||
break;
|
||||
case 'PREVIOUS_WEEK':
|
||||
$this->centerLabel = 'Previous week';
|
||||
break;
|
||||
case 'THIS_MONTH':
|
||||
$this->centerLabel = 'This month';
|
||||
break;
|
||||
case 'PREVIOUS_MONTH':
|
||||
$this->centerLabel = 'Previous month';
|
||||
break;
|
||||
case 'THIS_QUARTER':
|
||||
$this->centerLabel = 'This quarter';
|
||||
break;
|
||||
case 'PREVIOUS_QUARTER':
|
||||
$this->centerLabel = 'Previous quarter';
|
||||
break;
|
||||
case 'THIS_YEAR':
|
||||
$this->centerLabel = 'This year';
|
||||
break;
|
||||
case 'PREVIOUS_YEAR':
|
||||
$this->centerLabel = 'Previous year';
|
||||
break;
|
||||
default:
|
||||
$this->centerLabel = '';
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$this->value = 0;
|
||||
|
||||
public function render ($width = 300)
|
||||
{
|
||||
G::LoadClass( 'pmGauge' );
|
||||
$g = new pmGauge();
|
||||
$g->w = $width;
|
||||
$g->value = $this->value;
|
||||
|
||||
$g->redFrom = $this->redFrom;
|
||||
$g->redTo = $this->redTo;
|
||||
$g->yellowFrom = $this->yellowFrom;
|
||||
$g->yellowTo = $this->yellowTo;
|
||||
$g->greenFrom = $this->greenFrom;
|
||||
$g->greenTo = $this->greenTo;
|
||||
|
||||
$g->centerLabel = $this->centerLabel;
|
||||
$g->open = $this->open;
|
||||
$g->completed = $this->completed;
|
||||
$g->render();
|
||||
}
|
||||
$this->open = $casesCompleted;
|
||||
$this->completed = $casesCompleted + $casesTodo;
|
||||
switch ( $config['DAS_INS_CONTEXT_TIME'] ) {
|
||||
case 'TODAY' : $this->centerLabel = 'Today'; break;
|
||||
case 'YESTERDAY' : $this->centerLabel = 'Yesterday'; break;
|
||||
case 'THIS_WEEK' : $this->centerLabel = 'This week'; break;
|
||||
case 'PREVIOUS_WEEK' : $this->centerLabel = 'Previous week'; break;
|
||||
case 'THIS_MONTH' : $this->centerLabel = 'This month'; break;
|
||||
case 'PREVIOUS_MONTH' : $this->centerLabel = 'Previous month'; break;
|
||||
case 'THIS_QUARTER' : $this->centerLabel = 'This quarter'; break;
|
||||
case 'PREVIOUS_QUARTER' : $this->centerLabel = 'Previous quarter'; break;
|
||||
case 'THIS_YEAR' : $this->centerLabel = 'This year'; break;
|
||||
case 'PREVIOUS_YEAR' : $this->centerLabel = 'Previous year'; break;
|
||||
default : $this->centerLabel = '';break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function render ($width = 300) {
|
||||
G::LoadClass('pmGauge');
|
||||
$g = new pmGauge();
|
||||
$g->w = $width;
|
||||
$g->value = $this->value;
|
||||
|
||||
$g->redFrom = $this->redFrom;
|
||||
$g->redTo = $this->redTo;
|
||||
$g->yellowFrom = $this->yellowFrom;
|
||||
$g->yellowTo = $this->yellowTo;
|
||||
$g->greenFrom = $this->greenFrom;
|
||||
$g->greenTo = $this->greenTo;
|
||||
|
||||
$g->centerLabel = $this->centerLabel;
|
||||
$g->open = $this->open;
|
||||
$g->completed = $this->completed;
|
||||
$g->render();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,26 +2,31 @@
|
||||
|
||||
require_once 'classes/interfaces/dashletInterface.php';
|
||||
|
||||
class dashletProcessMakerCommunity implements DashletInterface {
|
||||
class dashletProcessMakerCommunity implements DashletInterface
|
||||
{
|
||||
|
||||
const version = '1.0';
|
||||
const version = '1.0';
|
||||
|
||||
public static function getAdditionalFields($className) {
|
||||
$additionalFields = array();
|
||||
public static function getAdditionalFields ($className)
|
||||
{
|
||||
$additionalFields = array ();
|
||||
|
||||
return $additionalFields;
|
||||
}
|
||||
return $additionalFields;
|
||||
}
|
||||
|
||||
public static function getXTemplate($className) {
|
||||
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
|
||||
}
|
||||
public static function getXTemplate ($className)
|
||||
{
|
||||
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
|
||||
}
|
||||
|
||||
public function setup($config) {
|
||||
return true;
|
||||
}
|
||||
public function setup ($config)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function render ($width = 300) {
|
||||
$html = "
|
||||
public function render ($width = 300)
|
||||
{
|
||||
$html = "
|
||||
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
|
||||
|
||||
<html xmlns=\"http://www.w3.org/1999/xhtml\">
|
||||
@@ -139,7 +144,7 @@ class dashletProcessMakerCommunity implements DashletInterface {
|
||||
</html>
|
||||
";
|
||||
|
||||
echo $html;
|
||||
}
|
||||
echo $html;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,26 +2,31 @@
|
||||
|
||||
require_once 'classes/interfaces/dashletInterface.php';
|
||||
|
||||
class dashletProcessMakerEnterprise implements DashletInterface {
|
||||
class dashletProcessMakerEnterprise implements DashletInterface
|
||||
{
|
||||
|
||||
const version = '1.0';
|
||||
const version = '1.0';
|
||||
|
||||
public static function getAdditionalFields($className) {
|
||||
$additionalFields = array();
|
||||
public static function getAdditionalFields ($className)
|
||||
{
|
||||
$additionalFields = array ();
|
||||
|
||||
return $additionalFields;
|
||||
}
|
||||
return $additionalFields;
|
||||
}
|
||||
|
||||
public static function getXTemplate($className) {
|
||||
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
|
||||
}
|
||||
public static function getXTemplate ($className)
|
||||
{
|
||||
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
|
||||
}
|
||||
|
||||
public function setup($config) {
|
||||
return true;
|
||||
}
|
||||
public function setup ($config)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function render ($width = 300) {
|
||||
$html = "
|
||||
public function render ($width = 300)
|
||||
{
|
||||
$html = "
|
||||
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
|
||||
|
||||
<html xmlns=\"http://www.w3.org/1999/xhtml\">
|
||||
@@ -247,7 +252,7 @@ class dashletProcessMakerEnterprise implements DashletInterface {
|
||||
</html>
|
||||
";
|
||||
|
||||
echo $html;
|
||||
}
|
||||
echo $html;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,107 +2,111 @@
|
||||
|
||||
require_once 'classes/interfaces/dashletInterface.php';
|
||||
|
||||
class dashletRssReader implements DashletInterface {
|
||||
class dashletRssReader implements DashletInterface
|
||||
{
|
||||
|
||||
const version = '1.0';
|
||||
const version = '1.0';
|
||||
|
||||
public static function getAdditionalFields($className) {
|
||||
$additionalFields = array();
|
||||
|
||||
$urlFrom = new stdclass();
|
||||
$urlFrom->xtype = 'textfield';
|
||||
$urlFrom->name = 'DAS_URL';
|
||||
$urlFrom->fieldLabel = 'Url';
|
||||
$urlFrom->width = 320;
|
||||
$urlFrom->maxLength = 200;
|
||||
$urlFrom->allowBlank = false;
|
||||
$urlFrom->value = "http://license.processmaker.com/syspmLicenseSrv/en/green/services/rssAP";
|
||||
$additionalFields[] = $urlFrom;
|
||||
|
||||
return $additionalFields;
|
||||
}
|
||||
|
||||
public static function getXTemplate($className) {
|
||||
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
|
||||
}
|
||||
|
||||
public function setup($config) {
|
||||
$this->urlFrom = isset($config['DAS_URL']) ? $config['DAS_URL'] : "http://license.processmaker.com/syspmLicenseSrv/en/green/services/rssAP";
|
||||
return true;
|
||||
}
|
||||
|
||||
public function render ($width = 300) {
|
||||
$pCurl = curl_init();
|
||||
curl_setopt($pCurl, CURLOPT_URL, $this->urlFrom);
|
||||
curl_setopt($pCurl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($pCurl, CURLOPT_FOLLOWLOCATION, false);
|
||||
curl_setopt($pCurl, CURLOPT_AUTOREFERER, true);
|
||||
//To avoid SSL error
|
||||
curl_setopt($pCurl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($pCurl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
|
||||
//To avoid timeouts
|
||||
curl_setopt($pCurl, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($pCurl, CURLOPT_TIMEOUT, 20);
|
||||
|
||||
curl_setopt($pCurl, CURLOPT_NOPROGRESS, false);
|
||||
curl_setopt($pCurl, CURLOPT_VERBOSE, true);
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = System::getSystemConfiguration();
|
||||
if ($sysConf['proxy_host'] != '') {
|
||||
curl_setopt($pCurl, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
|
||||
if ($sysConf['proxy_port'] != '') {
|
||||
curl_setopt($pCurl, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
|
||||
}
|
||||
if ($sysConf['proxy_user'] != '') {
|
||||
curl_setopt($pCurl, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
|
||||
}
|
||||
curl_setopt($pCurl, CURLOPT_HTTPHEADER, array('Expect:'));
|
||||
}
|
||||
|
||||
$self->rss = @simplexml_load_string(curl_exec($pCurl));
|
||||
if($self->rss)
|
||||
public static function getAdditionalFields ($className)
|
||||
{
|
||||
$index= 0;
|
||||
$render = '';
|
||||
$self->items = $self->rss->channel->item;
|
||||
if (count($self->rss->channel)!= 0) {
|
||||
$status = 'true';
|
||||
foreach($self->items as $self->item)
|
||||
{
|
||||
$self->title = $self->item->title;
|
||||
$self->link = $self->item->link;
|
||||
$additionalFields = array ();
|
||||
|
||||
$self->des = $self->item->description;
|
||||
$render[] = array('link' => '<a href="'.$self->link.'" target="_blank">'.$self->title.'</a><br/>','description' => $self->des.'<br/><hr>');
|
||||
$index++;
|
||||
$urlFrom = new stdclass();
|
||||
$urlFrom->xtype = 'textfield';
|
||||
$urlFrom->name = 'DAS_URL';
|
||||
$urlFrom->fieldLabel = 'Url';
|
||||
$urlFrom->width = 320;
|
||||
$urlFrom->maxLength = 200;
|
||||
$urlFrom->allowBlank = false;
|
||||
$urlFrom->value = "http://license.processmaker.com/syspmLicenseSrv/en/green/services/rssAP";
|
||||
$additionalFields[] = $urlFrom;
|
||||
|
||||
return $additionalFields;
|
||||
}
|
||||
|
||||
public static function getXTemplate ($className)
|
||||
{
|
||||
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
|
||||
}
|
||||
|
||||
public function setup ($config)
|
||||
{
|
||||
$this->urlFrom = isset( $config['DAS_URL'] ) ? $config['DAS_URL'] : "http://license.processmaker.com/syspmLicenseSrv/en/green/services/rssAP";
|
||||
return true;
|
||||
}
|
||||
|
||||
public function render ($width = 300)
|
||||
{
|
||||
$pCurl = curl_init();
|
||||
curl_setopt( $pCurl, CURLOPT_URL, $this->urlFrom );
|
||||
curl_setopt( $pCurl, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $pCurl, CURLOPT_FOLLOWLOCATION, false );
|
||||
curl_setopt( $pCurl, CURLOPT_AUTOREFERER, true );
|
||||
//To avoid SSL error
|
||||
curl_setopt( $pCurl, CURLOPT_SSL_VERIFYHOST, 0 );
|
||||
curl_setopt( $pCurl, CURLOPT_SSL_VERIFYPEER, 0 );
|
||||
|
||||
//To avoid timeouts
|
||||
curl_setopt( $pCurl, CURLOPT_CONNECTTIMEOUT, 10 );
|
||||
curl_setopt( $pCurl, CURLOPT_TIMEOUT, 20 );
|
||||
|
||||
curl_setopt( $pCurl, CURLOPT_NOPROGRESS, false );
|
||||
curl_setopt( $pCurl, CURLOPT_VERBOSE, true );
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = System::getSystemConfiguration();
|
||||
if ($sysConf['proxy_host'] != '') {
|
||||
curl_setopt( $pCurl, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
|
||||
if ($sysConf['proxy_port'] != '') {
|
||||
curl_setopt( $pCurl, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
|
||||
}
|
||||
if ($sysConf['proxy_user'] != '') {
|
||||
curl_setopt( $pCurl, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
|
||||
}
|
||||
curl_setopt( $pCurl, CURLOPT_HTTPHEADER, array ('Expect:'
|
||||
) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'Error';
|
||||
$render[] =array('link' => 'Error', 'description' =>"Unable to parse XML");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'Error';
|
||||
$render[] =array('link' => 'Error', 'description' =>"Unable to parse XML");
|
||||
}
|
||||
G::verifyPath ( PATH_SMARTY_C, true );
|
||||
$smarty = new Smarty();
|
||||
$smarty->template_dir = PATH_CORE.'templates/dashboard/';
|
||||
$smarty->compile_dir = PATH_SMARTY_C;
|
||||
|
||||
try {
|
||||
$smarty->assign('url', $this->urlFrom);
|
||||
$smarty->assign('render', $render);
|
||||
$smarty->assign('status', $status);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
print $item->key;
|
||||
}
|
||||
$smarty->display('dashletRssReaderTemplate.html',null,null);
|
||||
$self->rss = @simplexml_load_string( curl_exec( $pCurl ) );
|
||||
if ($self->rss) {
|
||||
$index = 0;
|
||||
$render = '';
|
||||
$self->items = $self->rss->channel->item;
|
||||
if (count( $self->rss->channel ) != 0) {
|
||||
$status = 'true';
|
||||
foreach ($self->items as $self->item) {
|
||||
$self->title = $self->item->title;
|
||||
$self->link = $self->item->link;
|
||||
|
||||
}
|
||||
$self->des = $self->item->description;
|
||||
$render[] = array ('link' => '<a href="' . $self->link . '" target="_blank">' . $self->title . '</a><br/>','description' => $self->des . '<br/><hr>'
|
||||
);
|
||||
$index ++;
|
||||
}
|
||||
} else {
|
||||
$status = 'Error';
|
||||
$render[] = array ('link' => 'Error','description' => "Unable to parse XML"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$status = 'Error';
|
||||
$render[] = array ('link' => 'Error','description' => "Unable to parse XML"
|
||||
);
|
||||
}
|
||||
G::verifyPath( PATH_SMARTY_C, true );
|
||||
$smarty = new Smarty();
|
||||
$smarty->template_dir = PATH_CORE . 'templates/dashboard/';
|
||||
$smarty->compile_dir = PATH_SMARTY_C;
|
||||
|
||||
try {
|
||||
$smarty->assign( 'url', $this->urlFrom );
|
||||
$smarty->assign( 'render', $render );
|
||||
$smarty->assign( 'status', $status );
|
||||
} catch (Exception $ex) {
|
||||
print $item->key;
|
||||
}
|
||||
$smarty->display( 'dashletRssReaderTemplate.html', null, null );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* class.dates.php
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
@@ -13,480 +14,518 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
* /
|
||||
|
||||
/*
|
||||
*
|
||||
* /*
|
||||
* Created on 21/01/2008
|
||||
* This class is used for handling dates
|
||||
*
|
||||
* @author David Callizaya <davidsantos@colosa.com>
|
||||
*/
|
||||
|
||||
require_once ( "classes/model/TaskPeer.php" );
|
||||
require_once ( "classes/model/HolidayPeer.php" );
|
||||
|
||||
/**
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
class dates {
|
||||
private $holidays = array();
|
||||
private $weekends = array();
|
||||
private $range = array();
|
||||
private $skipEveryYear = true;
|
||||
private $calendarDays = false; //by default we are using working days
|
||||
private $hoursPerDay = 8; //you should change this
|
||||
|
||||
|
||||
/**
|
||||
* Function that calculate a final date based on $sInitDate and $iDuration
|
||||
* This function also uses a Calendar component (class.calendar.php) where all the definition of
|
||||
* a User, task, Process or default calendar is defined. base on that information is possible to setup different calendars
|
||||
* and apply them to a task, process or user. Each calendar have Working Days, Business Hours and Holidays
|
||||
*
|
||||
* @name calculateDate
|
||||
* @access public
|
||||
* @author Hugo Loza <hugo@colosa.com>
|
||||
* @param date $sInitDate
|
||||
* @param double $iDuration
|
||||
* @param string $sTimeUnit
|
||||
* @param string $iTypeDay
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return array('DUE_DATE'=>'Final calculated date formatted as Y-m-d H:i:s','DUE_DATE_SECONDS'=>'Final calculated date in seconds','OLD_DUE_DATE'=>'Using deprecate4d function','OLD_DUE_DATE_SECONDS'=>'Using deprecated function','DUE_DATE_LOG'=>'Log of all the calculations made')
|
||||
* @todo test this function with negative durations (for events)
|
||||
*
|
||||
*
|
||||
*/
|
||||
function calculateDate( $sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid =NULL )
|
||||
{
|
||||
//$oldDate=$this->calculateDate_noCalendar( $sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid, $ProUid, $TasUid);
|
||||
//Set Calendar when the object is instanced in this order/priority (Task, User, Process, Default)
|
||||
G::LoadClass('calendar');
|
||||
$calendarObj=new calendar($UsrUid,$ProUid,$TasUid);
|
||||
//Get next Business Hours/Range based on :
|
||||
switch(strtoupper($sTimeUnit)){
|
||||
case 'DAYS': $hoursToProcess=$iDuration*8; break;//In Hours
|
||||
default: $hoursToProcess=$iDuration; break;//In Hours
|
||||
}
|
||||
$dateArray = explode(" ",$sInitDate);
|
||||
$currentDate = $dateArray[0];
|
||||
$currentTime = isset($dateArray[1])? $dateArray[1]: "00:00:00";
|
||||
|
||||
$startTime=(float) array_sum(explode(' ',microtime()));
|
||||
|
||||
|
||||
$calendarObj->addCalendarLog("* Starting at: $startTime");
|
||||
$calendarObj->addCalendarLog(">>>>> Hours to Process: $hoursToProcess");
|
||||
$calendarObj->addCalendarLog(">>>>> Current Date: $currentDate");
|
||||
$calendarObj->addCalendarLog(">>>>> Current Time: $currentTime");
|
||||
$array_hours = explode(":",$currentTime);
|
||||
$seconds2 = $array_hours[2];
|
||||
$minutes2 = 0;
|
||||
while($hoursToProcess>0){
|
||||
$validBusinessHour=$calendarObj->getNextValidBusinessHoursRange($currentDate,$currentTime);
|
||||
//For Date/Time operations
|
||||
$currentDateA = explode("-",$validBusinessHour['DATE']);
|
||||
$currentTimeA = explode(":",$validBusinessHour['TIME']);
|
||||
$hour = $currentTimeA[0];
|
||||
$minute = $currentTimeA[1];
|
||||
$second = isset($currentTimeA[2])?$currentTimeA[2]:0;
|
||||
$month = $currentDateA[1];
|
||||
$day = $currentDateA[2];
|
||||
$year = $currentDateA[0];
|
||||
$normalizedDate = date("Y-m-d H:i:s",mktime($hour,$minute,$second,$month,$day,$year));
|
||||
$normalizedDateInt = mktime($hour,$minute,$second,$month,$day,$year);
|
||||
$normalizedDateSeconds = ($hour*60*60)+($minute*60);
|
||||
$arrayHour = explode(".",$hoursToProcess);
|
||||
if(isset($arrayHour[1])){
|
||||
$minutes1 = $arrayHour[1];
|
||||
$cadm = strlen($minutes1);
|
||||
$minutes2 = (($minutes1/pow(10,$cadm))*60);
|
||||
}
|
||||
$possibleTime=date("Y-m-d H:i:s",mktime($hour+$hoursToProcess,$minute+$minutes2,$second+$seconds2,$month,$day,$year));
|
||||
$possibleTimeInt=mktime($hour+$hoursToProcess,$minute+$minutes2,$second+$seconds2,$month,$day,$year);
|
||||
$offsetPermitedMinutes="0";
|
||||
$calendarBusinessEndA=explode(":",$validBusinessHour['BUSINESS_HOURS']['CALENDAR_BUSINESS_END']);
|
||||
$calendarBusinessEndNormalized=date("Y-m-d H:i:s",mktime($calendarBusinessEndA[0],$calendarBusinessEndA[1]+$offsetPermitedMinutes,0,$month,$day,$year));
|
||||
$calendarBusinessEndInt=mktime($calendarBusinessEndA[0],$calendarBusinessEndA[1]+$offsetPermitedMinutes,0,$month,$day,$year);
|
||||
$calendarBusinessEndSeconds=($calendarBusinessEndA[0]*60*60)+($calendarBusinessEndA[1]*60);
|
||||
$calendarObj->addCalendarLog("Possible time: $possibleTime");
|
||||
$calendarObj->addCalendarLog("Current Start Date/Time: $normalizedDate");
|
||||
$calendarObj->addCalendarLog("Calendar Business End: $calendarBusinessEndNormalized");
|
||||
if($possibleTimeInt>$calendarBusinessEndInt){
|
||||
$currentDateTimeB = explode(" ",$calendarBusinessEndNormalized);
|
||||
$currentDate = $currentDateTimeB[0];
|
||||
$currentTime = $currentDateTimeB[1];
|
||||
$diff = abs($normalizedDateSeconds-$calendarBusinessEndSeconds);
|
||||
$diffHours = $diff/3600;
|
||||
$hoursToProcess = $hoursToProcess-$diffHours;
|
||||
}
|
||||
else{
|
||||
$currentDateTimeA = explode(" ",$possibleTime);
|
||||
$currentDate = $currentDateTimeA[0];
|
||||
$currentTime = $currentDateTimeA[1];
|
||||
$hoursToProcess = 0;
|
||||
}
|
||||
$calendarObj->addCalendarLog("** Hours to Process: $hoursToProcess");
|
||||
}
|
||||
$calendarObj->addCalendarLog("+++++++++++ Calculated Due Date $currentDate $currentTime");
|
||||
$result['DUE_DATE'] = $currentDate." ".$currentTime;
|
||||
$result['DUE_DATE_SECONDS'] = strtotime($currentDate." ".$currentTime);
|
||||
//$result['OLD_DUE_DATE'] = date("Y-m-d H:i:s",$oldDate);
|
||||
//$result['OLD_DUE_DATE_SECONDS']= $oldDate;
|
||||
|
||||
$endTime=(float) array_sum(explode(' ',microtime()));
|
||||
$calendarObj->addCalendarLog("* Ending at: $endTime");
|
||||
$calcTime=round($endTime-$startTime,3);
|
||||
$calendarObj->addCalendarLog("** Processing time: ". sprintf("%.4f", ($endTime-$startTime))." seconds");
|
||||
$result['DUE_DATE_LOG'] = $calendarObj->calendarLog;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate $sInitDate + $iDaysCount, skipping non laborable days.
|
||||
* Input: Any valid strtotime function type input.
|
||||
* Returns: Integer timestamp of the result.
|
||||
* Warning: It will hangs if there is no possible days to count as
|
||||
* "laborable".
|
||||
* @param date $sInitDate
|
||||
* @param double $iDuration
|
||||
* @param string $sTimeUnit
|
||||
* @param string $iTypeDay
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return integer timestamp of the result
|
||||
* @deprecated renamed by Hugo Loza (see calculateDate new function)
|
||||
*/
|
||||
|
||||
function calculateDate_noCalendar( $sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid =NULL ) {
|
||||
//load in class variables the config of working days, holidays etc..
|
||||
$this->prepareInformation( $UsrUid , $ProUid , $TasUid );
|
||||
$iHours = 0; $iDays = 0;
|
||||
//convert the $iDuration and $sTimeUnit in hours and days, take in mind 8 hours = 1 day. and then we will have similar for 5 days = 1 weekends
|
||||
if ( strtolower ( $sTimeUnit ) == 'hours' ) {
|
||||
$iAux = intval(abs($iDuration));
|
||||
$iHours = $iAux % $this->hoursPerDay;
|
||||
$iDays = intval( $iAux / $this->hoursPerDay );
|
||||
}
|
||||
if ( strtolower ( $sTimeUnit ) == 'days' ) {
|
||||
$iAux = intval(abs($iDuration * $this->hoursPerDay));
|
||||
$iHours = $iAux % 8;
|
||||
$iDays = intval( $iAux / 8 );
|
||||
}
|
||||
$addSign = ( $iDuration >= 0 ) ? '+' : '-';
|
||||
$iInitDate = strtotime( $sInitDate );
|
||||
if ( $iTypeDay == 1 ) { // working days
|
||||
// if there are days calculate the days,
|
||||
$iEndDate = $this->addDays( $iInitDate , $iDays, $addSign );
|
||||
// if there are hours calculate the hours, and probably add a day if the quantity of hours for last day > 8 hours
|
||||
$iEndDate = $this->addHours( $iEndDate , $iHours, $addSign );
|
||||
}
|
||||
else { // $task->getTasTypeDay() == 2 // calendar days
|
||||
$iEndDate = strtotime( $addSign . $iDays . ' days ' , $iInitDate );
|
||||
$iEndDate = strtotime( $addSign . $iHours . ' hours ' , $iEndDate );
|
||||
}
|
||||
return $iEndDate;
|
||||
}
|
||||
require_once ("classes/model/TaskPeer.php");
|
||||
require_once ("classes/model/HolidayPeer.php");
|
||||
|
||||
/**
|
||||
* Calculate duration of the $sInitDate - $sEndDate.
|
||||
* @param date $sInitDate
|
||||
* @param date $sEndDate
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return int
|
||||
*
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
function calculateDuration( $sInitDate, $sEndDate = '', $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) {
|
||||
$this->prepareInformation($UsrUid, $ProUid, $TasUid);
|
||||
if ((string)$sEndDate == '') {
|
||||
$sEndDate = date('Y-m-d H:i:s');
|
||||
}
|
||||
if (strtotime($sInitDate) > strtotime($sEndDate)) {
|
||||
$sAux = $sInitDate;
|
||||
$sInitDate = $sEndDate;
|
||||
$sEndDate = $sAux;
|
||||
}
|
||||
$aAux1 = explode(' ', $sInitDate);
|
||||
$aAux2 = explode(' ', $sEndDate);
|
||||
$aInitDate = explode('-', $aAux1[0]);
|
||||
$aEndDate = explode('-', $aAux2[0]);
|
||||
$i = 1;
|
||||
$iWorkedDays = 0;
|
||||
$bFinished = false;
|
||||
$fHours1 = 0.0;
|
||||
$fHours2 = 0.0;
|
||||
if (count($aInitDate) != 3) {
|
||||
$aInitDate = array(0, 0, 0);
|
||||
}
|
||||
if (count($aEndDate) != 3) {
|
||||
$aEndDate = array(0, 0, 0);
|
||||
}
|
||||
if ($aInitDate !== $aEndDate) {
|
||||
while (!$bFinished && ($i < 10000)) {
|
||||
$sAux = date('Y-m-d', mktime(0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0]));
|
||||
if ($sAux != implode('-', $aEndDate)) {
|
||||
if (!in_array($sAux, $this->holidays)) {
|
||||
if (!in_array(date('w', mktime(0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0])), $this->weekends)) {
|
||||
$iWorkedDays++;
|
||||
class dates
|
||||
{
|
||||
private $holidays = array ();
|
||||
private $weekends = array ();
|
||||
private $range = array ();
|
||||
private $skipEveryYear = true;
|
||||
private $calendarDays = false; //by default we are using working days
|
||||
private $hoursPerDay = 8; //you should change this
|
||||
|
||||
|
||||
/**
|
||||
* Function that calculate a final date based on $sInitDate and $iDuration
|
||||
* This function also uses a Calendar component (class.calendar.php) where all the definition of
|
||||
* a User, task, Process or default calendar is defined.
|
||||
* base on that information is possible to setup different calendars
|
||||
* and apply them to a task, process or user. Each calendar have Working Days, Business Hours and Holidays
|
||||
*
|
||||
* @name calculateDate
|
||||
* @access public
|
||||
* @author Hugo Loza <hugo@colosa.com>
|
||||
* @param date $sInitDate
|
||||
* @param double $iDuration
|
||||
* @param string $sTimeUnit
|
||||
* @param string $iTypeDay
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return array('DUE_DATE'=>'Final calculated date formatted as Y-m-d H:i:s','DUE_DATE_SECONDS'=>'Final calculated date in seconds','OLD_DUE_DATE'=>'Using deprecate4d function','OLD_DUE_DATE_SECONDS'=>'Using deprecated function','DUE_DATE_LOG'=>'Log of all the calculations made')
|
||||
* @todo test this function with negative durations (for events)
|
||||
*
|
||||
*
|
||||
*/
|
||||
function calculateDate ($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL)
|
||||
{
|
||||
//$oldDate=$this->calculateDate_noCalendar( $sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid, $ProUid, $TasUid);
|
||||
//Set Calendar when the object is instanced in this order/priority (Task, User, Process, Default)
|
||||
G::LoadClass( 'calendar' );
|
||||
$calendarObj = new calendar( $UsrUid, $ProUid, $TasUid );
|
||||
//Get next Business Hours/Range based on :
|
||||
switch (strtoupper( $sTimeUnit )) {
|
||||
case 'DAYS':
|
||||
$hoursToProcess = $iDuration * 8;
|
||||
break; //In Hours
|
||||
default:
|
||||
$hoursToProcess = $iDuration;
|
||||
break; //In Hours
|
||||
}
|
||||
$dateArray = explode( " ", $sInitDate );
|
||||
$currentDate = $dateArray[0];
|
||||
$currentTime = isset( $dateArray[1] ) ? $dateArray[1] : "00:00:00";
|
||||
|
||||
$startTime = (float) array_sum( explode( ' ', microtime() ) );
|
||||
|
||||
$calendarObj->addCalendarLog( "* Starting at: $startTime" );
|
||||
$calendarObj->addCalendarLog( ">>>>> Hours to Process: $hoursToProcess" );
|
||||
$calendarObj->addCalendarLog( ">>>>> Current Date: $currentDate" );
|
||||
$calendarObj->addCalendarLog( ">>>>> Current Time: $currentTime" );
|
||||
$array_hours = explode( ":", $currentTime );
|
||||
$seconds2 = $array_hours[2];
|
||||
$minutes2 = 0;
|
||||
while ($hoursToProcess > 0) {
|
||||
$validBusinessHour = $calendarObj->getNextValidBusinessHoursRange( $currentDate, $currentTime );
|
||||
//For Date/Time operations
|
||||
$currentDateA = explode( "-", $validBusinessHour['DATE'] );
|
||||
$currentTimeA = explode( ":", $validBusinessHour['TIME'] );
|
||||
$hour = $currentTimeA[0];
|
||||
$minute = $currentTimeA[1];
|
||||
$second = isset( $currentTimeA[2] ) ? $currentTimeA[2] : 0;
|
||||
$month = $currentDateA[1];
|
||||
$day = $currentDateA[2];
|
||||
$year = $currentDateA[0];
|
||||
$normalizedDate = date( "Y-m-d H:i:s", mktime( $hour, $minute, $second, $month, $day, $year ) );
|
||||
$normalizedDateInt = mktime( $hour, $minute, $second, $month, $day, $year );
|
||||
$normalizedDateSeconds = ($hour * 60 * 60) + ($minute * 60);
|
||||
$arrayHour = explode( ".", $hoursToProcess );
|
||||
if (isset( $arrayHour[1] )) {
|
||||
$minutes1 = $arrayHour[1];
|
||||
$cadm = strlen( $minutes1 );
|
||||
$minutes2 = (($minutes1 / pow( 10, $cadm )) * 60);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
$possibleTime = date( "Y-m-d H:i:s", mktime( $hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year ) );
|
||||
$possibleTimeInt = mktime( $hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year );
|
||||
$offsetPermitedMinutes = "0";
|
||||
$calendarBusinessEndA = explode( ":", $validBusinessHour['BUSINESS_HOURS']['CALENDAR_BUSINESS_END'] );
|
||||
$calendarBusinessEndNormalized = date( "Y-m-d H:i:s", mktime( $calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year ) );
|
||||
$calendarBusinessEndInt = mktime( $calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year );
|
||||
$calendarBusinessEndSeconds = ($calendarBusinessEndA[0] * 60 * 60) + ($calendarBusinessEndA[1] * 60);
|
||||
$calendarObj->addCalendarLog( "Possible time: $possibleTime" );
|
||||
$calendarObj->addCalendarLog( "Current Start Date/Time: $normalizedDate" );
|
||||
$calendarObj->addCalendarLog( "Calendar Business End: $calendarBusinessEndNormalized" );
|
||||
if ($possibleTimeInt > $calendarBusinessEndInt) {
|
||||
$currentDateTimeB = explode( " ", $calendarBusinessEndNormalized );
|
||||
$currentDate = $currentDateTimeB[0];
|
||||
$currentTime = $currentDateTimeB[1];
|
||||
$diff = abs( $normalizedDateSeconds - $calendarBusinessEndSeconds );
|
||||
$diffHours = $diff / 3600;
|
||||
$hoursToProcess = $hoursToProcess - $diffHours;
|
||||
} else {
|
||||
$currentDateTimeA = explode( " ", $possibleTime );
|
||||
$currentDate = $currentDateTimeA[0];
|
||||
$currentTime = $currentDateTimeA[1];
|
||||
$hoursToProcess = 0;
|
||||
}
|
||||
$calendarObj->addCalendarLog( "** Hours to Process: $hoursToProcess" );
|
||||
}
|
||||
else {
|
||||
$bFinished = true;
|
||||
}
|
||||
}
|
||||
if (isset($aAux1[1])) {
|
||||
$aAux1[1] = explode(':', $aAux1[1]);
|
||||
$fHours1 = 24 - ($aAux1[1][0] + ($aAux1[1][1] / 60) + ($aAux1[1][2] / 3600));
|
||||
}
|
||||
if (isset($aAux2[1])) {
|
||||
$aAux2[1] = explode(':', $aAux2[1]);
|
||||
$fHours2 = $aAux2[1][0] + ($aAux2[1][1] / 60) + ($aAux2[1][2] / 3600);
|
||||
}
|
||||
$fDuration = ($iWorkedDays * 24) + $fHours1 + $fHours2;
|
||||
}
|
||||
else {
|
||||
$fDuration = (strtotime($sEndDate) - strtotime($sInitDate)) / 3600;
|
||||
}
|
||||
return $fDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration functions
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return void
|
||||
*/
|
||||
function prepareInformation( $UsrUid = NULL , $ProUid = NULL , $TasUid =NULL )
|
||||
{
|
||||
// setup calendarDays according the task
|
||||
if (isset($TasUid))
|
||||
{
|
||||
$task = TaskPeer::retrieveByPK( $TasUid );
|
||||
if (!is_null($task)) {
|
||||
$this->calendarDays = ($task->getTasTypeDay()==2);
|
||||
}
|
||||
$calendarObj->addCalendarLog( "+++++++++++ Calculated Due Date $currentDate $currentTime" );
|
||||
$result['DUE_DATE'] = $currentDate . " " . $currentTime;
|
||||
$result['DUE_DATE_SECONDS'] = strtotime( $currentDate . " " . $currentTime );
|
||||
//$result['OLD_DUE_DATE'] = date("Y-m-d H:i:s",$oldDate);
|
||||
//$result['OLD_DUE_DATE_SECONDS']= $oldDate;
|
||||
|
||||
|
||||
$endTime = (float) array_sum( explode( ' ', microtime() ) );
|
||||
$calendarObj->addCalendarLog( "* Ending at: $endTime" );
|
||||
$calcTime = round( $endTime - $startTime, 3 );
|
||||
$calendarObj->addCalendarLog( "** Processing time: " . sprintf( "%.4f", ($endTime - $startTime) ) . " seconds" );
|
||||
$result['DUE_DATE_LOG'] = $calendarObj->calendarLog;
|
||||
return $result;
|
||||
}
|
||||
|
||||
//get an array with all holidays.
|
||||
$aoHolidays=HolidayPeer::doSelect(new Criteria());
|
||||
$holidays=array();
|
||||
foreach($aoHolidays as $holiday)
|
||||
$holidays[] = strtotime($holiday->getHldDate());
|
||||
|
||||
// by default the weekdays are from monday to friday
|
||||
$this->weekends = array(0,6);
|
||||
$this->holidays = $holidays;
|
||||
return ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to repeat for every year all dates defined in $this->holiday
|
||||
* @param $bSkipEveryYear
|
||||
* @return void
|
||||
*/
|
||||
function setSkipEveryYear( $bSkipEveryYear )
|
||||
{
|
||||
$this->skipEveryYear = $bSkipEveryYear===true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single date to holidays
|
||||
* @param data $sDate
|
||||
* @return void
|
||||
*/
|
||||
function addHoliday( $sDate )
|
||||
{
|
||||
if ($date=strtotime( $sDate )) $this->holidays[]=self::truncateTime($date);
|
||||
else throw new Exception("Invalid date: $sDate.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the holidays
|
||||
* @param date/array $aDate must be an array of (strtotime type) dates
|
||||
* @return void
|
||||
*/
|
||||
function setHolidays( $aDates )
|
||||
{
|
||||
foreach($aDates as $sDate) $this->holidays = $aDates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the weekends
|
||||
* @param array/integers $aWeekends must be an array of integers [1,7]
|
||||
* 1=Sunday
|
||||
* 7=Saturday
|
||||
* @return void
|
||||
*/
|
||||
function setWeekends( $aWeekends )
|
||||
{
|
||||
$this->weekends = $aWeekends;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one day of week to the weekends list
|
||||
* @param $iDayNumber must be an array of integers [1,7]
|
||||
* 1=Sunday
|
||||
* 7=Saturday
|
||||
* @return void
|
||||
*/
|
||||
function skipDayOfWeek( $iDayNumber )
|
||||
{
|
||||
if ($iDayNumber<1 || $iDayNumber>7) throw new Exception("The day of week must be a number from 1 to 7.");
|
||||
$this->weekends[]=$iDayNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a range of non working dates
|
||||
* @param date $sDateA must be a (strtotime type) dates
|
||||
* @param date $sDateB must be a (strtotime type) dates
|
||||
* @return void
|
||||
*/
|
||||
function addNonWorkingRange( $sDateA , $sDateB )
|
||||
{
|
||||
if ($date=strtotime( $sDateA )) $iDateA=self::truncateTime($date);
|
||||
else throw new Exception("Invalid date: $sDateA.");
|
||||
if ($date=strtotime( $sDateB )) $iDateB=self::truncateTime($date);
|
||||
else throw new Exception("Invalid date: $sDateB.");
|
||||
if ($iDateA>$iDateB) { $s=$iDateA;$iDateA=$iDateB;$iDateB=$s; };
|
||||
$this->range[]=array( $iDateA , $iDateB );
|
||||
}
|
||||
|
||||
/**
|
||||
* PRIVATE UTILITARY FUNCTIONS
|
||||
* Add days to the date
|
||||
* @param date $iInitDate
|
||||
* @param int $iDaysCount
|
||||
* @param string $addSign
|
||||
* @return date $iEndDate
|
||||
*/
|
||||
private function addDays( $iInitDate , $iDaysCount, $addSign = '+' )
|
||||
{
|
||||
$iEndDate = $iInitDate;
|
||||
$aList = $this->holidays;
|
||||
for( $r=1; $r <= $iDaysCount ; $r++) {
|
||||
$iEndDate = strtotime( $addSign . "1 day", $iEndDate );
|
||||
$dayOfWeek = idate('w',$iEndDate); //now sunday=0
|
||||
if ( array_search( $dayOfWeek, $this->weekends )!== false ) $r--; //continue loop, but we are adding one more day.
|
||||
}
|
||||
return $iEndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add hours to the date
|
||||
* @param date $iInitDate
|
||||
* @param int $iHoursCount
|
||||
* @param string $addSign
|
||||
* @return $iEndDate
|
||||
*/
|
||||
|
||||
private function addHours( $sInitDate , $iHoursCount, $addSign = '+' )
|
||||
{
|
||||
$iEndDate = strtotime( $addSign . $iHoursCount ." hours", $sInitDate );
|
||||
return $iEndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare if the date is in range
|
||||
* @param $iDate = valid timestamp
|
||||
* @return true if it is within any of the ranges defined.
|
||||
*/
|
||||
private function inRange( $iDate )
|
||||
{
|
||||
$aRange = $this->range;
|
||||
$iYear = idate( 'Y', $iDate );
|
||||
foreach($aRange as $key => $rang)
|
||||
{
|
||||
if ($this->skipEveryYear)
|
||||
{
|
||||
$deltaYears = idate( 'Y', $rang[1] ) - idate( 'Y', $rang[0] );
|
||||
$rang[0]=self::changeYear( $rang[0] , $iYear );
|
||||
$rang[1]=self::changeYear( $rang[1] , $iYear + $deltaYears );
|
||||
}
|
||||
if (($iDate>=$rang[0]) && ($iDate<=$rang[1])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate a date
|
||||
* @param $iDate = valid timestamp
|
||||
* @return date
|
||||
*/
|
||||
private function truncateTime( $iDate )
|
||||
{
|
||||
return mktime(0,0,0,idate('m',$iDate),idate('d',$iDate),idate('Y',$iDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time
|
||||
* @param timestamp $iDate
|
||||
* @return date
|
||||
*/
|
||||
private function getTime( $iDate )
|
||||
{
|
||||
return array(idate('H',$iDate),idate('m',$iDate),idate('s',$iDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set time
|
||||
* @param timestamp $iDate
|
||||
* @param timestamp $aTime
|
||||
* @return date
|
||||
*/
|
||||
private function setTime( $iDate , $aTime )
|
||||
{
|
||||
return mktime($aTime[0],$aTime[1],$aTime[2],idate('m',$iDate),idate('d',$iDate),idate('Y',$iDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the dates of $this->skip['List'] with its
|
||||
* year changed to $iYear.
|
||||
* Warning: Don't know what to do if change a 29-02-2004 to 29-02-2005
|
||||
* the last one doesn't exist.
|
||||
* @param List $iYear
|
||||
* @return array
|
||||
*/
|
||||
private function listForYear( $iYear )
|
||||
{
|
||||
$aList = $this->holidays;
|
||||
foreach($aList as $k => $v)
|
||||
{
|
||||
$aList[$k] = self::changeYear( $v , $iYear );
|
||||
}
|
||||
return $aList;
|
||||
}
|
||||
/**
|
||||
* Calculate $sInitDate + $iDaysCount, skipping non laborable days.
|
||||
* Input: Any valid strtotime function type input.
|
||||
* Returns: Integer timestamp of the result.
|
||||
* Warning: It will hangs if there is no possible days to count as
|
||||
* "laborable".
|
||||
*
|
||||
* @param date $sInitDate
|
||||
* @param double $iDuration
|
||||
* @param string $sTimeUnit
|
||||
* @param string $iTypeDay
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return integer timestamp of the result
|
||||
* @deprecated renamed by Hugo Loza (see calculateDate new function)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns an array with all the dates of $this->skip['List'] with its
|
||||
* year changed to $iYear.
|
||||
* Warning: Don't know what to do if change a 29-02-2004 to 29-02-2005
|
||||
* the last one doesn't exist.
|
||||
* @param array $iYear
|
||||
* @param date $iDate
|
||||
* @return array
|
||||
*/
|
||||
private function changeYear( $iDate , $iYear )
|
||||
{
|
||||
if ($delta = ( $iYear - idate('Y',$iDate) ) )
|
||||
function calculateDate_noCalendar ($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL)
|
||||
{
|
||||
$iDate = strtotime( "$delta year" , $iDate );
|
||||
//load in class variables the config of working days, holidays etc..
|
||||
$this->prepareInformation( $UsrUid, $ProUid, $TasUid );
|
||||
$iHours = 0;
|
||||
$iDays = 0;
|
||||
//convert the $iDuration and $sTimeUnit in hours and days, take in mind 8 hours = 1 day. and then we will have similar for 5 days = 1 weekends
|
||||
if (strtolower( $sTimeUnit ) == 'hours') {
|
||||
$iAux = intval( abs( $iDuration ) );
|
||||
$iHours = $iAux % $this->hoursPerDay;
|
||||
$iDays = intval( $iAux / $this->hoursPerDay );
|
||||
}
|
||||
if (strtolower( $sTimeUnit ) == 'days') {
|
||||
$iAux = intval( abs( $iDuration * $this->hoursPerDay ) );
|
||||
$iHours = $iAux % 8;
|
||||
$iDays = intval( $iAux / 8 );
|
||||
}
|
||||
$addSign = ($iDuration >= 0) ? '+' : '-';
|
||||
$iInitDate = strtotime( $sInitDate );
|
||||
if ($iTypeDay == 1) { // working days
|
||||
// if there are days calculate the days,
|
||||
$iEndDate = $this->addDays( $iInitDate, $iDays, $addSign );
|
||||
// if there are hours calculate the hours, and probably add a day if the quantity of hours for last day > 8 hours
|
||||
$iEndDate = $this->addHours( $iEndDate, $iHours, $addSign );
|
||||
} else { // $task->getTasTypeDay() == 2 // calendar days
|
||||
$iEndDate = strtotime( $addSign . $iDays . ' days ', $iInitDate );
|
||||
$iEndDate = strtotime( $addSign . $iHours . ' hours ', $iEndDate );
|
||||
}
|
||||
return $iEndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate duration of the $sInitDate - $sEndDate.
|
||||
*
|
||||
* @param date $sInitDate
|
||||
* @param date $sEndDate
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return int
|
||||
*
|
||||
*/
|
||||
function calculateDuration ($sInitDate, $sEndDate = '', $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL)
|
||||
{
|
||||
$this->prepareInformation( $UsrUid, $ProUid, $TasUid );
|
||||
if ((string) $sEndDate == '') {
|
||||
$sEndDate = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
if (strtotime( $sInitDate ) > strtotime( $sEndDate )) {
|
||||
$sAux = $sInitDate;
|
||||
$sInitDate = $sEndDate;
|
||||
$sEndDate = $sAux;
|
||||
}
|
||||
$aAux1 = explode( ' ', $sInitDate );
|
||||
$aAux2 = explode( ' ', $sEndDate );
|
||||
$aInitDate = explode( '-', $aAux1[0] );
|
||||
$aEndDate = explode( '-', $aAux2[0] );
|
||||
$i = 1;
|
||||
$iWorkedDays = 0;
|
||||
$bFinished = false;
|
||||
$fHours1 = 0.0;
|
||||
$fHours2 = 0.0;
|
||||
if (count( $aInitDate ) != 3) {
|
||||
$aInitDate = array (0,0,0
|
||||
);
|
||||
}
|
||||
if (count( $aEndDate ) != 3) {
|
||||
$aEndDate = array (0,0,0
|
||||
);
|
||||
}
|
||||
if ($aInitDate !== $aEndDate) {
|
||||
while (! $bFinished && ($i < 10000)) {
|
||||
$sAux = date( 'Y-m-d', mktime( 0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0] ) );
|
||||
if ($sAux != implode( '-', $aEndDate )) {
|
||||
if (! in_array( $sAux, $this->holidays )) {
|
||||
if (! in_array( date( 'w', mktime( 0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0] ) ), $this->weekends )) {
|
||||
$iWorkedDays ++;
|
||||
}
|
||||
}
|
||||
$i ++;
|
||||
} else {
|
||||
$bFinished = true;
|
||||
}
|
||||
}
|
||||
if (isset( $aAux1[1] )) {
|
||||
$aAux1[1] = explode( ':', $aAux1[1] );
|
||||
$fHours1 = 24 - ($aAux1[1][0] + ($aAux1[1][1] / 60) + ($aAux1[1][2] / 3600));
|
||||
}
|
||||
if (isset( $aAux2[1] )) {
|
||||
$aAux2[1] = explode( ':', $aAux2[1] );
|
||||
$fHours2 = $aAux2[1][0] + ($aAux2[1][1] / 60) + ($aAux2[1][2] / 3600);
|
||||
}
|
||||
$fDuration = ($iWorkedDays * 24) + $fHours1 + $fHours2;
|
||||
} else {
|
||||
$fDuration = (strtotime( $sEndDate ) - strtotime( $sInitDate )) / 3600;
|
||||
}
|
||||
return $fDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration functions
|
||||
*
|
||||
* @param string $UsrUid
|
||||
* @param string $ProUid
|
||||
* @param string $TasUid
|
||||
* @return void
|
||||
*/
|
||||
function prepareInformation ($UsrUid = NULL, $ProUid = NULL, $TasUid = NULL)
|
||||
{
|
||||
// setup calendarDays according the task
|
||||
if (isset( $TasUid )) {
|
||||
$task = TaskPeer::retrieveByPK( $TasUid );
|
||||
if (! is_null( $task )) {
|
||||
$this->calendarDays = ($task->getTasTypeDay() == 2);
|
||||
}
|
||||
}
|
||||
|
||||
//get an array with all holidays.
|
||||
$aoHolidays = HolidayPeer::doSelect( new Criteria() );
|
||||
$holidays = array ();
|
||||
foreach ($aoHolidays as $holiday)
|
||||
$holidays[] = strtotime( $holiday->getHldDate() );
|
||||
|
||||
// by default the weekdays are from monday to friday
|
||||
$this->weekends = array (0,6
|
||||
);
|
||||
$this->holidays = $holidays;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to repeat for every year all dates defined in $this->holiday
|
||||
*
|
||||
* @param $bSkipEveryYear
|
||||
* @return void
|
||||
*/
|
||||
function setSkipEveryYear ($bSkipEveryYear)
|
||||
{
|
||||
$this->skipEveryYear = $bSkipEveryYear === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single date to holidays
|
||||
*
|
||||
* @param data $sDate
|
||||
* @return void
|
||||
*/
|
||||
function addHoliday ($sDate)
|
||||
{
|
||||
if ($date = strtotime( $sDate ))
|
||||
$this->holidays[] = self::truncateTime( $date );
|
||||
else
|
||||
throw new Exception( "Invalid date: $sDate." );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the holidays
|
||||
*
|
||||
* @param date/array $aDate must be an array of (strtotime type) dates
|
||||
* @return void
|
||||
*/
|
||||
function setHolidays ($aDates)
|
||||
{
|
||||
foreach ($aDates as $sDate)
|
||||
$this->holidays = $aDates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the weekends
|
||||
*
|
||||
* @param array/integers $aWeekends must be an array of integers [1,7]
|
||||
* 1=Sunday
|
||||
* 7=Saturday
|
||||
* @return void
|
||||
*/
|
||||
function setWeekends ($aWeekends)
|
||||
{
|
||||
$this->weekends = $aWeekends;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one day of week to the weekends list
|
||||
*
|
||||
* @param $iDayNumber must be an array of integers [1,7]
|
||||
* 1=Sunday
|
||||
* 7=Saturday
|
||||
* @return void
|
||||
*/
|
||||
function skipDayOfWeek ($iDayNumber)
|
||||
{
|
||||
if ($iDayNumber < 1 || $iDayNumber > 7)
|
||||
throw new Exception( "The day of week must be a number from 1 to 7." );
|
||||
$this->weekends[] = $iDayNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a range of non working dates
|
||||
*
|
||||
* @param date $sDateA must be a (strtotime type) dates
|
||||
* @param date $sDateB must be a (strtotime type) dates
|
||||
* @return void
|
||||
*/
|
||||
function addNonWorkingRange ($sDateA, $sDateB)
|
||||
{
|
||||
if ($date = strtotime( $sDateA ))
|
||||
$iDateA = self::truncateTime( $date );
|
||||
else
|
||||
throw new Exception( "Invalid date: $sDateA." );
|
||||
if ($date = strtotime( $sDateB ))
|
||||
$iDateB = self::truncateTime( $date );
|
||||
else
|
||||
throw new Exception( "Invalid date: $sDateB." );
|
||||
if ($iDateA > $iDateB) {
|
||||
$s = $iDateA;
|
||||
$iDateA = $iDateB;
|
||||
$iDateB = $s;
|
||||
}
|
||||
;
|
||||
$this->range[] = array ($iDateA,$iDateB
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* PRIVATE UTILITARY FUNCTIONS
|
||||
* Add days to the date
|
||||
*
|
||||
* @param date $iInitDate
|
||||
* @param int $iDaysCount
|
||||
* @param string $addSign
|
||||
* @return date $iEndDate
|
||||
*/
|
||||
private function addDays ($iInitDate, $iDaysCount, $addSign = '+')
|
||||
{
|
||||
$iEndDate = $iInitDate;
|
||||
$aList = $this->holidays;
|
||||
for ($r = 1; $r <= $iDaysCount; $r ++) {
|
||||
$iEndDate = strtotime( $addSign . "1 day", $iEndDate );
|
||||
$dayOfWeek = idate( 'w', $iEndDate ); //now sunday=0
|
||||
if (array_search( $dayOfWeek, $this->weekends ) !== false)
|
||||
$r --; //continue loop, but we are adding one more day.
|
||||
}
|
||||
return $iEndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add hours to the date
|
||||
*
|
||||
* @param date $iInitDate
|
||||
* @param int $iHoursCount
|
||||
* @param string $addSign
|
||||
* @return $iEndDate
|
||||
*/
|
||||
|
||||
private function addHours ($sInitDate, $iHoursCount, $addSign = '+')
|
||||
{
|
||||
$iEndDate = strtotime( $addSign . $iHoursCount . " hours", $sInitDate );
|
||||
return $iEndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare if the date is in range
|
||||
*
|
||||
* @param $iDate = valid timestamp
|
||||
* @return true if it is within any of the ranges defined.
|
||||
*/
|
||||
private function inRange ($iDate)
|
||||
{
|
||||
$aRange = $this->range;
|
||||
$iYear = idate( 'Y', $iDate );
|
||||
foreach ($aRange as $key => $rang) {
|
||||
if ($this->skipEveryYear) {
|
||||
$deltaYears = idate( 'Y', $rang[1] ) - idate( 'Y', $rang[0] );
|
||||
$rang[0] = self::changeYear( $rang[0], $iYear );
|
||||
$rang[1] = self::changeYear( $rang[1], $iYear + $deltaYears );
|
||||
}
|
||||
if (($iDate >= $rang[0]) && ($iDate <= $rang[1]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate a date
|
||||
*
|
||||
* @param $iDate = valid timestamp
|
||||
* @return date
|
||||
*/
|
||||
private function truncateTime ($iDate)
|
||||
{
|
||||
return mktime( 0, 0, 0, idate( 'm', $iDate ), idate( 'd', $iDate ), idate( 'Y', $iDate ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time
|
||||
*
|
||||
* @param timestamp $iDate
|
||||
* @return date
|
||||
*/
|
||||
private function getTime ($iDate)
|
||||
{
|
||||
return array (idate( 'H', $iDate ),idate( 'm', $iDate ),idate( 's', $iDate )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set time
|
||||
*
|
||||
* @param timestamp $iDate
|
||||
* @param timestamp $aTime
|
||||
* @return date
|
||||
*/
|
||||
private function setTime ($iDate, $aTime)
|
||||
{
|
||||
return mktime( $aTime[0], $aTime[1], $aTime[2], idate( 'm', $iDate ), idate( 'd', $iDate ), idate( 'Y', $iDate ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the dates of $this->skip['List'] with its
|
||||
* year changed to $iYear.
|
||||
* Warning: Don't know what to do if change a 29-02-2004 to 29-02-2005
|
||||
* the last one doesn't exist.
|
||||
*
|
||||
* @param List $iYear
|
||||
* @return array
|
||||
*/
|
||||
private function listForYear ($iYear)
|
||||
{
|
||||
$aList = $this->holidays;
|
||||
foreach ($aList as $k => $v) {
|
||||
$aList[$k] = self::changeYear( $v, $iYear );
|
||||
}
|
||||
return $aList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the dates of $this->skip['List'] with its
|
||||
* year changed to $iYear.
|
||||
* Warning: Don't know what to do if change a 29-02-2004 to 29-02-2005
|
||||
* the last one doesn't exist.
|
||||
*
|
||||
* @param array $iYear
|
||||
* @param date $iDate
|
||||
* @return array
|
||||
*/
|
||||
private function changeYear ($iDate, $iYear)
|
||||
{
|
||||
if ($delta = ($iYear - idate( 'Y', $iDate ))) {
|
||||
$iDate = strtotime( "$delta year", $iDate );
|
||||
}
|
||||
return $iDate;
|
||||
}
|
||||
return $iDate;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,14 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: Erik Amaru Ortiz <erik@colosa.com>
|
||||
* Author: Erik Amaru Ortiz <erik@colosa.com>
|
||||
* Description:This is a class for load all additional connections; if exist in a particular proccess
|
||||
* Date: 15-05-2008
|
||||
* Date: 15-05-2008
|
||||
*
|
||||
*
|
||||
* class.dbConnections.php
|
||||
*
|
||||
* Email bugs/suggestions to erik@colosa.com
|
||||
*
|
||||
* Email bugs/suggestions to erik@colosa.com
|
||||
*/
|
||||
|
||||
require_once 'model/DbSource.php';
|
||||
@@ -18,199 +17,171 @@ require_once 'model/Content.php';
|
||||
* dbConnections
|
||||
*
|
||||
*
|
||||
* @copyright 2008 Colosa
|
||||
* @package workflow.engine.classes
|
||||
* @copyright 2008 Colosa
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
*/
|
||||
*/
|
||||
class dbConnections
|
||||
{
|
||||
private $PRO_UID;
|
||||
public $connections;
|
||||
private $types;
|
||||
private $PRO_UID;
|
||||
public $connections;
|
||||
private $types;
|
||||
|
||||
/*errors handle*/
|
||||
private $errno;
|
||||
private $errstr;
|
||||
|
||||
private $encodesList;
|
||||
/*errors handle*/
|
||||
private $errno;
|
||||
private $errstr;
|
||||
|
||||
/**
|
||||
* construct of dbConnections
|
||||
*
|
||||
* @param string $pPRO_UID
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($pPRO_UID = null)
|
||||
{
|
||||
$this->errno = 0;
|
||||
$this->errstr = "";
|
||||
$this->PRO_UID = $pPRO_UID;
|
||||
|
||||
$this->getAllConnections();
|
||||
}
|
||||
private $encodesList;
|
||||
|
||||
/**
|
||||
* getAllConnections
|
||||
*
|
||||
* @return Array $connections
|
||||
*/
|
||||
public function getAllConnections()
|
||||
{
|
||||
if( isset($this->PRO_UID) ){
|
||||
$oDBSource = new DbSource();
|
||||
$oContent = new Content();
|
||||
$connections = Array();
|
||||
$types = Array();
|
||||
$this->have_any_connectios = false;
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_UID);
|
||||
$c->addSelectColumn(DbSourcePeer::PRO_UID);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_TYPE);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_SERVER);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_DATABASE_NAME);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_USERNAME);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_PASSWORD);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_PORT);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_ENCODE);
|
||||
$c->addSelectColumn(ContentPeer::CON_VALUE);
|
||||
/**
|
||||
* construct of dbConnections
|
||||
*
|
||||
* @param string $pPRO_UID
|
||||
* @return void
|
||||
*/
|
||||
public function __construct ($pPRO_UID = null)
|
||||
{
|
||||
$this->errno = 0;
|
||||
$this->errstr = "";
|
||||
$this->PRO_UID = $pPRO_UID;
|
||||
|
||||
$c->add(DbSourcePeer::PRO_UID, $this->PRO_UID);
|
||||
$c->add(ContentPeer::CON_CATEGORY, 'DBS_DESCRIPTION');
|
||||
$c->addJoin(DbSourcePeer::DBS_UID, ContentPeer::CON_ID);
|
||||
$this->getAllConnections();
|
||||
}
|
||||
|
||||
$result = DbSourcePeer::doSelectRS($c);
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
/**
|
||||
* getAllConnections
|
||||
*
|
||||
* @return Array $connections
|
||||
*/
|
||||
public function getAllConnections ()
|
||||
{
|
||||
if (isset( $this->PRO_UID )) {
|
||||
$oDBSource = new DbSource();
|
||||
$oContent = new Content();
|
||||
$connections = Array ();
|
||||
$types = Array ();
|
||||
$this->have_any_connectios = false;
|
||||
|
||||
while ($row = $result->getRow()) {
|
||||
$connections[] = Array(
|
||||
'DBS_UID' => $row[0],
|
||||
'DBS_TYPE' => $row[2],
|
||||
'DBS_SERVER' => $row[3],
|
||||
'DBS_DATABASE_NAME' => $row[4],
|
||||
'DBS_USERNAME' => $row[5],
|
||||
'DBS_PASSWORD' => $row[6],
|
||||
'DBS_PORT' => $row[7],
|
||||
'DBS_ENCODE' => $row[8],
|
||||
'CON_VALUE' => $row[9],
|
||||
);
|
||||
$c = new Criteria();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_UID );
|
||||
$c->addSelectColumn( DbSourcePeer::PRO_UID );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_TYPE );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_SERVER );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_DATABASE_NAME );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_USERNAME );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_PASSWORD );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_PORT );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_ENCODE );
|
||||
$c->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
|
||||
$c->add( DbSourcePeer::PRO_UID, $this->PRO_UID );
|
||||
$c->add( ContentPeer::CON_CATEGORY, 'DBS_DESCRIPTION' );
|
||||
$c->addJoin( DbSourcePeer::DBS_UID, ContentPeer::CON_ID );
|
||||
|
||||
$result = DbSourcePeer::doSelectRS( $c );
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
|
||||
while ($row = $result->getRow()) {
|
||||
$connections[] = Array ('DBS_UID' => $row[0],'DBS_TYPE' => $row[2],'DBS_SERVER' => $row[3],'DBS_DATABASE_NAME' => $row[4],'DBS_USERNAME' => $row[5],'DBS_PASSWORD' => $row[6],'DBS_PORT' => $row[7],'DBS_ENCODE' => $row[8],'CON_VALUE' => $row[9]
|
||||
);
|
||||
$result->next();
|
||||
}
|
||||
if (! in_array( $row[2], $types )) {
|
||||
$types[] = $row[2];
|
||||
}
|
||||
$this->connections = $connections;
|
||||
return $connections;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getConnections
|
||||
*
|
||||
* @param string $pType
|
||||
* @return Array $connections
|
||||
*/
|
||||
public function getConnections ($pType)
|
||||
{
|
||||
$connections = Array ();
|
||||
foreach ($this->connections as $c) {
|
||||
if (trim( $pType ) == trim( $c['DBS_TYPE'] )) {
|
||||
$connections[] = $c;
|
||||
}
|
||||
}
|
||||
if (count( $connections ) > 0) {
|
||||
return $connections;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getConnectionsProUid
|
||||
*
|
||||
* @param string $pType
|
||||
* @return Array $connections
|
||||
*/
|
||||
public function getConnectionsProUid ($pProUid)
|
||||
{
|
||||
$connections = Array ();
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_UID );
|
||||
$c->addSelectColumn( DbSourcePeer::PRO_UID );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_TYPE );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_SERVER );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_DATABASE_NAME );
|
||||
|
||||
$result = DbSourcePeer::doSelectRS( $c );
|
||||
$result->next();
|
||||
}
|
||||
if(!in_array($row[2], $types)) {
|
||||
$types[] = $row[2];
|
||||
}
|
||||
$this->connections = $connections;
|
||||
return $connections;
|
||||
$row = $result->getRow();
|
||||
while ($row = $result->getRow()) {
|
||||
if (trim( $pProUid ) == trim( $row[1] )) {
|
||||
$connections[] = Array ('DBS_UID' => $row[0],'DBS_NAME' => '[' . $row[3] . '] ' . $row[2] . ': ' . $row[4]
|
||||
);
|
||||
}
|
||||
$result->next();
|
||||
}
|
||||
|
||||
if (count( $connections ) > 0) {
|
||||
return $connections;
|
||||
} else {
|
||||
return Array ();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getConnections
|
||||
*
|
||||
* @param string $pType
|
||||
* @return Array $connections
|
||||
*/
|
||||
public function getConnections($pType){
|
||||
$connections = Array();
|
||||
foreach($this->connections as $c){
|
||||
if(trim($pType) == trim($c['DBS_TYPE'])){
|
||||
$connections[] = $c;
|
||||
}
|
||||
/**
|
||||
* loadAdditionalConnections
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadAdditionalConnections ()
|
||||
{
|
||||
PROPEL::Init( PATH_METHODS . 'dbConnections/genericDbConnections.php' );
|
||||
}
|
||||
if(count($connections) > 0){
|
||||
return $connections;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getDbServicesAvailables
|
||||
*
|
||||
* @return array $servicesAvailables
|
||||
*/
|
||||
public function getDbServicesAvailables ()
|
||||
{
|
||||
$servicesAvailables = Array ();
|
||||
|
||||
/**
|
||||
* getConnectionsProUid
|
||||
*
|
||||
* @param string $pType
|
||||
* @return Array $connections
|
||||
*/
|
||||
public function getConnectionsProUid($pProUid)
|
||||
{
|
||||
$connections = Array();
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_UID);
|
||||
$c->addSelectColumn(DbSourcePeer::PRO_UID);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_TYPE);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_SERVER);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_DATABASE_NAME);
|
||||
|
||||
$result = DbSourcePeer::doSelectRS($c);
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
while ($row = $result->getRow()) {
|
||||
if(trim($pProUid) == trim($row[1])){
|
||||
$connections[] = Array(
|
||||
'DBS_UID' => $row[0],
|
||||
'DBS_NAME' => '[' . $row[3] . '] ' . $row[2] . ': ' . $row[4]
|
||||
$dbServices = Array ('mysql' => Array ('id' => 'mysql','command' => 'mysql_connect','name' => 'MySql'
|
||||
),'pgsql' => Array ('id' => 'pgsql','command' => 'pg_connect','name' => 'PostgreSql'
|
||||
),'mssql' => Array ('id' => 'mssql','command' => 'mssql_connect','name' => 'Microsoft SQL Server'
|
||||
),'oracle' => Array ('id' => 'oracle','command' => 'oci_connect','name' => 'Oracle'
|
||||
)
|
||||
);
|
||||
}
|
||||
$result->next();
|
||||
}
|
||||
|
||||
if(count($connections) > 0){
|
||||
return $connections;
|
||||
} else {
|
||||
return Array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* loadAdditionalConnections
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadAdditionalConnections()
|
||||
{
|
||||
PROPEL::Init ( PATH_METHODS.'dbConnections/genericDbConnections.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* getDbServicesAvailables
|
||||
*
|
||||
* @return array $servicesAvailables
|
||||
*/
|
||||
public function getDbServicesAvailables()
|
||||
{
|
||||
$servicesAvailables = Array();
|
||||
|
||||
$dbServices = Array(
|
||||
'mysql' => Array(
|
||||
'id' => 'mysql',
|
||||
'command' => 'mysql_connect',
|
||||
'name' => 'MySql'
|
||||
),
|
||||
'pgsql' => Array(
|
||||
'id' => 'pgsql',
|
||||
'command' => 'pg_connect',
|
||||
'name' => 'PostgreSql'
|
||||
),
|
||||
'mssql' => Array(
|
||||
'id' => 'mssql',
|
||||
'command' => 'mssql_connect',
|
||||
'name' => 'Microsoft SQL Server'),
|
||||
'oracle'=> Array(
|
||||
'id' => 'oracle',
|
||||
'command' => 'oci_connect',
|
||||
'name' => 'Oracle'
|
||||
)
|
||||
);
|
||||
/*,
|
||||
/*,
|
||||
'informix'=> Array(
|
||||
'id' => 'informix',
|
||||
'command' => 'ifx_connect',
|
||||
@@ -222,231 +193,240 @@ class dbConnections
|
||||
'name' => 'SQLite'
|
||||
)
|
||||
*/
|
||||
|
||||
foreach($dbServices as $service) {
|
||||
if(@function_exists($service['command'])){
|
||||
$servicesAvailables[] = $service;
|
||||
}
|
||||
|
||||
foreach ($dbServices as $service) {
|
||||
if (@function_exists( $service['command'] )) {
|
||||
$servicesAvailables[] = $service;
|
||||
}
|
||||
}
|
||||
return $servicesAvailables;
|
||||
}
|
||||
return $servicesAvailables;
|
||||
}
|
||||
|
||||
/**
|
||||
* showMsg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showMsg()
|
||||
{
|
||||
if ($this->errno != 0) {
|
||||
$msg = "
|
||||
|
||||
/**
|
||||
* showMsg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showMsg ()
|
||||
{
|
||||
if ($this->errno != 0) {
|
||||
$msg = "
|
||||
<center>
|
||||
<fieldset style='width:90%'><legend>Class NET</legend>
|
||||
<div align=left>
|
||||
<div align=left>
|
||||
<font color='red'>
|
||||
<b>NET::ERROR NO -> $this->errno<br/>
|
||||
NET::ERROR MSG -> $this->errstr</b>
|
||||
</font>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<center>";
|
||||
print ($msg);
|
||||
print ($msg) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getEncondeList
|
||||
*
|
||||
* @param string $engine
|
||||
* @return $this->ordx($this->encodesList);
|
||||
*/
|
||||
public function getEncondeList($engine = ''){
|
||||
switch( $engine ){
|
||||
default:
|
||||
case 'mysql':
|
||||
$encodes = Array(
|
||||
Array('big5', 'big5 - Big5 Traditional Chinese'),
|
||||
Array('dec8', 'dec8 - DEC West European'),
|
||||
Array('cp850', 'cp850 - DOS West European'),
|
||||
Array('hp8', 'hp8 - HP West European'),
|
||||
Array('koi8r', 'koi8r - KOI8-R Relcom Russian'),
|
||||
Array('latin1', 'latin1 - cp1252 West European'),
|
||||
Array('latin2', 'latin2 - ISO 8859-2 Central European'),
|
||||
Array('swe7', 'swe7 - 7bit Swedish'),
|
||||
Array('ascii', 'ascii - US ASCII'),
|
||||
Array('ujis', 'ujis - EUC-JP Japanese'),
|
||||
Array('sjis', 'sjis - Shift-JIS Japanese'),
|
||||
Array('hebrew', 'hebrew - ISO 8859-8 Hebrew'),
|
||||
Array('tis620', 'tis620 - TIS620 Thai'),
|
||||
Array('euckr', 'euckr - EUC-KR Korean'),
|
||||
Array('koi8u', 'koi8u - KOI8-U Ukrainian'),
|
||||
Array('gb2312', 'gb2312 - GB2312 Simplified Chinese'),
|
||||
Array('greek', 'greek - ISO 8859-7 Greek'),
|
||||
Array('cp1250', 'cp1250 - Windows Central European'),
|
||||
Array('gbk', 'gbk - GBK Simplified Chinese'),
|
||||
Array('latin5', 'latin5 - ISO 8859-9 Turkish'),
|
||||
Array('armscii8', 'armscii8 - ARMSCII-8 Armenian'),
|
||||
Array('utf8', 'utf8 - UTF-8 Unicode'),
|
||||
Array('ucs2', 'ucs2 - UCS-2 Unicode'),
|
||||
Array('cp866', 'cp866 - DOS Russian'),
|
||||
Array('keybcs2', 'keybcs2 - DOS Kamenicky Czech-Slovak'),
|
||||
Array('macce', 'macce - Mac Central European'),
|
||||
Array('macroman', 'macroman - Mac West European'),
|
||||
Array('cp852', 'cp852 - DOS Central European'),
|
||||
Array('latin7', 'atin7 - ISO 8859-13 Baltic'),
|
||||
Array('cp1251', 'cp1251 - Windows Cyrillic'),
|
||||
Array('cp1256', 'cp1256 - Windows Arabic'),
|
||||
Array('cp1257', 'cp1257 - Windows Baltic'),
|
||||
Array('binary', 'binary - Binary pseudo charset'),
|
||||
Array('geostd8', 'geostd8 - GEOSTD8 Georgian'),
|
||||
Array('cp932', 'cp932] - SJIS for Windows Japanese'),
|
||||
Array('eucjpms', 'eucjpms - UJIS for Windows Japanese')
|
||||
);
|
||||
/**
|
||||
* getEncondeList
|
||||
*
|
||||
* @param string $engine
|
||||
* @return $this->ordx($this->encodesList);
|
||||
*/
|
||||
public function getEncondeList ($engine = '')
|
||||
{
|
||||
switch ($engine) {
|
||||
default:
|
||||
case 'mysql':
|
||||
$encodes = Array (Array ('big5','big5 - Big5 Traditional Chinese'
|
||||
),Array ('dec8','dec8 - DEC West European'
|
||||
),Array ('cp850','cp850 - DOS West European'
|
||||
),Array ('hp8','hp8 - HP West European'
|
||||
),Array ('koi8r','koi8r - KOI8-R Relcom Russian'
|
||||
),Array ('latin1','latin1 - cp1252 West European'
|
||||
),Array ('latin2','latin2 - ISO 8859-2 Central European'
|
||||
),Array ('swe7','swe7 - 7bit Swedish'
|
||||
),Array ('ascii','ascii - US ASCII'
|
||||
),Array ('ujis','ujis - EUC-JP Japanese'
|
||||
),Array ('sjis','sjis - Shift-JIS Japanese'
|
||||
),Array ('hebrew','hebrew - ISO 8859-8 Hebrew'
|
||||
),Array ('tis620','tis620 - TIS620 Thai'
|
||||
),Array ('euckr','euckr - EUC-KR Korean'
|
||||
),Array ('koi8u','koi8u - KOI8-U Ukrainian'
|
||||
),Array ('gb2312','gb2312 - GB2312 Simplified Chinese'
|
||||
),Array ('greek','greek - ISO 8859-7 Greek'
|
||||
),Array ('cp1250','cp1250 - Windows Central European'
|
||||
),Array ('gbk','gbk - GBK Simplified Chinese'
|
||||
),Array ('latin5','latin5 - ISO 8859-9 Turkish'
|
||||
),Array ('armscii8','armscii8 - ARMSCII-8 Armenian'
|
||||
),Array ('utf8','utf8 - UTF-8 Unicode'
|
||||
),Array ('ucs2','ucs2 - UCS-2 Unicode'
|
||||
),Array ('cp866','cp866 - DOS Russian'
|
||||
),Array ('keybcs2','keybcs2 - DOS Kamenicky Czech-Slovak'
|
||||
),Array ('macce','macce - Mac Central European'
|
||||
),Array ('macroman','macroman - Mac West European'
|
||||
),Array ('cp852','cp852 - DOS Central European'
|
||||
),Array ('latin7','atin7 - ISO 8859-13 Baltic'
|
||||
),Array ('cp1251','cp1251 - Windows Cyrillic'
|
||||
),Array ('cp1256','cp1256 - Windows Arabic'
|
||||
),Array ('cp1257','cp1257 - Windows Baltic'
|
||||
),Array ('binary','binary - Binary pseudo charset'
|
||||
),Array ('geostd8','geostd8 - GEOSTD8 Georgian'
|
||||
),Array ('cp932','cp932] - SJIS for Windows Japanese'
|
||||
),Array ('eucjpms','eucjpms - UJIS for Windows Japanese'
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
case 'pgsql':
|
||||
$encodes = Array(
|
||||
Array("BIG5", "BIG5"),
|
||||
Array("EUC_CN", "EUC_CN"),
|
||||
Array("EUC_JP", "EUC_JP"),
|
||||
Array("EUC_KR", "EUC_KR"),
|
||||
Array("EUC_TW", "EUC_TW"),
|
||||
Array("GB18030", "GB18030"),
|
||||
Array("GBK", "GBK"),
|
||||
Array("ISO_8859_5", "ISO_8859_5"),
|
||||
Array("ISO_8859_6", "ISO_8859_6"),
|
||||
Array("ISO_8859_7", "ISO_8859_7"),
|
||||
Array("ISO_8859_8", "ISO_8859_8"),
|
||||
Array("JOHAB", "JOHAB"),
|
||||
Array("KOI8", "KOI8"),
|
||||
Array("selected", "LATIN1"),
|
||||
Array("LATIN2", "LATIN2"),
|
||||
Array("LATIN3", "LATIN3"),
|
||||
Array("LATIN4", "LATIN4"),
|
||||
Array("LATIN5", "LATIN5"),
|
||||
Array("LATIN6", "LATIN6"),
|
||||
Array("LATIN7", "LATIN7"),
|
||||
Array("LATIN8", "LATIN8"),
|
||||
Array("LATIN9", "LATIN9"),
|
||||
Array("LATIN10", "LATIN10"),
|
||||
Array("SJIS", "SJIS"),
|
||||
Array("SQL_ASCII", "SQL_ASCII"),
|
||||
Array("UHC", "UHC"),
|
||||
Array("UTF8", "UTF8"),
|
||||
Array("WIN866", "WIN866"),
|
||||
Array("WIN874", "WIN874"),
|
||||
Array("WIN1250", "WIN1250"),
|
||||
Array("WIN1251", "WIN1251"),
|
||||
Array("WIN1252", "WIN1252"),
|
||||
Array("WIN1256", "WIN1256"),
|
||||
Array("WIN1258", "WIN1258")
|
||||
);
|
||||
break;
|
||||
case 'mssql':
|
||||
$encodes = Array(Array('utf8', 'utf8 - UTF-8 Unicode'));
|
||||
break;
|
||||
case 'oracle':
|
||||
$encodes = Array();
|
||||
break;
|
||||
}
|
||||
|
||||
$this->encodesList = $encodes;
|
||||
return $this->ordx($this->encodesList);
|
||||
}
|
||||
break;
|
||||
case 'pgsql':
|
||||
$encodes = Array (Array ("BIG5","BIG5"
|
||||
),Array ("EUC_CN","EUC_CN"
|
||||
),Array ("EUC_JP","EUC_JP"
|
||||
),Array ("EUC_KR","EUC_KR"
|
||||
),Array ("EUC_TW","EUC_TW"
|
||||
),Array ("GB18030","GB18030"
|
||||
),Array ("GBK","GBK"
|
||||
),Array ("ISO_8859_5","ISO_8859_5"
|
||||
),Array ("ISO_8859_6","ISO_8859_6"
|
||||
),Array ("ISO_8859_7","ISO_8859_7"
|
||||
),Array ("ISO_8859_8","ISO_8859_8"
|
||||
),Array ("JOHAB","JOHAB"
|
||||
),Array ("KOI8","KOI8"
|
||||
),Array ("selected","LATIN1"
|
||||
),Array ("LATIN2","LATIN2"
|
||||
),Array ("LATIN3","LATIN3"
|
||||
),Array ("LATIN4","LATIN4"
|
||||
),Array ("LATIN5","LATIN5"
|
||||
),Array ("LATIN6","LATIN6"
|
||||
),Array ("LATIN7","LATIN7"
|
||||
),Array ("LATIN8","LATIN8"
|
||||
),Array ("LATIN9","LATIN9"
|
||||
),Array ("LATIN10","LATIN10"
|
||||
),Array ("SJIS","SJIS"
|
||||
),Array ("SQL_ASCII","SQL_ASCII"
|
||||
),Array ("UHC","UHC"
|
||||
),Array ("UTF8","UTF8"
|
||||
),Array ("WIN866","WIN866"
|
||||
),Array ("WIN874","WIN874"
|
||||
),Array ("WIN1250","WIN1250"
|
||||
),Array ("WIN1251","WIN1251"
|
||||
),Array ("WIN1252","WIN1252"
|
||||
),Array ("WIN1256","WIN1256"
|
||||
),Array ("WIN1258","WIN1258"
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mssql':
|
||||
$encodes = Array (Array ('utf8','utf8 - UTF-8 Unicode'
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'oracle':
|
||||
$encodes = Array ();
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* getErrno
|
||||
*
|
||||
* @return integer $errno
|
||||
*/
|
||||
public function getErrno()
|
||||
{
|
||||
return $this->errno;
|
||||
}
|
||||
$this->encodesList = $encodes;
|
||||
return $this->ordx( $this->encodesList );
|
||||
}
|
||||
|
||||
/**
|
||||
* getErrmsg
|
||||
*
|
||||
* @return string errstr
|
||||
*/
|
||||
public function getErrmsg()
|
||||
{
|
||||
return $this->errstr;
|
||||
}
|
||||
/**
|
||||
* getErrno
|
||||
*
|
||||
* @return integer $errno
|
||||
*/
|
||||
public function getErrno ()
|
||||
{
|
||||
return $this->errno;
|
||||
}
|
||||
|
||||
/**
|
||||
* getErrmsg
|
||||
*
|
||||
* @param array $m
|
||||
* @return array $aRet
|
||||
*/
|
||||
public function ordx($m)
|
||||
{
|
||||
$aTmp = Array();
|
||||
$aRet = Array();
|
||||
for($i=0; $i<count($m); $i++){
|
||||
array_push($aTmp, $m[$i][0].'|'.$m[$i][1]);
|
||||
/**
|
||||
* getErrmsg
|
||||
*
|
||||
* @return string errstr
|
||||
*/
|
||||
public function getErrmsg ()
|
||||
{
|
||||
return $this->errstr;
|
||||
}
|
||||
usort($aTmp,"strnatcasecmp");
|
||||
|
||||
for($i=0; $i<count($aTmp); $i++){
|
||||
$x = explode('|', $aTmp[$i]);
|
||||
array_push($aRet, Array($x[0], $x[1]));
|
||||
|
||||
/**
|
||||
* getErrmsg
|
||||
*
|
||||
* @param array $m
|
||||
* @return array $aRet
|
||||
*/
|
||||
public function ordx ($m)
|
||||
{
|
||||
$aTmp = Array ();
|
||||
$aRet = Array ();
|
||||
for ($i = 0; $i < count( $m ); $i ++) {
|
||||
array_push( $aTmp, $m[$i][0] . '|' . $m[$i][1] );
|
||||
}
|
||||
usort( $aTmp, "strnatcasecmp" );
|
||||
|
||||
for ($i = 0; $i < count( $aTmp ); $i ++) {
|
||||
$x = explode( '|', $aTmp[$i] );
|
||||
array_push( $aRet, Array ($x[0],$x[1]
|
||||
) );
|
||||
}
|
||||
return $aRet;
|
||||
}
|
||||
return $aRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function encryptThepassw
|
||||
* @author krlos Pacha C. <carlos@colosa.com>
|
||||
* @access public
|
||||
* @param string proUid
|
||||
* @return void
|
||||
*/
|
||||
public function encryptThepassw($proUid){
|
||||
$oDBSource = new DbSource();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_UID);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_DATABASE_NAME);
|
||||
$c->addSelectColumn(DbSourcePeer::DBS_PASSWORD);
|
||||
$c->add(DbSourcePeer::PRO_UID, $proUid);
|
||||
$result = DbSourcePeer::doSelectRS($c);
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
while ($row = $result->getRow()) {
|
||||
if($row[2]!=''){
|
||||
$aPass = explode('_', $row[2]);
|
||||
if(count($aPass)==1) {
|
||||
$passEncrypt = G::encrypt($row[2], $row[1]);
|
||||
$passEncrypt.="_2NnV3ujj3w";
|
||||
$c2 = new Criteria('workflow');
|
||||
$c2->add(DbSourcePeer::DBS_PASSWORD, $passEncrypt);
|
||||
$c3 = new Criteria('workflow');
|
||||
$c3->add(DbSourcePeer::DBS_UID, $row[0]);
|
||||
BasePeer::doUpdate($c3, $c2, Propel::getConnection('workflow'));
|
||||
}
|
||||
}
|
||||
$result->next();
|
||||
|
||||
/**
|
||||
* Function encryptThepassw
|
||||
*
|
||||
* @author krlos Pacha C. <carlos@colosa.com>
|
||||
* @access public
|
||||
* @param string proUid
|
||||
* @return void
|
||||
*/
|
||||
public function encryptThepassw ($proUid)
|
||||
{
|
||||
$oDBSource = new DbSource();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_UID );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_DATABASE_NAME );
|
||||
$c->addSelectColumn( DbSourcePeer::DBS_PASSWORD );
|
||||
$c->add( DbSourcePeer::PRO_UID, $proUid );
|
||||
$result = DbSourcePeer::doSelectRS( $c );
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
while ($row = $result->getRow()) {
|
||||
if ($row[2] != '') {
|
||||
$aPass = explode( '_', $row[2] );
|
||||
if (count( $aPass ) == 1) {
|
||||
$passEncrypt = G::encrypt( $row[2], $row[1] );
|
||||
$passEncrypt .= "_2NnV3ujj3w";
|
||||
$c2 = new Criteria( 'workflow' );
|
||||
$c2->add( DbSourcePeer::DBS_PASSWORD, $passEncrypt );
|
||||
$c3 = new Criteria( 'workflow' );
|
||||
$c3->add( DbSourcePeer::DBS_UID, $row[0] );
|
||||
BasePeer::doUpdate( $c3, $c2, Propel::getConnection( 'workflow' ) );
|
||||
}
|
||||
}
|
||||
$result->next();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* Function getPassWithoutEncrypt
|
||||
* @author krlos Pacha C. <carlos@colosa.com>
|
||||
* @access public
|
||||
* @param string passw
|
||||
* @return string
|
||||
*/
|
||||
public function getPassWithoutEncrypt($aInfoCon){
|
||||
$passw='';
|
||||
if($aInfoCon['DBS_PASSWORD']!=''){
|
||||
$aPassw =explode('_',$aInfoCon['DBS_PASSWORD']);
|
||||
$passw = $aPassw[0];
|
||||
if(sizeof($aPassw)>1)
|
||||
$passw = ($passw == 'none') ? "": G::decrypt($passw,$aInfoCon['DBS_DATABASE_NAME']);
|
||||
|
||||
/**
|
||||
* Function getPassWithoutEncrypt
|
||||
*
|
||||
* @author krlos Pacha C. <carlos@colosa.com>
|
||||
* @access public
|
||||
* @param string passw
|
||||
* @return string
|
||||
*/
|
||||
public function getPassWithoutEncrypt ($aInfoCon)
|
||||
{
|
||||
$passw = '';
|
||||
if ($aInfoCon['DBS_PASSWORD'] != '') {
|
||||
$aPassw = explode( '_', $aInfoCon['DBS_PASSWORD'] );
|
||||
$passw = $aPassw[0];
|
||||
if (sizeof( $aPassw ) > 1)
|
||||
$passw = ($passw == 'none') ? "" : G::decrypt( $passw, $aInfoCon['DBS_DATABASE_NAME'] );
|
||||
}
|
||||
return $passw;
|
||||
}
|
||||
return $passw;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* class.dynaFormField.php
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,191 +14,167 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
G::LoadClass('xmlDb');
|
||||
G::LoadClass( 'xmlDb' );
|
||||
|
||||
/**
|
||||
* Dynaform Field - DynaformField class
|
||||
* Dynaform Field - DynaformField class
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
class DynaFormField extends DBTable
|
||||
{
|
||||
/**
|
||||
* Function SetTo
|
||||
* @param string $objConnection
|
||||
* @return void
|
||||
*/
|
||||
function SetTo( $objConnection )
|
||||
{
|
||||
DBTable::SetTo( $objConnection, 'dynaForm', array('XMLNODE_NAME') );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a dynaForm
|
||||
* @param string $sUID
|
||||
* @return void
|
||||
*/
|
||||
function Load( $sUID )
|
||||
{
|
||||
parent::Load( $sUID );
|
||||
if (is_array($this->Fields)) {
|
||||
foreach( $this->Fields as $name => $value ){
|
||||
if (strcasecmp($name,'dependentfields')==0) {
|
||||
$this->Fields[$name]=explode(',', $value );
|
||||
{
|
||||
|
||||
/**
|
||||
* Function SetTo
|
||||
*
|
||||
* @param string $objConnection
|
||||
* @return void
|
||||
*/
|
||||
function SetTo ($objConnection)
|
||||
{
|
||||
DBTable::SetTo( $objConnection, 'dynaForm', array ('XMLNODE_NAME'
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a dynaForm
|
||||
*
|
||||
* @param string $sUID
|
||||
* @return void
|
||||
*/
|
||||
function Load ($sUID)
|
||||
{
|
||||
parent::Load( $sUID );
|
||||
if (is_array( $this->Fields )) {
|
||||
foreach ($this->Fields as $name => $value) {
|
||||
if (strcasecmp( $name, 'dependentfields' ) == 0) {
|
||||
$this->Fields[$name] = explode( ',', $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Fields of a dynaForm
|
||||
* @param string $uid
|
||||
* @return void
|
||||
*/
|
||||
function Delete ( $uid )
|
||||
{
|
||||
$this->Fields['XMLNODE_NAME'] = $uid;
|
||||
parent::Delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Fields of a dynaform
|
||||
* @param array $Fields
|
||||
* @param array $labels
|
||||
* @param array $options
|
||||
* @return void
|
||||
*/
|
||||
function Save ( $Fields , $labels=array() , $options=array() )
|
||||
{
|
||||
/**
|
||||
* Delete Fields of a dynaForm
|
||||
*
|
||||
* @param string $uid
|
||||
* @return void
|
||||
*/
|
||||
function Delete ($uid)
|
||||
{
|
||||
$this->Fields['XMLNODE_NAME'] = $uid;
|
||||
parent::Delete();
|
||||
}
|
||||
|
||||
if ($Fields['TYPE'] === 'javascript'){
|
||||
$Fields['XMLNODE_VALUE'] = $Fields['CODE'];
|
||||
unset($Fields['CODE']);
|
||||
$labels = array();
|
||||
}
|
||||
if ($Fields['XMLNODE_NAME_OLD'] == '') {
|
||||
if (($Fields['XMLNODE_NAME'][0] == '1') || ($Fields['XMLNODE_NAME'][0] == '2') ||
|
||||
($Fields['XMLNODE_NAME'][0] == '3') || ($Fields['XMLNODE_NAME'][0] == '4') ||
|
||||
($Fields['XMLNODE_NAME'][0] == '5') || ($Fields['XMLNODE_NAME'][0] == '6') ||
|
||||
($Fields['XMLNODE_NAME'][0] == '7') || ($Fields['XMLNODE_NAME'][0] == '8') ||
|
||||
($Fields['XMLNODE_NAME'][0] == '9') || ($Fields['XMLNODE_NAME'][0] == '10')) {
|
||||
$Fields['XMLNODE_NAME'] = '_' . $Fields['XMLNODE_NAME'];
|
||||
}
|
||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm WHERE XMLNODE_NAME="'.$Fields['XMLNODE_NAME'].'"');
|
||||
}
|
||||
else {
|
||||
if (($Fields['XMLNODE_NAME_OLD'][0] == '1') || ($Fields['XMLNODE_NAME_OLD'][0] == '2') ||
|
||||
($Fields['XMLNODE_NAME_OLD'][0] == '3') || ($Fields['XMLNODE_NAME_OLD'][0] == '4') ||
|
||||
($Fields['XMLNODE_NAME_OLD'][0] == '5') || ($Fields['XMLNODE_NAME_OLD'][0] == '6') ||
|
||||
($Fields['XMLNODE_NAME_OLD'][0] == '7') || ($Fields['XMLNODE_NAME_OLD'][0] == '8') ||
|
||||
($Fields['XMLNODE_NAME_OLD'][0] == '9') || ($Fields['XMLNODE_NAME_OLD'][0] == '10')) {
|
||||
$Fields['XMLNODE_NAME_OLD'] = '_' . $Fields['XMLNODE_NAME_OLD'];
|
||||
}
|
||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm WHERE XMLNODE_NAME="'.$Fields['XMLNODE_NAME_OLD'].'"');
|
||||
}
|
||||
$this->is_new = ($res->count()==0);
|
||||
$this->Fields = $Fields;
|
||||
unset($this->Fields['XMLNODE_NAME_OLD']);
|
||||
/*
|
||||
/**
|
||||
* Save Fields of a dynaform
|
||||
*
|
||||
* @param array $Fields
|
||||
* @param array $labels
|
||||
* @param array $options
|
||||
* @return void
|
||||
*/
|
||||
function Save ($Fields, $labels = array(), $options = array())
|
||||
{
|
||||
|
||||
if ($Fields['TYPE'] === 'javascript') {
|
||||
$Fields['XMLNODE_VALUE'] = $Fields['CODE'];
|
||||
unset( $Fields['CODE'] );
|
||||
$labels = array ();
|
||||
}
|
||||
if ($Fields['XMLNODE_NAME_OLD'] == '') {
|
||||
if (($Fields['XMLNODE_NAME'][0] == '1') || ($Fields['XMLNODE_NAME'][0] == '2') || ($Fields['XMLNODE_NAME'][0] == '3') || ($Fields['XMLNODE_NAME'][0] == '4') || ($Fields['XMLNODE_NAME'][0] == '5') || ($Fields['XMLNODE_NAME'][0] == '6') || ($Fields['XMLNODE_NAME'][0] == '7') || ($Fields['XMLNODE_NAME'][0] == '8') || ($Fields['XMLNODE_NAME'][0] == '9') || ($Fields['XMLNODE_NAME'][0] == '10')) {
|
||||
$Fields['XMLNODE_NAME'] = '_' . $Fields['XMLNODE_NAME'];
|
||||
}
|
||||
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $Fields['XMLNODE_NAME'] . '"' );
|
||||
} else {
|
||||
if (($Fields['XMLNODE_NAME_OLD'][0] == '1') || ($Fields['XMLNODE_NAME_OLD'][0] == '2') || ($Fields['XMLNODE_NAME_OLD'][0] == '3') || ($Fields['XMLNODE_NAME_OLD'][0] == '4') || ($Fields['XMLNODE_NAME_OLD'][0] == '5') || ($Fields['XMLNODE_NAME_OLD'][0] == '6') || ($Fields['XMLNODE_NAME_OLD'][0] == '7') || ($Fields['XMLNODE_NAME_OLD'][0] == '8') || ($Fields['XMLNODE_NAME_OLD'][0] == '9') || ($Fields['XMLNODE_NAME_OLD'][0] == '10')) {
|
||||
$Fields['XMLNODE_NAME_OLD'] = '_' . $Fields['XMLNODE_NAME_OLD'];
|
||||
}
|
||||
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $Fields['XMLNODE_NAME_OLD'] . '"' );
|
||||
}
|
||||
$this->is_new = ($res->count() == 0);
|
||||
$this->Fields = $Fields;
|
||||
unset( $this->Fields['XMLNODE_NAME_OLD'] );
|
||||
/*
|
||||
* MPD-10 to create fields that do not appear many attributes, only the main ones?
|
||||
* The show those who are not white
|
||||
*/
|
||||
if ($this->is_new){
|
||||
foreach($this->Fields as $key => $value){
|
||||
if ($value=="")
|
||||
unset( $this->Fields[$key] );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
|
||||
}
|
||||
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||
if ($this->is_new) {
|
||||
foreach ($this->Fields as $key => $value) {
|
||||
if ($value == "")
|
||||
unset( $this->Fields[$key] );
|
||||
}
|
||||
} else {
|
||||
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
|
||||
}
|
||||
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
||||
' VALUES ("cdata", "'."\n".'")');*/
|
||||
parent::Save();
|
||||
if ($this->is_new) {
|
||||
/*
|
||||
parent::Save();
|
||||
if ($this->is_new) {
|
||||
/*
|
||||
* Create a new field.
|
||||
*/
|
||||
foreach( $labels as $lang => $value ) {
|
||||
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||
foreach ($labels as $lang => $value) {
|
||||
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
||||
' VALUES ("cdata", "'."\n".'")');*/
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
||||
.'VALUES ("","'."\n ".'","cdata")');
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE) '
|
||||
.'VALUES ("'.$lang.'","'.str_replace('"','""',$value)/*."\n "*/.'")');
|
||||
if (isset($options[$lang])) {
|
||||
foreach($options[$lang] as $option => $text ) {
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
||||
.'VALUES ("","'." ".'","cdata")');
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,name) '
|
||||
.'VALUES ("option","'.str_replace('"','""',$text).'","'.str_replace('"','""',$option).'")');
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
||||
.'VALUES ("","'."\n ".'","cdata")');
|
||||
}
|
||||
}
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
||||
.'VALUES ("","'."\n".'","cdata")');
|
||||
}
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
||||
' VALUES ("cdata", "'."\n".'")');
|
||||
} else {
|
||||
/*
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n " . '","cdata")' );
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE) ' . 'VALUES ("' . $lang . '","' . str_replace( '"', '""', $value )/*."\n "*/.'")' );
|
||||
if (isset( $options[$lang] )) {
|
||||
foreach ($options[$lang] as $option => $text) {
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . " " . '","cdata")' );
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace( '"', '""', $text ) . '","' . str_replace( '"', '""', $option ) . '")' );
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n " . '","cdata")' );
|
||||
}
|
||||
}
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n" . '","cdata")' );
|
||||
}
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm' . ' (XMLNODE_TYPE,XMLNODE_VALUE)' . ' VALUES ("cdata", "' . "\n" . '")' );
|
||||
} else {
|
||||
/*
|
||||
* Update an existing field.
|
||||
*/
|
||||
$this->_dbses->Execute('UPDATE dynaForm SET XMLNODE_NAME = "' . $Fields['XMLNODE_NAME'] . '" WHERE XMLNODE_NAME = "' . $Fields['XMLNODE_NAME_OLD'] . '"');
|
||||
foreach( $labels as $lang => $value ) {
|
||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].' WHERE XMLNODE_NAME ="'.$lang.'"');
|
||||
if ($res->count()>0) {
|
||||
$res = $this->_dbses->Execute('UPDATE dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].' SET XMLNODE_VALUE = '
|
||||
.'"'.str_replace('"','""',$value).'" WHERE XMLNODE_NAME ="'.$lang.'"');
|
||||
} else {
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE) '
|
||||
.'VALUES ("'.$lang.'","'.str_replace('"','""',$value).'")');
|
||||
$this->_dbses->Execute( 'UPDATE dynaForm SET XMLNODE_NAME = "' . $Fields['XMLNODE_NAME'] . '" WHERE XMLNODE_NAME = "' . $Fields['XMLNODE_NAME_OLD'] . '"' );
|
||||
foreach ($labels as $lang => $value) {
|
||||
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm.' . $Fields['XMLNODE_NAME'] . ' WHERE XMLNODE_NAME ="' . $lang . '"' );
|
||||
if ($res->count() > 0) {
|
||||
$res = $this->_dbses->Execute( 'UPDATE dynaForm.' . $Fields['XMLNODE_NAME'] . ' SET XMLNODE_VALUE = ' . '"' . str_replace( '"', '""', $value ) . '" WHERE XMLNODE_NAME ="' . $lang . '"' );
|
||||
} else {
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE) ' . 'VALUES ("' . $lang . '","' . str_replace( '"', '""', $value ) . '")' );
|
||||
}
|
||||
if (isset( $options[$lang] )) {
|
||||
$res = $this->_dbses->Execute( 'DELETE FROM dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' WHERE 1' );
|
||||
foreach ($options[$lang] as $option => $text) {
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace( '"', '""', $text ) . '","' . str_replace( '"', '""', $option ) . '")' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($options[$lang])) {
|
||||
$res = $this->_dbses->Execute('DELETE FROM dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' WHERE 1');
|
||||
foreach($options[$lang] as $option => $text ) {
|
||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,name) '
|
||||
.'VALUES ("option","'.str_replace('"','""',$text).'","'.str_replace('"','""',$option).'")');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if is New the Field
|
||||
* @return array
|
||||
*/
|
||||
function isNew()
|
||||
{
|
||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm WHERE XMLNODE_NAME="'.$this->Fields['XMLNODE_NAME'].'"');
|
||||
return ($res->count()==0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if is New the Field
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function isNew ()
|
||||
{
|
||||
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $this->Fields['XMLNODE_NAME'] . '"' );
|
||||
return ($res->count() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,110 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* class.memcached.php
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
|
||||
/**
|
||||
* class.memcached.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
class FileCache {
|
||||
|
||||
function __construct($dir) {
|
||||
$this->dir = $dir;
|
||||
}
|
||||
|
||||
private function _name($key) {
|
||||
return sprintf ( "%s/%s", $this->dir, sha1 ( $key ) );
|
||||
}
|
||||
|
||||
public function get($key, $expiration = 3600) {
|
||||
|
||||
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
|
||||
return FALSE;
|
||||
class FileCache
|
||||
{
|
||||
|
||||
function __construct ($dir)
|
||||
{
|
||||
$this->dir = $dir;
|
||||
}
|
||||
|
||||
$cache_path = $this->_name ( $key );
|
||||
|
||||
if (! @file_exists ( $cache_path )) {
|
||||
return FALSE;
|
||||
|
||||
private function _name ($key)
|
||||
{
|
||||
return sprintf( "%s/%s", $this->dir, sha1( $key ) );
|
||||
}
|
||||
|
||||
if (filemtime ( $cache_path ) < (time () - $expiration)) {
|
||||
// $this->clear($key);
|
||||
// different users can have different timeout requests
|
||||
return FALSE;
|
||||
|
||||
public function get ($key, $expiration = 3600)
|
||||
{
|
||||
|
||||
if (! is_dir( $this->dir ) or ! is_writable( $this->dir )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cache_path = $this->_name( $key );
|
||||
|
||||
if (! @file_exists( $cache_path )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (filemtime( $cache_path ) < (time() - $expiration)) {
|
||||
// $this->clear($key);
|
||||
// different users can have different timeout requests
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! $fp = @fopen( $cache_path, 'rb' )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
flock( $fp, LOCK_SH );
|
||||
|
||||
$cache = '';
|
||||
|
||||
if (filesize( $cache_path ) > 0) {
|
||||
$cache = unserialize( fread( $fp, filesize( $cache_path ) ) );
|
||||
} else {
|
||||
$cache = NULL;
|
||||
}
|
||||
|
||||
flock( $fp, LOCK_UN );
|
||||
fclose( $fp );
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
if (! $fp = @fopen ( $cache_path, 'rb' )) {
|
||||
return FALSE;
|
||||
|
||||
public function set ($key, $data)
|
||||
{
|
||||
|
||||
if (! is_dir( $this->dir ) or ! is_writable( $this->dir )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cache_path = $this->_name( $key );
|
||||
|
||||
if (! $fp = fopen( $cache_path, 'wb' )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flock( $fp, LOCK_EX )) {
|
||||
fwrite( $fp, serialize( $data ) );
|
||||
flock( $fp, LOCK_UN );
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
fclose( $fp );
|
||||
@chmod( $cache_path, 0777 );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flock ( $fp, LOCK_SH );
|
||||
|
||||
$cache = '';
|
||||
|
||||
if (filesize ( $cache_path ) > 0) {
|
||||
$cache = unserialize ( fread ( $fp, filesize ( $cache_path ) ) );
|
||||
|
||||
public function clear ($key)
|
||||
{
|
||||
$cache_path = $this->_name( $key );
|
||||
|
||||
if (file_exists( $cache_path )) {
|
||||
unlink( $cache_path );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
$cache = NULL;
|
||||
}
|
||||
|
||||
flock ( $fp, LOCK_UN );
|
||||
fclose ( $fp );
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
public function set($key, $data) {
|
||||
|
||||
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cache_path = $this->_name ( $key );
|
||||
|
||||
if (! $fp = fopen ( $cache_path, 'wb' )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flock ( $fp, LOCK_EX )) {
|
||||
fwrite ( $fp, serialize ( $data ) );
|
||||
flock ( $fp, LOCK_UN );
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
fclose ( $fp );
|
||||
@chmod ( $cache_path, 0777 );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function clear($key) {
|
||||
$cache_path = $this->_name ( $key );
|
||||
|
||||
if (file_exists ( $cache_path )) {
|
||||
unlink ( $cache_path );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* class.groupUser.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
@@ -13,13 +14,13 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
* It works with the table GROUP_USER
|
||||
@@ -32,54 +33,60 @@
|
||||
|
||||
/**
|
||||
* GroupUser - GroupUser class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
* @author Julio Cesar Laura Avendaño
|
||||
* @copyright 2007 COLOSA
|
||||
*/
|
||||
|
||||
G::LoadClass('pmObject');
|
||||
G::LoadClass( 'pmObject' );
|
||||
|
||||
class GroupUser extends DBTable
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param object $oConnection
|
||||
* @return variant
|
||||
*/
|
||||
function GroupUser($oConnection = null)
|
||||
{
|
||||
if ($oConnection){
|
||||
return parent::setTo($oConnection, 'GROUP_USER', array('GRP_UID', 'USR_UID'));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $oConnection
|
||||
* @return variant
|
||||
*/
|
||||
function GroupUser ($oConnection = null)
|
||||
{
|
||||
if ($oConnection) {
|
||||
return parent::setTo( $oConnection, 'GROUP_USER', array ('GRP_UID','USR_UID'
|
||||
) );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the Data Base connection
|
||||
* @param object $oConnection
|
||||
* @return variant/ the connection or void
|
||||
*/
|
||||
function setTo($oConnection = null)
|
||||
{
|
||||
if ($oConnection) {
|
||||
return parent::setTo($oConnection, 'GROUP_USER', array('GRP_UID', 'USR_UID'));
|
||||
} else {
|
||||
return;
|
||||
function setTo ($oConnection = null)
|
||||
{
|
||||
if ($oConnection) {
|
||||
return parent::setTo( $oConnection, 'GROUP_USER', array ('GRP_UID','USR_UID'
|
||||
) );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Of to assign a user from a group
|
||||
* @param string $sGroup
|
||||
* @param string $sUser
|
||||
* @return void
|
||||
*/
|
||||
function ofToAssignUser($sGroup = '', $sUser = '')
|
||||
{
|
||||
$this->Fields['GRP_UID'] = $sGroup;
|
||||
$this->Fields['USR_UID'] = $sUser;
|
||||
parent::delete();
|
||||
}
|
||||
/**
|
||||
* Of to assign a user from a group
|
||||
*
|
||||
* @param string $sGroup
|
||||
* @param string $sUser
|
||||
* @return void
|
||||
*/
|
||||
function ofToAssignUser ($sGroup = '', $sUser = '')
|
||||
{
|
||||
$this->Fields['GRP_UID'] = $sGroup;
|
||||
$this->Fields['USR_UID'] = $sUser;
|
||||
parent::delete();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* class.groups.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,11 +14,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -29,6 +30,7 @@ require_once 'classes/model/Users.php';
|
||||
|
||||
/**
|
||||
* Groups - Groups class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
* @copyright 2007 COLOSA
|
||||
*/
|
||||
@@ -36,421 +38,426 @@ require_once 'classes/model/Users.php';
|
||||
class Groups
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the assigned users of a group
|
||||
* @param string $sGroupUID
|
||||
* @return array
|
||||
*/
|
||||
function getUsersOfGroup($sGroupUID)
|
||||
{
|
||||
try {
|
||||
$aUsers = array();
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
$oDataset = UsersPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
/**
|
||||
* Get the assigned users of a group
|
||||
*
|
||||
* @param string $sGroupUID
|
||||
* @return array
|
||||
*/
|
||||
function getUsersOfGroup ($sGroupUID)
|
||||
{
|
||||
try {
|
||||
$aUsers = array ();
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->addJoin( UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->add( GroupUserPeer::GRP_UID, $sGroupUID );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' );
|
||||
$oDataset = UsersPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aUsers[] = $aRow;
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aUsers;
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aUsers[] = $aRow;
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aUsers;
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active groups for an user
|
||||
* @param string $sUserUID
|
||||
* @return array
|
||||
*/
|
||||
function getActiveGroupsForAnUser($sUserUID)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->addSelectColumn(GroupUserPeer::GRP_UID);
|
||||
$oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
|
||||
$oCriteria->add(GroupUserPeer::USR_UID, $sUserUID);
|
||||
$oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
|
||||
$oCriteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN);
|
||||
$oDataset = GroupUserPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
/**
|
||||
* Get the active groups for an user
|
||||
*
|
||||
* @param string $sUserUID
|
||||
* @return array
|
||||
*/
|
||||
function getActiveGroupsForAnUser ($sUserUID)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->addSelectColumn( GroupUserPeer::GRP_UID );
|
||||
$oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
|
||||
$oCriteria->add( GroupUserPeer::USR_UID, $sUserUID );
|
||||
$oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
|
||||
$oCriteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN );
|
||||
$oDataset = GroupUserPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
|
||||
$aGroups = array();
|
||||
$aRow = $oDataset->getRow();
|
||||
while (is_array($aRow)) {
|
||||
$aGroups[] = $aRow['GRP_UID'];
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
}
|
||||
return $aGroups;
|
||||
$aGroups = array ();
|
||||
$aRow = $oDataset->getRow();
|
||||
while (is_array( $aRow )) {
|
||||
$aGroups[] = $aRow['GRP_UID'];
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
}
|
||||
return $aGroups;
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a user to group
|
||||
* @param string $GrpUid, $UsrUid
|
||||
* @return array
|
||||
*/
|
||||
function addUserToGroup($GrpUid, $UsrUid)
|
||||
{
|
||||
try {
|
||||
$oGrp = GroupUserPeer::retrieveByPk($GrpUid, $UsrUid);
|
||||
if (is_object($oGrp) && get_class($oGrp) == 'GroupUser') {
|
||||
return true;
|
||||
} else {
|
||||
$oGrp = new GroupUser();
|
||||
$oGrp->setGrpUid($GrpUid);
|
||||
$oGrp->setUsrUid($UsrUid);
|
||||
$oGrp->Save();
|
||||
}
|
||||
/**
|
||||
* Set a user to group
|
||||
*
|
||||
* @param string $GrpUid, $UsrUid
|
||||
* @return array
|
||||
*/
|
||||
function addUserToGroup ($GrpUid, $UsrUid)
|
||||
{
|
||||
try {
|
||||
$oGrp = GroupUserPeer::retrieveByPk( $GrpUid, $UsrUid );
|
||||
if (is_object( $oGrp ) && get_class( $oGrp ) == 'GroupUser') {
|
||||
return true;
|
||||
} else {
|
||||
$oGrp = new GroupUser();
|
||||
$oGrp->setGrpUid( $GrpUid );
|
||||
$oGrp->setUsrUid( $UsrUid );
|
||||
$oGrp->Save();
|
||||
}
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Remove a user from group
|
||||
* @param string $GrpUid, $UsrUid
|
||||
* @return array
|
||||
*/
|
||||
function removeUserOfGroup($GrpUid, $UsrUid)
|
||||
{
|
||||
$gu = new GroupUser();
|
||||
$gu->remove($GrpUid, $UsrUid);
|
||||
}
|
||||
function removeUserOfGroup ($GrpUid, $UsrUid)
|
||||
{
|
||||
$gu = new GroupUser();
|
||||
$gu->remove( $GrpUid, $UsrUid );
|
||||
}
|
||||
|
||||
/**
|
||||
* get all groups
|
||||
* @param none
|
||||
* @return $objects
|
||||
*/
|
||||
function getAllGroups()
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL);
|
||||
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
|
||||
$objects = GroupwfPeer::doSelect($criteria, $con);
|
||||
return $objects;
|
||||
}
|
||||
catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* get all the groups from a single user
|
||||
* @param $sUserUid user uid
|
||||
* @return an array of group objects
|
||||
*/
|
||||
function getUserGroups($sUserUID)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL);
|
||||
$criteria->add(GroupUserPeer::USR_UID, $sUserUID);
|
||||
$criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
|
||||
$criteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN);
|
||||
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
|
||||
$objects = GroupwfPeer::doSelect($criteria, $con);
|
||||
return $objects;
|
||||
}
|
||||
catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Available Groups for a single user
|
||||
* @author Qennix
|
||||
* @param string $sUserUid
|
||||
* @return object
|
||||
*/
|
||||
|
||||
function getAvailableGroupsCriteria($sUserUid, $filter=''){
|
||||
try{
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(GroupUserPeer::GRP_UID);
|
||||
$oCriteria->add(GroupUserPeer::USR_UID,$sUserUid);
|
||||
$oCriteria->add(GroupUserPeer::GRP_UID,'',Criteria::NOT_EQUAL);
|
||||
$oDataset = GroupUserPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$gUIDs = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$gUIDs[] = $aRow['GRP_UID'];
|
||||
$oDataset->next();
|
||||
/**
|
||||
* get all groups
|
||||
*
|
||||
* @param none
|
||||
* @return $objects
|
||||
*/
|
||||
function getAllGroups ()
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add( GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL );
|
||||
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
|
||||
$objects = GroupwfPeer::doSelect( $criteria, $con );
|
||||
return $objects;
|
||||
} catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
|
||||
$oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
|
||||
$oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
|
||||
$oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupwfPeer::GRP_UID, $gUIDs, Criteria::NOT_IN);
|
||||
$oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
|
||||
$oCriteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
|
||||
$oCriteria->add(ContentPeer::CON_LANG,SYS_LANG);
|
||||
}
|
||||
|
||||
if ($filter !=''){
|
||||
$oCriteria->add(ContentPeer::CON_VALUE,'%'.$filter.'%',Criteria::LIKE);
|
||||
/**
|
||||
* get all the groups from a single user
|
||||
*
|
||||
* @param $sUserUid user uid
|
||||
* @return an array of group objects
|
||||
*/
|
||||
function getUserGroups ($sUserUID)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add( GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL );
|
||||
$criteria->add( GroupUserPeer::USR_UID, $sUserUID );
|
||||
$criteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
|
||||
$criteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN );
|
||||
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
|
||||
$objects = GroupwfPeer::doSelect( $criteria, $con );
|
||||
return $objects;
|
||||
} catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
catch(exception $e){
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get Available Groups for a single user
|
||||
*
|
||||
* @author Qennix
|
||||
* @param string $sUserUid
|
||||
* @return object
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get Assigned Groups for a single user
|
||||
* @author Qennix
|
||||
* @param string $sUserUid
|
||||
* @return object
|
||||
*/
|
||||
function getAvailableGroupsCriteria ($sUserUid, $filter = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( GroupUserPeer::GRP_UID );
|
||||
$oCriteria->add( GroupUserPeer::USR_UID, $sUserUid );
|
||||
$oCriteria->add( GroupUserPeer::GRP_UID, '', Criteria::NOT_EQUAL );
|
||||
$oDataset = GroupUserPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$gUIDs = array ();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$gUIDs[] = $aRow['GRP_UID'];
|
||||
$oDataset->next();
|
||||
}
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( GroupwfPeer::GRP_UID );
|
||||
$oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
|
||||
$oCriteria->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
$oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->add( GroupwfPeer::GRP_UID, $gUIDs, Criteria::NOT_IN );
|
||||
$oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
|
||||
$oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
|
||||
$oCriteria->add( ContentPeer::CON_LANG, SYS_LANG );
|
||||
|
||||
function getAssignedGroupsCriteria($sUserUid, $filter=''){
|
||||
try{
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
|
||||
$oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
|
||||
$oCriteria->addSelectColumn(GroupwfPeer::GRP_LDAP_DN);
|
||||
$oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
|
||||
$oCriteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupUserPeer::USR_UID, $sUserUid, Criteria::EQUAL);
|
||||
$oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
|
||||
$oCriteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
|
||||
$oCriteria->add(ContentPeer::CON_LANG,SYS_LANG);
|
||||
if ($filter != '') {
|
||||
$oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE );
|
||||
}
|
||||
|
||||
if ($filter !=''){
|
||||
$oCriteria->add(ContentPeer::CON_VALUE,'%'.$filter.'%',Criteria::LIKE);
|
||||
return $oCriteria;
|
||||
} catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
catch(exception $e){
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get Assigned Groups for a single user
|
||||
*
|
||||
* @author Qennix
|
||||
* @param string $sUserUid
|
||||
* @return object
|
||||
*/
|
||||
|
||||
function getGroupsForUser($usrUid) {
|
||||
$criteria = $this->getAssignedGroupsCriteria($usrUid);
|
||||
$criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
|
||||
$dataset = GroupwfPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
$groups = array();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (!isset($groups[$row['GRP_UID']])) {
|
||||
$groups[$row['GRP_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
function getAssignedGroupsCriteria ($sUserUid, $filter = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( GroupwfPeer::GRP_UID );
|
||||
$oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
|
||||
$oCriteria->addSelectColumn( GroupwfPeer::GRP_LDAP_DN );
|
||||
$oCriteria->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
$oCriteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->add( GroupUserPeer::USR_UID, $sUserUid, Criteria::EQUAL );
|
||||
$oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
|
||||
$oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
|
||||
$oCriteria->add( ContentPeer::CON_LANG, SYS_LANG );
|
||||
|
||||
/**
|
||||
* Remove a user from all groups
|
||||
* @param string $sUsrUid
|
||||
* @return void
|
||||
*/
|
||||
public function removeUserOfAllGroups($sUserUID = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(GroupUserPeer::USR_UID, $sUserUID);
|
||||
GroupUserPeer::doDelete($oCriteria);
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
if ($filter != '') {
|
||||
$oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a criteria object of all users from group
|
||||
* @param string $sGroupUID
|
||||
* @return array
|
||||
*/
|
||||
function getUsersGroupCriteria($sGroupUID = '')
|
||||
{
|
||||
require_once 'classes/model/GroupUser.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(GroupUserPeer::GRP_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);
|
||||
$oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
return $oCriteria;
|
||||
return $oCriteria;
|
||||
} catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a criteria object of all groups from user
|
||||
* @param string $sGroupUID
|
||||
* @return array
|
||||
*/
|
||||
function getUserGroupsCriteria($sUserUID = '')
|
||||
{
|
||||
require_once 'classes/model/GroupUser.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(GroupUserPeer::GRP_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupUserPeer::GRP_UID, $sUserUID);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
return $oCriteria;
|
||||
function getGroupsForUser ($usrUid)
|
||||
{
|
||||
$criteria = $this->getAssignedGroupsCriteria( $usrUid );
|
||||
$criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE );
|
||||
$dataset = GroupwfPeer::doSelectRS( $criteria );
|
||||
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$dataset->next();
|
||||
$groups = array ();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (! isset( $groups[$row['GRP_UID']] )) {
|
||||
$groups[$row['GRP_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of groups
|
||||
* @param string $sGroupUid
|
||||
* @return integer $cnt
|
||||
*/
|
||||
function getNumberGroups($sUserUID)
|
||||
{
|
||||
try {
|
||||
$allGroups = $this->getUserGroups($sUserUID);
|
||||
$cnt = 0;
|
||||
foreach ($allGroups as $group) {
|
||||
$cnt++;
|
||||
}
|
||||
return $cnt;
|
||||
/**
|
||||
* Remove a user from all groups
|
||||
*
|
||||
* @param string $sUsrUid
|
||||
* @return void
|
||||
*/
|
||||
public function removeUserOfAllGroups ($sUserUID = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( GroupUserPeer::USR_UID, $sUserUID );
|
||||
GroupUserPeer::doDelete( $oCriteria );
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
print_r($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the available users list criteria object
|
||||
* @param string $sGroupUID
|
||||
* @return object
|
||||
*/
|
||||
function getAvailableUsersCriteria($sGroupUID = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
$oDataset = UsersPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aUIDs = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aUIDs[] = $aRow['USR_UID'];
|
||||
$oDataset->next();
|
||||
}
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$oCriteria->add(UsersPeer::USR_UID, $aUIDs, Criteria::NOT_IN);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
return $oCriteria;
|
||||
/**
|
||||
* Get a criteria object of all users from group
|
||||
*
|
||||
* @param string $sGroupUID
|
||||
* @return array
|
||||
*/
|
||||
function getUsersGroupCriteria ($sGroupUID = '')
|
||||
{
|
||||
require_once 'classes/model/GroupUser.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( GroupUserPeer::GRP_UID );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_USERNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_EMAIL );
|
||||
$oCriteria->addJoin( GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->add( GroupUserPeer::GRP_UID, $sGroupUID );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' );
|
||||
return $oCriteria;
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if a user is assigned to a group
|
||||
* @param $GrpUid group Uid
|
||||
* @param $UsrUid user Uid
|
||||
* @return 1/0 if it's or not assigned
|
||||
*/
|
||||
function verifyUsertoGroup($GrpUid, $UsrUid)
|
||||
{
|
||||
try {
|
||||
$oGrp = GroupUserPeer::retrieveByPk($GrpUid, $UsrUid);
|
||||
if (is_object($oGrp) && get_class($oGrp) == 'GroupUser') {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Get a criteria object of all groups from user
|
||||
*
|
||||
* @param string $sGroupUID
|
||||
* @return array
|
||||
*/
|
||||
function getUserGroupsCriteria ($sUserUID = '')
|
||||
{
|
||||
require_once 'classes/model/GroupUser.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( GroupUserPeer::GRP_UID );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
$oCriteria->addJoin( GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->add( GroupUserPeer::GRP_UID, $sUserUID );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' );
|
||||
return $oCriteria;
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the existence of a Group
|
||||
* @param $sGroupUid group Uid
|
||||
* @return 1/0 if exist or not
|
||||
*/
|
||||
function verifyGroup($sGroupUID)
|
||||
{
|
||||
try {
|
||||
$aUsers = array();
|
||||
$oCriteria = new Criteria();
|
||||
//$oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupwfPeer::GRP_UID, $sGroupUID);
|
||||
//$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
if(is_array($aRow))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
/**
|
||||
* Get the number of groups
|
||||
*
|
||||
* @param string $sGroupUid
|
||||
* @return integer $cnt
|
||||
*/
|
||||
function getNumberGroups ($sUserUID)
|
||||
{
|
||||
try {
|
||||
$allGroups = $this->getUserGroups( $sUserUID );
|
||||
$cnt = 0;
|
||||
foreach ($allGroups as $group) {
|
||||
$cnt ++;
|
||||
}
|
||||
return $cnt;
|
||||
} catch (exception $oError) {
|
||||
print_r( $oError );
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all the data of a group with a search based on it uid
|
||||
* @param $GrpUid group uid
|
||||
* @return an array of objects/false/exception object
|
||||
*
|
||||
*/
|
||||
public function load($GrpUid){
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(GroupwfPeer::GRP_UID, $GrpUid, Criteria::EQUAL);
|
||||
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
|
||||
$objects = GroupwfPeer::doSelect($criteria, $con);
|
||||
if(is_array($objects) && count($objects)>0){
|
||||
return $objects[0];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Return the available users list criteria object
|
||||
*
|
||||
* @param string $sGroupUID
|
||||
* @return object
|
||||
*/
|
||||
function getAvailableUsersCriteria ($sGroupUID = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$oCriteria->addJoin( GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->add( GroupUserPeer::GRP_UID, $sGroupUID );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' );
|
||||
$oDataset = UsersPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aUIDs = array ();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aUIDs[] = $aRow['USR_UID'];
|
||||
$oDataset->next();
|
||||
}
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
$oCriteria->add( UsersPeer::USR_UID, $aUIDs, Criteria::NOT_IN );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' );
|
||||
return $oCriteria;
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (exception $e) {
|
||||
throw $e;
|
||||
|
||||
/**
|
||||
* Verify if a user is assigned to a group
|
||||
*
|
||||
* @param $GrpUid group Uid
|
||||
* @param $UsrUid user Uid
|
||||
* @return 1/0 if it's or not assigned
|
||||
*/
|
||||
function verifyUsertoGroup ($GrpUid, $UsrUid)
|
||||
{
|
||||
try {
|
||||
$oGrp = GroupUserPeer::retrieveByPk( $GrpUid, $UsrUid );
|
||||
if (is_object( $oGrp ) && get_class( $oGrp ) == 'GroupUser') {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the existence of a Group
|
||||
*
|
||||
* @param $sGroupUid group Uid
|
||||
* @return 1/0 if exist or not
|
||||
*/
|
||||
function verifyGroup ($sGroupUID)
|
||||
{
|
||||
try {
|
||||
$aUsers = array ();
|
||||
$oCriteria = new Criteria();
|
||||
//$oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add( GroupwfPeer::GRP_UID, $sGroupUID );
|
||||
//$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
$oDataset = GroupwfPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
if (is_array( $aRow ))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all the data of a group with a search based on it uid
|
||||
*
|
||||
* @param $GrpUid group uid
|
||||
* @return an array of objects/false/exception object
|
||||
*
|
||||
*/
|
||||
public function load ($GrpUid)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add( GroupwfPeer::GRP_UID, $GrpUid, Criteria::EQUAL );
|
||||
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
|
||||
$objects = GroupwfPeer::doSelect( $criteria, $con );
|
||||
if (is_array( $objects ) && count( $objects ) > 0) {
|
||||
return $objects[0];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
<?php
|
||||
/**
|
||||
* class.javaBridgePM.php
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,166 +14,160 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined ( 'JAVA_BRIDGE_PATH') ) define ( 'JAVA_BRIDGE_PATH', 'JavaBridgePM' );
|
||||
if ( ! defined ( 'JAVA_BRIDGE_PORT') ) define ( 'JAVA_BRIDGE_PORT', '8080' );
|
||||
if ( ! defined ( 'JAVA_BRIDGE_HOST') ) define ( 'JAVA_BRIDGE_HOST', '127.0.0.1' );
|
||||
|
||||
/**
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
class JavaBridgePM
|
||||
{
|
||||
var $JavaBridgeDir = JAVA_BRIDGE_PATH;
|
||||
if (! defined( 'JAVA_BRIDGE_PATH' ))
|
||||
define( 'JAVA_BRIDGE_PATH', 'JavaBridgePM' );
|
||||
if (! defined( 'JAVA_BRIDGE_PORT' ))
|
||||
define( 'JAVA_BRIDGE_PORT', '8080' );
|
||||
if (! defined( 'JAVA_BRIDGE_HOST' ))
|
||||
define( 'JAVA_BRIDGE_HOST', '127.0.0.1' );
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
class JavaBridgePM
|
||||
{
|
||||
var $JavaBridgeDir = JAVA_BRIDGE_PATH;
|
||||
var $JavaBridgePort = JAVA_BRIDGE_PORT;
|
||||
var $JavaBridgeHost = JAVA_BRIDGE_HOST;
|
||||
|
||||
/**
|
||||
* checkJavaExtension
|
||||
* check if the java extension was loaded.
|
||||
* check if the java extension was loaded.
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
function checkJavaExtension()
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
function checkJavaExtension ()
|
||||
{
|
||||
try {
|
||||
if (!extension_loaded('java')) {
|
||||
if (!(@include_once("java/Java.inc"))) {
|
||||
$urlJavaInc = "http://$this->JavaBridgeHost:$this->JavaBridgePort/$this->JavaBridgeDir/java/Java.inc";
|
||||
@include_once( $urlJavaInc);
|
||||
$includedFiles = get_included_files();
|
||||
$found = false;
|
||||
foreach ($includedFiles as $filename) {
|
||||
if ( $urlJavaInc == $filename ) $found = true;
|
||||
try {
|
||||
if (! extension_loaded( 'java' )) {
|
||||
if (! (@include_once ("java/Java.inc"))) {
|
||||
$urlJavaInc = "http://$this->JavaBridgeHost:$this->JavaBridgePort/$this->JavaBridgeDir/java/Java.inc";
|
||||
@include_once ($urlJavaInc);
|
||||
$includedFiles = get_included_files();
|
||||
$found = false;
|
||||
foreach ($includedFiles as $filename) {
|
||||
if ($urlJavaInc == $filename)
|
||||
$found = true;
|
||||
}
|
||||
if (! $found) {
|
||||
throw new Exception( 'The PHP/Java Bridge is not defined' );
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ( !$found ) {
|
||||
throw new Exception ('The PHP/Java Bridge is not defined' ) ;
|
||||
|
||||
if (! function_exists( "java_get_server_name" )) {
|
||||
throw new Exception( 'The loaded java extension is not the PHP/Java Bridge' );
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
throw new Exception( 'Error in checkJavaExtension: ' . $e->getMessage() );
|
||||
}
|
||||
|
||||
if ( !function_exists("java_get_server_name")) {
|
||||
throw new Exception ('The loaded java extension is not the PHP/Java Bridge' );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch ( Exception $e ) {
|
||||
throw new Exception ( 'Error in checkJavaExtension: ' . $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a php value to a java one...
|
||||
* @param string $value
|
||||
* @param string $className
|
||||
* @returns boolean success
|
||||
*/
|
||||
function convertValue($value, $className)
|
||||
{
|
||||
// if we are a string, just use the normal conversion
|
||||
// methods from the java extension...
|
||||
try {
|
||||
if ($className == 'java.lang.String') {
|
||||
$temp = new Java('java.lang.String', $value);
|
||||
return $temp;
|
||||
}
|
||||
else if ($className == 'java.lang.Boolean' ||
|
||||
$className == 'java.lang.Integer' ||
|
||||
$className == 'java.lang.Long' ||
|
||||
$className == 'java.lang.Short' ||
|
||||
$className == 'java.lang.Double' ||
|
||||
$className == 'java.math.BigDecimal') {
|
||||
$temp = new Java($className, $value);
|
||||
return $temp;
|
||||
}
|
||||
else if ($className == 'java.sql.Timestamp' ||
|
||||
$className == 'java.sql.Time') {
|
||||
$temp = new Java($className);
|
||||
$javaObject = $temp->valueOf($value);
|
||||
return $javaObject;
|
||||
}
|
||||
}
|
||||
catch (Exception $err) {
|
||||
echo ( 'unable to convert value, ' . $value .
|
||||
' could not be converted to ' . $className);
|
||||
return false;
|
||||
}
|
||||
|
||||
echo ( 'unable to convert value, class name '.$className.
|
||||
' not recognised');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* generateJrxmlFromDynaform
|
||||
* @param string $outDocUid
|
||||
* @param string $dynaformUid
|
||||
* @param object $template
|
||||
* @return void
|
||||
*/
|
||||
function generateJrxmlFromDynaform ( $outDocUid, $dynaformUid, $template ) {
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$dyn = new Dynaform();
|
||||
$aFields = $dyn->load( $dynaformUid);
|
||||
$xmlFields = $dyn->getDynaformFields( $dynaformUid);
|
||||
|
||||
$reportTpl = PATH_TPL . 'javaBridgePM/classic.xml';
|
||||
$reportFilename = PATH_DYNAFORM . $aFields['PRO_UID'] . PATH_SEP . $outDocUid .'.jrxml';
|
||||
foreach ( $xmlFields as $key => $val ) {
|
||||
if ( $val->type == 'submit' || $val->type == 'button' || $val->type == 'title' || $val->type == 'subtitle' )
|
||||
unset ( $xmlFields[$key] );
|
||||
}
|
||||
|
||||
//$sqlSentence = 'SELECT * from ' . $tableName;
|
||||
$sqlSentence = 'dynaform/';
|
||||
|
||||
$template = new TemplatePower( $reportTpl );
|
||||
$template->prepare();
|
||||
$template->assign ( 'sqlSentence', $sqlSentence );
|
||||
$template->assign ( 'tableName', $aFields['DYN_TITLE'] );
|
||||
$template->assign ( 'heightDetail', count ($xmlFields)*15 + 20 );
|
||||
$template->assign ( 'PAGE_NUMBER' , '{PAGE_NUMBER}' );
|
||||
* convert a php value to a java one...
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $className
|
||||
* @return s boolean success
|
||||
*/
|
||||
function convertValue ($value, $className)
|
||||
{
|
||||
// if we are a string, just use the normal conversion
|
||||
// methods from the java extension...
|
||||
try {
|
||||
if ($className == 'java.lang.String') {
|
||||
$temp = new Java( 'java.lang.String', $value );
|
||||
return $temp;
|
||||
} else if ($className == 'java.lang.Boolean' || $className == 'java.lang.Integer' || $className == 'java.lang.Long' || $className == 'java.lang.Short' || $className == 'java.lang.Double' || $className == 'java.math.BigDecimal') {
|
||||
$temp = new Java( $className, $value );
|
||||
return $temp;
|
||||
} else if ($className == 'java.sql.Timestamp' || $className == 'java.sql.Time') {
|
||||
$temp = new Java( $className );
|
||||
$javaObject = $temp->valueOf( $value );
|
||||
return $javaObject;
|
||||
}
|
||||
} catch (Exception $err) {
|
||||
echo ('unable to convert value, ' . $value . ' could not be converted to ' . $className);
|
||||
return false;
|
||||
}
|
||||
|
||||
$logoReporte = 'http://' .$_SERVER['SERVER_NAME'] . ':' .$_SERVER['SERVER_PORT'] .
|
||||
'/images/processmaker.logo.jpg';
|
||||
$template->assign ( 'logoReporte', $logoReporte );
|
||||
|
||||
foreach ( $xmlFields as $key => $val ) {
|
||||
$template->newBlock( 'fields');
|
||||
$template->assign ( 'fieldName' , $key );
|
||||
}
|
||||
|
||||
|
||||
$posX = 140;
|
||||
$posLabelX = 5;
|
||||
$posY = 10;
|
||||
foreach ( $xmlFields as $key => $val ) {
|
||||
$template->newBlock( 'detailFields');
|
||||
$template->assign ( 'fieldName' , '{' . $key . '}' );
|
||||
$template->assign ( 'fieldLabel' , $key );
|
||||
$template->assign ( 'labelPosX' , $posLabelX );
|
||||
$template->assign ( 'fieldPosX' , $posX );
|
||||
$template->assign ( 'fieldPosY' , $posY );
|
||||
$posY += 15;
|
||||
}
|
||||
|
||||
$content = $template->getOutputContent();
|
||||
$iSize = file_put_contents ( $reportFilename, $content );
|
||||
printf("saved %s bytes in file %s \n", $iSize, $reportFilename );
|
||||
echo ('unable to convert value, class name ' . $className . ' not recognised');
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* generateJrxmlFromDynaform
|
||||
*
|
||||
* @param string $outDocUid
|
||||
* @param string $dynaformUid
|
||||
* @param object $template
|
||||
* @return void
|
||||
*/
|
||||
function generateJrxmlFromDynaform ($outDocUid, $dynaformUid, $template)
|
||||
{
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$dyn = new Dynaform();
|
||||
$aFields = $dyn->load( $dynaformUid );
|
||||
$xmlFields = $dyn->getDynaformFields( $dynaformUid );
|
||||
|
||||
$reportTpl = PATH_TPL . 'javaBridgePM/classic.xml';
|
||||
$reportFilename = PATH_DYNAFORM . $aFields['PRO_UID'] . PATH_SEP . $outDocUid . '.jrxml';
|
||||
foreach ($xmlFields as $key => $val) {
|
||||
if ($val->type == 'submit' || $val->type == 'button' || $val->type == 'title' || $val->type == 'subtitle')
|
||||
unset( $xmlFields[$key] );
|
||||
}
|
||||
|
||||
//$sqlSentence = 'SELECT * from ' . $tableName;
|
||||
$sqlSentence = 'dynaform/';
|
||||
|
||||
$template = new TemplatePower( $reportTpl );
|
||||
$template->prepare();
|
||||
$template->assign( 'sqlSentence', $sqlSentence );
|
||||
$template->assign( 'tableName', $aFields['DYN_TITLE'] );
|
||||
$template->assign( 'heightDetail', count( $xmlFields ) * 15 + 20 );
|
||||
$template->assign( 'PAGE_NUMBER', '{PAGE_NUMBER}' );
|
||||
|
||||
$logoReporte = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/images/processmaker.logo.jpg';
|
||||
$template->assign( 'logoReporte', $logoReporte );
|
||||
|
||||
foreach ($xmlFields as $key => $val) {
|
||||
$template->newBlock( 'fields' );
|
||||
$template->assign( 'fieldName', $key );
|
||||
}
|
||||
|
||||
$posX = 140;
|
||||
$posLabelX = 5;
|
||||
$posY = 10;
|
||||
foreach ($xmlFields as $key => $val) {
|
||||
$template->newBlock( 'detailFields' );
|
||||
$template->assign( 'fieldName', '{' . $key . '}' );
|
||||
$template->assign( 'fieldLabel', $key );
|
||||
$template->assign( 'labelPosX', $posLabelX );
|
||||
$template->assign( 'fieldPosX', $posX );
|
||||
$template->assign( 'fieldPosY', $posY );
|
||||
$posY += 15;
|
||||
}
|
||||
|
||||
$content = $template->getOutputContent();
|
||||
$iSize = file_put_contents( $reportFilename, $content );
|
||||
printf( "saved %s bytes in file %s \n", $iSize, $reportFilename );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.jrml.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,75 +15,77 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Jrml - Jrml class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
* @author Maborak <maborak@maborak.com>
|
||||
* @copyright 2008 COLOSA
|
||||
*/
|
||||
|
||||
class Jrml
|
||||
class Jrml
|
||||
{
|
||||
public $rows;
|
||||
public $sql;
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* This function is the constructor of the class Jrml
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
function __construct($data=array())
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->sql = $data['sql'];
|
||||
$this->rows = $this->get_rows($data['type']);
|
||||
$this->md = $this->get_md();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for get rows
|
||||
* @param array $a
|
||||
* @return array
|
||||
*/
|
||||
private function get_rows($a)
|
||||
{
|
||||
$b=array();
|
||||
foreach ($a as $key=>$value){
|
||||
$b[]=$key;
|
||||
}
|
||||
return $b;
|
||||
}
|
||||
|
||||
public function get_md()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for get the header
|
||||
* @return string
|
||||
*/
|
||||
public function get_header()
|
||||
{
|
||||
$xml="<queryString><![CDATA[{$this->sql}]]></queryString>";
|
||||
foreach ($this->data['type'] as $key=>$value)
|
||||
public $rows;
|
||||
public $sql;
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* This function is the constructor of the class Jrml
|
||||
*
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
function __construct ($data = array())
|
||||
{
|
||||
$xml.="<field name='{$key}' class='{$value}'><fieldDescription><![CDATA[]]></fieldDescription></field>";
|
||||
$this->data = $data;
|
||||
$this->sql = $data['sql'];
|
||||
$this->rows = $this->get_rows( $data['type'] );
|
||||
$this->md = $this->get_md();
|
||||
}
|
||||
$xml.="<background><band/></background>";
|
||||
$xml.='
|
||||
|
||||
/**
|
||||
* This function is for get rows
|
||||
*
|
||||
* @param array $a
|
||||
* @return array
|
||||
*/
|
||||
private function get_rows ($a)
|
||||
{
|
||||
$b = array ();
|
||||
foreach ($a as $key => $value) {
|
||||
$b[] = $key;
|
||||
}
|
||||
return $b;
|
||||
}
|
||||
|
||||
public function get_md ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for get the header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_header ()
|
||||
{
|
||||
$xml = "<queryString><![CDATA[{$this->sql}]]></queryString>";
|
||||
foreach ($this->data['type'] as $key => $value) {
|
||||
$xml .= "<field name='{$key}' class='{$value}'><fieldDescription><![CDATA[]]></fieldDescription></field>";
|
||||
}
|
||||
$xml .= "<background><band/></background>";
|
||||
$xml .= '
|
||||
<title>
|
||||
<band height="58">
|
||||
<line>
|
||||
@@ -95,64 +99,65 @@ class Jrml
|
||||
<textElement textAlignment="Center">
|
||||
<font size="26" isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA['.$this->data['title'].']]></text>
|
||||
<text><![CDATA[' . $this->data['title'] . ']]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</title>
|
||||
<pageHeader>
|
||||
<band/>
|
||||
</pageHeader>';
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for get a column of the header
|
||||
* @return string
|
||||
*/
|
||||
public function get_column_header()
|
||||
{
|
||||
$xml="<columnHeader><band height='18'>";
|
||||
$w = (int)($this->data['columnWidth']/sizeof($this->rows));
|
||||
$i=0;
|
||||
foreach ($this->data['type'] as $key=>$value)
|
||||
</pageHeader>';
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for get a column of the header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_column_header ()
|
||||
{
|
||||
$xml.="<staticText><reportElement mode='Opaque' x='{$i}' y='0' width='{$w}' height='18' forecolor='#FFFFFF' backcolor='#999999'/>
|
||||
$xml = "<columnHeader><band height='18'>";
|
||||
$w = (int) ($this->data['columnWidth'] / sizeof( $this->rows ));
|
||||
$i = 0;
|
||||
foreach ($this->data['type'] as $key => $value) {
|
||||
$xml .= "<staticText><reportElement mode='Opaque' x='{$i}' y='0' width='{$w}' height='18' forecolor='#FFFFFF' backcolor='#999999'/>
|
||||
<textElement>
|
||||
<font size='12'/>
|
||||
</textElement>
|
||||
<text><![CDATA[{$key}]]></text>
|
||||
</staticText>";
|
||||
$i=$i+$w;
|
||||
$i = $i + $w;
|
||||
}
|
||||
$xml .= " </band></columnHeader>";
|
||||
return $xml;
|
||||
}
|
||||
$xml.=" </band></columnHeader>";
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for get the detail
|
||||
* @return string
|
||||
*/
|
||||
public function get_detail()
|
||||
{
|
||||
$xml='<detail><band height="20">';
|
||||
$w = (int)($this->data['columnWidth']/sizeof($this->rows));
|
||||
$i=0;
|
||||
foreach ($this->data['type'] as $key=>$value)
|
||||
|
||||
/**
|
||||
* This function is for get the detail
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_detail ()
|
||||
{
|
||||
$xml.="<textField hyperlinkType='None'><reportElement x='{$i}' y='0' width='{$w}' height='20'/><textElement><font size='12'/></textElement><textFieldExpression class='{$value}'><![CDATA[\$F{{$key}}]]></textFieldExpression></textField>";
|
||||
$i=$i+$w;
|
||||
$xml = '<detail><band height="20">';
|
||||
$w = (int) ($this->data['columnWidth'] / sizeof( $this->rows ));
|
||||
$i = 0;
|
||||
foreach ($this->data['type'] as $key => $value) {
|
||||
$xml .= "<textField hyperlinkType='None'><reportElement x='{$i}' y='0' width='{$w}' height='20'/><textElement><font size='12'/></textElement><textFieldExpression class='{$value}'><![CDATA[\$F{{$key}}]]></textFieldExpression></textField>";
|
||||
$i = $i + $w;
|
||||
}
|
||||
$xml .= '</band></detail>';
|
||||
return $xml;
|
||||
}
|
||||
$xml.='</band></detail>';
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for get the footer
|
||||
* @return string
|
||||
*/
|
||||
public function get_footer()
|
||||
{
|
||||
$xml='<columnFooter>
|
||||
|
||||
/**
|
||||
* This function is for get the footer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_footer ()
|
||||
{
|
||||
$xml = '<columnFooter>
|
||||
<band/>
|
||||
</columnFooter>
|
||||
<pageFooter>
|
||||
@@ -201,22 +206,23 @@ class Jrml
|
||||
<summary>
|
||||
<band/>
|
||||
</summary>';
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for export
|
||||
* @return string
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$xml='<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="'.$this->data['name'].'" pageWidth="'.$this->data['pageWidth'].'" pageHeight="842" columnWidth="'.$this->data['columnWidth'].'" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">';
|
||||
$xml.=$this->get_header();
|
||||
$xml.=$this->get_column_header();
|
||||
$xml.=$this->get_detail();
|
||||
$xml.=$this->get_footer();
|
||||
$xml.='</jasperReport>';
|
||||
return $xml;
|
||||
}
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for export
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function export ()
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="' . $this->data['name'] . '" pageWidth="' . $this->data['pageWidth'] . '" pageHeight="842" columnWidth="' . $this->data['columnWidth'] . '" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">';
|
||||
$xml .= $this->get_header();
|
||||
$xml .= $this->get_column_header();
|
||||
$xml .= $this->get_detail();
|
||||
$xml .= $this->get_footer();
|
||||
$xml .= '</jasperReport>';
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.memcached.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,11 +15,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -30,158 +32,169 @@
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
|
||||
class PMmemcached {
|
||||
const ONE_MINUTE = 60;
|
||||
const ONE_HOUR = 3600;
|
||||
const TWO_HOURS = 7200;
|
||||
const EIGHT_HOURS = 28800;
|
||||
class PMmemcached
|
||||
{
|
||||
const ONE_MINUTE = 60;
|
||||
const ONE_HOUR = 3600;
|
||||
const TWO_HOURS = 7200;
|
||||
const EIGHT_HOURS = 28800;
|
||||
|
||||
var $version;
|
||||
var $mem;
|
||||
var $connected = false;
|
||||
var $enabled = false;
|
||||
var $supported = false;
|
||||
var $version;
|
||||
var $mem;
|
||||
var $connected = false;
|
||||
var $enabled = false;
|
||||
var $supported = false;
|
||||
|
||||
private static $instance = NULL;
|
||||
private static $instance = NULL;
|
||||
|
||||
public function __construct($workspace) {
|
||||
$this->enabled = MEMCACHED_ENABLED;
|
||||
$this->connected = false;
|
||||
$this->workspace = $workspace;
|
||||
if (class_exists ( 'Memcached' )) {
|
||||
$this->mem = new Memcached ();
|
||||
$this->class = 'Memcached';
|
||||
$this->connected = true;
|
||||
}
|
||||
else {
|
||||
if (class_exists ( 'Memcache' )) {
|
||||
$this->mem = new Memcache ();
|
||||
$this->class = 'Memcache';
|
||||
$this->supported = true;
|
||||
$this->connected = @$this->mem->connect ( MEMCACHED_SERVER, 11211 );
|
||||
if ($this->connected) {
|
||||
$this->version = $this->mem->getVersion ();
|
||||
public function __construct ($workspace)
|
||||
{
|
||||
$this->enabled = MEMCACHED_ENABLED;
|
||||
$this->connected = false;
|
||||
$this->workspace = $workspace;
|
||||
if (class_exists( 'Memcached' )) {
|
||||
$this->mem = new Memcached();
|
||||
$this->class = 'Memcached';
|
||||
$this->connected = true;
|
||||
} else {
|
||||
if (class_exists( 'Memcache' )) {
|
||||
$this->mem = new Memcache();
|
||||
$this->class = 'Memcache';
|
||||
$this->supported = true;
|
||||
$this->connected = @$this->mem->connect( MEMCACHED_SERVER, 11211 );
|
||||
if ($this->connected) {
|
||||
$this->version = $this->mem->getVersion();
|
||||
}
|
||||
} else {
|
||||
G::Loadclass( 'fileCache' );
|
||||
// create cache folder
|
||||
$cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/";
|
||||
if (! file_exists( $cacheFolder )) {
|
||||
if (! mkdir( $cacheFolder )) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->class = 'fileCache';
|
||||
$this->connected = true;
|
||||
$this->mem = new FileCache( $cacheFolder );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
G::Loadclass ( 'fileCache' );
|
||||
// create cache folder
|
||||
$cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/";
|
||||
if (! file_exists ( $cacheFolder )) {
|
||||
if (! mkdir ( $cacheFolder )) {
|
||||
|
||||
if (! MEMCACHED_ENABLED) {
|
||||
$this->connected = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->class = 'fileCache';
|
||||
$this->connected = true;
|
||||
$this->mem = new FileCache ( $cacheFolder );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! MEMCACHED_ENABLED) {
|
||||
$this->connected = false;
|
||||
return false;
|
||||
/**
|
||||
* to get singleton instance
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getSingleton ($workspace)
|
||||
{
|
||||
if (! self::$instance instanceof self) {
|
||||
self::$instance = new PMmemcached( $workspace );
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* to get singleton instance
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getSingleton($workspace) {
|
||||
if (! self::$instance instanceof self) {
|
||||
self::$instance = new PMmemcached ( $workspace );
|
||||
public function __clone ()
|
||||
{
|
||||
throw new Exception( "Clone is not allowed." );
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
throw new Exception ( "Clone is not allowed." );
|
||||
}
|
||||
public function __wakeup ()
|
||||
{
|
||||
throw new Exception( "Deserializing is not allowed." );
|
||||
}
|
||||
|
||||
public function __wakeup() {
|
||||
throw new Exception ( "Deserializing is not allowed." );
|
||||
}
|
||||
function set ($key, $object, $timeout = 0)
|
||||
{
|
||||
if (! $this->connected)
|
||||
return false;
|
||||
if ($this->class != 'filecache')
|
||||
$this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout );
|
||||
else
|
||||
$this->mem->set( $this->workspace . '_' . $key, $object );
|
||||
}
|
||||
|
||||
function set($key, $object, $timeout = 0) {
|
||||
if (! $this->connected)
|
||||
return false;
|
||||
if ($this->class != 'filecache')
|
||||
$this->mem->set ( $this->workspace . '_' . $key, $object, false, $timeout );
|
||||
else
|
||||
$this->mem->set ( $this->workspace . '_' . $key, $object );
|
||||
}
|
||||
function get ($key)
|
||||
{
|
||||
if (! $this->connected)
|
||||
return false;
|
||||
return $this->mem->get( $this->workspace . '_' . $key );
|
||||
}
|
||||
|
||||
function get($key) {
|
||||
if (! $this->connected)
|
||||
return false;
|
||||
return $this->mem->get ( $this->workspace . '_' . $key );
|
||||
}
|
||||
function add ($key, $value)
|
||||
{
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->add( $this->workspace . '_' . $key, $value );
|
||||
}
|
||||
|
||||
function add($key, $value) {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->add ( $this->workspace . '_' . $key, $value );
|
||||
}
|
||||
function increment ($key, $value)
|
||||
{
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->increment( $this->workspace . '_' . $key, $value );
|
||||
}
|
||||
|
||||
function increment($key, $value) {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->increment ( $this->workspace . '_' . $key, $value );
|
||||
}
|
||||
function delete ($key)
|
||||
{
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->delete( $this->workspace . '_' . $key );
|
||||
}
|
||||
|
||||
function delete($key) {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->delete ( $this->workspace . '_' . $key );
|
||||
}
|
||||
function flush ()
|
||||
{
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->flush();
|
||||
}
|
||||
|
||||
function flush() {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->flush ();
|
||||
}
|
||||
function getStats ()
|
||||
{
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $status = $this->mem->getStats();
|
||||
}
|
||||
|
||||
function getStats() {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $status = $this->mem->getStats ();
|
||||
}
|
||||
function printDetails ()
|
||||
{
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
$status = $this->mem->getStats();
|
||||
echo "<table border='1'>";
|
||||
echo "<tr><td>Memcache Server version:</td><td> " . $status["version"] . "</td></tr>";
|
||||
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status["uptime"] / 3660) . "</td></tr>";
|
||||
echo "<tr><td>Total number of items stored by this server ever since it started </td><td>" . $status["total_items"] . "</td></tr>";
|
||||
echo "<tr><td>Number of open connections </td><td>" . $status["curr_connections"] . "</td></tr>";
|
||||
echo "<tr><td>Total number of connections opened since the server started running </td><td>" . $status["total_connections"] . "</td></tr>";
|
||||
echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status["connection_structures"] . "</td></tr>";
|
||||
echo "<tr><td>Cumulative number of retrieval requests </td><td>" . $status["cmd_get"] . "</td></tr>";
|
||||
echo "<tr><td> Cumulative number of storage requests </td><td>" . $status["cmd_set"] . "</td></tr>";
|
||||
|
||||
function printDetails() {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
$status = $this->mem->getStats ();
|
||||
echo "<table border='1'>";
|
||||
echo "<tr><td>Memcache Server version:</td><td> " . $status ["version"] . "</td></tr>";
|
||||
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status ["uptime"] / 3660) . "</td></tr>";
|
||||
echo "<tr><td>Total number of items stored by this server ever since it started </td><td>" . $status ["total_items"] . "</td></tr>";
|
||||
echo "<tr><td>Number of open connections </td><td>" . $status ["curr_connections"] . "</td></tr>";
|
||||
echo "<tr><td>Total number of connections opened since the server started running </td><td>" . $status ["total_connections"] . "</td></tr>";
|
||||
echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status ["connection_structures"] . "</td></tr>";
|
||||
echo "<tr><td>Cumulative number of retrieval requests </td><td>" . $status ["cmd_get"] . "</td></tr>";
|
||||
echo "<tr><td> Cumulative number of storage requests </td><td>" . $status ["cmd_set"] . "</td></tr>";
|
||||
$percCacheHit = ((real) $status["get_hits"] / (real) $status["cmd_get"] * 100);
|
||||
$percCacheHit = round( $percCacheHit, 3 );
|
||||
$percCacheMiss = 100 - $percCacheHit;
|
||||
|
||||
$percCacheHit = (( real ) $status ["get_hits"] / ( real ) $status ["cmd_get"] * 100);
|
||||
$percCacheHit = round ( $percCacheHit, 3 );
|
||||
$percCacheMiss = 100 - $percCacheHit;
|
||||
echo "<tr><td>Number of keys that have been requested and found present </td><td>" . $status["get_hits"] . " ($percCacheHit%)</td></tr>";
|
||||
echo "<tr><td>Number of items that have been requested and not found </td><td>" . $status["get_misses"] . "($percCacheMiss%)</td></tr>";
|
||||
|
||||
echo "<tr><td>Number of keys that have been requested and found present </td><td>" . $status ["get_hits"] . " ($percCacheHit%)</td></tr>";
|
||||
echo "<tr><td>Number of items that have been requested and not found </td><td>" . $status ["get_misses"] . "($percCacheMiss%)</td></tr>";
|
||||
$MBRead = (real) $status["bytes_read"] / (1024 * 1024);
|
||||
|
||||
$MBRead = ( real ) $status ["bytes_read"] / (1024 * 1024);
|
||||
|
||||
echo "<tr><td>Total number of bytes read by this server from network </td><td>" . $MBRead . " Mega Bytes</td></tr>";
|
||||
$MBWrite = ( real ) $status ["bytes_written"] / (1024 * 1024);
|
||||
echo "<tr><td>Total number of bytes sent by this server to network </td><td>" . $MBWrite . " Mega Bytes</td></tr>";
|
||||
$MBSize = ( real ) $status ["limit_maxbytes"] / (1024 * 1024);
|
||||
echo "<tr><td>Number of bytes this server is allowed to use for storage.</td><td>" . $MBSize . " Mega Bytes</td></tr>";
|
||||
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>" . $status ["evictions"] . "</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
echo "<tr><td>Total number of bytes read by this server from network </td><td>" . $MBRead . " Mega Bytes</td></tr>";
|
||||
$MBWrite = (real) $status["bytes_written"] / (1024 * 1024);
|
||||
echo "<tr><td>Total number of bytes sent by this server to network </td><td>" . $MBWrite . " Mega Bytes</td></tr>";
|
||||
$MBSize = (real) $status["limit_maxbytes"] / (1024 * 1024);
|
||||
echo "<tr><td>Number of bytes this server is allowed to use for storage.</td><td>" . $MBSize . " Mega Bytes</td></tr>";
|
||||
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>" . $status["evictions"] . "</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,346 +4,348 @@ require_once 'classes/interfaces/dashletInterface.php';
|
||||
require_once 'classes/model/Dashlet.php';
|
||||
require_once 'classes/model/DashletInstance.php';
|
||||
|
||||
class PMDashlet extends DashletInstance implements DashletInterface {
|
||||
class PMDashlet extends DashletInstance implements DashletInterface
|
||||
{
|
||||
|
||||
// Own properties
|
||||
private $dashletInstance;
|
||||
private $dashletObject;
|
||||
// Own properties
|
||||
private $dashletInstance;
|
||||
private $dashletObject;
|
||||
|
||||
// Interface functions
|
||||
|
||||
public static function getAdditionalFields($className) {
|
||||
try {
|
||||
if (!class_exists($className)) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $className . '.php';
|
||||
}
|
||||
G::LoadClass($className);
|
||||
eval("\$additionalFields = $className::getAdditionalFields(\$className);");
|
||||
return $additionalFields;
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
// Interface functions
|
||||
|
||||
|
||||
|
||||
public function setup($dasInsUid) {
|
||||
try {
|
||||
$this->dashletInstance = $this->loadDashletInstance($dasInsUid);
|
||||
if (!isset($this->dashletInstance['DAS_CLASS'])) {
|
||||
throw new Exception(G::LoadTranslation('ID_ERROR_OBJECT_NOT_EXISTS') . ' - Probably the plugin related is disabled');
|
||||
}
|
||||
$className = $this->dashletInstance['DAS_CLASS'];
|
||||
G::LoadClass($className);
|
||||
if (!class_exists($className)) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $className . '.php';
|
||||
}
|
||||
$this->dashletObject = new $className();
|
||||
$this->dashletObject->setup($this->dashletInstance);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function render($width = 300) {
|
||||
try {
|
||||
if (is_null($this->dashletObject)) {
|
||||
throw new Exception('Please call to the function "setup" before call the function "render".');
|
||||
}
|
||||
$this->dashletObject->render($width);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
// Getter and Setters
|
||||
|
||||
public function getDashletInstance() {
|
||||
return $this->dashletInstance;
|
||||
}
|
||||
|
||||
public function getDashletObject() {
|
||||
return $this->dashletObject;
|
||||
}
|
||||
|
||||
// Own functions
|
||||
|
||||
public function getDashletsInstances($start = null, $limit = null) {
|
||||
try {
|
||||
$dashletsInstances = array();
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn('*');
|
||||
$criteria->addJoin(DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN);
|
||||
if (!is_null($start)) {
|
||||
$criteria->setOffset($start);
|
||||
}
|
||||
if (!is_null($limit)) {
|
||||
$criteria->setLimit($limit);
|
||||
}
|
||||
$dataset = DashletInstancePeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
$arrayField = unserialize($row["DAS_INS_ADDITIONAL_PROPERTIES"]);
|
||||
|
||||
$row['DAS_INS_STATUS_LABEL'] = ($row['DAS_INS_STATUS'] == '1' ? G::LoadTranslation('ID_ACTIVE') : G::LoadTranslation('ID_INACTIVE'));
|
||||
$row['DAS_INS_TITLE'] = (isset($arrayField['DAS_INS_TITLE']) && !empty($arrayField['DAS_INS_TITLE']))? $arrayField['DAS_INS_TITLE'] : '';
|
||||
if (!class_exists($row['DAS_CLASS'])) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $row['DAS_CLASS'] . '.php';
|
||||
public static function getAdditionalFields ($className)
|
||||
{
|
||||
try {
|
||||
if (! class_exists( $className )) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $className . '.php';
|
||||
}
|
||||
G::LoadClass( $className );
|
||||
eval( "\$additionalFields = $className::getAdditionalFields(\$className);" );
|
||||
return $additionalFields;
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
eval("\$row['DAS_VERSION'] = defined('" . $row['DAS_CLASS'] . "::version') ? " . $row['DAS_CLASS'] . "::version : \$row['DAS_VERSION'];");
|
||||
}
|
||||
|
||||
switch ($row['DAS_INS_OWNER_TYPE']) {
|
||||
case 'EVERYBODY':
|
||||
$row['DAS_INS_OWNER_TITLE'] = G::LoadTranslation('ID_ALL_USERS');
|
||||
break;
|
||||
case 'USER':
|
||||
require_once 'classes/model/Users.php';
|
||||
$userInstance = new Users();
|
||||
try {
|
||||
$user = $userInstance->load($row['DAS_INS_OWNER_UID']);
|
||||
$row['DAS_INS_OWNER_TITLE'] = $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME'];
|
||||
public function setup ($dasInsUid)
|
||||
{
|
||||
try {
|
||||
$this->dashletInstance = $this->loadDashletInstance( $dasInsUid );
|
||||
if (! isset( $this->dashletInstance['DAS_CLASS'] )) {
|
||||
throw new Exception( G::LoadTranslation( 'ID_ERROR_OBJECT_NOT_EXISTS' ) . ' - Probably the plugin related is disabled' );
|
||||
}
|
||||
catch (Exception $error) {
|
||||
$this->remove($row['DAS_INS_UID']);
|
||||
$row['DAS_INS_UID'] = '';
|
||||
$className = $this->dashletInstance['DAS_CLASS'];
|
||||
G::LoadClass( $className );
|
||||
if (! class_exists( $className )) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $className . '.php';
|
||||
}
|
||||
break;
|
||||
case 'DEPARTMENT':
|
||||
$this->dashletObject = new $className();
|
||||
$this->dashletObject->setup( $this->dashletInstance );
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function render ($width = 300)
|
||||
{
|
||||
try {
|
||||
if (is_null( $this->dashletObject )) {
|
||||
throw new Exception( 'Please call to the function "setup" before call the function "render".' );
|
||||
}
|
||||
$this->dashletObject->render( $width );
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
// Getter and Setters
|
||||
|
||||
|
||||
public function getDashletInstance ()
|
||||
{
|
||||
return $this->dashletInstance;
|
||||
}
|
||||
|
||||
public function getDashletObject ()
|
||||
{
|
||||
return $this->dashletObject;
|
||||
}
|
||||
|
||||
// Own functions
|
||||
|
||||
|
||||
public function getDashletsInstances ($start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$dashletsInstances = array ();
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( '*' );
|
||||
$criteria->addJoin( DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN );
|
||||
if (! is_null( $start )) {
|
||||
$criteria->setOffset( $start );
|
||||
}
|
||||
if (! is_null( $limit )) {
|
||||
$criteria->setLimit( $limit );
|
||||
}
|
||||
$dataset = DashletInstancePeer::doSelectRS( $criteria );
|
||||
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
$arrayField = unserialize( $row["DAS_INS_ADDITIONAL_PROPERTIES"] );
|
||||
|
||||
$row['DAS_INS_STATUS_LABEL'] = ($row['DAS_INS_STATUS'] == '1' ? G::LoadTranslation( 'ID_ACTIVE' ) : G::LoadTranslation( 'ID_INACTIVE' ));
|
||||
$row['DAS_INS_TITLE'] = (isset( $arrayField['DAS_INS_TITLE'] ) && ! empty( $arrayField['DAS_INS_TITLE'] )) ? $arrayField['DAS_INS_TITLE'] : '';
|
||||
if (! class_exists( $row['DAS_CLASS'] )) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $row['DAS_CLASS'] . '.php';
|
||||
}
|
||||
eval( "\$row['DAS_VERSION'] = defined('" . $row['DAS_CLASS'] . "::version') ? " . $row['DAS_CLASS'] . "::version : \$row['DAS_VERSION'];" );
|
||||
|
||||
switch ($row['DAS_INS_OWNER_TYPE']) {
|
||||
case 'EVERYBODY':
|
||||
$row['DAS_INS_OWNER_TITLE'] = G::LoadTranslation( 'ID_ALL_USERS' );
|
||||
break;
|
||||
case 'USER':
|
||||
require_once 'classes/model/Users.php';
|
||||
$userInstance = new Users();
|
||||
try {
|
||||
$user = $userInstance->load( $row['DAS_INS_OWNER_UID'] );
|
||||
$row['DAS_INS_OWNER_TITLE'] = $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME'];
|
||||
} catch (Exception $error) {
|
||||
$this->remove( $row['DAS_INS_UID'] );
|
||||
$row['DAS_INS_UID'] = '';
|
||||
}
|
||||
break;
|
||||
case 'DEPARTMENT':
|
||||
require_once 'classes/model/Department.php';
|
||||
$departmentInstance = new Department();
|
||||
try {
|
||||
$department = $departmentInstance->load( $row['DAS_INS_OWNER_UID'] );
|
||||
$row['DAS_INS_OWNER_TITLE'] = $department['DEPO_TITLE'];
|
||||
} catch (Exception $error) {
|
||||
$this->remove( $row['DAS_INS_UID'] );
|
||||
$row['DAS_INS_UID'] = '';
|
||||
}
|
||||
break;
|
||||
case 'GROUP':
|
||||
require_once 'classes/model/Groupwf.php';
|
||||
$groupInstance = new Groupwf();
|
||||
try {
|
||||
$group = $groupInstance->load( $row['DAS_INS_OWNER_UID'] );
|
||||
$row['DAS_INS_OWNER_TITLE'] = $group['GRP_TITLE'];
|
||||
} catch (Exception $error) {
|
||||
$this->remove( $row['DAS_INS_UID'] );
|
||||
$row['DAS_INS_UID'] = '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$row['DAS_INS_OWNER_TITLE'] = $row['DAS_INS_OWNER_TYPE'];
|
||||
break;
|
||||
}
|
||||
if ($row['DAS_INS_UID'] != '') {
|
||||
$dashletsInstances[] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
return $dashletsInstances;
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDashletsInstancesQuantity ()
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( '*' );
|
||||
$criteria->addJoin( DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN );
|
||||
return DashletInstancePeer::doCount( $criteria );
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function loadDashletInstance ($dasInsUid)
|
||||
{
|
||||
try {
|
||||
$dashletInstance = $this->load( $dasInsUid );
|
||||
//Load data from the serialized field
|
||||
$dashlet = new Dashlet();
|
||||
$dashletFields = $dashlet->load( $dashletInstance['DAS_UID'] );
|
||||
if (is_null( $dashletFields )) {
|
||||
$dashletFields = array ();
|
||||
}
|
||||
return array_merge( $dashletFields, $dashletInstance );
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function saveDashletInstance ($data)
|
||||
{
|
||||
try {
|
||||
$this->createOrUpdate( $data );
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteDashletInstance ($dasInsUid)
|
||||
{
|
||||
try {
|
||||
$this->remove( $dasInsUid );
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDashletsInstancesForUser ($userUid)
|
||||
{
|
||||
try {
|
||||
$dashletsInstances = array ();
|
||||
// Include required classes
|
||||
require_once 'classes/model/Department.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
// Check for "public" dashlets
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_UID );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_CLASS );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_TITLE );
|
||||
$criteria->addJoin( DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN );
|
||||
$criteria->add( DashletInstancePeer::DAS_INS_OWNER_TYPE, 'EVERYBODY' );
|
||||
$dataset = DashletInstancePeer::doSelectRS( $criteria );
|
||||
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (! isset( $dashletsInstances[$row['DAS_INS_UID']] )) {
|
||||
$arrayField = unserialize( $row["DAS_INS_ADDITIONAL_PROPERTIES"] );
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate( $row['DAS_CLASS'] );
|
||||
$row["DAS_TITLE"] = (isset( $arrayField["DAS_INS_TITLE"] ) && ! empty( $arrayField["DAS_INS_TITLE"] )) ? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset( $arrayField["DAS_INS_SUBTITLE"] ) && ! empty( $arrayField["DAS_INS_SUBTITLE"] )) ? str_replace( "@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"] ) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
// Check for the direct assignments
|
||||
$usersInstance = new Users();
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_UID );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_CLASS );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_TITLE );
|
||||
$criteria->addJoin( DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN );
|
||||
$criteria->add( DashletInstancePeer::DAS_INS_OWNER_TYPE, 'USER' );
|
||||
$criteria->add( DashletInstancePeer::DAS_INS_OWNER_UID, $userUid );
|
||||
$dataset = DashletInstancePeer::doSelectRS( $criteria );
|
||||
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (! isset( $dashletsInstances[$row['DAS_INS_UID']] )) {
|
||||
$arrayField = unserialize( $row["DAS_INS_ADDITIONAL_PROPERTIES"] );
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate( $row['DAS_CLASS'] );
|
||||
$row["DAS_TITLE"] = (isset( $arrayField["DAS_INS_TITLE"] ) && ! empty( $arrayField["DAS_INS_TITLE"] )) ? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset( $arrayField["DAS_INS_SUBTITLE"] ) && ! empty( $arrayField["DAS_INS_SUBTITLE"] )) ? str_replace( "@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"] ) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
// Check for department assigments
|
||||
$departmentInstance = new Department();
|
||||
try {
|
||||
$department = $departmentInstance->load($row['DAS_INS_OWNER_UID']);
|
||||
$row['DAS_INS_OWNER_TITLE'] = $department['DEPO_TITLE'];
|
||||
$departments = $departmentInstance->getDepartmentsForUser( $userUid );
|
||||
foreach ($departments as $depUid => $department) {
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_UID );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_CLASS );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_TITLE );
|
||||
$criteria->addJoin( DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN );
|
||||
$criteria->add( DashletInstancePeer::DAS_INS_OWNER_TYPE, 'DEPARTMENT' );
|
||||
$criteria->add( DashletInstancePeer::DAS_INS_OWNER_UID, $depUid );
|
||||
$dataset = DashletInstancePeer::doSelectRS( $criteria );
|
||||
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (! isset( $dashletsInstances[$row['DAS_INS_UID']] )) {
|
||||
$arrayField = unserialize( $row["DAS_INS_ADDITIONAL_PROPERTIES"] );
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate( $row['DAS_CLASS'] );
|
||||
$row["DAS_TITLE"] = (isset( $arrayField["DAS_INS_TITLE"] ) && ! empty( $arrayField["DAS_INS_TITLE"] )) ? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset( $arrayField["DAS_INS_SUBTITLE"] ) && ! empty( $arrayField["DAS_INS_SUBTITLE"] )) ? str_replace( "@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"] ) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
}
|
||||
catch (Exception $error) {
|
||||
$this->remove($row['DAS_INS_UID']);
|
||||
$row['DAS_INS_UID'] = '';
|
||||
// Check for group assignments
|
||||
G::LoadClass( 'groups' );
|
||||
$groupsInstance = new Groups();
|
||||
$groups = $groupsInstance->getGroupsForUser( $userUid );
|
||||
foreach ($groups as $grpUid => $group) {
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_UID );
|
||||
$criteria->addSelectColumn( DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_CLASS );
|
||||
$criteria->addSelectColumn( DashletPeer::DAS_TITLE );
|
||||
$criteria->addJoin( DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN );
|
||||
$criteria->add( DashletInstancePeer::DAS_INS_OWNER_TYPE, 'GROUP' );
|
||||
$criteria->add( DashletInstancePeer::DAS_INS_OWNER_UID, $grpUid );
|
||||
$dataset = DashletInstancePeer::doSelectRS( $criteria );
|
||||
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (! isset( $dashletsInstances[$row['DAS_INS_UID']] )) {
|
||||
$arrayField = unserialize( $row["DAS_INS_ADDITIONAL_PROPERTIES"] );
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate( $row['DAS_CLASS'] );
|
||||
$row["DAS_TITLE"] = (isset( $arrayField["DAS_INS_TITLE"] ) && ! empty( $arrayField["DAS_INS_TITLE"] )) ? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset( $arrayField["DAS_INS_SUBTITLE"] ) && ! empty( $arrayField["DAS_INS_SUBTITLE"] )) ? str_replace( "@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"] ) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'GROUP':
|
||||
require_once 'classes/model/Groupwf.php';
|
||||
$groupInstance = new Groupwf();
|
||||
try {
|
||||
$group = $groupInstance->load($row['DAS_INS_OWNER_UID']);
|
||||
$row['DAS_INS_OWNER_TITLE'] = $group['GRP_TITLE'];
|
||||
// Check for role assigments
|
||||
// ToDo: Next release
|
||||
// Check for permission assigments
|
||||
// ToDo: Next release
|
||||
return array_values( $dashletsInstances );
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getXTemplate ($className)
|
||||
{
|
||||
try {
|
||||
if (! class_exists( $className )) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $className . '.php';
|
||||
}
|
||||
catch (Exception $error) {
|
||||
$this->remove($row['DAS_INS_UID']);
|
||||
$row['DAS_INS_UID'] = '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$row['DAS_INS_OWNER_TITLE'] = $row['DAS_INS_OWNER_TYPE'];
|
||||
break;
|
||||
G::LoadClass( $className );
|
||||
eval( "\$additionalFields = $className::getXTemplate(\$className);" );
|
||||
return $additionalFields;
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
if ($row['DAS_INS_UID'] != '') {
|
||||
$dashletsInstances[] = $row;
|
||||
}
|
||||
|
||||
private static function setIncludePath ()
|
||||
{
|
||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||
$pluginsDashlets = $oPluginRegistry->getDashlets();
|
||||
foreach ($pluginsDashlets as $pluginDashlet) {
|
||||
set_include_path( get_include_path() . PATH_SEPARATOR . PATH_PLUGINS . $pluginDashlet . PATH_SEP );
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
return $dashletsInstances;
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDashletsInstancesQuantity() {
|
||||
try {
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn('*');
|
||||
$criteria->addJoin(DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN);
|
||||
return DashletInstancePeer::doCount($criteria);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function loadDashletInstance($dasInsUid) {
|
||||
try {
|
||||
$dashletInstance = $this->load($dasInsUid);
|
||||
//Load data from the serialized field
|
||||
$dashlet = new Dashlet();
|
||||
$dashletFields = $dashlet->load($dashletInstance['DAS_UID']);
|
||||
if (is_null($dashletFields)) {
|
||||
$dashletFields = array();
|
||||
}
|
||||
return array_merge($dashletFields, $dashletInstance);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function saveDashletInstance($data) {
|
||||
try {
|
||||
$this->createOrUpdate($data);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteDashletInstance($dasInsUid) {
|
||||
try {
|
||||
$this->remove($dasInsUid);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDashletsInstancesForUser($userUid) {
|
||||
try {
|
||||
$dashletsInstances = array();
|
||||
// Include required classes
|
||||
require_once 'classes/model/Department.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
// Check for "public" dashlets
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_UID);
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_CLASS);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_TITLE);
|
||||
$criteria->addJoin(DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN);
|
||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'EVERYBODY');
|
||||
$dataset = DashletInstancePeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (!isset($dashletsInstances[$row['DAS_INS_UID']])) {
|
||||
$arrayField = unserialize($row["DAS_INS_ADDITIONAL_PROPERTIES"]);
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate($row['DAS_CLASS']);
|
||||
$row["DAS_TITLE"] = (isset($arrayField["DAS_INS_TITLE"]) && !empty($arrayField["DAS_INS_TITLE"]))? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset($arrayField["DAS_INS_SUBTITLE"]) && !empty($arrayField["DAS_INS_SUBTITLE"]))? str_replace("@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"]) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
// Check for the direct assignments
|
||||
$usersInstance = new Users();
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_UID);
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_CLASS);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_TITLE);
|
||||
$criteria->addJoin(DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN);
|
||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'USER');
|
||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_UID, $userUid);
|
||||
$dataset = DashletInstancePeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (!isset($dashletsInstances[$row['DAS_INS_UID']])) {
|
||||
$arrayField = unserialize($row["DAS_INS_ADDITIONAL_PROPERTIES"]);
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate($row['DAS_CLASS']);
|
||||
$row["DAS_TITLE"] = (isset($arrayField["DAS_INS_TITLE"]) && !empty($arrayField["DAS_INS_TITLE"]))? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset($arrayField["DAS_INS_SUBTITLE"]) && !empty($arrayField["DAS_INS_SUBTITLE"]))? str_replace("@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"]) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
// Check for department assigments
|
||||
$departmentInstance = new Department();
|
||||
$departments = $departmentInstance->getDepartmentsForUser($userUid);
|
||||
foreach ($departments as $depUid => $department) {
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_UID);
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_CLASS);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_TITLE);
|
||||
$criteria->addJoin(DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN);
|
||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'DEPARTMENT');
|
||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_UID, $depUid);
|
||||
$dataset = DashletInstancePeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (!isset($dashletsInstances[$row['DAS_INS_UID']])) {
|
||||
$arrayField = unserialize($row["DAS_INS_ADDITIONAL_PROPERTIES"]);
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate($row['DAS_CLASS']);
|
||||
$row["DAS_TITLE"] = (isset($arrayField["DAS_INS_TITLE"]) && !empty($arrayField["DAS_INS_TITLE"]))? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset($arrayField["DAS_INS_SUBTITLE"]) && !empty($arrayField["DAS_INS_SUBTITLE"]))? str_replace("@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"]) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
}
|
||||
// Check for group assignments
|
||||
G::LoadClass('groups');
|
||||
$groupsInstance = new Groups();
|
||||
$groups = $groupsInstance->getGroupsForUser($userUid);
|
||||
foreach ($groups as $grpUid => $group) {
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_UID);
|
||||
$criteria->addSelectColumn(DashletInstancePeer::DAS_INS_ADDITIONAL_PROPERTIES);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_CLASS);
|
||||
$criteria->addSelectColumn(DashletPeer::DAS_TITLE);
|
||||
$criteria->addJoin(DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN);
|
||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'GROUP');
|
||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_UID, $grpUid);
|
||||
$dataset = DashletInstancePeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
if (!isset($dashletsInstances[$row['DAS_INS_UID']])) {
|
||||
$arrayField = unserialize($row["DAS_INS_ADDITIONAL_PROPERTIES"]);
|
||||
|
||||
$row['DAS_XTEMPLATE'] = $this->getXTemplate($row['DAS_CLASS']);
|
||||
$row["DAS_TITLE"] = (isset($arrayField["DAS_INS_TITLE"]) && !empty($arrayField["DAS_INS_TITLE"]))? $arrayField["DAS_INS_TITLE"] : $row["DAS_TITLE"];
|
||||
$row["DAS_TITLE"] = $row["DAS_TITLE"] . ((isset($arrayField["DAS_INS_SUBTITLE"]) && !empty($arrayField["DAS_INS_SUBTITLE"]))? str_replace("@@USR_USERNAME", $_SESSION["USR_USERNAME"], $arrayField["DAS_INS_SUBTITLE"]) : null);
|
||||
|
||||
$dashletsInstances[$row['DAS_INS_UID']] = $row;
|
||||
}
|
||||
$dataset->next();
|
||||
}
|
||||
}
|
||||
// Check for role assigments
|
||||
// ToDo: Next release
|
||||
// Check for permission assigments
|
||||
// ToDo: Next release
|
||||
return array_values($dashletsInstances);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getXTemplate($className) {
|
||||
try {
|
||||
if (!class_exists($className)) {
|
||||
self::setIncludePath();
|
||||
require_once 'classes' . PATH_SEP . 'class.' . $className . '.php';
|
||||
}
|
||||
G::LoadClass($className);
|
||||
eval("\$additionalFields = $className::getXTemplate(\$className);");
|
||||
return $additionalFields;
|
||||
}
|
||||
catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setIncludePath() {
|
||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||
$pluginsDashlets = $oPluginRegistry->getDashlets();
|
||||
foreach ($pluginsDashlets as $pluginDashlet) {
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_PLUGINS . $pluginDashlet . PATH_SEP);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,238 +1,246 @@
|
||||
<?php
|
||||
class pmGauge {
|
||||
/**
|
||||
width
|
||||
*/
|
||||
var $w = 610;
|
||||
|
||||
/**
|
||||
height
|
||||
*/
|
||||
var $h = 300;
|
||||
|
||||
/**
|
||||
value of gauge
|
||||
*/
|
||||
var $value = 50;
|
||||
|
||||
/**
|
||||
maxValue
|
||||
*/
|
||||
var $maxValue = 100;
|
||||
|
||||
/**
|
||||
redFrom
|
||||
*/
|
||||
var $redFrom = 80;
|
||||
|
||||
/**
|
||||
redTo
|
||||
*/
|
||||
var $redTo = 100;
|
||||
|
||||
/**
|
||||
yellowFrom
|
||||
*/
|
||||
var $yellowFrom = 60;
|
||||
|
||||
/**
|
||||
yellowTo
|
||||
*/
|
||||
var $yellowTo = 80;
|
||||
|
||||
/**
|
||||
greenFrom
|
||||
*/
|
||||
var $greenFrom = 0;
|
||||
|
||||
/**
|
||||
greenTo
|
||||
*/
|
||||
var $greenTo = 60;
|
||||
|
||||
/**
|
||||
centerLabel, the label in the middle of the gauge
|
||||
*/
|
||||
var $centerLabel = '';
|
||||
|
||||
function render () {
|
||||
$this->h = $this->w / 2;
|
||||
$im = imagecreatetruecolor($this->w, $this->h);
|
||||
$width = $this->w;
|
||||
$height = $this->h;
|
||||
$center_x = intval($width / 2);
|
||||
$center_y = intval($height / 2);
|
||||
|
||||
//gauge color
|
||||
$bgcolor = ImageColorAllocate($im, 247, 247, 247);
|
||||
$extRing = ImageColorAllocate($im, 214, 214, 214);
|
||||
$blueRing = ImageColorAllocate($im, 70, 132, 238);
|
||||
$blueRingLine = ImageColorAllocate($im, 106, 114, 127);
|
||||
$arrowBody = ImageColorAllocate($im, 228, 114, 86);
|
||||
$arrowLine = ImageColorAllocate($im, 207, 74, 42);
|
||||
$redArc = ImageColorAllocate($im, 220, 57, 18);
|
||||
$yellowArc = ImageColorAllocate($im, 255, 153, 0);
|
||||
|
||||
$black = ImageColorAllocate($im, 0,0,0);
|
||||
$white = ImageColorAllocate($im, 255, 255, 255);
|
||||
$gray = ImageColorAllocate($im, 190, 190, 190);
|
||||
|
||||
$fontArial = PATH_THIRDPARTY . 'html2ps_pdf/fonts/arial.ttf';
|
||||
|
||||
ImageFilledRectangle($im, 0, 0, $width-1, $height-1, $white);
|
||||
ImageRectangle ($im, 0, 0, $width-1, $height-1, $gray);
|
||||
|
||||
<?php
|
||||
|
||||
class pmGauge
|
||||
{
|
||||
/**
|
||||
* width
|
||||
*/
|
||||
var $w = 610;
|
||||
|
||||
/**
|
||||
* height
|
||||
*/
|
||||
var $h = 300;
|
||||
|
||||
/**
|
||||
* value of gauge
|
||||
*/
|
||||
var $value = 50;
|
||||
|
||||
/**
|
||||
* maxValue
|
||||
*/
|
||||
var $maxValue = 100;
|
||||
|
||||
/**
|
||||
* redFrom
|
||||
*/
|
||||
var $redFrom = 80;
|
||||
|
||||
/**
|
||||
* redTo
|
||||
*/
|
||||
var $redTo = 100;
|
||||
|
||||
/**
|
||||
* yellowFrom
|
||||
*/
|
||||
var $yellowFrom = 60;
|
||||
|
||||
/**
|
||||
* yellowTo
|
||||
*/
|
||||
var $yellowTo = 80;
|
||||
|
||||
/**
|
||||
* greenFrom
|
||||
*/
|
||||
var $greenFrom = 0;
|
||||
|
||||
/**
|
||||
* greenTo
|
||||
*/
|
||||
var $greenTo = 60;
|
||||
|
||||
/**
|
||||
* centerLabel, the label in the middle of the gauge
|
||||
*/
|
||||
var $centerLabel = '';
|
||||
|
||||
function render ()
|
||||
{
|
||||
$this->h = $this->w / 2;
|
||||
$im = imagecreatetruecolor( $this->w, $this->h );
|
||||
$width = $this->w;
|
||||
$height = $this->h;
|
||||
$center_x = intval( $width / 2 );
|
||||
$center_y = intval( $height / 2 );
|
||||
|
||||
//gauge color
|
||||
$bgcolor = ImageColorAllocate( $im, 247, 247, 247 );
|
||||
$extRing = ImageColorAllocate( $im, 214, 214, 214 );
|
||||
$blueRing = ImageColorAllocate( $im, 70, 132, 238 );
|
||||
$blueRingLine = ImageColorAllocate( $im, 106, 114, 127 );
|
||||
$arrowBody = ImageColorAllocate( $im, 228, 114, 86 );
|
||||
$arrowLine = ImageColorAllocate( $im, 207, 74, 42 );
|
||||
$redArc = ImageColorAllocate( $im, 220, 57, 18 );
|
||||
$yellowArc = ImageColorAllocate( $im, 255, 153, 0 );
|
||||
|
||||
$black = ImageColorAllocate( $im, 0, 0, 0 );
|
||||
$white = ImageColorAllocate( $im, 255, 255, 255 );
|
||||
$gray = ImageColorAllocate( $im, 190, 190, 190 );
|
||||
|
||||
$fontArial = PATH_THIRDPARTY . 'html2ps_pdf/fonts/arial.ttf';
|
||||
|
||||
ImageFilledRectangle( $im, 0, 0, $width - 1, $height - 1, $white );
|
||||
ImageRectangle( $im, 0, 0, $width - 1, $height - 1, $gray );
|
||||
|
||||
//center coords
|
||||
$cX = intval( $this->w / 2 );
|
||||
//$cX = intval($this->w /4);
|
||||
$cY = intval( $this->h / 2 );
|
||||
|
||||
//diameter for gauge
|
||||
$diameter = intval( $this->h * 4 / 5 );
|
||||
|
||||
$this->renderGauge( $im, $cX, $cY, $diameter );
|
||||
|
||||
/*
|
||||
//center coords
|
||||
$cX = intval($this->w /2);
|
||||
//$cX = intval($this->w /4);
|
||||
$cY = intval($this->h /2);
|
||||
|
||||
$cX = intval($this->w * 3/4);
|
||||
$cY = intval($this->h /2);
|
||||
|
||||
//diameter for gauge
|
||||
$diameter = intval( $this->h * 4/5 );
|
||||
|
||||
$this->renderGauge($im, $cX, $cY, $diameter);
|
||||
|
||||
/*
|
||||
//center coords
|
||||
$cX = intval($this->w * 3/4);
|
||||
$cY = intval($this->h /2);
|
||||
|
||||
//diameter for gauge
|
||||
$diameter = intval( $this->h * 4/5 );
|
||||
|
||||
$this->renderGauge($im, $cX, $cY, $diameter);
|
||||
*/
|
||||
Header("Content-type: image/png");
|
||||
ImagePng($im);
|
||||
|
||||
}
|
||||
|
||||
function renderGauge($im, $cX, $cY, $diameter) {
|
||||
//gauge color
|
||||
$bgcolor = ImageColorAllocate($im, 247, 247, 247);
|
||||
$extRing = ImageColorAllocate($im, 214, 214, 214);
|
||||
$blueRing = ImageColorAllocate($im, 70, 132, 238);
|
||||
$blueRingLine = ImageColorAllocate($im, 106, 114, 127);
|
||||
$arrowBody = ImageColorAllocate($im, 228, 114, 86);
|
||||
$arrowLine = ImageColorAllocate($im, 207, 74, 42);
|
||||
$redArc = ImageColorAllocate($im, 220, 57, 18);
|
||||
$yellowArc = ImageColorAllocate($im, 255, 153, 0);
|
||||
$greenArc = ImageColorAllocate($im, 0, 136, 0);
|
||||
|
||||
$black = ImageColorAllocate($im, 0,0,0);
|
||||
$white = ImageColorAllocate($im, 255, 255, 255);
|
||||
$gray = ImageColorAllocate($im, 190, 190, 190);
|
||||
|
||||
$fontArial = PATH_THIRDPARTY . 'html2ps_pdf/fonts/arial.ttf';
|
||||
|
||||
$dX = intval($diameter *8/7 ); //for now ratio aspect is 8:7
|
||||
$dY = intval($diameter);
|
||||
$dXRing = intval($dX * 0.90);
|
||||
$dYRing = intval($dY * 0.90);
|
||||
|
||||
$dXRingColor = intval($dX * 0.86);
|
||||
$dYRingColor = intval($dY * 0.86);
|
||||
|
||||
$dXRingCenter = intval($dX * 0.66);
|
||||
$dYRingCenter = intval($dY * 0.66);
|
||||
|
||||
imagefilledellipse($im, $cX, $cY, $dX, $dY, $extRing);
|
||||
|
||||
imagefilledellipse($im, $cX, $cY, $dXRing, $dYRing, $bgcolor);
|
||||
|
||||
//drawing the red arc
|
||||
if ( $this->redFrom > $this->maxValue ) $this->redFrom = $this->maxValue;
|
||||
if ( $this->redTo > $this->maxValue ) $this->redTo = $this->maxValue;
|
||||
if ( $this->yellowFrom > $this->maxValue ) $this->yellowFrom = $this->maxValue;
|
||||
if ( $this->yellowTo > $this->maxValue ) $this->yellowTo = $this->maxValue;
|
||||
if ( $this->greenFrom > $this->maxValue ) $this->greenFrom = $this->maxValue;
|
||||
if ( $this->greenTo > $this->maxValue ) $this->greenTo = $this->maxValue;
|
||||
|
||||
$redFrom = $this->redFrom/$this->maxValue*300 - 240 ;
|
||||
$redTo = $this->redTo/$this->maxValue*300 - 240;
|
||||
$yellowFrom = $this->yellowFrom/$this->maxValue*300 - 240;
|
||||
$yellowTo = $this->yellowTo/$this->maxValue*300 - 240;
|
||||
$greenFrom = $this->greenFrom/$this->maxValue*300 - 240;
|
||||
$greenTo = $this->greenTo/$this->maxValue*300 - 240;
|
||||
|
||||
if ( $this->redFrom != $this->redTo || $this->redTo != $this->maxValue ) {
|
||||
imagefilledarc ($im, $cX, $cY, $dXRingColor, $dYRingColor, $redFrom, $redTo, $redArc, IMG_ARC_PIE );
|
||||
}
|
||||
if ( $this->yellowFrom != $this->yellowTo || $this->yellowTo != $this->maxValue ) {
|
||||
imagefilledarc ($im, $cX, $cY, $dXRingColor, $dYRingColor, $yellowFrom, $yellowTo, $yellowArc, IMG_ARC_PIE );
|
||||
}
|
||||
if ( $this->greenFrom != $this->greenTo || $this->greenTo != $this->maxValue ) {
|
||||
imagefilledarc ($im, $cX, $cY, $dXRingColor, $dYRingColor, $greenFrom, $greenTo, $greenArc, IMG_ARC_PIE );
|
||||
}
|
||||
imagefilledellipse($im, $cX, $cY, $dXRingCenter, $dYRingCenter, $bgcolor);
|
||||
|
||||
//ticks
|
||||
$radiusX = intval($dX * 0.42);
|
||||
$radiusY = intval($dY * 0.42);
|
||||
$min = 5;
|
||||
while($min <= 55) {
|
||||
if ($min % 5 == 0)
|
||||
$len = $radiusX / 8;
|
||||
else
|
||||
$len = $radiusX / 25;
|
||||
|
||||
$ang = (2 * M_PI * $min) / 60;
|
||||
$x1 = sin($ang) * ($radiusX - $len) + $cX;
|
||||
$y1 = cos($ang) * ($radiusY - $len) + $cY;
|
||||
$x2 = sin($ang) * $radiusX + $cX;
|
||||
$y2 = cos($ang) * $radiusY + $cY;
|
||||
|
||||
ImageLine($im, $x1, $y1, $x2, $y2, $black);
|
||||
|
||||
|
||||
if ($min % 5 == 0) {
|
||||
$textToDisplay = sprintf("%d", (55-$min)*$this->maxValue/50 );
|
||||
$bbox = imagettfbbox(8, 0, $fontArial, $textToDisplay );
|
||||
$x1 = sin($ang) * ($radiusX - 2.5*$len) + $cX - $bbox[4] / 2;
|
||||
$y1 = cos($ang) * ($radiusY - 2.5*$len) + $cY +2;// - abs($bbox[5]);
|
||||
imagettftext ( $im, 8, 0, $x1, $y1, $gray, $fontArial, $textToDisplay );
|
||||
}
|
||||
$min++;
|
||||
}
|
||||
|
||||
if (trim($this->centerLabel) != '' ) {
|
||||
$textToDisplay = trim($this->centerLabel);
|
||||
$bbox = imagettfbbox(8, 0, $fontArial, $textToDisplay );
|
||||
$x1 = $cX - $bbox[4] / 2;
|
||||
$y1 = $cY *3/4 + abs($bbox[5]);
|
||||
imagettftext ( $im, 8, 0, $x1, $y1, $black, $fontArial, $textToDisplay );
|
||||
}
|
||||
|
||||
imagettftext ( $im, 9, 0, $cX*0.60, $cY*1.8, $gray, $fontArial, $this->open );
|
||||
imagettftext ( $im, 9, 0, $cX*1.40, $cY*1.8, $gray, $fontArial, $this->completed );
|
||||
|
||||
|
||||
//drawing the arrow, simple way
|
||||
$radiusX = intval($dX * 0.35);
|
||||
$radiusY = intval($dY * 0.35);
|
||||
|
||||
$ang = - M_PI/6 + 2*M_PI - ( 2 * M_PI * $this->value )*50/60 /$this->maxValue ;
|
||||
$x1 = sin($ang) * ($radiusX) + $cX;
|
||||
$y1 = cos($ang) * ($radiusY) + $cY;
|
||||
ImageLine($im, $cX, $cY, $x1, $y1, $arrowLine);
|
||||
|
||||
/*
|
||||
*/
|
||||
Header( "Content-type: image/png" );
|
||||
ImagePng( $im );
|
||||
|
||||
}
|
||||
|
||||
function renderGauge ($im, $cX, $cY, $diameter)
|
||||
{
|
||||
//gauge color
|
||||
$bgcolor = ImageColorAllocate( $im, 247, 247, 247 );
|
||||
$extRing = ImageColorAllocate( $im, 214, 214, 214 );
|
||||
$blueRing = ImageColorAllocate( $im, 70, 132, 238 );
|
||||
$blueRingLine = ImageColorAllocate( $im, 106, 114, 127 );
|
||||
$arrowBody = ImageColorAllocate( $im, 228, 114, 86 );
|
||||
$arrowLine = ImageColorAllocate( $im, 207, 74, 42 );
|
||||
$redArc = ImageColorAllocate( $im, 220, 57, 18 );
|
||||
$yellowArc = ImageColorAllocate( $im, 255, 153, 0 );
|
||||
$greenArc = ImageColorAllocate( $im, 0, 136, 0 );
|
||||
|
||||
$black = ImageColorAllocate( $im, 0, 0, 0 );
|
||||
$white = ImageColorAllocate( $im, 255, 255, 255 );
|
||||
$gray = ImageColorAllocate( $im, 190, 190, 190 );
|
||||
|
||||
$fontArial = PATH_THIRDPARTY . 'html2ps_pdf/fonts/arial.ttf';
|
||||
|
||||
$dX = intval( $diameter * 8 / 7 ); //for now ratio aspect is 8:7
|
||||
$dY = intval( $diameter );
|
||||
$dXRing = intval( $dX * 0.90 );
|
||||
$dYRing = intval( $dY * 0.90 );
|
||||
|
||||
$dXRingColor = intval( $dX * 0.86 );
|
||||
$dYRingColor = intval( $dY * 0.86 );
|
||||
|
||||
$dXRingCenter = intval( $dX * 0.66 );
|
||||
$dYRingCenter = intval( $dY * 0.66 );
|
||||
|
||||
imagefilledellipse( $im, $cX, $cY, $dX, $dY, $extRing );
|
||||
|
||||
imagefilledellipse( $im, $cX, $cY, $dXRing, $dYRing, $bgcolor );
|
||||
|
||||
//drawing the red arc
|
||||
if ($this->redFrom > $this->maxValue)
|
||||
$this->redFrom = $this->maxValue;
|
||||
if ($this->redTo > $this->maxValue)
|
||||
$this->redTo = $this->maxValue;
|
||||
if ($this->yellowFrom > $this->maxValue)
|
||||
$this->yellowFrom = $this->maxValue;
|
||||
if ($this->yellowTo > $this->maxValue)
|
||||
$this->yellowTo = $this->maxValue;
|
||||
if ($this->greenFrom > $this->maxValue)
|
||||
$this->greenFrom = $this->maxValue;
|
||||
if ($this->greenTo > $this->maxValue)
|
||||
$this->greenTo = $this->maxValue;
|
||||
|
||||
$redFrom = $this->redFrom / $this->maxValue * 300 - 240;
|
||||
$redTo = $this->redTo / $this->maxValue * 300 - 240;
|
||||
$yellowFrom = $this->yellowFrom / $this->maxValue * 300 - 240;
|
||||
$yellowTo = $this->yellowTo / $this->maxValue * 300 - 240;
|
||||
$greenFrom = $this->greenFrom / $this->maxValue * 300 - 240;
|
||||
$greenTo = $this->greenTo / $this->maxValue * 300 - 240;
|
||||
|
||||
if ($this->redFrom != $this->redTo || $this->redTo != $this->maxValue) {
|
||||
imagefilledarc( $im, $cX, $cY, $dXRingColor, $dYRingColor, $redFrom, $redTo, $redArc, IMG_ARC_PIE );
|
||||
}
|
||||
if ($this->yellowFrom != $this->yellowTo || $this->yellowTo != $this->maxValue) {
|
||||
imagefilledarc( $im, $cX, $cY, $dXRingColor, $dYRingColor, $yellowFrom, $yellowTo, $yellowArc, IMG_ARC_PIE );
|
||||
}
|
||||
if ($this->greenFrom != $this->greenTo || $this->greenTo != $this->maxValue) {
|
||||
imagefilledarc( $im, $cX, $cY, $dXRingColor, $dYRingColor, $greenFrom, $greenTo, $greenArc, IMG_ARC_PIE );
|
||||
}
|
||||
imagefilledellipse( $im, $cX, $cY, $dXRingCenter, $dYRingCenter, $bgcolor );
|
||||
|
||||
//ticks
|
||||
$radiusX = intval( $dX * 0.42 );
|
||||
$radiusY = intval( $dY * 0.42 );
|
||||
$min = 5;
|
||||
while ($min <= 55) {
|
||||
if ($min % 5 == 0)
|
||||
$len = $radiusX / 8;
|
||||
else
|
||||
$len = $radiusX / 25;
|
||||
|
||||
$ang = (2 * M_PI * $min) / 60;
|
||||
$x1 = sin( $ang ) * ($radiusX - $len) + $cX;
|
||||
$y1 = cos( $ang ) * ($radiusY - $len) + $cY;
|
||||
$x2 = sin( $ang ) * $radiusX + $cX;
|
||||
$y2 = cos( $ang ) * $radiusY + $cY;
|
||||
|
||||
ImageLine( $im, $x1, $y1, $x2, $y2, $black );
|
||||
|
||||
if ($min % 5 == 0) {
|
||||
$textToDisplay = sprintf( "%d", (55 - $min) * $this->maxValue / 50 );
|
||||
$bbox = imagettfbbox( 8, 0, $fontArial, $textToDisplay );
|
||||
$x1 = sin( $ang ) * ($radiusX - 2.5 * $len) + $cX - $bbox[4] / 2;
|
||||
$y1 = cos( $ang ) * ($radiusY - 2.5 * $len) + $cY + 2; // - abs($bbox[5]);
|
||||
imagettftext( $im, 8, 0, $x1, $y1, $gray, $fontArial, $textToDisplay );
|
||||
}
|
||||
$min ++;
|
||||
}
|
||||
|
||||
if (trim( $this->centerLabel ) != '') {
|
||||
$textToDisplay = trim( $this->centerLabel );
|
||||
$bbox = imagettfbbox( 8, 0, $fontArial, $textToDisplay );
|
||||
$x1 = $cX - $bbox[4] / 2;
|
||||
$y1 = $cY * 3 / 4 + abs( $bbox[5] );
|
||||
imagettftext( $im, 8, 0, $x1, $y1, $black, $fontArial, $textToDisplay );
|
||||
}
|
||||
|
||||
imagettftext( $im, 9, 0, $cX * 0.60, $cY * 1.8, $gray, $fontArial, $this->open );
|
||||
imagettftext( $im, 9, 0, $cX * 1.40, $cY * 1.8, $gray, $fontArial, $this->completed );
|
||||
|
||||
//drawing the arrow, simple way
|
||||
$radiusX = intval( $dX * 0.35 );
|
||||
$radiusY = intval( $dY * 0.35 );
|
||||
|
||||
$ang = - M_PI / 6 + 2 * M_PI - (2 * M_PI * $this->value) * 50 / 60 / $this->maxValue;
|
||||
$x1 = sin( $ang ) * ($radiusX) + $cX;
|
||||
$y1 = cos( $ang ) * ($radiusY) + $cY;
|
||||
ImageLine( $im, $cX, $cY, $x1, $y1, $arrowLine );
|
||||
|
||||
/*
|
||||
//arrowLine
|
||||
$arrowHeight = intval($dY * 0.02);
|
||||
$arrowWidth = intval($dX * 0.35);
|
||||
$arrowTail = intval($dX * 0.15);
|
||||
$values = array(
|
||||
0, -$arrowHeight,
|
||||
-$arrowTail, 0,
|
||||
0, -$arrowHeight,
|
||||
-$arrowTail, 0,
|
||||
0, $arrowHeight,
|
||||
$arrowWidth, 0,
|
||||
$arrowWidth, 0,
|
||||
0, -$arrowHeight
|
||||
);
|
||||
|
||||
|
||||
//rotate n degrees
|
||||
$n = 20;
|
||||
$ang = (2 * M_PI * $n) / 60;
|
||||
|
||||
|
||||
foreach ( $values as $k => $val ) {
|
||||
if ( $k % 2 == 0 ) {
|
||||
//$values[$k] = sin($ang)*$val + 20;
|
||||
@@ -246,25 +254,24 @@
|
||||
$values[$k] += $cY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
imagefilledpolygon ($im, $values, 5, $arrowBody);
|
||||
imagepolygon ($im, $values, 5, $arrowLine);
|
||||
*/
|
||||
//blue ring
|
||||
$dXBlueRing = $dX * 0.07;
|
||||
$dYBlueRing = $dY * 0.07;
|
||||
imagefilledellipse($im, $cX, $cY, $dXBlueRing, $dXBlueRing, $blueRing);
|
||||
imageellipse ($im, $cX, $cY, $dXBlueRing, $dYBlueRing, $blueRingLine);
|
||||
|
||||
imageellipse ($im, $cX, $cY, $dX, $dY, $black);
|
||||
|
||||
$textToDisplay = sprintf ( "%5.2f%%", $this->value );
|
||||
$bbox = imagettfbbox(9, 0, $fontArial, $textToDisplay );
|
||||
$centerX = $cX - $bbox[4] / 2;
|
||||
$centerY = $cY+$dYRing/2+3-abs($bbox[5]);
|
||||
imagettftext ( $im, 9, 0, $centerX, $centerY, $black, $fontArial, $textToDisplay );
|
||||
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
//blue ring
|
||||
$dXBlueRing = $dX * 0.07;
|
||||
$dYBlueRing = $dY * 0.07;
|
||||
imagefilledellipse( $im, $cX, $cY, $dXBlueRing, $dXBlueRing, $blueRing );
|
||||
imageellipse( $im, $cX, $cY, $dXBlueRing, $dYBlueRing, $blueRingLine );
|
||||
|
||||
imageellipse( $im, $cX, $cY, $dX, $dY, $black );
|
||||
|
||||
$textToDisplay = sprintf( "%5.2f%%", $this->value );
|
||||
$bbox = imagettfbbox( 9, 0, $fontArial, $textToDisplay );
|
||||
$centerX = $cX - $bbox[4] / 2;
|
||||
$centerY = $cY + $dYRing / 2 + 3 - abs( $bbox[5] );
|
||||
imagettftext( $im, 9, 0, $centerX, $centerY, $black, $fontArial, $textToDisplay );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* class.ArrayPeer.php
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
@@ -13,11 +14,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -26,20 +27,23 @@
|
||||
|
||||
/**
|
||||
* Phing Class Wrapper
|
||||
*
|
||||
* @author Erik Amaru Ortiz <erik@colosa.com>
|
||||
*/
|
||||
|
||||
include_once 'phing/Phing.php';
|
||||
set_include_path(PATH_THIRDPARTY . 'propel-generator/classes/' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path( PATH_THIRDPARTY . 'propel-generator/classes/' . PATH_SEPARATOR . get_include_path() );
|
||||
|
||||
if (!class_exists('Phing')) {
|
||||
throw new Exception('Fatal Error: Phing is not loaded!');
|
||||
if (! class_exists( 'Phing' )) {
|
||||
throw new Exception( 'Fatal Error: Phing is not loaded!' );
|
||||
}
|
||||
|
||||
class pmPhing extends Phing
|
||||
{
|
||||
function getPhingVersion()
|
||||
{
|
||||
return 'pmPhing Ver 1.0';
|
||||
}
|
||||
}
|
||||
|
||||
public function getPhingVersion ()
|
||||
{
|
||||
return 'pmPhing Ver 1.0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
/**
|
||||
* class.pmScript.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -14,11 +15,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -32,58 +33,61 @@
|
||||
// License: LGPL, see LICENSE
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* PMScript - PMScript class
|
||||
*
|
||||
* @author Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
|
||||
* last modify 2008.08.13 by Erik Amaru Ortiz <erik@colosa.com>
|
||||
* last modify comment was added and adapted the catch errors
|
||||
* @copyright 2007 COLOSA
|
||||
*/
|
||||
function __autoload($sClassName)
|
||||
function __autoload ($sClassName)
|
||||
{
|
||||
if (defined('SYS_SYS')) {
|
||||
if (defined( 'SYS_SYS' )) {
|
||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||
if (file_exists($sPath . $sClassName . '.php')) {
|
||||
if (file_exists( $sPath . $sClassName . '.php' )) {
|
||||
require_once $sPath . $sClassName . '.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Start - Custom functions
|
||||
G::LoadClass('pmFunctions');
|
||||
G::LoadClass( 'pmFunctions' );
|
||||
//End - Custom functions
|
||||
//call plugin
|
||||
if (class_exists('folderData')) {
|
||||
if (class_exists( 'folderData' )) {
|
||||
//$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
|
||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
|
||||
foreach ($aAvailablePmFunctions as $key => $class) {
|
||||
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
|
||||
if (file_exists($filePlugin)) {
|
||||
include_once( $filePlugin);
|
||||
if (file_exists( $filePlugin )) {
|
||||
include_once ($filePlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
//end plugin
|
||||
//Add External Triggers
|
||||
$dir = G::ExpandPath("classes") . 'triggers';
|
||||
$filesArray = array();
|
||||
if (file_exists($dir)) {
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
$dir = G::ExpandPath( "classes" ) . 'triggers';
|
||||
$filesArray = array ();
|
||||
if (file_exists( $dir )) {
|
||||
if ($handle = opendir( $dir )) {
|
||||
while (false !== ($file = readdir( $handle ))) {
|
||||
if (($file != ".") && ($file != "..")) {
|
||||
$extFile = explode(".", $file);
|
||||
if ($extFile[sizeof($extFile) - 1] == 'php') {
|
||||
include_once( $dir . PATH_SEP . $file);
|
||||
$extFile = explode( ".", $file );
|
||||
if ($extFile[sizeof( $extFile ) - 1] == 'php') {
|
||||
include_once ($dir . PATH_SEP . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
closedir( $handle );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PMScript - PMScript class
|
||||
*
|
||||
* @copyright 2007 COLOSA
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
@@ -93,12 +97,12 @@ class PMScript
|
||||
/**
|
||||
* Original fields
|
||||
*/
|
||||
public $aOriginalFields = array();
|
||||
public $aOriginalFields = array ();
|
||||
|
||||
/**
|
||||
* Fields to use
|
||||
*/
|
||||
public $aFields = array();
|
||||
public $aFields = array ();
|
||||
|
||||
/**
|
||||
* Script
|
||||
@@ -117,224 +121,185 @@ class PMScript
|
||||
|
||||
/**
|
||||
* Constructor of the class PMScript
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function PMScript()
|
||||
public function PMScript ()
|
||||
{
|
||||
$this->aFields['__ERROR__'] = 'none';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fields to use
|
||||
*
|
||||
* @param array $aFields
|
||||
* @return void
|
||||
*/
|
||||
public function setFields($aFields=array())
|
||||
public function setFields ($aFields = array())
|
||||
{
|
||||
if (!is_array($aFields)) {
|
||||
$aFields = array();
|
||||
if (! is_array( $aFields )) {
|
||||
$aFields = array ();
|
||||
}
|
||||
$this->aOriginalFields = $this->aFields = $aFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current script
|
||||
*
|
||||
* @param string $sScript
|
||||
* @return void
|
||||
*/
|
||||
public function setScript($sScript='')
|
||||
public function setScript ($sScript = '')
|
||||
{
|
||||
$this->sScript = $sScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the syntax
|
||||
*
|
||||
* @param string $sScript
|
||||
* @return boolean
|
||||
*/
|
||||
public function validSyntax($sScript)
|
||||
public function validSyntax ($sScript)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function executeAndCatchErrors($sScript, $sCode)
|
||||
public function executeAndCatchErrors ($sScript, $sCode)
|
||||
{
|
||||
ob_start('handleFatalErrors');
|
||||
set_error_handler('handleErrors');
|
||||
ob_start( 'handleFatalErrors' );
|
||||
set_error_handler( 'handleErrors' );
|
||||
$_SESSION['_CODE_'] = $sCode;
|
||||
eval($sScript);
|
||||
unset($_SESSION['_CODE_']);
|
||||
eval( $sScript );
|
||||
unset( $_SESSION['_CODE_'] );
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the current script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute ()
|
||||
{
|
||||
$sScript = "";
|
||||
$iAux = 0;
|
||||
$bEqual = false;
|
||||
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]'
|
||||
. '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
|
||||
$this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||
if ($iOcurrences) {
|
||||
for ($i = 0; $i < $iOcurrences; $i++) {
|
||||
$sAux = substr($this->sScript, $iAux, $aMatch[0][$i][1] - $iAux);
|
||||
if (!$bEqual) {
|
||||
if (strpos($sAux, '==') !== false) {
|
||||
for ($i = 0; $i < $iOcurrences; $i ++) {
|
||||
$sAux = substr( $this->sScript, $iAux, $aMatch[0][$i][1] - $iAux );
|
||||
if (! $bEqual) {
|
||||
if (strpos( $sAux, '==' ) !== false) {
|
||||
$bEqual = false;
|
||||
} else {
|
||||
if (strpos($sAux, '=') !== false) {
|
||||
if (strpos( $sAux, '=' ) !== false) {
|
||||
$bEqual = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($bEqual) {
|
||||
if (strpos($sAux, ';') !== false) {
|
||||
if (strpos( $sAux, ';' ) !== false) {
|
||||
$bEqual = false;
|
||||
}
|
||||
}
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
eval("if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['"
|
||||
. $aMatch[2][$i][0] . "'] = null; }");
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = null; }" );
|
||||
} else {
|
||||
eval( "if (!isset(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")) { \$this->aFields"
|
||||
. (isset($aMatch[2][$i][0]) ? "['" . $aMatch[2][$i][0]
|
||||
. "']" : '') . $aMatch[5][$i][0] . " = null; }");
|
||||
eval( "if (!isset(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")) { \$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . " = null; }" );
|
||||
}
|
||||
}
|
||||
$sScript .= $sAux;
|
||||
$iAux = $aMatch[0][$i][1] + strlen($aMatch[0][$i][0]);
|
||||
$iAux = $aMatch[0][$i][1] + strlen( $aMatch[0][$i][0] );
|
||||
switch ($aMatch[1][$i][0]) {
|
||||
case '@':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToString(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToString(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToInteger(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToInteger(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '#':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToFloat(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToFloat(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToUrl(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToUrl(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '$':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmSqlEscape(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmSqlEscape(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -342,17 +307,12 @@ class PMScript
|
||||
$this->affected_fields[] = $aMatch[2][$i][0];
|
||||
}
|
||||
}
|
||||
$sScript .= substr($this->sScript, $iAux);
|
||||
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n "
|
||||
. " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
|
||||
$sScript .= substr( $this->sScript, $iAux );
|
||||
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n " . " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
|
||||
//echo '<pre>-->'; print_r($this->aFields); echo '<---</pre>';
|
||||
$this->executeAndCatchErrors($sScript, $this->sScript);
|
||||
for ($i = 0; $i < count($this->affected_fields); $i++) {
|
||||
$_SESSION['TRIGGER_DEBUG']['DATA'][] = Array(
|
||||
'key' => $this->affected_fields[$i],
|
||||
'value' => isset($this->aFields[$this->affected_fields[$i]])
|
||||
? $this->aFields[$this->affected_fields[$i]]
|
||||
: ''
|
||||
$this->executeAndCatchErrors( $sScript, $this->sScript );
|
||||
for ($i = 0; $i < count( $this->affected_fields ); $i ++) {
|
||||
$_SESSION['TRIGGER_DEBUG']['DATA'][] = Array ('key' => $this->affected_fields[$i],'value' => isset( $this->aFields[$this->affected_fields[$i]] ) ? $this->aFields[$this->affected_fields[$i]] : ''
|
||||
);
|
||||
}
|
||||
//echo '<pre>-->'; print_r($_SESSION['TRIGGER_DEBUG']['DATA']); echo '<---</pre>';
|
||||
@@ -360,178 +320,141 @@ class PMScript
|
||||
|
||||
/**
|
||||
* Evaluate the current script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function evaluate()
|
||||
public function evaluate ()
|
||||
{
|
||||
$bResult = null;
|
||||
$sScript = '';
|
||||
$iAux = 0;
|
||||
$bEqual = false;
|
||||
$variableIsDefined = true;
|
||||
$iOcurrences = preg_match_all('/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]'
|
||||
. '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
|
||||
$this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||
if ($iOcurrences) {
|
||||
for ($i = 0; $i < $iOcurrences; $i++) {
|
||||
for ($i = 0; $i < $iOcurrences; $i ++) {
|
||||
// if the variables for that condition has not been previously defined then $variableIsDefined
|
||||
// is set to false
|
||||
if (!isset($this->aFields[$aMatch[2][$i][0]])) {
|
||||
if (! isset( $this->aFields[$aMatch[2][$i][0]] )) {
|
||||
// $variableIsDefined = false;
|
||||
$this->aFields[$aMatch[2][$i][0]] = '';
|
||||
}
|
||||
$sAux = substr($this->sScript, $iAux, $aMatch[0][$i][1] - $iAux);
|
||||
if (!$bEqual) {
|
||||
if (strpos($sAux, '=') !== false) {
|
||||
$sAux = substr( $this->sScript, $iAux, $aMatch[0][$i][1] - $iAux );
|
||||
if (! $bEqual) {
|
||||
if (strpos( $sAux, '=' ) !== false) {
|
||||
$bEqual = true;
|
||||
}
|
||||
}
|
||||
if ($bEqual) {
|
||||
if (strpos($sAux, ';') !== false) {
|
||||
if (strpos( $sAux, ';' ) !== false) {
|
||||
$bEqual = false;
|
||||
}
|
||||
}
|
||||
$sScript .= $sAux;
|
||||
$iAux = $aMatch[0][$i][1] + strlen($aMatch[0][$i][0]);
|
||||
$iAux = $aMatch[0][$i][1] + strlen( $aMatch[0][$i][0] );
|
||||
switch ($aMatch[1][$i][0]) {
|
||||
case '@':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToString(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToString(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToInteger(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToInteger(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '#':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToFloat(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToFloat(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmToUrl(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmToUrl(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '$':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||
} else {
|
||||
$sScript .= "pmSqlEscape(\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0] . ")";
|
||||
$sScript .= "pmSqlEscape(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
if ($bEqual) {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
} else {
|
||||
if (!isset($aMatch[5][$i][0])) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
} else {
|
||||
$sScript .= "\$this->aFields"
|
||||
. (isset($aMatch[2][$i][0])
|
||||
? "['" . $aMatch[2][$i][0] . "']"
|
||||
: '') . $aMatch[5][$i][0];
|
||||
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sScript .= substr($this->sScript, $iAux);
|
||||
$sScript .= substr( $this->sScript, $iAux );
|
||||
$sScript = '$bResult = ' . $sScript . ';';
|
||||
// checks if the syntax is valid or if the variables in that condition has been previously defined
|
||||
if ($this->validSyntax($sScript) && $variableIsDefined) {
|
||||
if ($this->validSyntax( $sScript ) && $variableIsDefined) {
|
||||
$this->bError = false;
|
||||
eval($sScript);
|
||||
eval( $sScript );
|
||||
} else {
|
||||
// echo "<script> alert('".G::loadTranslation('MSG_CONDITION_NOT_DEFINED')."'); </script>";
|
||||
G::SendTemporalMessage('MSG_CONDITION_NOT_DEFINED', 'error', 'labels');
|
||||
G::SendTemporalMessage( 'MSG_CONDITION_NOT_DEFINED', 'error', 'labels' );
|
||||
$this->bError = true;
|
||||
}
|
||||
return $bResult;
|
||||
@@ -540,60 +463,65 @@ class PMScript
|
||||
|
||||
//Start - Private functions
|
||||
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @param variant $vValue
|
||||
* @return string
|
||||
*/
|
||||
function pmToString($vValue)
|
||||
function pmToString ($vValue)
|
||||
{
|
||||
return (string) $vValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to integer
|
||||
*
|
||||
* @param variant $vValue
|
||||
* @return integer
|
||||
*/
|
||||
function pmToInteger($vValue)
|
||||
function pmToInteger ($vValue)
|
||||
{
|
||||
return (int) $vValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to float
|
||||
*
|
||||
* @param variant $vValue
|
||||
* @return float
|
||||
*/
|
||||
function pmToFloat($vValue)
|
||||
function pmToFloat ($vValue)
|
||||
{
|
||||
return (float) $vValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to Url
|
||||
*
|
||||
* @param variant $vValue
|
||||
* @return url
|
||||
*/
|
||||
function pmToUrl($vValue)
|
||||
function pmToUrl ($vValue)
|
||||
{
|
||||
return urlencode($vValue);
|
||||
return urlencode( $vValue );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to data base escaped string
|
||||
*
|
||||
* @param variant $vValue
|
||||
* @return string
|
||||
*/
|
||||
function pmSqlEscape($vValue)
|
||||
function pmSqlEscape ($vValue)
|
||||
{
|
||||
return G::sqlEscape($vValue);
|
||||
return G::sqlEscape( $vValue );
|
||||
}
|
||||
|
||||
//End - Private functions
|
||||
|
||||
|
||||
|
||||
/* * *************************************************************************
|
||||
* Error handler
|
||||
* author: Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
|
||||
@@ -607,13 +535,13 @@ function pmSqlEscape($vValue)
|
||||
* @param string $errline
|
||||
* @return void
|
||||
*/
|
||||
function handleErrors($errno, $errstr, $errfile, $errline)
|
||||
function handleErrors ($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
if ($errno != '' && ($errno != 8) && ($errno != 2048)) {
|
||||
if (isset($_SESSION['_CODE_'])) {
|
||||
if (isset( $_SESSION['_CODE_'] )) {
|
||||
$sCode = $_SESSION['_CODE_'];
|
||||
unset($_SESSION['_CODE_']);
|
||||
registerError(1, $errstr, $errline - 1, $sCode);
|
||||
unset( $_SESSION['_CODE_'] );
|
||||
registerError( 1, $errstr, $errline - 1, $sCode );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -624,50 +552,44 @@ function handleErrors($errno, $errstr, $errfile, $errline)
|
||||
* @return buffer
|
||||
*/
|
||||
|
||||
function handleFatalErrors($buffer)
|
||||
function handleFatalErrors ($buffer)
|
||||
{
|
||||
if (preg_match('/(error<\/b>:)(.+)(<br)/', $buffer, $regs)) {
|
||||
$err = preg_replace('/<.*?>/', '', $regs[2]);
|
||||
$aAux = explode(' in ', $err);
|
||||
if (preg_match( '/(error<\/b>:)(.+)(<br)/', $buffer, $regs )) {
|
||||
$err = preg_replace( '/<.*?>/', '', $regs[2] );
|
||||
$aAux = explode( ' in ', $err );
|
||||
$sCode = $_SESSION['_CODE_'];
|
||||
unset($_SESSION['_CODE_']);
|
||||
registerError(2, $aAux[0], 0, $sCode);
|
||||
if (strpos($_SERVER['REQUEST_URI'], '/cases/cases_Step') !== false) {
|
||||
if (strpos($_SERVER['REQUEST_URI'], '&ACTION=GENERATE') !== false) {
|
||||
G::LoadClass('case');
|
||||
unset( $_SESSION['_CODE_'] );
|
||||
registerError( 2, $aAux[0], 0, $sCode );
|
||||
if (strpos( $_SERVER['REQUEST_URI'], '/cases/cases_Step' ) !== false) {
|
||||
if (strpos( $_SERVER['REQUEST_URI'], '&ACTION=GENERATE' ) !== false) {
|
||||
G::LoadClass( 'case' );
|
||||
$oCase = new Cases();
|
||||
$aNextStep = $oCase->getNextStep($_SESSION['PROCESS'],
|
||||
$_SESSION['APPLICATION'],
|
||||
$_SESSION['INDEX'],
|
||||
$_SESSION['STEP_POSITION']);
|
||||
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
||||
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
|
||||
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
|
||||
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
||||
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
|
||||
}
|
||||
G::header('Location: ' . $aNextStep['PAGE']);
|
||||
die;
|
||||
G::header( 'Location: ' . $aNextStep['PAGE'] );
|
||||
die();
|
||||
}
|
||||
$_SESSION['_NO_EXECUTE_TRIGGERS_'] = 1;
|
||||
G::header('Location: ' . $_SERVER['REQUEST_URI']);
|
||||
die;
|
||||
G::header( 'Location: ' . $_SERVER['REQUEST_URI'] );
|
||||
die();
|
||||
} else {
|
||||
G::LoadClass('case');
|
||||
G::LoadClass( 'case' );
|
||||
$oCase = new Cases();
|
||||
$aNextStep = $oCase->getNextStep($_SESSION['PROCESS'],
|
||||
$_SESSION['APPLICATION'],
|
||||
$_SESSION['INDEX'],
|
||||
$_SESSION['STEP_POSITION']);
|
||||
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
||||
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
|
||||
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
|
||||
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
||||
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
|
||||
}
|
||||
if (strpos($aNextStep['PAGE'], 'TYPE=ASSIGN_TASK&UID=-1') !== false) {
|
||||
G::SendMessageText('Fatal error in trigger', 'error');
|
||||
if (strpos( $aNextStep['PAGE'], 'TYPE=ASSIGN_TASK&UID=-1' ) !== false) {
|
||||
G::SendMessageText( 'Fatal error in trigger', 'error' );
|
||||
}
|
||||
G::header('Location: ' . $aNextStep['PAGE']);
|
||||
die;
|
||||
G::header( 'Location: ' . $aNextStep['PAGE'] );
|
||||
die();
|
||||
}
|
||||
}
|
||||
return $buffer;
|
||||
@@ -682,11 +604,10 @@ function handleFatalErrors($buffer)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function registerError($iType, $sError, $iLine, $sCode)
|
||||
function registerError ($iType, $sError, $iLine, $sCode)
|
||||
{
|
||||
$sType = ($iType == 1 ? 'ERROR' : 'FATAL');
|
||||
$_SESSION['TRIGGER_DEBUG']['ERRORS'][][$sType] = $sError . ($iLine > 0 ? ' (line ' . $iLine . ')' : '')
|
||||
. ':<br /><br />' . $sCode;
|
||||
$_SESSION['TRIGGER_DEBUG']['ERRORS'][][$sType] = $sError . ($iLine > 0 ? ' (line ' . $iLine . ')' : '') . ':<br /><br />' . $sCode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -695,7 +616,7 @@ function registerError($iType, $sError, $iLine, $sCode)
|
||||
* @param type $connection
|
||||
* @return type
|
||||
*/
|
||||
function getEngineDataBaseName($connection)
|
||||
function getEngineDataBaseName ($connection)
|
||||
{
|
||||
$aDNS = $connection->getDSN();
|
||||
return $aDNS["phptype"];
|
||||
@@ -707,7 +628,7 @@ function getEngineDataBaseName($connection)
|
||||
* @param type $sql
|
||||
* @param type $connection
|
||||
*/
|
||||
function executeQueryOci($sql, $connection, $aParameter=array())
|
||||
function executeQueryOci ($sql, $connection, $aParameter = array())
|
||||
{
|
||||
|
||||
$aDNS = $connection->getDSN();
|
||||
@@ -719,53 +640,53 @@ function executeQueryOci($sql, $connection, $aParameter=array())
|
||||
|
||||
if ($sPort != "1521") {
|
||||
// if not default port
|
||||
$conn = oci_connect($sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse);
|
||||
$conn = oci_connect( $sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse );
|
||||
} else {
|
||||
$conn = oci_connect($sUsername, $sPassword, $sHostspec . "/" . $sDatabse);
|
||||
$conn = oci_connect( $sUsername, $sPassword, $sHostspec . "/" . $sDatabse );
|
||||
}
|
||||
|
||||
if (!$conn) {
|
||||
if (! $conn) {
|
||||
$e = oci_error();
|
||||
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
|
||||
trigger_error( htmlentities( $e['message'], ENT_QUOTES ), E_USER_ERROR );
|
||||
return $e;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case preg_match("/^(SELECT|SHOW|DESCRIBE|DESC|WITH)\s/i", $sql):
|
||||
$stid = oci_parse($conn, $sql);
|
||||
if (count($aParameter) > 0) {
|
||||
case preg_match( "/^(SELECT|SHOW|DESCRIBE|DESC|WITH)\s/i", $sql ):
|
||||
$stid = oci_parse( $conn, $sql );
|
||||
if (count( $aParameter ) > 0) {
|
||||
foreach ($aParameter as $key => $val) {
|
||||
oci_bind_by_name($stid, $key, $val);
|
||||
oci_bind_by_name( $stid, $key, $val );
|
||||
}
|
||||
}
|
||||
oci_execute($stid, OCI_DEFAULT);
|
||||
oci_execute( $stid, OCI_DEFAULT );
|
||||
|
||||
$result = Array();
|
||||
$result = Array ();
|
||||
$i = 1;
|
||||
while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
|
||||
$result[$i++] = $row;
|
||||
while ($row = oci_fetch_array( $stid, OCI_ASSOC + OCI_RETURN_NULLS )) {
|
||||
$result[$i ++] = $row;
|
||||
}
|
||||
oci_free_statement($stid);
|
||||
oci_close($conn);
|
||||
oci_free_statement( $stid );
|
||||
oci_close( $conn );
|
||||
return $result;
|
||||
break;
|
||||
case preg_match("/^(INSERT|UPDATE|DELETE)\s/i", $sql):
|
||||
$stid = oci_parse($conn, $sql);
|
||||
case preg_match( "/^(INSERT|UPDATE|DELETE)\s/i", $sql ):
|
||||
$stid = oci_parse( $conn, $sql );
|
||||
$isValid = true;
|
||||
if (count($aParameter) > 0) {
|
||||
if (count( $aParameter ) > 0) {
|
||||
foreach ($aParameter as $key => $val) {
|
||||
oci_bind_by_name($stid, $key, $val);
|
||||
oci_bind_by_name( $stid, $key, $val );
|
||||
}
|
||||
}
|
||||
$objExecute = oci_execute($stid, OCI_DEFAULT);
|
||||
$objExecute = oci_execute( $stid, OCI_DEFAULT );
|
||||
if ($objExecute) {
|
||||
oci_commit($conn);
|
||||
oci_commit( $conn );
|
||||
} else {
|
||||
oci_rollback($conn);
|
||||
oci_rollback( $conn );
|
||||
$isValid = false;
|
||||
}
|
||||
oci_free_statement($stid);
|
||||
oci_close($conn);
|
||||
oci_free_statement( $stid );
|
||||
oci_close( $conn );
|
||||
if ($isValid) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -774,20 +695,20 @@ function executeQueryOci($sql, $connection, $aParameter=array())
|
||||
break;
|
||||
default:
|
||||
// Stored procedures
|
||||
$stid = oci_parse($conn, $sql);
|
||||
$aParameterRet = array();
|
||||
if (count($aParameter) > 0) {
|
||||
$stid = oci_parse( $conn, $sql );
|
||||
$aParameterRet = array ();
|
||||
if (count( $aParameter ) > 0) {
|
||||
foreach ($aParameter as $key => $val) {
|
||||
$aParameterRet[$key] = $val;
|
||||
// The third parameter ($aParameterRet[$key]) returned a value by reference.
|
||||
oci_bind_by_name($stid, $key, $aParameterRet[$key]);
|
||||
oci_bind_by_name( $stid, $key, $aParameterRet[$key] );
|
||||
}
|
||||
}
|
||||
$objExecute = oci_execute($stid, OCI_DEFAULT);
|
||||
oci_free_statement($stid);
|
||||
oci_close($conn);
|
||||
$objExecute = oci_execute( $stid, OCI_DEFAULT );
|
||||
oci_free_statement( $stid );
|
||||
oci_close( $conn );
|
||||
return $aParameterRet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
/**
|
||||
* class.case.php
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
@@ -14,11 +15,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -29,6 +30,7 @@ require_once 'classes/model/AdditionalTables.php';
|
||||
/**
|
||||
* PmTable Class
|
||||
* New class to handle pmTable in native form invoking to Phing & Propel
|
||||
*
|
||||
* @author Erik Amaru Ortiz <erik@colosa.com>
|
||||
*/
|
||||
class PmTable
|
||||
@@ -50,11 +52,11 @@ class PmTable
|
||||
private $db;
|
||||
private $alterTable = true;
|
||||
|
||||
public function __construct($tableName=null)
|
||||
public function __construct ($tableName = null)
|
||||
{
|
||||
if (isset($tableName)) {
|
||||
if (isset( $tableName )) {
|
||||
$this->tableName = $tableName;
|
||||
$this->className = $this->toCamelCase($tableName);
|
||||
$this->className = $this->toCamelCase( $tableName );
|
||||
}
|
||||
|
||||
$this->dbConfig = new StdClass();
|
||||
@@ -62,21 +64,23 @@ class PmTable
|
||||
|
||||
/**
|
||||
* Set columns to pmTable
|
||||
*
|
||||
* @param array $columns contains a array of abjects
|
||||
* array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...)
|
||||
* array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...)
|
||||
*/
|
||||
public function setColumns($columns)
|
||||
public function setColumns ($columns)
|
||||
{
|
||||
$this->columns = $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a data source
|
||||
*
|
||||
* @param string $dbsUid DBS_UID to relate the pmTable to phisical table
|
||||
*/
|
||||
public function setDataSource($dbsUid)
|
||||
public function setDataSource ($dbsUid)
|
||||
{
|
||||
$this->dataSource = self::resolveDbSource($dbsUid);
|
||||
$this->dataSource = self::resolveDbSource( $dbsUid );
|
||||
|
||||
switch ($this->dataSource) {
|
||||
case 'workflow':
|
||||
@@ -98,10 +102,10 @@ class PmTable
|
||||
default:
|
||||
require_once 'classes/model/DbSource.php';
|
||||
$oDBSource = new DbSource();
|
||||
$proUid = $oDBSource->getValProUid($this->dataSource);
|
||||
$dbSource = $oDBSource->load($this->dataSource, $proUid);
|
||||
$proUid = $oDBSource->getValProUid( $this->dataSource );
|
||||
$dbSource = $oDBSource->load( $this->dataSource, $proUid );
|
||||
|
||||
if (is_object($dbSource)) {
|
||||
if (is_object( $dbSource )) {
|
||||
$this->dbConfig->adapter = $dbSource->getDbsType();
|
||||
$this->dbConfig->host = $dbSource->getDbsServer();
|
||||
$this->dbConfig->name = $dbSource->getDbsDatabaseName();
|
||||
@@ -109,7 +113,7 @@ class PmTable
|
||||
$this->dbConfig->passwd = $dbSource->getDbsPassword();
|
||||
$this->dbConfig->port = $dbSource->getDbsPort();
|
||||
}
|
||||
if (is_array($dbSource)) {
|
||||
if (is_array( $dbSource )) {
|
||||
$this->dbConfig->adapter = $dbSource['DBS_TYPE'];
|
||||
$this->dbConfig->host = $dbSource['DBS_SERVER'];
|
||||
$this->dbConfig->name = $dbSource['DBS_DATABASE_NAME'];
|
||||
@@ -117,7 +121,7 @@ class PmTable
|
||||
$this->dbConfig->passwd = $dbSource['DBS_PASSWORD'];
|
||||
$this->dbConfig->port = $dbSource['DBS_PORT'];
|
||||
} else {
|
||||
throw new Exception("Db source with id $dbsUid does not exist!");
|
||||
throw new Exception( "Db source with id $dbsUid does not exist!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,10 +129,11 @@ class PmTable
|
||||
/**
|
||||
* Backward compatibility function
|
||||
* Resolve a propel data source
|
||||
*
|
||||
* @param string $dbsUid corresponding to DBS_UID key
|
||||
* @return string contains resolved DBS_UID
|
||||
*/
|
||||
public function resolveDbSource($dbsUid)
|
||||
public function resolveDbSource ($dbsUid)
|
||||
{
|
||||
switch ($dbsUid) {
|
||||
case 'workflow':
|
||||
@@ -147,21 +152,22 @@ class PmTable
|
||||
return $dbsUid;
|
||||
}
|
||||
|
||||
public function getDataSource()
|
||||
public function getDataSource ()
|
||||
{
|
||||
return $this->dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Data base config object
|
||||
*
|
||||
* @return object containing dbConfig var
|
||||
*/
|
||||
public function getDbConfig()
|
||||
public function getDbConfig ()
|
||||
{
|
||||
return $this->dbConfig;
|
||||
}
|
||||
|
||||
public function setAlterTable($value)
|
||||
public function setAlterTable ($value)
|
||||
{
|
||||
$this->alterTable = $value;
|
||||
}
|
||||
@@ -169,7 +175,7 @@ class PmTable
|
||||
/**
|
||||
* Build the pmTable with all dependencies
|
||||
*/
|
||||
public function build()
|
||||
public function build ()
|
||||
{
|
||||
$this->prepare();
|
||||
$this->preparePropelIniFile();
|
||||
@@ -182,11 +188,11 @@ class PmTable
|
||||
}
|
||||
}
|
||||
|
||||
public function buildModelFor($dbsUid, $tablesList)
|
||||
public function buildModelFor ($dbsUid, $tablesList)
|
||||
{
|
||||
$this->setDataSource($dbsUid);
|
||||
$this->setDataSource( $dbsUid );
|
||||
$loadSchema = false;
|
||||
$this->prepare($loadSchema);
|
||||
$this->prepare( $loadSchema );
|
||||
$this->phingbuildModel();
|
||||
$this->phingbuildSql();
|
||||
//$this->upgradeDatabaseFor($this->dataSource, $tablesList);
|
||||
@@ -195,10 +201,10 @@ class PmTable
|
||||
/**
|
||||
* Prepare the pmTable env
|
||||
*/
|
||||
public function prepare($loadSchema=true)
|
||||
public function prepare ($loadSchema = true)
|
||||
{
|
||||
//prevent execute prepare() twice or more
|
||||
if (is_object($this->dom)) {
|
||||
if (is_object( $this->dom )) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -210,94 +216,93 @@ class PmTable
|
||||
$this->classesDir = $this->baseDir . 'classes' . PATH_SEP;
|
||||
|
||||
// G::mk_dir create the requested dir and the parents directories if not exists
|
||||
G::mk_dir($this->configDir);
|
||||
G::mk_dir($this->dataDir);
|
||||
G::mk_dir( $this->configDir );
|
||||
G::mk_dir( $this->dataDir );
|
||||
|
||||
if ($loadSchema) {
|
||||
$this->loadSchema();
|
||||
}
|
||||
}
|
||||
|
||||
public function loadSchema()
|
||||
public function loadSchema ()
|
||||
{
|
||||
$this->dom = new DOMDocument('1.0', 'utf-8');
|
||||
$this->dom = new DOMDocument( '1.0', 'utf-8' );
|
||||
$this->dom->preserveWhiteSpace = false;
|
||||
$this->dom->formatOutput = true;
|
||||
|
||||
if (file_exists($this->configDir . $this->schemaFilename)) {
|
||||
if (@$this->dom->load($this->configDir . $this->schemaFilename) !== true) {
|
||||
throw new Exception('Error: ' . $this->schemaFilename . ' is a invalid xml file!');
|
||||
if (file_exists( $this->configDir . $this->schemaFilename )) {
|
||||
if (@$this->dom->load( $this->configDir . $this->schemaFilename ) !== true) {
|
||||
throw new Exception( 'Error: ' . $this->schemaFilename . ' is a invalid xml file!' );
|
||||
}
|
||||
$this->rootNode = $this->dom->firstChild;
|
||||
} else {
|
||||
$this->rootNode = $this->dom->createElement('database');
|
||||
$this->rootNode->setAttribute('name', $this->dataSource);
|
||||
$this->dom->appendChild($this->rootNode);
|
||||
$this->rootNode = $this->dom->createElement( 'database' );
|
||||
$this->rootNode->setAttribute( 'name', $this->dataSource );
|
||||
$this->dom->appendChild( $this->rootNode );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the xml schema for propel
|
||||
*/
|
||||
public function buildSchema()
|
||||
public function buildSchema ()
|
||||
{
|
||||
$tableNode = $this->dom->createElement('table');
|
||||
$tableNode->setAttribute('name', $this->tableName);
|
||||
$tableNode = $this->dom->createElement( 'table' );
|
||||
$tableNode->setAttribute( 'name', $this->tableName );
|
||||
|
||||
if ($this->hasAutoIncrementPKey()) {
|
||||
$tableNode->setAttribute('idMethod', 'native');
|
||||
$tableNode->setAttribute( 'idMethod', 'native' );
|
||||
}
|
||||
|
||||
// specifying collation
|
||||
switch ($this->dbConfig->adapter) {
|
||||
case 'mysql':
|
||||
$vendorNode = $this->dom->createElement('vendor');
|
||||
$vendorNode->setAttribute('type', $this->dbConfig->adapter);
|
||||
$parameterNode = $this->dom->createElement('parameter');
|
||||
$parameterNode->setAttribute('name', 'Collation');
|
||||
$parameterNode->setAttribute('value', 'utf8_general_ci');
|
||||
$vendorNode->appendChild($parameterNode);
|
||||
$tableNode->appendChild($vendorNode);
|
||||
$vendorNode = $this->dom->createElement( 'vendor' );
|
||||
$vendorNode->setAttribute( 'type', $this->dbConfig->adapter );
|
||||
$parameterNode = $this->dom->createElement( 'parameter' );
|
||||
$parameterNode->setAttribute( 'name', 'Collation' );
|
||||
$parameterNode->setAttribute( 'value', 'utf8_general_ci' );
|
||||
$vendorNode->appendChild( $parameterNode );
|
||||
$tableNode->appendChild( $vendorNode );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->columns as $column) {
|
||||
|
||||
// create the column node
|
||||
$columnNode = $this->dom->createElement('column');
|
||||
$columnNode = $this->dom->createElement( 'column' );
|
||||
// setting column node attributes
|
||||
$columnNode->setAttribute('name', $column->field_name);
|
||||
$columnNode->setAttribute('type', $column->field_type);
|
||||
$columnNode->setAttribute( 'name', $column->field_name );
|
||||
$columnNode->setAttribute( 'type', $column->field_type );
|
||||
|
||||
if ($column->field_size != '' && $column->field_size != 0) {
|
||||
$columnNode->setAttribute('size', $column->field_size);
|
||||
$columnNode->setAttribute( 'size', $column->field_size );
|
||||
}
|
||||
|
||||
$columnNode->setAttribute('required', ($column->field_null ? 'false' : 'true'));
|
||||
$columnNode->setAttribute( 'required', ($column->field_null ? 'false' : 'true') );
|
||||
|
||||
// only define the primaryKey attribute if it is defined
|
||||
if ($column->field_key) {
|
||||
$columnNode->setAttribute('primaryKey', "true");
|
||||
$columnNode->setAttribute( 'primaryKey', "true" );
|
||||
}
|
||||
|
||||
// only define the autoIncrement attribute if it is defined
|
||||
if ($column->field_autoincrement) {
|
||||
$columnNode->setAttribute('autoIncrement', "true");
|
||||
$columnNode->setAttribute( 'autoIncrement', "true" );
|
||||
}
|
||||
$tableNode->appendChild($columnNode);
|
||||
$tableNode->appendChild( $columnNode );
|
||||
}
|
||||
|
||||
$xpath = new DOMXPath($this->dom);
|
||||
$xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]');
|
||||
$xpath = new DOMXPath( $this->dom );
|
||||
$xtable = $xpath->query( '/database/table[@name="' . $this->tableName . '"]' );
|
||||
|
||||
if ($xtable->length == 0) {
|
||||
//the table definition does not exist, then just append the new node
|
||||
$this->rootNode->appendChild($tableNode);
|
||||
$this->rootNode->appendChild( $tableNode );
|
||||
} else {
|
||||
// the table definition already exist, then replace the node
|
||||
$replacedNode = $xtable->item(0);
|
||||
$this->rootNode->replaceChild($tableNode, $replacedNode);
|
||||
$replacedNode = $xtable->item( 0 );
|
||||
$this->rootNode->replaceChild( $tableNode, $replacedNode );
|
||||
}
|
||||
|
||||
// saving the xml result file
|
||||
@@ -307,7 +312,7 @@ class PmTable
|
||||
/**
|
||||
* Remove the pmTable and all related objects, files and others
|
||||
*/
|
||||
public function remove()
|
||||
public function remove ()
|
||||
{
|
||||
$this->prepare();
|
||||
$this->removeFromSchema();
|
||||
@@ -318,16 +323,16 @@ class PmTable
|
||||
/**
|
||||
* Remove the target pmTable from schema of propel
|
||||
*/
|
||||
public function removeFromSchema()
|
||||
public function removeFromSchema ()
|
||||
{
|
||||
$xpath = new DOMXPath($this->dom);
|
||||
$xpath = new DOMXPath( $this->dom );
|
||||
// locate the node
|
||||
$xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]');
|
||||
$xtable = $xpath->query( '/database/table[@name="' . $this->tableName . '"]' );
|
||||
if ($xtable->length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->rootNode->removeChild($xtable->item(0));
|
||||
$this->rootNode->removeChild( $xtable->item( 0 ) );
|
||||
// saving the xml result file
|
||||
$this->saveSchema();
|
||||
}
|
||||
@@ -335,29 +340,29 @@ class PmTable
|
||||
/**
|
||||
* Remove the model related classes files
|
||||
*/
|
||||
public function removeModelFiles()
|
||||
public function removeModelFiles ()
|
||||
{
|
||||
@unlink($this->classesDir . $this->className . '.php');
|
||||
@unlink($this->classesDir . $this->className . 'Peer.php');
|
||||
@unlink($this->classesDir . 'map' . PATH_SEP . $this->className . 'MapBuilder.php');
|
||||
@unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . '.php');
|
||||
@unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . 'Peer.php');
|
||||
@unlink( $this->classesDir . $this->className . '.php' );
|
||||
@unlink( $this->classesDir . $this->className . 'Peer.php' );
|
||||
@unlink( $this->classesDir . 'map' . PATH_SEP . $this->className . 'MapBuilder.php' );
|
||||
@unlink( $this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . '.php' );
|
||||
@unlink( $this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . 'Peer.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop the phisical table of target pmTable or any specified as parameter
|
||||
*/
|
||||
public function dropTable($tableName=null)
|
||||
public function dropTable ($tableName = null)
|
||||
{
|
||||
$tableName = isset($tableName) ? $tableName : $this->tableName;
|
||||
$con = Propel::getConnection($this->dataSource);
|
||||
$tableName = isset( $tableName ) ? $tableName : $this->tableName;
|
||||
$con = Propel::getConnection( $this->dataSource );
|
||||
$stmt = $con->createStatement();
|
||||
|
||||
if (is_object($con)) {
|
||||
if (is_object( $con )) {
|
||||
try {
|
||||
$stmt->executeQuery("DROP TABLE {$tableName}");
|
||||
$stmt->executeQuery( "DROP TABLE {$tableName}" );
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Physical table '$tableName' does not exist!");
|
||||
throw new Exception( "Physical table '$tableName' does not exist!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,28 +370,27 @@ class PmTable
|
||||
/**
|
||||
* Save the xml schema for propel
|
||||
*/
|
||||
public function saveSchema()
|
||||
public function saveSchema ()
|
||||
{
|
||||
$this->dom->save($this->configDir . $this->schemaFilename);
|
||||
$this->dom->save( $this->configDir . $this->schemaFilename );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and create if not exists the propel ini file
|
||||
*/
|
||||
public function preparePropelIniFile()
|
||||
public function preparePropelIniFile ()
|
||||
{
|
||||
$adapter = $this->dbConfig->adapter;
|
||||
|
||||
if (file_exists($this->configDir . "propel.$adapter.ini")) {
|
||||
if (file_exists( $this->configDir . "propel.$adapter.ini" )) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!file_exists(PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini")) {
|
||||
throw new Exception("Invalid or not supported engine '$adapter'!");
|
||||
if (! file_exists( PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini" )) {
|
||||
throw new Exception( "Invalid or not supported engine '$adapter'!" );
|
||||
}
|
||||
|
||||
@copy(PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini",
|
||||
$this->configDir . "propel.$adapter.ini");
|
||||
@copy( PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini", $this->configDir . "propel.$adapter.ini" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,34 +399,35 @@ class PmTable
|
||||
* for the related table
|
||||
* - this function is not executing other sentenses like 'SET FOREIGN_KEY_CHECKS = 0;' for mysql, and others
|
||||
*/
|
||||
public function upgradeDatabase()
|
||||
public function upgradeDatabase ()
|
||||
{
|
||||
$con = Propel::getConnection($this->dataSource);
|
||||
$con = Propel::getConnection( $this->dataSource );
|
||||
$stmt = $con->createStatement();
|
||||
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
|
||||
$lines = file( $this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql' );
|
||||
$previous = null;
|
||||
$queryStack = array();
|
||||
$queryStack = array ();
|
||||
$aDNS = $con->getDSN();
|
||||
$dbEngine = $aDNS["phptype"];
|
||||
|
||||
foreach ($lines as $j => $line) {
|
||||
switch ($dbEngine) {
|
||||
case 'mysql':
|
||||
$line = trim($line); // Remove comments from the script
|
||||
$line = trim( $line ); // Remove comments from the script
|
||||
|
||||
if (strpos($line, "--") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "--"));
|
||||
|
||||
if (strpos( $line, "--" ) === 0) {
|
||||
$line = substr( $line, 0, strpos( $line, "--" ) );
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
if (empty( $line )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($line, "#") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "#"));
|
||||
if (strpos( $line, "#" ) === 0) {
|
||||
$line = substr( $line, 0, strpos( $line, "#" ) );
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
if (empty( $line )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -434,21 +439,19 @@ class PmTable
|
||||
|
||||
// If the current line doesnt end with ; then put this line together
|
||||
// with the next one, thus supporting multi-line statements.
|
||||
if (strrpos($line, ";") != strlen($line) - 1) {
|
||||
if (strrpos( $line, ";" ) != strlen( $line ) - 1) {
|
||||
$previous = $line;
|
||||
continue;
|
||||
}
|
||||
|
||||
$line = substr($line, 0, strrpos($line, ";"));
|
||||
$line = substr( $line, 0, strrpos( $line, ";" ) );
|
||||
// just execute the drop and create table for target table nad not for others
|
||||
if (stripos($line, 'CREATE TABLE') !== false || stripos($line, 'DROP TABLE') !== false) {
|
||||
$isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName
|
||||
. '[\]\'\"\`]{1}/i', $line, $match);
|
||||
if (stripos( $line, 'CREATE TABLE' ) !== false || stripos( $line, 'DROP TABLE' ) !== false) {
|
||||
$isCreateForCurrentTable = preg_match( '/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match );
|
||||
if ($isCreateForCurrentTable) {
|
||||
$queryStack['create'] = $line;
|
||||
} else {
|
||||
$isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName
|
||||
. '[\]\'\"\`]{1}/i', $line, $match);
|
||||
$isDropForCurrentTable = preg_match( '/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match );
|
||||
if ($isDropForCurrentTable) {
|
||||
$queryStack['drop'] = $line;
|
||||
}
|
||||
@@ -456,21 +459,22 @@ class PmTable
|
||||
}
|
||||
break;
|
||||
case 'mssql':
|
||||
$line = trim($line); // Remove comments from the script
|
||||
$line = trim( $line ); // Remove comments from the script
|
||||
|
||||
if (strpos($line, "--") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "--"));
|
||||
|
||||
if (strpos( $line, "--" ) === 0) {
|
||||
$line = substr( $line, 0, strpos( $line, "--" ) );
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
if (empty( $line )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($line, "#") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "#"));
|
||||
if (strpos( $line, "#" ) === 0) {
|
||||
$line = substr( $line, 0, strpos( $line, "#" ) );
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
if (empty( $line )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -482,47 +486,47 @@ class PmTable
|
||||
|
||||
// If the current line doesnt end with ; then put this line together
|
||||
// with the next one, thus supporting multi-line statements.
|
||||
if (strrpos($line, ";") != strlen($line) - 1) {
|
||||
if (strrpos( $line, ";" ) != strlen( $line ) - 1) {
|
||||
$previous = $line;
|
||||
continue;
|
||||
}
|
||||
|
||||
$line = substr($line, 0, strrpos($line, ";"));
|
||||
$line = substr( $line, 0, strrpos( $line, ";" ) );
|
||||
|
||||
if (strpos($line, $this->tableName) == false) {
|
||||
if (strpos( $line, $this->tableName ) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$auxCreate = explode('CREATE', $line);
|
||||
$auxDrop = explode('IF EXISTS', $auxCreate['0']);
|
||||
$auxCreate = explode( 'CREATE', $line );
|
||||
$auxDrop = explode( 'IF EXISTS', $auxCreate['0'] );
|
||||
|
||||
$queryStack['drop'] = 'IF EXISTS' . $auxDrop['1'];
|
||||
$queryStack['drop'] = 'IF EXISTS' . $auxDrop['1'];
|
||||
$queryStack['create'] = 'CREATE' . $auxCreate['1'];
|
||||
|
||||
break;
|
||||
case 'oracle':
|
||||
$line = trim($line); // Remove comments from the script
|
||||
if (empty($line)) {
|
||||
$line = trim( $line ); // Remove comments from the script
|
||||
if (empty( $line )) {
|
||||
continue;
|
||||
}
|
||||
switch (true) {
|
||||
case preg_match("/^CREATE TABLE\s/i", $line):
|
||||
if (strpos($line, $this->tableName) == true) {
|
||||
case preg_match( "/^CREATE TABLE\s/i", $line ):
|
||||
if (strpos( $line, $this->tableName ) == true) {
|
||||
$inCreate = true;
|
||||
$lineCreate .= $line . ' ';
|
||||
}
|
||||
break;
|
||||
case preg_match("/ALTER TABLE\s/i", $line):
|
||||
if (strpos($line, $this->tableName) == true) {
|
||||
case preg_match( "/ALTER TABLE\s/i", $line ):
|
||||
if (strpos( $line, $this->tableName ) == true) {
|
||||
$inAlter = true;
|
||||
$lineAlter .= $line . ' ';
|
||||
}
|
||||
break;
|
||||
case preg_match("/^DROP TABLE\s/i", $line):
|
||||
if (strpos($line, $this->tableName) == true) {
|
||||
case preg_match( "/^DROP TABLE\s/i", $line ):
|
||||
if (strpos( $line, $this->tableName ) == true) {
|
||||
$inDrop = true;
|
||||
$lineDrop .= $line . ' ';
|
||||
if (strrpos($line, ";") > 0) {
|
||||
if (strrpos( $line, ";" ) > 0) {
|
||||
$queryStack['drop'] = $lineDrop;
|
||||
$inDrop = false;
|
||||
}
|
||||
@@ -531,21 +535,21 @@ class PmTable
|
||||
default:
|
||||
if ($inCreate) {
|
||||
$lineCreate .= $line . ' ';
|
||||
if (strrpos($line, ";") > 0) {
|
||||
if (strrpos( $line, ";" ) > 0) {
|
||||
$queryStack['create'] = $lineCreate;
|
||||
$inCreate = false;
|
||||
}
|
||||
}
|
||||
if ($inAlter) {
|
||||
$lineAlter .= $line . ' ';
|
||||
if (strrpos($line, ";") > 0) {
|
||||
if (strrpos( $line, ";" ) > 0) {
|
||||
$queryStack['alter'] = $lineAlter;
|
||||
$inAlter = false;
|
||||
}
|
||||
}
|
||||
if ($inDrop) {
|
||||
$lineDrop .= $line . ' ';
|
||||
if (strrpos($line, ";") > 0) {
|
||||
if (strrpos( $line, ";" ) > 0) {
|
||||
$queryStack['drop'] = $lineDrop;
|
||||
$inDrop = false;
|
||||
}
|
||||
@@ -556,64 +560,65 @@ class PmTable
|
||||
}
|
||||
|
||||
if ($dbEngine == 'oracle') {
|
||||
$queryStack['drop'] = substr($queryStack['drop'], 0, strrpos($queryStack['drop'], ";"));
|
||||
$queryStack['create'] = substr($queryStack['create'], 0, strrpos($queryStack['create'], ";"));
|
||||
$queryStack['alter'] = substr($queryStack['alter'], 0, strrpos($queryStack['alter'], ";"));
|
||||
$queryStack['drop'] = substr( $queryStack['drop'], 0, strrpos( $queryStack['drop'], ";" ) );
|
||||
$queryStack['create'] = substr( $queryStack['create'], 0, strrpos( $queryStack['create'], ";" ) );
|
||||
$queryStack['alter'] = substr( $queryStack['alter'], 0, strrpos( $queryStack['alter'], ";" ) );
|
||||
$queryIfExistTable = "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME = '" . $this->tableName . "'";
|
||||
|
||||
$rs = $stmt->executeQuery($queryIfExistTable);
|
||||
$rs = $stmt->executeQuery( $queryIfExistTable );
|
||||
if ($rs->next()) {
|
||||
$stmt->executeQuery($queryStack['drop']);
|
||||
$stmt->executeQuery( $queryStack['drop'] );
|
||||
}
|
||||
$stmt->executeQuery($queryStack['create']);
|
||||
$stmt->executeQuery($queryStack['alter']);
|
||||
$stmt->executeQuery( $queryStack['create'] );
|
||||
$stmt->executeQuery( $queryStack['alter'] );
|
||||
} else {
|
||||
if (isset($queryStack['create'])) {
|
||||
if (isset( $queryStack['create'] )) {
|
||||
// first at all we need to verify if we have a valid schema defined,
|
||||
// so we verify that creating a dummy table
|
||||
$swapQuery = str_replace($this->tableName, $this->tableName . '_TMP', $queryStack['create']);
|
||||
$swapQuery = str_replace( $this->tableName, $this->tableName . '_TMP', $queryStack['create'] );
|
||||
|
||||
// if there is a problem with user defined table schema executeQuery() will throw a sql exception
|
||||
$stmt->executeQuery($swapQuery);
|
||||
$stmt->executeQuery( $swapQuery );
|
||||
|
||||
// if there was not problem above proceced deleting the dummy table and drop and create the target table
|
||||
$stmt->executeQuery("DROP TABLE {$this->tableName}_TMP");
|
||||
if (!isset($queryStack['drop'])) {
|
||||
$stmt->executeQuery( "DROP TABLE {$this->tableName}_TMP" );
|
||||
if (! isset( $queryStack['drop'] )) {
|
||||
$queryStack['drop'] = "DROP TABLE {$this->tableName}";
|
||||
}
|
||||
if (!isset($queryStack['create'])) {
|
||||
throw new Exception('A problem occurred resolving the schema to update for this table');
|
||||
if (! isset( $queryStack['create'] )) {
|
||||
throw new Exception( 'A problem occurred resolving the schema to update for this table' );
|
||||
}
|
||||
$stmt->executeQuery($queryStack['drop']);
|
||||
$stmt->executeQuery($queryStack['create']);
|
||||
$stmt->executeQuery( $queryStack['drop'] );
|
||||
$stmt->executeQuery( $queryStack['create'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function upgradeDatabaseFor($dataSource, $tablesList=array())
|
||||
public function upgradeDatabaseFor ($dataSource, $tablesList = array())
|
||||
{
|
||||
$con = Propel::getConnection($dataSource);
|
||||
$con = Propel::getConnection( $dataSource );
|
||||
$stmt = $con->createStatement();
|
||||
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
|
||||
$lines = file( $this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql' );
|
||||
$previous = null;
|
||||
$errors = '';
|
||||
|
||||
foreach ($lines as $j => $line) {
|
||||
$line = trim($line); // Remove comments from the script
|
||||
$line = trim( $line ); // Remove comments from the script
|
||||
|
||||
if (strpos($line, "--") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "--"));
|
||||
|
||||
if (strpos( $line, "--" ) === 0) {
|
||||
$line = substr( $line, 0, strpos( $line, "--" ) );
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
if (empty( $line )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($line, "#") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "#"));
|
||||
if (strpos( $line, "#" ) === 0) {
|
||||
$line = substr( $line, 0, strpos( $line, "#" ) );
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
if (empty( $line )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -625,23 +630,23 @@ class PmTable
|
||||
|
||||
// If the current line doesnt end with ; then put this line together
|
||||
// with the next one, thus supporting multi-line statements.
|
||||
if (strrpos($line, ";") != strlen($line) - 1) {
|
||||
if (strrpos( $line, ";" ) != strlen( $line ) - 1) {
|
||||
$previous = $line;
|
||||
continue;
|
||||
}
|
||||
|
||||
$line = substr($line, 0, strrpos($line, ";"));
|
||||
$line = substr( $line, 0, strrpos( $line, ";" ) );
|
||||
|
||||
// execute
|
||||
$isCreate = stripos($line, 'CREATE TABLE') !== false;
|
||||
$isDrop = stripos($line, 'DROP TABLE') !== false;
|
||||
$isCreate = stripos( $line, 'CREATE TABLE' ) !== false;
|
||||
$isDrop = stripos( $line, 'DROP TABLE' ) !== false;
|
||||
|
||||
if ($isCreate || $isDrop) {
|
||||
if (preg_match('/TABLE\s[\'\"\`]+(\w+)[\'\"\`]+/i', $line, $match)) {
|
||||
if (in_array($match[1], $tablesList)) {
|
||||
if (preg_match( '/TABLE\s[\'\"\`]+(\w+)[\'\"\`]+/i', $line, $match )) {
|
||||
if (in_array( $match[1], $tablesList )) {
|
||||
//error_log($line);
|
||||
try {
|
||||
$stmt->executeQuery($line);
|
||||
$stmt->executeQuery( $line );
|
||||
} catch (Exception $e) {
|
||||
$errors .= $e->getMessage() . "\n";
|
||||
continue;
|
||||
@@ -656,9 +661,10 @@ class PmTable
|
||||
|
||||
/**
|
||||
* verify if on the columns list was set a column as primary key
|
||||
*
|
||||
* @return boolean to affirm if was defined a column as pk.
|
||||
*/
|
||||
public function hasAutoIncrementPKey()
|
||||
public function hasAutoIncrementPKey ()
|
||||
{
|
||||
foreach ($this->columns as $column) {
|
||||
if ($column->field_autoincrement) {
|
||||
@@ -673,14 +679,14 @@ class PmTable
|
||||
*
|
||||
* @return array contains all supported columns types provided by propel
|
||||
*/
|
||||
public function getPropelSupportedColumnTypes()
|
||||
public function getPropelSupportedColumnTypes ()
|
||||
{
|
||||
/**
|
||||
* http://www.propelorm.org/wiki/Documentation/1.2/Schema
|
||||
* [type = "BOOLEAN|TINYINT|SMALLINT|INTEGER|BIGINT|DOUBLE|FLOAT|REAL|DECIMAL|CHAR|{VARCHAR}
|
||||
* |LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB"]
|
||||
* |LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB"]
|
||||
*/
|
||||
$types = array();
|
||||
$types = array ();
|
||||
|
||||
$types['BOOLEAN'] = 'BOOLEAN';
|
||||
$types['TINYINT'] = 'TINYINT';
|
||||
@@ -700,96 +706,96 @@ class PmTable
|
||||
//$types['BLOB'] = 'BLOB'; <- disabled
|
||||
//$types['CLOB'] = 'CLOB'; <- disabled
|
||||
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name any string witha name separated by underscore
|
||||
* @return string contains a camelcase expresion for $name
|
||||
*/
|
||||
public function toCamelCase($name)
|
||||
public function toCamelCase ($name)
|
||||
{
|
||||
$tmp = explode('_', trim($name));
|
||||
$tmp = explode( '_', trim( $name ) );
|
||||
foreach ($tmp as $i => $part) {
|
||||
$tmp[$i] = ucFirst(strtolower($part));
|
||||
$tmp[$i] = ucFirst( strtolower( $part ) );
|
||||
}
|
||||
return implode('', $tmp);
|
||||
return implode( '', $tmp );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run om task for phing to build all mdoel classes
|
||||
*/
|
||||
public function phingbuildModel()
|
||||
public function phingbuildModel ()
|
||||
{
|
||||
$this->_callPhing('om');
|
||||
$this->_callPhing( 'om' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run sql task for phing to generate the sql schema
|
||||
*/
|
||||
public function phingbuildSql()
|
||||
public function phingbuildSql ()
|
||||
{
|
||||
$this->_callPhing('sql');
|
||||
$this->_callPhing( 'sql' );
|
||||
}
|
||||
|
||||
/**
|
||||
* call phing to execute a determinated task
|
||||
*
|
||||
* @param string $taskName [om|sql]
|
||||
*/
|
||||
private function _callPhing($taskName)
|
||||
private function _callPhing ($taskName)
|
||||
{
|
||||
$options = array(
|
||||
'project.dir' => $this->configDir,
|
||||
'build.properties' => "propel.{$this->dbConfig->adapter}.ini",
|
||||
'propel.targetPackage' => 'classes',
|
||||
'propel.output.dir' => $this->targetDir,
|
||||
'propel.php.dir' => $this->baseDir
|
||||
$options = array ('project.dir' => $this->configDir,'build.properties' => "propel.{$this->dbConfig->adapter}.ini",'propel.targetPackage' => 'classes','propel.output.dir' => $this->targetDir,'propel.php.dir' => $this->baseDir
|
||||
);
|
||||
|
||||
self::callPhing(array($taskName), PATH_THIRDPARTY . 'propel-generator/build.xml', $options, false);
|
||||
self::callPhing( array ($taskName
|
||||
), PATH_THIRDPARTY . 'propel-generator/build.xml', $options, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $target - task name to execute
|
||||
*
|
||||
* @param string $target - task name to execute
|
||||
* @param string $buildFile - build file path
|
||||
* @param array $options - array options to override the options on .ini file
|
||||
* @param bool $verbose - to show a verbose output
|
||||
* @param array $options - array options to override the options on .ini file
|
||||
* @param bool $verbose - to show a verbose output
|
||||
*/
|
||||
public static function callPhing($target, $buildFile='', $options=array(), $verbose=true)
|
||||
public static function callPhing ($target, $buildFile = '', $options = array(), $verbose = true)
|
||||
{
|
||||
G::loadClass('pmPhing');
|
||||
G::loadClass( 'pmPhing' );
|
||||
|
||||
$args = array();
|
||||
$args = array ();
|
||||
foreach ($options as $key => $value) {
|
||||
$args[] = "-D$key=$value";
|
||||
}
|
||||
|
||||
if ($buildFile) {
|
||||
$args[] = '-f';
|
||||
$args[] = realpath($buildFile);
|
||||
$args[] = realpath( $buildFile );
|
||||
}
|
||||
|
||||
if (!$verbose) {
|
||||
if (! $verbose) {
|
||||
$args[] = '-q';
|
||||
}
|
||||
|
||||
if (is_array($target)) {
|
||||
$args = array_merge($args, $target);
|
||||
if (is_array( $target )) {
|
||||
$args = array_merge( $args, $target );
|
||||
} else {
|
||||
$args[] = $target;
|
||||
}
|
||||
|
||||
if (DIRECTORY_SEPARATOR != '\\' && (function_exists('posix_isatty') && @posix_isatty(STDOUT))) {
|
||||
if (DIRECTORY_SEPARATOR != '\\' && (function_exists( 'posix_isatty' ) && @posix_isatty( STDOUT ))) {
|
||||
$args[] = '-logger';
|
||||
$args[] = 'phing.listener.AnsiColorLogger';
|
||||
}
|
||||
|
||||
Phing::startup();
|
||||
Phing::setProperty('phing.home', getenv('PHING_HOME'));
|
||||
Phing::setProperty( 'phing.home', getenv( 'PHING_HOME' ) );
|
||||
|
||||
$m = new pmPhing();
|
||||
$m->execute($args);
|
||||
$m->execute( $args );
|
||||
$m->runBuild();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.replacementLogo.php
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,93 +15,98 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
class replacementLogo {
|
||||
|
||||
//var $dir='';
|
||||
/**
|
||||
* This function is the constructor of the replacementLogo class
|
||||
* param
|
||||
* @return void
|
||||
*/
|
||||
function replacementLogo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function upload a file
|
||||
*
|
||||
*
|
||||
* @name upLoadFile
|
||||
*
|
||||
* @param string $dirUpload
|
||||
* @param string $namefile
|
||||
* @param string $typefile
|
||||
* @param string $errorfile
|
||||
* @param string $tpnfile
|
||||
* @param string $formf
|
||||
* @return string
|
||||
*/
|
||||
function upLoadFile($dirUpload, $namefile, $typefile, $errorfile, $tpnfile, $formf) {
|
||||
|
||||
//we are cheking the extension for file
|
||||
$aExt = explode ( ".", $namefile );
|
||||
$infoupload = ''; //|| ($formf["type"]['uploadfile'] == "application/octet-stream")image/png
|
||||
if (($typefile == "image/jpeg") || ($typefile == "image/png")) {
|
||||
if ($errorfile > 0) {
|
||||
$infoupload = "Return Code: " . $errorfile . "<br />";
|
||||
} else {
|
||||
if (file_exists ( $dirUpload . $namefile )) {
|
||||
$infoupload = $namefile . " already exist. ";
|
||||
} else {
|
||||
move_uploaded_file ( $tpnfile, $dirUpload . $namefile );
|
||||
$infoupload = "Stored in: " . $dirUpload . $namefile;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$infoupload = "- " . $typefile . " Invalid file your file should be jpeg";
|
||||
class replacementLogo
|
||||
{
|
||||
|
||||
//var $dir='';
|
||||
/**
|
||||
* This function is the constructor of the replacementLogo class
|
||||
* param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function replacementLogo ()
|
||||
{
|
||||
|
||||
}
|
||||
return $infoupload;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets the logos' names
|
||||
*
|
||||
*
|
||||
* @name getNameLogo
|
||||
*
|
||||
* param
|
||||
* @return array
|
||||
*/
|
||||
function getNameLogo($usrUid) {
|
||||
|
||||
require_once 'classes/model/Configuration.php';
|
||||
$oCriteria = new Criteria ( 'workflow' );
|
||||
$oCriteria->addSelectColumn ( ConfigurationPeer::CFG_VALUE );
|
||||
$oCriteria->add ( ConfigurationPeer::CFG_UID, 'USER_LOGO_REPLACEMENT' );
|
||||
$oDataset = ConfigurationPeer::doSelectRS ( $oCriteria );
|
||||
$oDataset->next ();
|
||||
$aRow = $oDataset->getRow ();
|
||||
if (isset ( $aRow [0] ))
|
||||
$ainfoLogo = @unserialize ( $aRow [0] );
|
||||
else
|
||||
$ainfoLogo = NULL;
|
||||
|
||||
return ($ainfoLogo);
|
||||
}
|
||||
|
||||
} // end class
|
||||
/**
|
||||
* This function upload a file
|
||||
*
|
||||
*
|
||||
* @name upLoadFile
|
||||
*
|
||||
* @param string $dirUpload
|
||||
* @param string $namefile
|
||||
* @param string $typefile
|
||||
* @param string $errorfile
|
||||
* @param string $tpnfile
|
||||
* @param string $formf
|
||||
* @return string
|
||||
*/
|
||||
public function upLoadFile ($dirUpload, $namefile, $typefile, $errorfile, $tpnfile, $formf)
|
||||
{
|
||||
|
||||
//we are cheking the extension for file
|
||||
$aExt = explode( ".", $namefile );
|
||||
$infoupload = ''; //|| ($formf["type"]['uploadfile'] == "application/octet-stream")image/png
|
||||
if (($typefile == "image/jpeg") || ($typefile == "image/png")) {
|
||||
if ($errorfile > 0) {
|
||||
$infoupload = "Return Code: " . $errorfile . "<br />";
|
||||
} else {
|
||||
if (file_exists( $dirUpload . $namefile )) {
|
||||
$infoupload = $namefile . " already exist. ";
|
||||
} else {
|
||||
move_uploaded_file( $tpnfile, $dirUpload . $namefile );
|
||||
$infoupload = "Stored in: " . $dirUpload . $namefile;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$infoupload = "- " . $typefile . " Invalid file your file should be jpeg";
|
||||
}
|
||||
return $infoupload;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets the logos' names
|
||||
*
|
||||
*
|
||||
* @name getNameLogo
|
||||
*
|
||||
* param
|
||||
* @return array
|
||||
*/
|
||||
public function getNameLogo ($usrUid)
|
||||
{
|
||||
|
||||
require_once 'classes/model/Configuration.php';
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( ConfigurationPeer::CFG_VALUE );
|
||||
$oCriteria->add( ConfigurationPeer::CFG_UID, 'USER_LOGO_REPLACEMENT' );
|
||||
$oDataset = ConfigurationPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
if (isset( $aRow[0] )) {
|
||||
$ainfoLogo = @unserialize( $aRow[0] );
|
||||
} else {
|
||||
$ainfoLogo = null;
|
||||
}
|
||||
return ($ainfoLogo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||
*
|
||||
@@ -19,437 +19,427 @@
|
||||
*
|
||||
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class used as interface to have access to the search index services
|
||||
*
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
/**
|
||||
* Class used as interface to have access to the search index services
|
||||
*
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
*/
|
||||
class BpmnEngine_Services_SearchIndex
|
||||
{
|
||||
private $_solrIsEnabled = false;
|
||||
private $_solrHost = "";
|
||||
|
||||
function __construct($solrIsEnabled = false, $solrHost = "")
|
||||
{
|
||||
// check if Zend Library is available
|
||||
// if(class_exists("Zend_Registry")){
|
||||
// $registry = Zend_Registry::getInstance();
|
||||
// //check if configuration is enabled
|
||||
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') &&
|
||||
// $registry->get('solrEnabled') == 1;
|
||||
// $this->solrHost =
|
||||
// $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
|
||||
// }
|
||||
// else{
|
||||
// //use the parameters to initialize class
|
||||
$this->_solrIsEnabled = $solrIsEnabled;
|
||||
$this->_solrHost = $solrHost;
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* no input parameters @param[in]
|
||||
*
|
||||
* @param
|
||||
* [out] bool true if index service is enabled false in other case
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once ('class.solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
return $solr->isEnabled ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of facets in base to the specified query and filter
|
||||
* @gearman = true
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param
|
||||
* [in] Entity_FacetRequest facetRequestEntity Facet request entity
|
||||
* @param
|
||||
* [out] array FacetGroup
|
||||
*/
|
||||
public function getFacetsList($facetRequestEntity)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once ('entities/FacetGroup.php');
|
||||
require_once ('entities/FacetItem.php');
|
||||
require_once ('entities/SelectedFacetGroupItem.php');
|
||||
require_once ('entities/FacetResult.php');
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// get array of selected facet groups
|
||||
$facetRequestEntity->selectedFacetsString = str_replace (',,', ',', $facetRequestEntity->selectedFacetsString);
|
||||
// remove descriptions of selected facet groups
|
||||
|
||||
$aGroups = explode (',', $facetRequestEntity->selectedFacetsString);
|
||||
|
||||
$aGroups = array_filter ($aGroups); // remove empty items
|
||||
|
||||
$aSelectedFacetGroups = array ();
|
||||
foreach ($aGroups as $i => $value) {
|
||||
$gi = explode (':::', $value);
|
||||
$gr = explode ('::', $gi [0]);
|
||||
$it = explode ('::', $gi [1]);
|
||||
|
||||
// create string for remove condition
|
||||
$count = 0;
|
||||
$removeCondition = str_replace ($value . ',', '', $facetRequestEntity->selectedFacetsString, $count);
|
||||
if ($count == 0) {
|
||||
$removeCondition = str_replace ($value, '', $facetRequestEntity->selectedFacetsString, $count);
|
||||
}
|
||||
$selectedFacetGroupData = array (
|
||||
'selectedFacetGroupName' => $gr [0],
|
||||
'selectedFacetGroupPrintName' => $gr [1],
|
||||
'selectedFacetItemName' => $it [0],
|
||||
'selectedFacetItemPrintName' => $it [1],
|
||||
'selectedFacetRemoveCondition' => $removeCondition
|
||||
);
|
||||
|
||||
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
|
||||
}
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// convert request to index request
|
||||
// create filters
|
||||
$filters = array ();
|
||||
if (! empty ($aSelectedFacetGroups)) {
|
||||
// exclude facetFields and facetDates included in filter from the next
|
||||
// list of facets
|
||||
foreach ($aSelectedFacetGroups as $value) {
|
||||
$facetRequestEntity->facetFields = array_diff ($facetRequestEntity->facetFields, array (
|
||||
$value->selectedFacetGroupName
|
||||
));
|
||||
$facetRequestEntity->facetDates = array_diff ($facetRequestEntity->facetDates, array (
|
||||
$value->selectedFacetGroupName
|
||||
));
|
||||
}
|
||||
|
||||
// $facetFields = array_diff($facetFields,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
// $facetDates = array_diff($facetDates,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
foreach ($aSelectedFacetGroups as $group) {
|
||||
$filters [] = $group->selectedFacetGroupName . ':' . urlencode ($group->selectedFacetItemName);
|
||||
}
|
||||
}
|
||||
$facetRequestEntity->filters = $filters;
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$facetsList = $solr->getFacetsList ($facetRequestEntity);
|
||||
|
||||
$numFound = $facetsList->response->numFound;
|
||||
|
||||
$facetCounts = $facetsList->facet_counts;
|
||||
|
||||
$facetGroups = array ();
|
||||
// convert facet fields result to objects
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet field results
|
||||
$facetFieldsResult = $facetsList->facet_counts->facet_fields;
|
||||
if (! empty ($facetFieldsResult)) {
|
||||
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
||||
if (count ($facetvalues) > 0) // if the group have facets included
|
||||
{
|
||||
$data = array (
|
||||
'facetGroupName' => $facetGroup
|
||||
);
|
||||
$data ['facetGroupPrintName'] = $facetGroup;
|
||||
$data ['facetGroupType'] = 'field';
|
||||
$facetItems = array ();
|
||||
for ($i = 0; $i < count ($facetvalues); $i += 2) {
|
||||
$dataItem = array ();
|
||||
$dataItem ['facetName'] = $facetvalues [$i];
|
||||
$dataItem ['facetPrintName'] = $facetvalues [$i];
|
||||
$dataItem ['facetCount'] = $facetvalues [$i + 1];
|
||||
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
|
||||
$facetItems [] = $newFacetItem;
|
||||
}
|
||||
$data ['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
|
||||
|
||||
$facetGroups [] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet date ranges results
|
||||
$facetDatesResult = $facetsList->facet_counts->facet_dates;
|
||||
if (! empty ($facetDatesResult)) {
|
||||
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
||||
if (count ((array)$facetvalues) > 3) // if the group have any facets included
|
||||
// besides start, end and gap
|
||||
{
|
||||
$data = array (
|
||||
'facetGroupName' => $facetGroup
|
||||
);
|
||||
$data ['facetGroupPrintName'] = $facetGroup;
|
||||
$data ['facetGroupType'] = 'daterange';
|
||||
$facetItems = array ();
|
||||
$facetvalueskeys = array_keys ((array)$facetvalues);
|
||||
foreach ($facetvalueskeys as $i => $k) {
|
||||
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
||||
$dataItem = array ();
|
||||
if ($i < count ($facetvalueskeys) - 4) {
|
||||
|
||||
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||
}
|
||||
else {
|
||||
// the last group
|
||||
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
}
|
||||
|
||||
$dataItem ['facetCount'] = $facetvalues->$k;
|
||||
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
|
||||
$facetItems [] = $newFacetItem;
|
||||
}
|
||||
}
|
||||
|
||||
$data ['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
|
||||
|
||||
$facetGroups [] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO:convert facet queries
|
||||
// -----
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create a filter string used in the filter of results of a datatable
|
||||
$filterText = ''; // the list of selected filters used for filtering result,
|
||||
// send in ajax
|
||||
foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
|
||||
$filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode ($selectedFacetGroup->selectedFacetItemName) . ',';
|
||||
}
|
||||
$filterText = substr_replace ($filterText, '', - 1);
|
||||
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create result
|
||||
$dataFacetResult = array (
|
||||
'aFacetGroups' => $facetGroups,
|
||||
'aSelectedFacetGroups' => $aSelectedFacetGroups,
|
||||
'sFilterText' => $filterText
|
||||
);
|
||||
$facetResult = Entity_FacetResult::createForRequest ($dataFacetResult);
|
||||
|
||||
return $facetResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of documents in search server
|
||||
* @param string $workspace
|
||||
* @return integer number of documents
|
||||
*
|
||||
*/
|
||||
public function getNumberDocuments($workspace)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$numberDocuments = $solr->getNumberDocuments ($workspace);
|
||||
|
||||
return $numberDocuments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update document Index
|
||||
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
|
||||
*/
|
||||
public function updateIndexDocument($solrUpdateDocumentEntity)
|
||||
{
|
||||
G::LoadClass ('solr');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$solr->updateDocument ($solrUpdateDocumentEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete document from index
|
||||
* @param string $workspace
|
||||
* @param string $idQuery
|
||||
*/
|
||||
public function deleteDocumentFromIndex($workspace, $idQuery)
|
||||
{
|
||||
G::LoadClass ('solr');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$solr->deleteDocument ($workspace, $idQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit index changes
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function commitIndexChanges($workspace)
|
||||
{
|
||||
G::LoadClass ('solr');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// commit
|
||||
$solr->commitChanges ($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize index changes
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function optimizeIndexChanges($workspace)
|
||||
{
|
||||
G::LoadClass ('solr');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// commit
|
||||
$solr->optimizeChanges ($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call Solr server to return the list of paginated pages.
|
||||
* @param FacetRequest $solrRequestData
|
||||
* @return Entity_SolrQueryResult
|
||||
*/
|
||||
public function getDataTablePaginatedList($solrRequestData)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
require_once ('entities/SolrRequestData.php');
|
||||
require_once ('entities/SolrQueryResult.php');
|
||||
|
||||
// prepare the list of sorted columns
|
||||
// verify if the data of sorting is available
|
||||
if (isset ($solrRequestData->sortCols [0])) {
|
||||
for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
|
||||
// verify if column is sortable
|
||||
if ($solrRequestData->includeCols [$solrRequestData->sortCols [$i]] != '' && $solrRequestData->sortableCols [$i] == "true") {
|
||||
// change sorting column index to column names
|
||||
$solrRequestData->sortCols [$i] = $solrRequestData->includeCols [$solrRequestData->sortCols [$i]];
|
||||
// define the direction of the sorting columns
|
||||
$solrRequestData->sortDir [$i] = $solrRequestData->sortDir [$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove placeholder fields
|
||||
// the placeholder doesn't affect the the solr's response
|
||||
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
|
||||
// array(''));
|
||||
|
||||
// execute query
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$solrPaginatedResult = $solr->executeQuery ($solrRequestData);
|
||||
|
||||
// get total number of documents in index
|
||||
$numTotalDocs = $solr->getNumberDocuments ($solrRequestData->workspace);
|
||||
|
||||
// create the Datatable response of the query
|
||||
$numFound = $solrPaginatedResult->response->numFound;
|
||||
|
||||
$docs = $solrPaginatedResult->response->docs;
|
||||
// print_r($docs);
|
||||
// insert list of names in docs result
|
||||
$data = array (
|
||||
"sEcho" => '', // must be completed in response
|
||||
"iTotalRecords" => intval ($numTotalDocs), // we must get the
|
||||
// total number of
|
||||
// documents
|
||||
"iTotalDisplayRecords" => $numFound,
|
||||
"aaData" => array ()
|
||||
);
|
||||
// copy result document or add placeholders to result
|
||||
foreach ($docs as $i => $doc) {
|
||||
$data ['aaData'] [$i] = array ();
|
||||
foreach ($solrRequestData->includeCols as $columnName) {
|
||||
if ($columnName == '') {
|
||||
$data ['aaData'] [$i] [] = ''; // placeholder
|
||||
}
|
||||
else {
|
||||
if (isset ($doc->$columnName)) {
|
||||
$data ['aaData'] [$i] [] = $doc->$columnName;
|
||||
}
|
||||
else {
|
||||
$data ['aaData'] [$i] [] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$solrQueryResponse = Entity_SolrQueryResult::createForRequest ($data);
|
||||
//
|
||||
|
||||
return $solrQueryResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of stored fields in the index.
|
||||
* @param string $workspace
|
||||
* @return array of index fields
|
||||
*/
|
||||
public function getIndexFields($workspace)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
private $_solrIsEnabled = false;
|
||||
private $_solrHost = "";
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// print "SearchIndex!!!!";
|
||||
// create list of facets
|
||||
$solrFieldsData = $solr->getListIndexedStoredFields ($workspace);
|
||||
// copy list of arrays
|
||||
$listFields = array ();
|
||||
foreach ($solrFieldsData->fields as $key => $fieldData) {
|
||||
if (array_key_exists ('dynamicBase', $fieldData)) {
|
||||
$originalFieldName = substr ($key, 0, - strlen ($fieldData->dynamicBase) + 1);
|
||||
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
||||
// Maintain case sensitive variable names
|
||||
$listFields [$originalFieldName] = $key;
|
||||
}
|
||||
else {
|
||||
// $listFields[strtolower($key)] = $key;
|
||||
// Maintain case sensitive variable names
|
||||
$listFields [$key] = $key;
|
||||
}
|
||||
public function __construct ($solrIsEnabled = false, $solrHost = "")
|
||||
{
|
||||
// check if Zend Library is available
|
||||
// if(class_exists("Zend_Registry")){
|
||||
// $registry = Zend_Registry::getInstance();
|
||||
// //check if configuration is enabled
|
||||
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') &&
|
||||
// $registry->get('solrEnabled') == 1;
|
||||
// $this->solrHost =
|
||||
// $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
|
||||
// }
|
||||
// else{
|
||||
// //use the parameters to initialize class
|
||||
$this->_solrIsEnabled = $solrIsEnabled;
|
||||
$this->_solrHost = $solrHost;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* no input parameters @param[in]
|
||||
*
|
||||
* @param [out] bool true if index service is enabled false in other case
|
||||
*/
|
||||
public function isEnabled ()
|
||||
{
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once ('class.solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
return $solr->isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of facets in base to the specified query and filter
|
||||
* @gearman = true
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param [in] Entity_FacetRequest facetRequestEntity Facet request entity
|
||||
* @param [out] array FacetGroup
|
||||
*/
|
||||
public function getFacetsList ($facetRequestEntity)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once ('entities/FacetGroup.php');
|
||||
require_once ('entities/FacetItem.php');
|
||||
require_once ('entities/SelectedFacetGroupItem.php');
|
||||
require_once ('entities/FacetResult.php');
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// get array of selected facet groups
|
||||
$facetRequestEntity->selectedFacetsString = str_replace( ',,', ',', $facetRequestEntity->selectedFacetsString );
|
||||
// remove descriptions of selected facet groups
|
||||
|
||||
|
||||
$aGroups = explode( ',', $facetRequestEntity->selectedFacetsString );
|
||||
|
||||
$aGroups = array_filter( $aGroups ); // remove empty items
|
||||
|
||||
|
||||
$aSelectedFacetGroups = array ();
|
||||
foreach ($aGroups as $i => $value) {
|
||||
$gi = explode( ':::', $value );
|
||||
$gr = explode( '::', $gi[0] );
|
||||
$it = explode( '::', $gi[1] );
|
||||
|
||||
// create string for remove condition
|
||||
$count = 0;
|
||||
$removeCondition = str_replace( $value . ',', '', $facetRequestEntity->selectedFacetsString, $count );
|
||||
if ($count == 0) {
|
||||
$removeCondition = str_replace( $value, '', $facetRequestEntity->selectedFacetsString, $count );
|
||||
}
|
||||
$selectedFacetGroupData = array ('selectedFacetGroupName' => $gr[0],'selectedFacetGroupPrintName' => $gr[1],'selectedFacetItemName' => $it[0],'selectedFacetItemPrintName' => $it[1],'selectedFacetRemoveCondition' => $removeCondition
|
||||
);
|
||||
|
||||
$aSelectedFacetGroups[] = Entity_SelectedFacetGroupItem::createForRequest( $selectedFacetGroupData );
|
||||
}
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// convert request to index request
|
||||
// create filters
|
||||
$filters = array ();
|
||||
if (! empty( $aSelectedFacetGroups )) {
|
||||
// exclude facetFields and facetDates included in filter from the next
|
||||
// list of facets
|
||||
foreach ($aSelectedFacetGroups as $value) {
|
||||
$facetRequestEntity->facetFields = array_diff( $facetRequestEntity->facetFields, array ($value->selectedFacetGroupName
|
||||
) );
|
||||
$facetRequestEntity->facetDates = array_diff( $facetRequestEntity->facetDates, array ($value->selectedFacetGroupName
|
||||
) );
|
||||
}
|
||||
|
||||
// $facetFields = array_diff($facetFields,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
// $facetDates = array_diff($facetDates,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
foreach ($aSelectedFacetGroups as $group) {
|
||||
$filters[] = $group->selectedFacetGroupName . ':' . urlencode( $group->selectedFacetItemName );
|
||||
}
|
||||
}
|
||||
$facetRequestEntity->filters = $filters;
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
|
||||
// create list of facets
|
||||
$facetsList = $solr->getFacetsList( $facetRequestEntity );
|
||||
|
||||
$numFound = $facetsList->response->numFound;
|
||||
|
||||
$facetCounts = $facetsList->facet_counts;
|
||||
|
||||
$facetGroups = array ();
|
||||
// convert facet fields result to objects
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet field results
|
||||
$facetFieldsResult = $facetsList->facet_counts->facet_fields;
|
||||
if (! empty( $facetFieldsResult )) {
|
||||
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
||||
if (count( $facetvalues ) > 0) // if the group have facets included
|
||||
{
|
||||
$data = array ('facetGroupName' => $facetGroup
|
||||
);
|
||||
$data['facetGroupPrintName'] = $facetGroup;
|
||||
$data['facetGroupType'] = 'field';
|
||||
$facetItems = array ();
|
||||
for ($i = 0; $i < count( $facetvalues ); $i += 2) {
|
||||
$dataItem = array ();
|
||||
$dataItem['facetName'] = $facetvalues[$i];
|
||||
$dataItem['facetPrintName'] = $facetvalues[$i];
|
||||
$dataItem['facetCount'] = $facetvalues[$i + 1];
|
||||
$dataItem['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty( $facetRequestEntity->selectedFacetsString ) ? '' : ',') . $data['facetGroupName'] . '::' . $data['facetGroupPrintName'] . ':::' . $dataItem['facetName'] . '::' . $dataItem['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert( $dataItem );
|
||||
$facetItems[] = $newFacetItem;
|
||||
}
|
||||
$data['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert( $data );
|
||||
|
||||
$facetGroups[] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet date ranges results
|
||||
$facetDatesResult = $facetsList->facet_counts->facet_dates;
|
||||
if (! empty( $facetDatesResult )) {
|
||||
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
||||
if (count( (array) $facetvalues ) > 3) // if the group have any facets included
|
||||
// besides start, end and gap
|
||||
{
|
||||
$data = array ('facetGroupName' => $facetGroup
|
||||
);
|
||||
$data['facetGroupPrintName'] = $facetGroup;
|
||||
$data['facetGroupType'] = 'daterange';
|
||||
$facetItems = array ();
|
||||
$facetvalueskeys = array_keys( (array) $facetvalues );
|
||||
foreach ($facetvalueskeys as $i => $k) {
|
||||
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
||||
$dataItem = array ();
|
||||
if ($i < count( $facetvalueskeys ) - 4) {
|
||||
|
||||
$dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
|
||||
$dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
|
||||
} else {
|
||||
// the last group
|
||||
$dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
$dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
}
|
||||
|
||||
$dataItem['facetCount'] = $facetvalues->$k;
|
||||
$dataItem['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty( $facetRequestEntity->selectedFacetsString ) ? '' : ',') . $data['facetGroupName'] . '::' . $data['facetGroupPrintName'] . ':::' . $dataItem['facetName'] . '::' . $dataItem['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert( $dataItem );
|
||||
$facetItems[] = $newFacetItem;
|
||||
}
|
||||
}
|
||||
|
||||
$data['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert( $data );
|
||||
|
||||
$facetGroups[] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO:convert facet queries
|
||||
// -----
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create a filter string used in the filter of results of a datatable
|
||||
$filterText = ''; // the list of selected filters used for filtering result,
|
||||
// send in ajax
|
||||
foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
|
||||
$filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode( $selectedFacetGroup->selectedFacetItemName ) . ',';
|
||||
}
|
||||
$filterText = substr_replace( $filterText, '', - 1 );
|
||||
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
|
||||
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create result
|
||||
$dataFacetResult = array ('aFacetGroups' => $facetGroups,'aSelectedFacetGroups' => $aSelectedFacetGroups,'sFilterText' => $filterText
|
||||
);
|
||||
$facetResult = Entity_FacetResult::createForRequest( $dataFacetResult );
|
||||
|
||||
return $facetResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of documents in search server
|
||||
*
|
||||
* @param string $workspace
|
||||
* @return integer number of documents
|
||||
*
|
||||
*/
|
||||
public function getNumberDocuments ($workspace)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
|
||||
// create list of facets
|
||||
$numberDocuments = $solr->getNumberDocuments( $workspace );
|
||||
|
||||
return $numberDocuments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update document Index
|
||||
*
|
||||
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
|
||||
*/
|
||||
public function updateIndexDocument ($solrUpdateDocumentEntity)
|
||||
{
|
||||
G::LoadClass( 'solr' );
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
|
||||
// create list of facets
|
||||
$solr->updateDocument( $solrUpdateDocumentEntity );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete document from index
|
||||
*
|
||||
* @param string $workspace
|
||||
* @param string $idQuery
|
||||
*/
|
||||
public function deleteDocumentFromIndex ($workspace, $idQuery)
|
||||
{
|
||||
G::LoadClass( 'solr' );
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
|
||||
// create list of facets
|
||||
$solr->deleteDocument( $workspace, $idQuery );
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit index changes
|
||||
*
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function commitIndexChanges ($workspace)
|
||||
{
|
||||
G::LoadClass( 'solr' );
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
|
||||
// commit
|
||||
$solr->commitChanges( $workspace );
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize index changes
|
||||
*
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function optimizeIndexChanges ($workspace)
|
||||
{
|
||||
G::LoadClass( 'solr' );
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
|
||||
// commit
|
||||
$solr->optimizeChanges( $workspace );
|
||||
}
|
||||
|
||||
/**
|
||||
* Call Solr server to return the list of paginated pages.
|
||||
*
|
||||
* @param FacetRequest $solrRequestData
|
||||
* @return Entity_SolrQueryResult
|
||||
*/
|
||||
public function getDataTablePaginatedList ($solrRequestData)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
require_once ('entities/SolrRequestData.php');
|
||||
require_once ('entities/SolrQueryResult.php');
|
||||
|
||||
// prepare the list of sorted columns
|
||||
// verify if the data of sorting is available
|
||||
if (isset( $solrRequestData->sortCols[0] )) {
|
||||
for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
|
||||
// verify if column is sortable
|
||||
if ($solrRequestData->includeCols[$solrRequestData->sortCols[$i]] != '' && $solrRequestData->sortableCols[$i] == "true") {
|
||||
// change sorting column index to column names
|
||||
$solrRequestData->sortCols[$i] = $solrRequestData->includeCols[$solrRequestData->sortCols[$i]];
|
||||
// define the direction of the sorting columns
|
||||
$solrRequestData->sortDir[$i] = $solrRequestData->sortDir[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove placeholder fields
|
||||
// the placeholder doesn't affect the the solr's response
|
||||
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
|
||||
// array(''));
|
||||
|
||||
|
||||
// execute query
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
$solrPaginatedResult = $solr->executeQuery( $solrRequestData );
|
||||
|
||||
// get total number of documents in index
|
||||
$numTotalDocs = $solr->getNumberDocuments( $solrRequestData->workspace );
|
||||
|
||||
// create the Datatable response of the query
|
||||
$numFound = $solrPaginatedResult->response->numFound;
|
||||
|
||||
$docs = $solrPaginatedResult->response->docs;
|
||||
// print_r($docs);
|
||||
// insert list of names in docs result
|
||||
$data = array ("sEcho" => '', // must be completed in response
|
||||
"iTotalRecords" => intval( $numTotalDocs ), // we must get the
|
||||
// total number of
|
||||
// documents
|
||||
"iTotalDisplayRecords" => $numFound,"aaData" => array ()
|
||||
);
|
||||
// copy result document or add placeholders to result
|
||||
foreach ($docs as $i => $doc) {
|
||||
$data['aaData'][$i] = array ();
|
||||
foreach ($solrRequestData->includeCols as $columnName) {
|
||||
if ($columnName == '') {
|
||||
$data['aaData'][$i][] = ''; // placeholder
|
||||
} else {
|
||||
if (isset( $doc->$columnName )) {
|
||||
$data['aaData'][$i][] = $doc->$columnName;
|
||||
} else {
|
||||
$data['aaData'][$i][] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$solrQueryResponse = Entity_SolrQueryResult::createForRequest( $data );
|
||||
//
|
||||
|
||||
|
||||
return $solrQueryResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of stored fields in the index.
|
||||
*
|
||||
* @param string $workspace
|
||||
* @return array of index fields
|
||||
*/
|
||||
public function getIndexFields ($workspace)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
|
||||
// print "SearchIndex!!!!";
|
||||
// create list of facets
|
||||
$solrFieldsData = $solr->getListIndexedStoredFields( $workspace );
|
||||
// copy list of arrays
|
||||
$listFields = array ();
|
||||
foreach ($solrFieldsData->fields as $key => $fieldData) {
|
||||
if (array_key_exists( 'dynamicBase', $fieldData )) {
|
||||
$originalFieldName = substr( $key, 0, - strlen( $fieldData->dynamicBase ) + 1 );
|
||||
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
||||
// Maintain case sensitive variable names
|
||||
$listFields[$originalFieldName] = $key;
|
||||
} else {
|
||||
// $listFields[strtolower($key)] = $key;
|
||||
// Maintain case sensitive variable names
|
||||
$listFields[$key] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return $listFields;
|
||||
}
|
||||
|
||||
return $listFields;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.serverConfiguration.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,11 +15,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -25,392 +27,442 @@
|
||||
|
||||
/**
|
||||
* ServerConfiguration - serverConf class
|
||||
*
|
||||
* @author Hugo Loza
|
||||
* @copyright 2010 COLOSA
|
||||
* @license GNU Affero General Public License
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
class serverConf {
|
||||
private $_aProperties = array ();
|
||||
private $_aHeartbeatConfig = array ();
|
||||
private $_aWSapces = array ();
|
||||
private $aWSinfo = array ();
|
||||
private $pluginsA = array ();
|
||||
private $errors = array ();
|
||||
private static $instance = NULL;
|
||||
private $haveSetupData = false;
|
||||
private $beatType = 'starting';
|
||||
private $ip;
|
||||
private $index = 0;
|
||||
private $os;
|
||||
private $webserver;
|
||||
private $host;
|
||||
private $php;
|
||||
private $mysql;
|
||||
private $pmVersion;
|
||||
private $pmProduct = 'PMCE';
|
||||
private $nextBeatDate;
|
||||
public $logins;
|
||||
private $lanDirection;
|
||||
private $lanLanguage;
|
||||
public $workspaces = array();
|
||||
public $rtlLang = array('ar','iw','fa');
|
||||
public $filePath = '';
|
||||
class serverConf
|
||||
{
|
||||
private $_aProperties = array ();
|
||||
private $_aHeartbeatConfig = array ();
|
||||
private $_aWSapces = array ();
|
||||
private $aWSinfo = array ();
|
||||
private $pluginsA = array ();
|
||||
private $errors = array ();
|
||||
private static $instance = NULL;
|
||||
private $haveSetupData = false;
|
||||
private $beatType = 'starting';
|
||||
private $ip;
|
||||
private $index = 0;
|
||||
private $os;
|
||||
private $webserver;
|
||||
private $host;
|
||||
private $php;
|
||||
private $mysql;
|
||||
private $pmVersion;
|
||||
private $pmProduct = 'PMCE';
|
||||
private $nextBeatDate;
|
||||
public $logins;
|
||||
private $lanDirection;
|
||||
private $lanLanguage;
|
||||
public $workspaces = array ();
|
||||
public $rtlLang = array ('ar','iw','fa'
|
||||
);
|
||||
public $filePath = '';
|
||||
|
||||
|
||||
public function __construct() {
|
||||
if (defined('PATH_DATA')) {
|
||||
$this->filePath = PATH_DATA . 'srvConf.singleton';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is instancing to this object
|
||||
* param
|
||||
* @return object
|
||||
*/
|
||||
function &getSingleton() {
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new serverConf ( );
|
||||
if ((file_exists ( self::$instance->filePath ))&&(filesize(self::$instance->filePath)>0)){
|
||||
self::$instance->unSerializeInstance ( file_get_contents ( self::$instance->filePath ) );
|
||||
}
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function generates a storable representation of this obejct
|
||||
* param
|
||||
* @return void
|
||||
*/
|
||||
function serializeInstance() {
|
||||
return serialize ( self::$instance );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes a single serialized object and converts it back a object
|
||||
* @param string $serialized
|
||||
* @return void
|
||||
*/
|
||||
function unSerializeInstance($serialized) {
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new serverConf ( );
|
||||
}
|
||||
|
||||
if($instance = @unserialize ( $serialized )){
|
||||
self::$instance = $instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This will save the object in the specified file (defined as a property of this class)
|
||||
* param
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveSingleton() {
|
||||
if (defined('PATH_DATA')) {
|
||||
$this->filePath = PATH_DATA . 'srvConf.singleton';
|
||||
$size = file_put_contents ( $this->filePath, $this->serializeInstance () );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* With this is possible to save a property that will be saved in the properties
|
||||
* array of this class.
|
||||
* @param string $propertyName
|
||||
* @param string $propertyValue
|
||||
*/
|
||||
function setProperty($propertyName, $propertyValue) {
|
||||
$this->_aProperties [$propertyName] = $propertyValue;
|
||||
$this->saveSingleton ();
|
||||
}
|
||||
|
||||
/**
|
||||
* To unset a defined property. If it doesn't exist then it does nothing.
|
||||
* @param string $propertyName
|
||||
* @return void
|
||||
*/
|
||||
function unsetProperty($propertyName) {
|
||||
if (isset ( $this->_aProperties [$propertyName] )) {
|
||||
unset ( $this->_aProperties [$propertyName] );
|
||||
$this->saveSingleton ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a defined property. If it doesn't exist then returns null
|
||||
* @param string $propertyName
|
||||
* @return string/null
|
||||
*/
|
||||
function getProperty($propertyName) {
|
||||
if (isset ( $this->_aProperties [$propertyName] )) {
|
||||
return $this->_aProperties [$propertyName];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to have a record of succesful logins to the system (total and by WS)
|
||||
* param
|
||||
* @return void
|
||||
*/
|
||||
function sucessfulLogin() {
|
||||
$this->logins ++;
|
||||
if ( isset ($this->workspaces[SYS_SYS]) && isset ($this->workspaces[SYS_SYS]['WSP_LOGINS']) )
|
||||
$this->workspaces[SYS_SYS]['WSP_LOGINS'] ++;
|
||||
|
||||
if ( isset ($this->workspaces[SYS_SYS]) && !isset ($this->workspaces[SYS_SYS]['WSP_LOGINS']) )
|
||||
$this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1;
|
||||
|
||||
$this->saveSingleton ();
|
||||
}
|
||||
|
||||
function setWsInfo($wsname,$info){
|
||||
$this->aWSinfo[$wsname]=$info;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will togle the status of a workspace (enabled,disabled)
|
||||
* @param string $wsName
|
||||
* @return void
|
||||
*/
|
||||
function changeStatusWS($wsName) {
|
||||
|
||||
if (isset ( $this->_aWSapces [$wsName] )) { //Enable WS
|
||||
unset ( $this->_aWSapces [$wsName] );
|
||||
}
|
||||
else {
|
||||
$this->_aWSapces [$wsName] = 'disabled';
|
||||
}
|
||||
$this->saveSingleton ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the status of a WS. If is disabled will return 1 otherwise 0
|
||||
* @param $wsname
|
||||
* @return boolean
|
||||
*/
|
||||
function isWSDisabled($wsName) {
|
||||
return isset ( $this->_aWSapces [$wsName] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check only if the server address or server name has changed,
|
||||
* to send another beat in next minute.
|
||||
* param
|
||||
* @return boolean
|
||||
*/
|
||||
function checkIfHostNameHasChanged() {
|
||||
//removed the PM_VERSION control, because when an upgrade is done, the haveSetupData has to be changed.
|
||||
if ($this->ip != getenv ( 'SERVER_ADDR' ))
|
||||
return false;
|
||||
|
||||
if ($this->host != getenv ( 'SERVER_NAME' ))
|
||||
return false;
|
||||
|
||||
return $this->haveSetupData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Will return a list of all WS in this system and their related information.
|
||||
* @uses getWSList
|
||||
* param
|
||||
* @return array
|
||||
*/
|
||||
function getWSList() {
|
||||
$dir = PATH_DB;
|
||||
$wsArray = array ();
|
||||
if (file_exists ( $dir )) {
|
||||
if ($handle = opendir ( $dir )) {
|
||||
while ( false !== ($file = readdir ( $handle )) ) {
|
||||
if (($file != ".") && ($file != "..")) {
|
||||
if (file_exists ( PATH_DB . $file . '/db.php' )) { //print $file."/db.php <hr>";
|
||||
$statusl = ($this->isWSDisabled ( $file )) ? 'DISABLED' : 'ENABLED';
|
||||
if(isset($this->aWSinfo[$file])){
|
||||
$wsInfo = $this->aWSinfo[$file];
|
||||
}else{
|
||||
$wsInfo ['num_processes'] = "not gathered yet";
|
||||
$wsInfo ['num_cases'] = "not gathered yet";;
|
||||
$wsInfo ['num_users'] = "not gathered yet";
|
||||
}
|
||||
$wsArray [$file] = array ('WSP_ID' => $file, 'WSP_NAME' => $file, 'WSP_STATUS' => $statusl, 'WSP_PROCESS_COUNT' => $wsInfo ['num_processes'], 'WSP_CASES_COUNT' => $wsInfo ['num_cases'], 'WSP_USERS_COUNT' => isset($wsInfo ['num_users'])?$wsInfo ['num_users']:"" );
|
||||
if (isset ( $this->workspaces [$file] ['WSP_LOGINS'] ))
|
||||
$wsArray [$file] ['WSP_LOGINS'] = $this->workspaces [$file] ['WSP_LOGINS'];
|
||||
|
||||
}
|
||||
}
|
||||
public function __construct ()
|
||||
{
|
||||
if (defined( 'PATH_DATA' )) {
|
||||
$this->filePath = PATH_DATA . 'srvConf.singleton';
|
||||
}
|
||||
closedir ( $handle );
|
||||
}
|
||||
}
|
||||
return $wsArray;
|
||||
|
||||
}
|
||||
/**
|
||||
* Will return all the information of a WS.
|
||||
* - Status
|
||||
* - # of cases
|
||||
* - # of processes
|
||||
* - # of users
|
||||
* @param string $wsName
|
||||
* @return array
|
||||
*/
|
||||
function getWorkspaceInfo($wsName) {
|
||||
$aResult = Array ('num_processes' => '0', 'num_cases' => '0' );
|
||||
$result = array();
|
||||
require_once 'classes/model/Process.php';
|
||||
require_once 'classes/model/Application.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
|
||||
$Criteria = new Criteria('workflow');
|
||||
$Criteria->add (ProcessPeer::PRO_STATUS, 'ACTIVE' , CRITERIA::EQUAL );
|
||||
$aResult['num_processes'] = ProcessPeer::doCount($Criteria);
|
||||
|
||||
$Criteria = new Criteria('workflow');
|
||||
$Criteria->add (ApplicationPeer::APP_STATUS, 'COMPLETED' , CRITERIA::NOT_EQUAL );
|
||||
$aResult['num_cases'] = ApplicationPeer::doCount($Criteria);
|
||||
|
||||
$Criteria = new Criteria('workflow');
|
||||
$Criteria->add (UsersPeer::USR_STATUS, array('DELETED','DISABLED') , CRITERIA::NOT_IN );
|
||||
$aResult['num_users'] = UsersPeer::doCount($Criteria);
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will list the plugins of the system
|
||||
* param
|
||||
* @return array
|
||||
*/
|
||||
function getPluginsList() {
|
||||
return $this->pluginsA;
|
||||
}
|
||||
|
||||
/***
|
||||
* Register a PLugin
|
||||
*/
|
||||
function addPlugin($workspace,$info){
|
||||
$this->pluginsA[$workspace]=$info;
|
||||
}
|
||||
|
||||
function getDBVersion(){
|
||||
$sMySQLVersion = '?????';
|
||||
if (defined ( "DB_HOST" )) {
|
||||
G::LoadClass ( 'net' );
|
||||
G::LoadClass ( 'dbConnections' );
|
||||
$dbNetView = new NET ( DB_HOST );
|
||||
$dbNetView->loginDbServer ( DB_USER, DB_PASS );
|
||||
|
||||
$dbConns = new dbConnections ( '' );
|
||||
$availdb = '';
|
||||
foreach ( $dbConns->getDbServicesAvailables () as $key => $val ) {
|
||||
if ($availdb != '')
|
||||
$availdb .= ', ';
|
||||
$availdb .= $val ['name'];
|
||||
}
|
||||
|
||||
try {
|
||||
$sMySQLVersion = $dbNetView->getDbServerVersion ( 'mysql' );
|
||||
}
|
||||
catch ( Exception $oException ) {
|
||||
$sMySQLVersion = '?????';
|
||||
}
|
||||
/**
|
||||
* This function is instancing to this object
|
||||
* param
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
function &getSingleton ()
|
||||
{
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new serverConf();
|
||||
if ((file_exists( self::$instance->filePath )) && (filesize( self::$instance->filePath ) > 0)) {
|
||||
self::$instance->unSerializeInstance( file_get_contents( self::$instance->filePath ) );
|
||||
}
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
return $sMySQLVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will reset all the logins' count
|
||||
* param
|
||||
* @return void
|
||||
*/
|
||||
function resetLogins() {
|
||||
$this->logins = 0;
|
||||
if(is_array($this->workspaces)){
|
||||
foreach ( $this->workspaces as $wsName => $wsinfo ) {
|
||||
$this->workspaces [$wsName] ['WSP_LOGINS'] = 0;
|
||||
/**
|
||||
* This function generates a storable representation of this obejct
|
||||
* param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function serializeInstance ()
|
||||
{
|
||||
return serialize( self::$instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes a single serialized object and converts it back a object
|
||||
*
|
||||
* @param string $serialized
|
||||
* @return void
|
||||
*/
|
||||
function unSerializeInstance ($serialized)
|
||||
{
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new serverConf();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of language direction property
|
||||
* @param void
|
||||
* @return string
|
||||
*/
|
||||
function getLanDirection() {
|
||||
if (!isset($this->lanDirection) ) {
|
||||
$this->lanDirection = 'L';
|
||||
}
|
||||
if( defined('SYS_LANG') ) {
|
||||
//if we already have the landirection for this language, just return from serverConf
|
||||
if ( $this->lanLanguage == SYS_LANG )
|
||||
return $this->lanDirection;
|
||||
if ($instance = @unserialize( $serialized )) {
|
||||
self::$instance = $instance;
|
||||
}
|
||||
}
|
||||
|
||||
//if not , we need to query Database, in order to get the direction
|
||||
$this->lanDirection = 'L'; //default value;
|
||||
$this->lanLanguage = SYS_LANG;
|
||||
require_once 'classes/model/Language.php';
|
||||
$oLang = new Language();
|
||||
try{
|
||||
$aLang = $oLang->load(SYS_LANG);
|
||||
if( isset($aLang['LAN_DIRECTION']) ){
|
||||
$this->lanDirection = strtoupper($aLang['LAN_DIRECTION']);
|
||||
/**
|
||||
* This will save the object in the specified file (defined as a property of this class)
|
||||
* param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveSingleton ()
|
||||
{
|
||||
if (defined( 'PATH_DATA' )) {
|
||||
$this->filePath = PATH_DATA . 'srvConf.singleton';
|
||||
$size = file_put_contents( $this->filePath, $this->serializeInstance() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* With this is possible to save a property that will be saved in the properties
|
||||
* array of this class.
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @param string $propertyValue
|
||||
*/
|
||||
function setProperty ($propertyName, $propertyValue)
|
||||
{
|
||||
$this->_aProperties[$propertyName] = $propertyValue;
|
||||
$this->saveSingleton();
|
||||
}
|
||||
|
||||
/**
|
||||
* To unset a defined property.
|
||||
* If it doesn't exist then it does nothing.
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return void
|
||||
*/
|
||||
function unsetProperty ($propertyName)
|
||||
{
|
||||
if (isset( $this->_aProperties[$propertyName] )) {
|
||||
unset( $this->_aProperties[$propertyName] );
|
||||
$this->saveSingleton();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a defined property.
|
||||
* If it doesn't exist then returns null
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return string/null
|
||||
*/
|
||||
function getProperty ($propertyName)
|
||||
{
|
||||
if (isset( $this->_aProperties[$propertyName] )) {
|
||||
return $this->_aProperties[$propertyName];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to have a record of succesful logins to the system (total and by WS)
|
||||
* param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function sucessfulLogin ()
|
||||
{
|
||||
$this->logins ++;
|
||||
if (isset( $this->workspaces[SYS_SYS] ) && isset( $this->workspaces[SYS_SYS]['WSP_LOGINS'] ))
|
||||
$this->workspaces[SYS_SYS]['WSP_LOGINS'] ++;
|
||||
|
||||
if (isset( $this->workspaces[SYS_SYS] ) && ! isset( $this->workspaces[SYS_SYS]['WSP_LOGINS'] ))
|
||||
$this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1;
|
||||
|
||||
$this->saveSingleton();
|
||||
}
|
||||
|
||||
function setWsInfo ($wsname, $info)
|
||||
{
|
||||
$this->aWSinfo[$wsname] = $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will togle the status of a workspace (enabled,disabled)
|
||||
*
|
||||
* @param string $wsName
|
||||
* @return void
|
||||
*/
|
||||
function changeStatusWS ($wsName)
|
||||
{
|
||||
|
||||
if (isset( $this->_aWSapces[$wsName] )) { //Enable WS
|
||||
unset( $this->_aWSapces[$wsName] );
|
||||
} else {
|
||||
$this->_aWSapces[$wsName] = 'disabled';
|
||||
}
|
||||
$this->saveSingleton();
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->lanDirection = 'L';
|
||||
}
|
||||
}
|
||||
return $this->lanDirection;
|
||||
}
|
||||
/**
|
||||
* With this is possible to save a property that will be saved in the properties
|
||||
* array of this class.
|
||||
* @param string $propertyName
|
||||
* @param string $propertyValue
|
||||
* @param string $workspace
|
||||
*/
|
||||
function setHeartbeatProperty($propertyName, $propertyValue, $workspace) {
|
||||
$this->_aHeartbeatConfig [$workspace][$propertyName] = $propertyValue;
|
||||
$this->saveSingleton ();
|
||||
}
|
||||
|
||||
/**
|
||||
* To unset a defined property. If it doesn't exist then it does nothing.
|
||||
* @param string $propertyName
|
||||
* @param string $workspace
|
||||
* @return void
|
||||
*/
|
||||
function unsetHeartbeatProperty($propertyName,$workspace) {
|
||||
if (isset ( $this->_aHeartbeatConfig [$workspace][$propertyName] ))
|
||||
unset ( $this->_aHeartbeatConfig [$workspace][$propertyName] );
|
||||
$this->saveSingleton ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a defined property. If it doesn't exist then returns null
|
||||
* @param string $propertyName
|
||||
* @return string/null
|
||||
*/
|
||||
function getHeartbeatProperty($propertyName, $workspace) {
|
||||
if (isset ( $this->_aHeartbeatConfig [$workspace][$propertyName] )) {
|
||||
return $this->_aHeartbeatConfig [$workspace][$propertyName];
|
||||
} else {
|
||||
return null;
|
||||
/**
|
||||
* Return the status of a WS.
|
||||
* If is disabled will return 1 otherwise 0
|
||||
*
|
||||
* @param $wsname
|
||||
* @return boolean
|
||||
*/
|
||||
function isWSDisabled ($wsName)
|
||||
{
|
||||
return isset( $this->_aWSapces[$wsName] );
|
||||
}
|
||||
}
|
||||
|
||||
function isRtl ($lang = SYS_LANG) {
|
||||
$lang = substr($lang, 0, 2);
|
||||
return in_array($lang, $this->rtlLang);
|
||||
}
|
||||
/**
|
||||
* Check only if the server address or server name has changed,
|
||||
* to send another beat in next minute.
|
||||
* param
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function checkIfHostNameHasChanged ()
|
||||
{
|
||||
//removed the PM_VERSION control, because when an upgrade is done, the haveSetupData has to be changed.
|
||||
if ($this->ip != getenv( 'SERVER_ADDR' ))
|
||||
return false;
|
||||
|
||||
if ($this->host != getenv( 'SERVER_NAME' ))
|
||||
return false;
|
||||
|
||||
return $this->haveSetupData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return a list of all WS in this system and their related information.
|
||||
*
|
||||
* @uses getWSList
|
||||
* param
|
||||
* @return array
|
||||
*/
|
||||
function getWSList ()
|
||||
{
|
||||
$dir = PATH_DB;
|
||||
$wsArray = array ();
|
||||
if (file_exists( $dir )) {
|
||||
if ($handle = opendir( $dir )) {
|
||||
while (false !== ($file = readdir( $handle ))) {
|
||||
if (($file != ".") && ($file != "..")) {
|
||||
if (file_exists( PATH_DB . $file . '/db.php' )) { //print $file."/db.php <hr>";
|
||||
$statusl = ($this->isWSDisabled( $file )) ? 'DISABLED' : 'ENABLED';
|
||||
if (isset( $this->aWSinfo[$file] )) {
|
||||
$wsInfo = $this->aWSinfo[$file];
|
||||
} else {
|
||||
$wsInfo['num_processes'] = "not gathered yet";
|
||||
$wsInfo['num_cases'] = "not gathered yet";
|
||||
;
|
||||
$wsInfo['num_users'] = "not gathered yet";
|
||||
}
|
||||
$wsArray[$file] = array ('WSP_ID' => $file,'WSP_NAME' => $file,'WSP_STATUS' => $statusl,'WSP_PROCESS_COUNT' => $wsInfo['num_processes'],'WSP_CASES_COUNT' => $wsInfo['num_cases'],'WSP_USERS_COUNT' => isset( $wsInfo['num_users'] ) ? $wsInfo['num_users'] : ""
|
||||
);
|
||||
if (isset( $this->workspaces[$file]['WSP_LOGINS'] ))
|
||||
$wsArray[$file]['WSP_LOGINS'] = $this->workspaces[$file]['WSP_LOGINS'];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir( $handle );
|
||||
}
|
||||
}
|
||||
return $wsArray;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return all the information of a WS.
|
||||
* - Status
|
||||
* - # of cases
|
||||
* - # of processes
|
||||
* - # of users
|
||||
*
|
||||
* @param string $wsName
|
||||
* @return array
|
||||
*/
|
||||
function getWorkspaceInfo ($wsName)
|
||||
{
|
||||
$aResult = Array ('num_processes' => '0','num_cases' => '0'
|
||||
);
|
||||
$result = array ();
|
||||
require_once 'classes/model/Process.php';
|
||||
require_once 'classes/model/Application.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->add( ProcessPeer::PRO_STATUS, 'ACTIVE', CRITERIA::EQUAL );
|
||||
$aResult['num_processes'] = ProcessPeer::doCount( $Criteria );
|
||||
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->add( ApplicationPeer::APP_STATUS, 'COMPLETED', CRITERIA::NOT_EQUAL );
|
||||
$aResult['num_cases'] = ApplicationPeer::doCount( $Criteria );
|
||||
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->add( UsersPeer::USR_STATUS, array ('DELETED','DISABLED'
|
||||
), CRITERIA::NOT_IN );
|
||||
$aResult['num_users'] = UsersPeer::doCount( $Criteria );
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will list the plugins of the system
|
||||
* param
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getPluginsList ()
|
||||
{
|
||||
return $this->pluginsA;
|
||||
}
|
||||
|
||||
/**
|
||||
* *
|
||||
* Register a PLugin
|
||||
*/
|
||||
function addPlugin ($workspace, $info)
|
||||
{
|
||||
$this->pluginsA[$workspace] = $info;
|
||||
}
|
||||
|
||||
function getDBVersion ()
|
||||
{
|
||||
$sMySQLVersion = '?????';
|
||||
if (defined( "DB_HOST" )) {
|
||||
G::LoadClass( 'net' );
|
||||
G::LoadClass( 'dbConnections' );
|
||||
$dbNetView = new NET( DB_HOST );
|
||||
$dbNetView->loginDbServer( DB_USER, DB_PASS );
|
||||
|
||||
$dbConns = new dbConnections( '' );
|
||||
$availdb = '';
|
||||
foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
|
||||
if ($availdb != '')
|
||||
$availdb .= ', ';
|
||||
$availdb .= $val['name'];
|
||||
}
|
||||
|
||||
try {
|
||||
$sMySQLVersion = $dbNetView->getDbServerVersion( 'mysql' );
|
||||
} catch (Exception $oException) {
|
||||
$sMySQLVersion = '?????';
|
||||
}
|
||||
}
|
||||
return $sMySQLVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will reset all the logins' count
|
||||
* param
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function resetLogins ()
|
||||
{
|
||||
$this->logins = 0;
|
||||
if (is_array( $this->workspaces )) {
|
||||
foreach ($this->workspaces as $wsName => $wsinfo) {
|
||||
$this->workspaces[$wsName]['WSP_LOGINS'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of language direction property
|
||||
*
|
||||
* @param void
|
||||
* @return string
|
||||
*/
|
||||
function getLanDirection ()
|
||||
{
|
||||
if (! isset( $this->lanDirection )) {
|
||||
$this->lanDirection = 'L';
|
||||
}
|
||||
if (defined( 'SYS_LANG' )) {
|
||||
//if we already have the landirection for this language, just return from serverConf
|
||||
if ($this->lanLanguage == SYS_LANG)
|
||||
return $this->lanDirection;
|
||||
|
||||
//if not , we need to query Database, in order to get the direction
|
||||
$this->lanDirection = 'L'; //default value;
|
||||
$this->lanLanguage = SYS_LANG;
|
||||
require_once 'classes/model/Language.php';
|
||||
$oLang = new Language();
|
||||
try {
|
||||
$aLang = $oLang->load( SYS_LANG );
|
||||
if (isset( $aLang['LAN_DIRECTION'] )) {
|
||||
$this->lanDirection = strtoupper( $aLang['LAN_DIRECTION'] );
|
||||
}
|
||||
$this->saveSingleton();
|
||||
} catch (Exception $e) {
|
||||
$this->lanDirection = 'L';
|
||||
}
|
||||
}
|
||||
return $this->lanDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* With this is possible to save a property that will be saved in the properties
|
||||
* array of this class.
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @param string $propertyValue
|
||||
* @param string $workspace
|
||||
*/
|
||||
function setHeartbeatProperty ($propertyName, $propertyValue, $workspace)
|
||||
{
|
||||
$this->_aHeartbeatConfig[$workspace][$propertyName] = $propertyValue;
|
||||
$this->saveSingleton();
|
||||
}
|
||||
|
||||
/**
|
||||
* To unset a defined property.
|
||||
* If it doesn't exist then it does nothing.
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @param string $workspace
|
||||
* @return void
|
||||
*/
|
||||
function unsetHeartbeatProperty ($propertyName, $workspace)
|
||||
{
|
||||
if (isset( $this->_aHeartbeatConfig[$workspace][$propertyName] ))
|
||||
unset( $this->_aHeartbeatConfig[$workspace][$propertyName] );
|
||||
$this->saveSingleton();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a defined property.
|
||||
* If it doesn't exist then returns null
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return string/null
|
||||
*/
|
||||
function getHeartbeatProperty ($propertyName, $workspace)
|
||||
{
|
||||
if (isset( $this->_aHeartbeatConfig[$workspace][$propertyName] )) {
|
||||
return $this->_aHeartbeatConfig[$workspace][$propertyName];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function isRtl ($lang = SYS_LANG)
|
||||
{
|
||||
$lang = substr( $lang, 0, 2 );
|
||||
return in_array( $lang, $this->rtlLang );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* class.Sessions.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
@@ -13,247 +14,249 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*
|
||||
*/
|
||||
require_once 'classes/model/Session.php';
|
||||
|
||||
/**
|
||||
* Sessions - Sessions class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
* @author Everth S. Berrios Morales
|
||||
* @copyright 2008 COLOSA
|
||||
*/
|
||||
|
||||
class Sessions {
|
||||
|
||||
protected $tmpfile;
|
||||
private $sessionId;
|
||||
private $globals;
|
||||
|
||||
/**
|
||||
* This function is the constructor of the Sessions class
|
||||
* @param string $sSessionId
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($sSessionId=NULL){
|
||||
$this->sessionId = $sSessionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets the user session
|
||||
*
|
||||
*
|
||||
* @name getSessionUser
|
||||
*
|
||||
* @param string sSessionId
|
||||
* @return array
|
||||
*/
|
||||
public function getSessionUser($sSessionId=NULL)
|
||||
{
|
||||
try
|
||||
{
|
||||
if($sSessionId != NULL){
|
||||
$this->sessionId = $sSessionId;
|
||||
} else if($this->sessionId == NULL){
|
||||
throw new Exception('session id was not set.');
|
||||
}
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(SessionPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(SessionPeer::SES_STATUS);
|
||||
$oCriteria->addSelectColumn(SessionPeer::SES_DUE_DATE);
|
||||
$oCriteria->add(SessionPeer::SES_UID, $this->sessionId);
|
||||
|
||||
$oDataset = SessionPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
if( !is_array($aRow) ){
|
||||
$this->deleteTmpfile();
|
||||
}
|
||||
return $aRow;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks the user session
|
||||
*
|
||||
*
|
||||
* @name verifySession
|
||||
*
|
||||
* @param string sSessionId
|
||||
* @return array
|
||||
*/
|
||||
public function verifySession($sSessionId=NULL)
|
||||
{
|
||||
try
|
||||
{
|
||||
if($sSessionId != NULL){
|
||||
$this->sessionId = $sSessionId;
|
||||
} else if($this->sessionId == NULL){
|
||||
throw new Exception('session id was not set.');
|
||||
}
|
||||
|
||||
$date=date('Y-m-d H:i:s');
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(SessionPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(SessionPeer::SES_STATUS);
|
||||
$oCriteria->addSelectColumn(SessionPeer::SES_DUE_DATE);
|
||||
$oCriteria->add(SessionPeer::SES_UID, $this->sessionId);
|
||||
$oCriteria->add(SessionPeer::SES_STATUS, 'ACTIVE');
|
||||
$oCriteria->add(SessionPeer::SES_DUE_DATE, $date, Criteria::GREATER_EQUAL);
|
||||
|
||||
$oDataset = SessionPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
class Sessions
|
||||
{
|
||||
|
||||
if( !is_array($aRow) ){
|
||||
$this->deleteTmpfile();
|
||||
}
|
||||
|
||||
return $aRow;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function registers into globals variables
|
||||
*
|
||||
*
|
||||
* @name registerGlobal
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function registerGlobal($name, $value)
|
||||
{
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
|
||||
if($this->sessionId == NULL){
|
||||
throw new Exception('session id was not set.');
|
||||
}
|
||||
|
||||
$tmpfile_content = '';
|
||||
if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
|
||||
$tmpfile_content = file_get_contents($this->tmpfile);
|
||||
}
|
||||
|
||||
//getting the global array
|
||||
if( $tmpfile_content != ''){
|
||||
$this->globals = unserialize($tmpfile_content);
|
||||
} else {
|
||||
$this->globals = Array();
|
||||
}
|
||||
|
||||
//registering the new global variable
|
||||
$this->globals[$name] = $value;
|
||||
|
||||
//saving the global array
|
||||
$tmpfile_content = serialize($this->globals);
|
||||
file_put_contents($this->tmpfile, $tmpfile_content);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets a global variable
|
||||
*
|
||||
*
|
||||
* @name getGlobal
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getGlobal($name)
|
||||
{
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
|
||||
if($this->sessionId == NULL){
|
||||
throw new Exception('session id was not set.');
|
||||
}
|
||||
|
||||
$tmpfile_content = '';
|
||||
if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
|
||||
$tmpfile_content = file_get_contents($this->tmpfile);
|
||||
}
|
||||
|
||||
//getting the global array
|
||||
if( $tmpfile_content != ''){
|
||||
$this->globals = unserialize($tmpfile_content);
|
||||
} else {
|
||||
$this->globals = Array();
|
||||
}
|
||||
|
||||
//getting the new global variable
|
||||
if( isset($this->globals[$name]) ){
|
||||
return $this->globals[$name];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets all globals variables
|
||||
*
|
||||
*
|
||||
* @name getGlobals
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function getGlobals()
|
||||
{
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
|
||||
if($this->sessionId == NULL){
|
||||
throw new Exception('session id was not set.');
|
||||
}
|
||||
|
||||
$tmpfile_content = '';
|
||||
if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
|
||||
$tmpfile_content = file_get_contents($this->tmpfile);
|
||||
}
|
||||
|
||||
//getting the global array
|
||||
if( $tmpfile_content != ''){
|
||||
$this->globals = unserialize($tmpfile_content);
|
||||
} else {
|
||||
$this->globals = Array();
|
||||
}
|
||||
return $this->globals;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function removes a temporal file
|
||||
*
|
||||
*
|
||||
* @name deleteTmpfile
|
||||
*
|
||||
* param
|
||||
* @return void
|
||||
*/
|
||||
private function deleteTmpfile(){
|
||||
if($this->sessionId == NULL){
|
||||
throw new Exception('session id was not set.');
|
||||
protected $tmpfile;
|
||||
private $sessionId;
|
||||
private $globals;
|
||||
|
||||
/**
|
||||
* This function is the constructor of the Sessions class
|
||||
*
|
||||
* @param string $sSessionId
|
||||
* @return void
|
||||
*/
|
||||
public function __construct ($sSessionId = NULL)
|
||||
{
|
||||
$this->sessionId = $sSessionId;
|
||||
}
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
@unlink($this->tmpfile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function gets the user session
|
||||
*
|
||||
*
|
||||
* @name getSessionUser
|
||||
*
|
||||
* @param string sSessionId
|
||||
* @return array
|
||||
*/
|
||||
public function getSessionUser ($sSessionId = NULL)
|
||||
{
|
||||
try {
|
||||
if ($sSessionId != NULL) {
|
||||
$this->sessionId = $sSessionId;
|
||||
} else if ($this->sessionId == NULL) {
|
||||
throw new Exception( 'session id was not set.' );
|
||||
}
|
||||
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( SessionPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( SessionPeer::SES_STATUS );
|
||||
$oCriteria->addSelectColumn( SessionPeer::SES_DUE_DATE );
|
||||
$oCriteria->add( SessionPeer::SES_UID, $this->sessionId );
|
||||
|
||||
$oDataset = SessionPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
if (! is_array( $aRow )) {
|
||||
$this->deleteTmpfile();
|
||||
}
|
||||
return $aRow;
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks the user session
|
||||
*
|
||||
*
|
||||
* @name verifySession
|
||||
*
|
||||
* @param string sSessionId
|
||||
* @return array
|
||||
*/
|
||||
public function verifySession ($sSessionId = NULL)
|
||||
{
|
||||
try {
|
||||
if ($sSessionId != NULL) {
|
||||
$this->sessionId = $sSessionId;
|
||||
} else if ($this->sessionId == NULL) {
|
||||
throw new Exception( 'session id was not set.' );
|
||||
}
|
||||
|
||||
$date = date( 'Y-m-d H:i:s' );
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( SessionPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( SessionPeer::SES_STATUS );
|
||||
$oCriteria->addSelectColumn( SessionPeer::SES_DUE_DATE );
|
||||
$oCriteria->add( SessionPeer::SES_UID, $this->sessionId );
|
||||
$oCriteria->add( SessionPeer::SES_STATUS, 'ACTIVE' );
|
||||
$oCriteria->add( SessionPeer::SES_DUE_DATE, $date, Criteria::GREATER_EQUAL );
|
||||
|
||||
$oDataset = SessionPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
if (! is_array( $aRow )) {
|
||||
$this->deleteTmpfile();
|
||||
}
|
||||
|
||||
return $aRow;
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function registers into globals variables
|
||||
*
|
||||
*
|
||||
* @name registerGlobal
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function registerGlobal ($name, $value)
|
||||
{
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
|
||||
if ($this->sessionId == NULL) {
|
||||
throw new Exception( 'session id was not set.' );
|
||||
}
|
||||
|
||||
$tmpfile_content = '';
|
||||
if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
|
||||
$tmpfile_content = file_get_contents( $this->tmpfile );
|
||||
}
|
||||
|
||||
//getting the global array
|
||||
if ($tmpfile_content != '') {
|
||||
$this->globals = unserialize( $tmpfile_content );
|
||||
} else {
|
||||
$this->globals = Array ();
|
||||
}
|
||||
|
||||
//registering the new global variable
|
||||
$this->globals[$name] = $value;
|
||||
|
||||
//saving the global array
|
||||
$tmpfile_content = serialize( $this->globals );
|
||||
file_put_contents( $this->tmpfile, $tmpfile_content );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets a global variable
|
||||
*
|
||||
*
|
||||
* @name getGlobal
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getGlobal ($name)
|
||||
{
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
|
||||
if ($this->sessionId == NULL) {
|
||||
throw new Exception( 'session id was not set.' );
|
||||
}
|
||||
|
||||
$tmpfile_content = '';
|
||||
if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
|
||||
$tmpfile_content = file_get_contents( $this->tmpfile );
|
||||
}
|
||||
|
||||
//getting the global array
|
||||
if ($tmpfile_content != '') {
|
||||
$this->globals = unserialize( $tmpfile_content );
|
||||
} else {
|
||||
$this->globals = Array ();
|
||||
}
|
||||
|
||||
//getting the new global variable
|
||||
if (isset( $this->globals[$name] )) {
|
||||
return $this->globals[$name];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets all globals variables
|
||||
*
|
||||
*
|
||||
* @name getGlobals
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function getGlobals ()
|
||||
{
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
|
||||
if ($this->sessionId == NULL) {
|
||||
throw new Exception( 'session id was not set.' );
|
||||
}
|
||||
|
||||
$tmpfile_content = '';
|
||||
if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
|
||||
$tmpfile_content = file_get_contents( $this->tmpfile );
|
||||
}
|
||||
|
||||
//getting the global array
|
||||
if ($tmpfile_content != '') {
|
||||
$this->globals = unserialize( $tmpfile_content );
|
||||
} else {
|
||||
$this->globals = Array ();
|
||||
}
|
||||
return $this->globals;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function removes a temporal file
|
||||
*
|
||||
*
|
||||
* @name deleteTmpfile
|
||||
*
|
||||
* param
|
||||
* @return void
|
||||
*/
|
||||
private function deleteTmpfile ()
|
||||
{
|
||||
if ($this->sessionId == NULL) {
|
||||
throw new Exception( 'session id was not set.' );
|
||||
}
|
||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||
@unlink( $this->tmpfile );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.toolBar.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,162 +15,154 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* ToolBar - ToolBar class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
class ToolBar extends form
|
||||
class ToolBar extends form
|
||||
{
|
||||
var $type = 'toolbar';
|
||||
var $align = 'left';
|
||||
var $type = 'toolbar';
|
||||
var $align = 'left';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* XmlForm_Field_ToolBar - XmlForm_Field_ToolBar class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
class XmlForm_Field_ToolBar extends XmlForm_Field
|
||||
class XmlForm_Field_ToolBar extends XmlForm_Field
|
||||
{
|
||||
var $xmlfile = '';
|
||||
var $type = 'toolbar';
|
||||
var $toolBar;
|
||||
var $home='';
|
||||
var $withoutLabel = true;
|
||||
|
||||
/**
|
||||
* Constructor of the class XmlForm_Field_ToolBar
|
||||
* @param string $xmlNode
|
||||
* @param string $lang
|
||||
* @param string $home
|
||||
* @param string $owner
|
||||
* @return void
|
||||
*/
|
||||
function XmlForm_Field_ToolBar($xmlNode, $lang='en', $home='', $owner)
|
||||
{
|
||||
parent::XmlForm_Field($xmlNode, $lang, $home, $owner);
|
||||
$this->home = $home;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the ToolBar
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
function render( $value )
|
||||
{
|
||||
$this->toolBar = new toolBar( $this->xmlfile , $this->home );
|
||||
$template = PATH_CORE . 'templates/' . $this->type . '.html';
|
||||
$out = $this->toolBar->render( $template , $scriptCode ) ;
|
||||
$oHeadPublisher =& headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile( $this->toolBar->scriptURL );
|
||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||
return $out;
|
||||
}
|
||||
var $xmlfile = '';
|
||||
var $type = 'toolbar';
|
||||
var $toolBar;
|
||||
var $home = '';
|
||||
var $withoutLabel = true;
|
||||
|
||||
/**
|
||||
* Constructor of the class XmlForm_Field_ToolBar
|
||||
*
|
||||
* @param string $xmlNode
|
||||
* @param string $lang
|
||||
* @param string $home
|
||||
* @param string $owner
|
||||
* @return void
|
||||
*/
|
||||
function XmlForm_Field_ToolBar ($xmlNode, $lang = 'en', $home = '', $owner)
|
||||
{
|
||||
parent::XmlForm_Field( $xmlNode, $lang, $home, $owner );
|
||||
$this->home = $home;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the ToolBar
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
function render ($value)
|
||||
{
|
||||
$this->toolBar = new toolBar( $this->xmlfile, $this->home );
|
||||
$template = PATH_CORE . 'templates/' . $this->type . '.html';
|
||||
$out = $this->toolBar->render( $template, $scriptCode );
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile( $this->toolBar->scriptURL );
|
||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* XmlForm_Field_toolButton - XmlForm_Field_toolButton class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
class XmlForm_Field_toolButton extends XmlForm_Field
|
||||
{
|
||||
var $file = '';
|
||||
var $fileAlt = '';
|
||||
var $url = '';
|
||||
var $urlAlt = '';
|
||||
var $home = 'public_html';
|
||||
/* types of buttons:
|
||||
var $file = '';
|
||||
var $fileAlt = '';
|
||||
var $url = '';
|
||||
var $urlAlt = '';
|
||||
var $home = 'public_html';
|
||||
/* types of buttons:
|
||||
* image
|
||||
* text
|
||||
* image/text
|
||||
* text/image
|
||||
*/
|
||||
var $buttonType = 'image';
|
||||
var $withoutLabel = false;
|
||||
var $buttonStyle = '';
|
||||
var $buttonType = 'image';
|
||||
var $withoutLabel = false;
|
||||
var $buttonStyle = '';
|
||||
/*$hoverMethod : back | switch*/
|
||||
var $hoverMethod='back';
|
||||
var $class;
|
||||
|
||||
/**
|
||||
* Prints the components of the toolBar
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
function render( $value )
|
||||
{
|
||||
$url = $this->file;
|
||||
if ($this->home === "methods")
|
||||
$url = G::encryptlink( SYS_URI . $url );
|
||||
if ($this->home === "public_html")
|
||||
$url ='/' . $url ;
|
||||
$urlAlt = $this->fileAlt;
|
||||
if ($this->fileAlt!=='') {
|
||||
if ($this->home === "methods")
|
||||
$urlAlt = G::encryptlink( SYS_URI . $urlAlt );
|
||||
if ($this->home === "public_html")
|
||||
$urlAlt ='/' . $urlAlt ;
|
||||
}
|
||||
$this->url=$url;
|
||||
$this->urlAlt=$urlAlt;
|
||||
switch($this->buttonType){
|
||||
case 'image':
|
||||
$html='';
|
||||
if ($this->hoverMethod==='back') {
|
||||
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'.
|
||||
(($this->style)?' style="'.$this->style.'"':'').' onmouseover=\'backImage(this,"url('.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').') no-repeat")\' onmouseout=\'backImage(this,"")\' title=\'' . addslashes($this->label) . '\' />';
|
||||
}
|
||||
elseif($this->hoverMethod==='switch'){
|
||||
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'.
|
||||
(($this->style)?' style="'.$this->style.'"':'').' onmouseover=\'switchImage(this,"'.htmlentities( $url, ENT_QUOTES, 'utf-8').'","'.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').'")\' onmouseout=\'switchImage(this,"'.htmlentities( $url, ENT_QUOTES, 'utf-8').'","'.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').'")\'/>';
|
||||
}
|
||||
else {
|
||||
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'.
|
||||
(($this->style)?' style="'.$this->style.'"':'').'/>';
|
||||
var $hoverMethod = 'back';
|
||||
var $class;
|
||||
|
||||
/**
|
||||
* Prints the components of the toolBar
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
function render ($value)
|
||||
{
|
||||
$url = $this->file;
|
||||
if ($this->home === "methods")
|
||||
$url = G::encryptlink( SYS_URI . $url );
|
||||
if ($this->home === "public_html")
|
||||
$url = '/' . $url;
|
||||
$urlAlt = $this->fileAlt;
|
||||
if ($this->fileAlt !== '') {
|
||||
if ($this->home === "methods")
|
||||
$urlAlt = G::encryptlink( SYS_URI . $urlAlt );
|
||||
if ($this->home === "public_html")
|
||||
$urlAlt = '/' . $urlAlt;
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
$html=$this->htmlentities($this->label, ENT_QUOTES,'utf-8');
|
||||
break;
|
||||
case 'html':
|
||||
$html='<div '.
|
||||
' onmouseover=\'backImage(this,"url('.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').') no-repeat")\' onmouseout=\'backImage(this,"")\' style="width:25px;height:25px;margin-bottom:3px">'.
|
||||
$this->label.'</div>';
|
||||
|
||||
//$html=$this->label;
|
||||
break;
|
||||
case 'image/text':
|
||||
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'.
|
||||
(($this->style)?' style="'.$this->style.'"':'').'/><br/>'.
|
||||
$this->htmlentities($this->label, ENT_QUOTES,'utf-8');
|
||||
break;
|
||||
case 'text/image':
|
||||
$html=$this->htmlentities($this->label, ENT_QUOTES,'utf-8').
|
||||
'<br/><img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'.
|
||||
(($this->style)?' style="'.$this->style.'"':'').'/>';
|
||||
break;
|
||||
case 'class':
|
||||
$html='<a href="#" onclick="'. $this->onclick.'" onmouseover="backImage(this, \'url(/images/dynamicForm/hover.gif) no-repeat\')" onmouseout="backImage(this, \'\')" style="width:25px;height:25px;margin-bottom:3px">
|
||||
<div class="'.$this->class.'" title="'.strip_tags($this->label).'" style="width:25px;height:25px;margin-bottom:3px"></div>
|
||||
$this->url = $url;
|
||||
$this->urlAlt = $urlAlt;
|
||||
switch ($this->buttonType) {
|
||||
case 'image':
|
||||
$html = '';
|
||||
if ($this->hoverMethod === 'back') {
|
||||
$html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . ' onmouseover=\'backImage(this,"url(' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . ') no-repeat")\' onmouseout=\'backImage(this,"")\' title=\'' . addslashes( $this->label ) . '\' />';
|
||||
} elseif ($this->hoverMethod === 'switch') {
|
||||
$html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . ' onmouseover=\'switchImage(this,"' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '","' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . '")\' onmouseout=\'switchImage(this,"' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '","' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . '")\'/>';
|
||||
} else {
|
||||
$html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . '/>';
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
$html = $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' );
|
||||
break;
|
||||
case 'html':
|
||||
$html = '<div ' . ' onmouseover=\'backImage(this,"url(' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . ') no-repeat")\' onmouseout=\'backImage(this,"")\' style="width:25px;height:25px;margin-bottom:3px">' . $this->label . '</div>';
|
||||
|
||||
//$html=$this->label;
|
||||
break;
|
||||
case 'image/text':
|
||||
$html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . '/><br/>' . $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' );
|
||||
break;
|
||||
case 'text/image':
|
||||
$html = $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' ) . '<br/><img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . '/>';
|
||||
break;
|
||||
case 'class':
|
||||
$html = '<a href="#" onclick="' . $this->onclick . '" onmouseover="backImage(this, \'url(/images/dynamicForm/hover.gif) no-repeat\')" onmouseout="backImage(this, \'\')" style="width:25px;height:25px;margin-bottom:3px">
|
||||
<div class="' . $this->class . '" title="' . strip_tags( $this->label ) . '" style="width:25px;height:25px;margin-bottom:3px"></div>
|
||||
</a>';
|
||||
return $html;
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
return '<a class="toolButton" ' . (($this->buttonStyle) ? ' style="' . $this->buttonStyle . '"' : '') . (($this->onclick) ? ' onclick="' . htmlentities( $this->onclick, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>' . $html . '</a>';
|
||||
}
|
||||
return '<a class="toolButton" '.
|
||||
(($this->buttonStyle)?' style="'.$this->buttonStyle.'"':'').
|
||||
(($this->onclick)?' onclick="'. htmlentities($this->onclick, ENT_QUOTES,'utf-8').'"':'').
|
||||
'>'.$html.'</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,165 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @author Hugo Loza <hugo@colosa.com>
|
||||
*
|
||||
* This class Helps registering and implementing Wizard for Triggers
|
||||
* This class Helps registering and implementing Wizard for Triggers
|
||||
*/
|
||||
G::LoadThirdParty ( 'html2ps_pdf/classes', 'include' );
|
||||
G::LoadThirdParty ( 'html2ps_pdf/classes/org/active-link/doc', 'PHPClass' );
|
||||
G::LoadThirdParty( 'html2ps_pdf/classes', 'include' );
|
||||
G::LoadThirdParty( 'html2ps_pdf/classes/org/active-link/doc', 'PHPClass' );
|
||||
|
||||
/**
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
|
||||
class triggerLibrary {
|
||||
class triggerLibrary
|
||||
{
|
||||
|
||||
private $_aTriggerClasses_ = array ();
|
||||
private $_aTriggerClasses_ = array ();
|
||||
|
||||
private static $instance = NULL;
|
||||
private static $instance = NULL;
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//Initialize the Library and register the Default
|
||||
$this->registerFunctionsFileToLibrary ( PATH_CORE . "classes" . PATH_SEP . "class.pmFunctions.php", "ProcessMaker Functions" );
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct ()
|
||||
{
|
||||
//Initialize the Library and register the Default
|
||||
$this->registerFunctionsFileToLibrary( PATH_CORE . "classes" . PATH_SEP . "class.pmFunctions.php", "ProcessMaker Functions" );
|
||||
|
||||
//Register all registered PLugin Functions
|
||||
if (class_exists( 'folderData' )) {
|
||||
//$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
|
||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
|
||||
foreach ($aAvailablePmFunctions as $key => $class) {
|
||||
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
|
||||
|
||||
if (file_exists( $filePlugin ) && ! is_dir( $filePlugin )) {
|
||||
$this->registerFunctionsFileToLibrary( $filePlugin, "ProcessMaker Functions" );
|
||||
}
|
||||
}
|
||||
|
||||
//Register all registered PLugin Functions
|
||||
if (class_exists ( 'folderData' )) {
|
||||
//$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
|
||||
$oPluginRegistry = &PMPluginRegistry::getSingleton ();
|
||||
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions ();
|
||||
foreach ( $aAvailablePmFunctions as $key => $class ) {
|
||||
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
|
||||
|
||||
if ( file_exists($filePlugin) && !is_dir($filePlugin)) {
|
||||
$this->registerFunctionsFileToLibrary ( $filePlugin, "ProcessMaker Functions" );
|
||||
}
|
||||
}
|
||||
//Add External Triggers
|
||||
$dir = G::ExpandPath( "classes" ) . 'triggers';
|
||||
$filesArray = array ();
|
||||
|
||||
}
|
||||
//Add External Triggers
|
||||
$dir = G::ExpandPath( "classes" ).'triggers';
|
||||
$filesArray = array();
|
||||
|
||||
if (file_exists($dir)){
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if( $file != "." && $file != ".." && !is_dir($dir . PATH_SEP . $file)){
|
||||
$this->registerFunctionsFileToLibrary( $dir . PATH_SEP . $file, "ProcessMaker External Functions");
|
||||
}
|
||||
if (file_exists( $dir )) {
|
||||
if ($handle = opendir( $dir )) {
|
||||
while (false !== ($file = readdir( $handle ))) {
|
||||
if ($file != "." && $file != ".." && ! is_dir( $dir . PATH_SEP . $file )) {
|
||||
$this->registerFunctionsFileToLibrary( $dir . PATH_SEP . $file, "ProcessMaker External Functions" );
|
||||
}
|
||||
}
|
||||
closedir( $handle );
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* &getSingleton
|
||||
*
|
||||
* @return self::$instance;
|
||||
*/
|
||||
function &getSingleton()
|
||||
{
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new triggerLibrary ( );
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* serializeInstance
|
||||
*
|
||||
* @return serialize ( self::$instance );
|
||||
*/
|
||||
function serializeInstance()
|
||||
{
|
||||
return serialize ( self::$instance );
|
||||
}
|
||||
|
||||
/**
|
||||
* unSerializeInstance
|
||||
*
|
||||
* @param integer $serialized
|
||||
* @return void
|
||||
*/
|
||||
function unSerializeInstance($serialized)
|
||||
{
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new PMPluginRegistry ( );
|
||||
}
|
||||
|
||||
$instance = unserialize ( $serialized );
|
||||
self::$instance = $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* registerFunctionsFileToLibrary
|
||||
*
|
||||
* @param string $filePath
|
||||
* @param string $libraryName
|
||||
* @return void
|
||||
*/
|
||||
function registerFunctionsFileToLibrary($filePath, $libraryName)
|
||||
{
|
||||
$aLibrary = $this->getMethodsFromLibraryFile ( $filePath );
|
||||
$aLibrary->libraryFile = $filePath;
|
||||
$aLibrary->libraryName = $libraryName;
|
||||
if(isset($aLibrary->info['className'])){
|
||||
$this->_aTriggerClasses_ [$aLibrary->info['className']] = $aLibrary;
|
||||
/**
|
||||
* &getSingleton
|
||||
*
|
||||
* @return self::$instance;
|
||||
*/
|
||||
function &getSingleton ()
|
||||
{
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new triggerLibrary();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* serializeInstance
|
||||
*
|
||||
* @return serialize ( self::$instance );
|
||||
*/
|
||||
function serializeInstance ()
|
||||
{
|
||||
return serialize( self::$instance );
|
||||
}
|
||||
|
||||
/**
|
||||
* getMethodsFromLibraryFile
|
||||
*
|
||||
* @param string $file
|
||||
* @return object(PHPClass) $parsedLibrary
|
||||
*/
|
||||
function getMethodsFromLibraryFile($file)
|
||||
{
|
||||
// parse class comments from file
|
||||
$parsedLibrary = new PHPClass ( );
|
||||
//$success = $parsedLibrary->parseFromFile ( PATH_CORE . "classes" . PATH_SEP . $file );
|
||||
$success = $parsedLibrary->parseFromFile ( $file );
|
||||
/**
|
||||
* unSerializeInstance
|
||||
*
|
||||
* @param integer $serialized
|
||||
* @return void
|
||||
*/
|
||||
function unSerializeInstance ($serialized)
|
||||
{
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new PMPluginRegistry();
|
||||
}
|
||||
|
||||
return $parsedLibrary;
|
||||
}
|
||||
$instance = unserialize( $serialized );
|
||||
self::$instance = $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* getRegisteredClasses
|
||||
*
|
||||
* @return array ($this->_aTriggerClasses_)
|
||||
*/
|
||||
function getRegisteredClasses()
|
||||
{
|
||||
return ($this->_aTriggerClasses_);
|
||||
}
|
||||
/**
|
||||
* registerFunctionsFileToLibrary
|
||||
*
|
||||
* @param string $filePath
|
||||
* @param string $libraryName
|
||||
* @return void
|
||||
*/
|
||||
function registerFunctionsFileToLibrary ($filePath, $libraryName)
|
||||
{
|
||||
$aLibrary = $this->getMethodsFromLibraryFile( $filePath );
|
||||
$aLibrary->libraryFile = $filePath;
|
||||
$aLibrary->libraryName = $libraryName;
|
||||
if (isset( $aLibrary->info['className'] )) {
|
||||
$this->_aTriggerClasses_[$aLibrary->info['className']] = $aLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* getLibraryDefinition
|
||||
*
|
||||
* @param string $libraryClassName
|
||||
* @return array ($this->_aTriggerClasses_[$libraryClassName])
|
||||
*/
|
||||
function getLibraryDefinition($libraryClassName)
|
||||
{
|
||||
return ($this->_aTriggerClasses_[$libraryClassName]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* __destruct
|
||||
*
|
||||
* @return void
|
||||
*/ function __destruct()
|
||||
{
|
||||
/**
|
||||
* getMethodsFromLibraryFile
|
||||
*
|
||||
* @param string $file
|
||||
* @return object(PHPClass) $parsedLibrary
|
||||
*/
|
||||
function getMethodsFromLibraryFile ($file)
|
||||
{
|
||||
// parse class comments from file
|
||||
$parsedLibrary = new PHPClass();
|
||||
//$success = $parsedLibrary->parseFromFile ( PATH_CORE . "classes" . PATH_SEP . $file );
|
||||
$success = $parsedLibrary->parseFromFile( $file );
|
||||
|
||||
//TODO - Insert your code here
|
||||
}
|
||||
return $parsedLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* getRegisteredClasses
|
||||
*
|
||||
* @return array ($this->_aTriggerClasses_)
|
||||
*/
|
||||
function getRegisteredClasses ()
|
||||
{
|
||||
return ($this->_aTriggerClasses_);
|
||||
}
|
||||
|
||||
/**
|
||||
* getLibraryDefinition
|
||||
*
|
||||
* @param string $libraryClassName
|
||||
* @return array ($this->_aTriggerClasses_[$libraryClassName])
|
||||
*/
|
||||
function getLibraryDefinition ($libraryClassName)
|
||||
{
|
||||
return ($this->_aTriggerClasses_[$libraryClassName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* __destruct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __destruct ()
|
||||
{
|
||||
|
||||
//TODO - Insert your code here
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.wsResponse.php
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,200 +15,219 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
|
||||
class wsResponse
|
||||
{
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $status, $message )
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->timestamp = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getPayloadString
|
||||
* @param string $operation
|
||||
* @return string
|
||||
*/
|
||||
function getPayloadString ( $operation )
|
||||
{
|
||||
$res = "<$operation>\n";
|
||||
$res .= "<status_code>" . $this->status_code . "</status_code>";
|
||||
$res .= "<message>" . $this->message . "</message>";
|
||||
$res .= "<timestamp>" . $this->timestamp . "</timestamp>";
|
||||
// $res .= "<array>" . $this->timestamp . "</array>";
|
||||
$res .= "<$operation>";
|
||||
return $res;
|
||||
}
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function getPayloadArray
|
||||
* @return array
|
||||
*/
|
||||
function getPayloadArray()
|
||||
{
|
||||
return array("status_code" => $this->status_code , 'message'=> $this->message, 'timestamp' => $this->timestamp);
|
||||
}
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
function __construct ($status, $message)
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->timestamp = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getPayloadString
|
||||
*
|
||||
* @param string $operation
|
||||
* @return string
|
||||
*/
|
||||
function getPayloadString ($operation)
|
||||
{
|
||||
$res = "<$operation>\n";
|
||||
$res .= "<status_code>" . $this->status_code . "</status_code>";
|
||||
$res .= "<message>" . $this->message . "</message>";
|
||||
$res .= "<timestamp>" . $this->timestamp . "</timestamp>";
|
||||
// $res .= "<array>" . $this->timestamp . "</array>";
|
||||
$res .= "<$operation>";
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getPayloadArray
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getPayloadArray ()
|
||||
{
|
||||
return array ("status_code" => $this->status_code,'message' => $this->message,'timestamp' => $this->timestamp
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class wsCreateUserResponse
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
*/
|
||||
class wsCreateUserResponse
|
||||
{
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $userUID = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $userUID
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $status, $message, $userUID )
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->userUID = $userUID;
|
||||
$this->timestamp = date('Y-m-d H:i:s');
|
||||
}
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $userUID = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $userUID
|
||||
* @return void
|
||||
*/
|
||||
function __construct ($status, $message, $userUID)
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->userUID = $userUID;
|
||||
$this->timestamp = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class wsCreateGroupResponse
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
*/
|
||||
class wsCreateGroupResponse
|
||||
{
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $groupUID = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $groupUID
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $status, $message, $groupUID ) {
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->groupUID = $groupUID;
|
||||
$this->timestamp = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $groupUID = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $groupUID
|
||||
* @return void
|
||||
*/
|
||||
function __construct ($status, $message, $groupUID)
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->groupUID = $groupUID;
|
||||
$this->timestamp = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class wsCreateDepartmentResponse
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
*/
|
||||
class wsCreateDepartmentResponse
|
||||
{
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $departmentUID = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $departmentUID
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $status, $message, $departmentUID ) {
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->departmentUID = $departmentUID;
|
||||
$this->timestamp = date('Y-m-d H:i:s');
|
||||
}
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $departmentUID = '';
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $departmentUID
|
||||
* @return void
|
||||
*/
|
||||
function __construct ($status, $message, $departmentUID)
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->departmentUID = $departmentUID;
|
||||
$this->timestamp = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class wsGetVariableResponse
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
class wsGetVariableResponse
|
||||
{
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $variables = null;
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $variables
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $status, $message, $variables ) {
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->variables = $variables;
|
||||
$this->timestamp = date('Y-m-d H:i:s');
|
||||
}
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $variables = null;
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param string $variables
|
||||
* @return void
|
||||
*/
|
||||
function __construct ($status, $message, $variables)
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->variables = $variables;
|
||||
$this->timestamp = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class wsGetCaseNotesResponse
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
class wsGetCaseNotesResponse
|
||||
{
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $notes = null;
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param array|object|string $notes
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $status, $message, $notes ) {
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->notes = $notes;
|
||||
$this->timestamp = date('Y-m-d H:i:s');
|
||||
}
|
||||
public $status_code = 0;
|
||||
public $message = '';
|
||||
public $notes = null;
|
||||
public $timestamp = '';
|
||||
|
||||
/**
|
||||
* Function __construct
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param array|object|string $notes
|
||||
* @return void
|
||||
*/
|
||||
function __construct ($status, $message, $notes)
|
||||
{
|
||||
$this->status_code = $status;
|
||||
$this->message = $message;
|
||||
$this->notes = $notes;
|
||||
$this->timestamp = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.xmlfield_Image.php
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,11 +15,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -26,23 +28,27 @@
|
||||
// DEPRECATED this class is also part of the xmlform package this class will be also removed
|
||||
// in future releases of pm, its discouraged the inclusion this class in the future from a
|
||||
// external file like this
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
class XmlForm_Field_Image extends XmlForm_Field
|
||||
{
|
||||
var $file = '';
|
||||
var $home = 'public_html';
|
||||
var $withoutLabel = false;
|
||||
function render( $value, $owner = null )
|
||||
{
|
||||
$url = G::replaceDataField($this->file, $owner->values);
|
||||
if ($this->home === "methods") $url = G::encryptlink( SYS_URI . $url );
|
||||
if ($this->home === "public_html") $url ='/' . $url ;
|
||||
return '<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'" '.
|
||||
(($this->style)?'style="'.$this->style.'"':'')
|
||||
.' alt ="'.htmlentities($value,ENT_QUOTES,'utf-8').'"/>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
public $file = '';
|
||||
public $home = 'public_html';
|
||||
public $withoutLabel = false;
|
||||
|
||||
public function render ($value, $owner = null)
|
||||
{
|
||||
$url = G::replaceDataField( $this->file, $owner->values );
|
||||
if ($this->home === "methods") {
|
||||
$url = G::encryptlink( SYS_URI . $url );
|
||||
}
|
||||
if ($this->home === "public_html") {
|
||||
$url = '/' . $url;
|
||||
}
|
||||
return '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '" ' . (($this->style) ? 'style="' . $this->style . '"' : '') . ' alt ="' . htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '"/>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.xmlfield_InputPM.php
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -13,11 +15,11 @@
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
@@ -27,125 +29,129 @@
|
||||
|
||||
class XmlForm_Field_TextPM extends XmlForm_Field_SimpleText
|
||||
{
|
||||
var $size=15;
|
||||
var $maxLength=64;
|
||||
var $validate='Any';
|
||||
var $mask = '';
|
||||
var $defaultValue='';
|
||||
var $required=false;
|
||||
var $dependentFields='';
|
||||
var $linkField='';
|
||||
//Possible values:(-|UPPER|LOWER|CAPITALIZE)
|
||||
var $strTo='';
|
||||
var $readOnly=false;
|
||||
var $sqlConnection=0;
|
||||
var $sql='';
|
||||
var $sqlOption=array();
|
||||
//Atributes only for grids
|
||||
var $formula = '';
|
||||
var $function = '';
|
||||
var $replaceTags = 0;
|
||||
var $showVars = 0;
|
||||
var $process = '';
|
||||
var $symbol = '@@';
|
||||
public $size = 15;
|
||||
public $maxLength = 64;
|
||||
public $validate = 'Any';
|
||||
public $mask = '';
|
||||
public $defaultValue = '';
|
||||
public $required = false;
|
||||
public $dependentFields = '';
|
||||
public $linkField = '';
|
||||
//Possible values:(-|UPPER|LOWER|CAPITALIZE)
|
||||
public $strTo = '';
|
||||
public $readOnly = false;
|
||||
public $sqlConnection = 0;
|
||||
public $sql = '';
|
||||
public $sqlOption = array ();
|
||||
//Atributes only for grids
|
||||
public $formula = '';
|
||||
public $function = '';
|
||||
public $replaceTags = 0;
|
||||
public $showVars = 0;
|
||||
public $process = '';
|
||||
public $symbol = '@@';
|
||||
|
||||
/**
|
||||
* Function render
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @parameter string value
|
||||
* @parameter string owner
|
||||
* @return string
|
||||
*/
|
||||
function render( $value = NULL , $owner = NULL )
|
||||
{
|
||||
//$this->executeSQL();
|
||||
//if (isset($this->sqlOption)) {
|
||||
// reset($this->sqlOption);
|
||||
// $firstElement=key($this->sqlOption);
|
||||
// if (isset($firstElement)) $value = $firstElement;
|
||||
//}
|
||||
//NOTE: string functions must be in G class
|
||||
if ($this->strTo==='UPPER')
|
||||
$value = strtoupper($value);
|
||||
if ($this->strTo==='LOWER')
|
||||
$value = strtolower($value);
|
||||
//if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value);
|
||||
$onkeypress = G::replaceDataField( $this->onkeypress, $owner->values );
|
||||
if ($this->replaceTags == 1) {
|
||||
$value = G::replaceDataField( $value, $owner->values );
|
||||
/**
|
||||
* Function render
|
||||
*
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param eter string value
|
||||
* @param eter string owner
|
||||
* @return string
|
||||
*/
|
||||
public function render ($value = null, $owner = null)
|
||||
{
|
||||
//$this->executeSQL();
|
||||
//if (isset($this->sqlOption)) {
|
||||
// reset($this->sqlOption);
|
||||
// $firstElement=key($this->sqlOption);
|
||||
// if (isset($firstElement)) $value = $firstElement;
|
||||
//}
|
||||
//NOTE: string functions must be in G class
|
||||
if ($this->strTo === 'UPPER') {
|
||||
$value = strtoupper( $value );
|
||||
}
|
||||
if ($this->strTo === 'LOWER') {
|
||||
$value = strtolower( $value );
|
||||
}
|
||||
//if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value);
|
||||
$onkeypress = G::replaceDataField( $this->onkeypress, $owner->values );
|
||||
if ($this->replaceTags == 1) {
|
||||
$value = G::replaceDataField( $value, $owner->values );
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField( $this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form[' . $this->name . ']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
} else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly) {
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
} else {
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
}
|
||||
} elseif ($this->mode === 'view') {
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="display:none;' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField($this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
}
|
||||
else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode==='edit') {
|
||||
if ($this->readOnly)
|
||||
return '<input class="module_app_input___gray" id="form['.$this->name.']" name="form['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $value , ENT_COMPAT, 'utf-8').'\' readOnly="readOnly" style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'" onkeypress="'.htmlentities( $onkeypress , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
else
|
||||
return '<input class="module_app_input___gray" id="form['.$this->name.']" name="form['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $value , ENT_COMPAT, 'utf-8').'\' style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'" onkeypress="'.htmlentities( $onkeypress , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
} elseif ($this->mode==='view') {
|
||||
return '<input class="module_app_input___gray" id="form['.$this->name.']" name="form['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $value , ENT_COMPAT, 'utf-8').'\' style="display:none;'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'" onkeypress="'.htmlentities( $onkeypress , ENT_COMPAT, 'utf-8').'"/>' .
|
||||
$this->htmlentities( $value , ENT_COMPAT, 'utf-8');
|
||||
} else {
|
||||
return $this->htmlentities( $value , ENT_COMPAT, 'utf-8');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function renderGrid
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @parameter array values
|
||||
* @parameter string owner
|
||||
* @return string
|
||||
*/
|
||||
function renderGrid( $values=array() , $owner )
|
||||
{
|
||||
$result=array();
|
||||
$r=1;
|
||||
foreach($values as $v) {
|
||||
if ($this->replaceTags == 1) {
|
||||
$v = G::replaceDataField( $v, $owner->values );
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField($this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
}
|
||||
else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode==='edit') {
|
||||
if ($this->readOnly)
|
||||
$result[] = '<input class="module_app_input___gray" id="form['. $owner->name .']['.$r.']['.$this->name.']" name="form['. $owner->name .']['.$r.']['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value="'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'" readOnly="readOnly" style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
else
|
||||
$result[] = '<input class="module_app_input___gray" id="form['. $owner->name .']['.$r.']['.$this->name.']" name="form['. $owner->name .']['.$r.']['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value="'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'" style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
} elseif ($this->mode==='view') {
|
||||
$result[] = $this->htmlentities( $v , ENT_COMPAT, 'utf-8');
|
||||
} else {
|
||||
$result[] = $this->htmlentities( $v , ENT_COMPAT, 'utf-8');
|
||||
}
|
||||
$r++;
|
||||
/**
|
||||
* Function renderGrid
|
||||
*
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param eter array values
|
||||
* @param eter string owner
|
||||
* @return string
|
||||
*/
|
||||
public function renderGrid ($values = array(), $owner)
|
||||
{
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
foreach ($values as $v) {
|
||||
if ($this->replaceTags == 1) {
|
||||
$v = G::replaceDataField( $v, $owner->values );
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField( $this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form[' . $owner->name . '][' . $r . '][' . $this->name . ']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
} else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly) {
|
||||
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '" readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
} else {
|
||||
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
}
|
||||
} elseif ($this->mode === 'view') {
|
||||
$result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
$result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
$r ++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function attachEvents
|
||||
* @access public
|
||||
* @parameter string $element
|
||||
* @return string
|
||||
*/
|
||||
function attachEvents($element)
|
||||
{
|
||||
return "myForm.aElements[i] = new G_Text(myForm, $element,'{$this->name}');
|
||||
/**
|
||||
* Function attachEvents
|
||||
*
|
||||
* @access public
|
||||
* @param eter string $element
|
||||
* @return string
|
||||
*/
|
||||
public function attachEvents ($element)
|
||||
{
|
||||
return "myForm.aElements[i] = new G_Text(myForm, $element,'{$this->name}');
|
||||
myForm.aElements[i].setAttributes(" . $this->getAttributes() . ");";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,86 +159,87 @@ class XmlForm_Field_TextPM extends XmlForm_Field_SimpleText
|
||||
*/
|
||||
class XmlForm_Field_TextareaPM extends XmlForm_Field
|
||||
{
|
||||
var $rows = 12;
|
||||
var $cols = 40;
|
||||
var $required = false;
|
||||
var $readOnly = false;
|
||||
var $wrap = 'OFF';
|
||||
var $showVars = 0;
|
||||
var $process = '';
|
||||
var $symbol = '@@';
|
||||
public $rows = 12;
|
||||
public $cols = 40;
|
||||
public $required = false;
|
||||
public $readOnly = false;
|
||||
public $wrap = 'OFF';
|
||||
public $showVars = 0;
|
||||
public $process = '';
|
||||
public $symbol = '@@';
|
||||
|
||||
/**
|
||||
* Function render
|
||||
* @author Julio Cesar Laura Avendao <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @parameter string value
|
||||
* @parameter string owner
|
||||
* @return string
|
||||
*/
|
||||
function render( $value = NULL, $owner )
|
||||
{
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField($this->process, $owner->values );
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
/**
|
||||
* Function render
|
||||
*
|
||||
* @author Julio Cesar Laura Avendao <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param eter string value
|
||||
* @param eter string owner
|
||||
* @return string
|
||||
*/
|
||||
public function render ($value = null, $owner)
|
||||
{
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField( $this->process, $owner->values );
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form[' . $this->name . ']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
} else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly) {
|
||||
return '<textarea id="form[' . $this->name . ']" name="form[' . $this->name . ']" cols="' . $this->cols . '" rows="' . $this->rows . '" style="' . $this->style . '" wrap="' . htmlentities( $this->wrap, ENT_QUOTES, 'UTF-8' ) . '" class="FormTextPM" readOnly>' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '</textarea>' . $sShowVars;
|
||||
} else {
|
||||
return '<textarea id="form[' . $this->name . ']" name="form[' . $this->name . ']" cols="' . $this->cols . '" rows="' . $this->rows . '" style="' . $this->style . '" wrap="' . htmlentities( $this->wrap, ENT_QUOTES, 'UTF-8' ) . '" class="FormTextPM" >' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '</textarea>' . $sShowVars;
|
||||
}
|
||||
} elseif ($this->mode === 'view') {
|
||||
return '<textarea id="form[' . $this->name . ']" name="form[' . $this->name . ']" cols="' . $this->cols . '" rows="' . $this->rows . '" readOnly style="border:0px;backgroud-color:inherit;' . $this->style . '" wrap="' . htmlentities( $this->wrap, ENT_QUOTES, 'UTF-8' ) . '" class="FormTextPM" >' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '</textarea>';
|
||||
} else {
|
||||
return '<textarea id="form[' . $this->name . ']" name="form[' . $this->name . ']" cols="' . $this->cols . '" rows="' . $this->rows . '" style="' . $this->style . '" wrap="' . htmlentities( $this->wrap, ENT_QUOTES, 'UTF-8' ) . '" class="FormTextArea" >' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '</textarea>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode==='edit') {
|
||||
if ($this->readOnly)
|
||||
return '<textarea id="form['.$this->name.']" name="form['.$this->name.']" cols="'.$this->cols.'" rows="'.$this->rows.'" style="'.$this->style.'" wrap="'.htmlentities($this->wrap,ENT_QUOTES,'UTF-8').'" class="FormTextPM" readOnly>'.$this->htmlentities( $value ,ENT_COMPAT,'utf-8').'</textarea>' . $sShowVars;
|
||||
else
|
||||
return '<textarea id="form['.$this->name.']" name="form['.$this->name.']" cols="'.$this->cols.'" rows="'.$this->rows.'" style="'.$this->style.'" wrap="'.htmlentities($this->wrap,ENT_QUOTES,'UTF-8').'" class="FormTextPM" >'.$this->htmlentities( $value ,ENT_COMPAT,'utf-8').'</textarea>' . $sShowVars;
|
||||
} elseif ($this->mode==='view') {
|
||||
return '<textarea id="form['.$this->name.']" name="form['.$this->name.']" cols="'.$this->cols.'" rows="'.$this->rows.'" readOnly style="border:0px;backgroud-color:inherit;'.$this->style.'" wrap="'.htmlentities($this->wrap,ENT_QUOTES,'UTF-8').'" class="FormTextPM" >'.$this->htmlentities( $value ,ENT_COMPAT,'utf-8').'</textarea>';
|
||||
} else {
|
||||
return '<textarea id="form['.$this->name.']" name="form['.$this->name.']" cols="'.$this->cols.'" rows="'.$this->rows.'" style="'.$this->style.'" wrap="'.htmlentities($this->wrap,ENT_QUOTES,'UTF-8').'" class="FormTextArea" >'.$this->htmlentities( $value ,ENT_COMPAT,'utf-8').'</textarea>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function renderGrid
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @parameter string values
|
||||
* @parameter string owner
|
||||
* @return string
|
||||
*/
|
||||
function renderGrid( $values = NULL , $owner )
|
||||
{
|
||||
$result=array();
|
||||
$r=1;
|
||||
foreach($values as $v) {
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField($this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
}
|
||||
else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode==='edit') {
|
||||
if ($this->readOnly)
|
||||
$result[] = '<input class="module_app_input___gray" id="form['. $owner->name .']['.$r.']['.$this->name.']" name="form['. $owner->name .']['.$r.']['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'\' readOnly="readOnly"/>' . $sShowVars;
|
||||
else
|
||||
$result[] = '<input class="module_app_input___gray" id="form['. $owner->name .']['.$r.']['.$this->name.']" name="form['. $owner->name .']['.$r.']['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'\' />' . $sShowVars;
|
||||
} elseif ($this->mode==='view') {
|
||||
if(stristr($_SERVER['HTTP_USER_AGENT'], 'iPhone')){
|
||||
//$result[] = '<div style="overflow:hidden;height:25px;padding:0px;margin:0px;">'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'</div>';
|
||||
$result[] = $this->htmlentities( $v , ENT_COMPAT, 'utf-8');
|
||||
}
|
||||
else{
|
||||
//$result[] = '<div style="overflow:hidden;width:inherit;height:2em;padding:0px;margin:0px;">'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'</div>';
|
||||
$result[] = $this->htmlentities( $v , ENT_COMPAT, 'utf-8');
|
||||
}
|
||||
} else{
|
||||
$result[] = $this->htmlentities( $v , ENT_COMPAT, 'utf-8');
|
||||
}
|
||||
$r++;
|
||||
/**
|
||||
* Function renderGrid
|
||||
*
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param eter string values
|
||||
* @param eter string owner
|
||||
* @return string
|
||||
*/
|
||||
public function renderGrid ($values = null, $owner)
|
||||
{
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
foreach ($values as $v) {
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField( $this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form[' . $owner->name . '][' . $r . '][' . $this->name . ']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
} else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly) {
|
||||
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly"/>' . $sShowVars;
|
||||
} else {
|
||||
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '\' />' . $sShowVars;
|
||||
}
|
||||
} elseif ($this->mode === 'view') {
|
||||
if (stristr( $_SERVER['HTTP_USER_AGENT'], 'iPhone' )) {
|
||||
//$result[] = '<div style="overflow:hidden;height:25px;padding:0px;margin:0px;">'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'</div>';
|
||||
$result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
//$result[] = '<div style="overflow:hidden;width:inherit;height:2em;padding:0px;margin:0px;">'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'</div>';
|
||||
$result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
} else {
|
||||
$result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
$r ++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,230 +247,239 @@ class XmlForm_Field_TextareaPM extends XmlForm_Field
|
||||
*/
|
||||
class XmlForm_Field_hours extends XmlForm_Field_SimpleText
|
||||
{
|
||||
var $size = 15;
|
||||
var $maxLength = 64;
|
||||
var $validate = 'Any';
|
||||
var $mask = '';
|
||||
var $defaultValue = '';
|
||||
var $required = false;
|
||||
var $dependentFields= '';
|
||||
var $linkField = '';
|
||||
//Possible values:(-|UPPER|LOWER|CAPITALIZE)
|
||||
var $strTo = '';
|
||||
var $readOnly = false;
|
||||
var $sqlConnection = 0;
|
||||
var $sql = '';
|
||||
var $sqlOption = array();
|
||||
//Atributes only for grids
|
||||
var $formula = '';
|
||||
var $function = '';
|
||||
var $replaceTags = 0;
|
||||
var $showVars = 0;
|
||||
var $process = '';
|
||||
var $symbol = '@@';
|
||||
public $size = 15;
|
||||
public $maxLength = 64;
|
||||
public $validate = 'Any';
|
||||
public $mask = '';
|
||||
public $defaultValue = '';
|
||||
public $required = false;
|
||||
public $dependentFields = '';
|
||||
public $linkField = '';
|
||||
//Possible values:(-|UPPER|LOWER|CAPITALIZE)
|
||||
public $strTo = '';
|
||||
public $readOnly = false;
|
||||
public $sqlConnection = 0;
|
||||
public $sql = '';
|
||||
public $sqlOption = array ();
|
||||
//Atributes only for grids
|
||||
public $formula = '';
|
||||
public $function = '';
|
||||
public $replaceTags = 0;
|
||||
public $showVars = 0;
|
||||
public $process = '';
|
||||
public $symbol = '@@';
|
||||
|
||||
/**
|
||||
* Function render
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @parameter string value
|
||||
* @parameter string owner
|
||||
* @return string
|
||||
*/
|
||||
function render( $value = NULL , $owner = NULL )
|
||||
{
|
||||
if ($this->strTo==='UPPER')
|
||||
$value = strtoupper($value);
|
||||
if ($this->strTo==='LOWER')
|
||||
$value = strtolower($value);
|
||||
//if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value);
|
||||
$onkeypress = G::replaceDataField( $this->onkeypress, $owner->values );
|
||||
if ($this->replaceTags == 1) {
|
||||
$value = G::replaceDataField( $value, $owner->values );
|
||||
/**
|
||||
* Function render
|
||||
*
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param eter string value
|
||||
* @param eter string owner
|
||||
* @return string
|
||||
*/
|
||||
public function render ($value = null, $owner = null)
|
||||
{
|
||||
if ($this->strTo === 'UPPER') {
|
||||
$value = strtoupper( $value );
|
||||
}
|
||||
if ($this->strTo === 'LOWER') {
|
||||
$value = strtolower( $value );
|
||||
}
|
||||
//if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value);
|
||||
$onkeypress = G::replaceDataField( $this->onkeypress, $owner->values );
|
||||
if ($this->replaceTags == 1) {
|
||||
$value = G::replaceDataField( $value, $owner->values );
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField( $this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form[' . $this->name . ']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
} else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly) {
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
} else {
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
}
|
||||
} elseif ($this->mode === 'view') {
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' style="display:none;' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField($this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
}
|
||||
else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode==='edit') {
|
||||
if ($this->readOnly)
|
||||
return '<input class="module_app_input___gray" id="form['.$this->name.']" name="form['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $value , ENT_COMPAT, 'utf-8').'\' readOnly="readOnly" style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'" onkeypress="'.htmlentities( $onkeypress , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
else
|
||||
return '<input class="module_app_input___gray" id="form['.$this->name.']" name="form['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $value , ENT_COMPAT, 'utf-8').'\' style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'" onkeypress="'.htmlentities( $onkeypress , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
} elseif ($this->mode==='view') {
|
||||
return '<input class="module_app_input___gray" id="form['.$this->name.']" name="form['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value=\''.$this->htmlentities( $value , ENT_COMPAT, 'utf-8').'\' style="display:none;'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'" onkeypress="'.htmlentities( $onkeypress , ENT_COMPAT, 'utf-8').'"/>' .
|
||||
$this->htmlentities( $value , ENT_COMPAT, 'utf-8');
|
||||
} else {
|
||||
return $this->htmlentities( $value , ENT_COMPAT, 'utf-8');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function renderGrid
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @parameter array values
|
||||
* @parameter string owner
|
||||
* @return string
|
||||
*/
|
||||
function renderGrid( $values=array() , $owner )
|
||||
{
|
||||
$result=array();
|
||||
$r=1;
|
||||
foreach($values as $v) {
|
||||
if ($this->replaceTags == 1) {
|
||||
$v = G::replaceDataField( $v, $owner->values );
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField($this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
}
|
||||
else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode==='edit') {
|
||||
if ($this->readOnly)
|
||||
$result[] = '<input class="module_app_input___gray" id="form['. $owner->name .']['.$r.']['.$this->name.']" name="form['. $owner->name .']['.$r.']['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value="'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'" readOnly="readOnly" style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
else
|
||||
$result[] = '<input class="module_app_input___gray" id="form['. $owner->name .']['.$r.']['.$this->name.']" name="form['. $owner->name .']['.$r.']['.$this->name.']" type ="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" value="'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'" style="'.htmlentities( $this->style , ENT_COMPAT, 'utf-8').'"/>' . $sShowVars;
|
||||
} elseif ($this->mode==='view') {
|
||||
$result[] = '<p align="'.$this->align.'">'.$this->htmlentities( number_format($v, 2), ENT_COMPAT, 'utf-8').'</p>';
|
||||
} else {
|
||||
$result[] = '<p align="'.$this->align.'">'.$this->htmlentities( number_format($v, 2), ENT_COMPAT, 'utf-8').'</p>';
|
||||
}
|
||||
$r++;
|
||||
/**
|
||||
* Function renderGrid
|
||||
*
|
||||
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param eter array values
|
||||
* @param eter string owner
|
||||
* @return string
|
||||
*/
|
||||
public function renderGrid ($values = array(), $owner)
|
||||
{
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
foreach ($values as $v) {
|
||||
if ($this->replaceTags == 1) {
|
||||
$v = G::replaceDataField( $v, $owner->values );
|
||||
}
|
||||
if ($this->showVars == 1) {
|
||||
$this->process = G::replaceDataField( $this->process, $owner->values );
|
||||
//$sShowVars = ' <a href="#" onclick="showDynaformsFormVars(\'form['.$owner->name .']['.$r.']['.$this->name.']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;">' . $this->symbol . '</a>';
|
||||
$sShowVars = ' <input type="button" value="' . $this->symbol . '" onclick="showDynaformsFormVars(\'form[' . $owner->name . '][' . $r . '][' . $this->name . ']\', \'../controls/varsAjax\', \'' . $this->process . '\', \'' . $this->symbol . '\');return false;"/>';
|
||||
} else {
|
||||
$sShowVars = '';
|
||||
}
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly) {
|
||||
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '" readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
} else {
|
||||
$result[] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ) . '" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . $sShowVars;
|
||||
}
|
||||
} elseif ($this->mode === 'view') {
|
||||
$result[] = '<p align="' . $this->align . '">' . $this->htmlentities( number_format( $v, 2 ), ENT_COMPAT, 'utf-8' ) . '</p>';
|
||||
} else {
|
||||
$result[] = '<p align="' . $this->align . '">' . $this->htmlentities( number_format( $v, 2 ), ENT_COMPAT, 'utf-8' ) . '</p>';
|
||||
}
|
||||
$r ++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function attachEvents
|
||||
* @access public
|
||||
* @parameter string $element
|
||||
* @return string
|
||||
*/
|
||||
function attachEvents($element)
|
||||
{
|
||||
return "myForm.aElements[i] = new G_Text(myForm, $element,'{$this->name}');
|
||||
/**
|
||||
* Function attachEvents
|
||||
*
|
||||
* @access public
|
||||
* @param eter string $element
|
||||
* @return string
|
||||
*/
|
||||
public function attachEvents ($element)
|
||||
{
|
||||
return "myForm.aElements[i] = new G_Text(myForm, $element,'{$this->name}');
|
||||
myForm.aElements[i].setAttributes(" . $this->getAttributes() . ");";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getDynaformsVars
|
||||
* @access public
|
||||
* @parameter string $sProcessUID
|
||||
* @parameter boolean $bSystemVars
|
||||
* @return array
|
||||
*/
|
||||
function getDynaformsVars($sProcessUID, $bSystemVars = true, $bIncMulSelFields = 0)
|
||||
{
|
||||
$aFields = array();
|
||||
$aFieldsNames = array();
|
||||
/**
|
||||
* Function getDynaformsVars
|
||||
*
|
||||
* @access public
|
||||
* @param eter string $sProcessUID
|
||||
* @param eter boolean $bSystemVars
|
||||
* @return array
|
||||
*/
|
||||
function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields = 0)
|
||||
{
|
||||
$aFields = array ();
|
||||
$aFieldsNames = array ();
|
||||
if ($bSystemVars) {
|
||||
$aAux = G::getSystemConstants();
|
||||
foreach ($aAux as $sName => $sValue) {
|
||||
$aFields[] = array('sName' => $sName, 'sType' => 'system', 'sLabel'=> 'System variable');
|
||||
}
|
||||
//we're adding the ping variable to the system list
|
||||
$aFields[] = array('sName' => 'PIN', 'sType' => 'system', 'sLabel' => 'System variable');
|
||||
$aAux = G::getSystemConstants();
|
||||
foreach ($aAux as $sName => $sValue) {
|
||||
$aFields[] = array ('sName' => $sName,'sType' => 'system','sLabel' => 'System variable'
|
||||
);
|
||||
}
|
||||
//we're adding the ping variable to the system list
|
||||
$aFields[] = array ('sName' => 'PIN','sType' => 'system','sLabel' => 'System variable'
|
||||
);
|
||||
}
|
||||
$aInvalidTypes = array('title', 'subtitle', 'link', 'file', 'button', 'reset', 'submit', 'javascript');
|
||||
$aMultipleSelectionFields = array('listbox', 'checkgroup', 'grid');
|
||||
$aInvalidTypes = array ('title','subtitle','link','file','button','reset','submit','javascript'
|
||||
);
|
||||
$aMultipleSelectionFields = array ('listbox','checkgroup','grid'
|
||||
);
|
||||
if ($bIncMulSelFields != 0) {
|
||||
$aInvalidTypes = array_merge($aInvalidTypes, $aMultipleSelectionFields);
|
||||
$aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields );
|
||||
}
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(DynaformPeer::DYN_FILENAME);
|
||||
$oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
|
||||
$oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform');
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME );
|
||||
$oCriteria->add( DynaformPeer::PRO_UID, $sProcessUID );
|
||||
$oCriteria->add( DynaformPeer::DYN_TYPE, 'xmlform' );
|
||||
$oDataset = DynaformPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if (file_exists(PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml')) {
|
||||
$G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG);
|
||||
if (($G_FORM->type == 'xmlform') || ($G_FORM->type == '')) {
|
||||
foreach($G_FORM->fields as $k => $v) {
|
||||
if (!in_array($v->type, $aInvalidTypes)) {
|
||||
if (!in_array($k, $aFieldsNames)) {
|
||||
$aFields[] = array('sName' => $k,
|
||||
'sType' => $v->type,
|
||||
'sLabel'=> ($v->type != 'grid' ? $v->label : '[ ' . G::LoadTranslation('ID_GRID') . ' ]')
|
||||
);
|
||||
$aFieldsNames[] = $k;
|
||||
}
|
||||
if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) {
|
||||
$G_FORM = new Form( $aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG );
|
||||
if (($G_FORM->type == 'xmlform') || ($G_FORM->type == '')) {
|
||||
foreach ($G_FORM->fields as $k => $v) {
|
||||
if (! in_array( $v->type, $aInvalidTypes )) {
|
||||
if (! in_array( $k, $aFieldsNames )) {
|
||||
$aFields[] = array ('sName' => $k,'sType' => $v->type,'sLabel' => ($v->type != 'grid' ? $v->label : '[ ' . G::LoadTranslation( 'ID_GRID' ) . ' ]')
|
||||
);
|
||||
$aFieldsNames[] = $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$oDataset->next();
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aFields;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getGridsVars
|
||||
* @access public
|
||||
* @parameter string $sProcessUID
|
||||
* @return array
|
||||
*/
|
||||
function getGridsVars($sProcessUID)
|
||||
{
|
||||
$aFields = array();
|
||||
$aFieldsNames = array();
|
||||
/**
|
||||
* Function getGridsVars
|
||||
*
|
||||
* @access public
|
||||
* @param eter string $sProcessUID
|
||||
* @return array
|
||||
*/
|
||||
function getGridsVars ($sProcessUID)
|
||||
{
|
||||
$aFields = array ();
|
||||
$aFieldsNames = array ();
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(DynaformPeer::DYN_FILENAME);
|
||||
$oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME );
|
||||
$oCriteria->add( DynaformPeer::PRO_UID, $sProcessUID );
|
||||
$oDataset = DynaformPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG);
|
||||
if ($G_FORM->type == 'xmlform') {
|
||||
foreach($G_FORM->fields as $k => $v) {
|
||||
if ($v->type == 'grid') {
|
||||
if (!in_array($k, $aFieldsNames)) {
|
||||
$aFields[] = array('sName' => $k, 'sXmlForm' => str_replace($sProcessUID . '/', '', $v->xmlGrid));
|
||||
$aFieldsNames[] = $k;
|
||||
$G_FORM = new Form( $aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG );
|
||||
if ($G_FORM->type == 'xmlform') {
|
||||
foreach ($G_FORM->fields as $k => $v) {
|
||||
if ($v->type == 'grid') {
|
||||
if (! in_array( $k, $aFieldsNames )) {
|
||||
$aFields[] = array ('sName' => $k,'sXmlForm' => str_replace( $sProcessUID . '/', '', $v->xmlGrid )
|
||||
);
|
||||
$aFieldsNames[] = $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$oDataset->next();
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aFields;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class XmlForm_Field_CheckBoxTable
|
||||
*/
|
||||
class XmlForm_Field_CheckBoxTable extends XmlForm_Field_Checkbox
|
||||
{
|
||||
/**
|
||||
* Function render
|
||||
* @author The Answer
|
||||
* @access public
|
||||
* @parameter string value
|
||||
* @parameter string owner
|
||||
* @return string
|
||||
*/
|
||||
function render( $value = NULL , $owner = NULL )
|
||||
{
|
||||
//$optionName = $owner->values['USR_UID'];
|
||||
$optionName = $value;
|
||||
$onclick = (($this->onclick)? ' onclick="' . G::replaceDataField( $this->onclick, $owner->values ) . '" ' : '');
|
||||
$html ='<input class="FormCheck" id="form['.$this->name.']['.$optionName.']" name="form['.$this->name.
|
||||
']['.$optionName.']" type=\'checkbox\' value="'. $value . '"' . $onclick .
|
||||
'> <span class="FormCheck"></span></input>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function render
|
||||
*
|
||||
* @author The Answer
|
||||
* @access public
|
||||
* @param eter string value
|
||||
* @param eter string owner
|
||||
* @return string
|
||||
*/
|
||||
public function render ($value = null, $owner = null)
|
||||
{
|
||||
//$optionName = $owner->values['USR_UID'];
|
||||
$optionName = $value;
|
||||
$onclick = (($this->onclick) ? ' onclick="' . G::replaceDataField( $this->onclick, $owner->values ) . '" ' : '');
|
||||
$html = '<input class="FormCheck" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][' . $optionName . ']" type=\'checkbox\' value="' . $value . '"' . $onclick . '> <span class="FormCheck"></span></input>';
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,4 +24,5 @@
|
||||
*/
|
||||
$G_PUBLISH = new Publisher ();
|
||||
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/forgotPassword', '', array(), 'retrivePassword.php');
|
||||
G::RenderPage ( "publish" );
|
||||
G::RenderPage ( "publish" );
|
||||
|
||||
|
||||
@@ -131,11 +131,8 @@ if ($oServerConf->getProperty ('LOGIN_NO_WS')) {
|
||||
$G_PUBLISH->AddContent ('xmlform', 'xmlform', 'login/sysLogin', '', $aField, 'sysLogin');
|
||||
}
|
||||
|
||||
//g::dump($G_PUBLISH);
|
||||
|
||||
G::RenderPage ("publish");
|
||||
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var oInfoPanel;
|
||||
@@ -186,3 +183,6 @@ G::RenderPage ("publish");
|
||||
oInfoPanel.addContent(oRPC.xmlhttp.responseText);
|
||||
};
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
Reference in New Issue
Block a user