当前位置: 首页>>代码示例>>PHP>>正文


PHP profile_manager_get_categorized_fields函数代码示例

本文整理汇总了PHP中profile_manager_get_categorized_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP profile_manager_get_categorized_fields函数的具体用法?PHP profile_manager_get_categorized_fields怎么用?PHP profile_manager_get_categorized_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了profile_manager_get_categorized_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: profile_manager_create_user_event

/**
 * function to add custom profile fields to user on register
 * 
 * @param $event
 * @param $object_type
 * @param $object
 * @return unknown_type
 */
function profile_manager_create_user_event($event, $object_type, $object)
{
    $custom_profile_fields = array();
    // retrieve all field that were on the register page
    foreach ($_POST as $key => $value) {
        if (strpos($key, "custom_profile_fields_") === 0) {
            $key = substr($key, 22);
            $custom_profile_fields[$key] = get_input("custom_profile_fields_" . $key);
        }
    }
    if (count($custom_profile_fields) > 0) {
        $categorized_fields = profile_manager_get_categorized_fields(null, true, true);
        $configured_fields = $categorized_fields['fields'];
        // set ignore access
        $ia = elgg_get_ignore_access();
        elgg_set_ignore_access(true);
        foreach ($custom_profile_fields as $shortname => $value) {
            // determine if $value should be an array
            if (!is_array($value) && !empty($configured_fields)) {
                // only do something if it not is already an array
                foreach ($configured_fields as $configured_field) {
                    if ($configured_field->metadata_name == $shortname) {
                        if ($configured_field->metadata_type == "tags" || $configured_field->output_as_tags == "yes") {
                            $value = string_to_tag_array($value);
                            // no need to continue this foreach
                            break;
                        }
                    }
                }
            }
            // use create_metadata to listen to default access
            if (is_array($value)) {
                $i = 0;
                foreach ($value as $interval) {
                    $i++;
                    if ($i == 1) {
                        $multiple = false;
                    } else {
                        $multiple = true;
                    }
                    create_metadata($object->guid, $shortname, $interval, 'text', $object->guid, get_default_access($object), $multiple);
                }
            } else {
                create_metadata($object->guid, $shortname, $value, 'text', $object->guid, get_default_access($object));
            }
        }
        // restore ignore access
        elgg_set_ignore_access($ia);
    }
    if (isset($_FILES["profile_icon"])) {
        add_profile_icon($object);
    }
}
开发者ID:remy40,项目名称:gvrs,代码行数:61,代码来源:events.php

示例2: elgg_view

<?php

/**
 * Profile Manager
 * 
 * Full Profile view
 * 
 * @package profile_manager
 * @author ColdTrick IT Solutions
 * @copyright Coldtrick IT Solutions 2009
 * @link http://www.coldtrick.com/
 */
$profile_user = $vars['entity'];
$icon = elgg_view("profile/icon", array('entity' => $vars['entity'], 'size' => 'large', 'override' => true));
$categorized_fields = profile_manager_get_categorized_fields($vars['entity']);
$cats = $categorized_fields['categories'];
$fields = $categorized_fields['fields'];
if (count($cats) > 0) {
    $profile_type_guid = $profile_user->custom_profile_type;
    $result .= "<div id='custom_fields_userdetails'>\n";
    // only show category headers if more than 1 category available
    if (count($cats) > 1) {
        $show_header = true;
    } else {
        $show_header = false;
    }
    foreach ($cats as $cat_guid => $cat) {
        if ($show_header) {
            // make nice title
            if ($cat_guid == 0) {
                $title = elgg_echo("profile_manager:categories:list:default");
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:full_profile.php

示例3: elgg_get_plugin_setting

 * @author ColdTrick IT Solutions
 * @copyright Coldtrick IT Solutions 2009
 * @link http://www.coldtrick.com/
 */
$profile_icon = elgg_get_plugin_setting("profile_icon_on_register", "profile_manager");
$profile_type_selection = elgg_get_plugin_setting("profile_type_selection", "profile_manager");
$tabbed = false;
if (elgg_get_plugin_setting("edit_profile_mode", "profile_manager") == "tabbed") {
    $tabbed = true;
}
echo "<fieldset>";
// mandatory profile icon
if ($profile_icon == "yes") {
    echo elgg_view("input/profile_icon");
}
$categorized_fields = profile_manager_get_categorized_fields(null, true, true);
$fields = $categorized_fields['fields'];
$cats = $categorized_fields['categories'];
if (elgg_is_sticky_form('profile_manager_register')) {
    extract(elgg_get_sticky_values('profile_manager_register'));
    elgg_clear_sticky_form('profile_manager_register');
}
if ($profile_type_selection != "admin") {
    $types_options = array("type" => "object", "subtype" => CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_SUBTYPE, "limit" => 0, "owner_guid" => $vars["config"]->site_guid);
    if ($types = elgg_get_entities($types_options)) {
        $types_options_values = array();
        $types_options_values[""] = elgg_echo("profile_manager:profile:edit:custom_profile_type:default");
        foreach ($types as $type) {
            $types_options_values[$type->guid] = $type->getTitle();
            // preparing descriptions of profile types
            $description = $type->getDescription();
开发者ID:socialweb,项目名称:PiGo,代码行数:31,代码来源:fields.php

示例4: elgg_extract

/**
* Profile Manager
*
* Replaces default Elgg profile edit form
*
* @author ColdTrick IT Solutions
* @copyright Coldtrick IT Solutions 2009
* @link http://www.coldtrick.com/
*
* @uses $user The user entity
*/
$user = elgg_extract('entity', $vars);
elgg_require_js('profile_manager/profile_edit');
echo elgg_view('profile/edit/name', $vars);
// Build fields
$categorized_fields = profile_manager_get_categorized_fields($user, true);
$cats = $categorized_fields['categories'];
$fields = $categorized_fields['fields'];
$edit_profile_mode = elgg_get_plugin_setting('edit_profile_mode', 'profile_manager');
$simple_access_control = elgg_get_plugin_setting('simple_access_control', 'profile_manager');
$access_id = get_default_access($user);
if (!empty($cats)) {
    // Profile type selector
    $setting = elgg_get_plugin_setting('profile_type_selection', 'profile_manager', 'user');
    $profile_type = $user->custom_profile_type;
    // can user edit? or just admins
    if ($setting == 'user' || elgg_is_admin_logged_in()) {
        // get profile types
        $types = elgg_get_entities(['type' => 'object', 'subtype' => CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_SUBTYPE, 'limit' => false, 'owner_guid' => elgg_get_site_entity()->getGUID()]);
        if ($types) {
            $types_description = '';
开发者ID:coldtrick,项目名称:profile_manager,代码行数:31,代码来源:edit.php

示例5: profile_manager_profile_completeness

/**
 * returns an array with percentage completeness and required / missing fields 
 * 
 * @param optional ElggUser $user
 */
function profile_manager_profile_completeness($user = null)
{
    $result = false;
    if (empty($user)) {
        $user = elgg_get_logged_in_user_entity();
    }
    if (!empty($user) && $user instanceof ElggUser) {
        $required_fields = array();
        $missing_fields = array();
        $percentage_completeness = 100;
        $fields = profile_manager_get_categorized_fields($user, true, false, true);
        if (!empty($fields["categories"])) {
            foreach ($fields["categories"] as $cat_guid => $cat) {
                $cat_fields = $fields["fields"][$cat_guid];
                foreach ($cat_fields as $field) {
                    if ($field->count_for_completeness == "yes") {
                        $required_fields[] = $field;
                        $metaname = $field->metadata_name;
                        if (empty($user->{$metaname}) && $user->{$metaname} !== 0) {
                            $missing_fields[] = $field;
                        }
                    }
                }
            }
        }
        if (count($required_fields) > 0) {
            $percentage_completeness = 100 - round(count($missing_fields) / count($required_fields) * 100);
        }
        $result = array("required_fields" => $required_fields, "missing_fields" => $missing_fields, "percentage_completeness" => $percentage_completeness);
    }
    return $result;
}
开发者ID:remy40,项目名称:gvrs,代码行数:37,代码来源:functions.php

示例6: subsite_manager_get_missing_subsite_profile_fields

function subsite_manager_get_missing_subsite_profile_fields($user_guid = 0)
{
    global $CONFIG, $SUBSITE_MANAGER_MAIN_PROFILE_FIELDS;
    $result = false;
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (subsite_manager_on_subsite() && !empty($user_guid) && ($user = get_user($user_guid)) && elgg_is_active_plugin("profile_manager")) {
        if ($categorized_fields = profile_manager_get_categorized_fields($user, true, true)) {
            $fields = $categorized_fields["fields"];
            $cats = $categorized_fields["categories"];
            if (!empty($fields)) {
                // filter out main site fields
                foreach ($fields as $cat_guid => $cat_fields) {
                    if (!empty($cat_fields)) {
                        foreach ($cat_fields as $index => $field) {
                            if ($user->get($field->metadata_name)) {
                                // user already filled out this field
                                unset($fields[$cat_guid][$index]);
                            }
                        }
                        if (empty($fields[$cat_guid])) {
                            unset($fields[$cat_guid]);
                        }
                    }
                }
                // filter empty categories
                foreach ($cats as $cat_guid => $cat) {
                    if (!array_key_exists($cat_guid, $fields)) {
                        unset($cats[$cat_guid]);
                    }
                }
                if (!empty($fields) && !empty($cats)) {
                    $categorized_fields = array("categories" => $cats, "fields" => $fields);
                } else {
                    $categorized_fields = false;
                }
            } else {
                $categorized_fields = false;
            }
            if (!empty($categorized_fields)) {
                $result = $categorized_fields;
            }
        }
    }
    // restore global to get correct metadata
    profile_manager_get_categorized_fields($user, true);
    return $result;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:49,代码来源:functions.php

示例7: profile_manager_action_register_hook

/**
 * function to check if custom fields on register have been filled (if required)
 * 
 * @param $hook_name
 * @param $entity_type
 * @param $return_value
 * @param $parameters
 * @return unknown_type
 */
function profile_manager_action_register_hook($hook_name, $entity_type, $return_value, $parameters)
{
    elgg_make_sticky_form('register');
    elgg_make_sticky_form('profile_manager_register');
    // validate mandatory profile fields
    $profile_icon = elgg_get_plugin_setting("profile_icon_on_register", "profile_manager");
    // new
    $profile_type_guid = get_input("custom_profile_fields_custom_profile_type", false);
    $fields = profile_manager_get_categorized_fields($user, true, true, true, $profile_type_guid);
    $required_fields = array();
    if (!empty($fields["categories"])) {
        foreach ($fields["categories"] as $cat_guid => $cat) {
            $cat_fields = $fields["fields"][$cat_guid];
            foreach ($cat_fields as $field) {
                if ($field->show_on_register == "yes" && $field->admin_only != "yes" && $field->mandatory == "yes") {
                    $required_fields[] = $field;
                }
            }
        }
    }
    if ($required_fields || $profile_icon == "yes") {
        $custom_profile_fields = array();
        foreach ($_POST as $key => $value) {
            if (strpos($key, "custom_profile_fields_") == 0) {
                $key = substr($key, 22);
                $custom_profile_fields[$key] = $value;
            }
        }
        foreach ($required_fields as $entity) {
            $passed_value = $custom_profile_fields[$entity->metadata_name];
            if (empty($passed_value)) {
                register_error(sprintf(elgg_echo("profile_manager:register_pre_check:missing"), $entity->getTitle()));
                forward(REFERER);
            }
        }
        if ($profile_icon == "yes") {
            $profile_icon = $_FILES["profile_icon"];
            $error = false;
            if (empty($profile_icon["name"])) {
                register_error(sprintf(elgg_echo("profile_manager:register_pre_check:missing"), "profile_icon"));
                $error = true;
            } elseif ($profile_icon["error"] != 0) {
                register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:error"));
                $error = true;
            } elseif (!in_array(strtolower(substr($profile_icon["name"], -3)), array("jpg", "png", "gif"))) {
                register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:nosupportedimage"));
                $error = true;
            }
            if ($error) {
                forward(REFERER);
            }
        }
    }
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:63,代码来源:hooks.php

示例8: getfields

function getfields($req)
{
    global $CONFIG;
    set_time_limit(0);
    //this avoids timeouts
    include $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php";
    include $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/classes.php";
    if ($req["datasource"] == $data_source) {
        $suggest = 1;
    } else {
        $suggest = 0;
    }
    if ($req["datasource"] == 1) {
        //if we chose RDF as input
        include_once $CONFIG->path . "mod/mmsearch/custom/MeducatorParser.php";
        include_once $CONFIG->path . "mod/mmsearch/custom/MeducatorMetadata.php";
        include_once $CONFIG->path . "engine/lib/mmplus.php";
        //$address = $CONFIG->API_URL . "eidsearch?id=" . "8163";
        //$address =$CONFIG->API_URL . "searchall?properties=mdc:creator";
        $address = $CONFIG->API_URL . "propertysearch?property=mdc:title&value=";
        $rdf_info = connectToSesame($address);
        $medParser = new MeducatorParser($rdf_info, true);
        $elements = $medParser->results;
        $values = array();
        foreach ($elements as $element) {
            $values = array_merge($values, array_keys($element));
        }
        $values = array_unique($values);
        foreach ($values as $value) {
            $fields[] = array("name" => trim($value), "metadata" => 0, "uses" => 0, "tags" => 0);
        }
    } elseif ($req["datasource"] == 2) {
        //if we chose Elgg database as input
        $query = "SELECT distinct e.* from elggentities e join elggusers_entity u on e.guid = u.guid JOIN (SELECT subm1.*, s1.string FROM elggmetadata subm1 JOIN elggmetastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid where ((m1.name_id='440' AND m1.string IN ('356'))) and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes')";
        $entities = get_data($query, "entity_row_to_elggstar");
        $entity = $entities[0];
        $fields = array();
        $categorized_fields = profile_manager_get_categorized_fields($entity, true);
        $cats = $categorized_fields['categories'];
        $db_fields = $categorized_fields['fields'];
        if (!empty($db_fields)) {
            foreach ($cats as $cat_guid => $cat) {
                foreach ($db_fields[$cat_guid] as $db_field) {
                    $metadata_name = $db_field->metadata_name;
                    // get options
                    $options = $db_field->getOptions();
                    // get type of field
                    if ($db_field->user_editable == "no") {
                        $valtype = "non_editable";
                    } else {
                        $valtype = $db_field->metadata_type;
                    }
                    $fields[] = array("name" => trim($db_field->getTitle()), "metadata" => 0, "uses" => 0, "tags" => 0);
                }
            }
        }
    }
    if ($suggest) {
        //if we decided to suggest values, suggest the values of the previous configuration
        include_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php";
        $fields_metadata = explode(";", $metadata_fields);
        $fields_uses = explode(";", $uses_fields);
        $fields_tags = explode(";", $tags_fields);
        $i = 0;
        foreach ($fields as $field) {
            if (in_array($field["name"], $fields_metadata)) {
                $fields[$i]["metadata"] = 1;
            }
            if (in_array($field["name"], $fields_uses)) {
                $fields[$i]["uses"] = 1;
            }
            if (in_array($field["name"], $fields_tags)) {
                $fields[$i]["tags"] = 1;
            }
            $i++;
        }
    }
    return $fields;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:79,代码来源:procedures_retrieve.php

示例9: get_input

    $acl = ACCESS_LOGGED_IN;
}
$username = get_input("username");
$targetUser = get_user_by_username($username);
if (!$targetUser) {
    register_error(elgg_echo("profile:notfound"));
    forward();
}
$editable = $targetUser->canEdit();
if (!$editable) {
    register_error(elgg_echo("profile:noaccess"));
    forward();
}
$name = get_input("name");
$value = get_input("value");
$categories = profile_manager_get_categorized_fields($targetUser, true);
$success = false;
$fieldNames = '';
foreach ($categories['fields'] as $category) {
    foreach ($category as $field) {
        $fieldNames = $fieldNames . ' ' . $field->metadata_name;
        if ($field->metadata_name == $name) {
            create_metadata($targetUser->guid, $name, $value, '', 0, $acl);
            $success = true;
            break;
        }
    }
    if ($success) {
        break;
    }
}
开发者ID:pleio,项目名称:rijkshuisstijl,代码行数:31,代码来源:setprofileparameter.php

示例10: actionRegister

 /**
  * Function to check if custom fields on register have been filled (if required)
  * Also generates a username if needed
  *
  * @param string  $hook_name    name of the hook
  * @param string  $entity_type  type of the hook
  * @param unknown $return_value return value
  * @param unknown $parameters   hook parameters
  *
  * @return void
  */
 public static function actionRegister($hook_name, $entity_type, $return_value, $parameters)
 {
     elgg_make_sticky_form('register');
     elgg_make_sticky_form('profile_manager_register');
     // validate mandatory profile fields
     $profile_icon = elgg_get_plugin_setting('profile_icon_on_register', 'profile_manager');
     // general terms
     $terms = elgg_get_plugin_setting('registration_terms', 'profile_manager');
     // new
     $profile_type_guid = get_input('custom_profile_fields_custom_profile_type', false);
     $fields = profile_manager_get_categorized_fields(null, true, true, true, $profile_type_guid);
     $required_fields = [];
     if (!empty($fields['categories'])) {
         foreach ($fields['categories'] as $cat_guid => $cat) {
             $cat_fields = $fields['fields'][$cat_guid];
             foreach ($cat_fields as $field) {
                 if ($field->show_on_register == 'yes' && $field->mandatory == 'yes') {
                     $required_fields[] = $field;
                 }
             }
         }
     }
     if ($terms || $required_fields || $profile_icon == 'yes') {
         $custom_profile_fields = [];
         foreach ($_POST as $key => $value) {
             if (strpos($key, 'custom_profile_fields_') == 0) {
                 $key = substr($key, 22);
                 $custom_profile_fields[$key] = $value;
             }
         }
         foreach ($required_fields as $entity) {
             $passed_value = $custom_profile_fields[$entity->metadata_name];
             if (is_array($passed_value)) {
                 if (!count($passed_value)) {
                     register_error(elgg_echo('profile_manager:register_pre_check:missing', [$entity->getTitle()]));
                     forward(REFERER);
                 }
             } else {
                 $passed_value = trim($passed_value);
                 if (strlen($passed_value) < 1) {
                     register_error(elgg_echo('profile_manager:register_pre_check:missing', [$entity->getTitle()]));
                     forward(REFERER);
                 }
             }
         }
         if ($profile_icon == 'yes') {
             $profile_icon = $_FILES['profile_icon'];
             $error = false;
             if (empty($profile_icon['name'])) {
                 register_error(elgg_echo('profile_manager:register_pre_check:missing', ['profile_icon']));
                 $error = true;
             } elseif ($profile_icon['error'] != 0) {
                 register_error(elgg_echo('profile_manager:register_pre_check:profile_icon:error'));
                 $error = true;
             } else {
                 // test if we can handle the image
                 $image = get_resized_image_from_uploaded_file('profile_icon', '10', '10', true, false);
                 if (!$image) {
                     register_error(elgg_echo('profile_manager:register_pre_check:profile_icon:nosupportedimage'));
                     $error = true;
                 }
             }
             if ($error) {
                 forward(REFERER);
             }
         }
         if ($terms) {
             $terms_accepted = get_input('accept_terms');
             if ($terms_accepted !== 'yes') {
                 register_error(elgg_echo('profile_manager:register_pre_check:terms'));
                 forward(REFERER);
             }
         }
     }
     // generate username
     $username = get_input('username');
     $email = get_input('email');
     if (empty($username) && elgg_get_plugin_setting('generate_username_from_email', 'profile_manager') == 'yes') {
         set_input('username', self::generateUsernameFromEmail($email));
     }
 }
开发者ID:coldtrick,项目名称:profile_manager,代码行数:92,代码来源:Users.php

示例11: showfields

function showfields($req)
{
    global $CONFIG;
    include $CONFIG->path . "mod/profile_manager/actions/members/config.php";
    include $CONFIG->path . "mod/profile_manager/actions/members/classes.php";
    $query = "SELECT distinct e.* from elggentities e join elggusers_entity u on e.guid = u.guid JOIN (SELECT subm1.*, s1.string FROM elggmetadata subm1 JOIN elggmetastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid where ((m1.name_id='440' AND m1.string IN ('356'))) and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes') order by e.time_created desc";
    $entities = get_data($query, "entity_row_to_elggstar");
    $entity = $entities[0];
    $titles = array();
    $name = $entity->getGUID();
    $lr[$name] = new LearningResource();
    $categorized_fields = profile_manager_get_categorized_fields($entity, true);
    //print_r("<br><br>$categorized_fields");
    $cats = $categorized_fields['categories'];
    $fields = $categorized_fields['fields'];
    //print_r($cats);
    if (!empty($fields)) {
        foreach ($cats as $cat_guid => $cat) {
            foreach ($fields[$cat_guid] as $field) {
                $metadata_name = $field->metadata_name;
                // get options
                $options = $field->getOptions();
                // get type of field
                if ($field->user_editable == "no") {
                    $valtype = "non_editable";
                } else {
                    $valtype = $field->metadata_type;
                }
                // make title
                $titles[]["value"] = trim($field->getTitle());
            }
        }
    }
    $config_values = processFileForOptions($req['file']);
    //it reads an option from the file specified (it creates an array with form array["option"]=value)
    $fields_loms = explode(";", substr($config_values["loms_fields"], 1, -1));
    $fields_uses = explode(";", substr($config_values["uses_fields"], 1, -1));
    $fields_tags = explode(";", substr($config_values["tags_fields"], 1, -1));
    $i = 0;
    //if the field we are analyzing is part of the fields currently selected in 'config.php', we will select its checkbox
    foreach ($titles as $title) {
        if (in_array($title["value"], $fields_loms)) {
            $titles[$i]["loms"] = 1;
        } else {
            $titles[$i]["loms"] = 0;
        }
        if (in_array($title["value"], $fields_uses)) {
            $titles[$i]["uses"] = 1;
        } else {
            $titles[$i]["uses"] = 0;
        }
        if (in_array($title["value"], $fields_tags)) {
            $titles[$i]["tags"] = 1;
        } else {
            $titles[$i]["tags"] = 0;
        }
        $i++;
    }
    return $titles;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:60,代码来源:procedures_retrieve.php

示例12: profile_manager_action_register_hook

/**
 * Function to check if custom fields on register have been filled (if required)
 * Also generates a username if needed
 *
 * @param string  $hook_name    name of the hook
 * @param string  $entity_type  type of the hook
 * @param unknown $return_value return value
 * @param unknown $parameters   hook parameters
 *
 * @return void
 */
function profile_manager_action_register_hook($hook_name, $entity_type, $return_value, $parameters)
{
    elgg_make_sticky_form('register');
    elgg_make_sticky_form('profile_manager_register');
    // validate mandatory profile fields
    $profile_icon = elgg_get_plugin_setting("profile_icon_on_register", "profile_manager");
    // general terms
    $terms = elgg_get_plugin_setting("registration_terms", "profile_manager");
    // new
    $profile_type_guid = get_input("custom_profile_fields_custom_profile_type", false);
    $fields = profile_manager_get_categorized_fields(null, true, true, true, $profile_type_guid);
    $required_fields = array();
    if (!empty($fields["categories"])) {
        foreach ($fields["categories"] as $cat_guid => $cat) {
            $cat_fields = $fields["fields"][$cat_guid];
            foreach ($cat_fields as $field) {
                if ($field->show_on_register == "yes" && $field->mandatory == "yes") {
                    $required_fields[] = $field;
                }
            }
        }
    }
    if ($terms || $required_fields || $profile_icon == "yes") {
        $custom_profile_fields = array();
        foreach ($_POST as $key => $value) {
            if (strpos($key, "custom_profile_fields_") == 0) {
                $key = substr($key, 22);
                $custom_profile_fields[$key] = $value;
            }
        }
        foreach ($required_fields as $entity) {
            $passed_value = trim($custom_profile_fields[$entity->metadata_name]);
            if (strlen($passed_value) < 1) {
                register_error(elgg_echo("profile_manager:register_pre_check:missing", array($entity->getTitle())));
                forward(REFERER);
            }
        }
        if ($profile_icon == "yes") {
            $profile_icon = $_FILES["profile_icon"];
            $error = false;
            if (empty($profile_icon["name"])) {
                register_error(elgg_echo("profile_manager:register_pre_check:missing", array("profile_icon")));
                $error = true;
            } elseif ($profile_icon["error"] != 0) {
                register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:error"));
                $error = true;
            } else {
                // test if we can handle the image
                $image = get_resized_image_from_uploaded_file('profile_icon', '10', '10', true, false);
                if (!$image) {
                    register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:nosupportedimage"));
                    $error = true;
                }
            }
            if ($error) {
                forward(REFERER);
            }
        }
        if ($terms) {
            $terms_accepted = get_input("accept_terms");
            if ($terms_accepted !== "yes") {
                register_error(elgg_echo("profile_manager:register_pre_check:terms"));
                forward(REFERER);
            }
        }
    }
    // generate username
    $username = get_input('username');
    $email = get_input('email');
    if (empty($username) && !empty($email) && elgg_get_plugin_setting("generate_username_from_email", "profile_manager") == "yes") {
        $email_parts = explode('@', $email);
        $base_username = $email_parts[0];
        $tmp_username = $base_username;
        $i = 1;
        while (get_user_by_username($tmp_username)) {
            $tmp_username = $base_username . $i;
            $i++;
        }
        set_input('username', $tmp_username);
    }
}
开发者ID:pleio,项目名称:profile_manager,代码行数:92,代码来源:hooks.php

示例13: subsite_manager_profile_manager_profile_hook

/**
 * Make sure we get the profile manager user categories correctly
 * Merge the site configuration with main site configuration
 *
 * @param string $hook
 * @param string $type
 * @param mixed $returnvalue
 * @param mixed $params
 * @return mixed
 */
function subsite_manager_profile_manager_profile_hook($hook, $type, $returnvalue, $params)
{
    static $running;
    $result = $returnvalue;
    if (subsite_manager_on_subsite() && empty($running)) {
        $running = true;
        $site = elgg_get_site_entity();
        elgg_set_config("site_guid", $site->getOwnerGUID());
        $user = elgg_extract("user", $params);
        $edit = elgg_extract("edit", $params);
        $register = elgg_extract("register", $params);
        $profile_type_limit = elgg_extract("profile_type_limit", $params);
        $profile_type_guid = elgg_extract("profile_type_guid", $params);
        // get main fields
        $main_cat_fields = profile_manager_get_categorized_fields($user, $edit, false, $profile_type_limit, $profile_type_guid);
        if ($register) {
            $main_register_fields = subsite_manager_get_main_profile_fields_configuration(true);
            foreach ($main_cat_fields["fields"] as $cat_key => $category) {
                foreach ($category as $key => $field) {
                    if ($main_register_fields && array_key_exists($field->metadata_name, $main_register_fields)) {
                        $field->setVolatileData("mandatory", $main_register_fields[$field->metadata_name]['mandatory']);
                        $field->setVolatileData("show_on_register", $main_register_fields[$field->metadata_name]['show_on_register']);
                    } else {
                        if ($field->show_on_register !== "yes") {
                            unset($main_cat_fields["fields"][$cat_key][$key]);
                        }
                    }
                }
            }
            // cleanup categories
            foreach ($main_cat_fields["fields"] as $cat_key => $category) {
                if (empty($category)) {
                    unset($main_cat_fields["fields"][$cat_key]);
                    unset($main_cat_fields["categories"][$cat_key]);
                }
            }
        }
        // merge categories
        $site_cats = elgg_extract("categories", $result, array());
        $main_cats = elgg_extract("categories", $main_cat_fields);
        if (isset($main_cats[0])) {
            unset($site_cats[0]);
        }
        $merged_cats = $site_cats + $main_cats;
        ksort($merged_cats);
        if (array_key_exists(-1, $merged_cats)) {
            $admin = $merged_cats[-1];
            unset($merged_cats[-1]);
            $merged_cats[-1] = $admin;
        }
        // merge fields
        $site_fields = elgg_extract("fields", $result, array());
        $main_fields = elgg_extract("fields", $main_cat_fields);
        $merged_fields = $main_fields + $site_fields;
        if (is_array($main_fields[0]) && is_array($site_fields[0])) {
            $merged_fields[0] = array_merge($main_fields[0], $site_fields[0]);
        }
        ksort($merged_fields);
        $result = array("categories" => $merged_cats, "fields" => $merged_fields);
        $running = false;
        elgg_set_config("site_guid", $site->getGUID());
    }
    return $result;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:74,代码来源:hooks.php

示例14: get_snapshot


//.........这里部分代码省略.........
                    foreach ($values as $value) {
                        $guid_from = substr(strrchr($value, "#"), 1);
                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        $entity = get_entity($guid_from);
                        if (empty($entity)) {
                            continue;
                        }
                        //this is a temporary check from the database since we still need it in order not to have problem with the normal search that still takes info from it
                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        $lr[$guid]->replinks["from"][] = $guid_from;
                    }
                }
            }
            //insert replinks["to"]
            foreach ($lr as $guid => $resource) {
                foreach ($resource->replinks["from"] as $guid_from) {
                    $lr[$guid_from]->replinks["to"][] = $guid;
                }
            }
        } else {
            echo "\n\nNo resources returned. There must be an error somewhere...";
            exit;
        }
    } elseif ($data_source == 2) {
        $fields = array_unique(array_merge($metadatas_fields, $usess_fields, $tagss_fields));
        $query = "SELECT distinct e.* from elggentities e join elggusers_entity u on e.guid = u.guid JOIN (SELECT subm1.*, s1.string FROM elggmetadata subm1 JOIN elggmetastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid where ((m1.name_id='440' AND m1.string IN ('356'))) and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes') order by e.time_created desc";
        $entities = get_data($query, "entity_row_to_elggstar");
        foreach ($entities as $entity) {
            $guid = $entity->getGUID();
            $lr[$guid] = new LearningResource();
            $lr[$guid]->setName($entity->get('name'));
            $lr[$guid]->setUsername($entity->get('username'));
            $lr[$guid]->setGUID($guid);
            $categorized_fields = profile_manager_get_categorized_fields($entity, true);
            $cats = $categorized_fields['categories'];
            $db_fields = $categorized_fields['fields'];
            if (!empty($db_fields)) {
                foreach ($cats as $cat_guid => $cat) {
                    foreach ($db_fields[$cat_guid] as $db_field) {
                        $metadata_name = $db_field->metadata_name;
                        // get options
                        $options = $db_field->getOptions();
                        // get type of db_field
                        if ($db_field->user_editable == "no") {
                            $valtype = "non_editable";
                        } else {
                            $valtype = $db_field->metadata_type;
                        }
                        $field = $db_field->getTitle();
                        if (in_array($field, $fields)) {
                            // get value
                            if ($metadata = get_metadata_byname($entity->guid, $metadata_name)) {
                                //print_r($metadata);
                                if (is_array($metadata)) {
                                    $value = '';
                                    foreach ($metadata as $md) {
                                        if (!empty($value)) {
                                            $value .= ', ';
                                        }
                                        $value .= $md->value;
                                        $access_id = $md->access_id;
                                    }
                                } else {
                                    $value = $metadata->value;
                                    $access_id = $metadata->access_id;
                                }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:67,代码来源:functions.php

示例15: profile_manager_profile_completeness

/**
 * Returns an array with percentage completeness and required / missing fields
 *
 * @param ElggUser $user User to count completeness for
 *
 * @return boolean|array
 */
function profile_manager_profile_completeness($user = null)
{
    if (empty($user)) {
        $user = elgg_get_logged_in_user_entity();
    }
    if (!elgg_instanceof($user, 'user')) {
        return false;
    }
    $required_fields = [];
    $missing_fields = [];
    $percentage_completeness = 100;
    $fields = profile_manager_get_categorized_fields($user, true, false, true);
    if (!empty($fields['categories'])) {
        foreach ($fields['categories'] as $cat_guid => $cat) {
            $cat_fields = $fields['fields'][$cat_guid];
            foreach ($cat_fields as $field) {
                if ($field->count_for_completeness == 'yes') {
                    $required_fields[] = $field;
                    $metaname = $field->metadata_name;
                    if (empty($user->{$metaname}) && $user->{$metaname} !== 0) {
                        $missing_fields[] = $field;
                    }
                }
            }
        }
    }
    if (count($required_fields) > 0) {
        $percentage_completeness = 100 - round(count($missing_fields) / count($required_fields) * 100);
    }
    return ['required_fields' => $required_fields, 'missing_fields' => $missing_fields, 'percentage_completeness' => $percentage_completeness];
}
开发者ID:coldtrick,项目名称:profile_manager,代码行数:38,代码来源:functions.php


注:本文中的profile_manager_get_categorized_fields函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。