function mso_edit_comuser($data) { global $MSO; $CI =& get_instance(); $data = mso_xss_clean_data($data, array('user_login', 'password', 'comusers_email', 'comusers_new_password', 'comusers_nik', 'comusers_icq', 'comusers_url', 'comusers_msn', 'comusers_jaber', 'comusers_skype', 'comusers_avatar_url', 'comusers_description', 'comusers_date_birth_y', 'comusers_date_birth_m', 'comusers_date_birth_d', 'comusers_notify', 'comusers_language', 'comusers_activate_key', 'comusers_activate_string', 'comusers_admin_note')); if (isset($data['user_login'])) { $user_login = $data['user_login']; } else { $user_login = $MSO->data['session']['users_login']; } if (isset($data['password'])) { $password = $data['password']; } else { $password = $MSO->data['session']['users_password']; } # проверка можно ли редактировать этому пользователю с этим паролем и этим разрешением if (!mso_check_user_password($user_login, $password, 'admin_comusers')) { return array('result' => 0, 'description' => 'Login/password incorrect'); } $comusers_id = isset($data['comusers_id']) ? (int) $data['comusers_id'] : 0; if ($comusers_id <= 0) { return array('result' => 0, 'description' => 'Comuser ID incorrect'); } $comusers_email = isset($data['comusers_email']) ? $data['comusers_email'] : ''; # нет email - ошибка if (!$comusers_email or !mso_valid_email($comusers_email)) { return array('result' => 0, 'description' => 'Email incorrect'); } ### пароль $comusers_new_password = ''; if (isset($data['comusers_new_password'])) { $comusers_new_password = mso_strip($data['comusers_new_password'], false); if ($comusers_new_password and strlen($comusers_new_password) > 6) { $comusers_new_password = mso_md5($comusers_new_password); } else { return array('result' => 0, 'description' => 'Password incorrect'); } } $comusers_nik = isset($data['comusers_nik']) ? $data['comusers_nik'] : ''; $comusers_icq = isset($data['comusers_icq']) ? $data['comusers_icq'] : ''; $comusers_url = isset($data['comusers_url']) ? $data['comusers_url'] : ''; $comusers_msn = isset($data['comusers_msn']) ? $data['comusers_msn'] : ''; $comusers_jaber = isset($data['comusers_jaber']) ? $data['comusers_jaber'] : ''; $comusers_skype = isset($data['comusers_skype']) ? $data['comusers_skype'] : ''; $comusers_avatar_url = isset($data['comusers_avatar_url']) ? $data['comusers_avatar_url'] : ''; $comusers_description = isset($data['comusers_description']) ? $data['comusers_description'] : ''; $comusers_date_birth_y = isset($data['comusers_date_birth_y']) ? $data['comusers_date_birth_y'] : '1970'; $comusers_date_birth_m = isset($data['comusers_date_birth_m']) ? $data['comusers_date_birth_m'] : '1'; $comusers_date_birth_d = isset($data['comusers_date_birth_d']) ? $data['comusers_date_birth_d'] : '1'; $comusers_notify = isset($data['comusers_notify']) ? $data['comusers_notify'] : '0'; $comusers_language = isset($data['comusers_language']) ? $data['comusers_language'] : 'ru'; $comusers_activate_key = isset($data['comusers_activate_key']) ? $data['comusers_activate_key'] : ''; $comusers_activate_string = isset($data['comusers_activate_string']) ? $data['comusers_activate_string'] : ''; $comusers_admin_note = isset($data['comusers_admin_note']) ? $data['comusers_admin_note'] : ''; # дату в MySQL $comusers_date_birth = mso_date_convert_to_mysql($comusers_date_birth_y, $comusers_date_birth_m, $comusers_date_birth_d); $upd_data = array('comusers_nik' => $comusers_nik, 'comusers_admin_note' => $comusers_admin_note, 'comusers_email' => $comusers_email, 'comusers_icq' => $comusers_icq, 'comusers_url' => $comusers_url, 'comusers_msn' => $comusers_msn, 'comusers_jaber' => $comusers_jaber, 'comusers_skype' => $comusers_skype, 'comusers_avatar_url' => $comusers_avatar_url, 'comusers_description' => $comusers_description, 'comusers_date_birth' => $comusers_date_birth, 'comusers_notify' => $comusers_notify, 'comusers_language' => $comusers_language, 'comusers_activate_string' => $comusers_activate_string, 'comusers_activate_key' => $comusers_activate_key); if ($comusers_new_password) { $upd_data['comusers_password'] = $comusers_new_password; } // _pr($upd_data); $CI->db->where('comusers_id', $comusers_id); $res = $CI->db->update('comusers', $upd_data) ? '1' : '0'; mso_flush_cache(); // сбросим кэш $response = array('result' => $res, 'description' => 'Update'); return $response; }
function calendar_widget_custom($arg = array(), $num = 1) { # массив названий месяцев if (!isset($arg['months'])) { $arg['months'] = array(t('Январь'), t('Февраль'), t('Март'), t('Апрель'), t('Май'), t('Июнь'), t('Июль'), t('Август'), t('Сентябрь'), t('Октябрь'), t('Ноябрь'), t('Декабрь')); } # массив названий дней недели if (!isset($arg['days'])) { $arg['days'] = array(t('Пн'), t('Вт'), t('Ср'), t('Чт'), t('Пт'), t('Сб'), t('Вс')); } # оформление виджета if (!isset($arg['header'])) { $arg['header'] = '<h2 class="box"><span>' . t('Календарь') . '</span></h2>'; } if (!isset($arg['block_start'])) { $arg['block_start'] = '<div class="calendar">'; } if (!isset($arg['block_end'])) { $arg['block_end'] = '</div>'; } if (!isset($arg['elem_previous'])) { $arg['elem_previous'] = '««'; } if (!isset($arg['elem_next'])) { $arg['elem_next'] = '»»'; } $prefs = array('start_day' => 'monday', 'month_type' => 'long', 'day_type' => 'long', 'show_next_prev' => TRUE, 'local_time' => time(), 'next_prev_url' => getinfo('site_url') . 'archive/'); $prefs['template'] = ' {table_open}<table border="0" cellpadding="0" cellspacing="0">{/table_open} {heading_row_start}<tr>{/heading_row_start} {heading_previous_cell}<th><a href="{previous_url}">' . $arg['elem_previous'] . '</a></th>{/heading_previous_cell} {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell} {heading_next_cell}<th><a href="{next_url}">' . $arg['elem_next'] . '</a></th>{/heading_next_cell} {heading_row_end}</tr>{/heading_row_end} {week_row_start}<tr class="week">{/week_row_start} {week_day_cell}<td>{week_day}</td>{/week_day_cell} {week_row_end}</tr>{/week_row_end} {cal_row_start}<tr>{/cal_row_start} {cal_cell_start}<td>{/cal_cell_start} {cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content} {cal_cell_content_today}<div class="today-content"><a href="{content}">{day}</a></div>{/cal_cell_content_today} {cal_cell_no_content}{day}{/cal_cell_no_content} {cal_cell_no_content_today}<div class="today">{day}</div>{/cal_cell_no_content_today} {cal_cell_blank} {/cal_cell_blank} {cal_cell_end}</td>{/cal_cell_end} {cal_row_end}</tr>{/cal_row_end} {table_close}</table>{/table_close}'; $CI =& get_instance(); $CI->load->library('calendar', $prefs); $mktime = mktime() + getinfo('time_zone') * 60 * 60; // с учетом часового пояса ? # если это архив, то нужно показать календарь на этот год и месяц if (is_type('archive')) { $year = (int) mso_segment(2); if ($year > date('Y', $mktime) or $year < 2000) { $year = date('Y', $mktime); } $month = (int) mso_segment(3); if ($month > 12 or $month < 1) { $month = date('m', $mktime); } } else { $year = date('Y', $mktime); $month = date('m', $mktime); } # для выделения дат нужно смотреть записи, которые в этом месяце $CI->db->select('page_date_publish'); $CI->db->from('page'); $CI->db->join('page_type', 'page_type.page_type_id = page.page_type_id'); $CI->db->where('page_status', 'publish'); $CI->db->where('page_type_name', 'blog'); $CI->db->where('page_date_publish >= ', mso_date_convert_to_mysql($year, $month)); $CI->db->where('page_date_publish < ', mso_date_convert_to_mysql($year, $month + 1)); # не выводить неопубликованные $CI->db->where('page_date_publish < ', mso_date_convert('Y-m-d H:i:s', date('Y-m-d H:i:s'))); $query = $CI->db->get(); $data = array(); if ($query->num_rows() > 0) { $pages = $query->result_array(); foreach ($pages as $key => $page) { $d = (int) mso_date_convert('d', $page['page_date_publish']); $data[$d] = getinfo('site_url') . 'archive/' . $year . '/' . $month . '/' . $d; } /* $data = array( 3 => 'http://your-site.com/news/article/2006/03/', 7 => 'http://your-site.com/news/article/2006/07/" title="123', 26 => 'http://your-site.com/news/article/2006/26/' ); */ } $out = $CI->calendar->generate($year, $month, $data); $month_en = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $day_en = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); $out = str_replace($month_en, $arg['months'], $out); $out = str_replace($day_en, $arg['days'], $out); # если используется английский, то заменим большие названия на маленькие $out = str_replace(array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'), array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), $out); $out = $arg['header'] . $arg['block_start'] . $out . $arg['block_end']; return $out; }