@@ -51,95 +51,95 @@ |
||
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | class FieldsMetaData extends SugarBean { |
| 54 | - // database table columns |
|
| 55 | - var $id; |
|
| 56 | - var $name; |
|
| 57 | - var $vname; |
|
| 58 | - var $custom_module; |
|
| 59 | - var $type; |
|
| 60 | - var $len; |
|
| 61 | - var $required; |
|
| 62 | - var $default_value; |
|
| 63 | - var $deleted; |
|
| 64 | - var $ext1; |
|
| 65 | - var $ext2; |
|
| 66 | - var $ext3; |
|
| 67 | - var $audited; |
|
| 68 | - var $inline_edit; |
|
| 54 | + // database table columns |
|
| 55 | + var $id; |
|
| 56 | + var $name; |
|
| 57 | + var $vname; |
|
| 58 | + var $custom_module; |
|
| 59 | + var $type; |
|
| 60 | + var $len; |
|
| 61 | + var $required; |
|
| 62 | + var $default_value; |
|
| 63 | + var $deleted; |
|
| 64 | + var $ext1; |
|
| 65 | + var $ext2; |
|
| 66 | + var $ext3; |
|
| 67 | + var $audited; |
|
| 68 | + var $inline_edit; |
|
| 69 | 69 | var $duplicate_merge; |
| 70 | 70 | var $reportable; |
| 71 | - var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
| 72 | - |
|
| 73 | - var $table_name = 'fields_meta_data'; |
|
| 74 | - var $object_name = 'FieldsMetaData'; |
|
| 75 | - var $module_dir = 'DynamicFields'; |
|
| 76 | - var $column_fields = array( |
|
| 77 | - 'id', |
|
| 78 | - 'name', |
|
| 79 | - 'vname', |
|
| 80 | - 'custom_module', |
|
| 81 | - 'type', |
|
| 82 | - 'len', |
|
| 83 | - 'required', |
|
| 84 | - 'default_value', |
|
| 85 | - 'deleted', |
|
| 86 | - 'ext1', |
|
| 87 | - 'ext2', |
|
| 88 | - 'ext3', |
|
| 89 | - 'audited', |
|
| 90 | - 'inline_edit', |
|
| 91 | - 'massupdate', |
|
| 71 | + var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
| 72 | + |
|
| 73 | + var $table_name = 'fields_meta_data'; |
|
| 74 | + var $object_name = 'FieldsMetaData'; |
|
| 75 | + var $module_dir = 'DynamicFields'; |
|
| 76 | + var $column_fields = array( |
|
| 77 | + 'id', |
|
| 78 | + 'name', |
|
| 79 | + 'vname', |
|
| 80 | + 'custom_module', |
|
| 81 | + 'type', |
|
| 82 | + 'len', |
|
| 83 | + 'required', |
|
| 84 | + 'default_value', |
|
| 85 | + 'deleted', |
|
| 86 | + 'ext1', |
|
| 87 | + 'ext2', |
|
| 88 | + 'ext3', |
|
| 89 | + 'audited', |
|
| 90 | + 'inline_edit', |
|
| 91 | + 'massupdate', |
|
| 92 | 92 | 'duplicate_merge', |
| 93 | 93 | 'reportable', |
| 94 | - ); |
|
| 95 | - |
|
| 96 | - var $list_fields = array( |
|
| 97 | - 'id', |
|
| 98 | - 'name', |
|
| 99 | - 'vname', |
|
| 100 | - 'type', |
|
| 101 | - 'len', |
|
| 102 | - 'required', |
|
| 103 | - 'default_value', |
|
| 104 | - 'audited', |
|
| 94 | + ); |
|
| 95 | + |
|
| 96 | + var $list_fields = array( |
|
| 97 | + 'id', |
|
| 98 | + 'name', |
|
| 99 | + 'vname', |
|
| 100 | + 'type', |
|
| 101 | + 'len', |
|
| 102 | + 'required', |
|
| 103 | + 'default_value', |
|
| 104 | + 'audited', |
|
| 105 | 105 | 'inline_edit', |
| 106 | - 'massupdate', |
|
| 106 | + 'massupdate', |
|
| 107 | 107 | 'duplicate_merge', |
| 108 | 108 | 'reportable', |
| 109 | - ); |
|
| 109 | + ); |
|
| 110 | 110 | |
| 111 | - var $field_name_map; |
|
| 112 | - var $new_schema = true; |
|
| 111 | + var $field_name_map; |
|
| 112 | + var $new_schema = true; |
|
| 113 | 113 | |
| 114 | - ////////////////////////////////////////////////////////////////// |
|
| 115 | - // METHODS |
|
| 116 | - ////////////////////////////////////////////////////////////////// |
|
| 114 | + ////////////////////////////////////////////////////////////////// |
|
| 115 | + // METHODS |
|
| 116 | + ////////////////////////////////////////////////////////////////// |
|
| 117 | 117 | |
| 118 | - function FieldsMetaData() |
|
| 119 | - { |
|
| 120 | - parent::SugarBean(); |
|
| 121 | - $this->disable_row_level_security = true; |
|
| 122 | - } |
|
| 118 | + function FieldsMetaData() |
|
| 119 | + { |
|
| 120 | + parent::SugarBean(); |
|
| 121 | + $this->disable_row_level_security = true; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - function mark_deleted($id) |
|
| 125 | - { |
|
| 126 | - $query = "DELETE FROM $this->table_name WHERE id='$id'"; |
|
| 127 | - $this->db->query($query, true,"Error deleting record: "); |
|
| 128 | - $this->mark_relationships_deleted($id); |
|
| 124 | + function mark_deleted($id) |
|
| 125 | + { |
|
| 126 | + $query = "DELETE FROM $this->table_name WHERE id='$id'"; |
|
| 127 | + $this->db->query($query, true,"Error deleting record: "); |
|
| 128 | + $this->mark_relationships_deleted($id); |
|
| 129 | 129 | |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - function get_list_view_data(){ |
|
| 133 | - $data = parent::get_list_view_data(); |
|
| 134 | - $data['VNAME'] = translate($this->vname, $this->custom_module); |
|
| 135 | - $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >'; |
|
| 136 | - return $data; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - function get_summary_text() |
|
| 141 | - { |
|
| 142 | - return $this->name; |
|
| 143 | - } |
|
| 132 | + function get_list_view_data(){ |
|
| 133 | + $data = parent::get_list_view_data(); |
|
| 134 | + $data['VNAME'] = translate($this->vname, $this->custom_module); |
|
| 135 | + $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >'; |
|
| 136 | + return $data; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + function get_summary_text() |
|
| 141 | + { |
|
| 142 | + return $this->name; |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | var $inline_edit; |
| 69 | 69 | var $duplicate_merge; |
| 70 | 70 | var $reportable; |
| 71 | - var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
| 71 | + var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
| 72 | 72 | |
| 73 | 73 | var $table_name = 'fields_meta_data'; |
| 74 | 74 | var $object_name = 'FieldsMetaData'; |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | function mark_deleted($id) |
| 125 | 125 | { |
| 126 | 126 | $query = "DELETE FROM $this->table_name WHERE id='$id'"; |
| 127 | - $this->db->query($query, true,"Error deleting record: "); |
|
| 127 | + $this->db->query($query, true, "Error deleting record: "); |
|
| 128 | 128 | $this->mark_relationships_deleted($id); |
| 129 | 129 | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - function get_list_view_data(){ |
|
| 132 | + function get_list_view_data() { |
|
| 133 | 133 | $data = parent::get_list_view_data(); |
| 134 | 134 | $data['VNAME'] = translate($this->vname, $this->custom_module); |
| 135 | - $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >'; |
|
| 135 | + $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="'.$this->id.'"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record='.$this->id.'" >'; |
|
| 136 | 136 | return $data; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -40,95 +40,95 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | require_once('modules/DynamicFields/FieldCases.php'); |
| 42 | 42 | require_once('modules/DynamicFields/DynamicField.php'); |
| 43 | - global $db; |
|
| 44 | - if(!isset($db)){ |
|
| 45 | - $db = DBManagerFactory::getInstance(); |
|
| 46 | - } |
|
| 47 | - $result = $db->query( 'SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module'); |
|
| 48 | - $modules = array(); |
|
| 49 | - /* |
|
| 43 | + global $db; |
|
| 44 | + if(!isset($db)){ |
|
| 45 | + $db = DBManagerFactory::getInstance(); |
|
| 46 | + } |
|
| 47 | + $result = $db->query( 'SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module'); |
|
| 48 | + $modules = array(); |
|
| 49 | + /* |
|
| 50 | 50 | * get the real field_meta_data |
| 51 | 51 | */ |
| 52 | - while($row = $db->fetchByAssoc($result)){ |
|
| 53 | - $the_modules = $row['custom_module']; |
|
| 54 | - if(!isset($modules[$the_modules])){ |
|
| 55 | - $modules[$the_modules] = array(); |
|
| 56 | - } |
|
| 57 | - $modules[$the_modules][$row['name']] = $row['name']; |
|
| 58 | - } |
|
| 52 | + while($row = $db->fetchByAssoc($result)){ |
|
| 53 | + $the_modules = $row['custom_module']; |
|
| 54 | + if(!isset($modules[$the_modules])){ |
|
| 55 | + $modules[$the_modules] = array(); |
|
| 56 | + } |
|
| 57 | + $modules[$the_modules][$row['name']] = $row['name']; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $simulate = false; |
|
| 61 | - if(!isset($_REQUEST['run'])){ |
|
| 62 | - $simulate = true; |
|
| 63 | - echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE"; |
|
| 64 | - } |
|
| 60 | + $simulate = false; |
|
| 61 | + if(!isset($_REQUEST['run'])){ |
|
| 62 | + $simulate = true; |
|
| 63 | + echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE"; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - foreach($modules as $the_module=>$fields){ |
|
| 67 | - if(isset($beanList[$the_module])) |
|
| 68 | - { |
|
| 69 | - $class_name = $beanList[$the_module]; |
|
| 70 | - echo "<br><br>Scanning $the_module <br>"; |
|
| 66 | + foreach($modules as $the_module=>$fields){ |
|
| 67 | + if(isset($beanList[$the_module])) |
|
| 68 | + { |
|
| 69 | + $class_name = $beanList[$the_module]; |
|
| 70 | + echo "<br><br>Scanning $the_module <br>"; |
|
| 71 | 71 | |
| 72 | - require_once($beanFiles[$class_name]); |
|
| 73 | - $mod = new $class_name(); |
|
| 74 | - if(!$db->tableExists($mod->table_name . "_cstm")){ |
|
| 75 | - $mod->custom_fields = new DynamicField(); |
|
| 76 | - $mod->custom_fields->setup($mod); |
|
| 77 | - $mod->custom_fields->createCustomTable(); |
|
| 78 | - } |
|
| 72 | + require_once($beanFiles[$class_name]); |
|
| 73 | + $mod = new $class_name(); |
|
| 74 | + if(!$db->tableExists($mod->table_name . "_cstm")){ |
|
| 75 | + $mod->custom_fields = new DynamicField(); |
|
| 76 | + $mod->custom_fields->setup($mod); |
|
| 77 | + $mod->custom_fields->createCustomTable(); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - $result = $db->query("DESCRIBE $mod->table_name" . "_cstm"); |
|
| 80 | + $result = $db->query("DESCRIBE $mod->table_name" . "_cstm"); |
|
| 81 | 81 | |
| 82 | - while($row = $db->fetchByAssoc($result)){ |
|
| 82 | + while($row = $db->fetchByAssoc($result)){ |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | - $col = $row['Field']; |
|
| 86 | - $type = $row['Type']; |
|
| 87 | - $fieldDef = $mod->getFieldDefinition($col); |
|
| 88 | - $the_field = get_widget($fieldDef['type']); |
|
| 89 | - $the_field->set($fieldDef); |
|
| 85 | + $col = $row['Field']; |
|
| 86 | + $type = $row['Type']; |
|
| 87 | + $fieldDef = $mod->getFieldDefinition($col); |
|
| 88 | + $the_field = get_widget($fieldDef['type']); |
|
| 89 | + $the_field->set($fieldDef); |
|
| 90 | 90 | |
| 91 | - if(!isset($fields[$col]) && $col != 'id_c'){ |
|
| 92 | - if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col"); |
|
| 93 | - unset($fields[$col]); |
|
| 94 | - echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>"; |
|
| 95 | - } else{ |
|
| 96 | - if($col != 'id_c'){ |
|
| 97 | - if(trim($the_field->get_db_type()) != trim($type)){ |
|
| 91 | + if(!isset($fields[$col]) && $col != 'id_c'){ |
|
| 92 | + if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col"); |
|
| 93 | + unset($fields[$col]); |
|
| 94 | + echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>"; |
|
| 95 | + } else{ |
|
| 96 | + if($col != 'id_c'){ |
|
| 97 | + if(trim($the_field->get_db_type()) != trim($type)){ |
|
| 98 | 98 | |
| 99 | - echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>"; |
|
| 100 | - if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm')); |
|
| 101 | - } |
|
| 102 | - } |
|
| 99 | + echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>"; |
|
| 100 | + if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm')); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - unset($fields[$col]); |
|
| 105 | - } |
|
| 104 | + unset($fields[$col]); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - echo sizeof($fields) . " field(s) missing from $mod->table_name" . "_cstm<br>"; |
|
| 110 | - foreach($fields as $field){ |
|
| 111 | - echo "Adding Column $field to $mod->table_name" . "_cstm<br>"; |
|
| 112 | - if(!$simulate){ |
|
| 113 | - $the_field = $mod->getFieldDefinition($field); |
|
| 114 | - $field = get_widget($the_field['type']); |
|
| 115 | - $field->set($the_field); |
|
| 116 | - $query = $field->get_db_add_alter_table($mod->table_name . '_cstm'); |
|
| 117 | - echo $query; |
|
| 118 | - if(!empty($query)){ |
|
| 119 | - $mod->db->query($query); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - } |
|
| 109 | + echo sizeof($fields) . " field(s) missing from $mod->table_name" . "_cstm<br>"; |
|
| 110 | + foreach($fields as $field){ |
|
| 111 | + echo "Adding Column $field to $mod->table_name" . "_cstm<br>"; |
|
| 112 | + if(!$simulate){ |
|
| 113 | + $the_field = $mod->getFieldDefinition($field); |
|
| 114 | + $field = get_widget($the_field['type']); |
|
| 115 | + $field->set($the_field); |
|
| 116 | + $query = $field->get_db_add_alter_table($mod->table_name . '_cstm'); |
|
| 117 | + echo $query; |
|
| 118 | + if(!empty($query)){ |
|
| 119 | + $mod->db->query($query); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | - DynamicField::deleteCache(); |
|
| 128 | - echo '<br>Done<br>'; |
|
| 129 | - if($simulate){ |
|
| 130 | - echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>'; |
|
| 131 | - } |
|
| 127 | + DynamicField::deleteCache(); |
|
| 128 | + echo '<br>Done<br>'; |
|
| 129 | + if($simulate){ |
|
| 130 | + echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>'; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | |
@@ -137,4 +137,4 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | |
| 139 | 139 | |
| 140 | - ?> |
|
| 141 | 140 | \ No newline at end of file |
| 141 | + ?> |
|
| 142 | 142 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -41,45 +41,45 @@ discard block |
||
| 41 | 41 | require_once('modules/DynamicFields/FieldCases.php'); |
| 42 | 42 | require_once('modules/DynamicFields/DynamicField.php'); |
| 43 | 43 | global $db; |
| 44 | - if(!isset($db)){ |
|
| 44 | + if (!isset($db)) { |
|
| 45 | 45 | $db = DBManagerFactory::getInstance(); |
| 46 | 46 | } |
| 47 | - $result = $db->query( 'SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module'); |
|
| 47 | + $result = $db->query('SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module'); |
|
| 48 | 48 | $modules = array(); |
| 49 | 49 | /* |
| 50 | 50 | * get the real field_meta_data |
| 51 | 51 | */ |
| 52 | - while($row = $db->fetchByAssoc($result)){ |
|
| 52 | + while ($row = $db->fetchByAssoc($result)) { |
|
| 53 | 53 | $the_modules = $row['custom_module']; |
| 54 | - if(!isset($modules[$the_modules])){ |
|
| 54 | + if (!isset($modules[$the_modules])) { |
|
| 55 | 55 | $modules[$the_modules] = array(); |
| 56 | 56 | } |
| 57 | 57 | $modules[$the_modules][$row['name']] = $row['name']; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $simulate = false; |
| 61 | - if(!isset($_REQUEST['run'])){ |
|
| 61 | + if (!isset($_REQUEST['run'])) { |
|
| 62 | 62 | $simulate = true; |
| 63 | 63 | echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE"; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - foreach($modules as $the_module=>$fields){ |
|
| 67 | - if(isset($beanList[$the_module])) |
|
| 66 | + foreach ($modules as $the_module=>$fields) { |
|
| 67 | + if (isset($beanList[$the_module])) |
|
| 68 | 68 | { |
| 69 | 69 | $class_name = $beanList[$the_module]; |
| 70 | 70 | echo "<br><br>Scanning $the_module <br>"; |
| 71 | 71 | |
| 72 | 72 | require_once($beanFiles[$class_name]); |
| 73 | 73 | $mod = new $class_name(); |
| 74 | - if(!$db->tableExists($mod->table_name . "_cstm")){ |
|
| 74 | + if (!$db->tableExists($mod->table_name."_cstm")) { |
|
| 75 | 75 | $mod->custom_fields = new DynamicField(); |
| 76 | 76 | $mod->custom_fields->setup($mod); |
| 77 | 77 | $mod->custom_fields->createCustomTable(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $result = $db->query("DESCRIBE $mod->table_name" . "_cstm"); |
|
| 80 | + $result = $db->query("DESCRIBE $mod->table_name"."_cstm"); |
|
| 81 | 81 | |
| 82 | - while($row = $db->fetchByAssoc($result)){ |
|
| 82 | + while ($row = $db->fetchByAssoc($result)) { |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | $col = $row['Field']; |
@@ -88,16 +88,16 @@ discard block |
||
| 88 | 88 | $the_field = get_widget($fieldDef['type']); |
| 89 | 89 | $the_field->set($fieldDef); |
| 90 | 90 | |
| 91 | - if(!isset($fields[$col]) && $col != 'id_c'){ |
|
| 92 | - if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col"); |
|
| 91 | + if (!isset($fields[$col]) && $col != 'id_c') { |
|
| 92 | + if (!$simulate)$db->query("ALTER TABLE $mod->table_name"."_cstm DROP COLUMN $col"); |
|
| 93 | 93 | unset($fields[$col]); |
| 94 | - echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>"; |
|
| 95 | - } else{ |
|
| 96 | - if($col != 'id_c'){ |
|
| 97 | - if(trim($the_field->get_db_type()) != trim($type)){ |
|
| 94 | + echo "Dropping Column $col from $mod->table_name"."_cstm for module $the_module<br>"; |
|
| 95 | + } else { |
|
| 96 | + if ($col != 'id_c') { |
|
| 97 | + if (trim($the_field->get_db_type()) != trim($type)) { |
|
| 98 | 98 | |
| 99 | - echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>"; |
|
| 100 | - if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm')); |
|
| 99 | + echo "Fixing Column Type for $col changing $type to ".$the_field->get_db_type()."<br>"; |
|
| 100 | + if (!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name.'_cstm')); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - echo sizeof($fields) . " field(s) missing from $mod->table_name" . "_cstm<br>"; |
|
| 110 | - foreach($fields as $field){ |
|
| 111 | - echo "Adding Column $field to $mod->table_name" . "_cstm<br>"; |
|
| 112 | - if(!$simulate){ |
|
| 109 | + echo sizeof($fields)." field(s) missing from $mod->table_name"."_cstm<br>"; |
|
| 110 | + foreach ($fields as $field) { |
|
| 111 | + echo "Adding Column $field to $mod->table_name"."_cstm<br>"; |
|
| 112 | + if (!$simulate) { |
|
| 113 | 113 | $the_field = $mod->getFieldDefinition($field); |
| 114 | 114 | $field = get_widget($the_field['type']); |
| 115 | 115 | $field->set($the_field); |
| 116 | - $query = $field->get_db_add_alter_table($mod->table_name . '_cstm'); |
|
| 116 | + $query = $field->get_db_add_alter_table($mod->table_name.'_cstm'); |
|
| 117 | 117 | echo $query; |
| 118 | - if(!empty($query)){ |
|
| 118 | + if (!empty($query)) { |
|
| 119 | 119 | $mod->db->query($query); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | DynamicField::deleteCache(); |
| 128 | 128 | echo '<br>Done<br>'; |
| 129 | - if($simulate){ |
|
| 129 | + if ($simulate) { |
|
| 130 | 130 | echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>'; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -1,5 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -89,15 +91,19 @@ discard block |
||
| 89 | 91 | $the_field->set($fieldDef); |
| 90 | 92 | |
| 91 | 93 | if(!isset($fields[$col]) && $col != 'id_c'){ |
| 92 | - if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col"); |
|
| 94 | + if(!$simulate) { |
|
| 95 | + $db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col"); |
|
| 96 | + } |
|
| 93 | 97 | unset($fields[$col]); |
| 94 | 98 | echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>"; |
| 95 | - } else{ |
|
| 99 | + } else{ |
|
| 96 | 100 | if($col != 'id_c'){ |
| 97 | 101 | if(trim($the_field->get_db_type()) != trim($type)){ |
| 98 | 102 | |
| 99 | 103 | echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>"; |
| 100 | - if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm')); |
|
| 104 | + if(!$simulate) { |
|
| 105 | + $db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm')); |
|
| 106 | + } |
|
| 101 | 107 | } |
| 102 | 108 | } |
| 103 | 109 | |
@@ -46,39 +46,39 @@ |
||
| 46 | 46 | * Contributor(s): ______________________________________.. |
| 47 | 47 | ********************************************************************************/ |
| 48 | 48 | $fields_array['Relationship'] = array ('column_fields' => Array( |
| 49 | - 'id', |
|
| 50 | - 'relationship_name', |
|
| 51 | - 'lhs_module', |
|
| 52 | - 'lhs_table', |
|
| 53 | - 'lhs_key', |
|
| 54 | - 'rhs_module', |
|
| 55 | - 'rhs_table', |
|
| 56 | - 'rhs_key', |
|
| 57 | - 'join_table', |
|
| 58 | - 'join_key_lhs', |
|
| 59 | - 'join_key_rhs', |
|
| 60 | - 'relationship_type', |
|
| 61 | - 'relationship_role_column', |
|
| 62 | - 'relationship_role_column_value', |
|
| 63 | - 'reverse', |
|
| 64 | - ), |
|
| 49 | + 'id', |
|
| 50 | + 'relationship_name', |
|
| 51 | + 'lhs_module', |
|
| 52 | + 'lhs_table', |
|
| 53 | + 'lhs_key', |
|
| 54 | + 'rhs_module', |
|
| 55 | + 'rhs_table', |
|
| 56 | + 'rhs_key', |
|
| 57 | + 'join_table', |
|
| 58 | + 'join_key_lhs', |
|
| 59 | + 'join_key_rhs', |
|
| 60 | + 'relationship_type', |
|
| 61 | + 'relationship_role_column', |
|
| 62 | + 'relationship_role_column_value', |
|
| 63 | + 'reverse', |
|
| 64 | + ), |
|
| 65 | 65 | 'list_fields' => Array( |
| 66 | - 'id', |
|
| 67 | - 'relationship_name', |
|
| 68 | - 'lhs_module', |
|
| 69 | - 'lhs_table', |
|
| 70 | - 'lhs_key', |
|
| 71 | - 'rhs_module', |
|
| 72 | - 'rhs_table', |
|
| 73 | - 'rhs_key', |
|
| 74 | - 'join_table', |
|
| 75 | - 'join_key_lhs', |
|
| 76 | - 'join_key_rhs', |
|
| 77 | - 'relationship_type', |
|
| 78 | - 'relationship_role_column', |
|
| 79 | - 'relationship_role_column_value', |
|
| 80 | - 'reverse', |
|
| 81 | - ), |
|
| 66 | + 'id', |
|
| 67 | + 'relationship_name', |
|
| 68 | + 'lhs_module', |
|
| 69 | + 'lhs_table', |
|
| 70 | + 'lhs_key', |
|
| 71 | + 'rhs_module', |
|
| 72 | + 'rhs_table', |
|
| 73 | + 'rhs_key', |
|
| 74 | + 'join_table', |
|
| 75 | + 'join_key_lhs', |
|
| 76 | + 'join_key_rhs', |
|
| 77 | + 'relationship_type', |
|
| 78 | + 'relationship_role_column', |
|
| 79 | + 'relationship_role_column_value', |
|
| 80 | + 'reverse', |
|
| 81 | + ), |
|
| 82 | 82 | 'required_fields' => array("relationship_name"=>1), |
| 83 | 83 | ); |
| 84 | 84 | ?> |
| 85 | 85 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * All Rights Reserved. |
| 46 | 46 | * Contributor(s): ______________________________________.. |
| 47 | 47 | ********************************************************************************/ |
| 48 | -$fields_array['Relationship'] = array ('column_fields' => Array( |
|
| 48 | +$fields_array['Relationship'] = array('column_fields' => Array( |
|
| 49 | 49 | 'id', |
| 50 | 50 | 'relationship_name', |
| 51 | 51 | 'lhs_module', |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -48,30 +48,30 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | class RelationshipHandler extends Relationship { |
| 50 | 50 | |
| 51 | - var $db; //Database link by reference |
|
| 51 | + var $db; //Database link by reference |
|
| 52 | 52 | |
| 53 | - var $base_module; //name of module |
|
| 54 | - var $base_bean; //actual object |
|
| 55 | - var $base_vardef_field; //base's vardef field name of relationship with rel1 |
|
| 53 | + var $base_module; //name of module |
|
| 54 | + var $base_bean; //actual object |
|
| 55 | + var $base_vardef_field; //base's vardef field name of relationship with rel1 |
|
| 56 | 56 | |
| 57 | - var $rel1_module; //name of related module |
|
| 58 | - var $rel1_bean; //actual related object |
|
| 59 | - var $rel1_relationship_name; //Relationship name between base and rel1 |
|
| 60 | - var $rel1_vardef_field; //rel1's vardef field name of relationship with rel2 |
|
| 61 | - var $rel1_vardef_field_base; //rel1's vardef field name of relationship with base |
|
| 57 | + var $rel1_module; //name of related module |
|
| 58 | + var $rel1_bean; //actual related object |
|
| 59 | + var $rel1_relationship_name; //Relationship name between base and rel1 |
|
| 60 | + var $rel1_vardef_field; //rel1's vardef field name of relationship with rel2 |
|
| 61 | + var $rel1_vardef_field_base; //rel1's vardef field name of relationship with base |
|
| 62 | 62 | |
| 63 | - var $rel2_module; //name of related related module |
|
| 64 | - var $rel2_bean; //actual related related object |
|
| 65 | - var $rel2_relationship_name; //Relationship name between rel1 and rel2 |
|
| 66 | - var $rel2_vardef_field; //rel2's vardef field name of relationship with rel1 |
|
| 63 | + var $rel2_module; //name of related related module |
|
| 64 | + var $rel2_bean; //actual related related object |
|
| 65 | + var $rel2_relationship_name; //Relationship name between rel1 and rel2 |
|
| 66 | + var $rel2_vardef_field; //rel2's vardef field name of relationship with rel1 |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - var $base_array; //Info array |
|
| 70 | - var $rel1_array; //Info array |
|
| 71 | - var $rel2_array; //Info array |
|
| 69 | + var $base_array; //Info array |
|
| 70 | + var $rel1_array; //Info array |
|
| 71 | + var $rel2_array; //Info array |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - /* |
|
| 74 | + /* |
|
| 75 | 75 | |
| 76 | 76 | info arrays contain: |
| 77 | 77 | |
@@ -85,33 +85,33 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | ///////////////////////////Setup and populate functions////////////////////////////// |
| 87 | 87 | |
| 88 | - function RelationshipHandler(& $db, $base_module=""){ |
|
| 88 | + function RelationshipHandler(& $db, $base_module=""){ |
|
| 89 | 89 | |
| 90 | - $this->db = $db; |
|
| 91 | - $this->base_module = $base_module; |
|
| 90 | + $this->db = $db; |
|
| 91 | + $this->base_module = $base_module; |
|
| 92 | 92 | |
| 93 | - //end function RelationshipHandler |
|
| 94 | - } |
|
| 93 | + //end function RelationshipHandler |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){ |
|
| 96 | + function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){ |
|
| 97 | 97 | |
| 98 | - $this->base_vardef_field = $base_vardef_field; |
|
| 99 | - $this->rel1_vardef_field = $rel1_vardef_field; |
|
| 98 | + $this->base_vardef_field = $base_vardef_field; |
|
| 99 | + $this->rel1_vardef_field = $rel1_vardef_field; |
|
| 100 | 100 | |
| 101 | - //end function set_rel_vardef_fields |
|
| 102 | - } |
|
| 101 | + //end function set_rel_vardef_fields |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - function set_rel_relationship_names($build_rel2=false){ |
|
| 105 | + function set_rel_relationship_names($build_rel2=false){ |
|
| 106 | 106 | |
| 107 | - $this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship']; |
|
| 107 | + $this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship']; |
|
| 108 | 108 | |
| 109 | - if($build_rel2==true){ |
|
| 110 | - $this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship']; |
|
| 111 | - } |
|
| 109 | + if($build_rel2==true){ |
|
| 110 | + $this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship']; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - //end function set_rel_relationship_names |
|
| 114 | - } |
|
| 113 | + //end function set_rel_relationship_names |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | |
@@ -119,131 +119,131 @@ discard block |
||
| 119 | 119 | ///////////////////////////////END Setup and populate functions///////////////////// |
| 120 | 120 | |
| 121 | 121 | |
| 122 | - /* |
|
| 122 | + /* |
|
| 123 | 123 | set the build_rel2 to true if you want the rel2 info array as well |
| 124 | 124 | This function will build all the relationship info it can based on values set in the setup functions |
| 125 | 125 | When you use the info arrays (rel1_array) or (rel2_array), make sure you always check for empty values |
| 126 | 126 | */ |
| 127 | - function build_info($build_rel2=false){ |
|
| 128 | - if($this->base_bean == null){ |
|
| 129 | - $this->base_bean = get_module_info($this->base_module); |
|
| 130 | - } |
|
| 127 | + function build_info($build_rel2=false){ |
|
| 128 | + if($this->base_bean == null){ |
|
| 129 | + $this->base_bean = get_module_info($this->base_module); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - if(empty($this->rel1_bean)){ |
|
| 133 | - $this->build_rel1_info(); |
|
| 134 | - $this->rel1_module = $this->rel1_bean->module_dir; |
|
| 135 | - } |
|
| 132 | + if(empty($this->rel1_bean)){ |
|
| 133 | + $this->build_rel1_info(); |
|
| 134 | + $this->rel1_module = $this->rel1_bean->module_dir; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - if($build_rel2==true && $this->rel2_bean==""){ |
|
| 138 | - $this->build_rel2_info(); |
|
| 139 | - $this->rel2_module = $this->rel2_bean->module_dir; |
|
| 140 | - } |
|
| 137 | + if($build_rel2==true && $this->rel2_bean==""){ |
|
| 138 | + $this->build_rel2_info(); |
|
| 139 | + $this->rel2_module = $this->rel2_bean->module_dir; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - //translate the module titles to the proper language |
|
| 143 | - $this->build_module_labels($build_rel2); |
|
| 142 | + //translate the module titles to the proper language |
|
| 143 | + $this->build_module_labels($build_rel2); |
|
| 144 | 144 | |
| 145 | - //end function build_info |
|
| 146 | - } |
|
| 145 | + //end function build_info |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - function build_rel1_info(){ |
|
| 148 | + function build_rel1_info(){ |
|
| 149 | 149 | |
| 150 | - $this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field); |
|
| 150 | + $this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field); |
|
| 151 | 151 | |
| 152 | - //end function build_rel1_info |
|
| 153 | - } |
|
| 152 | + //end function build_rel1_info |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - function build_rel2_info(){ |
|
| 155 | + function build_rel2_info(){ |
|
| 156 | 156 | |
| 157 | - $this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field); |
|
| 157 | + $this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field); |
|
| 158 | 158 | |
| 159 | - //end function build_rel1_info |
|
| 160 | - } |
|
| 159 | + //end function build_rel1_info |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /* |
|
| 162 | + /* |
|
| 163 | 163 | Translates the module names to their singular and plural label and puts them in |
| 164 | 164 | the info arrays. Does it for base, rel1, and rel2 if specified |
| 165 | 165 | */ |
| 166 | 166 | |
| 167 | - function build_module_labels($build_rel2=false){ |
|
| 168 | - global $app_list_strings; |
|
| 169 | - |
|
| 170 | - ///Base Module Labels |
|
| 171 | - if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){ |
|
| 172 | - $this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir]; |
|
| 173 | - } else { |
|
| 174 | - $this->base_array['plabel'] = $this->base_bean->module_dir; |
|
| 175 | - } |
|
| 176 | - if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){ |
|
| 177 | - $this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir]; |
|
| 178 | - } else { |
|
| 179 | - $this->base_array['slabel'] = $this->base_bean->object_name; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - ///Rel1 Module Labels |
|
| 183 | - if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){ |
|
| 184 | - $this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir]; |
|
| 185 | - } else { |
|
| 186 | - $this->rel1_array['plabel'] = $this->rel1_bean->module_dir; |
|
| 187 | - } |
|
| 167 | + function build_module_labels($build_rel2=false){ |
|
| 168 | + global $app_list_strings; |
|
| 169 | + |
|
| 170 | + ///Base Module Labels |
|
| 171 | + if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){ |
|
| 172 | + $this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir]; |
|
| 173 | + } else { |
|
| 174 | + $this->base_array['plabel'] = $this->base_bean->module_dir; |
|
| 175 | + } |
|
| 176 | + if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){ |
|
| 177 | + $this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir]; |
|
| 178 | + } else { |
|
| 179 | + $this->base_array['slabel'] = $this->base_bean->object_name; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + ///Rel1 Module Labels |
|
| 183 | + if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){ |
|
| 184 | + $this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir]; |
|
| 185 | + } else { |
|
| 186 | + $this->rel1_array['plabel'] = $this->rel1_bean->module_dir; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){ |
|
| 190 | - $this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir]; |
|
| 191 | - } else { |
|
| 192 | - $this->rel1_array['slabel'] = $this->rel1_bean->object_name; |
|
| 193 | - } |
|
| 189 | + if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){ |
|
| 190 | + $this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir]; |
|
| 191 | + } else { |
|
| 192 | + $this->rel1_array['slabel'] = $this->rel1_bean->object_name; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | |
| 196 | - //Rel2 Module Labels |
|
| 197 | - if($build_rel2==true){ |
|
| 196 | + //Rel2 Module Labels |
|
| 197 | + if($build_rel2==true){ |
|
| 198 | 198 | |
| 199 | - if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){ |
|
| 200 | - $this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir]; |
|
| 201 | - } else { |
|
| 202 | - $this->rel2_array['plabel'] = $this->rel2_bean->module_dir; |
|
| 203 | - } |
|
| 204 | - if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){ |
|
| 205 | - $this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir]; |
|
| 206 | - } else { |
|
| 207 | - $this->rel2_array['slabel'] = $this->rel2_bean->module_dir; |
|
| 208 | - } |
|
| 209 | - //end if build_rel2 is true |
|
| 210 | - } |
|
| 199 | + if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){ |
|
| 200 | + $this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir]; |
|
| 201 | + } else { |
|
| 202 | + $this->rel2_array['plabel'] = $this->rel2_bean->module_dir; |
|
| 203 | + } |
|
| 204 | + if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){ |
|
| 205 | + $this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir]; |
|
| 206 | + } else { |
|
| 207 | + $this->rel2_array['slabel'] = $this->rel2_bean->module_dir; |
|
| 208 | + } |
|
| 209 | + //end if build_rel2 is true |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - //end function buld_module_lables |
|
| 213 | - } |
|
| 212 | + //end function buld_module_lables |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | 215 | |
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | |
| 219 | - function build_related_list($type="base"){ |
|
| 220 | - //type can be base, rel1 |
|
| 219 | + function build_related_list($type="base"){ |
|
| 220 | + //type can be base, rel1 |
|
| 221 | 221 | |
| 222 | - $target_list = ""; |
|
| 222 | + $target_list = ""; |
|
| 223 | 223 | |
| 224 | - if($type=="base"){ |
|
| 225 | - $target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name); |
|
| 226 | - //Possibility exists that this is a new relationship, so capture via relationship fields |
|
| 227 | - if(empty($target_list)){ |
|
| 228 | - $target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field); |
|
| 229 | - //end if the target list is empty |
|
| 230 | - } |
|
| 231 | - } |
|
| 224 | + if($type=="base"){ |
|
| 225 | + $target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name); |
|
| 226 | + //Possibility exists that this is a new relationship, so capture via relationship fields |
|
| 227 | + if(empty($target_list)){ |
|
| 228 | + $target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field); |
|
| 229 | + //end if the target list is empty |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - if($type=="rel1"){ |
|
| 234 | - $target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name); |
|
| 233 | + if($type=="rel1"){ |
|
| 234 | + $target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name); |
|
| 235 | 235 | |
| 236 | - //Possibility exists that this is a new relationship, so capture via relationship fields |
|
| 237 | - if(empty($target_list)){ |
|
| 238 | - $target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field); |
|
| 239 | - //end if the target list is empty |
|
| 240 | - } |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - return $target_list; |
|
| 236 | + //Possibility exists that this is a new relationship, so capture via relationship fields |
|
| 237 | + if(empty($target_list)){ |
|
| 238 | + $target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field); |
|
| 239 | + //end if the target list is empty |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + return $target_list; |
|
| 244 | 244 | |
| 245 | - //end function build_related_list |
|
| 246 | - } |
|
| 245 | + //end function build_related_list |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | |
@@ -252,92 +252,92 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | function get_relationship_information(& $target_bean, $get_upstream_rel_field_name = false){ |
| 254 | 254 | |
| 255 | - $target_module_name = $target_bean->module_dir; |
|
| 256 | - $current_module_name = $this->base_module; |
|
| 255 | + $target_module_name = $target_bean->module_dir; |
|
| 256 | + $current_module_name = $this->base_module; |
|
| 257 | 257 | |
| 258 | - //Look for downstream connection |
|
| 259 | - $rel_array = $this->retrieve_by_sides($current_module_name, $target_module_name, $this->db); |
|
| 258 | + //Look for downstream connection |
|
| 259 | + $rel_array = $this->retrieve_by_sides($current_module_name, $target_module_name, $this->db); |
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | - //Does a downstream relationship exist |
|
| 263 | - if($rel_array!=null){ |
|
| 264 | - if($rel_array['relationship_type']=="many-to-many"){ |
|
| 265 | - $target_bean->$rel_array['join_key_lhs'] = $this->base_bean->id; |
|
| 266 | - if($rel_array['relationship_role_column']!=""){ |
|
| 267 | - $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 268 | - } |
|
| 269 | - //end if many-to-many |
|
| 270 | - } |
|
| 262 | + //Does a downstream relationship exist |
|
| 263 | + if($rel_array!=null){ |
|
| 264 | + if($rel_array['relationship_type']=="many-to-many"){ |
|
| 265 | + $target_bean->$rel_array['join_key_lhs'] = $this->base_bean->id; |
|
| 266 | + if($rel_array['relationship_role_column']!=""){ |
|
| 267 | + $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 268 | + } |
|
| 269 | + //end if many-to-many |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - if($rel_array['relationship_type']=="one-to-many"){ |
|
| 273 | - $target_bean->$rel_array['rhs_key'] = $this->base_bean->id; |
|
| 274 | - if($rel_array['relationship_role_column']!=""){ |
|
| 275 | - $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 276 | - } |
|
| 277 | - //end if one-to-many |
|
| 278 | - } |
|
| 272 | + if($rel_array['relationship_type']=="one-to-many"){ |
|
| 273 | + $target_bean->$rel_array['rhs_key'] = $this->base_bean->id; |
|
| 274 | + if($rel_array['relationship_role_column']!=""){ |
|
| 275 | + $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 276 | + } |
|
| 277 | + //end if one-to-many |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | - return; |
|
| 281 | - //end if downstream relationship exists |
|
| 282 | - } |
|
| 280 | + return; |
|
| 281 | + //end if downstream relationship exists |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | |
| 285 | 285 | |
| 286 | - //Look for upstream connection |
|
| 287 | - $rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db); |
|
| 286 | + //Look for upstream connection |
|
| 287 | + $rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db); |
|
| 288 | 288 | |
| 289 | - //Does an upstream relationship exist |
|
| 290 | - if($rel_array!=null){ |
|
| 291 | - if($rel_array['relationship_type']=="many-to-many"){ |
|
| 292 | - $target_bean->$rel_array['join_key_rhs'] = $this->base_bean->id; |
|
| 293 | - if($rel_array['relationship_role_column']!=""){ |
|
| 294 | - $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 295 | - } |
|
| 296 | - //end if many-to-many |
|
| 297 | - } |
|
| 289 | + //Does an upstream relationship exist |
|
| 290 | + if($rel_array!=null){ |
|
| 291 | + if($rel_array['relationship_type']=="many-to-many"){ |
|
| 292 | + $target_bean->$rel_array['join_key_rhs'] = $this->base_bean->id; |
|
| 293 | + if($rel_array['relationship_role_column']!=""){ |
|
| 294 | + $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 295 | + } |
|
| 296 | + //end if many-to-many |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - if($rel_array['relationship_type']=="one-to-many"){ |
|
| 300 | - $this->$rel_array['rhs_key'] = $this->base_bean->id; |
|
| 301 | - if($rel_array['relationship_role_column']!=""){ |
|
| 302 | - $this->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 303 | - } |
|
| 304 | - //end if one-to-many |
|
| 305 | - } |
|
| 299 | + if($rel_array['relationship_type']=="one-to-many"){ |
|
| 300 | + $this->$rel_array['rhs_key'] = $this->base_bean->id; |
|
| 301 | + if($rel_array['relationship_role_column']!=""){ |
|
| 302 | + $this->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
|
| 303 | + } |
|
| 304 | + //end if one-to-many |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | |
| 308 | - ///Fill additional id field if necessary |
|
| 309 | - if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){ |
|
| 310 | - $target_bean->$id_name = $this->base_bean->id; |
|
| 308 | + ///Fill additional id field if necessary |
|
| 309 | + if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){ |
|
| 310 | + $target_bean->$id_name = $this->base_bean->id; |
|
| 311 | 311 | if($get_upstream_rel_field_name) { |
| 312 | 312 | $target_bean->new_rel_relname = $id_name; |
| 313 | 313 | $target_bean->new_rel_id = $this->base_bean->id; |
| 314 | 314 | } |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - //end if an upstream relationship exists |
|
| 318 | - } |
|
| 317 | + //end if an upstream relationship exists |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | //end function get_relationship_information |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | function traverse_rel_meta($base_module, & $target_bean, $target_rel_name){ |
| 324 | - $id_name = null; |
|
| 324 | + $id_name = null; |
|
| 325 | 325 | |
| 326 | - //returns name of variable to store id in |
|
| 327 | - //if none exists, then returns null |
|
| 328 | - foreach($target_bean->field_defs as $field_array){ |
|
| 326 | + //returns name of variable to store id in |
|
| 327 | + //if none exists, then returns null |
|
| 328 | + foreach($target_bean->field_defs as $field_array){ |
|
| 329 | 329 | |
| 330 | - if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){ |
|
| 330 | + if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){ |
|
| 331 | 331 | |
| 332 | - $id_name = $this->get_id_name($target_bean, $field_array['name']); |
|
| 333 | - return $id_name; |
|
| 334 | - //end if rel name match |
|
| 335 | - } |
|
| 332 | + $id_name = $this->get_id_name($target_bean, $field_array['name']); |
|
| 333 | + return $id_name; |
|
| 334 | + //end if rel name match |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - //end foreach field def |
|
| 338 | - } |
|
| 337 | + //end foreach field def |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - return null; |
|
| 340 | + return null; |
|
| 341 | 341 | |
| 342 | 342 | //end function traverse_rel_meta |
| 343 | 343 | } |
@@ -345,17 +345,17 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | function get_id_name(& $target_bean, $field_name){ |
| 347 | 347 | |
| 348 | - foreach($target_bean->relationship_fields as $target_id => $rel_name){ |
|
| 348 | + foreach($target_bean->relationship_fields as $target_id => $rel_name){ |
|
| 349 | 349 | |
| 350 | - if($rel_name == $field_name){ |
|
| 351 | - //relationship id found |
|
| 352 | - return $target_id; |
|
| 353 | - //end if match |
|
| 354 | - } |
|
| 355 | - //end foreach |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - return null; |
|
| 350 | + if($rel_name == $field_name){ |
|
| 351 | + //relationship id found |
|
| 352 | + return $target_id; |
|
| 353 | + //end if match |
|
| 354 | + } |
|
| 355 | + //end foreach |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + return null; |
|
| 359 | 359 | //end function get_id_name |
| 360 | 360 | } |
| 361 | 361 | |
@@ -364,27 +364,27 @@ discard block |
||
| 364 | 364 | |
| 365 | 365 | function process_by_rel_bean($rel1_module){ |
| 366 | 366 | |
| 367 | - $this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db); |
|
| 368 | - $this->rel1_module = $rel1_module; |
|
| 369 | - $this->rel1_bean = get_module_info($this->rel1_module); |
|
| 367 | + $this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db); |
|
| 368 | + $this->rel1_module = $rel1_module; |
|
| 369 | + $this->rel1_bean = get_module_info($this->rel1_module); |
|
| 370 | 370 | |
| 371 | 371 | //end function process_by_rel_bean |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | |
| 375 | 375 | function get_rel1_vardef_field_base($field_defs){ |
| 376 | - foreach($field_defs as $field_array){ |
|
| 376 | + foreach($field_defs as $field_array){ |
|
| 377 | 377 | |
| 378 | - if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){ |
|
| 378 | + if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){ |
|
| 379 | 379 | |
| 380 | - $this->rel1_vardef_field_base = $field_array['name']; |
|
| 381 | - //end if rel name match |
|
| 382 | - } |
|
| 380 | + $this->rel1_vardef_field_base = $field_array['name']; |
|
| 381 | + //end if rel name match |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - //end foreach field def |
|
| 385 | - } |
|
| 384 | + //end foreach field def |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - return null; |
|
| 387 | + return null; |
|
| 388 | 388 | |
| 389 | 389 | |
| 390 | 390 | //end get_rel1_vardef_field_base |
@@ -393,15 +393,15 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | function get_farthest_reach(){ |
| 395 | 395 | |
| 396 | - if($this->rel1_vardef_field!=""){ |
|
| 397 | - //the farthest reach is rel2 |
|
| 398 | - $this->build_info(true); |
|
| 399 | - return $this->rel2_bean; |
|
| 400 | - } |
|
| 396 | + if($this->rel1_vardef_field!=""){ |
|
| 397 | + //the farthest reach is rel2 |
|
| 398 | + $this->build_info(true); |
|
| 399 | + return $this->rel2_bean; |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - //the farthest reach is rel1 |
|
| 403 | - $this->build_info(false); |
|
| 404 | - return $this->rel1_bean; |
|
| 402 | + //the farthest reach is rel1 |
|
| 403 | + $this->build_info(false); |
|
| 404 | + return $this->rel1_bean; |
|
| 405 | 405 | |
| 406 | 406 | //end function get_farthest_reach |
| 407 | 407 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -48,27 +48,27 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | class RelationshipHandler extends Relationship { |
| 50 | 50 | |
| 51 | - var $db; //Database link by reference |
|
| 51 | + var $db; //Database link by reference |
|
| 52 | 52 | |
| 53 | - var $base_module; //name of module |
|
| 54 | - var $base_bean; //actual object |
|
| 55 | - var $base_vardef_field; //base's vardef field name of relationship with rel1 |
|
| 53 | + var $base_module; //name of module |
|
| 54 | + var $base_bean; //actual object |
|
| 55 | + var $base_vardef_field; //base's vardef field name of relationship with rel1 |
|
| 56 | 56 | |
| 57 | - var $rel1_module; //name of related module |
|
| 58 | - var $rel1_bean; //actual related object |
|
| 59 | - var $rel1_relationship_name; //Relationship name between base and rel1 |
|
| 60 | - var $rel1_vardef_field; //rel1's vardef field name of relationship with rel2 |
|
| 61 | - var $rel1_vardef_field_base; //rel1's vardef field name of relationship with base |
|
| 57 | + var $rel1_module; //name of related module |
|
| 58 | + var $rel1_bean; //actual related object |
|
| 59 | + var $rel1_relationship_name; //Relationship name between base and rel1 |
|
| 60 | + var $rel1_vardef_field; //rel1's vardef field name of relationship with rel2 |
|
| 61 | + var $rel1_vardef_field_base; //rel1's vardef field name of relationship with base |
|
| 62 | 62 | |
| 63 | - var $rel2_module; //name of related related module |
|
| 64 | - var $rel2_bean; //actual related related object |
|
| 65 | - var $rel2_relationship_name; //Relationship name between rel1 and rel2 |
|
| 66 | - var $rel2_vardef_field; //rel2's vardef field name of relationship with rel1 |
|
| 63 | + var $rel2_module; //name of related related module |
|
| 64 | + var $rel2_bean; //actual related related object |
|
| 65 | + var $rel2_relationship_name; //Relationship name between rel1 and rel2 |
|
| 66 | + var $rel2_vardef_field; //rel2's vardef field name of relationship with rel1 |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - var $base_array; //Info array |
|
| 70 | - var $rel1_array; //Info array |
|
| 71 | - var $rel2_array; //Info array |
|
| 69 | + var $base_array; //Info array |
|
| 70 | + var $rel1_array; //Info array |
|
| 71 | + var $rel2_array; //Info array |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | /* |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | ///////////////////////////Setup and populate functions////////////////////////////// |
| 87 | 87 | |
| 88 | - function RelationshipHandler(& $db, $base_module=""){ |
|
| 88 | + function RelationshipHandler(& $db, $base_module = "") { |
|
| 89 | 89 | |
| 90 | 90 | $this->db = $db; |
| 91 | 91 | $this->base_module = $base_module; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | //end function RelationshipHandler |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field=""){ |
|
| 96 | + function set_rel_vardef_fields($base_vardef_field, $rel1_vardef_field = "") { |
|
| 97 | 97 | |
| 98 | 98 | $this->base_vardef_field = $base_vardef_field; |
| 99 | 99 | $this->rel1_vardef_field = $rel1_vardef_field; |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | - function set_rel_relationship_names($build_rel2=false){ |
|
| 105 | + function set_rel_relationship_names($build_rel2 = false) { |
|
| 106 | 106 | |
| 107 | 107 | $this->rel1_relationship_name = $this->base_bean->field_defs[$this->base_vardef_field]['relationship']; |
| 108 | 108 | |
| 109 | - if($build_rel2==true){ |
|
| 109 | + if ($build_rel2 == true) { |
|
| 110 | 110 | $this->rel2_relationship_name = $this->rel1_bean->field_defs[$this->rel1_vardef_field]['relationship']; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | This function will build all the relationship info it can based on values set in the setup functions |
| 125 | 125 | When you use the info arrays (rel1_array) or (rel2_array), make sure you always check for empty values |
| 126 | 126 | */ |
| 127 | - function build_info($build_rel2=false){ |
|
| 128 | - if($this->base_bean == null){ |
|
| 127 | + function build_info($build_rel2 = false) { |
|
| 128 | + if ($this->base_bean == null) { |
|
| 129 | 129 | $this->base_bean = get_module_info($this->base_module); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if(empty($this->rel1_bean)){ |
|
| 132 | + if (empty($this->rel1_bean)) { |
|
| 133 | 133 | $this->build_rel1_info(); |
| 134 | 134 | $this->rel1_module = $this->rel1_bean->module_dir; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if($build_rel2==true && $this->rel2_bean==""){ |
|
| 137 | + if ($build_rel2 == true && $this->rel2_bean == "") { |
|
| 138 | 138 | $this->build_rel2_info(); |
| 139 | 139 | $this->rel2_module = $this->rel2_bean->module_dir; |
| 140 | 140 | } |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | //end function build_info |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - function build_rel1_info(){ |
|
| 148 | + function build_rel1_info() { |
|
| 149 | 149 | |
| 150 | 150 | $this->rel1_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field); |
| 151 | 151 | |
| 152 | 152 | //end function build_rel1_info |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - function build_rel2_info(){ |
|
| 155 | + function build_rel2_info() { |
|
| 156 | 156 | |
| 157 | 157 | $this->rel2_bean = $this->trace_relationship_module($this->base_module, $this->base_vardef_field, $this->rel1_vardef_field); |
| 158 | 158 | |
@@ -164,29 +164,29 @@ discard block |
||
| 164 | 164 | the info arrays. Does it for base, rel1, and rel2 if specified |
| 165 | 165 | */ |
| 166 | 166 | |
| 167 | - function build_module_labels($build_rel2=false){ |
|
| 167 | + function build_module_labels($build_rel2 = false) { |
|
| 168 | 168 | global $app_list_strings; |
| 169 | 169 | |
| 170 | 170 | ///Base Module Labels |
| 171 | - if(!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])){ |
|
| 171 | + if (!empty($app_list_strings['moduleList'][$this->base_bean->module_dir])) { |
|
| 172 | 172 | $this->base_array['plabel'] = $app_list_strings['moduleList'][$this->base_bean->module_dir]; |
| 173 | 173 | } else { |
| 174 | 174 | $this->base_array['plabel'] = $this->base_bean->module_dir; |
| 175 | 175 | } |
| 176 | - if(!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])){ |
|
| 176 | + if (!empty($app_list_strings['moduleListSingular'][$this->base_bean->module_dir])) { |
|
| 177 | 177 | $this->base_array['slabel'] = $app_list_strings['moduleListSingular'][$this->base_bean->module_dir]; |
| 178 | 178 | } else { |
| 179 | 179 | $this->base_array['slabel'] = $this->base_bean->object_name; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | ///Rel1 Module Labels |
| 183 | - if(!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])){ |
|
| 183 | + if (!empty($app_list_strings['moduleList'][$this->rel1_bean->module_dir])) { |
|
| 184 | 184 | $this->rel1_array['plabel'] = $app_list_strings['moduleList'][$this->rel1_bean->module_dir]; |
| 185 | 185 | } else { |
| 186 | 186 | $this->rel1_array['plabel'] = $this->rel1_bean->module_dir; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if(!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])){ |
|
| 189 | + if (!empty($app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir])) { |
|
| 190 | 190 | $this->rel1_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel1_bean->module_dir]; |
| 191 | 191 | } else { |
| 192 | 192 | $this->rel1_array['slabel'] = $this->rel1_bean->object_name; |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | |
| 196 | 196 | //Rel2 Module Labels |
| 197 | - if($build_rel2==true){ |
|
| 197 | + if ($build_rel2 == true) { |
|
| 198 | 198 | |
| 199 | - if(!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])){ |
|
| 199 | + if (!empty($app_list_strings['moduleList'][$this->rel2_bean->module_dir])) { |
|
| 200 | 200 | $this->rel2_array['plabel'] = $app_list_strings['moduleList'][$this->rel2_bean->module_dir]; |
| 201 | 201 | } else { |
| 202 | 202 | $this->rel2_array['plabel'] = $this->rel2_bean->module_dir; |
| 203 | 203 | } |
| 204 | - if(!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])){ |
|
| 204 | + if (!empty($app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir])) { |
|
| 205 | 205 | $this->rel2_array['slabel'] = $app_list_strings['moduleListSingular'][$this->rel2_bean->module_dir]; |
| 206 | 206 | } else { |
| 207 | 207 | $this->rel2_array['slabel'] = $this->rel2_bean->module_dir; |
@@ -216,25 +216,25 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | |
| 219 | - function build_related_list($type="base"){ |
|
| 219 | + function build_related_list($type = "base") { |
|
| 220 | 220 | //type can be base, rel1 |
| 221 | 221 | |
| 222 | 222 | $target_list = ""; |
| 223 | 223 | |
| 224 | - if($type=="base"){ |
|
| 224 | + if ($type == "base") { |
|
| 225 | 225 | $target_list = $this->base_bean->get_linked_beans($this->base_vardef_field, $this->rel1_bean->object_name); |
| 226 | 226 | //Possibility exists that this is a new relationship, so capture via relationship fields |
| 227 | - if(empty($target_list)){ |
|
| 227 | + if (empty($target_list)) { |
|
| 228 | 228 | $target_list = search_filter_rel_info($this->base_bean, $this->rel1_bean->module_dir, $this->base_vardef_field); |
| 229 | 229 | //end if the target list is empty |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if($type=="rel1"){ |
|
| 233 | + if ($type == "rel1") { |
|
| 234 | 234 | $target_list = $this->rel1_bean->get_linked_beans($this->rel1_vardef_field, $this->rel2_bean->object_name); |
| 235 | 235 | |
| 236 | 236 | //Possibility exists that this is a new relationship, so capture via relationship fields |
| 237 | - if(empty($target_list)){ |
|
| 237 | + if (empty($target_list)) { |
|
| 238 | 238 | $target_list = search_filter_rel_info($this->rel1_bean, $this->rel2_bean->module_dir, $this->rel1_vardef_field); |
| 239 | 239 | //end if the target list is empty |
| 240 | 240 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | ///////BEGIN Functions to find relationships///////////////////////////////// |
| 252 | 252 | |
| 253 | -function get_relationship_information(& $target_bean, $get_upstream_rel_field_name = false){ |
|
| 253 | +function get_relationship_information(& $target_bean, $get_upstream_rel_field_name = false) { |
|
| 254 | 254 | |
| 255 | 255 | $target_module_name = $target_bean->module_dir; |
| 256 | 256 | $current_module_name = $this->base_module; |
@@ -260,18 +260,18 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | //Does a downstream relationship exist |
| 263 | - if($rel_array!=null){ |
|
| 264 | - if($rel_array['relationship_type']=="many-to-many"){ |
|
| 263 | + if ($rel_array != null) { |
|
| 264 | + if ($rel_array['relationship_type'] == "many-to-many") { |
|
| 265 | 265 | $target_bean->$rel_array['join_key_lhs'] = $this->base_bean->id; |
| 266 | - if($rel_array['relationship_role_column']!=""){ |
|
| 266 | + if ($rel_array['relationship_role_column'] != "") { |
|
| 267 | 267 | $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
| 268 | 268 | } |
| 269 | 269 | //end if many-to-many |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if($rel_array['relationship_type']=="one-to-many"){ |
|
| 272 | + if ($rel_array['relationship_type'] == "one-to-many") { |
|
| 273 | 273 | $target_bean->$rel_array['rhs_key'] = $this->base_bean->id; |
| 274 | - if($rel_array['relationship_role_column']!=""){ |
|
| 274 | + if ($rel_array['relationship_role_column'] != "") { |
|
| 275 | 275 | $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
| 276 | 276 | } |
| 277 | 277 | //end if one-to-many |
@@ -287,18 +287,18 @@ discard block |
||
| 287 | 287 | $rel_array = $this->retrieve_by_sides($target_module_name, $current_module_name, $this->db); |
| 288 | 288 | |
| 289 | 289 | //Does an upstream relationship exist |
| 290 | - if($rel_array!=null){ |
|
| 291 | - if($rel_array['relationship_type']=="many-to-many"){ |
|
| 290 | + if ($rel_array != null) { |
|
| 291 | + if ($rel_array['relationship_type'] == "many-to-many") { |
|
| 292 | 292 | $target_bean->$rel_array['join_key_rhs'] = $this->base_bean->id; |
| 293 | - if($rel_array['relationship_role_column']!=""){ |
|
| 293 | + if ($rel_array['relationship_role_column'] != "") { |
|
| 294 | 294 | $target_bean->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
| 295 | 295 | } |
| 296 | 296 | //end if many-to-many |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if($rel_array['relationship_type']=="one-to-many"){ |
|
| 299 | + if ($rel_array['relationship_type'] == "one-to-many") { |
|
| 300 | 300 | $this->$rel_array['rhs_key'] = $this->base_bean->id; |
| 301 | - if($rel_array['relationship_role_column']!=""){ |
|
| 301 | + if ($rel_array['relationship_role_column'] != "") { |
|
| 302 | 302 | $this->$rel_array['relationship_role_column'] = $rel_array['relationship_role_column_value']; |
| 303 | 303 | } |
| 304 | 304 | //end if one-to-many |
@@ -306,9 +306,9 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | |
| 308 | 308 | ///Fill additional id field if necessary |
| 309 | - if(($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null){ |
|
| 309 | + if (($id_name = $this->traverse_rel_meta($current_module_name, $target_bean, $rel_array['relationship_name'])) != null) { |
|
| 310 | 310 | $target_bean->$id_name = $this->base_bean->id; |
| 311 | - if($get_upstream_rel_field_name) { |
|
| 311 | + if ($get_upstream_rel_field_name) { |
|
| 312 | 312 | $target_bean->new_rel_relname = $id_name; |
| 313 | 313 | $target_bean->new_rel_id = $this->base_bean->id; |
| 314 | 314 | } |
@@ -320,14 +320,14 @@ discard block |
||
| 320 | 320 | //end function get_relationship_information |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | -function traverse_rel_meta($base_module, & $target_bean, $target_rel_name){ |
|
| 323 | +function traverse_rel_meta($base_module, & $target_bean, $target_rel_name) { |
|
| 324 | 324 | $id_name = null; |
| 325 | 325 | |
| 326 | 326 | //returns name of variable to store id in |
| 327 | 327 | //if none exists, then returns null |
| 328 | - foreach($target_bean->field_defs as $field_array){ |
|
| 328 | + foreach ($target_bean->field_defs as $field_array) { |
|
| 329 | 329 | |
| 330 | - if(!empty($field_array['relationship']) && $field_array['relationship']==$target_rel_name){ |
|
| 330 | + if (!empty($field_array['relationship']) && $field_array['relationship'] == $target_rel_name) { |
|
| 331 | 331 | |
| 332 | 332 | $id_name = $this->get_id_name($target_bean, $field_array['name']); |
| 333 | 333 | return $id_name; |
@@ -343,11 +343,11 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | |
| 346 | -function get_id_name(& $target_bean, $field_name){ |
|
| 346 | +function get_id_name(& $target_bean, $field_name) { |
|
| 347 | 347 | |
| 348 | - foreach($target_bean->relationship_fields as $target_id => $rel_name){ |
|
| 348 | + foreach ($target_bean->relationship_fields as $target_id => $rel_name) { |
|
| 349 | 349 | |
| 350 | - if($rel_name == $field_name){ |
|
| 350 | + if ($rel_name == $field_name) { |
|
| 351 | 351 | //relationship id found |
| 352 | 352 | return $target_id; |
| 353 | 353 | //end if match |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | ///////////////////////////END functions to find relationships ////////////////////// |
| 363 | 363 | |
| 364 | 364 | |
| 365 | -function process_by_rel_bean($rel1_module){ |
|
| 365 | +function process_by_rel_bean($rel1_module) { |
|
| 366 | 366 | |
| 367 | 367 | $this->rel1_relationship_name = $this::retrieve_by_modules($this->base_module, $rel1_module, $this->db); |
| 368 | 368 | $this->rel1_module = $rel1_module; |
@@ -372,10 +372,10 @@ discard block |
||
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | |
| 375 | -function get_rel1_vardef_field_base($field_defs){ |
|
| 376 | - foreach($field_defs as $field_array){ |
|
| 375 | +function get_rel1_vardef_field_base($field_defs) { |
|
| 376 | + foreach ($field_defs as $field_array) { |
|
| 377 | 377 | |
| 378 | - if(!empty($field_array['relationship']) && $field_array['relationship']==$this->rel1_relationship_name){ |
|
| 378 | + if (!empty($field_array['relationship']) && $field_array['relationship'] == $this->rel1_relationship_name) { |
|
| 379 | 379 | |
| 380 | 380 | $this->rel1_vardef_field_base = $field_array['name']; |
| 381 | 381 | //end if rel name match |
@@ -391,9 +391,9 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | |
| 394 | -function get_farthest_reach(){ |
|
| 394 | +function get_farthest_reach() { |
|
| 395 | 395 | |
| 396 | - if($this->rel1_vardef_field!=""){ |
|
| 396 | + if ($this->rel1_vardef_field != "") { |
|
| 397 | 397 | //the farthest reach is rel2 |
| 398 | 398 | $this->build_info(true); |
| 399 | 399 | return $this->rel2_bean; |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -320,6 +320,9 @@ |
||
| 320 | 320 | //end function get_relationship_information |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | +/** |
|
| 324 | + * @param string $base_module |
|
| 325 | + */ |
|
| 323 | 326 | function traverse_rel_meta($base_module, & $target_bean, $target_rel_name){ |
| 324 | 327 | $id_name = null; |
| 325 | 328 | |
@@ -49,115 +49,115 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | class Relationship extends SugarBean { |
| 51 | 51 | |
| 52 | - var $object_name='Relationship'; |
|
| 53 | - var $module_dir = 'Relationships'; |
|
| 54 | - var $new_schema = true; |
|
| 55 | - var $table_name = 'relationships'; |
|
| 56 | - |
|
| 57 | - var $id; |
|
| 58 | - var $relationship_name; |
|
| 59 | - var $lhs_module; |
|
| 60 | - var $lhs_table; |
|
| 61 | - var $lhs_key; |
|
| 62 | - var $rhs_module; |
|
| 63 | - var $rhs_table; |
|
| 64 | - var $rhs_key; |
|
| 65 | - var $join_table; |
|
| 66 | - var $join_key_lhs; |
|
| 67 | - var $join_key_rhs; |
|
| 68 | - var $relationship_type; |
|
| 69 | - var $relationship_role_column; |
|
| 70 | - var $relationship_role_column_value; |
|
| 71 | - var $reverse; |
|
| 72 | - |
|
| 73 | - var $_self_referencing; |
|
| 74 | - |
|
| 75 | - function Relationship() { |
|
| 76 | - parent::SugarBean(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /*returns true if the relationship is self referencing. equality check is performed for both table and |
|
| 52 | + var $object_name='Relationship'; |
|
| 53 | + var $module_dir = 'Relationships'; |
|
| 54 | + var $new_schema = true; |
|
| 55 | + var $table_name = 'relationships'; |
|
| 56 | + |
|
| 57 | + var $id; |
|
| 58 | + var $relationship_name; |
|
| 59 | + var $lhs_module; |
|
| 60 | + var $lhs_table; |
|
| 61 | + var $lhs_key; |
|
| 62 | + var $rhs_module; |
|
| 63 | + var $rhs_table; |
|
| 64 | + var $rhs_key; |
|
| 65 | + var $join_table; |
|
| 66 | + var $join_key_lhs; |
|
| 67 | + var $join_key_rhs; |
|
| 68 | + var $relationship_type; |
|
| 69 | + var $relationship_role_column; |
|
| 70 | + var $relationship_role_column_value; |
|
| 71 | + var $reverse; |
|
| 72 | + |
|
| 73 | + var $_self_referencing; |
|
| 74 | + |
|
| 75 | + function Relationship() { |
|
| 76 | + parent::SugarBean(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /*returns true if the relationship is self referencing. equality check is performed for both table and |
|
| 80 | 80 | * key names. |
| 81 | 81 | */ |
| 82 | - function is_self_referencing() { |
|
| 83 | - if (empty($this->_self_referencing)) { |
|
| 84 | - $this->_self_referencing=false; |
|
| 82 | + function is_self_referencing() { |
|
| 83 | + if (empty($this->_self_referencing)) { |
|
| 84 | + $this->_self_referencing=false; |
|
| 85 | 85 | |
| 86 | - //is it self referencing, both table and key name from lhs and rhs should be equal. |
|
| 87 | - if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) { |
|
| 88 | - $this->_self_referencing=true; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - return $this->_self_referencing; |
|
| 92 | - } |
|
| 86 | + //is it self referencing, both table and key name from lhs and rhs should be equal. |
|
| 87 | + if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) { |
|
| 88 | + $this->_self_referencing=true; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + return $this->_self_referencing; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /*returns true if a relationship with provided name exists*/ |
|
| 95 | - static function exists($relationship_name,&$db) { |
|
| 96 | - $query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
| 97 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 98 | - $row = $db->fetchByAssoc($result); |
|
| 99 | - if ($row != null) { |
|
| 100 | - return true; |
|
| 101 | - } |
|
| 94 | + /*returns true if a relationship with provided name exists*/ |
|
| 95 | + static function exists($relationship_name,&$db) { |
|
| 96 | + $query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
| 97 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
| 98 | + $row = $db->fetchByAssoc($result); |
|
| 99 | + if ($row != null) { |
|
| 100 | + return true; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - return false; |
|
| 104 | - } |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - static function delete($relationship_name,&$db) { |
|
| 106 | + static function delete($relationship_name,&$db) { |
|
| 107 | 107 | |
| 108 | - $query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
| 109 | - $result = $db->query($query,true," Error updating relationships table for ".$relationship_name); |
|
| 108 | + $query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
| 109 | + $result = $db->query($query,true," Error updating relationships table for ".$relationship_name); |
|
| 110 | 110 | |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | |
| 114 | - function get_other_module($relationship_name, $base_module, &$db){ |
|
| 115 | - //give it the relationship_name and base module |
|
| 116 | - //it will return the module name on the other side of the relationship |
|
| 114 | + function get_other_module($relationship_name, $base_module, &$db){ |
|
| 115 | + //give it the relationship_name and base module |
|
| 116 | + //it will return the module name on the other side of the relationship |
|
| 117 | 117 | |
| 118 | - $query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
| 119 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 120 | - $row = $db->fetchByAssoc($result); |
|
| 121 | - if ($row != null) { |
|
| 118 | + $query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
|
| 119 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
| 120 | + $row = $db->fetchByAssoc($result); |
|
| 121 | + if ($row != null) { |
|
| 122 | 122 | |
| 123 | - if($row['rhs_module']==$base_module){ |
|
| 124 | - return $row['lhs_module']; |
|
| 125 | - } |
|
| 126 | - if($row['lhs_module']==$base_module){ |
|
| 127 | - return $row['rhs_module']; |
|
| 128 | - } |
|
| 129 | - } |
|
| 123 | + if($row['rhs_module']==$base_module){ |
|
| 124 | + return $row['lhs_module']; |
|
| 125 | + } |
|
| 126 | + if($row['lhs_module']==$base_module){ |
|
| 127 | + return $row['rhs_module']; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - return false; |
|
| 131 | + return false; |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | - //end function get_other_module |
|
| 135 | - } |
|
| 134 | + //end function get_other_module |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - function retrieve_by_sides($lhs_module, $rhs_module, &$db){ |
|
| 138 | - //give it the relationship_name and base module |
|
| 139 | - //it will return the module name on the other side of the relationship |
|
| 137 | + function retrieve_by_sides($lhs_module, $rhs_module, &$db){ |
|
| 138 | + //give it the relationship_name and base module |
|
| 139 | + //it will return the module name on the other side of the relationship |
|
| 140 | 140 | |
| 141 | - $query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'"; |
|
| 142 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 143 | - $row = $db->fetchByAssoc($result); |
|
| 144 | - if ($row != null) { |
|
| 141 | + $query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'"; |
|
| 142 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
| 143 | + $row = $db->fetchByAssoc($result); |
|
| 144 | + if ($row != null) { |
|
| 145 | 145 | |
| 146 | - return $row; |
|
| 146 | + return $row; |
|
| 147 | 147 | |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - return null; |
|
| 150 | + return null; |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | - //end function retrieve_by_sides |
|
| 154 | - } |
|
| 153 | + //end function retrieve_by_sides |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){ |
|
| 157 | - //give it the relationship_name and base module |
|
| 158 | - //it will return the module name on the other side of the relationship |
|
| 156 | + static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){ |
|
| 157 | + //give it the relationship_name and base module |
|
| 158 | + //it will return the module name on the other side of the relationship |
|
| 159 | 159 | |
| 160 | - $query = " SELECT * FROM relationships |
|
| 160 | + $query = " SELECT * FROM relationships |
|
| 161 | 161 | WHERE deleted=0 |
| 162 | 162 | AND ( |
| 163 | 163 | (lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."') |
@@ -165,113 +165,113 @@ discard block |
||
| 165 | 165 | (lhs_module = '".$rhs_module."' AND rhs_module = '".$lhs_module."') |
| 166 | 166 | ) |
| 167 | 167 | "; |
| 168 | - if(!empty($type)){ |
|
| 169 | - $query .= " AND relationship_type='$type'"; |
|
| 170 | - } |
|
| 171 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 172 | - $row = $db->fetchByAssoc($result); |
|
| 173 | - if ($row != null) { |
|
| 168 | + if(!empty($type)){ |
|
| 169 | + $query .= " AND relationship_type='$type'"; |
|
| 170 | + } |
|
| 171 | + $result = $db->query($query,true," Error searching relationships table.."); |
|
| 172 | + $row = $db->fetchByAssoc($result); |
|
| 173 | + if ($row != null) { |
|
| 174 | 174 | |
| 175 | - return $row['relationship_name']; |
|
| 175 | + return $row['relationship_name']; |
|
| 176 | 176 | |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - return null; |
|
| 179 | + return null; |
|
| 180 | 180 | |
| 181 | 181 | |
| 182 | - //end function retrieve_by_sides |
|
| 183 | - } |
|
| 182 | + //end function retrieve_by_sides |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | 185 | |
| 186 | - function retrieve_by_name($relationship_name) { |
|
| 186 | + function retrieve_by_name($relationship_name) { |
|
| 187 | 187 | |
| 188 | - if (empty($GLOBALS['relationships'])) { |
|
| 189 | - $this->load_relationship_meta(); |
|
| 190 | - } |
|
| 188 | + if (empty($GLOBALS['relationships'])) { |
|
| 189 | + $this->load_relationship_meta(); |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | // _ppd($GLOBALS['relationships']); |
| 193 | 193 | |
| 194 | - if (array_key_exists($relationship_name, $GLOBALS['relationships'])) { |
|
| 195 | - |
|
| 196 | - foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value) |
|
| 197 | - { |
|
| 198 | - $this->$field = $value; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - else { |
|
| 202 | - $GLOBALS['log']->fatal('Error fetching relationship from cache '.$relationship_name); |
|
| 203 | - return false; |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - function load_relationship_meta() { |
|
| 208 | - if (!file_exists(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only())) { |
|
| 209 | - $this->build_relationship_cache(); |
|
| 210 | - } |
|
| 211 | - include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only()); |
|
| 212 | - $GLOBALS['relationships']=$relationships; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - function build_relationship_cache() { |
|
| 216 | - $query="SELECT * from relationships where deleted=0"; |
|
| 217 | - $result=$this->db->query($query); |
|
| 218 | - |
|
| 219 | - while (($row=$this->db->fetchByAssoc($result))!=null) { |
|
| 220 | - $relationships[$row['relationship_name']] = $row; |
|
| 221 | - } |
|
| 194 | + if (array_key_exists($relationship_name, $GLOBALS['relationships'])) { |
|
| 195 | + |
|
| 196 | + foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value) |
|
| 197 | + { |
|
| 198 | + $this->$field = $value; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + else { |
|
| 202 | + $GLOBALS['log']->fatal('Error fetching relationship from cache '.$relationship_name); |
|
| 203 | + return false; |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + function load_relationship_meta() { |
|
| 208 | + if (!file_exists(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only())) { |
|
| 209 | + $this->build_relationship_cache(); |
|
| 210 | + } |
|
| 211 | + include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only()); |
|
| 212 | + $GLOBALS['relationships']=$relationships; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + function build_relationship_cache() { |
|
| 216 | + $query="SELECT * from relationships where deleted=0"; |
|
| 217 | + $result=$this->db->query($query); |
|
| 218 | + |
|
| 219 | + while (($row=$this->db->fetchByAssoc($result))!=null) { |
|
| 220 | + $relationships[$row['relationship_name']] = $row; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - sugar_mkdir($this->cache_file_dir(), null, true); |
|
| 223 | + sugar_mkdir($this->cache_file_dir(), null, true); |
|
| 224 | 224 | $out = "<?php \n \$relationships = " . var_export($relationships, true) . ";"; |
| 225 | 225 | sugar_file_put_contents_atomic(Relationship::cache_file_dir() . '/' . Relationship::cache_file_name_only(), $out); |
| 226 | 226 | |
| 227 | 227 | require_once("data/Relationships/RelationshipFactory.php"); |
| 228 | 228 | SugarRelationshipFactory::deleteCache(); |
| 229 | - } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | |
| 232 | - public static function cache_file_dir() { |
|
| 233 | - return sugar_cached("modules/Relationships"); |
|
| 234 | - } |
|
| 235 | - public static function cache_file_name_only() { |
|
| 236 | - return 'relationships.cache.php'; |
|
| 237 | - } |
|
| 232 | + public static function cache_file_dir() { |
|
| 233 | + return sugar_cached("modules/Relationships"); |
|
| 234 | + } |
|
| 235 | + public static function cache_file_name_only() { |
|
| 236 | + return 'relationships.cache.php'; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - public static function delete_cache() { |
|
| 240 | - $filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(); |
|
| 241 | - if (file_exists($filename)) { |
|
| 242 | - unlink($filename); |
|
| 243 | - } |
|
| 239 | + public static function delete_cache() { |
|
| 240 | + $filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(); |
|
| 241 | + if (file_exists($filename)) { |
|
| 242 | + unlink($filename); |
|
| 243 | + } |
|
| 244 | 244 | require_once("data/Relationships/RelationshipFactory.php"); |
| 245 | 245 | SugarRelationshipFactory::deleteCache(); |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | 248 | |
| 249 | - function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){ |
|
| 250 | - global $beanList; |
|
| 251 | - global $dictionary; |
|
| 249 | + function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){ |
|
| 250 | + global $beanList; |
|
| 251 | + global $dictionary; |
|
| 252 | 252 | |
| 253 | - $temp_module = get_module_info($base_module); |
|
| 253 | + $temp_module = get_module_info($base_module); |
|
| 254 | 254 | |
| 255 | - $rel_attribute1_name = $temp_module->field_defs[strtolower($rel_module1_name)]['relationship']; |
|
| 256 | - $rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db); |
|
| 257 | - $rel_module1_bean = get_module_info($rel_module1); |
|
| 255 | + $rel_attribute1_name = $temp_module->field_defs[strtolower($rel_module1_name)]['relationship']; |
|
| 256 | + $rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db); |
|
| 257 | + $rel_module1_bean = get_module_info($rel_module1); |
|
| 258 | 258 | |
| 259 | - if($rel_module2_name!=""){ |
|
| 260 | - if($rel_module2_name == 'ProjectTask'){ |
|
| 261 | - $rel_module2_name = strtolower($rel_module2_name); |
|
| 262 | - } |
|
| 263 | - $rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship']; |
|
| 264 | - $rel_module2 = $this->get_other_module($rel_attribute2_name, $rel_module1_bean->module_dir, $rel_module1_bean->db); |
|
| 265 | - $rel_module2_bean = get_module_info($rel_module2); |
|
| 266 | - return $rel_module2_bean; |
|
| 259 | + if($rel_module2_name!=""){ |
|
| 260 | + if($rel_module2_name == 'ProjectTask'){ |
|
| 261 | + $rel_module2_name = strtolower($rel_module2_name); |
|
| 262 | + } |
|
| 263 | + $rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship']; |
|
| 264 | + $rel_module2 = $this->get_other_module($rel_attribute2_name, $rel_module1_bean->module_dir, $rel_module1_bean->db); |
|
| 265 | + $rel_module2_bean = get_module_info($rel_module2); |
|
| 266 | + return $rel_module2_bean; |
|
| 267 | 267 | |
| 268 | - } else { |
|
| 269 | - //no rel_module2, so return rel_module2 bean |
|
| 270 | - return $rel_module1_bean; |
|
| 271 | - } |
|
| 268 | + } else { |
|
| 269 | + //no rel_module2, so return rel_module2 bean |
|
| 270 | + return $rel_module1_bean; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - //end function trace_relationship_module |
|
| 274 | - } |
|
| 273 | + //end function trace_relationship_module |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | |
| 277 | 277 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | class Relationship extends SugarBean { |
| 51 | 51 | |
| 52 | - var $object_name='Relationship'; |
|
| 52 | + var $object_name = 'Relationship'; |
|
| 53 | 53 | var $module_dir = 'Relationships'; |
| 54 | 54 | var $new_schema = true; |
| 55 | 55 | var $table_name = 'relationships'; |
@@ -81,21 +81,21 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function is_self_referencing() { |
| 83 | 83 | if (empty($this->_self_referencing)) { |
| 84 | - $this->_self_referencing=false; |
|
| 84 | + $this->_self_referencing = false; |
|
| 85 | 85 | |
| 86 | 86 | //is it self referencing, both table and key name from lhs and rhs should be equal. |
| 87 | 87 | if ($this->lhs_table == $this->rhs_table && $this->lhs_key == $this->rhs_key) { |
| 88 | - $this->_self_referencing=true; |
|
| 88 | + $this->_self_referencing = true; |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | return $this->_self_referencing; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /*returns true if a relationship with provided name exists*/ |
| 95 | - static function exists($relationship_name,&$db) { |
|
| 95 | + static function exists($relationship_name, &$db) { |
|
| 96 | 96 | $query = "SELECT relationship_name FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
| 97 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 98 | - $row = $db->fetchByAssoc($result); |
|
| 97 | + $result = $db->query($query, true, " Error searching relationships table.."); |
|
| 98 | + $row = $db->fetchByAssoc($result); |
|
| 99 | 99 | if ($row != null) { |
| 100 | 100 | return true; |
| 101 | 101 | } |
@@ -103,27 +103,27 @@ discard block |
||
| 103 | 103 | return false; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - static function delete($relationship_name,&$db) { |
|
| 106 | + static function delete($relationship_name, &$db) { |
|
| 107 | 107 | |
| 108 | 108 | $query = "UPDATE relationships SET deleted=1 WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
| 109 | - $result = $db->query($query,true," Error updating relationships table for ".$relationship_name); |
|
| 109 | + $result = $db->query($query, true, " Error updating relationships table for ".$relationship_name); |
|
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
| 114 | - function get_other_module($relationship_name, $base_module, &$db){ |
|
| 114 | + function get_other_module($relationship_name, $base_module, &$db) { |
|
| 115 | 115 | //give it the relationship_name and base module |
| 116 | 116 | //it will return the module name on the other side of the relationship |
| 117 | 117 | |
| 118 | 118 | $query = "SELECT relationship_name, rhs_module, lhs_module FROM relationships WHERE deleted=0 AND relationship_name = '".$relationship_name."'"; |
| 119 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 120 | - $row = $db->fetchByAssoc($result); |
|
| 119 | + $result = $db->query($query, true, " Error searching relationships table.."); |
|
| 120 | + $row = $db->fetchByAssoc($result); |
|
| 121 | 121 | if ($row != null) { |
| 122 | 122 | |
| 123 | - if($row['rhs_module']==$base_module){ |
|
| 123 | + if ($row['rhs_module'] == $base_module) { |
|
| 124 | 124 | return $row['lhs_module']; |
| 125 | 125 | } |
| 126 | - if($row['lhs_module']==$base_module){ |
|
| 126 | + if ($row['lhs_module'] == $base_module) { |
|
| 127 | 127 | return $row['rhs_module']; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | //end function get_other_module |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - function retrieve_by_sides($lhs_module, $rhs_module, &$db){ |
|
| 137 | + function retrieve_by_sides($lhs_module, $rhs_module, &$db) { |
|
| 138 | 138 | //give it the relationship_name and base module |
| 139 | 139 | //it will return the module name on the other side of the relationship |
| 140 | 140 | |
| 141 | 141 | $query = "SELECT * FROM relationships WHERE deleted=0 AND lhs_module = '".$lhs_module."' AND rhs_module = '".$rhs_module."'"; |
| 142 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 143 | - $row = $db->fetchByAssoc($result); |
|
| 142 | + $result = $db->query($query, true, " Error searching relationships table.."); |
|
| 143 | + $row = $db->fetchByAssoc($result); |
|
| 144 | 144 | if ($row != null) { |
| 145 | 145 | |
| 146 | 146 | return $row; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | //end function retrieve_by_sides |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type =''){ |
|
| 156 | + static function retrieve_by_modules($lhs_module, $rhs_module, &$db, $type = '') { |
|
| 157 | 157 | //give it the relationship_name and base module |
| 158 | 158 | //it will return the module name on the other side of the relationship |
| 159 | 159 | |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | (lhs_module = '".$rhs_module."' AND rhs_module = '".$lhs_module."') |
| 166 | 166 | ) |
| 167 | 167 | "; |
| 168 | - if(!empty($type)){ |
|
| 168 | + if (!empty($type)) { |
|
| 169 | 169 | $query .= " AND relationship_type='$type'"; |
| 170 | 170 | } |
| 171 | - $result = $db->query($query,true," Error searching relationships table.."); |
|
| 172 | - $row = $db->fetchByAssoc($result); |
|
| 171 | + $result = $db->query($query, true, " Error searching relationships table.."); |
|
| 172 | + $row = $db->fetchByAssoc($result); |
|
| 173 | 173 | if ($row != null) { |
| 174 | 174 | |
| 175 | 175 | return $row['relationship_name']; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | if (array_key_exists($relationship_name, $GLOBALS['relationships'])) { |
| 195 | 195 | |
| 196 | - foreach($GLOBALS['relationships'][$relationship_name] as $field=>$value) |
|
| 196 | + foreach ($GLOBALS['relationships'][$relationship_name] as $field=>$value) |
|
| 197 | 197 | { |
| 198 | 198 | $this->$field = $value; |
| 199 | 199 | } |
@@ -209,20 +209,20 @@ discard block |
||
| 209 | 209 | $this->build_relationship_cache(); |
| 210 | 210 | } |
| 211 | 211 | include(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only()); |
| 212 | - $GLOBALS['relationships']=$relationships; |
|
| 212 | + $GLOBALS['relationships'] = $relationships; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | function build_relationship_cache() { |
| 216 | - $query="SELECT * from relationships where deleted=0"; |
|
| 217 | - $result=$this->db->query($query); |
|
| 216 | + $query = "SELECT * from relationships where deleted=0"; |
|
| 217 | + $result = $this->db->query($query); |
|
| 218 | 218 | |
| 219 | - while (($row=$this->db->fetchByAssoc($result))!=null) { |
|
| 219 | + while (($row = $this->db->fetchByAssoc($result)) != null) { |
|
| 220 | 220 | $relationships[$row['relationship_name']] = $row; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | sugar_mkdir($this->cache_file_dir(), null, true); |
| 224 | - $out = "<?php \n \$relationships = " . var_export($relationships, true) . ";"; |
|
| 225 | - sugar_file_put_contents_atomic(Relationship::cache_file_dir() . '/' . Relationship::cache_file_name_only(), $out); |
|
| 224 | + $out = "<?php \n \$relationships = ".var_export($relationships, true).";"; |
|
| 225 | + sugar_file_put_contents_atomic(Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(), $out); |
|
| 226 | 226 | |
| 227 | 227 | require_once("data/Relationships/RelationshipFactory.php"); |
| 228 | 228 | SugarRelationshipFactory::deleteCache(); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public static function delete_cache() { |
| 240 | - $filename=Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(); |
|
| 240 | + $filename = Relationship::cache_file_dir().'/'.Relationship::cache_file_name_only(); |
|
| 241 | 241 | if (file_exists($filename)) { |
| 242 | 242 | unlink($filename); |
| 243 | 243 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){ |
|
| 249 | + function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name = "") { |
|
| 250 | 250 | global $beanList; |
| 251 | 251 | global $dictionary; |
| 252 | 252 | |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | $rel_module1 = $this->get_other_module($rel_attribute1_name, $base_module, $temp_module->db); |
| 257 | 257 | $rel_module1_bean = get_module_info($rel_module1); |
| 258 | 258 | |
| 259 | - if($rel_module2_name!=""){ |
|
| 260 | - if($rel_module2_name == 'ProjectTask'){ |
|
| 259 | + if ($rel_module2_name != "") { |
|
| 260 | + if ($rel_module2_name == 'ProjectTask') { |
|
| 261 | 261 | $rel_module2_name = strtolower($rel_module2_name); |
| 262 | 262 | } |
| 263 | 263 | $rel_attribute2_name = $rel_module1_bean->field_defs[strtolower($rel_module2_name)]['relationship']; |
@@ -1,5 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -197,8 +199,7 @@ discard block |
||
| 197 | 199 | { |
| 198 | 200 | $this->$field = $value; |
| 199 | 201 | } |
| 200 | - } |
|
| 201 | - else { |
|
| 202 | + } else { |
|
| 202 | 203 | $GLOBALS['log']->fatal('Error fetching relationship from cache '.$relationship_name); |
| 203 | 204 | return false; |
| 204 | 205 | } |
@@ -246,6 +246,9 @@ |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | + /** |
|
| 250 | + * @param string $base_module |
|
| 251 | + */ |
|
| 249 | 252 | function trace_relationship_module($base_module, $rel_module1_name, $rel_module2_name=""){ |
| 250 | 253 | global $beanList; |
| 251 | 254 | global $dictionary; |
@@ -11,21 +11,21 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if (!empty($_REQUEST['cron'])) { |
| 13 | 13 | |
| 14 | - require_once('modules/jjwg_Maps/jjwg_Maps.php'); |
|
| 15 | - require_once('modules/jjwg_Maps/controller.php'); |
|
| 16 | - /* |
|
| 14 | + require_once('modules/jjwg_Maps/jjwg_Maps.php'); |
|
| 15 | + require_once('modules/jjwg_Maps/controller.php'); |
|
| 16 | + /* |
|
| 17 | 17 | * This script can be used as an entry point for a cron |
| 18 | 18 | * job to run the address geocoding on a regular basis. |
| 19 | 19 | * index.php?module=jjwg_Maps&entryPoint=jjwg_Maps&cron=1&limit=2500 |
| 20 | 20 | */ |
| 21 | - $controller = new jjwg_MapsController(); |
|
| 22 | - $controller->action_geocode_addresses(); |
|
| 21 | + $controller = new jjwg_MapsController(); |
|
| 22 | + $controller->action_geocode_addresses(); |
|
| 23 | 23 | |
| 24 | - exit; |
|
| 24 | + exit; |
|
| 25 | 25 | |
| 26 | 26 | } else { |
| 27 | 27 | |
| 28 | - /* |
|
| 28 | + /* |
|
| 29 | 29 | * This script is also used to pass selected records from |
| 30 | 30 | * a module list view to the Maps Module (jjwg_Maps). |
| 31 | 31 | * |
@@ -45,25 +45,25 @@ discard block |
||
| 45 | 45 | * 4.) Parameter Search - Checked Records - Map |
| 46 | 46 | * Uses 'uid'(s) parameter to define search |
| 47 | 47 | */ |
| 48 | - //echo 'Test:<pre>'."\n"; |
|
| 49 | - //foreach (array_keys($_REQUEST) as $key) { |
|
| 50 | - // echo 'Name: '.htmlspecialchars($key).' Value: '.htmlspecialchars($_REQUEST[$key])."\n"; |
|
| 51 | - //} |
|
| 48 | + //echo 'Test:<pre>'."\n"; |
|
| 49 | + //foreach (array_keys($_REQUEST) as $key) { |
|
| 50 | + // echo 'Name: '.htmlspecialchars($key).' Value: '.htmlspecialchars($_REQUEST[$key])."\n"; |
|
| 51 | + //} |
|
| 52 | 52 | |
| 53 | - // Redirect parameters to view/action using Javascript form post. |
|
| 54 | - echo '<html><head></head><body>'; |
|
| 55 | - echo '<form name="redirect" action="index.php" method="POST">'."\n"; |
|
| 56 | - echo '<input type="hidden" name="module" value="jjwg_Maps">'."\n"; |
|
| 57 | - echo '<input type="hidden" name="action" value="map_display">'."\n"; |
|
| 58 | - foreach (array_keys($_REQUEST) as $key) { |
|
| 53 | + // Redirect parameters to view/action using Javascript form post. |
|
| 54 | + echo '<html><head></head><body>'; |
|
| 55 | + echo '<form name="redirect" action="index.php" method="POST">'."\n"; |
|
| 56 | + echo '<input type="hidden" name="module" value="jjwg_Maps">'."\n"; |
|
| 57 | + echo '<input type="hidden" name="action" value="map_display">'."\n"; |
|
| 58 | + foreach (array_keys($_REQUEST) as $key) { |
|
| 59 | 59 | if (!in_array($key, array('action','module','entryPoint','display_module', 'quick_address'))) { |
| 60 | - echo '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($_REQUEST[$key]).'">'."\n"; |
|
| 60 | + echo '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($_REQUEST[$key]).'">'."\n"; |
|
| 61 | 61 | } |
| 62 | - } |
|
| 63 | - echo '<input type="hidden" name="display_module" value="'.htmlspecialchars($_REQUEST['display_module']).'">'."\n"; |
|
| 64 | - echo '</form>'."\n"; |
|
| 65 | - echo '<script language="javascript" type="text/javascript">document.redirect.submit();</script>'."\n"; |
|
| 66 | - echo '</body></html>'; |
|
| 62 | + } |
|
| 63 | + echo '<input type="hidden" name="display_module" value="'.htmlspecialchars($_REQUEST['display_module']).'">'."\n"; |
|
| 64 | + echo '</form>'."\n"; |
|
| 65 | + echo '<script language="javascript" type="text/javascript">document.redirect.submit();</script>'."\n"; |
|
| 66 | + echo '</body></html>'; |
|
| 67 | 67 | |
| 68 | - exit; |
|
| 68 | + exit; |
|
| 69 | 69 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | |
| 4 | 4 | require_once('include/utils.php'); |
| 5 | 5 | require_once('include/export_utils.php'); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | echo '<input type="hidden" name="module" value="jjwg_Maps">'."\n"; |
| 57 | 57 | echo '<input type="hidden" name="action" value="map_display">'."\n"; |
| 58 | 58 | foreach (array_keys($_REQUEST) as $key) { |
| 59 | - if (!in_array($key, array('action','module','entryPoint','display_module', 'quick_address'))) { |
|
| 59 | + if (!in_array($key, array('action', 'module', 'entryPoint', 'display_module', 'quick_address'))) { |
|
| 60 | 60 | echo '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($_REQUEST[$key]).'">'."\n"; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -4,11 +4,11 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Jjwg_MapsViewGeocoding_Test extends SugarView { |
| 6 | 6 | |
| 7 | - function Jjwg_MapsViewGeocoding_Test() { |
|
| 8 | - parent::SugarView(); |
|
| 9 | - } |
|
| 7 | + function Jjwg_MapsViewGeocoding_Test() { |
|
| 8 | + parent::SugarView(); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - function display() { |
|
| 11 | + function display() { |
|
| 12 | 12 | |
| 13 | 13 | if (!isset($_REQUEST['geocoding_address'])) $_REQUEST['geocoding_address'] = ''; |
| 14 | 14 | ?> |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | <?php |
| 31 | 31 | if (!empty($_REQUEST['process_trigger'])) { |
| 32 | 32 | |
| 33 | - echo '<br /><br /><pre>'; |
|
| 34 | - print_r($this->bean->geocoding_results); |
|
| 35 | - echo '</pre><br /><br />'; |
|
| 33 | + echo '<br /><br /><pre>'; |
|
| 34 | + print_r($this->bean->geocoding_results); |
|
| 35 | + echo '</pre><br /><br />'; |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | ?> |
| 43 | 43 | \ No newline at end of file |
@@ -1,6 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 4 | + die('Not A Valid Entry Point'); |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | class Jjwg_MapsViewGeocoding_Test extends SugarView { |
| 6 | 8 | |
@@ -10,8 +12,10 @@ discard block |
||
| 10 | 12 | |
| 11 | 13 | function display() { |
| 12 | 14 | |
| 13 | - if (!isset($_REQUEST['geocoding_address'])) $_REQUEST['geocoding_address'] = ''; |
|
| 14 | -?> |
|
| 15 | + if (!isset($_REQUEST['geocoding_address'])) { |
|
| 16 | + $_REQUEST['geocoding_address'] = ''; |
|
| 17 | + } |
|
| 18 | + ?> |
|
| 15 | 19 | |
| 16 | 20 | <div class="moduleTitle"><h2><?php echo $GLOBALS['mod_strings']['LBL_MAP_ADDRESS_TEST']; ?></h2><div class="clear"></div></div> |
| 17 | 21 | <div class="clear"></div> |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -4,18 +4,18 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Jjwg_MapsViewQuick_Radius_Display extends SugarView { |
| 6 | 6 | |
| 7 | - function Jjwg_MapsViewQuick_Radius_Display() { |
|
| 7 | + function Jjwg_MapsViewQuick_Radius_Display() { |
|
| 8 | 8 | parent::SugarView(); |
| 9 | - } |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - function display() { |
|
| 11 | + function display() { |
|
| 12 | 12 | |
| 13 | 13 | $url = 'index.php?module='.$GLOBALS['currentModule'].'&action=map_markers'; |
| 14 | 14 | foreach (array_keys($_REQUEST) as $key) { |
| 15 | - // Exclude certain request parameters |
|
| 16 | - if (!in_array($key, array('action', 'module', 'entryPoint', 'record', 'relate_id'))) { |
|
| 15 | + // Exclude certain request parameters |
|
| 16 | + if (!in_array($key, array('action', 'module', 'entryPoint', 'record', 'relate_id'))) { |
|
| 17 | 17 | $url .= '&'.$key.'='.urlencode($_REQUEST[$key]); |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | ?> |
@@ -30,5 +30,5 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | <?php |
| 32 | 32 | |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -4,18 +4,18 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Jjwg_MapsViewMap_Display extends SugarView { |
| 6 | 6 | |
| 7 | - function Jjwg_MapsViewMap_Display() { |
|
| 7 | + function Jjwg_MapsViewMap_Display() { |
|
| 8 | 8 | parent::SugarView(); |
| 9 | - } |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - function display() { |
|
| 11 | + function display() { |
|
| 12 | 12 | // Limit URI query string parameters. Used to avoid URL length errors. |
| 13 | 13 | $valid_names = array('action', 'module', 'entryPoint', 'submit', 'cron', 'geocoding_process', 'process_trigger', 'distance', 'unit_type', 'record', 'related_id', 'related_module', 'quick_address', 'display_module', 'list_id', 'uid', 'current_post'); |
| 14 | 14 | $url = $GLOBALS['sugar_config']['site_url'] . '/index.php?module=' . $GLOBALS['currentModule'] . '&action=map_markers'; |
| 15 | 15 | foreach (array_keys($_REQUEST) as $key) { |
| 16 | - if (in_array($key, $valid_names) && !in_array($key, array('action', 'module', 'entryPoint'))) { |
|
| 16 | + if (in_array($key, $valid_names) && !in_array($key, array('action', 'module', 'entryPoint'))) { |
|
| 17 | 17 | $url .= '&'.$key.'='.urlencode($_REQUEST[$key]); |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | ?> |
@@ -76,5 +76,5 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | <?php |
| 78 | 78 | |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 4 | 4 | |
| 5 | 5 | class Jjwg_MapsViewMap_Display extends SugarView { |
| 6 | 6 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | function display() { |
| 12 | 12 | // Limit URI query string parameters. Used to avoid URL length errors. |
| 13 | 13 | $valid_names = array('action', 'module', 'entryPoint', 'submit', 'cron', 'geocoding_process', 'process_trigger', 'distance', 'unit_type', 'record', 'related_id', 'related_module', 'quick_address', 'display_module', 'list_id', 'uid', 'current_post'); |
| 14 | - $url = $GLOBALS['sugar_config']['site_url'] . '/index.php?module=' . $GLOBALS['currentModule'] . '&action=map_markers'; |
|
| 14 | + $url = $GLOBALS['sugar_config']['site_url'].'/index.php?module='.$GLOBALS['currentModule'].'&action=map_markers'; |
|
| 15 | 15 | foreach (array_keys($_REQUEST) as $key) { |
| 16 | 16 | if (in_array($key, $valid_names) && !in_array($key, array('action', 'module', 'entryPoint'))) { |
| 17 | 17 | $url .= '&'.$key.'='.urlencode($_REQUEST[$key]); |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |