/** * 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(); } }