Example #1
0
/** Function to get permitted fields of current user of a particular module to find duplicate records --Pavani*/
function getMergeFields($module, $str)
{
    global $adb, $current_user;
    $tabid = getTabid($module);
    if ($str == "available_fields") {
        $result = getFieldsResultForMerge($tabid);
    } else {
        //if($str == fileds_to_merge)
        $sql = "select * from vtiger_user2mergefields where tabid=? and userid=? and visible=1";
        $result = $adb->pquery($sql, array($tabid, $current_user->id));
    }
    $num_rows = $adb->num_rows($result);
    $user_profileid = fetchUserProfileId($current_user->id);
    $permitted_list = getProfile2FieldPermissionList($module, $user_profileid);
    $sql_def_org = "select fieldid from vtiger_def_org_field where tabid=? and visible=0";
    $result_def_org = $adb->pquery($sql_def_org, array($tabid));
    $num_rows_org = $adb->num_rows($result_def_org);
    $permitted_org_list = array();
    for ($i = 0; $i < $num_rows_org; $i++) {
        $permitted_org_list[$i] = $adb->query_result($result_def_org, $i, "fieldid");
    }
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    for ($i = 0; $i < $num_rows; $i++) {
        $field_id = $adb->query_result($result, $i, "fieldid");
        foreach ($permitted_list as $field => $data) {
            if ($data[4] == $field_id and $data[1] == 0) {
                if ($is_admin == 'true' || in_array($field_id, $permitted_org_list)) {
                    $field = "<option value=\"" . $field_id . "\">" . getTranslatedString($data[0], $module) . "</option>";
                    $fields .= $field;
                    break;
                }
            }
        }
    }
    return $fields;
}
Example #2
0
/** Function to getProfile2allfieldsListinsert value to profile2fieldPermissions table
 * @param $mod_array -- mod_array :: Type string
 * @param $profileid -- profileid :: Type integer
 * @returns $profilelist -- profilelist :: Type string
 */
function getProfile2AllFieldList($mod_array, $profileid)
{
    global $log;
    $log->debug("Entering getProfile2AllFieldList(" . $mod_array . "," . $profileid . ") method ...");
    $log->info("in getProfile2AllFieldList vtiger_profile id is " . $profileid);
    global $adb;
    $profilelist = array();
    for ($i = 0; $i < count($mod_array); $i++) {
        $profilelist[key($mod_array)] = getProfile2FieldPermissionList(key($mod_array), $profileid);
        next($mod_array);
    }
    $log->debug("Exiting getProfile2AllFieldList method ...");
    return $profilelist;
}