Esempio n. 1
0
 public function startMaintenance()
 {
     $this->setState(Ampoliros::STATE_MAINTENANCE);
     $this->setInterface(Ampoliros::INTERFACE_CONSOLE);
     $this->startRoot();
     import('com.solarix.ampoliros.maintenance.AmpolirosMaintenanceHandler');
     import('com.solarix.ampoliros.util.Hook');
     $hook = new Hook($GLOBALS['gEnv']['root']['db'], 'ampoliros', 'instance');
     switch ($hook->CallHooks('maintenance', $null, '')) {
         case Hook::RESULT_ABORT:
             AmpDie('Maintenance aborted');
             break;
     }
     $amp_mnt = new AmpolirosMaintenanceHandler();
     $GLOBALS['gEnv']['runtime']['maintenance']['result'] = $amp_mnt->DoMaintenance();
     $amp_mnt->SendReport($GLOBALS['gEnv']['runtime']['maintenance']['result']);
 }
Esempio n. 2
0
function main_default($eventData)
{
    global $gEnv, $gXml_def, $gLocale, $gPage_title;
    $main = new AmpolirosMaintenanceHandler();
    $main_time = $main->GetLastMaintenanceTime();
    $tasks = $main->GetTasksList();
    $tabs[0]['label'] = $gLocale->GetStr('general_status.tab');
    $tabs[1]['label'] = $gLocale->GetStr('general_report.tab');
    $tabs[2]['label'] = $gLocale->GetStr('general_tasks.tab');
    $country = new LocaleCountry($GLOBALS['gEnv']['root']['locale']['country']);
    $date_array = $country->GetDateArrayFromUnixTimestamp($main_time);
    $row = 0;
    $gXml_def = '<vertgroup>
      <children>
    
      <tab><name>general</name>
        <args>
          <tabs type="array">' . huixml_encode($tabs) . '</tabs>
          <tabactionfunction>general_tab_builder</tabactionfunction>
          <activetab>' . (isset($eventData['tab']) ? $eventData['tab'] : '') . '</activetab>
        </args>
        <children>
    
        <vertgroup>
          <children>
    
            <label><name>status</name>
              <args>
                <label type="encoded">' . urlencode($gLocale->GetStr('status.label')) . '</label>
                <bold>true</bold>
              </args>
            </label>
    
        <horizgroup>
          <children>
    
            <label>
              <args>
                <label type="encoded">' . urlencode($gLocale->GetStr('last_maintenance.label')) . '</label>
              </args>
            </label>
    
            <date>
              <args>
                <readonly>true</readonly>
                <type>date</type>
                <value type="array">' . huixml_encode($date_array) . '</value>
              </args>
            </date>
    
            <date>
              <args>
                <readonly>true</readonly>
                <type>time</type>
                <value type="array">' . huixml_encode($date_array) . '</value>
              </args>
            </date>
    
          </children>
        </horizgroup>
    
            <horizbar/>';
    if (isset($GLOBALS['gEnv']['runtime']['maintenance']['result'])) {
        $row = 0;
        $gXml_def .= '
                <label>
                  <args>
                    <label type="encoded">' . urlencode($gLocale->GetStr('report.label')) . '</label>
                    <bold>true</bold>
                  </args>
                </label>
        <grid><children>';
        foreach ($GLOBALS['gEnv']['runtime']['maintenance']['result'] as $task => $result) {
            $gXml_def .= '<label row="' . $row . '" col="0">
              <args>
                <nowrap>true</nowrap>
                <label type="encoded">' . urlencode($tasks[$task]['description']) . '</label>
              </args>
            </label>
            <button row="' . $row . '" col="1">
              <args>
                <themeimage>' . ($result ? 'button_ok' : 'button_cancel') . '</themeimage>
                <disabled>true</disabled>
              </args>
            </button>';
            $row++;
        }
        $gXml_def .= '</children></grid><horizbar/>';
    }
    $gXml_def .= '        <button>
              <args>
                <themeimage>button_ok</themeimage>
                <label type="encoded">' . urlencode($gLocale->GetStr('run_maintenance.button')) . '</label>
                <horiz>true</horiz>
                <frame>false</frame>
                <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default'), array('action', 'run_maintenance')))) . '</action>
              </args>
            </button>
    
          </children>
        </vertgroup>
    
        <vertgroup>
          <children>
    
            <label>
              <args>
                <label type="encoded">' . urlencode($gLocale->GetStr('report.label')) . '</label>
                <bold>true</bold>
              </args>
            </label>
    
            <form><name>report</name>
              <args>
                <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default'), array('action', 'set_report')))) . '</action>
              </args>
              <children>
    
            <grid>
              <children>
    
                <label row="0" col="0">
                  <args>
                    <label type="encoded">' . urlencode($gLocale->GetStr('report_enabled.label')) . '</label>
                  </args>
                </label>
    
                <checkbox row="0" col="1"><name>reportenabled</name>
                  <args>
                    <disp>action</disp>
                    <checked>' . ($main->GetReportsEnableStatus() ? 'true' : 'false') . '</checked>
                  </args>
                </checkbox>
    
                <label row="1" col="0">
                  <args>
                    <label type="encoded">' . urlencode($gLocale->GetStr('report_email.label')) . '</label>
                  </args>
                </label>
    
                <string row="1" col="1"><name>reportemail</name>
                  <args>
                    <disp>action</disp>
                    <value type="encoded">' . urlencode($main->GetReportsEmail()) . '</value>
                    <size>25</size>
                  </args>
                </string>
    
              </children>
            </grid>
    
            </children>
            </form>
    
            <horizbar/>
    
            <button>
              <args>
                <themeimage>button_ok</themeimage>
                <label type="encoded">' . urlencode($gLocale->GetStr('apply.button')) . '</label>
                <horiz>true</horiz>
                <frame>false</frame>
                <formsubmit>report</formsubmit>
                <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default'), array('action', 'set_report')))) . '</action>
              </args>
            </button>
    
          </children>
        </vertgroup>
    
        <vertgroup>
          <children>
    
            <label>
              <args>
                <label type="encoded">' . urlencode($gLocale->GetStr('scheduled_tasks.label')) . '</label>
                <bold>true</bold>
              </args>
            </label>
    
            <form><name>settings</name>
              <args>
                <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default'), array('action', 'set_general')))) . '</action>
              </args>
              <children>
    
                <grid>
                  <children>';
    reset($tasks);
    foreach ($tasks as $task) {
        $gXml_def .= '<checkbox row="' . $row . '" col="0"><name type="encoded">' . urlencode($task['name'] . '_task') . '</name>
          <args>
            <disp>action</disp>
            <checked>' . ($task['enabled'] ? 'true' : 'false') . '</checked>
          </args>
        </checkbox>
        <label row="' . $row . '" col="1">
          <args>
            <label type="encoded">' . urlencode($task['description']) . '</label>
            <nowrap>false</nowrap>
          </args>
        </label>';
        $row++;
    }
    $gXml_def .= '              </children>
                </grid>
    
              </children>
            </form>
    
        <horizbar/>
    
            <button>
              <args>
                <themeimage>button_ok</themeimage>
                <label type="encoded">' . urlencode($gLocale->GetStr('apply.button')) . '</label>
                <horiz>true</horiz>
                <frame>false</frame>
                <formsubmit>settings</formsubmit>
                <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default'), array('action', 'set_general')))) . '</action>
              </args>
            </button>
    
          </children>
          </vertgroup>
    
          </children>
        </tab>
    
      </children>
    </vertgroup>';
    $gPage_title .= ' - ' . $gLocale->GetStr('general.title');
}