ProcessMaker-MA "Implementacion de la interfaz para los Applications"
- Se ha implementado la interfaz para los Applications
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseOauthAccessTokens.php';
|
||||
require_once ("classes" . PATH_SEP . "model" . PATH_SEP . "om" . PATH_SEP . "BaseOauthAccessTokens.php");
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,6 +13,166 @@ require_once 'classes/model/om/BaseOauthAccessTokens.php';
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class OauthAccessTokens extends BaseOauthAccessTokens {
|
||||
class OauthAccessTokens extends BaseOauthAccessTokens
|
||||
{
|
||||
public function load($oauthAccessTokenId)
|
||||
{
|
||||
try {
|
||||
$oatoken = OauthAccessTokensPeer::retrieveByPK($oauthAccessTokenId);
|
||||
|
||||
if (!is_null($oatoken)) {
|
||||
$arrayField = $oatoken->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($arrayField, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
|
||||
return $arrayField;
|
||||
} else {
|
||||
throw (new Exception("The row \"$oauthAccessTokenId\" in table OAUTH_ACCESS_TOKENS doesn't exist!"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function update($arrayData)
|
||||
{
|
||||
$cnn = Propel::getConnection(OauthAccessTokensPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$cnn->begin();
|
||||
|
||||
$this->load($arrayData["ACCESS_TOKEN"]);
|
||||
$this->fromArray($arrayData, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($this->validate()) {
|
||||
if (isset($arrayData["CLIENT_ID"])) {
|
||||
$this->setClientId($arrayData["CLIENT_ID"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["USER_ID"])) {
|
||||
$this->setUserId($arrayData["USER_ID"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["EXPIRES"])) {
|
||||
$this->setExpires($arrayData["EXPIRES"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["SCOPE"])) {
|
||||
$this->setScope($arrayData["SCOPE"]);
|
||||
}
|
||||
|
||||
$result = $this->save();
|
||||
$result = ($result == 0)? (($contentResult > 0)? 1 : 0) : $result;
|
||||
|
||||
$cnn->commit();
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
$cnn->rollback();
|
||||
|
||||
throw (new Exception("Failed Validation in class \"" . get_class($this) . "\"."));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($oauthAccessTokenId)
|
||||
{
|
||||
$cnn = Propel::getConnection(OauthAccessTokensPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$oclient = OauthAccessTokensPeer::retrieveByPK($oauthAccessTokenId);
|
||||
|
||||
if (!is_null($oclient)) {
|
||||
$cnn->begin();
|
||||
|
||||
$result = $oclient->delete();
|
||||
$cnn->commit();
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
throw (new Exception("The row \"$oauthAccessTokenId\" in table OAUTH_ACCESS_TOKENS doesn't exist!"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// OauthAccessTokens
|
||||
|
||||
} // OauthAccessTokens
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseOauthClients.php';
|
||||
require_once ("classes" . PATH_SEP . "model" . PATH_SEP . "om" . PATH_SEP . "BaseOauthClients.php");
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,6 +13,200 @@ require_once 'classes/model/om/BaseOauthClients.php';
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class OauthClients extends BaseOauthClients {
|
||||
class OauthClients extends BaseOauthClients
|
||||
{
|
||||
public function load($oauthClientId)
|
||||
{
|
||||
try {
|
||||
$oclient = OauthClientsPeer::retrieveByPK($oauthClientId);
|
||||
|
||||
if (!is_null($oclient)) {
|
||||
$arrayField = $oclient->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($arrayField, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
|
||||
return $arrayField;
|
||||
} else {
|
||||
throw (new Exception("The row \"$oauthClientId\" in table OAUTH_CLIENTS doesn't exist!"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public function update($arrayData)
|
||||
{
|
||||
$cnn = Propel::getConnection(OauthClientsPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$cnn->begin();
|
||||
|
||||
$this->load($arrayData["CLIENT_ID"]);
|
||||
$this->fromArray($arrayData, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($this->validate()) {
|
||||
if (isset($arrayData["CLIENT_NAME"])) {
|
||||
$this->setClientName($arrayData["CLIENT_NAME"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["CLIENT_DESCRIPTION"])) {
|
||||
$this->setClientDescription($arrayData["CLIENT_DESCRIPTION"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["CLIENT_WEBSITE"])) {
|
||||
$this->setClientWebsite($arrayData["CLIENT_WEBSITE"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["REDIRECT_URI"])) {
|
||||
$this->setRedirectUri($arrayData["REDIRECT_URI"]);
|
||||
}
|
||||
|
||||
$result = $this->save();
|
||||
$result = ($result == 0)? (($contentResult > 0)? 1 : 0) : $result;
|
||||
|
||||
$cnn->commit();
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
$cnn->rollback();
|
||||
|
||||
throw (new Exception("Failed Validation in class \"" . get_class($this) . "\"."));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($oauthClientId)
|
||||
{
|
||||
$cnn = Propel::getConnection(OauthClientsPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$oclient = OauthClientsPeer::retrieveByPK($oauthClientId);
|
||||
|
||||
if (!is_null($oclient)) {
|
||||
$cnn->begin();
|
||||
|
||||
$result = $oclient->delete();
|
||||
$cnn->commit();
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
throw (new Exception("The row \"$oauthClientId\" in table OAUTH_CLIENTS doesn't exist!"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAll($arrayFilterData = array(), $sortField = "", $sortDir = "", $start = 0, $limit = 25)
|
||||
{
|
||||
//SQL
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(OauthClientsPeer::CLIENT_ID);
|
||||
$criteria->addSelectColumn(OauthClientsPeer::CLIENT_SECRET);
|
||||
$criteria->addSelectColumn(OauthClientsPeer::CLIENT_NAME);
|
||||
$criteria->addSelectColumn(OauthClientsPeer::CLIENT_DESCRIPTION);
|
||||
$criteria->addSelectColumn(OauthClientsPeer::CLIENT_WEBSITE);
|
||||
$criteria->addSelectColumn(OauthClientsPeer::REDIRECT_URI);
|
||||
$criteria->addSelectColumn(OauthClientsPeer::USR_UID);
|
||||
|
||||
if ($arrayFilterData && isset($arrayFilterData["USR_UID"]) && $arrayFilterData["USR_UID"] != "") {
|
||||
$criteria->add(OauthClientsPeer::USR_UID, $arrayFilterData["USR_UID"], Criteria::EQUAL);
|
||||
}
|
||||
|
||||
if ($arrayFilterData && isset($arrayFilterData["SEARCH"]) && $arrayFilterData["SEARCH"] != "") {
|
||||
//$criteria->add(
|
||||
// $criteria->getNewCriterion(OauthClientsPeer::CLIENT_NAME, "%" . $arrayFilterData["SEARCH"] . "%", Criteria::LIKE)->addOr(
|
||||
// $criteria->getNewCriterion(OauthClientsPeer::CLIENT_DESCRIPTION, "%" . $arrayFilterData["SEARCH"] . "%", Criteria::LIKE))->addOr(
|
||||
// $criteria->getNewCriterion(OauthClientsPeer::CLIENT_WEBSITE, "%" . $arrayFilterData["SEARCH"] . "%", Criteria::LIKE))->addOr(
|
||||
// $criteria->getNewCriterion(OauthClientsPeer::REDIRECT_URI, "%" . $arrayFilterData["SEARCH"] . "%", Criteria::LIKE))
|
||||
//);
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(OauthClientsPeer::CLIENT_NAME, "%" . $arrayFilterData["SEARCH"] . "%", Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(OauthClientsPeer::CLIENT_DESCRIPTION, "%" . $arrayFilterData["SEARCH"] . "%", Criteria::LIKE))
|
||||
);
|
||||
}
|
||||
|
||||
$sortField = ($sortField && $sortField != "")? OauthClientsPeer::TABLE_NAME . "." . $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(" . OauthClientsPeer::CLIENT_ID . ") AS NUM_REC");
|
||||
|
||||
$rsCriteriaCount = OauthClientsPeer::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 = OauthClientsPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = array();
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$arrayData[] = $rsCriteria->getRow();
|
||||
}
|
||||
|
||||
return array("numRecTotal" => $numRecTotal, "data" => $arrayData);
|
||||
}
|
||||
}
|
||||
|
||||
// OauthClients
|
||||
|
||||
} // OauthClients
|
||||
|
||||
17
workflow/engine/methods/oauth2/accessTokenSetup.php
Normal file
17
workflow/engine/methods/oauth2/accessTokenSetup.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$config = array();
|
||||
$config["pageSize"] = 20;
|
||||
|
||||
$arrayScope = array(
|
||||
array("value" => "view_processes", "label" => "View Processes"),
|
||||
array("value" => "edit_processes", "label" => "Edit Processes")
|
||||
);
|
||||
|
||||
$headPublisher = &headPublisher::getSingleton();
|
||||
$headPublisher->addContent("oauth2" . PATH_SEP . "accessTokenSetup"); //Adding a HTML file .html
|
||||
$headPublisher->addExtJsScript("oauth2" . PATH_SEP . "accessTokenSetup", false); //Adding a JavaScript file .js
|
||||
$headPublisher->assign("CONFIG", $config);
|
||||
$headPublisher->assign("SCOPE", $arrayScope);
|
||||
|
||||
G::RenderPage("publish", "extJs");
|
||||
|
||||
63
workflow/engine/methods/oauth2/accessTokenSetupAjax.php
Normal file
63
workflow/engine/methods/oauth2/accessTokenSetupAjax.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
$option = (isset($_POST["option"]))? $_POST["option"] : "";
|
||||
|
||||
$response = array();
|
||||
|
||||
switch ($option) {
|
||||
case "UPD":
|
||||
$oauthAccessTokenId = $_POST["oauthAccessTokenId"];
|
||||
$scope = $_POST["scope"];
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
"ACCESS_TOKEN" => $oauthAccessTokenId,
|
||||
"SCOPE" => $scope
|
||||
);
|
||||
|
||||
$oatoken = new OauthAccessTokens();
|
||||
$result = $oatoken->update($arrayData);
|
||||
|
||||
$response["status"] = "OK";
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "DEL":
|
||||
$oauthAccessTokenId = $_POST["oauthAccessTokenId"];
|
||||
|
||||
try {
|
||||
$oatoken = new OauthAccessTokens();
|
||||
$result = $oatoken->remove($oauthAccessTokenId);
|
||||
|
||||
$response["status"] = "OK";
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "LST":
|
||||
$pageSize = $_POST["pageSize"];
|
||||
|
||||
$sortField = (isset($_POST["sort"]))? $_POST["sort"]: "";
|
||||
$sortDir = (isset($_POST["dir"]))? $_POST["dir"]: "";
|
||||
$start = (isset($_POST["start"]))? $_POST["start"]: 0;
|
||||
$limit = (isset($_POST["limit"]))? $_POST["limit"]: $pageSize;
|
||||
|
||||
try {
|
||||
$oatoken = new OauthAccessTokens();
|
||||
$result = $oatoken->getAll(array("USER_ID" => $_SESSION["USER_LOGGED"]), $sortField, $sortDir, $start, $limit);
|
||||
|
||||
$response["status"] = "OK";
|
||||
$response["success"] = true;
|
||||
$response["resultTotal"] = $result["numRecTotal"];
|
||||
$response["resultRoot"] = $result["data"];
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
echo G::json_encode($response);
|
||||
|
||||
12
workflow/engine/methods/oauth2/clientSetup.php
Normal file
12
workflow/engine/methods/oauth2/clientSetup.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
$config = array();
|
||||
$config["pageSize"] = 20;
|
||||
|
||||
$headPublisher = &headPublisher::getSingleton();
|
||||
$headPublisher->addContent("oauth2" . PATH_SEP . "clientSetup"); //Adding a HTML file .html
|
||||
$headPublisher->addExtJsScript("oauth2" . PATH_SEP . "clientSetup", false); //Adding a JavaScript file .js
|
||||
$headPublisher->assign("CONFIG", $config);
|
||||
$headPublisher->assign("CREATE_CLIENT", (isset($_GET["create_app"]))? 1 : 0);
|
||||
|
||||
G::RenderPage("publish", "extJs");
|
||||
|
||||
97
workflow/engine/methods/oauth2/clientSetupAjax.php
Normal file
97
workflow/engine/methods/oauth2/clientSetupAjax.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
$option = (isset($_POST["option"]))? $_POST["option"] : "";
|
||||
|
||||
$response = array();
|
||||
|
||||
switch ($option) {
|
||||
case "INS":
|
||||
$name = $_POST["name"];
|
||||
$description = $_POST["description"];
|
||||
$webSite = $_POST["webSite"];
|
||||
$redirectUri = $_POST["redirectUri"];
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
//"CLIENT_ID" => "",
|
||||
"CLIENT_NAME" => $name,
|
||||
"CLIENT_DESCRIPTION" => $description,
|
||||
"CLIENT_WEBSITE" => $webSite,
|
||||
"REDIRECT_URI" => $redirectUri,
|
||||
"USR_UID" => $_SESSION["USER_LOGGED"]
|
||||
);
|
||||
|
||||
$oclient = new OauthClients();
|
||||
$result = $oclient->create($arrayData);
|
||||
|
||||
$response["status"] = "OK";
|
||||
$response["data"] = $result;
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "UPD":
|
||||
$oauthClientId = $_POST["oauthClientId"];
|
||||
$name = $_POST["name"];
|
||||
$description = $_POST["description"];
|
||||
$webSite = $_POST["webSite"];
|
||||
$redirectUri = $_POST["redirectUri"];
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
"CLIENT_ID" => $oauthClientId,
|
||||
"CLIENT_NAME" => $name,
|
||||
"CLIENT_DESCRIPTION" => $description,
|
||||
"CLIENT_WEBSITE" => $webSite,
|
||||
"REDIRECT_URI" => $redirectUri,
|
||||
"USR_UID" => $_SESSION["USER_LOGGED"]
|
||||
);
|
||||
|
||||
$oclient = new OauthClients();
|
||||
$result = $oclient->update($arrayData);
|
||||
|
||||
$response["status"] = "OK";
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "DEL":
|
||||
$oauthClientId = $_POST["oauthClientId"];
|
||||
|
||||
try {
|
||||
$oclient = new OauthClients();
|
||||
$result = $oclient->remove($oauthClientId);
|
||||
|
||||
$response["status"] = "OK";
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "LST":
|
||||
$pageSize = $_POST["pageSize"];
|
||||
$search = $_POST["search"];
|
||||
|
||||
$sortField = (isset($_POST["sort"]))? $_POST["sort"]: "";
|
||||
$sortDir = (isset($_POST["dir"]))? $_POST["dir"]: "";
|
||||
$start = (isset($_POST["start"]))? $_POST["start"]: 0;
|
||||
$limit = (isset($_POST["limit"]))? $_POST["limit"]: $pageSize;
|
||||
|
||||
try {
|
||||
$oclient = new OauthClients();
|
||||
$result = $oclient->getAll(array("USR_UID" => $_SESSION["USER_LOGGED"], "SEARCH" => $search), $sortField, $sortDir, $start, $limit);
|
||||
|
||||
$response["status"] = "OK";
|
||||
$response["success"] = true;
|
||||
$response["resultTotal"] = $result["numRecTotal"];
|
||||
$response["resultRoot"] = $result["data"];
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
echo G::json_encode($response);
|
||||
|
||||
8
workflow/engine/methods/users/userMain.php
Normal file
8
workflow/engine/methods/users/userMain.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$headPublisher = &headPublisher::getSingleton();
|
||||
$headPublisher->addContent("users" . PATH_SEP . "userMain"); //Adding a html file .html
|
||||
$headPublisher->addExtJsScript("users" . PATH_SEP . "userMain", true); //Adding a javascript file .js
|
||||
$headPublisher->assign("CREATE_CLIENT", (isset($_GET["create_app"]))? 1 : 0);
|
||||
|
||||
G::RenderPage("publish", "extJs");
|
||||
|
||||
2
workflow/engine/templates/oauth2/accessTokenSetup.html
Normal file
2
workflow/engine/templates/oauth2/accessTokenSetup.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<div></div>
|
||||
|
||||
434
workflow/engine/templates/oauth2/accessTokenSetup.js
Normal file
434
workflow/engine/templates/oauth2/accessTokenSetup.js
Normal file
@@ -0,0 +1,434 @@
|
||||
Ext.namespace("accessTokenSetup");
|
||||
|
||||
accessTokenSetup.application = {
|
||||
init: function ()
|
||||
{
|
||||
var OACCESSTOKENOPTION = "";
|
||||
var loadMaskData = new Ext.LoadMask(Ext.getBody(), {msg: _("ID_LOADING_GRID")});
|
||||
|
||||
function oauthAccessTokenProcessAjax(option, oauthAccessTokenId)
|
||||
{
|
||||
//Message
|
||||
var msg = "";
|
||||
|
||||
switch (option) {
|
||||
case "UPD":
|
||||
msg = "Update data...";
|
||||
break;
|
||||
case "DEL":
|
||||
msg = "Delete data...";
|
||||
break;
|
||||
//case "LST":
|
||||
// break;
|
||||
}
|
||||
|
||||
var loadMaskAux = new Ext.LoadMask(Ext.getBody(), {msg: msg});
|
||||
loadMaskAux.show();
|
||||
|
||||
//Data
|
||||
var p;
|
||||
|
||||
switch (option) {
|
||||
case "UPD":
|
||||
var arrayCheckbox = Ext.getCmp("chkgrpScope").getValue();
|
||||
var scope = "";
|
||||
|
||||
for (var i = 0; i <= arrayCheckbox.length - 1; i++) {
|
||||
scope = scope + ((scope != "")? " " : "") + arrayCheckbox[i].value;
|
||||
}
|
||||
|
||||
p = {
|
||||
option: option,
|
||||
oauthAccessTokenId: oauthAccessTokenId,
|
||||
scope: scope
|
||||
};
|
||||
break;
|
||||
case "DEL":
|
||||
p = {
|
||||
option: option,
|
||||
oauthAccessTokenId: oauthAccessTokenId
|
||||
};
|
||||
break;
|
||||
//case "LST":
|
||||
// break;
|
||||
}
|
||||
|
||||
Ext.Ajax.request({
|
||||
url: "../oauth2/accessTokenSetupAjax",
|
||||
method: "POST",
|
||||
params: p,
|
||||
|
||||
success: function (response, opts)
|
||||
{
|
||||
var dataResponse = Ext.util.JSON.decode(response.responseText);
|
||||
|
||||
switch (option) {
|
||||
case "UPD":
|
||||
case "DEL":
|
||||
if (dataResponse.status) {
|
||||
if (dataResponse.status == "OK") {
|
||||
pagingData.moveFirst();
|
||||
} else {
|
||||
Ext.MessageBox.alert(_("ID_ALERT"), dataResponse.message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//case "LST":
|
||||
// break;
|
||||
}
|
||||
|
||||
loadMaskAux.hide();
|
||||
},
|
||||
failure: function (response, opts)
|
||||
{
|
||||
loadMaskAux.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function oauthAccessTokenSetForm(option, oauthAccessTokenId)
|
||||
{
|
||||
switch (option) {
|
||||
case "UPD":
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
Ext.getCmp("oauthAccessTokenId").setValue(record.get("ACCESS_TOKEN")); //oauthAccessTokenId
|
||||
Ext.getCmp("lblClientName").setText(record.get("CLIENT_NAME"));
|
||||
|
||||
winData.setTitle("Edit Application");
|
||||
winData.show();
|
||||
|
||||
Ext.getCmp("btnSubmit").btnEl.dom.innerHTML = "Edit Application";
|
||||
|
||||
for (var i = 0; i <= SCOPE.length - 1; i++) {
|
||||
Ext.getCmp("chkgrpScope").setValue("chk" + SCOPE[i].value, false)
|
||||
}
|
||||
|
||||
var arrayScope = record.get("SCOPE").split(" ");
|
||||
|
||||
for (var i = 0; i <= arrayScope.length - 1; i++) {
|
||||
Ext.getCmp("chkgrpScope").setValue("chk" + arrayScope[i], true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Variables
|
||||
var pageSize = parseInt(CONFIG.pageSize);
|
||||
|
||||
//Stores
|
||||
var storeData = new Ext.data.Store({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: "../oauth2/accessTokenSetupAjax",
|
||||
method: "POST"
|
||||
}),
|
||||
|
||||
//baseParams: {"option": "LST", "pageSize": pageSize},
|
||||
|
||||
reader: new Ext.data.JsonReader({
|
||||
totalProperty: "resultTotal",
|
||||
root: "resultRoot",
|
||||
fields: [
|
||||
{name: "ACCESS_TOKEN", type: "string"},
|
||||
{name: "CLIENT_ID", type: "string"},
|
||||
{name: "USER_ID", type: "string"},
|
||||
{name: "EXPIRES", type: "string"},
|
||||
{name: "SCOPE", type: "string"},
|
||||
{name: "CLIENT_NAME", type: "string"},
|
||||
{name: "CLIENT_DESCRIPTION", type: "string"}
|
||||
]
|
||||
}),
|
||||
|
||||
//autoLoad: true, //First call
|
||||
remoteSort: true,
|
||||
|
||||
listeners: {
|
||||
beforeload: function (store, opt)
|
||||
{
|
||||
loadMaskData.show();
|
||||
|
||||
this.baseParams = {
|
||||
option: "LST",
|
||||
pageSize: pageSize
|
||||
};
|
||||
},
|
||||
load: function (store, record, opt)
|
||||
{
|
||||
loadMaskData.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var storePageSize = new Ext.data.SimpleStore({
|
||||
fields: ["size"],
|
||||
data: [["20"], ["30"], ["40"], ["50"], ["100"]],
|
||||
autoLoad: true
|
||||
});
|
||||
|
||||
var chkgrpScopeItems = [];
|
||||
|
||||
for (var i = 0; i <= SCOPE.length - 1; i++) {
|
||||
chkgrpScopeItems.push(
|
||||
{
|
||||
xtype: "checkbox",
|
||||
id: "chk" + SCOPE[i].value,
|
||||
name: "chk" + SCOPE[i].value,
|
||||
value: SCOPE[i].value,
|
||||
boxLabel: SCOPE[i].label
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//Components
|
||||
var winData = new Ext.Window({
|
||||
layout: "fit",
|
||||
width: 400,
|
||||
height: 250,
|
||||
//title: "",
|
||||
modal: true,
|
||||
resizable: false,
|
||||
closeAction: "hide",
|
||||
|
||||
items: [
|
||||
new Ext.FormPanel({
|
||||
id: "frmOauthAccessToken",
|
||||
|
||||
frame: true,
|
||||
labelAlign: "right",
|
||||
labelWidth: 160,
|
||||
autoWidth: true,
|
||||
autoScroll: false,
|
||||
|
||||
defaults: {width: 200},
|
||||
|
||||
items: [
|
||||
{
|
||||
xtype: "hidden",
|
||||
id: "oauthAccessTokenId",
|
||||
name: "oauthAccessTokenId",
|
||||
},
|
||||
{
|
||||
xtype: "label",
|
||||
id: "lblClientName",
|
||||
|
||||
fieldLabel: "Application"
|
||||
},
|
||||
{
|
||||
xtype: "checkboxgroup",
|
||||
id: "chkgrpScope",
|
||||
name: "chkgrpScope",
|
||||
|
||||
fieldLabel: "This Application Can Perform",
|
||||
columns: 1,
|
||||
items: chkgrpScopeItems
|
||||
}
|
||||
]
|
||||
})
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
id: "btnSubmit",
|
||||
//text: "",
|
||||
handler: function ()
|
||||
{
|
||||
oauthAccessTokenProcessAjax(OACCESSTOKENOPTION, Ext.getCmp("oauthAccessTokenId").getValue());
|
||||
|
||||
winData.hide();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: _("ID_CANCEL"),
|
||||
handler: function ()
|
||||
{
|
||||
winData.hide();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var cboPageSize = new Ext.form.ComboBox({
|
||||
id: "cboPageSize",
|
||||
|
||||
mode: "local",
|
||||
triggerAction: "all",
|
||||
store: storePageSize,
|
||||
valueField: "size",
|
||||
displayField: "size",
|
||||
width: 50,
|
||||
editable: false,
|
||||
|
||||
listeners: {
|
||||
select: function (combo, record, index)
|
||||
{
|
||||
pageSize = parseInt(record.data["size"]);
|
||||
|
||||
pagingData.pageSize = pageSize;
|
||||
pagingData.moveFirst();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var pagingData = new Ext.PagingToolbar({
|
||||
id: "pagingData",
|
||||
|
||||
pageSize: pageSize,
|
||||
store: storeData,
|
||||
displayInfo: true,
|
||||
displayMsg: "Displaying data " + "{" + "0" + "}" + " - " + "{" + "1" + "}" + " of " + "{" + "2" + "}",
|
||||
emptyMsg: "No data to display",
|
||||
items: ["-", "Page size:", cboPageSize]
|
||||
});
|
||||
|
||||
var cmodel = new Ext.grid.ColumnModel({
|
||||
defaults: {
|
||||
sortable: true
|
||||
},
|
||||
|
||||
columns: [
|
||||
{id: "ACCESS_TOKEN", dataIndex: "ACCESS_TOKEN", hidden: true, hideable: false},
|
||||
{id: "CLIENT_ID", dataIndex: "CLIENT_ID", hidden: true, hideable: false},
|
||||
{id: "CLIENT_NAME", dataIndex: "CLIENT_NAME", header: "Application", width: 200, align: "left"},
|
||||
{id: "CLIENT_DESCRIPTION", dataIndex: "CLIENT_DESCRIPTION", header: "Description", width: 250, align: "left"},
|
||||
{id: "USER_ID", dataIndex: "USER_ID", hidden: true, hideable: false},
|
||||
{id: "EXPIRES", dataIndex: "EXPIRES", hidden: true, hideable: false},
|
||||
{id: "SCOPE", dataIndex: "SCOPE", hidden: true, hideable: false},
|
||||
{
|
||||
id: "ACTION",
|
||||
dataIndex: "ACCESS_TOKEN",
|
||||
header: "",
|
||||
sortable: false,
|
||||
menuDisabled: true,
|
||||
hideable: false,
|
||||
//width: 75,
|
||||
//align: "center",
|
||||
renderer: function (value, metaData, record, rowIndex, colIndex, store)
|
||||
{
|
||||
var id1 = Ext.id();
|
||||
var id2 = Ext.id();
|
||||
|
||||
setTimeout(
|
||||
function ()
|
||||
{
|
||||
var btn1 = new Ext.Button({
|
||||
text: "Edit",
|
||||
iconCls: "button_menu_ext ss_sprite ss_pencil",
|
||||
renderTo: id1,
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
var sm = grdpnlMain.getSelectionModel();
|
||||
sm.selectRow(rowIndex, true);
|
||||
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
OACCESSTOKENOPTION = "UPD";
|
||||
|
||||
oauthAccessTokenSetForm(OACCESSTOKENOPTION, record.get("ACCESS_TOKEN"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var btn2 = new Ext.Button({
|
||||
text: "Delete",
|
||||
iconCls: "button_menu_ext ss_sprite ss_cross",
|
||||
renderTo: id2,
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
var sm = grdpnlMain.getSelectionModel();
|
||||
sm.selectRow(rowIndex, true);
|
||||
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
Ext.MessageBox.confirm(
|
||||
_("ID_CONFIRM"),
|
||||
"Do you want to delete selected Application?",
|
||||
function (btn)
|
||||
{
|
||||
if (btn == "yes") {
|
||||
OACCESSTOKENOPTION = "DEL";
|
||||
|
||||
oauthAccessTokenProcessAjax(OACCESSTOKENOPTION, record.get("ACCESS_TOKEN"));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
5
|
||||
);
|
||||
|
||||
return "<div style=\"text-align: center; line-height: 0;\"><div id=\"" + id1 + "\" style=\"display: inline-block;\"></div><div id=\"" + id2 + "\" style=\"display: inline-block; margin-left: 0.45em;\"></div></div>";
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var smodel = new Ext.grid.RowSelectionModel({
|
||||
singleSelect: true,
|
||||
listeners: {
|
||||
//
|
||||
}
|
||||
});
|
||||
|
||||
var grdpnlMain = new Ext.grid.GridPanel({
|
||||
id: "grdpnlMain",
|
||||
|
||||
store: storeData,
|
||||
colModel: cmodel,
|
||||
selModel: smodel,
|
||||
|
||||
columnLines: true,
|
||||
viewConfig: {forceFit: true}, //Expand all columns
|
||||
enableColumnResize: true,
|
||||
enableHdMenu: true, //Menu of the column
|
||||
|
||||
//tbar: ["->", txtSearch, btnTextClear, btnSearch],
|
||||
//bbar: pagingData,
|
||||
|
||||
//style: "margin: 0 auto 0 auto;",
|
||||
//width: 550,
|
||||
//height: 450,
|
||||
title: "<div><div style=\"float: left;\">" + "Applications" + "</div><div id=\"divClientSetup\" style=\"float: right;\"></div><div style=\"clear: both; height: 0; line-height:0; font-size: 0;\"></div></div>",
|
||||
border: false,
|
||||
|
||||
listeners: {
|
||||
afterrender: function (grid)
|
||||
{
|
||||
var btn = new Ext.Button({
|
||||
text: " " + "Setup My Applications",
|
||||
iconCls: "button_menu_ext ss_sprite ss_cog",
|
||||
renderTo: "divClientSetup",
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
location.href = "clientSetup";
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Menu context
|
||||
|
||||
//Initialize events
|
||||
cboPageSize.setValue(pageSize);
|
||||
|
||||
grdpnlMain.store.load();
|
||||
|
||||
//Load all panels
|
||||
var viewport = new Ext.Viewport({
|
||||
layout: "fit",
|
||||
autoScroll: false,
|
||||
items: [grdpnlMain]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ext.onReady(accessTokenSetup.application.init, accessTokenSetup.application);
|
||||
|
||||
1
workflow/engine/templates/oauth2/clientSetup.html
Normal file
1
workflow/engine/templates/oauth2/clientSetup.html
Normal file
@@ -0,0 +1 @@
|
||||
<div></div>
|
||||
701
workflow/engine/templates/oauth2/clientSetup.js
Normal file
701
workflow/engine/templates/oauth2/clientSetup.js
Normal file
@@ -0,0 +1,701 @@
|
||||
Ext.namespace("clientSetup");
|
||||
|
||||
clientSetup.application = {
|
||||
init: function ()
|
||||
{
|
||||
var OCLIENTOPTION = "";
|
||||
var loadMaskData = new Ext.LoadMask(Ext.getBody(), {msg: _("ID_LOADING_GRID")});
|
||||
|
||||
function oauthClientProcessAjax(option, oauthClientId)
|
||||
{
|
||||
//Message
|
||||
var msg = "";
|
||||
|
||||
switch (option) {
|
||||
case "INS":
|
||||
msg = "Insert data...";
|
||||
break;
|
||||
case "UPD":
|
||||
msg = "Update data...";
|
||||
break;
|
||||
case "DEL":
|
||||
msg = "Delete data...";
|
||||
break;
|
||||
//case "LST":
|
||||
// break;
|
||||
}
|
||||
|
||||
var loadMaskAux = new Ext.LoadMask(Ext.getBody(), {msg: msg});
|
||||
loadMaskAux.show();
|
||||
|
||||
//Data
|
||||
var p;
|
||||
|
||||
switch (option) {
|
||||
case "INS":
|
||||
p = {
|
||||
option: option,
|
||||
name: Ext.getCmp("txtName").getValue(),
|
||||
description: Ext.getCmp("txtDescription").getValue(),
|
||||
webSite: Ext.getCmp("txtWebSite").getValue(),
|
||||
redirectUri: Ext.getCmp("txtRedirectUri").getValue()
|
||||
};
|
||||
break;
|
||||
case "UPD":
|
||||
p = {
|
||||
option: option,
|
||||
oauthClientId: oauthClientId,
|
||||
name: Ext.getCmp("txtName").getValue(),
|
||||
description: Ext.getCmp("txtDescription").getValue(),
|
||||
webSite: Ext.getCmp("txtWebSite").getValue(),
|
||||
redirectUri: Ext.getCmp("txtRedirectUri").getValue()
|
||||
};
|
||||
break;
|
||||
case "DEL":
|
||||
p = {
|
||||
option: option,
|
||||
oauthClientId: oauthClientId
|
||||
};
|
||||
break;
|
||||
//case "LST":
|
||||
// break;
|
||||
}
|
||||
|
||||
Ext.Ajax.request({
|
||||
url: "../oauth2/clientSetupAjax",
|
||||
method: "POST",
|
||||
params: p,
|
||||
|
||||
success: function (response, opts)
|
||||
{
|
||||
var dataResponse = Ext.util.JSON.decode(response.responseText);
|
||||
|
||||
switch (option) {
|
||||
case "INS":
|
||||
case "UPD":
|
||||
case "DEL":
|
||||
if (dataResponse.status) {
|
||||
if (dataResponse.status == "OK") {
|
||||
pagingData.moveFirst();
|
||||
|
||||
switch (option) {
|
||||
case "INS":
|
||||
dataResponse.data.CLIENT_NAME = Ext.getCmp("txtName").getValue();
|
||||
|
||||
insertSuccessView(dataResponse.data);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Ext.MessageBox.alert(_("ID_ALERT"), dataResponse.message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//case "LST":
|
||||
// break;
|
||||
}
|
||||
|
||||
loadMaskAux.hide();
|
||||
},
|
||||
failure: function (response, opts)
|
||||
{
|
||||
loadMaskAux.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function oauthClientSetForm(option, oauthClientId)
|
||||
{
|
||||
switch (option) {
|
||||
case "INS":
|
||||
Ext.getCmp("oauthClientId").setValue("");
|
||||
Ext.getCmp("txtName").setValue("");
|
||||
Ext.getCmp("txtDescription").setValue("");
|
||||
Ext.getCmp("txtWebSite").setValue("");
|
||||
Ext.getCmp("txtRedirectUri").setValue("");
|
||||
|
||||
Ext.getCmp("txtName").allowBlank = true;
|
||||
|
||||
winData.setTitle("New Application");
|
||||
winData.show();
|
||||
|
||||
Ext.getCmp("btnSubmit").btnEl.dom.innerHTML = "Register Application";
|
||||
|
||||
Ext.getCmp("txtName").allowBlank = false;
|
||||
break;
|
||||
case "UPD":
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
Ext.getCmp("oauthClientId").setValue(record.get("CLIENT_ID")); //oauthClientId
|
||||
Ext.getCmp("txtName").setValue(record.get("CLIENT_NAME"));
|
||||
Ext.getCmp("txtDescription").setValue(record.get("CLIENT_DESCRIPTION"));
|
||||
Ext.getCmp("txtWebSite").setValue(record.get("CLIENT_WEBSITE"));
|
||||
Ext.getCmp("txtRedirectUri").setValue(record.get("REDIRECT_URI"));
|
||||
|
||||
Ext.getCmp("txtName").allowBlank = true;
|
||||
|
||||
winData.setTitle("Edit Application");
|
||||
winData.show();
|
||||
|
||||
Ext.getCmp("btnSubmit").btnEl.dom.innerHTML = "Edit Application";
|
||||
|
||||
Ext.getCmp("txtName").allowBlank = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function insertSuccessView(data)
|
||||
{
|
||||
var html = "Your application \"" + data.CLIENT_NAME + "\" was registered successfully!" + "<br /><br />";
|
||||
html = html + "<h3>" + "Application Credentials" + "</h3><br />";
|
||||
html = html + " <b>* " + "Client ID" + ":</b> " + data.CLIENT_ID + "<br />";
|
||||
html = html + " <b>* " + "Client Secret" + ":</b> " + data.CLIENT_SECRET + "<br /><br />";
|
||||
html = html + "<h3>" + "Next Steps" + "</h3><br />";
|
||||
html = html + " <b>* </b>" + "Make authorize requests" + "<br />";
|
||||
html = html + " <b>* </b>" + "Get access tokens" + "<br />";
|
||||
|
||||
var formItems = Ext.getCmp("frmInsertSuccessView").form.items;
|
||||
formItems.items[0].setValue(html);
|
||||
|
||||
winInsertSuccess.show();
|
||||
}
|
||||
|
||||
function detailView()
|
||||
{
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
var html = "Your application \"" + record.get("CLIENT_NAME") + "\"" + "<br /><br />";
|
||||
html = html + "<h3>" + "Application Details" + "</h3><br />";
|
||||
html = html + " <b>* " + "Description" + ":</b> " + record.get("CLIENT_DESCRIPTION") + "<br />";
|
||||
html = html + " <b>* " + "Web Site" + ":</b> " + record.get("CLIENT_WEBSITE") + "<br />";
|
||||
html = html + " <b>* " + "Callback URL" + ":</b> " + record.get("REDIRECT_URI") + "<br /><br />";
|
||||
html = html + "<h3>" + "Application Credentials" + "</h3><br />";
|
||||
html = html + " <b>* " + "Client ID" + ":</b> " + record.get("CLIENT_ID") + "<br />";
|
||||
html = html + " <b>* " + "Client Secret" + ":</b> " + record.get("CLIENT_SECRET") + "<br /><br />";
|
||||
|
||||
var formItems = Ext.getCmp("frmDetailView").form.items;
|
||||
formItems.items[0].setValue(html);
|
||||
|
||||
winDetail.show();
|
||||
}
|
||||
}
|
||||
|
||||
function onMnuContext(grid, rowIndex, e)
|
||||
{
|
||||
e.stopEvent();
|
||||
|
||||
var coords = e.getXY();
|
||||
|
||||
mnuContext.showAt([coords[0], coords[1]]);
|
||||
}
|
||||
|
||||
//Variables
|
||||
var pageSize = parseInt(CONFIG.pageSize);
|
||||
|
||||
//Stores
|
||||
var storeData = new Ext.data.Store({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: "../oauth2/clientSetupAjax",
|
||||
method: "POST"
|
||||
}),
|
||||
|
||||
//baseParams: {"option": "LST", "pageSize": pageSize},
|
||||
|
||||
reader: new Ext.data.JsonReader({
|
||||
totalProperty: "resultTotal",
|
||||
root: "resultRoot",
|
||||
fields: [
|
||||
{name: "CLIENT_ID", type: "string"},
|
||||
{name: "CLIENT_SECRET", type: "string"},
|
||||
{name: "CLIENT_NAME", type: "string"},
|
||||
{name: "CLIENT_DESCRIPTION", type: "string"},
|
||||
{name: "CLIENT_WEBSITE", type: "string"},
|
||||
{name: "REDIRECT_URI", type: "string"},
|
||||
{name: "USR_UID", type: "string"}
|
||||
]
|
||||
}),
|
||||
|
||||
//autoLoad: true, //First call
|
||||
remoteSort: true,
|
||||
|
||||
listeners: {
|
||||
beforeload: function (store, opt)
|
||||
{
|
||||
loadMaskData.show();
|
||||
|
||||
btnEdit.setDisabled(true);
|
||||
btnDelete.setDisabled(true);
|
||||
btnDetail.setDisabled(true);
|
||||
|
||||
this.baseParams = {
|
||||
option: "LST",
|
||||
pageSize: pageSize,
|
||||
search: Ext.getCmp("txtSearch").getValue()
|
||||
};
|
||||
},
|
||||
load: function (store, record, opt)
|
||||
{
|
||||
loadMaskData.hide();
|
||||
|
||||
if (CREATE_CLIENT == 1) {
|
||||
OCLIENTOPTION = "INS";
|
||||
CREATE_CLIENT = 0;
|
||||
|
||||
oauthClientSetForm(OCLIENTOPTION, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var storePageSize = new Ext.data.SimpleStore({
|
||||
fields: ["size"],
|
||||
data: [["20"], ["30"], ["40"], ["50"], ["100"]],
|
||||
autoLoad: true
|
||||
});
|
||||
|
||||
//Components
|
||||
var winData = new Ext.Window({
|
||||
layout: "fit",
|
||||
width: 550,
|
||||
height: 475,
|
||||
//title: "",
|
||||
modal: true,
|
||||
resizable: false,
|
||||
closeAction: "hide",
|
||||
|
||||
items: [
|
||||
new Ext.FormPanel({
|
||||
id: "frmOauthClient",
|
||||
|
||||
frame: true,
|
||||
labelAlign: "right",
|
||||
labelWidth: 80,
|
||||
autoWidth: true,
|
||||
//height: 395,
|
||||
autoScroll: false,
|
||||
|
||||
defaults: {width: 425},
|
||||
|
||||
items: [
|
||||
{
|
||||
xtype: "hidden",
|
||||
id: "oauthClientId",
|
||||
name: "oauthClientId",
|
||||
},
|
||||
{
|
||||
xtype: "textfield",
|
||||
id: "txtName",
|
||||
name: "txtName",
|
||||
|
||||
fieldLabel: "Name"
|
||||
},
|
||||
{
|
||||
xtype: "label",
|
||||
|
||||
fieldLabel: " ",
|
||||
labelSeparator: "",
|
||||
|
||||
html: "<span style=\"font-size: 11px;\">" + "Your application name. This is used to attribute the source in user-facing authorization screens. 32 characters max." + "</span><div style=\"height: 5px;\"></div>"
|
||||
},
|
||||
{
|
||||
xtype: "textarea",
|
||||
id: "txtDescription",
|
||||
name: "txtDescription",
|
||||
|
||||
fieldLabel: "Description",
|
||||
height: 55
|
||||
},
|
||||
{
|
||||
xtype: "label",
|
||||
|
||||
fieldLabel: " ",
|
||||
labelSeparator: "",
|
||||
|
||||
html: "<span style=\"font-size: 11px;\">" + "Your application description, which will be shown in user-facing authorization screens. Between 10 and 200 characters max." + "</span><div style=\"height: 5px;\"></div>"
|
||||
},
|
||||
{
|
||||
xtype: "textfield",
|
||||
id: "txtWebSite",
|
||||
name: "txtWebSite",
|
||||
|
||||
fieldLabel: "Web Site",
|
||||
vtype: "url"
|
||||
},
|
||||
{
|
||||
xtype: "label",
|
||||
|
||||
fieldLabel: " ",
|
||||
labelSeparator: "",
|
||||
|
||||
html: "<span style=\"font-size: 11px;\">" + "Your application's publicly accessible home page, where users can go to download, make use of, or find out more information about your application. This fully-qualified URL is used in the source attribution for request created by your application and will be shown in user-facing authorization screens. (If you don't have a URL yet, just put a placeholder here but remember to change it later.)" + "</span><div style=\"height: 5px;\"></div>"
|
||||
},
|
||||
{
|
||||
xtype: "textfield",
|
||||
id: "txtRedirectUri",
|
||||
name: "txtRedirectUri",
|
||||
|
||||
fieldLabel: "Callback URL",
|
||||
vtype: "url"
|
||||
},
|
||||
{
|
||||
xtype: "label",
|
||||
|
||||
fieldLabel: " ",
|
||||
labelSeparator: "",
|
||||
|
||||
html: "<span style=\"font-size: 11px;\">" + "here should we return after successfully authenticating? For @Anywhere applications, only the domain specified in the callback will be used. OAuth 1.0a applications should explicitly specify their oauth_callback URL on the request token step, regardless of the value given here. To restrict your application from using callbacks, leave this field blank." + "</span>"
|
||||
}
|
||||
]
|
||||
})
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
id: "btnSubmit",
|
||||
//text: "",
|
||||
handler: function ()
|
||||
{
|
||||
if (Ext.getCmp("frmOauthClient").getForm().isValid()) {
|
||||
oauthClientProcessAjax(OCLIENTOPTION, Ext.getCmp("oauthClientId").getValue());
|
||||
|
||||
Ext.getCmp("txtName").allowBlank = true;
|
||||
|
||||
winData.hide();
|
||||
} else {
|
||||
Ext.MessageBox.alert(_("ID_INVALID_DATA"), _("ID_CHECK_FIELDS_MARK_RED"));
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: _("ID_CANCEL"),
|
||||
handler: function ()
|
||||
{
|
||||
Ext.getCmp("txtName").allowBlank = true;
|
||||
|
||||
winData.hide();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var winInsertSuccess = new Ext.Window({
|
||||
layout: "fit",
|
||||
width: 450,
|
||||
height: 300,
|
||||
title: "Registration Success",
|
||||
modal: true,
|
||||
resizable: false,
|
||||
closeAction: "hide",
|
||||
|
||||
items: [
|
||||
new Ext.FormPanel({
|
||||
id: "frmInsertSuccessView",
|
||||
|
||||
frame: true,
|
||||
labelAlign: "right",
|
||||
labelWidth: 1,
|
||||
autoWidth: true,
|
||||
//height: 395,
|
||||
autoScroll: true,
|
||||
items: [
|
||||
{
|
||||
xtype: "displayfield",
|
||||
fieldLabel: ""
|
||||
}
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
var winDetail = new Ext.Window({
|
||||
layout: "fit",
|
||||
width: 450,
|
||||
height: 300,
|
||||
title: "Detail",
|
||||
modal: true,
|
||||
resizable: false,
|
||||
closeAction: "hide",
|
||||
|
||||
items: [
|
||||
new Ext.FormPanel({
|
||||
id: "frmDetailView",
|
||||
|
||||
frame: true,
|
||||
labelAlign: "right",
|
||||
labelWidth: 1,
|
||||
autoWidth: true,
|
||||
//height: 395,
|
||||
autoScroll: true,
|
||||
items: [
|
||||
{
|
||||
xtype: "displayfield",
|
||||
fieldLabel: ""
|
||||
}
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
var btnNew = new Ext.Action({
|
||||
id: "btnNew",
|
||||
|
||||
text: _("ID_NEW"),
|
||||
iconCls: "button_menu_ext ss_sprite ss_add",
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
OCLIENTOPTION = "INS";
|
||||
|
||||
oauthClientSetForm(OCLIENTOPTION, "");
|
||||
}
|
||||
});
|
||||
|
||||
var btnEdit = new Ext.Action({
|
||||
id: "btnEdit",
|
||||
|
||||
text: _("ID_EDIT"),
|
||||
iconCls: "button_menu_ext ss_sprite ss_pencil",
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
OCLIENTOPTION = "UPD";
|
||||
|
||||
oauthClientSetForm(OCLIENTOPTION, record.get("CLIENT_ID"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var btnDelete = new Ext.Action({
|
||||
id: "btnDelete",
|
||||
|
||||
text: _("ID_DELETE"),
|
||||
iconCls: "button_menu_ext ss_sprite ss_cross",
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
Ext.MessageBox.confirm(
|
||||
_("ID_CONFIRM"),
|
||||
"Do you want to delete selected Application?",
|
||||
function (btn)
|
||||
{
|
||||
if (btn == "yes") {
|
||||
OCLIENTOPTION = "DEL";
|
||||
|
||||
oauthClientProcessAjax(OCLIENTOPTION, record.get("CLIENT_ID"));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var btnDetail = new Ext.Action({
|
||||
id: "btnDetail",
|
||||
|
||||
text: _("ID_DETAIL"),
|
||||
iconCls: "button_menu_ext ss_sprite ss_zoom",
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
detailView();
|
||||
}
|
||||
});
|
||||
|
||||
var btnSearch = new Ext.Action({
|
||||
id: "btnSearch",
|
||||
|
||||
text: _("ID_SEARCH"),
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
pagingData.moveFirst();
|
||||
}
|
||||
});
|
||||
|
||||
var txtSearch = new Ext.form.TextField({
|
||||
id: "txtSearch",
|
||||
|
||||
emptyText: _("ID_ENTER_SEARCH_TERM"),
|
||||
width: 150,
|
||||
allowBlank: true,
|
||||
|
||||
listeners: {
|
||||
specialkey: function (f, e)
|
||||
{
|
||||
if (e.getKey() == e.ENTER) {
|
||||
pagingData.moveFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var btnTextClear = new Ext.Action({
|
||||
id: "btnTextClear",
|
||||
|
||||
text: "X",
|
||||
ctCls: "pm_search_x_button",
|
||||
handler: function ()
|
||||
{
|
||||
txtSearch.reset();
|
||||
}
|
||||
});
|
||||
|
||||
var cboPageSize = new Ext.form.ComboBox({
|
||||
id: "cboPageSize",
|
||||
|
||||
mode: "local",
|
||||
triggerAction: "all",
|
||||
store: storePageSize,
|
||||
valueField: "size",
|
||||
displayField: "size",
|
||||
width: 50,
|
||||
editable: false,
|
||||
|
||||
listeners: {
|
||||
select: function (combo, record, index)
|
||||
{
|
||||
pageSize = parseInt(record.data["size"]);
|
||||
|
||||
pagingData.pageSize = pageSize;
|
||||
pagingData.moveFirst();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var pagingData = new Ext.PagingToolbar({
|
||||
id: "pagingData",
|
||||
|
||||
pageSize: pageSize,
|
||||
store: storeData,
|
||||
displayInfo: true,
|
||||
displayMsg: "Displaying data " + "{" + "0" + "}" + " - " + "{" + "1" + "}" + " of " + "{" + "2" + "}",
|
||||
emptyMsg: "No data to display",
|
||||
items: ["-", "Page size:", cboPageSize]
|
||||
});
|
||||
|
||||
var cmodel = new Ext.grid.ColumnModel({
|
||||
defaults: {
|
||||
sortable: true
|
||||
},
|
||||
|
||||
columns: [
|
||||
{id: "CLIENT_ID", dataIndex: "CLIENT_ID", hidden: true, hideable: false},
|
||||
{id: "CLIENT_SECRET", dataIndex: "CLIENT_SECRET", hidden: true, hideable: false},
|
||||
{id: "CLIENT_NAME", dataIndex: "CLIENT_NAME", header: "Name", width: 200, align: "left"},
|
||||
{id: "CLIENT_DESCRIPTION", dataIndex: "CLIENT_DESCRIPTION", header: "Description", width: 250, align: "left"},
|
||||
{id: "CLIENT_WEBSITE", dataIndex: "CLIENT_WEBSITE", hidden: true, hideable: false},
|
||||
{id: "REDIRECT_URI", dataIndex: "REDIRECT_URI", hidden: true, hideable: false},
|
||||
{id: "USR_UID", dataIndex: "USR_UID", hidden: true, hideable: false}
|
||||
]
|
||||
});
|
||||
|
||||
var smodel = new Ext.grid.RowSelectionModel({
|
||||
singleSelect: true,
|
||||
listeners: {
|
||||
rowselect: function (sm)
|
||||
{
|
||||
btnEdit.setDisabled(false);
|
||||
btnDelete.setDisabled(false);
|
||||
btnDetail.setDisabled(false);
|
||||
},
|
||||
rowdeselect: function (sm)
|
||||
{
|
||||
btnEdit.setDisabled(true);
|
||||
btnDelete.setDisabled(true);
|
||||
btnDetail.setDisabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var grdpnlMain = new Ext.grid.GridPanel({
|
||||
id: "grdpnlMain",
|
||||
|
||||
store: storeData,
|
||||
colModel: cmodel,
|
||||
selModel: smodel,
|
||||
|
||||
columnLines: true,
|
||||
viewConfig: {forceFit: true}, //Expand all columns
|
||||
enableColumnResize: true,
|
||||
enableHdMenu: true, //Menu of the column
|
||||
//autoExpandColumn: "CLIENT_DESCRIPTION",
|
||||
|
||||
//tbar: [btnNew, "-", btnEdit, btnDelete, "-", btnDetail, "->", txtSearch, btnTextClear, btnSearch],
|
||||
tbar: [btnNew, "-", btnEdit, btnDelete, "-", btnDetail],
|
||||
//bbar: pagingData,
|
||||
|
||||
//style: "margin: 0 auto 0 auto;",
|
||||
//width: 550,
|
||||
//height: 450,
|
||||
title: "<div><div style=\"float: left;\">" + "My Applications" + "</div><div id=\"divAccessTokenSetup\" style=\"float: right;\"></div><div style=\"clear: both; height: 0; line-height:0; font-size: 0;\"></div></div>",
|
||||
border: false,
|
||||
|
||||
listeners: {
|
||||
afterrender: function (grid)
|
||||
{
|
||||
var btn = new Ext.Button({
|
||||
text: " " + "Applications",
|
||||
iconCls: "button_menu_ext ss_sprite ss_arrow_left",
|
||||
renderTo: "divAccessTokenSetup",
|
||||
|
||||
handler: function ()
|
||||
{
|
||||
location.href = "accessTokenSetup";
|
||||
}
|
||||
});
|
||||
},
|
||||
rowdblclick: function (grid, rowIndex, evt)
|
||||
{
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
OCLIENTOPTION = "UPD";
|
||||
|
||||
oauthClientSetForm(OCLIENTOPTION, record.get("CLIENT_ID"));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Menu context
|
||||
var mnuContext = new Ext.menu.Menu({
|
||||
id: "mnuContext",
|
||||
|
||||
items: [btnEdit, btnDelete, "-", btnDetail]
|
||||
});
|
||||
|
||||
//Initialize events
|
||||
grdpnlMain.on(
|
||||
"rowcontextmenu",
|
||||
function (grid, rowIndex, evt)
|
||||
{
|
||||
var sm = grid.getSelectionModel();
|
||||
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
|
||||
},
|
||||
this
|
||||
);
|
||||
|
||||
grdpnlMain.addListener("rowcontextmenu", onMnuContext, this);
|
||||
|
||||
cboPageSize.setValue(pageSize);
|
||||
|
||||
grdpnlMain.store.load();
|
||||
|
||||
//Load all panels
|
||||
var viewport = new Ext.Viewport({
|
||||
layout: "fit",
|
||||
autoScroll: false,
|
||||
items: [grdpnlMain]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ext.onReady(clientSetup.application.init, clientSetup.application);
|
||||
|
||||
1
workflow/engine/templates/users/userMain.html
Normal file
1
workflow/engine/templates/users/userMain.html
Normal file
@@ -0,0 +1 @@
|
||||
<div></div>
|
||||
74
workflow/engine/templates/users/userMain.js
Normal file
74
workflow/engine/templates/users/userMain.js
Normal file
@@ -0,0 +1,74 @@
|
||||
Ext.namespace("userMain");
|
||||
|
||||
userMain.application = {
|
||||
init: function ()
|
||||
{
|
||||
var treepnlMenu = new Ext.tree.TreePanel({
|
||||
id: "treepnlMenu",
|
||||
region: "west",
|
||||
|
||||
//title: "",
|
||||
width: 240,
|
||||
collapsible: true,
|
||||
collapseMode: "mini",
|
||||
hideCollapseTool: true,
|
||||
split: true,
|
||||
rootVisible: false,
|
||||
loader: new Ext.tree.TreeLoader(),
|
||||
root: new Ext.tree.AsyncTreeNode({
|
||||
expanded: true,
|
||||
children: [
|
||||
{
|
||||
id: "nodeInfo",
|
||||
text: "Personal Information",
|
||||
leaf: true,
|
||||
url: "../users/usersInit"
|
||||
|
||||
},
|
||||
{
|
||||
id: "nodeApplication",
|
||||
text: "Applications",
|
||||
leaf: true,
|
||||
url: "../oauth2/accessTokenSetup"
|
||||
}
|
||||
]
|
||||
}),
|
||||
listeners: {
|
||||
click: function (node, evt)
|
||||
{
|
||||
document.getElementById("iframe").src = node.attributes.url;
|
||||
},
|
||||
afterrender: function (treepnl)
|
||||
{
|
||||
var index = (CREATE_CLIENT == 1)? 1 : 0;
|
||||
|
||||
var node = treepnl.getRootNode().childNodes[index];
|
||||
node.select();
|
||||
|
||||
setTimeout(function () { document.getElementById("iframe").src = (CREATE_CLIENT == 1)? "../oauth2/clientSetup?create_app" : node.attributes.url; }, 5);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var viewport = new Ext.Viewport({
|
||||
layout: "border",
|
||||
items: [
|
||||
treepnlMenu,
|
||||
{
|
||||
xtype: "iframepanel",
|
||||
id: "iframepnlIframe",
|
||||
region: "center",
|
||||
|
||||
frameConfig: {
|
||||
name: "iframe",
|
||||
id: "iframe"
|
||||
},
|
||||
deferredRender: false
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ext.onReady(userMain.application.init, userMain.application);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
}
|
||||
</style>
|
||||
<body onresize="autoResizeScreen()" onload="autoResizeScreen()">
|
||||
<iframe name="frameMain" id="frameMain" src ="../users/usersInit" width="100%" height="200" frameborder="0">
|
||||
<iframe name="frameMain" id="frameMain" src ="../users/userMain<?php echo ((isset($_GET["create_app"]))? "?create_app" : ""); ?>" width="100%" height="200" frameborder="0">
|
||||
<p>Your browser does not support iframes.</p>
|
||||
</iframe>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user