Ejemplo n.º 1
0
 public function create($arrayData)
 {
     $cnn = Propel::getConnection(OauthClientsPeer::DATABASE_NAME);
     try {
         $cnn->begin();
         $id = G::generateCode(32, "ALPHA");
         $secret = G::generateUniqueID();
         $this->setClientId($id);
         $this->setClientSecret($secret);
         $this->setClientName($arrayData["CLIENT_NAME"]);
         $this->setClientDescription($arrayData["CLIENT_DESCRIPTION"]);
         $this->setClientWebsite($arrayData["CLIENT_WEBSITE"]);
         $this->setRedirectUri($arrayData["REDIRECT_URI"]);
         $this->setUsrUid($arrayData["USR_UID"]);
         if ($this->validate()) {
             $result = $this->save();
             $cnn->commit();
             return array("CLIENT_ID" => $id, "CLIENT_SECRET" => $secret);
         } else {
             $cnn->rollback();
             throw new Exception("Failed Validation in class \"" . get_class($this) . "\".");
         }
     } catch (Exception $e) {
         $cnn->rollback();
         throw $e;
     }
 }
Ejemplo n.º 2
0
 /**
  * @covers G::generateCode
  * @todo   Implement testGenerateCode().
  */
 public function testGenerateCode()
 {
     $uid = G::generateCode();
     $this->assertTrue(is_numeric($uid) && strlen($uid) == 4);
     $uid = G::generateCode(10);
     $this->assertTrue(is_numeric($uid) && strlen($uid) == 10);
     $uid = G::generateCode('ALPHA');
     $this->assertTrue(is_string($uid) && strlen($uid) == 4);
 }
Ejemplo n.º 3
0
<?php

switch ($_SERVER['REQUEST_METHOD']) {
    case 'GET':
        $G_PUBLISH = new Publisher();
        $tpl = array_key_exists('l', $_GET) ? 'oauth2/registration_done' : 'oauth2/register';
        $G_PUBLISH->AddContent('view', $tpl);
        G::RenderPage('publish', 'minimal');
        break;
    case 'POST':
        $data = $_POST['form'];
        $clientId = G::generateCode(32, 'ALPHA');
        $secret = G::generateUniqueID();
        $client = new OauthClients();
        $client->setClientId($clientId);
        $client->setClientSecret($secret);
        $client->setClientName($data['name']);
        $client->setClientDescription($data['description']);
        $client->setClientWebsite($data['web_site']);
        $client->setRedirectUri($data['callback_url']);
        $client->setUsrUid($_SESSION['USER_LOGGED']);
        $client->save();
        $data['clientId'] = $clientId;
        $data['secret'] = $secret;
        header('location: register?l=' . base64_encode(json_encode($data)));
        break;
}
Ejemplo n.º 4
0
/**
 *
 * @method
 *
 * Creates a random string of letters and/or numbers of a specified length,which
 * can be used as the PINs (public identification numbers) and codes for cases.
 *
 * @name generateCode
 * @label generate Code
 * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#generateCode.28.29
 *
 * @param int | $iDigits = 4 | Number of characters | The number of characters to be generated.
 * @param string(32) | $sType="NUMERIC" | Type of characters | The type of of characters to be generated
 * @return string | $generateString | Generated string | The generated string of random characters.
 *
 */
function generateCode($iDigits = 4, $sType = 'NUMERIC')
{
    return G::generateCode($iDigits, $sType);
}
Ejemplo n.º 5
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;
     }
 }
Ejemplo n.º 6
0
 /**
  * Creates the Application
  *
  * @param
  *   $sProUid the process id
  *   $sUsrUid the userid
  * @return     void
  */
 public function create($sProUid, $sUsrUid)
 {
     $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();
         $c->addSelectColumn('MAX(' . ApplicationPeer::APP_NUMBER . ')');
         //the appnumber is based in all processes
         //active, not only in the specified
         //process guid
         $result = ApplicationPeer::doSelectRS($c);
         $result->next();
         $row = $result->getRow();
         $maxNumber = $row[0] + 1;
         $this->setAppNumber($maxNumber);
         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;
     }
 }