Esempio n. 1
0
 /**
  * Deletes a layout
  * @param <type> $layoutId
  * @return <type>
  */
 public function Delete($layoutId)
 {
     try {
         $dbh = PDOConnect::init();
         // Make sure the layout id is present
         if ($layoutId == 0) {
             $this->ThrowError(__('No Layout selected'));
         }
         // Untag
         $this->unTagAll($layoutId);
         // Security
         $sth = $dbh->prepare('DELETE FROM lklayoutmediagroup WHERE layoutid = :layoutid');
         $sth->execute(array('layoutid' => $layoutId));
         $sth = $dbh->prepare('DELETE FROM lklayoutregiongroup WHERE layoutid = :layoutid');
         $sth->execute(array('layoutid' => $layoutId));
         // Media Links
         $sth = $dbh->prepare('DELETE FROM lklayoutmedia WHERE layoutid = :layoutid');
         $sth->execute(array('layoutid' => $layoutId));
         // Handle the deletion of the campaign
         $campaign = new Campaign();
         $campaignId = $campaign->GetCampaignId($layoutId);
         // Remove the Campaign (will remove links to this layout - orphaning the layout)
         if (!$campaign->Delete($campaignId)) {
             $this->ThrowError(25008, __('Unable to delete campaign'));
         }
         // Remove the Layout from any display defaults
         $sth = $dbh->prepare('UPDATE `display` SET defaultlayoutid = 4 WHERE defaultlayoutid = :layoutid');
         $sth->execute(array('layoutid' => $layoutId));
         // Remove the Layout from any Campaigns
         if (!$campaign->unlinkAllForLayout($layoutId)) {
             $this->ThrowError($campaign->GetErrorMessage());
         }
         // Remove the Layout (now it is orphaned it can be deleted safely)
         $sth = $dbh->prepare('DELETE FROM layout WHERE layoutid = :layoutid');
         $sth->execute(array('layoutid' => $layoutId));
         return true;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         if (!$this->IsError()) {
             $this->SetError(25008, __('Unable to delete layout'));
         }
         return false;
     }
 }
Esempio n. 2
0
 /**
  * Delete Campaign
  */
 public function Delete()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $db =& $this->db;
     $response = new ResponseManager();
     $campaignId = Kit::GetParam('CampaignID', _POST, _INT);
     // Authenticate this user
     $auth = $this->user->CampaignAuth($campaignId, true);
     if (!$auth->del) {
         trigger_error(__('You do not have permission to delete this campaign'), E_USER_ERROR);
     }
     // Validation
     if ($campaignId == 0 || $campaignId == '') {
         trigger_error(__('Campaign ID is missing'), E_USER_ERROR);
     }
     Kit::ClassLoader('campaign');
     $campaignObject = new Campaign($db);
     if (!$campaignObject->Delete($campaignId)) {
         trigger_error($campaignObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Campaign Deleted'), false);
     $response->Respond();
 }
Esempio n. 3
0
 /**
  * Delete User
  * @return bool
  */
 public function Delete()
 {
     if (!isset($this->userId) || $this->userId == 0) {
         return $this->SetError(__('Missing userId'));
     }
     try {
         $dbh = PDOConnect::init();
         // Delete all layouts
         $layout = new Layout();
         if (!$layout->deleteAllForUser($this->userId)) {
             return $this->SetError($layout->GetErrorMessage());
         }
         // Delete all Campaigns
         $campaign = new Campaign();
         if (!$campaign->deleteAllForUser($this->userId)) {
             return $this->SetError($campaign->GetErrorMessage());
         }
         // Delete all media
         $media = new Media();
         if (!$media->deleteAllForUser($this->userId)) {
             return $this->SetError($media->GetErrorMessage());
         }
         // Delete all schedules that have not been caught by deleting layouts and campaigns
         // These would be schedules for other peoples layouts
         $schedule = new Schedule();
         if (!$schedule->deleteAllForUser($this->userId)) {
         }
         // Delete the user itself
         $sth = $dbh->prepare('DELETE FROM `user` WHERE userid = :userid');
         $sth->execute(array('userid' => $this->userId));
         // Delete from the session table
         $sth = $dbh->prepare('DELETE FROM `session` WHERE userid = :userid');
         $sth->execute(array('userid' => $this->userId));
         return true;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
         if (!$this->IsError()) {
             $this->SetError(1, __('Unknown Error'));
         }
         return false;
     }
 }