/**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $plugins = elgg_get_plugins('inactive');
     if (empty($plugins)) {
         system_message('All plugins are active');
         return;
     }
     $ids = array_map(function (ElggPlugin $plugin) {
         return $plugin->getID();
     }, $plugins);
     $ids = array_values($ids);
     if ($this->option('all')) {
         $activate_ids = $ids;
     } else {
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion('Please select plugins you would like to activate (comma-separated list of indexes)', $ids);
         $question->setMultiselect(true);
         $activate_ids = $helper->ask($this->input, $this->output, $question);
     }
     if (empty($activate_ids)) {
         throw new \RuntimeException('You must select at least one plugin');
     }
     $plugins = [];
     foreach ($activate_ids as $plugin_id) {
         $plugins[] = elgg_get_plugin_from_id($plugin_id);
     }
     do {
         $additional_plugins_activated = false;
         foreach ($plugins as $key => $plugin) {
             if ($plugin->isActive()) {
                 unset($plugins[$key]);
                 continue;
             }
             if (!$plugin->activate()) {
                 // plugin could not be activated in this loop, maybe in the next loop
                 continue;
             }
             $ids = array('cannot_start' . $plugin->getID(), 'invalid_and_deactivated_' . $plugin->getID());
             foreach ($ids as $id) {
                 elgg_delete_admin_notice($id);
             }
             // mark that something has changed in this loop
             $additional_plugins_activated = true;
             unset($plugins[$key]);
             system_message("Plugin {$plugin->getFriendlyName()} has been activated");
         }
         if (!$additional_plugins_activated) {
             // no updates in this pass, break the loop
             break;
         }
     } while (count($plugins) > 0);
     if (count($plugins) > 0) {
         foreach ($plugins as $plugin) {
             $msg = $plugin->getError();
             $string = $msg ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
             register_error(elgg_echo($string, array($plugin->getFriendlyName())));
         }
     }
     elgg_flush_caches();
 }
Example #2
0
function pla_rdelete($server, $dn)
{
    # We delete all children, not only the visible children in the tree
    $children = $server->getContainerContents($dn, null, 0, '(objectClass=*)', LDAP_DEREF_NEVER);
    if (!is_array($children) || count($children) == 0) {
        printf('<span style="white-space: nowrap;">%s %s...', _('Deleting'), $dn);
        if ($server->delete($dn)) {
            printf(' <span style="color:green">%s</span></span><br />', _('Success'));
            return true;
        } else {
            system_message(array('title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($dn)), 'body' => ldap_error_msg($server->getErrorMessage(null), $server->getErrorNum(null)), 'type' => 'error'));
        }
    } else {
        foreach ($children as $child_dn) {
            pla_rdelete($server, $child_dn);
        }
        printf('<span style="white-space: nowrap;">%s %s...', _('Deleting'), $dn);
        if ($server->delete($dn)) {
            printf(' <span style="color:green">%s</span></span><br />', _('Success'));
            return true;
        } else {
            system_message(array('title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($dn)), 'body' => ldap_error_msg($server->getErrorMessage(null), $server->getErrorNum(null)), 'type' => 'error'));
        }
    }
}
Example #3
0
/**
 * insert user into elgg user table
 *
 * Get user info from db
 * Tries to insert, otherwise return error
 *
 * @return user
 */
function cas_insertUser($username, $casUser, $config)
{
    //     $name = $attr['cn'];
    //     $uname = !empty($attr['textuid']) ? $attr['textuid'] : str_replace(".", "",$username);
    //     $email = $attr['mail'];
    $name = $casUser->name;
    $uname = !empty($casUser->username) ? $casUser->username : $username;
    $email = $casUser->email;
    $password = md5($uname . $email);
    $user = new ElggUser();
    $user->username = $uname;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = 2;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->save();
    $guid = $user->guid;
    $obj = get_entity($guid);
    if (isset($config->casadminuser) && $config->casadminuser == $username) {
        if ($obj instanceof ElggUser && $obj->canEdit()) {
            $obj->admin = 'yes';
            if ($obj->admin) {
                system_message(elgg_echo('admin:user:makeadmin:yes'));
            } else {
                register_error(elgg_echo('admin:user:makeadmin:no'));
            }
        } else {
            register_error(elgg_echo('admin:user:makeadmin:no'));
        }
    }
    return $user;
}
Example #4
0
function LoginUser($tool_provider)
{
    // Clear any existing sessions
    if (elgg_is_logged_in()) {
        logout();
    }
    $values = GetPluginSettings();
    $userprovision = $values['userprovision'];
    $user_id = $tool_provider->user->getID(BasicLTI_Tool_Provider::ID_SCOPE_GLOBAL);
    $consumer_key = $tool_provider->consumer->guid;
    $context_id = $tool_provider->user->context->id;
    // Does user exist
    $user = CheckLTIUser($user_id);
    // Provision user, if on and needed
    if (empty($user)) {
        if ($userprovision) {
            $user = CreateLTIUser($consumer_key, $context_id, $tool_provider->user);
            if (empty($user)) {
                forward();
            }
        } else {
            system_message(elgg_echo('LTI:info:noprovision'));
            forward();
            exit;
        }
    }
    // Set up current context id
    $user->context_id = $context_id;
    $user->email = $tool_provider->user->email;
    $user->name = $tool_provider->user->fullname;
    $user->save();
    // Login
    $result = login($user, false);
    return $result;
}
Example #5
0
function show_next_celebrations()
{
    $ViewReminder = elgg_get_plugin_setting("ViewReminder", "celebrations");
    if (!$ViewReminder) {
        $ViewReminder = "no";
    }
    if ($ViewReminder = "yes") {
        $nextdaysCelebrations = elgg_get_plugin_setting("nextdaysCelebrations", "celebrations");
        if (!$nextdaysCelebrations) {
            $nextdaysCelebrations = 7;
        }
        $celebrations = user_celebrations($nextdaysCelebrations, 'next', 0);
        //draw celebrations
        if (!empty($celebrations)) {
            foreach ($celebrations as $key => $val) {
                if ($val['rest'] == 0) {
                    $days = elgg_echo('next_celebrations:today');
                } elseif ($val['rest'] == 1) {
                    $days = elgg_echo('next_celebrations:dayleft');
                } else {
                    $days = elgg_echo('next_celebrations:in') . ' ' . $val['rest'] . ' ' . elgg_echo('next_celebrations:daysleft');
                }
                system_message($days . elgg_echo('next_celebrations:celebrate') . $val['fullname'] . elgg_echo('next_celebrations:genitive') . elgg_echo('today_celebrations:' . $val['type']) . '.');
            }
        }
    }
    return true;
}
Example #6
0
function au_landing_user_login($event, $type, $object)
{
    if (elgg_instanceof($object, 'user')) {
        if (!is_email_address($object->email)) {
            system_message(elgg_echo('au_landing:invalidemail'));
        }
    }
}
Example #7
0
function cclite_revoke()
{
    // unregister user's access tokens
    set_plugin_usersetting('access_key', NULL);
    set_plugin_usersetting('access_secret', NULL);
    system_message(elgg_echo('cclite:revoke:success'));
    forward('pg/settings/plugins');
}
/**
 * Used at the top of a page to mark it as logged in users only.
 *
 * @return void
 * @since 1.9.0
 */
function elgg_gatekeeper()
{
    if (!elgg_is_logged_in()) {
        _elgg_services()->session->set('last_forward_from', current_page_url());
        system_message(elgg_echo('loggedinrequired'));
        forward('/login', 'login');
    }
}
Example #9
0
function gvgroups_leave_group($group, $user)
{
    if ($group->leave($user)) {
        system_message(elgg_echo("gvgroups:localgroups:unsubscribe", array($group->name)));
    } else {
        register_error(elgg_echo("gvgroups:localgroups:error_unsubscribe", array($group->name)));
    }
}
Example #10
0
function log_event(&$sql, $date, $user_id, $user_name, $action, $comment)
{
    $query = "insert into syslog (date, user_id, user_name, action, comment) values ('{$date}', '{$user_id}', '{$user_name}', '{$action}', '{$comment}')";
    $rs = $sql->Execute($query);
    if (!$rs) {
        system_message($sql->ErrorMsg());
    }
}
Example #11
0
function doConnect($tool_provider)
{
    $result = LoginUser($tool_provider);
    if (!$result && !empty($tool_provider->return_url)) {
        $urlencode = urlencode(sprintf(elgg_echo('LTI:error:login'), elgg_get_config('sitename')));
        forward($tool_provider->return_url . '&lti_msg=' . $urlencode);
        return false;
    }
    if (!$result && empty($tool_provider->return_url)) {
        system_message(sprintf(elgg_echo('LTI:error:login'), elgg_get_config('sitename')));
        forward();
        return false;
    }
    // Send login time to consumer if has setting service and can handle freetext
    $freetext = strpos(strtolower($tool_provider->context->getSetting('ext_ims_lis_resultvalue_sourcedids')), 'freetext');
    if ($tool_provider->context->hasSettingService() && $freetext) {
        $consumer_name_array = explode("-", $tool_provider->consumer->consumer_name, 2);
        $consumer_name = $consumer_name_array[0];
        $version = strtolower($consumer_name_array[1]);
        $outcome = new LTI_Outcome($tool_provider->context->getSetting('lis_result_sourcedid'), '');
        $outcome->type = 'freetext';
        $result = $tool_provider->context->doOutcomesService(LTI_Context::EXT_READ, $outcome);
        $count = 1;
        switch ($consumer_name) {
            case 'moodle':
                if (!empty($result)) {
                    system_message(sprintf('LTI:last:login'), $result);
                }
                $outcome = new LTI_Outcome($tool_provider->context->getSetting("lis_result_sourcedid"), date('d-M-Y'));
                $outcome->type = 'freetext';
                $outcome->status = 'final';
                break;
            default:
                if (!empty($result)) {
                    $pieces = explode(' ', $result);
                    $count = intval($pieces[0]);
                    $count++;
                    $last_login = $pieces[1] . ' ' . $pieces[2] . ' - Logins: ' . $count;
                    system_message(sprintf('LTI:last:login'), $last_login);
                }
                // Assume freetext available and send back date/count
                $outcome = new LTI_Outcome($tool_provider->context->getSetting('lis_result_sourcedid'), $count . ' ' . date('d-M-Y H:i'));
                $outcome->type = 'freetext';
                $outcome->status = 'interim';
                break;
        }
        $result = $tool_provider->context->doOutcomesService(LTI_Context::EXT_WRITE, $outcome);
    }
    // Store return URL for later use, if present
    if (!empty($tool_provider->return_url)) {
        $_SESSION['return_url'] = $tool_provider->return_url;
        $_SESSION['return_name'] = 'Return to ' . $tool_provider->consumer->name;
    }
    ProvisionLTIGroup($tool_provider);
    system_messages('Forwarded to Profile');
    forward();
    return false;
}
Example #12
0
function register_user($uname, $upass)
{
    global $sql;
    global $cfg;
    $timestamp = time();
    if ($cfg['DB_TYPE'] === 'mysql') {
        $query = "select admin_id, admin_pass, admin_type, created_by from admin where binary admin_name = ?";
    }
    $rs = exec_query($sql, $query, array($uname));
    if ($rs->RecordCount() != 1) {
        write_log("Login error, <b><i>" . htmlspecialchars($uname, ENT_QUOTES, "UTF-8") . "</i></b> unknown username");
        return false;
    }
    $udata = $rs->FetchRow();
    if (crypt($_POST['upass'], $udata[1]) === $udata[1] || md5($_POST['upass']) === $udata[1]) {
        if (isset($_SESSION['user_logged'])) {
            write_log($_SESSION['user_logged'] . " user already logged or session sharing problem! Aborting...");
            system_message(tr('User already logged or session sharing problem! Aborting...'));
        } else {
            if ($udata['admin_type'] == "user") {
                $domain_admin_id = $udata['admin_id'];
                $query = <<<SQL_QUERY
                          select
                                domain_status
                          from
                                domain
                          where
                                domain_admin_id = ?;
SQL_QUERY;
                $rs = exec_query($sql, $query, array($domain_admin_id));
                $user_dom_data = $rs->FetchRow();
                if ($user_dom_data['domain_status'] != $cfg['ITEM_OK_STATUS']) {
                    write_log(htmlspecialchars($uname, ENT_QUOTES, "UTF-8") . " Domain status is not OK - user can not login");
                    return false;
                }
            }
            // all is OK let's login the user
            $user_login_time = time();
            $query = <<<SQL_QUERY
        insert into login
            (session_id, lastaccess)
        values
            (?, ?)
SQL_QUERY;
            $rs = exec_query($sql, $query, array($uname, $user_login_time));
            $_SESSION['user_logged'] = $uname;
            $_SESSION['user_type'] = $udata['admin_type'];
            $_SESSION['user_id'] = $udata['admin_id'];
            $_SESSION['user_created_by'] = $udata['created_by'];
            $_SESSION['user_login_time'] = $user_login_time;
            write_log(htmlspecialchars($uname, ENT_QUOTES, "UTF-8") . " user logged in.");
            return true;
        }
    } else {
        write_log(htmlspecialchars($uname, ENT_QUOTES, "UTF-8") . " bad password login data.");
        return false;
    }
}
Example #13
0
function exec_query(&$sql, $query, $data)
{
    $stmt = $sql->Prepare($query);
    $rs = $sql->Execute($query, $data);
    if (!$rs) {
        system_message($sql->ErrorMsg());
    }
    return $rs;
}
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $upgrader = _elgg_services()->upgrades;
     $result = $upgrader->run();
     if ($result['failure'] == true) {
         register_error($result['reason']);
     } else {
         system_message('Upgrade script ran without failures');
     }
 }
Example #15
0
function gen_packages_list(&$tpl, &$sql, $user_id)
{
    global $cfg;
    if (isset($cfg['HOSTING_PLANS_LEVEL']) && $cfg['HOSTING_PLANS_LEVEL'] === 'admin') {
        $query = <<<SQL_QUERY
\t\t\tselect
\t\t\t\tt1.*,
\t\t\t\tt2.admin_id, t2.admin_type
\t\t\tfrom
\t\t\t\thosting_plans as t1,
\t\t\t\tadmin as t2
\t\t\twhere
\t\t\t\tt2.admin_type=?
\t\t\tand
\t\t\t\tt1.reseller_id = t2.admin_id
\t\t\tand
\t\t\t\tt1.status=1
\t\t\torder by
\t\t\t\tt1.id
SQL_QUERY;
        $rs = exec_query($sql, $query, array('admin'));
    } else {
        $query = <<<SQL_QUERY
\t\t\t\tselect
\t\t\t\t\t*
\t\t\t\tfrom
\t\t\t\t\thosting_plans
\t\t\t\twhere
\t\t\t\t\treseller_id = ?
\t\t\t\t  and
\t\t\t\t\tstatus = '1'
SQL_QUERY;
        $rs = exec_query($sql, $query, array($user_id));
    }
    if ($rs->RecordCount() == 0) {
        system_message(tr('No available hosting packages'));
    } else {
        while (!$rs->EOF) {
            $description = $rs->fields['description'];
            if ($description == '') {
                $description = '';
            }
            $price = $rs->fields['price'];
            if ($price == 0 || $price == '') {
                $price = "/ " . tr('free of charge');
            } else {
                $price = "/ " . $price . " " . $rs->fields['value'] . " " . $rs->fields['payment'];
            }
            $tpl->assign(array('PACK_NAME' => $rs->fields['name'], 'PACK_ID' => $rs->fields['id'], 'USER_ID' => $user_id, 'PURCHASE' => tr('Purchase'), 'PACK_INFO' => $description, 'PRICE' => $price));
            $tpl->parse('PURCHASE_LIST', '.purchase_list');
            $rs->MoveNext();
        }
    }
}
function elgg_modifications_generate_digischool_menu_page_handler($page)
{
    admin_gatekeeper();
    if (elgg_is_active_plugin("menu_builder")) {
        // remove current menu items
        $current_options = array("type" => "object", "subtype" => "menu_builder_menu_item", "limit" => false);
        if ($current_items = elgg_get_entities($current_options)) {
            foreach ($current_items as $current_item) {
                $current_item->delete();
            }
        }
        // 			var_dump($current_items);
        // 			exit();
        // add the new ones
        $site = elgg_get_site_entity();
        $site_acl = $site->getACL();
        $menu_items = array(array("title" => "Voorpagina", "url" => "[wwwroot]", "access_id" => ACCESS_PUBLIC, "children" => array(array("title" => "Alle blogs", "url" => "[wwwroot]blog/all", "access_id" => ACCESS_PUBLIC), array("title" => "Alle activiteiten", "url" => "[wwwroot]activity", "access_id" => ACCESS_LOGGED_IN))), array("title" => "Statische pagina's", "url" => "[wwwroot]lidworden", "access_id" => ACCESS_LOGGED_IN), array("title" => "Archief", "url" => "Zelf in te vullen", "access_id" => ACCESS_PUBLIC), array("title" => "Leermiddelen", "url" => "#", "access_id" => ACCESS_PUBLIC, "children" => array(array("title" => "Vakpagina", "url" => "hier de link naar uw vakp", "access_id" => ACCESS_PUBLIC), array("title" => "Leermiddelenbank Digischool", "url" => "[wwwroot]", "access_id" => ACCESS_PUBLIC), array("title" => "Leden keurmerkgroepen", "url" => "zelf te vullen", "access_id" => ACCESS_PUBLIC))), array("title" => "Leden", "url" => "#", "access_id" => ACCESS_LOGGED_IN, "children" => array(array("title" => "Mijn groepen", "url" => "[wwwroot]groups/member/[username]", "access_id" => $site_acl), array("title" => "Mijn profielpagina", "url" => "[wwwroot]profile/[username]", "access_id" => $site_acl), array("title" => "Alle groepen", "url" => "[wwwroot]groups/all/?filter=pop", "access_id" => $site_acl), array("title" => "Lid worden", "url" => "[wwwroot]lidworden", "access_id" => ACCESS_PUBLIC), array("title" => "Content toevoegen", "url" => "[wwwroot]add", "access_id" => $site_acl), array("title" => "Mijn dashboard", "url" => "[wwwroot]dashboard", "access_id" => $site_acl), array("title" => "Zoeken leden", "url" => "[wwwroot]members", "access_id" => $site_acl), array("title" => "Mijn contacten", "url" => "[wwwroot]friends/[username]", "access_id" => $site_acl), array("title" => "Contactverzoeken", "url" => "[wwwroot]friend_request/", "access_id" => $site_acl), array("title" => "Mijn instellingen", "url" => "[wwwroot]settings", "access_id" => $site_acl), array("title" => "Nieuwe groep maken", "url" => "[wwwroot]groups/add", "access_id" => $site_acl))), array("title" => "Beheer", "url" => "[wwwroot]admin", "access_id" => ACCESS_PRIVATE, "children" => array(array("title" => "Gebruikersbeheer", "url" => "[wwwroot]admin/users/newest", "access_id" => ACCESS_PRIVATE), array("title" => "Nodig leden uit", "url" => "[wwwroot]admin/users/invite", "access_id" => ACCESS_PRIVATE), array("title" => "Pluginbeheer", "url" => "[wwwroot]admin/plugins", "access_id" => ACCESS_PRIVATE), array("title" => "Beheer template", "url" => "[wwwroot]admin/appearance/template", "access_id" => ACCESS_PRIVATE))));
        $i = 0;
        foreach ($menu_items as $main_item) {
            $item = new ElggObject();
            $item->subtype = "menu_builder_menu_item";
            $item->owner_guid = $site->getGUID();
            $item->container_guid = $site->getGUID();
            $item->site_guid = $site->getGUID();
            $item->access_id = $main_item["access_id"];
            $item->parent_guid = 0;
            $item->title = $main_item["title"];
            $item->url = $main_item["url"];
            $item->order = $i;
            $i++;
            $item->save();
            if (array_key_exists("children", $main_item)) {
                foreach ($main_item["children"] as $sub_item) {
                    $submenu_item = new ElggObject();
                    $submenu_item->subtype = "menu_builder_menu_item";
                    $submenu_item->owner_guid = $site->getGUID();
                    $submenu_item->container_guid = $site->getGUID();
                    $submenu_item->site_guid = $site->getGUID();
                    $submenu_item->access_id = $sub_item["access_id"];
                    $submenu_item->parent_guid = $item->getGUID();
                    $submenu_item->title = $sub_item["title"];
                    $submenu_item->url = $sub_item["url"];
                    $submenu_item->order = $i;
                    $i++;
                    $submenu_item->save();
                }
            }
        }
        system_message("menu created");
    } else {
        register_error("plugin menu_builder not activated");
    }
    forward();
}
Example #17
0
/**
 * Check if the event qualifies for points and award them to the user
 *
 * @param string $event
 * @param string $type
 * @param mixed $object
 * @return boolean
 */
function apply_event_rules($event, $type, $object)
{
    // Subject
    $user = elgg_get_logged_in_user_entity();
    if (!$user) {
        return true;
    }
    if ($user->isAdmin()) {
        return true;
    }
    // Object
    if (is_object($object)) {
        $entity = $object;
    } else {
        if (is_array($object)) {
            $entity = elgg_extract('entity', $object, null);
            if (!$entity) {
                $entity = elgg_extract('user', $object, null);
            }
            if (!$entity) {
                $entity = elgg_extract('group', $object, null);
            }
        }
    }
    if (!is_object($entity)) {
        // Terminate early, nothing to act upon
        return true;
    }
    // Get rules associated with events
    $rules = get_scoring_rules('events');
    // Apply rules
    foreach ($rules as $rule_name => $rule_options) {
        $rule_options['name'] = $rule_name;
        $gmRule = gmRule::applyRule($entity, $rule_options, "{$event}::{$type}");
        $errors = $gmRule->getErrors();
        if ($errors) {
            foreach ($errors as $error) {
                register_error($error);
            }
        }
        $messages = $gmRule->getMessages();
        if ($messages) {
            foreach ($messages as $message) {
                system_message($message);
            }
        }
        //error_log(print_r($gmRule->getLog(), true));
        if ($gmRule->terminateEvent()) {
            return false;
        }
    }
    return true;
}
Example #18
0
function uncaptcha_register_user($hook, $entity_type, $returnvalue, $params)
{
    if (get_plugin_setting('instant_enable', 'uncaptcha')) {
        $params->enable();
    }
    if (get_plugin_setting('login_after', 'uncaptcha')) {
        if (login($params)) {
            system_message(elgg_echo('uncaptcha:register:auto_login'));
        }
    }
    return true;
}
Example #19
0
function event_create_object($event, $type, \ElggObject $object)
{
    if (!is_on_probation($object->getOwnerEntity())) {
        return true;
    }
    $object->{QUARANTINED} = '1';
    if (elgg_get_plugin_setting(QUARANTINE_PRIVATE, PLUGIN_ID)) {
        system_message(elgg_echo('probation:moderated:private'));
    } else {
        system_message(elgg_echo('probation:moderated'));
    }
    State::$entities_quarantined[$object->guid] = $object;
}
Example #20
0
function white_list_admin($hook, $type, $value, $params)
{
    $pluginId = get_input('plugin_id');
    if ($pluginId != 'white_list') {
        return $value;
    }
    $company_emails = get_input('company_email');
    $company_emails = string_to_tag_array($company_emails);
    $site = elgg_get_site_entity();
    $site->company_emails = $company_emails;
    system_message(elgg_echo("filters:save:success"));
    forward(REFERER);
}
Example #21
0
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $params = array('displayname' => 'Administrator', 'username' => $this->ask('Enter admin username: '******'admin'), 'password' => $this->ask('Enter admin password: '******'email' => $email = $this->ask('Enter admin email: '), 'dbuser' => $this->ask('Enter database username: '******'dbpassword' => $this->ask('Enter database password: '******'dbname' => $this->ask('Enter database name: '), 'dbprefix' => $this->ask('Enter database prefix [elgg_]: ', 'elgg_'), 'sitename' => $this->ask('Enter site name: '), 'siteemail' => $this->ask("Enter site email [{$email}]: ", $email), 'wwwroot' => $this->ask('Enter site URL [http://localhost/]: ', 'http://localhost/'), 'dataroot' => $this->ask('Enter data directory path: '), 'timezone' => 'UTC');
     global $CONFIG;
     $CONFIG = new \stdClass();
     $CONFIG->system_cache_enabled = false;
     foreach ($params as $key => $value) {
         $CONFIG->{$key} = $value;
     }
     $installer = new ElggInstaller();
     $htaccess = !is_file(\Elgg\Filesystem\Directory\Local::root()->getPath('.htaccess'));
     $installer->batchInstall($params, $htaccess);
     system_message('Installation is successful');
 }
Example #22
0
/**
 * Saves the site categories.
 *
 * @param type $hook
 * @param type $type
 * @param type $value
 * @param type $params
 */
function categories_save_site_categories($hook, $type, $value, $params)
{
    $plugin_id = get_input('plugin_id');
    if ($plugin_id != 'categories') {
        return $value;
    }
    $categories = get_input('categories');
    $categories = string_to_tag_array($categories);
    $site = elgg_get_site_entity();
    $site->categories = $categories;
    system_message(elgg_echo("categories:save:success"));
    elgg_delete_admin_notice('categories_admin_notice_no_categories');
    forward(REFERER);
}
Example #23
0
/**
 * Handle a standard OpenID server request
 */
function action_default()
{
    global $store;
    $server =& getServer();
    $method = $_SERVER['REQUEST_METHOD'];
    /*$request = null;
      if ($method == 'GET') {
          $request = $_GET;
      } else {
          $request = $_POST;
      } */
    $request = $server->decodeRequest();
    if (!$request) {
        return "";
        //about_render();
    }
    setRequestInfo($request);
    if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) {
        $identity = getLoggedInUser();
        if (isTrusted($identity, $request->trust_root, $request->return_to)) {
            if ($request->message->isOpenID1()) {
                $response =& $request->answer(true);
            } else {
                $response =& $request->answer(true, false, getServerURL(), $identity);
            }
        } else {
            if ($request->immediate) {
                $response =& $request->answer(false, getServerURL());
            } else {
                if (!getLoggedInUser()) {
                    $_SESSION['last_forward_from'] = current_page_url() . '?' . http_build_query(Auth_OpenID::getQuery());
                    system_message(elgg_echo('openid_server:not_logged_in'));
                    forward('login');
                }
                return trust_render($request);
            }
        }
        addSregFields(&$response);
    } else {
        $response =& $server->handleRequest($request);
    }
    $webresponse =& $server->encodeResponse($response);
    foreach ($webresponse->headers as $k => $v) {
        header("{$k}: {$v}");
    }
    header(header_connection_close);
    print $webresponse->body;
    exit(0);
}
/**
 * Request user validation email.
 * Send email out to the address and request a confirmation.
 *
 * @param int $user_guid The user
 * @return mixed
 */
function uservalidationbyemail_request_validation($user_guid)
{
    global $CONFIG;
    $user_guid = (int) $user_guid;
    $user = get_entity($user_guid);
    if ($user && $user instanceof ElggUser) {
        // Work out validate link
        $link = $CONFIG->site->url . "action/email/confirm?u={$user_guid}&c=" . uservalidationbyemail_generate_code($user_guid, $user->email);
        // Send validation email
        $result = notify_user($user->guid, $CONFIG->site->guid, sprintf(elgg_echo('email:validate:subject'), $user->username), sprintf(elgg_echo('email:validate:body'), $user->name, $link), NULL, 'email');
        if ($result) {
            system_message(elgg_echo('uservalidationbyemail:registerok'));
        }
        return $result;
    }
    return false;
}
/**
 * Request user validation email.
 * Send email out to the address and request a confirmation.
 *
 * @param int  $user_guid       The user's GUID
 * @param bool $admin_requested Was it requested by admin
 * @return mixed
 */
function uservalidationbyadmin_request_validation($user_guid, $admin_requested = FALSE)
{
    $site = elgg_get_site_entity();
    $user_guid = (int) $user_guid;
    $user = get_entity($user_guid);
    /*	
    	if (($user) && ($user instanceof ElggUser)) {
    		// Work out validate link
    		$code = uservalidationbyadmin_generate_code($user_guid, $user->email);
    		$link = "{$site->url}uservalidationbyadmin/confirm?u=$user_guid&c=$code";
    		// Send validation email
    		$subject = elgg_echo('email:validate:subject', array($user->name, $site->name));
    		$body = elgg_echo('email:validate:body', array($user->name, $site->name, $link, $site->name, $site->url));
    		$result = notify_user($user->guid, $site->guid, $subject, $body, NULL, 'email');
    		if ($result && !$admin_requested) {
    			system_message(elgg_echo('uservalidationbyadmin:registerok'));
    		}
    		return $result;
    	}
    */
    //notify admin
    if ($user && $user instanceof ElggUser) {
        $admin = get_admin_user_details();
        // Work out validate link
        $code = uservalidationbyadmin_generate_code($user_guid, $user->email);
        $link = "{$site->url}uservalidationbyadmin/confirm?u={$user_guid}&c={$code}";
        // IP detection
        $ip_address = $_SERVER['REMOTE_ADDR'];
        $geoloc = "https://secure.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=" . $ip_address;
        $geotags = get_meta_tags($geoloc);
        $geocountry = $geotags['country'];
        $georegion = $geotags['region'];
        $geocity = $geotags['city'];
        $geocertainty = $geotags['certainty'];
        $geostring = $ip_address . " ; " . $geocountry . " ; " . $georegion . " ; " . $geocity . " ; " . $geocertainty;
        // Send validation email
        $subject = elgg_echo('email:validate:subject', array($user->name, $site->name));
        $body = elgg_echo('email:validate:body', array($admin->name, $user->name, $ip_address, $geostring, $link, $site->name, $site->url));
        $result = notify_user($admin->guid, $site->guid, $subject, $body, NULL, 'email');
        if ($result && !$admin_requested) {
            system_message(elgg_echo('uservalidationbyadmin:registerok'));
        }
        return $result;
    }
    return FALSE;
}
Example #26
0
 public function run()
 {
     //Step 1: define the semantics
     //$this->debug = true;
     //Step 2: transform assessments into the HFLTS
     parent::run();
     if ($this->debug) {
         system_message($this->N . " x " . $this->M . " x " . $this->P);
     }
     //Step 3: establish the alternatives, criteria and the weights of the criteria
     self::crossAlternativesWithCriteria();
     //Step 4: find out the positive ideal and the negative ideal solution
     self::idealSolution();
     //Step 5: derive the compromise solutions
     self::linguisticCompromise();
     $this->ranking();
     return $this->ranking[0]['vikor']['label'];
 }
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $path = $this->argument('path');
     if ($path) {
         // make sure the path ends with a slash
         $path = rtrim($path, DIRECTORY_SEPARATOR);
         $path .= DIRECTORY_SEPARATOR;
         if (!is_dir($path)) {
             throw new RuntimeException("{$path} is not a valid directory");
         }
         if (datalist_set('path', $path)) {
             system_message("Root path has been changed");
         } else {
             system_message("Root path could not be changed");
         }
     }
     system_message("Current root path: " . datalist_get('path'));
 }
Example #28
0
/**
 * Request user validation email.
 * Send email out to the address and request a confirmation.
 *
 * @param int  $user_guid       The user's GUID
 * @param bool $admin_requested Was it requested by admin
 * @return mixed
 */
function uservalidationbyadmin_request_validation($user_guid, $admin_requested = FALSE)
{
    $site = elgg_get_site_entity();
    if ($site && $site->email) {
        $from = $site->email;
    } else {
        $from = 'noreply@' . get_site_domain($site->guid);
    }
    $user_guid = (int) $user_guid;
    $user = get_entity($user_guid);
    //notify admins
    if ($user && $user instanceof ElggUser) {
        // Work out validate link
        $code = uservalidationbyadmin_generate_code($user_guid, $user->email);
        $link = "{$site->url}uservalidationbyadmin/confirm?u={$user_guid}&c={$code}";
        // IP detection
        $ip_address = $_SERVER['REMOTE_ADDR'];
        /*$geoloc = "https://secure.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=".$ip_address;
        		$geotags = get_meta_tags($geoloc);
        		$geocountry = $geotags['country'];
        		$georegion = $geotags['region'];
        		$geocity = $geotags['city'];
        		$geocertainty = $geotags['certainty'];*/
        $geostring = $ip_address;
        //." ; ".$geocountry." ; ".$georegion." ; ".$geocity." ; ".$geocertainty;
        // Send validation email
        $subject = elgg_echo('email:validate:subject', array($user->name, $site->name));
        $body = elgg_echo('email:validate:body', array($user->name, $user->email, $ip_address, $geostring, $link, $site->name, $site->url));
        $emails = elgg_get_plugin_setting('emails', 'uservalidationbyadmin');
        $admin_mails = explode(",", $emails);
        $sent_total = 0;
        foreach ($admin_mails as $mail) {
            if (elgg_send_email($from, $mail, $subject, $body)) {
                $sent_total++;
            }
        }
        // Atleast 1 mail sent
        if ($sent_total > 0 && !$admin_requested) {
            system_message(elgg_echo('uservalidationbyadmin:registerok'));
        }
        return $result;
    }
    return FALSE;
}
Example #29
0
 public function run()
 {
     //step 1: transform the linguistic expressions into HFLTS.
     //Since all criteria are of the maximizing type no normalization is needed
     parent::run();
     //$this->debug = true;
     if ($this->debug) {
         system_message($this->N . " x " . $this->M . " x " . $this->P);
     }
     //step 2: identify the concordance an discordance indices
     $this->crossAlternativesWithCriteria();
     //step 3: construct the concordance and discordance matrices
     $this->concordanceBalance();
     //step 4: get the net dominance and disadvantage indices (c_i and d_i)
     $this->dominanceBalance();
     //step 5: rank the alternatives in acoordance with c_i and d_i
     $this->ranking();
     return $this->ranking[0]['electre']['label'];
 }
Example #30
0
/**
 * Request user validation email.
 * Send email out to the address and request a confirmation.
 *
 * @param int  $user_guid       The user's GUID
 * @param bool $admin_requested Was it requested by admin
 * @return mixed
 */
function uservalidationbyemail_request_validation($user_guid, $admin_requested = FALSE)
{
    $site = elgg_get_site_entity();
    $user_guid = (int) $user_guid;
    $user = get_entity($user_guid);
    if ($user && $user instanceof ElggUser) {
        // Work out validate link
        $code = uservalidationbyemail_generate_code($user_guid, $user->email);
        $link = "{$site->url}uservalidationbyemail/confirm?u={$user_guid}&c={$code}";
        // Send validation email
        $subject = elgg_echo('email:validate:subject', array($user->name, $site->name));
        $body = elgg_echo('email:validate:body', array($user->name, $site->name, $link, $site->name, $site->url));
        $result = notify_user($user->guid, $site->guid, $subject, $body, array(), 'email');
        if ($result && !$admin_requested) {
            system_message(elgg_echo('uservalidationbyemail:registerok'));
        }
        return $result;
    }
    return FALSE;
}