コード例 #1
0
ファイル: mongo.php プロジェクト: tapiau/muyo
 /**
  * @param string $name
  * @param array $setting
  * @param mixed $defaultValue
  */
 protected function schemaColumnApplyDefault(&$name, &$setting, &$defaultValue)
 {
     if ($name == $this->getPrimaryKey()) {
         array_set_default($setting, 'type', 'string');
     }
     parent::schemaColumnApplyDefault($name, $setting, $defaultValue);
 }
コード例 #2
0
function commit_sets_from_root_sets($db, $root_sets)
{
    $repository_name_to_id = array();
    foreach ($db->fetch_table('repositories') as $row) {
        $repository_name_to_id[$row['repository_name']] = $row['repository_id'];
    }
    $commit_sets = array();
    foreach ($root_sets as $repository_name => $revisions) {
        $repository_id = array_get($repository_name_to_id, $repository_name);
        if (!$repository_id) {
            exit_with_error('RepositoryNotFound', array('name' => $repository_name));
        }
        foreach ($revisions as $i => $revision) {
            $commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $revision));
            if (!$commit) {
                exit_with_error('RevisionNotFound', array('repository' => $repository_name, 'revision' => $revision));
            }
            array_set_default($commit_sets, $i, array());
            array_push($commit_sets[$i], $commit['commit_id']);
        }
    }
    $commit_count_per_set = count($commit_sets[0]);
    foreach ($commit_sets as $commits) {
        if ($commit_count_per_set != count($commits)) {
            exit_with_error('InvalidRootSets', array('rootSets' => $root_sets));
        }
    }
    return $commit_sets;
}
コード例 #3
0
 public function add()
 {
     $errors = array();
     $audience = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $audience = extract_values($_POST, array('name', 'sort', 'description'));
         $audience['active'] = 1;
         $errors = $this->bo->validate($audience);
         if (!$errors) {
             $receipt = $this->bo->add($audience);
             $this->redirect(array('menuaction' => 'booking.uiaudience.index'));
         }
     }
     array_set_default($audience, 'sort', '0');
     $this->flash_form_errors($errors);
     $audience['cancel_link'] = self::link(array('menuaction' => 'booking.uiaudience.index'));
     self::render_template('audience_new', array('audience' => $audience));
 }
コード例 #4
0
 public function add()
 {
     $errors = array();
     $agegroup = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $agegroup = extract_values($_POST, array('name', 'sort', 'description'));
         $agegroup['active'] = true;
         $errors = $this->bo->validate($agegroup);
         if (!$errors) {
             $receipt = $this->bo->add($agegroup);
             $this->redirect(array('menuaction' => 'booking.uiagegroup.index', 'id' => $receipt['id']));
         }
     }
     $this->flash_form_errors($errors);
     $agegroup['cancel_link'] = self::link(array('menuaction' => 'booking.uiagegroup.index'));
     array_set_default($agegroup, 'sort', '0');
     self::render_template('agegroup_new', array('agegroup' => $agegroup));
 }
コード例 #5
0
ファイル: backend.lib.php プロジェクト: jijkoun/ssscrape
 /**
  * Connects to the PostgreSQL database.
  *
  * \param settings An associative array with connection settings: the
  * 'hostname', 'username' and 'password' indices will be used for connection
  * setttings. The key 'keep_settings' can be used to indicate whether the
  * settings are stored. The 'escape_column_names' and 'escape_table_names'
  * keys can be set to indicate whether column and table names should be
  * escaped when using CRUD functions.
  */
 function connect(array $settings)
 {
     if (is_null($settings)) {
         $settings = array();
     }
     assert('is_assoc_array($settings)');
     /* We support "hostname", "username" and "pass" too, although the
      * real connection string uses other names */
     $aliases = array('hostname' => 'host', 'pass' => 'password', 'username' => 'user', 'database' => 'dbname');
     foreach ($aliases as $old => $new) {
         if (array_has_key($settings, $old)) {
             array_set_default($settings, $new, $settings[$old]);
         }
     }
     /* List of keywords that are allowed in the connection string: */
     $keywords = array('host', 'hostaddr', 'port', 'dbname', 'user', 'password', 'connect_timeout', 'options', 'sslmode', 'service');
     /* Create a connection string from the supplied values, leaving out
      * illegal (name, value) pairs */
     $options = array();
     foreach ($keywords as $keyword) {
         if (array_key_exists($keyword, $settings)) {
             $value = $settings[$keyword];
             assert('is_string($value)');
             /* Escape single and double quotes */
             $value = str_replace("'", "\\'", $value);
             $value = str_replace('"', '\\"', $value);
             $options[] = sprintf('%s=%s', $keyword, $value);
         }
     }
     $connection_string = implode(' ', $options);
     $this->id = pg_connect($connection_string) or trigger_error(sprintf('Could not connect to database %s', $settings['dbname']), E_USER_ERROR);
     /* Keep connection settings only if requested. This makes select_db()
      * work, but stores the plaintext password in the object's memory. */
     if (!array_get_default($settings, 'keep_settings', false)) {
         /* Unset both the aliases and the connection keywords */
         array_unset_keys($settings, array_keys($aliases));
         array_unset_keys($settings, $keywords);
     }
     $this->settings = $settings;
 }
コード例 #6
0
 private function map_metrics_to_tests($metrics_table, $test_id_to_parent)
 {
     $test_to_metrics = array();
     if (!$metrics_table) {
         return $test_to_metrics;
     }
     foreach ($metrics_table as $metric_row) {
         $this->id_to_metric[$metric_row['metric_id']] = $metric_row;
         $test_id = $metric_row['metric_test'];
         array_set_default($test_to_metrics, $test_id, array());
         array_push($test_to_metrics[$test_id], $metric_row);
         $parent_id = $test_id_to_parent[$test_id];
         if ($parent_id) {
             array_set_default($this->test_id_to_child_metrics, $parent_id, array());
             $parent_metrics =& $this->test_id_to_child_metrics[$parent_id];
             if (!in_array($metric_row['metric_name'], $parent_metrics)) {
                 array_push($parent_metrics, $metric_row);
             }
         }
     }
     return $test_to_metrics;
 }
コード例 #7
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $season = $this->bo->read_single($id);
     $season['buildings_link'] = self::link(array('menuaction' => 'booking.uibuilding.index'));
     $season['building_link'] = self::link(array('menuaction' => 'booking.uibuilding.show', 'id' => $season['building_id']));
     $from = strtotime($season['from_']);
     $to = strtotime($season['to_']);
     $season['from_'] = date("Y-m-d", $from);
     $season['to_'] = date("Y-m-d", $to);
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_set_default($_POST, 'resources', array());
         $season = array_merge($season, extract_values($_POST, $this->fields));
         $errors = $this->bo->validate($season);
         if (!$errors) {
             try {
                 $receipt = $this->bo->update($season);
                 $this->redirect(array('menuaction' => 'booking.uiseason.show', 'id' => $season['id']));
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not update object due to insufficient permissions');
             }
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'season.js');
     phpgwapi_yui::load_widget('datatable');
     phpgwapi_yui::load_widget('autocomplete');
     $season['resources_json'] = json_encode(array_map('intval', $season['resources']));
     $season['cancel_link'] = self::link(array('menuaction' => 'booking.uiseason.show', 'id' => $season['id']));
     self::render_template('season_edit', array('season' => $season, 'lang' => $lang));
 }
コード例 #8
0
ファイル: index.php プロジェクト: einars/tiny-dropbox
function get_setup()
{
    $ser = @file_get_contents(get_setup_file_name());
    $setup = @unserialize($ser);
    if ($setup === false) {
        $setup = array();
    }
    array_set_default($setup, 'title', null);
    array_set_default($setup, 'password', 'master');
    array_set_default($setup, 'custom-stylesheet', null);
    array_set_default($setup, 'css-customizations', null);
    array_set_default($setup, 'introduction', null);
    array_set_default($setup, 'uploads', array());
    array_set_default($setup, 'storage-limit-mb', null);
    array_set_default($setup, 'language', 'en');
    array_set_default($setup, 'owner-session', get_session_id());
    array_set_default($setup, 'owner-ip', $_SERVER['REMOTE_ADDR']);
    return $setup;
}
コード例 #9
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $event = $this->bo->read_single($id);
     $building_info = $this->bo->so->get_building_info($id);
     $event['building_id'] = $building_info['id'];
     $event['building_name'] = $building_info['name'];
     $config = CreateObject('phpgwapi.config', 'booking');
     $config->read();
     $external_site_address = isset($config->config_data['external_site_address']) && $config->config_data['external_site_address'] ? $config->config_data['external_site_address'] : $GLOBALS['phpgw_info']['server']['webserver_url'];
     $link = $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.uibuilding.schedule&id=' . $event['building_id'] . "&date=" . substr($event['from_'], 0, -9);
     $errors = array();
     $customer = array();
     if ($event['customer_identifier_type']) {
         $customer['customer_identifier_type'] = $event['customer_identifier_type'];
         $customer['customer_ssn'] = $event['customer_ssn'];
         $customer['customer_organization_number'] = $event['customer_organization_number'];
         $customer['customer_internal'] = $event['customer_internal'];
         $orginfo = $this->bo->so->get_org($event['customer_organization_number']);
         $customer['customer_organization_id'] = $orginfo['id'];
         $customer['customer_organization_name'] = $orginfo['name'];
     } else {
         $customer['customer_organization_name'] = $event['customer_organization_name'];
         $customer['customer_organization_id'] = $event['customer_organization_id'];
         $organization = $this->organization_bo->read_single($event['customer_organization_id']);
         $customer['customer_identifier_type'] = 'organization_number';
         $customer['customer_ssn'] = $organization['customer_internal'];
         $customer['customer_organization_number'] = $organization['organization_number'];
         $customer['customer_internal'] = $organization['customer_internal'];
     }
     list($event, $errors) = $this->extract_and_validate($event);
     if ($event['customer_organization_number']) {
         $orginfo = $this->bo->so->get_org($event['customer_organization_number']);
         $event['customer_organization_id'] = $orginfo['id'];
         $event['customer_organization_name'] = $orginfo['name'];
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!$_POST['organization_name']) {
             $event['customer_organization_name'] = Null;
             $event['customer_organization_id'] = Null;
         }
         array_set_default($_POST, 'resources', array());
         if ($_POST['organization_name']) {
             $event['customer_organization_name'] = $_POST['organization_name'];
             $event['customer_organization_id'] = $_POST['organization_id'];
             $organization = $this->organization_bo->read_single(intval(phpgw::get_var('organization_id', 'POST')));
             if ($organization['customer_internal'] == 0) {
                 $event['customer_identifier_type'] = $organization['customer_identifier_type'];
                 $event['customer_internal'] = $organization['customer_internal'];
                 if (strlen($organization['customer_organization_number']) == 9) {
                     $event['customer_organization_number'] = $organization['customer_organization_number'];
                 } else {
                     $errors['organization_number'] = lang('The organization number is wrong or not present');
                 }
             } else {
                 $event['customer_identifier_type'] = 'organization_number';
                 $event['customer_internal'] = $organization['customer_internal'];
                 if (strlen($organization['customer_number']) == 6 || strlen($organization['customer_number']) == 5) {
                     $event['customer_organization_number'] = $organization['customer_number'];
                 } else {
                     $errors['resource_number'] = lang('The resource number is wrong or not present');
                 }
             }
         } elseif ($_POST['customer_identifier_type'] == 'ssn') {
             $event['customer_identifier_type'] = 'ssn';
             $event['customer_ssn'] = $_POST['customer_ssn'];
         } elseif ($_POST['customer_identifier_type'] == 'organization_number') {
             $event['customer_identifier_type'] = 'organization_number';
             $event['customer_organization_number'] = $_POST['customer_organization_number'];
         }
         if ($_POST['cost'] != 0 and !$event['customer_organization_number'] and !$event['customer_ssn']) {
             $errors['invoice_data'] = lang('There is set a cost, but no invoice data is filled inn');
         }
         if (!$errors['event'] and !$errors['resource_number'] and !$errors['organization_number'] and !$errors['invoice_data'] && !$errors['contact_name'] && !$errors['cost']) {
             if ((phpgw::get_var('sendtorbuilding', 'POST') || phpgw::get_var('sendtocontact', 'POST') || phpgw::get_var('sendtocollision', 'POST')) && phpgw::get_var('active', 'POST')) {
                 if (phpgw::get_var('sendtocollision', 'POST') || phpgw::get_var('sendtocontact', 'POST') || phpgw::get_var('sendtorbuilding', 'POST')) {
                     $maildata = $this->create_sendt_mail_notification_comment_text($event, $errors);
                     if (phpgw::get_var('sendtocollision', 'POST')) {
                         $comment_text_log = "<span style='color: green;'>" . lang('Message sent about the changes in the reservations') . ':</span><br />';
                         $res = array();
                         $resname = '';
                         foreach ($event['resources'] as $resid) {
                             $res = $this->bo->so->get_resource_info($resid);
                             $resname .= $res['name'] . ', ';
                         }
                         $comment_text_log .= $event['building_name'] . " (" . substr($resname, 0, -2) . ") " . pretty_timestamp($event['from_']) . " - " . pretty_timestamp($event['to_']);
                         $this->add_comment($event, $comment_text_log);
                     }
                     if (phpgw::get_var('sendtocollision', 'POST')) {
                         $subject = $config->config_data['event_conflict_mail_subject'];
                         $body = "<p>" . $config->config_data['event_mail_conflict_contact_active_collision'] . "<br />\n" . phpgw::get_var('mail', 'POST') . "\n";
                         $body .= '<br /><a href="' . $link . '">Link til ' . $config->config_data['application_mail_systemname'] . '</a></p>';
                         $body .= "<p>" . $config->config_data['application_mail_signature'] . "</p>";
                         $mail_sendt_to = '';
                         foreach (array_keys($maildata) as $mail) {
                             if ($mail == '') {
                                 continue;
                             }
                             usort($maildata[$mail], function ($a, $b) {
                                 $adate = explode('-', $a['date']);
                                 $bdate = explode('-', $b['date']);
                                 $astart = $adate[2] . $adate[1] . $adate[0] . str_replace(':', '', $a['start']);
                                 $bstart = $bdate[2] . $bdate[1] . $bdate[0] . str_replace(':', '', $b['start']);
                                 return $astart - $bstart;
                             });
                             $mailbody = '';
                             $comment_text_log = "Reserverasjoner som har blitt overskrevet: \n";
                             $mail_sendt_to = $mail_sendt_to . ' ' . $mail;
                             foreach ($maildata[$mail] as $data) {
                                 $comment_text_log .= $data['date'] . ', ' . $data['building'] . ', ' . $data['resource'] . ', Kl. ' . $data['start'] . ' - ' . $data['end'] . " \n";
                             }
                             $mailbody .= $body . "<pre>" . $comment_text_log . "</pre>";
                             $this->send_mailnotification($mail, $subject, $mailbody);
                         }
                         if (strpos($mail_sendt_to, '@') !== False) {
                             $comment = "<p>Melding om konflikt er sendt til" . $mail_sendt_to . "<br />\n" . phpgw::get_var('mail', 'POST') . "</p>";
                             $this->add_comment($event, $comment);
                         }
                     }
                     if (phpgw::get_var('sendtocontact', 'POST')) {
                         $subject = $config->config_data['event_change_mail_subject'];
                         $body = "<p>" . $config->config_data['event_change_mail'] . "\n" . phpgw::get_var('mail', 'POST');
                         $body .= '<br /><a href="' . $link . '">Link til ' . $config->config_data['application_mail_systemname'] . '</a></p>';
                         $this->send_mailnotification($event['contact_email'], $subject, $body);
                         $comment = $comment_text_log . '<br />Denne er sendt til ' . $event['contact_email'];
                         $this->add_comment($event, $comment);
                     }
                     if (phpgw::get_var('sendtorbuilding', 'POST')) {
                         $subject = $config->config_data['event_mail_building_subject'];
                         $body = "<p>" . $config->config_data['event_mail_building'] . "<br />\n" . phpgw::get_var('mail', 'POST') . "</p>";
                         if ($event['customer_organization_name']) {
                             $username = $event['customer_organization_name'];
                         } else {
                             $username = $event['contact_name'];
                         }
                         $res = array();
                         $resname = '';
                         foreach ($event['resources'] as $resid) {
                             $res = $this->bo->so->get_resource_info($resid);
                             $resname .= $res['name'] . ', ';
                         }
                         $resources = $event['building_name'] . " (" . substr($resname, 0, -2) . ") " . pretty_timestamp($event['from_']) . " - " . pretty_timestamp($event['to_']);
                         $body .= '<p>' . $username . ' har fått innvilget et arrangement i ' . $resources . ".";
                         $body .= '<br /><a href="' . $link . '">Link til ' . $config->config_data['application_mail_systemname'] . '</a></p>';
                         $body .= "<p>" . $config->config_data['application_mail_signature'] . "</p>";
                         $sendt = 0;
                         $mail_sendt_to = '';
                         if ($event['contact_email']) {
                             $sendt++;
                             $mail_sendt_to = $mail_sendt_to . ' ' . $event['contact_email'];
                             $this->send_mailnotification($event['contact_email'], $subject, $body);
                         }
                         if ($building_info['email']) {
                             $sendt++;
                             $mail_sendt_to = $mail_sendt_to . ' ' . $building_info['email'];
                             $this->send_mailnotification($building_info['email'], $subject, $body);
                         }
                         if ($building_info['tilsyn_email']) {
                             $sendt++;
                             $mail_sendt_to = $mail_sendt_to . ' ' . $building_info['tilsyn_email'];
                             $this->send_mailnotification($building_info['tilsyn_email'], $subject, $body);
                         }
                         if ($building_info['tilsyn_email2']) {
                             $sendt++;
                             $mail_sendt_to = $mail_sendt_to . ' ' . $building_info['tilsyn_email2'];
                             $this->send_mailnotification($building_info['sendtorbuilding_email2'], $subject, $body);
                         }
                         if ($_POST['sendtorbuilding_email1']) {
                             $sendt++;
                             $mail_sendt_to = $mail_sendt_to . ' ' . $_POST['sendtorbuilding_email1'];
                             $this->send_mailnotification($_POST['sendtorbuilding_email1'], $subject, $body);
                         }
                         if ($_POST['sendtorbuilding_email2']) {
                             $sendt++;
                             $mail_sendt_to = $mail_sendt_to . ' ' . $_POST['sendtorbuilding_email2'];
                             $this->send_mailnotification($_POST['sendtorbuilding_email2'], $subject, $body);
                         }
                         if ($sendt <= 0) {
                             $errors['mailtobuilding'] = lang('Unable to send warning, No mailadresses found');
                         } else {
                             $comment_text_log = phpgw::get_var('mail', 'POST');
                             $comment = 'Melding om endring er sendt til ansvarlig for bygg: ' . $mail_sendt_to . '<br />' . $comment_text_log;
                             $this->add_comment($event, $comment);
                         }
                     }
                 }
                 if (!phpgw::get_var('active', 'POST')) {
                     $subject = $config->config_data['event_canceled_mail_subject'];
                     $body = $config->config_data['event_canceled_mail'] . "\n" . phpgw::get_var('mail', 'POST');
                     if ($event['customer_organization_name']) {
                         $comment_text_log = $event['customer_organization_name'];
                     } else {
                         $comment_text_log = $event['contact_name'];
                     }
                     $comment_text_log = $comment_text_log . ' sitt arrangement i ' . $event['building_name'] . ' ' . date('d-m-Y H:i', strtotime($event['from_'])) . " har blitt kansellert.";
                     $body .= "<br />\n" . $comment_text_log;
                     $body = html_entity_decode($body);
                     $sendt = 0;
                     $mail_sendt_to = '';
                     if ($building_info['email']) {
                         $sendt++;
                         $mail_sendt_to = $mail_sendt_to . ' ' . $building_info['email'];
                         $this->send_mailnotification($building_info['email'], $subject, $body);
                     }
                     if ($building_info['tilsyn_email']) {
                         $sendt++;
                         $mail_sendt_to = $mail_sendt_to . ' ' . $building_info['tilsyn_email'];
                         $this->send_mailnotification($building_info['tilsyn_email'], $subject, $body);
                     }
                     if ($building_info['tilsyn_email2']) {
                         $sendt++;
                         $mail_sendt_to = $mail_sendt_to . ' ' . $building_info['tilsyn_email2'];
                         $this->send_mailnotification($building_info['tilsyn_email2'], $subject, $body);
                     }
                     if ($_POST['sendtorbuilding_email1']) {
                         $sendt++;
                         $mail_sendt_to = $mail_sendt_to . ' ' . $_POST['sendtorbuilding_email1'];
                         $this->send_mailnotification($_POST['sendtorbuilding_email1'], $subject, $body);
                     }
                     if ($_POST['sendtorbuilding_email2']) {
                         $sendt++;
                         $mail_sendt_to = $mail_sendt_to . ' ' . $_POST['sendtorbuilding_email2'];
                         $this->send_mailnotification($_POST['sendtorbuilding_email2'], $subject, $body);
                     }
                     if ($sendt <= 0) {
                         $errors['mailtobuilding'] = lang('Unable to send warning, No mailadresses found');
                     } else {
                         $comment = '<span style="color:red;">Dette arrangemenet er kanselert</span>. Denne er sendt til ' . $mail_sendt_to . '<br />' . phpgw::get_var('mail', 'POST');
                         $this->add_comment($event, $comment);
                     }
                     //						$receipt = $this->bo->update($event);
                     //						$this->redirect(array('menuaction' => 'booking.uievent.edit', 'id'=>$event['id']));
                 }
             }
             $receipt = $this->bo->update($event);
             $this->redirect(array('menuaction' => 'booking.uievent.edit', 'id' => $event['id']));
         }
     }
     if ($errors['allocation']) {
         $errors['allocation'] = lang('Event created, Overlaps with existing allocation, Remember to send a notification');
     } elseif ($errors['booking']) {
         $errors['booking'] = lang('Event created, Overlaps with existing booking, Remember to send a notification');
     }
     $this->flash_form_errors($errors);
     if ($customer['customer_identifier_type']) {
         $event['customer_identifier_type'] = $customer['customer_identifier_type'];
         $event['customer_ssn'] = $customer['customer_ssn'];
         $event['customer_organization_number'] = $customer['customer_organization_number'];
         $event['customer_internal'] = $customer['customer_internal'];
     }
     self::add_javascript('booking', 'booking', 'event.js');
     $event['resources_json'] = json_encode(array_map('intval', $event['resources']));
     $event['application_link'] = self::link(array('menuaction' => 'booking.uiapplication.show', 'id' => $event['application_id']));
     $event['cancel_link'] = self::link(array('menuaction' => 'booking.uievent.index'));
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     #			$comments = array_reverse($event['comments']);
     $comments = $this->bo->so->get_ordered_comments($id);
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $audience = $audience['results'];
     $this->install_customer_identifier_ui($event);
     $this->add_template_helpers();
     self::render_template('event_edit', array('event' => $event, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience, 'comments' => $comments));
 }
コード例 #10
0
ファイル: model.php プロジェクト: tapiau/muyo
 /**
  * @param string $name
  * @param array $setting
  * @param mixed $defaultValue
  */
 protected function schemaColumnApplyDefault(&$name, &$setting, &$defaultValue)
 {
     if ($name === $this->getPrimaryKey()) {
         array_set_default($setting, 'type', 'int');
         array_set_default($setting, 'hidden', 'true');
     }
 }
コード例 #11
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $application = $this->bo->read_single($id);
     $this->check_application_assigned_to_current_user($application);
     $building_info = $this->bo->so->get_building_info($id);
     $application['building_id'] = $building_info['id'];
     $application['building_name'] = $building_info['name'];
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_set_default($_POST, 'resources', array());
         array_set_default($_POST, 'accepted_documents', array());
         $application = array_merge($application, extract_values($_POST, $this->fields));
         $application['message'] = $_POST['comment'];
         $this->agegroup_bo->extract_form_data($application);
         $this->extract_customer_identifier($application);
         if ($application['frontend_modified'] == '') {
             unset($application['frontend_modified']);
         }
         $errors = $this->validate($application);
         foreach ($_POST['from_'] as &$from) {
             $timestamp = strtotime($from);
             $from = date("Y-m-d H:i:s", $timestamp);
         }
         foreach ($_POST['to_'] as &$to) {
             $timestamp = strtotime($to);
             $to = date("Y-m-d H:i:s", $timestamp);
         }
         $application['dates'] = array_map(array(self, '_combine_dates'), $_POST['from_'], $_POST['to_']);
         if (!$errors) {
             $receipt = $this->bo->update($application);
             $this->bo->send_notification($application);
             $this->redirect(array('menuaction' => $this->url_prefix . '.show', 'id' => $application['id']));
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'application.js');
     $this->set_case_officer($application);
     $application['resources_json'] = json_encode(array_map('intval', $application['resources']));
     $application['accepted_documents_json'] = json_encode($application['accepted_documents']);
     $application['cancel_link'] = self::link(array('menuaction' => 'booking.uiapplication.index'));
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $audience = $audience['results'];
     $this->install_customer_identifier_ui($application);
     $application['customer_identifier_types']['ssn'] = 'Date of birth or SSN';
     self::render_template('application_edit', array('application' => $application, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience));
 }
コード例 #12
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $allocation = $this->bo->read_single($id);
     $allocation['building'] = $this->building_bo->so->read_single($allocation['building_id']);
     $allocation['building_name'] = $allocation['building']['name'];
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_set_default($_POST, 'resources', array());
         $allocation = array_merge($allocation, extract_values($_POST, $this->fields));
         $organization = $this->organization_bo->read_single(intval(phpgw::get_var('organization_id', 'POST')));
         $errors = $this->bo->validate($allocation);
         if (!$errors) {
             try {
                 $receipt = $this->bo->update($allocation);
                 $this->bo->so->update_id_string();
                 $this->send_mailnotification_to_organization($organization, lang('Allocation changed'), phpgw::get_var('mail', 'POST'));
                 $this->redirect(array('menuaction' => 'booking.uiallocation.show', 'id' => $allocation['id']));
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not update object due to insufficient permissions');
             }
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'allocation.js');
     $allocation['resources_json'] = json_encode(array_map('intval', $allocation['resources']));
     $allocation['cancel_link'] = self::link(array('menuaction' => 'booking.uiallocation.show', 'id' => $allocation['id']));
     $allocation['application_link'] = self::link(array('menuaction' => 'booking.uiapplication.show', 'id' => $allocation['application_id']));
     self::render_template('allocation_edit', array('allocation' => $allocation));
 }
コード例 #13
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $event = $this->bo->read_single($id);
     $building_info = $this->bo->so->get_building_info($id);
     $event['building_id'] = $building_info['id'];
     $event['building_name'] = $building_info['name'];
     $bouser = CreateObject('bookingfrontend.bouser');
     $config = CreateObject('phpgwapi.config', 'booking');
     $config->read();
     $errors = array();
     $customer = array();
     if ($event['customer_identifier_type']) {
         $customer['customer_identifier_type'] = $event['customer_identifier_type'];
         $customer['customer_ssn'] = $event['customer_ssn'];
         $customer['customer_organization_number'] = $event['customer_organization_number'];
         $customer['customer_internal'] = $event['customer_internal'];
         $orginfo = $this->bo->so->get_org($event['customer_organization_number']);
         $customer['customer_organization_id'] = $orginfo['id'];
         $customer['customer_organization_name'] = $orginfo['name'];
     } else {
         $customer['customer_organization_name'] = $event['customer_organization_name'];
         $customer['customer_organization_id'] = $event['customer_organization_id'];
         $organization = $this->organization_bo->read_single($event['customer_organization_id']);
         $customer['customer_identifier_type'] = 'organization_number';
         $customer['customer_ssn'] = $organization['customer_internal'];
         $customer['customer_organization_number'] = $organization['organization_number'];
         $customer['customer_internal'] = $organization['customer_internal'];
     }
     if ($config->config_data['split_pool'] == 'yes') {
         $split = 1;
     } else {
         $split = 0;
     }
     $resources = $event['resources'];
     $activity = $this->organization_bo->so->get_resource_activity($resources);
     $mailadresses = $this->building_users($event['building_id'], $split, $activity);
     if (!$bouser->is_organization_admin($customer['customer_organization_id'])) {
         $date = substr($event['from_'], 0, 10);
         $this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $event['building_id'], 'date' => $date));
     }
     $currres = $event['resources'];
     //            list($event, $errors) = $this->extract_and_validate($event);
     if ($event['customer_organization_number']) {
         $orginfo = $this->bo->so->get_org($event['customer_organization_number']);
         $event['customer_organization_id'] = $orginfo['id'];
         $event['customer_organization_name'] = $orginfo['name'];
     }
     $orgdate = array();
     foreach ($event['dates'] as $odate) {
         if (substr($odate['from_'], 0, 10) == substr($event['from_'], 0, 10)) {
             $orgdate['from'] = $odate['from_'];
             $orgdate['to'] = $odate['to_'];
         }
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $test = $this->bo->read_single($event['id']);
         $event['from_'] = substr($_POST['org_from'], 0, 11) . $_POST['from_'] . ":00";
         $event['to_'] = substr($_POST['org_to'], 0, 11) . $_POST['to_'] . ":00";
         array_set_default($_POST, 'resources', array());
         if ($event['from_'] < $test['from_'] || $event['to_'] > $test['to_']) {
             $errors['out_of_range'] = lang("You can't extend the event, for that contact administrator");
         }
         if (sizeof($currres) != sizeof($_POST['resources'])) {
             $errors['resource_number'] = lang("You can't change resources to the event, for that contact administrator");
         }
         if (!$errors['event'] and !$errors['resource_number'] and !$errors['organization_number'] and !$errors['invoice_data'] && !$errors['contact_name'] && !$errors['out_of_range']) {
             if ($event['from_'] > $test['from_'] || $event['to_'] < $test['to_']) {
                 $this->bo->send_notification(true, $event, $mailadresses, $orgdate);
             }
             $message = '';
             $this->bo->send_admin_notification(true, $event, $message, $orgdate);
             $this->bo->update($event);
             $date = substr($event['from_'], 0, 10);
             $this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $event['building_id'], 'date' => $date));
         }
     }
     $this->flash_form_errors($errors);
     if ($customer['customer_identifier_type']) {
         $event['customer_identifier_type'] = $customer['customer_identifier_type'];
         $event['customer_ssn'] = $customer['customer_ssn'];
         $event['customer_organization_number'] = $customer['customer_organization_number'];
         $event['customer_internal'] = $customer['customer_internal'];
     }
     $date = substr($event['from_'], 0, 10);
     self::add_javascript('booking', 'booking', 'event.js');
     $event['resources_json'] = json_encode(array_map('intval', $event['resources']));
     $event['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $event['building_id'], 'date' => $date));
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     $comments = $this->bo->so->get_ordered_comments($id);
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $audience = $audience['results'];
     $this->install_customer_identifier_ui($event);
     $this->add_template_helpers();
     self::render_template('event_edit', array('event' => $event, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience, 'comments' => $comments));
 }
コード例 #14
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $booking = $this->bo->read_single($id);
     $booking['building'] = $this->building_bo->so->read_single($booking['building_id']);
     $booking['building_name'] = $booking['building']['name'];
     $group = $this->group_bo->read_single($booking['group_id']);
     $errors = array();
     $update_count = 0;
     $today = getdate();
     $step = intval(phpgw::get_var('step', 'POST'));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!($_POST['recurring'] == 'on' || $_POST['outseason'] == 'on')) {
             array_set_default($_POST, 'resources', array());
             $booking = array_merge($booking, extract_values($_POST, $this->fields));
             $this->agegroup_bo->extract_form_data($booking);
             $errors = $this->bo->validate($booking);
             #					if (strtotime($_POST['from_']) < ($today[0]-60*60*24*7*2))
             #					{
             #						$errors['booking'] = lang('You cant edit a booking that is older than 2 weeks');
             #					}
             if (!$errors) {
                 $receipt = $this->bo->update($booking);
                 $this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $booking['building_id']));
             }
         } else {
             $step++;
             if (strtotime($_POST['from_']) < $today[0] - 60 * 60 * 24 * 7 * 2 && $step != 3) {
                 $errors['booking'] = lang('You cant update bookings that is older than 2 weeks');
             }
             if (!$booking['allocation_id'] && $_POST['outseason'] == 'on') {
                 $errors['booking'] = lang('This booking is not connected to a season');
             }
             if (!$errors) {
                 $max_dato = strtotime($_POST['to_']);
                 // highest date from input
                 $season = $this->season_bo->read_single($booking['season_id']);
                 if ($_POST['recurring'] == 'on') {
                     $repeat_until = strtotime($_POST['repeat_until']) + 60 * 60 * 24;
                 } else {
                     $repeat_until = strtotime($season['to_']) + 60 * 60 * 24;
                     $_POST['repeat_until'] = $season['to_'];
                 }
                 $where_clauses[] = sprintf("bb_booking.from_ >= '%s 00:00:00'", date('Y-m-d', strtotime($booking['from_'])));
                 if ($_POST['recurring'] == 'on') {
                     $where_clauses[] = sprintf("bb_booking.to_ < '%s 00:00:00'", date('Y-m-d', $repeat_until));
                 }
                 $where_clauses[] = sprintf("EXTRACT(DOW FROM bb_booking.from_) in (%s)", date('w', strtotime($booking['from_'])));
                 $where_clauses[] = sprintf("EXTRACT(HOUR FROM bb_booking.from_) = %s", date('H', strtotime($booking['from_'])));
                 $where_clauses[] = sprintf("EXTRACT(MINUTE FROM bb_booking.from_) = %s", date('i', strtotime($booking['from_'])));
                 $where_clauses[] = sprintf("EXTRACT(HOUR FROM bb_booking.to_) = %s", date('H', strtotime($booking['to_'])));
                 $where_clauses[] = sprintf("EXTRACT(MINUTE FROM bb_booking.to_) = %s", date('i', strtotime($booking['to_'])));
                 $params['sort'] = 'from_';
                 $params['filters']['where'] = $where_clauses;
                 $params['filters']['season_id'] = $booking['season_id'];
                 $params['filters']['group_id'] = $booking['group_id'];
                 $bookings = $this->bo->so->read($params);
                 if ($step == 2) {
                     $_SESSION['audience'] = $_POST['audience'];
                     $_SESSION['male'] = $_POST['male'];
                     $_SESSION['female'] = $_POST['female'];
                     $_SESSION['from'] = mb_strcut($_POST['from_'], 11, strlen($_POST['from_']));
                     $_SESSION['to'] = mb_strcut($_POST['to_'], 11, strlen($_POST['to_']));
                 }
                 if ($step == 3) {
                     foreach ($bookings['results'] as $b) {
                         //reformatting the post variable to fit the booking object
                         $temp_agegroup = array();
                         $sexes = array('male', 'female');
                         foreach ($sexes as $sex) {
                             $i = 0;
                             foreach ($_SESSION[$sex] as $agegroup_id => $value) {
                                 $temp_agegroup[$i]['agegroup_id'] = $agegroup_id;
                                 $temp_agegroup[$i][$sex] = $value;
                                 $i++;
                             }
                         }
                         $b['agegroups'] = $temp_agegroup;
                         $b['audience'] = $_SESSION['audience'];
                         $b['group_id'] = $_POST['group_id'];
                         $b['activity_id'] = $_POST['activity_id'];
                         $b['from_'] = mb_strcut($b['from_'], 0, 11) . $_SESSION['from'];
                         $b['to_'] = mb_strcut($b['to_'], 0, 11) . $_SESSION['to'];
                         $errors = $this->bo->validate($b);
                         if (!$errors) {
                             $receipt = $this->bo->update($b);
                             $update_count++;
                         }
                     }
                     unset($_SESSION['female']);
                     unset($_SESSION['male']);
                     unset($_SESSION['audience']);
                 }
             }
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('bookingfrontend', 'bookingfrontend', 'booking.js');
     if ($step < 2) {
         $booking['resources_json'] = json_encode(array_map('intval', $booking['resources']));
         $booking['organization_name'] = $group['organization_name'];
     }
     $booking['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $booking['building_id']));
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $audience = $audience['results'];
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     $group = $this->group_bo->so->read_single($booking['group_id']);
     $groups = $this->group_bo->so->read(array('filters' => array('organization_id' => $group['organization_id'], 'active' => 1)));
     $groups = $groups['results'];
     if ($step < 2) {
         self::render_template('booking_edit', array('booking' => $booking, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience, 'groups' => $groups, 'step' => $step, 'repeat_until' => $_POST['repeat_until'], 'recurring' => $_POST['recurring'], 'outseason' => $_POST['outseason']));
     } else {
         if ($step >= 2) {
             self::render_template('booking_edit_preview', array('booking' => $booking, 'bookings' => $bookings, 'agegroups' => $agegroups, 'audience' => $audience, 'groups' => $groups, 'activities' => $activities, 'step' => $step, 'repeat_until' => $_POST['repeat_until'], 'recurring' => $_POST['recurring'], 'outseason' => $_POST['outseason'], 'group_id' => $_POST['group_id'], 'activity_id' => $_POST['activity_id'], 'update_count' => $update_count));
         }
     }
 }
コード例 #15
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $booking = $this->bo->read_single($id);
     $booking['group'] = $this->group_bo->so->read_single($booking['group_id']);
     $booking['organization_id'] = $booking['group']['organization_id'];
     $booking['organization_name'] = $booking['group']['organization_name'];
     $booking['building'] = $this->building_bo->so->read_single($booking['building_id']);
     $booking['building_name'] = $booking['building']['name'];
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_set_default($_POST, 'resources', array());
         $booking = array_merge($booking, extract_values($_POST, $this->fields));
         $booking['allocation_id'] = $booking['allocation_id'] ? $booking['allocation_id'] : null;
         $this->agegroup_bo->extract_form_data($booking);
         $group = $this->group_bo->read_single(intval(phpgw::get_var('group_id', 'GET')));
         $errors = $this->bo->validate($booking);
         if (!$errors) {
             try {
                 $receipt = $this->bo->update($booking);
                 $this->send_mailnotification_to_group($group, lang('Booking changed'), phpgw::get_var('mail', 'POST'));
                 $this->redirect(array('menuaction' => 'booking.uibooking.show', 'id' => $booking['id']));
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not update object due to insufficient permissions');
             }
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'booking.js');
     $booking['resources_json'] = json_encode(array_map('intval', $booking['resources']));
     $booking['cancel_link'] = self::link(array('menuaction' => 'booking.uibooking.show', 'id' => $booking['id']));
     $booking['application_link'] = self::link(array('menuaction' => 'booking.uiapplication.show', 'id' => $booking['application_id']));
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $audience = $audience['results'];
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     self::render_template('booking_edit', array('booking' => $booking, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience));
 }