Example #1
0
 public function GetWorkflows($module_name, $start_types = false)
 {
     $xreygshti = "start_types";
     ${"GLOBALS"}["tvkeevw"] = "module_name";
     global $adb, $current_user;
     if (${${"GLOBALS"}["dzgvygmve"]} == "Events") {
         ${${"GLOBALS"}["tvkeevw"]} = "Calendar";
     }
     $wvdjedue = "module_name";
     if (${$xreygshti} === false) {
         ${"GLOBALS"}["jfsbjte"] = "sql";
         ${${"GLOBALS"}["jfsbjte"]} = "SELECT * FROM vtiger_wf_settings WHERE module_name = ? AND active = 1";
     } else {
         if (is_array(${${"GLOBALS"}["qkrtqbzspqei"]})) {
             ${"GLOBALS"}["upjaqlkush"] = "sql";
             ${${"GLOBALS"}["upjaqlkush"]} = "SELECT * FROM vtiger_wf_settings WHERE module_name = ? AND active = 1 AND `trigger` IN ('" . implode("','", ${${"GLOBALS"}["qkrtqbzspqei"]}) . "')";
         } else {
             $vmxdxkownx = "sql";
             ${$vmxdxkownx} = "SELECT * FROM vtiger_wf_settings WHERE module_name = ? AND active = 1 AND `trigger` = '" . ${${"GLOBALS"}["qkrtqbzspqei"]} . "'";
         }
     }
     ${${"GLOBALS"}["tydgcp"]} = \Workflow\VtUtils::pquery(${${"GLOBALS"}["nlgdcz"]}, array(${$wvdjedue}));
     if ($adb->num_rows(${${"GLOBALS"}["tydgcp"]}) > 0) {
         ${${"GLOBALS"}["dyrorjnwams"]} = array();
         ${"GLOBALS"}["iqlpcfgsfg"] = "result";
         while (${${"GLOBALS"}["mghkudhvefbq"]} = $adb->fetch_array(${${"GLOBALS"}["iqlpcfgsfg"]})) {
             $fnliuzmjfu = "user";
             ${"GLOBALS"}["fmsvsgxfoein"] = "user";
             ${"GLOBALS"}["nsuivkxmtsyc"] = "row";
             if (${${"GLOBALS"}["mghkudhvefbq"]}["execution_user"] == "0") {
                 ${${"GLOBALS"}["mghkudhvefbq"]}["execution_user"] = $current_user->id;
             }
             if (empty(${${"GLOBALS"}["nsuivkxmtsyc"]}["execution_user"])) {
                 $teknlho = "row";
                 ${$teknlho}["execution_user"] = \Users::getActiveAdminId();
             }
             ${"GLOBALS"}["qclwupfymm"] = "row";
             ${${"GLOBALS"}["fmsvsgxfoein"]} = new \Users();
             $user->retrieveCurrentUserInfoFromFile(${${"GLOBALS"}["mghkudhvefbq"]}["execution_user"]);
             ${${"GLOBALS"}["ogulunomx"]} = new \Workflow\Main(${${"GLOBALS"}["qclwupfymm"]}["id"], false, ${$fnliuzmjfu});
             if ($wf->checkAuth("exec", ${${"GLOBALS"}["nyuqdt"]})) {
                 $undhwiaz = "wf";
                 ${${"GLOBALS"}["dyrorjnwams"]}[] = ${$undhwiaz};
             }
         }
         return ${${"GLOBALS"}["dyrorjnwams"]};
     }
     return array();
 }
 public function getRecordsList()
 {
     $moduleName = $this->api->getModuleName();
     $user = new Users();
     $currentUser = $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
     vglobal('current_user', $currentUser);
     $listQuery = '';
     $queryGenerator = new QueryGenerator($moduleName, $currentUser);
     $queryGenerator->initForDefaultCustomView();
     $listQuery = $queryGenerator->getQuery();
     $db = PearDatabase::getInstance();
     $listResult = $db->query($listQuery);
     $records = [];
     while ($row = $db->fetch_array($listResult)) {
         $records[] = $row;
     }
     //$listQuery = getListQuery('OSSTimeControl', '');
     return ['headers' => $queryGenerator->getFields(), 'records' => $records, 'count' => 456];
 }
Example #3
0
 function addCallLogs($data)
 {
     $adb = PearDatabase::getInstance();
     $log = vglobal('log');
     include_once 'include/main/WebUI.php';
     $log->info("Start HistoryCall::addCallLogs | user id: " . $this->userID);
     $resultData = array('status' => 2);
     $user = new Users();
     $count = 0;
     $current_user = $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
     $data = json_decode($data);
     foreach ($data->callLogs as $call) {
         $to_number = $call->to_number;
         $from_number = $data->phoneNumber;
         $destination = $this->findPhoneNumber($to_number);
         $CallHistory = CRMEntity::getInstance('CallHistory');
         $CallHistory->column_fields['assigned_user_id'] = $this->userID;
         $CallHistory->column_fields['callhistorytype'] = $this->getType($call->type, $call->duration);
         $CallHistory->column_fields['country'] = $call->country_iso;
         $CallHistory->column_fields['to_number'] = $to_number;
         $CallHistory->column_fields['from_number'] = $from_number;
         $CallHistory->column_fields['location'] = $call->location;
         $CallHistory->column_fields['phonecallid'] = $call->callid;
         $CallHistory->column_fields['start_time'] = $this->getDate($call->start_time);
         $CallHistory->column_fields['end_time'] = $this->getDate($call->end_time);
         $CallHistory->column_fields['duration'] = $call->duration;
         $CallHistory->column_fields['imei'] = $data->imei;
         $CallHistory->column_fields['ipAddress'] = $data->ipAddress;
         $CallHistory->column_fields['simSerial'] = $data->simSerial;
         $CallHistory->column_fields['subscriberId'] = $data->subscriberId;
         if ($destination) {
             $CallHistory->column_fields['destination'] = $destination;
         }
         $CallHistory->save('CallHistory');
         $count++;
     }
     $resultData = array('status' => 1, 'count' => $count);
     $log->info("End HistoryCall::addCallLogs | return: " . print_r($resultData, true));
     return $resultData;
 }
 public function getRecordDetail($record)
 {
     $moduleName = $this->api->getModuleName();
     $user = new Users();
     $currentUser = $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
     vglobal('current_user', $currentUser);
     $recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
     $rawData = $recordModel->getData();
     $moduleModel = $recordModel->getModule();
     $fields = [];
     $moduleBlockFields = Vtiger_Field_Model::getAllForModule($moduleModel);
     foreach ($moduleBlockFields as $moduleFields) {
         foreach ($moduleFields as $moduleField) {
             $block = $moduleField->get('block');
             $fields[$block->label][$moduleField->get('name')] = $rawData[$moduleField->get('name')];
             if (empty($block)) {
                 continue;
             }
         }
     }
     return ['rawData' => $rawData, 'data' => $fields];
 }
Example #5
0
 public function sendEmail()
 {
     require_once 'vtlib/Vtiger/Mailer.php';
     $vtigerMailer = new Vtiger_Mailer();
     $recipientEmails = $this->getRecipientEmails();
     Vtiger_Utils::ModuleLog('ScheduleReprots', $recipientEmails);
     foreach ($recipientEmails as $name => $email) {
         $vtigerMailer->AddAddress($email, $name);
     }
     vimport('~modules/Report/models/Record.php');
     $reportRecordModel = Reports_Record_Model::getInstanceById($this->get('reportid'));
     $currentTime = date('Y-m-d.H.i.s');
     Vtiger_Utils::ModuleLog('ScheduleReprots Send Mail Start ::', $currentTime);
     $reportname = decode_html($reportRecordModel->getName());
     $subject = $reportname;
     Vtiger_Utils::ModuleLog('ScheduleReprot Name ::', $reportname);
     $vtigerMailer->Subject = $subject;
     $vtigerMailer->Body = $this->getEmailContent($reportRecordModel);
     $vtigerMailer->IsHTML();
     $baseFileName = $reportname . '__' . $currentTime;
     $oReportRun = ReportRun::getInstance($this->get('reportid'));
     $reportFormat = $this->scheduledFormat;
     $attachments = array();
     if ($reportFormat == 'CSV') {
         $fileName = $baseFileName . '.csv';
         $filePath = 'storage/' . $fileName;
         $attachments[$fileName] = $filePath;
         $oReportRun->writeReportToCSVFile($filePath);
     }
     foreach ($attachments as $attachmentName => $path) {
         $vtigerMailer->AddAttachment($path, decode_html($attachmentName));
     }
     //Added cc to account owner
     $accountOwnerId = Users::getActiveAdminId();
     $vtigerMailer->AddCC(getUserEmail($accountOwnerId), getUserFullName($accountOwnerId));
     $status = $vtigerMailer->Send(true);
     foreach ($attachments as $attachmentName => $path) {
         unlink($path);
     }
     return $status;
 }
Example #6
0
$result = $adb->pquery('SELECT 1 FROM vtiger_currencies WHERE currency_name = ?', array('CFA Franc BEAC'));
if (!$adb->num_rows($result)) {
    Migration_Index_View::ExecuteQuery('INSERT INTO vtiger_currencies (currencyid, currency_name, currency_code, currency_symbol) VALUES(?, ?, ?, ?)', array($adb->getUniqueID('vtiger_currencies'), 'CFA Franc BEAC', 'XAF', 'CFA'));
}
echo "<br>Added CFA Franc BCEAO and CFA Franc BEAC currencies";
$sql = "ALTER TABLE vtiger_loginhistory MODIFY user_name VARCHAR( 255 )";
Migration_Index_View::ExecuteQuery($sql, array());
$sql = "UPDATE vtiger_activitytype SET presence = '0' WHERE activitytype ='Mobile Call'";
Migration_Index_View::ExecuteQuery($sql, array());
//77 ends(Some function addGroupTaxTemplatesForQuotesAndPurchaseOrder)
//78 starts
//78 ends
//79 starts
Migration_Index_View::ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_shareduserinfo\n\t\t\t\t\t\t(userid INT(19) NOT NULL default 0, shareduserid INT(19) NOT NULL default 0,\n\t\t\t\t\t\tcolor VARCHAR(50), visible INT(19) default 1);", array());
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_mailscanner_rules ADD assigned_to INT(10), ADD cc VARCHAR(255), ADD bcc VARCHAR(255)', array());
$assignedToId = Users::getActiveAdminId();
Migration_Index_View::ExecuteQuery("UPDATE vtiger_mailscanner_rules SET assigned_to=?", array($assignedToId));
echo "<br> Adding assigned to, cc, bcc fields for mail scanner rules";
//Schema changes for vtiger_troubletickets hours & days column
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_troubletickets MODIFY hours decimal(25,8)', array());
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_troubletickets MODIFY days decimal(25,8)', array());
Migration_Index_View::ExecuteQuery("UPDATE vtiger_field SET defaultvalue=? WHERE tablename=? and fieldname=?", array('1', 'vtiger_pricebook', 'active'));
echo "<br> updated default value for pricebooks active";
$relationId = $adb->getUniqueID('vtiger_relatedlists');
$contactTabId = getTabid('Contacts');
$vendorTabId = getTabId('Vendors');
$actions = 'SELECT';
$query = 'SELECT max(sequence) as maxsequence FROM vtiger_relatedlists where tabid = ?';
$result = $adb->pquery($query, array($contactTabId));
$sequence = $adb->query_result($result, 0, 'maxsequence');
$query = 'INSERT INTO vtiger_relatedlists VALUES(?,?,?,?,?,?,?,?)';
Example #7
0
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">@import url("themes/softed/style.css");br { display: block; margin: 2px; }</style>
</head><body class=small style="font-size: 12px; margin: 2px; padding: 2px; background-color:#f7fff3; ">
<table width="100%" border=0><tr><td><span style='color:red;float:right;margin-right:30px;'><h2>Proud member of the <a href='http://corebos.org'>coreBOS</a> family!</h2></span></td></tr></table>
<hr style="height: 1px">
<?php 
// Turn on debugging level
$Vtiger_Utils_Log = true;
require_once 'include/utils/utils.php';
include_once 'vtlib/Vtiger/Module.php';
require 'modules/com_vtiger_workflow/VTEntityMethodManager.inc';
global $current_user, $adb;
set_time_limit(0);
ini_set('memory_limit', '1024M');
$current_user = new Users();
$current_user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
if (isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '') {
    $current_language = $_SESSION['authenticated_user_language'];
} else {
    if (!empty($current_user->language)) {
        $current_language = $current_user->language;
    } else {
        $current_language = $default_language;
    }
}
$app_strings = return_application_language($current_language);
$query_count = 0;
$success_query_count = 0;
$failure_query_count = 0;
$success_query_array = array();
$failure_query_array = array();
if (!defined('INSTALLATION_MODE')) {
    Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_salutationtype ADD COLUMN sortorderid INT(1)', array());
}
$summaryFields = array('Accounts' => array('assigned_user_id', 'email1', 'phone', 'bill_city', 'bill_country', 'website'), 'Contacts' => array('assigned_user_id', 'email', 'phone', 'mailingcity', 'mailingcountry'), 'Leads' => array('assigned_user_id', 'email', 'phone', 'city', 'country', 'leadsource'), 'HelpDesk' => array('assigned_user_id', 'ticketstatus', 'parent_id', 'ticketseverities', 'description'), 'Potentials' => array('assigned_user_id', 'amount', 'sales_stage', 'closingdate'), 'Project' => array('assigned_user_id', 'targetenddate'));
foreach ($summaryFields as $moduleName => $fieldsList) {
    $updateQuery = 'UPDATE vtiger_field SET summaryfield = 1
						WHERE fieldname IN (' . generateQuestionMarks($fieldsList) . ') AND tabid = ' . getTabid($moduleName);
    Migration_Index_View::ExecuteQuery($updateQuery, $fieldsList);
}
Migration_Index_View::ExecuteQuery('UPDATE vtiger_field SET defaultvalue=? WHERE tablename=? AND fieldname= ?', array('Active', 'vtiger_users', 'status'));
Migration_Index_View::ExecuteQuery('UPDATE vtiger_field SET defaultvalue=? WHERE tablename=? AND fieldname= ?', array('12', 'vtiger_users', 'hour_format'));
// Adding users field into all the available profiles, this is used in email templates
// when non-admin sends an email with users field in the template
$module = 'Users';
$user = new $module();
$activeAdmin = Users::getActiveAdminId();
$user->retrieve_entity_info($activeAdmin, $module);
$handler = vtws_getModuleHandlerFromName($module, $user);
$meta = $handler->getMeta();
$moduleFields = $meta->getModuleFields();
$userAccessbleFields = array();
$skipFields = array(98, 115, 116, 31, 32);
foreach ($moduleFields as $fieldName => $webserviceField) {
    if ($webserviceField->getFieldDataType() == 'string' || $webserviceField->getFieldDataType() == 'email' || $webserviceField->getFieldDataType() == 'phone') {
        if (!in_array($webserviceField->getUitype(), $skipFields) && $fieldName != 'asterisk_extension') {
            $userAccessbleFields[$webserviceField->getFieldId()] .= $fieldName;
        }
    }
}
$tabId = getTabid($module);
$query = 'SELECT profileid FROM vtiger_profile';
 /**
  * Update the value for relation
  * @param string $sourceModule Source module name
  * @param int $sourceRecord Source record
  */
 public function reloadValue($sourceModule, $sourceRecord)
 {
     $currentUser = vglobal('current_user');
     $user = new Users();
     vglobal('current_user', $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId()));
     vglobal('currentModule', $sourceModule);
     $db = PearDatabase::getInstance();
     $params = $this->get('field')->getFieldParams();
     $sourceRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecord, $sourceModule);
     $targetModel = Vtiger_RelationListView_Model::getInstance($sourceRecordModel, $params['module']);
     $fieldInfo = Vtiger_Functions::getModuleFieldInfoWithId($params['field']);
     $query = $targetModel->getRelationQuery();
     $explodedQuery = explode('FROM', $query, 2);
     $relationQuery = 'SELECT DISTINCT ' . $fieldInfo['columnname'] . ' FROM' . $explodedQuery[1] . ' AND ' . $fieldInfo['columnname'] . " <> ''";
     vglobal('current_user', $currentUser);
     $result = $db->query($relationQuery);
     $currentValue = self::COMMA;
     while ($value = $db->getSingleValue($result)) {
         $currentValue .= $value . self::COMMA;
     }
     $db->update($this->get('field')->get('table'), [$this->get('field')->get('column') => $currentValue], $sourceRecordModel->getEntity()->tab_name_index[$this->get('field')->get('table')] . ' = ?', [$sourceRecord]);
 }
Example #10
0
 /**
  * Function to get contents of this task
  * @param <Object> $entity
  * @return <Array> contents
  */
 public function getContents($entity, $entityCache = false)
 {
     if (!$this->contents) {
         global $adb, $current_user;
         $taskContents = array();
         $entityId = $entity->getId();
         $utils = new VTWorkflowUtils();
         $adminUser = $utils->adminUser();
         if (!$entityCache) {
             $entityCache = new VTEntityCache($adminUser);
         }
         $fromUserId = Users::getActiveAdminId();
         $entityOwnerId = $entity->get('assigned_user_id');
         if ($entityOwnerId) {
             list($moduleId, $fromUserId) = explode('x', $entityOwnerId);
         }
         $ownerEntity = $entityCache->forId($entityOwnerId);
         if ($ownerEntity->getModuleName() === 'Groups') {
             list($moduleId, $recordId) = vtws_getIdComponents($entityId);
             $fromUserId = Vtiger_Util_Helper::getCreator($recordId);
         }
         if ($this->fromEmail && !($ownerEntity->getModuleName() === 'Groups' && strpos($this->fromEmail, 'assigned_user_id : (Users) ') !== false)) {
             $et = new VTEmailRecipientsTemplate($this->fromEmail);
             $fromEmailDetails = $et->render($entityCache, $entityId);
             $con1 = strpos($fromEmailDetails, '&lt;');
             $con2 = strpos($fromEmailDetails, '&gt;');
             if ($con1 && $con2) {
                 list($fromName, $fromEmail) = explode('&lt;', $fromEmailDetails);
                 list($fromEmail, $rest) = explode('&gt;', $fromEmail);
             } else {
                 $fromName = "";
                 $fromEmail = $fromEmailDetails;
             }
         } else {
             $userObj = CRMEntity::getInstance('Users');
             $userObj->retrieveCurrentUserInfoFromFile($fromUserId);
             if ($userObj) {
                 $fromEmail = $userObj->email1;
                 $fromName = $userObj->user_name;
             } else {
                 $result = $adb->pquery('SELECT user_name, email1 FROM vtiger_users WHERE id = ?', array($fromUserId));
                 $fromEmail = $adb->query_result($result, 0, 'email1');
                 $fromName = $adb->query_result($result, 0, 'user_name');
             }
         }
         if (!$fromEmail) {
             $utils->revertUser();
             return false;
         }
         $taskContents['fromEmail'] = $fromEmail;
         $taskContents['fromName'] = $fromName;
         if ($entity->getModuleName() === 'Events') {
             $contactId = $entity->get('contact_id');
             if ($contactId) {
                 $contactIds = '';
                 list($wsId, $recordId) = explode('x', $entityId);
                 $webserviceObject = VtigerWebserviceObject::fromName($adb, 'Contacts');
                 $result = $adb->pquery('SELECT contactid FROM vtiger_cntactivityrel WHERE activityid = ?', array($recordId));
                 $numOfRows = $adb->num_rows($result);
                 for ($i = 0; $i < $numOfRows; $i++) {
                     $contactIds .= vtws_getId($webserviceObject->getEntityId(), $adb->query_result($result, $i, 'contactid')) . ',';
                 }
             }
             $entity->set('contact_id', trim($contactIds, ','));
             $entityCache->cache[$entityId] = $entity;
         }
         $et = new VTEmailRecipientsTemplate($this->recepient);
         $toEmail = $et->render($entityCache, $entityId);
         $ecct = new VTEmailRecipientsTemplate($this->emailcc);
         $ccEmail = $ecct->render($entityCache, $entityId);
         $ebcct = new VTEmailRecipientsTemplate($this->emailbcc);
         $bccEmail = $ebcct->render($entityCache, $entityId);
         if (strlen(trim($toEmail, " \t\n,")) == 0 && strlen(trim($ccEmail, " \t\n,")) == 0 && strlen(trim($bccEmail, " \t\n,")) == 0) {
             $utils->revertUser();
             return false;
         }
         $taskContents['toEmail'] = $toEmail;
         $taskContents['ccEmail'] = $ccEmail;
         $taskContents['bccEmail'] = $bccEmail;
         $st = new VTSimpleTemplate($this->subject);
         $taskContents['subject'] = $st->render($entityCache, $entityId);
         $ct = new VTSimpleTemplate($this->content);
         $taskContents['content'] = $ct->render($entityCache, $entityId);
         $this->contents = $taskContents;
         $utils->revertUser();
     }
     if (is_array($this->contents)) {
         $this->contents = Zend_Json::encode($this->contents);
     }
     return $this->contents;
 }
 /**
  * Create new Email record (and link to given record) including attachements
  */
 function __CreateNewEmail($mailrecord, $module, $linkfocus)
 {
     global $current_user, $adb;
     if (!$current_user) {
         $current_user = Users::getActiveAdminUser();
     }
     $assignedToId = $linkfocus->column_fields['assigned_user_id'];
     if (vtws_getOwnerType($assignedToId) == 'Groups') {
         $assignedToId = Users::getActiveAdminId();
     }
     $focus = new Emails();
     $focus->column_fields['parent_type'] = $module;
     $focus->column_fields['activitytype'] = 'Emails';
     $focus->column_fields['parent_id'] = "{$linkfocus->id}@-1|";
     $focus->column_fields['subject'] = $mailrecord->_subject;
     $focus->column_fields['description'] = $mailrecord->getBodyHTML();
     $focus->column_fields['assigned_user_id'] = $assignedToId;
     $focus->column_fields["date_start"] = date('Y-m-d', $mailrecord->_date);
     $focus->column_fields["time_start"] = gmdate("H:i:s");
     $focus->column_fields["email_flag"] = 'MAILSCANNER';
     $from = $mailrecord->_from[0];
     $to = $mailrecord->_to[0];
     $cc = !empty($mailrecord->_cc) ? implode(',', $mailrecord->_cc) : '';
     $bcc = !empty($mailrecord->_bcc) ? implode(',', $mailrecord->_bcc) : '';
     $flag = '';
     // 'SENT'/'SAVED'
     //emails field were restructured and to,bcc and cc field are JSON arrays
     $focus->column_fields['from_email'] = $from;
     $focus->column_fields['saved_toid'] = $to;
     $focus->column_fields['ccmail'] = $cc;
     $focus->column_fields['bccmail'] = $bcc;
     $focus->save('Emails');
     $emailid = $focus->id;
     $this->log("Created [{$focus->id}]: {$mailrecord->_subject} linked it to " . $linkfocus->id);
     // TODO: Handle attachments of the mail (inline/file)
     $this->__SaveAttachements($mailrecord, 'Emails', $focus);
     return $emailid;
 }
Example #12
0
 function getOwnerId()
 {
     require_once 'modules/Users/Users.php';
     $return = vtlib_purify($this->data['ownerid']);
     return empty($return) ? Users::getActiveAdminId() : $return;
 }
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_module_dashboard_widgets MODIFY data TEXT', array());
$linkIdResult = $adb->pquery('SELECT linkid FROM vtiger_links WHERE vtiger_links.linklabel="Notebook"', array());
$noteBookLinkId = $adb->query_result($linkIdResult, 0, 'linkid');
$result = $adb->pquery('SELECT vtiger_homestuff.stufftitle, vtiger_homestuff.userid, vtiger_notebook_contents.contents FROM
						vtiger_homestuff INNER JOIN vtiger_notebook_contents on vtiger_notebook_contents.notebookid = vtiger_homestuff.stuffid
						WHERE vtiger_homestuff.stufftype = ?', array('Notebook'));
for ($i = 0; $i < $adb->num_rows($result); $i++) {
    $noteBookTitle = $adb->query_result($result, $i, 'stufftitle');
    $userId = $adb->query_result($result, $i, 'userid');
    $noteBookContent = $adb->query_result($result, $i, 'contents');
    $query = 'INSERT INTO vtiger_module_dashboard_widgets(linkid, userid, filterid, title, data) VALUES(?,?,?,?,?)';
    $params = array($noteBookLinkId, $userId, 0, $noteBookTitle, $noteBookContent);
    Migration_Index_View::ExecuteQuery($query, $params);
}
//SalesPlatform.ru begin create default widgets for admin
$adminId = Users::getActiveAdminId();
$result = $adb->pquery('SELECT tabid FROM vtiger_tab WHERE vtiger_tab.name="Home"', array());
$moduleId = $adb->query_result($result, 0, 'tabid');
$result = $adb->pquery('SELECT linkid FROM vtiger_links WHERE vtiger_links.linklabel IN (?,?,?,?,?) ' . 'AND vtiger_links.linktype=? AND vtiger_links.tabid=?;', array("History", "Funnel", "Upcoming Activities", "Overdue Activities", "Tag Cloud", "DASHBOARDWIDGET", $moduleId));
for ($i = 0; $i < $adb->num_rows($result); $i++) {
    $linkId = $adb->query_result($result, $i, 'linkid');
    $query = 'INSERT INTO vtiger_module_dashboard_widgets(linkid, userid, filterid) VALUES(?,?,?);';
    $params = array($linkId, $adminId, 0);
    Migration_Index_View::ExecuteQuery($query, $params);
}
//SalesPlatform.ru end
$moduleInstance = Vtiger_Module::getInstance('ModComments');
$modCommentsUserId = Vtiger_Field::getInstance("userid", $moduleInstance);
$modCommentsReasonToEdit = Vtiger_Field::getInstance("reasontoedit", $moduleInstance);
if (!$modCommentsUserId) {
    $blockInstance = Vtiger_Block::getInstance('LBL_MODCOMMENTS_INFORMATION', $moduleInstance);