public function addInvites($gid, $emails)
	{
		$exists = array();
		$added  = array();

		$current = $this->getInviteEmails($gid, true);

		foreach ($emails as $e)
		{
			if (in_array($e, $current))
			{
				$exists[] = $e;
			}
			else
			{
				$added[] = $e;
			}
		}

		if (count($added) > 0)
		{
			foreach ($added as $a)
			{
				$model = self::blank();
				$model->set([
					'email'     => $a,
					'gidNumber' => $gid,
					'token'     => md5($a)
				]);
				$model->save();
			}
		}

		$return['exists'] = $exists;
		$return['added']  = $added;

		return $return;
	}
public function addInvites($gid, $emails)
	{
		$exists = array();
		$added  = array();

		$current = $this->getInviteEmails($gid, true);

		foreach ($emails as $e)
		{
			if (in_array($e, $current))
			{
				$exists[] = $e;
			}
			else
			{
				$added[] = $e;
			}
		}

		if (count($added) > 0)
		{
			foreach ($added as $a)
			{
				$model = self::blank();
				$model->set([
					'email'     => $a,
					'gidNumber' => $gid,
					'token'     => md5($a)
				]);
				$model->save();
			}
		}

		$return['exists'] = $exists;
		$return['added']  = $added;

		return $return;
	}
public function addInvites ( $ gid , $ emails ) { $ exists = array ( ) ; $ added = array ( ) ; $ current = $ this -> getInviteEmails ( $ gid , true ) ; foreach ( $ emails as $ e ) { if ( in_array ( $ e , $ current ) ) { $ exists [ ] = $ e ; } else { $ added [ ] = $ e ; } } if ( count ( $ added ) > 0 ) { foreach ( $ added as $ a ) { $ model = self :: blank ( ) ; $ model -> set ( [ 'email' => $ a , 'gidNumber' => $ gid , 'token' => md5 ( $ a ) ] ) ; $ model -> save ( ) ; } } $ return [ 'exists' ] = $ exists ; $ return [ 'added' ] = $ added ; return $ return ; }
Add a list of emails to a group as invitees

@param   integer  $gid     Group ID
@param   array    $emails  Array of email addresses
@return  array
Add a list of emails to a group as invitees