/**
     * @see Plugin::SkinBeginHtmlHead()
     */
    function SkinBeginHtmlHead(&$params)
    {
        $relative_to = is_admin_page() ? 'rsc_url' : 'blog';
        require_js('#flowplayer#', $relative_to);
        add_js_headline('flowplayer.conf = { flashfit: true, embed: false }');
        $this->require_skin();
        add_css_headline('.flowplayer_block {
	margin: 1em auto 0;
	background: #000;
}
.flowplayer_block .flowplayer {
	display: block;
	margin: auto;
}
.flowplayer_text {
	font-size: 84%;
	text-align: center;
	margin: 4px 0;
}');
    }
    /**
     * @see Plugin::SkinBeginHtmlHead()
     */
    function SkinBeginHtmlHead(&$params)
    {
        global $Blog;
        $relative_to = is_admin_page() ? 'rsc_url' : 'blog';
        require_css('#videojs_css#', $relative_to);
        require_js('#videojs#', $relative_to);
        $this->require_skin();
        // Set a video size in css style, because option setting is ignored by some reason
        $width = intval($this->get_coll_setting('width', $Blog));
        $width = empty($width) ? '100%' : $width . 'px';
        $height = intval($this->get_coll_setting('height', $Blog));
        add_css_headline('.video-js{ width: ' . $width . ' !important; max-width: 100% !important; height: ' . $height . 'px !important; margin: auto; }
.videojs_block {
	margin: 0 auto 1em;
}
.videojs_block .videojs_text {
	font-size: 84%;
	text-align: center;
	margin: 4px 0;
}');
    }
Example #3
0
/**
 * Get action icons to delete thread
 *
 * @param integer Thread ID
 * @return string Action icon
 */
function col_thread_delete_action($thread_ID)
{
    global $Blog, $samedomain_htsrv_url, $admin_url;
    if (is_admin_page()) {
        $redirect_to = rawurlencode(regenerate_url('', '', '', '&'));
        return action_icon(T_('Delete'), 'delete', $admin_url . '?ctrl=threads&thrd_ID=' . $thread_ID . '&action=delete&' . url_crumb('messaging_threads') . '&redirect_to=' . $redirect_to);
    } else {
        $redirect_to = get_dispctrl_url('threads');
        return action_icon(T_('Delete'), 'delete', $samedomain_htsrv_url . 'action.php?mname=messaging&thrd_ID=' . $thread_ID . '&action=delete&redirect_to=' . $redirect_to . '&' . url_crumb('messaging_threads'));
    }
}
Example #4
0
/**
 * Get the edit actions for comment
 *
 * @param object Comment
 * @return string The edit actions
 */
function comment_edit_actions($Comment)
{
    global $current_User, $admin_url;
    $r = '';
    if (!is_logged_in()) {
        return $r;
    }
    $user_has_edit_perm = $current_User->check_perm('comment!CURSTATUS', 'edit', false, $Comment);
    $user_has_delete_perm = $current_User->check_perm('comment!CURSTATUS', 'delete', false, $Comment);
    if ($user_has_edit_perm || $user_has_delete_perm) {
        // Display edit and delete button if current user has the rights:
        $redirect_to = rawurlencode(regenerate_url('comment_ID,action', 'filter=restore', '', '&'));
        if ($user_has_edit_perm) {
            // Display edit button only if current user can edit comment with current status
            $Comment->get_Item();
            $item_Blog =& $Comment->Item->get_Blog();
            if ($item_Blog->get_setting('in_skin_editing') && !is_admin_page()) {
                $edit_url = url_add_param($item_Blog->gen_blogurl(), 'disp=edit_comment&c=' . $Comment->ID);
            } else {
                $edit_url = $admin_url . '?ctrl=comments&comment_ID=' . $Comment->ID . '&action=edit&redirect_to=' . $redirect_to;
            }
            $r .= action_icon(TS_('Edit this comment...'), 'properties', $edit_url);
        }
        if ($user_has_delete_perm) {
            // Display delete/recycle button because current user has permission to delete/recycle this comment
            $params = array();
            if ($Comment->status == 'trash') {
                // Comment is already in the recycle bin, display delete action and add js confirm
                $title = T_('Delete this comment!');
                $params['onclick'] = "return confirm('" . TS_('You are about to delete this comment!\\nThis cannot be undone!') . "')";
            } else {
                // Comment will be moved into the recycle bin
                $title = T_('Recycle this comment!');
            }
            $r .= action_icon($title, 'delete', $admin_url . '?ctrl=comments&comment_ID=' . $Comment->ID . '&action=delete&' . url_crumb('comment') . '&redirect_to=' . $redirect_to, NULL, NULL, NULL, $params);
        }
    }
    return $r;
}
Example #5
0
 /**
  * Get the blog's media directory (and create it if necessary).
  *
  * If we're {@link is_admin_page() on an admin page}, it adds status messages.
  * @todo These status messages should rather go to a "syslog" and not be displayed to a normal user
  *
  * @param boolean Create the directory, if it does not exist yet?
  * @return string path string on success, false if the dir could not be created
  */
 function get_media_dir($create = true)
 {
     global $media_path, $Messages, $Settings, $Debuglog;
     if (!$Settings->get('fm_enable_roots_blog')) {
         // User directories are disabled:
         $Debuglog->add('Attempt to access blog media dir, but this feature is globally disabled', 'files');
         return false;
     }
     switch ($this->media_location) {
         case 'default':
             $mediadir = get_canonical_path($media_path . 'blogs/' . $this->urlname . '/');
             break;
         case 'subdir':
             $mediadir = get_canonical_path($media_path . $this->media_subdir);
             break;
         case 'custom':
             $mediadir = get_canonical_path($this->media_fullpath);
             break;
         case 'none':
         default:
             $Debuglog->add('Attempt to access blog media dir, but this feature is disabled for this blog', 'files');
             return false;
     }
     // TODO: use a File object here (to access perms, ..) when FileCache::get_by_path() is provided.
     if ($create && !is_dir($mediadir)) {
         // TODO: Link to some help page(s) with errors!
         if (!is_writable(dirname($mediadir))) {
             // add error
             if (is_admin_page()) {
                 $Messages->add(sprintf(T_("The blog's media directory «%s» could not be created, because the parent directory is not writable or does not exist."), rel_path_to_base($mediadir)) . get_manual_link('media_file_permission_errors'), 'error');
             }
             return false;
         } elseif (!@mkdir($mediadir)) {
             // add error
             if (is_admin_page()) {
                 $Messages->add(sprintf(T_("The blog's media directory «%s» could not be created."), rel_path_to_base($mediadir)) . get_manual_link('directory_creation_error'), 'error');
             }
             return false;
         } else {
             // chmod and add note:
             $chmod = $Settings->get('fm_default_chmod_dir');
             if (!empty($chmod)) {
                 @chmod($mediadir, octdec($chmod));
             }
             if (is_admin_page()) {
                 $Messages->add(sprintf(T_("The blog's media directory «%s» has been created with permissions %s."), rel_path_to_base($mediadir), substr(sprintf('%o', fileperms($mediadir)), -3)), 'success');
             }
         }
     }
     return $mediadir;
 }
Example #6
0
 /**
  * Detect admin page
  */
 function detect_admin_page()
 {
     global $Debuglog;
     if (empty($this->test_mode) || !empty($this->test_mode) && !empty($this->test_admin)) {
         if (is_admin_page()) {
             // We are inside of admin, this supersedes 'direct' access
             // NOTE: this is not really a referer type but more a hit type
             // $Debuglog->add( 'Hit: Referer is admin page.', 'request' );
             //$this->referer_type = 'admin';
             return true;
         }
     }
     return false;
 }
Example #7
0
 /**
  * Get the main Chapter.
  *
  * @return Chapter
  */
 function &get_main_Chapter()
 {
     if (is_null($this->main_Chapter)) {
         $ChapterCache =& get_ChapterCache();
         /**
          * @var Chapter
          */
         $this->main_Chapter =& $ChapterCache->get_by_ID($this->main_cat_ID, false);
         if (empty($this->main_Chapter)) {
             // If main chapter is broken we should get it from one of extra chapters
             $chapters = $this->get_Chapters();
             foreach ($chapters as $Chapter) {
                 if (!empty($Chapter)) {
                     // We have found a valid Chapter...
                     $this->main_Chapter =& $Chapter;
                     $this->main_cat_ID = $Chapter->ID;
                     break;
                 }
             }
         }
         if (empty($this->main_Chapter)) {
             // If we still don't have a valid Chapter, display clean error and die().
             global $admin_url, $Blog, $blog;
             if (empty($Blog)) {
                 if (!empty($blog)) {
                     $BlogCache =& get_BlogCache();
                     $Blog =& $BlogCache->get_by_ID($blog, false);
                 }
             }
             $url_to_edit_post = $admin_url . '?ctrl=items&action=edit&p=' . $this->ID;
             if (!empty($Blog)) {
                 $url_to_edit_post .= '&blog=' . $Blog->ID;
                 if (is_admin_page()) {
                     // Try to set a main category
                     $default_cat_ID = $Blog->get_setting('default_cat_ID');
                     if (!empty($default_cat_ID)) {
                         // If default category is set
                         $this->main_cat_ID = $default_cat_ID;
                         $this->main_Chapter =& $ChapterCache->get_by_ID($this->main_cat_ID, false);
                     } else {
                         // Set from first chapter of the blog
                         $ChapterCache->clear();
                         $ChapterCache->load_subset($Blog->ID);
                         if ($Chapter =& $ChapterCache->get_next()) {
                             $this->main_cat_ID = $Chapter->ID;
                             $this->main_Chapter =& $Chapter;
                         }
                     }
                 }
             }
             $message = sprintf('Item with ID <a %s>%s</a> has an invalid main category ID %s.', 'href="' . $url_to_edit_post . '"', $this->ID, $this->main_cat_ID);
             if (empty($Blog)) {
                 // No blog defined
                 $message .= ' In addition we cannot fallback to the default category because no valid blog ID has been specified.';
             }
             if (empty($this->main_Chapter)) {
                 // Main chapter is not defined, because blog doesn't have the default cat ID and even blog doesn't have any categories
                 debug_die($message);
             } else {
                 // Main chapter is defined, we can show the page
                 global $Messages;
                 $Messages->add($message);
             }
         }
     }
     return $this->main_Chapter;
 }
Example #8
0
 /**
  * Provide link to edit a comment if user has edit rights
  *
  * @param string to display before link
  * @param string to display after link
  * @param string link text
  * @param string link title
  * @param string class name
  * @param string Glue string for url params
  * @param boolean TRUE - to save context(memorized params)
  * @param string Redirect url
  * @return boolean
  */
 function edit_link($before = ' ', $after = ' ', $text = '#', $title = '#', $class = '', $glue = '&amp;', $save_context = true, $redirect_to = NULL)
 {
     global $current_User, $admin_url;
     if (!is_logged_in(false)) {
         return false;
     }
     if (empty($this->ID)) {
         // Happens in Preview
         return false;
     }
     if (!$current_User->check_perm('comment!CURSTATUS', 'edit', false, $this)) {
         // If User has no permission to edit this comment:
         return false;
     }
     if ($text == '#') {
         $text = get_icon('edit') . ' ' . T_('Edit...');
     }
     if ($title == '#') {
         $title = T_('Edit this comment');
     }
     $this->get_Item();
     $item_Blog =& $this->Item->get_Blog();
     echo $before;
     if ($item_Blog->get_setting('in_skin_editing') && !is_admin_page()) {
         echo '<a href="' . url_add_param($item_Blog->gen_blogurl(), 'disp=edit_comment' . $glue . 'c=' . $this->ID);
     } else {
         echo '<a href="' . $admin_url . '?ctrl=comments' . $glue . 'action=edit' . $glue . 'comment_ID=' . $this->ID;
     }
     if ($save_context) {
         if ($redirect_to != NULL) {
             echo $glue . 'redirect_to=' . $redirect_to;
         } else {
             echo $glue . 'redirect_to=' . rawurlencode(regenerate_url('', 'filter=restore', '', '&'));
         }
     }
     echo '" title="' . $title . '"';
     if (!empty($class)) {
         echo ' class="' . $class . '"';
     }
     echo '>' . $text . '</a>';
     echo $after;
     return true;
 }
Example #9
0
 function record_view()
 {
     if ($this->logged > 0) {
         return true;
     }
     global $wpdb, $posts;
     if (!isset($posts) || !is_array($posts) || count($posts) == 0 || is_admin_page()) {
         return;
     }
     $ids = array();
     $ak_posts = $posts;
     foreach ($ak_posts as $post) {
         $ids[] = $post->ID;
     }
     if (is_feed()) {
         $result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET feed_views = feed_views + 1\n\t\t\t\t, total = total + {$this->feed_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
         if (!$result) {
             return false;
         }
     } else {
         if (is_archive() && !is_category()) {
             $result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET archive_views = archive_views + 1\n\t\t\t\t, total = total + {$this->archive_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
             if (!$result) {
                 return false;
             }
         } else {
             if (is_category()) {
                 $result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET category_views = category_views + 1\n\t\t\t\t, total = total + {$this->category_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
                 if (!$result) {
                     return false;
                 }
             } else {
                 if (is_single()) {
                     $result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET single_views = single_views + 1\n\t\t\t\t, total = total + {$this->single_value}\n\t\t\t\tWHERE post_id = '" . $ids[0] . "'\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
                     if (!$result) {
                         return false;
                     }
                 } else {
                     $result = mysql_query("\n\t\t\t\tUPDATE {$wpdb->ak_popularity}\n\t\t\t\tSET home_views = home_views + 1\n\t\t\t\t, total = total + {$this->home_value}\n\t\t\t\tWHERE post_id IN (" . implode(',', $ids) . ")\n\t\t\t", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
                     if (!$result) {
                         return false;
                     }
                 }
             }
         }
     }
     $this->logged++;
     return true;
 }
Example #10
0
 /**
  * Get checkable list of renderers
  *
  * @param array If given, assume these renderers to be checked.
  * @param array params from where to get 'apply_rendering' setting
  */
 function get_renderer_checkboxes($current_renderers = NULL, $params)
 {
     global $inc_path, $admin_url;
     load_funcs('plugins/_plugin.funcs.php');
     $name_prefix = isset($params['name_prefix']) ? $params['name_prefix'] : '';
     $this->restart();
     // make sure iterator is at start position
     if (!is_array($current_renderers)) {
         $current_renderers = explode('.', $current_renderers);
     }
     $atLeastOneRenderer = false;
     $setting_Blog = NULL;
     if (isset($params['Comment']) && !empty($params['Comment'])) {
         // get Comment apply_rendering setting
         $Comment =& $params['Comment'];
         $comment_Item =& $Comment->get_Item();
         $setting_Blog =& $comment_Item->get_Blog();
         $setting_name = 'coll_apply_comment_rendering';
     } elseif (isset($params['Item'])) {
         // get Post apply_rendering setting
         $setting_name = 'coll_apply_rendering';
         $Item =& $params['Item'];
         $setting_Blog =& $Item->get_Blog();
     } elseif (isset($params['Blog']) && isset($params['setting_name'])) {
         // get given "apply_rendering" collection setting from the given Blog
         $setting_Blog =& $params['Blog'];
         $setting_name = $params['setting_name'];
     } else {
         // Invalid params
         return '';
     }
     if ($setting_name == 'coll_apply_comment_rendering') {
         // Get Comment renderer plugins
         $RendererPlugins = $this->get_list_by_events(array('FilterCommentContent'));
     } else {
         // Get Item renderer plugins
         $RendererPlugins = $this->get_list_by_events(array('RenderItemAsHtml', 'RenderItemAsXml', 'RenderItemAsText'));
     }
     $r = '<input type="hidden" name="renderers_displayed" value="1" />';
     foreach ($RendererPlugins as $loop_RendererPlugin) {
         // Go through whole list of renders
         // echo ' ',$loop_RendererPlugin->code;
         if (empty($loop_RendererPlugin->code)) {
             // No unique code!
             continue;
         }
         if (empty($setting_Blog)) {
             // If $setting_Blog is not set we can't get apply_rendering options
             continue;
         }
         // get rendering setting from plugin coll settings
         $apply_rendering = $loop_RendererPlugin->get_coll_setting($setting_name, $setting_Blog);
         if ($apply_rendering == 'stealth' || $apply_rendering == 'never') {
             // This is not an option.
             continue;
         }
         $atLeastOneRenderer = true;
         $r .= '<div>';
         $r .= '<input type="checkbox" class="checkbox" name="' . $name_prefix . 'renderers[]" value="' . $loop_RendererPlugin->code . '" id="renderer_' . $loop_RendererPlugin->code . '"';
         switch ($apply_rendering) {
             case 'always':
                 $r .= ' checked="checked" disabled="disabled"';
                 break;
             case 'opt-out':
                 if (in_array($loop_RendererPlugin->code, $current_renderers) || in_array('default', $current_renderers)) {
                     $r .= ' checked="checked"';
                 }
                 break;
             case 'opt-in':
                 if (in_array($loop_RendererPlugin->code, $current_renderers)) {
                     $r .= ' checked="checked"';
                 }
                 break;
             case 'lazy':
                 if (in_array($loop_RendererPlugin->code, $current_renderers)) {
                     $r .= ' checked="checked"';
                 }
                 $r .= ' disabled="disabled"';
                 break;
         }
         $r .= ' title="' . format_to_output($loop_RendererPlugin->short_desc, 'formvalue') . '" /> <label for="renderer_' . $loop_RendererPlugin->code . '" title="';
         $r .= format_to_output($loop_RendererPlugin->short_desc, 'formvalue') . '">';
         $r .= format_to_output($loop_RendererPlugin->name) . '</label>';
         // fp> TODO: the first thing we want here is a TINY javascript popup with the LONG desc. The links to readme and external help should be inside of the tiny popup.
         // fp> a javascript DHTML onhover help would be even better than the JS popup
         // external help link:
         $r .= ' ' . $loop_RendererPlugin->get_help_link('$help_url');
         $r .= "</div>\n";
     }
     if (!$atLeastOneRenderer) {
         if (is_admin_page()) {
             // Display info about no renderer plugins only in backoffice
             global $admin_url;
             $r .= '<a title="' . T_('Configure plugins') . '" href="' . $admin_url . '?ctrl=plugins"' . '>' . T_('No renderer plugins are installed.') . '</a>';
         } else {
             return '';
         }
     }
     return $r;
 }
Example #11
0
 if ($user_ID > 0) {
     // Print info of the registered users
     $UserCache =& get_UserCache();
     $User =& $UserCache->get_by_ID($user_ID);
     $Ajaxlog->add('User: #' . $user_ID . ' ' . $User->login);
     echo '<div class="bubbletip_user">';
     if ($User->check_status('is_closed')) {
         // display only info about closed accounts
         echo T_('This account has been closed.');
         echo '</div>';
         /* end of: <div class="bubbletip_user"> */
         break;
     }
     $avatar_overlay_text = '';
     $link_class = '';
     if (is_admin_page()) {
         // Set avatar size for Back-office
         $avatar_size = $Settings->get('bubbletip_size_admin');
     } else {
         if (is_logged_in()) {
             // Set avatar size for logged in users in the Front-office
             $avatar_size = $Settings->get('bubbletip_size_front');
         } else {
             // Set avatar size for Anonymous users
             $avatar_size = $Settings->get('bubbletip_size_anonymous');
             $avatar_overlay_text = $Settings->get('bubbletip_overlay');
             $link_class = 'overlay_link';
         }
     }
     $width = $thumbnail_sizes[$avatar_size][1];
     $height = $thumbnail_sizes[$avatar_size][2];
Example #12
0
/**
 * Get a link with task title
 *
 * @param object Item
 * @param boolean Display country flag
 * @param boolean Display status banner
 * @return string Link
 */
function task_title_link($Item, $display_flag = true, $display_status = false)
{
    global $current_User, $admin_url;
    $col = '';
    if ($display_status && is_logged_in()) {
        // Display status
        $col .= $Item->get_status(array('format' => 'styled'));
    }
    if ($display_flag) {
        // Display country flag
        $col .= locale_flag($Item->locale, 'w16px', 'flag', '', false) . ' ';
    }
    $Item->get_Blog();
    if (is_admin_page()) {
        // Url to item page in backoffice
        $item_url = $admin_url . '?ctrl=items&amp;blog=' . $Item->get_blog_ID() . '&amp;p=' . $Item->ID;
    } else {
        // Url to item page in frontoffice
        $item_url = $Item->get_permanent_url();
    }
    if ($Item->Blog->get_setting('allow_comments') != 'never') {
        // The current blog can have comments:
        $nb_comments = generic_ctp_number($Item->ID, 'feedback');
        $comments_url = is_admin_page() ? $item_url : url_add_tail($item_url, '#comments');
        $col .= '<a href="' . $comments_url . '" title="' . sprintf(T_('%d feedbacks'), $nb_comments) . '" class="">';
        if ($nb_comments) {
            $col .= get_icon('comments');
        } else {
            $col .= get_icon('nocomment');
        }
        $col .= '</a> ';
    }
    $col .= '<a href="' . $item_url . '" class="" title="' . T_('View this post...') . '">' . $Item->dget('title') . '</a></strong>';
    return $col;
}
    /**
     * Initialize sql query
     *
     * @todo count?
     *
     * @param boolean
     */
    function query_init($force_init = false)
    {
        global $DB;
        if (!$force_init && !empty($this->query_is_initialized)) {
            // Don't initialize query because it was already done
            return;
        }
        // Save to know the query init was done
        $this->query_is_initialized = true;
        if (empty($this->filters)) {
            // Filters have not been set before, we'll use the default filterset:
            // If there is a preset filter, we need to activate its specific defaults:
            $this->filters['filter_preset'] = param($this->param_prefix . 'filter_preset', 'string', $this->default_filters['filter_preset'], true);
            $this->activate_preset_filters();
            // Use the default filters:
            $this->set_filters($this->default_filters);
        }
        // GENERATE THE QUERY:
        /*
         * Resrict to selected blog
         */
        // If we dont have specific comment or post ids, we have to restric to blog
        if (!is_null($this->Blog) && ($this->filters['post_ID'] == NULL || !empty($this->filters['post_ID']) && substr($this->filters['post_ID'], 0, 1) == '-') && ($this->filters['comment_ID'] == NULL || !empty($this->filters['comment_ID']) && substr($this->filters['comment_ID'], 0, 1) == '-') && ($this->filters['comment_ID_list'] == NULL || !empty($this->filters['comment_ID_list']) && substr($this->filters['comment_ID_list'], 0, 1) == '-')) {
            // restriction for blog
            $this->ItemQuery->where_chapter($this->Blog->ID);
        }
        /*
         * filtering stuff:
         */
        $this->CommentQuery->where_author($this->filters['author_IDs']);
        $this->CommentQuery->where_author_email($this->filters['author_email']);
        $this->CommentQuery->where_author_url($this->filters['author_url'], $this->filters['url_match'], $this->filters['include_emptyurl']);
        $this->CommentQuery->where_author_IP($this->filters['author_IP']);
        $this->ItemQuery->where_ID($this->filters['post_ID']);
        $this->CommentQuery->where_ID($this->filters['comment_ID'], $this->filters['author']);
        $this->CommentQuery->where_ID_list($this->filters['comment_ID_list']);
        $this->CommentQuery->where_rating($this->filters['rating_toshow'], $this->filters['rating_turn'], $this->filters['rating_limit']);
        $this->CommentQuery->where_keywords($this->filters['keywords'], $this->filters['phrase'], $this->filters['exact']);
        $this->CommentQuery->where_statuses($this->filters['statuses']);
        $this->CommentQuery->where_types($this->filters['types']);
        $this->ItemQuery->where_datestart('', '', '', '', $this->filters['timestamp_min'], $this->filters['timestamp_max']);
        if (!is_null($this->Blog) && isset($this->filters['user_perm'])) {
            // If Blog and required user permission is set, add the corresponding restriction
            $this->CommentQuery->user_perm_restrict($this->filters['user_perm'], $this->Blog->ID);
        }
        /*
         * ORDER BY stuff:
         */
        $available_sort_options = array('date', 'type', 'author', 'author_url', 'author_email', 'author_IP', 'spam_karma', 'status', 'item_ID');
        $order_by = gen_order_clause($this->filters['orderby'], $this->filters['order'], $this->Cache->dbprefix, $this->Cache->dbIDname, $available_sort_options);
        if ($this->filters['threaded_comments']) {
            // In mode "Threaded comments" we should get all replies in the begining of the list
            $order_by = $this->Cache->dbprefix . 'in_reply_to_cmt_ID DESC, ' . $order_by;
        }
        $this->CommentQuery->order_by($order_by);
        // GET Item IDs, this way we don't have to JOIN two times the items and the categories table into the comment query
        if (isset($this->filters['post_statuses'])) {
            // Set post statuses by filters
            $post_show_statuses = $this->filters['post_statuses'];
        } elseif (is_admin_page()) {
            // Allow all kind of post status ( This statuses will be filtered later by user perms )
            $post_show_statuses = get_visibility_statuses('keys');
        } else {
            // Allow only inskin statuses for posts
            $post_show_statuses = get_inskin_statuses(isset($this->Blog) ? $this->Blog->ID : NULL, 'post');
        }
        // Restrict post filters to available statuses. When blog = 0 we will check visibility statuses for each blog separately ( on the same query ).
        $this->ItemQuery->where_visibility($post_show_statuses);
        $sql_item_IDs = 'SELECT DISTINCT post_ID' . $this->ItemQuery->get_from();
        if (strpos($this->ItemQuery->get_from(), 'T_categories') === false && strpos($this->ItemQuery->get_where(), 'cat_blog_ID') !== false) {
            // Join categories table because it is required here for the field "cat_blog_ID"
            $sql_item_IDs .= ' INNER JOIN T_categories ON post_main_cat_ID = cat_ID ';
        }
        $sql_item_IDs .= $this->ItemQuery->get_where();
        $item_IDs = $DB->get_col($sql_item_IDs, 0, 'Get CommentQuery Item IDs');
        if (empty($item_IDs)) {
            // There is no item which belongs to the given blog and user may view it, so there are no comments either
            parent::count_total_rows(0);
            $this->CommentQuery->WHERE_and('FALSE');
            return;
        }
        $this->CommentQuery->where_post_ID(implode(',', $item_IDs));
        /*
         * Restrict to active comments by default, show expired comments only if it was requested
         * Note: This condition makes the CommentQuery a lot slower!
         */
        $this->CommentQuery->expiry_restrict($this->filters['expiry_statuses']);
        /*
         * GET TOTAL ROW COUNT:
         */
        $sql_count = '
				SELECT COUNT( ' . $this->Cache->dbIDname . ') ' . $this->CommentQuery->get_from() . $this->CommentQuery->get_where();
        parent::count_total_rows($sql_count);
        /*
         * Page set up:
         */
        if ($this->page > 1) {
            // We have requested a specific page number
            if ($this->limit > 0) {
                $pgstrt = '';
                $pgstrt = (intval($this->page) - 1) * $this->limit . ', ';
                $this->CommentQuery->LIMIT($pgstrt . $this->limit);
            }
        } else {
            $this->CommentQuery->LIMIT($this->limit);
        }
    }
Example #14
0
 /**
  * Get url to write a new Post
  *
  * @param integer Category ID
  * @param string Post title
  * @param string Post urltitle
  * @param string Post type
  * @return string Url to write a new Post
  */
 function get_write_item_url($cat_ID = 0, $post_title = '', $post_urltitle = '', $post_type = '')
 {
     $url = '';
     if (is_logged_in(false)) {
         // Only logged in and activated users can write a Post
         global $current_User;
         $ChapterCache =& get_ChapterCache();
         $selected_Chapter = $ChapterCache->get_by_ID($cat_ID, false, false);
         if ($selected_Chapter && $selected_Chapter->lock) {
             // This category is locked, don't allow to create new post with this cat
             return '';
         }
         if ($current_User->check_perm('blog_post_statuses', 'edit', false, $this->ID)) {
             // We have permission to add a post with at least one status:
             if ($this->get_setting('in_skin_editing') && !is_admin_page()) {
                 // We have a mode 'In-skin editing' for the current Blog
                 // User must have a permission to publish a post in this blog
                 $cat_url_param = '';
                 if ($cat_ID > 0) {
                     // Link to create a Item with predefined category
                     $cat_url_param = '&amp;cat=' . $cat_ID;
                 }
                 $url = url_add_param($this->get('url'), 'disp=edit' . $cat_url_param);
             } elseif ($current_User->check_perm('admin', 'restricted')) {
                 // Edit a post from Back-office
                 global $admin_url;
                 $url = $admin_url . '?ctrl=items&amp;action=new&amp;blog=' . $this->ID;
                 if (!empty($cat_ID)) {
                     // Add category param to preselect category on the form
                     $url = url_add_param($url, 'cat=' . $cat_ID);
                 }
             }
             if (!empty($post_title)) {
                 // Append a post title
                 $url = url_add_param($url, 'post_title=' . $post_title);
             }
             if (!empty($post_urltitle)) {
                 // Append a post urltitle
                 $url = url_add_param($url, 'post_urltitle=' . $post_urltitle);
             }
             if (!empty($post_type)) {
                 // Append a post type
                 $url = url_add_param($url, 'post_type=' . $post_type);
             }
         }
     }
     return $url;
 }
Example #15
0
 /**
  * Get number of posts and percent of published posts by this user
  *
  * @param array Params
  * @return string Result
  */
 function get_reputation_posts($params = array())
 {
     // Make sure we are not missing any param:
     $params = array_merge(array('text' => T_('%s (%s%% are public)')), $params);
     $total_num_posts = $this->get_num_posts();
     $public_num_posts = $this->get_num_posts('published');
     if ($total_num_posts > 0) {
         // Calc percent of published posts
         $public_percent = floor($public_num_posts / $total_num_posts * 100);
     } else {
         // To avoid devision by zero
         $public_percent = 0;
     }
     if ($total_num_posts > 0) {
         // Make a link to page with user's posts:
         global $current_User;
         if (is_admin_page() && is_logged_in() && ($this->ID == $current_User->ID || $current_User->check_perm('users', 'view'))) {
             // For back-office
             global $admin_url;
             $total_num_posts_url = $admin_url . '?ctrl=user&amp;user_tab=activity&amp;user_ID=' . $this->ID;
         } else {
             // For front-office
             global $Blog;
             if (!empty($Blog)) {
                 // Only if blog is defined
                 $total_num_posts_url = url_add_param($Blog->gen_blogurl(), 'disp=useritems&amp;user_ID=' . $this->ID);
             }
         }
     }
     if (empty($total_num_posts_url)) {
         // No link to view posts
         $total_num_posts = '<b>' . $total_num_posts . '</b>';
     } else {
         // Set a posts number as link if it is allowed:
         $total_num_posts = '<a href="' . $total_num_posts_url . '"><b>' . $total_num_posts . '</b></a>';
     }
     return sprintf($params['text'], $total_num_posts, $public_percent);
 }
 /**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     global $MainList;
     $params = array_merge(array('ItemList' => $MainList, 'display_button_reset' => true, 'display_empty_filter' => false), $params);
     if (empty($params['ItemList'])) {
         // Empty ItemList object
         return false;
     }
     if (isset($params['show_filters'])) {
         // Get the predefined filters
         $show_filters = $params['show_filters'];
         unset($params['show_filters']);
     }
     $this->init_display($params);
     if (isset($show_filters)) {
         // Rewrite default filters by predefined
         $this->disp_params['show_filters'] = array_merge($this->disp_params['show_filters'], $show_filters);
     }
     $filters = implode(' ' . T_('AND') . ' ', $params['ItemList']->get_filter_titles(array(), array('categories_text' => '', 'categories_nor_text' => T_('NOT') . ' ', 'tags_nor_text' => T_('NOT') . ' ', 'authors_nor_text' => T_('NOT') . ' ', 'group_mask' => '$filter_items$', 'filter_mask' => '<div class="filter_item $filter_class$">' . "\n" . '<div class="group">$group_title$</div>' . "\n" . '<div class="name">$filter_name$</div>' . "\n" . '<div class="icon">$clear_icon$</div>' . "\n" . '</div>', 'filter_mask_nogroup' => '<div class="filter_item $filter_class$">' . "\n" . '<div class="name">$filter_name$</div>' . "\n" . '<div class="icon">$clear_icon$</div>' . "\n" . '</div>', 'before_items' => '( ', 'after_items' => ' )', 'separator_and' => ' ' . T_('AND') . ' ', 'separator_or' => ' ' . T_('OR') . ' ', 'separator_nor' => ' ' . T_('NOR') . ' ', 'separator_comma' => ' ' . T_('OR') . ' ', 'display_category' => !empty($this->disp_params['show_filters']['category']), 'display_archive' => !empty($this->disp_params['show_filters']['archive']), 'display_keyword' => !empty($this->disp_params['show_filters']['keyword']), 'display_tag' => !empty($this->disp_params['show_filters']['tag']), 'display_author' => !empty($this->disp_params['show_filters']['author']), 'display_assignee' => !empty($this->disp_params['show_filters']['assignee']), 'display_locale' => !empty($this->disp_params['show_filters']['locale']), 'display_status' => !empty($this->disp_params['show_filters']['status']), 'display_visibility' => !empty($this->disp_params['show_filters']['visibility']), 'display_time' => !empty($this->disp_params['show_filters']['time']), 'display_limit' => !empty($this->disp_params['show_filters']['limit']))));
     if (empty($filters) && !$this->disp_params['display_empty_filter']) {
         // No filters
         return;
     }
     // START DISPLAY:
     echo $this->disp_params['block_start'];
     // Display title if requested
     $this->disp_title();
     echo $this->disp_params['block_body_start'];
     if (empty($filters)) {
         // No filters
         if ($this->disp_params['display_empty_filter']) {
             if (is_admin_page() && get_param('tab') == 'type') {
                 // Try to get a title for current selected post type on back-office pages:
                 $current_post_type_title = '"' . get_param('tab_type') . '"';
             }
             if (empty($current_post_type_title)) {
                 // Use this title by default for unknown selected post type:
                 $current_post_type_title = T_('items');
             }
             echo sprintf(T_('No filters - Showing all %s'), $current_post_type_title);
         }
     } else {
         // Display the filters
         echo $filters;
         if ($params['display_button_reset']) {
             // Button to reset all filters
             echo '<p>' . action_icon(T_('Reset all filters'), 'reset_filters', regenerate_url('catsel,cat,' . $params['ItemList']->param_prefix . 'tag,' . $params['ItemList']->param_prefix . 'author,' . $params['ItemList']->param_prefix . 'author_login,' . $params['ItemList']->param_prefix . 'assgn,' . $params['ItemList']->param_prefix . 'assgn_login,' . $params['ItemList']->param_prefix . 'author_assignee,' . $params['ItemList']->param_prefix . 'lc,' . $params['ItemList']->param_prefix . 'status,' . $params['ItemList']->param_prefix . 'show_statuses,' . $params['ItemList']->param_prefix . 'types,' . $params['ItemList']->param_prefix . 's,' . $params['ItemList']->param_prefix . 'sentence,' . $params['ItemList']->param_prefix . 'exact,' . $params['ItemList']->param_prefix . 'p,' . $params['ItemList']->param_prefix . 'title,' . $params['ItemList']->param_prefix . 'pl,' . $params['ItemList']->param_prefix . 'm,' . $params['ItemList']->param_prefix . 'w,' . $params['ItemList']->param_prefix . 'dstart,' . $params['ItemList']->param_prefix . 'dstop,' . $params['ItemList']->param_prefix . 'show_past,' . $params['ItemList']->param_prefix . 'show_future'), ' ' . T_('Reset all filters'), 3, 4) . '<p>';
         }
     }
     echo $this->disp_params['block_body_end'];
     echo $this->disp_params['block_end'];
     return true;
 }
Example #17
0
 /**
  * Build the evobar menu
  */
 function build_evobar_menu()
 {
     /**
      * @var Menu
      */
     global $topleft_Menu;
     global $current_User;
     global $admin_url;
     global $Blog;
     if (!$current_User->check_perm('admin', 'normal')) {
         return;
     }
     if (!empty($Blog) && $current_User->check_perm('stats', 'list')) {
         // Permission to view stats for user's blogs:
         $entries = array();
         $entries['stats_sep'] = array('separator' => true);
         $entries['stats'] = array('text' => T_('Blog analytics'), 'href' => $admin_url . '?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog=' . $Blog->ID, 'entries' => array('summary' => array('text' => T_('Hit summary') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog=' . $Blog->ID), 'refsearches' => array('text' => T_('Search B-hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=refsearches&amp;tab3=hits&amp;blog=' . $Blog->ID), 'referers' => array('text' => T_('Referered B-hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=referers&amp;blog=' . $Blog->ID), 'other' => array('text' => T_('Direct B-hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=other&amp;blog=' . $Blog->ID), 'hits' => array('text' => T_('All Hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=hits&amp;blog=' . $Blog->ID), 'domains' => array('text' => T_('Referring domains') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=domains&amp;blog=' . $Blog->ID)));
         $topleft_Menu->add_menu_entries('blog', $entries);
     }
     if ($current_User->check_perm('stats', 'view')) {
         // We have permission to view all stats
         // TODO: this is hackish and would require a proper function call
         $topleft_Menu->_menus['entries']['tools']['disabled'] = false;
         // TODO: this is hackish and would require a proper function call
         if (!empty($topleft_Menu->_menus['entries']['tools']['entries'])) {
             // There are already entries aboce, insert a separator:
             $topleft_Menu->add_menu_entries('tools', array('stats_sep' => array('separator' => true)));
         }
         $entries = array();
         $entries['stats'] = array('text' => T_('Global analytics'), 'href' => $admin_url . '?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog=0', 'entries' => array('summary' => array('text' => T_('Hit summary') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog=0'), 'refsearches' => array('text' => T_('Search B-hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=refsearches&amp;tab3=hits&amp;blog=0'), 'referers' => array('text' => T_('Referered B-hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=referers&amp;blog=0'), 'other' => array('text' => T_('Direct B-hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=other&amp;blog=0'), 'hits' => array('text' => T_('All Hits') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=hits&amp;blog=0'), 'domains' => array('text' => T_('Referring domains') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&amp;tab=domains&amp;blog=0'), 'goals' => array('text' => T_('Goals') . '&hellip;', 'href' => $admin_url . '?ctrl=goals')));
         if (!is_admin_page()) {
             $blog_ID = empty($Blog) ? 0 : $Blog->ID;
             $entries['stats_page'] = array('text' => T_('Page stats') . '&hellip;', 'href' => $admin_url . '?ctrl=stats&tab=hits&blog=' . $blog_ID . '&reqURI=' . rawurlencode($_SERVER['REQUEST_URI']));
         }
         $topleft_Menu->add_menu_entries('tools', $entries);
     }
 }
Example #18
0
 /**
  * Display next Publish/Restrict to link
  *
  * @param array link params
  * @param boolean true to display next publish status, and false to display next restrict status link
  * @return boolean true if link was displayed | false otherwise
  */
 function next_status_link($params, $publish)
 {
     global $admin_url;
     $params = array_merge(array('before' => '', 'after' => '', 'before_text' => '', 'after_text' => '', 'text' => '#', 'title' => '', 'class' => '', 'glue' => '&amp;', 'redirect_to' => '', 'post_navigation' => 'same_blog', 'nav_target' => NULL), $params);
     if ($publish) {
         $next_status_in_row = $this->get_next_status(true);
         $action = 'publish';
         $button_default_icon = 'move_up_' . $next_status_in_row[2];
     } else {
         $next_status_in_row = $this->get_next_status(false);
         $action = 'restrict';
         $button_default_icon = 'move_down_' . $next_status_in_row[2];
     }
     if ($next_status_in_row === false) {
         // Next status is not allowed for current user
         return false;
     }
     $next_status = $next_status_in_row[0];
     $next_status_label = $next_status_in_row[1];
     if (isset($params['text_' . $next_status])) {
         // Set text from params for next status
         $text = $params['text_' . $next_status];
     } elseif ($params['text'] != '#') {
         // Set text from params for any atatus
         $text = $params['text'];
     } else {
         // Default text
         $text = get_icon($button_default_icon, 'imgtag', array('title' => '')) . ' ' . $next_status_label;
     }
     if (empty($params['title'])) {
         $status_title = get_visibility_statuses('moderation-titles');
         $params['title'] = $status_title[$next_status];
     }
     $glue = $params['glue'];
     $r = $params['before'];
     $r .= '<a href="' . $admin_url . '?ctrl=items' . $glue . 'action=' . $action . $glue . 'post_status=' . $next_status . $glue . 'post_ID=' . $this->ID . $glue . url_crumb('item');
     // set redirect_to
     $redirect_to = $params['redirect_to'];
     if (empty($redirect_to) && !is_admin_page()) {
         // we are in front office
         if ($next_status == 'deprecated') {
             if ($params['post_navigation'] == 'same_category') {
                 $redirect_to = get_caturl($params['nav_target']);
             } else {
                 $this->get_Blog();
                 $redirect_to = $this->Blog->gen_blogurl();
             }
         } else {
             $redirect_to = $this->add_navigation_param($this->get_permanent_url(), $params['post_navigation'], $params['nav_target']);
         }
     }
     if (!empty($redirect_to)) {
         $r .= $glue . 'redirect_to=' . rawurlencode($redirect_to);
     }
     $r .= '" title="' . $params['title'] . '"';
     if (empty($params['class_' . $next_status])) {
         // Set class for all statuses
         $class = empty($params['class']) ? '' : $params['class'];
     } else {
         // Set special class for next status
         $class = $params['class_' . $next_status];
     }
     if (!empty($class)) {
         $r .= ' class="' . $class . '"';
     }
     $r .= '>' . $params['before_text'] . $text . $params['after_text'] . '</a>';
     $r .= $params['after'];
     echo $r;
     return true;
 }
Example #19
0
$Form->hidden('file_ID', $cropped_File->ID);
$Form->hidden('image_crop_data', '');
if (isset($Blog)) {
    $Form->hidden('blog', $Blog->ID);
}
$close_icon = '';
if ($display_mode == 'js') {
    // Display a close link for popup window
    $close_icon = action_icon(T_('Close this window'), 'close', '', '', 0, 0, array('id' => 'close_button', 'class' => 'floatright'));
}
$Form->begin_fieldset(T_('Crop profile picture') . $close_icon, array('class' => 'fieldset clear', 'id' => 'image_crop'));
$cropped_image_tag = $cropped_File->get_tag('', '', '', '', 'original', '');
echo '<p class="crop_button top">';
$Form->button(array('submit', 'actionArray[crop]', T_('Crop'), 'SaveButton btn-primary'));
echo '</p>';
echo '<div id="image_crop_block"' . (!is_admin_page() && $display_mode != 'js' ? ' class="short_width"' : '') . '><div>';
// Main image
echo '<div id="target_cropped_image">' . $cropped_image_tag . '</div>';
echo '</div><div>';
// Check if we should display big preview images, Hide them on small screens:
$display_big_preview = (empty($image_width) || $image_width > 400) && (empty($image_height) || $image_height > 400);
// Preview thumbnails
echo '<div class="preview_cropped_images' . (!$display_big_preview ? ' only_small_preview' : '') . '" style="display:none">';
if ($display_big_preview) {
    echo '<div class="preview_cropped_image" style="width:128px;height:128px">' . $cropped_image_tag . '</div>';
}
echo '<div class="preview_cropped_image" style="width:64px;height:64px">' . $cropped_image_tag . '</div>';
if ($display_big_preview) {
    echo '<div class="preview_cropped_image circle" style="width:128px;height:128px">' . $cropped_image_tag . '</div>';
}
echo '<div class="preview_cropped_image circle" style="width:64px;height:64px">' . $cropped_image_tag . '</div>';
Example #20
0
function user_status($user_status, $user_ID)
{
    global $current_User;
    $user_status_icons = get_user_status_icons(true);
    $status_content = $user_status_icons[$user_status];
    if (is_admin_page() && $current_User->check_perm('users', 'edit')) {
        // current User is an administrator and view is displayed on admin interface, return link to user admin tab
        return '<a href="' . get_user_identity_url($user_ID, 'admin') . '">' . $status_content . '</a>';
    }
    return $status_content;
}
Example #21
0
/**
 * Get htsrv url on the same domain as the http request came from
 * _init_hit.inc.php should be called before this call, because ReqHost and ReqPath must be initialized
 */
function get_samedomain_htsrv_url($secure = false)
{
    global $ReqHost, $ReqPath, $htsrv_url, $htsrv_url_sensitive, $Blog;
    if ($secure) {
        $req_htsrv_url = $htsrv_url_sensitive;
    } else {
        $req_htsrv_url = $htsrv_url;
    }
    if (strpos($ReqHost . $ReqPath, $req_htsrv_url) !== false) {
        return $req_htsrv_url;
    }
    $req_url_parts = @parse_url($ReqHost);
    $hsrv_url_parts = @parse_url($req_htsrv_url);
    if (!isset($req_url_parts['host']) || !isset($hsrv_url_parts['host'])) {
        debug_die('Invalid hosts!');
    }
    $req_domain = $req_url_parts['host'];
    $htsrv_domain = $hsrv_url_parts['host'];
    $samedomain_htsrv_url = substr_replace($req_htsrv_url, $req_domain, strpos($req_htsrv_url, $htsrv_domain), strlen($htsrv_domain));
    if (!is_admin_page() && !empty($Blog) && $samedomain_htsrv_url != $Blog->get_local_htsrv_url()) {
        debug_die('Inconsistent state!');
    }
    return $samedomain_htsrv_url;
}
Example #22
0
 /**
  * Constructor
  *
  * Will fail if non existent User or Blog is requested.
  * But specific access permissions on (threfore existence of) this User or Blog should have been tested before anyway.
  *
  * @param string Root type: 'user', 'group' or 'collection'
  * @param integer ID of the user, the group or the collection the file belongs to...
  * @param boolean Create the directory, if it does not exist yet?
  */
 function FileRoot($root_type, $root_in_type_ID, $create = true)
 {
     /**
      * @var User
      */
     global $current_User;
     global $Messages;
     global $Settings, $Debuglog;
     global $Blog;
     // Store type:
     $this->type = $root_type;
     // Store ID in type:
     $this->in_type_ID = $root_in_type_ID;
     // Generate unique ID:
     $this->ID = FileRoot::gen_ID($root_type, $root_in_type_ID);
     switch ($root_type) {
         case 'user':
             $UserCache =& get_UserCache();
             if (!($User =& $UserCache->get_by_ID($root_in_type_ID, false, false))) {
                 // User not found
                 return false;
             }
             $this->name = $User->get('login');
             //.' ('. /* TRANS: short for "user" */ T_('u').')';
             $this->ads_path = $User->get_media_dir($create);
             $this->ads_url = $User->get_media_url();
             return;
         case 'collection':
             $BlogCache =& get_BlogCache();
             if (!($Blog =& $BlogCache->get_by_ID($root_in_type_ID, false, false))) {
                 // Blog not found
                 return false;
             }
             $this->name = $Blog->get('shortname');
             //.' ('. /* TRANS: short for "blog" */ T_('b').')';
             $this->ads_path = $Blog->get_media_dir($create);
             $this->ads_url = $Blog->get_media_url();
             return;
         case 'shared':
             // fp> TODO: handle multiple shared directories
             global $media_path, $media_url;
             $rds_shared_subdir = 'shared/global/';
             $ads_shared_dir = $media_path . $rds_shared_subdir;
             if (!$Settings->get('fm_enable_roots_shared')) {
                 // Shared dir is disabled:
                 $Debuglog->add('Attempt to access shared dir, but this feature is globally disabled', 'files');
             } elseif (!mkdir_r($ads_shared_dir)) {
                 // Only display error on an admin page:
                 if (is_admin_page()) {
                     $Messages->add(sprintf(T_('The directory &laquo;%s&raquo; could not be created.'), $rds_shared_subdir) . get_manual_link('directory_creation_error'), 'error');
                 }
             } else {
                 $this->name = T_('Shared');
                 $this->ads_path = $ads_shared_dir;
                 if (isset($Blog)) {
                     // (for now) Let's make shared files appear as being part of the currently displayed blog:
                     $this->ads_url = $Blog->get_local_media_url() . 'shared/global/';
                 } else {
                     $this->ads_url = $media_url . 'shared/global/';
                 }
             }
             return;
         case 'skins':
             // fp> some stuff here should go out of here... but I don't know where to put it yet. I'll see after the Skin refactoring.
             if (!$Settings->get('fm_enable_roots_skins')) {
                 // Skins root is disabled:
                 $Debuglog->add('Attempt to access skins dir, but this feature is globally disabled', 'files');
             } elseif (empty($current_User) || !$current_User->check_perm('templates')) {
                 // No perm to access templates:
                 $Debuglog->add('Attempt to access skins dir, but no permission', 'files');
             } else {
                 global $skins_path, $skins_url;
                 $this->name = T_('Skins');
                 $this->ads_path = $skins_path;
                 if (isset($Blog)) {
                     // (for now) Let's make skin files appear as being part of the currently displayed blog:
                     $this->ads_url = $Blog->get_local_skins_url();
                 } else {
                     $this->ads_url = $skins_url;
                 }
             }
             return;
     }
     debug_die("Invalid root type");
 }
Example #23
0
 /**
  * Restrict by members
  *
  * @param boolean TRUE to select only member of the current Blog
  */
 function where_members($members)
 {
     global $DB, $Blog;
     if (empty($members) || is_admin_page() || empty($Blog) || $Blog->get_setting('allow_access') != 'members') {
         // Don't restrict
         return;
     }
     // Get blog owner
     $blogowner_SQL = new SQL();
     $blogowner_SQL->SELECT('user_ID');
     $blogowner_SQL->FROM('T_users');
     $blogowner_SQL->FROM_add('INNER JOIN T_blogs ON blog_owner_user_ID = user_ID');
     $blogowner_SQL->WHERE('blog_ID = ' . $DB->quote($Blog->ID));
     // Calculate what users are members of the blog
     $userperms_SQL = new SQL();
     $userperms_SQL->SELECT('user_ID');
     $userperms_SQL->FROM('T_users');
     $userperms_SQL->FROM_add('INNER JOIN T_coll_user_perms ON ( bloguser_user_ID = user_ID AND bloguser_ismember = 1 )');
     $userperms_SQL->WHERE('bloguser_blog_ID = ' . $DB->quote($Blog->ID));
     // Calculate what user groups are members of the blog
     $usergroups_SQL = new SQL();
     $usergroups_SQL->SELECT('user_ID');
     $usergroups_SQL->FROM('T_users');
     $usergroups_SQL->FROM_add('INNER JOIN T_groups ON grp_ID = user_grp_ID');
     $usergroups_SQL->FROM_add('LEFT JOIN T_coll_group_perms ON ( bloggroup_group_ID = grp_ID AND bloggroup_ismember = 1 )');
     $usergroups_SQL->WHERE('bloggroup_blog_ID = ' . $DB->quote($Blog->ID));
     $members_count_sql = 'SELECT DISTINCT user_ID FROM ( ' . $blogowner_SQL->get() . ' UNION ' . $userperms_SQL->get() . ' UNION ' . $usergroups_SQL->get() . ' ) members';
     $this->WHERE_and('user_ID IN ( ' . $members_count_sql . ' ) ');
 }
Example #24
0
$form_title = '';
$form_class = 'fform user_report_form';
$Form->title_fmt = '<span style="float:right">$global_icons$</span><div>$title$</div>' . "\n";
if ($display_mode != 'js') {
    if (!$user_profile_only) {
        echo_user_actions($Form, $edited_User, $action);
    }
    $form_text_title = T_('Report User');
    // used for js confirmation message on leave the changed form
    $form_title = get_usertab_header($edited_User, '', $form_text_title);
}
$Form->begin_form($form_class, $form_title, array('title' => isset($form_text_title) ? $form_text_title : $form_title));
$Form->hidden_ctrl();
if (is_admin_page()) {
    // Params for backoffice
    $Form->hidden('user_tab', $user_tab);
    $Form->hidden('is_backoffice', 1);
} else {
    // Params for frontoffice
    global $Blog;
    $Form->hidden('blog', $Blog->ID);
}
$close_icon = '';
if ($display_mode == 'js') {
    // Display a close link for popup window
    $close_icon = action_icon(T_('Close this window'), 'close', '', '', 0, 0, array('id' => 'close_button', 'class' => 'floatright'));
}
$Form->begin_fieldset(T_('Report User') . $close_icon, array('class' => 'fieldset clear'));
user_report_form(array('Form' => $Form, 'user_ID' => $edited_User->ID, 'crumb_name' => 'user', 'cancel_url' => get_secure_htsrv_url() . 'profile_update.php?' . (is_admin_page() ? 'is_backoffice=1&amp;' : '') . 'action=remove_report&amp;' . 'user_ID=' . $edited_User->ID . '&amp;' . (empty($Blog) || is_admin_page() ? '' : 'blog=' . $Blog->ID . '&amp;') . url_crumb('user')));
$Form->end_fieldset();
$Form->end_form();
    $params = array_merge($default_params, $params);
} else {
    // Use a default params
    $params = $default_params;
}
// ------------------- PREV/NEXT USER LINKS -------------------
user_prevnext_links(array('block_start' => '<table class="prevnext_user"><tr>', 'prev_start' => '<td width="33%">', 'prev_end' => '</td>', 'prev_no_user' => '<td width="33%">&nbsp;</td>', 'back_start' => '<td width="33%" class="back_users_list">', 'back_end' => '</td>', 'next_start' => '<td width="33%" class="right">', 'next_end' => '</td>', 'next_no_user' => '<td width="33%">&nbsp;</td>', 'block_end' => '</tr></table>', 'user_tab' => 'pwdchange'));
// ------------- END OF PREV/NEXT USER LINKS -------------------
// check if reqID exists. If exists it means that this form is displayed because a password change request by email.
$reqID = param('reqID', 'string', '');
$Form = new Form($form_action, 'user_checkchanges');
$Form->switch_template_parts($params['skin_form_params']);
if (!$user_profile_only) {
    echo_user_actions($Form, $edited_User, $action);
}
$is_admin = is_admin_page();
if ($is_admin) {
    $form_title = get_usertab_header($edited_User, 'pwdchange', T_('Change password'));
    $form_class = 'fform';
    $Form->title_fmt = '<span style="float:right">$global_icons$</span><div>$title$</div>' . "\n";
} else {
    $form_title = '';
    $form_class = 'bComment';
}
$has_full_access = $current_User->check_perm('users', 'edit');
$Form->begin_form($form_class, $form_title);
$Form->add_crumb('user');
$Form->hidden_ctrl();
$Form->hidden('user_tab', 'pwdchange');
$Form->hidden('password_form', '1');
$Form->hidden('reqID', $reqID);
Example #26
0
    /**
     * Load items by the given categories or collection ID
     * After the Items are loaded create a map of loaded items by categories
     *
     * @param array of category ids
     * @param integer collection ID
     * @return boolean true if load items was required and it was loaded successfully, false otherwise
     */
    function load_by_categories($cat_array, $coll_ID)
    {
        global $DB, $posttypes_specialtypes;
        if (empty($cat_array) && empty($coll_ID)) {
            // Nothing to load
            return false;
        }
        // In case of an empty cat_array param, use categoriesfrom the given collection
        if (empty($cat_array)) {
            // Get all categories from the given subset
            $ChapterCache =& get_ChapterCache();
            $subset_chapters = $ChapterCache->get_chapters_by_subset($coll_ID);
            $cat_array = array();
            foreach ($subset_chapters as $Chapter) {
                $cat_array[] = $Chapter->ID;
            }
        }
        // Check which category is not loaded
        $not_loaded_cat_ids = array();
        foreach ($cat_array as $cat_ID) {
            if (!isset($this->items_by_cat_map[$cat_ID])) {
                // This category is not loaded
                $not_loaded_cat_ids[] = $cat_ID;
                // Initialize items_by_cat_map for this cat_ID
                $this->items_by_cat_map[$cat_ID] = array('items' => array(), 'sorted' => false);
            }
        }
        if (empty($not_loaded_cat_ids)) {
            // Requested categories items are all loaded
            return false;
        }
        // Query to load all Items from the given categories
        $sql = 'SELECT postcat_cat_ID as cat_ID, postcat_post_ID as post_ID FROM T_postcats
					WHERE postcat_cat_ID IN ( ' . implode(', ', $not_loaded_cat_ids) . ' )
					ORDER BY postcat_post_ID';
        $cat_posts = $DB->get_results($sql, ARRAY_A, 'Get all category post ids pair by category');
        // Initialize $Blog from coll_ID
        $BlogCache =& get_BlogCache();
        $Blog = $BlogCache->get_by_ID($coll_ID);
        $visibility_statuses = is_admin_page() ? get_visibility_statuses('keys', array('trash')) : get_inskin_statuses($coll_ID, 'post');
        // Create ItemQuery for loading visible items
        $ItemQuery = new ItemQuery($this->dbtablename, $this->dbprefix, $this->dbIDname);
        // Set filters what to select
        $ItemQuery->SELECT($this->dbtablename . '.*');
        $ItemQuery->where_chapter2($Blog, $not_loaded_cat_ids, "");
        $ItemQuery->where_visibility($visibility_statuses);
        $ItemQuery->where_datestart(NULL, NULL, NULL, NULL, $Blog->get_timestamp_min(), $Blog->get_timestamp_max());
        $ItemQuery->where_types('-' . implode(',', $posttypes_specialtypes));
        // Clear previous items from the cache and load by the defined SQL
        $this->clear(true);
        $this->load_by_sql($ItemQuery);
        foreach ($cat_posts as $row) {
            // Iterate through the post - cat pairs and fill the map
            if (empty($this->cache[$row['post_ID']])) {
                // The Item was not loaded because it does not correspond to the defined filters
                continue;
            }
            // Add to the map
            $this->items_by_cat_map[$row['cat_ID']]['items'][] = $this->get_by_ID($row['post_ID']);
        }
    }
/**
 * Get block/unblock icon
 *
 * @param block value
 * @param user ID
 * @return icon
 */
function contact_block($block, $user_ID, $user_status)
{
    if ($user_status == 'closed') {
        return '';
    }
    // set action url
    $action_url = regenerate_url();
    if (!is_admin_page()) {
        // in front office the action will be processed by messaging module handle_htsrv_action() through action.php
        $action_url = get_samedomain_htsrv_url() . 'action.php?mname=messaging&disp=contacts&redirect_to=' . rawurlencode($action_url);
    }
    if ($block == 0) {
        return action_icon(T_('Block contact'), 'file_allowed', $action_url . '&action=block&user_ID=' . $user_ID . '&amp;' . url_crumb('messaging_contacts'));
    } else {
        return action_icon(T_('Unblock contact'), 'file_not_allowed', $action_url . '&action=unblock&user_ID=' . $user_ID . '&amp;' . url_crumb('messaging_contacts'));
    }
}
Example #28
0
/**
 * Display login form
 *
 * @param array params
 */
function display_login_form($params)
{
    global $Settings, $Plugins, $Session, $Blog, $blog, $dummy_fields;
    global $secure_htsrv_url, $admin_url, $baseurl, $ReqHost;
    $params = array_merge(array('form_action' => '', 'form_name' => 'login_form', 'form_layout' => '', 'form_class' => 'bComment', 'source' => 'inskin login form', 'inskin' => true, 'login_required' => true, 'validate_required' => NULL, 'redirect_to' => '', 'login' => '', 'action' => '', 'reqID' => '', 'sessID' => '', 'transmit_hashed_password' => false), $params);
    $inskin = $params['inskin'];
    $login = $params['login'];
    $redirect_to = $params['redirect_to'];
    $links = array();
    if (empty($params['login_required']) && $params['action'] != 'req_validatemail' && strpos($redirect_to, $admin_url) !== 0 && strpos($ReqHost . $redirect_to, $admin_url) !== 0) {
        // No login required, allow to pass through
        // TODO: dh> validate redirect_to param?!
        // check if redirect_to url requires logged in user
        if (require_login($redirect_to, true)) {
            // logged in user require for redirect_to url
            if (!empty($blog)) {
                // blog is set
                if (empty($Blog)) {
                    $BlogCache =& get_BlogCache();
                    $Blog = $BlogCache->get_by_ID($blog, false);
                }
                // set abort url to Blog url
                $abort_url = $Blog->gen_blogurl();
            } else {
                // set abort login url to base url
                $abort_url = $baseurl;
            }
        } else {
            // logged in user isn't required for redirect_to url, set abort url to redirect_to
            $abort_url = $redirect_to;
        }
        $links[] = '<a href="' . htmlspecialchars(url_rel_to_same_host($abort_url, $ReqHost)) . '">' . T_('Abort login!') . '</a>';
    }
    if (!$inskin && is_logged_in()) {
        // if we arrive here, but are logged in, provide an option to logout (e.g. during the email validation procedure)
        $links[] = get_user_logout_link();
    }
    if (count($links)) {
        echo '<div style="float:right; margin: 0 1em">' . implode($links, ' &middot; ') . '</div>
		<div class="clear"></div>';
    }
    $Form = new Form($params['form_action'], $params['form_name'], 'post', $params['form_layout']);
    $Form->begin_form($params['form_class']);
    $Form->add_crumb('loginform');
    $source = param('source', 'string', $params['source'] . ' login form');
    $Form->hidden('source', $source);
    $Form->hidden('redirect_to', $redirect_to);
    if ($inskin) {
        // inskin login form
        $Form->hidden('inskin', true);
        $separator = '<br />';
    } else {
        // standard login form
        $Form->hidden('validate_required', $params['validate_required']);
        if (isset($params['action'], $params['reqID'], $params['sessID']) && $params['action'] == 'validatemail') {
            // the user clicked the link from the "validate your account" email, but has not been logged in; pass on the relevant data:
            $Form->hidden('action', 'validatemail');
            $Form->hidden('reqID', $params['reqID']);
            $Form->hidden('sessID', $params['sessID']);
        }
        $separator = '';
    }
    // check if should transmit hashed password
    if ($params['transmit_hashed_password']) {
        // used by JS-password encryption/hashing:
        $pwd_salt = $Session->get('core.pwd_salt');
        if (empty($pwd_salt)) {
            // Do not regenerate if already set because we want to reuse the previous salt on login screen reloads
            // fp> Question: the comment implies that the salt is reset even on failed login attemps. Why that? I would only have reset it on successful login. Do experts recommend it this way?
            // but if you kill the session you get a new salt anyway, so it's no big deal.
            // At that point, why not reset the salt at every reload? (it may be good to keep it, but I think the reason should be documented here)
            $pwd_salt = generate_random_key(64);
            $Session->set('core.pwd_salt', $pwd_salt, 86400);
            $Session->dbsave();
            // save now, in case there's an error later, and not saving it would prevent the user from logging in.
        }
        $Form->hidden('pwd_salt', $pwd_salt);
        $Form->hidden('pwd_hashed', '');
        // gets filled by JS
    }
    $Form->begin_field();
    $Form->text_input($dummy_fields['login'], $params['login'], 18, T_('Login'), $separator . T_('Enter your username (or email address).'), array('maxlength' => 255, 'class' => 'input_text', 'required' => true));
    $Form->end_field();
    if ($inskin) {
        $lost_password_url = regenerate_url('disp', 'disp=lostpassword');
    } else {
        $lost_password_url = $secure_htsrv_url . 'login.php?action=lostpassword&amp;redirect_to=' . rawurlencode(url_rel_to_same_host($redirect_to, $secure_htsrv_url));
    }
    if (!empty($login)) {
        $lost_password_url .= '&amp;' . $dummy_fields['login'] . '=' . rawurlencode($login);
    }
    $pwd_note = $pwd_note = '<a href="' . $lost_password_url . '">' . T_('Lost password ?') . '</a>';
    $Form->begin_field();
    $Form->password_input($dummy_fields['pwd'], '', 18, T_('Password'), array('note' => $pwd_note, 'maxlength' => 70, 'class' => 'input_text', 'required' => true));
    $Form->end_field();
    // Allow a plugin to add fields/payload
    $Plugins->trigger_event('DisplayLoginFormFieldset', array('Form' => &$Form));
    // Submit button(s):
    $submit_buttons = array(array('name' => 'login_action[login]', 'value' => T_('Log in!'), 'class' => 'search', 'style' => 'font-size: 120%'));
    if (!$inskin && strpos($redirect_to, $admin_url) !== 0 && strpos($ReqHost . $redirect_to, $admin_url) !== 0 && !is_admin_page()) {
        // provide button to log straight into backoffice, if we would not go there anyway
        $submit_buttons[] = array('name' => 'login_action[redirect_to_backoffice]', 'value' => T_('Log into backoffice!'), 'class' => 'search');
    }
    $Form->buttons_input($submit_buttons);
    if ($inskin) {
        $before_register_link = '<strong>';
        $after_register_link = '</strong>';
        $register_link_style = 'text-align:right; margin: 1em 0 1ex';
    } else {
        echo '<div class="center notes" style="margin: 1em 0">' . T_('You will have to accept cookies in order to log in.') . '</div>';
        // Passthrough REQUEST data (when login is required after having POSTed something)
        // (Exclusion of 'login_action', 'login', and 'action' has been removed. This should get handled via detection in Form (included_input_field_names),
        //  and "action" is protected via crumbs)
        $Form->hiddens_by_key(remove_magic_quotes($_REQUEST));
        $before_register_link = '';
        $after_register_link = '';
        $register_link_style = 'text-align:right';
    }
    echo '<div class="login_actions" style="' . $register_link_style . '">';
    echo get_user_register_link($before_register_link, $after_register_link, T_('No account yet? Register here') . ' &raquo;', '#', true, $redirect_to, $source);
    echo '</div>';
    $Form->end_form();
    echo '<script type="text/javascript">';
    // Autoselect login text input or pwd input, if there\'s a login already:
    echo 'var login = document.getElementById("' . $dummy_fields['login'] . '");
		if( login.value.length > 0 )
		{	// Focus on the password field:
			document.getElementById("' . $dummy_fields['pwd'] . '").focus();
		}
		else
		{	// Focus on the login field:
			login.focus();
		}';
    if ($params['transmit_hashed_password']) {
        // Hash the password onsubmit and clear the original pwd field
        // TODO: dh> it would be nice to disable the clicked/used submit button. That's how it has been when the submit was attached to the submit button(s)
        echo 'addEvent( document.getElementById("login_form"), "submit", function(){' . 'var form = document.getElementById("login_form");' . 'if( form.pwd_hashed && form.' . $dummy_fields['pwd'] . ' && form.pwd_salt && typeof hex_sha1 != "undefined" && typeof hex_md5 != "undefined" )
				{' . 'form.pwd_hashed.value = hex_sha1( hex_md5(form.' . $dummy_fields['pwd'] . '.value) + form.pwd_salt.value );
					form.' . $dummy_fields['pwd'] . '.value = "padding_padding_padding_padding_padding_padding_hashed_' . $Session->ID . '";' . '}
				return true;
			}, false );';
    }
    echo '</script>';
}
Example #29
0
 /**
  * Initiates the smiley array if not already initiated
  *
  * Attempts to use skin specific smileys where available
  *	- skins_adm/skin/rsc/smilies/
  *	- skins/skin/smilies/
  *
  * Attempts to fallback to default smilies
  *	- rsc/smilies/
  *
  * If no image file found the smiley is not added
  *
  * @return array of available smilies( code, image url )
  */
 function InitSmilies()
 {
     if (isset($this->smilies)) {
         // smilies are already cached
         return;
     }
     global $admin_skin, $adminskins_path, $adminskins_url, $rsc_path, $rsc_url, $skin, $skins_path, $skins_url;
     // set the skin path/url and the default (rsc) path/url
     $currentskin_path = (is_admin_page() ? $adminskins_path . $admin_skin . '/rsc' : $skins_path . $skin) . '/smilies/';
     $currentskin_url = (is_admin_page() ? $adminskins_url . $admin_skin . '/rsc' : $skins_url . $skin) . '/smilies/';
     $default_path = $rsc_path . 'smilies/';
     $default_url = $rsc_url . 'smilies/';
     $skin_has_smilies = is_dir($currentskin_path);
     // check if skin has a /smilies/ folder
     $this->smilies = array();
     $temp_list = explode("\n", str_replace(array("\r", "\t"), '', $this->Settings->get('smiley_list')));
     foreach ($temp_list as $temp_smiley) {
         $a_smiley = explode('<->', preg_replace_callback('#^(\\S.+?\\s)(.+?)(\\/\\/.*?)*$#', array($this, 'get_smiley'), $temp_smiley));
         if (isset($a_smiley[0]) and isset($a_smiley[1])) {
             // lets see if the file exists
             $temp_img = trim($a_smiley[1]);
             if ($skin_has_smilies && is_file($currentskin_path . $temp_img)) {
                 $temp_url = $currentskin_url . $temp_img;
                 // skin has it's own smiley, use it
                 $temp_path = $currentskin_path . $temp_img;
             } elseif (is_file($default_path . $temp_img)) {
                 $temp_url = $default_url . $temp_img;
                 // no skin image, but default smiley found so use it
                 $temp_path = $default_path . $temp_img;
             } else {
                 $temp_url = '';
                 // no smiley image found, so don't add the smiley
             }
             if ($temp_url) {
                 $this->smilies[] = array('code' => trim($a_smiley[0]), 'image' => $temp_url, 'path' => $temp_path);
             }
         }
     }
 }
Example #30
0
 /**
  * Build the evobar menu
  */
 function build_evobar_menu()
 {
     /**
      * @var Menu
      */
     global $topleft_Menu, $topright_Menu;
     global $current_User;
     global $baseurl, $home_url, $admin_url, $debug, $debug_jslog, $dev_menu, $seo_page_type, $robots_index;
     global $Blog, $blog, $activate_collection_toolbar;
     global $Settings;
     $perm_admin_normal = $current_User->check_perm('admin', 'normal');
     $perm_admin_restricted = $current_User->check_perm('admin', 'restricted');
     $entries = NULL;
     $working_blog = get_working_blog();
     if ($working_blog) {
         // Set collection url only when current user has an access to the working blog
         if (is_admin_page()) {
             // Front page of the working blog
             $BlogCache =& get_BlogCache();
             $working_Blog =& $BlogCache->get_by_ID($working_blog);
             $collection_url = $working_Blog->get('url');
         } else {
             // Dashboard of the working blog
             $collection_url = $admin_url . '?ctrl=dashboard&amp;blog=' . $working_blog;
         }
     }
     if ($perm_admin_normal || $perm_admin_restricted) {
         // Normal OR Restricted Access to Admin:
         $entries = array();
         if ($perm_admin_normal) {
             // Only for normal access
             $entries['b2evo'] = array('text' => '<strong>b2evolution</strong>', 'href' => $home_url, 'entry_class' => 'rwdhide');
         }
         $entries['front'] = array('text' => T_('Front<u>-office</u>'), 'href' => $baseurl, 'title' => T_('Go to the site home page (Front-office)'));
         $entries['dashboard'] = array('text' => T_('Back<u>-office</u>'), 'href' => $admin_url, 'title' => T_('Go to the site dashboard (Back-office)'));
         if ($perm_admin_normal) {
             // Only for normal access
             $entries['write'] = array('text' => '<span class="fa fa-plus-square"></span> ' . T_('Post'), 'title' => T_('No blog is currently selected'), 'disabled' => true, 'entry_class' => 'rwdhide');
         }
         if ($working_blog) {
             // Display a link to manage first available collection
             $entries['blog'] = array('text' => T_('Collection'), 'href' => $collection_url, 'disabled' => true);
         }
         $entries['tools'] = array('text' => T_('More'), 'href' => $admin_url . '#', 'disabled' => true);
     }
     if ((!is_admin_page() || !empty($activate_collection_toolbar)) && !empty($Blog)) {
         // A blog is currently selected AND we can activate toolbar items for selected collection:
         if ($current_User->check_perm('blog_post_statuses', 'edit', false, $Blog->ID)) {
             // We have permission to add a post with at least one status:
             $write_item_url = $Blog->get_write_item_url();
             if ($write_item_url) {
                 // write item URL is not empty, so it's sure that user can create new post
                 if (!$perm_admin_normal) {
                     $entries['write'] = array('text' => '<span class="fa fa-plus-square"></span> ' . T_('Post'));
                 }
                 $entries['write']['href'] = $write_item_url;
                 $entries['write']['disabled'] = false;
                 $entries['write']['title'] = T_('Write a new post into this blog');
             }
         }
         if ($perm_admin_normal && $working_blog) {
             if (empty($write_item_url)) {
                 // Display restricted message on this blog
                 $entries['write']['title'] = T_('You don\'t have permission to post into this blog');
             }
             // BLOG MENU:
             $entries['blog'] = array('text' => T_('Collection'), 'title' => T_('Manage this blog'), 'href' => $collection_url);
             $display_separator = false;
             if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) {
                 // Check if current user has an access to post lists
                 $items_url = $admin_url . '?ctrl=items&amp;blog=' . $Blog->ID . '&amp;filter=restore';
                 // Collection front page
                 $entries['blog']['entries']['coll_front'] = array('text' => T_('Collection Front Page') . '&hellip;', 'href' => $Blog->get('url'));
                 // Collection dashboard
                 $entries['blog']['entries']['coll_dashboard'] = array('text' => T_('Collection Dashboard') . '&hellip;', 'href' => $admin_url . '?ctrl=dashboard&amp;blog=' . $Blog->ID);
                 $entries['blog']['entries'][] = array('separator' => true);
                 if ($Blog->get('type') == 'manual') {
                     // Manual view
                     $entries['blog']['entries']['manual'] = array('text' => T_('Manual view') . '&hellip;', 'href' => $items_url . '&amp;tab=manual');
                 }
                 if ($Blog->get_setting('use_workflow')) {
                     // Workflow view
                     $entries['blog']['entries']['workflow'] = array('text' => T_('Workflow view') . '&hellip;', 'href' => $items_url . '&amp;tab=tracker');
                 }
                 $entries['blog']['entries']['posts'] = array('text' => T_('Posts') . '&hellip;', 'href' => $items_url);
                 $display_separator = true;
             }
             // Check if user has permission for published, draft or depreceted comments (any of these)
             if ($current_User->check_perm('blog_comments', 'edit', false, $Blog->ID)) {
                 // Comments:
                 $entries['blog']['entries']['comments'] = array('text' => T_('Comments') . '&hellip;', 'href' => $admin_url . '?ctrl=comments&amp;blog=' . $Blog->ID . '&amp;filter=restore');
                 $display_separator = true;
             }
             // Chapters / Categories:
             if ($current_User->check_perm('blog_cats', 'edit', false, $Blog->ID)) {
                 // Either permission for a specific blog or the global permission:
                 $entries['blog']['entries']['chapters'] = array('text' => T_('Categories') . '&hellip;', 'href' => $admin_url . '?ctrl=chapters&amp;blog=' . $Blog->ID);
                 $display_separator = true;
             }
             if ($display_separator) {
                 $entries['blog']['entries'][] = array('separator' => true);
             }
             // PLACE HOLDER FOR FILES MODULE:
             $entries['blog']['entries']['files'] = NULL;
             // BLOG SETTINGS:
             if ($current_User->check_perm('blog_properties', 'edit', false, $Blog->ID)) {
                 // We have permission to edit blog properties:
                 $blog_param = '&amp;blog=' . $Blog->ID;
                 $entries['blog']['entries']['features'] = array('text' => T_('Features'), 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=home' . $blog_param, 'entries' => array('front' => array('text' => T_('Front page') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=home' . $blog_param), 'posts' => array('text' => T_('Posts') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=features' . $blog_param), 'comments' => array('text' => T_('Comments') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=comments' . $blog_param), 'other' => array('text' => T_('Other displays') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=other' . $blog_param), 'more' => array('text' => T_('More') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=more' . $blog_param)));
                 $entries['blog']['entries']['skin'] = array('text' => T_('Skin') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=skin' . $blog_param);
                 $entries['blog']['entries']['plugin_settings'] = array('text' => T_('Plugins') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=plugin_settings' . $blog_param);
                 $entries['blog']['entries']['widgets'] = array('text' => T_('Widgets') . '&hellip;', 'href' => $admin_url . '?ctrl=widgets' . $blog_param);
                 if (!is_admin_page()) {
                     // Display a menu to turn on/off the debug containers
                     global $ReqURI, $Session;
                     if ($Session->get('display_containers_' . $Blog->ID) == 1) {
                         // To hide the debug containers
                         $entries['blog']['entries']['containers'] = array('text' => T_('Hide containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=hide'));
                     } else {
                         // To show the debug containers
                         $entries['blog']['entries']['containers'] = array('text' => T_('Show containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=show'));
                     }
                 }
                 $entries['blog']['entries']['general'] = array('text' => T_('Settings'), 'href' => $admin_url . '?ctrl=coll_settings' . $blog_param, 'entries' => array('general' => array('text' => T_('General') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=general' . $blog_param), 'urls' => array('text' => T_('URLs') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=urls' . $blog_param), 'seo' => array('text' => T_('SEO') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=seo' . $blog_param)));
                 if ($current_User->check_perm('options', 'view', false, $Blog->ID)) {
                     // Post Types & Statuses
                     $entries['blog']['entries']['general']['entries']['item_types'] = array('text' => T_('Post Types') . '&hellip;', 'href' => $admin_url . '?ctrl=itemtypes&amp;tab=settings&amp;tab3=types' . $blog_param);
                     $entries['blog']['entries']['general']['entries']['item_statuses'] = array('text' => T_('Post Statuses') . '&hellip;', 'href' => $admin_url . '?ctrl=itemstatuses&amp;tab=settings&amp;tab3=statuses' . $blog_param);
                 }
                 $entries['blog']['entries']['general']['entries']['advanced'] = array('text' => T_('Advanced') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=advanced' . $blog_param);
                 if ($Blog && $Blog->advanced_perms) {
                     $entries['blog']['entries']['general']['entries']['userperms'] = array('text' => T_('User perms') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=perm' . $blog_param);
                     $entries['blog']['entries']['general']['entries']['groupperms'] = array('text' => T_('Group perms') . '&hellip;', 'href' => $admin_url . '?ctrl=coll_settings&amp;tab=permgroup' . $blog_param);
                 }
                 if ($current_User->check_perm('options', 'view')) {
                     // Check if current user has a permission to view the common settings of the blogs
                     $entries['blog']['entries']['general']['entries']['common_settings'] = array('text' => T_('Common Settings') . '&hellip;', 'href' => $admin_url . '?ctrl=collections&amp;tab=blog_settings');
                 }
             }
         }
     }
     if ($perm_admin_restricted) {
         // DEV MENU:
         $dev_entries = array();
         if ($dev_menu || $debug || $debug_jslog) {
             if (isset($Blog)) {
                 $dev_entries['coll'] = array('text' => 'Collection = ' . $Blog->shortname, 'disabled' => true);
             }
             global $disp, $is_front;
             if (!empty($disp)) {
                 $dev_entries['disp'] = array('text' => '$disp = ' . $disp, 'disabled' => true);
             }
             global $disp_detail;
             if (!empty($disp_detail)) {
                 $dev_entries['disp_detail'] = array('text' => '$disp_detail = ' . $disp_detail, 'disabled' => true);
             }
             if (!empty($seo_page_type)) {
                 // Set in skin_init()
                 $dev_entries['seo_page_type'] = array('text' => '> ' . $seo_page_type, 'disabled' => true);
             }
             global $is_front;
             if (!empty($is_front)) {
                 $dev_entries['front'] = array('text' => 'This is the FRONT page', 'disabled' => true);
             }
             if ($robots_index === false) {
                 $debug_text = 'NO INDEX';
             } else {
                 $debug_text = 'do index';
             }
             $dev_entries['noindex'] = array('text' => $debug_text, 'disabled' => true);
         }
         if (($dev_menu || $debug) && !is_admin_page() && !empty($Blog)) {
             // Display a menu to turn on/off the debug containers
             global $ReqURI, $Session;
             $dev_entries[] = array('separator' => true);
             if ($Session->get('display_containers_' . $Blog->ID) == 1) {
                 // To hide the debug containers
                 $dev_entries['containers'] = array('text' => T_('Hide containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=hide'));
             } else {
                 // To show the debug containers
                 $dev_entries['containers'] = array('text' => T_('Show containers'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_containers=show'));
             }
             if ($Session->get('display_includes_' . $Blog->ID) == 1) {
                 // To hide the debug includes
                 $dev_entries['includes'] = array('text' => T_('Hide includes'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_includes=hide'));
             } else {
                 // To show the debug includes
                 $dev_entries['includes'] = array('text' => T_('Show includes'), 'href' => url_add_param(regenerate_url('display_containers'), 'display_includes=show'));
             }
         }
         // MORE menu:
         if ($current_User->check_perm('users', 'view')) {
             // Users:
             $entries['tools']['disabled'] = false;
             $entries['tools']['entries']['users'] = array('text' => T_('Users') . '&hellip;', 'href' => $admin_url . '?ctrl=users');
         }
         // PLACE HOLDER FOR MESSAGING MODULE:
         $entries['tools']['entries']['messaging'] = NULL;
         // PLACE HOLDER FOR FILES MODULE:
         $entries['tools']['entries']['files'] = NULL;
         $perm_options = $current_User->check_perm('options', 'view');
         $perm_spam = $perm_options && $current_User->check_perm('spamblacklist', 'view');
         $perm_emails = $current_User->check_perm('emails', 'view');
         $perm_maintenance = $current_User->check_perm('perm_maintenance', 'upgrade');
         if ($perm_spam || $perm_options || $perm_maintenance) {
             $entries['tools']['entries'][] = array('separator' => true);
             if ($perm_emails) {
                 $entries['tools']['entries']['email'] = array('text' => T_('Emails'), 'href' => $admin_url . '?ctrl=campaigns', 'entries' => array('campaigns' => array('text' => T_('Campaigns') . '&hellip;', 'href' => $admin_url . '?ctrl=campaigns'), 'blocked' => array('text' => T_('Addresses') . '&hellip;', 'href' => $admin_url . '?ctrl=email'), 'sent' => array('text' => T_('Sent') . '&hellip;', 'href' => $admin_url . '?ctrl=email&amp;tab=sent'), 'return' => array('text' => T_('Returned') . '&hellip;', 'href' => $admin_url . '?ctrl=email&amp;tab=return'), 'settings' => array('text' => T_('Settings') . '&hellip;', 'href' => $admin_url . '?ctrl=email&amp;tab=settings')));
             }
             $entries['tools']['disabled'] = false;
             $entries['tools']['entries']['system'] = array('text' => T_('System'), 'href' => $admin_url . '?ctrl=system');
             if ($perm_options) {
                 $entries['tools']['entries']['system']['entries']['status'] = array('text' => T_('Status') . '&hellip;', 'href' => $admin_url . '?ctrl=system');
             }
             if ($perm_options) {
                 $entries['tools']['entries']['system']['entries']['crontab'] = array('text' => T_('Scheduler') . '&hellip;', 'href' => $admin_url . '?ctrl=crontab');
             }
             if ($perm_spam) {
                 $entries['tools']['entries']['system']['entries']['antispam'] = array('text' => T_('Antispam') . '&hellip;', 'href' => $admin_url . '?ctrl=antispam');
             }
         }
         if ($perm_options) {
             // Global settings:
             $entries['tools']['entries']['system']['entries']['regional'] = array('text' => T_('Regional') . '&hellip;', 'href' => $admin_url . '?ctrl=regional');
             $entries['tools']['entries']['system']['entries']['skins'] = array('text' => T_('Skins') . '&hellip;', 'href' => $admin_url . '?ctrl=skins&amp;tab=system');
             $entries['tools']['entries']['system']['entries']['plugins'] = array('text' => T_('Plugins') . '&hellip;', 'href' => $admin_url . '?ctrl=plugins');
             $entries['tools']['entries']['system']['entries']['remote'] = array('text' => T_('Remote publishing') . '&hellip;', 'href' => $admin_url . '?ctrl=remotepublish');
             $entries['tools']['entries']['system']['entries']['maintenance'] = array('text' => T_('Maintenance') . '&hellip;', 'href' => $admin_url . '?ctrl=tools');
             $entries['tools']['entries']['system']['entries']['syslog'] = array('text' => T_('System log'), 'href' => '?ctrl=syslog');
         }
     }
     if ($entries !== NULL) {
         $topleft_Menu->add_menu_entries(NULL, $entries);
     }
     // ---------------------------------------------------------------------------
     /*
      * RIGHT MENU
      */
     global $localtimenow, $is_admin_page;
     $entries = array();
     // Dev menu:
     global $debug_jslog;
     if ($debug || $debug_jslog) {
         // Show JS log menu if debug is enabled
         $dev_entries[] = array('separator' => true);
         $dev_entries['jslog'] = array('text' => T_('JS log'), 'title' => T_('JS log'), 'class' => 'jslog_switcher');
     }
     if (!empty($dev_entries)) {
         // Add Dev menu if at least one entry is should be displayed
         $entries['dev'] = array('href' => $admin_url . '#', 'text' => '<span class="fa fa-wrench"></span> Dev', 'entries' => $dev_entries);
     }
     // User menu:
     $current_user_Group = $current_User->get_Group();
     $userprefs_entries = array('name' => array('text' => $current_User->get_avatar_imgtag('crop-top-32x32', '', 'left') . '&nbsp;' . $current_User->get_preferred_name() . '<br />&nbsp;<span class="note">' . $current_user_Group->get_name() . '</span>', 'href' => get_user_profile_url()));
     $userprefs_entries[] = array('separator' => true);
     $user_profile_url = get_user_profile_url();
     if (!empty($user_profile_url)) {
         // Display this menu item only when url is available to current user
         $userprefs_entries['profile'] = array('text' => T_('Edit your profile') . '&hellip;', 'href' => $user_profile_url);
     }
     $user_avatar_url = get_user_avatar_url();
     if (!empty($user_avatar_url)) {
         // Display this menu item only when url is available to current user
         $userprefs_entries['avatar'] = array('text' => T_('Your profile picture') . '&hellip;', 'href' => $user_avatar_url);
     }
     $user_pwdchange_url = get_user_pwdchange_url();
     if (!empty($user_pwdchange_url)) {
         // Display this menu item only when url is available to current user
         $userprefs_entries['pwdchange'] = array('text' => T_('Change password') . '&hellip;', 'href' => $user_pwdchange_url);
     }
     $user_preferences_url = get_user_preferences_url();
     if (!empty($user_preferences_url)) {
         // Display this menu item only when url is available to current user
         $userprefs_entries['userprefs'] = array('text' => T_('Preferences') . '&hellip;', 'href' => $user_preferences_url);
     }
     $user_subs_url = get_user_subs_url();
     if (!empty($user_subs_url)) {
         // Display this menu item only when url is available to current user
         $userprefs_entries['subs'] = array('text' => T_('Notifications') . '&hellip;', 'href' => $user_subs_url);
     }
     $entries['userprefs'] = array('text' => '<strong>' . $current_User->get_colored_login(array('login_text' => 'name')) . '</strong>', 'href' => get_user_profile_url(), 'entries' => $userprefs_entries);
     $entries['time'] = array('text' => date(locale_shorttimefmt(), $localtimenow), 'disabled' => true, 'entry_class' => 'rwdhide');
     if ($current_User->check_perm('admin', 'normal') && $current_User->check_perm('options', 'view')) {
         // Make time as link to Timezone settings if permission
         $entries['time']['disabled'] = false;
         $entries['time']['href'] = $admin_url . '?ctrl=time';
     }
     // ADMIN SKINS:
     if ($is_admin_page) {
         $admin_skins = get_admin_skins();
         if (count($admin_skins) > 1) {
             // We have several admin skins available: display switcher:
             $entries['userprefs']['entries']['admskins'] = array('text' => T_('Admin skin'));
             $redirect_to = rawurlencode(regenerate_url('', '', '', '&'));
             foreach ($admin_skins as $admin_skin) {
                 $entries['userprefs']['entries']['admskins']['entries'][$admin_skin] = array('text' => $admin_skin, 'href' => $admin_url . '?ctrl=users&amp;action=change_admin_skin&amp;new_admin_skin=' . rawurlencode($admin_skin) . '&amp;redirect_to=' . $redirect_to);
             }
         }
     }
     $entries['userprefs']['entries'][] = array('separator' => true);
     $entries['userprefs']['entries']['logout'] = array('text' => T_('Log out!'), 'href' => get_user_logout_url());
     $topright_Menu->add_menu_entries(NULL, $entries);
 }