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


PHP CRatings::Calculate方法代码示例

本文整理汇总了PHP中CRatings::Calculate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRatings::Calculate方法的具体用法?PHP CRatings::Calculate怎么用?PHP CRatings::Calculate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRatings的用法示例。


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

示例1: array

        if ($arRes['ACTIVE'] == 'N') {
            CRatings::Delete($arRes['ID']);
        } else {
            $authorityId = $arRes['ID'];
        }
    }
    if ($authorityId == false) {
        $arConfig = array();
        $arConfig['MAIN'] = array('VOTE' => array('USER' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '1', 'LIMIT' => '30')), 'RATING' => array('BONUS' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '1')));
        $arAddRating = array('ACTIVE' => 'Y', 'NAME' => GetMessage('MAIN_RATING_AUTHORITY'), 'ENTITY_ID' => 'USER', 'CALCULATION_METHOD' => 'SUM', 'POSITION' => 'Y', 'AUTHORITY' => 'Y', 'CONFIGS' => $arConfig);
        $authorityId = CRatings::Add($arAddRating);
    }
    $strSql = "\n\t\t\tINSERT INTO b_rating_user (ENTITY_ID, RATING_ID)\n\t\t\tSELECT \n\t\t\t\tu.ID, '{$authorityId}'\n\t\t\tFROM \n\t\t\t\tb_user u \n\t\t\t\tLEFT JOIN b_rating_user ru ON ru.RATING_ID = {$authorityId} AND ru.ENTITY_ID = u.ID \n\t\t\tWHERE \n\t\t\t\tru.ENTITY_ID IS NULL";
    $DB->Query($strSql, false, $err_mess . __LINE__);
    $arParams = array();
    $arParams['DEFAULT_CONFIG_NEW_USER'] = 'Y';
    CRatings::SetAuthorityDefaultValue($arParams);
    CRatings::Calculate($authorityId, true);
    CRatings::Calculate($ratingId, true);
    $ratingArray = 'array(1 => "' . $ratingId . '", 2 => "' . $authorityId . '")';
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/forum/index.php", array("SHOW_RATING" => 'Y'));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/forum/index.php", array("RATING_ID" => $ratingArray));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/people/index.php", array("RATING_ID" => $ratingId));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/people/user.php", array("RATING_ID" => $ratingArray));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/groups/group.php", array("RATING_ID" => $ratingId));
    COption::SetOptionString("socialnetwork", "tooltip_rating_id", serialize(array($ratingId, $authorityId)), "", WIZARD_SITE_ID);
    COption::SetOptionString("socialnetwork", "tooltip_show_rating", "Y", "", WIZARD_SITE_ID);
    COption::SetOptionString("main", "rating_normalization", 10);
    COption::SetOptionString("forum", "SHOW_VOTES", "N");
    COption::SetOptionString("main", "rating_vote_type", 'like');
}
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:rating.php

示例2: while

$bCreateRule = true;
$rsData = $DB->Query("SELECT ID, ACTIVE FROM b_rating_rule WHERE CONDITION_MODULE = 'intranet'");
while ($arRule = $rsData->Fetch()) {
    if ($arRule["ACTIVE"] == "N") {
        $DB->Query("DELETE FROM b_rating_rule WHERE ID = " . $arRule["ID"], true);
    } else {
        COption::SetOptionString("intranet", "ratingSubordinateId", $arRule['ID']);
        CRatingRule::Apply($arRule['ID']);
        $bCreateRule = false;
    }
}
// после авторитета
if ($bCreateRule) {
    $dbRes = CLanguage::GetList($by = 'sort', $order = 'asc');
    while ($arRes = $dbRes->Fetch()) {
        if (file_exists(dirname(__FILE__) . '/' . $arRes['LID'] . '/rating.php')) {
            require dirname(__FILE__) . '/' . $arRes['LID'] . '/rating.php';
        }
    }
    $arFields = array("ACTIVE" => "Y", "NAME" => $MESS['INTR_INSTALL_RATING_RULE'], "ENTITY_TYPE_ID" => "USER", "CONDITION_NAME" => "SUBORDINATE", "CONDITION_MODULE" => "intranet", "CONDITION_CLASS" => "CRatingRulesIntranet", "CONDITION_METHOD" => "subordinateCheck", "CONDITION_CONFIG" => array("SUBORDINATE" => array()), "ACTION_NAME" => "empty", "ACTION_CONFIG" => array(), "ACTIVATE" => "N", "ACTIVATE_CLASS" => "empty", "ACTIVATE_METHOD" => "empty", "DEACTIVATE" => "N", "DEACTIVATE_CLASS" => "empty ", "DEACTIVATE_METHOD" => "empty", "~CREATED" => $DB->GetNowFunction(), "~LAST_MODIFIED" => $DB->GetNowFunction());
    $arFields["CONDITION_CONFIG"] = serialize($arFields["CONDITION_CONFIG"]);
    $arFields["ACTION_CONFIG"] = serialize($arFields["ACTION_CONFIG"]);
    $ID = $DB->Add("b_rating_rule", $arFields, array("ACTION_CONFIG", "CONDITION_CONFIG"));
    COption::SetOptionString("intranet", "ratingSubordinateId", $ID);
    CRatingRule::Apply($ID);
}
// recount ratings
$rsData = CRatings::GetList(array('ID' => 'ASC'), array());
while ($arRes = $rsData->Fetch()) {
    CRatings::Calculate($arRes['ID'], true);
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:rating.php

示例3: Update

 /**
  * <p>Метод изменяет параметры рейтинга с идентификатором <i>id</i>. Динамичный метод.</p>
  *
  *
  * @param int $id  Идентификатор рейтинга.
  *
  * @param array $fields  Массив значений параметров. В качестве ключей данного массива
  * допустимо использовать: <ul> <li> <b>NAME</b> – название рейтинга</li> <li>
  * <b>ACTIVE</b> – активность рейтинга (Y|N)</li> <li> <b>ENTITY_ID</b> – оцениваемый
  * объект (например: USER, BLOG, и т.д.)</li> <li> <b>CALCULATION_METHOD</b> – тип подсчета
  * рейтинга (SUM-суммирование критериев, AVG – средние значение
  * критериев)</li> <li> <b>CONFIGS</b> – массив, описывающий критерии
  * рейтингования</li> <li> <b>NEW_CALC</b> – обнуляет предыдущее значение
  * рейтинга</li> </ul>
  *
  * @return bool 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * // изменим название рейтинга и сделаем его не активным
  * $arUpdateRating = array(
  * 	'ACTIVE' =&gt; 'N',
  * 	'NAME' =&gt; 'Рейтинг, измененный через API',
  * );
  * $result = CRatings::Update(1, $arUpdateRating);
  * if ($result)
  *     echo "Рейтинг успешно обновлен.";
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li><a href="http://dev.1c-bitrix.ru/api_help/main/reference/cratings/add.php">CRating::Add</a></li> </ul><a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cratings/update.php
  * @author Bitrix
  */
 public static function Update($ID, $arFields)
 {
     global $DB, $stackCacheManager;
     $ID = intval($ID);
     $err_mess = CRatings::err_mess() . "<br>Function: Update<br>Line: ";
     // check only general field
     if (!CRatings::__CheckFields($arFields)) {
         return false;
     }
     $arFields_u = array("ACTIVE" => $arFields['ACTIVE'] == 'Y' ? 'Y' : 'N', "NAME" => $arFields["NAME"], "ENTITY_ID" => $arFields["ENTITY_ID"], "CALCULATION_METHOD" => $arFields["CALCULATION_METHOD"], "~LAST_MODIFIED" => $DB->GetNowFunction());
     $strUpdate = $DB->PrepareUpdate("b_rating", $arFields_u);
     if (!$DB->Query("UPDATE b_rating SET " . $strUpdate . " WHERE ID=" . $ID, false, $err_mess . __LINE__)) {
         return false;
     }
     if (!isset($arFields["CONFIGS"])) {
         $stackCacheManager->Clear("b_rating");
         return true;
     }
     // queries modules and give them to inspect the field settings
     foreach (GetModuleEvents("main", "OnAfterUpdateRating", true) as $arEvent) {
         $arFields = ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     CRatings::__UpdateComponents($ID, $arFields);
     $arFields_u = array("POSITION" => "'" . ($arFields['POSITION'] == 'Y' ? 'Y' : 'N') . "'", "AUTHORITY" => "'" . ($arFields['AUTHORITY'] == 'Y' ? 'Y' : 'N') . "'", "CONFIGS" => "'" . $DB->ForSQL(serialize($arFields["CONFIGS"])) . "'");
     $DB->Update("b_rating", $arFields_u, "WHERE ID = " . $ID);
     if ($arFields['AUTHORITY'] == 'Y') {
         CRatings::SetAuthorityRating($ID);
     }
     if ($arFields['NEW_CALC'] == 'Y') {
         $DB->Query("UPDATE b_rating_results SET PREVIOUS_VALUE = 0 WHERE RATING_ID=" . $ID . " and ENTITY_TYPE_ID='" . $DB->ForSql($arFields["ENTITY_ID"]) . "'", false, $err_mess . __LINE__);
     }
     $strSql = "SELECT COMPLEX_NAME FROM b_rating_component WHERE RATING_ID = {$ID} and ACTIVE = 'N'";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     $arrRatingComponentId = array();
     while ($arRes = $res->Fetch()) {
         $arrRatingComponentId[] = $arRes['COMPLEX_NAME'];
     }
     if (!empty($arrRatingComponentId)) {
         $DB->Query("DELETE FROM b_rating_component_results WHERE RATING_ID = {$ID} AND COMPLEX_NAME IN ('" . implode("','", $arrRatingComponentId) . "')", false, $err_mess . __LINE__);
     }
     CRatings::Calculate($ID, true);
     CAgent::RemoveAgent("CRatings::Calculate({$ID});", "main");
     $AID = CAgent::AddAgent("CRatings::Calculate({$ID});", "main", "N", 3600, "", "Y", "");
     $stackCacheManager->Clear("b_rating");
     return true;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:87,代码来源:ratings.php

示例4: IntVal

	if($_REQUEST['action_target']=='selected')
	{
		$rsData = CRatings::GetList(array($by=>$order), $arFilter);
		while($arRes = $rsData->Fetch())
			$arID[] = $arRes['ID'];
	}

	foreach($arID as $ID)
	{
		$ID = IntVal($ID);
		if($ID <= 0)
			continue;
		switch($_REQUEST['action'])
		{
			case "recalculate":
				if(!CRatings::Calculate($ID, true))
					$lAdmin->AddGroupError(GetMessage("RATING_LIST_ERR_CAL"), $ID);
			break;
			case "delete":
				if(!CRatings::Delete($ID))
					$lAdmin->AddGroupError(GetMessage("RATING_LIST_ERR_DEL"), $ID);
			break;
		}
	}
}

$rsData = CRatings::GetList(array($by=>$order), $arFilter);
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("RATING_LIST_NAV")));
开发者ID:ASDAFF,项目名称:open_bx,代码行数:30,代码来源:rating_list.php


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