Example #1
0
 public function importContent()
 {
     echo "Importing data for table {$this->table}:\n";
     $db = Database::getInstance();
     foreach ($this->getContent() as $row) {
         $db->insert($this->table, $row, true);
     }
     echo "Importing complete.\n\n";
 }
Example #2
0
 public function postSave()
 {
     $user = ClientUser::getInstance();
     // Update the user name.
     $user->update(array('first' => Request::get('first'), 'last' => Request::get('last')));
     // Update the password.
     $password = Request::post('password');
     $new_password = Request::post('new_password');
     $new_password_confirm = Request::post('new_password_confirm');
     if (!empty($password) && $user->checkPass($password)) {
         if (false) {
             Messenger::error('Your password did not meet the required criteria.');
         } elseif ($new_password != $new_password_confirm) {
             Messenger::error('You did not enter the same password twice.');
         } else {
             $user->setPass($new_password);
         }
     } elseif (!empty($new_password) || !empty($new_password)) {
         Messenger::error('You did not enter your correct current password.');
     }
     // Update mailing list preferences.
     $new_lists = Request::get('subscribed', 'array', 'int', array());
     $new_lists = array_combine($new_lists, $new_lists);
     $all_lists = Subscription::getLists();
     $user_id = ClientUser::getInstance()->id;
     $user_lists = Subscription::getUserLists($user_id);
     $remove_lists = array();
     foreach ($user_lists as $list) {
         if (empty($new_lists[$list['message_list_id']]) && !empty($list['visible'])) {
             $remove_lists[$list['message_list_id']] = $list['message_list_id'];
         }
     }
     $add_lists = $new_lists;
     unset($add_lists[0]);
     if (!isset($new_lists[0])) {
         foreach ($all_lists as $list) {
             if (empty($list['visible'])) {
                 $remove_lists[$list['message_list_id']] = $list['message_list_id'];
             }
         }
     }
     $db = Database::getInstance();
     if (!empty($remove_lists)) {
         $db->delete('message_list_user', array('message_list_id' => array('IN', $remove_lists), 'user_id' => $user_id));
     }
     if (!empty($add_lists)) {
         $db->insertMultiple('message_list_user', array('message_list_id' => $add_lists, 'user_id' => $user_id), true);
     }
     if (count(Messenger::getErrors()) == 0) {
         Navigation::redirect(null, array('msg' => 'saved'));
     }
 }
Example #3
0
 /**
  * The main page with options to send emails or tests.
  */
 public function get()
 {
     $message_id = Request::get('id', 'int');
     if (!$message_id || !($message = Database::getInstance()->selectRow('message', array('message_id' => $message_id)))) {
         Messenger::error('Message not found.');
         return;
     }
     $template = Template::getInstance();
     $template->set('content', 'mailing_send');
     $template->set('message', $message);
     JS::set('message_id', $message['message_id']);
     JS::addSessionToken();
 }
Example #4
0
 public static function date($name, $settings = array())
 {
     $content = Database::getInstance()->selectRow($settings['table'], array($settings['key'] => $settings['id']), array($settings['column']));
     if ($content) {
         $value = $content[$settings['column']];
     } else {
         $value = '';
     }
     if (ClientUser::getInstance()->isAdmin()) {
         JS::startup('lightning.cms.initDate()');
         JS::set('token', Session::getInstance()->getToken());
         return '<img src="/images/lightning/pencil.png" class="cms_edit_date icon-16" id="cms_edit_' . $settings['id'] . '">' . '<img src="/images/lightning/save.png" class="cms_save_date icon-16" id="cms_save_' . $settings['id'] . '" style="display:none">' . '<span id="cms_' . $settings['id'] . '" style="display:none">' . Time::datePop('cms_' . $settings['id'], $value, 'true', 0) . '</span>' . '<input type="hidden" id="cms_key_' . $settings['id'] . '" value="' . $settings['key'] . '" />' . '<input type="hidden" id="cms_column_' . $settings['id'] . '" value="' . $settings['column'] . '" />' . '<input type="hidden" id="cms_table_' . $settings['id'] . '" value="' . $settings['table'] . '" />';
     } else {
         return $value;
     }
 }
Example #5
0
 public function __construct()
 {
     ClientUser::requireAdmin();
     $list_id = Request::get('list', 'int');
     if ($list_id === 0) {
         Template::getInstance()->set('title', 'Users not on any mailing list.');
         $this->accessTableCondition = array('message_list_id' => array('IS NULL'));
     } elseif ($list_id > 0) {
         $list = Database::getInstance()->selectField('name', 'message_list', array('message_list_id' => $list_id));
         Template::getInstance()->set('title', "Users on list {$list}.");
         $this->accessTableCondition = array('message_list_id' => $list_id);
     } else {
         Template::getInstance()->set('title', 'All users on all lists.');
     }
     parent::__construct();
 }
Example #6
0
 public function getFields()
 {
     // TODO: REQUIRE ADMIN
     $cl = Request::get('criteria_list', 'explode', 'int');
     $output = array();
     if (!empty($cl)) {
         $fields = Database::getInstance()->select('message_criteria', array('message_criteria_id' => array('IN', $cl)));
         foreach ($fields as $f) {
             if (!empty($f['variables'])) {
                 $values = Database::getInstance()->selectRow('message_message_criteria', array('message_id' => Request::get('message_id', 'int'), 'message_criteria_id' => $f['message_criteria_id']));
                 $output[] = array('criteria_id' => $f['message_criteria_id'], 'variables' => explode(',', $f['variables']), 'values' => json_decode($values['field_values']));
             }
         }
     }
     Output::json(array('criteria' => $output));
 }
Example #7
0
 public function execute($job)
 {
     $mailer = new MailerTool();
     $date = new DateTime();
     $time = $date->getTimestamp();
     $start = $job['last_start'] + $date->getOffset();
     $end = $time + $date->getOffset();
     // Load all messages that should be sent on a specific date.
     $messages = Database::getInstance()->selectColumn('message', 'message_id', ['send_date' => ['BETWEEN', $start, $end]]);
     foreach ($messages as $message_id) {
         $start_time = time();
         $this->out("Sending message {$message_id}");
         $count = $mailer->sendBulk($message_id, false, true);
         $time = Time::formatLength(time() - $start_time);
         $this->out("Message {$message_id} sent to {$count} users in {$time}");
     }
 }
Example #8
0
 public function execute()
 {
     // Load the bounce handler.
     require_once HOME_PATH . '/Lightning/Vendor/BounceHandler/src/BounceHandler.php';
     $bounce_handler = new \cfortune\PHPBounceHandler\BounceHandler();
     // Parse the message.
     $bounce_info = $bounce_handler->get_the_facts(file_get_contents('php://stdin'));
     // If this was a message failure.
     if (!empty($bounce_info[0]['recipient']) && preg_match('/5\\.\\d\\.\\d/', $bounce_info[0]['status'])) {
         $email = $bounce_info[0]['recipient'];
         $user = User::loadByEmail($email);
         if (!$user) {
             // Bounced from an unknown recipient, ignore this.
             Tracker::trackEvent('Email Bounced', 0, 0);
             return;
         }
         // Track the bounced event.
         // TODO: we can scan the email for a link to see if we know the message id.
         Tracker::trackEvent('Email Bounced', 0, $user->user_id);
         // Get the last 6 send/bounce events.
         // TODO: Also check for a reactivation email.
         $mail_history = Database::getInstance()->select('tracker_event', array('user_id' => $user->user_id, 'tracker_id' => array('IN', array(Tracker::getTrackerId('Email Sent'), Tracker::getTrackerId('Email Bounced')))), array(), 'ORDER BY date DESC LIMIT 6');
         $bounce_count = 0;
         $bounce_id = Tracker::getTrackerId('Email Bounced');
         foreach ($mail_history as $history) {
             if ($history['tracker_id'] == $bounce_id) {
                 $bounce_count++;
             }
         }
         // If there are two bounced messages, deactivate the user.
         if ($bounce_count >= 2) {
             // TODO: Instead of '1' here, we should have a table like `tracker`
             // that tracks tracker sub_ids by name.
             Tracker::trackEvent('Deactivate User', 1, $user->user_id);
             $user->unsubscribeAll();
         }
     }
 }
Example #9
0
 protected function customImportPostProcess(&$values, &$ids)
 {
     static $mailing_list_id;
     $db = Database::getInstance();
     if (!isset($mailing_list_id)) {
         if (!($mailing_list_id = Request::get('message_list_id', 'int'))) {
             // No default list was selected
             if ($new_list = trim(Request::get('new_message_list'))) {
                 $mailing_list_id = $db->insert('message_list', ['name' => $new_list]);
             } else {
                 $mailing_list_id = false;
             }
         }
     }
     $time = time();
     // This will only update users that were just added.
     $db->update('user', ['created' => $time], ['user_id' => ['IN', $ids]]);
     // This will add all the users to the mailing list.
     if (!empty($mailing_list_id)) {
         $user_ids = $db->selectColumn('user', 'user_id', ['email' => ['IN', $values['email']]]);
         $db->insertMultiple('message_list_user', ['user_id' => $user_ids, 'message_list_id' => $mailing_list_id, 'time' => $time], true);
     }
 }
Example #10
0
 public function conformSchema()
 {
     echo "Conforming {$this->table}:\n";
     $this->loadSchema();
     $db = Database::getInstance();
     $this->table_exists = $db->tableExists($this->table);
     if ($this->table_exists) {
         //            foreach ($this->getKeys() as $key => $settings) {
         //                if (!empty($this->current_keys[$key])) {
         //                    if ($this->keysMatch($this->current_keys[$key])) {
         //                        continue;
         //                    }
         //                    else {
         //                        $db->dropIndex($this->table, $key);
         //                    }
         //                }
         //                $db->query();
         //            }
     } else {
         echo "Creating table:\n";
         $db->createTable($this->table, $this->getColumns(), $this->getKeys());
     }
     echo "Conforming complete.\n\n";
 }
Example #11
0
 /**
  * Upgrades users by assigning them roles at the base of their type field's value
  */
 public function postUpgradeRoles()
 {
     $users = Database::getInstance()->selectAll(array('from' => 'user', 'join' => array(array('LEFT JOIN', 'user_role', 'ON user_role.user_id = user.user_id'))), array(), array('user.user_id', 'user.type', 'user_role.role_id'));
     // because of we add new role, roles numbers are differ from user.types
     // so we use this array to make their conformity
     $typesToRoles = array('3' => 2, '4' => 3, '5' => 1);
     // assigning roles
     $i = 0;
     foreach ($users as $user) {
         // if role not set yet
         if (empty($user['role_id'])) {
             // insert
             if (array_key_exists($user['type'], $typesToRoles)) {
                 if (empty($user['role_id']) or $user['role_id'] == NULL) {
                     $values = array('role_id' => $typesToRoles[$user['type']], 'user_id' => $user['user_id']);
                     Database::getInstance()->insert('user_role', $values);
                     $i++;
                 }
             }
         }
     }
     Messenger::message(" {$i} users was upgraded!");
     return $this->get();
 }
Example #12
0
 public function postUpdateDate()
 {
     if (ClientUser::getInstance()->isAdmin()) {
         $id = Request::post('id');
         $key = Request::post('key');
         $column = Request::post('column');
         $table = Request::post('table');
         $m = Request::post("date_m");
         $d = Request::post("date_d");
         $y = Request::post("date_y");
         if ($m > 0 && $d > 0) {
             if ($y == 0) {
                 $y = date("Y");
             }
             $value = gregoriantojd($m, $d, $y);
         } else {
             $value = 0;
         }
         Database::getInstance()->update($table, array($column => $value), array($key => $id));
         Output::json(Output::SUCCESS);
     } else {
         Output::json(Output::ACCESS_DENIED);
     }
 }
Example #13
0
 protected function afterDelete($deleted_id)
 {
     // Clean up user connections for this list.
     Database::getInstance()->delete('message_list_user', array('message_list_id' => $deleted_id));
 }
Example #14
0
 /**
  * When a user logs in to an existing account from a temporary anonymous session, this
  * moves the data over to the user's account.
  *
  * @param $anon_user
  */
 public function merge_users($anon_user)
 {
     // FIRST MAKE SURE THIS USER IS ANONYMOUS
     if (Database::getInstance()->check('user', array('user_id' => $anon_user, 'email' => ''))) {
         // TODO: Basic information should be moved here, but this function should be overriden.
         Database::getInstance()->delete('user', array('user_id' => $anon_user));
     }
 }
Example #15
0
 /**
  * Convert a zipcode to a long/lat array.
  *
  * @param string $zip
  *   The zip code.
  *
  * @return array
  *   The longitude and latitude.
  */
 public static function zipToCoordinates($zip)
 {
     return Database::getInstance()->selectRow('zipcode', array('zip' => $zip));
 }
Example #16
0
 public function post()
 {
     $blog_id = Request::get('id', 'int') | Request::get('blog_id', 'int');
     $action = Request::get('action');
     // AUTHORIZE A BLOG COMMENT.
     switch ($action) {
         case 'post_comment_check':
             echo md5($_POST['email'] . $_POST['name'] . $_POST['comment']);
             exit;
         case 'post_comment':
             // FIRST CHECK FOR SPAM
             if ($_POST['check_val'] == md5($_POST['email'] . $_POST['name'] . $_POST['comment'])) {
                 $values = array('blog_id' => $blog_id, 'ip_address' => Request::server('ip_int'), 'email_address' => Request::post('email', 'email'), 'name' => Request::post('name'), 'comment' => Request::post('comment'), 'time' => time());
                 Database::getInstance()->insert('blog_comment', $values);
                 echo "success";
             } else {
                 echo "spam error";
             }
             exit;
         case 'remove_blog_comment':
             $user = ClientUser::getInstance();
             if ($user->isAdmin() && $_POST['blog_comment_id'] > 0) {
                 Database::getInstance()->delete('blog_comment', array('blog_comment_id' => Request::post('blog_comment_id', 'int')));
                 echo "ok";
             } else {
                 echo "access denied";
             }
             exit;
         case 'approve_blog_comment':
             $user = ClientUser::getInstance();
             if ($user->isAdmin() && $_POST['blog_comment_id'] > 0) {
                 Database::getInstance()->update('blog_comment', array('approved' => 1), array('blog_comment_id' => Request::post('blog_comment_id', 'int')));
                 echo "ok";
                 exit;
             }
     }
 }
Example #17
0
 public static function getUserLists($user_id)
 {
     return Database::getInstance()->selectIndexed(array('from' => 'message_list_user', 'join' => array('JOIN', 'message_list', 'USING(message_list_id)')), 'message_list_id', array('user_id' => $user_id));
 }
Example #18
0
 public static function getHistoryAllSubIDs($tracker, $start = -30, $end = 0, $user_id = -1)
 {
     // Start the criteria with tracker id.
     if (is_array($tracker)) {
         $criteria = array('tracker_id' => array('IN', $tracker));
     } else {
         $criteria = array('tracker_id' => $tracker);
     }
     // Filter by date range.
     $start = Time::today() + $start;
     $end = Time::today() + $end;
     $criteria['date'] = array('BETWEEN', $start, $end);
     // Add the user ID if required.
     if ($user_id != -1) {
         $criteria['user_id'] = $user_id;
     }
     // Run the query.
     $results = Database::getInstance()->select('tracker_event', $criteria, array('y' => array('expression' => 'COUNT(*)'), 'x' => 'date', 'set' => 'sub_id'), 'GROUP BY date, sub_id');
     $data = new ChartData($start, $end);
     $data->createDataSets($results);
     return $data->getData();
 }
Example #19
0
 public static function selectAllPages()
 {
     return Database::getInstance()->select('page', array('site_map' => 1));
 }
Example #20
0
 public function setTemplate($template_id)
 {
     $this->template = Database::getInstance()->selectRow('message_template', array('template_id' => $template_id));
 }
Example #21
0
 /**
  * Load the test users into the user array.
  */
 protected function loadTestUsers()
 {
     // Load the test users.
     $users = Configuration::get('mailer.test');
     if (empty($users)) {
         $this->users = array();
     } else {
         $this->users = Database::getInstance()->selectAll('user', array('email' => array('IN', $users)));
     }
     // Load the spam test users.
     $spam_test_from = Configuration::get('spam_test_from');
     $spam_test_emails = Configuration::get('mailer.spam_test');
     if (is_array($spam_test_emails)) {
         foreach ($spam_test_emails as $spam_test) {
             $this->users[] = array('email' => $spam_test, 'first' => 'Spam', 'last' => 'Test', 'from' => $spam_test_from, 'user_id' => 0, 'salt' => 'na');
         }
     }
 }
Example #22
0
 /**
  * Get the database object associated with this object. This allows
  * an object to be overidden with a child object.
  *
  * @return Database
  *   The DB object.
  */
 public static function getDatabase()
 {
     return Database::getInstance();
 }
Example #23
0
 public function postSave()
 {
     $user = ClientUser::getInstance();
     if (!$user->isAdmin()) {
         return $this->get();
     }
     $page_id = Request::post('page_id', 'int');
     $title = Request::post('title');
     $url = Request::post('url', 'url');
     // Create an array of the new values.
     $new_values = array('title' => $title, 'url' => !empty($url) ? $url : Scrub::url($title), 'keywords' => Request::post('keywords'), 'description' => Request::post('description'), 'site_map' => Request::post('sitemap', 'int'), 'body' => Request::post('page_body', 'html', '', '', true), 'last_update' => time(), 'layout' => Request::post('layout', 'int'));
     // Save the page.
     if ($page_id != 0) {
         Database::getInstance()->update('page', $new_values, array('page_id' => $page_id));
     } else {
         $page_id = Database::getInstance()->insert('page', $new_values);
     }
     $output = array();
     $output['url'] = $new_values['url'];
     $output['page_id'] = $page_id;
     $output['title'] = $title;
     Output::json($output);
 }
Example #24
0
 public static function getSitemapUrls()
 {
     $web_root = Configuration::get('web_root');
     $blogs = Database::getInstance()->select(['from' => static::BLOG_TABLE, 'join' => ['LEFT JOIN', ['from' => static::COMMENT_TABLE, 'as' => static::COMMENT_TABLE, 'fields' => ['time', 'blog_id'], 'order' => ['time' => 'DESC']], 'USING ( blog_id )']], [], [[static::BLOG_TABLE => ['blog_time' => 'time']], [static::COMMENT_TABLE => ['blog_comment_time' => 'time']], 'url'], 'GROUP BY blog_id');
     $urls = array();
     foreach ($blogs as $b) {
         $urls[] = array('loc' => $web_root . "/{$b['url']}.htm", 'lastmod' => date("Y-m-d", max($b['blog_time'], $b['blog_comment_time']) ?: time()), 'changefreq' => 'yearly', 'priority' => 0.3);
     }
     return $urls;
 }
Example #25
0
 /**
  * Save the current session data.
  */
 public function saveData()
 {
     Database::getInstance()->update('session', array('content' => json_encode($this->content)), array('session_id' => $this->id));
 }
Example #26
0
 /**
  * Render the edit field component.
  *
  * @param array $field
  *   The field settings.
  * @param array $row
  *   The data row.
  *
  * @return string
  *   The rendered HTML.
  */
 protected function renderEditField($field, &$row = array())
 {
     // Make sure the form_field is set.
     if (!isset($field['form_field'])) {
         $field['form_field'] = $field['field'];
     }
     // Get the default field value.
     if (!empty($_POST)) {
         $v = Request::post($field['form_field']);
     } elseif (empty($row)) {
         $v = isset($field['default']) ? $field['default'] : '';
     } elseif (isset($field['edit_value'])) {
         if (is_callable($field['edit_value'])) {
             $v = $row[] = $field['edit_value']($row);
         } else {
             $v = $row[] = $field['edit_value'];
         }
     } elseif (!empty($row[$field['field']])) {
         $v = $row[$field['field']];
     }
     if (isset($this->preset[$field['field']]['render_' . $this->action . '_field'])) {
         $this->get_row(false);
         return $this->preset[$field['field']]['render_' . $this->action . '_field']($this->list);
     }
     // Prepare value.
     if (!isset($field['Value'])) {
         $field['Value'] = isset($v) ? $v : null;
     }
     if (!empty($field['encrypted'])) {
         $field['Value'] = $this->decrypt($field['Value']);
     }
     // Set the default value if new.
     if ($this->action == "new" && isset($field['default'])) {
         $field['Value'] = $field['default'];
     }
     // Print form input.
     $options = array();
     $return = '';
     switch (preg_replace('/\\([0-9]+\\)/', '', $field['type'])) {
         case 'text':
         case 'mediumtext':
         case 'longtext':
         case 'html':
             $config = array();
             $editor = !empty($field['editor']) ? strtolower($field['editor']) : 'default';
             switch ($editor) {
                 case 'full':
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Full";
                     break;
                 case 'print':
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Print";
                     break;
                 case 'basic_image':
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Basic_Image";
                     break;
                 case 'basic':
                 default:
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Basic";
                     break;
             }
             if (!empty($field['full_page'])) {
                 $config['fullPage'] = true;
                 $config['allowedContent'] = true;
             }
             if (!empty($field['height'])) {
                 $config['height'] = $field['height'];
             }
             if (!empty($field['upload'])) {
                 $config['finder'] = true;
             }
             return CKEditor::iframe($field['form_field'], $field['Value'], $config);
             break;
         case 'div':
             if ($field['Value'] == '') {
                 $field['Value'] = "<p></p>";
             }
             return "<input type='hidden' name='{$field['form_field']}' id='{$field['form_field']}' value='" . $this->convert_quotes($field['Value']) . "' />\n\t\t\t\t\t\t\t<div id='{$field['form_field']}_div' spellcheck='true'>{$field['Value']}</div>";
             break;
         case 'plaintext':
             return "<textarea name='{$field['form_field']}' id='{$field['form_field']}' spellcheck='true' cols='90' rows='10'>{$field['Value']}</textarea>";
             break;
         case 'hidden':
             return "<input type='hidden' name='{$field['form_field']}' id='{$field['form_field']}' value='" . $this->convert_quotes($field['Value']) . "' />";
             break;
         case 'image':
             if (!empty($field['Value'])) {
                 $return .= '<img src="' . $this->getImageLocationWeb($field, $field['Value']) . '" class="table_edit_image" />';
             }
             // Fall through.
         // Fall through.
         case 'file':
             if ($field['Value'] != '' && (!isset($field['replaceable']) || empty($field['replaceable'])) || $field['Value'] == '') {
                 $return .= "<input type='file' name='{$field['form_field']}' id='{$field['form_field']}' />";
             }
             return $return;
             break;
         case 'time':
             return Time::timePop($field['form_field'], $field['Value'], !empty($field['allow_blank']));
             break;
         case 'date':
             $return = Time::datePop($field['form_field'], !empty($field['Value']) ? $field['Value'] : 0, !empty($field['allow_blank']), !empty($field['start_year']) ? $field['start_year'] : 0);
             return $return;
             break;
         case 'datetime':
             return Time::dateTimePop($field['form_field'], $field['Value'], !empty($field['allow_blank']), isset($field['start_year']) ? $field['start_year'] : date('Y') - 10);
             break;
         case 'lookup':
         case 'yesno':
         case 'state':
         case 'country':
         case 'select':
             if ($field['type'] == 'lookup') {
                 $options = Database::getInstance()->selectColumn($field['lookuptable'], $field['display_column'], !empty($field['filter']) ? $field['filter'] : array(), !empty($field['lookupkey']) ? $field['lookupkey'] : $field['field']);
             } elseif ($field['type'] == "yesno") {
                 $options = array(1 => 'No', 2 => 'Yes');
             } elseif ($field['type'] == "state") {
                 $options = Location::getStateOptions();
             } elseif ($field['type'] == "country") {
                 $options = Location::getCountryOptions();
             } else {
                 $options = $field['options'];
             }
             if (!is_array($options)) {
                 return false;
             }
             if (!empty($field['allow_blank'])) {
                 $options = array('' => '') + $options;
             }
             $output = BasicHTML::select($field['form_field'], $options, $field['Value']);
             if (!empty($field['pop_add'])) {
                 if ($field['table_url']) {
                     $location = $field['table_url'];
                 } else {
                     $location = "table.php?table=" . $field['lookuptable'];
                 }
                 $output .= "<a onclick='lightning.table.newPop(\"{$location}\",\"{$field['form_field']}\",\"{$field['display_column']}\")'>Add New Item</a>";
             }
             return $output;
             break;
         case 'range':
             $output = "<select name='{$field['form_field']}' id='{$field['form_field']}'>";
             if ($field['allow_blank']) {
                 $output .= '<option value="0"></option>';
             }
             if ($field['start'] < $field['end']) {
                 for ($k = $field['start']; $k <= $field['end']; $k++) {
                     $output .= "<option value='{$k}'" . ($field['Value'] == $k ? 'selected="selected"' : '') . ">{$k}</option>";
                 }
             }
             $output .= '</select>';
             return $output;
             break;
         case 'checkbox':
             return "<input type='checkbox' name='{$field['form_field']}' id='{$field['form_field']}' value='1' " . ($field['Value'] == 1 ? "checked" : '') . " />";
             break;
         case 'note':
             return $field['note'];
             break;
         case 'checklist':
             $vals = $this->decode_bool_group($field['Value']);
             $output = '';
             foreach ($field['options'] as $i => $opt) {
                 if (is_array($opt)) {
                     $id = $opt[0];
                     $name = $opt[1];
                 } else {
                     $id = $i;
                     $name = $opt;
                 }
                 $output .= "<div class='checlist_item'><input type='checkbox' name='{$field['form_field']}_{$id}' value='1' " . ($vals[$id] == 1 ? "checked" : '') . " />{$name}</div>";
             }
             return $output;
             break;
         case 'varchar':
         case 'char':
             preg_match('/(.+)\\(([0-9]+)\\)/i', $field['type'], $array);
             $options['size'] = $array[2];
         default:
             if (!empty($field['autocomplete'])) {
                 $options['classes'] = array('table_autocomplete');
                 $options['autocomplete'] = false;
             }
             return Text::textfield($field['form_field'], $field['Value'], $options);
             break;
     }
 }
Example #27
0
echo $message;
?>
</li><? endforeach; ?></ul>
                            </div>
                        <?
                        endif;
                        if (!empty($content)) :
                            $this->build($content);
                        endif; ?>
                    </div>
                <? endif; ?>
            </div>
            <pre>
            <?
            if (ClientUser::getInstance()->isAdmin()) {
                $database = Database::getInstance();
                print_r($database->getQueries());
                print_r($database->timeReport());
            }
            ?>
            </pre>
        </section>
    </div>
</div>
<?php 
echo JS::render();
echo CSS::render();
echo $this->renderFooter();
?>
</body>
</html>
Example #28
0
    protected static function jsonOut($output) {
        // Send the cookies if enabled.
        if (static::$jsonCookies) {
            self::sendCookies();
        }

        // Add debug data.
        if (Configuration::get('debug')) {
            $database = Database::getInstance();
            $output['database'] = array(
                'queries' => $database->getQueries(),
                'time' => $database->timeReport(),
            );
        }

        // Output the data.
        header('Content-type: application/json');
        echo json_encode($output);
        exit;
    }