Example #1
0
 /**
  * Adds a Display
  * @return 
  * @param $display Object
  * @param $isAuditing Object
  * @param $defaultLayoutID Object
  * @param $license Object
  * @param $licensed Object
  * @param $incSchedule Object
  */
 public function Add($display, $isAuditing, $defaultLayoutID, $license, $licensed, $incSchedule)
 {
     Debug::LogEntry('audit', 'IN', 'Display', 'Add');
     try {
         $dbh = PDOConnect::init();
         // Create the SQL
         $SQL = "";
         $SQL .= "INSERT INTO display (display, isAuditing, defaultlayoutid, license, licensed, inc_schedule, email_alert, alert_timeout) ";
         $SQL .= " VALUES (:display, :isauditing, :defaultlayoutid, :license, :licensed, :inc_schedule, :email_alert, :alert_timeout) ";
         $sth = $dbh->prepare($SQL);
         $sth->execute(array('display' => $display, 'isauditing' => 0, 'defaultlayoutid' => 1, 'license' => $license, 'licensed' => 0, 'inc_schedule' => 0, 'email_alert' => 0, 'alert_timeout' => 0));
         // Get the ID of the inserted record
         $displayId = $dbh->lastInsertId();
         // Also want to add the DisplayGroup associated with this Display.
         $displayGroupObject = new DisplayGroup($this->db);
         if (!($displayGroupId = $displayGroupObject->Add($display, 1, ''))) {
             $this->ThrowError(25001, __('Could not add a display group for the new display.'));
         }
         // Link the Two together
         if (!$displayGroupObject->Link($displayGroupId, $displayId)) {
             $this->ThrowError(25001, __('Could not link the new display with its group.'));
         }
         Debug::LogEntry('audit', 'OUT', 'Display', 'Add');
         return $displayId;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         if (!$this->IsError()) {
             $this->SetError(25000, __('Could not add display'));
         }
         return false;
     }
 }
Example #2
0
 public function Boot()
 {
     $db =& $this->db;
     // Will need to add some upgrade PHP to create a DisplayGroup (+ link record) for every Currently existing display.
     $dg = new DisplayGroup($db);
     // Get all displays
     $SQL = "SELECT DisplayID, Display FROM display";
     if (!($result = $db->query($SQL))) {
         reportError('20.php', "Error creating display groups");
     }
     while ($row = $db->get_assoc_row($result)) {
         // For each display create a display group and link it to the display
         $displayID = Kit::ValidateParam($row['DisplayID'], _INT);
         $display = Kit::ValidateParam($row['Display'], _STRING);
         $displayGroupID = $dg->Add($display, 1);
         $dg->Link($displayGroupID, $displayID);
     }
     // We also need to do a number on the schedule records
     // Each schedule record needs to be altered so that the displayID_list now reflects the displayGroupIDs
     $this->UpdateSchedules();
     // Create groups for all current users
     $this->UpdateUserGroups();
     return true;
 }
Example #3
0
 /**
  * Sets the Members of a group
  * @return
  */
 public function SetMemberOf()
 {
     $db =& $this->db;
     $response = new ResponseManager();
     Kit::ClassLoader('displaygroup');
     $displayGroupObject = new DisplayGroup($db);
     $displayID = Kit::GetParam('DisplayID', _REQUEST, _INT);
     $displayGroups = Kit::GetParam('DisplayGroupID', _POST, _ARRAY, array());
     $members = array();
     // Get a list of current members
     $SQL = "";
     $SQL .= "SELECT displaygroup.DisplayGroupID ";
     $SQL .= "FROM   displaygroup ";
     $SQL .= "   INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID ";
     $SQL .= sprintf("WHERE  lkdisplaydg.DisplayID   = %d ", $displayID);
     $SQL .= " AND displaygroup.IsDisplaySpecific = 0 ";
     if (!($resultIn = $db->query($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Error getting Display Groups'), E_USER_ERROR);
     }
     while ($row = $db->get_assoc_row($resultIn)) {
         // Test whether this ID is in the array or not
         $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT);
         if (!in_array($displayGroupID, $displayGroups)) {
             // Its currently assigned but not in the $displays array
             //  so we unassign
             if (!$displayGroupObject->Unlink($displayGroupID, $displayID)) {
                 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
             }
         } else {
             $members[] = $displayGroupID;
         }
     }
     foreach ($displayGroups as $displayGroupID) {
         // Add any that are missing
         if (!in_array($displayGroupID, $members)) {
             if (!$displayGroupObject->Link($displayGroupID, $displayID)) {
                 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
             }
         }
     }
     $response->SetFormSubmitResponse(__('Group membership set'), false);
     $response->Respond();
 }