本文整理汇总了PHP中Vtiger_Functions::getArrayFromValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Functions::getArrayFromValue方法的具体用法?PHP Vtiger_Functions::getArrayFromValue怎么用?PHP Vtiger_Functions::getArrayFromValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Functions
的用法示例。
在下文中一共展示了Vtiger_Functions::getArrayFromValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDisplayValue
/**
* Function to get the Display Value, for the current field type with given DB Insert Value
* @param <Object> $value
* @return <Object>
*/
public function getDisplayValue($values)
{
if ($values == '')
return;
foreach (Vtiger_Functions::getArrayFromValue($values) as $value) {
if (Vtiger_Owner_UIType::getOwnerType($value) === 'User') {
$userModel = Users_Record_Model::getCleanInstance('Users');
$userModel->set('id', $value);
$detailViewUrl = $userModel->getDetailViewUrl();
$currentUser = Users_Record_Model::getCurrentUserModel();
if ($currentUser->isAdminUser()) {
$displayvalue[] = '<a href=' . $detailViewUrl . '>' . rtrim(getOwnerName($value)) . '</a>';
} else {
$displayvalue[] = rtrim(getOwnerName($value));
}
} else {
$currentUser = Users_Record_Model::getCurrentUserModel();
if ($currentUser->isAdminUser()) {
$recordModel = new Settings_Groups_Record_Model();
$recordModel->set('groupid', $value);
$detailViewUrl = $recordModel->getDetailViewUrl();
$displayvalue[] = '<a href=' . $detailViewUrl . '>' . rtrim(getOwnerName($value)) . '</a>';
} else {
$displayvalue[] = rtrim(getOwnerName($value));
}
}
}
$displayvalue = implode(', ', $displayvalue);
return $displayvalue;
}
示例2: handleEvent
function handleEvent($eventName, $entityData)
{
global $adb, $shared_owners;
if ($eventName == 'vtiger.entity.aftersave.final' && $shared_owners == true) {
$moduleName = $entityData->getModuleName();
$recordId = $entityData->getId();
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
$shownerids = $entityData->get('shownerid');
$inheritsharing = $entityData->get('inheritsharing');
if (array_key_exists("shownerid", $delta)) {
$usersUpadated = TRUE;
$oldValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['oldValue']);
$currentValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['currentValue']);
$addUsers = $currentValue;
$removeUser = array_diff($oldValue, $currentValue);
} else {
$usersUpadated = FALSE;
}
$updateRelatedRecords = TRUE;
if (array_key_exists("inheritsharing", $delta)) {
$inheritsharing = $delta['inheritsharing']['currentValue'];
$inheritsharingUpdated = TRUE;
if ('0' === $delta['inheritsharing']['currentValue']) {
$updateRelatedRecords = FALSE;
$removedShared = TRUE;
}
} else {
$inheritsharingUpdated = FALSE;
$inheritsharing = $entityData->get('inheritsharing');
if (!$inheritsharing) {
$updateRelatedRecords = FALSE;
}
}
if ($usersUpadated || $inheritsharingUpdated) {
if ($updateRelatedRecords) {
Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUsers, $removeUser, $moduleName);
}
if ($removedShared) {
Users_Privileges_Model::setSharedOwnerRecursively($recordId, [], $addUsers, $moduleName);
}
}
}
if ($eventName == 'vtiger.entity.link.after' && $shared_owners == true && Vtiger_Processes_Model::getConfig('sales', 'popup', 'update_shared_permissions') == 'true') {
$destinationModule = array('Products', 'Services');
if ($entityData['sourceModule'] == 'Potentials' && in_array($entityData['destinationModule'], $destinationModule)) {
$adb = PearDatabase::getInstance();
$result1 = $adb->pquery('SELECT smownerid, shownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['destinationRecordId']));
$result2 = $adb->pquery('SELECT shownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['sourceRecordId']));
if ($adb->num_rows($result1) == 1 && $adb->num_rows($result2) == 1) {
$smownerid = $adb->query_result($result1, 0, 'smownerid') . ',' . $adb->query_result($result1, 0, 'shownerid');
$shownerid = $adb->query_result($result2, 0, 'shownerid') . ',' . trim($smownerid, ',');
$adb->pquery("UPDATE vtiger_crmentity SET shownerid = ? WHERE crmid = ?;", [trim($shownerid, ','), $entityData['sourceRecordId']]);
}
}
}
}
示例3: handleEvent
function handleEvent($eventName, $entityData)
{
if ($eventName == 'vtiger.entity.aftersave.final' && vglobal('shared_owners') == true) {
$moduleName = $entityData->getModuleName();
$recordId = $entityData->getId();
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
if (array_key_exists('assigned_user_id', $delta)) {
$usersUpadated = TRUE;
$oldValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['oldValue']);
$currentValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['currentValue']);
$addUsers = $currentValue;
$removeUser = array_diff($oldValue, $currentValue);
Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUsers, $removeUser, $moduleName);
}
}
}
示例4: getDisplayValue
/**
* Function to get the Display Value, for the current field type with given DB Insert Value
* @param <Object> $value
* @return <Object>
*/
public function getDisplayValue($values)
{
if ($values == NULL) {
return;
}
foreach (Vtiger_Functions::getArrayFromValue($values) as $value) {
$userModel = Users_Record_Model::getCleanInstance('Users');
$userModel->set('id', $value);
$detailViewUrl = $userModel->getDetailViewUrl();
$currentUser = Users_Record_Model::getCurrentUserModel();
if (!$currentUser->isAdminUser()) {
return getOwnerName($value);
}
$displayvalue[] = "<a href=" . $detailViewUrl . ">" . getOwnerName($value) . "</a> ";
}
$displayvalue = implode(',', $displayvalue);
return $displayvalue;
}
示例5: handleEvent
function handleEvent($eventName, $entityData)
{
if ($eventName == 'vtiger.entity.aftersave.final' && vglobal('shared_owners') == true) {
$moduleName = $entityData->getModuleName();
$recordId = $entityData->getId();
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
if (array_key_exists('assigned_user_id', $delta)) {
$usersUpadated = TRUE;
$oldValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['oldValue']);
$currentValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['currentValue']);
$addUsers = $currentValue;
$removeUser = array_diff($oldValue, $currentValue);
Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUsers, $removeUser, $moduleName);
}
}
if ($eventName == 'vtiger.entity.link.after' && vglobal('shared_owners') == true && Vtiger_Processes_Model::getConfig('sales', 'popup', 'update_shared_permissions') == 'true') {
$destinationModule = ['Products', 'Services'];
if ($entityData['sourceModule'] == 'Potentials' && in_array($entityData['destinationModule'], $destinationModule)) {
$db = PearDatabase::getInstance();
$sourceRecordId =& $entityData['sourceRecordId'];
$destinationRecordId =& $entityData['destinationRecordId'];
$recordMetaData = Vtiger_Functions::getCRMRecordMetadata($sourceRecordId);
$shownerIds = Vtiger_SharedOwner_UIType::getSharedOwners($sourceRecordId, $entityData['sourceModule']);
$shownerIds[] = $recordMetaData['smownerid'];
$shownerIds = array_unique($shownerIds);
$usersExist = [];
$shownersTable = Vtiger_SharedOwner_UIType::getShownerTable($entityData['destinationModule']);
$result = $db->pquery('SELECT crmid, userid FROM ' . $shownersTable . ' WHERE userid IN(' . implode(',', $shownerIds) . ') AND crmid = ?', [$destinationRecordId]);
while ($row = $db->getRow($result)) {
$usersExist[$row['crmid']][$row['userid']] = true;
}
foreach ($shownerIds as $userId) {
if (!isset($usersExist[$destinationRecordId][$userId])) {
$db->insert($shownersTable, ['crmid' => $destinationRecordId, 'userid' => $userId]);
}
}
}
}
}
示例6: handleEvent
function handleEvent($eventName, $data)
{
global $adb, $shared_owners;
if ($eventName == 'vtiger.entity.aftersave.final' && $shared_owners == true) {
$moduleName = $data->getModuleName();
$recordId = $data->getId();
if ($data->get('inheritsharing') != NULL && $data->get('inheritsharing') !== 0) {
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
if (array_key_exists("shownerid", $delta)) {
$oldValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['oldValue']);
$currentValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['currentValue']);
if (count($oldValue) == 0) {
$addUser = $currentValue;
$removeUser = array();
} else {
$removeUser = array_diff($oldValue, $currentValue);
$addUser = array_diff($currentValue, $oldValue);
}
Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUser, $removeUser, $moduleName);
}
}
}
if ($eventName == 'vtiger.entity.link.after') {
$destinationModule = array('Products', 'Services');
if ($entityData['sourceModule'] == 'Potentials' && in_array($entityData['destinationModule'], $destinationModule)) {
global $adb;
$result1 = $adb->pquery('SELECT smownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['destinationRecordId']));
$result2 = $adb->pquery('SELECT smownerid,shownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['sourceRecordId']));
if ($adb->num_rows($result1) == 1 && $adb->num_rows($result2) == 1) {
$smownerid = $adb->query_result($result1, 0, 'smownerid');
$shownerid = $adb->query_result($result2, 0, 'shownerid') . ',' . $smownerid;
if ($smownerid != $adb->query_result($result2, 0, 'smownerid')) {
$adb->pquery("UPDATE vtiger_crmentity SET shownerid = ? WHERE crmid = ?;", array(rtrim($shownerid, ','), $entityData['sourceRecordId']));
}
}
}
}
}
示例7: setSharedOwnerRecursively
/**
* Function to get set Shared Owner Recursively
*/
public function setSharedOwnerRecursively($recordId, $addUser, $removeUser, $moduleName)
{
$log = vglobal('log');
$db = PearDatabase::getInstance();
$log->info("Entering Into fn setSharedOwnerRecursively( $recordId , $addUser, $removeUser, $moduleName )");
$records = self::getSharedRecordsRecursively($recordId, $moduleName);
$sqlRecords = implode("','", $records);
$result = $db->pquery("SELECT crmid, shownerid FROM vtiger_crmentity WHERE crmid in ('$sqlRecords');");
$sqlUpdate = '';
for ($i = 0; $i < $db->num_rows($result); $i++) {
$crmid = $db->query_result_raw($result, $i, 'crmid');
$shownerid = $db->query_result_raw($result, $i, 'shownerid');
$shownerIdArray = Vtiger_Functions::getArrayFromValue($shownerid);
foreach ($shownerIdArray as $key => $user) {
if (in_array($user, $removeUser)) {
unset($shownerIdArray[$key]);
}
}
$newArray = array_merge($shownerIdArray, $addUser);
$db->query("UPDATE vtiger_crmentity SET shownerid='" . implode(",", $newArray) . "' WHERE crmid='$crmid';");
}
$log->info("Exiting fn setSharedOwnerRecursively()");
}