/** * Module Installed * * Only display the content between the tags if the named module is installed * * @param string $name * * @return tagdata or FALSE */ function smarty_block_module_installed($params, $tagdata, &$smarty, &$repeat) { if (module_installed($params['name'])) { return $tagdata; } else { return ''; } }
/** * Search * * Performs the search and stores results * * @param string $query */ function search($query = '', $page = 0) { $this->CI->load->helper('shorten'); // content search $content_types = unserialize(setting('search_content_types')); if (!empty($content_types)) { $this->CI->load->model('publish/content_model'); $this->CI->load->model('publish/content_type_model'); $this->CI->load->model('custom_fields_model'); foreach ($content_types as $type => $summary_field) { $content = $this->CI->content_model->get_contents(array('keyword' => $query, 'type' => $type, 'sort' => 'relevance', 'sort_dir' => 'DESC', 'limit' => '50')); if (!empty($content)) { foreach ($content as $item) { // prep summary field if (!empty($summary_field)) { $item['summary'] = shorten(strip_tags($item[$summary_field]), setting('search_trim'), TRUE); } $item['result_type'] = 'content'; $this->content_results[$item['id']] = $item; $this->relevance_keys['content|' . $item['id']] = $item['relevance']; } } } } // product search if (setting('search_products') == '1' and module_installed('store')) { $this->CI->load->model('store/products_model'); $products = $this->CI->products_model->get_products(array('keyword' => $query, 'sort' => 'relevance', 'sort_dir' => 'DESC', 'limit' => '50')); if (!empty($products)) { foreach ($products as $product) { // prep summary field $product['summary'] = shorten(strip_tags($product['description']), setting('search_trim'), TRUE); $product['result_type'] = 'product'; $this->product_results[$product['id']] = $product; $this->relevance_keys['product|' . $product['id']] = $product['relevance']; } } } // sort results arsort($this->relevance_keys); // put together final results array foreach ($this->relevance_keys as $item => $relevance) { list($type, $id) = explode('|', $item); if ($type == 'content') { $this->results[] = $this->content_results[$id]; } elseif ($type == 'product') { $this->results[] = $this->product_results[$id]; } } // how many total results? $this->total_results = count($this->results); if ($this->total_results == 0) { return array(); } // grab the segment of the array corresponding to our page return array_slice($this->results, $page * $this->results_per_page, $this->results_per_page); }
/** * Standard modular run function for search results. * * @param string Search string * @param boolean Whether to only do a META (tags) search * @param ID_TEXT Order direction * @param integer Start position in total results * @param integer Maximum results to return in total * @param boolean Whether only to search titles (as opposed to both titles and content) * @param string Where clause that selects the content according to the main search string (SQL query fragment) (blank: full-text search) * @param SHORT_TEXT Username/Author to match for * @param ?MEMBER Member-ID to match for (NULL: unknown) * @param TIME Cutoff date * @param string The sort type (gets remapped to a field in this function) * @set title add_date * @param integer Limit to this number of results * @param string What kind of boolean search to do * @set or and * @param string Where constraints known by the main search code (SQL query fragment) * @param string Comma-separated list of categories to search under * @param boolean Whether it is a boolean search * @return array List of maps (template, orderer) */ function run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $limit_to, $boolean_operator, $where_clause, $search_under, $boolean_search) { unset($author_id); unset($limit_to); if (!module_installed('catalogues')) { return array(); } $remapped_orderer = ''; switch ($sort) { case 'title': $remapped_orderer = 'cc_title'; break; case 'add_date': $remapped_orderer = 'cc_add_date'; break; } require_code('catalogues'); require_lang('catalogues'); // Calculate our where clause (search) if ($author != '') { return array(); } if (!is_null($cutoff)) { $where_clause .= ' AND '; $where_clause .= 'cc_add_date>' . strval($cutoff); } if (!$GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $where_clause .= ' AND '; $where_clause .= 'z.category_name IS NOT NULL'; $where_clause .= ' AND '; $where_clause .= 'p.category_name IS NOT NULL'; } $g_or = _get_where_clause_groups(get_member()); // Calculate and perform query if ($g_or == '') { $rows = get_search_rows('catalogue_category', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'catalogue_categories r', array('r.cc_title', 'r.cc_description'), $where_clause, $content_where, $remapped_orderer, 'r.*'); } else { $rows = get_search_rows('catalogue_category', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'catalogue_categories r LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access z ON (' . db_string_equal_to('z.module_the_name', 'catalogues_category') . ' AND z.category_name=r.id AND ' . str_replace('group_id', 'z.group_id', $g_or) . ') LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_category_access p ON (' . db_string_equal_to('p.module_the_name', 'catalogues_catalogue') . ' AND p.category_name=r.c_name AND ' . str_replace('group_id', 'p.group_id', $g_or) . ')', array('r.cc_title', 'r.cc_description'), $where_clause, $content_where, $remapped_orderer, 'r.*'); } $out = array(); foreach ($rows as $i => $row) { $out[$i]['data'] = $row; unset($rows[$i]); if ($remapped_orderer != '' && array_key_exists($remapped_orderer, $row)) { $out[$i]['orderer'] = $row[$remapped_orderer]; } elseif (substr($remapped_orderer, 0, 7) == '_rating') { $out[$i]['orderer'] = $row['compound_rating']; } } return $out; }
function admin_preload() { if (module_installed('billing', 'store', 'coupons')) { $this->CI->admin_navigation->child_link('reports', 10, 'Invoices', site_url('admincp/reports/invoices')); $this->CI->admin_navigation->child_link('reports', 20, 'Product Orders', site_url('admincp/reports/products')); $this->CI->admin_navigation->child_link('reports', 30, 'Subscriptions', site_url('admincp/reports/subscriptions')); $this->CI->admin_navigation->child_link('reports', 40, 'Cancellations', site_url('admincp/reports/cancellations')); $this->CI->admin_navigation->child_link('reports', 50, 'Expirations', site_url('admincp/reports/expirations')); $this->CI->admin_navigation->child_link('reports', 55, 'Coupons', site_url('admincp/reports/coupons')); $this->CI->admin_navigation->child_link('reports', 60, 'Taxes Received', site_url('admincp/reports/taxes')); } $this->CI->admin_navigation->child_link('reports', 70, 'Registrations', site_url('admincp/reports/registrations')); $this->CI->admin_navigation->child_link('reports', 80, 'Popular Content', site_url('admincp/reports/popular')); $this->CI->admin_navigation->child_link('configuration', 100, 'Cronjob', site_url('admincp/reports/cronjob')); }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('calendar')) { return NULL; } if (!has_actual_page_access(get_member(), 'calendar')) { return NULL; } if ($GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)') == 0) { return NULL; } require_lang('calendar'); $info = array(); $info['lang'] = do_lang_tempcode('CALENDAR'); $info['default'] = false; return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('iotds')) { return NULL; } if (!has_actual_page_access(get_member(), 'iotds')) { return NULL; } if ($GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)') == 0) { return NULL; } require_lang('iotds'); $info = array(); $info['lang'] = do_lang_tempcode('IOTD_ARCHIVE'); $info['default'] = true; return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('galleries')) { return NULL; } if (!has_actual_page_access(get_member(), 'galleries')) { return NULL; } if ($GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)') <= 1) { return NULL; } require_lang('galleries'); $info = array(); $info['lang'] = do_lang_tempcode('GALLERIES'); $info['default'] = true; return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('cedi')) { return NULL; } // TODO: Update in v10 if (!has_actual_page_access(get_member(), 'cedi')) { return NULL; } if ($GLOBALS['SITE_DB']->query_value('seedy_pages', 'COUNT(*)') <= 1) { return NULL; } require_lang('cedi'); $info = array(); $info['lang'] = do_lang_tempcode('CEDI_PAGES'); $info['default'] = true; return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('banners')) { return NULL; } require_lang('banners'); $info = array(); $info['db_table'] = 'banners'; $info['db_identifier'] = 'name'; $info['db_validated'] = 'validated'; $info['db_add_date'] = 'add_date'; $info['db_edit_date'] = 'edit_date'; $info['edit_module'] = 'cms_banners'; $info['edit_type'] = '_ed'; $info['edit_identifier'] = 'id'; $info['title'] = do_lang_tempcode('BANNERS'); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('calendar')) { return NULL; } require_lang('calendar'); $info = array(); $info['db_table'] = 'calendar_events'; $info['db_identifier'] = 'id'; $info['db_validated'] = 'validated'; $info['db_add_date'] = 'e_add_date'; $info['db_edit_date'] = 'e_edit_date'; $info['edit_module'] = 'cms_calendar'; $info['edit_type'] = 'ed'; $info['edit_identifier'] = 'id'; $info['title'] = do_lang_tempcode('EVENT'); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('filedump')) { return NULL; } if (!has_actual_page_access(get_member(), 'filedump')) { return NULL; } require_code('files2'); if (count(get_directory_contents(get_custom_file_base() . '/uploads/filedump')) == 0) { return NULL; } require_lang('filedump'); $info = array(); $info['lang'] = do_lang_tempcode('FILE_DUMP'); $info['default'] = false; $info['extra_sort_fields'] = array('file_size' => do_lang_tempcode('_FILE_SIZE')); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('galleries')) { return NULL; } if (!has_actual_page_access(get_member(), 'galleries')) { return NULL; } if ($GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)') == 0) { return NULL; } require_lang('galleries'); $info = array(); $info['lang'] = do_lang_tempcode('IMAGES'); $info['default'] = true; $info['category'] = 'cat'; $info['integer_category'] = false; return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('downloads')) { return NULL; } if (!has_actual_page_access(get_member(), 'downloads')) { return NULL; } if ($GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)') == 0) { return NULL; } require_lang('downloads'); $info = array(); $info['lang'] = do_lang_tempcode('SECTION_DOWNLOADS'); $info['default'] = true; $info['category'] = 'category_id'; $info['integer_category'] = true; $info['extra_sort_fields'] = array('file_size' => do_lang_tempcode('_FILE_SIZE')); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('news')) { return NULL; } require_lang('news'); $info = array(); $info['db_table'] = 'news'; $info['db_identifier'] = 'id'; $info['db_validated'] = 'validated'; $info['db_title'] = 'title'; $info['db_title_dereference'] = true; $info['db_add_date'] = 'date_and_time'; $info['db_edit_date'] = 'edit_date'; $info['edit_module'] = 'cms_news'; $info['edit_type'] = '_ed'; $info['edit_identifier'] = 'id'; $info['title'] = do_lang_tempcode('NEWS'); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('quiz')) { return NULL; } require_lang('quiz'); $info = array(); $info['db_table'] = 'quizzes'; $info['db_identifier'] = 'id'; $info['db_validated'] = 'q_validated'; $info['db_title'] = 'q_name'; $info['db_title_dereference'] = true; $info['db_add_date'] = 'q_add_date'; $info['db_edit_date'] = 'q_add_date'; $info['edit_module'] = 'cms_quiz'; $info['edit_type'] = '_ed'; $info['edit_identifier'] = 'id'; $info['title'] = do_lang_tempcode('QUIZZES'); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('downloads')) { return NULL; } require_lang('downloads'); $info = array(); $info['db_table'] = 'download_downloads'; $info['db_identifier'] = 'id'; $info['db_validated'] = 'validated'; $info['db_title'] = 'name'; $info['db_title_dereference'] = true; $info['db_add_date'] = 'add_date'; $info['db_edit_date'] = 'edit_date'; $info['edit_module'] = 'cms_downloads'; $info['edit_type'] = '_ed'; $info['edit_identifier'] = 'id'; $info['title'] = do_lang_tempcode('SECTION_DOWNLOADS'); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('galleries')) { return NULL; } if (!has_actual_page_access(get_member(), 'galleries')) { return NULL; } if ($GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)') == 0) { return NULL; } require_lang('galleries'); $info = array(); $info['lang'] = do_lang_tempcode('VIDEOS'); $info['default'] = true; $info['category'] = 'cat'; $info['integer_category'] = false; $info['extra_sort_fields'] = array('video_length' => do_lang_tempcode('VIDEO_LENGTH')); return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('cedi')) { return NULL; } require_lang('cedi'); $info = array(); $info['db_table'] = 'seedy_posts'; $info['db_identifier'] = 'id'; $info['db_validated'] = 'validated'; $info['db_title'] = 'the_message'; $info['db_title_dereference'] = true; $info['db_add_date'] = 'date_and_time'; $info['db_edit_date'] = 'edit_date'; $info['edit_module'] = 'cedi'; $info['edit_type'] = 'post'; $info['edit_identifier'] = 'post_id'; $info['title'] = do_lang_tempcode('CEDI'); $info['is_minor'] = true; return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (!module_installed('galleries')) { return NULL; } require_lang('galleries'); $info = array(); $info['db_table'] = 'images'; $info['db_identifier'] = 'id'; $info['db_validated'] = 'validated'; $info['db_title'] = 'comments'; $info['db_title_dereference'] = true; $info['db_add_date'] = 'add_date'; $info['db_edit_date'] = 'edit_date'; $info['edit_module'] = 'cms_galleries'; $info['edit_type'] = '_ed'; $info['view_module'] = 'galleries'; $info['view_type'] = 'image'; $info['edit_identifier'] = 'id'; $info['title'] = do_lang_tempcode('IMAGES'); return $info; }
function get_possible_links($menu_id) { // Each "possible link" must have the following 3 attributes: // - Text (display text) // - Type (content type, not used technically but just to show what type of content it is) // - Code (a base64_encoded, serialized array of data including: // - link_type (either "link" or "special), // - link_id (if in universal `links` table and link_type == "link"), // - special_type (if link_type == "special") $possible_links = array(); // get current links so we can prevent duplicates $this->load->model('menu_model'); $current_links = $this->menu_model->get_links(array('menu' => $this->session->userdata('manage_menu_id'), 'parent' => $this->session->userdata('manage_menu_parent_link_id'))); // add special links $special_links = array('home' => 'Home', 'control_panel' => 'Control Panel', 'my_account' => 'My Account', 'search' => 'Search'); if (module_installed('store')) { $special_links['store'] = 'Store'; $special_links['cart'] = 'Shopping Cart'; } if (module_installed('billing')) { $special_links['subscriptions'] = 'Subscription Plans'; } foreach ($special_links as $special_link_code => $special_link_name) { if (!$this->special_link_in_array($current_links, $special_link_code)) { $possible_links[] = array('text' => $special_link_name, 'type' => 'Special', 'code' => base64_encode(serialize(array('special_type' => $special_link_code, 'link_type' => 'special', 'link_text' => $special_link_name)))); } } // get all content links from the universal link database $this->load->model('link_model'); $links = $this->link_model->get_links(); foreach ((array) $links as $link) { if (!$this->universal_link_in_array($current_links, $link['id'])) { $possible_links[] = array('text' => $link['title'], 'type' => $link['type'], 'code' => base64_encode(serialize(array('link_id' => $link['id'], 'link_type' => 'link', 'link_text' => $link['title'])))); } } return $possible_links; }
function __construct() { parent::__construct(); // by defining _CONTROLPANEL, certain functionality can be modified to be appropriate to this context define("_CONTROLPANEL", "TRUE"); // load the SSL helper, and redirect to HTTPS if necessary (or to HTTP) $this->load->helper('ssl'); // load notices library (display success/error messages at top of screen) $this->load->library('notices'); $this->load->helper('admincp/get_notices'); // are they logged in? and an administrator? if ($this->user_model->logged_in() and !$this->user_model->is_admin()) { $this->notices->SetError('You are logged in but do not have control panel privileges.'); redirect(site_url('admincp/login')); die; } elseif (!$this->user_model->logged_in() and $this->router->fetch_class() != 'login') { redirect(site_url('admincp/login')); die; } // store dynamically-generated navigation $this->load->library('admin_navigation'); // add basic navigation categories $this->admin_navigation->parent_link('dashboard', 'Dashboard'); $this->admin_navigation->parent_link('publish', 'Publish'); if (module_installed('store') or module_installed('billing') or module_installed('coupons')) { $this->admin_navigation->parent_link('storefront', 'Storefront'); } $this->admin_navigation->parent_link('members', 'Members'); $this->admin_navigation->parent_link('reports', 'Reports'); $this->admin_navigation->parent_link('design', 'Design'); $this->admin_navigation->parent_link('configuration', 'Configuration'); $this->admin_navigation->child_link('dashboard', 1, 'Dashboard', site_url('admincp')); // admin-specific loading $this->load->helper('admincp/dataset_link'); $this->load->helper('directory'); $this->load->helper('form'); $this->load->helper('admincp/admin_link'); // load assets library (include stylesheets and javascript files dynamically) $this->load->library('head_assets'); // load caching library $this->load->driver('cache'); // init hooks $this->load->library('app_hooks'); // load all modules with control panel to build navigation, etc. $modules = $this->module_model->get_module_folders(); // first, reset module definitions so that we run them all as a "backend" call and their preloads get called $this->module_definitions = new stdClass(); foreach ($modules as $module) { MY_Loader::define_module($module . '/'); } // define WYSIWYG session variables for file uploading @session_start(); $_SESSION['KCFINDER'] = array(); $_SESSION['KCFINDER']['disabled'] = FALSE; // Safari base_href fix $url = parse_url(base_url()); $this->load->library('user_agent'); // if they are using Safari and don't have Hero installed in a sub-folder, this prefix "/" fixes the problem if (stripos($this->agent->browser(), 'safari') !== FALSE and trim($url['path'], '/') == '') { $prefix = '/'; } else { $prefix = ''; } $_SESSION['KCFINDER']['uploadURL'] = $prefix . str_replace(FCPATH, '', setting('path_editor_uploads')); $_SESSION['KCFINDER']['uploadDir'] = rtrim(setting('path_editor_uploads'), '/'); // check cronjob is active! if (setting('cron_last_update') == FALSE or time() - strtotime(setting('cron_last_update')) > 60 * 60 * 24) { $this->notices->SetError('WARNING! Your cronjob is not running properly. <a href="' . site_url('admincp/reports/cronjob') . '">Click here for details</a>'); } }
function parse_links(&$menu_items, &$menu_children, $links, $menu, &$smarty, $params) { if (empty($links)) { return FALSE; } foreach ($links as $link) { $display_this_item = TRUE; if ($link['privileges']) { if (!$smarty->CI->user_model->in_group($link['privileges'])) { $display_this_item = FALSE; } } if ($display_this_item == TRUE) { if ($link['special_type'] == FALSE) { // calculate URL if ($link['external_url']) { if (strstr($link['external_url'], ':')) { // full http:// URL $url = $link['external_url']; } else { $url = site_url($link['external_url']); } } else { // it's in the universal links database, and we have link_url_path $url = site_url($link['link_url_path']); } // is it active? $active = FALSE; if ($link['external_url'] == TRUE and current_url() == $url) { $active = TRUE; } elseif ($link['external_url'] == FALSE and trim($smarty->CI->uri->uri_string, '/') == trim($link['link_url_path'], '/')) { $active = TRUE; } $menu_items[$link['id']] = array('text' => $link['text'], 'url' => $url, 'active' => $active, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); } else { // it's a special link if ($link['special_type'] == 'home') { $menu_items[$link['id']] = array('text' => $link['text'], 'url' => site_url(), 'active' => $smarty->CI->uri->segment(1) == FALSE ? TRUE : FALSE, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); } elseif ($link['special_type'] == 'control_panel') { $menu_items[$link['id']] = array('text' => $link['text'], 'url' => site_url('admincp'), 'active' => $smarty->CI->uri->segment(1) == 'admincp' ? TRUE : FALSE, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); } elseif ($link['special_type'] == 'my_account') { $menu_items[$link['id']] = array('text' => $link['text'], 'url' => site_url('users'), 'active' => $smarty->CI->uri->segment(1) == 'users' ? TRUE : FALSE, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); if ($smarty->CI->user_model->logged_in() and $link['parent_menu_link_id'] == '0' and ($params['show_sub_menus'] == 'yes' or $params['show_sub_menus'] == 'active' and $menu_items[$link['id']] == TRUE)) { // add children $menu_children[$link['id']][] = 'profile'; $menu_children[$link['id']][] = 'password'; if (module_installed('billing')) { $menu_children[$link['id']][] = 'invoices'; } $menu_children[$link['id']][] = 'logout'; $menu_items['profile'] = array('text' => 'Update Profile', 'url' => site_url('users/profile'), 'active' => ($smarty->CI->uri->segment(1) == 'users' and $smarty->CI->uri->segment(2) == 'profile') ? TRUE : FALSE, 'class' => 'account_profile', 'is_child' => TRUE); $menu_items['password'] = array('text' => 'Change Password', 'url' => site_url('users/password'), 'active' => ($smarty->CI->uri->segment(1) == 'users' and $smarty->CI->uri->segment(2) == 'password') ? TRUE : FALSE, 'class' => 'account_password', 'is_child' => TRUE); if (module_installed('billing')) { $menu_items['invoices'] = array('text' => 'View Invoices', 'url' => site_url('users/invoices'), 'active' => ($smarty->CI->uri->segment(1) == 'users' and $smarty->CI->uri->segment(2) == 'invoices') ? TRUE : FALSE, 'class' => 'account_invoices', 'is_child' => TRUE); } $menu_items['logout'] = array('text' => 'Logout', 'url' => site_url('users/logout'), 'active' => ($smarty->CI->uri->segment(1) == 'users' and $smarty->CI->uri->segment(2) == 'logout') ? TRUE : FALSE, 'class' => 'account_logout', 'is_child' => TRUE); } } elseif ($link['special_type'] == 'store' and module_installed('store')) { $menu_items[$link['id']] = array('text' => $link['text'], 'url' => site_url('store'), 'active' => ($smarty->CI->uri->segment(1) == 'store' or $smarty->CI->uri->segment(1) == 'checkout') ? TRUE : FALSE, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); } elseif ($link['special_type'] == 'search') { $menu_items[$link['id']] = array('text' => $link['text'], 'url' => site_url('search'), 'active' => $smarty->CI->uri->segment(1) == 'search' ? TRUE : FALSE, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); } elseif ($link['special_type'] == 'subscriptions' and module_installed('billing')) { $menu_items[$link['id']] = array('text' => $link['text'], 'url' => site_url('subscriptions'), 'active' => $smarty->CI->uri->segment(1) == 'subscriptions' ? TRUE : FALSE, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); } elseif ($link['special_type'] == 'cart') { $menu_items[$link['id']] = array('text' => $link['text'], 'url' => site_url('users'), 'active' => $smarty->CI->uri->segment(1) == 'cart' ? TRUE : FALSE, 'class' => $link['class'], 'is_child' => $link['parent_menu_link_id'] != '0' ? TRUE : FALSE); } } // should we load children? // only if show_sub_menus parameter says so, and this isn't already a child link if ($link['parent_menu_link_id'] == '0' and ($params['show_sub_menus'] == 'yes' or $params['show_sub_menus'] == 'active' and $menu_items[$link['id']] == TRUE)) { // load children $links_children = $smarty->CI->menu_model->get_links(array('menu' => $menu['id'], 'parent' => $link['id'])); if (is_array($links_children)) { // track children foreach ($links_children as $link_child) { $menu_children[$link['id']][] = $link_child['id']; } parse_links($menu_items, $menu_children, $links_children, $menu, $smarty, $params); } } } } }
function install_location_data() { if (!module_installed('admin_locations')) { require_code('zones2'); reinstall_module('adminzone', 'admin_locations'); } require_code('files'); require_code('locations'); // Open WorldGazetteer.csv $myfile = fopen(get_file_base() . '/data_custom/locations/WorldGazetteer.csv', 'rb'); $header = fgetcsv($myfile, 4096); $locations = array(); while (($line = fgetcsv($myfile, 4096)) !== false) { $newline = array(); foreach ($header as $i => $h) { $newline[$h] = isset($line[$i]) ? $line[$i] : ''; } if ($newline['Latitude'] != '') { $newline['Latitude'] = float_to_raw_string(floatval($newline['Latitude']) / 100.0); $newline['Longitude'] = float_to_raw_string(floatval($newline['Longitude']) / 100.0); } // Fix inconsistencies $newline['Country'] = preg_replace('#^(Smaller|External) Territories of (the )?#', '', $newline['Country']); if ($newline['Country'] == 'UK') { $newline['Country'] = 'United Kingdom'; } if ($newline['Country'] == 'Reunion') { $newline['Country'] = 'France'; } $locations[] = $newline; } // Load US locations using CivicSpace-zipcodes.csv require_code('locations/us'); $myfile = fopen(get_file_base() . '/data_custom/locations/CivicSpace-zipcodes.csv', 'rb'); $header = fgetcsv($myfile, 4096); $us_locations = array(); while (($line = fgetcsv($myfile, 4096)) !== false) { $newline = array(); foreach ($header as $i => $h) { $newline[$h] = isset($line[$i]) ? $line[$i] : ''; } $state_name = state_code_to_state_name($newline['state']); $us_locations[$state_name][$newline['city']] = $newline; } // Load World locations using World_Cities_Location_table.csv require_code('locations/us'); $myfile = fopen(get_file_base() . '/data_custom/locations/World_Cities_Location_table.csv', 'rb'); $header = fgetcsv($myfile, 4096); $world_locations = array(); while (($line = fgetcsv($myfile, 4096)) !== false) { $newline = array(); foreach ($header as $i => $h) { $newline[$h] = isset($line[$i]) ? $line[$i] : ''; } // Fix inconsistencies if ($newline['Country'] == 'United States') { $newline['Country'] = 'United States of America'; } $world_locations[$newline['Country']][$newline['City']] = $newline; } // Delete current data $GLOBALS['SITE_DB']->query_delete('locations'); // Merge it all together, and put it into DB foreach ($locations as $location) { if ($location['Latitude'] == '') { if ($location['Country'] == 'United States of America' && $location['Type'] == 'locality') { // Get match for latitude / longitude in CivicSpace-zipcodes.csv if (isset($us_locations[$location['Parent1']][$location['Name']])) { $us_location = $us_locations[$location['Parent1']][$location['Name']]; $location['Latitude'] = $us_location['latitude']; $location['Longitude'] = $us_location['longitude']; } } } if ($location['Latitude'] == '') { // Get match for latitude / longitude in World_Cities_Location_table.csv if (isset($world_locations[$location['Country']][$location['Name']])) { $world_location = $world_locations[$location['Country']][$location['Name']]; $location['Latitude'] = $world_location['Latitude']; $location['Longitude'] = $world_location['Longitude']; } } $GLOBALS['SITE_DB']->query_insert('locations', array('l_place' => $location['Name'], 'l_type' => $location['Type'], 'l_continent' => find_continent($location['Country']), 'l_country' => $location['Country'], 'l_parent_1' => $location['Parent1'], 'l_parent_2' => $location['Parent2'], 'l_parent_3' => $location['Parent3'], 'l_population' => intval($location['Population']), 'l_latitude' => $location['Latitude'] == '' ? NULL : floatval($location['Latitude']), 'l_longitude' => $location['Longitude'] == '' ? NULL : floatval($location['Longitude']))); } }
public function modules($name = null, $subpage = null) { // Make sure the user can view this page if (!$this->check_permission('manage_modules')) { return; } if ($name != null) { // Make sure the module is installed! if (module_installed($name)) { // Load the module controller $file = path(ROOT, "third_party", "modules", $name, "admin.php"); if (file_exists($file)) { // Load the file include $file; // Init the module into a variable $class = ucfirst($name); $module = new $class(true); // Correct the module view path' $this->Template->set_controller($class, true); // Build our page title / desc, then load the view $this->Template->set('page_title', $class . " Config"); $this->Template->set('page_desc', "On this page, you can configure this module."); // Run the module installer $result = $module->admin(); if ($result == false) { // Correct the module view path' $this->Template->set_controller('Admin', false); // Build our page title / desc, then load the view $this->Template->set('page_title', "Error Loading Module"); $this->Template->set('page_desc', ""); $this->load->view('module_load_error'); return; } } } } else { $data = array("page_title" => "Module Management", "page_desc" => "On this page, you can install and manage your installed modules. You may also edit module config files here."); $this->load->view("module_index", $data); } }
<?php echo $this->head_assets->javascript('js/dashboard.js'); echo $this->head_assets->javascript('js/jquery.sparkline.js'); echo $this->head_assets->stylesheet('css/dashboard.css'); ?> <?php echo $this->load->view(branded_view('cp/header.php')); ?> <?php if (module_installed('billing', 'store', 'coupons')) { ?> <div id="dash_stats" rel="day"> <div id="date_selector"> <ul> <li><input type="radio" name="date_select" value="day" /> <span>Today</span></li> <li><input type="radio" name="date_select" value="week" /> <span>This Week</span></li> <li><input type="radio" name="date_select" value="month" /> <span>This Month</span></li> </ul> </div> <div class="stat"> <div class="wrap"> <span class="stat day"><?php echo setting('currency_symbol'); echo $day['revenue']; ?> </span> <span class="stat week"><?php echo setting('currency_symbol');
// collections custom fields if (!($field_group = $CI->config->item('collections_custom_field_group'))) { $field_group = $CI->custom_fields_model->new_group('Collections'); $this->settings_model->new_setting(2, 'collections_custom_field_group', $field_group, 'The custom field group ID for collection data.', 'text', ''); } $CI->custom_fields_model->new_custom_field($field_group, 'Image', 'file_upload', FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 'collections'); // collections $CI->load->model('store/collections_model'); $collection_id_blueberries = $CI->collections_model->new_collection('Blueberries', 'Our delicious blend of blueberries make the best pies.', 0, array('image' => 'themes/orchard/images/placeholders/blueberries.jpg')); $collection_id_cherries = $CI->collections_model->new_collection('Cherries', 'Even better than the cough candies!', 0, array('image' => 'themes/orchard/images/placeholders/cherries.jpg')); $collection_id_apples = $CI->collections_model->new_collection('Apples', 'You\'ll only ever eat apple pies again!', 0, array('image' => 'themes/orchard/images/placeholders/apples.jpg')); $collection_id_oranges = $CI->collections_model->new_collection('Oranges', 'Straight from Florida, in the back of a truck!', 0, array('image' => 'themes/orchard/images/placeholders/oranges.jpg')); $collection_id_pears = $CI->collections_model->new_collection('Pears', 'Not for the feint of heart', 0, array('image' => 'themes/orchard/images/placeholders/pears.jpg')); $collection_id_strawberries = $CI->collections_model->new_collection('Strawberries', 'On your cereal, ice cream, pies, and anything else!', 0, array('image' => 'themes/orchard/images/placeholders/strawberries.jpg')); // products $CI->load->model('store/products_model'); $CI->products_model->new_product('Fresh Blueberries', 'Order a basket of the freshest blueberries out there!', array($collection_id_blueberries), 4.99, 1, TRUE, FALSE, 0, FALSE, '', TRUE); } // menu $CI->load->model('menu_manager/menu_model'); $menu = $CI->menu_model->new_menu('main_menu'); $CI->menu_model->add_link($menu, FALSE, 'special', FALSE, 'Home', 'home'); if (module_installed('store')) { $CI->menu_model->add_link($menu, FALSE, 'special', FALSE, 'Store', 'store'); } $CI->menu_model->add_link($menu, FALSE, 'link', $blog['link_id'], 'News'); $CI->menu_model->add_link($menu, FALSE, 'link', $about['link_id'], 'About Us'); $CI->menu_model->add_link($menu, FALSE, 'link', $form['link_id'], 'Contact Us'); $CI->menu_model->add_link($menu, FALSE, 'special', FALSE, 'My Account', 'my_account'); $menu = $CI->menu_model->new_menu('footer_menu'); $CI->menu_model->add_link($menu, FALSE, 'special', FALSE, 'Control Panel', 'control_panel');
function cancel($subscription_id) { if (module_installed('billing')) { $this->load->model('billing/subscription_model'); $subscription = $this->subscription_model->get_subscription($subscription_id); if (empty($subscription) or $subscription['user_id'] != $this->user_model->get('id')) { die(show_error('The subscription your attempting to cancel is invalid.')); } if ($this->input->post('confirm')) { // do the cancellation $this->subscription_model->cancel_subscription($subscription_id); $this->smarty->assign('cancelled', TRUE); } else { $this->smarty->assign('cancelled', FALSE); } $this->smarty->assign('subscription', $subscription); $this->smarty->display('account_templates/cancel_subscription'); } else { die(show_error('Billing module is not installed.')); } }
function profile($id) { $user = $this->user_model->get_user($id); if (!$user) { die(show_error('User does not exist.')); } // navigation $this->admin_navigation->module_link('Edit Profile', site_url('admincp/users/edit/' . $user['id'])); // prep data $custom_fields = $this->user_model->get_custom_fields(); if (module_installed('billing')) { $this->load->model('billing/subscription_model'); $subscriptions = $this->subscription_model->get_subscriptions_friendly(array(), $user['id']); } // prep $show_usergroups $this->load->model('usergroup_model'); $usergroups = $this->usergroup_model->get_usergroups(); $usergroup_options = array(); foreach ($usergroups as $group) { $usergroup_options[$group['id']] = $group['name']; } $usergroups = $usergroup_options; foreach ($user['usergroups'] as $key => $group) { $user['usergroups'][$key] = $usergroups[$group]; } $user['show_usergroups'] = implode(', ', $user['usergroups']); // get billing address if (module_installed('billing')) { $billing_address = $this->user_model->get_billing_address($user['id']); $this->load->helper('format_street_address'); $formatted_billing_address = format_street_address($billing_address); } $data = array('user' => $user, 'custom_fields' => $custom_fields, 'subscriptions' => isset($subscriptions) ? $subscriptions : FALSE, 'usergroups' => $usergroups, 'billing_address' => isset($formatted_billing_address) ? $formatted_billing_address : FALSE); $this->load->view('profile', $data); }
?> </td> <td><?php echo $row['friendly_name']; ?> </td> <td><?php echo $row['name']; ?> </td> <td><?php echo $row['type']; ?> </td> <td><?php if (module_installed('billing')) { ?> <?php echo form_dropdown('billing_equiv', array('' => 'No', 'address_1' => 'Address Line 1', 'address_2' => 'Address Line 2', 'city' => 'City', 'state' => 'State/Province', 'country' => 'Country', 'postal_code' => 'Postal Code', 'phone' => 'Phone Number'), isset($row['billing_equiv']) ? $row['billing_equiv'] : ''); ?> <?php } else { ?> n/a <?php } ?> </td> <td><?php echo form_checkbox('admin_only', '1', (isset($row['admin_only']) and $row['admin_only'] == TRUE) ? TRUE : FALSE); ?>
function complete_install() { $theme = $this->input->post('theme'); // the deadliest code in the application! // wipes everything clean if ($this->input->post('reset') == 'yes') { // perform reset // Content, content types, forms, blogs, topics, RSS feeds, products, // collections, product options, subscriptions, and menus WILL be erased. // content & conte types $this->load->model('publish/content_type_model'); $types = $this->content_type_model->get_content_types(); if (!empty($types)) { foreach ($types as $type) { $this->content_type_model->delete_content_type($type['id']); } } // forms $this->load->model('forms/form_model'); $forms = $this->form_model->get_forms(); if (!empty($forms)) { foreach ($forms as $form) { $this->form_model->delete_form($form['id']); } } // blogs $this->load->model('blogs/blog_model'); $blogs = $this->blog_model->get_blogs(); if (!empty($blogs)) { foreach ($blogs as $blog) { $this->blog_model->delete_blog($blog['id']); } } // rss feeds $this->load->model('rss/rss_model'); $feeds = $this->rss_model->get_feeds(); if (!empty($feeds)) { foreach ($feeds as $feed) { $this->rss_model->delete_feed($feed['id']); } } // topics $this->load->model('publish/topic_model'); $topics = $this->topic_model->get_topics(); if (!empty($topics)) { foreach ($topics as $topic) { $this->topic_model->delete_topic($topic['id']); } } // products if (module_installed('store')) { $this->load->model('store/products_model'); $products = $this->products_model->get_products(); if (!empty($products)) { foreach ($products as $product) { $this->products_model->delete_product($product['id']); } } // collections $this->load->model('store/collections_model'); $collections = $this->collections_model->get_collections(); if (!empty($collections)) { foreach ($collections as $collection) { $this->collections_model->delete_collection($collection['id']); } } // product options $this->load->model('store/product_option_model'); $options = $this->product_option_model->get_options(); if (!empty($options)) { foreach ($options as $option) { $this->product_option_model->delete_option($option['id']); } } } if (module_installed('billing')) { // subscriptions $this->load->model('billing/subscription_plan_model'); $subscriptions = $this->subscription_plan_model->get_plans(); if (!empty($subscriptions)) { foreach ($subscriptions as $plan) { $this->subscription_plan_model->delete_plan($plan['id']); } } } // menus $this->load->model('menu_manager/menu_model'); $menus = $this->menu_model->get_menus(); if (!empty($menus)) { foreach ($menus as $menu) { $this->menu_model->delete_menu($menu['id']); } } // custom fields $this->load->model('custom_fields_model'); // custom fields - products if (module_installed('store')) { if ($this->config->item('products_custom_field_group')) { $group = $this->config->item('products_custom_field_group'); $this->custom_fields_model->delete_group($group, 'products'); $this->settings_model->delete_setting('products_custom_field_group'); } // custom fields - collections if ($this->config->item('collections_custom_field_group')) { $group = $this->config->item('collections_custom_field_group'); $this->custom_fields_model->delete_group($group, 'collections'); $this->settings_model->delete_setting('collections_custom_field_group'); } } // clear custom fields cache $this->custom_fields_model->cache = array(); } // pause to let MySQL have a break sleep(1); // reload settings $this->settings_model->set_settings(); if ($this->input->post('default_content') == 'yes') { // check for default content $install_file = FCPATH . 'themes/' . $theme . '/install.php'; if (file_exists($install_file)) { include $install_file; } else { die(show_error('Unable to locate installation file.')); } } // set setting $this->settings_model->update_setting('theme', $theme); $this->load->view('install_complete'); }