Skip to content
Snippets Groups Projects
Commit 2d84eb7c authored by Satish's avatar Satish
Browse files

Vtlib api to add settings link in CRM

parent 2f9e157c
No related branches found
No related tags found
1 merge request!245Vtlib api to add settings link in CRM
......@@ -764,4 +764,41 @@ function vtlib_mime_content_type($filename) {
return Vtiger_Functions::mime_content_type($filename);
}
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)) {
$blockName = ($blockName) ? $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;
}
?>
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