예제 #1
0
 /**
  * Index Action
  *
  * @param string $httpData (opional)
  */
 public function index($httpData)
 {
     $proUid = isset($httpData->prj_uid) ? $httpData->prj_uid : '';
     $appUid = isset($httpData->app_uid) ? $httpData->app_uid : '';
     $proReadOnly = isset($httpData->prj_readonly) ? $httpData->prj_readonly : 'false';
     $client = $this->getClientCredentials();
     if (isset($httpData->tracker_designer) && $httpData->tracker_designer == 1) {
         $client["tracker_designer"] = 1;
     }
     $authCode = $this->getAuthorizationCode($client);
     $debug = false;
     //System::isDebugMode();
     $loader = Maveriks\Util\ClassLoader::getInstance();
     $loader->add(PATH_TRUNK . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2");
     $request = array('grant_type' => 'authorization_code', 'code' => $authCode);
     $server = array('REQUEST_METHOD' => 'POST');
     $headers = array("PHP_AUTH_USER" => $client['CLIENT_ID'], "PHP_AUTH_PW" => $client['CLIENT_SECRET'], "Content-Type" => "multipart/form-data;", "Authorization" => "Basic " . base64_encode($client['CLIENT_ID'] . ":" . $client['CLIENT_SECRET']));
     $request = new \OAuth2\Request(array(), $request, array(), array(), array(), $server, null, $headers);
     $oauthServer = new \ProcessMaker\Services\OAuth2\Server();
     $response = $oauthServer->postToken($request, true);
     $clientToken = $response->getParameters();
     $clientToken["client_id"] = $client['CLIENT_ID'];
     $clientToken["client_secret"] = $client['CLIENT_SECRET'];
     $consolidated = 0;
     $enterprise = 0;
     $distribution = 0;
     /*----------------------------------********---------------------------------*/
     $this->setVar('prj_uid', $proUid);
     $this->setVar('app_uid', $appUid);
     $this->setVar('consolidated', $consolidated);
     $this->setVar('enterprise', $enterprise);
     $this->setVar('prj_readonly', $proReadOnly);
     $this->setVar('credentials', base64_encode(json_encode($clientToken)));
     $this->setVar('isDebugMode', $debug);
     $this->setVar("distribution", $distribution);
     $this->setVar("SYS_SYS", SYS_SYS);
     $this->setVar("SYS_LANG", SYS_LANG);
     $this->setVar("SYS_SKIN", SYS_SKIN);
     if ($debug) {
         if (!file_exists(PATH_HTML . "lib-dev/pmUI/build.cache")) {
             throw new RuntimeException("Development JS Files were are not generated!.\nPlease execute: \$>rake pmBuildDebug in pmUI project");
         }
         if (!file_exists(PATH_HTML . "lib-dev/mafe/build.cache")) {
             throw new RuntimeException("Development JS Files were are not generated!.\nPlease execute: \$>rake pmBuildDebug in MichelangeloFE project");
         }
         $mafeFiles = file(PATH_HTML . "lib-dev/mafe/build.cache", FILE_IGNORE_NEW_LINES);
         $mafeCssFiles = array();
         $mafeJsFiles = array();
         foreach ($mafeFiles as $file) {
             if (substr($file, -3) == ".js") {
                 $mafeJsFiles[] = $file;
             } else {
                 $mafeCssFiles[] = $file;
             }
         }
         $this->setVar('pmuiJsCacheFile', file(PATH_HTML . "lib-dev/pmUI/build.cache", FILE_IGNORE_NEW_LINES));
         $this->setVar('pmuiCssCacheFile', file(PATH_HTML . "lib-dev/pmUI/css.cache", FILE_IGNORE_NEW_LINES));
         $this->setVar('designerCacheFile', file(PATH_HTML . "lib-dev/mafe/applications.cache", FILE_IGNORE_NEW_LINES));
         $this->setVar('mafeJsFiles', $mafeJsFiles);
         $this->setVar('mafeCssFiles', $mafeCssFiles);
     } else {
         $buildhashFile = PATH_HTML . "lib/buildhash";
         if (!file_exists($buildhashFile)) {
             throw new RuntimeException("CSS and JS Files were are not generated!.\nPlease review install process");
         }
         $buildhash = file_get_contents($buildhashFile);
         $this->setVar('buildhash', $buildhash);
     }
     $translationMafe = "/translations/translationsMafe.js";
     $this->setVar('translationMafe', $translationMafe);
     if (!file_exists(PATH_HTML . "translations" . PATH_SEP . 'translationsMafe' . ".js")) {
         $translation = new Translation();
         $translation->generateFileTranslationMafe();
     }
     $this->setVar('sys_skin', SYS_SKIN);
     //Verify user
     $criteria = new Criteria('workflow');
     $criteria->addSelectColumn(OauthAccessTokensPeer::ACCESS_TOKEN);
     $criteria->addSelectColumn(OauthAccessTokensPeer::USER_ID);
     $criteria->add(OauthAccessTokensPeer::ACCESS_TOKEN, $clientToken['access_token'], Criteria::EQUAL);
     $rsCriteria = OauthAccessTokensPeer::doSelectRS($criteria);
     $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     if ($rsCriteria->next()) {
         $row = $rsCriteria->getRow();
         $user = new \ProcessMaker\BusinessModel\User();
         if ($user->checkPermission($row['USER_ID'], 'PM_FACTORY')) {
             $this->setView('designer/index');
         } else {
             $this->setVar('accessDenied', G::LoadTranslation('ID_ACCESS_DENIED'));
             $this->setView('designer/accessDenied');
         }
     }
     $this->render();
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = OauthAccessTokensPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setAccessToken($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setClientId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setUserId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setExpires($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setScope($arr[$keys[4]]);
     }
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(OauthAccessTokensPeer::ACCESS_TOKEN, $pks, Criteria::IN);
         $objs = OauthAccessTokensPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
예제 #4
0
 public function getAll($arrayFilterData = array(), $sortField = "", $sortDir = "", $start = 0, $limit = 25)
 {
     //SQL
     $criteria = new Criteria("workflow");
     $criteria->addSelectColumn(OauthAccessTokensPeer::ACCESS_TOKEN);
     $criteria->addSelectColumn(OauthAccessTokensPeer::CLIENT_ID);
     $criteria->addSelectColumn(OauthAccessTokensPeer::USER_ID);
     $criteria->addSelectColumn(OauthAccessTokensPeer::EXPIRES);
     $criteria->addSelectColumn(OauthAccessTokensPeer::SCOPE);
     $criteria->addSelectColumn(OauthClientsPeer::CLIENT_NAME);
     $criteria->addSelectColumn(OauthClientsPeer::CLIENT_DESCRIPTION);
     $criteria->addJoin(OauthAccessTokensPeer::CLIENT_ID, OauthClientsPeer::CLIENT_ID, Criteria::LEFT_JOIN);
     $criteria->add(OauthAccessTokensPeer::EXPIRES, date('Y-m-d H:i:s'), Criteria::GREATER_THAN);
     if ($arrayFilterData && isset($arrayFilterData["USER_ID"]) && $arrayFilterData["USER_ID"] != "") {
         $criteria->add(OauthAccessTokensPeer::USER_ID, $arrayFilterData["USER_ID"], Criteria::EQUAL);
     }
     if ($sortField && $sortField != "") {
         switch ($sortField) {
             case "CLIENT_NAME":
             case "CLIENT_DESCRIPTION":
                 $sortField = OauthClientsPeer::TABLE_NAME . "." . $sortField;
                 break;
             default:
                 $sortField = OauthAccessTokensPeer::TABLE_NAME . "." . $sortField;
                 break;
         }
     } else {
         $sortField = OauthClientsPeer::CLIENT_NAME;
     }
     if ($sortDir && $sortDir == "DESC") {
         $criteria->addDescendingOrderByColumn($sortField);
     } else {
         $criteria->addAscendingOrderByColumn($sortField);
     }
     //Number records total
     $criteriaCount = clone $criteria;
     $criteriaCount->clearSelectColumns();
     $criteriaCount->addSelectColumn("COUNT(" . OauthAccessTokensPeer::ACCESS_TOKEN . ") AS NUM_REC");
     $rsCriteriaCount = OauthAccessTokensPeer::doSelectRS($criteriaCount);
     $rsCriteriaCount->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $rsCriteriaCount->next();
     $row = $rsCriteriaCount->getRow();
     $numRecTotal = $row["NUM_REC"];
     //SQL
     if ($start && $limit && $limit > 0) {
         $criteria->setOffset($start);
         $criteria->setLimit($limit);
     }
     $rsCriteria = OauthAccessTokensPeer::doSelectRS($criteria);
     $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $arrayData = array();
     while ($rsCriteria->next()) {
         $arrayData[] = $rsCriteria->getRow();
     }
     return array("numRecTotal" => $numRecTotal, "data" => $arrayData);
 }