예제 #1
0
 public static function onAfterDelete(Entity\Event $event)
 {
     $primary = $event->getParameter("primary");
     $ID = $primary["ID"];
     $userInfo = self::$deletedList[$ID];
     if ($userInfo) {
         UserLinkTable::deleteBySocserv($userInfo["USER_ID"], $userInfo["ID"]);
         if ($userInfo["EXTERNAL_AUTH_ID"] === \CSocServBitrix24Net::ID) {
             $interface = new \CBitrix24NetOAuthInterface();
             $interface->setToken($userInfo["OATOKEN"]);
             $interface->setAccessTokenExpires($userInfo["OATOKEN_EXPIRES"]);
             $interface->setRefreshToken($userInfo["REFRESH_TOKEN"]);
             if ($interface->checkAccessToken() || $interface->getNewAccessToken()) {
                 $interface->RevokeAuth();
             }
         }
     }
 }
예제 #2
0
 protected static function notifyPossible($userId)
 {
     if (Main\Loader::includeModule('im')) {
         $ts = time();
         $alreadyShown = \CUserOptions::GetOption("socialservices", "possible_contacts", null, $userId);
         if (!is_array($alreadyShown) || $alreadyShown[static::POSSIBLE_RESET_TIME_KEY] < $ts - static::POSSIBLE_RESET_TIME) {
             $alreadyShown = array();
         } else {
             $ts = $alreadyShown[static::POSSIBLE_RESET_TIME_KEY];
             unset($alreadyShown[static::POSSIBLE_RESET_TIME_KEY]);
         }
         $contactList = UserLinkTable::getList(array('order' => array("RND" => "ASC"), 'filter' => array('=USER_ID' => $userId, '!=ID' => $alreadyShown), 'limit' => static::NOTIFY_POSSIBLE_COUNT, 'count_total' => true, 'group' => array("CONNECT.CONTACT_ID"), 'runtime' => array(new Entity\ExpressionField('RND', 'RAND()'), new Entity\ReferenceField("CONNECT", ContactConnectTable::getEntity(), array("=ref.LINK_ID" => "this.ID", "=ref.CONNECT_TYPE" => new Main\DB\SqlExpression('?', ContactConnectTable::TYPE_PORTAL)), array("join_type" => "inner")))));
         $count = $contactList->getCount();
         if ($count > 0) {
             $attach = new \CIMMessageParamAttach(null, \CIMMessageParamAttach::NORMAL);
             while ($contactInfo = $contactList->fetch()) {
                 $alreadyShown[] = $contactInfo["ID"];
                 $contactInfo["CONNECT"] = array();
                 $dbRes = ContactConnectTable::getList(array("filter" => array("=LINK_ID" => $contactInfo["ID"]), "limit" => 1, "select" => array("CONTACT_PROFILE_ID", "CONNECT_TYPE")));
                 while ($connect = $dbRes->fetch()) {
                     $contactInfo["CONNECT"][] = $connect;
                 }
                 if (count($contactInfo["CONNECT"]) > 0) {
                     $attachParams = array("NAME" => \CUser::FormatName(\CSite::GetNameFormat(), array("NAME" => $contactInfo["LINK_NAME"], "LAST_NAME" => $contactInfo["LINK_LAST_NAME"]), false, false));
                     if ($contactInfo["LINK_PICTURE"]) {
                         $attachParams["AVATAR"] = $contactInfo["LINK_PICTURE"];
                     }
                     $attachParams["NETWORK_ID"] = static::getConnectId($contactInfo["CONNECT"][0]);
                     $attach->AddUser($attachParams);
                 }
             }
             /*
             				if($count > static::NOTIFY_POSSIBLE_COUNT)
             				{
             					$attach->AddHtml('<a href="'.str_replace("#USER_ID#", $userId, Option::get("intranet", "path_user", "/company/persona/user/#USER_ID#/")).'">'.Loc::getMessage("SS_JOIN_NOTIFY_MORE", array("#NUM#" => $count - static::NOTIFY_POSSIBLE_COUNT)).'</a>');
             				}
             */
             $messageFields = array("TO_USER_ID" => $userId, "FROM_USER_ID" => 0, "NOTIFY_TYPE" => IM_NOTIFY_SYSTEM, "NOTIFY_MODULE" => "socialservices", "NOTIFY_EVENT" => "possible_contacts", "NOTIFY_MESSAGE" => Loc::getMessage("SS_JOIN_NOTIFY_POSSIBLE"), "NOTIFY_MESSAGE_OUT" => IM_MAIL_SKIP, "ATTACH" => $attach);
             \CIMNotify::Add($messageFields);
         }
         $alreadyShown[static::POSSIBLE_RESET_TIME_KEY] = $ts;
         \CUserOptions::SetOption("socialservices", "possible_contacts", $alreadyShown, false, $userId);
     }
 }