Ejemplo n.º 1
0
 /**
  * Shows a list of displays
  */
 public function DisplayList()
 {
     $user =& $this->user;
     $response = new ResponseManager();
     $displayGroupIDs = Kit::GetParam('DisplayGroupIDs', _SESSION, _ARRAY);
     $filter_name = Kit::GetParam('filter_name', _POST, _STRING);
     // Build 2 lists
     $groups = array();
     $displays = array();
     foreach ($user->DisplayGroupList(0, $filter_name) as $display) {
         $display['checked_text'] = in_array($display['displaygroupid'], $displayGroupIDs) ? 'checked' : '';
         if ($display['isdisplayspecific'] == 1) {
             $displays[] = $display;
         } else {
             $groups[] = $display;
         }
     }
     Theme::Set('id', 'DisplayList');
     Theme::Set('group_list_items', $groups);
     Theme::Set('display_list_items', $displays);
     $output = Theme::RenderReturn('schedule_page_display_list');
     $response->SetGridResponse($output);
     $response->callBack = 'DisplayListRender';
     $response->Respond();
 }
Ejemplo n.º 2
0
 /**
  * Return the Edit Form as HTML
  * @return
  */
 public function EditForm()
 {
     $db =& $this->db;
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     $mediaid = $this->mediaid;
     // Permissions
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this assignment.');
         $this->response->keepOpen = true;
         return $this->response;
     }
     Theme::Set('form_id', 'ModuleForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=EditMedia');
     Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" id="iRegionId" name="regionid" value="' . $regionid . '"><input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" /><input type="hidden" id="mediaid" name="mediaid" value="' . $mediaid . '">');
     Theme::Set('windowsCommand', htmlentities(urldecode($this->GetOption('windowsCommand'))));
     Theme::Set('linuxCommand', htmlentities(urldecode($this->GetOption('linuxCommand'))));
     $this->response->html = Theme::RenderReturn('media_form_shellcommand_edit');
     if ($this->showRegionOptions) {
         $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $layoutid . '&regionid=' . $regionid . '&q=RegionOptions")');
     } else {
         $this->response->AddButton(__('Cancel'), 'XiboDialogClose()');
     }
     $this->response->AddButton(__('Save'), '$("#ModuleForm").submit()');
     $this->response->dialogTitle = __('Edit Shell Command');
     $this->response->dialogSize = true;
     $this->response->dialogWidth = '450px';
     $this->response->dialogHeight = '250px';
     return $this->response;
 }
Ejemplo n.º 3
0
 function displayPage()
 {
     Theme::Set('version', VERSION);
     Theme::Set('text', Theme::RenderReturn('about_text'));
     // Render the Theme and output
     Theme::Render('about_page');
 }
Ejemplo n.º 4
0
 public function Grid()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $SQL = '';
     $SQL .= 'SELECT TransitionID, ';
     $SQL .= '   Transition, ';
     $SQL .= '   Code, ';
     $SQL .= '   HasDuration, ';
     $SQL .= '   HasDirection, ';
     $SQL .= '   AvailableAsIn, ';
     $SQL .= '   AvailableAsOut ';
     $SQL .= '  FROM `transition` ';
     $SQL .= ' ORDER BY Transition ';
     if (!($transitions = $db->GetArray($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Unable to get the list of transitions'), E_USER_ERROR);
     }
     $cols = array(array('name' => 'name', 'title' => __('Name')), array('name' => 'hasduration', 'title' => __('Has Duration'), 'icons' => true), array('name' => 'hasdirection', 'title' => __('Has Direction'), 'icons' => true), array('name' => 'enabledforin', 'title' => __('Enabled for In'), 'icons' => true), array('name' => 'enabledforout', 'title' => __('Enabled for Out'), 'icons' => true));
     Theme::Set('table_cols', $cols);
     $rows = array();
     foreach ($transitions as $transition) {
         $row = array();
         $row['transitionid'] = Kit::ValidateParam($transition['TransitionID'], _INT);
         $row['name'] = Kit::ValidateParam($transition['Transition'], _STRING);
         $row['hasduration'] = Kit::ValidateParam($transition['HasDuration'], _INT);
         $row['hasdirection'] = Kit::ValidateParam($transition['HasDirection'], _INT);
         $row['enabledforin'] = Kit::ValidateParam($transition['AvailableAsIn'], _INT);
         $row['enabledforout'] = Kit::ValidateParam($transition['AvailableAsOut'], _INT);
         // Initialise array of buttons, because we might not have any
         $row['buttons'] = array();
         // If the module config is not locked, present some buttons
         if (Config::GetSetting('TRANSITION_CONFIG_LOCKED_CHECKB') != 'Checked') {
             // Edit button
             $row['buttons'][] = array('id' => 'transition_button_edit', 'url' => 'index.php?p=transition&q=EditForm&TransitionID=' . $row['transitionid'], 'text' => __('Edit'));
         }
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     $output = Theme::RenderReturn('table_render');
     $response->SetGridResponse($output);
     $response->Respond();
 }
Ejemplo n.º 5
0
 function Grid()
 {
     $cols = array(array('name' => 'name', 'title' => __('Name')), array('name' => 'type', 'title' => __('Type')), array('name' => 'isdefault', 'title' => __('Default'), 'icons' => true));
     Theme::Set('table_cols', $cols);
     $rows = array();
     foreach ($this->user->DisplayProfileList() as $profile) {
         // Default Layout
         $profile['buttons'][] = array('id' => 'displayprofile_button_edit', 'url' => 'index.php?p=displayprofile&q=EditForm&displayprofileid=' . $profile['displayprofileid'], 'text' => __('Edit'));
         if ($profile['del'] == 1) {
             $profile['buttons'][] = array('id' => 'displayprofile_button_delete', 'url' => 'index.php?p=displayprofile&q=DeleteForm&displayprofileid=' . $profile['displayprofileid'], 'text' => __('Delete'));
         }
         $rows[] = $profile;
     }
     Theme::Set('table_rows', $rows);
     $output = Theme::RenderReturn('table_render');
     $response = new ResponseManager();
     $response->SetGridResponse($output);
     $response->Respond();
 }
Ejemplo n.º 6
0
    public function Grid()
    {
        $db =& $this->db;
        $user =& $this->user;
        $response = new ResponseManager();
        //display the display table
        $SQL = <<<SQL
        SELECT HelpID, Topic, Category, Link
          FROM `help`
        ORDER BY Topic, Category
SQL;
        // Load results into an array
        $helplinks = $db->GetArray($SQL);
        if (!is_array($helplinks)) {
            trigger_error($db->error());
            trigger_error(__('Error getting list of helplinks'), E_USER_ERROR);
        }
        $cols = array(array('name' => 'topic', 'title' => __('Topic')), array('name' => 'category', 'title' => __('Category')), array('name' => 'link', 'title' => __('Link')));
        Theme::Set('table_cols', $cols);
        $rows = array();
        foreach ($helplinks as $row) {
            $row['helpid'] = Kit::ValidateParam($row['HelpID'], _INT);
            $row['topic'] = Kit::ValidateParam($row['Topic'], _STRING);
            $row['category'] = Kit::ValidateParam($row['Category'], _STRING);
            $row['link'] = Kit::ValidateParam($row['Link'], _STRING);
            $row['buttons'] = array();
            // we only want to show certain buttons, depending on the user logged in
            if ($user->usertypeid == 1) {
                // Edit
                $row['buttons'][] = array('id' => 'help_button_edit', 'url' => 'index.php?p=help&q=EditForm&HelpID=' . $row['helpid'], 'text' => __('Edit'));
                // Delete
                $row['buttons'][] = array('id' => 'help_button_delete', 'url' => 'index.php?p=help&q=DeleteForm&HelpID=' . $row['helpid'], 'text' => __('Delete'));
                // Test
                $row['buttons'][] = array('id' => 'help_button_test', 'url' => HelpManager::Link($row['topic'], $row['category']), 'text' => __('Test'));
            }
            $rows[] = $row;
        }
        Theme::Set('table_rows', $rows);
        $output = Theme::RenderReturn('table_render');
        $response->SetGridResponse($output);
        $response->Respond();
    }
Ejemplo n.º 7
0
 public function ImportForm()
 {
     global $session;
     $db =& $this->db;
     $response = new ResponseManager();
     // Set the Session / Security information
     $sessionId = session_id();
     $securityToken = CreateFormToken();
     $session->setSecurityToken($securityToken);
     // Find the max file size
     $maxFileSizeBytes = convertBytes(ini_get('upload_max_filesize'));
     // Set some information about the form
     Theme::Set('form_id', 'LayoutImportForm');
     Theme::Set('form_action', 'index.php?p=layout&q=Import');
     Theme::Set('form_meta', '<input type="hidden" id="txtFileName" name="txtFileName" readonly="true" /><input type="hidden" name="hidFileID" id="hidFileID" value="" /><input type="hidden" name="template" value="' . Kit::GetParam('template', _GET, _STRING, 'false') . '" />');
     Theme::Set('form_upload_id', 'file_upload');
     Theme::Set('form_upload_action', 'index.php?p=content&q=FileUpload');
     Theme::Set('form_upload_meta', '<input type="hidden" id="PHPSESSID" value="' . $sessionId . '" /><input type="hidden" id="SecurityToken" value="' . $securityToken . '" /><input type="hidden" name="MAX_FILE_SIZE" value="' . $maxFileSizeBytes . '" />');
     Theme::Set('prepend', Theme::RenderReturn('form_file_upload_single'));
     $formFields = array();
     $formFields[] = FormManager::AddText('layout', __('Name'), NULL, __('The Name of the Layout - (1 - 50 characters). Leave blank to use the name from the import.'), 'n');
     $formFields[] = FormManager::AddCheckbox('replaceExisting', __('Replace Existing Media?'), NULL, __('If the import finds existing media with the same name, should it be replaced in the Layout or should the Layout use that media.'), 'r');
     if (Kit::GetParam('template', _GET, _STRING, 'false') != 'true') {
         $formFields[] = FormManager::AddCheckbox('importTags', __('Import Tags?'), NULL, __('Would you like to import any tags contained on the layout.'), 't');
     }
     Theme::Set('form_fields', $formFields);
     $response->SetFormRequestResponse(NULL, __('Import Layout'), '350px', '200px');
     $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DataSet', 'ImportCsv') . '")');
     $response->AddButton(__('Cancel'), 'XiboDialogClose()');
     $response->AddButton(__('Import'), '$("#LayoutImportForm").submit()');
     $response->Respond();
 }
Ejemplo n.º 8
0
 /**
  * Permissions form
  */
 public function PermissionsForm()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $helpManager = new HelpManager($db, $user);
     $templateId = Kit::GetParam('templateid', _GET, _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);
     // Set some information about the form
     Theme::Set('form_id', 'TemplatePermissionsForm');
     Theme::Set('form_action', 'index.php?p=template&q=Permissions');
     Theme::Set('form_meta', '<input type="hidden" name="templateid" value="' . $templateId . '" />');
     // List of all Groups with a view/edit/delete checkbox
     $SQL = '';
     $SQL .= 'SELECT `group`.GroupID, `group`.`Group`, View, Edit, Del, `group`.IsUserSpecific ';
     $SQL .= '  FROM `group` ';
     $SQL .= '   LEFT OUTER JOIN lktemplategroup ';
     $SQL .= '   ON lktemplategroup.GroupID = group.GroupID ';
     $SQL .= '       AND lktemplategroup.TemplateID = %d ';
     $SQL .= ' WHERE `group`.GroupID <> %d ';
     $SQL .= 'ORDER BY `group`.IsEveryone DESC, `group`.IsUserSpecific, `group`.`Group` ';
     $SQL = sprintf($SQL, $templateId, $user->getGroupFromId($user->userid, true));
     if (!($results = $db->query($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Unable to get permissions for this template'), E_USER_ERROR);
     }
     $checkboxes = array();
     while ($row = $db->get_assoc_row($results)) {
         $groupId = $row['GroupID'];
         $rowClass = $row['IsUserSpecific'] == 0 ? 'strong_text' : '';
         $checkbox = array('id' => $groupId, 'name' => Kit::ValidateParam($row['Group'], _STRING), 'class' => $rowClass, 'value_view' => $groupId . '_view', 'value_view_checked' => $row['View'] == 1 ? 'checked' : '', 'value_edit' => $groupId . '_edit', 'value_edit_checked' => $row['Edit'] == 1 ? 'checked' : '', 'value_del' => $groupId . '_del', 'value_del_checked' => $row['Del'] == 1 ? 'checked' : '');
         $checkboxes[] = $checkbox;
     }
     Theme::Set('form_rows', $checkboxes);
     $form = Theme::RenderReturn('campaign_form_permissions');
     $response->SetFormRequestResponse($form, __('Permissions'), '350px', '500px');
     $response->AddButton(__('Help'), 'XiboHelpRender("' . $helpManager->Link('Template', 'Permissions') . '")');
     $response->AddButton(__('Cancel'), 'XiboDialogClose()');
     $response->AddButton(__('Save'), '$("#TemplatePermissionsForm").submit()');
     $response->Respond();
 }
Ejemplo n.º 9
0
 public function Step6()
 {
     // Form to collect the library location and server key
     $formFields = array();
     $formFields[] = FormManager::AddHidden('step', 7);
     $formFields[] = FormManager::AddText('library_location', __('Library Location'), NULL, sprintf(__('%s needs somewhere to store the things you upload to be shown. Ideally, this should be somewhere outside the root of your web server - that is such that is not accessible by a web browser. Please input the full path to this folder. If the folder does not already exist, we will attempt to create it for you.'), Theme::GetConfig('app_name')), 'n');
     $formFields[] = FormManager::AddText('server_key', __('Server Key'), Install::gen_secret(6), sprintf(__('%s needs you to choose a "key". This will be required each time you set-up a new client. It should be complicated, and hard to remember. It is visible in the CMS interface, so it need not be written down separately.'), Theme::GetConfig('app_name')), 'n');
     $formFields[] = FormManager::AddCheckbox('stats', __('Statistics'), 1, sprintf(__('We\'d love to know you\'re running %s. If you\'re happy for us to collect anonymous statistics (version number, number of displays) then please leave the box ticked. Please un tick the box if your server does not have direct access to the internet.'), Theme::GetConfig('app_name')), 'n');
     // Put up an error message if one has been set (and then unset it)
     if ($this->errorMessage != '') {
         Theme::Set('message', $this->errorMessage);
         Theme::Set('prepend', Theme::RenderReturn('message_box'));
         $this->errorMessage == '';
     }
     // Return a rendered form
     Theme::Set('form_action', 'install.php');
     Theme::Set('form_fields', $formFields);
     Theme::Set('form_buttons', array(FormManager::AddButton(__('Next'))));
     return Theme::RenderReturn('form_render');
 }
Ejemplo n.º 10
0
 /**
  * Shows the Authorised applications this user has
  */
 public function UserTokens()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $store = OAuthStore::instance();
     try {
         $list = $store->listConsumerTokens(Kit::GetParam('userID', _GET, _INT));
     } catch (OAuthException $e) {
         trigger_error($e->getMessage());
         trigger_error(__('Error listing Log.'), E_USER_ERROR);
     }
     $rows = array();
     foreach ($list as $app) {
         $app['application_title'] = Kit::ValidateParam($app['application_title'], _STRING);
         $app['enabled'] = Kit::ValidateParam($app['enabled'], _STRING);
         $app['status'] = Kit::ValidateParam($app['status'], _STRING);
         $rows[] = $app;
     }
     Theme::Set('table_rows', $rows);
     $output = Theme::RenderReturn('application_form_user_applications');
     $response->SetFormRequestResponse($output, __('Authorized applications for user'), '650', '450');
     $response->AddButton(__('Help'), "XiboHelpRender('" . HelpManager::Link('User', 'Applications') . "')");
     $response->AddButton(__('Close'), 'XiboDialogClose()');
     $response->Respond();
 }
Ejemplo n.º 11
0
 /**
  * Member of Display Groups Form
  */
 public function MemberOfForm()
 {
     $db =& $this->db;
     $response = new ResponseManager();
     $displayID = Kit::GetParam('DisplayID', _REQUEST, _INT);
     // Auth
     $auth = $this->user->DisplayGroupAuth($this->GetDisplayGroupId($displayID), true);
     if (!$auth->modifyPermissions) {
         trigger_error(__('You do not have permission to change Display Groups on this display'), E_USER_ERROR);
     }
     // There needs to be two lists here.
     //  - DisplayGroups this Display is already assigned to
     //  - DisplayGroups this Display could be assigned to
     // Set some information about the form
     Theme::Set('displaygroups_assigned_id', 'displaysIn');
     Theme::Set('displaygroups_available_id', 'displaysOut');
     Theme::Set('displaygroups_assigned_url', 'index.php?p=display&q=SetMemberOf&DisplayID=' . $displayID);
     // Display Groups Assigned
     $SQL = "";
     $SQL .= "SELECT displaygroup.DisplayGroupID, ";
     $SQL .= "       displaygroup.DisplayGroup, ";
     $SQL .= "       CONCAT('DisplayGroupID_', displaygroup.DisplayGroupID) AS list_id ";
     $SQL .= "FROM   displaygroup ";
     $SQL .= "   INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID ";
     $SQL .= sprintf("WHERE  lkdisplaydg.DisplayID   = %d ", $displayID);
     $SQL .= " AND displaygroup.IsDisplaySpecific = 0 ";
     $SQL .= " ORDER BY displaygroup.DisplayGroup ";
     $displaygroupsAssigned = $db->GetArray($SQL);
     if (!is_array($displaygroupsAssigned)) {
         trigger_error($db->error());
         trigger_error(__('Error getting Display Groups'), E_USER_ERROR);
     }
     Theme::Set('displaygroups_assigned', $displaygroupsAssigned);
     // Display Groups not assigned
     $SQL = "";
     $SQL .= "SELECT displaygroup.DisplayGroupID, ";
     $SQL .= "       displaygroup.DisplayGroup, ";
     $SQL .= "       CONCAT('DisplayGroupID_', displaygroup.DisplayGroupID) AS list_id ";
     $SQL .= "  FROM displaygroup ";
     $SQL .= " WHERE displaygroup.IsDisplaySpecific = 0 ";
     $SQL .= " AND displaygroup.DisplayGroupID NOT IN ";
     $SQL .= "       (SELECT lkdisplaydg.DisplayGroupID ";
     $SQL .= "          FROM lkdisplaydg ";
     $SQL .= sprintf(" WHERE  lkdisplaydg.DisplayID   = %d ", $displayID);
     $SQL .= "       )";
     $SQL .= " ORDER BY displaygroup.DisplayGroup ";
     Debug::LogEntry('audit', $SQL);
     $displaygroups_available = $db->GetArray($SQL);
     if (!is_array($displaygroups_available)) {
         trigger_error($db->error());
         trigger_error(__('Error getting Display Groups'), E_USER_ERROR);
     }
     Theme::Set('displaygroups_available', $displaygroups_available);
     // Render the theme
     $form = Theme::RenderReturn('display_form_group_assign');
     $response->SetFormRequestResponse($form, __('Manage Membership'), '400', '375', 'DisplayGroupManageMembersCallBack');
     $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayGroup', 'Members') . '")');
     $response->AddButton(__('Cancel'), 'XiboDialogClose()');
     $response->AddButton(__('Save'), 'DisplayGroupMembersSubmit()');
     $response->Respond();
 }
Ejemplo n.º 12
0
 /**
  * Return the Edit Form as HTML
  * @return
  */
 public function EditForm()
 {
     $this->response = new ResponseManager();
     // Edit calls are the same as add calls, except you will to check the user has permissions to do the edit
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this assignment.');
         $this->response->keepOpen = false;
         return $this->response;
     }
     // All forms should set some meta data about the form.
     // Usually, you would want this meta data to remain the same.
     Theme::Set('form_id', 'ModuleForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=EditMedia');
     Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $this->layoutid . '"><input type="hidden" id="iRegionId" name="regionid" value="' . $this->regionid . '"><input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" /><input type="hidden" id="mediaid" name="mediaid" value="' . $this->mediaid . '">');
     // Extract the format from the raw node in the XLF
     $rawXml = new DOMDocument();
     $rawXml->loadXML($this->GetRaw());
     $formatNodes = $rawXml->getElementsByTagName('format');
     $formatNode = $formatNodes->item(0);
     $formFields = array();
     // Offer a choice of clock type
     $formFields[] = FormManager::AddCombo('clockTypeId', __('Clock Type'), $this->GetOption('clockTypeId'), array(array('clockTypeId' => '1', 'clockType' => 'Analogue'), array('clockTypeId' => '2', 'clockType' => 'Digital'), array('clockTypeId' => '3', 'clockType' => 'Flip Clock')), 'clockTypeId', 'clockType', __('Please select the type of clock to display.'), 'c');
     $formFields[] = FormManager::AddNumber('duration', __('Duration'), $this->duration, __('The duration in seconds this item should be displayed'), 'd', 'required');
     $formFields[] = FormManager::AddNumber('offset', __('Offset'), $this->GetOption('offset'), __('The offset in minutes that should be applied to the current time.'), 'o', NULL, 'offset-control-group');
     // Offer a choice of theme
     $formFields[] = FormManager::AddCombo('themeid', __('Theme'), $this->GetOption('theme'), array(array('themeid' => '1', 'theme' => 'Light'), array('themeid' => '2', 'theme' => 'Dark')), 'themeid', 'theme', __('Please select a theme for the clock.'), 't', 'analogue-control-group');
     $formFields[] = FormManager::AddMessage(sprintf(__('Enter a format for the Digital Clock below. e.g. [HH:mm] or [DD/MM/YYYY]. See the <a href="%s" target="_blank">format guide</a> for more information.'), HelpManager::Link('Widget', 'ClockFormat')), 'digital-control-group');
     $formFields[] = FormManager::AddMultiText('ta_text', NULL, $formatNode != NULL ? $formatNode->nodeValue : '', __('Enter a format for the clock'), 'f', 10, '', 'digital-control-group');
     Theme::Set('form_fields', $formFields);
     // Dependencies (some fields should be shown / hidden)
     $this->SetFieldDependencies();
     // Modules should be rendered using the theme engine.
     $this->response->html = Theme::RenderReturn('form_render');
     $this->response->dialogTitle = __('Edit Clock');
     $this->response->callBack = 'text_callback';
     // The response object outputs the required JSON object to the browser
     // which is then processed by the CMS JavaScript library (xibo-cms.js).
     if ($this->showRegionOptions) {
         $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $this->layoutid . '&regionid=' . $this->regionid . '&q=RegionOptions")');
     } else {
         $this->response->AddButton(__('Cancel'), 'XiboDialogClose()');
     }
     $this->response->AddButton(__('Apply'), 'XiboDialogApply("#ModuleForm")');
     $this->response->AddButton(__('Save'), '$("#ModuleForm").submit()');
     // The response must be returned.
     return $this->response;
 }
Ejemplo n.º 13
0
 /**
  * Edit Form
  */
 public function EditForm()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $helpManager = new HelpManager($db, $user);
     // Can we edit?
     if (Config::GetSetting('MODULE_CONFIG_LOCKED_CHECKB') == 'Checked') {
         trigger_error(__('Module Config Locked'), E_USER_ERROR);
     }
     $moduleId = Kit::GetParam('ModuleID', _GET, _INT);
     // Pull the currently known info from the DB
     $SQL = '';
     $SQL .= 'SELECT ModuleID, ';
     $SQL .= '   Name, ';
     $SQL .= '   Enabled, ';
     $SQL .= '   Description, ';
     $SQL .= '   RegionSpecific, ';
     $SQL .= '   ValidExtensions, ';
     $SQL .= '   ImageUri, ';
     $SQL .= '   PreviewEnabled ';
     $SQL .= '  FROM `module` ';
     $SQL .= ' WHERE ModuleID = %d ';
     $SQL = sprintf($SQL, $moduleId);
     if (!($row = $db->GetSingleRow($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Error getting Module'));
     }
     Theme::Set('validextensions', Kit::ValidateParam($row['ValidExtensions'], _STRING));
     Theme::Set('imageuri', Kit::ValidateParam($row['ImageUri'], _STRING));
     Theme::Set('isregionspecific', Kit::ValidateParam($row['RegionSpecific'], _INT));
     Theme::Set('enabled_checked', Kit::ValidateParam($row['Enabled'], _INT) ? 'checked' : '');
     Theme::Set('preview_enabled_checked', Kit::ValidateParam($row['PreviewEnabled'], _INT) ? 'checked' : '');
     // Set some information about the form
     Theme::Set('form_id', 'ModuleEditForm');
     Theme::Set('form_action', 'index.php?p=module&q=Edit');
     Theme::Set('form_meta', '<input type="hidden" name="ModuleID" value="' . $moduleId . '" />');
     $form = Theme::RenderReturn('module_form_edit');
     $response->SetFormRequestResponse($form, __('Edit Module'), '350px', '325px');
     $response->AddButton(__('Help'), 'XiboHelpRender("' . $helpManager->Link('Module', 'Edit') . '")');
     $response->AddButton(__('Cancel'), 'XiboDialogClose()');
     $response->AddButton(__('Save'), '$("#ModuleEditForm").submit()');
     $response->Respond();
 }
Ejemplo n.º 14
0
 /**
  * Return the Edit Form as HTML
  * @return 
  */
 public function EditForm()
 {
     $db =& $this->db;
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     $mediaid = $this->mediaid;
     // Can this user edit?
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this media.');
         $this->response->keepOpen = false;
         return $this->response;
     }
     Theme::Set('form_id', 'ModuleForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=EditMedia');
     Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" id="iRegionId" name="regionid" value="' . $regionid . '"><input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" /><input type="hidden" id="mediaid" name="mediaid" value="' . $mediaid . '">');
     // Get the embedded HTML out of RAW
     $rawXml = new DOMDocument();
     $rawXml->loadXML($this->GetRaw());
     Debug::LogEntry('audit', 'Raw XML returned: ' . $this->GetRaw());
     // Get the HTML Node out of this
     $textNodes = $rawXml->getElementsByTagName('embedHtml');
     $textNode = $textNodes->item(0);
     Theme::Set('embedHtml', $textNode->nodeValue);
     $textNodes = $rawXml->getElementsByTagName('embedScript');
     $textNode = $textNodes->item(0);
     Theme::Set('embedScript', $textNode->nodeValue);
     Theme::Set('duration', $this->duration);
     Theme::Set('durationFieldEnabled', $this->auth->modifyPermissions ? '' : ' readonly');
     // Is the transparency option set?
     if ($this->GetOption('transparency')) {
         Theme::Set('transparency_checked', 'checked');
     }
     //Output the form
     $form = Theme::RenderReturn('media_form_embedded_edit');
     if ($this->showRegionOptions) {
         $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $layoutid . '&regionid=' . $regionid . '&q=RegionOptions")');
     } else {
         $this->response->AddButton(__('Cancel'), 'XiboDialogClose()');
     }
     $this->response->html = $form;
     $this->response->dialogTitle = 'Edit Embedded HTML';
     $this->response->dialogSize = true;
     $this->response->dialogWidth = '650px';
     $this->response->dialogHeight = '450px';
     $this->response->AddButton(__('Save'), '$("#ModuleForm").submit()');
     return $this->response;
 }
Ejemplo n.º 15
0
 /**
  * Show the library
  * @return 
  */
 function LibraryAssignView()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     //Input vars
     $mediatype = Kit::GetParam('filter_type', _POST, _STRING);
     $name = Kit::GetParam('filter_name', _POST, _STRING);
     // Get a list of media
     $mediaList = $user->MediaList(NULL, array('type' => $mediatype, 'name' => $name));
     $rows = array();
     // Add some extra information
     foreach ($mediaList as $row) {
         $row['duration_text'] = sec2hms($row['duration']);
         $row['list_id'] = 'MediaID_' . $row['mediaid'];
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     // Render the Theme
     $response->SetGridResponse(Theme::RenderReturn('library_form_assign_list'));
     $response->callBack = 'LibraryAssignCallback';
     $response->pageSize = 5;
     $response->Respond();
 }
Ejemplo n.º 16
0
 /**
  * Return the Edit Form as HTML
  * @return
  */
 public function EditForm()
 {
     $this->response = new ResponseManager();
     $db =& $this->db;
     $user =& $this->user;
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     $mediaid = $this->mediaid;
     // Permissions
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this assignment.');
         $this->response->keepOpen = true;
         return $this->response;
     }
     // Other properties
     $popupNotification = $this->GetOption('popupNotification');
     // Get the text out of RAW
     $rawXml = new DOMDocument();
     $rawXml->loadXML($this->GetRaw());
     Debug::LogEntry('audit', 'Raw XML returned: ' . $this->GetRaw());
     // Get the Text Node out of this
     $textNodes = $rawXml->getElementsByTagName('template');
     $textNode = $textNodes->item(0);
     $text = $textNode->nodeValue;
     Theme::Set('form_id', 'ModuleForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=EditMedia');
     Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" id="iRegionId" name="regionid" value="' . $regionid . '"><input type="hidden" name="mediaid" value="' . $mediaid . '"><input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" />');
     $formFields = array();
     $formFields[] = FormManager::AddMessage(__('Ubuntu Client Only'));
     $formFields[] = FormManager::AddNumber('duration', __('Duration'), $this->duration, __('The duration in seconds this counter should be displayed'), 'd', 'required', '', $this->auth->modifyPermissions);
     $formFields[] = FormManager::AddCheckbox('popupNotification', __('Pop-up Notification?'), $popupNotification, __('Popup a notification when the counter changes?'), 'n');
     $formFields[] = FormManager::AddMultiText('ta_text', NULL, $text, __('Enter a format that should be applied to the counter when it is show.'), 't', 10);
     Theme::Set('form_fields', $formFields);
     if ($this->showRegionOptions) {
         $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $layoutid . '&regionid=' . $regionid . '&q=RegionOptions")');
     } else {
         $this->response->AddButton(__('Cancel'), 'XiboDialogClose()');
     }
     $this->response->html = Theme::RenderReturn('form_render');
     $this->response->callBack = 'text_callback';
     $this->response->dialogTitle = __('Edit Counter');
     $this->response->AddButton(__('Save'), '$("#ModuleForm").submit()');
     return $this->response;
 }
Ejemplo n.º 17
0
 /**
  * Return the Edit Form as HTML
  * @return
  */
 public function EditForm()
 {
     $this->response = new ResponseManager();
     // This is the logged in user and can be used to assess permissions
     $user =& $this->user;
     // The CMS provides the region width and height in case they are needed
     $rWidth = Kit::GetParam('rWidth', _REQUEST, _STRING);
     $rHeight = Kit::GetParam('rHeight', _REQUEST, _STRING);
     // Augment settings with templates
     $this->loadTemplates();
     // All forms should set some meta data about the form.
     // Usually, you would want this meta data to remain the same.
     Theme::Set('form_id', 'ModuleForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=EditMedia');
     Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $this->layoutid . '"><input type="hidden" id="iRegionId" name="regionid" value="' . $this->regionid . '"><input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" /><input type="hidden" id="mediaid" name="mediaid" value="' . $this->mediaid . '">');
     $tabs = array();
     $tabs[] = FormManager::AddTab('general', __('General'));
     $tabs[] = FormManager::AddTab('template', __('Appearance'), array(array('name' => 'enlarge', 'value' => true)));
     $tabs[] = FormManager::AddTab('effect', __('Effect'));
     $tabs[] = FormManager::AddTab('advanced', __('Advanced'));
     Theme::Set('form_tabs', $tabs);
     $formFields['general'][] = FormManager::AddText('name', __('Name'), $this->GetOption('name'), __('An optional name for this media'), 'n');
     // Duration
     $formFields['general'][] = FormManager::AddNumber('duration', __('Duration'), $this->duration, __('The duration in seconds this item should be displayed.'), 'd', 'required');
     // Search Term
     $formFields['general'][] = FormManager::AddText('searchTerm', __('Search Term'), $this->GetOption('searchTerm'), __('Search term. You can test your search term in the twitter.com search box first.'), 's', 'required');
     // Type
     $formFields['general'][] = FormManager::AddCombo('resultType', __('Type'), $this->GetOption('resultType'), array(array('typeid' => 'mixed', 'type' => __('Mixed')), array('typeid' => 'recent', 'type' => __('Recent')), array('typeid' => 'popular', 'type' => __('Popular'))), 'typeid', 'type', __('Recent shows only the most recent tweets, Popular the most popular and Mixed includes both popular and recent results.'), 't', 'required');
     // Distance
     $formFields['general'][] = FormManager::AddNumber('tweetDistance', __('Distance'), $this->GetOption('tweetDistance'), __('Distance in miles that the tweets should be returned from. Set to 0 for no restrictions.'), 'd');
     // Distance
     $formFields['general'][] = FormManager::AddNumber('tweetCount', __('Count'), $this->GetOption('tweetCount'), __('The number of Tweets to return.'), 'c');
     // Common fields
     $formFields['effect'][] = FormManager::AddCombo('effect', __('Effect'), $this->GetOption('effect'), array(array('effectid' => 'none', 'effect' => __('None')), array('effectid' => 'fade', 'effect' => __('Fade')), array('effectid' => 'fadeout', 'effect' => __('Fade Out')), array('effectid' => 'scrollHorz', 'effect' => __('Scroll Horizontal')), array('effectid' => 'scrollVert', 'effect' => __('Scroll Vertical')), array('effectid' => 'flipHorz', 'effect' => __('Flip Horizontal')), array('effectid' => 'flipVert', 'effect' => __('Flip Vertical')), array('effectid' => 'shuffle', 'effect' => __('Shuffle')), array('effectid' => 'tileSlide', 'effect' => __('Tile Slide')), array('effectid' => 'tileBlind', 'effect' => __('Tile Blinds')), array('effectid' => 'marqueeLeft', 'effect' => __('Marquee Left')), array('effectid' => 'marqueeRight', 'effect' => __('Marquee Right')), array('effectid' => 'marqueeUp', 'effect' => __('Marquee Up')), array('effectid' => 'marqueeDown', 'effect' => __('Marquee Down'))), 'effectid', 'effect', __('Please select the effect that will be used to transition between items. If all items should be output, select None. Marquee effects are CPU intensive and may not be suitable for lower power displays.'), 'e');
     $formFields['effect'][] = FormManager::AddNumber('speed', __('Speed'), $this->GetOption('speed'), __('The transition speed of the selected effect in milliseconds (normal = 1000) or the Marquee Speed in a low to high scale (normal = 1).'), 's', NULL, 'effect-controls');
     // A list of web safe colours
     $formFields['advanced'][] = FormManager::AddText('backgroundColor', __('Background Colour'), $this->GetOption('backgroundColor'), __('The selected effect works best with a background colour. Optionally add one here.'), 'c', NULL, 'background-color-group');
     // Field empty
     $formFields['advanced'][] = FormManager::AddText('noTweetsMessage', __('No tweets'), $this->GetOption('noTweetsMessage'), __('A message to display when there are no tweets returned by the search query'), 'n');
     $formFields['advanced'][] = FormManager::AddText('dateFormat', __('Date Format'), $this->GetOption('dateFormat'), __('The format to apply to all dates returned by the ticker. In PHP date format: http://uk3.php.net/manual/en/function.date.php'), 'f');
     $formFields['advanced'][] = FormManager::AddCheckbox('removeUrls', __('Remove URLs?'), $this->GetOption('removeUrls', 1), __('Should URLs be removed from the Tweet Text. Most URLs do not compliment digital signage.'), 'u');
     $formFields['advanced'][] = FormManager::AddNumber('updateInterval', __('Update Interval (mins)'), $this->GetOption('updateInterval', 60), __('Please enter the update interval in minutes. This should be kept as high as possible. For example, if the data will only change once per hour this could be set to 60.'), 'n', 'required');
     // Encode up the template
     if (Config::GetSetting('SERVER_MODE') == 'Test' && $this->user->usertypeid == 1) {
         $formFields['advanced'][] = FormManager::AddMessage('<pre>' . htmlentities(json_encode(array('id' => 'ID', 'value' => 'TITLE', 'template' => $this->GetRawNode('template'), 'css' => $this->GetRawNode('styleSheet')))) . '</pre>');
     }
     // Template - for standard stuff
     $formFields['template'][] = FormManager::AddCombo('templateId', __('Template'), $this->GetOption('templateId', 'tweet-only'), $this->settings['templates'], 'id', 'value', __('Select the template you would like to apply. This can be overridden using the check box below.'), 't', 'template-selector-control');
     // Add a field for whether to override the template or not.
     // Default to 1 so that it will work correctly with old items (that didn't have a template selected at all)
     $formFields['template'][] = FormManager::AddCheckbox('overrideTemplate', __('Override the template?'), $this->GetOption('overrideTemplate', 0), __('Tick if you would like to override the template.'), 'o');
     // Add a text template
     $formFields['template'][] = FormManager::AddMultiText('ta_text', NULL, $this->GetRawNode('template'), __('Enter the template. Please note that the background colour has automatically coloured to your layout background colour.'), 't', 10, NULL, 'template-override-controls');
     // Field for the style sheet (optional)
     $formFields['template'][] = FormManager::AddMultiText('ta_css', NULL, $this->GetRawNode('styleSheet'), __('Optional Stylesheet'), 's', 10, NULL, 'template-override-controls');
     // Add some field dependencies
     // When the override template check box is ticked, we want to expose the advanced controls and we want to hide the template selector
     $this->response->AddFieldAction('overrideTemplate', 'init', false, array('.template-override-controls' => array('display' => 'none'), '.template-selector-control' => array('display' => 'block')), 'is:checked');
     $this->response->AddFieldAction('overrideTemplate', 'change', false, array('.template-override-controls' => array('display' => 'none'), '.template-selector-control' => array('display' => 'block')), 'is:checked');
     $this->response->AddFieldAction('overrideTemplate', 'init', true, array('.template-override-controls' => array('display' => 'block'), '.template-selector-control' => array('display' => 'none')), 'is:checked');
     $this->response->AddFieldAction('overrideTemplate', 'change', true, array('.template-override-controls' => array('display' => 'block'), '.template-selector-control' => array('display' => 'none')), 'is:checked');
     // Present an error message if the module has not been configured. Don't prevent further configuration.
     if (!extension_loaded('curl') || $this->GetSetting('apiKey') == '' || $this->GetSetting('apiSecret') == '') {
         $formFields['general'][] = FormManager::AddMessage(__('The Twitter Widget has not been configured yet, please ask your CMS Administrator to look at it for you.'), 'alert alert-danger');
     }
     // Modules should be rendered using the theme engine.
     Theme::Set('form_fields_general', $formFields['general']);
     Theme::Set('form_fields_template', $formFields['template']);
     Theme::Set('form_fields_effect', $formFields['effect']);
     Theme::Set('form_fields_advanced', $formFields['advanced']);
     // Set the field dependencies
     $this->setFieldDepencencies();
     $this->response->html = Theme::RenderReturn('form_render');
     $this->response->dialogTitle = __($this->displayType);
     $this->response->callBack = 'text_callback';
     // The response object outputs the required JSON object to the browser
     // which is then processed by the CMS JavaScript library (xibo-cms.js).
     // Append the templates to the response
     $this->response->extra = $this->settings['templates'];
     $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $this->layoutid . '&regionid=' . $this->regionid . '&q=RegionOptions")');
     $this->response->AddButton(__('Apply'), 'XiboDialogApply("#ModuleForm")');
     $this->response->AddButton(__('Save'), '$("#ModuleForm").submit()');
     // The response must be returned.
     return $this->response;
 }
Ejemplo n.º 18
0
 /**
  * Resolution Delete Form
  */
 function DeleteForm()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $resolutionid = Kit::GetParam('resolutionid', _GET, _INT);
     // Set some information about the form
     Theme::Set('form_id', 'DeleteForm');
     Theme::Set('form_action', 'index.php?p=resolution&q=Delete');
     Theme::Set('form_meta', '<input type="hidden" name="resolutionid" value="' . $resolutionid . '" />');
     Theme::Set('form_fields', array(FormManager::AddMessage(__('Are you sure you want to delete?'))));
     $response->SetFormRequestResponse(Theme::RenderReturn('form_render'), __('Delete Resolution'), '250px', '150px');
     $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('Campaign', 'Delete') . '")');
     $response->AddButton(__('No'), 'XiboDialogClose()');
     $response->AddButton(__('Yes'), '$("#DeleteForm").submit()');
     $response->Respond();
 }
Ejemplo n.º 19
0
 /**
  * Delete Help Link Form
  */
 public function DeleteForm()
 {
     $db =& $this->db;
     $response = new ResponseManager();
     $helpId = Kit::GetParam('HelpID', _REQUEST, _INT);
     // Set some information about the form
     Theme::Set('form_id', 'HelpDeleteForm');
     Theme::Set('form_action', 'index.php?p=help&q=Delete');
     Theme::Set('form_meta', '<input type="hidden" name="HelpID" value="' . $helpId . '" />');
     $form = Theme::RenderReturn('help_form_delete');
     $response->SetFormRequestResponse($form, __('Delete Help Link'), '350px', '175px');
     $response->AddButton(__('No'), 'XiboDialogClose()');
     $response->AddButton(__('Yes'), '$("#HelpDeleteForm").submit()');
     $response->Respond();
 }
Ejemplo n.º 20
0
 /**
  * Shows information about Xibo
  * @return 
  */
 function About()
 {
     $response = new ResponseManager();
     Theme::Set('version', VERSION);
     // Render the Theme and output
     $output = Theme::RenderReturn('about_text');
     $response->SetFormRequestResponse($output, __('About'), '500', '500');
     $response->AddButton(__('Close'), 'XiboDialogClose()');
     $response->Respond();
 }
Ejemplo n.º 21
0
 /**
  * Shows the stats grid
  */
 public function StatsGrid()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $fromDt = Kit::GetParam('fromdt', _POST, _STRING);
     $toDt = Kit::GetParam('todt', _POST, _STRING);
     $displayId = Kit::GetParam('displayid', _POST, _INT);
     $mediaId = Kit::GetParam('mediaid', _POST, _INT);
     // What if the fromdt and todt are exactly the same?
     // in this case assume an entire day from midnight on the fromdt to midnight on the todt (i.e. add a day to the todt)
     if ($fromDt == $toDt) {
         $toDt = date("Y-m-d", strtotime($toDt) + 86399);
     }
     Theme::Set('form_action', '');
     Theme::Set('form_meta', '<input type="hidden" name="p" value="stats"/><input type="hidden" name="q" value="OutputCSV"/><input type="hidden" name="displayid" value="' . $displayId . '" /><input type="hidden" name="fromdt" value="' . $fromDt . '" /><input type="hidden" name="todt" value="' . $toDt . '" />');
     // Get an array of display id this user has access to.
     $displays = $this->user->DisplayList();
     $display_ids = array();
     foreach ($displays as $display) {
         $display_ids[] = $display['displayid'];
     }
     if (count($display_ids) <= 0) {
         trigger_error(__('No displays with View permissions'), E_USER_ERROR);
     }
     // 3 grids showing different stats.
     // Layouts Ran
     $SQL = 'SELECT display.Display, layout.Layout, COUNT(StatID) AS NumberPlays, SUM(TIME_TO_SEC(TIMEDIFF(end, start))) AS Duration, MIN(start) AS MinStart, MAX(end) AS MaxEnd ';
     $SQL .= '  FROM stat ';
     $SQL .= '  INNER JOIN layout ON layout.LayoutID = stat.LayoutID ';
     $SQL .= '  INNER JOIN display ON stat.DisplayID = display.DisplayID ';
     $SQL .= " WHERE stat.type = 'layout' ";
     $SQL .= sprintf("  AND stat.end > '%s' ", $fromDt);
     $SQL .= sprintf("  AND stat.start <= '%s' ", $toDt);
     $SQL .= ' AND stat.displayID IN (' . implode(',', $display_ids) . ') ';
     if ($displayId != 0) {
         $SQL .= sprintf("  AND stat.displayID = %d ", $displayId);
     }
     $SQL .= 'GROUP BY display.Display, layout.Layout ';
     $SQL .= 'ORDER BY display.Display, layout.Layout';
     if (!($results = $this->db->query($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Unable to get Layouts Shown'), E_USER_ERROR);
     }
     $rows = array();
     while ($row = $db->get_assoc_row($results)) {
         $row['Display'] = Kit::ValidateParam($row['Display'], _STRING);
         $row['Layout'] = Kit::ValidateParam($row['Layout'], _STRING);
         $row['NumberPlays'] = Kit::ValidateParam($row['NumberPlays'], _INT);
         $row['DurationSec'] = Kit::ValidateParam($row['Duration'], _INT);
         $row['Duration'] = sec2hms(Kit::ValidateParam($row['Duration'], _INT));
         $row['MinStart'] = Kit::ValidateParam($row['MinStart'], _STRING);
         $row['MaxEnd'] = Kit::ValidateParam($row['MaxEnd'], _STRING);
         $rows[] = $row;
     }
     Theme::Set('table_layouts_shown', $rows);
     // Media Ran
     $SQL = 'SELECT display.Display, media.Name, COUNT(StatID) AS NumberPlays, SUM(TIME_TO_SEC(TIMEDIFF(end, start))) AS Duration, MIN(start) AS MinStart, MAX(end) AS MaxEnd ';
     $SQL .= '  FROM stat ';
     $SQL .= '  INNER JOIN display ON stat.DisplayID = display.DisplayID ';
     $SQL .= '  INNER JOIN  media ON media.MediaID = stat.MediaID ';
     $SQL .= " WHERE stat.type = 'media' ";
     $SQL .= sprintf("  AND stat.end > '%s' ", $fromDt);
     $SQL .= sprintf("  AND stat.start <= '%s' ", $toDt);
     $SQL .= ' AND stat.displayID IN (' . implode(',', $display_ids) . ') ';
     if ($mediaId != 0) {
         $SQL .= sprintf("  AND media.MediaID = %d ", $mediaId);
     }
     if ($displayId != 0) {
         $SQL .= sprintf("  AND stat.displayID = %d ", $displayId);
     }
     $SQL .= 'GROUP BY display.Display, media.Name ';
     $SQL .= 'ORDER BY display.Display, media.Name';
     if (!($results = $this->db->query($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Unable to get Library Media Ran'), E_USER_ERROR);
     }
     $rows = array();
     while ($row = $db->get_assoc_row($results)) {
         $row['Display'] = Kit::ValidateParam($row['Display'], _STRING);
         $row['Media'] = Kit::ValidateParam($row['Name'], _STRING);
         $row['NumberPlays'] = Kit::ValidateParam($row['NumberPlays'], _INT);
         $row['DurationSec'] = Kit::ValidateParam($row['Duration'], _INT);
         $row['Duration'] = sec2hms(Kit::ValidateParam($row['Duration'], _INT));
         $row['MinStart'] = Kit::ValidateParam($row['MinStart'], _STRING);
         $row['MaxEnd'] = Kit::ValidateParam($row['MaxEnd'], _STRING);
         $rows[] = $row;
     }
     Theme::Set('table_media_shown', $rows);
     // Media on Layouts Ran
     $SQL = "SELECT display.Display, layout.Layout, IFNULL(media.Name, 'Text/Rss/Webpage') AS Name, COUNT(StatID) AS NumberPlays, SUM(TIME_TO_SEC(TIMEDIFF(end, start))) AS Duration, MIN(start) AS MinStart, MAX(end) AS MaxEnd ";
     $SQL .= '  FROM stat ';
     $SQL .= '  INNER JOIN display ON stat.DisplayID = display.DisplayID ';
     $SQL .= '  INNER JOIN layout ON layout.LayoutID = stat.LayoutID ';
     $SQL .= '  LEFT OUTER JOIN media ON media.MediaID = stat.MediaID ';
     $SQL .= " WHERE stat.type = 'media' ";
     $SQL .= sprintf("  AND stat.end > '%s' ", $fromDt);
     $SQL .= sprintf("  AND stat.start <= '%s' ", $toDt);
     $SQL .= ' AND stat.displayID IN (' . implode(',', $display_ids) . ') ';
     if ($mediaId != 0) {
         $SQL .= sprintf("  AND media.MediaID = %d ", $mediaId);
     }
     if ($displayId != 0) {
         $SQL .= sprintf("  AND stat.displayID = %d ", $displayId);
     }
     $SQL .= "GROUP BY display.Display, layout.Layout, IFNULL(media.Name, 'Text/Rss/Webpage') ";
     $SQL .= "ORDER BY display.Display, layout.Layout, IFNULL(media.Name, 'Text/Rss/Webpage')";
     if (!($results = $this->db->query($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Unable to get Library Media Ran'), E_USER_ERROR);
     }
     $rows = array();
     while ($row = $db->get_assoc_row($results)) {
         $row['Display'] = Kit::ValidateParam($row['Display'], _STRING);
         $row['Layout'] = Kit::ValidateParam($row['Layout'], _STRING);
         $row['Media'] = Kit::ValidateParam($row['Name'], _STRING);
         $row['NumberPlays'] = Kit::ValidateParam($row['NumberPlays'], _INT);
         $row['DurationSec'] = Kit::ValidateParam($row['Duration'], _INT);
         $row['Duration'] = sec2hms(Kit::ValidateParam($row['Duration'], _INT));
         $row['MinStart'] = Kit::ValidateParam($row['MinStart'], _STRING);
         $row['MaxEnd'] = Kit::ValidateParam($row['MaxEnd'], _STRING);
         $rows[] = $row;
     }
     Theme::Set('table_media_on_layouts_shown', $rows);
     $output = Theme::RenderReturn('stats_page_grid');
     $response->SetGridResponse($output);
     $response->Respond();
 }
Ejemplo n.º 22
0
 /**
  * Checks the Environment and Determines if it is suitable
  * @return string
  */
 public function CheckEnvironment()
 {
     $cols = array(array('name' => 'item', 'title' => __('Item')), array('name' => 'status', 'title' => __('Status'), 'icons' => true), array('name' => 'advice', 'title' => __('Advice')));
     Theme::Set('table_cols', $cols);
     $rows = array();
     // Check for PHP version
     $advice = sprintf(__("PHP version %s or later required."), Config::$VERSION_REQUIRED) . ' Detected ' . phpversion();
     if ($this->CheckPHP()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('PHP Version'), 'status' => $status, 'advice' => $advice);
     // Check for file system permissions
     $advice = __("Write access required for settings.php and install.php");
     if ($this->CheckFsPermissions()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('File System Permissions'), 'status' => $status, 'advice' => $advice);
     // Check for MySQL
     $advice = __('MySQL support must be enabled in PHP.');
     if ($this->CheckMySQL()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('MySQL database (PHP MySql)'), 'status' => $status, 'advice' => $advice);
     // Check for PDO
     $advice = __('PDO support with MySQL drivers must be enabled in PHP.');
     if ($this->CheckPDO()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('MySQL database (PDO MySql)'), 'status' => $status, 'advice' => $advice);
     // Check for JSON
     $advice = __('PHP JSON extension required to function.');
     if ($this->CheckJson()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('JSON Extension'), 'status' => $status, 'advice' => $advice);
     // Check for SOAP
     $advice = __('PHP SOAP extension required to function.');
     if ($this->CheckSoap()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('SOAP Extension'), 'status' => $status, 'advice' => $advice);
     // Check for GD (graphics)
     $advice = __('PHP GD extension to function.');
     if ($this->CheckGd()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('GD Extension'), 'status' => $status, 'advice' => $advice);
     // Check for PHP Session
     $advice = __('PHP session support to function.');
     if ($this->CheckSession()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('Session'), 'status' => $status, 'advice' => $advice);
     // Check for PHP FileInfo
     $advice = __('Requires PHP FileInfo support to function. If you are on Windows you need to enable the php_fileinfo.dll in your php.ini file.');
     if ($this->CheckFileInfo()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('FileInfo'), 'status' => $status, 'advice' => $advice);
     // Check for PHP PCRE
     $advice = __('PHP PCRE support to function.');
     if ($this->CheckPCRE()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('PCRE'), 'status' => $status, 'advice' => $advice);
     // Check for PHP Gettext
     $advice = __('PHP Gettext support to function.');
     if ($this->CheckGettext()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('Gettext'), 'status' => $status, 'advice' => $advice);
     // Check for Calendar
     $advice = __('PHP Calendar extension to function.');
     if ($this->CheckCal()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('Calendar Extension'), 'status' => $status, 'advice' => $advice);
     // Check for DOM
     $advice = __('PHP DOM core functionality enabled.');
     if ($this->CheckDom()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('DOM Extension'), 'status' => $status, 'advice' => $advice);
     // Check for DOM XML
     $advice = __('PHP DOM XML extension to function.');
     if ($this->CheckDomXml()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('DOM XML Extension'), 'status' => $status, 'advice' => $advice);
     // Check for Mcrypt
     $advice = __('PHP Mcrypt extension to function.');
     if ($this->CheckMcrypt()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
     }
     $rows[] = array('item' => __('Mcrypt Extension'), 'status' => $status, 'advice' => $advice);
     // Check to see if we are allowed to open remote URLs (home call will not work otherwise)
     $advice = __('You must have allow_url_fopen = On in your PHP.ini file for RSS Feeds / Anonymous statistics gathering to function.');
     if (ini_get('allow_url_fopen')) {
         $status = 1;
     } else {
         // Not a fault as this will not block installation / upgrade. Informational.
         $this->envWarning = true;
         $status = 2;
     }
     $rows[] = array('item' => __('Allow PHP to open external URLs'), 'status' => $status, 'advice' => $advice);
     // Check to see if timezone_identifiers_list exists
     $advice = __('This enables us to get a list of time zones supported by the hosting server.');
     if (function_exists('timezone_identifiers_list')) {
         $status = 1;
     } else {
         $status = 2;
         $this->envWarning = true;
     }
     $rows[] = array('item' => __('DateTimeZone'), 'status' => $status, 'advice' => $advice);
     // Check to see if Zip support exists
     $advice = __('This enables import / export of layouts.');
     if ($this->CheckZip()) {
         $status = 1;
     } else {
         $status = 0;
         $this->envFault = true;
     }
     $rows[] = array('item' => __('ZIP'), 'status' => $status, 'advice' => $advice);
     // Check to see if large file uploads enabled
     $advice = __('Support for uploading large files is recommended.');
     if ($this->CheckPHPUploads()) {
         $status = 1;
     } else {
         $this->envWarning = true;
         $status = 2;
         $advice = __('You probably want to allow larger files to be uploaded than is currently available with your PHP configuration.') . '<br />';
         $advice .= __('We suggest setting your PHP post_max_size and upload_max_size to at least 128M, and also increasing your max_execution_time to at least 120 seconds.');
     }
     $rows[] = array('item' => __('Large File Uploads'), 'status' => $status, 'advice' => $advice);
     // Check to see if Internationalization support is available
     $advice = __('International Support for formatting Dates, Numbers, etc.');
     if ($this->CheckIntlDateFormat()) {
         $status = 1;
     } else {
         $this->envWarning = true;
         $status = 2;
         $advice .= __('Translations will still function without this PHP module, however dates, times and numbers will not be shown in your locale.');
     }
     $rows[] = array('item' => __('Internationalization'), 'status' => $status, 'advice' => $advice);
     // Check to see if cURL is installed
     $advice = __('cURL is used to fetch data from the Internet or Local Network');
     if ($this->checkCurlInstalled()) {
         $status = 1;
     } else {
         $this->envFault = true;
         $status = 0;
         $advice .= __(' and is required.');
     }
     $rows[] = array('item' => __('cURL'), 'status' => $status, 'advice' => $advice);
     $this->envTested = true;
     Theme::Set('table_rows', $rows);
     return Theme::RenderReturn('table_render');
 }
Ejemplo n.º 23
0
 function Grid()
 {
     $db =& $this->db;
     $response = new ResponseManager();
     $type = Kit::GetParam('filter_type', _POST, _WORD);
     $fromDt = Kit::GetParam('filter_fromdt', _POST, _STRING);
     setSession('sessions', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
     setSession('sessions', 'filter_type', $type);
     setSession('sessions', 'filter_fromdt', $fromDt);
     $SQL = "SELECT session.userID, user.UserName,  IsExpired, LastPage,  session.LastAccessed,  RemoteAddr,  UserAgent ";
     $SQL .= "FROM `session` LEFT OUTER JOIN user ON user.userID = session.userID ";
     $SQL .= "WHERE 1 = 1 ";
     if ($fromDt != '') {
         // From Date is the Calendar Formatted DateTime in ISO format
         $SQL .= sprintf(" AND session.LastAccessed < '%s' ", DateManager::getMidnightSystemDate(DateManager::getTimestampFromString($fromDt)));
     }
     if ($type == "active") {
         $SQL .= " AND IsExpired = 0 ";
     }
     if ($type == "expired") {
         $SQL .= " AND IsExpired = 1 ";
     }
     if ($type == "guest") {
         $SQL .= " AND session.userID IS NULL ";
     }
     // Load results into an array
     $log = $db->GetArray($SQL);
     Debug::LogEntry('audit', $SQL);
     if (!is_array($log)) {
         trigger_error($db->error());
         trigger_error(__('Error getting the log'), E_USER_ERROR);
     }
     $cols = array(array('name' => 'lastaccessed', 'title' => __('Last Accessed')), array('name' => 'isexpired', 'title' => __('Active'), 'icons' => true), array('name' => 'username', 'title' => __('User Name')), array('name' => 'lastpage', 'title' => __('Last Page')), array('name' => 'ip', 'title' => __('IP Address')), array('name' => 'browser', 'title' => __('Browser')));
     Theme::Set('table_cols', $cols);
     $rows = array();
     foreach ($log as $row) {
         $row['userid'] = Kit::ValidateParam($row['userID'], _INT);
         $row['username'] = Kit::ValidateParam($row['UserName'], _STRING);
         $row['isexpired'] = Kit::ValidateParam($row['IsExpired'], _INT) == 1 ? 0 : 1;
         $row['lastpage'] = Kit::ValidateParam($row['LastPage'], _STRING);
         $row['lastaccessed'] = DateManager::getLocalDate(strtotime(Kit::ValidateParam($row['LastAccessed'], _STRING)));
         $row['ip'] = Kit::ValidateParam($row['RemoteAddr'], _STRING);
         $row['browser'] = Kit::ValidateParam($row['UserAgent'], _STRING);
         // Edit
         $row['buttons'][] = array('id' => 'sessions_button_logout', 'url' => 'index.php?p=sessions&q=ConfirmLogout&userid=' . $row['userid'], 'text' => __('Logout'));
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     $response->SetGridResponse(Theme::RenderReturn('table_render'));
     $response->Respond();
 }
Ejemplo n.º 24
0
 /**
  * Return the Edit Form as HTML
  * @return 
  */
 public function EditForm()
 {
     $db =& $this->db;
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     $mediaid = $this->mediaid;
     // Permissions
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this assignment.');
         $this->response->keepOpen = true;
         return $this->response;
     }
     Theme::Set('form_id', 'ModuleForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=EditMedia');
     Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" id="iRegionId" name="regionid" value="' . $regionid . '"><input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" /><input type="hidden" id="mediaid" name="mediaid" value="' . $mediaid . '">');
     // What is the source for this ticker?
     $sourceId = $this->GetOption('sourceId');
     $dataSetId = $this->GetOption('datasetid');
     Theme::Set('sourceId', $sourceId);
     // Data Set Source
     if ($sourceId == 2) {
         // Extra Fields for the DataSet
         Theme::Set('columns', $db->GetArray(sprintf("SELECT DataSetColumnID, Heading FROM datasetcolumn WHERE DataSetID = %d ", $dataSetId)));
         Theme::Set('upperLimit', $this->GetOption('upperLimit'));
         Theme::Set('lowerLimit', $this->GetOption('lowerLimit'));
         Theme::Set('filter', $this->GetOption('filter'));
         Theme::Set('ordering', $this->GetOption('ordering'));
     } else {
         // Extra Fields for the Ticker
         $subs = array(array('Substitute' => 'Title'), array('Substitute' => 'Description'), array('Substitute' => 'Content'), array('Substitute' => 'Copyright'), array('Substitute' => 'Link'), array('Substitute' => 'PermaLink'), array('Substitute' => 'Tag|Namespace'));
         Theme::Set('substitutions', $subs);
     }
     // Direction Options
     $directionOptions = array(array('directionid' => 'none', 'direction' => __('None')), array('directionid' => 'left', 'direction' => __('Left')), array('directionid' => 'right', 'direction' => __('Right')), array('directionid' => 'up', 'direction' => __('Up')), array('directionid' => 'down', 'direction' => __('Down')), array('directionid' => 'single', 'direction' => __('Single')));
     Theme::Set('direction_field_list', $directionOptions);
     // "Take from" Options
     $takeItemsFrom = array(array('takeitemsfromid' => 'start', 'takeitemsfrom' => __('Start of the Feed')), array('takeitemsfromid' => 'end', 'takeitemsfrom' => __('End of the Feed')));
     Theme::Set('takeitemsfrom_field_list', $takeItemsFrom);
     // Set up the variables we already have
     Theme::Set('direction', $this->GetOption('direction'));
     Theme::Set('copyright', $this->GetOption('copyright'));
     Theme::Set('scrollSpeed', $this->GetOption('scrollSpeed'));
     Theme::Set('updateInterval', $this->GetOption('updateInterval'));
     Theme::Set('uri', urldecode($this->GetOption('uri')));
     Theme::Set('numItems', $this->GetOption('numItems'));
     Theme::Set('takeItemsFrom', $this->GetOption('takeItemsFrom'));
     Theme::Set('itemsPerPage', $this->GetOption('itemsPerPage'));
     Theme::Set('datasetid', $this->GetOption('datasetid'));
     // Checkboxes
     Theme::Set('fitTextChecked', $this->GetOption('fitText', 0) == 0 ? '' : ' checked');
     Theme::Set('itemsSideBySideChecked', $this->GetOption('itemsSideBySide', 0) == 0 ? '' : ' checked');
     Theme::Set('durationIsPerItemChecked', $this->GetOption('durationIsPerItem') == 1 ? ' checked' : '');
     // Get the text out of RAW
     $rawXml = new DOMDocument();
     $rawXml->loadXML($this->GetRaw());
     Debug::LogEntry('audit', 'Raw XML returned: ' . $this->GetRaw());
     // Get the Text Node out of this
     $textNodes = $rawXml->getElementsByTagName('template');
     $textNode = $textNodes->item(0);
     Theme::Set('text', $textNode->nodeValue);
     // Get the CSS node
     $cssNodes = $rawXml->getElementsByTagName('css');
     if ($cssNodes->length > 0) {
         $cssNode = $cssNodes->item(0);
         Theme::Set('css', $cssNode->nodeValue);
     } else {
         Theme::Set('css', '');
     }
     // Duration
     Theme::Set('duration', $this->duration);
     Theme::Set('is_duration_enabled', $this->auth->modifyPermissions ? '' : ' readonly');
     // Output the form
     if ($sourceId == 2) {
         $this->response->html = Theme::RenderReturn('media_form_ticker_dataset_edit');
     } else {
         $this->response->html = Theme::RenderReturn('media_form_ticker_edit');
     }
     // Generate the Response
     $this->response->callBack = 'text_callback';
     $this->response->dialogTitle = __('Edit Ticker');
     $this->response->dialogClass = 'modal-big';
     if ($this->showRegionOptions) {
         $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $layoutid . '&regionid=' . $regionid . '&q=RegionOptions")');
     } else {
         $this->response->AddButton(__('Cancel'), 'XiboDialogClose()');
     }
     $this->response->AddButton(__('Save'), '$("#ModuleForm").submit()');
     return $this->response;
 }
Ejemplo n.º 25
0
 /**
  * Form to Edit a transition
  */
 public function TransitionEditForm()
 {
     $this->response = new ResponseManager();
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this media.');
         $this->response->keepOpen = false;
         return $this->response;
     }
     // Are we dealing with an IN or an OUT
     $type = Kit::GetParam('type', _REQUEST, _WORD);
     switch ($type) {
         case 'in':
             $transition = $this->GetOption('transIn');
             $duration = $this->GetOption('transInDuration', 0);
             $direction = $this->GetOption('transInDirection');
             break;
         case 'out':
             $transition = $this->GetOption('transOut');
             $duration = $this->GetOption('transOutDuration', 0);
             $direction = $this->GetOption('transOutDirection');
             break;
         default:
             trigger_error(_('Unknown transition type'), E_USER_ERROR);
     }
     // Add none to the list
     $transitions = $this->user->TransitionAuth($type);
     $transitions[] = array('code' => '', 'transition' => 'None', 'class' => '');
     // Compass points for direction
     $compassPoints = array(array('id' => 'N', 'name' => __('North')), array('id' => 'NE', 'name' => __('North East')), array('id' => 'E', 'name' => __('East')), array('id' => 'SE', 'name' => __('South East')), array('id' => 'S', 'name' => __('South')), array('id' => 'SW', 'name' => __('South West')), array('id' => 'W', 'name' => __('West')), array('id' => 'NW', 'name' => __('North West')));
     Theme::Set('form_id', 'TransitionForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=TransitionEdit');
     Theme::Set('form_meta', '
         <input type="hidden" name="type" value="' . $type . '">
         <input type="hidden" name="layoutid" value="' . $this->layoutid . '">
         <input type="hidden" name="mediaid" value="' . $this->mediaid . '">
         <input type="hidden" name="lkid" value="' . $this->lkid . '">
         <input type="hidden" id="iRegionId" name="regionid" value="' . $this->regionid . '">
         <input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" />
         ');
     $formFields[] = FormManager::AddCombo('transitionType', __('Transition'), $transition, $transitions, 'code', 'transition', __('What transition should be applied when this region is finished?'), 't');
     $formFields[] = FormManager::AddNumber('transitionDuration', __('Duration'), $duration, __('The duration for this transition, in milliseconds.'), 'l', '', 'transition-group');
     $formFields[] = FormManager::AddCombo('transitionDirection', __('Direction'), $direction, $compassPoints, 'id', 'name', __('The direction for this transition. Only appropriate for transitions that move, such as Fly.'), 'd', 'transition-group transition-direction');
     // Add some dependencies
     $this->response->AddFieldAction('transitionType', 'init', '', array('.transition-group' => array('display' => 'none')));
     $this->response->AddFieldAction('transitionType', 'init', '', array('.transition-group' => array('display' => 'block')), 'not');
     $this->response->AddFieldAction('transitionType', 'change', '', array('.transition-group' => array('display' => 'none')));
     $this->response->AddFieldAction('transitionType', 'change', '', array('.transition-group' => array('display' => 'block')), 'not');
     // Decide where the cancel button will take us
     if ($this->showRegionOptions) {
         $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $this->layoutid . '&regionid=' . $this->regionid . '&q=RegionOptions")');
     } else {
         $this->response->AddButton(__('Cancel'), 'XiboDialogClose()');
     }
     // Always include the save button
     $this->response->AddButton(__('Save'), '$("#TransitionForm").submit()');
     // Output the form and dialog
     Theme::Set('form_fields', $formFields);
     $this->response->html = Theme::RenderReturn('form_render');
     $this->response->dialogTitle = sprintf(__('Edit %s Transition for %s'), $type, $this->displayType);
     $this->response->dialogSize = true;
     $this->response->dialogWidth = '450px';
     $this->response->dialogHeight = '280px';
     return $this->response;
 }
Ejemplo n.º 26
0
 public function MediaManagerGrid()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $filterLayout = Kit::GetParam('filter_layout_name', _POST, _STRING);
     $filterRegion = Kit::GetParam('filter_region_name', _POST, _STRING);
     $filterMediaName = Kit::GetParam('filter_media_name', _POST, _STRING);
     $filterMediaType = Kit::GetParam('filter_type', _POST, _INT);
     setSession('mediamanager', 'filter_layout_name', $filterLayout);
     setSession('mediamanager', 'filter_region_name', $filterRegion);
     setSession('mediamanager', 'filter_media_name', $filterMediaName);
     setSession('mediamanager', 'filter_type', $filterMediaType);
     setSession('mediamanager', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
     // Lookup the module name
     if ($filterMediaType != 0) {
         $module = $this->user->ModuleList(NULL, array('id' => $filterMediaType));
         if (count($module) > 0) {
             $filterMediaType = $module[0]['Name'];
             Debug::LogEntry('audit', 'Matched module type ' . $filterMediaType, get_class(), __FUNCTION__);
         }
     }
     $cols = array(array('name' => 'layout', 'title' => __('Layout'), 'colClass' => 'group-word'), array('name' => 'region', 'title' => __('Region')), array('name' => 'media', 'title' => __('Media')), array('name' => 'mediatype', 'title' => __('Type')), array('name' => 'seq', 'title' => __('Sequence')));
     Theme::Set('table_cols', $cols);
     // We would like a list of all layouts, media and media assignments that this user
     // has access to.
     $layouts = $user->LayoutList(NULL, array('layout' => $filterLayout));
     $rows = array();
     foreach ($layouts as $layout) {
         // We have edit permissions?
         if (!$layout['edit']) {
             continue;
         }
         // Every layout this user has access to.. get the regions
         $layoutXml = new DOMDocument();
         $layoutXml->loadXML($layout['xml']);
         // Get ever region
         $regionNodeList = $layoutXml->getElementsByTagName('region');
         $regionNodeSequence = 0;
         //get the regions
         foreach ($regionNodeList as $region) {
             $regionId = $region->getAttribute('id');
             $ownerId = $region->getAttribute('userId') == '' ? $layout['ownerid'] : $region->getAttribute('userId');
             $regionAuth = $user->RegionAssignmentAuth($ownerId, $layout['layoutid'], $regionId, true);
             // Do we have permission to edit?
             if (!$regionAuth->edit) {
                 continue;
             }
             $regionNodeSequence++;
             $regionName = $region->getAttribute('name') == '' ? 'Region ' . $regionNodeSequence : $region->getAttribute('name');
             if ($filterRegion != '' && !stristr($regionName, $filterRegion)) {
                 continue;
             }
             // Media
             $xpath = new DOMXPath($layoutXml);
             $mediaNodes = $xpath->query("//region[@id='{$regionId}']/media");
             $mediaNodeSequence = 0;
             foreach ($mediaNodes as $mediaNode) {
                 $mediaId = $mediaNode->getAttribute('id');
                 $lkId = $mediaNode->getAttribute('lkid');
                 $mediaOwnerId = $mediaNode->getAttribute('userId') == '' ? $layout['ownerid'] : $mediaNode->getAttribute('userId');
                 $mediaType = $mediaNode->getAttribute('type');
                 // Permissions
                 $auth = $user->MediaAssignmentAuth($mediaOwnerId, $layout['layoutid'], $regionId, $mediaId, true);
                 if (!$auth->edit) {
                     continue;
                 }
                 // Create the media object without any region and layout information
                 require_once 'modules/' . $mediaType . '.module.php';
                 $tmpModule = new $mediaType($db, $user, $mediaId, $layout['layoutid'], $regionId, $lkId);
                 $mediaName = $tmpModule->GetName();
                 if ($filterMediaName != '' && !stristr($mediaName, $filterMediaName)) {
                     continue;
                 }
                 if ($filterMediaType != '' && $mediaType != strtolower($filterMediaType)) {
                     continue;
                 }
                 $mediaNodeSequence++;
                 $layout['region'] = $regionName;
                 $layout['media'] = $mediaName;
                 $layout['mediatype'] = $mediaType;
                 $layout['seq'] = $mediaNodeSequence;
                 $layout['buttons'] = array();
                 // Edit
                 $layout['buttons'][] = array('id' => 'homepage_mediamanager_edit_button', 'url' => 'index.php?p=module&mod=' . $mediaType . '&q=Exec&method=EditForm&showRegionOptions=0&layoutid=' . $layout['layoutid'] . '&regionid=' . $regionId . '&mediaid=' . $mediaId . '&lkid=' . $lkId, 'text' => __('Edit'));
                 $rows[] = $layout;
             }
         }
     }
     Theme::Set('table_rows', $rows);
     $output = Theme::RenderReturn('table_render');
     $response->SetGridResponse($output);
     $response->Respond();
 }
Ejemplo n.º 27
0
 /**
  * Shows the form to delete a template
  */
 public function DeleteTemplateForm()
 {
     $response = new ResponseManager();
     $templateId = Kit::GetParam('layoutid', _GET, _INT);
     $auth = $this->user->TemplateAuth($templateId, true);
     if (!$auth->del) {
         trigger_error(__('You do not have permissions to delete this template'), E_USER_ERROR);
     }
     Theme::Set('form_id', 'DeleteForm');
     Theme::Set('form_action', 'index.php?p=template&q=DeleteTemplate');
     Theme::Set('form_meta', '<input type="hidden" name="templateId" value="' . $templateId . '">');
     Theme::Set('form_fields', array(FormManager::AddMessage(__('Are you sure you want to delete this template?'))));
     $form = Theme::RenderReturn('form_render');
     $response->SetFormRequestResponse($form, __('Delete Template'), '300px', '200px');
     $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('Template', 'Delete') . '")');
     $response->AddButton(__('No'), 'XiboDialogClose()');
     $response->AddButton(__('Yes'), '$("#DeleteForm").submit()');
     $response->Respond();
 }
Ejemplo n.º 28
0
 /**
  * Return the Edit Form as HTML
  * @return
  */
 public function EditForm()
 {
     $this->response = new ResponseManager();
     // Edit calls are the same as add calls, except you will to check the user has permissions to do the edit
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this assignment.');
         $this->response->keepOpen = false;
         return $this->response;
     }
     // All forms should set some meta data about the form.
     // Usually, you would want this meta data to remain the same.
     Theme::Set('form_id', 'ModuleForm');
     Theme::Set('form_action', 'index.php?p=module&mod=' . $this->type . '&q=Exec&method=EditMedia');
     Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $this->layoutid . '"><input type="hidden" id="iRegionId" name="regionid" value="' . $this->regionid . '"><input type="hidden" name="showRegionOptions" value="' . $this->showRegionOptions . '" /><input type="hidden" id="mediaid" name="mediaid" value="' . $this->mediaid . '">');
     // Augment settings with templates
     $this->loadTemplates();
     // Two tabs
     $tabs = array();
     $tabs[] = FormManager::AddTab('general', __('General'));
     $tabs[] = FormManager::AddTab('advanced', __('Appearance'));
     $tabs[] = FormManager::AddTab('forecast', __('Forecast'));
     Theme::Set('form_tabs', $tabs);
     $formFields['general'][] = FormManager::AddText('name', __('Name'), $this->GetOption('name'), __('An optional name for this media'), 'n');
     $formFields['general'][] = FormManager::AddNumber('duration', __('Duration'), $this->duration, __('The duration in seconds this item should be displayed.'), 'd', 'required');
     $formFields['general'][] = FormManager::AddCheckbox('useDisplayLocation', __('Use the Display Location'), $this->GetOption('useDisplayLocation'), __('Use the location configured on the display'), 'd');
     // Any values for the form fields should be added to the theme here.
     $formFields['general'][] = FormManager::AddNumber('latitude', __('Latitude'), $this->GetOption('latitude'), __('The Latitude for this weather module'), 'l', '', 'locationControls');
     $formFields['general'][] = FormManager::AddNumber('longitude', __('Longitude'), $this->GetOption('longitude'), __('The Longitude for this weather module'), 'g', '', 'locationControls');
     $formFields['advanced'][] = FormManager::AddCombo('templateId', __('Weather Template'), $this->GetOption('templateId'), $this->settings['templates'], 'id', 'value', __('Select the template you would like to apply. This can be overridden using the check box below.'), 't', 'template-selector-control');
     $formFields['advanced'][] = FormManager::AddCombo('icons', __('Icons'), $this->GetOption('icons'), $this->iconsAvailable(), 'id', 'value', __('Select the icon set you would like to use.'), 't', 'icon-controls');
     $formFields['advanced'][] = FormManager::AddNumber('size', __('Size'), $this->GetOption('size', 1), __('Set the size. Start at 1 and work up until the widget fits your region appropriately.'), 's', 'number', 'template-selector-control');
     $formFields['advanced'][] = FormManager::AddCombo('units', __('Units'), $this->GetOption('units'), $this->unitsAvailable(), 'id', 'value', __('Select the units you would like to use.'), 'u');
     $formFields['advanced'][] = FormManager::AddCombo('lang', __('Language'), $this->GetOption('lang', TranslationEngine::GetLocale(2)), $this->supportedLanguages(), 'id', 'value', __('Select the language you would like to use.'), 'l');
     $formFields['advanced'][] = FormManager::AddNumber('updateInterval', __('Update Interval (mins)'), $this->GetOption('updateInterval', 60), __('Please enter the update interval in minutes. This should be kept as high as possible. For example, if the data will only change once per hour this could be set to 60.'), 'n', 'required');
     $formFields['advanced'][] = FormManager::AddCheckbox('dayConditionsOnly', __('Only show Daytime weather conditions'), $this->GetOption('dayConditionsOnly', 1), __('Tick if you would like to only show the Daytime weather conditions.'), 'd');
     $formFields['general'][] = FormManager::AddText('color', __('Colour'), $this->GetOption('color', '000'), __('Please select a colour for the foreground text.'), 'c', 'required');
     $formFields['advanced'][] = FormManager::AddCheckbox('overrideTemplate', __('Override the template?'), $this->GetOption('overrideTemplate'), __('Tick if you would like to override the template.'), 'o');
     $formFields['advanced'][] = FormManager::AddMultiText('currentTemplate', __('Template for Current Forecast'), $this->GetRawNode('currentTemplate'), __('Enter the template for the current forecast. For a list of substitutions click "Request Forecast" below.'), 't', 10, 'required', 'template-override-controls');
     $formFields['advanced'][] = FormManager::AddMultiText('dailyTemplate', __('Template for Daily Forecast'), $this->GetRawNode('dailyTemplate'), __('Enter the template for the current forecast. Replaces [dailyForecast] in main template.'), 't', 10, NULL, 'template-override-controls');
     $formFields['advanced'][] = FormManager::AddMultiText('styleSheet', __('CSS Style Sheet'), $this->GetRawNode('styleSheet'), __('Enter a CSS style sheet to style the weather widget'), 'c', 10, 'required', 'template-override-controls');
     $formFields['forecast'][] = FormManager::AddMessage(__('Please press Request Forecast to show the current forecast and all available substitutions.'));
     // Encode up the template
     if (Config::GetSetting('SERVER_MODE') == 'Test' && $this->user->usertypeid == 1) {
         $formFields['forecast'][] = FormManager::AddMessage('<pre>' . htmlentities(json_encode(array('id' => 'ID', 'value' => 'TITLE', 'main' => $this->GetRawNode('currentTemplate'), 'daily' => $this->GetRawNode('dailyTemplate'), 'css' => $this->GetRawNode('styleSheet')))) . '</pre>');
     }
     // Configure the field dependencies
     $this->SetFieldDepencencies();
     // Append the Templates to the response
     $this->response->extra = $this->settings['templates'];
     // Modules should be rendered using the theme engine.
     Theme::Set('form_fields_general', $formFields['general']);
     Theme::Set('form_fields_advanced', $formFields['advanced']);
     Theme::Set('form_fields_forecast', $formFields['forecast']);
     $this->response->html = Theme::RenderReturn('form_render');
     $this->response->dialogTitle = __('Forecast IO');
     $this->response->callBack = 'forecastIoFormSetup';
     // The response object outputs the required JSON object to the browser
     // which is then processed by the CMS JavaScript library (xibo-cms.js).
     $this->response->AddButton(__('Request Forecast'), 'requestTab("forecast", "index.php?p=module&q=exec&mod=' . $this->type . '&method=requestTab&layoutid=' . $this->layoutid . '&regionid=' . $this->regionid . '&mediaid=' . $this->mediaid . '")');
     $this->response->AddButton(__('Cancel'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $this->layoutid . '&regionid=' . $this->regionid . '&q=RegionOptions")');
     $this->response->AddButton(__('Apply'), 'XiboDialogApply("#ModuleForm")');
     $this->response->AddButton(__('Save'), '$("#ModuleForm").submit()');
     // The response must be returned.
     return $this->response;
 }
Ejemplo n.º 29
0
 /**
  * Show the library
  * @return 
  */
 function LayoutAssignView()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     //Input vars
     $name = Kit::GetParam('filter_name', _POST, _STRING);
     $tags = Kit::GetParam('filter_tags', _POST, _STRING);
     // Get a list of media
     $layoutList = $user->LayoutList(NULL, array('layout' => $name, 'tags' => $tags));
     $cols = array(array('name' => 'layout', 'title' => __('Name')));
     Theme::Set('table_cols', $cols);
     $rows = array();
     // Add some extra information
     foreach ($layoutList as $row) {
         $row['list_id'] = 'LayoutID_' . $row['layoutid'];
         $row['assign_icons'][] = array('assign_icons_class' => 'layout_assign_list_select');
         $row['dataAttributes'] = array(array('name' => 'rowid', 'value' => $row['list_id']), array('name' => 'litext', 'value' => $row['layout']));
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     // Render the Theme
     $response->SetGridResponse(Theme::RenderReturn('table_render'));
     $response->callBack = 'LayoutAssignCallback';
     $response->pageSize = 5;
     $response->Respond();
 }
Ejemplo n.º 30
0
 /**
  * A grid of modules
  */
 public function Grid()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $SQL = '';
     $SQL .= 'SELECT ModuleID, ';
     $SQL .= '   Name, ';
     $SQL .= '   Enabled, ';
     $SQL .= '   Description, ';
     $SQL .= '   RegionSpecific, ';
     $SQL .= '   ValidExtensions, ';
     $SQL .= '   ImageUri, ';
     $SQL .= '   PreviewEnabled, ';
     $SQL .= '   assignable, ';
     $SQL .= '   settings ';
     $SQL .= '  FROM `module` ';
     $SQL .= ' ORDER BY Name ';
     if (!($modules = $db->GetArray($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Unable to get the list of modules'), E_USER_ERROR);
     }
     $cols = array(array('name' => 'name', 'title' => __('Name')), array('name' => 'description', 'title' => __('Description')), array('name' => 'isregionspecific', 'title' => __('Library Media'), 'icons' => true), array('name' => 'validextensions', 'title' => __('Valid Extensions')), array('name' => 'imageuri', 'title' => __('Image Uri')), array('name' => 'preview_enabled', 'title' => __('Preview Enabled'), 'icons' => true), array('name' => 'assignable', 'title' => __('Assignable'), 'icons' => true, 'helpText' => __('Can this module be assigned to a Layout?')), array('name' => 'enabled', 'title' => __('Enabled'), 'icons' => true));
     Theme::Set('table_cols', $cols);
     $rows = array();
     foreach ($modules as $module) {
         $row = array();
         $row['moduleid'] = Kit::ValidateParam($module['ModuleID'], _INT);
         $row['name'] = Kit::ValidateParam($module['Name'], _STRING);
         $row['description'] = Kit::ValidateParam($module['Description'], _STRING);
         $row['isregionspecific'] = Kit::ValidateParam($module['RegionSpecific'], _INT) == 0 ? 1 : 0;
         $row['validextensions'] = Kit::ValidateParam($module['ValidExtensions'], _STRING);
         $row['imageuri'] = Kit::ValidateParam($module['ImageUri'], _STRING);
         $row['enabled'] = Kit::ValidateParam($module['Enabled'], _INT);
         $row['preview_enabled'] = Kit::ValidateParam($module['PreviewEnabled'], _INT);
         $row['assignable'] = Kit::ValidateParam($module['assignable'], _INT);
         $row['settings'] = json_decode(Kit::ValidateParam($module['settings'], _HTMLSTRING), true);
         // Initialise array of buttons, because we might not have any
         $row['buttons'] = array();
         // If the module config is not locked, present some buttons
         if (Config::GetSetting('MODULE_CONFIG_LOCKED_CHECKB') != 'Checked') {
             // Edit button
             $row['buttons'][] = array('id' => 'module_button_edit', 'url' => 'index.php?p=module&q=EditForm&ModuleID=' . $row['moduleid'], 'text' => __('Edit'));
         }
         // Are there any buttons we need to provide as part of the module?
         if (isset($row['settings']['buttons'])) {
             foreach ($row['settings']['buttons'] as $button) {
                 $button['text'] = __($button['text']);
                 $row['buttons'][] = $button;
             }
         }
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     $output = Theme::RenderReturn('table_render');
     $response->SetGridResponse($output);
     $response->Respond();
 }