Permalink
Browse files

Release 6.4.2

  • Loading branch information...
1 parent e979cc7 commit 26999fe38820976e3f35a2ba2e4f1f673d04bbb6 John Mertic committed Mar 13, 2012
View
4 ModuleInstall/ModuleScanner.php
@@ -263,11 +263,11 @@ public function scanDir($path){
* @param string $contents File contents
* @return boolean
*/
- protected function isPHPFile($contents)
+ public function isPHPFile($contents)
{
if(stripos($contents, '<?php') !== false) return true;
for($tag=0;($tag = stripos($contents, '<?', $tag)) !== false;$tag++) {
- if(strncasecmp(substr($contents, $tag, 13), '<?xml version', 13)) {
+ if(strncasecmp(substr($contents, $tag, 13), '<?xml version', 13) == 0) {
// <?xml version is OK, skip it
$tag++;
continue;
View
14 files.md5
@@ -1,5 +1,5 @@
<?php
-// created: 2012-02-29 15:51:29
+// created: 2012-03-12 10:50:53
$md5_string = array (
'./LICENSE.txt' => 'd3f150e4a5bed444763ebe8a81742a95',
'./.htaccess' => 'd41d8cd98f00b204e9800998ecf8427e',
@@ -1173,7 +1173,7 @@ $md5_string = array (
'./themes/Sugar5/css/print.css' => 'c00fb2d3011318e43c4b1332080d1698',
'./themes/Sugar5/css/deprecated.css' => 'b5471d86d506bea8630df869fbfbe9cb',
'./themes/Sugar5/css/chart.css' => '78bf9d159067f20c5e3fc6adf7762f1c',
- './sugar_version.php' => '5dac7dda0b72d3938b61289c3ada16c3',
+ './sugar_version.php' => '9e9b8cd083f1750d83cc883a0a3a4e69',
'./soap/SoapTypes.php' => '6dd557894d504db5527eceb5dab0a26f',
'./soap/SoapSugarUsers.php' => '929ace28687ade89743d2a661746244a',
'./soap/SoapStudio.php' => '0fd81758942a52940c119f3afa134fcd',
@@ -1188,9 +1188,9 @@ $md5_string = array (
'./soap.php' => 'b507c82aa35ff6765a082a1b875d4865',
'./service/v4_1/soap.php' => '7c63568c21b0ee71eb6aac6b5adebc5d',
'./service/v4_1/rest.php' => '0a622cbfedd7592f7b4cc174bd8245c8',
- './service/v4_1/registry.php' => '02002bf41e3614f8b15de925ef4155aa',
+ './service/v4_1/registry.php' => 'd26ac7142d9c2b8491754f2d01711088',
'./service/v4_1/SugarWebServiceUtilv4_1.php' => '914b66c8b3dff76e428d9be01c4442ab',
- './service/v4_1/SugarWebServiceImplv4_1.php' => '7be626b473a94beb92af78470868ddfe',
+ './service/v4_1/SugarWebServiceImplv4_1.php' => '2b19d928d604d18e82183db988bc6f26',
'./service/v4/soap.php' => '846a967557552767c6ae0d366d4d3d2e',
'./service/v4/rest.php' => '0721bd365d3151c72db6f95ce4b7e186',
'./service/v4/registry.php' => 'eb5f47fb4e4a536aad58984a433b41d5',
@@ -3023,7 +3023,7 @@ $md5_string = array (
'./modules/Activities/language/en_us.lang.php' => '915ca75c37f8eaf6212cb4638e1b5bbc',
'./modules/Activities/config.php' => '263bbe4872534909a02db8be2f6ab95a',
'./modules/Activities/SubPanelViewContacts.html' => 'ba5a475b493fcfb2b9dcec79380f9137',
- './modules/Activities/Activity.php' => 'f4f67a4dfa43195a30f4c33be12f5233',
+ './modules/Activities/Activity.php' => '4dde8c1760bd9021b0f2b27346e17df2',
'./modules/Activities/SubPanelView.html' => '9dc12c6183eb5c4d4dcb907f9732f142',
'./modules/Activities/SetAcceptStatus.php' => '99917cfe39ceb08a60bb806e63254f11',
'./modules/Activities/OpenListView.php' => '4eea6e4645852f3139c66e31cb69e772',
@@ -4172,7 +4172,7 @@ $md5_string = array (
'./include/utils/layout_utils.php' => '8e9ba2ade862c13f6b5af45f5713eb2c',
'./include/utils/file_utils.php' => 'd27f493aaffe0d4ecc32db336be9d0b0',
'./include/utils/external_cache.php' => 'a0e044ccf54743fddb2da7b1d6208a07',
- './include/utils/mvc_utils.php' => '8e9f321db0392a138cd61b8574686659',
+ './include/utils/mvc_utils.php' => '0f9fb4f2c9aec99a611775aaadc09e59',
'./include/utils/encryption_utils.php' => 'aed0886450487779feb6612dae1b68c9',
'./include/utils/db_utils.php' => '3d000220b95163739f8b9290e211cd9f',
'./include/utils/autoloader.php' => '3d86e0d26ac8fc289c5d5ca1e8cc6d5a',
@@ -7153,7 +7153,7 @@ $md5_string = array (
'./ModuleInstall/PackageManager/PackageManager.php' => 'a9996b2cdb5bf8711174c20752bccbe3',
'./ModuleInstall/PackageManager/PackageController.php' => 'af8c746cbb6ba5142568d34e535d0a94',
'./ModuleInstall/PackageManager/ListViewPackages.php' => '9ad64855ae4721d76eac402fd7adc524',
- './ModuleInstall/ModuleScanner.php' => '4c7a1ac1ca7b8913fa6c1b39f9802052',
+ './ModuleInstall/ModuleScanner.php' => 'b124cc2069f4419ae8c50335a6ffdbf2',
'./ModuleInstall/ModuleInstaller.php' => '968eddb60d3da05bbae7eeb0fa3b430d',
'./HandleAjaxCall.php' => 'e8f0cb63050a3f85e26d5f295c54d8b6',
);
View
2 include/utils/mvc_utils.php
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 modules/Activities/Activity.php
@@ -45,7 +45,7 @@
*/
require_once('data/SugarBean.php');
-abstract class Activity extends SugarBean
+class Activity extends SugarBean
{
//Member variable to store value of related records when secondary selects are made via create_new_list_query
View
65 service/v4_1/SugarWebServiceImplv4_1.php
@@ -104,39 +104,56 @@ function get_relationships($session, $module_name, $module_id, $link_field_name,
/**
* get_modified_relationships
*
- * Get a list of the relationship records that have been modified within a specified date range. This is used to
- * help facilitate sync operations.
+ * Get a list of the relationship records that have a date_modified value set within a specified date range. This is used to
+ * help facilitate sync operations. The module_name should be "Users" and the related_module one of "Meetings", "Calls" and
+ * "Contacts".
*
* @param xsd:string $session String of the session id
* @param xsd:string $module_name String value of the primary module to retrieve relationship against
* @param xsd:string $related_module String value of the related module to retrieve records off of
- * @param xsd:string $from_date String value in YYYY-MM-DD HH:MM:SS format of starting date modified range
- * @param xsd:string $to_date String value in YYYY-MM-DD HH:MM:SS format of ending date modified range
+ * @param xsd:string $from_date String value in YYYY-MM-DD HH:MM:SS format of date_start range (required)
+ * @param xsd:string $to_date String value in YYYY-MM-DD HH:MM:SS format of ending date_start range (required)
* @param xsd:int $offset Integer value of the offset to begin returning records from
* @param xsd:int $max_results Integer value of the max_results to return; -99 for unlimited
* @param xsd:int $deleted Integer value indicating deleted column value search (defaults to 0). Set to 1 to find deleted records
- * @param xsd:string $module_user_id String value of the user id to filter by (optional, no filtering by default)
+ * @param xsd:string $module_user_id String value of the user id (optional, but defaults to SOAP session user id anyway) The module_user_id value
+ * here ought to be the user id of the user initiating the SOAP session
* @param tns:select_fields $select_fields Array value of fields to select and return as name/value pairs
* @param xsd:string $relationship_name String value of the relationship name to search on
- * @param xsd:string $deletion_date String value in YYYY-MM-DD HH:MM:SS format for filtering on deleted records
+ * @param xsd:string $deletion_date String value in YYYY-MM-DD HH:MM:SS format for filtering on deleted records whose date_modified falls within range
* this allows deleted records to be returned as well
*
* @return Array records that match search criteria
*/
- function get_modified_relationships($session, $module_name, $related_module, $from_date, $to_date, $offset, $max_results, $deleted, $module_user_id = '', $select_fields = array(), $relationship_name = '', $deletion_date = ''){
+ function get_modified_relationships($session, $module_name, $related_module, $from_date, $to_date, $offset, $max_results, $deleted=0, $module_user_id = '', $select_fields = array(), $relationship_name = '', $deletion_date = ''){
global $beanList, $beanFiles;
$error = new SoapError();
$output_list = array();
- if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', $module_name, 'read', 'no_access', $error)) {
+ if(empty($from_date))
+ {
+ $error->set_error('invalid_call_error, missing from_date');
+ return array('result_count'=>0, 'next_offset'=>0, 'field_list'=>$select_fields, 'entry_list'=>array(), 'error'=>$error->get_soap_array());
+ }
+
+ if(empty($to_date))
+ {
+ $error->set_error('invalid_call_error, missing to_date');
+ return array('result_count'=>0, 'next_offset'=>0, 'field_list'=>$select_fields, 'entry_list'=>array(), 'error'=>$error->get_soap_array());
+ }
+
+ if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', $module_name, 'read', 'no_access', $error))
+ {
$GLOBALS['log']->info('End: SugarWebServiceImpl->get_modified_relationships');
return;
} // if
- if(empty($beanList[$module_name]) || empty($beanList[$related_module])){
+ if(empty($beanList[$module_name]) || empty($beanList[$related_module]))
+ {
$error->set_error('no_module');
return array('result_count'=>0, 'next_offset'=>0, 'field_list'=>$select_fields, 'entry_list'=>array(), 'error'=>$error->get_soap_array());
}
+
global $current_user;
if(!self::$helperObject->check_modules_access($current_user, $module_name, 'read') || !self::$helperObject->check_modules_access($current_user, $related_module, 'read')){
$error->set_error('no_access');
@@ -150,37 +167,19 @@ function get_modified_relationships($session, $module_name, $related_module, $fr
// Cast to integer
$deleted = (int)$deleted;
- $date_query = "(m1.date_modified > " . db_convert("'".$GLOBALS['db']->quote($from_date)."'", 'datetime'). " AND m1.date_modified <= ". db_convert("'".$GLOBALS['db']->quote($to_date)."'", 'datetime')." AND {0}.deleted = $deleted)";
+ $query = "(m1.date_modified > " . db_convert("'".$GLOBALS['db']->quote($from_date)."'", 'datetime'). " AND m1.date_modified <= ". db_convert("'".$GLOBALS['db']->quote($to_date)."'", 'datetime')." AND {0}.deleted = $deleted)";
if(isset($deletion_date) && !empty($deletion_date)){
- $date_query .= " OR ({0}.date_modified > " . db_convert("'".$GLOBALS['db']->quote($deletion_date)."'", 'datetime'). " AND {0}.date_modified <= ". db_convert("'".$GLOBALS['db']->quote($to_date)."'", 'datetime')." AND {0}.deleted = 1)";
- }
-
- $in = '';
- $ids = array(); //we do not support this right now
- if(isset($ids) && !empty($ids))
- {
- foreach($ids as $value)
- {
- $in .= ",'" . $GLOBALS['db']->quote($value) . "'";
- }
- $in = '('. substr($in, 1) . ')';
- }
- $query = '';
- if(isset($in) && !empty($in)){
- $query .= "( $date_query AND m1.id IN $in) OR (m1.id NOT IN $in AND {0}.deleted = 0)";
- } else {
- $query .= "( {0}.deleted = 0)";
+ $query .= " OR ({0}.date_modified > " . db_convert("'".$GLOBALS['db']->quote($deletion_date)."'", 'datetime'). " AND {0}.date_modified <= ". db_convert("'".$GLOBALS['db']->quote($to_date)."'", 'datetime')." AND {0}.deleted = 1)";
}
if(!empty($module_user_id))
{
- $query .= " AND";
- $query .= " m2.id = '".$GLOBALS['db']->quote($module_user_id)."'";
+ $query .= " AND m2.id = '".$GLOBALS['db']->quote($module_user_id)."'";
}
- if($related_module == 'Meetings' || $related_module == 'Calls' || $related_module = 'Contacts'){
- $query = string_format($query, array('m1'));
- }
+ //if($related_module == 'Meetings' || $related_module == 'Calls' || $related_module = 'Contacts'){
+ $query = string_format($query, array('m1'));
+ //}
require_once('soap/SoapRelationshipHelper.php');
$results = retrieve_modified_relationships($module_name, $related_module, $query, $deleted, $offset, $max_results, $select_fields, $relationship_name);
View
116 service/v4_1/registry.php
@@ -74,56 +74,70 @@ protected function registerFunction()
*/
protected function registerTypes() {
- parent::registerTypes();
-
- //modified_relationship_entry
- //This type consists of id, module_name and name_value_list type
- $this->serviceClass->registerType
- (
- 'modified_relationship_entry',
- 'complexType',
- 'array',
- 'all',
- '',
- array(
- 'id' => array('name'=>'id', 'type'=>'xsd:string'),
- 'module_name' => array('name'=>'module_name', 'type'=>'xsd:string'),
- 'name_value_list' => array('name'=>'name_value_list', 'type'=>'tns:name_value_lists')
- )
- );
-
- //modified_relationship_entry_list
- //This type holds the array of modified_relationship_entry types
- $this->serviceClass->registerType(
- 'modified_relationship_entry_list',
- 'complexType',
- 'array',
- '',
- 'SOAP-ENC:Array',
- array(),
- array(
- array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:modified_relationship_entry')
- ),
- 'modified_relationship_entry'
- );
-
- //modified_relationship_result
- //the top level result array
- $this->serviceClass->registerType
- (
- 'modified_relationship_result',
- 'complexType',
- 'array',
- 'all',
- '',
- array(
- 'result_count' => array('name'=>'result_count', 'type'=>'xsd:int'),
- 'next_offset' => array('name'=>'next_offset', 'type'=>'xsd:int'),
- 'entry_list' => array('name'=>'entry_list', 'type'=>'tns:modified_relationship_entry_list'),
- 'error' => array('name' =>'error', 'type'=>'tns:error_value'),
- )
- );
-
- }
+ parent::registerTypes();
+
+ $this->serviceClass->registerType
+ (
+ 'error_value',
+ 'complexType',
+ 'struct',
+ 'all',
+ '',
+ array(
+ 'number'=>array('name'=>'number', 'type'=>'xsd:string'),
+ 'name'=>array('name'=>'name', 'type'=>'xsd:string'),
+ 'description'=>array('name'=>'description', 'type'=>'xsd:string'),
+ )
+ );
+
+ //modified_relationship_entry_list
+ //This type holds the array of modified_relationship_entry types
+ $this->serviceClass->registerType(
+ 'modified_relationship_entry_list',
+ 'complexType',
+ 'array',
+ '',
+ 'SOAP-ENC:Array',
+ array(),
+ array(
+ array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:modified_relationship_entry[]')
+ ),
+ 'tns:modified_relationship_entry'
+ );
+
+ //modified_relationship_entry
+ //This type consists of id, module_name and name_value_list type
+ $this->serviceClass->registerType
+ (
+ 'modified_relationship_entry',
+ 'complexType',
+ 'struct',
+ 'all',
+ '',
+ array(
+ 'id' => array('name'=>'id', 'type'=>'xsd:string'),
+ 'module_name' => array('name'=>'module_name', 'type'=>'xsd:string'),
+ 'name_value_list' => array('name'=>'name_value_lists', 'type'=>'tns:name_value_list')
+ )
+ );
+
+ //modified_relationship_result
+ //the top level result array
+ $this->serviceClass->registerType
+ (
+ 'modified_relationship_result',
+ 'complexType',
+ 'struct',
+ 'all',
+ '',
+ array(
+ 'result_count' => array('name'=>'result_count', 'type'=>'xsd:int'),
+ 'next_offset' => array('name'=>'next_offset', 'type'=>'xsd:int'),
+ 'entry_list' => array('name'=>'entry_list', 'type'=>'tns:modified_relationship_entry_list'),
+ 'error' => array('name' =>'error', 'type'=>'tns:error_value'),
+ )
+ );
+
+}
}
View
8 sugar_version.php
@@ -38,10 +38,10 @@
-$sugar_version = '6.4.1';
-$sugar_db_version = '6.4.1';
+$sugar_version = '6.4.2';
+$sugar_db_version = '6.4.2';
$sugar_flavor = 'CE';
-$sugar_build = '7335';
-$sugar_timestamp = '2012-02-29 03:45pm';
+$sugar_build = '7526';
+$sugar_timestamp = '2012-03-12 10:44am';
?>
View
59 tests/ModuleInstall/ModuleScannerTest.php
@@ -39,7 +39,7 @@
class ModuleScannerTest extends Sugar_PHPUnit_Framework_TestCase
{
var $fileLoc;
-
+
public function setUp()
{
$this->fileLoc = "cache/moduleScannerTemp.php";
@@ -50,16 +50,39 @@ public function tearDown()
if (is_file($this->fileLoc))
unlink($this->fileLoc);
}
-
- public function testFileTemplatePass()
+
+ public function phpSamples()
+ {
+ return array(
+ array("<?php echo blah;", true),
+ array("<? echo blah;", true),
+ array("blah <? echo blah;", true),
+ array("blah <?xml echo blah;", true),
+ array("<?xml version=\"1.0\"></xml>", false),
+ array("<?xml \n echo blah;", true),
+ array("<?xml version=\"1.0\"><? blah ?></xml>", true),
+ array("<?xml version=\"1.0\"><?php blah ?></xml>", true),
+ );
+ }
+
+ /**
+ * @dataProvider phpSamples
+ */
+ public function testPHPFile($content, $is_php)
+ {
+ $ms = new MockModuleScanner();
+ $this->assertEquals($is_php, $ms->isPHPFile($content), "Bad PHP file result");
+ }
+
+ public function testFileTemplatePass()
{
-
+
$fileModContents = <<<EOQ
<?PHP
require_once('include/SugarObjects/templates/file/File.php');
class testFile_sugar extends File {
- function fileT_testFiles_sugar(){
+ function fileT_testFiles_sugar(){
parent::File();
\$this->file = new File();
\$file = "file";
@@ -72,20 +95,20 @@ function fileT_testFiles_sugar(){
$errors = $ms->scanFile($this->fileLoc);
$this->assertTrue(empty($errors));
}
-
- public function testFileFunctionFail()
+
+ public function testFileFunctionFail()
{
-
+
$fileModContents = <<<EOQ
<?PHP
require_once('include/SugarObjects/templates/file/File.php');
class testFile_sugar extends File {
- function fileT_testFiles_sugar(){
+ function fileT_testFiles_sugar(){
parent::File();
\$this->file = new File();
\$file = file('test.php');
-
+
}
}
?>
@@ -95,10 +118,10 @@ function fileT_testFiles_sugar(){
$errors = $ms->scanFile($this->fileLoc);
$this->assertTrue(!empty($errors));
}
-
- public function testCallUserFunctionFail()
+
+ public function testCallUserFunctionFail()
{
-
+
$fileModContents = <<<EOQ
<?PHP
call_user_func("sugar_file_put_contents", "test2.php", "test");
@@ -109,7 +132,13 @@ public function testCallUserFunctionFail()
$errors = $ms->scanFile($this->fileLoc);
$this->assertTrue(!empty($errors));
}
-
-
}
+
+class MockModuleScanner extends ModuleScanner
+{
+ public function isPHPFile($contents) {
+ return parent::isPHPFile($contents);
+ }
+}
+
View
5 tests/modules/Import/Bug50438Test.php
@@ -89,7 +89,10 @@ public function tearDown()
public function testParentsAreRelatedDuringImport()
{
- $file = 'upload://test50438.csv';
+ //$file = 'upload://test50438.csv';
+ $upload_dir = isset($GLOBALS['sugar_config']['upload_dir']) ? $GLOBALS['sugar_config']['upload_dir'] : 'upload';
+ $file = $upload_dir . '/test50438.csv';
+
$ret = file_put_contents($file, $this->fileArr);
$this->assertGreaterThan(0, $ret, 'Failed to write to '.$file .' for content '.var_export($this->fileArr,true));
View
277 tests/service/RESTAPI4_1Test.php
@@ -0,0 +1,277 @@
+<?php
+/*********************************************************************************
+ * SugarCRM Community Edition is a customer relationship management program developed by
+ * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Affero General Public License version 3 as published by the
+ * Free Software Foundation with the addition of the following permission added
+ * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
+ * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
+ * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Affero General Public License along with
+ * this program; if not, see http://www.gnu.org/licenses or write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ *
+ * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
+ * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU Affero General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "Powered by
+ * SugarCRM" logo. If the display of the logo is not reasonably feasible for
+ * technical reasons, the Appropriate Legal Notices must display the words
+ * "Powered by SugarCRM".
+ ********************************************************************************/
+
+
+
+require_once('tests/service/APIv3Helper.php');
+
+class RESTAPI4_1Test extends Sugar_PHPUnit_Framework_TestCase
+{
+ protected $_lastRawResponse;
+ protected $contact1;
+ protected $contact2;
+ protected $another_user;
+ protected $meeting1;
+ protected $meeting2;
+ protected $meeting3;
+ protected $call1;
+ protected $call2;
+
+ public function setUp()
+ {
+ global $beanList, $beanFiles;
+ $beanList = array();
+ $beanFiles = array();
+ require('include/modules.php');
+
+ $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/service/v4_1/soap.php';
+ parent::setUp();
+ $this->_login();
+ global $current_user;
+ $current_user = SugarTestUserUtilities::createAnonymousUser();
+ $this->another_user = SugarTestUserUtilities::createAnonymousUser();
+
+ $this->contact1 = SugarTestContactUtilities::createContact();
+ $this->contact1->contacts_users_id = $current_user->id;
+ $this->contact1->first_name = 'First1';
+ $this->contact1->last_name = 'Last1';
+ $this->contact1->save();
+
+ $this->contact1->user_sync->add($current_user);
+ $this->contact1->sync_contact = 1;
+ $this->contact1->save();
+
+ $this->contact2 = SugarTestContactUtilities::createContact();
+ $this->contact2->contacts_users_id = $this->another_user->id;
+ $this->contact2->first_name = 'First2';
+ $this->contact2->last_name = 'Last2';
+ $this->contact2->save();
+
+ $this->contact2->user_sync->add($this->another_user);
+ $this->contact2->sync_contact = 1;
+ $this->contact2->save();
+
+ $this->call1 = SugarTestCallUtilities::createCall();
+ $this->call1->name = 'RESTAPI4_1Test1';
+ $this->call1->load_relationship('users');
+ $this->call1->users->add($current_user);
+ $this->call1->save();
+
+ $this->call2 = SugarTestCallUtilities::createCall();
+ $this->call2->name = 'RESTAPI4_1Test2';
+ $this->call2->load_relationship('users');
+ $this->call2->users->add($current_user);
+ $this->call2->save();
+
+ $this->meeting1 = SugarTestMeetingUtilities::createMeeting();
+ $this->meeting1->name = 'RESTAPI4_1Test1';
+ $this->meeting1->load_relationship('users');
+ $this->meeting1->users->add($current_user);
+ $this->meeting1->save();
+
+ $this->meeting2 = SugarTestMeetingUtilities::createMeeting();
+ $this->meeting2->name = 'RESTAPI4_1Test2';
+ $this->meeting2->load_relationship('users');
+ $this->meeting2->users->add($this->another_user);
+ $this->meeting2->save();
+
+ $this->meeting3 = SugarTestMeetingUtilities::createMeeting();
+ $this->meeting3->name = 'RESTAPI4_1Test3';
+ $this->meeting3->load_relationship('users');
+ $this->meeting3->users->add($current_user);
+ $this->meeting3->save();
+
+ $this->meeting4 = SugarTestMeetingUtilities::createMeeting();
+ $this->meeting4->name = 'SOAPAPI4_1Test4';
+ $this->meeting4->load_relationship('users');
+ $this->meeting4->users->add($current_user);
+ $this->meeting4->mark_deleted($this->meeting4->id);
+ $this->meeting4->deleted = 1;
+ $this->meeting4->save();
+ $GLOBALS['db']->commit();
+ }
+
+ public function tearDown()
+ {
+ SugarTestContactUtilities::removeCreatedContactsUsersRelationships();
+ SugarTestContactUtilities::removeAllCreatedContacts();
+ SugarTestMeetingUtilities::removeMeetingContacts();
+ SugarTestMeetingUtilities::removeAllCreatedMeetings();
+ SugarTestCallUtilities::removeAllCreatedCalls();
+ unset($GLOBALS['beanList']);
+ unset($GLOBALS['beanFiles']);
+ unset($GLOBALS['app_list_strings']);
+ unset($GLOBALS['app_strings']);
+ unset($GLOBALS['mod_strings']);
+ unset($GLOBALS['current_user']);
+ }
+
+ protected function _makeRESTCall($method,$parameters)
+ {
+ // specify the REST web service to interact with
+ $url = $GLOBALS['sugar_config']['site_url'].'/service/v4_1/rest.php';
+ // Open a curl session for making the call
+ $curl = curl_init($url);
+ // set URL and other appropriate options
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
+ curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
+ // build the request URL
+ $json = json_encode($parameters);
+ $postArgs = "method=$method&input_type=JSON&response_type=JSON&rest_data=$json";
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs);
+ // Make the REST call, returning the result
+ $response = curl_exec($curl);
+ // Close the connection
+ curl_close($curl);
+
+ $this->_lastRawResponse = $response;
+
+ // Convert the result from JSON format to a PHP array
+ return json_decode($response,true);
+ }
+
+ protected function _returnLastRawResponse()
+ {
+ return "Error in web services call. Response was: {$this->_lastRawResponse}";
+ }
+
+ protected function _login()
+ {
+ $GLOBALS['db']->commit(); // Making sure we commit any changes before logging in
+ global $current_user;
+ return $this->_makeRESTCall('login',
+ array(
+ 'user_auth' =>
+ array(
+ 'user_name' => $current_user->user_name,
+ 'password' => $current_user->user_hash,
+ 'version' => '.01',
+ ),
+ 'application_name' => 'mobile',
+ 'name_value_list' => array(),
+ )
+ );
+ }
+
+
+ /**
+ *
+ */
+ public function testGetModifiedRelationships()
+ {
+ $result = $this->_login();
+ $this->assertTrue(!empty($result['id']) && $result['id'] != -1,$this->_returnLastRawResponse());
+ $session = $result['id'];
+
+ $callsAndMeetingsFields = array('id', 'date_modified', 'deleted', 'name', 'rt.deleted synced');
+ $contactsSelectFields = array('id', 'date_modified', 'deleted', 'first_name', 'last_name', 'rt.deleted synced');
+
+ global $timedate, $current_user;
+ $one_hour_ago = $timedate->asDb($timedate->getNow()->get("-1 hours"));
+ $one_hour_later = $timedate->asDb($timedate->getNow()->get("+1 hours"));
+
+ $result = $this->_makeRESTCall('get_modified_relationships',
+ array(
+ 'session' => $session,
+ 'module_name' => 'Users',
+ 'related_module' => 'Contacts',
+ 'from_date' => $one_hour_ago,
+ 'to_date' => $one_hour_later,
+ 'offset' => 0,
+ 'max_results' => 10,
+ 'deleted' => 0,
+ 'user_id' => $current_user->id,
+ 'select_fields' => $contactsSelectFields,
+ 'relationship_name' => 'contacts_users',
+ 'deletion_date' => '',
+ )
+ );
+
+ $this->assertNotEmpty($result['entry_list']);
+ $this->assertEquals(1, $result['result_count']);
+ $this->assertEquals(1, $result['next_offset']);
+
+
+ $result = $this->_makeRESTCall('get_modified_relationships',
+ array(
+ 'session' => $session,
+ 'module_name' => 'Users',
+ 'related_module' => 'Meetings',
+ 'from_date' => $one_hour_ago,
+ 'to_date' => $one_hour_later,
+ 'offset' => 0,
+ 'max_results' => 10,
+ 'deleted' => 0,
+ 'user_id' => $current_user->id,
+ 'select_fields' => $callsAndMeetingsFields,
+ 'relationship_name' => 'meetings_users',
+ 'deletion_date' => '',
+ )
+ );
+
+ $this->assertNotEmpty($result['entry_list']);
+ $this->assertEquals(2, $result['result_count']);
+ $this->assertEquals(2, $result['next_offset']);
+
+ $result = $this->_makeRESTCall('get_modified_relationships',
+ array(
+ 'session' => $session,
+ 'module_name' => 'Users',
+ 'related_module' => 'Meetings',
+ 'from_date' => $one_hour_ago,
+ 'to_date' => $one_hour_later,
+ 'offset' => 0,
+ 'max_results' => 10,
+ 'deleted' => 1,
+ 'user_id' => $current_user->id,
+ 'select_fields' => $callsAndMeetingsFields,
+ 'relationship_name' => 'meetings_users',
+ 'deletion_date' => $one_hour_ago,
+ )
+ );
+
+ $this->assertNotEmpty($result['entry_list']);
+ $this->assertEquals(1, $result['result_count']);
+ $this->assertEquals(1, $result['next_offset']);
+
+ }
+
+}

0 comments on commit 26999fe

Please sign in to comment.