Source for file threads.ctrl.php
Documentation is available at threads.ctrl.php
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( 'messaging/model/_thread.class.php', 'Thread' );
load_class( 'messaging/model/_message.class.php', 'Message' );
// Check minimum permission:
$current_User->check_perm( 'perm_messaging', 'write', true );
$AdminUI->set_path( 'messaging', 'messages' );
// Get action parameter from request:
if( param( 'thrd_ID', 'integer', '', true) )
{// Load thread from cache:
if( ($edited_Thread =
& $ThreadCache->get_by_ID( $thrd_ID, false )) ===
false )
{ unset
( $edited_Thread );
$Messages->add( sprintf( T_('Requested «%s» object does not exist any longer.'), T_('Thread') ), 'error' );
if( param( 'msg_ID', 'integer', '', true) )
{// Load message from cache:
if( ($edited_Message =
& $MessageCache->get_by_ID( $msg_ID, false )) ===
false )
{ unset
( $edited_Message );
$Messages->add( sprintf( T_('Requested «%s» object does not exist any longer.'), T_('Message') ), 'error' );
// Preload users to show theirs avatars
$current_User->check_perm( 'perm_messaging', 'write', true );
if( ! isset
($edited_Message) )
{ // We don't have a model to use, start with blank object:
$edited_Thread =
new Thread();
{ // Duplicate object in order no to mess with the cache:
$edited_Thread =
duplicate( $edited_Message->Thread ); // PHP4/5 abstraction
$edited_Message =
duplicate( $edited_Message ); // PHP4/5 abstraction
$edited_Message->Thread =
& $edited_Thread;
case 'create':
// Record new thread
// Check that this action request is not a CSRF hacked request:
$Session->assert_received_crumb( 'thread' );
$edited_Thread =
new Thread();
$edited_Message->Thread =
& $edited_Thread;
$current_User->check_perm( 'perm_messaging', 'write', true );
param( 'thrd_recipients', 'string' );
// Load data from request
if( $edited_Message->load_from_Request() )
{ // We could load data from form without errors:
if( $current_User->check_perm( 'perm_messaging', 'reply' ) )
if( !empty( $blocked_contacts ) )
param_error( 'thrd_recipients', T_( 'You don\'t have permission to initiate conversations with the following users: ' ).
implode( ', ', $blocked_contacts ) );
if( param( 'thrdtype', 'string', 'discussion' ) ==
'discussion' )
$edited_Message->dbinsert_discussion();
$edited_Message->dbinsert_individual();
$Messages->add( T_('New thread created.'), 'success' );
// Redirect so that a reload doesn't write to the DB twice:
// We have EXITed already at this point!!
// Check that this action request is not a CSRF hacked request:
$Session->assert_received_crumb( 'thread' );
$current_User->check_perm( 'perm_messaging', 'delete', true );
// Make sure we got an thrd_ID:
param( 'thrd_ID', 'integer', true );
if( param( 'confirm', 'integer', 0 ) )
{ // confirmed, Delete from DB:
$msg =
sprintf( T_('Thread «%s» deleted.'), $edited_Thread->dget('title') );
$edited_Thread->dbdelete( true );
unset
( $edited_Message );
$Messages->add( $msg, 'success' );
// Redirect so that a reload doesn't write to the DB twice:
// We have EXITed already at this point!!
{ // not confirmed, Check for restrictions:
if( ! $edited_Thread->check_delete( sprintf( T_('Cannot delete thread «%s»'), $edited_Thread->dget('title') ) ) )
{ // There are restrictions:
$AdminUI->breadcrumbpath_init( false ); // fp> I'm playing with the idea of keeping the current blog in the path here...
$AdminUI->breadcrumbpath_add( T_('Messages'), '?ctrl=threads' );
$AdminUI->breadcrumbpath_add( T_('Conversations'), '?ctrl=threads' );
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
$AdminUI->disp_html_head();
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
$AdminUI->disp_body_top();
$AdminUI->disp_payload_begin();
// We need to ask for confirmation:
$edited_Thread->confirm_delete(
sprintf( T_('Delete thread «%s»?'), $edited_Thread->dget('title') ),
$AdminUI->disp_view( 'messaging/views/_thread_list.view.php' );
$AdminUI->disp_view( 'messaging/views/_thread.form.php' );
// No specific request, list all threads:
$AdminUI->disp_view( 'messaging/views/_thread_list.view.php' );
$AdminUI->disp_payload_end();
// Display body bottom, debug info and close </html>:
$AdminUI->disp_global_footer();
* $Log: threads.ctrl.php,v $
* Revision 1.16 2010/01/30 18:55:32 blueyed
* Fix "Assigning the return value of new by reference is deprecated" (PHP 5.3)
* Revision 1.15 2010/01/15 16:57:38 efy-yury
* update messaging: crumbs
* Revision 1.14 2010/01/03 12:03:17 fplanque
* Revision 1.13 2009/12/06 22:55:20 fplanque
* Started breadcrumbs feature in admin.
* Work in progress. Help welcome ;)
* Also move file settings to Files tab and made FM always enabled
* Revision 1.12 2009/10/08 20:05:52 efy-maxim
* Modular/Pluggable Permissions
* Revision 1.11 2009/09/26 12:00:43 tblue246
* Revision 1.10 2009/09/25 07:32:52 efy-cantor
* replace get_cache to get_*cache
* Revision 1.9 2009/09/19 20:31:38 efy-maxim
* 'Reply' permission : SQL queries to check permission ; Block/Unblock functionality; Error messages on insert thread/message
* Revision 1.8 2009/09/19 11:29:05 efy-maxim
* Revision 1.7 2009/09/18 16:16:50 efy-maxim
* comments tab in messaging module
* Revision 1.6 2009/09/18 10:38:31 efy-maxim
* 15x15 icons next to login in messagin module
* Revision 1.5 2009/09/16 22:03:40 fplanque