Status->setActionClass($this); $this->Apply->setActionClass($this); } public function configure($clientId) { $clientdata = $this->Application->getModule('api')->get(array('clients', 'show', $clientId))->output; $this->ShowClient->Text = implode(PHP_EOL, $clientdata); $client = $this->Application->getModule('api')->get(array('clients', $clientId))->output; $this->ClientName->Text = $client->name; $this->ClientIdentifier->Text = $client->clientid; $this->ClientDescription->Text = $client->uname; $this->FileRetention->Text = intval($client->fileretention / 86400); // conversion to days $this->JobRetention->Text = intval($client->jobretention / 86400); // conversion to days $this->AutoPrune->Checked = $client->autoprune == 1; } public function status($sender, $param) { $status = $this->Application->getModule('api')->get(array('clients', 'status', $this->ClientIdentifier->Text))->output; $this->ShowClient->Text = implode(PHP_EOL, $status); } public function apply($sender, $param) { if($this->JobRetentionValidator->IsValid === false || $this->FileRetentionValidator->IsValid === false) { return false; } $client = array(); $client['clientid'] = $this->ClientIdentifier->Text; $client['fileretention'] = $this->FileRetention->Text * 86400; // conversion to seconds $client['jobretention'] = $this->JobRetention->Text * 86400; // conversion to seconds $client['autoprune'] = (integer)$this->AutoPrune->Checked; $this->Application->getModule('api')->set(array('clients', $client['clientid']), $client); } public function fileRetentionValidator($sender, $param) { $isValid = preg_match('/^\d+$/', $this->FileRetention->Text) && $this->FileRetention->Text >= 0; $param->setIsValid($isValid); } public function jobRetentionValidator($sender, $param) { $isValid = preg_match('/^\d+$/', $this->JobRetention->Text) && $this->JobRetention->Text >= 0; $param->setIsValid($isValid); } } ?>