/** * Deletes a Group * @return */ function Delete() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $response = new ResponseManager(); $displayProfile = new DisplayProfile(); $displayProfile->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT); if (!$displayProfile->Load()) { trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR); } if ($this->user->usertypeid != 1 && $this->user->userid != $displayProfile->userId) { trigger_error(__('You do not have permission to edit this profile'), E_USER_ERROR); } if (!$displayProfile->Delete($displayProfile->displayProfileId)) { trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Display Profile Deleted'), false); $response->Respond(); }
/** * Set a users password */ public function SetPassword() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); $newPassword = Kit::GetParam('newPassword', _POST, _STRING); $retypeNewPassword = Kit::GetParam('retypeNewPassword', _POST, _STRING); $userId = Kit::GetParam('UserId', _POST, _INT); // Check we are an admin if ($this->user->usertypeid != 1) { trigger_error(__('Trying to change the password for another user denied'), E_USER_ERROR); } Kit::ClassLoader('userdata'); $userData = new Userdata($db); if (!$userData->ChangePassword($userId, null, $newPassword, $retypeNewPassword, true)) { trigger_error($userData->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Password Changed')); $response->Respond(); }
public function Edit() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); // Can we edit? if (Config::GetSetting('MODULE_CONFIG_LOCKED_CHECKB') == 'Checked') { trigger_error(__('Module Config Locked'), E_USER_ERROR); } $moduleId = Kit::GetParam('ModuleID', _POST, _INT); $validExtensions = Kit::GetParam('ValidExtensions', _POST, _STRING, ''); $imageUri = Kit::GetParam('ImageUri', _POST, _STRING); $enabled = Kit::GetParam('Enabled', _POST, _CHECKBOX); $previewEnabled = Kit::GetParam('PreviewEnabled', _POST, _CHECKBOX); // Validation if ($moduleId == 0 || $moduleId == '') { trigger_error(__('Module ID is missing'), E_USER_ERROR); } if ($imageUri == '') { trigger_error(__('Image Uri is a required field.'), E_USER_ERROR); } // Deal with the Edit $SQL = "UPDATE `module` SET ImageUri = '%s', ValidExtensions = '%s', Enabled = %d, PreviewEnabled = %d WHERE ModuleID = %d"; $SQL = sprintf($SQL, $db->escape_string($imageUri), $db->escape_string($validExtensions), $enabled, $previewEnabled, $moduleId); if (!$db->query($SQL)) { trigger_error($db->error()); trigger_error(__('Unable to update module'), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Module Edited'), false); $response->Respond(); }
/** * Permissions Edit */ public function Permissions() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); Kit::ClassLoader('mediagroupsecurity'); Kit::ClassLoader('layoutmediagroupsecurity'); $layoutId = Kit::GetParam('layoutid', _POST, _INT); $regionId = Kit::GetParam('regionid', _POST, _STRING); $mediaId = Kit::GetParam('mediaid', _POST, _STRING); $groupIds = Kit::GetParam('groupids', _POST, _ARRAY); if (!$this->auth->modifyPermissions) { trigger_error(__('You do not have permissions to edit this layout'), E_USER_ERROR); } // Unlink all if ($this->assignedMedia) { $layoutMediaSecurity = new LayoutMediaGroupSecurity($db); if (!$layoutMediaSecurity->UnlinkAll($layoutId, $regionId, $mediaId)) { trigger_error(__('Unable to set permissions')); } } else { $mediaSecurity = new MediaGroupSecurity($db); if (!$mediaSecurity->UnlinkAll($mediaId)) { trigger_error(__('Unable to set permissions')); } } // Some assignments for the loop $lastGroupId = 0; $first = true; $view = 0; $edit = 0; $del = 0; // List of groupIds with view, edit and del assignments foreach ($groupIds as $groupPermission) { $groupPermission = explode('_', $groupPermission); $groupId = $groupPermission[0]; if ($first) { // First time through $first = false; $lastGroupId = $groupId; } if ($groupId != $lastGroupId) { // The groupId has changed, so we need to write the current settings to the db. // Link new permissions if ($this->assignedMedia) { if (!$layoutMediaSecurity->Link($layoutId, $regionId, $mediaId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions')); } } else { if (!$mediaSecurity->Link($mediaId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions')); } } // Reset $lastGroupId = $groupId; $view = 0; $edit = 0; $del = 0; } switch ($groupPermission[1]) { case 'view': $view = 1; break; case 'edit': $edit = 1; break; case 'del': $del = 1; break; } } // Need to do the last one if (!$first) { if ($this->assignedMedia) { if (!$layoutMediaSecurity->Link($layoutId, $regionId, $mediaId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions')); } } else { if (!$mediaSecurity->Link($mediaId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions')); } } } $response->SetFormSubmitResponse(__('Permissions Changed')); return $response; }
/** * 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(); }
/** * Set this templates permissions */ public function Permissions() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', 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); $groupIds = Kit::GetParam('groupids', _POST, _ARRAY); // Unlink all Kit::ClassLoader('templategroupsecurity'); $security = new TemplateGroupSecurity($db); if (!$security->UnlinkAll($templateId)) { trigger_error(__('Unable to set permissions'), E_USER_ERROR); } // Some assignments for the loop $lastGroupId = 0; $first = true; $view = 0; $edit = 0; $del = 0; // List of groupIds with view, edit and del assignments foreach ($groupIds as $groupPermission) { $groupPermission = explode('_', $groupPermission); $groupId = $groupPermission[0]; if ($first) { // First time through $first = false; $lastGroupId = $groupId; } if ($groupId != $lastGroupId) { // The groupId has changed, so we need to write the current settings to the db. // Link new permissions if (!$security->Link($templateId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions'), E_USER_ERROR); } // Reset $lastGroupId = $groupId; $view = 0; $edit = 0; $del = 0; } switch ($groupPermission[1]) { case 'view': $view = 1; break; case 'edit': $edit = 1; break; case 'del': $del = 1; break; } } // Need to do the last one if (!$first) { if (!$security->Link($templateId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions'), E_USER_ERROR); } } $response->SetFormSubmitResponse(__('Permissions Changed')); $response->Respond(); }
/** * Re-orders a medias regions * @return */ function TimelineReorder() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); // Vars $layoutId = Kit::GetParam('layoutid', _REQUEST, _INT); $regionId = Kit::GetParam('regionid', _POST, _STRING); $mediaList = Kit::GetParam('medialist', _POST, _STRING); // Check the user has permission Kit::ClassLoader('region'); $region = new region($db); $ownerId = $region->GetOwnerId($layoutId, $regionId); $regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutId, $regionId, true); if (!$regionAuth->edit) { trigger_error(__('You do not have permissions to edit this region'), E_USER_ERROR); } // Create a list of media if ($mediaList == '') { trigger_error(__('No media to reorder')); } // Trim the last | if there is one $mediaList = rtrim($mediaList, '|'); // Explode into an array $mediaList = explode('|', $mediaList); // Store in an array $resolvedMedia = array(); foreach ($mediaList as $mediaNode) { // Explode the second part of the array $mediaNode = explode(',', $mediaNode); $resolvedMedia[] = array('mediaid' => $mediaNode[0], 'lkid' => $mediaNode[1]); } // Hand off to the region object to do the actual reorder if (!$region->ReorderTimeline($layoutId, $regionId, $resolvedMedia)) { trigger_error($region->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Order Changed')); $response->keepOpen = true; $response->Respond(); }
function Delete() { // 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(); $resolutionID = Kit::GetParam('resolutionid', _POST, _INT); // Remove the resolution $resObject = new Resolution($db); if (!$resObject->Delete($resolutionID)) { trigger_error($resObject->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse('Resolution deleted'); $response->Respond(); }
/** * Truncate the Log */ public function Truncate() { // Check the token if (!Kit::CheckToken()) { trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR); } $db =& $this->db; if ($this->user->usertypeid != 1) { trigger_error(__('Only Administrator Users can truncate the log'), E_USER_ERROR); } $db->query("TRUNCATE TABLE log"); $response = new ResponseManager(); $response->SetFormSubmitResponse('Log Truncated'); $response->Respond(); }
/** * Wake on LAN */ public function WakeOnLan() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); $displayObject = new Display($db); $displayId = Kit::GetParam('DisplayId', _POST, _INT); if (!$displayObject->WakeOnLan($displayId)) { trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Wake on Lan command sent.')); $response->Respond(); }
/** * Puts the Server in Test Mode * @return */ public function SetServerTestMode() { $db =& $this->db; $response = new ResponseManager(); $setting = new Setting($db); if (!$setting->Edit('SERVER_MODE', 'Test')) { trigger_error(__('Cannot switch modes.'), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Server switched to Test Mode')); $response->Respond(); }
/** * Sets the Members of a group * @return */ public function SetMembers() { $db =& $this->db; $response = new ResponseManager(); $groupObject = new UserGroup($db); $groupID = Kit::GetParam('GroupID', _REQUEST, _INT); $users = Kit::GetParam('UserID', _POST, _ARRAY, array()); $members = array(); // Users in group $SQL = ""; $SQL .= "SELECT user.UserID, "; $SQL .= " user.UserName "; $SQL .= "FROM `user` "; $SQL .= " INNER JOIN lkusergroup "; $SQL .= " ON lkusergroup.UserID = user.UserID "; $SQL .= sprintf("WHERE lkusergroup.GroupID = %d", $groupID); if (!($resultIn = $db->query($SQL))) { trigger_error($db->error()); trigger_error(__('Error getting Users')); } while ($row = $db->get_assoc_row($resultIn)) { // Test whether this ID is in the array or not $userID = Kit::ValidateParam($row['UserID'], _INT); if (!in_array($userID, $users)) { // Its currently assigned but not in the $displays array // so we unassign if (!$groupObject->Unlink($groupID, $userID)) { trigger_error($groupObject->GetErrorMessage(), E_USER_ERROR); } } else { $members[] = $userID; } } foreach ($users as $userID) { // Add any that are missing if (!in_array($userID, $members)) { if (!$groupObject->Link($groupID, $userID)) { trigger_error($groupObject->GetErrorMessage(), E_USER_ERROR); } } } $response->SetFormSubmitResponse(__('Group membership set'), false); $response->Respond(); }
/** * Edit Transition */ public function Edit() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); // Can we edit? if (Config::GetSetting('TRANSITION_CONFIG_LOCKED_CHECKB') == 'Checked') { trigger_error(__('Transition Config Locked'), E_USER_ERROR); } $transitionId = Kit::GetParam('TransitionID', _POST, _INT); $enabledForIn = Kit::GetParam('EnabledForIn', _POST, _CHECKBOX); $enabledForOut = Kit::GetParam('EnabledForOut', _POST, _CHECKBOX); // Validation if ($transitionId == 0 || $transitionId == '') { trigger_error(__('Transition ID is missing'), E_USER_ERROR); } // Deal with the Edit $SQL = "UPDATE `transition` SET AvailableAsIn = %d, AvailableAsOut = %d WHERE TransitionID = %d"; $SQL = sprintf($SQL, $enabledForIn, $enabledForOut, $transitionId); if (!$db->query($SQL)) { trigger_error($db->error()); trigger_error(__('Unable to update transition'), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Transition Edited'), false); $response->Respond(); }
/** * Register a new application with OAuth */ public function Register() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $userid = Kit::GetParam('userid', _SESSION, _INT); $message = ''; try { $store = OAuthStore::instance(); $key = $store->updateConsumer($_POST, $userid); $c = $store->getConsumer($key, $userid); $message .= sprintf(__('Your consumer key is: %s'), $c['consumer_key']) . '<br />'; $message .= sprintf(__('Your consumer secret is: %s'), $c['consumer_secret']) . '<br />'; } catch (OAuthException $e) { trigger_error('Error: ' . $e->getMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse($message, false); $response->Respond(); }
public function VersionInstructions() { $response = new ResponseManager(); Kit::ClassLoader('media'); Kit::ClassLoader('display'); Kit::ClassLoader('lkmediadisplaygroup'); $displayGroupId = Kit::GetParam('displaygroupid', _POST, _INT); $mediaId = Kit::GetParam('mediaid', _POST, _INT); // Make sure we have permission to do this to this display $auth = $this->user->DisplayGroupAuth($displayGroupId, true); if (!$auth->edit) { trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); } // Make sure we have permission to use this file $mediaAuth = $this->user->MediaAuth($mediaId, true); if (!$mediaAuth->view) { trigger_error(__('You have selected media that you no longer have permission to use. Please reload the form.'), E_USER_ERROR); } // Make sure this file is assigned to this display group $link = new LkMediaDisplayGroup($this->db); if (!$link->Link($displayGroupId, $mediaId)) { trigger_error($display->GetErrorMessage(), E_USER_ERROR); } // Get the "StoredAs" for this media item $media = new Media($this->db); $storedAs = $media->GetStoredAs($mediaId); // Get a list of displays for this group $displays = $this->user->DisplayList(array('displayid'), array('displaygroupid' => $displayGroupId)); foreach ($displays as $display) { // Update the Display with the new instructions $displayObject = new Display($this->db); if (!$displayObject->SetVersionInstructions($display['displayid'], $mediaId, $storedAs)) { trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR); } } $response->SetFormSubmitResponse(__('Version Instructions Set')); $response->Respond(); }
public function Delete() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); $helpId = Kit::GetParam('HelpID', _POST, _INT); // Deal with the Edit Kit::ClassLoader('help'); $helpObject = new Help($db); if (!$helpObject->Delete($helpId)) { trigger_error($helpObject->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Help Link Deleted'), false); $response->Respond(); }
public function ImportCsv() { $db =& $this->db; $response = new ResponseManager(); $dataSetId = Kit::GetParam('datasetid', _POST, _INT); $overwrite = Kit::GetParam('overwrite', _POST, _CHECKBOX); $ignorefirstrow = Kit::GetParam('ignorefirstrow', _POST, _CHECKBOX); $auth = $this->user->DataSetAuth($dataSetId, true); if (!$auth->edit) { trigger_error(__('Access Denied'), E_USER_ERROR); } // 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 (original name) $fileName = Kit::GetParam('txtFileName', _POST, _STRING); $fileName = basename($fileName); $ext = strtolower(substr(strrchr($fileName, "."), 1)); // Check it is a CSV file if ($ext != 'csv') { trigger_error(__('Files with a CSV extension only.'), E_USER_ERROR); } // File upload directory.. get this from the settings object $csvFileLocation = Config::GetSetting('LIBRARY_LOCATION') . 'temp/' . $tmpName; // Enumerate over the columns in the DataSet and offer a column mapping for each one (from the file) $SQL = ""; $SQL .= "SELECT DataSetColumnID "; $SQL .= " FROM datasetcolumn "; $SQL .= sprintf(" WHERE DataSetID = %d ", $dataSetId); $SQL .= " AND DataSetColumnTypeID = 1 "; $SQL .= "ORDER BY ColumnOrder "; // Load results into an array $dataSetColumns = $db->GetArray($SQL); if (!is_array($dataSetColumns)) { trigger_error($db->error()); trigger_error(__('Error getting list of dataSetColumns'), E_USER_ERROR); } $spreadSheetMapping = array(); foreach ($dataSetColumns as $row) { $dataSetColumnId = Kit::ValidateParam($row['DataSetColumnID'], _INT); $spreadSheetColumn = Kit::GetParam('csvImport_' . $dataSetColumnId, _POST, _INT); $spreadSheetMapping[$spreadSheetColumn - 1] = $dataSetColumnId; } $dataSetObject = new DataSetData($db); if (!$dataSetObject->ImportCsv($dataSetId, $csvFileLocation, $spreadSheetMapping, $overwrite == 1, $ignorefirstrow == 1)) { trigger_error($dataSetObject->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('CSV File Imported')); $response->Respond(); }
/** * Tidies up the library */ public function tidyLibrary() { $response = new ResponseManager(); if (Config::GetSetting('SETTING_LIBRARY_TIDY_ENABLED') != 1) { trigger_error(__('Sorry this function is disabled.'), E_USER_ERROR); } $media = new Media(); if (!$media->deleteUnusedForUser($this->user->userid)) { trigger_error($media->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Library Tidy Complete')); $response->Respond(); }
/** * Tidies up the library */ public function TidyLibrary() { $response = new ResponseManager(); $tidyOldRevisions = Kit::GetParam('tidyOldRevisions', _POST, _CHECKBOX) == 1; $cleanUnusedFiles = Kit::GetParam('cleanUnusedFiles', _POST, _CHECKBOX) == 1; if (Config::GetSetting('SETTING_LIBRARY_TIDY_ENABLED') != 1) { trigger_error(__('Sorry this function is disabled.'), E_USER_ERROR); } $maintenance = new Maintenance(); if (!$maintenance->TidyLibrary($tidyOldRevisions, $cleanUnusedFiles)) { trigger_error($maintenance->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Library Tidy Complete')); $response->Respond(); }
public function Verify() { // Check the token if (!Kit::CheckToken()) { trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR); } $response = new ResponseManager(); try { $dbh = PDOConnect::init(); $dbh->exec('UPDATE `media` SET valid = 0 WHERE moduleSystemFile = 1'); } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage()); if (!$this->IsError()) { $this->SetError(1, __('Unknown Error')); } return false; } Media::installAllModuleFiles(); $response->SetFormSubmitResponse(__('Verified'), false); $response->Respond(); }
/** * 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(); }
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(); }
/** * Sets the Members of a group * @return */ public function SetMembers() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); Kit::ClassLoader('campaign'); $campaignObject = new Campaign($db); $campaignId = Kit::GetParam('CampaignID', _REQUEST, _INT); $layouts = Kit::GetParam('LayoutID', _POST, _ARRAY, array()); // Authenticate this user $auth = $this->user->CampaignAuth($campaignId, true); if (!$auth->edit) { trigger_error(__('You do not have permission to edit this campaign'), E_USER_ERROR); } // Remove all current members $campaignObject->UnlinkAll($campaignId); // Add all new members $displayOrder = 1; foreach ($layouts as $layoutId) { // Authenticate $auth = $this->user->LayoutAuth($layoutId, true); if (!$auth->view) { trigger_error(__('Your permissions to view a layout you are adding have been revoked. Please reload the Layouts form.'), E_USER_ERROR); } $campaignObject->Link($campaignId, $layoutId, $displayOrder); $displayOrder++; } $response->SetFormSubmitResponse(__('Layouts Added to Campaign'), false); $response->Respond(); }
/** * Logs out a user * @return */ function LogoutUser() { // Check the token if (!Kit::CheckToken()) { trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR); } $db =& $this->db; //ajax request handler $response = new ResponseManager(); $userID = Kit::GetParam('userid', _POST, _INT); $SQL = sprintf("UPDATE session SET IsExpired = 1 WHERE userID = %d", $userID); if (!$db->query($SQL)) { trigger_error($db->error()); trigger_error(__("Unable to log out this user"), E_USER_ERROR); } $response->SetFormSubmitResponse(__('User Logged Out.')); $response->Respond(); }
/** * Deletes an Event from all displays * @return */ public function DeleteDay() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $displayGroupIds = Kit::GetParam('DisplayGroupIDs', _POST, _ARRAY, Kit::GetParam('DisplayGroupIDs', _SESSION, _ARRAY)); $date = Kit::GetParam('date', _POST, _INT, 0); $dateString = date('Y-m-d', $date); if ($date == 0) { trigger_error(__('Day not selected'), E_USER_ERROR); } $events = $this->GetEventsForDay($date, $displayGroupIds); // Create an object to use for the delete $scheduleObject = new Schedule($db); foreach ($events as $event) { if ($event->editPermission) { // Delete the entire schedule. if (!$scheduleObject->Delete($event->eventID)) { trigger_error($scheduleObject->GetErrorMessage(), E_USER_ERROR); } } } $response->SetFormSubmitResponse(sprintf(__('All events for %s have been deleted'), $dateString)); $response->callBack = 'CallGenerateCalendar'; $response->Respond(); }
public function RequestScreenShot() { // Check the token if (!Kit::CheckToken()) { trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); $displayObject = new Display($db); $displayId = Kit::GetParam('displayId', _POST, _INT); if (!$displayObject->RequestScreenShot($displayId)) { trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Request Sent.')); $response->Respond(); }
public function ScheduleNow() { // 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(); $campaignId = Kit::GetParam('CampaignID', _POST, _INT, 0); $displayGroupIds = Kit::GetParam('DisplayGroupIDs', _POST, _ARRAY); $isPriority = Kit::GetParam('is_priority', _POST, _CHECKBOX); $fromDt = time(); $hours = Kit::GetParam('hours', _POST, _INT, 0); $minutes = Kit::GetParam('minutes', _POST, _INT, 0); $seconds = Kit::GetParam('seconds', _POST, _INT, 0); $duration = $hours * 3600 + $minutes * 60 + $seconds; $displayOrder = Kit::GetParam('DisplayOrder', _POST, _INT); // Validate if ($campaignId == 0) { trigger_error(__('No layout selected'), E_USER_ERROR); } if ($duration == 0) { trigger_error(__('You must enter a duration'), E_USER_ERROR); } // check that at least one display has been selected if ($displayGroupIds == '') { trigger_error(__('No displays selected'), E_USER_ERROR); } if ($fromDt < time() - 86400) { trigger_error(__('Your start time is in the past. Cannot schedule events in the past'), E_USER_ERROR); } $toDt = $fromDt + $duration; // Ready to do the add $scheduleObject = new Schedule($db); if (!$scheduleObject->Add($displayGroupIds, $fromDt, $toDt, $campaignId, '', '', '', $isPriority, $this->user->userid, $displayOrder)) { trigger_error($scheduleObject->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('The Event has been Scheduled')); $response->Respond(); }
/** * Sets the Members of a group * @return */ public function SetMembers() { // Check the token if (!Kit::CheckToken('assign_token')) { trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); $campaignObject = new Campaign(); $campaignId = Kit::GetParam('CampaignID', _REQUEST, _INT); $layouts = Kit::GetParam('LayoutID', _POST, _ARRAY, array()); // Authenticate this user $auth = $this->user->CampaignAuth($campaignId, true); if (!$auth->edit) { trigger_error(__('You do not have permission to edit this campaign'), E_USER_ERROR); } // Get all current members $currentMembers = Layout::Entries(NULL, array('campaignId' => $campaignId)); // Flatten $currentLayouts = array_map(function ($element) { return $element->layoutId; }, $currentMembers); // Work out which ones are NEW $newLayouts = array_diff($currentLayouts, $layouts); // Check permissions to all new layouts that have been selected foreach ($newLayouts as $layoutId) { // Authenticate $auth = $this->user->LayoutAuth($layoutId, true); if (!$auth->view) { trigger_error(__('Your permissions to view a layout you are adding have been revoked. Please reload the Layouts form.'), E_USER_ERROR); } } // Remove all current members $campaignObject->UnlinkAll($campaignId); // Add all new members $displayOrder = 1; foreach ($layouts as $layoutId) { // By this point everything should be authenticated $campaignObject->Link($campaignId, $layoutId, $displayOrder); $displayOrder++; } $response->SetFormSubmitResponse(__('Layouts Added to Campaign'), false); $response->Respond(); }
public function quota() { $response = new ResponseManager(); $groupId = Kit::GetParam('groupId', _POST, _INT); $libraryQuota = Kit::GetParam('libraryQuota', _POST, _INT); try { UserGroup::updateLibraryQuota($groupId, $libraryQuota); } catch (Exception $e) { Debug::Error($e->getMessage()); trigger_error(__('Problem setting quota'), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Quota has been updated'), false); $response->Respond(); }