Exemple #1
0
 /**
  * Set event
  *
  * @param $id
  * @param $timeout
  * @param $lat
  * @param $lng
  * @param $visible
  * @param $text
  * @param $time
  * @param $time_interval
  * @param $img
  * @param $tags
  *
  * @return bool|int
  */
 function set($id, $timeout, $lat, $lng, $visible, $text, $time, $time_interval, $img, $tags)
 {
     $data = $this->get($id);
     $User = User::instance();
     $id = (int) $id;
     $groups = $User->get_groups();
     if (in_array(AUTOMAIDAN_GROUP, $groups)) {
         return false;
     }
     if ($visible == 2) {
         $visible = array_filter($groups, function ($group) {
             return $group > 3;
         })[0];
     }
     if ($img != $data['img'] && $img) {
         (new SimpleImage($img))->thumbnail(260, 240)->save($img = STORAGE . '/events/' . md5(MICROTIME . '_' . $User->id) . '.png', 100);
         $img = url_by_source($img);
         unlink(source_by_url($data['img']));
     }
     if ($this->update_simple([$data['id'], $data['user'], $data['category'], TIME, $timeout ? TIME + max(0, (int) $timeout) : 0, $lat, $lng, $visible, $text, $time, $time_interval, $img, $data['confirmed']])) {
         if ($tags) {
             $this->db_prime()->q("DELETE FROM `[prefix]events_events_tags`\n\t\t\t\t\tWHERE `id` = '%s'", $id);
             $this->db_prime()->insert("INSERT IGNORE INTO `[prefix]events_tags`\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t`title`\n\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t'%s'\n\t\t\t\t\t\t)", array_map(function ($t) {
                 return [$t];
             }, $tags), true);
             foreach ($tags as &$t) {
                 $t = $this->db_prime()->qfs(["SELECT `id`\n\t\t\t\t\t\tFROM `[prefix]events_tags`\n\t\t\t\t\t\tWHERE `title` = '%s'\n\t\t\t\t\t\tLIMIT 1", $t]);
                 $t = [$t];
             }
             $this->db_prime()->insert("INSERT IGNORE INTO `[prefix]events_events_tags`\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t`id`,\n\t\t\t\t\t\t\t`tag`\n\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t{$id},\n\t\t\t\t\t\t\t'%s'\n\t\t\t\t\t\t)", $tags, true);
         }
         unset($this->cache->{$id}, $this->cache->all);
         return true;
     }
     return false;
 }
Exemple #2
0
 /**
  * Connecting to the Storage
  *
  * @param string	$base_url
  * @param string	$host
  * @param string	$user
  * @param string	$password
  */
 function __construct($base_url, $host, $user = '', $password = '')
 {
     $this->base_url = url_by_source(STORAGE);
     $this->connected = true;
 }
Exemple #3
0
                $a->content(h::{'p.lead.cs-center'}($L->sure_to_delete . ' ' . $L->storage . ' ' . $Config->storage[$rc[3]]['host'] . '/' . $Config->storage[$rc[3]]['connection'] . '?' . h::{'input[type=hidden]'}(['name' => 'mode', 'value' => 'delete']) . h::{'input[type=hidden]'}(['name' => 'storage', 'value' => $rc[3]])) . h::{'button[type=submit]'}($L->yes));
            }
            break;
        case 'test':
            interface_off();
            $test_dialog = false;
            $a->form = false;
            $a->generate_auto = false;
            $Storage = Storage::instance();
            if (isset($rc[3])) {
                $Page->Content = h::{'p.cs-test-result'}($Storage->test([$rc[3]]) ? $L->success : $L->failed);
            } else {
                $Page->Content = h::{'p.cs-test-result'}($Storage->test($_POST['storage']) ? $L->success : $L->failed);
            }
            break;
    }
} else {
    $storage_list = [];
    $Core = Core::instance();
    $storages = $Config->storage;
    if (!empty($storages)) {
        foreach ($storages as $i => &$storage_data) {
            $storage_list[] = [[$i ? h::{'a.cs-button-compact'}(h::icon('pencil'), ['href' => "{$a->action}/edit/{$i}", 'data-title' => "{$L->edit} {$L->storage}"]) . h::{'a.cs-button-compact'}(h::icon('trash-o'), ['href' => "{$a->action}/delete/{$i}", 'data-title' => "{$L->delete} {$L->storage}"]) . h::{'a.cs-button-compact'}(h::icon('signal'), ['onMouseDown' => "cs.storage_test('{$a->action}/test/{$i}', true);", 'data-title' => $L->test_connection]) : '-', ['class' => $i ? '' : 'text-primary']], [[$i ? $storage_data['url'] : $Core->storage_url ?: url_by_source(STORAGE), $i ? $storage_data['host'] : $Core->storage_host, $i ? $storage_data['connection'] : $Core->storage_type, $i ? $storage_data['user'] : $Core->storage_user ?: '-'], ['class' => $i ? '' : 'text-primary']]];
        }
        unset($i, $storage_data);
    }
    unset($storages);
    $a->content(h::{'table.cs-table.cs-center-all'}(h::{'thead tr th'}([$L->action, $L->storage_url, $L->storage_host, $L->storage_connection, $L->storage_user]) . h::{'tbody tr| td'}([$storage_list])) . h::{'p a.cs-button'}($L->add_storage, ['href' => "admin/System/{$rc['0']}/{$rc['1']}/add"]));
    unset($storage_list);
}
$test_dialog && $a->content(h::{'div#cs-storage-test.uk-modal div'}(h::h3($L->test_connection) . h::div()));