Solved: 3 Years, 5 Months ago Enhanced Account Switcher -- Adding MentionMe
#1
Solved: 3 Years, 5 Months ago
Hello Guys,

I want to add MentionMe tag and connect it with other accounts which is under Master account, For example when an account or master account tagged by a member an alert should go to all accounts under master account and master account also.. 

One more thing is when the alert opened by any of them ( Master or accounts under master ) the alert should disappear for all of them..

I kinda achieved the first point after reviewing Enhanced Account Switcher by adding to MentionMe plugin under 'mentionMeMyAlertsDoNewReplyEnd()' function this: 
 
$count = 0;
		
		$user = get_user((int) $uid);
		
		$accounts = $eas->accountswitcher_cache;
		if (is_array($accounts)) {
		// If recipient is master account send alerts to attached users
			foreach ($accounts as $key => $account) {
				if ($user['uid'] == $account['as_uid']) {
					++$count;
					if ($count > 0) {
						$alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, $tid);
						$alert->setExtraDetails(array(
							'thread_title' => $subject,
							'pid' => $pid,
							'tid' => $tid
						));
						$alert->setFromUserId($fromUser);
						$alerts[] = $alert;

						$mentionedAlready[$uid] = true;
					}
				}
			}
		}

		// If there are no users attached to the current account but the current account is attached to another user
		if ($count == 0 && $user['as_uid'] != 0) {
			$master = get_user((int) $uid);
			// Get the masters permission
			$permission = user_permissions($master['uid']);

			// If the master has permission to use the Enhanced Account Switcher, get the userlist
			if ($permission['as_canswitch'] == 1) {
			// If recipient is attached account, alert master account
				if ($master['uid'] == $user['as_uid']) {
					$alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, $tid);
					$alert->setExtraDetails(array(
						'thread_title' => $subject,
						'pid' => $pid,
						'tid' => $tid
					));
					$alert->setFromUserId($fromUser);
					$alerts[] = $alert;

					$mentionedAlready[$uid] = true;
				}
				if (is_array($accounts)) {
				// If recipient has the same master account, send alert
					foreach ($accounts as $key => $account) {
					// Leave recipient out
						if ($account['uid'] == $user['uid']) {
							continue;
						}
						if ($master['uid'] == $account['as_uid']) {
							$alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, $tid);
							$alert->setExtraDetails(array(
								'thread_title' => $subject,
								'pid' => $pid,
								'tid' => $tid
							));
							$alert->setFromUserId($fromUser);
							$alerts[] = $alert;

							$mentionedAlready[$uid] = true;
						}
					}
				}
			}
		}
		// If there are no users attached to the a recipient and the recipient isn't attached to another user
		if ($count == 0 && $user['as_uid'] == 0) {
			$alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, $tid);
			$alert->setExtraDetails(array(
				'thread_title' => $subject,
				'pid' => $pid,
				'tid' => $tid
			));
			$alert->setFromUserId($fromUser);
			$alerts[] = $alert;

			$mentionedAlready[$uid] = true;
		}
		if (!empty($alerts)) {
			MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts);
		}

Now for the second point, I'm not sure where to start? 

Thank you
best regards
Kurdish
Reply
#2
Solved: 3 Years, 5 Months ago
Guys, I need only to know... How this system is working? I mean MyAlert... AS I'm sending alert for all accounts which is associated with the master account.... I need to know how it work to Mark Read on other accounts if the alert had been opened on one of them.
Reply
#3
Solved: 3 Years, 5 Months ago
Hi, there seems to be a hook available for you:
https://github.com/MyBBStuff/MyAlerts/bl...#L727-L730
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)