public function render($width = 300)
 {
     $self->url = $this->urlFrom;
     $self->rss = @simplexml_load_file($self->url);
     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);
 }
Пример #2
0
function saveLog($sSource, $sType, $sDescription)
{
    try {
        global $sObject;
        global $isDebug;
        if ($isDebug) {
            print date("H:i:s") . " ({$sSource}) {$sType} {$sDescription} <br />\n";
        }
        G::verifyPath(PATH_DATA . "log" . PATH_SEP, true);
        //setExecutionMessage( PATH_DATA."log".PATH_SEP);
        $oFile = @fopen(PATH_DATA . "log" . PATH_SEP . "cron.log", "a+");
        @fwrite($oFile, date("Y-m-d H:i:s") . " | {$sObject} | " . $sSource . " | {$sType} | " . $sDescription . "\n");
        @fclose($oFile);
    } catch (Exception $e) {
        //CONTINUE
    }
}
Пример #3
0
 private function _default()
 {
     require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php';
     // put full path to Smarty.class.php
     global $G_ENABLE_BLANK_SKIN;
     //menu
     global $G_PUBLISH;
     global $G_MAIN_MENU;
     global $G_SUB_MENU;
     global $G_MENU_SELECTED;
     global $G_SUB_MENU_SELECTED;
     global $G_ID_MENU_SELECTED;
     global $G_ID_SUB_MENU_SELECTED;
     G::verifyPath(PATH_SMARTY_C, true);
     G::verifyPath(PATH_SMARTY_CACHE, true);
     $smarty = new Smarty();
     $oHeadPublisher =& headPublisher::getSingleton();
     $smarty->compile_dir = PATH_SMARTY_C;
     $smarty->cache_dir = PATH_SMARTY_CACHE;
     $smarty->config_dir = PATH_THIRDPARTY . 'smarty/configs';
     //To setup en extJS Theme for this Skin
     G::LoadClass('serverConfiguration');
     $oServerConf =& serverConf::getSingleton();
     $extSkin = $oServerConf->getProperty("extSkin");
     if (!$extSkin) {
         $extSkin = array();
     }
     $extSkin[SYS_SKIN] = "xtheme-gray";
     $oServerConf->setProperty("extSkin", $extSkin);
     //End of extJS Theme setup
     if (isset($G_ENABLE_BLANK_SKIN) && $G_ENABLE_BLANK_SKIN) {
         $smarty->template_dir = $this->layoutFileBlank['dirname'];
         $smarty->force_compile = $this->forceTemplateCompile;
         $smarty->display($layoutFileBlank['basename']);
     } else {
         $smarty->template_dir = $this->layoutFile['dirname'];
         $meta = null;
         $header = null;
         if (preg_match("/^.*\\(.*MSIE (\\d+)\\..+\\).*\$/", $_SERVER["HTTP_USER_AGENT"], $arrayMatch)) {
             $ie = intval($arrayMatch[1]);
             if ($ie == 10) {
                 $ie = 8;
                 $meta = "<meta http-equiv=\"X-UA-Compatible\" content=\"IE={$ie}\" />";
             }
         }
         if (isset($oHeadPublisher)) {
             if (defined('SYS_SYS')) {
                 $oHeadPublisher->title = isset($_SESSION['USR_USERNAME']) ? '(' . $_SESSION['USR_USERNAME'] . ' ' . G::LoadTranslation('ID_IN') . ' ' . SYS_SYS . ')' : '';
             }
             $header = $oHeadPublisher->printHeader();
             $header .= $oHeadPublisher->getExtJsStylesheets($this->cssFileName);
         }
         $smarty->assign("meta", $meta);
         $smarty->assign("header", $header);
         $footer = '';
         if (strpos($_SERVER['REQUEST_URI'], '/login/login') !== false) {
             $freeOfChargeText = "";
             if (!defined('SKIP_FREE_OF_CHARGE_TEXT')) {
                 $freeOfChargeText = "Supplied free of charge with no support, certification, warranty, <br>maintenance nor indemnity by Colosa and its Certified Partners.";
             }
             if (class_exists('pmLicenseManager')) {
                 $freeOfChargeText = "";
             }
             $fileFooter = PATH_SKINS . SYS_SKIN . PATH_SEP . 'footer.html';
             if (file_exists($fileFooter)) {
                 $footer .= file_get_contents($fileFooter);
             } else {
                 $fileFooter = PATH_SKIN_ENGINE . SYS_SKIN . PATH_SEP . 'footer.html';
                 if (file_exists($fileFooter)) {
                     $footer .= file_get_contents($fileFooter);
                 } else {
                     $fileFooter = PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . 'footer.html';
                     if (file_exists($fileFooter)) {
                         $footer .= file_get_contents($fileFooter);
                     } else {
                         $footer .= "<br />Copyright &copy; 2003-" . date('Y') . " <a href=\"http://www.colosa.com\" alt=\"Colosa, Inc.\" target=\"_blank\">Colosa, Inc.</a> All rights reserved.<br /> {$freeOfChargeText} " . "<br><br/><a href=\"http://www.processmaker.com\" alt=\"Powered by ProcessMaker - Open Source Workflow & Business Process Management (BPM) Management Software\" title=\"Powered by ProcessMaker\" target=\"_blank\"></a>";
                     }
                 }
             }
         }
         $oMenu = new Menu();
         $menus = $oMenu->generateArrayForTemplate($G_MAIN_MENU, 'SelectedMenu', 'mainMenu', $G_MENU_SELECTED, $G_ID_MENU_SELECTED);
         $smarty->assign('menus', $menus);
         $oSubMenu = new Menu();
         $subMenus = $oSubMenu->generateArrayForTemplate($G_SUB_MENU, 'selectedSubMenu', 'subMenu', $G_SUB_MENU_SELECTED, $G_ID_SUB_MENU_SELECTED);
         $smarty->assign('subMenus', $subMenus);
         if (!defined('NO_DISPLAY_USERNAME')) {
             define('NO_DISPLAY_USERNAME', 0);
         }
         if (NO_DISPLAY_USERNAME == 0) {
             $switch_interface = isset($_SESSION['user_experience']) && $_SESSION['user_experience'] == 'SWITCHABLE';
             $smarty->assign('user_logged', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '');
             $smarty->assign('tracker', SYS_COLLECTION == 'tracker' ? $G_PUBLISH->Parts[0]['File'] != 'tracker/login' ? true : '' : '');
             $smarty->assign('switch_interface', $switch_interface);
             $smarty->assign('switch_interface_label', G::LoadTranslation('ID_SWITCH_INTERFACE'));
             $smarty->assign('rolename', isset($_SESSION['USR_ROLENAME']) ? $_SESSION['USR_ROLENAME'] . '' : '');
             $smarty->assign('pipe', isset($_SESSION['USR_USERNAME']) ? ' | ' : '');
             $smarty->assign('logout', G::LoadTranslation('ID_LOGOUT'));
             $smarty->assign('workspace', defined('SYS_SYS') ? SYS_SYS : '');
             $uws = isset($_SESSION['USR_ROLENAME']) && $_SESSION['USR_ROLENAME'] != '' ? strtolower(G::LoadTranslation('ID_WORKSPACE_USING')) : G::LoadTranslation('ID_WORKSPACE_USING');
             $smarty->assign('workspace_label', $uws);
             G::LoadClass("configuration");
             $conf = new Configurations();
             $conf->getFormats();
             if (defined('SYS_SYS')) {
                 $smarty->assign('udate', $conf->getSystemDate(date('Y-m-d H:i:s')));
             } else {
                 $smarty->assign('udate', G::getformatedDate(date('Y-m-d H:i:s'), 'M d, yyyy', SYS_LANG));
             }
             $name = $conf->userNameFormat(isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '', isset($_SESSION['USR_FULLNAME']) ? htmlentities($_SESSION['USR_FULLNAME'], ENT_QUOTES, 'UTF-8') : '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '');
             $smarty->assign('user', $name);
         }
         if (class_exists('pmLicenseManager')) {
             $pmLicenseManagerO =& pmLicenseManager::getSingleton();
             $expireIn = $pmLicenseManagerO->getExpireIn();
             $expireInLabel = $pmLicenseManagerO->getExpireInLabel();
             //if($expireIn<=30){
             if ($expireInLabel != "") {
                 $smarty->assign('msgVer', '<label class="textBlack">' . $expireInLabel . '</label>&nbsp;&nbsp;');
             }
             //}
         }
         if (defined('SYS_SYS')) {
             $logout = '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/login/login';
         } else {
             $logout = '/sys/' . SYS_LANG . '/' . SYS_SKIN . '/login/login';
         }
         $smarty->assign('linklogout', $logout);
         $smarty->assign('footer', $footer);
         $smarty->assign('tpl_menu', PATH_TEMPLATE . 'menu.html');
         $smarty->assign('tpl_submenu', PATH_TEMPLATE . 'submenu.html');
         G::LoadClass('replacementLogo');
         $oLogoR = new replacementLogo();
         if (defined("SYS_SYS")) {
             $aFotoSelect = $oLogoR->getNameLogo(isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '');
             if (is_array($aFotoSelect)) {
                 $sFotoSelect = trim($aFotoSelect['DEFAULT_LOGO_NAME']);
                 $sWspaceSelect = trim($aFotoSelect['WORKSPACE_LOGO_NAME']);
             }
         }
         if (class_exists('PMPluginRegistry')) {
             $oPluginRegistry =& PMPluginRegistry::getSingleton();
             if (isset($sFotoSelect) && $sFotoSelect != '' && !strcmp($sWspaceSelect, SYS_SYS)) {
                 $sCompanyLogo = $oPluginRegistry->getCompanyLogo($sFotoSelect);
                 $sCompanyLogo = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/setup/showLogoFile.php?id=" . base64_encode($sCompanyLogo);
             } else {
                 $sCompanyLogo = $oPluginRegistry->getCompanyLogo('/images/processmaker.logo.jpg');
             }
         } else {
             $sCompanyLogo = '/images/processmaker.logo.jpg';
         }
         $smarty->assign('logo_company', $sCompanyLogo);
         $smarty->force_compile = $this->forceTemplateCompile;
         $smarty->display($this->layoutFile['basename']);
     }
 }
Пример #4
0
 /**
  * Upload a file and then copy to path+ nameToSave
  *
  * @author Mauricio Veliz <*****@*****.**>
  * @access public
  * @param string $file
  * @param string $path
  * @param string $nameToSave
  * @param integer $permission
  * @return void
  */
 public static function uploadFile($file, $path, $nameToSave, $permission = 0755)
 {
     try {
         if ($file == '') {
             throw new Exception('The filename is empty!');
         }
         if (filesize($file) > (ini_get('upload_max_filesize') + 0) * 1024 * 1024) {
             throw new Exception('The size of upload file exceeds the allowed by the server!');
         }
         $oldumask = umask(0);
         if (!is_dir($path)) {
             G::verifyPath($path, true);
         }
         if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
             $file = str_replace("\\\\", "\\", $file, $count);
             if (!$count) {
                 $winPath = explode("\\", $file);
                 $file = "";
                 foreach ($winPath as $k => $v) {
                     if ($v != "") {
                         $file .= $v . "\\";
                     }
                 }
                 $file = substr($file, 0, -1);
             }
         }
         G::LoadSystem('inputfilter');
         $filter = new InputFilter();
         $file = $filter->validateInput($file, "path");
         $path = $filter->validateInput($path, "path");
         move_uploaded_file($file, $path . "/" . $nameToSave);
         $nameToSave = $filter->validateInput($nameToSave, "path");
         @chmod($path . "/" . $nameToSave, $permission);
         umask($oldumask);
     } catch (Exception $oException) {
         throw $oException;
     }
 }
Пример #5
0
 /**
  * With this function we can rename a files
  * @param string $sSouce
  * @param string $sTarget
  * @param string $bSourceAbsolutePath
  * @param string $bTargetAbsolutePath
  * @return void
  */
 public function rename($sSouce, $sTarget, $bSourceAbsolutePath = false, $bTargetAbsolutePath = false)
 {
     if (!$bSourceAbsolutePath) {
         $sSouce = PATH_PLUGINS . $this->sPluginFolder . PATH_SEP . $sSouce;
     }
     if (!$bTargetAbsolutePath) {
         $sTarget = PATH_PLUGINS . $this->sPluginFolder . PATH_SEP . $sTarget;
     }
     G::verifyPath(dirname($sTarget), true);
     @chmod(dirname($sTarget), 0777);
     @rename($sSouce, $sTarget);
 }
    }
    $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
    $rs->next();
    $totalCount = 0;
    for ($j = 0; $j < $rs->getRecordCount(); $j++) {
        $result = $rs->getRow();
        $result["FILEDOCEXIST"] = casesShowOuputDocumentExist($result["FILEDOC"]);
        $result["FILEPDFEXIST"] = casesShowOuputDocumentExist($result["FILEPDF"]);
        $aProcesses[] = $result;
        $rs->next();
        $totalCount++;
    }
    //!dateFormat
    G::LoadClass('configuration');
    $conf = new Configurations();
    try {
        $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
    } catch (Exception $e) {
        $generalConfCasesList = array();
    }
    $dateFormat = "";
    if (isset($generalConfCasesList['casesListDateFormat']) && !empty($generalConfCasesList['casesListDateFormat'])) {
        $dateFormat = $generalConfCasesList['casesListDateFormat'];
    }
    $newDir = '/tmp/test/directory';
    $r = G::verifyPath($newDir);
    $r->data = $aProcesses;
    $r->totalCount = $totalCount;
    $r->dataFormat = $dateFormat;
    echo G::json_encode($r);
}
Пример #7
0
    public function getProcessFiles ($proUid, $type)

    {

        $filesList = array ();



        switch ($type) {

            case "mail":

            case "email":

                $basePath = PATH_DATA_MAILTEMPLATES;

                break;

            case "public":

                $basePath = PATH_DATA_PUBLIC;

                break;

            default:

                throw new Exception( "Unknow Process Files Type \"$type\"." );

                break;

        }



        $dir = $basePath . $proUid . PATH_SEP;



        G::verifyPath( $dir, true ); //Create if it does not exist





        //Creating the default template (if not exists)

        if (! file_exists( $dir . "alert_message.html" )) {

            @copy( PATH_TPL . "mails" . PATH_SEP . "alert_message.html", $dir . "alert_message.html" );

        }



        if ( (!file_exists( $dir . "unassignedMessage.html")) && file_exists($dir . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) {

            if (defined('PARTNER_FLAG')) {

                @copy( PATH_TPL . "mails" . PATH_SEP . "unassignedMessagePartner.html", $dir . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'));

            } else {

                @copy( PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $dir . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'));

            }

        }



        $files = glob( $dir . "*.*" );



        foreach ($files as $file) {

            $fileName = basename( $file );



            if ($fileName != "alert_message.html" && $fileName != G::LoadTranslation('ID_UNASSIGNED_MESSAGE')) {

                $filesList[] = array ("filepath" => $file,"filename" => $fileName);

            }

        }

        return $filesList;

    }
Пример #8
0
                break;
        }
        $paramBCC[] = array('id' => replaceQuotes($item), 'name' => $value);
    }
    $_DBArray['eventomsgbcc'] = $paramBCC;
} else {
    $_DBArray['eventomsgbcc'] = array();
}
$aFields['EVN_MESSAGE_TO_TO'] = $paramTO;
$aFields['EVN_MESSAGE_TO_CC'] = isset($parameters->CC) ? $paramCC : '';
$aFields['EVN_MESSAGE_TO_BCC'] = isset($parameters->BCC) ? $paramBCC : '';
$aFields['EVN_MESSAGE_TEMPLATE'] = isset($parameters->TEMPLATE) ? $parameters->TEMPLATE : '';
$aTemplates = array();
$aTemplates[] = array('TEMPLATE1' => 'char', 'TEMPLATE2' => 'char');
$sDirectory = PATH_DATA_MAILTEMPLATES . $aFields['PRO_UID'] . PATH_SEP;
G::verifyPath($sDirectory, true);
if (!file_exists($sDirectory . 'alert_message.html')) {
    @copy(PATH_TPL . 'mails' . PATH_SEP . 'alert_message.html', $sDirectory . 'alert_message.html');
}
$oDirectory = dir($sDirectory);
while ($sObject = $oDirectory->read()) {
    if ($sObject !== '.' && $sObject !== '..' && $sObject !== 'alert_message.html') {
        $aTemplates[] = array('TEMPLATE1' => $sObject, 'TEMPLATE2' => $sObject);
    }
}
$_DBArray['templates'] = $aTemplates;
$aTriggers[] = array('TRI_UID' => 'char', 'TRI_TITLE' => 'char');
G::LoadClass('processMap');
$oProcessMap = new ProcessMap();
$oDataset = TriggersPeer::doSelectRS($oProcessMap->getTriggersCriteria($aFields['PRO_UID']));
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
Пример #9
0
 public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "")
 {
     try {
         $applicationData = $this->loadCase($sApplicationUID);
         $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"];
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]);
                 $passwd = $aConfiguration["MESS_PASSWORD"];
                 $passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
                 $auxPass = explode('hash:', $passwdDec);
                 if (count($auxPass) > 1) {
                     if (count($auxPass) == 2) {
                         $passwd = $auxPass[1];
                     } else {
                         array_shift($auxPass);
                         $passwd = implode('', $auxPass);
                     }
                 }
                 $aConfiguration["MESS_PASSWORD"] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         //Send derivation notification - Start
         $oTask = new Task();
         $aTaskInfo = $oTask->load($sCurrentTask);
         if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') {
             return false;
         }
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match);
         if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
             if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
                 $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
             } else {
                 if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                     $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
                 } else {
                     if ($aConfiguration['MESS_SERVER'] != '') {
                         if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                             $sFrom .= ' <info@' . $sAux . '>';
                         } else {
                             $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                         }
                     } else {
                         $sFrom .= ' <*****@*****.**>';
                     }
                 }
             }
         }
         if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {
             $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields);
         } else {
             $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');
         }
         //erik: new behaviour for messages
         G::loadClass('configuration');
         $oConf = new Configurations();
         $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
         $conf = $oConf->aConfig;
         $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP;
         $swtplDefault = 0;
         $sBody = null;
         if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") {
             if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") {
                 $swtplDefault = 1;
             }
             $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"];
             if (!file_exists($fileTemplate)) {
                 throw new Exception("Template file \"{$fileTemplate}\" does not exist.");
             }
             $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields);
         } else {
             $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields));
         }
         G::LoadClass("tasks");
         G::LoadClass("groups");
         G::LoadClass("spool");
         $task = new Tasks();
         $group = new Groups();
         $oUser = new Users();
         foreach ($aTasks as $aTask) {
             $sTo = null;
             $sCc = null;
             switch ($aTask["TAS_ASSIGN_TYPE"]) {
                 case "SELF_SERVICE":
                     if ($swtplDefault == 1) {
                         G::verifyPath($pathEmail, true);
                         //Create if it does not exist
                         $fileTemplate = $pathEmail . "unassignedMessage.html";
                         if (!file_exists($fileTemplate)) {
                             @copy(PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $fileTemplate);
                         }
                         $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
                     }
                     if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {
                         $arrayTaskUser = array();
                         $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayGroup) {
                             $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]);
                             foreach ($arrayAux2 as $arrayUser) {
                                 $arrayTaskUser[] = $arrayUser["USR_UID"];
                             }
                         }
                         $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayUser) {
                             $arrayTaskUser[] = $arrayUser["USR_UID"];
                         }
                         $criteria = new Criteria("workflow");
                         $criteria->addSelectColumn(UsersPeer::USR_UID);
                         $criteria->addSelectColumn(UsersPeer::USR_USERNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_EMAIL);
                         $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN);
                         $rsCriteria = UsersPeer::doSelectRs($criteria);
                         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                         $to = null;
                         $cc = null;
                         $sw = 1;
                         while ($rsCriteria->next()) {
                             $row = $rsCriteria->getRow();
                             $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">";
                             if ($sw == 1) {
                                 $to = $toAux;
                                 $sw = 0;
                             } else {
                                 $cc = $cc . ($cc != null ? "," : null) . $toAux;
                             }
                         }
                         $sTo = $to;
                         $sCc = $cc;
                     }
                     break;
                 default:
                     if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
                         $aUser = $oUser->load($aTask["USR_UID"]);
                         $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">";
                     }
                     break;
             }
             if ($sTo != null) {
                 $oSpool = new spoolRun();
                 if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
                     $aConfiguration['MESS_RAUTH'] = 0;
                 } else {
                     $aConfiguration['MESS_RAUTH'] = 1;
                 }
                 $oSpool->setConfig(array("MESS_ENGINE" => $aConfiguration["MESS_ENGINE"], "MESS_SERVER" => $aConfiguration["MESS_SERVER"], "MESS_PORT" => $aConfiguration["MESS_PORT"], "MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"], "MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"], "SMTPAuth" => $aConfiguration["MESS_RAUTH"] == "1" ? true : false, "SMTPSecure" => isset($aConfiguration["SMTPSecure"]) ? $aConfiguration["SMTPSecure"] : ""));
                 $oSpool->create(array("msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending"));
                 if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") {
                     $oSpool->sendMail();
                 }
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
Пример #10
0
    /**

     * set_partner

     *

     * @return void

     */

    public function setPartner()

    {

        $partnerFlag = (defined('PARTNER_FLAG')) ? PARTNER_FLAG : false;

        if ($partnerFlag) {

            // Execute sql for partner

            $pathMysqlPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'mysql' . PATH_SEP;

            if (G::verifyPath($pathMysqlPartner)) {

                $res = array();

                $filesSlq = glob($pathMysqlPartner . '*.sql');

                foreach ($filesSlq as $value) {

                    $this->query_sql_file($value, $this->connection_database);

                }

            }



            // Execute to change of skin

            $pathSkinPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'skin' . PATH_SEP;

            if (G::verifyPath($pathSkinPartner)) {

                $res = array();

                $fileTar = glob($pathSkinPartner . '*.tar');

                foreach ($fileTar as $value) {

                    $dataFile = pathinfo($value);

                    $nameSkinTmp = $dataFile['filename'];

                    G::LoadThirdParty( 'pear/Archive', 'Tar' );

                    $tar = new Archive_Tar( $value );



                    $pathSkinTmp = $pathSkinPartner . 'tmp' . PATH_SEP;

                    G::rm_dir($pathSkinTmp);

                    G::verifyPath($pathSkinTmp, true);

                    chmod( $pathSkinTmp, 0777);

                    $tar->extract($pathSkinTmp);



                    $pathSkinName = $pathSkinTmp . $nameSkinTmp . PATH_SEP;

                    chmod( $pathSkinName, 0777);

                    G::verifyPath(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', true);

                    $skinClassic = PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp' . PATH_SEP;



                    if (is_dir($pathSkinName)) {

                        $this->copyFile($pathSkinName, $skinClassic);

                    }



                    G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'base');

                    rename(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', PATH_CORE . 'skinEngine' . PATH_SEP . 'base');

                    G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp');



                    break;

                }

            }



            //ACTIVE ENTERPRISE



            ini_set('max_execution_time', '0');

            ini_set('memory_limit', '256M');



            $serv = 'http://';

            if (isset($_SERVER['HTTPS']) && trim($_SERVER['HTTPS']) != '') {

                $serv = 'https://';

            }

            $serv .= $_SERVER['SERVER_NAME'];

            if (isset($_SERVER['SERVER_PORT']) && trim($_SERVER['SERVER_PORT']) != '') {

                $serv .= ':' . $_SERVER['SERVER_PORT'];

            }



            // create session

            $cookiefile =  sys_get_temp_dir() . PATH_SEP . 'curl-session';



            $fp = fopen($cookiefile, "w");

            fclose($fp);

            chmod($cookiefile, 0777);



            $user = urlencode($this->options['admin']['username']);

            $pass = urlencode($this->options['admin']['password']);

            $workspace = $this->options['name'];

            $lang = SYS_LANG;

            $skinName = SYS_SKIN;



            $ch = curl_init();



            // set URL and other appropriate options

            curl_setopt($ch, CURLOPT_URL, "$serv/sys{$workspace}/{$lang}/{$skinName}/login/authentication");

            curl_setopt($ch, CURLOPT_HEADER, 0);

            curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);

            curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);

            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

            curl_setopt($ch, CURLOPT_POST, true);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            curl_setopt($ch, CURLOPT_POSTFIELDS, "form[USR_USERNAME]=$user&form[USR_PASSWORD]=$pass&form[USER_LANG]=$lang");

            curl_setopt($ch, CURLOPT_TIMEOUT, 90);



            $output = curl_exec($ch);

            curl_close($ch);



            $ch = curl_init();

            $postData = array();

            // resolv the plugin name

            $plugins = glob(PATH_CORE."plugins/*.tar");

            if (count($plugins) > 0) {

                $pluginName = $plugins[0];



                // File to upload/post

                $postData['form[PLUGIN_FILENAME]'] = "@{$pluginName}";

                curl_setopt($ch, CURLOPT_URL, "$serv/sys{$workspace}/{$lang}/{$skinName}/setup/pluginsImportFile");

                curl_setopt($ch, CURLOPT_HEADER, 0);

                curl_setopt($ch, CURLOPT_VERBOSE, 0);

                curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);

                curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);

                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

                curl_setopt($ch, CURLOPT_POST, true);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

                curl_setopt($ch, CURLOPT_TIMEOUT, 90);



                $output = curl_exec($ch);

                curl_close($ch);

            }

        }

    }
Пример #11
0
    /**
     * 
     * @url GET /Templates/:proId
     */
    public function getTemplates($proId)
    {
        $templates = array();
        $path = PATH_DATA_MAILTEMPLATES . $proId . PATH_SEP;

        \G::verifyPath($path, true);

        if (defined('PARTNER_FLAG')) {
            if (!file_exists($path . 'actionsByEmailPartner.html')) {
                @copy(PATH_TPL . 'actionsByEmail' . PATH_SEP . 'actionsByEmailPartner.html', $path . 'actionsByEmail.html');
            }
        } else {
            if (!file_exists($path . 'actionsByEmail.html')) {
                @copy(PATH_TPL . 'actionsByEmail' . PATH_SEP . 'actionsByEmail.html', $path . 'actionsByEmail.html');
            }
        }

        $directory = dir($path);

        while ($object = $directory->read()) {
            if (($object !== '.') && ($object !== '..') && ($object !== 'alert_message.html')) {
                $templates[] = array('FILE' => $object, 'NAME' => $object);
            }
        }
        return $templates;
    }
Пример #12
0
 /**
  * Return the Process File Manager
  *
  * @param string $sProcessUID {@min 32} {@max 32}
  * @param string $userUID {@min 32} {@max 32}
  * @param array  $aData
  *
  * return array
  *
  * @access public
  */
 public function addProcessFilesManager($sProcessUID, $userUID, $aData)
 {
     try {
         $aData['prf_path'] = rtrim($aData['prf_path'], '/') . '/';
         if (!$aData['prf_filename']) {
             throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_filename')));
         }
         $extention = strstr($aData['prf_filename'], '.');
         if (!$extention) {
             $extention = '.html';
             $aData['prf_filename'] = $aData['prf_filename'].$extention;
         }
         if ($extention == '.docx' || $extention == '.doc' || $extention == '.html' || $extention == '.php' || $extention == '.jsp' ||
             $extention == '.xlsx' || $extention == '.xls' || $extention == '.js' || $extention == '.css' || $extention == '.txt') {
             $sEditable = true;
         } else {
             $sEditable = false;
         }
         $sMainDirectory = current(explode("/", $aData['prf_path']));
         if ($sMainDirectory != 'public' && $sMainDirectory != 'templates') {
             throw new \Exception(\G::LoadTranslation("ID_INVALID_PRF_PATH"));
         }
         if (strstr($aData['prf_path'],'/')) {
             $sSubDirectory = substr($aData['prf_path'], strpos($aData['prf_path'], "/")+1) ;
         } else {
             $sSubDirectory = '';
         }
         switch ($sMainDirectory) {
             case 'templates':
                 $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectory . $aData['prf_filename'];
                 $sCheckDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectory;
                 if ($extention != '.html') {
                     throw new \Exception(\G::LoadTranslation('ID_FILE_UPLOAD_INCORRECT_EXTENSION'));
                 }
                 break;
             case 'public':
                 $sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectory . $aData['prf_filename'];
                 $sCheckDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectory;
                 $sEditable = false;
                 if ($extention == '.exe') {
                     throw new \Exception(\G::LoadTranslation('ID_FILE_UPLOAD_INCORRECT_EXTENSION'));
                 }
                 break;
             default:
                 $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectory . $aData['prf_filename'];
                 break;
         }
         $content = $aData['prf_content'];
         if (file_exists($sDirectory) ) {
             $directory = $sMainDirectory. PATH_SEP . $sSubDirectory . $aData['prf_filename'];
             throw new \Exception(\G::LoadTranslation("ID_EXISTS_FILE", array($directory)));
         }
         
         if (!file_exists($sCheckDirectory)) {
             $sPkProcessFiles = \G::generateUniqueID();
             $oProcessFiles = new \ProcessFiles();
             $sDate = date('Y-m-d H:i:s');
             $oProcessFiles->setPrfUid($sPkProcessFiles);
             $oProcessFiles->setProUid($sProcessUID);
             $oProcessFiles->setUsrUid($userUID);
             $oProcessFiles->setPrfUpdateUsrUid('');
             $oProcessFiles->setPrfPath($sCheckDirectory);
             $oProcessFiles->setPrfType('folder');
             $oProcessFiles->setPrfEditable('');
             $oProcessFiles->setPrfCreateDate($sDate);
             $oProcessFiles->save();
         }
         \G::verifyPath($sCheckDirectory, true);
         $sPkProcessFiles = \G::generateUniqueID();
         $oProcessFiles = new \ProcessFiles();
         $sDate = date('Y-m-d H:i:s');
         $oProcessFiles->setPrfUid($sPkProcessFiles);
         $oProcessFiles->setProUid($sProcessUID);
         $oProcessFiles->setUsrUid($userUID);
         $oProcessFiles->setPrfUpdateUsrUid('');
         $oProcessFiles->setPrfPath($sDirectory);
         $oProcessFiles->setPrfType('file');
         $oProcessFiles->setPrfEditable($sEditable);
         $oProcessFiles->setPrfCreateDate($sDate);
         $oProcessFiles->save();
         $fp = fopen($sDirectory, 'w');
         $content = stripslashes($aData['prf_content']);
         $content = str_replace("@amp@", "&", $content);
         fwrite($fp, $content);
         fclose($fp);
         $oProcessFile = array('prf_uid' => $oProcessFiles->getPrfUid(),
                               'prf_filename' => $aData['prf_filename'],
                               'usr_uid' => $oProcessFiles->getUsrUid(),
                               'prf_update_usr_uid' => $oProcessFiles->getPrfUpdateUsrUid(),
                               'prf_path' => $sMainDirectory. PATH_SEP . $sSubDirectory,
                               'prf_type' => $oProcessFiles->getPrfType(),
                               'prf_editable' => $oProcessFiles->getPrfEditable(),
                               'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
                               'prf_update_date' => $oProcessFiles->getPrfUpdateDate(),
                               'prf_content' => $content);
         return $oProcessFile;
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #13
0
    public function generateFileTranslationMafe ()
    {
        $translation = Array ();

        $c = new Criteria();
        $c->add( TranslationPeer::TRN_ID, '%ID_MAFE_%', Criteria::LIKE );
        $c->addAscendingOrderByColumn( 'TRN_CATEGORY' );
        $c->addAscendingOrderByColumn( 'TRN_ID' );
        //$c->addAscendingOrderByColumn( 'TRN_LANG' );
        $tranlations = TranslationPeer::doSelect( $c );

        $mafeFolder = PATH_HTML . "translations";
        $cacheFileMafe = PATH_HTML . "translations" . PATH_SEP. 'translationsMafe' . ".js";

        foreach ($tranlations as $key => $row) {
            if ($row->getTrnCategory() === 'LABEL') {
                $translation[$row->getTrnLang()][$row->getTrnId()] = $row->getTrnValue();
            }
        }

        try {

            G::verifyPath($mafeFolder, true);
            if (! is_dir( dirname( $cacheFileMafe ) )) {
                G::mk_dir( dirname( $cacheFileMafe ) );
            }

            $f = fopen( $cacheFileMafe, 'w' );
            if ($f == false) {
                error_log("Error: Cannot write into cacheFileMafe: $cacheFileMafe\n");
            } else {
                fwrite( $f, "var __TRANSLATIONMAFE = " . Bootstrap::json_encode( $translation ) . ";\n");
                fclose( $f );
            }

            $res['cacheFileMafe'] = $cacheFileMafe;
            $res['languague'] = count($cacheFileMafe);
            $res['rowsMafeJS'] = count( $translation );
            return $res;
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
Пример #14
0
 function getProcessFiles($proUid, $type)
 {
     $filesList = array();
     switch ($type) {
         case 'mail':
         case 'email':
             $basePath = PATH_DATA_MAILTEMPLATES;
             break;
         case 'public':
             $basePath = PATH_DATA_PUBLIC;
             break;
         default:
             throw new Exception("Unknow Process Files Type '{$type}'.");
     }
     $dir = $basePath . $proUid . PATH_SEP;
     G::verifyPath($dir, true);
     // create if it does not exist.
     // creating the default template (if not exists)
     if (!file_exists($dir . 'alert_message.html')) {
         @copy(PATH_TPL . 'mails' . PATH_SEP . 'alert_message.html', $dir . 'alert_message.html');
     }
     $files = glob($dir . '*.*');
     foreach ($files as $file) {
         $fileName = basename($file);
         if ($fileName !== 'alert_message.html') {
             $filesList[] = array('filepath' => $file, 'filename' => $fileName);
         }
     }
     return $filesList;
 }
Пример #15
0
 /**
  * Upload a file and then copy to path+ nameToSave
  *
  * @author Mauricio Veliz <*****@*****.**>
  * @access public
  * @param string $file
  * @param string $path
  * @param string $nameToSave
  * @param integer $permission
  * @return void
  */
 public function uploadFile($file, $path, $nameToSave, $permission = 0666)
 {
     try {
         if ($file == '') {
             throw new Exception('The filename is empty!');
         }
         if (filesize($file) > (ini_get('upload_max_filesize') + 0) * 1024 * 1024) {
             throw new Exception('The size of upload file exceeds the allowed by the server!');
         }
         $oldumask = umask(0);
         if (!is_dir($path)) {
             G::verifyPath($path, true);
         }
         move_uploaded_file($file, $path . "/" . $nameToSave);
         chmod($path . "/" . $nameToSave, $permission);
         umask($oldumask);
     } catch (Exception $oException) {
         throw $oException;
     }
 }
Пример #16
0
 /**
  * exploreDirectory
  *
  * @param string $sProcessUID
  * @param string $sMainDirectory
  * @param string $sCurrentDirectory
  * @return void
  */
 public function exploreDirectory($sProcessUID, $sMainDirectory, $sCurrentDirectory)
 {
     switch ($sMainDirectory) {
         case 'mailTemplates':
             $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP;
             break;
         case 'public':
             $sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP;
             break;
         default:
             die;
             break;
     }
     G::verifyPath($sDirectory, true);
     $sDirectory .= $sCurrentDirectory . PATH_SEP;
     $aTheFiles = array();
     $aTheFiles[] = array('PATH' => 'char', 'EDIT' => 'char', 'DOWNLOAD_TEXT' => '', 'DOWNLOAD_JS' => '', 'DELETE_TEXT' => 'char', 'DELETE_JS' => 'char');
     $aDirectories = array();
     $aFiles = array();
     $oDirectory = dir($sDirectory);
     while ($sObject = $oDirectory->read()) {
         if ($sObject !== '.' && $sObject !== '..') {
             $sPath = $sDirectory . $sObject;
             if (is_dir($sPath)) {
                 $aDirectories[] = array('PATH' => ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '') . $sObject, 'DIRECTORY' => $sObject);
             } else {
                 $aAux = pathinfo($sPath);
                 $aFiles[] = array('FILE' => $sObject, 'EXT' => $aAux['extension']);
             }
         }
     }
     $oDirectory->close();
     if ($sCurrentDirectory == '') {
         $aTheFiles[] = array('PATH' => '<a href="#" onclick="goToHome(\'' . $sProcessUID . '\');" class="pagedTableHeader">..</a>', 'EDIT' => '', 'DOWNLOAD_TEXT' => '', 'DOWNLOAD_JS' => '', 'DELETE_TEXT' => '', 'DELETE_JS' => '');
     } else {
         $aAux = explode(PATH_SEP, $sCurrentDirectory);
         array_pop($aAux);
         $aTheFiles[] = array('PATH' => '<a href="#" onclick="goToDirectory(\'' . $sProcessUID . '\', \'' . $sMainDirectory . '\', \'' . implode(PATH_SEP, $aAux) . '\');" class="pagedTableHeader">..</a>', 'EDIT' => '', 'DOWNLOAD_TEXT' => '', 'DOWNLOAD_JS' => '', 'DELETE_TEXT' => '', 'DELETE_JS' => '');
     }
     foreach ($aDirectories as $aDirectories) {
         $aTheFiles[] = array('PATH' => '<a href="#" onclick="goToDirectory(\'' . $sProcessUID . '\', \'' . $sMainDirectory . '\', \'' . $aDirectories['PATH'] . '\');" class="pagedTableHeader">' . $aDirectories['DIRECTORY'] . '</a>', 'EDIT' => '', 'DOWNLOAD_TEXT' => '', 'DOWNLOAD_JS' => '', 'DELETE_TEXT' => G::LoadTranslation('ID_DELETE'), 'DELETE_JS' => 'deleteDirectory(\'' . $sProcessUID . '\', \'' . $sMainDirectory . '\', \'' . $sCurrentDirectory . '\', \'' . $aDirectories['DIRECTORY'] . '\');');
     }
     foreach ($aFiles as $aFile) {
         $aTheFiles[] = array('PATH' => $aFile['FILE'], 'EDIT' => $sMainDirectory == 'mailTemplates' ? 'Edit' : '', 'EDIT_JS' => "editFile('{$sProcessUID}', @@PATH)", 'DOWNLOAD_TEXT' => G::LoadTranslation('ID_DOWNLOAD'), 'DOWNLOAD_JS' => 'downloadFile(\'' . $sProcessUID . '\', \'' . $sMainDirectory . '\', \'' . $sCurrentDirectory . '\', \'' . $aFile['FILE'] . '\');', 'DELETE_TEXT' => G::LoadTranslation('ID_DELETE'), 'DELETE_JS' => 'deleteFile(\'' . $sProcessUID . '\', \'' . $sMainDirectory . '\', \'' . $sCurrentDirectory . '\', \'' . $aFile['FILE'] . '\');');
     }
     global $_DBArray;
     $_DBArray = isset($_SESSION['_DBArray']) ? $_SESSION['_DBArray'] : '';
     $_DBArray['objects'] = $aTheFiles;
     $_SESSION['_DBArray'] = $_DBArray;
     G::LoadClass('ArrayPeer');
     $oCriteria = new Criteria('dbarray');
     $oCriteria->setDBArrayTable('objects');
     $oCriteria->addAscendingOrderByColumn('DOWNLOAD_TEXT');
     global $G_PUBLISH;
     $G_PUBLISH = new Publisher();
     $G_PUBLISH->AddContent('propeltable', 'processes/files-paged-table', 'processes/processes_FilesList', $oCriteria, array('PRO_UID' => $sProcessUID, 'MAIN_DIRECTORY' => $sMainDirectory, 'CURRENT_DIRECTORY' => $sCurrentDirectory));
     G::RenderPage('publish', 'raw');
 }
Пример #17
0
function saveLog($sSource, $sType, $sDescription)
{
    try {
        global $isDebug;
        if ($isDebug) {
            print date('H:i:s') . " ({$sSource}) {$sType} {$sDescription} <br>\n";
        }
        @fwrite($oFile, date('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
        G::verifyPath(PATH_DATA . 'log' . PATH_SEP, true);
        if ($sType == 'action') {
            $oFile = @fopen(PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
        } else {
            $oFile = @fopen(PATH_DATA . 'log' . PATH_SEP . 'cronError.log', 'a+');
        }
        @fwrite($oFile, date('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
        @fclose($oFile);
    } catch (Exception $oError) {
        // CONTINUE
    }
}
Пример #18
0
    public function setPartner()

    {

        if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

            // Execute sql for partner

            $pathMysqlPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'mysql' . PATH_SEP;

            if (G::verifyPath($pathMysqlPartner)) {

                $res = array();

                $filesSlq = glob($pathMysqlPartner . '*.sql');

                foreach ($filesSlq as $value) {

                    $this->mysqlFileQuery($value);

                }

            }



            // Execute to change of skin

            $pathSkinPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'skin' . PATH_SEP;

            if (G::verifyPath($pathSkinPartner)) {

                $res = array();

                $fileTar = glob($pathSkinPartner . '*.tar');

                foreach ($fileTar as $value) {

                    $dataFile = pathinfo($value);

                    $nameSkinTmp = $dataFile['filename'];

                    G::LoadThirdParty( 'pear/Archive', 'Tar' );

                    $tar = new Archive_Tar( $value );



                    $pathSkinTmp = $pathSkinPartner . 'tmp' . PATH_SEP;

                    G::rm_dir($pathSkinTmp);

                    G::verifyPath($pathSkinTmp, true);

                    chmod( $pathSkinTmp, 0777);

                    $tar->extract($pathSkinTmp);



                    $pathSkinName = $pathSkinTmp . $nameSkinTmp . PATH_SEP;

                    chmod( $pathSkinName, 0777);

                    G::verifyPath(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', true);

                    $skinClassic = PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp' . PATH_SEP;



                    if (is_dir($pathSkinName)) {

                        $this->copyFile($pathSkinName, $skinClassic);

                    }



                    G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'base');

                    rename(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', PATH_CORE . 'skinEngine' . PATH_SEP . 'base');

                    G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp');



                    break;

                }

            }

        }

    }
 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, true);
     curl_setopt($pCurl, CURLOPT_VERBOSE, false);
     //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 = new stdclass();
     $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);
 }
Пример #20
0
 /**
  * @covers G::verifyPath
  * @todo   Implement testVerifyPath().
  */
 public function testVerifyPath()
 {
     $dirExist = PATH_HOME;
     $this->assertTrue(G::verifyPath($dirExist));
     $dirNoExist = PATH_HOME . 'test';
     if (is_dir($dirNoExist)) {
         rmdir($dirNoExist);
     }
     $this->assertFalse(G::verifyPath($dirNoExist));
     $dirNoExist = PATH_HOME . 'test';
     $this->assertFalse(G::verifyPath($dirNoExist, true));
     $this->assertTrue(G::verifyPath($dirNoExist));
     if (is_dir($dirNoExist)) {
         rmdir($dirNoExist);
     }
 }
Пример #21
0
function importSkin()
{
    try {
        if (!isset($_FILES['uploadedFile'])) {
            throw new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED'));
        }
        $uploadedInstances = count($_FILES['uploadedFile']['name']);
        $sw_error = false;
        $sw_error_exists = isset($_FILES['uploadedFile']['error']);
        $emptyInstances = 0;
        $quequeUpload = array();
        // upload files & check for errors
        $tmp = $_FILES['uploadedFile']['tmp_name'];
        $items = stripslashes($_FILES['uploadedFile']['name']);
        if ($sw_error_exists) {
            $up_err = $_FILES['uploadedFile']['error'];
        } else {
            $up_err = file_exists($tmp) ? 0 : 4;
        }
        if ($items == "" || $up_err == 4) {
            throw new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED'));
        }
        if ($up_err == 1 || $up_err == 2) {
            throw new Exception(G::LoadTranslation('ID_FILE_TOO_BIG'));
            //$errors[$i]='miscfilesize';
        }
        if ($up_err == 3) {
            throw new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR'));
            //$errors[$i]='miscfilepart';
        }
        if (!@is_uploaded_file($tmp)) {
            throw new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR'));
            //$errors[$i]='uploadfile';
        }
        $fileInfo = pathinfo($items);
        $validType = array('tar', 'gz');
        if (!in_array($fileInfo['extension'], $validType)) {
            throw new Exception(G::LoadTranslation('ID_FILE_UPLOAD_INCORRECT_EXTENSION'));
            //$errors[$i]='wrongtype';
        }
        $filename = $items;
        $tempPath = PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP;
        G::verifyPath($tempPath, true);
        $tempName = $tmp;
        G::uploadFile($tempName, $tempPath, $filename);
        G::LoadThirdParty('pear/Archive', 'Tar');
        $tar = new Archive_Tar($tempPath . $filename);
        $aFiles = $tar->listContent();
        $swConfigFile = false;
        foreach ($aFiles as $key => $val) {
            if (basename($val['filename']) == 'config.xml') {
                $skinName = dirname($val['filename']);
                $skinArray = explode("/", $skinName);
                if (count($skinArray) == 1) {
                    $swConfigFile = true;
                }
            }
        }
        if (!$swConfigFile) {
            @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename);
            throw new Exception(G::LoadTranslation('ID_SKIN_CONFIGURATION_MISSING'));
        }
        if (is_dir(PATH_CUSTOM_SKINS . $skinName)) {
            if (isset($_REQUEST['overwrite_files']) && $_REQUEST['overwrite_files'] == 'on') {
                G::rm_dir(PATH_CUSTOM_SKINS . $skinName, false);
            } else {
                throw new Exception(G::LoadTranslation('ID_SKIN_ALREADY_EXISTS'));
            }
        }
        $res = $tar->extract(PATH_CUSTOM_SKINS);
        if (!$res) {
            throw new Exception(G::LoadTranslation('ID_SKIN_ERROR_EXTRACTING'));
        }
        $configFileOriginal = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml';
        $configFileFinal = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml';
        $xmlConfiguration = file_get_contents($configFileOriginal);
        $workspace = $_REQUEST['workspace'] == 'global' ? '' : SYS_SYS;
        $xmlConfigurationObj = G::xmlParser($xmlConfiguration);
        $skinInformationArray = $xmlConfigurationObj->result["skinConfiguration"]["__CONTENT__"]["information"]["__CONTENT__"];
        if (isset($skinInformationArray["workspace"]["__VALUE__"])) {
            $workspace = $workspace != "" && !empty($skinInformationArray["workspace"]["__VALUE__"]) ? $skinInformationArray["workspace"]["__VALUE__"] . "|" . $workspace : $workspace;
            $xmlConfiguration = preg_replace("/(<workspace>)(.*)(<\\/workspace>)/i", "<workspace>" . $workspace . "</workspace><!-- \$2 -->", $xmlConfiguration);
        } else {
            $xmlConfiguration = preg_replace("/(<name>)(.*)(<\\/name>)/i", "<name>" . $skinName . "</name><!-- \$2 -->\n<workspace>" . $workspace . "</workspace>", $xmlConfiguration);
        }
        file_put_contents($configFileFinal, $xmlConfiguration);
        //Delete Temporal
        @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename);
        $response['success'] = true;
        $response['message'] = G::LoadTranslation('ID_SKIN_SUCCESSFUL_IMPORTED');
        G::auditLog("ImportSkin", "Skin Name: " . $skinName);
        print_r(G::json_encode($response));
    } catch (Exception $e) {
        $response['success'] = false;
        $response['message'] = $e->getMessage();
        $response['error'] = $e->getMessage();
        print_r(G::json_encode($response));
    }
}
Пример #22
0
function run_workspace_restore($args, $opts) {

  $filename = $args[0];



  G::verifyPath(PATH_DATA . 'upgrade', true);



  if (strpos($filename, "/") === false && strpos($filename, '\\') === false) {

    $filename = PATH_DATA . "backups/$filename";

    if (!file_exists($filename) && substr_compare($filename, ".tar", -4, 4, true) != 0)

      $filename .= ".tar";

  }

  $info = array_key_exists("info", $opts);

  $lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';

  $port = array_key_exists("port", $opts) ? $opts['port'] : '';

  if ($info) {

    workspaceTools::getBackupInfo($filename);

  } else {

    CLI::logging("Restoring from $filename\n");

    $workspace = array_key_exists("workspace", $opts) ? $opts['workspace'] : NULL;

    $overwrite = array_key_exists("overwrite", $opts);

    $multiple = array_key_exists("multiple", $opts);

    $dstWorkspace = isset($args[1]) ? $args[1] : null;

    if(!empty($multiple)){

        if(!Bootstrap::isLinuxOs()){

            CLI::error("This is not a Linux enviroment, cannot use this multiple [-m] feature.\n");

            return;

        }

        multipleFilesBackup::letsRestore ($filename,$workspace,$dstWorkspace,$overwrite);

    }

    else{

        $anotherExtention = ".*"; //if there are files with and extra extention: e.g. <file>.tar.number

        $multiplefiles = glob($filename . $anotherExtention);// example: //shared/workflow_data/backups/myWorkspace.tar.*

        if(count($multiplefiles) > 0)

        {

            CLI::error("Processmaker found these files: .\n");

            foreach($multiplefiles as $index => $value){

                CLI::logging($value . "\n");

            }

            CLI::error("Please, you should use -m parameter to restore them.\n");

            return;

        }

        workspaceTools::restore($filename, $workspace, $dstWorkspace, $overwrite, $lang, $port );

    }

  }

}
Пример #23
0
 public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array())
 {
     define("MAX_FREE_FRACTION", 1);
     define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/');
     G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
     require_once PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php';
     require_once PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php';
     parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
     $GLOBALS['g_config'] = array('cssmedia' => 'screen', 'media' => 'Letter', 'scalepoints' => false, 'renderimages' => true, 'renderfields' => true, 'renderforms' => false, 'pslevel' => 3, 'renderlinks' => true, 'pagewidth' => 800, 'landscape' => $sLandscape, 'method' => 'fpdf', 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15), 'encoding' => '', 'ps2pdf' => false, 'compress' => true, 'output' => 2, 'pdfversion' => '1.3', 'transparency_workaround' => false, 'imagequality_workaround' => false, 'draw_page_border' => isset($_REQUEST['pageborder']), 'debugbox' => false, 'html2xhtml' => true, 'mode' => 'html', 'smartpagebreak' => true);
     $GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties);
     $g_media = Media::predefined($GLOBALS['g_config']['media']);
     $g_media->set_landscape($GLOBALS['g_config']['landscape']);
     $g_media->set_margins($GLOBALS['g_config']['margins']);
     $g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
     if (isset($GLOBALS['g_config']['pdfSecurity'])) {
         if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "") {
             $GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID);
         }
         if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "") {
             $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID);
         }
         $g_media->set_security($GLOBALS['g_config']['pdfSecurity']);
         require_once HTML2PS_DIR . 'pdf.fpdf.encryption.php';
     }
     $pipeline = new Pipeline();
     if (extension_loaded('curl')) {
         require_once HTML2PS_DIR . 'fetcher.url.curl.class.php';
         $pipeline->fetchers = array(new FetcherURLCurl());
         if (isset($proxy)) {
             if ($proxy != '') {
                 $pipeline->fetchers[0]->set_proxy($proxy);
             }
         }
     } else {
         require_once HTML2PS_DIR . 'fetcher.url.class.php';
         $pipeline->fetchers[] = new FetcherURL();
     }
     $pipeline->data_filters[] = new DataFilterDoctype();
     $pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']);
     if ($GLOBALS['g_config']['html2xhtml']) {
         $pipeline->data_filters[] = new DataFilterHTML2XHTML();
     } else {
         $pipeline->data_filters[] = new DataFilterXHTML2XHTML();
     }
     $pipeline->parser = new ParserXHTML();
     $pipeline->pre_tree_filters = array();
     $header_html = '';
     $footer_html = '';
     $filter = new PreTreeFilterHeaderFooter($header_html, $footer_html);
     $pipeline->pre_tree_filters[] = $filter;
     if ($GLOBALS['g_config']['renderfields']) {
         $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields();
     }
     if ($GLOBALS['g_config']['method'] === 'ps') {
         $pipeline->layout_engine = new LayoutEnginePS();
     } else {
         $pipeline->layout_engine = new LayoutEngineDefault();
     }
     $pipeline->post_tree_filters = array();
     if ($GLOBALS['g_config']['pslevel'] == 3) {
         $image_encoder = new PSL3ImageEncoderStream();
     } else {
         $image_encoder = new PSL2ImageEncoderStream();
     }
     switch ($GLOBALS['g_config']['method']) {
         case 'fastps':
             if ($GLOBALS['g_config']['pslevel'] == 3) {
                 $pipeline->output_driver = new OutputDriverFastPS($image_encoder);
             } else {
                 $pipeline->output_driver = new OutputDriverFastPSLevel2($image_encoder);
             }
             break;
         case 'pdflib':
             $pipeline->output_driver = new OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']);
             break;
         case 'fpdf':
             $pipeline->output_driver = new OutputDriverFPDF();
             break;
         case 'png':
             $pipeline->output_driver = new OutputDriverPNG();
             break;
         case 'pcl':
             $pipeline->output_driver = new OutputDriverPCL();
             break;
         default:
             die('Unknown output method');
     }
     if (isset($GLOBALS['g_config']['watermarkhtml'])) {
         $watermark_text = $GLOBALS['g_config']['watermarkhtml'];
     } else {
         $watermark_text = '';
     }
     $pipeline->output_driver->set_watermark($watermark_text);
     if ($watermark_text != '') {
         $dispatcher =& $pipeline->getDispatcher();
     }
     if ($GLOBALS['g_config']['debugbox']) {
         $pipeline->output_driver->set_debug_boxes(true);
     }
     if ($GLOBALS['g_config']['draw_page_border']) {
         $pipeline->output_driver->set_show_page_border(true);
     }
     if ($GLOBALS['g_config']['ps2pdf']) {
         $pipeline->output_filters[] = new OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']);
     }
     if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps') {
         $pipeline->output_filters[] = new OutputFilterGZip();
     }
     if (!isset($GLOBALS['g_config']['process_mode'])) {
         $GLOBALS['g_config']['process_mode'] = '';
     }
     if ($GLOBALS['g_config']['process_mode'] == 'batch') {
         $filename = 'batch';
     } else {
         $filename = $sFilename;
     }
     switch ($GLOBALS['g_config']['output']) {
         case 0:
             $pipeline->destination = new DestinationBrowser($filename);
             break;
         case 1:
             $pipeline->destination = new DestinationDownload($filename);
             break;
         case 2:
             $pipeline->destination = new DestinationFile($filename);
             break;
     }
     copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
     try {
         $status = $pipeline->process((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media);
         copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf');
         unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf');
         unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
     } catch (Exception $e) {
         if ($e->getMessage() == 'ID_OUTPUT_NOT_GENERATE') {
             include_once 'classes/model/AppDocument.php';
             $dataDocument = explode('_', $sFilename);
             if (!isset($dataDocument[1])) {
                 $dataDocument[1] = 1;
             }
             $oAppDocument = new AppDocument();
             $oAppDocument->remove($dataDocument[0], $dataDocument[1]);
             G::SendTemporalMessage(G::LoadTranslation('ID_OUTPUT_NOT_GENERATE'), 'Error');
         }
     }
 }
Пример #24
0
 /**
  * Creates the Dynaform
  *
  * @param array $aData Fields with :
  * $aData['DYN_UID'] the dynaform id
  * $aData['USR_UID'] the userid
  * @return void
  */
 public function create($aData, $pmTableUid = '')
 {
     if (!isset($aData['PRO_UID'])) {
         throw new PropelException('The dynaform cannot be created. The PRO_UID is empty.');
     }
     $con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
     try {
         if (isset($aData['DYN_UID']) && $aData['DYN_UID'] == '') {
             unset($aData['DYN_UID']);
         }
         if (!isset($aData['DYN_UID'])) {
             $dynUid = G::generateUniqueID();
         } else {
             $dynUid = $aData['DYN_UID'];
         }
         $this->setDynUid($dynUid);
         $this->setProUid($aData['PRO_UID']);
         $this->setDynType(isset($aData['DYN_TYPE']) ? $aData['DYN_TYPE'] : 'xmlform');
         $this->setDynFilename($aData['PRO_UID'] . PATH_SEP . $dynUid);
         $this->setDynUpdateDate(date("Y-m-d H:i:s"));
         if (isset($aData["DYN_CONTENT"])) {
             $this->setDynContent($aData["DYN_CONTENT"]);
         }
         if (isset($aData["DYN_LABEL"])) {
             $this->setDynLabel($aData["DYN_LABEL"]);
         }
         if (!isset($aData['DYN_VERSION'])) {
             $aData['DYN_VERSION'] = 0;
         }
         $this->setDynVersion($aData['DYN_VERSION']);
         if (!isset($aData['DYN_CONTENT'])) {
             $aData['DYN_CONTENT'] = "{}";
         }
         $this->setDynContent($aData['DYN_CONTENT']);
         if ($this->validate()) {
             $con->begin();
             $res = $this->save();
             if (isset($aData['DYN_TITLE'])) {
                 $this->setDynTitle($aData['DYN_TITLE']);
             } else {
                 $this->setDynTitle('Default Dynaform Title');
             }
             if (isset($aData['DYN_DESCRIPTION'])) {
                 $this->setDynDescription($aData['DYN_DESCRIPTION']);
             } else {
                 $this->setDynDescription('Default Dynaform Description');
             }
             $con->commit();
             //Add Audit Log
             $mode = isset($aData['MODE']) ? $aData['MODE'] : 'Determined by Fields';
             $description = "";
             if ($pmTableUid != '') {
                 $pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
                 $addTabName = $pmTable->getAddTabName();
                 $description = "Create from a PM Table: " . $addTabName . ", ";
             }
             G::auditLog("CreateDynaform", $description . "Dynaform Title: " . $aData['DYN_TITLE'] . ", Type: " . $aData['DYN_TYPE'] . ", Description: " . $aData['DYN_DESCRIPTION'] . ", Mode: " . $mode);
             $sXml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
             $sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="" nextstepsave="prompt">' . "\n";
             $sXml .= '</dynaForm>';
             G::verifyPath(PATH_DYNAFORM . $this->getProUid(), true);
             $oFile = fopen(PATH_DYNAFORM . $this->getProUid() . '/' . $this->getDynUid() . '.xml', 'w');
             fwrite($oFile, $sXml);
             fclose($oFile);
             return $this->getDynUid();
         } else {
             $msg = '';
             foreach ($this->getValidationFailures() as $objValidationFailure) {
                 $msg .= $objValidationFailure->getMessage() . "<br/>";
             }
             throw new PropelException('The row cannot be created!', new PropelException($msg));
         }
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Пример #25
0
 /**
  * Set temporal data
  *
  * @param $data
  * @return void
  */
 public function _setTmpData($data)
 {
     G::verifyPath(PATH_C . 'dynEditor/', true);
     $fp = fopen(PATH_C . 'dynEditor/' . session_id() . '.php', 'w');
     fwrite($fp, '$tmpData=unserialize(\'' . addcslashes(serialize($data), '\\\'') . '\');');
     fclose($fp);
 }
Пример #26
0
 public function getSkingList()
 {
     //Create Skins custom folder if it doesn't exists
     if (!is_dir(PATH_CUSTOM_SKINS)) {
         G::verifyPath(PATH_CUSTOM_SKINS, true);
     }
     //Get Skin Config files
     $skinListArray = array();
     $customSkins = glob(PATH_CUSTOM_SKINS . "*/config.xml");
     if (!is_array($customSkins)) {
         $customSkins = array();
     }
     // getting al base skins
     $baseSkins = glob(G::ExpandPath("skinEngine") . '*/config.xml');
     // filtering no public skins (uxs, simplified)
     foreach ($baseSkins as $i => $skinName) {
         if (strpos($skinName, 'simplified') !== false || strpos($skinName, 'uxs') !== false || strpos($skinName, 'uxmodern') !== false) {
             unset($baseSkins[$i]);
         }
     }
     $customSkins = array_merge($baseSkins, $customSkins);
     $global = G::LoadTranslation('ID_GLOBAL');
     //Read and parse each Configuration File
     foreach ($customSkins as $key => $configInformation) {
         $folderId = basename(dirname($configInformation));
         if ($folderId == 'base') {
             $folderId = 'classic';
         }
         $partnerFlag = defined('PARTNER_FLAG') ? PARTNER_FLAG : false;
         if ($partnerFlag && $folderId == 'classic') {
             continue;
         }
         $xmlConfiguration = file_get_contents($configInformation);
         $xmlConfigurationObj = G::xmlParser($xmlConfiguration);
         if (isset($xmlConfigurationObj->result['skinConfiguration'])) {
             $skinInformationArray = $skinFilesArray = $xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['information']['__CONTENT__'];
             $res = array();
             $res['SKIN_FOLDER_ID'] = strtolower($folderId);
             foreach ($skinInformationArray as $keyInfo => $infoValue) {
                 $res['SKIN_' . strtoupper($keyInfo)] = isset($infoValue['__VALUE__']) ? $infoValue['__VALUE__'] : '';
             }
             $res['SKIN_CREATEDATE'] = isset($res['SKIN_CREATEDATE']) ? $res['SKIN_CREATEDATE'] : '';
             $res['SKIN_MODIFIEDDATE'] = isset($res['SKIN_MODIFIEDDATE']) ? $res['SKIN_MODIFIEDDATE'] : '';
             $res['SKIN_WORKSPACE'] = isset($res['SKIN_WORKSPACE']) ? $res['SKIN_WORKSPACE'] != '' ? $res['SKIN_WORKSPACE'] : $global : $global;
             $swWS = true;
             if ($res['SKIN_WORKSPACE'] != $global) {
                 $workspace = explode("|", $res['SKIN_WORKSPACE']);
                 $swWS = false;
                 foreach ($workspace as $key => $value) {
                     if ($value == SYS_SYS) {
                         $swWS = true;
                         break;
                     }
                 }
             }
             if ($swWS) {
                 $skinListArray['skins'][] = $res;
             }
         }
     }
     $skinListArray['currentSkin'] = SYS_SKIN;
     return $skinListArray;
 }
Пример #27
0
 /**
  * Creates the Dynaform
  *
  * @param array $aData Fields with :
  * $aData['DYN_UID'] the dynaform id
  * $aData['USR_UID'] the userid
  * @return void
  */
 public function create($aData)
 {
     if (!isset($aData['PRO_UID'])) {
         throw new PropelException('The dynaform cannot be created. The PRO_UID is empty.');
     }
     $con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
     try {
         if (isset($aData['DYN_UID']) && $aData['DYN_UID'] == '') {
             unset($aData['DYN_UID']);
         }
         if (!isset($aData['DYN_UID'])) {
             $dynUid = G::generateUniqueID();
         } else {
             $dynUid = $aData['DYN_UID'];
         }
         $this->setDynUid($dynUid);
         $this->setProUid($aData['PRO_UID']);
         $this->setDynType(isset($aData['DYN_TYPE']) ? $aData['DYN_TYPE'] : 'xmlform');
         $this->setDynFilename($aData['PRO_UID'] . PATH_SEP . $dynUid);
         if ($this->validate()) {
             $con->begin();
             $res = $this->save();
             if (isset($aData['DYN_TITLE'])) {
                 $this->setDynTitle($aData['DYN_TITLE']);
             } else {
                 $this->setDynTitle('Default Dynaform Title');
             }
             if (isset($aData['DYN_DESCRIPTION'])) {
                 $this->setDynDescription($aData['DYN_DESCRIPTION']);
             } else {
                 $this->setDynDescription('Default Dynaform Description');
             }
             $con->commit();
             $sXml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
             $sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="" nextstepsave="prompt">' . "\n";
             $sXml .= '</dynaForm>';
             G::verifyPath(PATH_DYNAFORM . $this->getProUid(), true);
             $oFile = fopen(PATH_DYNAFORM . $this->getProUid() . '/' . $this->getDynUid() . '.xml', 'w');
             fwrite($oFile, $sXml);
             fclose($oFile);
             return $this->getDynUid();
         } else {
             $msg = '';
             foreach ($this->getValidationFailures() as $objValidationFailure) {
                 $msg .= $objValidationFailure->getMessage() . "<br/>";
             }
             throw new PropelException('The row cannot be created!', new PropelException($msg));
         }
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Пример #28
0
    public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "")

    {

        try {

            $applicationData = $this->loadCase($sApplicationUID);

            $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"];



            if (!class_exists('System')) {

                G::LoadClass('system');

            }

            $aConfiguration = System::getEmailConfiguration();



            $msgError = "";

            if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {

                $msgError = "The default configuration wasn't defined";

                $aConfiguration['MESS_ENGINE'] = '';

            }



            //Send derivation notification - Start

            $oTask = new Task();

            $aTaskInfo = $oTask->load($sCurrentTask);



            if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') {

                return false;

            }



            $sFrom = G::buildFrom($aConfiguration, $sFrom);



            if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {

                $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields);

            } else {

                $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');

            }



            //erik: new behaviour for messages

            G::loadClass('configuration');

            $oConf = new Configurations;

            $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');

            $conf = $oConf->aConfig;



            $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP;

            $swtplDefault = 0;

            $sBody = null;



            if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) &&

                    isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) &&

                    $conf["TAS_DEF_MESSAGE_TYPE"] == "template" &&

                    $conf["TAS_DEF_MESSAGE_TEMPLATE"] != ""

            ) {

                if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") {

                    $swtplDefault = 1;

                }



                $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"];



                if (!file_exists($fileTemplate)) {

                    throw (new Exception("Template file \"$fileTemplate\" does not exist."));

                }



                $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields, false);

            } else {

                $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields, false));

            }



            G::LoadClass("tasks");

            G::LoadClass("groups");

            G::LoadClass("spool");



            $task = new Tasks();

            $group = new Groups();

            $oUser = new Users();



            foreach ($aTasks as $aTask) {

                $sTo = null;

                $sCc = null;



                switch ($aTask["TAS_ASSIGN_TYPE"]) {

                    case "SELF_SERVICE":

                        if ($swtplDefault == 1) {

                            G::verifyPath($pathEmail, true); //Create if it does not exist

                            $fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE');



                            if ((!file_exists($fileTemplate)) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) {

                                @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate);

                            }



                            $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);

                        }



                        if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {

                            $arrayTaskUser = array();



                            $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1);



                            foreach ($arrayAux1 as $arrayGroup) {

                                $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]);



                                foreach ($arrayAux2 as $arrayUser) {

                                    $arrayTaskUser[] = $arrayUser["USR_UID"];

                                }

                            }



                            $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1);



                            foreach ($arrayAux1 as $arrayUser) {

                                $arrayTaskUser[] = $arrayUser["USR_UID"];

                            }



                            $criteria = new Criteria("workflow");



                            $criteria->addSelectColumn(UsersPeer::USR_UID);

                            $criteria->addSelectColumn(UsersPeer::USR_USERNAME);

                            $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);

                            $criteria->addSelectColumn(UsersPeer::USR_LASTNAME);

                            $criteria->addSelectColumn(UsersPeer::USR_EMAIL);

                            $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN);

                            $rsCriteria = UsersPeer::doSelectRs($criteria);

                            $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);



                            $to = null;

                            $cc = null;

                            $sw = 1;



                            while ($rsCriteria->next()) {

                                $row = $rsCriteria->getRow();



                                $toAux = (

                                        (($row["USR_FIRSTNAME"] != "") || ($row["USR_LASTNAME"] != "")) ?

                                                $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : ""

                                        ) . "<" . $row["USR_EMAIL"] . ">";



                                if ($sw == 1) {

                                    $to = $toAux;

                                    $sw = 0;

                                } else {

                                    $cc = $cc . (($cc != null) ? "," : null) . $toAux;

                                }

                            }



                            $sTo = $to;

                            $sCc = $cc;

                        }

                        break;

                    default:

                        if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {

                            $aUser = $oUser->load($aTask["USR_UID"]);



                            $sTo = (

                                    (($aUser["USR_FIRSTNAME"] != "") || ($aUser["USR_LASTNAME"] != "")) ?

                                            $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : ""

                                    ) . "<" . $aUser["USR_EMAIL"] . ">";

                        }

                        break;

                }



                if ($sTo != null) {

                    $oSpool = new spoolRun();



                    $oSpool->setConfig($aConfiguration);

                    $oSpool->create(array(

                        "msg_uid" => "",

                        "app_uid" => $sApplicationUID,

                        "del_index" => $iDelegation,

                        "app_msg_type" => "DERIVATION",

                        "app_msg_subject" => $sSubject,

                        "app_msg_from" => $sFrom,

                        "app_msg_to" => $sTo,

                        "app_msg_body" => $sBody,

                        "app_msg_cc" => $sCc,

                        "app_msg_bcc" => "",

                        "app_msg_attach" => "",

                        "app_msg_template" => "",

                        "app_msg_status" => "pending",

                        "app_msg_error" => $msgError

                    ));



                    if ($msgError == '') {

                        if (($aConfiguration["MESS_BACKGROUND"] == "") ||

                                ($aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1")

                        ) {

                            $oSpool->sendMail();

                        }

                    }

                }

            }

            //Send derivation notification - End

        } catch (Exception $oException) {

            throw $oException;

        }

    }
Пример #29
0
    /**
     * @url POST /case/:app_uid/upload/location
     *
     * @param string $app_uid      { @min 32}{@max 32}
     * @param float $latitude      {@min -90}{@max 90}
     * @param float $longitude     {@min -180}{@max 180}
     */
    public function postInputDocumentLocation($app_uid, $latitude, $longitude)
    {
        try {
            $userUid       = $this->getUserId();
            $oMobile       = new \ProcessMaker\BusinessModel\Light();

            $url           = "http://maps.googleapis.com/maps/api/staticmap?center=".$latitude.','.$longitude."&format=jpg&size=600x600&zoom=15&markers=color:blue%7Clabel:S%7C".$latitude.','.$longitude;
            $imageLocation = imagecreatefromjpeg($url);
            $tmpfname = tempnam("php://temp","pmm");
            imagejpeg($imageLocation, $tmpfname);

            $_FILES["form"]["type"] = "image/jpeg";
            $_FILES["form"]["name"] = 'Location.jpg';
            $_FILES["form"]["tmp_name"] = $tmpfname;
            $_FILES["form"]["error"] = 0;
            $sizes = getimagesize($tmpfname);
            $_FILES["form"]["size"] = ($sizes['0'] * $sizes['1']);

            $request_data = array(array('name' => $_FILES["form"]["name"]));
            $file = $oMobile->postUidUploadFiles($userUid, $app_uid, $request_data);

            $strPathName = PATH_DOCUMENT . G::getPathFromUID($app_uid) . PATH_SEP;
            $strFileName = $file[0]['appDocUid'] . "_" . $file[0]['docVersion'] . ".jpg";
            if (! is_dir( $strPathName )) {
                G::verifyPath( $strPathName, true );
            }
            copy($tmpfname, $strPathName . $strFileName);
            unlink($tmpfname);
        } catch (\Exception $e) {
            throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
        }
        return $file;
    }
Пример #30
0
function saveLog($sSource, $sType, $sDescription)

{

    try {

        global $sObject;

        global $isDebug;



        if ($isDebug) {

            print date("H:i:s") . " ($sSource) $sType $sDescription <br />\n";

        }



        G::verifyPath(PATH_DATA . "log" . PATH_SEP, true);

        G::log("| $sObject | " . $sSource . " | $sType | " . $sDescription, PATH_DATA);

    } catch (Exception $e) {

        //CONTINUE

    }

}