Adding new values to chosen plugin (Multiple chosen select box )

Adding new values in chosen select box if value is not exists in a list .Chosen is a jQuery Plugin, which gives some likely looking multiple selects in your html form.

In the source code (chosen.jquery.js) Go to case 13 (13 is the keycode for ‘Enter’) option in the switch block
if (this.results_showing) {
return this.result_select(evt);
}

Add following code here
$(this.form_field).append('' + $(evt.target).val() + '');
$(this.form_field).trigger('chosen:updated');
this.result_highlight = this.search_results.find('li.active-result').last();
return this.result_select(evt);

and your final code looks like this :
case 13:
evt.preventDefault();
if (this.results_showing) {
if (!this.is_multiple || this.result_highlight) {
return this.result_select(evt);
}
$(this.form_field).append('' + $(evt.target).val() + '');
$(this.form_field).trigger('chosen:updated');
this.result_highlight = this.search_results.find('li.active-result').last();
return this.result_select(evt);
}
break;

Get URL Variables/parameters values With JavaScript


javscript function ///
//name = Pass URl parameter
function getParameterByName(name) {
alert(name);
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
var result= match && decodeURIComponent(match[1].replace(/\+/g, ' '));
alert(result);
}

// ]]>


and buttun onclick event onclick=”javascript:getParameterByName(‘utm_source’);”
URL = javascript_get_parameter.html?utm_source=massmail&utm_medium=email&utm_campaign=21-feb-2015

PHP Fatal error: Class ‘PMA_Message’ not found

  • Class ‘PMA_Message’ not found in /usr/local/apache2/apps/phpMyAdmin-3.5.5-all-languages/libraries/Message.class.php on line 601
  • Notice: Undefined property: PMA_Error :: $ _ hash in /usr/share/phpMyAdmin/libraries/Error.class.php on line 164
  • Notice: Undefined property: PMA_Error :: $ _ params in / usr / share / phpMyAdmin / libraries / Message. class.php on line 495 Fatal error: Class ‘PMA_Message’ not found in /usr/share/phpMyAdmin/libraries/Message.class.php on line 601

It seems to try and read authority of session file problem by looking

Change your session save path in php.ini file and in apc.ini file memory limit (if  apc cache is enable)

#chown apache: apache -r / var / lib / php / session /
#chmod 700 -R / var / lib / php / session /

Multiselect , Tags , Autosuggest using core javascript DOM element

<script>
function selectIngredient(select)
{
var option = select.options[select.selectedIndex];
var ul = select.parentNode.getElementsByTagName(‘ul’)[0];

var choices = ul.getElementsByTagName(‘input’);
for (var i = 0; i < choices.length; i++)
if (choices[i].value == option.value)
return;

var li = document.createElement(‘li’);
var input = document.createElement(‘input’);
var text = document.createTextNode(option.firstChild.data);

input.type = ‘hidden’;
input.name = ‘ingredients[]’;
input.value = option.value;

li.appendChild(input);
li.appendChild(text);
li.setAttribute(‘onclick’, ‘this.parentNode.removeChild(this);’);

ul.appendChild(li);
}
</script> <ul>

</ul>
<select onchange=”selectIngredient(this);”>
<option value=”Cheese”>Cheese</option>
<option value=”Olives”>Olives</option>
<option value=”Pepperoni”>Pepperoni</option>

</select>

Error message “Forbidden You don’t have permission to access / on this server”

By default, global directory settings is (httpd.conf line ~188):

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

set the options to : Options Indexes FollowSymLinks Includes ExecCGI

Finally, it should look like:

<Directory />
    #Options FollowSymLinks
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

Sample/Basic SugarCRM CE Wrapper Class (REST Web Service)

<?php
// namespace Rest;
class Rest {
var $url,

$username,

$password,

$session,

$logged_in,

$method,

$parameters;

private $UserId;

// public function Vanare($url, $username, $password){
// $this->setUrl();
// $this->setUsername();
// $this->setPassword();
// }
// To set the Url
public function setUrl($url = null) {
$this->url = $url;
}
// To set the entered username
public function setUsername($username = null) {
$this->username = $username;
}
// To set the entered password
public function setPassword($password = null) {
$this->password = $password;
}
public function call($method, $parameters, $url) {
ob_start ();
$curl_request = curl_init ();

curl_setopt ( $curl_request, CURLOPT_URL, $url );
curl_setopt ( $curl_request, CURLOPT_POST, 1 );
curl_setopt ( $curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
curl_setopt ( $curl_request, CURLOPT_HEADER, 1 );
curl_setopt ( $curl_request, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt ( $curl_request, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $curl_request, CURLOPT_FOLLOWLOCATION, 0 );

$jsonEncodedData = json_encode ( $parameters );

$post = array (
“method” => $method,
“input_type” => “JSON”,
“response_type” => “JSON”,
“rest_data” => $jsonEncodedData
);

curl_setopt ( $curl_request, CURLOPT_POSTFIELDS, $post );
$result = curl_exec ( $curl_request );
curl_close ( $curl_request );

$result = explode ( “\r\n\r\n”, $result, 2 );
$response = json_decode ( $result [1] );
ob_end_flush ();

return $response;
}
// Login with rest/sugarcrm
public function login($username = NULL, $password = NULL) {
$username = $this->username;

$password = $this->password;

$login_parameters = array (
“user_auth” => array (
“user_name” => $username,
“password” => md5 ( $password ),
“version” => “1”
),
“application_name” => “VanareClient”,
“name_value_list” => array ()
);

$data = $this->call ( “login”, $login_parameters, $this->url );

if (isset ( $data->id )) {
$this->session = $data->id;
}
return $data;
}
// Display the module data
public function ModuleData($session, $module_name, $query, $order_by, $offset, $select_fields, $link_name_to_fields_array, $max_results, $deleted, $Favorites) {
$parameters = array (

‘session’ => $session,

‘module_name’ => $module_name,

‘query’ => $query,

‘order_by’ => $order_by,

‘offset’ => $offset,

‘select_fields’ => $select_fields,

‘link_name_to_fields_array’ => $link_name_to_fields_array,

‘max_results’ => $max_results,

‘deleted’ => $deleted,

‘Favorites’ => $Favorites
);

$data = $this->call ( ‘get_entry_list’, $parameters, $this->url );

return $data;
}

// IMAP Function for Gmail
public function HomeGmailImap($Gmailusername, $Gmailpassowrd) {
}

// Inserting the New Record
public function ModuleSetEntry($session, $module_name, $name_value_list) {
$set_contact_parameters = array (
‘session’ => $session,

// The name of the module from which to retrieve records.
‘module_name’ => $module_name,

// Record attributes
‘name_value_list’ => $name_value_list
);
$data = $this->call ( “set_entry”, $set_contact_parameters, $this->url );

return $data;
}

// TO Delete Record
public function DeleteEntry($session, $module_name, $IdDelete) {
$set_delete_parameters = array (
‘session’ => $session,

// The name of the module from which to retrieve records.
‘module_name’ => $module_name,

// Record attributes
‘name_value_list’ => array (
array (
“name” => “id”,
“value” => $IdDelete
),
array (
“name” => “deleted”,
“value” => ‘1’
)
)
);
$data = $this->call ( “set_entry”, $set_delete_parameters, $this->url );

return $data;
}

// To Update Record
public function UpdateEntry($session, $module_name, $name_value_list) {
$set_update_parameters = array (
‘session’ => $session,

// The name of the module from which to retrieve records.
‘module_name’ => $module_name,

// Record attributes
‘name_value_list’ => $name_value_list
);
$data = $this->call ( “set_entry”, $set_update_parameters, $this->url );

return $data;
}
// Search String in Module
public function SearchModule($session, $search_string, $modules, $offset, $max_results) {
$parameters = array (
‘session’ => $session,
‘search_string’ => $search_string,
‘modules’ => $modules,
‘offset’ => $offset,
‘max_results’ => $max_results,
/*’assigned_user_id’ => $assigned_user_id,
‘unified_search_only’ => $unified_search_only,
‘select_fields’ => $select_fields,$assigned_user_id,$unified_search_only = FALSE,$select_fields*/

);

$data = $this->call ( “search_by_module”, $parameters, $this->url );

return $data;
}
/*
* public function SearchModule($session, $search_string, $modules, $offset, $max_results,$assigned_user_id,$unified_search_only) { $parameters = array ( ‘session’ => $session, ‘search_string’ => $search_string, ‘modules’ => $modules, ‘offset’ => $offset, ‘max_results’ => $max_results ); $data = $this->call ( “search_by_module”, $parameters, $this->url ); return $data; }
*/
// Set relationship
public function set_relationship($sesion, $module_name, $module_id, $link_field_name, $related_ids) {
$paremeters = array (
‘session’ => $session,
‘module_name’ => $module_name,
‘module_id’ => $module_id,
‘link_field_name’ => $link_field_name,
‘related_ids’ => array (
$related_ids
)
);

$data = $this->call ( “set_relationship”, $parameters, $this->url );

return $data;
}

// to set the relationship with attachements get_note_attachment
public function set_note_attachment($session, $note_id, $file, $filename) {
$parameters = array (
‘session’ => $session,
‘note’ => array (
‘id’ => $note_id,
‘file’ => $file,
‘filename’ => $filename,
‘related_module_name’ => ‘Cases’
)
);

$data = $this->call ( “set_note_attachment”, $parameters, $this->url );

return $data;
}

// get_note_attachment Download aatachment
public function get_note_attachment($session, $note_id) {
$parameters = array (
‘session’ => $session,
‘id’ => $note_id
);

$data = $this->call ( “get_note_attachment”, $parameters, $this->url );

return $data;
}
// Get last viewed links/modules/references
public function last_viewed($session, $modules) {
$parameters = array (
“session” => $session,

‘module_names’ => $modules
);

$data = $this->call ( “get_last_viewed”, $parameters, $this->url );

return $data;
}

// logout current session
public function logout($session) {
if (empty ( $session )) {
return false;
} else {
$logout_parameters = array (
// session id to expire
“session” => $session
);
$data = $this->call ( “logout”, $logout_parameters, $this->url );

return $data;
}
}
}

?>

Credit goes to https://github.com/asakusuma/SugarCRM-REST-API-Wrapper-Class