Exemplo n.º 1
0
 /**
  * Sets the Layout Xml and writes it back to the database
  * @return 
  * @param $layoutid Object
  * @param $xml Object
  */
 private function SetLayoutXml($layoutid, $xml)
 {
     $layout = new Layout($this->db);
     if (!$layout->SetLayoutXml($layoutid, $xml)) {
         return $this->SetError($layout->GetErrorMessage());
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Sets the Layout Xml and writes it back to the database
  * @return 
  * @param $layoutid Object
  * @param $xml Object
  */
 private function SetLayoutXml($layoutid, $xml)
 {
     // Update Cache
     $this->layoutXml = $xml;
     $layout = new Layout($this->db);
     $layout->delayFinalise = $this->delayFinalise;
     if (!$layout->SetLayoutXml($layoutid, $xml)) {
         return $this->SetError($layout->GetErrorMessage());
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Delete Template
  * @return <XiboAPIResponse>
  */
 public function TemplateDelete()
 {
     if (!$this->user->PageAuth('template')) {
         return $this->Error(1, 'Access Denied');
     }
     $layout = new Layout();
     $layoutId = $this->GetParam('templateId', _INT);
     if (!$this->user->LayoutAuth($layoutId)) {
         return $this->Error(1, 'Access Denied');
     }
     if (!$layout->Delete($layoutId)) {
         return $this->Error($layout->GetErrorNumber(), $layout->GetErrorMessage());
     }
     return $this->Respond($this->ReturnId('success', true));
 }
Exemplo n.º 4
0
 public function Import()
 {
     $db =& $this->db;
     $response = new ResponseManager();
     // What are we importing?
     $template = Kit::GetParam('template', _POST, _STRING, 'false');
     $template = $template == 'true';
     $layout = Kit::GetParam('layout', _POST, _STRING);
     $replaceExisting = Kit::GetParam('replaceExisting', _POST, _CHECKBOX);
     $importTags = Kit::GetParam('importTags', _POST, _CHECKBOX, !$template);
     // File data
     $tmpName = Kit::GetParam('hidFileID', _POST, _STRING);
     if ($tmpName == '') {
         trigger_error(__('Please ensure you have picked a file and it has finished uploading'), E_USER_ERROR);
     }
     // File name and extension (orignial name)
     $fileName = Kit::GetParam('txtFileName', _POST, _STRING);
     $fileName = basename($fileName);
     $ext = strtolower(substr(strrchr($fileName, "."), 1));
     // File upload directory.. get this from the settings object
     $fileLocation = Config::GetSetting('LIBRARY_LOCATION') . 'temp/' . $tmpName;
     Kit::ClassLoader('layout');
     $layoutObject = new Layout($this->db);
     if (!$layoutObject->Import($fileLocation, $layout, $this->user->userid, $template, $replaceExisting, $importTags)) {
         trigger_error($layoutObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Layout Imported'));
     $response->Respond();
 }
Exemplo n.º 5
0
 /**
  * Deletes a template
  * @return
  */
 function DeleteTemplate()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $templateId = Kit::GetParam('templateId', _POST, _INT);
     if ($templateId == 0) {
         trigger_error(__('No template selected'), E_USER_ERROR);
     }
     // Is this user allowed to delete this template?
     $auth = $this->user->TemplateAuth($templateId, true);
     if (!$auth->del) {
         trigger_error(__('Access denied'), E_USER_ERROR);
     }
     // Use the data class
     $template = new Layout();
     // Delete the template
     if (!$template->Delete($templateId)) {
         trigger_error($template->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('The Template has been Deleted'));
     $response->Respond();
 }
Exemplo n.º 6
0
 /**
  * Delete Layout
  * @return <XiboAPIResponse>
  */
 public function LayoutDelete()
 {
     if (!$this->user->PageAuth('layout')) {
         return $this->Error(1, 'Access Denied');
     }
     Kit::ClassLoader('Layout');
     $layout = new Layout($this->db);
     $layoutId = $this->GetParam('layoutId', _INT);
     if (!$this->user->LayoutAuth($layoutId)) {
         return $this->Error(1, 'Access Denied');
     }
     if (!$layout->Delete($layoutId)) {
         return $this->Error($layout->GetErrorNumber(), $layout->GetErrorMessage());
     }
     return $this->Respond($this->ReturnId('success', true));
 }
Exemplo n.º 7
0
 /**
  * Copys a layout
  */
 public function Copy()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error('Token does not match', E_USER_ERROR);
     }
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $layoutid = Kit::GetParam('layoutid', _POST, _INT);
     $layout = Kit::GetParam('layout', _POST, _STRING);
     $copyMedia = Kit::GetParam('copyMediaFiles', _POST, _CHECKBOX);
     Kit::ClassLoader('Layout');
     $layoutObject = new Layout($db);
     if (!$layoutObject->Copy($layoutid, $layout, $user->userid, (bool) $copyMedia)) {
         trigger_error($layoutObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Layout Copied'));
     $response->Respond();
 }
Exemplo n.º 8
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;
     }
 }