Example #1
0
function community_pagesetup()
{
    // register links --
    global $profile_id;
    global $PAGE;
    global $CFG;
    global $USER;
    require_once dirname(__FILE__) . "/default_template.php";
    require_once dirname(__FILE__) . "/lib/communities_config.php";
    $page_owner = $profile_id;
    $usertype = user_type($page_owner);
    $username = user_info('username', $page_owner);
    if (isloggedin()) {
        if (COMMUNITY_CONTEXT != "network") {
            if (defined("context") && context == COMMUNITY_CONTEXT) {
                $PAGE->menu[] = array('name' => 'community', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/communities\" class=\"selected\" >" . __gettext("Communities") . '</a></li>');
            } else {
                $PAGE->menu[] = array('name' => 'community', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/communities\" >" . __gettext("Communities") . '</a></li>');
            }
        }
    }
    if ($usertype == "community") {
        /*$PAGE->menu_sub[] = array( 'name' => 'profile:edit',
          'html' => '<a href="'.$CFG->wwwroot.'profile/edit.php?profile_id='.$page_owner.'">'
          . __gettext("Edit community profile") . '</a>');*/
        $PAGE->menu_sub[] = array('name' => 'community:pic', 'html' => a_href("{$CFG->wwwroot}_icons/?context=profile&amp;profile_id={$page_owner}", __gettext("Community site picture")));
        $PAGE->menu_sub[] = array('name' => 'community:edit', 'html' => a_href("{$CFG->wwwroot}_userdetails/?context=profile&amp;profile_id={$page_owner}", __gettext("Edit community details")));
        /*$PAGE->menu_sub[] = array( 'name' => 'profile:view',
          'html' => a_href("{$CFG->wwwroot}{$username}/profile",
          __gettext("Return to community profile")));*/
        $PAGE->menu_sub[] = array('name' => 'community:adminmembers', 'html' => a_href("{$CFG->wwwroot}{$username}/community/members", __gettext("Edit members")));
        $PAGE->menu_sub[] = array('name' => 'community:requests', 'html' => a_href("{$CFG->wwwroot}{$username}/community/requests", __gettext("View membership requests")));
        $PAGE->menu_sub[] = array('name' => 'community:invite', 'html' => a_href("{$CFG->wwwroot}{$username}/community/invite", __gettext("Invite people")));
        $PAGE->menu_sub[] = array('name' => 'community:invite', 'html' => a_href("{$CFG->wwwroot}{$USER->username}/communities", __gettext("Back to communities")));
    } else {
        if ($usertype == "person") {
            if (defined("context") && context == COMMUNITY_CONTEXT) {
                if (COMMUNITY_COMPACT_VIEW) {
                    $PAGE->menu_sub[] = array('name' => 'community', 'html' => a_href("{$CFG->wwwroot}{$username}/communities", __gettext("My Communities")));
                    if (logged_on && $page_owner == $_SESSION['userid'] && ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident))) {
                        $PAGE->menu_sub[] = array('name' => 'community:owned', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/new", __gettext("New Community")));
                    }
                } else {
                    if ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident)) {
                        $PAGE->menu_sub[] = array('name' => 'community:owned', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/create", __gettext("Create a Community")));
                        $PAGE->menu_sub[] = array('name' => 'community', 'html' => a_href("{$CFG->wwwroot}{$username}/communities", __gettext("My Communities")));
                        if ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident)) {
                            $PAGE->menu_sub[] = array('name' => 'community:owned', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/owned", __gettext("Owned Communities")));
                        }
                    }
                }
            }
        }
    }
    $PAGE->search_menu[] = array('name' => __gettext("Communities"), 'user_type' => 'community');
    // Add membership requests to the personal network page
    if (defined("context") && context == "community" && isloggedin() && $page_owner == $_SESSION['userid']) {
        $PAGE->menu_sub[] = array('name' => 'membership:invites', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/invitations", __gettext("Community invitations")));
    }
}
Example #2
0
function elggadmin_pagesetup()
{
    // first login?
    global $CFG;
    if (user_flag_get('admin', $_SESSION['userid']) && !isset($CFG->elggadmin_installed)) {
        $CFG->elggadmin_installed = true;
        set_config('elggadmin_installed', true);
        header_redirect(get_url(null, 'elggadmin::config'), __gettext('Welcome to the Elgg configuration manager!'));
    }
    if (context() == 'admin') {
        if (!plugin_is_loaded('pages')) {
            elgg_messages_add(__gettext('Error: <code>elggadmin</code> plugin needs <code>pages</code> plugin to run'));
        } else {
            pages_submenu_add('elggadmin', __gettext('Site administration'), get_url(null, 'elggadmin::'), 10);
        }
    } elseif (context() == 'elggadmin') {
        if (!plugin_is_loaded('pages')) {
            elgg_messages_add(__gettext('Error: <code>elggadmin</code> plugin needs <code>pages</code> plugin to run'));
            header_redirect(get_url(null, 'admin::'));
        }
        // submenu options
        pages_submenu_add('elggadmin', __gettext('Configuration manager'), get_url(null, 'elggadmin::'));
        pages_submenu_add('elggadmin:theme', __gettext('Default theme editor'), get_url(null, 'elggadmin::theme'));
        pages_submenu_add('elggadmin:frontpage', __gettext('Frontpage template editor'), get_url(null, 'elggadmin::frontpage'));
        pages_submenu_add('elggadmin:logs', __gettext('Error log'), get_url(null, 'elggadmin::logs'));
        sidebar_add(50, 'sidebar-' . elggadmin_currentpage(), elggadmin_sidebar());
        // clear sidebar
        $clear_sidebar[] = 'sidebar-profile';
        $clear_sidebar[] = 'sidebar-' . elggadmin_currentpage();
        sidebar_remove($clear_sidebar, true);
        if (elggadmin_is_404()) {
            header('HTTP/1.0 404 Not Found');
        }
    }
}
Example #3
0
function admin_pagesetup()
{
    global $PAGE, $CFG;
    /*
        if (isadmin()) {
            $PAGE->menu_top [] = array( 'name' => 'admin',
                                        //'html' => a_href("{$CFG->wwwroot}_admin/",
                                        //                "Administration"));
                                        'html' => "<li><a href=\"" . $CFG->wwwroot . "mod/admin/\">" . __gettext("Administration") . "</a></li>");
        }
    */
    if (defined("context") && context == "account") {
        $PAGE->menu_sub[] = array('name' => 'user:edit', 'html' => a_href("{$CFG->wwwroot}_userdetails/", __gettext("Edit user details")));
        /*$PAGE->menu_sub[] = array (
        		'name' => 'user:icon',
        		'html' => a_href("{$CFG->wwwroot}_icons/",__gettext("Your site picture")));*/
    }
    if (defined("context") && context == "admin" && isloggedin() && user_flag_get("admin", $_SESSION['userid'])) {
        $PAGE->menu_sub[] = array('name' => 'admin', 'html' => a_href(get_url(-1, 'admin::main'), __gettext("Main")));
        $PAGE->menu_sub[] = array('name' => 'admin:users:add', 'html' => a_href(get_url(-1, 'admin::users::add'), __gettext("Add users")));
        $PAGE->menu_sub[] = array('name' => 'admin:users', 'html' => a_href(get_url(-1, 'admin::users'), __gettext("Manage users")));
        $PAGE->menu_sub[] = array('name' => 'admin:users:banned', 'html' => a_href(get_url(-1, 'admin::users::banned'), __gettext("Banned users")));
        $PAGE->menu_sub[] = array('name' => 'admin:users:admin', 'html' => a_href(get_url(-1, 'admin::users::admin'), __gettext("Admin users")));
        $PAGE->menu_sub[] = array('name' => 'admin:flags', 'html' => a_href(get_url(-1, 'admin::flags'), __gettext("Manage flagged content")));
        $PAGE->menu_sub[] = array('name' => 'admin:spam', 'html' => a_href(get_url(-1, 'admin::spam'), __gettext("Spam control")));
    }
}
Example #4
0
function pages_php_allowed()
{
    if (page_owner() == -1 || PAGES_ALLOW_PHP_USER || PAGES_ALLOW_PHP_ADMIN && user_flag_get('admin', page_owner())) {
        return true;
    } else {
        return false;
    }
}
Example #5
0
/**
 * Send a message to a user
 *
 * @param integer $to the receiving user id
 * @param integer $from the sending user id
 * @param string $message the message body
 * @return boolean
 * @author Ben WerdMuller <*****@*****.**>
 * @author Misja Hoebe <*****@*****.**>
 */
function message_user($to, $from, $title, $message)
{
    global $messages, $CFG;
    if (isset($to->ident)) {
        $to = $to->ident;
    }
    $notifications = user_flag_get("emailnotifications", $to);
    if ($notifications) {
        $email_from = new StdClass();
        $email_from->email = $CFG->noreplyaddress;
        $email_from->name = $CFG->sitename;
        if ($email_to = get_record('users', 'ident', $to)) {
            if (!email_to_user($email_to, $email_from, $title, $message . "\n\n\n" . __gettext("You cannot reply to this message by email."))) {
                $messages[] = __gettext("Failed to send email. An unknown error occurred.");
            }
        }
    }
    $m = new StdClass();
    $m->title = $title;
    $m->body = $message;
    $m->from_id = $from;
    $m->to_id = $to;
    $m->posted = time();
    $m->status = 'unread';
    if (!insert_record('messages', $m)) {
        trigger_error(__FUNCTION__ . ": Failed to send message from {$from} to {$to}. An unknown error occurred.", E_ERROR);
        $messages[] = __gettext("Failed to send message. An unknown error occurred.");
    } else {
        plugin_hook("message", "publish", $m);
        return true;
    }
}
<?php

// Flag functions: get
// Ben Werdmuller, Sept 05
/* 
Parameters:
[0] - name of the flag
[1] - user ID
    
Returns:
        
$value - if the flag is set
false - if it isn't        
*/
$flagname = $parameter[0];
$userid = (int) $parameter[1];
$run_result = user_flag_get($flagname, $userid);
Example #7
0
function profile_permissions_check($object)
{
    global $page_owner;
    if ($object === "profile" && ($page_owner == $_SESSION['userid'] || user_flag_get("admin", $_SESSION['userid']))) {
        return true;
    }
    return false;
}
Example #8
0
/**
 * 
 * @return boolean
 */
function isadmin($userid = 0)
{
    global $USER;
    static $admins, $nonadmins;
    if (!isset($admins)) {
        $admins = array();
        $nonadmins = array();
    }
    if (empty($userid)) {
        if (empty($USER)) {
            // maybe not logged in
            return false;
        } else {
            $userid = (int) $USER->ident;
        }
    }
    if (in_array($userid, $admins)) {
        return true;
    } else {
        if (in_array($userid, $nonadmins)) {
            return false;
        } else {
            if (user_flag_get('admin', $userid)) {
                $admins[] = $userid;
                return true;
            } else {
                $nonadmins[] = $userid;
                return false;
            }
        }
    }
}
     $recipients[] = $to;
 }
 $msgs = 0;
 foreach ($recipients as $rcpt) {
     $msg->to_id = trim($rcpt);
     $msg->title = $subject;
     if ($recipient->user_type == "community") {
         $msg->title = "[" . $recipient->name . "] " . $subject;
     }
     $insert_id = insert_record('messages', $msg);
     if ($insert_id != -1) {
         $msgs++;
     }
     // Send the email confirmation if configured
     // Don't use the weblog plug-in hook because it inserts data in the messages table too
     $notifications = user_flag_get("emailnotifications", $msg->to_id);
     if ($notifications) {
         $email_from = new StdClass();
         $email_from->email = $CFG->noreplyaddress;
         $email_from->name = $CFG->sitename;
         $email_message = sprintf(__gettext("You have received a message from %s."), user_info("name", $msg->from_id));
         $email_message .= "\n\n";
         $email_message .= sprintf(__gettext("To reply, click here: %s"), $CFG->wwwroot . user_info("username", $msg->to_id) . "/messages/");
         $email_message = wordwrap($email_message);
         if ($email_to = get_record_sql("select * from " . $CFG->prefix . "users where ident = " . $msg->to_id)) {
             if (!email_to_user($email_to, $email_from, $msg->title, $email_message . "\n\n\n" . __gettext("You cannot reply to this message by email."))) {
                 $messages[] = __gettext("Failed to send email. An unknown error occurred.");
             }
         }
     }
 }
     }
     break;
     // Create a weblog comment
 // Create a weblog comment
 case "weblogs:comment:add":
     $comment = new StdClass();
     $comment->post_id = optional_param('post_id', 0, PARAM_INT);
     $comment->body = trim(optional_param('new_weblog_comment'));
     $comment->postedname = trim(optional_param('postedname'));
     $commentbackup = $comment;
     if (!empty($comment->post_id) && !empty($comment->body) && !empty($comment->postedname)) {
         $where = run("users:access_level_sql_where", $USER->ident);
         if ($post = get_record_select('weblog_posts', '(' . $where . ') AND ident = ' . $comment->post_id)) {
             if (run("spam:check", $comment->body) != true) {
                 // If we're logged on or comments are public, add one
                 if (logged_on || !$CFG->disable_publiccomments && user_flag_get("publiccomments", $post->owner)) {
                     $comment->owner = $USER->ident;
                     $comment->posted = time();
                     $comment = plugin_hook("weblog_comment", "create", $comment);
                     if (!empty($comment)) {
                         $insert_id = insert_record('weblog_comments', $comment);
                         $comment->ident = $insert_id;
                         $comment = plugin_hook("weblog_comment", "publish", $comment);
                         $messages[] = __gettext("Your comment has been added.");
                         // gettext variable
                         // If we're logged on and not the owner of this post, add post to our watchlist
                         if (logged_on && $comment->owner != $post->owner) {
                             delete_records('weblog_watchlist', 'weblog_post', $comment->post_id, 'owner', $comment->owner);
                             $wl = new StdClass();
                             $wl->owner = $comment->owner;
                             $wl->weblog_post = $comment->post_id;
      $run_result .= "<h3>" . __gettext("Change icon quota:") . "</h3>";
      $run_result .= templates_draw(array(
                                          'context' => 'databox',
                                          'name' => __gettext("New icon quota: "),
                                          'column1' => "<input type=\"text\" name=\"change_iconquota\" value=\"".$user_details->icon_quota."\" />"
                                          )
                                    );*/
    if ($user_details->user_type == "person") {
        $run_result .= "<h3>" . __gettext("User flags:") . "</h3>";
        // Is the user an administrator?
        if (user_flag_get("admin", $page_owner)) {
            $checkedyes = "checked = \"true\"";
            $checkedno = "";
        } else {
            $checkedyes = "";
            $checkedno = "checked = \"true\"";
        }
        $run_result .= templates_draw(array('context' => 'databox', 'name' => __gettext("Site administrator: "), 'column1' => "<input type=\"radio\" name=\"flag[admin]\" value=\"1\" {$checkedyes} />" . __gettext("Yes") . " " . "<input type=\"radio\" name=\"flag[admin]\" value=\"0\" {$checkedno} />" . __gettext("No")));
        // Is the user banned?
        if (user_flag_get("banned", $page_owner)) {
            $checkedyes = "checked = \"true\"";
            $checkedno = "";
        } else {
            $checkedyes = "";
            $checkedno = "checked = \"true\"";
        }
        $run_result .= templates_draw(array('context' => 'databox', 'name' => __gettext("Banned: "), 'column1' => "<input type=\"radio\" name=\"flag[banned]\" value=\"1\" {$checkedyes} />" . __gettext("Yes") . " " . "<input type=\"radio\" name=\"flag[banned]\" value=\"0\" {$checkedno} />" . __gettext("No")));
    }
    // Allow for user administration flags from other plugins
    $run_result .= run("admin:user:flags", $page_owner);
}
Example #12
0
/**
 * Render sidebar
 *
 * @return string
 */
function sidebar_display()
{
    global $PAGE;
    $body = '';
    if (!empty($PAGE->sidebar) && is_array($PAGE->sidebar)) {
        $sidebar = $PAGE->sidebar;
        // sort if needed
        ksort($sidebar);
        foreach ($sidebar as $w => $blocks) {
            foreach ($blocks as $block) {
                if (user_flag_get('sidebar' . $block['id'], page_owner()) != 'no') {
                    // print_object($block['id']);
                    if (empty($block['body']) && is_callable($block['id'])) {
                        // call function that returns sidebar body
                        $block_body = $block['id']();
                    } else {
                        $block_body = $block['body'];
                    }
                    $body .= templates_draw(array('context' => 'sidebar:block', 'id' => $block['id'], 'class' => $block['class'], 'body' => $block_body));
                }
            }
        }
    }
    return templates_draw(array('context' => 'sidebar:wrap', 'body' => $body));
}
 * @copyright Copyright (c) 2007 Pro Soft Resources Inc. http://www.prosoftpeople.com
 * @author Rolando Espinoza La fuente <*****@*****.**>
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 */
/**
 * Displays per-block settings on account settings
 */
global $page_owner;
$title = __gettext('Sidebar settings');
$blurb = __gettext("This settings allows you to configure what block you want to display on your sidebar.");
$body = "<h2>{$title}</h2>\n<p>{$blurb}</p>";
$settings = "<table>";
$blocks = sidebar_get_blocks();
foreach ($blocks as $b) {
    $flag_name = 'sidebar' . $b['id'];
    $flag = user_flag_get($flag_name, page_owner());
    if ($flag == 'no') {
        $yescheck = '';
        $nocheck = 'checked="true"';
    } else {
        $yescheck = 'checked="true"';
        $nocheck = '';
    }
    $name = 'flag[' . $flag_name . ']';
    $label = $b['label'];
    $yes = "<label><input type=\"radio\" name=\"{$name}\" value=\"yes\" {$yescheck} />" . __gettext('Yes') . "</label>";
    $no = "<label><input type=\"radio\" name=\"{$name}\" value=\"no\" {$nocheck} />" . __gettext('No') . "</label>";
    $settings .= "<tr><td><strong>{$label}</strong></td><td>{$yes}</td><td>{$no}</td></tr>";
}
$settings .= "</table>";
//FIXME preserve legacy style
$friend_id = optional_param('friend_id', 0, PARAM_INT);
if (isloggedin()) {
    switch ($action) {
        // Create a new community
        case "community:create":
            $comm_name = optional_param('comm_name');
            $comm_description = optional_param('comm_description');
            $comm_email = optional_param('comm_email');
            $comm_city = optional_param('comm_city');
            if (trim($comm_name) == "") {
                $messages[] = __gettext("Error! The community name cannot be blank.");
            }
            if (trim($comm_description) == "") {
                $messages[] = __gettext("Error! The community description cannot be blank.");
            }
            if (logged_on && !empty($comm_name) && ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident))) {
                $name = trim($comm_name);
                $c = new StdClass();
                $c->name = $name;
                $c->username = '******' . substr(base_convert(md5(time() . $comm_name), 16, 36), 0, 15);
                $c->user_type = 'community';
                $c->owner = $USER->ident;
                $cid = insert_record('users', $c);
                $c->ident = $cid;
                //Create a details of community
                $cd = new StdClass();
                $cd->owner = $cid;
                $cd->description = $comm_description;
                $cd->email = $comm_email;
                $cd->city = $comm_city;
                $communnity_details = insert_record('community_details', $cd);
<?php

// Get the user preferences for the editor
// Userid
$id = (int) $parameter;
// Editor is enabled by default
$value = "yes";
// Query result
if ($result = user_flag_get('visualeditor', $id)) {
    $value = $result;
} else {
    // No result, store a default value
    user_flag_set('visualeditor', $value, $id);
}
$run_result = $value;
<?php

$comm_name = '';
if (isset($_SESSION['comm_name'])) {
    $comm_name = $_SESSION['comm_name'];
}
$comm_username = '';
if (isset($_SESSION['comm_username'])) {
    $comm_username = $_SESSION['comm_username'];
}
global $page_owner, $CFG, $USER;
if (logged_on && $page_owner == $_SESSION['userid'] && ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident))) {
    $title = __gettext("Create a new community");
    // gettext variable
    $communityName = __gettext("Community name:");
    // gettext variable
    $buttonValue = __gettext("Create");
    // gettext variable
    $description = __gettext("Description:");
    // gettext variable
    $email = __gettext("Email -- Optional:");
    // gettext variable
    $city = __gettext("City -- Optional:");
    // gettext variable
    /*$fields = templates_draw(array('context' => 'databox1',
             'name' => $communityName,
             'column1' => "<input type=\"text\" name=\"comm_name\" value=\"$comm_name\" size=\"50\"/>"
             )
      );*/
    $fields .= templates_draw(array('context' => 'databox1', 'name' => $communityName, 'column1' => display_input_field(array("comm_name", "", "text"))));
    $fields .= templates_draw(array('context' => 'databox1', 'name' => $description, 'column1' => display_input_field(array("comm_description", "", "mediumtext"))));
global $USER;
global $messages;
$action = optional_param('action');
if (!empty($action) && isloggedin()) {
    switch ($action) {
        case "content:flag":
            $cf = new StdClass();
            $cf->url = trim(optional_param('address', '', PARAM_URL));
            if (!empty($cf->url)) {
                insert_record('content_flags', $cf);
                $messages[] = "You have flagged this page as being obscene or inappropriate. An administrator will investigate this shortly.";
            }
            break;
    }
    if (user_flag_get("admin", $USER->ident)) {
        switch ($action) {
            case "content:flags:delete":
                $remove = optional_param('remove', '', PARAM_URL);
                if (empty($remove)) {
                    $remove = array();
                }
                if (!is_array($remove)) {
                    $remove = array($remove);
                }
                foreach ($remove as $remove_url) {
                    $remove_url = trim($remove_url);
                    delete_records('content_flags', 'url', $remove_url);
                }
                $messages[] = "The selected content flags were deleted.";
                break;
Example #18
0
function gettext_userdetails_actions()
{
    global $CFG, $USER, $messages;
    $action = optional_param('action');
    $id = optional_param('id', 0, PARAM_INT);
    $lang = optional_param('lang', $CFG->defaultlocale, PARAM_ALPHAEXT);
    $lang_db = user_flag_get('language', $id);
    if ($lang == 'default') {
        $lang = $CFG->defaultlocale;
    }
    if (logged_on && !empty($action) && run("permissions:check", array("userdetails:change", $id)) && $action == "userdetails:update") {
        if (!empty($lang)) {
            if ($lang != $lang_db) {
                if (user_flag_set('language', $lang, $id)) {
                    $_SESSION['locale'] = $lang;
                    $USER->locale = $lang;
                    $messages[] .= __gettext("Preferred language") . " " . __gettext("saved") . ".";
                }
            }
        }
    }
}
    }
    $run_result = array();
    if (!empty($friend_id) && logged_on) {
        if (user_info("user_type", $friend_id) == "community") {
            if ($friend = get_record('users', 'ident', $friend_id)) {
                $owner = get_record('users', 'ident', $friend->owner);
                if ($friend->moderation == "no") {
                    $run_result[] = sprintf(__gettext("You joined %s."), stripslashes($friend->name));
                    if (user_flag_get("emailnotifications", $owner->ident)) {
                        $message_body = sprintf(__gettext("%s has joined %s!\n\nTo visit this user's profile, click on the following link:\n\n\t" . "%s\n\nTo view all community members, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username", $USER->ident) . "/", $CFG->wwwroot . $friend->username . "/community/members", $CFG->sitename);
                        $title = sprintf(__gettext("New %s member"), $friend->name);
                        notify_user($owner->ident, $title, $message_body);
                    }
                } else {
                    if ($friend->moderation == "yes") {
                        $run_result[] = sprintf(__gettext("Membership of %s needs to be approved. Your request has been added to the list."), stripslashes($friend->name));
                        if (user_flag_get("emailnotifications", $owner->ident)) {
                            $message_body = sprintf(__gettext("%s has applied to join %s!\n\nTo visit this user's profile, click on the following link:\n\n\t" . "%s\n\nTo view all membership requests and approve or deny this user, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username", $USER->ident) . "/", $CFG->wwwroot . $friend->username . "/community/members", $CFG->sitename);
                            $title = sprintf(__gettext("New %s member request"), $friend->name);
                            notify_user($owner->ident, $title, $message_body);
                        }
                    } else {
                        if ($friend->moderation == "priv") {
                            $run_result[] = sprintf(__gettext("%s is a private community. Your membership request has been declined."), stripslashes($friend->name));
                        }
                    }
                }
            }
        }
    }
}
Example #20
0
/**
 * Determines whether or not the current user has permission to do something with the comment.
 *
 * @param $owner The owner of the comment.
 * @return boolean True or false.
 */
function commentwall_permissions_check($owner)
{
    global $CFG;
    if (isloggedin()) {
        if ($owner == $_SESSION['userid'] || user_flag_get('admin', $_SESSION['userid'])) {
            return true;
        }
        if (user_info("user_type", $owner) == "community") {
            if (record_exists('users', 'ident', $owner, 'owner', $_SESSION['userid'], 'user_type', 'community')) {
                return true;
            }
            if (count_records_sql('SELECT count(u.ident) FROM ' . $CFG->prefix . 'friends f
                                             JOIN ' . $CFG->prefix . 'users u ON u.ident = f.friend
                                             WHERE u.ident = ? AND f.owner = ? AND u.user_type = ?', array($owner, $_SESSION['userid'], 'community'))) {
                return true;
            }
        }
    }
    return false;
}
            $body .= templates_draw(array('context' => 'databox', 'name' => __gettext("Public comments: "), 'column1' => "<label><input type=\"radio\" name=\"publiccomments\" value=\"yes\" checked=\"checked\" /> " . __gettext("Yes") . "</label> <label><input type=\"radio\" name=\"publiccomments\" value=\"no\" /> " . __gettext("No") . "</label>"));
        } else {
            $body .= templates_draw(array('context' => 'databox', 'name' => __gettext("Public comments: "), 'column1' => "<label><input type=\"radio\" name=\"publiccomments\" value=\"yes\" /> " . __gettext("Yes") . "</label> <label><input type=\"radio\" name=\"publiccomments\" value=\"no\" checked=\"checked\" /> " . __gettext("No") . "</label>"));
        }
    }
    $emailReplies = __gettext("Receive email notifications");
    $emailRules = __gettext("Set this to 'yes' if you would like to receive email copies of any messages you receive. This includes blog comments, notifications when people add you as a friend and more. You can always view these online as part of your recent activity page.");
    $body .= <<<END

        <h2>{$emailReplies}</h2>
        <p>
            {$emailRules}
        </p>

END;
    $emailreplies = user_flag_get("emailnotifications", $page_owner);
    if ($emailreplies) {
        $body .= templates_draw(array('context' => 'databox', 'name' => __gettext("Receive notifications: "), 'column1' => "<label><input type=\"radio\" name=\"receivenotifications\" value=\"yes\" checked=\"checked\" /> " . __gettext("Yes") . "</label> <label><input type=\"radio\" name=\"receivenotifications\" value=\"no\" /> " . __gettext("No") . "</label>"));
    } else {
        $body .= templates_draw(array('context' => 'databox', 'name' => __gettext("Receive notifications: "), 'column1' => "<label><input type=\"radio\" name=\"receivenotifications\" value=\"yes\" /> " . __gettext("Yes") . "</label> <label><input type=\"radio\" name=\"receivenotifications\" value=\"no\" checked=\"checked\" /> " . __gettext("No") . "</label>"));
    }
    if (empty($CFG->disable_passwordchanging)) {
        $password = __gettext("Change your password:"******"Leave this blank if you're happy to leave your password as it is.");
        // gettext variable
        $body .= <<<END

    <h2>
        {$password}
    </h2>
<?php

// List of users in the system
if (logged_on && user_flag_get("admin", $_SESSION['userid'])) {
    // We're only displaying 50 users a page, so if this variable exists it will serve as the offset
    $offset = optional_param('offset', 0, PARAM_INT);
    $run_result .= "<p>" . __gettext("The following is a list of all the users in the system, 50 users at a time. You can click each one to edit their user details as if you were logged in as them, as well as set user flags (including 'ban user' and 'set user as administrator').") . "</p>";
    $run_result .= "<p>" . __gettext("If you know the username of the user you would like to edit, you can also enter it below.") . "</p>";
    $current_type = optional_param('user_type', 'person');
    $user_types = get_user_types();
    if (!empty($user_types)) {
        $run_result .= '<p>' . __gettext('Filter user type');
        foreach ($user_types as $user_type) {
            $run_result .= ' | ';
            if ($user_type == $current_type) {
                $run_result .= $user_type;
            } else {
                $run_result .= '<a href="' . get_url_query(1, 'admin::users', 'user_type=' . $user_type) . '">' . $user_type . '</a>';
            }
        }
    }
    $run_result .= "<form action=\"" . url . "_userdetails/\" method=\"get\">";
    $run_result .= templates_draw(array('context' => 'adminTable', 'name' => "<h4>" . __gettext("Enter username") . "</h4>", 'column1' => "<input type=\"text\" name=\"profile_name\" value=\"\" /><input type=\"hidden\" name=\"context\" value=\"admin\" />", 'column2' => "<input type=\"submit\" value=\"" . __gettext("Edit user") . "\" />"));
    $run_result .= "</form>";
    $maxusers = count_records('users', 'user_type', $current_type);
    if ($users = get_records('users', 'user_type', $current_type, 'name ASC', '*', $offset, 50)) {
        if ($maxusers > $offset + 50) {
            $next = "<a href=\"" . get_url_query(null, 'admin::users', "user_type={$current_type}&offset=" . ($offset + 50)) . "\">" . __gettext("Next") . "</a>";
        } else {
            $next = "";
        }
Example #23
0
                   set_field('users', 'name', 'Administrator', 'username', 'news');
                   set_field('users', 'username', $CFG->newsinitialusername, 'username', 'news');
                                }
                */
            } else {
                $db->debug = false;
                error("Error: Main databases NOT set up successfully");
            }
        }
    } else {
        error("Error: Your database ({$CFG->dbtype}) is not yet fully supported by Elgg.  See the lib/db directory.");
    }
    print_continue("index.php");
    die;
}
if (user_flag_get("admin", $_SESSION['userid'])) {
    if (empty($CFG->version)) {
        $CFG->version = 1;
    }
    if (empty($CFG->release)) {
        $CFG->release = "";
    }
    if (!$datalists) {
        $CFG->version = -1;
    }
    /// Upgrades
    include_once $CFG->dirroot . "version.php";
    # defines $version
    include_once $CFG->dirroot . "lib/db/{$CFG->dbtype}.php";
    # defines upgrades
    if ($CFG->version) {
 $comment->object_id = optional_param('object_id', 0, PARAM_INT);
 $comment->object_type = optional_param('object_type', '');
 $comment->body = trim(optional_param('new_comment'));
 $comment->postedname = trim(optional_param('postedname'));
 $commentbackup = $comment;
 if (!empty($comment->object_id) && !empty($comment->body) && !empty($comment->postedname)) {
     $object_owner = get_owner($comment->object_id, $comment->object_type);
     $where = run("users:access_level_sql_where", $USER->ident);
     if ($comment_form_type == 'integrated') {
         $redirect_url = get_url($comment->object_id, $comment->object_type);
     } elseif ($comment_form_type == 'separate') {
         $redirect_url = $CFG->wwwroot . "mod/generic_comments/comment_page.php?object_id={$comment->object_id}&object_type={$comment->object_type}";
     }
     if (run("spam:check", $comment->body) != true) {
         // If we're logged on or comments are public, add one
         if (isloggedin() || !$CFG->disable_publiccomments && user_flag_get("publiccomments", $object_owner)) {
             $comment->owner = $USER->ident;
             $comment->posted = time();
             $comment = plugin_hook("comment", "create", $comment);
             if (!empty($comment)) {
                 $insert_id = insert_record('comments', $comment);
                 $comment->ident = $insert_id;
                 $comment = plugin_hook("comment", "publish", $comment);
                 $messages[] = __gettext("Your comment has been added.");
                 // gettext variable
                 $ok = true;
                 // If we're logged on and not the owner of this post, add post to our watchlist
                 if (isloggedin() && $comment->owner != $object_owner) {
                     delete_records('watchlist', 'object_id', $comment->object_id, 'object_type', $comment->object_type, 'owner', $comment->owner);
                     $wl = new StdClass();
                     $wl->owner = $comment->owner;
function pages_is_default($page_id, $owner = -1)
{
    if ($owner > 0) {
        $default = user_flag_get('pages_default', $owner);
    } else {
        $obj = get_config('pages_default');
        $default = $obj->value;
    }
    return $page_id == $default;
}
<?php

global $USER, $CFG;
// Main admin panel screen
// Site stats
if (logged_on && user_flag_get("admin", $USER->ident)) {
    $run_result .= "<h2>" . __gettext("Site statistics") . "</h2>";
    // Number of users of each type
    $users = count_users();
    if (!empty($users) && is_array($users)) {
        $data = '';
        foreach ($users as $user) {
            $data .= '<h4>' . $user->user_type . ":</h4><p>" . $user->numusers . "</p> ";
        }
        $run_result .= templates_draw(array('context' => 'adminTable', 'name' => "<h3>" . __gettext("Accounts by type") . "</h3> ", 'column1' => '' . $data . '', 'column2' => "&nbsp;"));
    }
    // Number of weblog posts
    $weblog_posts = count_records('weblog_posts');
    $weblog_comments = count_records('weblog_comments');
    $weblog_posts_7days = count_records_select('weblog_posts', "posted > ?", array(time() - 86400 * 7));
    $weblog_comments_7days = count_records_select('weblog_comments', "posted > ?", array(time() - 86400 * 7));
    $run_result .= templates_draw(array('context' => 'adminTable', 'name' => "<h3>" . __gettext("Weblog statistics") . "</h3> ", 'column1' => "<h4>" . __gettext("All-time:") . "</h4><p>" . sprintf(__gettext("%u weblog posts,\n %u comments"), $weblog_posts, $weblog_comments) . "</p><h4>" . __gettext("Last 7 days:") . "</h4><p>" . sprintf(__gettext("%u weblog posts,\n %u comments"), $weblog_posts_7days, $weblog_comments_7days) . "</p>", 'column2' => "&nbsp;"));
    // Number of files
    $files = get_record_sql('SELECT COUNT(ident) AS numfiles,SUM(size) AS totalsize FROM ' . $CFG->prefix . 'files');
    $files_7days = get_record_sql('SELECT COUNT(ident) AS numfiles, SUM(size) AS totalsize FROM ' . $CFG->prefix . 'files WHERE time_uploaded > ?', array(time() - 86400 * 7));
    $run_result .= templates_draw(array('context' => 'adminTable', 'name' => "<h3>" . __gettext("File statistics") . "</h3> ", 'column1' => "<h4>" . __gettext("All-time:") . "</h4> <p>" . sprintf(__gettext("%u files (%s)"), $files->numfiles, size_readable($files->totalsize)) . "</p><h4>" . __gettext("Last 7 days:") . "</h4><p>" . sprintf(__gettext("%u files (%s)"), $files_7days->numfiles, size_readable($files_7days->totalsize)) . "</p>", 'column2' => "&nbsp;"));
    // DB size
    $totaldbsize = 0;
    if ($CFG->dbtype == 'mysql') {
        if ($dbsize = get_records_sql('SHOW TABLE STATUS')) {
            foreach ($dbsize as $atable) {
<?php

$title = __gettext("Comment wall");
$blurb = __gettext("This setting allows you to configure who can post to your comment wall.");
$access = user_flag_get("commentwall_access", $page_owner);
if (!$access) {
    $access = "LOGGED_IN";
}
// If no access controls set then assume public
$pub = "";
$logi = "";
$pri = "";
$fo = "";
if ($access == "PUBLIC") {
    $pub = " selected=\"y\" ";
}
if ($access == "LOGGED_IN") {
    $logi = " selected=\"y\" ";
}
if ($access == "PRIVATE") {
    $pri = " selected=\"y\" ";
}
if ($access == "FRIENDS_ONLY") {
    $fo = " selected=\"y\" ";
}
$run_result .= "<h2>{$title}</h2>";
$run_result .= "<p>{$blurb}</p>";
$pubtext = __gettext("Public");
$logitext = __gettext("Logged in users");
$pritext = __gettext("Private");
$fotext = __gettext("Friends only");