I'm assuming here that your code will be running as part of a Q2A page request, and not as a separate page or iframe. If so, you have two global variables that you can access - $qa_login_userid and $qa_login_level - to get the info you need. To check if a user is logged in, use:
if (isset($qa_login_userid)) { ... }
If a user is logged in, to check if they're an editor, use:
if ($qa_login_level>=QA_USER_LEVEL_EDITOR) { ... }
QA_USER_LEVEL_EDITOR can be substituted with any other constant from the top of qa-app-users.php.
One caveat - If you're writing your code inside a function block, you'll need to add this just after the function opens to access those variables:
global $qa_login_userid, $qa_login_level;