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


PHP CSocNetGroup::Update方法代码示例

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


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

示例1: updateGroup

 public static function updateGroup($arFields)
 {
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "~" || substr($key, 0, 1) == "=") {
             unset($arFields[$key]);
         }
     }
     if (isset($arFields["IMAGE_ID"])) {
         unset($arFields["IMAGE_ID"]);
     }
     $groupID = $arFields['GROUP_ID'];
     unset($arFields['GROUP_ID']);
     if (intval($groupID) <= 0) {
         throw new Exception('Wrong group ID');
     }
     $arFilter = array("ID" => $groupID);
     if (!CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false)) {
         $arFilter['CHECK_PERMISSIONS'] = $GLOBALS["USER"]->GetID();
     }
     $dbRes = CSocNetGroup::GetList(array(), $arFilter);
     $arGroup = $dbRes->Fetch();
     if (is_array($arGroup)) {
         if ($arGroup["OWNER_ID"] == $GLOBALS["USER"]->GetID() || CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false)) {
             $res = CSocNetGroup::Update($arGroup["ID"], $arFields, false);
             if (intval($res) <= 0) {
                 throw new Exception('Cannot update group');
             }
         } else {
             throw new Exception('User has no permissions to update group');
         }
         return $res;
     } else {
         throw new Exception('Socialnetwork group not found');
     }
     return false;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:36,代码来源:rest.php

示例2: updateGroup

	public static function updateGroup($arFields)
	{
		$groupID = $arFields['GROUP_ID'];
		unset($arFields['GROUP_ID']);

		if(intval($groupID) <= 0)
			throw new Exception('Wrong group ID');

		$dbRes = CSocNetGroup::GetList(array(), array(
			"ID" => $groupID,
			"CHECK_PERMISSIONS" => "Y"
		));
		$arGroup = $dbRes->Fetch();
		if(is_array($arGroup))
		{
			if (
				$arGroup["OWNER_ID"] == $GLOBALS["USER"]->GetID()
				|| CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false)
			)
			{
				$res = CSocNetGroup::Update($arGroup["ID"], $arFields, false);
				if(intval($res) <= 0)
					throw new Exception('Cannot update group');
			}
			else
				throw new Exception('User has no permissions to update group');

			return $res;
		}
		else
			throw new Exception('Socialnetwork group not found');

		return false;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:34,代码来源:rest.php

示例3: SetOwner

 function SetOwner($userID, $groupID, $arGroup = false)
 {
     global $DB, $APPLICATION, $USER;
     if (!$arGroup) {
         $arGroup = CSocNetGroup::GetByID($groupID);
     }
     if (!$arGroup) {
         return false;
     }
     $DB->StartTransaction();
     // setting relations for the old owner
     $dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $arGroup["OWNER_ID"], "GROUP_ID" => $groupID), false, false, array("ID"));
     if ($arRelation = $dbRelation->Fetch()) {
         $arFields = array("ROLE" => SONET_ROLES_USER, "=DATE_UPDATE" => $DB->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $USER->GetID());
         if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields)) {
             $errorMessage = "";
             if ($e = $APPLICATION->GetException()) {
                 $errorMessage = $e->GetString();
             }
             if (StrLen($errorMessage) <= 0) {
                 $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_CURRENT_OWNER");
             }
             $APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
             $DB->Rollback();
             return false;
         }
     } else {
         $errorMessage = "";
         if ($e = $APPLICATION->GetException()) {
             $errorMessage = $e->GetString();
         }
         if (StrLen($errorMessage) <= 0) {
             $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_GET_CURRENT_OWNER_RELATION");
         }
         $APPLICATION->ThrowException($errorMessage, "ERROR_GET_USER2GROUP");
         $DB->Rollback();
         return false;
     }
     // delete requests to the old owner
     if (strlen($errorMessage) <= 0) {
         CSocNetUserToGroup::__SpeedFileDelete($arGroup["OWNER_ID"]);
     }
     if (strlen($errorMessage) <= 0) {
         // setting relations for the new owner
         $dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $userID, "GROUP_ID" => $groupID), false, false, array("ID"));
         if ($arRelation = $dbRelation->Fetch()) {
             $arFields = array("ROLE" => SONET_ROLES_OWNER, "=DATE_UPDATE" => $DB->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $USER->GetID());
             if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields)) {
                 $errorMessage = "";
                 if ($e = $APPLICATION->GetException()) {
                     $errorMessage = $e->GetString();
                 }
                 if (StrLen($errorMessage) <= 0) {
                     $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_NEW_OWNER_RELATION");
                 }
                 $APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
                 $DB->Rollback();
                 return false;
             }
         } else {
             $arFields = array("USER_ID" => $userID, "GROUP_ID" => $groupID, "ROLE" => SONET_ROLES_OWNER, "=DATE_CREATE" => $DB->CurrentTimeFunction(), "=DATE_UPDATE" => $DB->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $USER->GetID(), "MESSAGE" => false);
             if (!CSocNetUserToGroup::Add($arFields)) {
                 $errorMessage = "";
                 if ($e = $APPLICATION->GetException()) {
                     $errorMessage = $e->GetString();
                 }
                 if (StrLen($errorMessage) <= 0) {
                     $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_ADD_NEW_OWNER_RELATION");
                 }
                 $APPLICATION->ThrowException($errorMessage, "ERROR_ADD_USER2GROUP");
                 $DB->Rollback();
                 return false;
             }
         }
     }
     if (strlen($errorMessage) <= 0) {
         $GROUP_ID = CSocNetGroup::Update($groupID, array("OWNER_ID" => $userID));
         if (!$GROUP_ID || IntVal($GROUP_ID) <= 0) {
             $errorMessage = "";
             if ($e = $APPLICATION->GetException()) {
                 $errorMessage = $e->GetString();
             }
             if (StrLen($errorMessage) <= 0) {
                 $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_GROUP");
             }
             $APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_GROUP");
             $DB->Rollback();
             return false;
         }
     }
     if (CModule::IncludeModule("im")) {
         $bIMIncluded = true;
         $groupSiteId = CSocNetGroup::GetDefaultSiteId($groupID, $arGroup["SITE_ID"]);
         $workgroupsPage = COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", $groupSiteId);
         $groupUrlTemplate = COption::GetOptionString("socialnetwork", "group_path_template", "/workgroups/group/#group_id#/", $groupSiteId);
         $groupUrlTemplate = "#GROUPS_PATH#" . substr($groupUrlTemplate, strlen($workgroupsPage), strlen($groupUrlTemplate) - strlen($workgroupsPage));
         $groupUrl = str_replace(array("#group_id#", "#GROUP_ID#"), $groupID, $groupUrlTemplate);
     }
     // send message to the old owner
     if ($bIMIncluded) {
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:user_group.php

示例4: SetLastActivity

 function SetLastActivity($ID, $date = false)
 {
     if (!CSocNetGroup::__ValidateID($ID)) {
         return false;
     }
     $ID = IntVal($ID);
     if ($date == false) {
         CSocNetGroup::Update($ID, array("=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()));
     } else {
         CSocNetGroup::Update($ID, array("DATE_ACTIVITY" => $date));
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:12,代码来源:group.php

示例5: foreach

 $bError = false;
 if (!$lAdmin->IsUpdated($ID)) {
     continue;
 }
 foreach ($arFields as $key => $value) {
     $bAllowed = false;
     foreach ($arHeaders as $header) {
         if ($header["id"] === $key) {
             $bAllowed = true;
         }
     }
     if (!$bAllowed) {
         unset($arFields[$key]);
     }
 }
 if (!CSocNetGroup::Update($ID, $arFields, false)) {
     if ($ex = $APPLICATION->GetException()) {
         $lAdmin->AddUpdateError($ex->GetString(), $ID);
     } else {
         $lAdmin->AddUpdateError(GetMessage("SONET_ERROR_UPDATE"), $ID);
     }
     $DB->Rollback();
 } elseif (!empty($arFields["OWNER_ID"]) && !empty($arOwnerOld[$ID])) {
     $arUpdateFields = array("ROLE" => SONET_ROLES_USER, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $GLOBALS["USER"]->GetID());
     if (!CSocNetUserToGroup::Update($arOwnerOld[$ID]["RELATION_ID"], $arUpdateFields)) {
         $bError = true;
         if ($ex = $APPLICATION->GetException()) {
             $lAdmin->AddUpdateError($ex->GetString(), $ID);
         } else {
             $lAdmin->AddUpdateError(GetMessage("SONET_ERROR_UPDATE"), $ID);
         }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:group.php

示例6: elseif

     $arResult["GROUP_ID"] = CSocNetGroup::CreateGroup($USER->GetID(), $arFields, $bAutoSubscribe);
     if (!$arResult["GROUP_ID"]) {
         if ($e = $APPLICATION->GetException()) {
             $errorMessage .= $e->GetString();
             $errorID = $e->GetID();
             if (strlen($errorID) > 0) {
                 $arResult["ErrorFields"][] = $errorID;
             }
         }
     } else {
         $bFirstStepSuccess = true;
     }
 } else {
     $arFields["=DATE_UPDATE"] = $DB->CurrentTimeFunction();
     $arFields["=DATE_ACTIVITY"] = $DB->CurrentTimeFunction();
     $arResult["GROUP_ID"] = CSocNetGroup::Update($arParams["GROUP_ID"], $arFields, $bAutoSubscribe);
     if (!$arResult["GROUP_ID"] && ($e = $APPLICATION->GetException())) {
         $errorMessage .= $e->GetString();
         $errorID = $e->GetID();
         if ($errorID == "ERROR_IMAGE_ID") {
             $arResult["ErrorFields"][] = "GROUP_IMAGE_ID";
         } elseif (isset($e->messages) && is_array($e->messages) && is_array($e->messages[0]) && array_key_exists("id", $e->messages[0])) {
             $arResult["ErrorFields"][] = $e->messages[0]["id"];
         }
     } else {
         $rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
         while ($arSite = $rsSite->Fetch()) {
             BXClearCache(true, "/" . $arSite["ID"] . "/bitrix/search.tags.cloud/");
         }
     }
 }
开发者ID:vim84,项目名称:b-markt,代码行数:31,代码来源:component.php

示例7: SetOwner

	function SetOwner($userID, $groupID, $arGroup = false)
	{
		global $DB, $APPLICATION, $USER;

		if (!$arGroup)
			$arGroup = CSocNetGroup::GetByID($groupID);

		if (!$arGroup)
			return false;

		$DB->StartTransaction();
				
		// setting relations for the old owner
		$dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $arGroup["OWNER_ID"], "GROUP_ID" => $groupID), false, false, array("ID"));
		if ($arRelation = $dbRelation->Fetch())
		{
			$arFields = array(
				"ROLE" => SONET_ROLES_USER,
				"=DATE_UPDATE" => $DB->CurrentTimeFunction(),
				"INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER,
				"INITIATED_BY_USER_ID" => $USER->GetID(),
			);

			if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields))
			{
				$errorMessage = "";
				if ($e = $APPLICATION->GetException())
					$errorMessage = $e->GetString();
				if (StrLen($errorMessage) <= 0)
					$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_CURRENT_OWNER");

				$APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
				$DB->Rollback();
				return false;
			}
		}
		else
		{
			$errorMessage = "";
			if ($e = $APPLICATION->GetException())
				$errorMessage = $e->GetString();
			if (StrLen($errorMessage) <= 0)
				$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_GET_CURRENT_OWNER_RELATION");

			$APPLICATION->ThrowException($errorMessage, "ERROR_GET_USER2GROUP");
			$DB->Rollback();
			return false;
		}

		// delete requests to the old owner
		if (strlen($errorMessage) <= 0)
			CSocNetUserToGroup::__SpeedFileDelete($arGroup["OWNER_ID"]);

		if (strlen($errorMessage) <= 0)
		{
			// setting relations for the new owner
			$dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $userID, "GROUP_ID" => $groupID), false, false, array("ID"));
			if ($arRelation = $dbRelation->Fetch())
			{
				$arFields = array(
					"ROLE" => SONET_ROLES_OWNER,
					"=DATE_UPDATE" => $DB->CurrentTimeFunction(),
					"INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER,
					"INITIATED_BY_USER_ID" => $USER->GetID(),
				);

				if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields))
				{
					$errorMessage = "";
					if ($e = $APPLICATION->GetException())
						$errorMessage = $e->GetString();
					if (StrLen($errorMessage) <= 0)
						$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_NEW_OWNER_RELATION");

					$APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
					$DB->Rollback();
					return false;
				}
			}
			else
			{
				$arFields = array(
					"USER_ID" => $userID,
					"GROUP_ID" => $groupID,
					"ROLE" => SONET_ROLES_OWNER,
					"=DATE_CREATE" => $DB->CurrentTimeFunction(),
					"=DATE_UPDATE" => $DB->CurrentTimeFunction(),
					"INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER,
					"INITIATED_BY_USER_ID" => $USER->GetID(),
					"MESSAGE" => false,
				);

				if (!CSocNetUserToGroup::Add($arFields))
				{
					$errorMessage = "";
					if ($e = $APPLICATION->GetException())
						$errorMessage = $e->GetString();
					if (StrLen($errorMessage) <= 0)
						$errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_ADD_NEW_OWNER_RELATION");

//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:101,代码来源:user_group.php


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