SugarCRM

From EWIKI
Jump to navigation Jump to search

Download SugarCRM Community Edition

Compare SugarCRM Editions

Install

  • chown a-R pache.apache *
  • chcon -R -t public_content_rw_t *

Login Image

  • cd /var/www/sugar
  • mkdir custom/include
  • mkdir custom/include/images
  • cp ~mh/MyWorks.png custom/include/images/sugar_md.png
  • PNG: width="340" height="25"

Customize Default Home:

  • cd /var/www/html/sugar/custom/modules
  • mkdir Home
  • cp ../../../modules/Home/index.php .
  • vi index.php

       // This is here to get Sugar dashlets added above the rest
       $dashlets[create_guid()] = array('className' => 'CalendarDashlet',
                                        'module' => 'Calendar',
                                        'forceColumn' => 0,
                                        'fileLocation' => $dashletsFiles['CalendarDashlet']['file'],
                                         );
       $dashlets[create_guid()] = array ('className' => 'SugarFeedDashlet',
                                         'module' => 'SugarFeed',
                                         'forceColumn' => 1,
                                         'fileLocation' => $dashletsFiles['SugarFeedDashlet']['file'],
                                         );
       $dashlets[create_guid()] = array ('className' => 'MyContactsDashlet',
                                         'module' => 'Contacts',
                                         'forceColumn' => 1,
                                         'fileLocation' => $dashletsFiles['MyContactsDashlet']['file'],
                                         );
 

Switch off wizard at first login

  • vi Users/views/view.wizard.php
  • find $this->ss->assign('PROMPTTZ', ' checked');
  • change to ' '

SugarCRM REST API

The Sugar REST API is not really REST. It is more a JSON RPC.

Login Call

The first call must be a login:

URL:

GET http://localhost/sugar/service/v4_1/Contacts

POST parameter is (PHP):

 array(   
    "method" => 'login',   
    "input_type" => "JSON",   
    "response_type" => "JSON",   
    "rest_data" => json_encode(  
        array(   
	    "user_auth"=>array(   
		          "user_name"=>$username,   
		          "password"=>md5($password),   
	                  "version"=>"1"   
	     ),   
	     "application_name"=>"MyClient",   
	     "name_value_list"=>array(),   
	),   
  );   

Result is

HTTP/1.1 200 OK 
...
Content-Type: application/json; charset=UTF-8 
{
   "id":"9vnt87unhtur0545i4a2fcdig2",
   "module_name":"Users",
   "name_value_list": {
       "user_id":{ "name":"user_id","value":"1"},
       "user_name":{"name":"user_name","value":"admin"},
       "user_language":{"name":"user_language","value":"en_us"},
       "user_currency_id":{"name":"user_currency_id","value":"-99"},
       "user_is_admin":{"name":"user_is_admin","value":true},
       "user_default_team_id":{"name":"user_default_team_id","value":null},
       "user_default_dateformat":{"name":"user_default_dateformat","value":"d.m.Y"},
       "user_default_timeformat":{"name":"user_default_timeformat","value":"H:i"},
       "user_number_seperator":{"name":"user_number_seperator","value":"."},
       "user_decimal_seperator":{"name":"user_decimal_seperator","value":","},
       "mobile_max_list_entries":{"name":"mobile_max_list_entries","value":null},"mob
       ile_max_subpanel_entries":{"name":"mobile_max_subpanel_entries","value":null},
       "user_currency_name":{"name":"user_currency_name","value":"Euro"}
   }
}

The id is required for further actions as $session_id.

Get all Contacts

REST call should be something like

GET http://localhost/sugar/service/v4_1/Contacts

-- but Sugar "REST" is not as expected: URL is:

http://localhost/mh/sugar/service/v4_1/rest.php

POST parameter is (PHP):

 array(   
    "method" => 'get_entry_list',   
    "input_type" => "JSON",   
    "response_type" => "JSON",   
    "rest_data" => json_encode(  
        array(
           'session' => $session_id,      
           'module_name' => 'Contacts',   
           'query' => "",            // = SQL WHERE
           'order_by' => "",         // = SQL ORDER BY 
           'offset' => '0',   
           'select_fields' => array(   'id',   'name',   ), 
           'link_name_to_fields_array' => array(   ), 
           'max_results' => '20', 
           'deleted' => '0',    
           'Favorites' => false,   
       );    
  );   

Result is

 {
  "result_count":2,
  "total_count":"2",
  "next_offset":2,
  "entry_list":
  [
    {
      "id":"8c2b9a1d-8296-b4c9-ea45-51d1d8a7a654",
      "module_name":"Contacts",
      "name_value_list":
      {
        "id":
            {
               "name":"id",
               "value":"8c2b9a1d-8296-b4c9-ea45-51d1d8a7a654"
            },
        "name":{
               "name":"name",
               "value":"Maier"
        }
      }
    },
    {
      "id":"95f2195b-bf98-3ede-cc85-526a988a0efa",
      "module_name":"Contacts",
      "name_value_list":
      {
        "id":
           {
              "name":"id",
              "value":"95f2195b-bf98-3ede-cc85-526a988a0efa"
           },
        "name":
           {
              "name":"name",
              "value":"Schulz"
           }
      }
    }
  ],
  "relationship_list":[]
 }

Hmmm, that's not even a RESTlike pattern :-(

REST via PHP

Links:

REST via Java

Links:

oAuth

Link