Esempio n. 1
0
    /**
     * GetTriggerEmailsList
     * Get a list if triggeremails that this user owns/has access to.
     * If this user is an admin, it will returns all trigger email records.
     *
     * This function will delegate it's database query to TriggerEmails API.
     *
     * @param Int $userid Usedid to check triggeremails for. If it is not supplied, it will get currently loaded user's id
     * @return Mixed Returns an array of available trigger emails record if successul, FALSE if it encountered any errors.
     *
     * @uses TriggerEmails_API::GetRecordsByUserID()
     */
    function GetTriggerEmailsList($userid = 0) {
        if (!$userid && !$this->userid) {
            trigger_error('This user object is not loaded with any user.... You will need to supply the userid as a parameter.', E_USER_NOTICE);
            return false;
        }

        if (!$userid) {
            $userid = $this->userid;
        }

        // If user is a "System Admin" or a "List Admin", allow to access all triggers
        if ($userid == $this->userid) {
            if ($this->ListAdmin() || $this->listadmintype == 'a') {
                $userid = 0;
            }
        }

        if (!class_exists('TriggerEmails_API', false)) {
            require_once(dirname(__FILE__) . '/triggeremails.php');
        }

        $triggerapi = new TriggerEmails_API();
        return $triggerapi->GetRecordsByUserID($userid, array(), false, 0, 'all');
    }