| +--------------------------------------------------------------------------+ | Author: Aleksander Machniak | +--------------------------------------------------------------------------+ */ class kolab_client_task_sharedfolder extends kolab_client_task { protected $ajax_only = true; protected $menu = array( 'add' => 'sharedfolder.add', ); protected $list_attribs = array('cn'); /** * Default action. */ public function action_default() { $this->output->set_object('content', 'sharedfolder', true); $this->output->set_object('task_navigation', $this->menu()); $this->action_list(); // display form to add a shared folder if logged-in user has right to do so $caps = $this->get_capability('actions'); if (!empty($caps['sharedfolder.add'])) { $this->action_add(); } else { $this->output->command('set_watermark', 'taskcontent'); } } /** * Resource adding (form) action. */ public function action_add() { $data = $this->get_input('data', 'POST'); $output = $this->sharedfolder_form(null, $data, true); $this->output->set_object('taskcontent', $output); } /** * Resource information (form) action. */ public function action_info() { $id = $this->get_input('id', 'POST'); $result = $this->api_get('sharedfolder.info', array('id' => $id)); $sharedfolder = $result->get(); //console("action_info()", $sharedfolder); $output = $this->sharedfolder_form(null, $sharedfolder); $this->output->set_object('taskcontent', $output); } private function sharedfolder_form($attribs, $data = array()) { if (empty($attribs['id'])) { $attribs['id'] = 'sharedfolder-form'; } //console("sharedfolder_form(\$attribs, \$data)", $attribs, $data); // Form sections $sections = array( 'system' => 'sharedfolder.system', 'other' => 'sharedfolder.other', ); // field-to-section map and fields order $fields_map = array( 'type_id' => 'system', 'type_id_name' => 'system', 'cn' => 'system', 'ou' => 'system', 'preferredlanguage' => 'system', 'mail' => 'system', 'alias' => 'system', 'mailalternateaddress' => 'system', 'member' => 'system', 'uniquemember' => 'system', 'memberurl' => 'system', 'nsrole' => 'system', 'nsroledn' => 'system', /* Kolab Settings */ 'kolabhomeserver' => 'system', 'mailhost' => 'system', 'mailquota' => 'system', 'kolabfreebusyfuture' => 'system', 'kolabinvitationpolicy' => 'system', 'kolabdelegate' => 'system', 'kolaballowsmtprecipient' => 'system', 'kolaballowsmtpsender' => 'system', ); // Prepare fields list($fields, $types, $type) = $this->form_prepare('sharedfolder', $data); //console("Result from form_prepare", $fields, $types, $type); $add_mode = empty($data['id']); $accttypes = array(); foreach ($types as $idx => $elem) { $accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']); } // Add sharedfolder type id selector $fields['type_id'] = array( 'section' => 'system', 'type' => kolab_form::INPUT_SELECT, 'options' => $accttypes, 'onchange' => "kadm.sharedfolder_save(true, 'system')", ); //console($accttypes); // Hide account type selector if there's only one type if (count($accttypes) < 2 || !$add_mode) { //console("setting type_id form type to hidden"); $fields['type_id']['type'] = kolab_form::INPUT_HIDDEN; } // Create mode if ($add_mode) { // Page title $title = $this->translate('sharedfolder.add'); } // Edit mode else { $title = $data['cn']; // Add sharedfolder type name $fields['type_id_name'] = array( 'label' => 'sharedfolder.type_id', 'section' => 'system', 'value' => $accttypes[$type]['content'], ); } // Create form object and populate with fields $form = $this->form_create('sharedfolder', $attribs, $sections, $fields, $fields_map, $data, $add_mode); $form->set_title(kolab_html::escape($title)); return $form->output(); } }