Completed
Push — master ( d674d6...6c0c4d )
by Michael
04:12 queued 02:03
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Join page for the Xoops Partners Module
4
 *
5
 * LICENSE
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 *
11
 * @copyright   The XOOPS Project http://sourceforge.net/projects/xoops/
12
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
13
 * @author      Andricq Nicolas (AKA MusS)
14
 * @version     $Id: join.php 9326 2012-04-14 21:53:58Z beckmi $
15
 * @since       2.3.0
16
 */
17
 
18
// Include header
19
include_once 'header.php';
20
if ( $xoopsUser ){
21
    $op = xoopsPartners_CleanVars( $_REQUEST, 'op', 'add', 'string' );
22
    // Define template file
23
    $xoopsOption['template_main'] = 'xoopspartners_join.html';
24
    // Include Xoops header
25
    include XOOPS_ROOT_PATH . '/header.php';
26
    // Add module stylesheet and scripts
27
    $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/class.css', null );
28
    $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/module.css', null );
29
    $xoTheme->addScript( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/js/functions.js', null, '' );
30
    // Module Name
31
    $xoopsTpl->assign('module_name', $xoopsModule->getVar('name', 's'));
32
    $xoopsTpl->assign('sub_title', _XO_MD_JOIN);
33
    
34
    // Load Partners Handler
35
    $partners_handler = &xoops_getModuleHandler( 'partners' );
36
    // Retreive form data for all case
37
    switch ($op) {
38
        case 'add': // Add Partner/Category
39
        // Retreive form data for all case
40
        $obj = $partners_handler->create();
41
        $obj->displayJoinForm();
42
        break;
43
        case 'save':
44 View Code Duplication
            if ( !$GLOBALS['xoopsSecurity']->check() ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
                redirect_header( 'index.php', 0, $GLOBALS['xoopsSecurity']->getErrors( true ) );
46
            }
47
            // Diplay navigation menu
48
            $menu_handler->render( 1 );
49
            $id = xoopsPartners_CleanVars( $_REQUEST, $partners_handler->keyName, 0, 'int' );
50
            $obj = ( $id == 0 ) ? $partners_handler->create() : $partners_handler->get( $id );
51
            if ( is_object( $obj ) ) {
52
                $obj->setVars( $_REQUEST );
53
                $obj->setVar( 'dohtml', isset( $_REQUEST['dohtml'] ) ? 1 : 0 );
54
                $obj->setVar( 'dosmiley', isset( $_REQUEST['dosmiley'] ) ? 1 : 0 );
55
                $obj->setVar( 'doxcode', isset( $_REQUEST['doxcode'] ) ? 1 : 0 );
56
                $obj->setVar( 'doimage', isset( $_REQUEST['doimage'] ) ? 1 : 0 );
57
                $obj->setVar( 'dobr', isset( $_REQUEST['dobr'] ) ? 1 : 0 );
58
                $ret = $partners_handler->insert( $obj, true );
59
                if ( $ret ) {
60
                    $xoopsMailer =& getMailer();
61
                    $xoopsMailer->useMail();
62
                    $xoopsMailer->setTemplateDir( XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar( 'dirname', 'n') . '/language/'.$xoopsConfig['language'] . '/');
63
                    $xoopsMailer->setTemplate( 'join.tpl' );
64
                    $xoopsMailer->assign( 'SITENAME', $xoopsConfig['sitename'] );
65
                    $xoopsMailer->assign( 'SITEURL', XOOPS_URL . '/');
66
                    $xoopsMailer->assign( 'IP', $_SERVER['REMOTE_ADDR']);
67
                    $xoopsMailer->assign( 'USER', $xoopsUser->getVar( 'uname', 's' ) );
68
                    $xoopsMailer->assign( 'TITLE', $obj->getVar( 'title', 's' ) );
69
                    // Get category title
70
                    $category_handler = &xoops_getModuleHandler( 'category' );
71
                    $category_handler->get( $obj->getVar( 'category_id', 's' ) );
72
                    $xoopsMailer->assign( 'CATEGORY', $obj->getVar( 'cat_title', 's' ) );
73
                    
74
                    $xoopsMailer->setToEmails( $xoopsConfig['adminmail'] );
75
                    $xoopsMailer->setFromEmail( $xoopsUser->getVar( 'email', 's' ) );
76
                    $xoopsMailer->setFromName( $xoopsUser->getVar( 'uname', 's' ) );
77
                    $xoopsMailer->setSubject(sprintf( _XO_MD_NEWPARTNER, $xoopsConfig['sitename'] ) );
78
                    if ( !$xoopsMailer->send() ) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
79
                    }
80
                    // Redirect
81
                    xoopsPartners_redirect( 'index.php', 1, _XO_AD_DBSUCCESS );
82
                    // Display Xoops footer
83
                    xoops_cp_footer();
84
                    exit;
85
                }
86
            }
87
            // Display Error
88
            xoops_error( $ret, _XO_AD_PARTNER_SUBERROR );
89
            break;
90
    }
91
} else {
92
    redirect_header( 'index.php', 2, _NOPERM );
93
}
94
// Include Xoops Footer
95
include_once XOOPS_ROOT_PATH . '/footer.php';
96