Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2021, 07:05 AM
effeff70 effeff70 is offline
 
Join Date: Nov 2008
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Managing Calendar Events

Since events play a major role on my site, on vb4, I had developed an event maintenance page that basically listed all events in a table view and enabled moderators to enter new ones, update existing ones, etc.

I was able to migrade this code to vb5 but learned from vb-Support Team that I am bypassing search inclusion when managing events this way.
It was recommended to use the API but until today, I have not been able to get it to work despite the two code examples shown here.

The fact that there is no proper API documentation (all I have found is this) and now beginner's guide is a shame!

Is anybody on this forum able to give be a hand on this?
Basically, I am looking for code that used the vb5 API in order to create, read, update and delete events.
Reply With Quote
  #2  
Old 01-08-2021, 10:00 AM
delicjous's Avatar
delicjous delicjous is offline
 
Join Date: Nov 2014
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Because Events are based on posts, why don't just add a create thread button linkend to the forum your events belong to?

HTML Code:
<button type="button" class="b-button b-button--primary-light new-conversation-btn js-movable-toolbar-button" onclick="window.location.href='new-content/YOURFORUMIDHERE!!!!'">
	<span class="b-button__icon b-button__icon--plus"></span>
	<span class="b-button__text-primary js-button__text-primary">{vb:phrase plus_new_conversation}</span>
</button>
Thats the easiest way I could think of.

If you would have a direct text-container it is not a five minute-job. But could be done.
Reply With Quote
  #3  
Old 01-09-2021, 04:18 PM
effeff70 effeff70 is offline
 
Join Date: Nov 2008
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's not helping because this is my maintenance page:

The table shows all available events. Click on it, the map updates and the fields on the left get filled. Move tha marker on the map and the respective fields updates. Choose to either update the existing or to create a new event.
Reply With Quote
  #4  
Old 01-11-2021, 03:09 AM
delicjous's Avatar
delicjous delicjous is offline
 
Join Date: Nov 2014
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then you need not only the API You need to create a module (there are examples in the do not upload folder) with a frontend-controller, the API and perhaps Library. You could also look into my mod membermap. That is similar, but needs a lot more for your project.
Reply With Quote
  #5  
Old 01-11-2021, 11:40 AM
effeff70 effeff70 is offline
 
Join Date: Nov 2008
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, I do not need all that. The event maintenance page is not really integrated into my forum, it's separate.
All I need is -- as I said -- code examples on how to create, read, update, and delete events.
Reply With Quote
  #6  
Old 01-11-2021, 04:40 PM
shka shka is offline
 
Join Date: Mar 2016
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ich schreibe es mal auf deutsch, da geht das fl?ssiger. Wie bereits erw?hnt besteht ein Event in vB5 nicht nur aus einem Eintrag in den Event-Table, sondern aus einem Topic in einem Forumschannel, einem ersten Post in diesem Topic sowie eben jenem Eintrag im Event-Table.

Wie delicjous bereits schrieb - am Sinnvollsten ist ein vB-interne L?sung
Modul, welches die gleichen Frontendcontroller anbietet, die vB auch verwendet bei der Erstellung, Bearbeitung und L?schung von Events
- erstellen/bearbeiten : POST auf /forum/create-content/event (mit unt ohne mitgelieferte nodeid)
- delete : POST auf /forum/ajax/api/node/deleteNodes
Nur f?r ?bersicht der Events m?sste man schauen, ob vB da schon was im Frontend bietet (/forum/ajax/render/widget_calendar__events ist etwas unhandlich)

Falls du aber unbedingt ?ber die Api gehen willst, dann so.
- Script muss auf deinen vB-Server, aber au?erhalb vom vB-Verzeichnis,
- Zeile 5 vbpath muss angepasst werden
- Zeile 7-11 ?bernimmt die Sitzung des aktuell am vB angemeldeten Users und Initialisiert vB und die Api im Allgemeinen
- Zeile 13-23 aktueller User - auf diesen Infos musst du deine Berechtigung zum Ausf?hren des Scriptes aufbauen
- Zeile 38-47 deine Daten zum Event, Zeile 39 muss angepasst werden
- Zeile 51 dient zur Kontrolle, ob du deine EventApi bekommen hast
- Zeile 54 sollte dir die NodeId zum neu eingetragenen Event ausgeben.

PHP Code:
<?php

try {
    
// Path to your vBulletin installation
    
$vbpath '/var/www/html/forum';

    
// Start script
    
define('CSRF_PROTECTION'false);
    require_once(
$vbpath '/includes/vb5/autoloader.php');
    
vB5_Autoloader::register($vbpath);
    
vB5_Frontend_Application::init('config.php');

    
// Check current logged in user or group for rights to run this script
    
$userAPI vB_Api::instance("user");
    
$userinfo $userAPI->fetchCurrentUserinfo();
    
var_dump($userinfo['userid']);
    
var_dump($userinfo['username']);
    
var_dump($userinfo['usergroupid']);
    
var_dump($userinfo['membergroupids']);
    
var_dump($userinfo['displaygroupid']);
    
    
// No rights should die
    //die();

    /*
    $data = array(
        'parentid' => $forumChannelId,
        'title' => $title,
        'rawtext' => $text,
        'location' => $location,
        'eventstartdate' => $eventStartDate,
        'eventenddate' => $eventEndDate,
        'allday' => false
    );
    */


    
$data = array(
        
'parentid' => '21'//Channel for events
        
'title' => 'New Test Event',
        
'rawtext' => 'Test Event Description',
        
'location' => '',
        
'eventstartdate' => '1610755200'//01/16/2021 @ 12:00am (UTC)
        
'eventenddate' => '1610784000'//01/16/2021 @ 8:00am (UTC)
        
'allday' => false
    
);
    
$options = array();
 
    
$eventApivB_Api_Content_Event::getContentApi(vB_Types::instance()->getContentTypeID('vBForum_Event'));
    
//Now you should get a dump of event api
    //var_dump($eventApi);

    
$result $eventApi->add($data$options);
    
var_dump($result);
} catch (
vB_Exception_Database $e) {
    echo 
"An exception: " $e->getMessage() . "\n";
} catch (
Exception $e) {
    echo 
"An exception: " $e->getMessage() . "\n";
}
Reply With Quote
Благодарность от:
delicjous
  #7  
Old 01-16-2021, 10:41 AM
effeff70 effeff70 is offline
 
Join Date: Nov 2008
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Servus!

Danke für deine Hilfe.
Der Code läuft einwandfrei!

Rein aus Interesse:
Woher hast du gewusst, was das $data-Array beinhalten muss?
Reply With Quote
  #8  
Old 01-16-2021, 01:34 PM
shka shka is offline
 
Join Date: Mar 2016
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In dem Fall war das auskommentierte Array ja aus den Snippets auf vbulletin.com in deiner Anfrage. Aber sonst wäre das Vorgehen:

Event = normaler Post-Table + zusätzliche Felder in Event-Table (und die Spaltennamen sind in solchen Systemen üblicherweise auch Parameter-Namen)

Zur Kontrolle:
Auf der Webseite wird beim Erstellen eines Events ein Frontendcontroller (= Ajax-Call) mit POST-Daten aufgerufen. Und mehr kann dann das System ja auch nirgendwo zur Verfügung haben zur Erstellung der DB-Einträge. Allerdings noch mit userspezifischen Länderformatierungen bei Datum etc.

Der Frontentcontroller ist hier allerdings übersichtlich und ruft Event-Api::add() auf. Und von dort geht es auch relativ schnell in Event-Library::checkEventData(). Und dort werden alle Event-spezifischen Parameter geprüft.

Von daher auch der Hinweis von delicjous und mir, über Frontentcontroller zu gehen. Weil du deine CMS-Seite (und ich kann mir durchaus vorstellen, dass dies eine interessante Mod-Idee wäre) dann schön als Template/Modul innerhalb von vB und Nutzung der Rechteverwaltung davon umsetzen könntest.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06889 seconds
  • Memory Usage 2,262KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete