Ejemplo n.º 1
0
    /**
     *	'After'-operation methods
     */
    public function AfterInsertRecord()
    {
        // clone to other languages ---
        $total_languages = Languages::GetAllActive();
        $language_id = MicroGrid::GetParameter('language_id');
        $template_code = MicroGrid::GetParameter('template_code', false);
        $template_name = MicroGrid::GetParameter('template_name', false);
        $template_subject = MicroGrid::GetParameter('template_subject', false);
        $template_content = MicroGrid::GetParameter('template_content', false);
        $is_system_template = MicroGrid::GetParameter('is_system_template', false);
        for ($i = 0; $i < $total_languages[1]; $i++) {
            if ($language_id != '' && $total_languages[0][$i]['abbreviation'] != $language_id) {
                $sql = 'INSERT INTO ' . TABLE_EMAIL_TEMPLATES . ' (
							id,
							language_id,
							template_code,
							template_name,
							template_subject,
							template_content,
							is_system_template
						) VALUES (
							NULL,
							\'' . encode_text($total_languages[0][$i]['abbreviation']) . '\',
							\'' . encode_text($template_code) . '\',
							\'' . encode_text($template_name) . '\',
							\'' . encode_text($template_subject) . '\',
							\'' . encode_text($template_content) . '\',
							' . (int) $is_system_template . '
						)';
                database_void_query($sql);
                $this->SetSQLs('insert_lan_' . $total_languages[0][$i]['abbreviation'], $sql);
            }
        }
    }
Ejemplo n.º 2
0
 /**
  * Prepare fields array for translations 
  */
 public function PrepareTranslateFields($params = array())
 {
     $output = array();
     $total_languages = Languages::GetAllActive();
     foreach ($total_languages[0] as $key => $val) {
         $output[$val['abbreviation']]['lang_name'] = $val['lang_name'];
         $output[$val['abbreviation']]['icon_image'] = $val['icon_image'];
         foreach ($params as $p_key) {
             $output[$val['abbreviation']][$p_key] = self::GetParameter($p_key . '_' . $val['abbreviation'], false);
         }
     }
     return $output;
 }
Ejemplo n.º 3
0
    /**
     * After-insertion function
     */
    public function AfterInsertRecord()
    {
        $name = isset($_POST['descr_name']) ? prepare_input($_POST['descr_name']) : '';
        $description = isset($_POST['descr_description']) ? prepare_input($_POST['descr_description']) : '';
        // languages array
        $total_languages = Languages::GetAllActive();
        foreach ($total_languages[0] as $key => $val) {
            $sql = 'INSERT INTO ' . TABLE_CATEGORIES_DESCRIPTION . '(
						id, category_id, language_id, name, description)
					VALUES(
						NULL, ' . $this->lastInsertId . ', \'' . $val['abbreviation'] . '\', \'' . $name . '\', \'' . $description . '\'
					)';
            if (!database_void_query($sql)) {
                // error
            }
        }
    }
Ejemplo n.º 4
0
    function __construct($login_type = '')
    {
        parent::__construct();
        global $objSettings;
        $this->params = array();
        if (isset($_POST['first_name'])) {
            $this->params['first_name'] = prepare_input($_POST['first_name']);
        }
        if (isset($_POST['last_name'])) {
            $this->params['last_name'] = prepare_input($_POST['last_name']);
        }
        if (isset($_POST['user_name'])) {
            $this->params['user_name'] = prepare_input($_POST['user_name']);
        }
        if (isset($_POST['password'])) {
            $this->params['password'] = prepare_input($_POST['password']);
        }
        if (isset($_POST['email'])) {
            $this->params['email'] = prepare_input($_POST['email']);
        }
        if (isset($_POST['preferred_language'])) {
            $this->params['preferred_language'] = prepare_input($_POST['preferred_language']);
        }
        if (isset($_POST['account_type'])) {
            $this->params['account_type'] = prepare_input($_POST['account_type']);
        }
        if (isset($_POST['date_created'])) {
            $this->params['date_created'] = prepare_input($_POST['date_created']);
        }
        if (isset($_POST['is_active'])) {
            $this->params['is_active'] = (int) $_POST['is_active'];
        } else {
            $this->params['is_active'] = '0';
        }
        if (self::$PROJECT == 'HotelSite') {
            if (isset($_POST['hotels'])) {
                $this->params['hotels'] = prepare_input($_POST['hotels']);
            }
        }
        $this->primaryKey = 'id';
        $this->tableName = TABLE_ACCOUNTS;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?admin=admins_management';
        $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowLanguages = false;
        if ($login_type == 'owner') {
            $this->WHERE_CLAUSE = 'WHERE (' . TABLE_ACCOUNTS . '.account_type = \'mainadmin\' || ' . TABLE_ACCOUNTS . '.account_type = \'admin\' || ' . TABLE_ACCOUNTS . '.account_type = \'hotelowner\')';
        } else {
            if ($login_type == 'mainadmin') {
                $this->WHERE_CLAUSE = 'WHERE (' . TABLE_ACCOUNTS . '.account_type = \'admin\' || ' . TABLE_ACCOUNTS . '.account_type = \'hotelowner\')';
            } else {
                if ($login_type == 'admin') {
                    $this->WHERE_CLAUSE = 'WHERE ' . TABLE_ACCOUNTS . '.account_type = \'admin\'';
                } else {
                    if ($login_type == 'hotelowner') {
                        $this->WHERE_CLAUSE = 'WHERE ' . TABLE_ACCOUNTS . '.account_type = \'hotelowner\'';
                    }
                }
            }
        }
        $this->ORDER_CLAUSE = 'ORDER BY id ASC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_FIRST_NAME => array('table' => $this->tableName, 'field' => 'first_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _LAST_NAME => array('table' => $this->tableName, 'field' => 'last_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _ACTIVE => array('table' => $this->tableName, 'field' => 'is_active', 'type' => 'dropdownlist', 'source' => array('0' => _NO, '1' => _YES), 'sign' => '=', 'width' => '85px'));
        // prepare languages array
        $total_languages = Languages::GetAllActive();
        $arr_languages = array();
        foreach ($total_languages[0] as $key => $val) {
            $arr_languages[$val['abbreviation']] = $val['lang_name'];
        }
        $arr_account_types = array('admin' => _ADMIN, 'mainadmin' => _MAIN_ADMIN);
        if (self::$PROJECT == 'HotelSite') {
            $arr_account_types['hotelowner'] = _HOTEL_OWNER;
        }
        $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>');
        $datetime_format = get_datetime_format();
        if (self::$PROJECT == 'HotelSite') {
            $total_hotels = Hotels::GetAllActive();
            $arr_hotels = array();
            foreach ($total_hotels[0] as $key => $val) {
                $this->arrCompanies[$val['id']] = $val['name'];
            }
            $this->additionalFields = ', hotels';
            $this->accountTypeOnChange = 'onchange="javascript:AccountType_OnChange(this.value)"';
        }
        if ($objSettings->GetParameter('date_format') == 'mm/dd/yyyy') {
            $this->sqlFieldDatetimeFormat = '%b %d, %Y %H:%i';
        } else {
            $this->sqlFieldDatetimeFormat = '%d %b, %Y %H:%i';
        }
        $this->SetLocale(Application::Get('lc_time_name'));
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT ' . $this->primaryKey . ',
									first_name,
		                            last_name,
									CONCAT(first_name, \' \', last_name) as full_name,
									user_name,
									email,
									preferred_language,
									account_type,
									DATE_FORMAT(date_lastlogin, \'' . $this->sqlFieldDatetimeFormat . '\') as date_lastlogin,
									is_active
									' . $this->additionalFields . '
								FROM ' . $this->tableName;
        // define view mode fields
        $this->arrViewModeFields = array('full_name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => ''), 'user_name' => array('title' => _USER_NAME, 'type' => 'label', 'align' => 'left', 'width' => ''), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'link', 'maxlength' => '35', 'href' => 'mailto:{email}', 'align' => 'left', 'width' => ''), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'align' => 'center', 'width' => '120px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_account_types), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '80px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'align' => 'center', 'width' => '110px', 'format' => 'date', 'format_parameter' => $datetime_format), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '40px'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '70', 'validation_type' => 'email', 'unique' => true)), 'separator_2' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USER_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'alpha_numeric', 'unique' => true, 'username_generator' => true), 'password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'password', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY, 'password_generator' => true), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'source' => $arr_account_types, 'javascript_event' => $this->accountTypeOnChange), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'default' => Application::Get('lang'), 'source' => $arr_languages)), 'separator_3' => array('separator_info' => array('legend' => _OTHER), 'date_lastlogin' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'date_created' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => date('Y-m-d H:i:s')), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false)));
        if (self::$PROJECT == 'HotelSite') {
            $this->arrAddModeFields['separator_3']['hotels'] = array('title' => _HOTELS, 'type' => 'enum', 'width' => '', 'required' => false, 'readonly' => false, 'default' => '', 'source' => $this->arrCompanies, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'checkboxes', 'multi_select' => true);
        }
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.first_name,
								' . $this->tableName . '.last_name,
								' . $this->tableName . '.user_name,
								' . $this->tableName . '.password,
								' . $this->tableName . '.email,
								' . $this->tableName . '.account_type,
								' . $this->tableName . '.preferred_language,
								DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as date_created,
								DATE_FORMAT(' . $this->tableName . '.date_lastlogin, \'' . $this->sqlFieldDatetimeFormat . '\') as date_lastlogin,
								' . $this->tableName . '.is_active
								' . $this->additionalFields . '
							FROM ' . $this->tableName . '
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '32', 'required' => true, 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '32', 'required' => true, 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '70', 'required' => true, 'validation_type' => 'email', 'unique' => true)), 'separator_2' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USER_NAME, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '32', 'required' => true, 'readonly' => true, 'validation_type' => 'alpha_numeric', 'unique' => true), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'width' => '120px', 'required' => true, 'maxlength' => '32', 'readonly' => $login_type == 'owner' ? false : true, 'source' => $arr_account_types, 'javascript_event' => $this->accountTypeOnChange), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'width' => '120px', 'required' => true, 'readonly' => false, 'source' => $arr_languages)), 'separator_3' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label'), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0')));
        if (self::$PROJECT == 'HotelSite') {
            $this->arrEditModeFields['separator_3']['hotels'] = array('title' => _HOTELS, 'type' => 'enum', 'width' => '', 'required' => false, 'readonly' => false, 'default' => '', 'source' => $this->arrCompanies, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'checkboxes', 'multi_select' => true);
        }
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.first_name,
								' . $this->tableName . '.last_name,
								' . $this->tableName . '.user_name,
								' . $this->tableName . '.password,
								' . $this->tableName . '.email,
								' . $this->tableName . '.preferred_language,
								' . $this->tableName . '.account_type,
								DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as date_created,
								DATE_FORMAT(' . $this->tableName . '.date_lastlogin, \'' . $this->sqlFieldDatetimeFormat . '\') as date_lastlogin,
								' . $this->tableName . '.is_active
								' . $this->additionalFields . '
							FROM ' . $this->tableName . '
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        $this->arrDetailsModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'label'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'label'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label')), 'separator_2' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USER_NAME, 'type' => 'label'), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'source' => $arr_account_types), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'source' => $arr_languages)), 'separator_3' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label'), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active)));
        if (self::$PROJECT == 'HotelSite') {
            $this->arrDetailsModeFields['separator_3']['hotels'] = array('title' => _HOTELS, 'type' => 'enum', 'width' => '', 'required' => false, 'readonly' => false, 'default' => '', 'source' => $this->arrCompanies, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'checkboxes', 'multi_select' => true);
        }
    }
Ejemplo n.º 5
0
    /**
     *	Creates new menu 
     *		@param $param - array of parameters
     */
    public function MenuCreate($params = array())
    {
        // Block operation in demo mode
        if (strtolower(SITE_MODE) == 'demo') {
            $this->error = _OPERATION_BLOCKED;
            return false;
        }
        // Get input parameters
        if (isset($params['name'])) {
            $this->menu['menu_name'] = $params['name'];
        }
        if (isset($params['menu_placement'])) {
            $this->menu['menu_placement'] = $params['menu_placement'];
        }
        if (isset($params['order'])) {
            $this->menu['menu_order'] = $params['order'];
        }
        if (isset($params['language_id'])) {
            $this->menu['language_id'] = $params['language_id'];
        }
        if (isset($params['access_level'])) {
            $this->menu['access_level'] = $params['access_level'];
        }
        // Prevent creating of empty records in our 'menus' table
        if ($this->menu['menu_name'] != '') {
            $menu_code = strtoupper(get_random_string(10));
            $total_languages = Languages::GetAllActive();
            for ($i = 0; $i < $total_languages[1]; $i++) {
                $m = self::GetAll(' menu_order ASC', TABLE_MENUS, '', $total_languages[0][$i]['abbreviation']);
                $max_order = (int) ($m[1] + 1);
                $sql = 'INSERT INTO ' . TABLE_MENUS . ' (language_id, menu_code, menu_name, menu_placement, menu_order, access_level)
						VALUES(\'' . $total_languages[0][$i]['abbreviation'] . '\', \'' . $menu_code . '\', \'' . encode_text($this->menu['menu_name']) . '\', \'' . $this->menu['menu_placement'] . '\', ' . $max_order . ', \'' . $this->menu['access_level'] . '\')';
                if (!database_void_query($sql)) {
                    $this->error = _TRY_LATER;
                    return false;
                }
            }
            return true;
        } else {
            $this->error = _MENU_NAME_EMPTY;
            return false;
        }
    }
Ejemplo n.º 6
0
            $msg = draw_important_message($objPage->error, false);
        }
        // do restore action
    } else {
        if ($act == 'restore' && $objLogin->HasPrivileges('edit_pages')) {
            if ($objPage->PageRestore()) {
                $msg = draw_success_message(_PAGE_RESTORED, false);
            } else {
                $msg = draw_important_message($objPage->error, false);
            }
        }
    }
    // start main content
    $all_pages = array();
    $all_pages = Pages::GetAll($language_id, 'removed');
    $total_languages = Languages::GetAllActive();
    draw_title_bar(prepare_breadcrumbs(array(_MENUS_AND_PAGES => '', _PAGE_MANAGEMENT => '', _TRASH_PAGES => '')));
    if ($objSession->IsMessage('notice')) {
        echo $objSession->GetMessage('notice');
    }
    echo $msg;
    ?>
	<script type="text/javascript">
	<!--
		function confirmDelete(pid){
			if(!confirm('<?php 
    echo _PAGE_DELETE_WARNING;
    ?>
')){
				return false;
			}else{
Ejemplo n.º 7
0
 /**
  *	Return select box with all active languages
  */
 public static function GetAllActiveSelectBox($exclude_lang = '', $selected_lang = '')
 {
     $output = '<select name="selLanguages" id="selLanguages">';
     $total_languages = Languages::GetAllActive();
     foreach ($total_languages[0] as $key => $val) {
         $output .= '<option ' . ($selected_lang == $val['abbreviation'] ? 'selected="selected"' : '') . ' ';
         if ($exclude_lang != '' && $exclude_lang != $val['abbreviation']) {
             $output .= 'value="' . $val['abbreviation'] . '">' . $val['lang_name'] . ' &raquo; ' . strtoupper($exclude_lang) . '</option>';
         } else {
             $output .= 'value="' . $val['abbreviation'] . '">' . $val['lang_name'] . '</option>';
         }
     }
     $output .= '</select>';
     return $output;
 }
Ejemplo n.º 8
0
    function __construct()
    {
        parent::__construct();
        $this->params = array();
        if (isset($_POST['group_id'])) {
            $this->params['group_id'] = (int) prepare_input($_POST['group_id']);
        }
        if (isset($_POST['first_name'])) {
            $this->params['first_name'] = prepare_input($_POST['first_name']);
        }
        if (isset($_POST['last_name'])) {
            $this->params['last_name'] = prepare_input($_POST['last_name']);
        }
        if (isset($_POST['birth_date']) && $_POST['birth_date'] != '') {
            $this->params['birth_date'] = prepare_input($_POST['birth_date']);
        } else {
            $this->params['birth_date'] = '0000-00-00';
        }
        if (isset($_POST['company'])) {
            $this->params['company'] = prepare_input($_POST['company']);
        }
        if (isset($_POST['b_address'])) {
            $this->params['b_address'] = prepare_input($_POST['b_address']);
        }
        if (isset($_POST['b_address_2'])) {
            $this->params['b_address_2'] = prepare_input($_POST['b_address_2']);
        }
        if (isset($_POST['b_city'])) {
            $this->params['b_city'] = prepare_input($_POST['b_city']);
        }
        if (isset($_POST['b_state'])) {
            $this->params['b_state'] = prepare_input($_POST['b_state']);
        }
        if (isset($_POST['b_country'])) {
            $this->params['b_country'] = prepare_input($_POST['b_country']);
        }
        if (isset($_POST['b_zipcode'])) {
            $this->params['b_zipcode'] = prepare_input($_POST['b_zipcode']);
        }
        if (isset($_POST['phone'])) {
            $this->params['phone'] = prepare_input($_POST['phone']);
        }
        if (isset($_POST['fax'])) {
            $this->params['fax'] = prepare_input($_POST['fax']);
        }
        if (isset($_POST['email'])) {
            $this->params['email'] = prepare_input($_POST['email']);
        }
        if (isset($_POST['url'])) {
            $this->params['url'] = prepare_input($_POST['url'], false, 'medium');
        }
        if (isset($_POST['user_name'])) {
            $this->params['user_name'] = prepare_input($_POST['user_name']);
        }
        if (isset($_POST['user_password'])) {
            $this->params['user_password'] = prepare_input($_POST['user_password']);
        }
        if (isset($_POST['preferred_language'])) {
            $this->params['preferred_language'] = prepare_input($_POST['preferred_language']);
        }
        if (isset($_POST['date_created'])) {
            $this->params['date_created'] = prepare_input($_POST['date_created']);
        }
        if (isset($_POST['date_lastlogin'])) {
            $this->params['date_lastlogin'] = prepare_input($_POST['date_lastlogin']);
        }
        if (isset($_POST['registered_from_ip'])) {
            $this->params['registered_from_ip'] = prepare_input($_POST['registered_from_ip']);
        }
        if (isset($_POST['last_logged_ip'])) {
            $this->params['last_logged_ip'] = prepare_input($_POST['last_logged_ip']);
        }
        if (isset($_POST['email_notifications'])) {
            $this->params['email_notifications'] = prepare_input($_POST['email_notifications']);
        } else {
            $this->params['email_notifications'] = '0';
        }
        if (isset($_POST['notification_status_changed'])) {
            $this->params['notification_status_changed'] = prepare_input($_POST['notification_status_changed']);
        }
        if (isset($_POST['is_active'])) {
            $this->params['is_active'] = (int) $_POST['is_active'];
        } else {
            $this->params['is_active'] = '0';
        }
        if (isset($_POST['is_removed'])) {
            $this->params['is_removed'] = (int) $_POST['is_removed'];
        } else {
            $this->params['is_removed'] = '0';
        }
        if (isset($_POST['comments'])) {
            $this->params['comments'] = prepare_input($_POST['comments']);
        }
        if (isset($_POST['registration_code'])) {
            $this->params['registration_code'] = prepare_input($_POST['registration_code']);
        }
        if (isset($_POST['plan1_listings'])) {
            $this->params['plan1_listings'] = prepare_input($_POST['plan1_listings']);
        }
        if (isset($_POST['plan2_listings'])) {
            $this->params['plan2_listings'] = prepare_input($_POST['plan2_listings']);
        }
        if (isset($_POST['plan3_listings'])) {
            $this->params['plan3_listings'] = prepare_input($_POST['plan3_listings']);
        }
        if (isset($_POST['plan4_listings'])) {
            $this->params['plan4_listings'] = prepare_input($_POST['plan4_listings']);
        }
        $rid = MicroGrid::GetParameter('rid');
        $action = MicroGrid::GetParameter('action');
        $this->email_notifications = '';
        $this->user_password = '';
        $this->allow_adding_by_admin = ModulesSettings::Get('customers', 'allow_adding_by_admin');
        $this->allow_changing_password = ModulesSettings::Get('customers', 'password_changing_by_admin');
        $this->reg_confirmation = ModulesSettings::Get('customers', 'reg_confirmation');
        $allow_adding = $this->allow_adding_by_admin == 'yes' ? true : false;
        $this->primaryKey = 'id';
        $this->tableName = TABLE_CUSTOMERS;
        $this->dataSet = array();
        $this->error = '';
        ///$this->languageId  	= (isset($_REQUEST['language_id']) && $_REQUEST['language_id'] != '') ? $_REQUEST['language_id'] : Languages::GetDefaultLang();
        $this->formActionURL = 'index.php?admin=mod_customers_management';
        $this->actions = array('add' => $allow_adding, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowTopButtons = true;
        $this->allowLanguages = false;
        $this->WHERE_CLAUSE = '';
        $this->ORDER_CLAUSE = 'ORDER BY id DESC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $total_countries = Countries::GetAllCountries('priority_order DESC, name ASC');
        $arr_countries = array();
        foreach ($total_countries[0] as $key => $val) {
            $arr_countries[$val['abbrv']] = $val['name'];
        }
        // prepare plans array
        $total_plans = AdvertisePlans::GetAllPlans();
        $arr_plans = array();
        foreach ($total_plans[0] as $key => $val) {
            $arr_plans[$val['id']] = $val['plan_name'];
        }
        // prepare groups array
        $total_groups = CustomerGroups::GetAllGroups();
        $arr_groups = array();
        foreach ($total_groups[0] as $key => $val) {
            $arr_groups[$val['id']] = $val['name'];
        }
        // prepare languages array
        $total_languages = Languages::GetAllActive();
        $arr_languages = array();
        foreach ($total_languages[0] as $key => $val) {
            $arr_languages[$val['abbreviation']] = $val['lang_name'];
        }
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_FIRST_NAME => array('table' => 'c', 'field' => 'first_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _LAST_NAME => array('table' => 'c', 'field' => 'last_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _EMAIL => array('table' => 'c', 'field' => 'email', 'type' => 'text', 'sign' => 'like%', 'width' => '90px'), _ACTIVE => array('table' => 'c', 'field' => 'is_active', 'type' => 'dropdownlist', 'source' => array('0' => _NO, '1' => _YES), 'sign' => '=', 'width' => '85px'), _GROUP => array('table' => 'c', 'field' => 'group_id', 'type' => 'dropdownlist', 'source' => $arr_groups, 'sign' => '=', 'width' => '85px'));
        $customer_ip = get_current_ip();
        $datetime_format = get_datetime_format();
        $date_format_view = get_date_format('view');
        $date_format_edit = get_date_format('edit');
        $default_plan_info = AdvertisePlans::GetDefaultPlanInfo();
        $default_plan_id = isset($default_plan_info['id']) ? (int) $default_plan_info['id'] : 0;
        $default_plan_lc = isset($default_plan_info['listings_count']) ? (int) $default_plan_info['listings_count'] : 0;
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT
									c.' . $this->primaryKey . ',
		                            c.*,
									CONCAT(c.first_name, " ", c.last_name) as full_name,
									IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active,
									cg.name as group_name
								FROM ' . $this->tableName . ' c
									LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id ';
        // define view mode fields
        $this->arrViewModeFields = array('full_name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'user_name' => array('title' => _USERNAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'link', 'href' => 'mailto:{email}', 'align' => 'left', 'width' => '', 'maxlength' => '36'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'source' => $arr_countries), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label', 'align' => 'center', 'width' => '90px'), 'group_name' => array('title' => _GROUP, 'type' => 'label', 'align' => 'left', 'width' => '90px'), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '50px'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => false, 'maxlength' => '70', 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'validation_type' => 'text', 'maxlength' => '32', 'validation_minlength' => '4', 'readonly' => false, 'unique' => true), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'required' => true, 'validation_type' => 'password', 'maxlength' => '20', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'default' => Application::Get('lang'), 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => date('Y-m-d H:i:s')), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $customer_ip), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false), 'is_removed' => array('title' => _REMOVED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '1' ? (int) $default_plan_lc : '0'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '2' ? (int) $default_plan_lc : '0'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '3' ? (int) $default_plan_lc : '0'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '4' ? (int) $default_plan_lc : '0')));
        //----------------------------------------------------------------------
        // EDIT MODE
        // * password field must be written directly in SQL!!!
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
									' . $this->tableName . '.' . $this->primaryKey . ',
		                            ' . $this->tableName . '.*,
									' . $this->tableName . '.user_password,
									' . $this->tableName . '.date_created,
									' . $this->tableName . '.date_lastlogin,
									' . $this->tableName . '.notification_status_changed
								FROM ' . $this->tableName . '
								WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => true, 'maxlength' => '70', 'readonly' => false, 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'maxlength' => '20', 'required' => true, 'validation_type' => 'password', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY, 'visible' => $this->allow_changing_password == 'yes' ? true : false), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_removed' => array('title' => _REMOVED, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => '')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label')));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = 'SELECT
									c.' . $this->primaryKey . ',
		                            c.*,
									IF(c.email_notifications, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as email_notifications,
									IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active,
									IF(c.is_removed, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_removed,
									c.date_created,
									c.date_lastlogin,
									c.notification_status_changed,
									cg.name as group_name
								FROM ' . $this->tableName . ' c
									LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id
								WHERE c.' . $this->primaryKey . ' = _RID_';
        $this->arrDetailsModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'label'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'label'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'format' => 'date', 'format_parameter' => $date_format_view), 'url' => array('title' => _URL, 'type' => 'label')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'label'), 'b_address' => array('title' => _ADDRESS, 'type' => 'label'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'label'), 'b_city' => array('title' => _CITY, 'type' => 'label'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'label'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'source' => $arr_countries), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'label')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'label'), 'fax' => array('title' => _FAX, 'type' => 'label'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'group_name' => array('title' => _CUSTOMER_GROUP, 'type' => 'label'), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'label'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label'), 'customer_removed' => array('title' => _REMOVED, 'type' => 'label'), 'comments' => array('title' => _COMMENTS, 'type' => 'label')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label')));
    }
Ejemplo n.º 9
0
    /**	
     * Draws rewrite button
     * 		@param $draw
     */
    public function DrawRewriteButton($draw = true)
    {
        global $objSettings;
        $total_languages = Languages::GetAllActive();
        $output = '';
        $button_align_left = Application::Get('lang_dir') == 'ltr' ? 'text-align:left;' : 'text-align:right;';
        $button_align_right = Application::Get('lang_dir') == 'ltr' ? 'text-align:right;' : 'text-align:left;';
        if ($this->GetVocabularySize() <= 0) {
            $output .= '<form action="index.php?admin=vocabulary&filter_by=A" method="post">';
            $output .= draw_hidden_field('submition_type', '2', false);
            $output .= draw_token_field(false);
            $output .= '<table align="center" width="100%" border="0" cellspacing="0" cellpadding="3" class="main_text">
				  <tr valign="top">					
					<td style="' . $button_align_left . '">
						' . draw_languages_box('language_id', $total_languages[0], 'abbreviation', 'lang_name', $this->languageId, '', 'onchange="appGoTo(\'admin=vocabulary' . $this->filterByUrl . '&language_id=\'+this.value)"', false) . '
					</td>
					<td style="padding:5px;' . $button_align_right . '">
						' . prepare_permanent_link('index.php?admin=vocabulary&act=upload_form' . $this->langIdByUrl . $this->filterByUrl, '[ ' . _UPLOAD_FROM_FILE . ' ]') . '&nbsp;&nbsp;&nbsp;
					</td>
					<td width="185px" style="' . $button_align_left . '">
						<input class="form_button" type="submit" name="btnRewrite" value="' . decode_text(_BUTTON_REWRITE) . '"><br />
						<input class="form_checkbox" type="checkbox" name="all_languages" id="chk_all_languages"><label for="chk_all_languages">' . _APPLY_TO_ALL_LANGUAGES . '</label>
					</td>
				  </tr>
				  </table>
			</form>';
        }
        if ($draw) {
            echo $output;
        } else {
            return $output;
        }
    }
Ejemplo n.º 10
0
    /**
     * After-insertion operation
     */
    public function AfterInsertRecord()
    {
        // --- clone to other languages
        $total_languages = Languages::GetAllActive();
        $language_id = self::GetParameter('language_id', false);
        $news_code = self::GetParameter('news_code', false);
        $header_text = self::GetParameter('header_text', false);
        $body_text = self::GetParameter('body_text', false);
        $date_created = self::GetParameter('date_created', false);
        for ($i = 0; $i < $total_languages[1]; $i++) {
            if ($language_id != '' && $total_languages[0][$i]['abbreviation'] != $language_id) {
                $sql = 'INSERT INTO ' . TABLE_NEWS . ' (id, news_code, header_text, body_text, date_created, language_id)
						VALUES(NULL, \'' . encode_text($news_code) . '\', \'' . encode_text($header_text) . '\', \'' . encode_text($body_text) . '\', \'' . encode_text($date_created) . '\', \'' . encode_text($total_languages[0][$i]['abbreviation']) . '\')';
                database_void_query($sql);
                $this->SetSQLs('insert_lan_' . $total_languages[0][$i]['abbreviation'], $sql);
            }
        }
    }
Ejemplo n.º 11
0
    /**
     * Creates new page
     *		@param $params - set of fields
     *		@param $copy_to_other_langs
     */
    public function PageCreate($params = array(), $copy_to_other_langs = 'yes')
    {
        // Get input parameters
        if (isset($params['content_type'])) {
            $this->page['content_type'] = $params['content_type'];
        }
        if (isset($params['link_url'])) {
            $this->page['link_url'] = $params['link_url'];
        }
        if (isset($params['link_target'])) {
            $this->page['link_target'] = $params['link_target'];
        }
        if (isset($params['page_title'])) {
            $this->page['page_title'] = $params['page_title'];
        }
        if (isset($params['page_key'])) {
            $this->page['page_key'] = $params['page_key'];
        }
        if (isset($params['page_text'])) {
            $this->page['page_text'] = $params['page_text'];
        }
        if (isset($params['menu_id'])) {
            $this->page['menu_id'] = $params['menu_id'];
        }
        if (isset($params['menu_link'])) {
            $this->page['menu_link'] = $params['menu_link'];
        }
        if (isset($params['is_published'])) {
            $this->page['is_published'] = $params['is_published'];
        }
        if (isset($params['language_id'])) {
            $this->page['language_id'] = $params['language_id'];
        }
        if (isset($params['comments_allowed'])) {
            $this->page['comments_allowed'] = $params['comments_allowed'];
        }
        if (isset($params['show_in_search'])) {
            $this->page['show_in_search'] = $params['show_in_search'];
        }
        if (isset($params['priority_order'])) {
            $this->page['priority_order'] = $params['priority_order'];
        }
        if (isset($params['access_level'])) {
            $this->page['access_level'] = $params['access_level'];
        }
        if (isset($params['finish_publishing'])) {
            $this->page['finish_publishing'] = $params['finish_publishing'];
        }
        if (isset($params['tag_title'])) {
            $this->page['tag_title'] = $params['tag_title'];
        }
        if (isset($params['tag_keywords'])) {
            $this->page['tag_keywords'] = $params['tag_keywords'];
        }
        if (isset($params['tag_description'])) {
            $this->page['tag_description'] = $params['tag_description'];
        }
        // Menu link cannot be more then 40 characters
        if (strlen($this->page['menu_link']) > 40) {
            $this->error = _PAGE_LINK_TOO_LONG;
            return false;
        } else {
            if ($this->page['page_title'] == '') {
                $this->error = _PAGE_HEADER_EMPTY;
                return false;
            } else {
                if ($this->page['content_type'] == 'link' && $this->page['link_url'] == '') {
                    $this->error = str_replace('_FIELD_', '<b>' . _LINK . '</b>', _FIELD_CANNOT_BE_EMPTY);
                    $this->focusOnField = 'link_url';
                    return false;
                } else {
                    if (!check_integer($this->page['priority_order']) || $this->page['priority_order'] < 0) {
                        $this->error = str_replace('_FIELD_', '<b>' . _ORDER . '</b>', _FIELD_MUST_BE_NUMERIC_POSITIVE);
                        $this->focusOnField = 'priority_order';
                        return false;
                    } else {
                        if (strlen($this->page['tag_title']) > 255) {
                            $msg_text = str_replace('_FIELD_', '<b>TITLE</b>', _FIELD_LENGTH_ALERT);
                            $msg_text = str_replace('_LENGTH_', '255', $msg_text);
                            $this->error = $msg_text;
                            $this->focusOnField = 'tag_title';
                            return false;
                        } else {
                            if (strlen($this->page['tag_keywords']) > 512) {
                                $msg_text = str_replace('_FIELD_', '<b>KEYWORDS</b>', _FIELD_LENGTH_ALERT);
                                $msg_text = str_replace('_LENGTH_', '512', $msg_text);
                                $this->error = $msg_text;
                                $this->focusOnField = 'tag_keywords';
                                return false;
                            } else {
                                if (strlen($this->page['tag_description']) > 512) {
                                    $msg_text = str_replace('_FIELD_', '<b>DESCRIPTION</b>', _FIELD_LENGTH_ALERT);
                                    $msg_text = str_replace('_LENGTH_', '512', $msg_text);
                                    $this->error = $msg_text;
                                    $this->focusOnField = 'tag_description';
                                    return false;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (strtolower(SITE_MODE) == 'demo') {
            $this->error = _OPERATION_BLOCKED;
            return false;
        } else {
            if ($copy_to_other_langs == 'yes') {
                $total_languages = Languages::GetAllActive();
            } else {
                $total_languages = Languages::GetAllLanguages(' priority_order ASC', '', 'abbreviation=\'' . $this->page['language_id'] . '\'');
            }
            $page_code = get_random_string(10);
            for ($i = 0; $i < $total_languages[1]; $i++) {
                // Create new record
                $sql = 'INSERT INTO ' . TABLE_PAGES . '(
						id,
						page_code,
						language_id,
						content_type,
						link_url,
						link_target,
						page_key,
						page_title,
						page_text,
						menu_id,
						menu_link,
						tag_title,
						tag_keywords,
						tag_description,
						comments_allowed,
						show_in_search,
						date_created,
						date_updated,
						finish_publishing,
						is_published,
						is_system_page,
						system_page,
						status_changed,
						access_level,
						priority_order
					)VALUES(
						NULL,
						\'' . $page_code . '\',
						\'' . $total_languages[0][$i]['abbreviation'] . '\',
						\'' . $this->page['content_type'] . '\',
						\'' . encode_text($this->page['link_url']) . '\',
						\'' . $this->page['link_target'] . '\',
						\'\',
						\'' . encode_text($this->page['page_title']) . '\',
						\'' . encode_text($this->page['page_text']) . '\',
						' . (int) $this->GetMenuIdByLang($this->page['menu_id'], $total_languages[0][$i]['abbreviation']) . ',
						\'' . encode_text($this->page['menu_link']) . '\',
						\'' . encode_text($this->page['tag_title']) . '\',
						\'' . encode_text($this->page['tag_keywords']) . '\',
						\'' . encode_text($this->page['tag_description']) . '\',
						' . (int) $this->page['comments_allowed'] . ',
						' . (int) $this->page['show_in_search'] . ',
						\'' . date('Y-m-d H:i:s') . '\',
						\'0000-00-00 00:00:00\',
						\'' . $this->page['finish_publishing'] . '\',
						' . (int) $this->page['is_published'] . ',
						0,
						\'\',
						\'0000-00-00 00:00:00\',
						\'' . $this->page['access_level'] . '\',
						' . (int) $this->page['priority_order'] . '
					)';
                if (database_void_query($sql)) {
                    // Update page_key
                    $last_insert_id = mysql_insert_id();
                    $sql = 'UPDATE ' . TABLE_PAGES . ' 
							SET page_key=\'' . $this->page['page_key'] . '\'
							WHERE id=' . (int) $last_insert_id;
                    if (database_void_query($sql)) {
                        // ok
                        $this->page_id = $last_insert_id;
                    } else {
                        $this->error = _TRY_LATER;
                        return false;
                    }
                } else {
                    $this->error = _TRY_LATER;
                    return false;
                }
            }
            return true;
        }
    }
Ejemplo n.º 12
0
			<tr>
				<td	style="padding-left:5px;" colspan="3"><input class="form_button" type="submit" name="btnSubmit" value="' . _BUTTON_CHANGE . '"></td>
			</tr>
			</table>
		</form>';
    } else {
        if ($tabid == '1_2') {
            $tab_content_2 = '<form name="frmSettings" id="frmSettings" action="index.php?admin=settings" method="post">
			' . draw_hidden_field('tabid', $tabid, false) . '
			' . draw_token_field(false) . '
			
			<table width="99%" border="0" cellspacing="5" cellpadding="5" class="main_text">
			<tr valign="top">
				<td width="150px">' . _LANGUAGE . ':</td>
				<td>';
            $all_languages = Languages::GetAllActive();
            $tab_content_2 .= draw_languages_box('sel_language_id', $all_languages[0], 'abbreviation', 'lang_name', $language_id, '', 'onchange="javascript:appFormSubmit(\'frmSettings\');"', false);
            $tab_content_2 .= '</td>				
			</tr>
			</table>
		</form>

		<fieldset style="margin:10px;">
		<legend>' . _HEADERS_AND_FOOTERS . '</legend>
			<form action="index.php?admin=settings" method="post">
			' . draw_hidden_field('submition_type', 'visual_settings', false) . '
			' . draw_hidden_field('tabid', $tabid, false) . '
			' . draw_hidden_field('sel_language_id', $language_id, false) . '
			' . draw_token_field(false) . '
			
			<table width="99%" border="0" cellspacing="5" cellpadding="5" class="main_text">
Ejemplo n.º 13
0
    function __construct($type = '', $actions = array())
    {
        parent::__construct();
        $this->params = array();
        ///if(isset($_POST['parameter1']))   $this->params['parameter1'] = $_POST['parameter1'];
        ///if(isset($_POST['parameter2']))   $this->params['parameter2'] = $_POST['parameter2'];
        ///if(isset($_POST['parameter3']))   $this->params['parameter3'] = $_POST['parameter3'];
        // for checkboxes
        ///if(isset($_POST['parameter4']))   $this->params['parameter4'] = $_POST['parameter4']; else $this->params['parameter4'] = '0';
        $this->params['language_id'] = MicroGrid::GetParameter('language_id');
        $this->primaryKey = 'id';
        $this->tableName = TABLE_PAGES;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?admin=pages' . ($type != '' ? '&type=' . $type : '');
        $this->actions = array('add' => false, 'edit' => false, 'details' => false, 'delete' => false);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowLanguages = true;
        $this->languageId = $this->params['language_id'] != '' ? $this->params['language_id'] : Languages::GetDefaultLang();
        $this->WHERE_CLAUSE = 'WHERE
									' . $this->tableName . '.is_system_page = ' . ($type == 'system' ? '1' : '0') . ' AND 
									' . $this->tableName . '.is_home = 0 AND
									' . $this->tableName . '.is_removed = 0 AND
									' . $this->tableName . '.language_id = \'' . $this->languageId . '\'';
        $this->ORDER_CLAUSE = 'ORDER BY priority_order ASC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isFilteringAllowed = $type == 'system' ? false : true;
        // prepare menus array
        $total_menus = Menu::GetAll(' menu_order ASC', TABLE_MENUS, '', $this->languageId);
        $arr_menus = array();
        foreach ($total_menus[0] as $key => $val) {
            $arr_menus[$val['id']] = $val['menu_name'] . ($val['menu_placement'] == 'hidden' ? ' (' . _HIDDEN . ')' : '');
        }
        // define filtering fields
        $this->arrFilteringFields = array(_MENU_WORD => array('table' => TABLE_MENUS, 'field' => 'id', 'type' => 'dropdownlist', 'source' => $arr_menus, 'sign' => '=', 'width' => '150px'));
        // prepare languages array
        $total_languages = Languages::GetAllActive();
        $arr_languages = array();
        foreach ($total_languages[0] as $key => $val) {
            $arr_languages[$val['abbreviation']] = $val['lang_name'];
        }
        $comments_allow = Modules::IsModuleInstalled('comments') ? ModulesSettings::Get('comments', 'comments_allow') : 'no';
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ',
									' . $this->tableName . '.language_id,
									' . $this->tableName . '.content_type,
									' . $this->tableName . '.link_url,
									' . $this->tableName . '.link_target,
									' . $this->tableName . '.page_key,
									IF(' . $this->tableName . '.page_title != "", ' . $this->tableName . '.page_title, "- ' . _UNDEFINED . ' -") as page_title,
									' . $this->tableName . '.page_text,
									' . $this->tableName . '.menu_id,
									IF(' . $this->tableName . '.menu_link != "", ' . $this->tableName . '.menu_link, "- ' . _UNDEFINED . ' -") as menu_link,
									' . $this->tableName . '.comments_allowed,
									' . $this->tableName . '.is_home,
									' . $this->tableName . '.priority_order,
									IF(' . $this->tableName . '.access_level = "public", "' . _PUBLIC . '", "' . _REGISTERED . '") my_access_level,
									CASE
										WHEN ' . $this->tableName . '.is_published = 1 THEN
											IF(
												(finish_publishing = "0000-00-00" OR finish_publishing >= \'' . date('Y-m-d') . '\'),
												"<img src=\\"images/published_g.gif\\" alt=\\"\\" />",
												"<img src=\\"images/expired.gif\\" alt=\\"' . _EXPIRED . '\\" />"
											  ) 		
										ELSE "<img src=\\"images/published_x.gif\\" alt=\\"\\" />"
									END as is_published,
									IF(' . TABLE_MENUS . '.menu_name != "", ' . TABLE_MENUS . '.menu_name, "' . _NOT_AVAILABLE . '") as menu_name,
									CASE
										WHEN ' . $this->tableName . '.comments_allowed = 1 THEN
											CONCAT("<a href=\\"index.php?admin=mod_comments_management&pid=",
											' . $this->tableName . '.' . $this->primaryKey . ', "\\">", (SELECT COUNT(*) FROM ' . TABLE_COMMENTS . ' c WHERE c.article_id = ' . $this->tableName . '.' . $this->primaryKey . '),											
											(SELECT IF(COUNT(*) > 0, CONCAT("(",COUNT(*),")"), "") FROM ' . TABLE_COMMENTS . ' c WHERE c.is_published = 0 AND c.article_id = ' . $this->tableName . '.' . $this->primaryKey . '),
											"</a>")
										ELSE
											"<span class=gray>' . _NOT_ALLOWED . '</span>"
									END as comments_count,
									CONCAT(
										" <a href=\\"index.php?page=pages' . ($type == 'system' ? '&type=' . $type : '') . '&pid=", ' . $this->tableName . '.' . $this->primaryKey . ', "&mg_language_id=' . $this->languageId . '\\">' . _VIEW_WORD . '</a>
										' . ($actions['edit'] ? ' | <a href=\\"index.php?admin=pages_edit' . ($type != '' ? '&type=' . $type : '') . '&pid=", ' . $this->tableName . '.' . $this->primaryKey . ', "\\">' . _EDIT_WORD . '</a>' : '') . '
										' . ($actions['delete'] && $type != 'system' ? ' | <a href=\\"javascript:confirmRemoving(\'", ' . $this->tableName . '.' . $this->primaryKey . ', "\')\\">' . _REMOVE . '</a>' : '') . '
										") as action_links
								FROM ' . $this->tableName . '
									LEFT OUTER JOIN ' . TABLE_MENUS . ' ON ' . $this->tableName . '.menu_id=' . TABLE_MENUS . '.id';
        // define view mode fields
        $this->arrViewModeFields = array();
        $this->arrViewModeFields['menu_link'] = array('title' => _MENU_LINK, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '40');
        if ($type == 'system') {
            $this->arrViewModeFields['page_title'] = array('title' => _PAGE_HEADER, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '40');
        }
        $this->arrViewModeFields['menu_name'] = array('title' => _MENU_WORD, 'type' => 'label', 'align' => 'center', 'width' => '', 'visible' => $type == 'system' ? false : true);
        $this->arrViewModeFields['is_published'] = array('title' => _PUBLISHED, 'type' => 'label', 'align' => 'center', 'width' => '80px');
        $this->arrViewModeFields['my_access_level'] = array('title' => _ACCESS, 'type' => 'label', 'align' => 'center', 'width' => '75px');
        $this->arrViewModeFields['priority_order'] = array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '65px', 'visible' => 'true', 'movable' => true);
        $this->arrViewModeFields['comments_count'] = array('title' => _COMMENTS, 'type' => 'label', 'align' => 'center', 'width' => '90px', 'visible' => $comments_allow == 'yes' ? true : false);
        $this->arrViewModeFields['id'] = array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '50px');
        $this->arrViewModeFields['action_links'] = array('title' => _ACTIONS, 'type' => 'label', 'align' => 'center', 'sortable' => false, 'nowrap' => 'nowrap', 'width' => $type == 'system' ? '90px' : '130px');
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array();
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.parameter1,
								' . $this->tableName . '.parameter2,
								' . $this->tableName . '.parameter3
							FROM ' . $this->tableName . '
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array();
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array();
    }