/** * Returns list of the users * * @param string $app_id - if specified returns only users whish has access to the application * @return array */ public static function getUsers($app_id = null) { $contact_model = new waContactModel(); if ($app_id) { $sql = "SELECT c.id, c.name\n FROM " . $contact_model->getTableName() . " c JOIN\n wa_contact_rights r ON c.id = -r.group_id AND c.is_user = 1\n WHERE (r.app_id = s:app_id OR (r.app_id = 'webasyst' AND r.name = 'backend')) AND r.value > 0\n UNION\n (SELECT c.id, c.name\n FROM " . $contact_model->getTableName() . " c JOIN\n wa_user_groups g ON c.id = g.contact_id AND c.is_user = 1 JOIN\n wa_contact_rights r ON g.group_id = r.group_id\n WHERE (r.app_id = s:app_id OR (r.app_id = 'webasyst' AND r.name = 'backend')) AND r.value > 0\n ) ORDER BY name"; } else { $sql = "SELECT c.id, c.name FROM " . $contact_model->getTableName() . " c\n WHERE c.is_user = 1\n ORDER BY c.name"; } return $contact_model->query($sql, array('app_id' => $app_id))->fetchAll('id', true); }