CODE STYLE controllers/adminProxy.php

This commit is contained in:
Fernando Ontiveros
2012-10-19 11:31:42 -04:00
parent 4351ce5253
commit 92f6ff3f6b

View File

@@ -32,7 +32,7 @@ class adminProxy extends HttpProxyController
$updateRedirector = false; $updateRedirector = false;
$restart = false; $restart = false;
if (!file_exists($envFile) ) { // if ini file doesn't exists if (!file_exists($envFile) ) {
if (!is_writable(PATH_CONFIG)) { if (!is_writable(PATH_CONFIG)) {
throw new Exception('The enviroment config directory is not writable. <br/>Please give write permission to directory: /workflow/engine/config'); throw new Exception('The enviroment config directory is not writable. <br/>Please give write permission to directory: /workflow/engine/config');
} }
@@ -41,8 +41,7 @@ class adminProxy extends HttpProxyController
$content .= ";\r\n"; $content .= ";\r\n";
file_put_contents($envFile, $content); file_put_contents($envFile, $content);
//@chmod($envFile, 0777); //@chmod($envFile, 0777);
} } else {
else {
if (!is_writable($envFile)) { if (!is_writable($envFile)) {
throw new Exception('The enviroment ini file file is not writable. <br/>Please give write permission to file: /workflow/engine/config/env.ini'); throw new Exception('The enviroment ini file file is not writable. <br/>Please give write permission to file: /workflow/engine/config/env.ini');
} }
@@ -90,8 +89,7 @@ class adminProxy extends HttpProxyController
if ($updateRedirector) { if ($updateRedirector) {
if (!file_exists(PATH_HTML . 'index.html')) { if (!file_exists(PATH_HTML . 'index.html')) {
throw new Exception('The index.html file is not writable on workflow/public_html directory.'); throw new Exception('The index.html file is not writable on workflow/public_html directory.');
} } else {
else {
if (!is_writable(PATH_HTML . 'index.html')) { if (!is_writable(PATH_HTML . 'index.html')) {
throw new Exception(G::LoadTranslation('ID_INDEX_NOT_WRITEABLE') . ' /workflow/public_html/index.html'); throw new Exception(G::LoadTranslation('ID_INDEX_NOT_WRITEABLE') . ' /workflow/public_html/index.html');
} }
@@ -108,8 +106,7 @@ class adminProxy extends HttpProxyController
G::update_php_ini($envFile, $updatedConf); G::update_php_ini($envFile, $updatedConf);
if (substr($sysConf['default_skin'], 0, 2) == 'ux') { if (substr($sysConf['default_skin'], 0, 2) == 'ux') {
$urlPart = '/main/login'; $urlPart = '/main/login';
} } else {
else {
$urlPart = '/login/login'; $urlPart = '/login/login';
} }
@@ -119,7 +116,7 @@ class adminProxy extends HttpProxyController
$this->message = 'Saved Successfully'; $this->message = 'Saved Successfully';
} }
function uxUserUpdate($httpData) public function uxUserUpdate($httpData)
{ {
require_once 'classes/model/Users.php'; require_once 'classes/model/Users.php';
$data = G::json_decode($httpData->users); $data = G::json_decode($httpData->users);
@@ -127,8 +124,7 @@ class adminProxy extends HttpProxyController
if (!is_array($data)) { if (!is_array($data)) {
$list[0] = (array) $data ; $list[0] = (array) $data ;
} } else {
else {
$list = $data; $list = $data;
} }
@@ -149,15 +145,15 @@ class adminProxy extends HttpProxyController
if (count($rows) == 1) { if (count($rows) == 1) {
$retRow = $rows[0]; $retRow = $rows[0];
} } else {
else {
$retRow = $rows; $retRow = $rows;
} }
return array('success' => true, 'message'=>'done', 'users'=>$retRow); return array('success' => true, 'message'=>'done', 'users'=>$retRow);
} }
function calendarValidate($httpData) { public function calendarValidate($httpData)
{
$httpData=array_unique((array)$httpData); $httpData=array_unique((array)$httpData);
$message = ''; $message = '';
$oldName = isset($_POST['oldName'])? $_POST['oldName']:''; $oldName = isset($_POST['oldName'])? $_POST['oldName']:'';
@@ -169,16 +165,15 @@ class adminProxy extends HttpProxyController
$aCalendars = $oCalendar->getCalendarList(false,true); $aCalendars = $oCalendar->getCalendarList(false,true);
$aCalendarDefinitions = end($aCalendars); $aCalendarDefinitions = end($aCalendars);
foreach($aCalendarDefinitions as $aDefinitions) { foreach ($aCalendarDefinitions as $aDefinitions) {
if (trim($_POST['name'])==''){ if (trim($_POST['name'])=='') {
$validated = false; $validated = false;
$message = G::loadTranslation('ID_CALENDAR_INVALID_NAME'); $message = G::loadTranslation('ID_CALENDAR_INVALID_NAME');
break; break;
} }
if ($aDefinitions['CALENDAR_NAME'] != $_POST['name']){ if ($aDefinitions['CALENDAR_NAME'] != $_POST['name']) {
$validated = true; $validated = true;
} } else {
else {
if ($aDefinitions['CALENDAR_NAME'] != $oldName) { if ($aDefinitions['CALENDAR_NAME'] != $oldName) {
$validated = false; $validated = false;
$message = G::loadTranslation('ID_CALENDAR_INVALID_NAME'); $message = G::loadTranslation('ID_CALENDAR_INVALID_NAME');
@@ -195,7 +190,7 @@ class adminProxy extends HttpProxyController
return $message; return $message;
} }
function uxGroupUpdate($httpData) public function uxGroupUpdate($httpData)
{ {
G::LoadClass('groups'); G::LoadClass('groups');
$groups = new Groups(); $groups = new Groups();
@@ -216,7 +211,7 @@ class adminProxy extends HttpProxyController
return array('success' => $success, 'users' => $usersAdmin); return array('success' => $success, 'users' => $usersAdmin);
} }
function getUxTypesList($type = 'assoc') public function getUxTypesList($type = 'assoc')
{ {
$list = array(); $list = array();
@@ -227,8 +222,7 @@ class adminProxy extends HttpProxyController
'SWITCHABLE' => 'Switchable', 'SWITCHABLE' => 'Switchable',
'SINGLE' => 'Single Application' 'SINGLE' => 'Single Application'
); );
} } else {
else {
$list = array( $list = array(
array('NORMAL', 'Normal'), array('NORMAL', 'Normal'),
array('SIMPLIFIED', 'Simplified'), array('SIMPLIFIED', 'Simplified'),
@@ -236,16 +230,15 @@ class adminProxy extends HttpProxyController
array('SINGLE', 'Single Application') array('SINGLE', 'Single Application')
); );
} }
return $list; return $list;
} }
function calendarSave() public function calendarSave()
{ {
//{ $_POST['BUSINESS_DAY'] //{ $_POST['BUSINESS_DAY']
$businessDayArray = G::json_decode($_POST['BUSINESS_DAY']); $businessDayArray = G::json_decode($_POST['BUSINESS_DAY']);
$businessDayFixArray = array(); $businessDayFixArray = array();
for($i=0;$i<sizeof($businessDayArray);$i++) { for ($i=0; $i<sizeof($businessDayArray); $i++) {
$businessDayFixArray[$i+1]['CALENDAR_BUSINESS_DAY'] = $businessDayArray[$i]->CALENDAR_BUSINESS_DAY; $businessDayFixArray[$i+1]['CALENDAR_BUSINESS_DAY'] = $businessDayArray[$i]->CALENDAR_BUSINESS_DAY;
$businessDayFixArray[$i+1]['CALENDAR_BUSINESS_START'] = $businessDayArray[$i]->CALENDAR_BUSINESS_START; $businessDayFixArray[$i+1]['CALENDAR_BUSINESS_START'] = $businessDayArray[$i]->CALENDAR_BUSINESS_START;
$businessDayFixArray[$i+1]['CALENDAR_BUSINESS_END'] = $businessDayArray[$i]->CALENDAR_BUSINESS_END; $businessDayFixArray[$i+1]['CALENDAR_BUSINESS_END'] = $businessDayArray[$i]->CALENDAR_BUSINESS_END;
@@ -256,7 +249,7 @@ class adminProxy extends HttpProxyController
//{ $_POST['CALENDAR_WORK_DAYS'] //{ $_POST['CALENDAR_WORK_DAYS']
$calendarWorkDaysArray = G::json_decode($_POST['CALENDAR_WORK_DAYS']); $calendarWorkDaysArray = G::json_decode($_POST['CALENDAR_WORK_DAYS']);
$calendarWorkDaysFixArray = array(); $calendarWorkDaysFixArray = array();
for($i=0;$i<sizeof($calendarWorkDaysArray);$i++) { for ($i=0; $i<sizeof($calendarWorkDaysArray); $i++) {
$calendarWorkDaysFixArray[$i] = $calendarWorkDaysArray[$i].""; $calendarWorkDaysFixArray[$i] = $calendarWorkDaysArray[$i]."";
} }
$_POST['CALENDAR_WORK_DAYS'] = $calendarWorkDaysFixArray; $_POST['CALENDAR_WORK_DAYS'] = $calendarWorkDaysFixArray;
@@ -265,7 +258,7 @@ class adminProxy extends HttpProxyController
//{ $_POST['HOLIDAY'] //{ $_POST['HOLIDAY']
$holidayArray = G::json_decode($_POST['HOLIDAY']); $holidayArray = G::json_decode($_POST['HOLIDAY']);
$holidayFixArray = array(); $holidayFixArray = array();
for($i=0;$i<sizeof($holidayArray);$i++) { for ($i=0; $i<sizeof($holidayArray); $i++) {
$holidayFixArray[$i+1]['CALENDAR_HOLIDAY_NAME'] = $holidayArray[$i]->CALENDAR_HOLIDAY_NAME; $holidayFixArray[$i+1]['CALENDAR_HOLIDAY_NAME'] = $holidayArray[$i]->CALENDAR_HOLIDAY_NAME;
$holidayFixArray[$i+1]['CALENDAR_HOLIDAY_START'] = $holidayArray[$i]->CALENDAR_HOLIDAY_START; $holidayFixArray[$i+1]['CALENDAR_HOLIDAY_START'] = $holidayArray[$i]->CALENDAR_HOLIDAY_START;
$holidayFixArray[$i+1]['CALENDAR_HOLIDAY_END'] = $holidayArray[$i]->CALENDAR_HOLIDAY_END; $holidayFixArray[$i+1]['CALENDAR_HOLIDAY_END'] = $holidayArray[$i]->CALENDAR_HOLIDAY_END;
@@ -274,10 +267,10 @@ class adminProxy extends HttpProxyController
//} //}
//[ CALENDAR_STATUS BUSINESS_DAY_STATUS HOLIDAY_STATUS //[ CALENDAR_STATUS BUSINESS_DAY_STATUS HOLIDAY_STATUS
if($_POST['BUSINESS_DAY_STATUS']=="INACTIVE") { if ($_POST['BUSINESS_DAY_STATUS']=="INACTIVE") {
unset($_POST['BUSINESS_DAY_STATUS']); unset($_POST['BUSINESS_DAY_STATUS']);
} }
if($_POST['HOLIDAY_STATUS']=="INACTIVE") { if ($_POST['HOLIDAY_STATUS']=="INACTIVE") {
unset($_POST['HOLIDAY_STATUS']); unset($_POST['HOLIDAY_STATUS']);
} }
//] //]
@@ -286,7 +279,6 @@ class adminProxy extends HttpProxyController
G::LoadClass('calendar'); G::LoadClass('calendar');
$calendarObj=new calendar(); $calendarObj=new calendar();
$calendarObj->saveCalendarInfo($form); $calendarObj->saveCalendarInfo($form);
echo "{success: true}"; echo "{success: true}";
} }
@@ -295,21 +287,21 @@ class adminProxy extends HttpProxyController
* @param object $params * @param object $params
* @return array $data * @return array $data
*/ */
function testingOption($params){ public function testingOption($params)
{
$data['success'] = true; $data['success'] = true;
$data['optionAuthS'] = $params->optionAuthS; $data['optionAuthS'] = $params->optionAuthS;
return $data; return $data;
}// end testingOption function }
/** /**
* saving the authentication source data * saving the authentication source data
* @param object $params * @param object $params
* @return array $data * @return array $data
*/ */
function saveAuthSources($params){ public function saveAuthSources($params)
{
global $RBAC; global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) { if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
@@ -336,34 +328,31 @@ class adminProxy extends HttpProxyController
foreach ($params as $sField => $sValue) { foreach ($params as $sField => $sValue) {
if (in_array($sField, $aCommonFields)) { if (in_array($sField, $aCommonFields)) {
$aFields[$sField] = (($sField=='AUTH_SOURCE_ENABLED_TLS' || $sField=='AUTH_ANONYMOUS'))? ($sValue=='yes')?1:0 :$sValue; $aFields[$sField] = (($sField=='AUTH_SOURCE_ENABLED_TLS' || $sField=='AUTH_ANONYMOUS'))? ($sValue=='yes')?1:0 :$sValue;
} } else {
else {
$aData[$sField] = ($sValue=='Active Directory')?'ad':$sValue; $aData[$sField] = ($sValue=='Active Directory')?'ad':$sValue;
} }
} }
$aFields['AUTH_SOURCE_DATA'] = $aData; $aFields['AUTH_SOURCE_DATA'] = $aData;
if ($aFields['AUTH_SOURCE_UID'] == '') { if ($aFields['AUTH_SOURCE_UID'] == '') {
$RBAC->createAuthSource($aFields); $RBAC->createAuthSource($aFields);
} } else {
else {
$RBAC->updateAuthSource($aFields); $RBAC->updateAuthSource($aFields);
} }
$data=array(); $data=array();
$data['success'] = true; $data['success'] = true;
return $data; return $data;
}//end saveAuthSoruces function }
/** /**
* for Test email configuration * for Test email configuration
* @autor Alvaro <alvaro@colosa.com> * @autor Alvaro <alvaro@colosa.com>
*/ */
public function testConnection($params) { public function testConnection($params)
{
G::LoadClass('net'); G::LoadClass('net');
G::LoadThirdParty('phpmailer', 'class.smtp'); G::LoadThirdParty('phpmailer', 'class.smtp');
if ($_POST['typeTest'] == 'MAIL') if ($_POST['typeTest'] == 'MAIL') {
{
define("SUCCESSFUL", 'SUCCESSFUL'); define("SUCCESSFUL", 'SUCCESSFUL');
define("FAILED", 'FAILED'); define("FAILED", 'FAILED');
$mail_to = $_POST['mail_to']; $mail_to = $_POST['mail_to'];
@@ -388,9 +377,9 @@ class adminProxy extends HttpProxyController
$response = array('success' => $resp->status); $response = array('success' => $resp->status);
if ($resp->status == false) if ($resp->status == false) {
$response['msg'] = G::LoadTranslation('ID_SENDMAIL_NOT_INSTALLED'); $response['msg'] = G::LoadTranslation('ID_SENDMAIL_NOT_INSTALLED');
}
echo G::json_encode($response); echo G::json_encode($response);
die; die;
} }
@@ -437,20 +426,17 @@ class adminProxy extends HttpProxyController
$this->success = $Server->getErrno() == 0; $this->success = $Server->getErrno() == 0;
$this->msg = $this->result ? 'success' : $Server->error; $this->msg = $this->result ? 'success' : $Server->error;
break; break;
case 2: case 2:
$Server->scannPort($port); $Server->scannPort($port);
$this->success = $Server->getErrno() == 0; //'Successfull'.$smtp->status; $this->success = $Server->getErrno() == 0; //'Successfull'.$smtp->status;
$this->msg = $this->result ? '' : $Server->error; $this->msg = $this->result ? '' : $Server->error;
break; break;
case 3: //try to connect to host case 3: //try to connect to host
if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) {
$server = $hostinfo[1]; $server = $hostinfo[1];
$port = $hostinfo[2]; $port = $hostinfo[2];
} } else {
else {
$host = $srv; $host = $srv;
} }
@@ -459,17 +445,14 @@ class adminProxy extends HttpProxyController
$this->success = $smtp->Connect(($ssl ? 'ssl://':'').$server, $port, $timeout); $this->success = $smtp->Connect(($ssl ? 'ssl://':'').$server, $port, $timeout);
$this->msg = $this->result ? '' : $Server->error; $this->msg = $this->result ? '' : $Server->error;
break; break;
case 4: //try login to host case 4: //try login to host
if($auth_required == 'true') { if ($auth_required == 'true') {
try { try {
if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) {
$server = $hostinfo[1]; $server = $hostinfo[1];
$port = $hostinfo[2]; $port = $hostinfo[2];
} } else {
else {
$server = $srv; $server = $srv;
} }
if (strtoupper($UseSecureCon)=='TLS') { if (strtoupper($UseSecureCon)=='TLS') {
@@ -484,47 +467,38 @@ class adminProxy extends HttpProxyController
$ssl = (strtoupper($UseSecureCon) == 'ssl'); $ssl = (strtoupper($UseSecureCon) == 'ssl');
$server = $_POST['server']; $server = $_POST['server'];
if(strtoupper($UseSecureCon) == 'SSL') { if (strtoupper($UseSecureCon) == 'SSL') {
$resp = $smtp->Connect(('ssl://').$server, $port, $timeout); $resp = $smtp->Connect(('ssl://').$server, $port, $timeout);
} } else {
else {
$resp = $smtp->Connect($server, $port, $timeout); $resp = $smtp->Connect($server, $port, $timeout);
} }
if ($resp) { if ($resp) {
$hello = $_SERVER['SERVER_NAME']; $hello = $_SERVER['SERVER_NAME'];
$smtp->Hello($hello); $smtp->Hello($hello);
if (strtoupper($UseSecureCon) == 'TLS') { if (strtoupper($UseSecureCon) == 'TLS') {
$smtp->Hello($hello); $smtp->Hello($hello);
} }
if ( $smtp->Authenticate($user, $passwd) ) {
if( $smtp->Authenticate($user, $passwd) ) {
$this->success = true; $this->success = true;
} } else {
else {
$this->success = false; $this->success = false;
$this->msg = $smtp->error['error']; $this->msg = $smtp->error['error'];
} }
} } else {
else {
$this->success = false; $this->success = false;
$this->msg = $smtp->error['error']; $this->msg = $smtp->error['error'];
} }
} } catch (Exception $e) {
catch (Exception $e) {
$this->success = false; $this->success = false;
$this->msg = $e->getMessage(); $this->msg = $e->getMessage();
} }
} } else {
else {
$this->success = true; $this->success = true;
$this->msg = 'No authentication required!'; $this->msg = 'No authentication required!';
} }
break; break;
case 5:
case 5: //send a test mail if ($SendaTestMail == 'true') {
if($SendaTestMail == 'true') {
try { try {
$_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]'; $_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]';
$_POST['FROM_EMAIL'] = $user; $_POST['FROM_EMAIL'] = $user;
@@ -535,36 +509,29 @@ class adminProxy extends HttpProxyController
$_POST['MESS_PASSWORD'] = $passwd; $_POST['MESS_PASSWORD'] = $passwd;
$_POST['TO'] = $Mailto; $_POST['TO'] = $Mailto;
if($auth_required == 'true') { if ($auth_required == 'true') {
$_POST['SMTPAuth'] = true; $_POST['SMTPAuth'] = true;
} } else {
else {
$_POST['SMTPAuth'] = false; $_POST['SMTPAuth'] = false;
} }
if (strtolower($_POST["UseSecureCon"]) != "no") { if (strtolower($_POST["UseSecureCon"]) != "no") {
$_POST["SMTPSecure"] = $_POST["UseSecureCon"]; $_POST["SMTPSecure"] = $_POST["UseSecureCon"];
} }
if ($_POST['UseSecureCon'] == 'ssl') { if ($_POST['UseSecureCon'] == 'ssl') {
$_POST['MESS_SERVER'] = 'ssl://'.$_POST['MESS_SERVER']; $_POST['MESS_SERVER'] = 'ssl://'.$_POST['MESS_SERVER'];
} }
$resp = $this->sendTestMail(); $resp = $this->sendTestMail();
if ($resp->status == '1') { if ($resp->status == '1') {
$this->success=true; $this->success=true;
} } else {
else {
$this->success=false; $this->success=false;
$this->msg=$smtp->error['error']; $this->msg=$smtp->error['error'];
} }
} } catch (Exception $e) {
catch (Exception $e) {
$this->success = false; $this->success = false;
$this->msg = $e->getMessage(); $this->msg = $e->getMessage();
} }
} } else {
else {
$this->success=true; $this->success=true;
$this->msg='jump this step'; $this->msg='jump this step';
} }
@@ -576,8 +543,8 @@ class adminProxy extends HttpProxyController
* for send email configuration * for send email configuration
* @autor Alvaro <alvaro@colosa.com> * @autor Alvaro <alvaro@colosa.com>
*/ */
public function sendTestMail() { public function sendTestMail()
{
global $G_PUBLISH; global $G_PUBLISH;
G::LoadClass("system"); G::LoadClass("system");
G::LoadClass('spool'); G::LoadClass('spool');
@@ -590,11 +557,9 @@ class adminProxy extends HttpProxyController
case 'MAIL': case 'MAIL':
$engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1'); $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1');
break; break;
case 'PHPMAILER': case 'PHPMAILER':
$engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2'); $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2');
break; break;
case 'OPENMAIL': case 'OPENMAIL':
$engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3'); $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3');
break; break;
@@ -648,8 +613,7 @@ class adminProxy extends HttpProxyController
$o->status = true; $o->status = true;
$o->success = true; $o->success = true;
$o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS'); $o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS');
} } else {
else {
$o->status = false; $o->status = false;
$o->success = false; $o->success = false;
$o->msg = $oSpool->error; $o->msg = $oSpool->error;
@@ -661,10 +625,9 @@ class adminProxy extends HttpProxyController
* getting Save email configuration * getting Save email configuration
* @autor Alvaro <alvaro@colosa.com> * @autor Alvaro <alvaro@colosa.com>
*/ */
public function saveConfiguration() { public function saveConfiguration()
{
require_once 'classes/model/Configuration.php'; require_once 'classes/model/Configuration.php';
try { try {
$oConfiguration = new Configuration(); $oConfiguration = new Configuration();
$aFields['MESS_PASSWORD'] = $_POST['passwd']; $aFields['MESS_PASSWORD'] = $_POST['passwd'];
@@ -687,7 +650,7 @@ class adminProxy extends HttpProxyController
} }
$aFields['MESS_PASSWORD'] = $passwd; $aFields['MESS_PASSWORD'] = $passwd;
if ($aFields['MESS_PASSWORD'] != '') { // for plain text if ($aFields['MESS_PASSWORD'] != '') {
$aFields['MESS_PASSWORD'] = 'hash:'.$aFields['MESS_PASSWORD']; $aFields['MESS_PASSWORD'] = 'hash:'.$aFields['MESS_PASSWORD'];
$aFields['MESS_PASSWORD'] = G::encrypt($aFields['MESS_PASSWORD'],'EMAILENCRYPT'); $aFields['MESS_PASSWORD'] = G::encrypt($aFields['MESS_PASSWORD'],'EMAILENCRYPT');
} }
@@ -714,9 +677,9 @@ class adminProxy extends HttpProxyController
$UsrUid=''; $UsrUid='';
$AppUid=''; $AppUid='';
if($oConfiguration->exists($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid)) { if ($oConfiguration->exists($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid)) {
$oConfiguration->update( $oConfiguration->update(
array( array (
'CFG_UID' => 'Emails', 'CFG_UID' => 'Emails',
'OBJ_UID' => '', 'OBJ_UID' => '',
'CFG_VALUE' => serialize($aFields), 'CFG_VALUE' => serialize($aFields),
@@ -727,8 +690,7 @@ class adminProxy extends HttpProxyController
); );
$this->success='true'; $this->success='true';
$this->msg='Saved'; $this->msg='Saved';
} } else {
else {
$oConfiguration->create( $oConfiguration->create(
array( array(
'CFG_UID' => 'Emails', 'CFG_UID' => 'Emails',
@@ -742,8 +704,7 @@ class adminProxy extends HttpProxyController
$this->success='true'; $this->success='true';
$this->msg='Saved'; $this->msg='Saved';
} }
} } catch (Exception $e) {
catch (Exception $e) {
$this->success= false; $this->success= false;
$this->msg = $e->getMessage(); $this->msg = $e->getMessage();
} }
@@ -753,8 +714,8 @@ class adminProxy extends HttpProxyController
* loadFields for email configuration * loadFields for email configuration
* @autor Alvaro <alvaro@colosa.com> * @autor Alvaro <alvaro@colosa.com>
*/ */
public function loadFields() { public function loadFields()
{
G::loadClass('configuration'); G::loadClass('configuration');
$oConfiguration = new Configurations(); $oConfiguration = new Configurations();
@@ -796,6 +757,7 @@ class adminProxy extends HttpProxyController
G::mk_dir ( $dir ); G::mk_dir ( $dir );
$i = 0; $i = 0;
$images = array(); $images = array();
/** if we have at least one image it's load */ /** if we have at least one image it's load */
if (file_exists($dir)) { if (file_exists($dir)) {
if ($handle = opendir($dir)) { if ($handle = opendir($dir)) {
@@ -804,12 +766,9 @@ class adminProxy extends HttpProxyController
$extention = explode(".", $file); $extention = explode(".", $file);
$aImageProp = getimagesize($dir . '/' . $file, $info); $aImageProp = getimagesize($dir . '/' . $file, $info);
$sfileExtention = strtoupper($extention[count($extention)-1]); $sfileExtention = strtoupper($extention[count($extention)-1]);
if ( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) {
if( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) {
$check = (!strcmp($file, $sPhotoSelect)) ? '/images/toadd.png' : '/images/delete.png'; $check = (!strcmp($file, $sPhotoSelect)) ? '/images/toadd.png' : '/images/delete.png';
$onclick = (strcmp($file, $sPhotoSelect)) ? "onclick ='deleteLogo(\" $file \");return false;'" : ''; $onclick = (strcmp($file, $sPhotoSelect)) ? "onclick ='deleteLogo(\" $file \");return false;'" : '';
if ($i == 0) { if ($i == 0) {
$i++; $i++;
} }
@@ -831,12 +790,13 @@ class adminProxy extends HttpProxyController
echo G::json_encode($o); echo G::json_encode($o);
exit(); exit();
} }
/** /**
* Change Name logo * Change Name logo
* @param type $snameLogo * @param type $snameLogo
* @return type $snameLogo * @return type $snameLogo
*/ */
function changeNamelogo($snameLogo) public function changeNamelogo($snameLogo)
{ {
$snameLogo = preg_replace("/[áàâãª]/", "a", $snameLogo); $snameLogo = preg_replace("/[áàâãª]/", "a", $snameLogo);
$snameLogo = preg_replace("/[ÁÀÂÃ]/", "A", $snameLogo); $snameLogo = preg_replace("/[ÁÀÂÃ]/", "A", $snameLogo);
@@ -854,6 +814,7 @@ class adminProxy extends HttpProxyController
$snameLogo = str_replace( "[Ñ]", "N", $snameLogo); $snameLogo = str_replace( "[Ñ]", "N", $snameLogo);
return ($snameLogo); return ($snameLogo);
} }
/** /**
* Create Thumb * Create Thumb
* @param type $img_file * @param type $img_file
@@ -861,7 +822,7 @@ class adminProxy extends HttpProxyController
* @param type $thumb_path * @param type $thumb_path
* @param type $img_type * @param type $img_type
*/ */
function createThumb($img_file, $ori_path, $thumb_path, $img_type) public function createThumb($img_file, $ori_path, $thumb_path, $img_type)
{ {
$path = $ori_path; $path = $ori_path;
$img = $path.$img_file; $img = $path.$img_file;
@@ -890,14 +851,14 @@ class adminProxy extends HttpProxyController
// square // square
$tmp_width = $square_size; $tmp_width = $square_size;
$tmp_height = $square_size; $tmp_height = $square_size;
} else if ($img_height < $img_width) { } elseif ($img_height < $img_width) {
// wide // wide
$tmp_height = $square_size; $tmp_height = $square_size;
$tmp_width = intval(($img_width / $img_height) * $square_size); $tmp_width = intval(($img_width / $img_height) * $square_size);
if ($tmp_width % 2 != 0) { if ($tmp_width % 2 != 0) {
$tmp_width++; $tmp_width++;
} }
} else if ($img_height > $img_width) { } elseif ($img_height > $img_width) {
$tmp_width = $square_size; $tmp_width = $square_size;
$tmp_height = intval(($img_height / $img_width) * $square_size); $tmp_height = intval(($img_height / $img_width) * $square_size);
if (($tmp_height % 2) != 0) { if (($tmp_height % 2) != 0) {
@@ -946,10 +907,8 @@ class adminProxy extends HttpProxyController
$img_thumb_square = imagecreatefromgif($thumb); $img_thumb_square = imagecreatefromgif($thumb);
break; break;
} }
$thumb_width = imagesx($img_thumb_square); $thumb_width = imagesx($img_thumb_square);
$thumb_height = imagesy($img_thumb_square); $thumb_height = imagesy($img_thumb_square);
if ($thumb_height < $thumb_width) { if ($thumb_height < $thumb_width) {
// wide // wide
$x_src = ($thumb_width - $square_size) / 2; $x_src = ($thumb_width - $square_size) / 2;
@@ -957,16 +916,14 @@ class adminProxy extends HttpProxyController
$img_final = imagecreatetruecolor($square_size, $square_size); $img_final = imagecreatetruecolor($square_size, $square_size);
imagecopy($img_final, $img_thumb_square, 0, 0, imagecopy($img_final, $img_thumb_square, 0, 0,
$x_src, $y_src, $square_size, $square_size); $x_src, $y_src, $square_size, $square_size);
} } elseif ($thumb_height > $thumb_width) {
else if ($thumb_height > $thumb_width) {
// landscape // landscape
$x_src = 0; $x_src = 0;
$y_src = ($thumb_height - $square_size) / 2; $y_src = ($thumb_height - $square_size) / 2;
$img_final = imagecreatetruecolor($square_size, $square_size); $img_final = imagecreatetruecolor($square_size, $square_size);
imagecopy($img_final, $img_thumb_square, 0, 0, imagecopy($img_final, $img_thumb_square, 0, 0,
$x_src, $y_src, $square_size, $square_size); $x_src, $y_src, $square_size, $square_size);
} } else {
else {
$img_final = imagecreatetruecolor($square_size, $square_size); $img_final = imagecreatetruecolor($square_size, $square_size);
imagecopy($img_final, $img_thumb_square, 0, 0, imagecopy($img_final, $img_thumb_square, 0, 0,
0, 0, $square_size, $square_size); 0, 0, $square_size, $square_size);
@@ -995,7 +952,7 @@ class adminProxy extends HttpProxyController
* Upload Image * Upload Image
* @global type $_FILES * @global type $_FILES
*/ */
function uploadImage() public function uploadImage()
{ {
//!dataSystem //!dataSystem
$ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]);
@@ -1028,7 +985,6 @@ class adminProxy extends HttpProxyController
if (in_array($_FILES['img']['type'], $allowedType)) { if (in_array($_FILES['img']['type'], $allowedType)) {
// max upload file is 500 KB // max upload file is 500 KB
if ($_FILES['img']['size'] <= 500000) { if ($_FILES['img']['size'] <= 500000) {
$formf = $_FILES['img']; $formf = $_FILES['img'];
$namefile = $formf['name']; $namefile = $formf['name'];
$typefile = $formf['type']; $typefile = $formf['type'];
@@ -1037,43 +993,34 @@ class adminProxy extends HttpProxyController
$aMessage1 = array(); $aMessage1 = array();
$fileName = trim(str_replace(' ', '_', $namefile)); $fileName = trim(str_replace(' ', '_', $namefile));
$fileName = self::changeNamelogo($fileName); $fileName = self::changeNamelogo($fileName);
G::uploadFile($tmpFile, $dir, 'tmp' . $fileName); G::uploadFile($tmpFile, $dir, 'tmp' . $fileName);
try { try {
if (extension_loaded('exif')) { if (extension_loaded('exif')) {
$typeMime = exif_imagetype($dir . '/'. 'tmp'.$fileName); $typeMime = exif_imagetype($dir . '/'. 'tmp'.$fileName);
} } else {
else {
$arrayInfo = getimagesize($dir . '/' . 'tmp' . $fileName); $arrayInfo = getimagesize($dir . '/' . 'tmp' . $fileName);
$typeMime = $arrayInfo[2]; $typeMime = $arrayInfo[2];
} }
if ($typeMime == $allowedTypeArray['index' . base64_encode($_FILES['img']['type'])]) { if ($typeMime == $allowedTypeArray['index' . base64_encode($_FILES['img']['type'])]) {
$error = false; $error = false;
try { try {
list($imageWidth, $imageHeight, $imageType) = @getimagesize($dir . '/' . 'tmp' . $fileName); list($imageWidth, $imageHeight, $imageType) = @getimagesize($dir . '/' . 'tmp' . $fileName);
G::resizeImage($dir . '/tmp' . $fileName, $imageWidth, 49, $dir . '/' . $fileName); G::resizeImage($dir . '/tmp' . $fileName, $imageWidth, 49, $dir . '/' . $fileName);
} } catch (Exception $e) {
catch (Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
} }
$uploaded++; $uploaded++;
} } else {
else {
$failed = "3"; $failed = "3";
} }
unlink ($dir . '/tmp' . $fileName); unlink ($dir . '/tmp' . $fileName);
} } catch (Exception $e) {
catch (Exception $e) {
$failed = "3"; $failed = "3";
} }
} } else {
else {
$failed = "2"; $failed = "2";
} }
} } elseif ($_FILES['img']['type'] != '') {
else if ($_FILES['img']['type'] != '') {
$failed = "1"; $failed = "1";
} }
@@ -1085,7 +1032,7 @@ class adminProxy extends HttpProxyController
* Get Name Current Logo * Get Name Current Logo
* @return type * @return type
*/ */
function getNameCurrentLogo() public function getNameCurrentLogo()
{ {
G::LoadClass('replacementLogo'); G::LoadClass('replacementLogo');
$upload = new replacementLogo(); $upload = new replacementLogo();
@@ -1099,12 +1046,12 @@ class adminProxy extends HttpProxyController
* @param type $selectLogo * @param type $selectLogo
* @return type int value * @return type int value
*/ */
function isCurrentLogo() public function isCurrentLogo()
{ {
$arrayImg = explode(";", $_POST['selectLogo']); $arrayImg = explode(";", $_POST['selectLogo']);
foreach ($arrayImg as $imgname) { foreach ($arrayImg as $imgname) {
if ($imgname != "") { if ($imgname != "") {
if( strcmp($imgname, self::getNameCurrentLogo()) == 0 ) { if ( strcmp($imgname, self::getNameCurrentLogo()) == 0 ) {
echo '{success: true}'; echo '{success: true}';
exit(); exit();
} }
@@ -1120,7 +1067,7 @@ class adminProxy extends HttpProxyController
* @param * @param
* @return string '{success: true | false}' * @return string '{success: true | false}'
*/ */
function deleteImage() public function deleteImage()
{ {
//!dataSystem //!dataSystem
$ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]);
@@ -1134,15 +1081,14 @@ class adminProxy extends HttpProxyController
$arrayImg = explode(";", $_POST['images']); $arrayImg = explode(";", $_POST['images']);
foreach ($arrayImg as $imgname) { foreach ($arrayImg as $imgname) {
if ($imgname != "") { if ($imgname != "") {
if( strcmp($imgname, self::getNameCurrentLogo()) != 0 ) { if ( strcmp($imgname, self::getNameCurrentLogo()) != 0 ) {
if(file_exists($dir . '/' . $imgname)) { if (file_exists($dir . '/' . $imgname)) {
unlink ($dir . '/' . $imgname); unlink ($dir . '/' . $imgname);
} }
if(file_exists($dir . '/tmp' . $imgname)) { if (file_exists($dir . '/tmp' . $imgname)) {
unlink ($dir . '/tmp' . $imgname); unlink ($dir . '/tmp' . $imgname);
} }
} } else {
else {
echo '{success: false}'; echo '{success: false}';
exit(); exit();
} }
@@ -1157,13 +1103,13 @@ class adminProxy extends HttpProxyController
* @global type $_REQUEST * @global type $_REQUEST
* @global type $RBAC * @global type $RBAC
*/ */
function replacementLogo() public function replacementLogo()
{ {
global $_REQUEST; global $_REQUEST;
$sfunction = $_REQUEST['nameFunction']; $sfunction = $_REQUEST['nameFunction'];
$_GET['NAMELOGO'] = $_REQUEST['NAMELOGO']; $_GET['NAMELOGO'] = $_REQUEST['NAMELOGO'];
try {//ini_set('display_errors','1'); try {
global $RBAC; global $RBAC;
switch ($RBAC->userCanAccess('PM_LOGIN')) { switch ($RBAC->userCanAccess('PM_LOGIN')) {
case -2: case -2:
@@ -1210,8 +1156,7 @@ class adminProxy extends HttpProxyController
G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels'); G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels');
break; break;
} }
} } catch (Exception $oException) {
catch (Exception $oException) {
die($oException->getMessage()); die($oException->getMessage());
} }
exit(); exit();
@@ -1221,7 +1166,7 @@ class adminProxy extends HttpProxyController
* Show Logo * Show Logo
* @param type $imagen * @param type $imagen
*/ */
function showLogo($imagen) public function showLogo($imagen)
{ {
$info = @getimagesize($imagen); $info = @getimagesize($imagen);
$fp = fopen($imagen, "rb"); $fp = fopen($imagen, "rb");
@@ -1229,8 +1174,7 @@ class adminProxy extends HttpProxyController
header("Content-type: {$info['mime']}"); header("Content-type: {$info['mime']}");
fpassthru($fp); fpassthru($fp);
exit; exit;
} } else {
else {
throw new Exception("Image format not valid"); throw new Exception("Image format not valid");
} }
} }
@@ -1240,7 +1184,7 @@ class adminProxy extends HttpProxyController
* @param type $dir * @param type $dir
* @param type $newDir * @param type $newDir
*/ */
function cpyMoreLogos($dir,$newDir) public function cpyMoreLogos($dir, $newDir)
{ {
if (file_exists($dir)) { if (file_exists($dir)) {
if (($handle = opendir($dir))) { if (($handle = opendir($dir))) {
@@ -1250,7 +1194,6 @@ class adminProxy extends HttpProxyController
$aImageProp = getimagesize($dir . '/' . $file, $info); $aImageProp = getimagesize($dir . '/' . $file, $info);
$sfileExtention = strtoupper($extention[count($extention)-1]); $sfileExtention = strtoupper($extention[count($extention)-1]);
if ( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) { if ( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) {
$dir1 = $dir . PATH_SEP . $file; $dir1 = $dir . PATH_SEP . $file;
$dir2 = $newDir . PATH_SEP . $file; $dir2 = $newDir . PATH_SEP . $file;
copy($dir1, $dir2); copy($dir1, $dir2);
@@ -1265,7 +1208,7 @@ class adminProxy extends HttpProxyController
/** /**
* Show Logo File * Show Logo File
*/ */
function showLogoFile() public function showLogoFile()
{ {
$_GET['id'] = $_REQUEST['id']; $_GET['id'] = $_REQUEST['id'];
@@ -1276,16 +1219,13 @@ class adminProxy extends HttpProxyController
if (is_file($imagen)) { if (is_file($imagen)) {
self::showLogo($imagen); self::showLogo($imagen);
} } else {
else {
$newDir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos"; $newDir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos";
$dir = PATH_HOME . "public_html/files/logos"; $dir = PATH_HOME . "public_html/files/logos";
if (!is_dir($newDir)) { if (!is_dir($newDir)) {
G::mk_dir($newDir); G::mk_dir($newDir);
} }
//this function does copy all logos from public_html/files/logos to /shared/site/yourSite/files/logos
//cpyMoreLogos($dir,$newDir);
$newDir .= PATH_SEP.$base64Id; $newDir .= PATH_SEP.$base64Id;
$dir .= PATH_SEP.$base64Id; $dir .= PATH_SEP.$base64Id;
copy($dir,$newDir); copy($dir,$newDir);
@@ -1295,5 +1235,5 @@ class adminProxy extends HttpProxyController
die; die;
exit(); exit();
} }
} }