Exemple #1
0
 public static function next_id($name)
 {
     if ($name instanceof CActiveRecord) {
         $primaryKey = $name->primaryKey();
         if (empty($primaryKey)) {
             throw new CHttpException(405, 'primaryKey is null.');
         }
         $name = $name->tablename() . "_" . $name->primaryKey();
     } else {
         if (!is_string($name) || empty($name)) {
             throw new CHttpException(405, 'Exception ' . __CLASS__, __FUNCTION__);
         }
     }
     $seq = new Sequences();
     $new_id = $seq->next($name);
     if ($new_id == 0) {
         throw new CHttpException(405, 'new_id is required ' . __CLASS__, __FUNCTION__);
     }
     return $new_id;
 }
Exemple #2
0
 /**
  * Creates the Application
  *
  * @param
  *   $sProUid the process id
  *   $sUsrUid the userid
  * @return     void
  */
 public function create($sProUid, $sUsrUid)
 {
     require_once "classes/model/Sequences.php";
     $con = Propel::getConnection('workflow');
     try {
         //fill the default values for new application row
         $this->setAppUid(G::generateUniqueID());
         $this->setAppParent('');
         $this->setAppStatus('DRAFT');
         $this->setProUid($sProUid);
         $this->setAppProcStatus('');
         $this->setAppProcCode('');
         $this->setAppParallel('N');
         $this->setAppInitUser($sUsrUid);
         $this->setAppCurUser($sUsrUid);
         $this->setAppCreateDate('now');
         $this->setAppInitDate('now');
         $this->setAppUpdateDate('now');
         $pin = G::generateCode(4, 'ALPHANUMERIC');
         $this->setAppData(serialize(array('PIN' => $pin)));
         $this->setAppPin(md5($pin));
         $c = new Criteria();
         $c->clearSelectColumns();
         $oSequences = new Sequences();
         $oSequences->lockSequenceTable();
         $maxNumber = $oSequences->getSequeceNumber("APP_NUMBER");
         $this->setAppNumber($maxNumber);
         $oSequences->changeSequence('APP_NUMBER', $maxNumber);
         $oSequences->unlockSequenceTable();
         if ($this->validate()) {
             $con->begin();
             $res = $this->save();
             $con->commit();
             //to do: ID_CASE in translation $this->setAppTitle(G::LoadTranslation('ID_CASE') . $maxNumber);
             $lang = defined('SYS_LANG') ? SYS_LANG : 'en';
             Content::insertContent('APP_TITLE', '', $this->getAppUid(), $lang, '#' . $maxNumber);
             Content::insertContent('APP_DESCRIPTION', '', $this->getAppUid(), $lang, '');
             //Content::insertContent('APP_PROC_CODE', '', $this->getAppUid(), $lang, '');
             $con->commit();
             return $this->getAppUid();
         } else {
             $msg = '';
             foreach ($this->getValidationFailures() as $objValidationFailure) {
                 $msg .= $objValidationFailure->getMessage() . "<br/>";
             }
             throw new PropelException('The APPLICATION row cannot be created!', new PropelException($msg));
         }
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
 public function generateInfoSupport()
 {
     require_once PATH_CONTROLLERS . "installer.php";
     $params = array();
     $oServerConf =& serverConf::getSingleton();
     $pluginRegistry =& PMPluginRegistry::getSingleton();
     $licenseManager =& pmLicenseManager::getSingleton();
     //License Information:
     $activeLicense = $licenseManager->getActiveLicense();
     $licenseInfo = array();
     $noInclude = array('licensedfeaturesList', 'result', 'serial');
     foreach ($licenseManager as $index => $value) {
         if (!in_array($index, $noInclude)) {
             $licenseInfo[$index] = G::sanitizeInput($value);
         }
     }
     $params['l'] = $licenseInfo;
     //Operative System version (Linux, Windows)
     try {
         $os = '';
         if (file_exists('/etc/redhat-release')) {
             $fnewsize = filesize('/etc/redhat-release');
             $fp = fopen('/etc/redhat-release', 'r');
             $os = trim(fread($fp, $fnewsize));
             fclose($fp);
         }
         $os .= " (" . PHP_OS . ")";
     } catch (Exception $e) {
     }
     $params['s'] = $os;
     //On premise or cloud
     $licInfo = $oServerConf->getProperty('LICENSE_INFO');
     $params['lt'] = isset($licInfo[SYS_SYS]) ? isset($licInfo[SYS_SYS]['TYPE']) ? $licInfo[SYS_SYS]['TYPE'] : '' : '';
     //ProcessMaker Version
     $params['v'] = System::getVersion();
     if (file_exists(PATH_DATA . 'log/upgrades.log')) {
         $params['pmu'] = serialize(file_get_contents(PATH_DATA . 'log/upgrades.log', 'r'));
     } else {
         $params['pmu'] = serialize(G::LoadTranslation('ID_UPGRADE_NEVER_UPGRADE'));
     }
     //Database server Version (MySQL version)
     $installer = new Installer();
     $systemInfo = $installer->getSystemInfo();
     try {
         $params['mysql'] = mysql_get_server_info();
     } catch (Exception $e) {
         $params['mysql'] = '';
     }
     //PHP Version
     $params['php'] = $systemInfo->php->version;
     //Apache - IIS Version
     try {
         $params['apache'] = apache_get_version();
     } catch (Exception $e) {
         $params['apache'] = '';
     }
     //Installed Plugins (license info?)
     $arrayAddon = array();
     if (file_exists(PATH_DATA_SITE . "ee")) {
         $arrayAddon = unserialize(trim(file_get_contents(PATH_DATA_SITE . "ee")));
     }
     $plugins = array();
     foreach ($arrayAddon as $addon) {
         $sFileName = substr($addon["sFilename"], 0, strpos($addon["sFilename"], "-"));
         if (file_exists(PATH_PLUGINS . $sFileName . ".php")) {
             $plugin = array();
             $addonDetails = $pluginRegistry->getPluginDetails($sFileName . ".php");
             $plugin['name'] = $addonDetails->sNamespace;
             $plugin['description'] = $addonDetails->sDescription;
             $plugin['version'] = $addonDetails->iVersion;
             $plugin['enable'] = $addonDetails->enabled;
             $plugins[] = $plugin;
         }
     }
     $params['pl'] = $plugins;
     //Number of Users registered in PM. Including LDAP users and PM users.
     require_once "classes/model/RbacUsers.php";
     $criteria = new Criteria("rbac");
     $criteria->addSelectColumn(RbacUsersPeer::USR_AUTH_TYPE);
     $criteria->addSelectColumn("COUNT(" . RbacUsersPeer::USR_UID . ") AS USERS_NUMBER");
     $criteria->add(RbacUsersPeer::USR_UID, null, Criteria::ISNOTNULL);
     $criteria->addGroupByColumn(RbacUsersPeer::USR_AUTH_TYPE);
     $rs = RbacUsersPeer::doSelectRS($criteria);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $users = array('local' => 0);
     while ($rs->next()) {
         $row = $rs->getRow();
         if ($row['USR_AUTH_TYPE'] == '' || $row['USR_AUTH_TYPE'] == 'MYSQL') {
             $users['local'] = (int) $users['local'] + (int) $row['USERS_NUMBER'];
         } else {
             $users['USR_AUTH_TYPE'] = $row['USERS_NUMBER'];
         }
     }
     $params['u'] = $users;
     //Number of cases.
     $oSequences = new Sequences();
     $maxNumber = $oSequences->getSequeceNumber("APP_NUMBER");
     $params['c'] = $maxNumber - 1;
     //Number of active processes.
     $criteria = new Criteria("workflow");
     $criteria->addSelectColumn(ProcessPeer::PRO_STATUS);
     $criteria->addSelectColumn("COUNT(PROCESS.PRO_UID) AS NUMBER_PROCESS");
     $criteria->addGroupByColumn(ProcessPeer::PRO_STATUS);
     $rs = UsersPeer::doSelectRS($criteria);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $process = array();
     while ($rs->next()) {
         $row = $rs->getRow();
         $process[$row['PRO_STATUS']] = $row['NUMBER_PROCESS'];
     }
     $params['p'] = $process;
     //Country/city (Timezone)
     $params['t'] = defined('TIME_ZONE') && TIME_ZONE != "Unknown" ? TIME_ZONE : date_default_timezone_get();
     $params['w'] = count(System::listWorkspaces());
     $support = PATH_DATA_SITE . G::sanitizeString($licenseManager->info['FIRST_NAME'] . '-' . $licenseManager->info['LAST_NAME'] . '-' . SYS_SYS . '-' . date('YmdHis'), false, false) . '.spm';
     file_put_contents($support, serialize($params));
     G::streamFile($support, true);
     G::rm_dir($support);
 }