/** * Delete a contact * * @param int $id * * @return \Cubex\Core\Http\Redirect */ public function actionDestroy($id) { $contact = new Contact($id); $contact->forceLoad(); $contact->delete(); return Redirect::to('/contacts')->with('msg', new TransportMessage('info', "Contact '{$contact->name}' deleted.")); }
/** * @return int */ public function execute() { /*$campaignContact = new CampaignContact(); $campaignContact->campaignId = rand(1,9); $campaignContact->language = array_rand( ["en" => "en", "es" => "es", "de" => "de",] ); $campaignContact->contactId = rand(1,9); $campaignContact->saveChanges(); return 0;*/ $contact = new Contact(); $contact->name = "John Smith"; $contact->description = "John the test monkey"; $contact->email = "*****@*****.**"; $contact->jobTitle = "Test Monkey"; $contact->reference = "johnsmith"; $contact->signature = ' Kind Regards John Smith Test Monkey Cubex Tester 0123-456-789'; $contact->saveChanges(); $campaign = new Campaign(); $campaign->reference = "testcampaign:" . FileSystem::readRandomCharacters(3); $campaign->name = "Test Campaign"; $campaign->description = "A test created with sample data"; $campaign->active = true; $campaign->contactId = $contact->id(); $campaign->type = CampaignType::ACTION; $campaign->saveChanges(); $message = $campaign->message(); $message->setLanguage('en'); $message->subject = "This is my subject"; $message->plainText = "Hello {{name}}. how are you today?"; $message->saveAsNew(); $message->setLanguage('es'); $message->subject = "Este es mi tema"; $message->plainText = "Hola {{name}}. ¿Cómo estás hoy?"; $message->saveAsNew(); $message->setLanguage('de'); $message->subject = "Dies ist mein Thema"; $message->plainText = "Hallo {{name}}. Wie geht es Ihnen heute?"; $message->saveAsNew(); }
public function add() { $this->_throwIfNotSet("reference"); $this->_throwIfNotSet("description"); $this->_throwIfNotSet("name"); $this->_throwIfNotSet("email"); $contact = new Contact(); $contact->reference = $this->reference; $contact->description = $this->description; $contact->name = $this->name; $contact->email = $this->email; $contact->jobTitle = $this->jobTitle; $contact->signature = $this->signature; $contact->saveChanges(); echo "Added contact id {$contact->id()} ({$contact->name})"; }
public static function getAll($query) { $contactSelect = self::_getDisplayResultPattern("c", "name"); $campaignsSelect = self::_getDisplayResultPattern("C", "name"); $queryData = ["SELECT * FROM (\n (SELECT {$contactSelect}, %C, 'Contact' as `type` FROM %T WHERE %C LIKE %~)\n UNION ALL\n (SELECT {$campaignsSelect}, %C, 'Campaign' as `type` FROM %T WHERE %C LIKE %~ OR %C LIKE %~)\n ) %T ORDER BY %C", "name", Contact::tableName(), "name", $query, "name", Campaign::tableName(), "name", $query, "label", $query, "temp", "name"]; $results = DB::getAccessor("defero_db")->getRows(ParseQuery::parse(DB::getAccessor("defero_db"), $queryData)); return $results; }
public function contacts() { return [0 => '- Campaign Default -'] + Contact::collection()->getKeyPair('id', 'reference'); }
private static function _tryGetMapperUrl($query) { if (preg_match("/^(?:.* |)(?<tag>[CcP][0-9]+)(?:.* |)\$/", $query, $matches)) { $tag = $matches['tag']; $id = substr($tag, 1); $map = null; $ep = null; switch (substr($tag, 0, 1)) { case 'C': $ep = "/campaigns/%d"; $map = new Campaign($id); break; case 'c': $ep = "/contacts/%d"; $map = new Contact($id); break; } if ($map instanceof RecordMapper) { if ($map->exists()) { return sprintf($ep, $map->id()); } } } return null; }