/** * 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'); }
/** * Copy * * Create a copy of an existing trigger record record * * @param Integer $id Existing record to be copied over * @return Mixed Returns the newly created trigger email ID if successful, FALSE otherwise * * @uses TriggerEmails_API::Load() * @uses TriggerEmails_API::Save() * @uses GetLang() */ public function Copy($id = null) { if (!is_null($id)) { $api = new TriggerEmails_API(); if (!$api->Load($id)) { return false; } return $api->Copy(); } else { if ($this->triggeremailsid == 0) { return false; } $oldid = $this->triggeremailsid; $temp = $this->_properties; foreach ($this->_propertiesReadOnly as $properties) { $this->_properties[$properties] = 0; } $data = $this->GetData($oldid); if (array_key_exists($oldid, $data)) { $data = $data[$oldid]; } else { $data = array(); } $actions = $this->GetActions($oldid); if (array_key_exists($oldid, $actions)) { $actions = $actions[$oldid]; } else { $actions = array(); } $api = clone $this; $api->name = GetLang('CopyPrefix') . $api->name; $api->active = 0; $api->data = $data; $api->triggeractions = $actions; $this->_properties = $temp; return $api->Save(); } }