baseDn = $baseDn; $this->searchScope = $searchScope; $this->filter = $filter; $this->attributes = $attributes; $this->includeSystem = $includeSystem; $this->saveAsFile = $saveAsFile; $this->format = $format; $this->ending = $ending; } /** * Starts the export process. * * @return string JSON result */ public function doExport() { try { $this->checkParameters(); } catch (LAMException $e) { $data = Exporter::formatMessage('ERROR', $e->getTitle(), $e->getMessage()); $status = array( Exporter::STATUS => 'failed', Exporter::DATA => $data ); return json_encode($status); } } /** * Returns the HTML for an error message. * * @param string $type message type (e.g. INFO) * @param string $title title * @param string $message message * @return string HTML */ public static function formatMessage($type, $title, $message) { $msg = new htmlStatusMessage($type, $title, $message); $tabindex = 0; ob_start(); $msg->generateHTML(null, array($msg), array(), true, $tabindex, 'user'); $data = ob_get_contents(); ob_clean(); return $data; } /** * Checks the input parameters for validity. * * @throws LAMException in case of errors */ private function checkParameters() { if (!get_preg($this->baseDn, 'dn')) { throw new LAMException(_('Please enter a valid DN in the field:'), _('Base DN')); } } }