function getCalleeLink($fromHash, $toHash) { global $link; $fromHash = mysql_real_escape_string($fromHash); $toHash = mysql_real_escape_string($toHash); $callerName = getDisplayName($toHash); $userClient = new SoapClient(OM_SERVER_ADDRESS . '/services/UserService?wsdl'); $roomClient = new SoapClient(OM_SERVER_ADDRESS . '/services/RoomService?wsdl'); $session = $userClient->getSession(); $loginResult = $userClient->loginUser(array('SID' => $session->return->session_id, 'username' => OM_ADMIN_LOGIN, 'userpass' => OM_ADMIN_PASS)); if ($loginResult > 0) { //Successfully logged in, searching for a room, if its created $confs = $roomClient->getRooms(array('SID' => $session->return->session_id, 'start' => 0, 'max' => 100, 'orderby' => 'name', 'asc' => true))->return->result; $roomId = null; foreach ($confs as $value) { if ($value->name == $fromHash . $toHash) { //room exists, returning link to it $roomId = $value->rooms_id; } } if ($roomId == null) { //room doesn't exist, creating one and returning a link $addRoomResult = $roomClient->addRoomWithModeration(array('SID' => $session->return->session_id, 'name' => $fromHash . $toHash, 'roomtypes_id' => 1, 'comment' => 'Call room', 'numberOfPartizipants' => 2, 'ispublic' => true, 'appointment' => false, 'isDemoRoom' => false, 'demoTime' => 0, 'isModeratedRoom' => true))->return; if ($addRoomResult > 0) { $roomId = $addRoomResult; } else { dieWithMessage(METHOD_GETCALLEELINK, 'Failed to add a room'); } } $setUserObjectResult = $userClient->setUserObjectAndGenerateRoomHash(array('SID' => $session->return->session_id, 'username' => $callerName, 'firstname' => $callerName, 'lastname' => '', 'profilePictureUrl' => '', 'email' => '', 'externalUserId' => 0, 'externalUserType' => 'caller', 'room_id' => $roomId, 'becomeModeratorAsInt' => 0, 'showAudioVideoTestAsInt' => 2))->return; if ($setUserObjectResult != null) { showResult(METHOD_GETCALLEELINK, OM_SERVER_ADDRESS . '/openmeetings/main.lzx.swf8.swf?secureHash=' . $setUserObjectResult); } else { dieWithMessage(METHOD_GETCALLEELINK, "Setting user object failed"); } } else { dieWithMessage(METHOD_GETCALLEELINK, "Login failed"); } }
/** * Performance Optimization: Module Chart for Home Page Dashboard */ function module_Chart_HomePageDashboard($userinfo) { global $adb, $app_strings; $user_id = $userinfo->id; $graph_details = array(); $modrecords = array(); // List of modules which needs to be considered for chart $module_list = array('Accounts', 'Potentials', 'Contacts', 'Leads', 'Quotes', 'SalesOrder', 'PurchaseOrder', 'Invoice', 'HelpDesk', 'Calendar', 'Campaigns'); // List of special module to handle $spl_modules = array('Leads', 'HelpDesk', 'Potentials', 'Calendar'); // Leads module $leadcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_leaddetails le on le.leadid = se.crmid\r\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND (le.converted = 0 OR le.converted IS NULL)"); $modrecords['Leads'] = $adb->query_result($leadcountres, 0, 'count'); // HelpDesk module $helpdeskcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_troubletickets tt ON tt.ticketid = se.crmid\r\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND (tt.status != 'Closed' OR tt.status IS NULL)"); $modrecords['HelpDesk'] = $adb->query_result($helpdeskcountres, 0, 'count'); // Potentials module $potcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_potential pot ON pot.potentialid = se.crmid\r\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND (pot.sales_stage NOT IN ('" . $app_strings['LBL_CLOSE_WON'] . "','" . $app_strings['LBL_CLOSE_LOST'] . "') OR pot.sales_stage IS NULL)"); $modrecords['Potentials'] = $adb->query_result($potcountres, 0, 'count'); // Calendar moudule $calcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_activity act ON act.activityid = se.crmid\r\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND act.activitytype != 'Emails' AND\r\n\t\t\t((act.status!='Completed' AND act.status!='Deferred') OR act.status IS NULL)\r\n\t\t\tAND ((act.eventstatus!='Held' AND act.eventstatus!='Not Held') OR act.eventstatus IS NULL)"); $modrecords['Calendar'] = $adb->query_result($calcountres, 0, 'count'); // Ignore the special module $nor_modules = array_diff($module_list, $spl_modules); // Prepare module string to use in SQL (check permission) $inmodulestr = ''; foreach ($nor_modules as $modulename) { if (isPermitted("{$modulename}", "index", '') == 'yes') { if ($inmodulestr != '') { $inmodulestr .= ",'{$modulename}'"; } else { $inmodulestr = "'{$modulename}'"; } } } // Get count for module that needs special conditions $query = "SELECT setype, count(setype) setype_count FROM vtiger_crmentity se WHERE \r\n\t\tse.deleted = 0 AND se.smownerid={$user_id} AND se.setype in ({$inmodulestr}) GROUP BY se.setype"; $queryres = $adb->query($query); while ($resrow = $adb->fetch_array($queryres)) { $modrecords[$resrow['setype']] = $resrow['setype_count']; } // Get module custom filter info $cvidres = $adb->query("SELECT cvid,entitytype FROM vtiger_customview WHERE viewname='All' AND entitytype in ('" . implode("','", array_keys($modrecords)) . "')"); $cvidinfo = array(); while ($cvidrow = $adb->fetch_array($cvidres)) { $cvidinfo[$cvidrow['entitytype']] = $cvidrow['cvid']; } $name_val = ''; $cnt_val = ''; $target_val = ''; $urlstring = ''; $cnt_table = '<table border="0" cellpadding="3" cellspacing="1"><tbody><tr><th>Status</th><th>Total</th></tr>'; $test_target_val = ''; $total_records = 0; foreach ($module_list as $modulename) { if (isset($modrecords[$modulename])) { $modrec_count = $modrecords[$modulename]; if ($modrec_count > 0) { if ($name_val != '') { $name_val .= '::'; } $name_val .= $modulename; if ($cnt_val != '') { $cnt_val .= '::'; } $cnt_val .= $modrec_count; $modviewid = $cvidinfo[$modulename]; $username = getDisplayName(array('f' => $userinfo->first_name, 'l' => $userinfo->last_name)); if ($target_val != '') { $target_val .= '::'; } $target_val .= urlencode("index.php?module={$modulename}&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner={$username}&viewname={$modviewid}"); if ($test_target_val != '') { $test_target_val .= 'K'; } $test_target_val .= urlencode("index.php?module={$modulename}&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner={$username}&viewname={$modviewid}"); $urlstring .= 'K'; $cnt_table .= "<tr><td>{$modulename}</td><td align='center'>{$modrec_count}</td></tr>"; $total_records += $modrec_count; } } } $cnt_table .= '</tbody></table>'; $graph_details[] = $name_val; $graph_details[] = $cnt_val; $graph_details[] = " {$userinfo->user_name} : {$total_records} "; $graph_details[] = $target_val; $graph_details[] = ''; $graph_details[] = $urlstring; $graph_details[] = $cnt_table; $graph_details[] = $test_target_val; return $graph_details; }
/** Function to get owner name either user or group */ function getOwnerNameList($idList) { global $log; if (!is_array($idList) || count($idList) == 0) { return array(); } $nameList = array(); $db = PearDatabase::getInstance(); $sql = "select first_name,last_name,id from vtiger_users where id in (" . generateQuestionMarks($idList) . ")"; $result = $db->pquery($sql, $idList); $it = new SqlResultIterator($db, $result); foreach ($it as $row) { $nameList[$row->id] = getDisplayName(array('f' => $row->first_name, 'l' => $row->last_name)); } $groupIdList = array_diff($idList, array_keys($nameList)); if (count($groupIdList) > 0) { $sql = "select groupname,groupid from vtiger_groups where groupid in (" . generateQuestionMarks($groupIdList) . ")"; $result = $db->pquery($sql, $groupIdList); $it = new SqlResultIterator($db, $result); foreach ($it as $row) { $nameList[$row->groupid] = $row->groupname; } } return $nameList; }
ExecuteQuery("ALTER TABLE vtiger_field CHANGE COLUMN selected defaultvalue TEXT default ''"); ExecuteQuery("UPDATE vtiger_field SET defaultvalue='' WHERE defaultvalue='0'"); // Scheduled Reports (Email) ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_scheduled_reports(reportid INT, recipients TEXT, schedule TEXT,\n\t\t\t\t\t\t\t\t\tformat VARCHAR(10), next_trigger_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(reportid))\n\t\t\t\tENGINE=InnoDB DEFAULT CHARSET=utf8;"); // Change Display of User Name from user_name to lastname firstname. $updatedCVIds = array(); $updatedReportIds = array(); $usersQuery = "SELECT * FROM vtiger_users"; $usersInfo = $adb->query($usersQuery); $usersCount = $adb->num_rows($usersInfo); for ($i = 0; $i < $usersCount; $i++) { $username = $adb->query_result($usersInfo, $i, 'user_name'); $firstname = $adb->query_result($usersInfo, $i, 'first_name'); $lastname = $adb->query_result($usersInfo, $i, 'last_name'); $usernames[$i] = $username; $fullname = getDisplayName(array('f' => $firstname, 'l' => $lastname)); $fullnames[$i] = $fullname; } for ($i = 0; $i < $usersCount; $i++) { $cvQuery = "SELECT * FROM vtiger_cvadvfilter WHERE columnname LIKE '%:assigned_user_id%' AND value LIKE '%{$usernames[$i]}%'"; $cvResult = $adb->query($cvQuery); $cvCount = $adb->num_rows($cvResult); for ($k = 0; $k < $cvCount; $k++) { $id = $adb->query_result($cvResult, $k, 'cvid'); if (!in_array($id, $updatedCVIds)) { $value = $adb->query_result($cvResult, $k, 'value'); $value = explode(',', $value); $fullname = ''; if (count($value) > 1) { for ($m = 0; $m < count($value); $m++) { $index = array_keys($usernames, $value[$m]);
/** * Function creates HTML to display Events ListView * @param array $entry_list - collection of strings(Event Information) * return string $list_view - html tags in string format */ function constructEventListView(&$cal, $entry_list, $navigation_array = '') { global $mod_strings, $app_strings, $adb, $cal_log, $current_user, $theme; $cal_log->debug("Entering constructEventListView() method..."); $format = $cal['calendar']->hour_format; $date_format = $current_user->date_format; $date = new DateTimeField(null); $endDate = new DateTimeField(date("Y-m-d H:i:s", time() + 1 * 24 * 60 * 60)); $hour_startat = $date->getDisplayTime(); $hour_endat = $endDate->getDisplayTime(); $time_arr = getaddEventPopupTime($hour_startat, $hour_endat, $format); $temp_ts = $cal['calendar']->date_time->ts; //to get date in user selected date format $temp_date = $date->getDisplayDate(); if ($cal['calendar']->day_start_hour != 23) { $endtemp_date = $temp_date; } else { $endtemp_date = $endDate->getDisplayDate(); } $list_view = ""; $start_datetime = $app_strings['LBL_START_DATE_TIME']; $end_datetime = $app_strings['LBL_END_DATE_TIME']; //Events listview header labels $header = array('0' => '#', '1' => $start_datetime, '2' => $end_datetime, '3' => $mod_strings['LBL_EVENTTYPE'], '4' => $mod_strings['LBL_EVENTDETAILS']); $header_width = array('0' => '5%', '1' => '15%', '2' => '15%', '3' => '10%', '4' => '33%'); if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") { array_push($header, $mod_strings['LBL_ACTION']); array_push($header_width, '10%'); } if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0') { array_push($header, $mod_strings['LBL_STATUS']); array_push($header_width, '$10%'); } array_push($header, $mod_strings['LBL_ASSINGEDTO']); array_push($header_width, '15%'); $list_view .= "<table style='background-color: rgb(204, 204, 204);' class='small' align='center' border='0' cellpadding='5' cellspacing='1' width='98%'>\n <tr>"; $header_rows = count($header); $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, "Calendar", "index"); if ($navigationOutput != '') { $list_view .= "<tr width=100% bgcolor=white><td align=center colspan={$header_rows}>"; $list_view .= "<table align=center width='98%'><tr>" . $navigationOutput . "</tr></table></td></tr>"; } $list_view .= "<tr>"; for ($i = 0; $i < $header_rows; $i++) { $list_view .= "<td nowrap='nowrap' class='lvtCol' width='" . $header_width[$i] . "'>" . $header[$i] . "</td>"; } $list_view .= "</tr>"; $rows = count($entry_list); if ($rows != 0) { $userName = getDisplayName(array('f' => $current_user->column_fields['first_name'], 'l' => $current_user->column_fields['last_name'])); for ($i = 0; $i < count($entry_list); $i++) { $list_view .= "<tr class='lvtColData' onmouseover='this.className=\"lvtColDataHover\"' onmouseout='this.className=\"lvtColData\"' bgcolor='white'>"; $userNameSql = getSqlForNameInDisplayFormat(array('f' => 'vtiger_users.first_name', 'l' => 'vtiger_users.last_name')); $assigned_role_query = $adb->pquery("select vtiger_user2role.roleid,vtiger_user2role.userid\n\t\t\t\t\t\t\t\t\t\t\t\tfrom vtiger_user2role\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_users ON vtiger_users.id=vtiger_user2role.userid\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE {$userNameSql}=?", array($entry_list[$i]['assignedto'])); $assigned_user_role_id = $adb->query_result($assigned_role_query, 0, "roleid"); $assigned_user_id = $adb->query_result($assigned_role_query, 0, "userid"); $role_list = $adb->pquery("SELECT * from vtiger_role WHERE parentrole LIKE '" . formatForSqlLike($current_user->column_fields['roleid']) . formatForSqlLike($assigned_user_role_id) . "'", array()); $is_shared = $adb->pquery("SELECT * from vtiger_sharedcalendar where userid=? and sharedid=?", array($assigned_user_id, $current_user->id)); foreach ($entry_list[$i] as $key => $entry) { if ($key != 'visibility') { if (($key == 'eventdetail' || $key == 'action') && ($current_user->column_fields['is_admin'] != 'on' && $adb->num_rows($role_list) == 0 && ($adb->num_rows($is_shared) == 0 || $entry_list[$i]['visibility'] == 'Private')) && $userName != $entry_list[$i]['assignedto']) { if ($key == 'eventdetail') { $list_view .= "<td nowrap='nowrap'><font color='red'><b>" . $entry_list[$i]['assignedto'] . " - " . $mod_strings['LBL_BUSY'] . "</b></font></td>"; } else { $list_view .= "<td nowrap='nowrap'><font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font></td>"; } } else { $list_view .= "<td nowrap='nowrap'>{$entry}</td>"; } } } $list_view .= "</tr>"; } } else { $list_view .= "<tr><td style='background-color:#efefef;height:340px' align='center' colspan='9'>\n\t\t\t\t"; // JFV : remove LBL_NO for ja lang if ($_SESSION['authenticated_user_language'] == 'ja') { $list_view .= "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 45%; position: relative; z-index: 5000;'>\n\t\t\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td rowspan='2' width='25%'>\n\t\t\t\t\t\t\t\t<img src='" . vtiger_imageurl('empty.jpg', $theme) . "' height='60' width='61'></td>\n\t\t\t\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);padding-left:15px' nowrap='nowrap' width='75%' align='left'><span class='genHeaderSmall'>" . $app_strings['Events'] . " " . $app_strings['LBL_FOUND'] . "</span></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>"; } else { // JFV END $list_view .= "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 45%; position: relative; z-index: 5000;'>\n\t\t\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td rowspan='2' width='25%'>\n\t\t\t\t\t\t\t\t<img src='" . vtiger_imageurl('empty.jpg', $theme) . "' height='60' width='61'></td>\n\t\t\t\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='75%'><span class='genHeaderSmall'>" . $app_strings['LBL_NO'] . " " . $app_strings['Events'] . " " . $app_strings['LBL_FOUND'] . " !</span></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>"; // JFV } // JFV END //checking permission for Create/Edit Operation if (isPermitted("Calendar", "EditView") == "yes") { $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_CAN_CREATE'] . " " . $app_strings['LBL_AN'] . " " . $app_strings['Event'] . " " . $app_strings['LBL_NOW'] . ". " . $app_strings['LBL_CLICK_THE_LINK'] . ":<br>\n\t\t\t\t\t -<a href='javascript:void(0);' onClick='gshow(\"addEvent\",\"Call\",\"" . $temp_date . "\",\"" . $endtemp_date . "\",\"" . $time_arr['starthour'] . "\",\"" . $time_arr['startmin'] . "\",\"" . $time_arr['startfmt'] . "\",\"" . $time_arr['endhour'] . "\",\"" . $time_arr['endmin'] . "\",\"" . $time_arr['endfmt'] . "\",\"listview\",\"event\");'>" . $app_strings['LBL_CREATE'] . " " . $app_strings['LBL_AN'] . " " . $app_strings['Event'] . "</a><br>\n\t\t\t\t\t</td>"; } else { $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_ARE_NOT_ALLOWED_TO_CREATE'] . " " . $app_strings['LBL_AN'] . " " . $app_strings['Event'] . "<br></td>"; } $list_view .= "</tr>\n </table>\n\t\t\t\t</div>"; $list_view .= "</td></tr>"; } $list_view .= "</table>"; $cal_log->debug("Exiting constructEventListView() method..."); return $list_view; }
/** to get the customviewCombo for the class variable customviewmodule * @param $viewid :: Type Integer * $viewid will make the corresponding selected * @returns $customviewCombo :: Type String */ function getCustomViewCombo($viewid = '', $markselected = true) { global $adb, $current_user; global $app_strings; $tabid = getTabid($this->customviewmodule); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $shtml_user = ''; $shtml_pending = ''; $shtml_public = ''; $shtml_others = ''; $selected = 'selected'; if ($markselected == false) { $selected = ''; } $ssql = "select vtiger_customview.*, vtiger_users.first_name,vtiger_users.last_name from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype \r\n\t\t\t\t\tleft join vtiger_users on vtiger_customview.userid = vtiger_users.id "; $ssql .= " where vtiger_tab.tabid=?"; $sparams = array($tabid); if ($is_admin == false) { $ssql .= " and (vtiger_customview.status=0 or vtiger_customview.userid = ? or vtiger_customview.status = 3 or vtiger_customview.userid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '" . $current_user_parent_role_seq . "::%'))"; array_push($sparams, $current_user->id); } $ssql .= " ORDER BY viewname"; $result = $adb->pquery($ssql, $sparams); while ($cvrow = $adb->fetch_array($result)) { if ($cvrow['viewname'] == 'All') { $cvrow['viewname'] = $app_strings['COMBO_ALL']; } else { global $current_language; $current_module_strings = return_module_language($current_language, "CustomView"); $cvrow['viewname'] = $current_module_strings['JFV_cv_name'][$cvrow['viewname']] ? $current_module_strings['JFV_cv_name'][$cvrow['viewname']] : $cvrow['viewname']; } // JFV END $option = ''; $viewname = $cvrow['viewname']; if ($cvrow['status'] == CV_STATUS_DEFAULT || $cvrow['userid'] == $current_user->id) { $disp_viewname = $viewname; } else { $userName = getDisplayName(array('f' => $cvrow['first_name'], 'l' => $cvrow['last_name'])); $disp_viewname = $viewname . " [" . $userName . "] "; } if ($cvrow['setdefault'] == 1 && $viewid == '') { $option = "<option {$selected} value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>"; $this->setdefaultviewid = $cvrow['cvid']; } elseif ($cvrow['cvid'] == $viewid) { $option = "<option {$selected} value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>"; $this->setdefaultviewid = $cvrow['cvid']; } else { $option = "<option value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>"; } // Add the option to combo box at appropriate section if ($option != '') { if ($cvrow['status'] == CV_STATUS_DEFAULT || $cvrow['userid'] == $current_user->id) { $shtml_user .= $option; } elseif ($cvrow['status'] == CV_STATUS_PUBLIC) { if ($shtml_public == '') { $shtml_public = "<option disabled>--- " . $app_strings['LBL_PUBLIC'] . " ---</option>"; } $shtml_public .= $option; } elseif ($cvrow['status'] == CV_STATUS_PENDING) { if ($shtml_pending == '') { $shtml_pending = "<option disabled>--- " . $app_strings['LBL_PENDING'] . " ---</option>"; } $shtml_pending .= $option; } else { if ($shtml_others == '') { $shtml_others = "<option disabled>--- " . $app_strings['LBL_OTHERS'] . " ---</option>"; } $shtml_others .= $option; } } } $shtml = $shtml_user; if ($is_admin == true) { $shtml .= $shtml_pending; } $shtml = $shtml . $shtml_public . $shtml_others; return $shtml; }
function emitSlowPathHelper($obj, $ext_hhvm_cpp, $indent, $prefix) { fwrite($ext_hhvm_cpp, $indent . "TypedValue* args UNUSED = " . "((TypedValue*)ar) - 1;\n"); $func_call_prefix = 'return '; $func_call_suffix = ";\n"; if (!isTypeCppReturnByRef($obj->returnType)) { if ($obj->returnType == 'bool') { fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfBoolean;' . "\n"); $func_call_prefix = 'rv->m_data.num = ('; $func_call_suffix = ") ? 1LL : 0LL;\n" . $indent . "return rv;\n"; } else { if ($obj->returnType == 'int') { fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfInt64;' . "\n"); $func_call_prefix = 'rv->m_data.num = (long long)'; $func_call_suffix = ";\n" . $indent . "return rv;\n"; } else { if ($obj->returnType == 'long long') { fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfInt64;' . "\n"); $func_call_prefix = 'rv->m_data.num = (long long)'; $func_call_suffix = ";\n" . $indent . "return rv;\n"; } else { if ($obj->returnType == 'double') { fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfDouble;' . "\n"); $func_call_prefix = 'rv->m_data.dbl = '; $func_call_suffix = ";\n" . $indent . "return rv;\n"; } else { if ($obj->returnType == 'void') { fwrite($ext_hhvm_cpp, $indent . 'rv->m_data.num = 0LL;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfNull;' . "\n"); $func_call_prefix = ''; $func_call_suffix = ";\n" . $indent . "return rv;\n"; } else { throw new Exception("Unrecognized return type for " . getDisplayName($obj)); } } } } } } else { if ($obj->returnType == 'HPHP::String') { fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfString;' . "\n"); $func_call_prefix = ''; $func_call_suffix = ";\n" . $indent . 'if (rv->m_data.num == 0LL) ' . 'rv->m_type = KindOfNull;' . "\n" . $indent . 'return rv;' . "\n"; } else { if ($obj->returnType == 'HPHP::Array') { fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfArray;' . "\n"); $func_call_prefix = ''; $func_call_suffix = ";\n" . $indent . 'if (rv->m_data.num == 0LL) ' . 'rv->m_type = KindOfNull;' . "\n" . $indent . 'return rv;' . "\n"; } else { if ($obj->returnType == 'HPHP::Object') { fwrite($ext_hhvm_cpp, $indent . 'rv->_count = 0;' . "\n"); fwrite($ext_hhvm_cpp, $indent . 'rv->m_type = KindOfObject;' . "\n"); $func_call_prefix = ''; $func_call_suffix = ";\n" . $indent . 'if (rv->m_data.num == 0LL)' . 'rv->m_type = KindOfNull;' . "\n" . $indent . 'return rv;' . "\n"; } else { if ($obj->returnType == 'HPHP::Variant') { $func_call_prefix = ''; $func_call_suffix = ";\n" . $indent . 'if (rv->m_type == KindOfUninit) ' . 'rv->m_type = KindOfNull;' . "\n" . $indent . 'return rv;' . "\n"; } else { throw new Exception("Unrecognized return type for " . getDisplayName($obj)); } } } } } // Cast each argument to the required type as needed emitCasts($obj, $ext_hhvm_cpp, $indent); // Set up extraArgs if ($obj->isVarargs) { emitBuildExtraArgs($obj, $ext_hhvm_cpp, $indent); } // Set up variables for default values if needed foreach ($obj->params as $k => $p) { if (defValNeedsVariable($p)) { $defValType = $p->type; if (substr($defValType, -7) == ' const&') { $defValType = substr($defValType, 0, -7); } $defValType = preg_replace('/HPHP::/', '', $defValType); fwrite($ext_hhvm_cpp, $indent . $defValType . ' defVal' . $k); if ($defValType != 'Variant' || $p->defVal != 'null' && $p->defVal != 'null_variant') { fwrite($ext_hhvm_cpp, ' = ' . $p->defVal); } fwrite($ext_hhvm_cpp, ";\n"); } } // Emit the function call fwrite($ext_hhvm_cpp, $indent); fwrite($ext_hhvm_cpp, $func_call_prefix); fwrite($ext_hhvm_cpp, emitCall($obj, $prefix, true)); fwrite($ext_hhvm_cpp, $func_call_suffix); }
function get_user_array($add_blank = true, $status = "Active", $assigned_user = "", $private = "") { global $log; $log->debug("Entering get_user_array(" . $add_blank . "," . $status . "," . $assigned_user . "," . $private . ") method ..."); global $current_user; if (isset($current_user) && $current_user->id != '') { require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; } static $user_array = null; $module = $_REQUEST['module']; if ($user_array == null) { require_once 'include/database/PearDatabase.php'; $db = PearDatabase::getInstance(); $temp_result = array(); // Including deleted vtiger_users for now. if (empty($status)) { $query = "SELECT id, user_name from vtiger_users"; $params = array(); } else { if ($private == 'private') { $log->debug("Sharing is Private. Only the current user should be listed"); $query = "select id as id,user_name as user_name,first_name,last_name from vtiger_users where id=? and status='Active' union select vtiger_user2role.userid as id,vtiger_users.user_name as user_name ,\r\n\t\t\t\t\t\t\t vtiger_users.first_name as first_name ,vtiger_users.last_name as last_name \r\n\t\t\t\t\t\t\t from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like ? and status='Active' union \r\n\t\t\t\t\t\t\t select shareduserid as id,vtiger_users.user_name as user_name ,\r\n\t\t\t\t\t\t\t vtiger_users.first_name as first_name ,vtiger_users.last_name as last_name from vtiger_tmp_write_user_sharing_per inner join vtiger_users on vtiger_users.id=vtiger_tmp_write_user_sharing_per.shareduserid where status='Active' and vtiger_tmp_write_user_sharing_per.userid=? and vtiger_tmp_write_user_sharing_per.tabid=?"; $params = array($current_user->id, $current_user_parent_role_seq . "::%", $current_user->id, getTabid($module)); } else { $log->debug("Sharing is Public. All vtiger_users should be listed"); $query = "SELECT id, user_name,first_name,last_name from vtiger_users WHERE status=?"; $params = array($status); } } if (!empty($assigned_user)) { $query .= " OR id=?"; array_push($params, $assigned_user); } $query .= " order by user_name ASC"; $result = $db->pquery($query, $params, true, "Error filling in user array: "); if ($add_blank == true) { // Add in a blank row $temp_result[''] = ''; } // Get the id and the name. while ($row = $db->fetchByAssoc($result)) { $temp_result[$row['id']] = getDisplayName(array('f' => $row['first_name'], 'l' => $row['last_name'])); } $user_array =& $temp_result; } $log->debug("Exiting get_user_array method ..."); return $user_array; }
/** * getDisplayName: Evaluates the name of the object as it should be * displayed by the Bidowl GUI * obj should be already buffered * TODO: Replace "Lesezeichen, Papierkorb" with a language template variable */ function getDisplayName($obj, $TYPE = 0) { if ($TYPE == 0) { // first try to use the description as display name $result = getDisplayName($obj, 1); // if the description is empty, use the object name if ($result == "") { $result = getDisplayName($obj, 2); } return $result; } else { if ($TYPE == 1) { $result = $obj->get_attribute(OBJ_DESC); $result = str_replace("s workroom.", "", $result); $result = str_replace("s workroom", "", $result); $result = str_replace("Trashbin", "Papierkorb", $result); $result = str_replace("Everyone", "Jeder", $result); return $result; } else { if ($TYPE == 2) { $result = $obj->get_attribute(OBJ_NAME); $result = str_replace("'s workarea", "", stripslashes($result)); $result = preg_replace("/.*'s bookmarks/", "Lesezeichen", $result); $result = str_replace("trashbin", "Papierkorb", $result); $result = str_replace("Everyone", "Jeder", stripslashes($result)); $result = str_replace("sTeam", "Registrierte Benutzer", stripslashes($result)); return $result; } } } }