public static function render($userInputObject, $user) { global $list_max_entries_per_page; $adb = PearDatabase::getInstance(); $viewer = new Import_UI_Viewer(); $ownerId = $userInputObject->get('foruser'); $owner = new Users(); $owner->id = $ownerId; $owner->retrieve_entity_info($ownerId, 'Users'); if (!is_admin($user) && $user->id != $owner->id) { $viewer->display('OperationNotPermitted.tpl', 'Vtiger'); exit; } $userDBTableName = Import_Utils::getDbTableName($owner); $moduleName = $userInputObject->get('module'); $moduleMeta = self::getModuleMeta($moduleName, $user); $result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL'); $noOfRecords = $adb->num_rows($result); $importedRecordIds = array(); for ($i = 0; $i < $noOfRecords; ++$i) { $importedRecordIds[] = $adb->query_result($result, $i, 'recordid'); } if (count($importedRecordIds) == 0) { $importedRecordIds[] = 0; } $focus = CRMEntity::getInstance($moduleName); $queryGenerator = new QueryGenerator($moduleName, $user); $customView = new CustomView($moduleName); $viewId = $customView->getViewIdByName('All', $moduleName); $queryGenerator->initForCustomViewById($viewId); $list_query = $queryGenerator->getQuery(); // Fetch only last imported records $list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')'; if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) { $count_result = $adb->query(mkCountQuery($list_query)); $noofrows = $adb->query_result($count_result, 0, "count"); } else { $noofrows = null; } $start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false); $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limit_start_rec = ($start - 1) * $list_max_entries_per_page; $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows); $viewer->assign('recordListRange', $recordListRangeMsg); $controller = new ListViewController($adb, $user, $queryGenerator); $listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true); $listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true); $viewer->assign('CURRENT_PAGE', $start); $viewer->assign('LISTHEADER', $listview_header); $viewer->assign('LISTENTITY', $listview_entries); $viewer->assign('FOR_MODULE', $moduleName); $viewer->assign('FOR_USER', $ownerId); $isAjax = $userInputObject->get('ajax'); if (!empty($isAjax)) { echo $viewer->fetch('ListViewEntries.tpl'); } else { $viewer->display('ImportListView.tpl'); } }
/** * * @param WebserviceId $id * @param String $oldPassword * @param String $newPassword * @param String $confirmPassword * @param Users $user * */ function vtws_changePassword($id, $oldPassword, $newPassword, $confirmPassword, $user) { vtws_preserveGlobal('current_user', $user); $idComponents = vtws_getIdComponents($id); if ($idComponents[1] == $user->id || is_admin($user)) { $newUser = new Users(); $newUser->retrieve_entity_info($idComponents[1], 'Users'); if (!is_admin($user)) { if (empty($oldPassword)) { throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD)); } if (!$user->verifyPassword($oldPassword)) { throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD)); } } if (strcmp($newPassword, $confirmPassword) === 0) { $success = $newUser->change_password($oldPassword, $newPassword); $error = $newUser->db->hasFailedTransaction(); if ($error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR)); } if (!$success) { throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE)); } } else { throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE)); } VTWS_PreserveGlobal::flush(); return array('message' => 'Changed password successfully'); } }
/** * Function creates default user's Role, Profiles */ public function setDefaultUsersAccess() { $adminPassword = $_SESSION['installation_info']['admin_password']; $this->db->pquery('update vtiger_users set email1=? where id=1', array($_SESSION['installation_info']['admin_email'])); $newUser = new Users(); $newUser->retrieve_entity_info(1, 'Users'); $newUser->change_password('admin', $adminPassword, false); require_once 'modules/Users/CreateUserPrivilegeFile.php'; createUserPrivilegesfile(1); }
/** Creates a file with all the organization default sharing permissions and custom sharing permissins specific for the specified user. In this file the information of the other users whose data is shared with the specified user is stored. * @param $userid -- user id:: Type integer * @returns sharing_privileges_userid file under the user_privileges directory */ function createUserSharingPrivilegesfile($userid) { global $adb, $root_directory; checkFileAccessForInclusion('user_privileges/user_privileges_' . $userid . '.php'); require 'user_privileges/user_privileges_' . $userid . '.php'; $handle = @fopen($root_directory . 'user_privileges/sharing_privileges_' . $userid . '.php', "w+"); if ($handle) { $newbuf = ''; $newbuf .= "<?php\n\n"; $newbuf .= "\n"; $newbuf .= "//This is the sharing access privilege file\n"; $user_focus = new Users(); $user_focus->retrieve_entity_info($userid, "Users"); if ($user_focus->is_admin == 'on') { $newbuf .= "\n"; $newbuf .= "?>"; fputs($handle, $newbuf); fclose($handle); return; } else { //Constructig the Default Org Share Array $def_org_share = getAllDefaultSharingAction(); $newbuf .= "\$defaultOrgSharingPermission=" . constructArray($def_org_share) . ";\n"; $newbuf .= "\n"; //Constructing the Related Module Sharing Array $relModSharArr = array(); $query = "select * from vtiger_datashare_relatedmodules"; $result = $adb->pquery($query, array()); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $parTabId = $adb->query_result($result, $i, 'tabid'); $relTabId = $adb->query_result($result, $i, 'relatedto_tabid'); if (is_array($relModSharArr[$relTabId])) { $temArr = $relModSharArr[$relTabId]; $temArr[] = $parTabId; } else { $temArr = array(); $temArr[] = $parTabId; } $relModSharArr[$relTabId] = $temArr; } $newbuf .= "\$related_module_share=" . constructTwoDimensionalValueArray($relModSharArr) . ";\n\n"; //Constructing Lead Sharing Rules $lead_share_per_array = getUserModuleSharingObjects("Leads", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $lead_share_read_per = $lead_share_per_array['read']; $lead_share_write_per = $lead_share_per_array['write']; $lead_sharingrule_members = $lead_share_per_array['sharingrules']; $newbuf .= "\$Leads_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($lead_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($lead_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Leads_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($lead_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($lead_share_write_per['GROUP']) . ");\n\n"; //Constructing the Lead Email Related Module Sharing Array $lead_related_email = getRelatedModuleSharingArray("Leads", "Emails", $lead_sharingrule_members, $lead_share_read_per, $lead_share_write_per, $def_org_share); $lead_email_share_read_per = $lead_related_email['read']; $lead_email_share_write_per = $lead_related_email['write']; $newbuf .= "\$Leads_Emails_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($lead_email_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($lead_email_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Leads_Emails_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($lead_email_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($lead_email_share_write_per['GROUP']) . ");\n\n"; //Constructing Account Sharing Rules $account_share_per_array = getUserModuleSharingObjects("Accounts", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $account_share_read_per = $account_share_per_array['read']; $account_share_write_per = $account_share_per_array['write']; $account_sharingrule_members = $account_share_per_array['sharingrules']; /*echo '<pre>'; print_r($account_share_read_per['GROUP']); echo '</pre>';*/ $newbuf .= "\$Accounts_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($account_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($account_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Accounts_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($account_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($account_share_write_per['GROUP']) . ");\n\n"; //Constructing Contact Sharing Rules $newbuf .= "\$Contacts_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($account_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($account_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Contacts_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($account_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($account_share_write_per['GROUP']) . ");\n\n"; //Constructing the Account Potential Related Module Sharing Array $acct_related_pot = getRelatedModuleSharingArray("Accounts", "Potentials", $account_sharingrule_members, $account_share_read_per, $account_share_write_per, $def_org_share); $acc_pot_share_read_per = $acct_related_pot['read']; $acc_pot_share_write_per = $acct_related_pot['write']; $newbuf .= "\$Accounts_Potentials_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_pot_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_pot_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Accounts_Potentials_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_pot_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_pot_share_write_per['GROUP']) . ");\n\n"; //Constructing the Account Ticket Related Module Sharing Array $acct_related_tkt = getRelatedModuleSharingArray("Accounts", "HelpDesk", $account_sharingrule_members, $account_share_read_per, $account_share_write_per, $def_org_share); $acc_tkt_share_read_per = $acct_related_tkt['read']; $acc_tkt_share_write_per = $acct_related_tkt['write']; $newbuf .= "\$Accounts_HelpDesk_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_tkt_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_tkt_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Accounts_HelpDesk_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_tkt_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_tkt_share_write_per['GROUP']) . ");\n\n"; //Constructing the Account Email Related Module Sharing Array $acct_related_email = getRelatedModuleSharingArray("Accounts", "Emails", $account_sharingrule_members, $account_share_read_per, $account_share_write_per, $def_org_share); $acc_email_share_read_per = $acct_related_email['read']; $acc_email_share_write_per = $acct_related_email['write']; $newbuf .= "\$Accounts_Emails_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_email_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_email_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Accounts_Emails_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_email_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_email_share_write_per['GROUP']) . ");\n\n"; //Constructing the Account Quote Related Module Sharing Array $acct_related_qt = getRelatedModuleSharingArray("Accounts", "Quotes", $account_sharingrule_members, $account_share_read_per, $account_share_write_per, $def_org_share); $acc_qt_share_read_per = $acct_related_qt['read']; $acc_qt_share_write_per = $acct_related_qt['write']; $newbuf .= "\$Accounts_Quotes_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_qt_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_qt_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Accounts_Quotes_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_qt_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_qt_share_write_per['GROUP']) . ");\n\n"; //Constructing the Account SalesOrder Related Module Sharing Array $acct_related_so = getRelatedModuleSharingArray("Accounts", "SalesOrder", $account_sharingrule_members, $account_share_read_per, $account_share_write_per, $def_org_share); $acc_so_share_read_per = $acct_related_so['read']; $acc_so_share_write_per = $acct_related_so['write']; $newbuf .= "\$Accounts_SalesOrder_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_so_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_so_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Accounts_SalesOrder_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_so_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_so_share_write_per['GROUP']) . ");\n\n"; //Constructing the Account Invoice Related Module Sharing Array $acct_related_inv = getRelatedModuleSharingArray("Accounts", "Invoice", $account_sharingrule_members, $account_share_read_per, $account_share_write_per, $def_org_share); $acc_inv_share_read_per = $acct_related_inv['read']; $acc_inv_share_write_per = $acct_related_inv['write']; $newbuf .= "\$Accounts_Invoice_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_inv_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_inv_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Accounts_Invoice_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($acc_inv_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($acc_inv_share_write_per['GROUP']) . ");\n\n"; //Constructing Potential Sharing Rules $pot_share_per_array = getUserModuleSharingObjects("Potentials", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $pot_share_read_per = $pot_share_per_array['read']; $pot_share_write_per = $pot_share_per_array['write']; $pot_sharingrule_members = $pot_share_per_array['sharingrules']; $newbuf .= "\$Potentials_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($pot_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($pot_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Potentials_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($pot_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($pot_share_write_per['GROUP']) . ");\n\n"; //Constructing the Potential Quotes Related Module Sharing Array $pot_related_qt = getRelatedModuleSharingArray("Potentials", "Quotes", $pot_sharingrule_members, $pot_share_read_per, $pot_share_write_per, $def_org_share); $pot_qt_share_read_per = $pot_related_qt['read']; $pot_qt_share_write_per = $pot_related_qt['write']; $newbuf .= "\$Potentials_Quotes_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($pot_qt_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($pot_qt_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Potentials_Quotes_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($pot_qt_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($pot_qt_share_write_per['GROUP']) . ");\n\n"; //Constructing the Potential SalesOrder Related Module Sharing Array $pot_related_inv = getRelatedModuleSharingArray("Potentials", "SalesOrder", $pot_sharingrule_members, $pot_share_read_per, $pot_share_write_per, $def_org_share); $pot_inv_share_read_per = $pot_related_inv['read']; $pot_inv_share_write_per = $pot_related_inv['write']; $newbuf .= "\$Potentials_SalesOrder_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($pot_inv_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($pot_inv_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Potentials_SalesOrder_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($pot_inv_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($pot_inv_share_write_per['GROUP']) . ");\n\n"; //Constructing HelpDesk Sharing Rules $hd_share_per_array = getUserModuleSharingObjects("HelpDesk", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $hd_share_read_per = $hd_share_per_array['read']; $hd_share_write_per = $hd_share_per_array['write']; $newbuf .= "\$HelpDesk_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($hd_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($hd_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$HelpDesk_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($hd_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($hd_share_write_per['GROUP']) . ");\n\n"; //Constructing Emails Sharing Rules $email_share_per_array = getUserModuleSharingObjects("Emails", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $email_share_read_per = $email_share_per_array['read']; $email_share_write_per = $email_share_per_array['write']; $newbuf .= "\$Emails_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($email_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($email_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Emails_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($email_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($email_share_write_per['GROUP']) . ");\n\n"; //Constructing Campaigns Sharing Rules $campaign_share_per_array = getUserModuleSharingObjects("Campaigns", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $campaign_share_read_per = $campaign_share_per_array['read']; $campaign_share_write_per = $campaign_share_per_array['write']; $newbuf .= "\$Campaigns_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($campaign_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($campaign_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Campaigns_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($campaign_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($campaign_share_write_per['GROUP']) . ");\n\n"; //Constructing Quotes Sharing Rules $quotes_share_per_array = getUserModuleSharingObjects("Quotes", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $quotes_share_read_per = $quotes_share_per_array['read']; $quotes_share_write_per = $quotes_share_per_array['write']; $quotes_sharingrule_members = $quotes_share_per_array['sharingrules']; $newbuf .= "\$Quotes_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($quotes_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($quotes_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Quotes_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($quotes_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($quotes_share_write_per['GROUP']) . ");\n\n"; //Constructing the Quote SalesOrder Related Module Sharing Array $qt_related_so = getRelatedModuleSharingArray("Quotes", "SalesOrder", $quotes_sharingrule_members, $quotes_share_read_per, $quotes_share_write_per, $def_org_share); $qt_so_share_read_per = $qt_related_so['read']; $qt_so_share_write_per = $qt_related_so['write']; $newbuf .= "\$Quotes_SalesOrder_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($qt_so_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($qt_so_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Quotes_SalesOrder_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($qt_so_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($qt_so_share_write_per['GROUP']) . ");\n\n"; //Constructing Orders Sharing Rules $po_share_per_array = getUserModuleSharingObjects("PurchaseOrder", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $po_share_read_per = $po_share_per_array['read']; $po_share_write_per = $po_share_per_array['write']; $newbuf .= "\$PurchaseOrder_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($po_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($po_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$PurchaseOrder_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($po_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($po_share_write_per['GROUP']) . ");\n\n"; //Constructing Sales Order Sharing Rules $so_share_per_array = getUserModuleSharingObjects("SalesOrder", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $so_share_read_per = $so_share_per_array['read']; $so_share_write_per = $so_share_per_array['write']; $so_sharingrule_members = $so_share_per_array['sharingrules']; $newbuf .= "\$SalesOrder_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($so_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($so_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$SalesOrder_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($so_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($so_share_write_per['GROUP']) . ");\n\n"; //Constructing the SalesOrder Invoice Related Module Sharing Array $so_related_inv = getRelatedModuleSharingArray("SalesOrder", "Invoice", $so_sharingrule_members, $so_share_read_per, $so_share_write_per, $def_org_share); $so_inv_share_read_per = $so_related_inv['read']; $so_inv_share_write_per = $so_related_inv['write']; $newbuf .= "\$SalesOrder_Invoice_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($so_inv_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($so_inv_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$SalesOrder_Invoice_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($so_inv_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalValueArray($so_inv_share_write_per['GROUP']) . ");\n\n"; //Constructing Invoice Sharing Rules $inv_share_per_array = getUserModuleSharingObjects("Invoice", $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $inv_share_read_per = $inv_share_per_array['read']; $inv_share_write_per = $inv_share_per_array['write']; $newbuf .= "\$Invoice_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($inv_share_read_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($inv_share_read_per['GROUP']) . ");\n\n"; $newbuf .= "\$Invoice_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($inv_share_write_per['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($inv_share_write_per['GROUP']) . ");\n\n"; // Writing Sharing Rules For Custom Modules. // TODO: We are ignoring rules that has already been calculated above, it is good to add GENERIC logic here. $custom_modules = getSharingModuleList(array('Leads', 'Accounts', 'Contacts', 'Potentials', 'HelpDesk', 'Emails', 'Campaigns', 'Quotes', 'PurchaseOrder', 'SalesOrder', 'Invoice')); for ($idx = 0; $idx < count($custom_modules); ++$idx) { $module_name = $custom_modules[$idx]; $mod_share_perm_array = getUserModuleSharingObjects($module_name, $userid, $def_org_share, $current_user_roles, $parent_roles, $current_user_groups); $mod_share_read_perm = $mod_share_perm_array['read']; $mod_share_write_perm = $mod_share_perm_array['write']; $newbuf .= '$' . $module_name . "_share_read_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($mod_share_read_perm['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($mod_share_read_perm['GROUP']) . ");\n\n"; $newbuf .= '$' . $module_name . "_share_write_permission=array('ROLE'=>" . constructTwoDimensionalCharIntSingleValueArray($mod_share_write_perm['ROLE']) . ",'GROUP'=>" . constructTwoDimensionalArray($mod_share_write_perm['GROUP']) . ");\n\n"; } // END $newbuf .= "?>"; fputs($handle, $newbuf); fclose($handle); //Populating Temp Tables populateSharingtmptables($userid); } } }
} } if (isset($_POST['record']) && !is_admin($current_user) && $_POST['record'] != $current_user->id) { echo "Unauthorized access to user administration."; } elseif (!isset($_POST['record']) && !is_admin($current_user)) { echo "Unauthorized access to user administration."; } $focus = new Users(); if (isset($_REQUEST["record"]) && $_REQUEST["record"] != '') { $focus->mode = 'edit'; $focus->id = $_REQUEST["record"]; } else { $focus->mode = ''; } if ($_REQUEST['changepassword'] == 'true') { $focus->retrieve_entity_info($_REQUEST['record'], 'Users'); $focus->id = $_REQUEST['record']; if (isset($_POST['new_password'])) { $new_pass = $_POST['new_password']; $new_passwd = $_POST['new_password']; $new_pass = md5($new_pass); $old_pass = $_POST['old_password']; $uname = $_POST['user_name']; if (!$focus->change_password($_POST['old_password'], $_POST['new_password'])) { header("Location: index.php?action=Error&module=Users&error_string=" . urlencode($focus->error_string)); exit; } } } //save user Image if (!$_REQUEST['changepassword'] == 'true') {
public static function getScheduledImport() { $scheduledImports = array(); $importQueue = Import_Queue_Controller::getAll(Import_Queue_Controller::$IMPORT_STATUS_SCHEDULED); foreach ($importQueue as $importId => $importInfo) { $userId = $importInfo['user_id']; $user = new Users(); $user->id = $userId; $user->retrieve_entity_info($userId, 'Users'); $scheduledImports[$importId] = new Import_Data_Controller($importInfo, $user); } return $scheduledImports; }
function undoLastImport($obj, $user) { $adb = PearDatabase::getInstance(); $moduleName = $obj->get('module'); $ownerId = $obj->get('foruser'); $owner = new Users(); $owner->id = $ownerId; $owner->retrieve_entity_info($ownerId, 'Users'); $dbTableName = Import_Utils_Helper::getDbTableName($owner); if (!is_admin($user) && $user->id != $owner->id) { $viewer = new Vtiger_Viewer(); $viewer->view('OperationNotPermitted.tpl', 'Vtiger'); exit; } $result = $adb->query("SELECT recordid FROM {$dbTableName} WHERE temp_status = " . Import_Data_Controller::$IMPORT_RECORD_CREATED . " AND recordid IS NOT NULL;"); $noOfRecords = $adb->num_rows($result); $noOfRecordsDeleted = 0; for ($i = 0; $i < $noOfRecords; ++$i) { $recordId = $adb->query_result($result, $i, 'recordid'); if (isRecordExists($recordId) && isPermitted($moduleName, 'Delete', $recordId) == 'yes') { $focus = CRMEntity::getInstance($moduleName); $focus->id = $recordId; $focus->trash($moduleName, $recordId); $noOfRecordsDeleted++; } } $viewer = new Vtiger_Viewer(); $viewer->assign('FOR_MODULE', $moduleName); $viewer->assign('TOTAL_RECORDS', $noOfRecords); $viewer->assign('DELETED_RECORDS_COUNT', $noOfRecordsDeleted); $viewer->view('ImportUndoResult.tpl'); }
} $_SESSION['vtiger_authenticated_user_theme'] = $authenticated_user_theme; $_SESSION['authenticated_user_language'] = $authenticated_user_language; $log->debug("authenticated_user_theme is {$authenticated_user_theme}"); $log->debug("authenticated_user_language is {$authenticated_user_language}"); $log->debug("authenticated_user_id is " . $focus->id); $log->debug("app_unique_key is {$application_unique_key}"); // Clear all uploaded import files for this user if it exists global $import_dir; $tmp_file_name = $import_dir . "IMPORT_" . $focus->id; if (file_exists($tmp_file_name)) { unlink($tmp_file_name); } $userSetupStatus = Users_CRMSetup::getUserSetupStatus($focus->id); if ($userSetupStatus) { $user = $focus->retrieve_entity_info($focus->id, 'Users'); $isFirstUser = Users_CRMSetup::isFirstUser($user); if ($isFirstUser) { header('Location: index.php?module=Users&action=SystemSetup'); } else { $arr = $_SESSION['lastpage']; if (isset($_SESSION['lastpage'])) { header("Location: {$successURL}" . $arr); } else { header("Location: {$successURL}"); } } } else { $arr = $_SESSION['lastpage']; if (isset($_SESSION['lastpage'])) { header("Location: {$successURL}" . $arr);
public static function process($requestObject, $user) { $moduleName = $requestObject->get('module'); $mode = $requestObject->get('mode'); if($mode == 'undo_import') { Import_Index_Controller::undoLastImport($requestObject, $user); exit; } elseif($mode == 'listview') { Import_ListView_Controller::render($requestObject, $user); exit; } elseif($mode == 'delete_map') { Import_Index_Controller::deleteMap($requestObject, $user); exit; } elseif($mode == 'clear_corrupted_data') { Import_Utils::clearUserImportInfo($user); } elseif($mode == 'cancel_import') { $importId = $requestObject->get('import_id'); $importInfo = Import_Queue_Controller::getImportInfoById($importId); if($importInfo != null) { if($importInfo['user_id'] == $user->id || is_admin($user)) { $importuser = new Users(); $importuser->id = $importInfo['user_id']; $importuser->retrieve_entity_info($importInfo['user_id'], 'Users'); $importDataController = new Import_Data_Controller($importInfo, $importuser); $importStatusCount = $importDataController->getImportStatusCount(); $importDataController->finishImport(); Import_Controller::showResult($importInfo, $importStatusCount); } exit; } } // Check if import on the module is locked $lockInfo = Import_Lock_Controller::isLockedForModule($moduleName); if($lockInfo != null) { $lockedBy = $lockInfo['userid']; if($user->id != $lockedBy && !is_admin($user)) { Import_Utils::showImportLockedError($lockInfo); exit; } else { if($mode == 'continue_import' && $user->id == $lockedBy) { $importController = new Import_Controller($requestObject, $user); $importController->triggerImport(true); } else { $importInfo = Import_Queue_Controller::getImportInfoById($lockInfo['importid']); $lockOwner = $user; if($user->id != $lockedBy) { $lockOwner = new Users(); $lockOwner->id = $lockInfo['userid']; $lockOwner->retrieve_entity_info( $lockInfo['userid'], 'Users'); } Import_Controller::showImportStatus($importInfo, $lockOwner); } exit; } } if(Import_Utils::isUserImportBlocked($user)) { $importInfo = Import_Queue_Controller::getUserCurrentImportInfo($user); if($importInfo != null) { Import_Controller::showImportStatus($importInfo, $user); exit; } else { Import_Utils::showImportTableBlockedError($moduleName, $user); exit; } } Import_Utils::clearUserImportInfo($user); if($mode == 'upload_and_parse') { if(Import_Index_Controller::validateFileUpload($requestObject)) { Import_Index_Controller::loadAdvancedSettings($requestObject, $user); exit; } } elseif($mode == 'import') { Import_Controller::import($requestObject, $user); exit; } Import_Index_Controller::loadBasicSettings($requestObject, $user); }
/** * Function creates default user's Role, Profiles */ public function setDefaultUsersAccess() { $adminPassword = $_SESSION['config_file_info']['password']; $userDateFormat = $_SESSION['config_file_info']['dateformat']; $userTimeZone = $_SESSION['config_file_info']['timezone']; $userFirstName = $_SESSION['config_file_info']['firstname']; $userLastName = $_SESSION['config_file_info']['lastname']; $adminEmail = $_SESSION['config_file_info']['admin_email']; $adb = PearDatabase::getInstance(); $adb->pquery("UPDATE vtiger_users SET date_format = ?, time_zone = ?, first_name = ?, last_name = ?, email1 = ?, accesskey = ?, language = ?", array($userDateFormat, $userTimeZone, $userFirstName, $userLastName, $adminEmail, vtws_generateRandomAccessKey(16), $_SESSION['default_language'])); $newUser = new Users(); $newUser->retrieve_entity_info(1, 'Users'); $newUser->change_password('admin', $adminPassword, false); require_once 'modules/Users/CreateUserPrivilegeFile.php'; createUserPrivilegesfile(1); }
function buildDocumentModel() { global $adb; $model = new Vtiger_PDF_Model(); if (isset($this->focus->column_fields["spcompany"]) && $this->focus->column_fields["spcompany"] != '') { $selfcompany = html_entity_decode($this->focus->column_fields["spcompany"], ENT_QUOTES, 'UTF-8'); } else { $selfcompany = "Default"; } // Company information $result = $adb->pquery("SELECT * FROM vtiger_organizationdetails WHERE company=?", array($selfcompany)); $num_rows = $adb->num_rows($result); if ($num_rows) { $resultrow = $adb->fetch_array($result); $model->set('orgAddress', $adb->query_result($result, 0, "address")); $model->set('orgCity', $adb->query_result($result, 0, "city")); $model->set('orgState', $adb->query_result($result, 0, "state")); $model->set('orgCountry', $adb->query_result($result, 0, "country")); $model->set('orgCode', $adb->query_result($result, 0, "code")); $model->set('orgBillingAddress', implode(', ', array($adb->query_result($result, 0, "code"), $adb->query_result($result, 0, "city"), $adb->query_result($result, 0, "address")))); $model->set('orgPhone', $adb->query_result($result, 0, "phone")); $model->set('orgFax', $adb->query_result($result, 0, "fax")); $model->set('orgWebsite', $adb->query_result($result, 0, "website")); $model->set('orgInn', $adb->query_result($result, 0, "inn")); $model->set('orgKpp', $adb->query_result($result, 0, "kpp")); $model->set('orgBankAccount', $adb->query_result($result, 0, "bankaccount")); $model->set('orgBankName', $adb->query_result($result, 0, 'bankname')); $model->set('orgBankId', $adb->query_result($result, 0, 'bankid')); $model->set('orgCorrAccount', $adb->query_result($result, 0, 'corraccount')); $model->set('orgOKPO', $adb->query_result($result, 0, "okpo")); if ($adb->query_result($result, 0, 'director')) { $model->set('orgDirector', $adb->query_result($result, 0, 'director')); } else { $model->set('orgDirector', str_repeat('_', 15)); } if ($adb->query_result($result, 0, 'bookkeeper')) { $model->set('orgBookkeeper', $adb->query_result($result, 0, 'bookkeeper')); } else { $model->set('orgBookkeeper', str_repeat('_', 15)); } if ($adb->query_result($result, 0, 'entrepreneur')) { $model->set('orgEntrepreneur', $adb->query_result($result, 0, 'entrepreneur')); } else { $model->set('orgEntrepreneur', str_repeat('_', 15)); } if ($adb->query_result($result, 0, 'entrepreneurreg')) { $model->set('orgEntrepreneurreg', $adb->query_result($result, 0, 'entrepreneurreg')); } else { $model->set('orgEntrepreneurreg', str_repeat('_', 50)); } $model->set('orgLogo', '<img src="test/logo/' . $resultrow['logoname'] . '" />'); $model->set('orgLogoPath', 'test/logo/' . $resultrow['logoname']); $model->set('orgName', decode_html($resultrow['organizationname'])); } $model->set('billingAddress', $this->buildHeaderBillingAddress()); $model->set('shippingAddress', $this->buildHeaderShippingAddress()); // Add owner info into model if (isset($this->focus->column_fields['record_id']) && $this->focus->column_fields['record_id'] != '') { $ownerArr = getRecordOwnerId($this->focus->column_fields['record_id']); if (isset($ownerArr['Users'])) { $userEntity = new Users(); $userEntity->retrieve_entity_info($ownerArr['Users'], 'Users'); $this->generateEntityModel($userEntity, 'Users', 'owner_', $model); } if (isset($ownerArr['Groups'])) { $groupInstance = Settings_Groups_Record_Model::getInstance($ownerArr['Groups']); $model->set('owner_groupid', $groupInstance->getId()); $model->set('owner_groupname', $groupInstance->getName()); $model->set('owner_description', $groupInstance->getDescription()); } } return $model; }
protected function pullEvents($start, $end, &$result, $userid = false, $color = null, $textColor = 'white') { $dbStartDateOject = DateTimeField::convertToDBTimeZone($start); $dbStartDateTime = $dbStartDateOject->format('Y-m-d H:i:s'); $dbStartDateTimeComponents = explode(' ', $dbStartDateTime); $dbStartDate = $dbStartDateTimeComponents[0]; $dbEndDateObject = DateTimeField::convertToDBTimeZone($end); $dbEndDateTime = $dbEndDateObject->format('Y-m-d H:i:s'); $currentUser = Users_Record_Model::getCurrentUserModel(); $db = PearDatabase::getInstance(); $moduleModel = Vtiger_Module_Model::getInstance('Events'); if ($userid) { $focus = new Users(); $focus->id = $userid; $focus->retrieve_entity_info($userid, 'Users'); $user = Users_Record_Model::getInstanceFromUserObject($focus); $userName = $user->getName(); $queryGenerator = new QueryGenerator($moduleModel->get('name'), $user); } else { $queryGenerator = new QueryGenerator($moduleModel->get('name'), $currentUser); } $queryGenerator->setFields(array('subject', 'eventstatus', 'visibility', 'date_start', 'time_start', 'due_date', 'time_end', 'assigned_user_id', 'id', 'activitytype')); $query = $queryGenerator->getQuery(); $query .= " AND vtiger_activity.activitytype NOT IN ('Emails','Task') AND "; $hideCompleted = $currentUser->get('hidecompletedevents'); if ($hideCompleted) { $query .= "vtiger_activity.eventstatus != 'HELD' AND "; } $query .= " ((concat(date_start, '', time_start) >= '{$dbStartDateTime}' AND concat(due_date, '', time_end) < '{$dbEndDateTime}') OR ( due_date >= '{$dbStartDate}'))"; $params = array(); if (empty($userid)) { $eventUserId = $currentUser->getId(); } else { $eventUserId = $userid; } $params = array_merge(array($eventUserId), $this->getGroupsIdsForUsers($eventUserId)); $query .= " AND vtiger_crmentity.smownerid IN (" . generateQuestionMarks($params) . ")"; $queryResult = $db->pquery($query, $params); while ($record = $db->fetchByAssoc($queryResult)) { $item = array(); $crmid = $record['activityid']; $visibility = $record['visibility']; $activitytype = $record['activitytype']; $status = $record['eventstatus']; $item['id'] = $crmid; $item['visibility'] = $visibility; $item['activitytype'] = $activitytype; $item['status'] = $status; if (!$currentUser->isAdminUser() && $visibility == 'Private' && $userid && $userid != $currentUser->getId()) { $item['title'] = decode_html($userName) . ' - ' . decode_html(vtranslate('Busy', 'Events')) . '*'; $item['url'] = ''; } else { $item['title'] = decode_html($record['subject']) . ' - (' . decode_html(vtranslate($record['eventstatus'], 'Calendar')) . ')'; $item['url'] = sprintf('index.php?module=Calendar&view=Detail&record=%s', $crmid); } $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']); $userDateTimeString = $dateTimeFieldInstance->getFullcalenderDateTimevalue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $item['start'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1]; $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']); $userDateTimeString = $dateTimeFieldInstance->getFullcalenderDateTimevalue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $item['end'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1]; $item['className'] = $cssClass; $item['allDay'] = false; $item['color'] = $color; $item['textColor'] = $textColor; $item['module'] = $moduleModel->getName(); $result[] = $item; } }
$contact_ids = array(); $product_ids = array(); $pricebook_ids = array(); $quote_ids = array(); $salesorder_ids = array(); $purchaseorder_ids = array(); $invoice_ids = array(); $email_ids = array(); // Assigned user for all demo data. $assigned_user_name = "admin"; // Look up the user id for the assigned user $seed_user = new Users(); $assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name); global $current_user; $current_user = new Users(); $result = $current_user->retrieve_entity_info($assigned_user_id, 'Users'); $tagkey = 1; // Get _dom arrays $comboFieldNames = array('leadsource' => 'leadsource_dom', 'leadstatus' => 'lead_status_dom', 'industry' => 'industry_dom', 'rating' => 'rating_dom', 'opportunity_type' => 'opportunity_type_dom', 'sales_stage' => 'sales_stage_dom'); $comboFieldArray = getComboArray($comboFieldNames); $adb->println("company_name_array"); $adb->println($company_name_array); $cloudtag = array('SO_vendtl', 'X-CEED', 'X-CEED', 'vtiger_50usr'); for ($i = 0; $i < $company_name_count; $i++) { $account_name = $company_name_array[$i]; // Create new accounts. $account = new Accounts(); $account->column_fields["accountname"] = $account_name; $account->column_fields["phone"] = create_phone_number(); $account->column_fields["assigned_user_id"] = $assigned_user_id; $whitespace = array(" ", ".", "&", "\\/");
require_once 'include/database/PearDatabase.php'; global $adb, $mod_strings; $local_log =& LoggerManager::getLogger('UsersAjax'); $ajaxaction = $_REQUEST["ajxaction"]; if ($ajaxaction == "DETAILVIEW") { if (empty($_SESSION['Users_FORM_TOKEN']) || $_SESSION['Users_FORM_TOKEN'] !== (int) $_REQUEST['form_token']) { echo ":#:ERR" . $app_strings['LBL_PERMISSION']; die; } $userid = $_REQUEST["recordid"]; $tablename = $_REQUEST["tableName"]; $fieldname = $_REQUEST["fldName"]; $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]); if ($userid != "") { $userObj = new Users(); $userObj->retrieve_entity_info($userid, "Users"); $userObj->column_fields[$fieldname] = $fieldvalue; if ($fieldname == 'asterisk_extension') { $query = "select 1 from vtiger_asteriskextensions\n inner join vtiger_users on vtiger_users.id=vtiger_asteriskextensions.userid\n where status='Active' and asterisk_extension =?"; $params = array($fieldvalue); $result = $adb->pquery($query, $params); if ($adb->num_rows($result) > 0) { echo ":#:ERR" . $mod_strings['LBL_ASTERISKEXTENSIONS_EXIST']; return false; } } if ($fieldname == 'internal_mailer') { if (isset($_SESSION['internal_mailer']) && $_SESSION['internal_mailer'] != $userObj->column_fields['internal_mailer']) { $_SESSION['internal_mailer'] = $userObj->column_fields['internal_mailer']; } }
foreach ($user_focus->column_fields as $key => $value) { $upperKey = "USER_" . strtoupper($key); ${$upperKey} = $value; } $USER_MOBILE = $user_focus->column_fields["phone_mobile"]; $USER_NAME = $user_focus->column_fields["last_name"]; $USER_EMAIL = $user_focus->column_fields["email1"]; } else { $USER_NAME = ""; $USER_EMAIL = ""; $USER_MOBILE = ""; } $smcreatorid = $focus->column_fields['smcreatorid']; if (!empty($smcreatorid)) { $user_focus = new Users(); $user_focus->retrieve_entity_info($smcreatorid, "Users"); foreach ($user_focus->column_fields as $key => $value) { $upperKey = "CREATOR_" . strtoupper($key); ${$upperKey} = $value; } $CREATOR_MOBILE = $user_focus->column_fields["phone_mobile"]; $CREATOR_NAME = $user_focus->column_fields["last_name"]; $CREATOR_EMAIL = $user_focus->column_fields["email1"]; } else { $CREATOR_NAME = ""; $CREATOR_EMAIL = ""; $CREATOR_OBILE = ""; } $focus->id = $focus->column_fields["record_id"]; if (isset($module_enable_product) && $module_enable_product) { $associated_products = getAssociatedProducts_NoPrice("Memdays", $focus);
require_once 'modules/Users/Forms.php'; require_once 'include/database/PearDatabase.php'; require_once 'modules/Leads/ListViewTop.php'; global $app_strings; global $app_list_strings; global $mod_strings; global $currentModule, $default_charset; $smarty = new vtigerCRM_Smarty(); $focus = new Users(); if (isset($_REQUEST['record']) && isset($_REQUEST['record'])) { $smarty->assign("ID", vtlib_purify($_REQUEST['record'])); $mode = 'edit'; if (!is_admin($current_user) && $_REQUEST['record'] != $current_user->id) { die("Unauthorized access to user administration."); } $focus->retrieve_entity_info(vtlib_purify($_REQUEST['record']), 'Users'); $smarty->assign("USERNAME", getFullNameFromArray('Users', $focus->column_fields)); } else { $mode = 'create'; } if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { $focus->id = ""; $focus->user_name = ""; $mode = 'create'; //When duplicating the user the password fields should be empty $focus->column_fields['user_password'] = ''; $focus->column_fields['confirm_password'] = ''; } if (empty($focus->column_fields['time_zone'])) { $focus->column_fields['time_zone'] = DateTimeField::getDBTimeZone(); }
public function getActiveAdminUsers() { $db = PearDatabase::getInstance(); $sql = 'SELECT id FROM vtiger_users WHERE status=? AND is_admin=?'; $result = $db->pquery($sql, array('ACTIVE', 'on')); $noOfUsers = $db->num_rows($result); $users = array(); if ($noOfUsers > 0) { $focus = new Users(); for ($i = 0; $i < $noOfUsers; ++$i) { $userId = $db->query_result($result, $i, 'id'); $focus->id = $userId; $focus->retrieve_entity_info($userId, 'Users'); $userModel = self::getInstanceFromUserObject($focus); $users[$userModel->getId()] = $userModel; } } return $users; }
public function process($feed, $request, $start, $end, &$result, $userid = false, $color = null, $textColor = 'white') { $dbStartDateOject = DateTimeField::convertToDBTimeZone($start); $dbStartDateTime = $dbStartDateOject->format('Y-m-d H:i:s'); $dbStartDateTimeComponents = explode(' ', $dbStartDateTime); $dbStartDate = $dbStartDateTimeComponents[0]; $dbEndDateObject = DateTimeField::convertToDBTimeZone($end); $dbEndDateTime = $dbEndDateObject->format('Y-m-d H:i:s'); $currentUser = Users_Record_Model::getCurrentUserModel(); $db = PearDatabase::getInstance(); $moduleModel = Vtiger_Module_Model::getInstance('Events'); if ($userid) { $focus = new Users(); $focus->id = $userid; $focus->retrieve_entity_info($userid, 'Users'); $user = Users_Record_Model::getInstanceFromUserObject($focus); $userName = $user->getName(); } $params = array(); if (empty($userid)) { $eventUserId = $currentUser->getId(); } else { $eventUserId = $userid; } $params = array_merge(array($eventUserId), $feed->getGroupsIdsForUsers($eventUserId)); $query = 'SELECT vtiger_activity.subject, vtiger_activity.eventstatus, vtiger_activity.visibility, vtiger_activity.date_start, vtiger_activity.time_start, vtiger_activity.due_date, vtiger_activity.time_end, vtiger_activity.activityid, vtiger_activity.activitytype, vtiger_seactivityrel.crmid as parent_id FROM vtiger_activity LEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid WHERE'; $query .= " vtiger_activity.activitytype NOT IN ('Emails','Task') AND "; $hideCompleted = $currentUser->get('hidecompletedevents'); if ($hideCompleted) { $query .= "vtiger_activity.eventstatus != 'HELD' AND "; } $query .= " ((concat(date_start, '', time_start) >= '{$dbStartDateTime}' AND concat(due_date, '', time_end) < '{$dbEndDateTime}') ) AND vtiger_activity.smownerid IN (" . generateQuestionMarks($params) . ") AND vtiger_activity.deleted=0"; $queryResult = $db->pquery($query, $params); while ($record = $db->fetchByAssoc($queryResult)) { $item = array(); $crmid = $record['activityid']; $visibility = $record['visibility']; $activitytype = $record['activitytype']; $status = $record['eventstatus']; $item['id'] = $crmid; $item['visibility'] = $visibility; $item['activitytype'] = $activitytype; $item['status'] = $status; //dodanie powiazan albo z kontaktow albo z powiazanych $title_add = $record['parent_id'] ? Vtiger_Functions::getCRMRecordLabel($record['parent_id']) : implode(', ', getActivityRelatedContacts($crmid)); if (!$currentUser->isAdminUser() && $visibility == 'Private' && $userid && $userid != $currentUser->getId()) { $item['title'] = decode_html($userName); $item['url'] = ''; } else { $item['title'] = decode_html($record['subject']); $item['url'] = sprintf('index.php?module=Calendar&view=Detail&record=%s', $crmid); } if ($title_add != '') { $item['title'] .= ' [' . decode_html($title_add) . ']'; } $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']); $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $item['start'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1]; $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']); $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $item['end'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1]; $item['className'] = $cssClass; $item['allDay'] = false; $item['color'] = $color; $item['textColor'] = $textColor; $item['module'] = $moduleModel->getName(); $result[] = $item; } return $widget; }