当前位置: 首页>>代码示例>>PHP>>正文


PHP TrimEx函数代码示例

本文整理汇总了PHP中TrimEx函数的典型用法代码示例。如果您正苦于以下问题:PHP TrimEx函数的具体用法?PHP TrimEx怎么用?PHP TrimEx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TrimEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetList


//.........这里部分代码省略.........
             switch (strtoupper($key)) {
                 case "ID":
                     $arSqlSearch[] = GetFilterQuery("F.ID", $val, "N");
                     break;
                 case "USER_ID":
                     $arSqlSearch[] = "F.USER_ID = " . intval($val);
                     break;
                 case "MENU_FOR_USER":
                     $arSqlSearch[] = "(F.USER_ID=" . intval($val) . " OR F.COMMON='Y')";
                     break;
                 case "COMMON":
                     $arSqlSearch[] = "F.COMMON = '" . $DB->ForSql($val, 1) . "'";
                     break;
                 case "LANGUAGE_ID":
                     $arSqlSearch[] = "F.LANGUAGE_ID = '" . $DB->ForSql($val, 2) . "'";
                     break;
                 case "DATE1":
                     $arSqlSearch[] = "F.TIMESTAMP_X >= FROM_UNIXTIME('" . MkDateTime(FmtDate($val, "D.M.Y"), "d.m.Y") . "')";
                     break;
                 case "DATE2":
                     $arSqlSearch[] = "F.TIMESTAMP_X <= FROM_UNIXTIME('" . MkDateTime(FmtDate($val, "D.M.Y") . " 23:59:59", "d.m.Y") . "')";
                     break;
                 case "MODIFIED":
                     $arSqlSearch[] = GetFilterQuery("UM.ID, UM.LOGIN, UM.LAST_NAME, UM.NAME", $val);
                     break;
                 case "MODIFIED_ID":
                     $arSqlSearch[] = "F.MODIFIED_BY = " . intval($val);
                     break;
                 case "CREATED":
                     $arSqlSearch[] = GetFilterQuery("UC.ID, UC.LOGIN, UC.LAST_NAME, UC.NAME", $val);
                     break;
                 case "CREATED_ID":
                     $arSqlSearch[] = "F.CREATED_BY = " . intval($val);
                     break;
                 case "KEYWORDS":
                     $arSqlSearch[] = GetFilterQuery("F.COMMENTS", $val);
                     break;
                 case "NAME":
                     $arSqlSearch[] = GetFilterQuery("F.NAME", $val);
                     break;
                 case "URL":
                     $arSqlSearch[] = GetFilterQuery("F.URL", $val);
                     break;
                 case "MODULE_ID":
                     $arSqlSearch[] = "F.MODULE_ID='" . $DB->ForSql($val, 50) . "'";
                     break;
                 case "MENU_ID":
                     $arSqlSearch[] = "F.MENU_ID='" . $DB->ForSql($val, 255) . "'";
                     break;
             }
         }
     }
     $sOrder = "";
     foreach ($aSort as $key => $val) {
         $ord = strtoupper($val) != "ASC" ? "DESC" : "ASC";
         switch (strtoupper($key)) {
             case "ID":
                 $sOrder .= ", F.ID " . $ord;
                 break;
             case "LANGUAGE_ID":
                 $sOrder .= ", F.LANGUAGE_ID " . $ord;
                 break;
             case "COMMON":
                 $sOrder .= ", F.COMMON " . $ord;
                 break;
             case "USER_ID":
                 $sOrder .= ", F.USER_ID " . $ord;
                 break;
             case "TIMESTAMP_X":
                 $sOrder .= ", F.TIMESTAMP_X " . $ord;
                 break;
             case "MODIFIED_BY":
                 $sOrder .= ", F.MODIFIED_BY " . $ord;
                 break;
             case "NAME":
                 $sOrder .= ", F.NAME " . $ord;
                 break;
             case "URL":
                 $sOrder .= ", F.URL " . $ord;
                 break;
             case "SORT":
                 $sOrder .= ", F.C_SORT " . $ord;
                 break;
             case "MODULE_ID":
                 $sOrder .= ", F.MODULE_ID " . $ord;
                 break;
             case "MENU_ID":
                 $sOrder .= ", F.MENU_ID " . $ord;
                 break;
         }
     }
     if (strlen($sOrder) <= 0) {
         $sOrder = "F.ID DESC";
     }
     $strSqlOrder = " ORDER BY " . TrimEx($sOrder, ",");
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tF.ID, F.C_SORT, F.NAME, F.MENU_ID, F.URL, F.MODIFIED_BY, F.CREATED_BY, F.MODULE_ID, F.LANGUAGE_ID,\n\t\t\t\tF.COMMENTS, F.COMMON, F.USER_ID, UM.LOGIN AS M_LOGIN, UC.LOGIN as C_LOGIN, U.LOGIN, F.CODE_ID,\n\t\t\t\t" . $DB->DateToCharFunction("F.TIMESTAMP_X") . "\tTIMESTAMP_X,\n\t\t\t\t" . $DB->DateToCharFunction("F.DATE_CREATE") . "\tDATE_CREATE,\n\t\t\t\t" . $DB->Concat($DB->IsNull("UM.NAME", "''"), "' '", $DB->IsNull("UM.LAST_NAME", "''")) . " as M_USER_NAME,\n\t\t\t\t" . $DB->Concat($DB->IsNull("UC.NAME", "''"), "' '", $DB->IsNull("UC.LAST_NAME", "''")) . " as C_USER_NAME,\n\t\t\t\t" . $DB->Concat($DB->IsNull("U.NAME", "''"), "' '", $DB->IsNull("U.LAST_NAME", "''")) . " as USER_NAME\n\t\t\tFROM\n\t\t\t\tb_favorite F\n\t\t\t\tLEFT JOIN b_user UM ON (UM.ID = F.MODIFIED_BY)\n\t\t\t\tLEFT JOIN b_user UC ON (UC.ID = F.CREATED_BY)\n\t\t\t\tLEFT JOIN b_user U ON (U.ID = F.USER_ID)\n\t\t\tWHERE\n\t\t\t" . $strSqlSearch . "\n\t\t\t" . $strSqlOrder;
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $res;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:favorites.php

示例2: GetList


//.........这里部分代码省略.........
         $filterKeysCount = count($filterKeys);
         for ($i = 0; $i < $filterKeysCount; $i++) {
             $key = $filterKeys[$i];
             $val = $arFilter[$filterKeys[$i]];
             if (is_array($val) && count($val) <= 0 || !is_array($val) && (strlen($val) <= 0 || $val === 'NOT_REF')) {
                 continue;
             }
             $matchValueSet = in_array($key . "_EXACT_MATCH", $filterKeys) ? true : false;
             $key = strtoupper($key);
             switch ($key) {
                 case "ID":
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $matchValueSet ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("T.ID", $val, $match);
                     break;
                 case "HOLD_ON":
                     $arSqlSearch[] = $val == "Y" ? "T.HOLD_ON='Y'" : "T.HOLD_ON = 'N'";
                     break;
                 case "LID":
                 case "SITE":
                 case "SITE_ID":
                     if (is_array($val)) {
                         $val = implode(" | ", $val);
                     }
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $matchValueSet ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("T.SITE_ID", $val, $match);
                     break;
                 case "LAMP":
                     if (is_array($val)) {
                         if (count($val) > 0) {
                             $str = "";
                             foreach ($val as $value) {
                                 $str .= ", '" . $DB->ForSQL($value) . "'";
                             }
                             $str = TrimEx($str, ",");
                             $arSqlSearch[] = " " . $lamp . " in (" . $str . ")";
                         }
                     } elseif (strlen($val) > 0) {
                         $arSqlSearch[] = " " . $lamp . " = '" . $DB->ForSQL($val) . "'";
                     }
                     break;
                 case "DATE_CREATE_1":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.DATE_CREATE>=" . $DB->CharToDateFunction($val, "SHORT");
                     }
                     break;
                 case "DATE_CREATE_2":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.DATE_CREATE<" . $DB->CharToDateFunction($val, "SHORT") . " + INTERVAL 1 DAY";
                     }
                     break;
                 case "DATE_TIMESTAMP_1":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.TIMESTAMP_X>=" . $DB->CharToDateFunction($val, "SHORT");
                     }
                     break;
                 case "DATE_TIMESTAMP_2":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.TIMESTAMP_X<" . $DB->CharToDateFunction($val, "SHORT") . " + INTERVAL 1 DAY";
                     }
                     break;
                 case "DATE_CLOSE_1":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.DATE_CLOSE>=" . $DB->CharToDateFunction($val, "SHORT");
                     }
                     break;
                 case "DATE_CLOSE_2":
开发者ID:rasuldev,项目名称:torino,代码行数:67,代码来源:support.php

示例3: GetList

 function GetList(&$by, &$order, $arFilter = array(), &$isFiltered, $checkRights = "Y", $getUserName = "Y", $getExtraNames = "Y", $siteID = false, $arParams = array())
 {
     $err_mess = CTicket::err_mess() . "<br>Function: GetList<br>Line: ";
     global $DB, $USER, $USER_FIELD_MANAGER;
     $bAdmin = 'N';
     $bSupportTeam = 'N';
     $bSupportClient = 'N';
     $bDemo = 'N';
     $messJoin = "";
     if ($checkRights == 'Y') {
         $bAdmin = CTicket::IsAdmin() ? 'Y' : 'N';
         $bSupportTeam = CTicket::IsSupportTeam() ? 'Y' : 'N';
         $bSupportClient = CTicket::IsSupportClient() ? 'Y' : 'N';
         $bDemo = CTicket::IsDemo() ? 'Y' : 'N';
         $uid = intval($USER->GetID());
     } else {
         $bAdmin = 'Y';
         $bSupportTeam = 'Y';
         $bSupportClient = 'Y';
         $bDemo = 'Y';
         if (is_object($USER)) {
             $uid = intval($USER->GetID());
         } else {
             $uid = -1;
         }
     }
     if ($bAdmin != 'Y' && $bSupportTeam != 'Y' && $bSupportClient != 'Y' && $bDemo != 'Y') {
         return false;
     }
     if ($bSupportTeam == 'Y' || $bAdmin == 'Y' || $bDemo == 'Y') {
         $lamp = "\n\t\t\t\tif(ifnull(T.DATE_CLOSE,'x')<>'x', 'grey',\n\t\t\t\t\tif(ifnull(T.LAST_MESSAGE_USER_ID,0)='{$uid}', 'green',\n\t\t\t\t\t\tif(ifnull(T.OWNER_USER_ID,0)='{$uid}', 'red',\n\t\t\t\t\t\t\tif(T.LAST_MESSAGE_BY_SUPPORT_TEAM='Y','green_s',\n\t\t\t\t\t\t\t\tif(ifnull(T.RESPONSIBLE_USER_ID,0)='{$uid}', 'red',\n\t\t\t\t\t\t\t\t\t'yellow')))))\n\t\t\t\t";
     } else {
         $lamp = "\n\t\t\t\tif(ifnull(T.DATE_CLOSE,'x')<>'x', 'grey',\n\t\t\t\t\tif(ifnull(T.LAST_MESSAGE_USER_ID,0)='{$uid}', 'green', 'red'))\n\t\t\t\t";
     }
     $bJoinSupportTeamTbl = $bJoinClientTbl = false;
     $arSqlSearch = array();
     $strSqlSearch = "";
     if (is_array($arFilter)) {
         $filterKeys = array_keys($arFilter);
         for ($i = 0; $i < count($filterKeys); $i++) {
             $key = $filterKeys[$i];
             $val = $arFilter[$filterKeys[$i]];
             if (is_array($val) && count($val) <= 0 || !is_array($val) && (strlen($val) <= 0 || $val === 'NOT_REF')) {
                 continue;
             }
             $matchValueSet = in_array($key . "_EXACT_MATCH", $filterKeys) ? true : false;
             $key = strtoupper($key);
             switch ($key) {
                 case "ID":
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $matchValueSet ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("T.ID", $val, $match);
                     break;
                 case "HOLD_ON":
                     $arSqlSearch[] = $val == "Y" ? "T.HOLD_ON='Y'" : "T.HOLD_ON = 'N'";
                     break;
                 case "LID":
                 case "SITE":
                 case "SITE_ID":
                     if (is_array($val)) {
                         $val = implode(" | ", $val);
                     }
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $matchValueSet ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("T.SITE_ID", $val, $match);
                     break;
                 case "LAMP":
                     if (is_array($val)) {
                         if (count($val) > 0) {
                             foreach ($val as $value) {
                                 $str .= ", '" . $DB->ForSQL($value) . "'";
                             }
                             $str = TrimEx($str, ",");
                             $arSqlSearch[] = " " . $lamp . " in (" . $str . ")";
                         }
                     } elseif (strlen($val) > 0) {
                         $arSqlSearch[] = " " . $lamp . " = '" . $DB->ForSQL($val) . "'";
                     }
                     break;
                 case "DATE_CREATE_1":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.DATE_CREATE>=" . $DB->CharToDateFunction($val, "SHORT");
                     }
                     break;
                 case "DATE_CREATE_2":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.DATE_CREATE<" . $DB->CharToDateFunction($val, "SHORT") . " + INTERVAL 1 DAY";
                     }
                     break;
                 case "DATE_TIMESTAMP_1":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.TIMESTAMP_X>=" . $DB->CharToDateFunction($val, "SHORT");
                     }
                     break;
                 case "DATE_TIMESTAMP_2":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.TIMESTAMP_X<" . $DB->CharToDateFunction($val, "SHORT") . " + INTERVAL 1 DAY";
                     }
                     break;
                 case "DATE_CLOSE_1":
                     if (CheckDateTime($val)) {
                         $arSqlSearch[] = "T.DATE_CLOSE>=" . $DB->CharToDateFunction($val, "SHORT");
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:support.php

示例4: Set_sendMails

 function Set_sendMails($nf, $v, $arFields)
 {
     $I_Email = null;
     $U_Email = null;
     if (!$v->isNew) {
         $U_Email = "Y";
     } else {
         $I_Email = "Y";
     }
     IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/support/classes/general/messages.php", $v->arrSite["LANGUAGE_ID"]);
     $mf = self::GetCSupportTableFields("EventFields");
     $mf->ADMIN_EDIT_URL = "/bitrix/admin/ticket_edit.php";
     $mf->LANGUAGE = $v->arrSite["LANGUAGE_ID"];
     $mf->LANGUAGE_ID = $v->arrSite["LANGUAGE_ID"];
     $arrSet = array("ID" => "ID", "DATE_CREATE" => "DATE_CREATE", "TIMESTAMP" => "TIMESTAMP_X", "DATE_CLOSE" => "DATE_CLOSE", "TITLE" => "TITLE", "CATEGORY" => "CATEGORY_NAME", "CRITICALITY" => "CRITICALITY_NAME", "DIFFICULTY" => "DIFFICULTY_NAME", "STATUS" => "STATUS_NAME", "SLA" => "SLA_NAME", "OWNER_USER_ID" => "OWNER_USER_ID", "OWNER_GUEST_ID" => "OWNER_GUEST_ID", "OWNER_SID" => "OWNER_SID", "OWNER_USER_NAME" => "OWNER_NAME", "OWNER_USER_LOGIN" => "OWNER_LOGIN", "OWNER_USER_EMAIL" => "OWNER_EMAIL", "RESPONSIBLE_USER_ID" => "RESPONSIBLE_USER_ID", "RESPONSIBLE_USER_NAME" => "RESPONSIBLE_NAME", "RESPONSIBLE_USER_LOGIN" => "RESPONSIBLE_LOGIN", "RESPONSIBLE_USER_EMAIL" => "RESPONSIBLE_EMAIL", "CREATED_USER_ID" => "CREATED_USER_ID", "CREATED_GUEST_ID" => "CREATED_GUEST_ID", "CREATED_USER_LOGIN" => "CREATED_LOGIN", "CREATED_USER_EMAIL" => "CREATED_EMAIL", "CREATED_USER_NAME" => "CREATED_NAME");
     if (!$v->isNew) {
         $arrSet["MODIFIED_USER_ID"] = "MODIFIED_USER_ID";
         $arrSet["MODIFIED_GUEST_ID"] = "MODIFIED_GUEST_ID";
         $arrSet["MODIFIED_USER_LOGIN"] = "MODIFIED_LOGIN";
         $arrSet["MODIFIED_USER_EMAIL"] = "MODIFIED_EMAIL";
         $arrSet["MODIFIED_USER_NAME"] = "MODIFIED_NAME";
         $arrSet["RATE"] = "MARK_NAME";
         $arrSet["MESSAGES_AMOUNT"] = "MESSAGES";
     }
     $mf->FromArray((array) $nf, $arrSet);
     $arUserIDs = array($mf->OWNER_USER_ID, $mf->CREATED_USER_ID, $mf->MODIFIED_USER_ID, $mf->RESPONSIBLE_USER_ID);
     $arGuestIDs = array($mf->OWNER_GUEST_ID, $mf->CREATED_GUEST_ID, $mf->MODIFIED_GUEST_ID);
     $arStrUsers = CTicket::GetUsersPropertiesArray($arUserIDs, $arGuestIDs);
     // set name, login, email
     $userCategories = array('OWNER', 'RESPONSIBLE', 'CREATED');
     if (!$v->isNew) {
         $userCategories[] = 'MODIFIED';
     }
     foreach ($userCategories as $userCategory) {
         $propertyId = $userCategory . '_USER_ID';
         if ($mf->{$propertyId} > 0 && isset($arStrUsers['arUsers'][$mf->{$propertyId}])) {
             $name = CUser::FormatName(CSite::GetNameFormat(), $arStrUsers['arUsers'][$mf->{$propertyId}], true, true);
             $propertyName = $userCategory . '_USER_NAME';
             $mf->{$propertyName} = $name;
             $propertyLogin = $userCategory . '_USER_LOGIN';
             $mf->{$propertyLogin} = $arStrUsers['arUsers'][$mf->{$propertyId}]['LOGIN'];
             $propertyEmail = $userCategory . '_USER_EMAIL';
             $mf->{$propertyEmail} = $arStrUsers['arUsers'][$mf->{$propertyId}]['EMAIL'];
         }
     }
     $mf->FILES_LINKS = self::Set_getFilesLinks($v->arrFILES, $v->arrSite["LANGUAGE_ID"]);
     $mf->IMAGE_LINK = $mf->FILES_LINKS;
     $mf->MESSAGE_BODY = PrepareTxtForEmail($arFields["MESSAGE"], $v->arrSite["LANGUAGE_ID"], false, false);
     // сформируем email автора
     // Событие: "TICKET_CHANGE_BY_AUTHOR_FOR_AUTHOR"	- #DEFAULT_EMAIL_FROM# -> #OWNER_EMAIL# (Обращение изменено автором (для автора))
     // Событие: "TICKET_CHANGE_BY_SUPPORT_FOR_AUTHOR"	- #DEFAULT_EMAIL_FROM# -> #OWNER_EMAIL# (Обращение изменено сотрудником техподдержки (для автора))
     // Событие: "TICKET_NEW_FOR_AUTHOR"					- #DEFAULT_EMAIL_FROM# -> #OWNER_EMAIL# (Новое обращение (для автора))
     $ownerEmail = "";
     if ($mf->OWNER_USER_ID > 0 && isset($arStrUsers["arUsers"][$mf->OWNER_USER_ID])) {
         $ownerEmail = $arStrUsers["arUsers"][$mf->OWNER_USER_ID]["EMAIL"];
     } elseif ($mf->OWNER_GUEST_ID > 0 && isset($arStrUsers["arGuests"][$mf->OWNER_GUEST_ID])) {
         $ownerEmail = $arStrUsers["arGuests"][$mf->OWNER_GUEST_ID]["EMAIL"];
     }
     $arrOwnerEmails = self::EmailsFromStringToArray($mf->OWNER_SID, array($ownerEmail));
     if (intval($mf->OWNER_USER_ID) > 0) {
         $rs = CTicket::GetResponsibleList($mf->OWNER_USER_ID, $I_Email, $U_Email);
         while ($arr0 = $rs->Fetch()) {
             if (strlen($arr0['EMAIL']) > 0) {
                 $arrOwnerEmails[] = $arr0['EMAIL'];
             }
         }
     }
     $mf->OWNER_EMAIL = implode(", ", array_unique($arrOwnerEmails));
     // выбираем административные email'ы
     $arrAdminEMails = CTicket::GetAdminEmails();
     if (!is_array($arrAdminEMails)) {
         $arrAdminEMails = array();
     }
     TrimArr($arrAdminEMails);
     // сформируем email техподдержки
     // Событие: "TICKET_OVERDUE_REMINDER"				- #DEFAULT_EMAIL_FROM# -> #SUPPORT_EMAIL# (Напоминание о необходимости ответа (для техподдержки))
     // Событие: "TICKET_CHANGE_FOR_TECHSUPPORT"			- #DEFAULT_EMAIL_FROM# -> #SUPPORT_EMAIL# (Изменения в обращении (для техподдержки))
     // Событие: "TICKET_NEW_FOR_TECHSUPPORT"			- #DEFAULT_EMAIL_FROM# -> #SUPPORT_EMAIL# (Новое обращение (для техподдержки))
     $arrSupportEmails = array();
     if ($mf->RESPONSIBLE_USER_ID > 0 && isset($arStrUsers["arUsers"][$mf->RESPONSIBLE_USER_ID])) {
         $arrSupportEmails[] = $arStrUsers["arUsers"][$mf->RESPONSIBLE_USER_ID]["EMAIL"];
         // из группы ответсвенного, выбираем всех пользователей кто имеет доступ к рассылке
         $rs = CTicket::GetResponsibleList($mf->RESPONSIBLE_USER_ID, $I_Email, $U_Email, "Y");
         while ($arr0 = $rs->Fetch()) {
             if (strlen($arr0['EMAIL']) > 0) {
                 $arrSupportEmails[] = $arr0['EMAIL'];
             }
         }
     }
     if (count($arrSupportEmails) <= 0) {
         $arrSupportEmails = $arrAdminEMails;
     }
     if (count($arrSupportEmails) <= 0) {
         $se = COption::GetOptionString("main", "email_from", "");
         if (strlen($se) > 0) {
             $arrSupportEmails[] = $se;
         }
     }
     TrimArr($arrSupportEmails);
     $mf->SUPPORT_EMAIL = count($arrSupportEmails) > 0 ? TrimEx(implode(",", array_unique($arrSupportEmails)), ",") : "";
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:support.php

示例5: Set

 function Set($arFields, $OLD_SID, $CHECK_RIGHTS = "Y")
 {
     $err_mess = CAdvType_all::err_mess() . "<br>Function: Set<br>Line: ";
     global $DB, $USER;
     $SID = false;
     $OLD_SID = trim($OLD_SID);
     if (CAdvType::CheckFields($arFields, $OLD_SID, $CHECK_RIGHTS)) {
         $arFields_i = array();
         $arrKeys = array_keys($arFields);
         if (in_array("SID", $arrKeys)) {
             $arFields_i["SID"] = "'" . $DB->ForSql($arFields["SID"], 255) . "'";
         }
         if (in_array("ACTIVE", $arrKeys) && ($arFields["ACTIVE"] == "Y" || $arFields["ACTIVE"] == "N")) {
             $arFields_i["ACTIVE"] = "'" . $arFields["ACTIVE"] . "'";
         }
         if (in_array("SORT", $arrKeys)) {
             $arFields_i["SORT"] = "'" . intval($arFields["SORT"]) . "'";
         }
         if (in_array("NAME", $arrKeys)) {
             $arFields_i["NAME"] = "'" . $DB->ForSql($arFields["NAME"], 255) . "'";
         }
         if (in_array("DESCRIPTION", $arrKeys)) {
             $arFields_i["DESCRIPTION"] = "'" . $DB->ForSql($arFields["DESCRIPTION"], 2000) . "'";
         }
         if (count($arFields_i) > 0) {
             if (strlen($OLD_SID) > 0) {
                 if (in_array("DATE_MODIFY", $arrKeys) && CheckDateTime($arFields["DATE_MODIFY"])) {
                     $arFields_i["DATE_MODIFY"] = $DB->CharToDateFunction($arFields["DATE_MODIFY"]);
                 } else {
                     $arFields_i["DATE_MODIFY"] = $DB->GetNowFunction();
                 }
                 if (in_array("MODIFIED_BY", $arrKeys)) {
                     $arFields_i["MODIFIED_BY"] = intval($arFields["MODIFIED_BY"]);
                 } else {
                     $arFields_i["MODIFIED_BY"] = $USER->GetID();
                 }
                 $str = "";
                 while (list($field, $value) = each($arFields_i)) {
                     if (strlen($value) <= 0) {
                         $str .= "{$field} = '', ";
                     } else {
                         $str .= "{$field} = {$value}, ";
                     }
                 }
                 $str = TrimEx($str, ",");
                 $strSql = "UPDATE b_adv_type SET " . $str . " WHERE SID='" . $DB->ForSql($OLD_SID, 255) . "'";
                 $DB->Query($strSql, false, $err_mess . __LINE__);
                 if (in_array("SID", $arrKeys)) {
                     $SID = $arFields["SID"];
                     // если SID изменился то
                     if ($arFields["SID"] != $OLD_SID) {
                         // обновим тип у баннеров
                         $arF = array("TYPE_SID" => "'" . $DB->ForSql($arFields["SID"], 255) . "'");
                         $DB->Update("b_adv_banner", $arF, "WHERE TYPE_SID='" . $DB->ForSql($OLD_SID, 255) . "'", $err_mess . __LINE__);
                         // обновим тип у баннеров
                         $arF = array("TYPE_SID" => "'" . $DB->ForSql($arFields["SID"], 255) . "'");
                         $DB->Update("b_adv_contract_2_type", $arF, "WHERE TYPE_SID='" . $DB->ForSql($OLD_SID, 255) . "'", $err_mess . __LINE__);
                     }
                 } else {
                     $SID = $OLD_SID;
                 }
             } elseif (strlen($arFields_i["SID"]) > 0) {
                 if (in_array("DATE_CREATE", $arrKeys) && CheckDateTime($arFields["DATE_CREATE"])) {
                     $arFields_i["DATE_CREATE"] = $DB->CharToDateFunction($arFields["DATE_CREATE"]);
                 } else {
                     $arFields_i["DATE_CREATE"] = $DB->GetNowFunction();
                 }
                 if (in_array("CREATED_BY", $arrKeys)) {
                     $arFields_i["CREATED_BY"] = intval($arFields["CREATED_BY"]);
                 } else {
                     $arFields_i["CREATED_BY"] = $USER->GetID();
                 }
                 if (in_array("DATE_MODIFY", $arrKeys) && CheckDateTime($arFields["DATE_MODIFY"])) {
                     $arFields_i["DATE_MODIFY"] = $DB->CharToDateFunction($arFields["DATE_MODIFY"]);
                 } else {
                     $arFields_i["DATE_MODIFY"] = $DB->GetNowFunction();
                 }
                 if (in_array("MODIFIED_BY", $arrKeys)) {
                     $arFields_i["MODIFIED_BY"] = intval($arFields["MODIFIED_BY"]);
                 } else {
                     $arFields_i["MODIFIED_BY"] = $USER->GetID();
                 }
                 $str1 = $str2 = "";
                 while (list($field, $value) = each($arFields_i)) {
                     $str1 .= $field . ", ";
                     if (strlen($value) <= 0) {
                         $str2 .= "'', ";
                     } else {
                         $str2 .= "{$value}, ";
                     }
                 }
                 $str1 = TrimEx($str1, ",");
                 $str2 = TrimEx($str2, ",");
                 $strSql = "INSERT INTO b_adv_type (" . $str1 . ") VALUES (" . $str2 . ")";
                 $DB->Query($strSql, false, $err_mess . __LINE__);
                 $SID = $arFields["SID"];
             }
         }
     } else {
         $SID = $arFields["SID"];
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:advertising.php

示例6: GetList

 public static function GetList($arSort = array(), $arFilter = array())
 {
     global $DB;
     $arSqlSearch = array();
     if (is_array($arFilter)) {
         $filter_keys = array_keys($arFilter);
         for ($i = 0, $ic = count($filter_keys); $i < $ic; $i++) {
             $val = $arFilter[$filter_keys[$i]];
             if (strlen($val) <= 0 || $val == 'NOT_REF') {
                 continue;
             }
             switch (strtoupper($filter_keys[$i])) {
                 case 'ID':
                     $arSqlSearch[] = GetFilterQuery('CS.ID', $val, 'N');
                     break;
                 case 'ENTITY_ID':
                     $arSqlSearch[] = GetFilterQuery('CS.ENTITY_ID', $val);
                     break;
                 case 'STATUS_ID':
                     $arSqlSearch[] = GetFilterQuery('CS.STATUS_ID', $val);
                     break;
                 case 'NAME':
                     $arSqlSearch[] = GetFilterQuery('CS.NAME', $val);
                     break;
                 case 'SORT':
                     $arSqlSearch[] = GetFilterQuery('CS.SORT', $val);
                     break;
                 case 'SYSTEM':
                     $arSqlSearch[] = $val == 'Y' ? "CS.SYSTEM='Y'" : "CS.SYSTEM='N'";
                     break;
             }
         }
     }
     $sOrder = '';
     foreach ($arSort as $key => $val) {
         $ord = strtoupper($val) != 'ASC' ? 'DESC' : 'ASC';
         switch (strtoupper($key)) {
             case 'ID':
                 $sOrder .= ', CS.ID ' . $ord;
                 break;
             case 'ENTITY_ID':
                 $sOrder .= ', CS.ENTITY_ID ' . $ord;
                 break;
             case 'STATUS_ID':
                 $sOrder .= ', CS.STATUS_ID ' . $ord;
                 break;
             case 'NAME':
                 $sOrder .= ', CS.NAME ' . $ord;
                 break;
             case 'SORT':
                 $sOrder .= ', CS.SORT ' . $ord;
                 break;
             case 'SYSTEM':
                 $sOrder .= ', CS.SYSTEM ' . $ord;
                 break;
         }
     }
     if (strlen($sOrder) <= 0) {
         $sOrder = 'CS.ID DESC';
     }
     $strSqlOrder = ' ORDER BY ' . TrimEx($sOrder, ',');
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tCS.ID, CS.ENTITY_ID, CS.STATUS_ID, CS.NAME, CS.NAME_INIT, CS.SORT, CS.SYSTEM\n\t\t\tFROM\n\t\t\t\tb_crm_status CS\n\t\t\tWHERE\n\t\t\t{$strSqlSearch}\n\t\t\t{$strSqlOrder}";
     $res = $DB->Query($strSql, false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
     return $res;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:66,代码来源:crm_status.php

示例7: i2c_create_db

function i2c_create_db(&$total_reindex, &$reindex_success, &$step_reindex, &$int_prev, $step = 0, $file_name = false, $file_type = false, $file_db = false, $file_idx = false)
{
    $step = intval($step);
    if ($file_name === false) {
        $file_name = IP_DEFAULT_SOURCE_FILENAME;
    }
    if ($file_type === false) {
        $file_type = IP_DEFAULT_SOURCE_TYPE;
    }
    if ($file_db === false) {
        $file_db = IP_DB_FILENAME;
    }
    if ($file_idx === false) {
        $file_idx = IP_IDX_FILENAME;
    }
    $start = getmicrotime();
    $bExtTotal = is_array($total_reindex);
    if ($bExtTotal) {
        $my_total_reindex = $total_reindex[0];
        $fseek = $total_reindex[1];
    } else {
        $fseek = $total_reindex;
        $my_total_reindex = $total_reindex;
    }
    if ($fp = fopen($_SERVER["DOCUMENT_ROOT"] . $file_name, "rb")) {
        if ($fseek <= 0) {
            $mode = "wb";
        } else {
            $mode = "ab";
        }
        $f_db = fopen($_SERVER["DOCUMENT_ROOT"] . $file_db, $mode);
        $f_idx = fopen($_SERVER["DOCUMENT_ROOT"] . $file_idx, $mode);
        $d = 1000000;
        if ($fseek <= 0) {
            fwrite($f_idx, $d . "\n0,0\n");
        }
        $src_db_lines = 0;
        $step_reindex = 0;
        if ($bExtTotal) {
            fseek($fp, $fseek);
        }
        while ($fp > 0 && !feof($fp)) {
            $arr = fgetcsv($fp, 1000, ",");
            if (is_array($arr) && $file_type == "maxmind.com" && !isset($beginIpNum)) {
                while (list($key, $value) = each($arr)) {
                    $value = trim($value);
                    if ($value == "beginIpNum" || $value == "endIpNum" || $value == "countryCode") {
                        ${$value} = $key;
                    }
                }
            }
            $src_db_lines++;
            if (!$bExtTotal) {
                if ($fseek > 0 && $src_db_lines <= $fseek) {
                    continue;
                }
            }
            if ($file_type == "maxmind.com") {
                $ix_beginIpNum = !isset($beginIpNum) ? 2 : intval($beginIpNum);
                $ip_from = TrimEx($arr[$ix_beginIpNum], "\"");
                $ix_endIpNum = !isset($endIpNum) ? 3 : intval($endIpNum);
                $ip_to = TrimEx($arr[$ix_endIpNum], "\"");
                $ip_to = (double) $ip_to;
                if ($ip_to <= 0) {
                    continue;
                }
                $ix_countryCode = !isset($countryCode) ? 4 : intval($countryCode);
                $country_id = TrimEx($arr[$ix_countryCode], "\"");
            } else {
                $ip_from = TrimEx($arr[0], "\"");
                $ip_to = TrimEx($arr[1], "\"");
                $country_id = TrimEx($arr[2], "\"");
            }
            if (strlen($country_id) <= 0 && strlen($country_id) != 2) {
                continue;
            }
            $ip_from_p = str_pad($ip_from, 10, "0", STR_PAD_LEFT);
            $ip_to_p = str_pad($ip_to, 10, "0", STR_PAD_LEFT);
            fwrite($f_db, $ip_from_p . $ip_to_p . $country_id . "\n");
            $step_reindex++;
            $int = floor($ip_from / $d);
            if ($int != $int_prev) {
                fwrite($f_idx, $int . "," . ($my_total_reindex + $step_reindex) . "\n");
            }
            $int_prev = $int;
            if ($step > 0 && getmicrotime() - $start > $step) {
                $reindex_success = "N";
                break;
            }
        }
        if ($reindex_success != "N") {
            $reindex_success = "Y";
        }
        if ($bExtTotal) {
            $total_reindex[0] += $step_reindex;
            $total_reindex[1] = ftell($fp);
        } else {
            $total_reindex += $step_reindex;
        }
        fclose($fp);
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:ip_tools.php

示例8: number_format

     $arAnswer["PERCENT"] = $arAnswer["PERCENT2"] = $arAnswer["PERCENT3"];
     if ($counterSum > 0) {
         $arAnswer["PERCENT"] = $arAnswer["PERCENT2"] = $arAnswer["PERCENT3"] = $percentage = $arAnswer["COUNTER"] * 100 / $counter;
         if (is_float($percentage)) {
             $arAnswer["PERCENT"] = number_format($percentage, 0, ".", "");
             $arAnswer["PERCENT2"] = number_format($percentage, 1, ".", "");
             if ($arAnswer["PERCENT2"] != $percentage) {
                 $arAnswer["PERCENT3"] = number_format($percentage, 2, ".", "");
             }
         }
         $sum1 += $arAnswer["PERCENT"];
         $sum2 += $arAnswer["PERCENT2"];
         $sum3 += $arAnswer["PERCENT3"];
     }
     $arAnswer["BAR_PERCENT"] = $arAnswer["FIELD_TYPE"] == 0 || $arAnswer["FIELD_TYPE"] == 2 ? $counterMax > 0 ? round($arAnswer["COUNTER"] * 100 / $counterMax) : 0 : round($arAnswer["PERCENT"]);
     $arAnswer["COLOR"] = empty($arAnswer["COLOR"]) && ($color = GetNextRGB($color, count($arQuestion["ANSWERS"]))) ? $color : TrimEx($arAnswer["COLOR"], "#");
     $arQuestion["ANSWERS"][$aID] = $arAnswer;
 }
 $var = $sum1 == 100 ? 1 : ($sum2 == 100 ? 2 : 3);
 if ($var > 1) {
     foreach ($arQuestion["ANSWERS"] as $aID => $arAnswer) {
         $arQuestion["ANSWERS"][$aID]["PERCENT"] = $arQuestion["ANSWERS"][$aID]["PERCENT" . $var];
     }
 }
 $arResult["QUESTIONS"][$qID]["COUNTER_SUM"] = $counterSum;
 $arResult["QUESTIONS"][$qID]["COUNTER_MAX"] = $counterMax;
 //Images
 $arResult["QUESTIONS"][$qID]["IMAGE"] = CFile::GetFileArray($arResult["QUESTIONS"][$qID]["IMAGE_ID"]);
 //Diagram type
 if (!empty($arParams["QUESTION_DIAGRAM_" . $qID]) && $arParams["QUESTION_DIAGRAM_" . $qID] != "-") {
     $arResult["QUESTIONS"][$qID]["DIAGRAM_TYPE"] = trim($arParams["QUESTION_DIAGRAM_" . $qID]);
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:component.php

示例9: SupportDeadlineNotify


//.........这里部分代码省略.........
     //$oldMess = $MESS;
     IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/support/classes/general/messages.php", $arSite["LANGUAGE_ID"]);
     $sourceName = strlen($arTicket["SOURCE_NAME"]) <= 0 ? "" : "[" . $arTicket["SOURCE_NAME"] . "] ";
     if (intval($arTicket["OWNER_USER_ID"]) > 0 || strlen(trim($arTicket["OWNER_LOGIN"])) > 0) {
         $ownerText = "[" . $arTicket["OWNER_USER_ID"] . "] (" . $arTicket["OWNER_LOGIN"] . ") " . $arTicket["OWNER_NAME"];
         //if(strlen(trim($OWNER_SID)) > 0 && $OWNER_SID != "null") $ownerText = " / " . $ownerText;
     }
     if (intval($arTicket["RESPONSIBLE_USER_ID"]) > 0) {
         $responsibleText = "[" . $arTicket["RESPONSIBLE_USER_ID"] . "] (" . $arTicket["RESPONSIBLE_LOGIN"] . ") " . $arTicket["RESPONSIBLE_NAME"];
         if (CTicket::IsSupportTeam($arTicket["RESPONSIBLE_USER_ID"]) || CTicket::IsAdmin($arTicket["RESPONSIBLE_USER_ID"])) {
             $responsibleText .= " " . GetMessage("SUP_TECHSUPPORT_HINT");
         }
     }
     $arAdminEMails = CTicket::GetAdminEmails();
     if (count($arAdminEMails) > 0) {
         $support_admin_email = implode(",", $arAdminEMails);
     }
     // prepare email to author
     $arrOwnerEMail = array($arTicket["OWNER_EMAIL"]);
     $arrEmails = explode(",", $arTicket["OWNER_SID"]);
     if (is_array($arrEmails) && count($arrEmails) > 0) {
         foreach ($arrEmails as $email) {
             $email = trim($email);
             if (strlen($email) > 0) {
                 preg_match_all("#[<\\[\\(](.*?)[>\\]\\)]#i" . BX_UTF_PCRE_MODIFIER, $email, $arr);
                 if (is_array($arr[1]) && count($arr[1]) > 0) {
                     foreach ($arr[1] as $email) {
                         $email = trim($email);
                         if (strlen($email) > 0 && !in_array($email, $arrOwnerEMail) && check_email($email)) {
                             $arrOwnerEMail[] = $email;
                         }
                     }
                 } elseif (!in_array($email, $arrOwnerEMail) && check_email($email)) {
                     $arrOwnerEMail[] = $email;
                 }
             }
         }
     }
     TrimArr($arrOwnerEMail);
     $ownerEmail = implode(", ", $arrOwnerEMail);
     // prepare email to support
     $support_email = $arTicket["RESPONSIBLE_EMAIL"];
     if (strlen($support_email) <= 0) {
         $support_email = $support_admin_email;
     }
     if (strlen($support_email) <= 0) {
         $support_email = COption::GetOptionString("main", "email_from", "");
     }
     $arr = explode(",", $support_email);
     $arr = array_unique($arr);
     $support_email = implode(",", $arr);
     if (is_array($arr) && count($arr) > 0) {
         foreach ($arr as $email) {
             unset($arAdminEMails[$email]);
         }
     }
     $support_admin_email = implode(",", $arAdminEMails);
     $createdModuleName = "";
     if ($arTicket["CREATED_MODULE_NAME"] == "support" || !strlen($arTicket["CREATED_MODULE_NAME"])) {
         if (intval($arTicket["CREATED_USER_ID"]) > 0) {
             $createdText = "[" . $arTicket["CREATED_USER_ID"] . "] (" . $arTicket["CREATED_LOGIN"] . ") " . $arTicket["CREATED_NAME"];
             if (CTicket::IsSupportTeam($arTicket["CREATED_USER_ID"]) || CTicket::IsAdmin($arTicket["CREATED_USER_ID"])) {
                 $createdText .= " " . GetMessage("SUP_TECHSUPPORT_HINT");
             }
         }
     } else {
         $createdModuleName = "[" . $arTicket["CREATED_MODULE_NAME"] . "]";
     }
     $MESSAGE = PrepareTxtForEmail($arMessage["MESSAGE"], $arSite["LANGUAGE_ID"], false, false);
     $remainedTime = $arMessage["EXPIRATION_DATE_STMP"] - time();
     if ($remainedTime > 0) {
         $strRemainedTime = "";
         $hours = intval($remainedTime / 3600);
         if ($hours > 0) {
             $strRemainedTime .= $hours . " " . GetMessage("SUP_HOUR") . " ";
             $remainedTime = $remainedTime - $hours * 3600;
         }
         $strRemainedTime .= intval($remainedTime / 60) . " " . GetMessage("SUP_MIN") . " ";
         $strRemainedTime .= $remainedTime % 60 . " " . GetMessage("SUP_SEC");
     }
     $arFields_notify = array("ID" => $arTicket["ID"], "LANGUAGE_ID" => $arSite["LANGUAGE_ID"], "DATE_CREATE" => $arTicket["DATE_CREATE"], "TITLE" => $arTicket["TITLE"], "STATUS" => $arTicket["STATUS_NAME"], "CATEGORY" => $arTicket["CATEGORY_NAME"], "CRITICALITY" => $arTicket["CRITICALITY_NAME"], "DIFFICULTY" => $arTicket["DIFFICULTY_NAME"], "RATE" => $arTicket["MARK_NAME"], "SLA" => $arTicket["SLA_NAME"], "SOURCE" => $sourceName, "ADMIN_EDIT_URL" => "/bitrix/admin/ticket_edit.php", "EXPIRATION_DATE" => $arMessage["EXPIRATION_DATE"], "REMAINED_TIME" => $strRemainedTime, "OWNER_EMAIL" => TrimEx($ownerEmail, ","), "OWNER_USER_ID" => $arTicket["OWNER_USER_ID"], "OWNER_USER_NAME" => $arTicket["OWNER_NAME"], "OWNER_USER_LOGIN" => $arTicket["OWNER_LOGIN"], "OWNER_USER_EMAIL" => $arTicket["OWNER_EMAIL"], "OWNER_TEXT" => $ownerText, "OWNER_SID" => $arTicket["OWNER_SID"], "SUPPORT_EMAIL" => TrimEx($support_email, ","), "RESPONSIBLE_USER_ID" => $arTicket["RESPONSIBLE_USER_ID"], "RESPONSIBLE_USER_NAME" => $arTicket["RESPONSIBLE_NAME"], "RESPONSIBLE_USER_LOGIN" => $arTicket["RESPONSIBLE_LOGIN"], "RESPONSIBLE_USER_EMAIL" => $arTicket["RESPONSIBLE_EMAIL"], "RESPONSIBLE_TEXT" => $responsibleText, "SUPPORT_ADMIN_EMAIL" => TrimEx($support_admin_email, ","), "CREATED_USER_ID" => $arTicket["CREATED_USER_ID"], "CREATED_USER_LOGIN" => $arTicket["CREATED_LOGIN"], "CREATED_USER_EMAIL" => $arTicket["CREATED_EMAIL"], "CREATED_USER_NAME" => $arTicket["CREATED_NAME"], "CREATED_MODULE_NAME" => $createdModuleName, "CREATED_TEXT" => $createdText, "MESSAGE_BODY" => $MESSAGE);
     //$MESS = $oldMess;
     $arFields = array("NOTIFY_AGENT_ID" => "null", "IS_NOTIFIED" => "'Y'");
     // execute event
     $rs = GetModuleEvents('support', 'OnBeforeTicketNotify');
     while ($arr = $rs->Fetch()) {
         $arFields = ExecuteModuleEventEx($arr, array($arTicket["ID"], $arFields));
         if (!$arFields) {
             return false;
         }
     }
     // check value again and send notification
     if (isset($arFields['IS_NOTIFIED']) && $arFields['IS_NOTIFIED'] === "'Y'") {
         CEvent::Send("TICKET_OVERDUE_REMINDER", $arTicket["SITE_ID"], $arFields_notify);
     }
     // event for notification
     $DB->Update("b_ticket", $arFields, "WHERE ID='" . $arTicket["ID"] . "'", $err_mess . __LINE__);
     $arFields = array("NOTIFY_AGENT_DONE" => "'Y'");
     $DB->Update("b_ticket_message", $arFields, "WHERE ID='" . $arMessage["ID"] . "'", $err_mess . __LINE__);
 }
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:reminder.php

示例10: GetList

 public static function GetList($arSort = array(), $arFilter = array())
 {
     global $DB;
     $arSqlSearch = array();
     $err_mess = self::err_mess() . '<br />Function: GetList<br>Line: ';
     if (is_array($arFilter)) {
         self::PrepareSearchQuery($arFilter, $arSqlSearch);
     }
     $sOrder = '';
     foreach ($arSort as $key => $val) {
         $ord = strtoupper($val) != 'ASC' ? 'DESC' : 'ASC';
         switch (strtoupper($key)) {
             case 'ID':
                 $sOrder .= ', CFM.ID ' . $ord;
                 break;
             case 'ENTITY_ID':
                 $sOrder .= ', CFM.ENTITY_ID ' . $ord;
                 break;
             case 'ELEMENT_ID':
                 $sOrder .= ', CFM.ELEMENT_ID ' . $ord;
                 break;
             case 'TYPE_ID':
                 $sOrder .= ', CFM.TYPE_ID ' . $ord;
                 break;
             case 'VALUE_TYPE':
                 $sOrder .= ', CFM.VALUE_TYPE ' . $ord;
                 break;
             case 'COMPLEX_ID':
                 $sOrder .= ', CFM.COMPLEX_ID ' . $ord;
                 break;
             case 'VALUE':
                 $sOrder .= ', CFM.VALUE ' . $ord;
                 break;
         }
     }
     if (strlen($sOrder) <= 0) {
         $sOrder = 'CFM.ID DESC';
     }
     $strSqlOrder = ' ORDER BY ' . TrimEx($sOrder, ",");
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tCFM.ID, CFM.ENTITY_ID, CFM.ELEMENT_ID, CFM.TYPE_ID, CFM.VALUE_TYPE, CFM.COMPLEX_ID, CFM.VALUE\n\t\t\tFROM\n\t\t\t\tb_crm_field_multi CFM\n\t\t\tWHERE\n\t\t\t{$strSqlSearch}\n\t\t\t{$strSqlOrder}";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $res;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:44,代码来源:crm_field_multi.php

示例11: max

			$counterMax = max(intVal($arAnswer["COUNTER"]), $counterMax);
		}

		if ($arParams["NEED_SORT"] != "N")
			uasort($arQuestion["ANSWERS"], "_vote_answer_sort");
		$color = "";

		foreach ($arQuestion["ANSWERS"] as $aID => $arAnswer)
		{
			$arResult["LAST_VOTE"] = ($arResult["LAST_VOTE"] === false ? $arAnswer["LAST_VOTE"] : $arResult["LAST_VOTE"]);
			$arResult["LAST_VOTE"] = min($arResult["LAST_VOTE"], $arAnswer["LAST_VOTE"]);
			$arAnswer["PERCENT"] = ($counterSum > 0 ? number_format(($arAnswer["COUNTER"]*100/$counter),0,",","") : 0);
			$arAnswer["BAR_PERCENT"] = ($arAnswer["FIELD_TYPE"] == 0 || $arAnswer["FIELD_TYPE"] == 2 ?  /* radio || dropdown */
				($counterMax > 0 ? round($arAnswer["COUNTER"]*100/$counterMax) : 0) : round($arAnswer["PERCENT"]));
			$arAnswer["COLOR"] = (empty($arAnswer["COLOR"]) && ($color = GetNextRGB($color, count($arQuestion["ANSWERS"]))) ?
				$color : TrimEx($arAnswer["COLOR"], "#"));
			$arQuestion["ANSWERS"][$aID] = $arAnswer;
		}
		$arResult["QUESTIONS"][$qID]["COUNTER_SUM"] = $counterSum;
		$arResult["QUESTIONS"][$qID]["COUNTER_MAX"] = $counterMax;

		//Images
		$arResult["QUESTIONS"][$qID]["IMAGE"] = CFile::GetFileArray($arResult["QUESTIONS"][$qID]["IMAGE_ID"]);

		//Diagram type
		if (!empty($arParams["QUESTION_DIAGRAM_".$qID]) && $arParams["QUESTION_DIAGRAM_".$qID]!="-")
			$arResult["QUESTIONS"][$qID]["DIAGRAM_TYPE"] = trim($arParams["QUESTION_DIAGRAM_".$qID]);

		//Answers
		$arResult["QUESTIONS"][$qID]["ANSWERS"] = $arQuestion["ANSWERS"];
	}
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:31,代码来源:component.php

示例12: GetList


//.........这里部分代码省略.........
         foreach ($arEntity as $sEntityType) {
             $arEntityAttr = $CCrmPerms->GetUserAttrForSelectEntity($sEntityType, 'READ');
             $arUserAttr[$sEntityType] = $arEntityAttr;
         }
         if (empty($arUserAttr)) {
             $CDBResult = new CDBResult();
             $CDBResult->InitFromArray(array());
             return $CDBResult;
         }
         $arUserPerm = array();
         foreach ($arUserAttr as $sEntityType => $_arAttrs) {
             if (isset($_arAttrs[0]) && is_array($_arAttrs[0]) && empty($_arAttrs[0])) {
                 $arInEntity[] = $sEntityType;
                 continue;
             }
             foreach ($_arAttrs as $_arAttr) {
                 if (empty($_arAttr)) {
                     continue;
                 }
                 $_icnt = count($_arAttr);
                 $_idcnt = -1;
                 foreach ($_arAttr as $sAttr) {
                     if ($sAttr[0] == 'D') {
                         $_idcnt++;
                     }
                 }
                 if ($_icnt == 1 && ($_idcnt == 1 || $_idcnt == -1)) {
                     $_idcnt = 0;
                 }
                 $arUserPerm[] = "(P.ENTITY = '{$sEntityType}' AND SUM(CASE WHEN P.ATTR = '" . implode("' or P.ATTR = '", $_arAttr) . "' THEN 1 ELSE 0 END) = " . ($_icnt - $_idcnt) . ')';
             }
         }
         $arPermission = array();
         if (!empty($arInEntity)) {
             $arPermission[] = " CER.ENTITY_TYPE IN ('" . implode("','", $arInEntity) . "')";
         }
         if (!empty($arUserPerm)) {
             $arPermission[] = "\n\t\t\t\t\t\tEXISTS(\n\t\t\t\t\t\t\tSELECT 1\n\t\t\t\t\t\t\tFROM b_crm_entity_perms P\n\t\t\t\t\t\t\tWHERE P.ENTITY = CER.ENTITY_TYPE AND CER.ENTITY_ID = P.ENTITY_ID\n\t\t\t\t\t\t\tGROUP BY P.ENTITY, P.ENTITY_ID\n\t\t\t\t\t\t\tHAVING " . implode(" \n\t\t\t\t\t\t\t\tOR ", $arUserPerm) . "\n\t\t\t\t\t\t)";
         }
         if (!empty($arPermission)) {
             $strPermission = 'AND (' . implode(' OR ', $arPermission) . ')';
         }
     }
     $sOrder = '';
     foreach ($arSort as $key => $val) {
         $ord = strtoupper($val) != 'ASC' ? 'DESC' : 'ASC';
         switch (strtoupper($key)) {
             case 'ID':
                 $sOrder .= ', CER.ID ' . $ord;
                 break;
             case 'CREATED_BY_ID':
                 $sOrder .= ', CE.CREATED_BY_ID ' . $ord;
                 break;
             case 'EVENT_TYPE':
                 $sOrder .= ', CE.EVENT_TYPE ' . $ord;
                 break;
             case 'ENTITY_TYPE':
                 $sOrder .= ', CER.ENTITY_TYPE ' . $ord;
                 break;
             case 'ENTITY_ID':
                 $sOrder .= ', CER.ENTITY_ID ' . $ord;
                 break;
             case 'EVENT_ID':
                 $sOrder .= ', CE.EVENT_ID ' . $ord;
                 break;
             case 'DATE_CREATE':
                 $sOrder .= ', CE.DATE_CREATE ' . $ord;
                 break;
             case 'EVENT_NAME':
                 $sOrder .= ', CE.EVENT_NAME 	 ' . $ord;
                 break;
             case 'ENTITY_FIELD':
                 $sOrder .= ', CER.ENTITY_FIELD 	 ' . $ord;
                 break;
         }
     }
     if (strlen($sOrder) <= 0) {
         $sOrder = 'CER.ID DESC';
     }
     $strSqlOrder = ' ORDER BY ' . TrimEx($sOrder, ',');
     // where
     $arWhereFields = array('ID' => array('TABLE_ALIAS' => 'CER', 'FIELD_NAME' => 'CER.ID', 'FIELD_TYPE' => 'int', 'JOIN' => false), 'ENTITY_TYPE' => array('TABLE_ALIAS' => 'CER', 'FIELD_NAME' => 'CER.ENTITY_TYPE', 'FIELD_TYPE' => 'string', 'JOIN' => false), 'EVENT_REL_ID' => array('TABLE_ALIAS' => 'CER', 'FIELD_NAME' => 'CER.EVENT_ID', 'FIELD_TYPE' => 'string', 'JOIN' => false), 'EVENT_ID' => array('TABLE_ALIAS' => 'CE', 'FIELD_NAME' => 'CE.EVENT_ID', 'FIELD_TYPE' => 'string', 'JOIN' => false), 'CREATED_BY_ID' => array('TABLE_ALIAS' => 'CE', 'FIELD_NAME' => 'CE.CREATED_BY_ID', 'FIELD_TYPE' => 'int', 'JOIN' => false), 'ASSIGNED_BY_ID' => array('TABLE_ALIAS' => 'CER', 'FIELD_NAME' => 'CER.ASSIGNED_BY_ID', 'FIELD_TYPE' => 'int', 'JOIN' => false), 'EVENT_TYPE' => array('TABLE_ALIAS' => 'CE', 'FIELD_NAME' => 'CE.EVENT_TYPE', 'FIELD_TYPE' => 'string', 'JOIN' => false), 'EVENT_DESC' => array('TABLE_ALIAS' => 'CE', 'FIELD_NAME' => 'CE.EVENT_TEXT_1', 'FIELD_TYPE' => 'string', 'JOIN' => false), 'ENTITY_ID' => array('TABLE_ALIAS' => 'CER', 'FIELD_NAME' => 'CER.ENTITY_ID', 'FIELD_TYPE' => 'int', 'JOIN' => false), 'ENTITY_FIELD' => array('TABLE_ALIAS' => 'CER', 'FIELD_NAME' => 'CER.ENTITY_FIELD', 'FIELD_TYPE' => 'string', 'JOIN' => false), 'DATE_CREATE' => array('TABLE_ALIAS' => 'CE', 'FIELD_NAME' => 'CE.DATE_CREATE', 'FIELD_TYPE' => 'datetime', 'JOIN' => false));
     $obQueryWhere = new CSQLWhere();
     $obQueryWhere->SetFields($arWhereFields);
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $sQueryWhereFields = $obQueryWhere->GetQuery($arFilter);
     if (!empty($sQueryWhereFields)) {
         $strSqlSearch .= "\n\t\t\t\tAND ({$sQueryWhereFields}) ";
     }
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tCER.ID,\n\t\t\t\tCER.ENTITY_TYPE,\n\t\t\t\tCER.ENTITY_ID,\n\t\t\t\tCER.ENTITY_FIELD,\n\t\t\t\t" . $DB->DateToCharFunction('CE.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\tCER.EVENT_ID,\n\t\t\t\tCE.EVENT_NAME,\n\t\t\t\tCE.EVENT_TYPE,\n\t\t\t\tCE.EVENT_TEXT_1,\n\t\t\t\tCE.EVENT_TEXT_2,\n\t\t\t\tCE.FILES,\n\t\t\t\tCE.CREATED_BY_ID,\n\t\t\t\tU.LOGIN as CREATED_BY_LOGIN,\n\t\t\t\tU.NAME as CREATED_BY_NAME,\n\t\t\t\tU.LAST_NAME as CREATED_BY_LAST_NAME,\n\t\t\t\tU.SECOND_NAME as CREATED_BY_SECOND_NAME\n\t\t\tFROM\n\t\t\t\tb_crm_event_relations CER,\n\t\t\t\tb_crm_event CE LEFT JOIN b_user U ON CE.CREATED_BY_ID = U.ID\n\t\t\tWHERE\n\t\t\t\tCER.EVENT_ID = CE.ID\n\t\t\t\t{$strSqlSearch}\n\t\t\t\t{$strPermission}\n\t\t\t\t{$strSqlOrder}";
     if ($nPageTop !== false) {
         $nPageTop = (int) $nPageTop;
         $strSql = $DB->TopSql($strSql, $nPageTop);
     }
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     $res->SetUserFields(array('FILES' => array('MULTIPLE' => 'Y')));
     return $res;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:crm_event.php

示例13: GetVetting

 public static function GetVetting($arFilter, $arSort)
 {
     global $DB;
     $err_mess = CRatingRule::err_mess() . "<br>Function: GetVetting<br>Line: ";
     $arSqlSearch = array();
     if (is_array($arFilter)) {
         $filter_keys = array_keys($arFilter);
         for ($i = 0; $i < count($filter_keys); $i++) {
             $val = $arFilter[$filter_keys[$i]];
             if (strlen($val) <= 0 || $val == "NOT_REF") {
                 continue;
             }
             switch (strtoupper($filter_keys[$i])) {
                 case "RULE_ID":
                     $arSqlSearch[] = GetFilterQuery("RULE_ID", $val, "N");
                     break;
                 case "ENTITY_TYPE_ID":
                     $arSqlSearch[] = GetFilterQuery("ENTITY_TYPE_ID", $val, "N");
                     break;
                 case "ENTITY_ID":
                     $arSqlSearch[] = GetFilterQuery("ENTITY_ID", $val, "N");
                     break;
                 case "APPLIED":
                     if (in_array($val, array('Y', 'N'))) {
                         $arSqlSearch[] = "APPLIED = '" . $val . "'";
                     }
                     break;
             }
         }
     }
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $sOrder = "";
     foreach ($arSort as $key => $val) {
         $ord = strtoupper($val) != "ASC" ? "DESC" : "ASC";
         switch (strtoupper($key)) {
             case "ID":
                 $sOrder .= ", ID " . $ord;
                 break;
             case "RULE_ID":
                 $sOrder .= ", RULE_ID " . $ord;
                 break;
             case "ENTITY_TYPE_ID":
                 $sOrder .= ", ENTITY_TYPE_ID " . $ord;
                 break;
             case "ENTITY_ID":
                 $sOrder .= ", ENTITY_ID " . $ord;
                 break;
             case "APPLIED":
                 $sOrder .= ", APPLIED " . $ord;
                 break;
         }
     }
     if (strlen($sOrder) <= 0) {
         $sOrder = "ID ASC";
     }
     $strSqlOrder = " ORDER BY " . TrimEx($sOrder, ",");
     $strSql = "SELECT * FROM b_rating_rule_vetting WHERE {$strSqlSearch} {$strSqlOrder}";
     return $DB->Query($strSql, false, $err_mess . __LINE__);
 }
开发者ID:rasuldev,项目名称:torino,代码行数:59,代码来源:rating_rule.php

示例14: GetList

 public function GetList($aSort = array(), $arFilter = array())
 {
     global $DB;
     $arSqlSearch = array();
     if (is_array($arFilter)) {
         foreach ($arFilter as $key => $val) {
             if (strlen($val) <= 0 || $val == "NOT_REF") {
                 continue;
             }
             $key = strtoupper($key);
             switch ($key) {
                 case "ID":
                 case "CODE_ID":
                 case "USER_ID":
                     $arSqlSearch[] = $key . "=" . intval($val);
                     break;
                 case "KEYS_STRING":
                     $arSqlSearch[] = GetFilterQuery("KEYS_STRING", $val);
                     break;
             }
         }
     }
     $sOrder = "";
     foreach ($aSort as $key => $val) {
         $ord = strtoupper($val) != "ASC" ? "DESC" : "ASC";
         switch (strtoupper($key)) {
             case "ID":
                 $sOrder .= ", ID " . $ord;
                 break;
             case "KEYS_STRING":
                 $sOrder .= ", KEYS_STRING " . $ord;
                 break;
             case "CODE_ID":
                 $sOrder .= ", CODE_ID " . $ord;
                 break;
             case "USER_ID":
                 $sOrder .= ", USER_ID " . $ord;
                 break;
         }
     }
     if (strlen($sOrder) > 0) {
         $strSqlOrder = " ORDER BY " . TrimEx($sOrder, ",");
     } else {
         $strSqlOrder = "";
     }
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $strSql = "\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tb_hot_keys\n\t\t\tWHERE\n\t\t\t" . $strSqlSearch . "\n\t\t\t" . $strSqlOrder;
     $res = $DB->Query($strSql, false, $this->ErrOrig() . " Line: " . __LINE__);
     return $res;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:50,代码来源:hot_keys.php

示例15: GetDataByID


//.........这里部分代码省略.........
	 * // выведем поля результата
	 * echo "&lt;pre&gt;"; print_r($arResult); echo "&lt;/pre&gt;";
	 * 
	 * // выведем значения ответов
	 * echo "&lt;pre&gt;"; print_r($arAnswer); echo "&lt;/pre&gt;";
	 * 
	 * // выведем значения ответов в несколько ином формате
	 * echo "&lt;pre&gt;"; print_r($arAnswer2); echo "&lt;/pre&gt;";
	 * ?&gt;
	 * 
	 * &lt;?
	 * $RESULT_ID = 189; // ID результата
	 * 
	 * // получим данные по всем вопросам
	 * $arAnswer = <b>CFormResult::GetDataByID</b>(
	 * 	$RESULT_ID, 
	 * 	array(), 
	 * 	$arResult, 
	 * 	$arAnswer2);
	 * 
	 * // выведем поля результата
	 * echo "&lt;pre&gt;"; print_r($arResult); echo "&lt;/pre&gt;";
	 * 
	 * // выведем значения ответов
	 * echo "&lt;pre&gt;"; print_r($arAnswer); echo "&lt;/pre&gt;";
	 * 
	 * // выведем значения ответов в несколько ином формате
	 * echo "&lt;pre&gt;"; print_r($arAnswer2); echo "&lt;/pre&gt;";
	 * ?&gt;
	 * </pre>
	 *
	 *
	 *
	 * <h4>See Also</h4> 
	 * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/index.php">Поля CFormResult</a> </li>
	 * <li> <a href="http://dev.1c-bitrix.ru/api_help/form/classes/cform/index.php">Поля CForm</a> </li> <li> <a
	 * href="http://dev.1c-bitrix.ru/api_help/form/classes/cform/getresultanswerarray.php">CForm::GetResultAnswerArray</a>
	 * </li> </ul><a name="examples"></a>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/getdatabyid.php
	 * @author Bitrix
	 */
	public static function GetDataByID($RESULT_ID, $arrFIELD_SID, &$arrRES, &$arrANSWER)
	{
		global $DB, $strError;
		$err_mess = (CAllFormResult::err_mess())."<br>Function: GetDataByID<br>Line: ";
		$arrReturn = array();
		$RESULT_ID = intval($RESULT_ID);
		$z = CFormResult::GetByID($RESULT_ID);
		if ($arrRES = $z->Fetch())
		{
			if (is_array($arrFIELD_SID) && count($arrFIELD_SID)>0)
			{
				foreach($arrFIELD_SID as $field) $str .= ",'".$DB->ForSql($field,50)."'";
				$str = TrimEx($str,",");
				if (strlen($str)>0) $s = "and SID in ($str)";
			}
			$strSql = "SELECT ID, SID, SID as VARNAME FROM b_form_field WHERE FORM_ID='".$arrRES["FORM_ID"]."' ".$s;
			$q = $DB->Query($strSql, false, $err_mess.__LINE__);
			while ($qr = $q->Fetch())
			{
				$arrFIELDS[$qr["ID"]] = $qr["SID"];
			}
			if (is_array($arrFIELDS)) $arrKeys = array_keys($arrFIELDS);
			CForm::GetResultAnswerArray($arrRES["FORM_ID"], $arrColumns, $arrAnswers, $arrAnswersSID, array("RESULT_ID"=>$RESULT_ID));

			foreach ($arrAnswers[$RESULT_ID] as $fid => $arrAns)
			{
				if (is_array($arrKeys))
				{
					if (in_array($fid,$arrKeys))
					{
						$sid = $arrFIELDS[$fid];
						$arrANSWER[$sid] = $arrAns;
						$arrA = array_values($arrAns);
						foreach($arrA as $arr) $arrReturn[$sid][] = $arr;
					}
				}
			}
		}
		else return false;

		if (is_array($arrANSWER)) reset($arrANSWER);
		if (is_array($arrReturn)) reset($arrReturn);
		if (is_array($arrRES)) reset($arrRES);

		/*
		echo "<pre>arrRES\n";
		print_r($arrRES);
		echo "arrANSWER\n";
		print_r($arrANSWER);
		echo "arrReturn\n";
		print_r($arrReturn);
		echo "</pre>";
		*/

		return $arrReturn;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:form_callformresult.php


注:本文中的TrimEx函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。