function get_upload($upload_id)
 {
     if (!$upload_id) {
         return array();
     }
     $query = he_database::placeholder("SELECT * FROM `se_he_uploads` \r\n           WHERE `uploads_id`=?", $upload_id);
     return he_database::fetch_row($query);
 }
    /**
     * Checks if module has db structure and if it is needed upgrade or not
     *
     * @return void;
     */
    function check_db_structure()
    {
        global $settings;

        $file_version = $this->get_version();

        //check if db structure is ready
        if( !$settings['he_mass_mailing_version'] )
        {
            if( !he_database::fetch_row("SHOW COLUMNS FROM se_settings LIKE 'he_mass_mailing_version'") )
            {
                he_database::query("ALTER TABLE `se_settings` ADD `he_mass_mailing_version` int(10) NOT NULL DEFAULT $file_version");
                he_database::query("ALTER TABLE `se_settings` ADD `he_mass_mailing_last_execute` int(10) NOT NULL");
                he_database::query("ALTER TABLE `se_settings` ADD `he_mass_mailing_limit_per_execute` int(10) NOT NULL DEFAULT 30");
                he_database::query("CREATE TABLE `se_he_mass_mailing_campaign` (`id` int(11) NOT NULL AUTO_INCREMENT,`subject` varchar(255) NOT NULL,`message` text NOT NULL,`sender` int(10) NOT NULL,`sent_time` int(10) unsigned NOT NULL,`is_email` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
                he_database::query("CREATE TABLE `se_he_mass_mailing_queue` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`campaign_id` int(11) NOT NULL,`recipient` int(10) NOT NULL,`email` varchar(64) NOT NULL,`full_name` varchar(128) NOT NULL,`replace` text NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
                $settings['he_mass_mailing_version'] = $file_version;
            }
        }

        //check db and file version
        if( $file_version > $settings['he_mass_mailing_version'] )
        {
            //db version is older than file so we have to upgrade db version
            switch( $settings['he_mass_mailing_version'] )
            {
                case 101:
                break;
            }
        }
    }
 function get_wall_link($object, $object_id)
 {
     global $user, $url;
     if (!$object || !$object_id) {
         return '';
     }
     if ($object == 'userhome' || !$user->user_exists) {
         return '';
     }
     if ($object == 'user' && $user->user_info['user_id'] == $object_id) {
         return '';
     }
     if ($object == 'user') {
         $sql = he_database::placeholder("SELECT `user_id`, `user_username`, `user_fname`, `user_lname` FROM `se_users` " . "WHERE `user_id`=?", $object_id);
         $row = he_database::fetch_row($sql);
         $wall_owner = new se_user();
         $wall_owner->user_exists = 1;
         $wall_owner->user_info['user_id'] = $row['user_id'];
         $wall_owner->user_info['user_username'] = $row['user_username'];
         $wall_owner->user_info['user_fname'] = $row['user_fname'];
         $wall_owner->user_info['user_lname'] = $row['user_lname'];
         $wall_owner->user_displayname();
         $wall_url = $url->url_create('profile', $wall_owner->user_info['user_username']);
         $wall_label = $wall_owner->user_displayname;
     } elseif ($object == 'group') {
         $sql = he_database::placeholder("SELECT `group_title` FROM `se_groups` " . "WHERE `group_id`=?", $object_id);
         $wall_url = $url->url_create('group', null, $object_id);
         $wall_label = he_database::fetch_field($sql);
     } elseif ($object == 'pages') {
         $sql = he_database::placeholder("SELECT `pages_title` FROM `se_pages` " . "WHERE `pages_id`=?", $object_id);
         $wall_url = $url->url_create('pages', null, $object_id);
         $wall_label = he_database::fetch_field($sql);
     } else {
         return '';
     }
     return SE_Language::get(690706106, array($wall_url, $wall_label));
 }
 function result_info($result_id)
 {
     if (!$result_id) {
         return array();
     }
     $query = he_database::placeholder("SELECT * FROM `se_he_quiz_result` WHERE `id`=?", $result_id);
     return he_database::fetch_row($query);
 }
$page = "admin_levels_wallsettings";
include "admin_header.php";
if (isset($_POST['task'])) {
    $task = $_POST['task'];
} else {
    $task = "main";
}
if (isset($_POST['level_id'])) {
    $level_id = $_POST['level_id'];
} elseif (isset($_GET['level_id'])) {
    $level_id = $_GET['level_id'];
} else {
    $level_id = 0;
}
$query = he_database::placeholder("SELECT * FROM `se_levels` WHERE `level_id`=?", $level_id);
$level_info = he_database::fetch_row($query);
if (!$level_info) {
    header("Location: admin_levels.php");
    exit;
}
// SET RESULT VARIABLE
$result = 0;
if ($task == "dosave") {
    $level_info['level_wall_allowed'] = $_POST['level_wall_allowed'];
    $level_info['level_wall_action_privacy'] = is_array($_POST['level_wall_action_privacy']) ? $_POST['level_wall_action_privacy'] : array();
    //GET PRIVACY AND PRIVACY DIFFERENCES
    if (empty($level_info['level_wall_action_privacy']) || !is_array($level_info['level_wall_action_privacy'])) {
        $level_info['level_wall_action_privacy'] = array(63);
    }
    rsort($level_info['level_wall_action_privacy']);
    $new_privacy_options = $level_info['level_wall_action_privacy'];