Example #1
0
 /**
  * Get a list of group names for a layout
  * @param <type> $layoutId
  * @return <type>
  */
 private function GroupsForLayout($layoutId)
 {
     $db =& $this->db;
     Kit::ClassLoader('campaign');
     $campaign = new Campaign($db);
     $campaignId = $campaign->GetCampaignId($layoutId);
     $SQL = '';
     $SQL .= 'SELECT `group`.Group ';
     $SQL .= '  FROM `group` ';
     $SQL .= '   INNER JOIN lkcampaigngroup ';
     $SQL .= '   ON `group`.GroupID = lkcampaigngroup.GroupID ';
     $SQL .= ' WHERE lkcampaigngroup.CampaignID = %d ';
     $SQL = sprintf($SQL, $campaignId);
     if (!($results = $db->query($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Unable to get group information for layout'), E_USER_ERROR);
     }
     $groups = '';
     while ($row = $db->get_assoc_row($results)) {
         $groups .= $row['Group'] . ', ';
     }
     $groups = trim($groups);
     $groups = trim($groups, ',');
     return $groups;
 }
Example #2
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;
     }
 }