Permalink
Browse files

Small cleanups & simplifications

  • Loading branch information...
flack committed Jan 11, 2019
1 parent 259fa62 commit 709b7a1d5e6bd203c41dd616ec449f0319935c9d
Showing with 82 additions and 107 deletions.
  1. +1 −1 lib/midcom/config/test.php
  2. +1 −1 lib/midcom/core/dbaobject.php
  3. +1 −1 lib/midcom/cron/purgedeleted.php
  4. +2 −2 lib/midcom/helper/_dbfactory.php
  5. +2 −2 lib/midcom/helper/_styleloader.php
  6. +1 −1 lib/midcom/helper/exporter/xml.php
  7. +3 −3 lib/midcom/helper/misc.php
  8. +1 −1 lib/midcom/helper/toolbar.php
  9. +1 −1 lib/midcom/response/relocate.php
  10. +3 −3 lib/midcom/services/rcs/backend/rcs.php
  11. +1 −5 lib/midgard/admin/asgard/copytree.php
  12. +2 −2 lib/midgard/admin/asgard/handler/type.php
  13. +1 −5 lib/midgard/admin/user/style/midgard-admin-user-generate-passwords.php
  14. +4 −7 lib/net/nehmer/blog/handler/archive.php
  15. +0 −3 lib/net/nehmer/blog/handler/feed.php
  16. +2 −2 lib/net/nehmer/blog/style/feeds-item.php
  17. +4 −4 lib/net/nehmer/blog/style/index-item.php
  18. +2 −2 lib/net/nemein/tag/handler.php
  19. +1 −1 lib/net/nemein/wiki/handler/view.php
  20. +1 −1 lib/net/nemein/wiki/viewer.php
  21. +2 −2 lib/org/openpsa/calendar/handler/calendar.php
  22. +4 −4 lib/org/openpsa/calendar/handler/event/view.php
  23. +1 −1 lib/org/openpsa/calendar/handler/ical.php
  24. +1 −1 lib/org/openpsa/calendar/midcom/interfaces.php
  25. +1 −1 lib/org/openpsa/contacts/duplicates/check.php
  26. +1 −6 lib/org/openpsa/core/acl/synchronizer.php
  27. +2 −3 lib/org/openpsa/core/filter/select.php
  28. +2 −2 lib/org/openpsa/directmarketing/handler/campaign/rules.php
  29. +1 −1 lib/org/openpsa/directmarketing/handler/logger.php
  30. +2 −2 lib/org/openpsa/directmarketing/handler/message/report.php
  31. +1 −1 lib/org/openpsa/directmarketing/sender/backend/email.php
  32. +1 −1 lib/org/openpsa/documents/handler/document/admin.php
  33. +1 −1 lib/org/openpsa/expenses/handler/index.php
  34. +1 −1 lib/org/openpsa/expenses/style/hours_grid.php
  35. +2 −2 lib/org/openpsa/invoices/style/show-items.php
  36. +2 −2 lib/org/openpsa/mail/message.php
  37. +1 −1 lib/org/openpsa/mypage/handler/workingon.php
  38. +2 −2 lib/org/openpsa/projects/style/show-frontpage.php
  39. +1 −1 lib/org/openpsa/qbpager/main.php
  40. +4 −4 lib/org/openpsa/relatedto/handler/relatedto.php
  41. +4 −4 lib/org/openpsa/relatedto/plugin.php
  42. +2 −2 lib/org/openpsa/reports/handler/base.php
  43. +0 −1 lib/org/openpsa/reports/handler/projects/report.php
  44. +0 −3 lib/org/openpsa/slideshow/handler/edit.php
  45. +7 −8 lib/org/openpsa/user/accounthelper.php
  46. +2 −2 lib/org/openpsa/user/validator.php
@@ -14,7 +14,7 @@
class midcom_config_test
{
const OK = 0;
const WARNING = 1;
const WARNING = 1;
const ERROR = 2;
private $messages = [
@@ -536,7 +536,7 @@ public function disable_rcs()
}
public function enable_rcs()
{
$this->_use_rcs = true;
$this->_use_rcs = true;
}
public function set_rcs_message($msg)
{
@@ -75,7 +75,7 @@ public function process_class($mgdschema)
foreach ($qb->iterate() as $obj) {
$stats['found']++;
if (!$obj->purge()) {
$stats['errors'][] = "Failed to purge {$obj->guid}, deleted: {$obj->metadata->deleted}, revised: {$obj->metadata->revised}. errstr: " . midcom_connection::get_error_string();
$stats['errors'][] = "Failed to purge {$obj->guid}, deleted: {$obj->metadata->deleted}, revised: {$obj->metadata->revised}. errstr: " . midcom_connection::get_error_string();
debug_print_r('Purge failed for object', $obj);
continue;
}
@@ -47,7 +47,7 @@ public function get_object_by_guid($guid)
throw new midcom_error_midgard($e, $guid);
}
$person_class = midcom::get()->config->get('person_class');
$person_class = midcom::get()->config->get('person_class');
if ( get_class($tmp) == 'midgard_person'
&& $person_class != 'midgard_person') {
$tmp = new $person_class($guid);
@@ -419,7 +419,7 @@ private function _get_parent_candidates($classname)
&& $reflector->get_link_target($parent_property)) {
$target_class = $reflector->get_link_name($parent_property);
if ($target_class == 'midgard_person') {
$person_class = midcom::get()->config->get('person_class');
$person_class = midcom::get()->config->get('person_class');
if ($person_class != 'midgard_person') {
$target_class = $person_class;
}
@@ -444,7 +444,7 @@ private function _get_element_from_snippet($_element)
$current_context = midcom_core_context::get()->id;
foreach ($this->_styledirs[$current_context] as $path) {
$filename = $path . "/{$_element}.php";
$filename = $path . "/{$_element}.php";
if (file_exists($filename)) {
$this->_snippets[$filename] = file_get_contents($filename);
return $this->_snippets[$filename];
@@ -644,7 +644,7 @@ private function _merge_styledirs($component_style)
/* then the contextstyle */
$this->_styledirs[$current_context][count($this->_styledirs[$current_context])] = $component_style;
$this->_styledirs[$current_context] = array_merge($this->_styledirs[$current_context], $this->_styledirs_append[$current_context]);
$this->_styledirs[$current_context] = array_merge($this->_styledirs[$current_context], $this->_styledirs_append[$current_context]);
}
/**
@@ -60,7 +60,7 @@ private function _xml_to_array(SimpleXMLIterator $sxi)
*/
public function array2data(array $array, $root_node = 'array', $prefix = '')
{
$data = "{$prefix}<{$root_node}>\n";
$data = "{$prefix}<{$root_node}>\n";
foreach ($array as $key => $field) {
if (is_numeric($key)) {
@@ -377,13 +377,13 @@ public static function get_element_content($element_name, $theme_root = OPENPSA2
$theme_path = implode('/', $path_array);
$candidates = [];
if ($substyle) {
$candidates[] = $theme_root . $theme_path . "/style/{$substyle}/{$element_name}.php";
$candidates[] = $theme_root . $theme_path . "/style/{$substyle}/{$element_name}.php";
}
if ($page) {
$candidates[] = $theme_root . $theme_path . "/style{$page}/{$element_name}.php";
$candidates[] = $theme_root . $theme_path . "/style{$page}/{$element_name}.php";
}
$candidates[] = $theme_root . $theme_path . "/style/{$element_name}.php";
$candidates[] = $theme_root . $theme_path . "/style/{$element_name}.php";
foreach (array_filter($candidates, 'file_exists') as $candidate) {
return file_get_contents($candidate);
@@ -565,7 +565,7 @@ public function render()
foreach ($visible_items as $i => $item) {
$output .= '<li class="';
if ($i == 0) {
$output .= $first_class . ' ';
$output .= $first_class . ' ';
} elseif ($i == $last) {
$output .= 'last_item ';
}
@@ -35,7 +35,7 @@ public function send()
if ($prefix == '') {
$prefix = '/';
}
$this->url = "{$prefix}{$this->url}";
$this->url = "{$prefix}{$this->url}";
debug_add("This is a relative URL from the local site, prepending anchor prefix: {$this->url}");
}
$location = "Location: {$this->url}";
@@ -86,7 +86,7 @@ public function rcs_update($object, $message)
}
$filename = $this->_generate_rcs_filename($object->guid);
$rcsfilename = "{$filename},v";
$rcsfilename = "{$filename},v";
if (!file_exists($rcsfilename)) {
// The methods return basically what the RCS unix level command returns, so nonzero value is error and zero is ok...
@@ -121,7 +121,7 @@ public function get_revision($revision)
// , must become . to work. Therefore this:
str_replace(',', '.', $revision);
$this->exec('co -q -f -r' . escapeshellarg(trim($revision)) . " {$filepath} 2>/dev/null");
$this->exec('co -q -f -r' . escapeshellarg(trim($revision)) . " {$filepath} 2>/dev/null");
$data = $this->rcs_readfile($this->_guid);
@@ -262,7 +262,7 @@ private function rcs_parse_history_entry($entry)
if ($message_array[0] != 'Object') {
$history['user'] = $message_array[0];
}
$history['ip'] = $message_array[1];
$history['ip'] = $message_array[1];
$history['message'] = $message_array[2];
}
return $history;
@@ -91,11 +91,7 @@ protected function _draw_element($object, $label, $level = 0, $autoexpand = fals
$label = "#{$object->id}";
}
if ($this->copy_tree) {
$checked = ' checked="checked"';
} else {
$checked = '';
}
$checked = ($this->copy_tree) ? ' checked="checked"' : '';
if ($this->inputs) {
// This value is used for compiling the exclusion list: if the object is found from this list, but not from the selection list,
@@ -104,8 +104,8 @@ private function _find_component()
}
$help = new midcom_admin_help_help();
$this->_request_data['help'] = $help->get_help_contents('asgard_'.$this->type, $help_component);
$this->_request_data['component'] = $component;
$this->_request_data['help'] = $help->get_help_contents('asgard_'.$this->type, $help_component);
$this->_request_data['component'] = $component;
}
/**
@@ -4,11 +4,7 @@
$max_amount = 100;
$max_length = 16;
if (isset($_GET['f_submit'])) {
$no_similars = false;
} else {
$no_similars = true;
}
$no_similars = !isset($_GET['f_submit']);
extract($_GET);
@@ -275,7 +275,7 @@ public function _handler_list($handler_id, array $args, array &$data)
&& !$data['datamanager']->get_schema('default')->get_field('categories')['type_config']['allow_multiple']) {
$qb->add_constraint('extra1', '=', (string) $data['category']);
} else {
$qb->add_constraint('extra1', 'LIKE', "%|{$this->_request_data['category']}|%");
$qb->add_constraint('extra1', 'LIKE', "%|{$data['category']}|%");
}
//Fall-through
@@ -290,9 +290,6 @@ public function _handler_list($handler_id, array $args, array &$data)
case 'archive-month':
$this->_set_startend_from_month($args[0], $args[1]);
break;
default:
throw new midcom_error("The request handler {$handler_id} is not supported.");
}
$qb->add_constraint('metadata.published', '>=', $this->_start->format('Y-m-d H:i:s'));
@@ -369,9 +366,9 @@ private function _set_startend_from_month($year, $month)
}
$now = new DateTime();
$this->_start = new DateTime("{$year}-" . sprintf('%02d', $month) . "-01 00:00:00");
$this->_start = new DateTime("{$year}-" . sprintf('%02d', $month) . "-01 00:00:00");
if ($this->_start > $now) {
throw new midcom_error_notfound("The month '{$year}-" . sprintf('%02d', $month) . "' is in the future, no archive available.");
throw new midcom_error_notfound("The month '{$year}-" . sprintf('%02d', $month) . "' is in the future, no archive available.");
}
if ($month == 12) {
@@ -382,7 +379,7 @@ private function _set_startend_from_month($year, $month)
$endmonth = $month + 1;
}
$this->_end = new DateTime("{$endyear}-" . sprintf('%02d', $endmonth) . "-01 00:00:00");
$this->_end = new DateTime("{$endyear}-" . sprintf('%02d', $endmonth) . "-01 00:00:00");
}
/**
@@ -116,9 +116,6 @@ private function _create_feed($handler_id)
$this->_feed->title = sprintf($this->_l10n->get('%s category %s'), $this->_feed->title, $this->_request_data['category']);
$this->_feed->syndicationURL = "{$this->_feed->link}feeds/category/{$this->_request_data['category']}";
break;
default:
throw new midcom_error("The feed handler {$handler_id} is unsupported");
}
}
@@ -34,12 +34,12 @@
$item->description = '';
if ($data['article']->abstract != '') {
$item->description .= '<div class="abstract">' . $view['abstract']. '</div>';
$item->description .= '<div class="abstract">' . $view['abstract'] . '</div>';
}
if ( array_key_exists('image', $view)
&& $data['config']->get('rss_use_image')) {
$item->description .= "\n<div class=\"image\">" . $view['image'] .'</div>';
$item->description .= "\n<div class=\"image\">" . $view['image'] . '</div>';
}
if ($data['config']->get('rss_use_content')) {
@@ -13,12 +13,12 @@
if (array_key_exists('ajax_comments_enable', $data)) {
$published .= ' <a href="#switch_comments" onClick="showAjaxComments(this, \''.$data['article']->guid.'\'); return false;">'
.sprintf($data['l10n']->get('%s comments'), net_nehmer_comments_comment::count_by_objectguid($data['article']->guid))
."</a>.";
. sprintf($data['l10n']->get('%s comments'), net_nehmer_comments_comment::count_by_objectguid($data['article']->guid))
. "</a>.";
} elseif (array_key_exists('comments_enable', $data)) {
$published .= " <a href=\"{$data['local_view_url']}#net_nehmer_comments_{$data['article']->guid}\">"
.sprintf($data['l10n']->get('%s comments'), net_nehmer_comments_comment::count_by_objectguid($data['article']->guid))
."</a>.";
. sprintf($data['l10n']->get('%s comments'), net_nehmer_comments_comment::count_by_objectguid($data['article']->guid))
. "</a>.";
}
?>

@@ -68,7 +68,7 @@ private static function _create_tag($tagname, $url, $object, $component)
$tagstring = self::resolve_tagname($tagname);
$tag = net_nemein_tag_tag_dba::get_by_tag($tagstring);
if (!$tag) {
$tag = new net_nemein_tag_tag_dba();
$tag = new net_nemein_tag_tag_dba();
$tag->tag = $tagstring;
$tag->url = $url;
if (!$tag->create()) {
@@ -77,7 +77,7 @@ private static function _create_tag($tagname, $url, $object, $component)
return;
}
}
$link = new net_nemein_tag_link_dba();
$link = new net_nemein_tag_link_dba();
$link->tag = $tag->id;
$link->context = self::resolve_context($tagname);
$link->value = self::resolve_value($tagname);
@@ -244,7 +244,7 @@ private function _autogenerate_toc($content)
}
}
}
$toc .= "<li class='{$heading_tag}'><a href='#{$anchor}'>" . strip_tags($heading) . "</a>";
$toc .= "<li class='{$heading_tag}'><a href='#{$anchor}'>" . strip_tags($heading) . "</a>";
}
for ($i = $current_list_level; $i > 0; $i--) {
$toc .= "</li>\n</ol>\n";
@@ -41,7 +41,7 @@ public function _on_handle($handler_id, array $args)
MIDCOM_TOOLBAR_POST => true,
MIDCOM_TOOLBAR_POST_HIDDENARGS => [
$action => 1,
'target' => 'folder',
'target' => 'folder',
]
]);
}
@@ -64,7 +64,7 @@ public function _handler_calendar(array &$data)
$buttons[] = $workflow->get_button('#', [
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create event'),
MIDCOM_TOOLBAR_GLYPHICON => 'plus',
MIDCOM_TOOLBAR_OPTIONS => [
MIDCOM_TOOLBAR_OPTIONS => [
'id' => 'openpsa_calendar_add_event',
]
]);
@@ -84,7 +84,7 @@ public function _handler_calendar(array &$data)
MIDCOM_TOOLBAR_URL => '#',
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('go to'),
MIDCOM_TOOLBAR_GLYPHICON => 'calendar',
MIDCOM_TOOLBAR_OPTIONS => [
MIDCOM_TOOLBAR_OPTIONS => [
'rel' => 'directlink',
'id' => 'date-navigation',
]
@@ -59,7 +59,7 @@ public function _handler_event(Request $request, $handler_id, $guid, array &$dat
MIDCOM_TOOLBAR_URL => 'javascript:window.print()',
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('print'),
MIDCOM_TOOLBAR_GLYPHICON => 'print',
MIDCOM_TOOLBAR_OPTIONS => ['rel' => 'directlink']
MIDCOM_TOOLBAR_OPTIONS => ['rel' => 'directlink']
];
$relatedto_button_settings = null;
@@ -68,10 +68,10 @@ public function _handler_event(Request $request, $handler_id, $guid, array &$dat
$user = midcom::get()->auth->user->get_storage();
$date = $this->_l10n->get_formatter()->date();
$relatedto_button_settings = [
'wikinote' => [
'wikinote' => [
'component' => 'net.nemein.wiki',
'node' => false,
'wikiword' => str_replace('/', '-', sprintf($this->_l10n->get($this->_config->get('wiki_title_skeleton')), $data['event']->title, $date, $user->name)),
'node' => false,
'wikiword' => str_replace('/', '-', sprintf($this->_l10n->get($this->_config->get('wiki_title_skeleton')), $data['event']->title, $date, $user->name)),
],
];
}
@@ -202,7 +202,7 @@ public function _show_user_busy($handler_id, array &$data)
}
}
// Only display the requested user as participant
$event->participants[$data['person']->id] = true;
$event->participants[$data['person']->id] = true;
// Always force busy in this view
$event->busy = true;
$encoder->add_event($event);
@@ -99,7 +99,7 @@ public function _on_reindex($topic, $config, &$indexer)
$root_event = self::find_root_event();
$qb = org_openpsa_calendar_event_dba::new_query_builder();
$qb->add_constraint('up', '=', $root_event->id);
$qb->add_constraint('up', '=', $root_event->id);
$dm = datamanager::from_schemadb($config->get('schemadb'));
$indexer = new org_openpsa_calendar_midcom_indexer($topic, $indexer);
@@ -479,7 +479,7 @@ private function output($output, $message, $indent = '')
{
debug_add($message);
if ($output) {
echo $indent . 'INFO: ' . $message . "<br/>\n";
echo $indent . 'INFO: ' . $message . "<br/>\n";
flush();
}
}
@@ -72,12 +72,7 @@ private function _write_full_midcom_acls(midcom_core_dbaobject $object, $owner_i
// Clear old ACLs applying to others than current user or selected owner group
if ( $privilege->assignee != midcom::get()->auth->user->id
&& $privilege->assignee != $owner_id) {
if (is_array($privilege->assignee)) {
$assignee_key = $privilege->assignee['identifier'];
} else {
$assignee_key = $privilege->assignee;
}
debug_add("Removing privilege {$privilege->privilegename} from {$assignee_key}");
debug_add("Removing privilege {$privilege->privilegename} from {$privilege->assignee}");
$object->unset_privilege($privilege->privilegename, $privilege->assignee);
}
}
@@ -77,7 +77,7 @@ public function render()
echo '<select class="filter_input" onchange="document.forms[\'' . $this->name . '_filter\'].submit();" name="' . $this->name . '">';
foreach ($options as $option) {
echo '<option value="' . $option['id'] . '"';
echo '<option value="' . $option['id'] . '"';
if ($option['selected'] == true) {
echo " selected=\"selected\"";
}
@@ -109,12 +109,11 @@ protected function _get_options()
$options = [];
foreach ($data as $id => $title) {
$option = [
$options[] = [
'id' => $id,
'title' => $title,
'selected' => in_array($id, $this->_selection)
];
$options[] = $option;
}
return $options;
}
Oops, something went wrong.

0 comments on commit 709b7a1

Please sign in to comment.