Skip to content
Snippets Groups Projects
Commit 9d9897bd authored by Satish's avatar Satish
Browse files

New function added to update the entries in vtiger_link

parent 77ca4738
No related branches found
No related tags found
No related merge requests found
......@@ -286,5 +286,29 @@ class Vtiger_Link {
return $user->is_admin == 'on' || $user->column_fields['is_admin'] == 'on';
}
static function updateLink($tabId, $linkId, $linkInfo = array()) {
if ($linkInfo && is_array($linkInfo)) {
$db = PearDatabase::getInstance();
$result = $db->pquery('SELECT 1 FROM vtiger_links WHERE tabid=? AND linkid=?', array($tabId, $linkId));
if ($db->num_rows($result)) {
$columnsList = $db->getColumnNames('vtiger_links');
$isColumnUpdate = false;
$sql = 'UPDATE vtiger_links SET ';
foreach ($linkInfo as $column => $columnValue) {
if (in_array($column, $columnsList)) {
$columnValue = ($column == 'sequence') ? intval($columnValue) : $columnValue;
$sql .= "$column='$columnValue',";
$isColumnUpdate = true;
}
}
if ($isColumnUpdate) {
$sql = trim($sql, ',').' WHERE tabid=? AND linkid=?';
$db->pquery($sql, array($tabId, $linkId));
}
}
}
}
}
?>
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