Esempio n. 1
0
require_once PATH_CORE . '/components/com_members/models/incremental/groups.php';
require_once PATH_CORE . '/components/com_members/models/incremental/options.php';

$uid = (int)$this->profile->get('id');
$incrOpts = new ModIncrementalRegistrationOptions;

$isIncrementalEnabled = $incrOpts->isEnabled($uid);
*/
//$profiles = $this->profile->profiles()->ordered()->rows();
$entries = $this->profile->profiles();
$p = $entries->getTableName();
$f = Components\Members\Models\Profile\Field::blank()->getTableName();
$o = Components\Members\Models\Profile\Option::blank()->getTableName();
$profiles = $entries->select($p . '.*,' . $o . '.label')->join($f, $f . '.name', $p . '.profile_key', 'inner')->joinRaw($o, $o . '.field_id=' . $f . '.id AND ' . $o . '.value=' . $p . '.profile_value', 'left')->ordered()->rows();
// Convert to XML so we can use the Form processor
$xml = Components\Members\Models\Profile\Field::toXml($this->fields, 'edit');
// Gather data to pass to the form processor
$data = new Hubzero\Config\Registry(Components\Members\Models\Profile::collect($profiles));
// Create a new form
Hubzero\Form\Form::addFieldPath(Component::path('com_members') . DS . 'models' . DS . 'fields');
$form = new Hubzero\Form\Form('profile', array('control' => 'profile'));
$form->load($xml);
$form->bind($data);
$fields = array();
foreach ($profiles as $profile) {
    if (isset($fields[$profile->get('profile_key')])) {
        $values = $fields[$profile->get('profile_key')]->get('profile_value');
        if (!is_array($values)) {
            $values = array($fields[$profile->get('profile_key')]->get('label', $values));
        }
        $values[] = $profile->get('label', $profile->get('profile_value'));
Esempio n. 2
0
        ?>
>middleName</option>
								<option value="surname" <?php 
        if ($mapping['field'] == 'surname') {
            echo 'selected="selected"';
        }
        ?>
>surname</option>
							</optgroup>
							<optgroup label="<?php 
        echo Lang::txt('COM_MEMBERS_IMPORT_FIELDS_PROFILE');
        ?>
">
								<?php 
        include_once Component::path('com_members') . DS . 'models' . DS . 'profile' . DS . 'field.php';
        $fields = Components\Members\Models\Profile\Field::all()->ordered()->rows();
        foreach ($fields as $field) {
            ?>
									<option value="<?php 
            echo $field->get('name');
            ?>
" <?php 
            if ($mapping['field'] == $field->get('name')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $field->get('name');
            ?>
</option>
									<?php 
Esempio n. 3
0
 /**
  * Display a member's profile
  *
  * @return  void
  */
 private function profile()
 {
     if (!$this->group->isSuperGroup()) {
         return;
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'member.php';
     $id = Request::getInt('member', 0);
     $profile = Components\Members\Models\Member::oneOrFail($id);
     if (!$profile->get('id')) {
         App::abort(404, Lang::txt('PLG_GROUPS_MEMBERS_PROFILE_NOT_FOUND'));
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'profile' . DS . 'field.php';
     $fields = Components\Members\Models\Profile\Field::all()->including(['options', function ($option) {
         $option->select('*')->ordered();
     }])->where('action_edit', '!=', Components\Members\Models\Profile\Field::STATE_HIDDEN)->ordered()->rows();
     // Set the page title
     Document::setTitle(Lang::txt(strtoupper($this->name)) . ': ' . $this->group->get('description') . ': ' . Lang::txt(strtoupper($profile->get('name'))));
     $params = Plugin::params('members', 'profile');
     $params->merge(new \Hubzero\Config\Registry($profile->get('params')));
     // Display form asking for a reason to deny membership
     $view = $this->view('default', 'profile')->set('params', $params)->set('option', $this->_option)->set('profile', $profile)->set('fields', $fields)->set('group', $this->group)->set('authorized', $this->authorized)->set('membership_control', $this->membership_control);
     $this->_output = $view->loadTemplate();
 }
Esempio n. 4
0
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access
defined('_HZEXEC_') or die;
include_once Component::path('com_members') . DS . 'models' . DS . 'profile' . DS . 'field.php';
$fields = Components\Members\Models\Profile\Field::all()->including(['options', function ($option) {
    $option->select('*');
}])->ordered()->rows();
$access = array();
foreach ($fields as $field) {
    $access[$field->get('name')] = $field->get('access');
}
// Convert to XML so we can use the Form processor
$xml = Components\Members\Models\Profile\Field::toXml($fields);
$profiles = $this->profile->profiles()->ordered()->rows();
// Gather data to pass to the form processor
$data = new Hubzero\Config\Registry(Components\Members\Models\Profile::collect($profiles));
$data->set('tags', $this->profile->tags('string'));
foreach ($profiles as $profile) {
    $d = isset($access[$profile->get('profile_key')]) ? $access[$profile->get('profile_key')] : 1;
    $access[$profile->get('profile_key')] = $profile->get('access', $d);
}
// Create a new form
Hubzero\Form\Form::addFieldPath(Component::path('com_members') . DS . 'models' . DS . 'fields');
$form = new Hubzero\Form\Form('profile', array('control' => 'profile'));
$form->load($xml);
$form->bind($data);
$fields = $form->getFieldset('basic');
?>
Esempio n. 5
0
 /**
  * View the profile page
  *
  * @return  string
  */
 private function display()
 {
     //get member params
     $rparams = new \Hubzero\Config\Registry($this->member->get('params'));
     //get profile plugin's params
     $params = $this->params;
     $params->merge($rparams);
     $xreg = null;
     $fields = Components\Members\Models\Profile\Field::all()->including(['options', function ($option) {
         $option->select('*')->ordered();
     }])->where('action_edit', '!=', Components\Members\Models\Profile\Field::STATE_HIDDEN)->ordered()->rows();
     if (App::get('session')->get('registration.incomplete')) {
         $xreg = new \Components\Members\Models\Registration();
         $xreg->loadProfile($this->member);
         $check = $xreg->check('update');
         // Validate profile data
         // @TODO  Move this to central validation model (e.g., registraiton)?
         // Compile profile data
         $profile = array();
         foreach ($fields as $field) {
             $profile[$field->get('name')] = $this->member->get($field->get('name'));
         }
         // Validate profile fields
         $form = new Hubzero\Form\Form('profile', array('control' => 'profile'));
         $form->load(Components\Members\Models\Profile\Field::toXml($fields, 'edit', $profile));
         $form->bind(new Hubzero\Config\Registry($profile));
         if (!$form->validate($profile)) {
             $check = false;
             foreach ($form->getErrors() as $key => $error) {
                 if ($error instanceof Hubzero\Form\Exception\MissingData) {
                     $xreg->_missing[$key] = (string) $error;
                 }
                 $xreg->_invalid[$key] = (string) $error;
             }
         }
         // If no errors, redirect to where they were going
         if ($check) {
             App::get('session')->set('registration.incomplete', 0);
             App::redirect($_SERVER['REQUEST_URI']);
         }
     }
     $view = $this->view('default', 'index')->set('params', $params)->set('option', 'com_members')->set('profile', $this->member)->set('fields', $fields)->set('completeness', $this->getProfileCompleteness($fields, $this->member))->set('registration_update', $xreg);
     return $view->setErrors($this->getErrors())->loadTemplate();
 }