Skip to content
Snippets Groups Projects
Commit 5a89f907 authored by Uma's avatar Uma Committed by Uma
Browse files

Merge with master branch

parent 272c5779
No related branches found
No related tags found
1 merge request!35737789504 security issue
......@@ -775,56 +775,4 @@ function vtlib_module_icon($modulename){
function vtlib_mime_content_type($filename) {
return Vtiger_Functions::mime_content_type($filename);
}
/**
* Function to add settings entry in CRM settings page
* @param string $linkName
* @param string $linkURL
* @param string $blockName
* @return boolean true/false
*/
function vtlib_addSettingsLink($linkName, $linkURL, $blockName = false) {
$success = true;
$db = PearDatabase::getInstance();
//Check entry name exist in DB or not
$result = $db->pquery('SELECT 1 FROM vtiger_settings_field WHERE name=?', array($linkName));
if ($result && !$db->num_rows($result)) {
$blockId = 0;
if ($blockName) {
$blockId = getSettingsBlockId($blockName);//Check block name exist in DB or not
}
if (!$blockId) {
$blockName = 'LBL_OTHER_SETTINGS';
$blockId = getSettingsBlockId($blockName);//Check block name exist in DB or not
}
//Add block in to DB if not exists
if (!$blockId) {
$blockSeqResult = $db->pquery('SELECT MAX(sequence) AS sequence FROM vtiger_settings_blocks', array());
if ($db->num_rows($blockSeqResult)) {
$blockId = $db->getUniqueID('vtiger_settings_blocks');
$blockSequence = $db->query_result($blockSeqResult, 0, 'sequence');
$db->pquery('INSERT INTO vtiger_settings_blocks(blockid, label, sequence) VALUES(?,?,?)', array($blockId, 'LBL_OTHER_SETTINGS', $blockSequence++));
}
}
//Add settings field in to DB
if ($blockId) {
$fieldSeqResult = $db->pquery('SELECT MAX(sequence) AS sequence FROM vtiger_settings_field WHERE blockid=?', array($blockId));
if ($db->num_rows($fieldSeqResult)) {
$fieldId = $db->getUniqueID('vtiger_settings_field');
$linkURL = ($linkURL) ? $linkURL : '';
$fieldSequence = $db->query_result($fieldSeqResult, 0, 'sequence');
$db->pquery('INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence, active, pinned) VALUES(?,?,?,?,?,?,?,?,?)', array($fieldId, $blockId, $entryName, '', $entryName, $linkURL, $fieldSequence++, 0, 0));
}
} else {
$success = false;
}
}
return $success;
}
?>
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment