本文整理汇总了PHP中Users_Record_Model::getInstanceById方法的典型用法代码示例。如果您正苦于以下问题:PHP Users_Record_Model::getInstanceById方法的具体用法?PHP Users_Record_Model::getInstanceById怎么用?PHP Users_Record_Model::getInstanceById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users_Record_Model
的用法示例。
在下文中一共展示了Users_Record_Model::getInstanceById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCrmUserExtension
/**
* Returns crm user extension assigned to caller number or null if not assigned user for caller number
*
* @param string $callerNumber
* @return string
*/
private function getCrmUserExtension($callerNumber)
{
$crmUserExtension = null;
$callerUserInfo = PBXManager_Record_Model::lookUpRelatedWithNumber($callerNumber);
if ($callerUserInfo) {
$callerRecordModel = Vtiger_Record_Model::getInstanceById($callerUserInfo['id']);
$assignedUser = Users_Record_Model::getInstanceById($callerRecordModel->get('assigned_user_id'), "Users");
$crmUserExtension = $assignedUser->get('phone_crm_extension');
}
return $crmUserExtension;
}
示例2: getUsers
function getUsers($currentUserModel, $moduleName)
{
$users = $currentUserModel->getAccessibleUsersForModule($moduleName);
$userIds = array_keys($users);
$usersList = array();
$usersWSId = Mobile_WS_Utils::getEntityModuleWSId('Users');
foreach ($userIds as $userId) {
$userRecord = Users_Record_Model::getInstanceById($userId, 'Users');
$usersList[] = array('value' => $usersWSId . 'x' . $userId, 'label' => $userRecord->get("first_name") . ' ' . $userRecord->get('last_name'));
}
return $usersList;
}
示例3: createUserDirectory
public function createUserDirectory($params)
{
$adb = PearDatabase::getInstance();
$user = Users_Record_Model::getInstanceById($params['user'], 'Users');
$user_name = $user->get('user_name');
$path = '/' . $user_name . '/';
$dirHash = sha1($path);
$parent_dirid = 0;
$davStorageDir = vglobal('davStorageDir');
@mkdir($davStorageDir . $path);
//$adb->pquery('INSERT INTO vtiger_files_dir (name,path,parent_dirid,hash,mtime,userid) VALUES (?,?,?,?, NOW(),?);',
// array($user_name, $path, $parent_dirid, $dirHash, $params['user']));
}
示例4: process
public function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$userid = $request->get('record');
$userRecordModel = Users_Record_Model::getInstanceById($userid, $moduleName);
$viewer = $this->getViewer($request);
$usersList = $userRecordModel->getAll(true);
if (array_key_exists($userid, $usersList)) {
unset($usersList[$userid]);
}
$viewer->assign('USERID', $userid);
$viewer->assign('DELETE_USER_NAME', $userRecordModel->getName());
$viewer->assign('USER_LIST', $usersList);
$viewer->view('DeleteUser.tpl', $moduleName);
}
示例5: process
public function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
$imageId = $request->get('imageid');
$response = new Vtiger_Response();
if ($recordId) {
$recordModel = Users_Record_Model::getInstanceById($recordId, $moduleName);
$status = $recordModel->deleteImage($imageId);
if ($status) {
$response->setResult(array(vtranslate('LBL_IMAGE_DELETED_SUCCESSFULLY', $moduleName)));
}
} else {
$response->setError(vtranslate('LBL_IMAGE_NOT_DELETED', $moduleName));
}
$response->emit();
}
示例6: process
public function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$qualifiedModuleName = $request->getModule(false);
$recordId = $request->get('record');
$transferRecordId = $request->get('transfer_record');
$moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
$recordModel = Settings_Groups_Record_Model::getInstance($recordId);
$transferToOwner = Settings_Groups_Record_Model::getInstance($transferRecordId);
if (!$transferToOwner) {
$transferToOwner = Users_Record_Model::getInstanceById($transferRecordId, 'Users');
}
if ($recordModel && $transferToOwner) {
$recordModel->delete($transferToOwner);
}
$response = new Vtiger_Response();
$result = array('success' => true);
$response->setResult($result);
$response->emit();
}
示例7: Save
public function Save(Vtiger_Request $request)
{
$workflowId = $request->get('for_workflow');
if (!empty($workflowId)) {
$record = $request->get('task_id');
if ($record) {
$taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($record);
} else {
$workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId);
$taskRecordModel = Settings_Workflows_TaskRecord_Model::getCleanInstance($workflowModel, $request->get('taskType'));
}
$taskObject = $taskRecordModel->getTaskObject();
$taskObject->summary = $request->get("summary");
$active = $request->get("active");
if ($active == "true") {
$taskObject->active = true;
} else {
if ($active == "false") {
$taskObject->active = false;
}
}
$checkSelectDate = $request->get('check_select_date');
if (!empty($checkSelectDate)) {
$trigger = array('days' => ($request->get('select_date_direction') == 'after' ? 1 : -1) * (int) $request->get('select_date_days'), 'field' => $request->get('select_date_field'));
$taskObject->trigger = $trigger;
} else {
$taskObject->trigger = null;
}
$fieldNames = $taskObject->getFieldNames();
foreach ($fieldNames as $fieldName) {
if ($fieldName == 'field_value_mapping') {
$taskObject->{$fieldName} = $request->getRaw($fieldName);
} else {
$taskObject->{$fieldName} = $request->get($fieldName);
}
if ($fieldName == 'calendar_repeat_limit_date') {
$taskObject->{$fieldName} = DateTimeField::convertToDBFormat($request->get($fieldName));
}
}
$taskType = get_class($taskObject);
if ($taskType === 'VTCreateEntityTask') {
$relationModuleModel = Vtiger_Module_Model::getInstance($taskObject->entity_type);
$ownerFieldModels = $relationModuleModel->getFieldsByType('owner');
$fieldMapping = Zend_Json::decode($taskObject->field_value_mapping);
foreach ($fieldMapping as $key => $mappingInfo) {
if (array_key_exists($mappingInfo['fieldname'], $ownerFieldModels)) {
$userRecordModel = Users_Record_Model::getInstanceById($mappingInfo['value'], 'Users');
$ownerName = $userRecordModel->get('user_name');
if (!$ownerName) {
$groupRecordModel = Settings_Groups_Record_Model::getInstance($mappingInfo['value']);
$ownerName = $groupRecordModel->getName();
}
$fieldMapping[$key]['value'] = $ownerName;
}
}
$taskObject->field_value_mapping = Zend_Json::encode($fieldMapping);
}
$taskRecordModel->save();
$response = new Vtiger_Response();
$response->setResult(array('for_workflow' => $workflowId));
$response->emit();
}
}
示例8: icalendar_event_organizer
function icalendar_event_organizer($activity)
{
$adb = PearDatabase::getInstance();
$recordModel = Users_Record_Model::getInstanceById($activity['assigned_user_id'], 'Users');
$email = $recordModel->get('email1');
$organizer = 'mailto:' . $email;
$this->add_property('ORGANIZER', $organizer);
return true;
}
示例9: vtws_transferOwnership
function vtws_transferOwnership($ownerId, $newOwnerId, $delete = true)
{
$db = PearDatabase::getInstance();
//Updating the smcreatorid,smownerid, modifiedby in vtiger_crmentity
$sql = "UPDATE vtiger_crmentity SET smcreatorid=? WHERE smcreatorid=? AND setype<>?";
$db->pquery($sql, array($newOwnerId, $ownerId, 'ModComments'));
$sql = "UPDATE vtiger_crmentity SET smownerid=? WHERE smownerid=? AND setype<>?";
$db->pquery($sql, array($newOwnerId, $ownerId, 'ModComments'));
$sql = "update vtiger_crmentity set modifiedby=? where modifiedby=?";
$db->pquery($sql, array($newOwnerId, $ownerId));
//deleting from vtiger_tracker
if ($delete) {
$sql = "delete from vtiger_tracker where user_id=?";
$db->pquery($sql, array($ownerId));
}
//updating the vtiger_import_maps
$sql = "update vtiger_import_maps set assigned_user_id=? where assigned_user_id=?";
$db->pquery($sql, array($newOwnerId, $ownerId));
if (Vtiger_Utils::CheckTable('vtiger_customerportal_prefs')) {
$query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
$params = array($newOwnerId, 'defaultassignee', $ownerId);
$db->pquery($query, $params);
$query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
$params = array($newOwnerId, 'userid', $ownerId);
$db->pquery($query, $params);
}
//delete from vtiger_homestuff
if ($delete) {
$sql = "delete from vtiger_homestuff where userid=?";
$db->pquery($sql, array($ownerId));
}
//delete from vtiger_users to vtiger_role vtiger_table
if ($delete) {
$sql = "delete from vtiger_users2group where userid=?";
$db->pquery($sql, array($ownerId));
}
$sql = "select tabid,fieldname,tablename,columnname from vtiger_field left join " . "vtiger_fieldmodulerel on vtiger_field.fieldid=vtiger_fieldmodulerel.fieldid where uitype " . "in (52,53,77,101) or (uitype=10 and relmodule='Users')";
$result = $db->pquery($sql, array());
$it = new SqlResultIterator($db, $result);
$columnList = array();
foreach ($it as $row) {
$column = $row->tablename . '.' . $row->columnname;
if (!in_array($column, $columnList)) {
$columnList[] = $column;
if ($row->columnname == 'smcreatorid' || $row->columnname == 'smownerid') {
$sql = "update {$row->tablename} set {$row->columnname}=? where {$row->columnname}=? and setype<>?";
$db->pquery($sql, array($newOwnerId, $ownerId, 'ModComments'));
} else {
$sql = "update {$row->tablename} set {$row->columnname}=? where {$row->columnname}=?";
$db->pquery($sql, array($newOwnerId, $ownerId));
}
}
}
//update workflow tasks Assigned User from Deleted User to Transfer User
$newOwnerModel = Users_Record_Model::getInstanceById($newOwnerId, 'Users');
$ownerModel = Users_Record_Model::getInstanceById($ownerId, 'Users');
vtws_transferOwnershipForWorkflowTasks($ownerModel, $newOwnerModel);
vtws_updateWebformsRoundrobinUsersLists($ownerId, $newOwnerId);
}
示例10: getOwnerName
/**
* Function to get Owner name for ownerId
* @param <Integer> $ownerId
* @return <String> $ownerName
*/
public static function getOwnerName($ownerId) {
$cache = Vtiger_Cache::getInstance();
if ($cache->hasOwnerDbName($ownerId)) {
return $cache->getOwnerDbName($ownerId);
}
$ownerModel = Users_Record_Model::getInstanceById($ownerId, 'Users');
$userName = $ownerModel->get('user_name');
$ownerName = '';
if ($userName) {
$ownerName = $userName;
} else {
$ownerModel = Settings_Groups_Record_Model::getInstance($ownerId);
if(!empty($ownerModel)) {
$ownerName = $ownerModel->getName();
}
}
if(!empty($ownerName)) {
$cache->setOwnerDbName($ownerId, $ownerName);
}
return $ownerName;
}
示例11: restoreUser
public function restoreUser(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$record = $request->get('userid');
$recordModel = Users_Record_Model::getInstanceById($record, $moduleName);
$recordModel->set('status', 'Active');
$recordModel->set('id', $record);
$recordModel->set('mode', 'edit');
$recordModel->set('user_hash', $recordModel->getUserHash());
$recordModel->save();
$db = PearDatabase::getInstance();
$db->pquery("UPDATE vtiger_users SET deleted=? WHERE id=?", array(0, $record));
$userModuleModel = Users_Module_Model::getInstance($moduleName);
$listViewUrl = $userModuleModel->getListViewUrl();
$response = new Vtiger_Response();
$response->setResult(array('message' => vtranslate('LBL_USER_RESTORED_SUCCESSFULLY', $moduleName), 'listViewUrl' => $listViewUrl));
$response->emit();
}
示例12: getModifiedBy
function getModifiedBy()
{
$changeUserId = $this->get('whodid');
return Users_Record_Model::getInstanceById($changeUserId, 'Users');
}
示例13: transferOwnership
protected function transferOwnership($transferToGroup)
{
$db = PearDatabase::getInstance();
$groupId = $this->getId();
$transferGroupId = $transferToGroup->getId();
$query = 'UPDATE vtiger_crmentity SET smownerid=? WHERE smownerid=?';
$params = array($transferGroupId, $groupId);
$db->pquery($query, $params);
if (Vtiger_Utils::CheckTable('vtiger_customerportal_prefs')) {
$query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
$params = array($transferGroupId, 'defaultassignee', $groupId);
$db->pquery($query, $params);
$query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
$params = array($transferGroupId, 'userid', $groupId);
$db->pquery($query, $params);
}
//update workflow tasks Assigned User from Deleted Group to Transfer Owner
$newOwnerModel = $this->getInstance($transferGroupId);
if (!$newOwnerModel) {
$newOwnerModel = Users_Record_Model::getInstanceById($transferGroupId, 'Users');
}
$ownerModel = $this->getInstance($groupId);
vtws_transferOwnershipForWorkflowTasks($ownerModel, $newOwnerModel);
vtws_updateWebformsRoundrobinUsersLists($groupId, $transferGroupId);
}
示例14: emailEdit
function emailEdit($request)
{
$viewer = $this->getViewer($request);
$this->emailActionsData($request);
$recordId = $request->get('record');
$moduleName = $request->getModule();
$viewer = $this->getViewer($request);
if (!$this->record) {
$this->record = Vtiger_DetailView_Model::getInstance($moduleName, $recordId);
}
$recordModel = $this->record->getRecord();
$TO = Zend_Json::decode(html_entity_decode($recordModel->get('saved_toid')));
$CC = Zend_Json::decode(html_entity_decode($recordModel->get('ccmail')));
$BCC = Zend_Json::decode(html_entity_decode($recordModel->get('bccmail')));
$parentIds = explode('|', $recordModel->get('parent_id'));
$toMailInfo = $toMailNamesList = array();
foreach ($parentIds as $index => $parentFieldId) {
if (empty($parentFieldId)) {
continue;
}
$parentIdComponents = explode('@', $parentFieldId);
$parentId = $parentIdComponents[0];
if ($parentIdComponents[1] === '-1') {
$parentRecordModel = Users_Record_Model::getInstanceById($parentId, 'Users');
} else {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId);
}
$emailFields = array_keys($parentRecordModel->getModule()->getFieldsByType('email'));
foreach ($emailFields as $emailField) {
$emailValue = $parentRecordModel->get($emailField);
if (in_array($emailValue, $TO)) {
//expecting parent ids and to will be same order
$toMailInfo[$parentId][] = $emailValue;
//SalesPlatform.ru begin
$toMailNamesList[$parentId][] = array('label' => html_entity_decode($parentRecordModel->getName(), ENT_COMPAT | ENT_HTML401, 'UTF-8'), 'value' => $emailValue);
//$toMailNamesList[$parentId][] = array('label' => $parentRecordModel->getName(), 'value' => $emailValue);
//SalesPlatform.ru end
}
}
}
$viewer->assign('TO', $TO);
$viewer->assign('TOMAIL_INFO', $toMailInfo);
$viewer->assign('TOMAIL_NAMES_LIST', $toMailNamesList);
$viewer->assign('CC', implode(',', $CC));
$viewer->assign('BCC', implode(',', $BCC));
$viewer->assign('RECORDID', $request->get('record'));
$viewer->assign('RELATED_LOAD', true);
$viewer->assign('EMAIL_MODE', 'edit');
echo $viewer->view('ComposeEmailForm.tpl', $moduleName, true);
}
示例15: checkImportStatus
function checkImportStatus(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$user = Users_Record_Model::getCurrentUserModel();
$mode = $request->getMode();
// Check if import on the module is locked
$lockInfo = Import_Lock_Action::isLockedForModule($moduleName);
if ($lockInfo != null) {
$lockedBy = $lockInfo['userid'];
if ($user->id != $lockedBy && !$user->isAdminUser()) {
Import_Utils_Helper::showImportLockedError($lockInfo);
exit;
} else {
if ($mode == 'continueImport' && $user->id == $lockedBy) {
$importController = new Import_Main_View($request, $user);
$importController->triggerImport(true);
} else {
$importInfo = Import_Queue_Action::getImportInfoById($lockInfo['importid']);
$lockOwner = $user;
if ($user->id != $lockedBy) {
$lockOwner = Users_Record_Model::getInstanceById($lockInfo['userid'], 'Users');
}
Import_Main_View::showImportStatus($importInfo, $lockOwner);
}
exit;
}
}
if (Import_Utils_Helper::isUserImportBlocked($user)) {
$importInfo = Import_Queue_Action::getUserCurrentImportInfo($user);
if ($importInfo != null) {
Import_Main_View::showImportStatus($importInfo, $user);
exit;
} else {
Import_Utils_Helper::showImportTableBlockedError($moduleName, $user);
exit;
}
}
Import_Utils_Helper::clearUserImportInfo($user);
}