Implementacion de la notificacion para android y ios
add method add endpoints to api.ini change message in send notification change .pem and conf PM-3587 Cambiar el texto de notificaciones
This commit is contained in:
@@ -2503,6 +2503,17 @@ class wsBase
|
||||
|
||||
$oCase->sendNotifications( $appdel['TAS_UID'], $nextDelegations, $appFields['APP_DATA'], $caseId, $delIndex, $sFromName );
|
||||
|
||||
// Send notifications Mobile - Start
|
||||
try {
|
||||
$oLight = new \ProcessMaker\BusinessModel\Light();
|
||||
$nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $delIndex);
|
||||
$notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
$notificationMobile->routeCaseNotification($userId, $_SESSION["PROCESS"], $appdel['TAS_UID'], $appFields, $nextDelegations, $nextIndex);
|
||||
} catch (Exception $e) {
|
||||
\G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log");
|
||||
}
|
||||
// Send notifications Mobile - End
|
||||
|
||||
//Save data - Start
|
||||
//$appFields = $oCase->loadCase($caseId);
|
||||
//$oCase->updateCase($caseId, $appFields);
|
||||
|
||||
151
workflow/engine/classes/model/NotificationDevice.php
Normal file
151
workflow/engine/classes/model/NotificationDevice.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseNotificationDevice.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'NOTIFICATION_DEVICE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class NotificationDevice extends BaseNotificationDevice {
|
||||
|
||||
public function create(array $arrayData)
|
||||
{
|
||||
|
||||
$cnn = Propel::getConnection(NotificationDevicePeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$this->setDevUid(G::generateUniqueID());
|
||||
$this->setUsrUid($arrayData['USR_UID']);
|
||||
$this->setSysLang($arrayData['SYS_LANG']);
|
||||
$this->setDevRegId($arrayData['DEV_REG_ID']);
|
||||
$this->setDevType($arrayData['DEV_TYPE']);
|
||||
$this->setDevCreate('now');
|
||||
$this->setDevUpdate('now');
|
||||
|
||||
if ($this->validate()) {
|
||||
$cnn->begin();
|
||||
$result = $this->save();
|
||||
$cnn->commit();
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
throw $e;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function update(array $arrayData)
|
||||
{
|
||||
|
||||
$cnn = Propel::getConnection(NotificationDevicePeer::DATABASE_NAME);
|
||||
$rs = NotificationDevicePeer::retrieveByPK($arrayData['DEV_UID'],$arrayData['USR_UID']);
|
||||
try {
|
||||
$arrayData['DEV_UPDATE'] = date('Y-m-d H:i:s');
|
||||
$rs->fromArray($arrayData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($this->validate()) {
|
||||
$cnn->begin();
|
||||
$result = $rs->save();
|
||||
$cnn->commit();
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
throw $e;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function loadByDeviceId ($deviceId)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->clearSelectColumns();
|
||||
$criteria->add(NotificationDevicePeer::DEV_REG_ID, $deviceId, Criteria::EQUAL);
|
||||
|
||||
$rs = NotificationDevicePeer::doSelectRS($criteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$device = array();
|
||||
while ($rs->next()) {
|
||||
$row = $rs->getRow();
|
||||
$device[] = $row;
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
return $device;
|
||||
}
|
||||
|
||||
public function loadByUsersId ($userId)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
$criteria->clearSelectColumns();
|
||||
$criteria->add(NotificationDevicePeer::USR_UID, $userId, Criteria::EQUAL);
|
||||
|
||||
$rs = NotificationDevicePeer::doSelectRS($criteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$device = array();
|
||||
while ($rs->next()) {
|
||||
$row = $rs->getRow();
|
||||
$device[] = $row;
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
return $device;
|
||||
}
|
||||
|
||||
public function getAll ()
|
||||
{
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
|
||||
$oCriteria->addSelectColumn( NotificationDevicePeer::DEV_UID );
|
||||
$oCriteria->addSelectColumn( NotificationDevicePeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( NotificationDevicePeer::DEV_TYPE );
|
||||
$oCriteria->addSelectColumn( NotificationDevicePeer::DEV_REG_ID );
|
||||
$oCriteria->addSelectColumn( NotificationDevicePeer::DEV_CREATE );
|
||||
|
||||
//execute the query
|
||||
$oDataset = NotificationDevicePeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$aRows = array ();
|
||||
while ($oDataset->next()) {
|
||||
$aRows[] = $oDataset->getRow();
|
||||
}
|
||||
return $aRows;
|
||||
}
|
||||
|
||||
public function remove($devUid, $usrUid)
|
||||
{
|
||||
if (!$this->exists($devUid, $usrUid)) {
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_DOES_NOT_EXIST"));
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$this->setDevUid($devUid);
|
||||
$this->setUsrUid($usrUid);
|
||||
$this->delete();
|
||||
if ($this->isDeleted()) {
|
||||
$result["message"] = G::LoadTranslation("ID_DELETED_SUCCESSFULLY");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function exists($devUid, $usrUid)
|
||||
{
|
||||
$oRow = NotificationDevicePeer::retrieveByPK($devUid, $usrUid);
|
||||
return (( get_class ($oRow) == 'NotificationDevice' )&&(!is_null($oRow)));
|
||||
}
|
||||
|
||||
} // NotificationDevice
|
||||
23
workflow/engine/classes/model/NotificationDevicePeer.php
Normal file
23
workflow/engine/classes/model/NotificationDevicePeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseNotificationDevicePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/NotificationDevice.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'NOTIFICATION_DEVICE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class NotificationDevicePeer extends BaseNotificationDevicePeer {
|
||||
|
||||
} // NotificationDevicePeer
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
require_once 'propel/map/MapBuilder.php';
|
||||
include_once 'creole/CreoleTypes.php';
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'NOTIFICATION_DEVICE' table to 'workflow' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package workflow.classes.model.map
|
||||
*/
|
||||
class NotificationDeviceMapBuilder
|
||||
{
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'classes.model.map.NotificationDeviceMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('workflow');
|
||||
|
||||
$tMap = $this->dbMap->addTable('NOTIFICATION_DEVICE');
|
||||
$tMap->setPhpName('NotificationDevice');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addPrimaryKey('DEV_UID', 'DevUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addPrimaryKey('USR_UID', 'UsrUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addColumn('SYS_LANG', 'SysLang', 'string', CreoleTypes::VARCHAR, false, 10);
|
||||
|
||||
$tMap->addColumn('DEV_REG_ID', 'DevRegId', 'string', CreoleTypes::VARCHAR, true, 150);
|
||||
|
||||
$tMap->addColumn('DEV_TYPE', 'DevType', 'string', CreoleTypes::VARCHAR, true, 50);
|
||||
|
||||
$tMap->addColumn('DEV_CREATE', 'DevCreate', 'int', CreoleTypes::TIMESTAMP, true, null);
|
||||
|
||||
$tMap->addColumn('DEV_UPDATE', 'DevUpdate', 'int', CreoleTypes::TIMESTAMP, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // NotificationDeviceMapBuilder
|
||||
926
workflow/engine/classes/model/om/BaseNotificationDevice.php
Normal file
926
workflow/engine/classes/model/om/BaseNotificationDevice.php
Normal file
File diff suppressed because it is too large
Load Diff
587
workflow/engine/classes/model/om/BaseNotificationDevicePeer.php
Normal file
587
workflow/engine/classes/model/om/BaseNotificationDevicePeer.php
Normal file
File diff suppressed because it is too large
Load Diff
9
workflow/engine/config/mobile.ini
Normal file
9
workflow/engine/config/mobile.ini
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
;Setting Android
|
||||
android[url] = "https://android.googleapis.com/gcm/send"
|
||||
android[serverApiKey] = "AIzaSyALwyLUYtZDcJQr54V5rxhZjoWnOLWCSvc"
|
||||
|
||||
;Setting Apple
|
||||
apple[url] = "ssl://gateway.push.apple.com:2195"
|
||||
apple[passphrase] = "ProcessMakerMobile"
|
||||
apple[pemFile] = "mobileios.pem"
|
||||
67
workflow/engine/config/mobileios.pem
Normal file
67
workflow/engine/config/mobileios.pem
Normal file
@@ -0,0 +1,67 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFnjCCBIagAwIBAgIIV0mdM8QauHcwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV
|
||||
BAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3Js
|
||||
ZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3
|
||||
aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw
|
||||
HhcNMTUwOTExMjEwNjUwWhcNMTYwOTEwMjEwNjUwWjCBnTEtMCsGCgmSJomT8ixk
|
||||
AQEMHWNvbS5wcm9jZXNzbWFrZXIuUHJvY2Vzc01ha2VyMUowSAYDVQQDDEFBcHBs
|
||||
ZSBQcm9kdWN0aW9uIElPUyBQdXNoIFNlcnZpY2VzOiBjb20ucHJvY2Vzc21ha2Vy
|
||||
LlByb2Nlc3NNYWtlcjETMBEGA1UECwwKOTQyUVA3UUpFOTELMAkGA1UEBhMCVVMw
|
||||
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCjmBoDUUVRaAX3XQvMh/h1
|
||||
347uLIMQzeYCYqbB5i+bDvH09c0DYym+zSrFhGCVsdl7Ys0+djZYYMHCDrkj5ygw
|
||||
hETHamts9+wI8oaojnOv/ZGvqYgG77PGtxj1lJ+MqC4y05WdcwTqc5k+jwPE/6RX
|
||||
mFNtCcbMJi67dJWtmobrzgApGFYEAjjhbFpmdc2Leccl3maivgTkwpIV2IT1I65X
|
||||
r/jqT0LZM+EZYuxeHLatVCvzr67I7iCYQGVyAVj1kJCTpa7jBVyJRNDSej0irGza
|
||||
Dwx3R17JYLk5ZYwuyF6KlCzcW7mz7SQiynt4PRrd+Tnp38REBRQMnnNK2XVaqTTX
|
||||
AgMBAAGjggHlMIIB4TAdBgNVHQ4EFgQUjODT9WBRKS7I5viOZ/ffI4YMb3owCQYD
|
||||
VR0TBAIwADAfBgNVHSMEGDAWgBSIJxcJqbYYYIvs67r2R1nFUlSjtzCCAQ8GA1Ud
|
||||
IASCAQYwggECMIH/BgkqhkiG92NkBQEwgfEwgcMGCCsGAQUFBwICMIG2DIGzUmVs
|
||||
aWFuY2Ugb24gdGhpcyBjZXJ0aWZpY2F0ZSBieSBhbnkgcGFydHkgYXNzdW1lcyBh
|
||||
Y2NlcHRhbmNlIG9mIHRoZSB0aGVuIGFwcGxpY2FibGUgc3RhbmRhcmQgdGVybXMg
|
||||
YW5kIGNvbmRpdGlvbnMgb2YgdXNlLCBjZXJ0aWZpY2F0ZSBwb2xpY3kgYW5kIGNl
|
||||
cnRpZmljYXRpb24gcHJhY3RpY2Ugc3RhdGVtZW50cy4wKQYIKwYBBQUHAgEWHWh0
|
||||
dHA6Ly93d3cuYXBwbGUuY29tL2FwcGxlY2EvME0GA1UdHwRGMEQwQqBAoD6GPGh0
|
||||
dHA6Ly9kZXZlbG9wZXIuYXBwbGUuY29tL2NlcnRpZmljYXRpb25hdXRob3JpdHkv
|
||||
d3dkcmNhLmNybDALBgNVHQ8EBAMCB4AwEwYDVR0lBAwwCgYIKwYBBQUHAwIwEAYK
|
||||
KoZIhvdjZAYDAgQCBQAwDQYJKoZIhvcNAQEFBQADggEBAIGp5UrIDWr2S+fDqKZX
|
||||
hcNZymREJJD3uQexTBSjReWBp9Af3z5CpULQAwwPzHStv7JQfpnac1ZQPdOODBao
|
||||
+S/vsECqrqTvTjnyaFHDaZUIBW4PQsd4ziCO9q9aOY546ABfSFcy3iA0faeT/Zff
|
||||
NK2vs7t8y3bARNAhbJmDi6QGiCwDW7F4hKoaSDmEdcdNlP4iZXMYgp96M48EESWf
|
||||
/tZNrSyRQV987ImX+JjQcO4lUyCDixwWpgIvOhCcX2fDK7Xp0qu1i+m3R4vjfbR1
|
||||
394qdaLkeLZsgRV/ZIOmXBggZsPe4kj5LnekxrjYlOjHdT5F5uvXB4qVN6vbJugu
|
||||
jbQ=
|
||||
-----END CERTIFICATE-----
|
||||
Bag Attributes
|
||||
friendlyName: ProcessMaker Prod Key
|
||||
localKeyID: 8C E0 D3 F5 60 51 29 2E C8 E6 F8 8E 67 F7 DF 23 86 0C 6F 7A
|
||||
Key Attributes: <No Attributes>
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,1256F970115DA637
|
||||
|
||||
/r8cNwTEVrnc+xrmcvEppG0RQuUaf/Fch+L4GaVm4/EA/YW0++gEbhBqmnTTLlXR
|
||||
9tO3NoHcRyVS8Rw7TDCWdFiqqBKIMYxtPsw5L2ftCThgP2BU74/zbb7vYfbkaW7o
|
||||
cRdU72l30BzYvRtgQoGTTfg6lGaiZVez+iJoO6pvNnRcEz6+RcdTvc4UcmMbmK4L
|
||||
U/r3fuLs3fVOaVaJ6JJr9+OmXx4P2Rb63IvXfVB/itiXCgt5fC4O+ZVteLirQ5JF
|
||||
IoHqM8iHopNW9RpkzDuVL5PhIY+LT0Rh44BJ9dnPNVtvK/MFxQgjPuO41brVdPK1
|
||||
UheZBEEX0ZcQsQWuJ5h7nslccvZSlfHqLv8Dy+ffveNUXYigs2X26oK+/YHxIMfo
|
||||
P6B+DXkQCopJRmQTRTPl8fiEi/cQRRxlGLtzAoujBrYf748NYUEzShz4Nvzh3D94
|
||||
Ujhsd2QPMGBt7sysAJSESczW2ilHce+XKzp16/1hV3VUNImhrrpYxi8rL4jF2Voc
|
||||
Mn7piS+PogDhofMfJNhFtKrDWJyEx4yU7wCUocwB1qVDp/sQTzpsjX+0Dp65cSPU
|
||||
dBVT1hnDPw8PEVMB9YhmhBsyaeIjc/HbHYIOti2cFHCvGXspt8wHjCP3sumFjVT+
|
||||
V3Pwn7eXOc7liRtqOfFFkOKG69Da4PFBxoLwN5osN8CJDNnmojIrnGOr47TBD/Np
|
||||
lMHRnFZ1GviAdOCQAVV+M3p/3pQUryfmBWTmmu/Cf96kKvxwxGYK+I1SDYNu8BMC
|
||||
3CzEPt2togsLp+ulZTVVDl3T4dlVadlGZ1CrSPZtlc2Ormcp3c3FQNHN4xzqC3LE
|
||||
N659RWq9iatTe9SXJfhy4URQXfEjF74bKXPs0w9MKi4Y7hOQquKK2G6ccrbCUYPu
|
||||
KQqF4CIUCNsTsKZYehOHBAQ6pd0tA1aaXjmANEjKAbc7IrlM6scHukoJ3iS4WeVJ
|
||||
8/CAJHIypKD+9FO4NjHntxFhEcSzkuZHd0fGvdCsEmqerwDIE1b4D3d6WbcSdgmW
|
||||
WtIkL6TDUrXDi6m9zDcUzgKlP2p/P0dBJOIuC7J8k3u99gH3eI8rFMxxAT3mPRRx
|
||||
7+Z1LztGmHWpOhdE7Y/S3hh6ycL3d7sR9Pz2Xgy1Fm+n+CQATE4FnE8K3HCNip5f
|
||||
w3fG9N/nZQKQBpuawtZVIaLL0sbRD4CoTU3BLp1jG/xc/SCMkGkRtQueckmLFaJr
|
||||
bkk9RKPlkY03GInJfssBtuLjyeOKQQ8Ot5VZpjJz+i6Un/glbY2j+PLDr6ldym+2
|
||||
qn8UMTNYv2Vp72SaITZEGN6NdHLWgHq5VczTeBFzubsJm/YFRYmXvBjbIRy2q08j
|
||||
e3MbZIRxivQoP0qc8WhZYwRFXxeqX2r1Lpw8JH2N8sXaJDPq65gHEboIjZmdabQO
|
||||
92Svz4g/3q/Kwhvw17ZJy7a1/2XEhssR7oXw9v0KU7N4EiWgk+HyHoi+pHi8rqy0
|
||||
zYShyak/vWPwmO7kjH6ZX6iSZD35L85TeZeyLeFqO8+KkL6lsmg+xVFjatlhGkqw
|
||||
PqTx2+I+33thzMuPrS/us0trECRoJ2Vsa7Xb1qqw5ACVV1gXG3nNaRLxUoYI2GjT
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -5167,5 +5167,28 @@
|
||||
<column name="EMAIL_EVENT_SUBJECT" type="VARCHAR" size="150" required="false" default=""/>
|
||||
<column name="PRF_UID" type="VARCHAR" size="32" required="false" default="" />
|
||||
</table>
|
||||
|
||||
<table name="NOTIFICATION_DEVICE">
|
||||
<vendor type="mysql">
|
||||
<parameter name="Name" value="NOTIFICATION_DEVICE" />
|
||||
<parameter name="Engine" value="InnoDB" />
|
||||
<parameter name="Version" value="10" />
|
||||
<parameter name="Row_format" value="Dynamic" />
|
||||
<parameter name="Data_free" value="0" />
|
||||
<parameter name="Auto_increment" value="" />
|
||||
<parameter name="Check_time" value="" />
|
||||
<parameter name="Collation" value="utf8_general_ci" />
|
||||
<parameter name="Checksum" value="" />
|
||||
<parameter name="Create_options" value="" />
|
||||
<parameter name="Comment" value="Definitions Notification device."/>
|
||||
</vendor>
|
||||
<column name="DEV_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default=""/>
|
||||
<column name="USR_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default=""/>
|
||||
<column name="SYS_LANG" type="VARCHAR" size="10" required="false" default=""/>
|
||||
<column name="DEV_REG_ID" type="VARCHAR" size="150" required="true" default=""/>
|
||||
<column name="DEV_TYPE" type="VARCHAR" size="50" required="true" default=""/>
|
||||
<column name="DEV_CREATE" type="TIMESTAMP" required="true" />
|
||||
<column name="DEV_UPDATE" type="TIMESTAMP" required="true" />
|
||||
</table>
|
||||
</database>
|
||||
|
||||
|
||||
@@ -2897,3 +2897,22 @@ CREATE TABLE `EMAIL_EVENT`
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#-- NOTIFICATION_DEVICE
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `NOTIFICATION_DEVICE`;
|
||||
|
||||
CREATE TABLE `NOTIFICATION_DEVICE`
|
||||
(
|
||||
`DEV_UID` VARCHAR(32) default '' NOT NULL,
|
||||
`USR_UID` VARCHAR(32) default '' NOT NULL,
|
||||
`SYS_LANG` VARCHAR(10) default '',
|
||||
`DEV_REG_ID` VARCHAR(150) default '' NOT NULL,
|
||||
`DEV_TYPE` VARCHAR(50) default '',
|
||||
`DEV_CREATE` DATETIME NOT NULL,
|
||||
`DEV_UPDATE` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`DEV_UID`, `USR_UID`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Definitions Notification device.';
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
# SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -135,6 +135,16 @@ try {
|
||||
}
|
||||
// Send notifications - End
|
||||
|
||||
// Send notifications Mobile - Start
|
||||
try {
|
||||
$oLight = new \ProcessMaker\BusinessModel\Light();
|
||||
$nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $appFields['DEL_INDEX']);
|
||||
$notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
$notificationMobile->routeCaseNotification($_SESSION['USER_LOGGED'], $_SESSION['PROCESS'], $_SESSION['TASK'], $appFields, $_POST['form']['TASKS'], $nextIndex);
|
||||
} catch (Exception $e) {
|
||||
\G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log");
|
||||
}
|
||||
// Send notifications Mobile - End
|
||||
|
||||
// Events - Start
|
||||
$oEvent = new Event();
|
||||
|
||||
@@ -508,8 +508,8 @@ class Light
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks);
|
||||
$fields['message'] = trim(strip_tags($fields['message']));
|
||||
$array = json_decode(json_encode($fields), true);
|
||||
$array['message'] = trim(strip_tags($array['message']));
|
||||
if ($array ["status_code"] != 0) {
|
||||
throw (new \Exception($array ["message"]));
|
||||
} else {
|
||||
@@ -1251,5 +1251,26 @@ class Light
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getInformationDerivatedCase($app_uid, $del_index)
|
||||
{
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$children = array ();
|
||||
$oCriteria->clearSelectColumns();
|
||||
$oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX );
|
||||
$oCriteria->addSelectColumn( AppDelegationPeer::PRO_UID );
|
||||
$oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID );
|
||||
$oCriteria->addSelectColumn( AppDelegationPeer::USR_UID );
|
||||
$oCriteria->add( AppDelegationPeer::APP_UID, $app_uid );
|
||||
$oCriteria->add( AppDelegationPeer::DEL_PREVIOUS, $del_index );
|
||||
$oDataset = AppDelegationPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
while ($row = $oDataset->getRow()) {
|
||||
$children[] = $row;
|
||||
$oDataset->next();
|
||||
}
|
||||
return $children;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Light;
|
||||
|
||||
use G;
|
||||
|
||||
class NotificationDevice
|
||||
{
|
||||
/**
|
||||
* Post Create register device with userUid
|
||||
*
|
||||
* @param array $request_data
|
||||
* @param string $use_uid
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
*
|
||||
*/
|
||||
public function saveDevice($use_uid, $request_data)
|
||||
{
|
||||
$arrayData = array();
|
||||
$arrayData['USR_UID'] = $use_uid;
|
||||
$arrayData['DEV_REG_ID'] = $request_data['deviceIdToken'];
|
||||
$arrayData['SYS_LANG'] = $request_data['sysLanguage'];
|
||||
$arrayData['DEV_TYPE'] = $request_data['deviceType'];
|
||||
$arrayData['DEV_STATUS'] = 'active';
|
||||
|
||||
$oNoti = new \NotificationDevice();
|
||||
$devices = $oNoti->loadByDeviceId($request_data['deviceIdToken']);
|
||||
$response = array();
|
||||
if (!$devices){
|
||||
if($oNoti->create($arrayData)){
|
||||
$response["devUid"] = $oNoti->getDevUid();
|
||||
$response["message"] = G:: LoadTranslation("ID_RECORD_SAVED_SUCCESFULLY");
|
||||
G::auditLog("Create", "Device Save: Device ID (".$oNoti->getDevUid().") ");
|
||||
}
|
||||
} else {
|
||||
$response["devUid"] = $devices[0]['DEV_UID'];
|
||||
$response["message"] = G:: LoadTranslation("ID_RECORD_EXISTS_IN_TABLE",array($devices[0]['DEV_UID'], "NOTIFICATION_DEVICE"));
|
||||
//throw new \Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
|
||||
}
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update register device with userUid
|
||||
*
|
||||
* @param array $request_data
|
||||
* @param string $dev_uid
|
||||
* @param string $use_uid
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
*
|
||||
*/
|
||||
public function updateDevice($dev_uid, $use_uid, $request_data)
|
||||
{
|
||||
|
||||
$arrayData = array();
|
||||
$arrayData['USR_UID'] = $use_uid;
|
||||
$arrayData['DEV_UID'] = $dev_uid;
|
||||
if(isset($request_data['deviceIdToken'])){
|
||||
$arrayData['DEV_REG_ID'] = $request_data['deviceIdToken'];
|
||||
}
|
||||
if(isset($request_data['sysLanguage'])) {
|
||||
$arrayData['SYS_LANG'] = $request_data['sysLanguage'];
|
||||
}
|
||||
if(isset($request_data['deviceType'])) {
|
||||
$arrayData['DEV_TYPE'] = $request_data['deviceType'];
|
||||
}
|
||||
$oNoti = new \NotificationDevice();
|
||||
$response = array();
|
||||
if($oNoti->update($arrayData)){
|
||||
$response["message"] = G:: LoadTranslation("ID_RECORD_SAVED_SUCCESFULLY");
|
||||
G::auditLog("Create", "Device Save: Device ID (".$oNoti->getDevUid().") ");
|
||||
}
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Message each user id
|
||||
*
|
||||
* @param array $request_data
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
*
|
||||
*/
|
||||
public function sendMessage($userIds, $message, $data = null)
|
||||
{
|
||||
try {
|
||||
$oNoti = new \NotificationDevice();
|
||||
$devices = array();
|
||||
if (is_array($userIds)){
|
||||
foreach ($userIds as $id) {
|
||||
$deviceUser = $oNoti->loadByUsersId($id);
|
||||
$devices = array_merge($devices, $deviceUser);
|
||||
}
|
||||
} else {
|
||||
$devices = $oNoti->loadByUsersId($userIds);
|
||||
}
|
||||
|
||||
$devicesAndroidIds = array();
|
||||
$devicesAppleIds = array();
|
||||
foreach ($devices as $dev) {
|
||||
switch ($dev['DEV_TYPE']) {
|
||||
case "apple":
|
||||
$devicesAppleIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
case "android":
|
||||
$devicesAndroidIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count($devicesAppleIds) > 0) {
|
||||
$oNotification = new PushMessageIOS();
|
||||
$oNotification->setSettingNotification();
|
||||
$oNotification->setDevices($devicesAppleIds);
|
||||
$response['android'] = $oNotification->send($message, $data);
|
||||
}
|
||||
if (count($devicesAndroidIds) > 0) {
|
||||
$oNotification = new PushMessageAndroid();
|
||||
$oNotification->setSettingNotification();
|
||||
$oNotification->setDevices($devicesAndroidIds);
|
||||
$response['apple'] = $oNotification->send($message, $data);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception(\Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Message each user id
|
||||
*
|
||||
* @param array $request_data
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
*
|
||||
*/
|
||||
public function routeCaseNotification($currentUserId, $processId, $currentTaskId, $appFields, $aTasks, $nextIndex)
|
||||
{
|
||||
try {
|
||||
$oUser = new \Users();
|
||||
$aUser = $oUser->load( $currentUserId );
|
||||
|
||||
$response = array();
|
||||
$task = new \Tasks();
|
||||
$group = new \Groups();
|
||||
foreach ($aTasks as $aTask) {
|
||||
$arrayTaskUser = array();
|
||||
switch ($aTask["TAS_ASSIGN_TYPE"]) {
|
||||
case "SELF_SERVICE":
|
||||
if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {
|
||||
$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"];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
|
||||
$arrayTaskUser = $aTask["USR_UID"];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// $oTask = new \Task();
|
||||
// $currentTask = $oTask->load($aTask['TAS_UID']);
|
||||
$delIndex = null;
|
||||
foreach ($nextIndex as $nIndex) {
|
||||
if($aTask['TAS_UID'] == $nIndex['TAS_UID']){
|
||||
$delIndex = $nIndex['DEL_INDEX'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$userIds = $arrayTaskUser;
|
||||
$message = '#'. $appFields['APP_NUMBER'] . ' : '.$appFields['APP_TITLE'];
|
||||
$data = array(
|
||||
'processId' => $processId,
|
||||
'taskId' => $aTask["TAS_UID"],
|
||||
'caseId' => $appFields['APP_UID'],
|
||||
'caseTitle' => $appFields['APP_TITLE'],
|
||||
'delIndex' => $delIndex,
|
||||
'typeList' => 'todo'
|
||||
);
|
||||
|
||||
if ($userIds) {
|
||||
|
||||
$oNoti = new \NotificationDevice();
|
||||
$devices = array();
|
||||
if (is_array($userIds)){
|
||||
foreach ($userIds as $id) {
|
||||
$deviceUser = $oNoti->loadByUsersId($id);
|
||||
$devices = array_merge($devices, $deviceUser);
|
||||
}
|
||||
} else {
|
||||
$devices = $oNoti->loadByUsersId($userIds);
|
||||
$lists = new \ProcessMaker\BusinessModel\Lists();
|
||||
$counter = $lists->getCounters($userIds);
|
||||
$light = new \ProcessMaker\Services\Api\Light();
|
||||
$result = $light->parserCountersCases($counter);
|
||||
$data['counters'] = $result;
|
||||
}
|
||||
|
||||
$devicesAndroidIds = array();
|
||||
$devicesAppleIds = array();
|
||||
foreach ($devices as $dev) {
|
||||
switch ($dev['DEV_TYPE']) {
|
||||
case "apple":
|
||||
$devicesAppleIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
case "android":
|
||||
$devicesAndroidIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count($devicesAppleIds) > 0) {
|
||||
$oNotification = new PushMessageIOS();
|
||||
$oNotification->setSettingNotification();
|
||||
$oNotification->setDevices($devicesAppleIds);
|
||||
$response['apple'] = $oNotification->send($message, $data);
|
||||
}
|
||||
if (count($devicesAndroidIds) > 0) {
|
||||
$oNotification = new PushMessageAndroid();
|
||||
$oNotification->setSettingNotification();
|
||||
$oNotification->setDevices($devicesAndroidIds);
|
||||
$response['android'] = $oNotification->send($message, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception(\Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* Class PushMessageAndroid
|
||||
* Class to send push notifications using Google Cloud Messaging for Android
|
||||
* Example usage
|
||||
*
|
||||
* $an = new PushMessageAndroid();
|
||||
* $an->setKey($apiKey);
|
||||
* $an->setDevices($devices);
|
||||
* $response = $an->send($message);
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Light;
|
||||
|
||||
class PushMessageAndroid
|
||||
{
|
||||
var $url = 'https://android.googleapis.com/gcm/send';
|
||||
var $serverApiKey = "AIzaSyBO-VLXGhjf0PPlwmPFTPQEKIBfVDydLAk";
|
||||
var $devices = array();
|
||||
|
||||
/**
|
||||
* @param $url string the url server
|
||||
*/
|
||||
function setUrl($url){
|
||||
$this->$url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $apiKeyIn string the server API key
|
||||
*/
|
||||
function setKey($apiKeyIn){
|
||||
$this->serverApiKey = $apiKeyIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the devices to send to
|
||||
* @param $deviceIds string or array of device tokens to send
|
||||
*/
|
||||
function setDevices($deviceIds)
|
||||
{
|
||||
if(is_array($deviceIds)){
|
||||
$this->devices = $deviceIds;
|
||||
} else {
|
||||
$this->devices = array($deviceIds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the setting value config
|
||||
*/
|
||||
public function setSettingNotification()
|
||||
{
|
||||
$conf = \System::getSystemConfiguration( PATH_CONFIG . 'mobile.ini' );
|
||||
$this->setUrl($conf['android']['url']);
|
||||
$this->setKey($conf['android']['serverApiKey']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the message to the device
|
||||
* @param $message string the message to send
|
||||
* @param $data array send extra information for app
|
||||
* @return mixed
|
||||
*/
|
||||
function send($message, $data)
|
||||
{
|
||||
if(!is_array($this->devices) || count($this->devices) == 0){
|
||||
$this->error("No devices set");
|
||||
}
|
||||
if(strlen($this->serverApiKey) < 8){
|
||||
$this->error("Server API Key not set");
|
||||
}
|
||||
|
||||
if (!is_null($data)) {
|
||||
$fields = array(
|
||||
'registration_ids' => $this->devices,
|
||||
'data' => array(
|
||||
"message" => $message,
|
||||
"data" => $data
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$fields = array(
|
||||
'registration_ids' => $this->devices,
|
||||
'data' => array( "message" => $message ),
|
||||
);
|
||||
}
|
||||
|
||||
$headers = array(
|
||||
'Authorization: key=' . $this->serverApiKey,
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
// Open connection
|
||||
$ch = curl_init();
|
||||
|
||||
// Set the url, number of POST vars, POST data
|
||||
curl_setopt( $ch, CURLOPT_URL, $this->url );
|
||||
|
||||
curl_setopt( $ch, CURLOPT_POST, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
|
||||
|
||||
// Avoids problem with https certificate
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
// Execute post
|
||||
$result = curl_exec($ch);
|
||||
|
||||
// Close connection
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function error($msg)
|
||||
{
|
||||
echo "Android send notification failed with error:";
|
||||
echo "\t" . $msg;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Class PushMessageIOS
|
||||
* Class to send push notifications for iOS
|
||||
* Example usage
|
||||
*
|
||||
* $ios = new PushMessageIOS($passphrase);
|
||||
* $ios->setDevices($devicesToken);
|
||||
* $response = $an->send($message);
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Light;
|
||||
|
||||
class PushMessageIOS
|
||||
{
|
||||
var $url = 'ssl://gateway.sandbox.push.apple.com:2195';
|
||||
var $passphrase = "sample";
|
||||
var $pemFile;
|
||||
var $devices = array();
|
||||
var $response = array();
|
||||
|
||||
/**
|
||||
* @param $url string the url server
|
||||
*/
|
||||
function setUrl($url){
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param $passphrase update your private key's
|
||||
*/
|
||||
function setKey($passphrase){
|
||||
$this->passphrase = $passphrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the devices token to send to
|
||||
* @param $deviceIds array of device tokens to send to
|
||||
*/
|
||||
function setDevices($devicesToken)
|
||||
{
|
||||
if(is_array($devicesToken)){
|
||||
$this->devices = $devicesToken;
|
||||
} else {
|
||||
$this->devices = array($devicesToken);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the setting value config
|
||||
*/
|
||||
public function setSettingNotification()
|
||||
{
|
||||
$conf = \System::getSystemConfiguration( PATH_CONFIG . 'mobile.ini' );
|
||||
$this->setUrl($conf['apple']['url']);
|
||||
$this->setKey($conf['apple']['passphrase']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the message to the device
|
||||
* @param $message the message to send
|
||||
* @return mixed
|
||||
*/
|
||||
function send($message, $data)
|
||||
{
|
||||
if(!is_array($this->devices) || count($this->devices) == 0){
|
||||
$this->error("No devices set");
|
||||
}
|
||||
if(strlen($this->passphrase) < 8){
|
||||
$this->error("Server API Key not set");
|
||||
}
|
||||
|
||||
$ctx = stream_context_create();
|
||||
stream_context_set_option($ctx, 'ssl', 'local_cert', PATH_CONFIG . 'mobileios.pem');
|
||||
stream_context_set_option($ctx, 'ssl', 'passphrase', $this->passphrase);
|
||||
|
||||
// Open a connection to the APNS server
|
||||
// $fp = stream_socket_client(
|
||||
// $this->url, $err,
|
||||
// $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
|
||||
// if (!$fp)
|
||||
// exit("Failed to connect: $err $errstr" . PHP_EOL);
|
||||
|
||||
// Create the payload body
|
||||
if (!is_null($data)) {
|
||||
$body['aps'] = array(
|
||||
'alert' => $message,
|
||||
'sound' => 'default',
|
||||
'data' => $data
|
||||
);
|
||||
} else {
|
||||
$body['aps'] = array(
|
||||
'alert' => $message,
|
||||
'sound' => 'default'
|
||||
);
|
||||
}
|
||||
|
||||
// Encode the payload as JSON
|
||||
$payload = json_encode($body);
|
||||
|
||||
// // Build the binary notification
|
||||
// $msg = chr(0) . pack('n', 32) . pack('H*', $this->devices) . pack('n', strlen($payload)) . $payload;
|
||||
//
|
||||
// // Send it to the server
|
||||
// $result = fwrite($fp, $msg, strlen($msg));
|
||||
// fclose($fp);
|
||||
|
||||
foreach ($this->devices as $item) {
|
||||
// Open a connection to the APNS server
|
||||
$fp = stream_socket_client($this->url, $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
|
||||
|
||||
if (!$fp) {
|
||||
throw (new \Exception( G::LoadTranslation( 'ID_FAILED' ).': ' ."$err $errstr"));
|
||||
} else {
|
||||
//echo 'Apple service is online. ' . '<br />';
|
||||
}
|
||||
|
||||
// Build the binary notification
|
||||
$msg = chr(0) . pack('n', 32) . pack('H*', $item) . pack('n', strlen($payload)) . $payload;
|
||||
|
||||
// Send it to the server
|
||||
$result = fwrite($fp, $msg, strlen($msg));
|
||||
|
||||
if (!$result) {
|
||||
$this->response['undelivered'][] = 'Undelivered message count: ' . $item;
|
||||
} else {
|
||||
$this->response['delivered'][] = 'Delivered message count: ' . $item;
|
||||
}
|
||||
|
||||
if ($fp) {
|
||||
fclose($fp);
|
||||
//echo 'The connection has been closed by the client' . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
function error($msg){
|
||||
echo "Android send notification failed with error:";
|
||||
echo "\t" . $msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api\Light;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Process Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class NotificationDevice extends Api
|
||||
{
|
||||
/**
|
||||
* Post Create register device with userUid
|
||||
*
|
||||
* @param array $request_data
|
||||
*
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
* @return array
|
||||
*
|
||||
* @url POST /notification
|
||||
*/
|
||||
public function saveDevice($request_data)
|
||||
{
|
||||
try {
|
||||
$use_uid = $this->getUserId();
|
||||
$oNotification = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
$response = $oNotification->saveDevice($use_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post Create register device with userUid
|
||||
*
|
||||
* @param string $dev_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
* @return array
|
||||
*
|
||||
* @url PUT /notification/:dev_uid
|
||||
*/
|
||||
public function updateDeviceLanguage($dev_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$use_uid = $this->getUserId();
|
||||
$oNotification = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
$response = $oNotification->updateDevice($dev_uid, $use_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all list record device
|
||||
*
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
* @return array
|
||||
*
|
||||
* @url GET /notification
|
||||
*/
|
||||
public function getDevice()
|
||||
{
|
||||
try {
|
||||
$oNotification = new \NotificationDevice();
|
||||
$response = $oNotification->getAll();
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete record device with dev_uid and usr_uid
|
||||
*
|
||||
* @param string $dev_uid {@min 32}{@max 32}
|
||||
*
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
* @return array
|
||||
*
|
||||
* @url DELETE /notification/:dev_uid
|
||||
*/
|
||||
public function deleteDevice($dev_uid)
|
||||
{
|
||||
try {
|
||||
$usr_uid = $this->getUserId();
|
||||
$oNotification = new \NotificationDevice();
|
||||
$response = $oNotification->remove($dev_uid, $usr_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Message by device id
|
||||
*
|
||||
* @param array $request_data
|
||||
*
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
* @return array
|
||||
*
|
||||
* @url POST /notification/sendmessage
|
||||
*/
|
||||
public function sendMessage($request_data)
|
||||
{
|
||||
try {
|
||||
// type si string or array users ids
|
||||
$usrIds = $request_data['userIds'];
|
||||
$message = $request_data['message'];
|
||||
// if need send data each device
|
||||
$data = isset($request_data['data'])?$request_data['data'] : null;
|
||||
$oNotification = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
$response = $oNotification->sendMessage($usrIds, $message, $data);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,7 @@ debug = 1
|
||||
[alias: light]
|
||||
light = "ProcessMaker\Services\Api\Light"
|
||||
tracker = "ProcessMaker\Services\Api\Light\Tracker"
|
||||
notification = "ProcessMaker\Services\Api\Light\NotificationDevice"
|
||||
|
||||
[alias: consolidated]
|
||||
list = "ProcessMaker\Services\Api\Consolidated"
|
||||
|
||||
Reference in New Issue
Block a user