diff --git a/CHANGLOG.md b/CHANGLOG.md index 656d326..46c1ddc 100644 --- a/CHANGLOG.md +++ b/CHANGLOG.md @@ -1,3 +1,16 @@ +ICTCore 0.7.5 +-------------- + +Dated: 07-March-2017 + +* Extension support added for accounts +* Twig based template added for gateway configurations and Application data +* Data and Token libraries updated +* Sip, SMTP and SMPP added as provider sub-type +* Multi tasking support improved for Task and Schedule +* Namespaces and PSR-4 based auto-loading support added +* PhpUnit support added for unit testing + ICTCore 0.7.0 -------------- diff --git a/README.md b/README.md index f417335..408dc98 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,10 @@ Getting started Following is an example about sending fax by using ICTCore // prepare a program with fax document - $programData = array('file_name' => '/some/pdf/file.pdf'); - $faxProgram = new Sendfax(null, array('data' => $programData)); + $faxProgram = new Sendfax(); + $faxProgram->file_name = '/some/pdf/file.pdf'; + $faxProgram->save(); + $faxProgram->compile(); // create a transmission $contact_id = 12; diff --git a/TODO.md b/TODO.md index 75b9a0c..4f84d10 100644 --- a/TODO.md +++ b/TODO.md @@ -4,4 +4,6 @@ ICTCore TODOs 1. Complete multi tenant support 2. Route / Billing support 3. Multiple node support / scalability -4. Email and SMS delivery tracking \ No newline at end of file +4. Email and SMS delivery tracking +5. IVR Program, to allow custom scenarios via APIs +5. Campaign support \ No newline at end of file diff --git a/composer.json b/composer.json index f56290c..f240f99 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,17 @@ { "require": { - "jacwright/restserver": "dev-master", "swiftmailer/swiftmailer": "@stable", "nategood/httpful": "^0.2.20", "aza/thread": "^1.1", - "twig/twig": "^1.28" + "twig/twig": "^1.28", + "jacwright/restserver": "dev-master" }, "autoload": { "psr-4": { "ICT\\Core\\": ["core/", "core/lib/"], "ICT\\Core\\Test\\": ["tests/core/", "tests/core/lib/"] } + }, + "require-dev": { } } diff --git a/composer.lock b/composer.lock index 40af844..01c67db 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "cecdb0ac94faf3c3f8e678e6df137b26", + "content-hash": "572e2bc9801f576059fd767e702fc46e", "packages": [ { "name": "aza/clibase", @@ -264,12 +264,12 @@ "source": { "type": "git", "url": "https://github.com/jacwright/RestServer.git", - "reference": "adfa1460e61178d53d63e72b2e65ab68d53b8ad7" + "reference": "584aa063caeb88f2bbbdcd145786ae0df1df029c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jacwright/RestServer/zipball/adfa1460e61178d53d63e72b2e65ab68d53b8ad7", - "reference": "adfa1460e61178d53d63e72b2e65ab68d53b8ad7", + "url": "https://api.github.com/repos/jacwright/RestServer/zipball/584aa063caeb88f2bbbdcd145786ae0df1df029c", + "reference": "584aa063caeb88f2bbbdcd145786ae0df1df029c", "shasum": "" }, "require": { @@ -304,7 +304,7 @@ "rest", "rest-server" ], - "time": "2016-06-21T14:05:17+00:00" + "time": "2016-12-20T19:04:05+00:00" }, { "name": "nategood/httpful", @@ -475,8 +475,8 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "jacwright/restserver": 20, - "swiftmailer/swiftmailer": 0 + "swiftmailer/swiftmailer": 0, + "jacwright/restserver": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/core/Account.php b/core/Account.php index b97075c..5e7093f 100644 --- a/core/Account.php +++ b/core/Account.php @@ -357,7 +357,7 @@ public function dissociate() } /** - * Compile given program with current account + * Deploy given program with current account * ( only if given program support it ) * @param \ICT\Core\Program $oProgram * @return int $program_id @@ -372,7 +372,7 @@ public function install_program(Program $oProgram) $oProgram->{$parameter_name} = $oToken->render_variable($parameter_value, Token::KEEP_ORIGNAL); } $oProgram->save(); - $oProgram->compile(); + $oProgram->deploy(); return $oProgram->program_id; } diff --git a/core/Api/ProgramApi.php b/core/Api/ProgramApi.php index 9e4a94a..8bcc248 100755 --- a/core/Api/ProgramApi.php +++ b/core/Api/ProgramApi.php @@ -30,6 +30,7 @@ public function create($program_name = null, $data = array()) $this->set($oProgram, $data); if ($oProgram->save()) { + $oProgram->deploy(); return $oProgram->program_id; } else { throw new CoreException(417, 'Program creation failed'); diff --git a/core/Program.php b/core/Program.php index 41afde3..ea05830 100644 --- a/core/Program.php +++ b/core/Program.php @@ -305,7 +305,7 @@ protected function _load() */ protected function resource_load_account() { - if (isset($this->account_id) && !empty($this->account_id)) { + if (!Token::is_token($this->account_id) && !empty($this->account_id)) { $oAccount = new Account($this->account_id); return $oAccount; } diff --git a/core/Program/Emailtofax.php b/core/Program/Emailtofax.php index 46e174f..e2b8d0d 100644 --- a/core/Program/Emailtofax.php +++ b/core/Program/Emailtofax.php @@ -68,7 +68,7 @@ public function parameter_save() */ protected function resource_load_account() { - if (isset($this->account_id) && !empty($this->account_id)) { + if (!Token::is_token($this->account_id) && !empty($this->account_id)) { $oAccount = new Account($this->account_id); return $oAccount; } else if (isset($this->email) && !empty($this->email)) { diff --git a/core/Program/Faxtoemail.php b/core/Program/Faxtoemail.php index 82bd4df..7666fa2 100644 --- a/core/Program/Faxtoemail.php +++ b/core/Program/Faxtoemail.php @@ -85,7 +85,7 @@ public function parameter_save() */ protected function resource_load_account() { - if (isset($this->account_id) && !empty($this->account_id)) { + if (!Token::is_token($this->account_id) && !empty($this->account_id)) { $oAccount = new Account($this->account_id); return $oAccount; } else if (isset($this->phone) && !empty($this->phone)) { diff --git a/core/Program/Receiveemail.php b/core/Program/Receiveemail.php index 3a971af..dd6cd01 100644 --- a/core/Program/Receiveemail.php +++ b/core/Program/Receiveemail.php @@ -17,6 +17,7 @@ use ICT\Core\Result; use ICT\Core\Scheme; use ICT\Core\Service\Email; +use ICT\Core\Token; use ICT\Core\Transmission; class Receiveemail extends Program @@ -60,7 +61,7 @@ public function parameter_save() */ protected function resource_load_account() { - if (isset($this->account_id) && !empty($this->account_id)) { + if (!Token::is_token($this->account_id) && !empty($this->account_id)) { $oAccount = new Account($this->account_id); return $oAccount; } else if (isset($this->email) && !empty($this->email)) { diff --git a/core/Program/Receivefax.php b/core/Program/Receivefax.php index f126bed..c3088a3 100644 --- a/core/Program/Receivefax.php +++ b/core/Program/Receivefax.php @@ -21,6 +21,7 @@ use ICT\Core\Result; use ICT\Core\Scheme; use ICT\Core\Service\Fax; +use ICT\Core\Token; use ICT\Core\Transmission; class Receivefax extends Program @@ -78,7 +79,7 @@ public function parameter_save() */ protected function resource_load_account() { - if (isset($this->account_id) && !empty($this->account_id)) { + if (!Token::is_token($this->account_id) && !empty($this->account_id)) { $oAccount = new Account($this->account_id); return $oAccount; } else if (isset($this->phone) && !empty($this->phone)) { diff --git a/core/Program/Receivesms.php b/core/Program/Receivesms.php index 7e240ff..d2e26ad 100644 --- a/core/Program/Receivesms.php +++ b/core/Program/Receivesms.php @@ -17,6 +17,7 @@ use ICT\Core\Result; use ICT\Core\Scheme; use ICT\Core\Service\Sms; +use ICT\Core\Token; use ICT\Core\Transmission; class Receivesms extends Program @@ -60,7 +61,7 @@ public function parameter_save() */ protected function resource_load_account() { - if (isset($this->account_id) && !empty($this->account_id)) { + if (!Token::is_token($this->account_id) && !empty($this->account_id)) { $oAccount = new Account($this->account_id); return $oAccount; } else if (isset($this->phone) && !empty($this->phone)) { diff --git a/core/lib/Token.php b/core/lib/Token.php index 5d77810..14aadb7 100644 --- a/core/lib/Token.php +++ b/core/lib/Token.php @@ -171,4 +171,17 @@ public function render_string_callback($org_matchs) } } + /** + * Test if given text is a token placeholder or not + * @param string $subject what we need to examine + * @return boolean test result true or false + */ + public static function is_token($subject) { + if (preg_match("/^\[(([\w]+)(:[\w]+)*)\]$/", $subject)) { + return true; + } else { + return false; + } + } + } \ No newline at end of file diff --git a/docs/dependencies.md b/docs/dependencies.md index 22bd43b..d5db71d 100755 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -1,37 +1,49 @@ System Dependencies =================== -Linux (GPL) -Freeswitch (MPL 1.1 License) -Sendmail (Sendmail License) -Kannel (BSD-style) -PHP (BSD) -Apache (Apache License 2.0) -MySQL (GPL) or MariaDB (LGPL) +* Linux (GPL) +* Freeswitch (MPL 1.1 License) +* Sendmail (Sendmail License) +* Kannel (BSD-style) +* PHP (BSD) +* Apache (Apache License 2.0) +* MySQL (GPL) or MariaDB (LGPL) -composer (MIT) - jacwright (MIT) - nategood (MIT) - swiftmailer (MIT) - -ioncube-loader (Commercial) +* composer (MIT) + * twig (BSD) + * jacwright (MIT) + * nategood (MIT) + * swiftmailer (MIT) + * aza/thread (MIT) Class Dependencies ================== -Core - Program - Message / Data - Application - Gateway - Event - Dialplan (for inbound programs only) - Account - Transmission - Account - Contact - Spool - Result - Sequence - Request - Dialplan - Response + +### Common Libraries +* Conf +* Data +* DB +* Log +* Scheme +* Session +* Thread +* Token + +### Core (Communication Related) +* Request +* Response +* Dialplan +* Program + * Message / Data + * Application + * Gateway + * Action + * Dialplan (for inbound programs only) + * Account +* Transmission + * Account + * Contact + * Spool + * Result +* Service + * Gateway \ No newline at end of file diff --git a/docs/intro_components.md b/docs/intro_components.md index 4e09ece..2d0d420 100644 --- a/docs/intro_components.md +++ b/docs/intro_components.md @@ -1,6 +1,6 @@ Basic components of ICTCore =========================== -Before starting developed with ICTCore, it is recommended to get an introduction with basic building block of ICTCore. for ease of understanding, we can divide them into four main categories as mentioned in following. +Before starting development with ICTCore, it is recommended to get an introduction with basic building block of ICTCore. for ease of understanding, we can divide them into four main categories as mentioned in following. 1. User Data 2. Logic @@ -27,7 +27,7 @@ Stored data / file holding information received or need to be delivered via some 4. Text (for sms) -Logic +Logic ----- In ICTCore we have tried to keep logic related components independent and separate from other technical things. there are three components in this category. @@ -100,8 +100,8 @@ Telecommunication engine / backend like Asterisk, Freeswitch, Sendmail etc .. cu 2. Sendmail 3. Kannel -### Schedule -In case some transmission need scheduling, reminder or a transmission configured for retry got failed, don't worry Schedule is here to take care of such things. +### Task and Schedule +In case a transmission or some other action require a delay execution, Task and Schedule interfaces can be used for that. For example a reminder or failed transmission can be configured for retry, by using Schedule interface. Infrastructure @@ -116,6 +116,8 @@ Currently we only support Providers but later on we will add other components. 5. (TODO) Backup servers ### Provider -A trunk, 3rd party provider required to originate / terminate transmissions. - +A trunk, 3rd party provider required to originate / terminate transmissions. ICTCore support following 3 type providers +1. Sip for Voice and Fax +2. Smpp for SMS +3. Sendmail for Email \ No newline at end of file diff --git a/tests/core/lib/TokenTest.php b/tests/core/lib/TokenTest.php index 52495a3..f86e38e 100644 --- a/tests/core/lib/TokenTest.php +++ b/tests/core/lib/TokenTest.php @@ -135,6 +135,30 @@ public function testMerge() $this->assertSame($newData['array1']['child3']['dog3'], $dog3); } + /** + * @covers ICT\Core\Token::token_resolve + * @todo Implement testToken_resolve(). + */ + public function testToken_resolve() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ICT\Core\Token::render + * @todo Implement testRender(). + */ + public function testRender() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + /** * @covers ICT\Core\Token::render_template * @todo Implement testRender_template(). @@ -187,4 +211,27 @@ public function testRender_string() $this->assertEmpty($unknown, "Testing with REPLACE_EMPTY failed"); } + /** + * @covers ICT\Core\Token::render_string_callback + * @todo Implement testRender_string_callback(). + */ + public function testRender_string_callback() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ICT\Core\Token::is_token + */ + public function testIs_token() + { + $this->assertTrue($this->object->is_token("[somthting]")); + $this->assertTrue($this->object->is_token("[somthting:special]")); + $this->assertFalse($this->object->is_token("[somthting] other")); + $this->assertFalse($this->object->is_token("everything else")); + } + } \ No newline at end of file diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e66b403..21f339f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -436,20 +436,20 @@ "source": { "type": "git", "url": "https://github.com/jacwright/RestServer.git", - "reference": "adfa1460e61178d53d63e72b2e65ab68d53b8ad7" + "reference": "584aa063caeb88f2bbbdcd145786ae0df1df029c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jacwright/RestServer/zipball/adfa1460e61178d53d63e72b2e65ab68d53b8ad7", - "reference": "adfa1460e61178d53d63e72b2e65ab68d53b8ad7", + "url": "https://api.github.com/repos/jacwright/RestServer/zipball/584aa063caeb88f2bbbdcd145786ae0df1df029c", + "reference": "584aa063caeb88f2bbbdcd145786ae0df1df029c", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2016-06-21T14:05:17+00:00", + "time": "2016-12-20T19:04:05+00:00", "type": "library", - "installation-source": "source", + "installation-source": "dist", "autoload": { "psr-0": { "Jacwright\\RestServer": "source/"