コード例 #1
0
ファイル: Username.php プロジェクト: kevinwojo/framework
 /**
  * Method to test for a valid color in hexadecimal.
  *
  * @param   object   &$element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed    $value     The form field value to validate.
  * @param   string   $group     The field name group control value. This acts as as an array container for the field.
  *                              For example if the field has name="foo" and the group value is set to "bar" then the
  *                              full field name would end up being "bar[foo]".
  * @param   object   &$input    An optional Registry object with the entire data set to validate against the entire form.
  * @param   object   &$form     The form object for which the field is being tested.
  * @return  boolean  True if the value is valid, false otherwise.
  */
 public function test(&$element, $value, $group = null, &$input = null, &$form = null)
 {
     $duplicate = User::all()->whereEquals('username', $value)->where('id', '<>', (int) $userId)->total();
     if ($duplicate) {
         return false;
     }
     return true;
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: kevinwojo/hubzero-cms
 function display($tpl = null)
 {
     $user = User::getInstance();
     // If this is an auth_link account update, carry on, otherwise raise an error
     if ($user->isGuest() || !$user->hasAttribute('auth_link_id') || !is_numeric($user->username) || !$user->username < 0) {
         App::abort('405', 'Method not allowed');
         return;
     }
     // Get and add the js and extra css to the page
     \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'link.css');
     \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'providers.css');
     \Hubzero\Document\Assets::addComponentScript('com_users', 'link');
     // Import a few things
     jimport('joomla.user.helper');
     // Look up a few things
     $hzal = \Hubzero\Auth\Link::find_by_id($user->get("auth_link_id"));
     $hzad = \Hubzero\Auth\Domain::find_by_id($hzal->auth_domain_id);
     $plugins = Plugin::byType('authentication');
     // Get the display name for the current plugin being used
     Plugin::import('authentication', $hzad->authenticator);
     $plugin = Plugin::byType('authentication', $hzad->authenticator);
     $pparams = new \Hubzero\Config\Registry($plugin->params);
     $refl = new ReflectionClass("plgAuthentication{$plugin->name}");
     $display_name = $pparams->get('display_name', $refl->hasMethod('onGetLinkDescription') ? $refl->getMethod('onGetLinkDescription')->invoke(NULL) : ucfirst($plugin->name));
     // Look for conflicts - first check in the hub accounts
     $profile_conflicts = \Hubzero\User\User::all()->whereEquals('email', $hzal->email)->rows();
     // Now check the auth_link table
     $link_conflicts = \Hubzero\Auth\Link::find_by_email($hzal->email, array($hzad->id));
     $conflict = array();
     if ($profile_conflicts) {
         foreach ($profile_conflicts as $juser) {
             $auth_link = \Hubzero\Auth\Link::find_by_user_id($juser->id);
             $dname = is_object($auth_link) && $auth_link->auth_domain_name ? $auth_link->auth_domain_name : 'hubzero';
             $conflict[] = array("auth_domain_name" => $dname, "name" => $juser->name, "email" => $juser->email);
         }
     }
     if ($link_conflicts) {
         foreach ($link_conflicts as $l) {
             $juser = User::getInstance($l['user_id']);
             $conflict[] = array("auth_domain_name" => $l['auth_domain_name'], "name" => $juser->name, "email" => $l['email']);
         }
     }
     // Make sure we don't somehow have any duplicate conflicts
     $conflict = array_map("unserialize", array_unique(array_map("serialize", $conflict)));
     // @TODO: Could also check for high probability of name matches???
     // Get the site name
     $sitename = Config::get('sitename');
     // Assign variables to the view
     $this->assign('hzal', $hzal);
     $this->assign('hzad', $hzad);
     $this->assign('plugins', $plugins);
     $this->assign('display_name', $display_name);
     $this->assign('conflict', $conflict);
     $this->assign('sitename', $sitename);
     $this->assignref('juser', $user);
     parent::display($tpl);
 }
コード例 #3
0
ファイル: Email.php プロジェクト: kevinwojo/framework
 /**
  * Method to test for a valid color in hexadecimal.
  *
  * @param   object   &$element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed    $value     The form field value to validate.
  * @param   string   $group     The field name group control value. This acts as as an array container for the field.
  *                              For example if the field has name="foo" and the group value is set to "bar" then the
  *                              full field name would end up being "bar[foo]".
  * @param   object   &$input    An optional Registry object with the entire data set to validate against the entire form.
  * @param   object   &$form     The form object for which the field is being tested.
  * @return  boolean  True if the value is valid, false otherwise.
  */
 public function test(&$element, $value, $group = null, &$input = null, &$form = null)
 {
     // If the field is empty and not required, the field is valid.
     $required = (string) $element['required'] == 'true' || (string) $element['required'] == 'required';
     if (!$required && empty($value)) {
         return true;
     }
     // Test the value against the regular expression.
     if (!parent::test($element, $value, $group, $input, $form)) {
         return false;
     }
     // Check if we should test for uniqueness.
     $unique = (string) $element['unique'] == 'true' || (string) $element['unique'] == 'unique';
     if ($unique) {
         // Get the extra field check attribute.
         $userId = $form instanceof Form ? $form->getValue('id') : '';
         $duplicate = User::all()->whereEquals('email', $value)->where('id', '<>', (int) $userId)->total();
         if ($duplicate) {
             return false;
         }
     }
     return true;
 }
コード例 #4
0
 /**
  * Checks if username already exists
  *
  * @param   string  $username  Username to check
  * @return  array   Status & message
  */
 public function checkusername($username)
 {
     $ret['status'] = 'error';
     if (empty($username)) {
         $ret['message'] = 'Please enter a username.';
         return $ret;
     }
     // check the general validity
     if (!Helpers\Utility::validlogin($username)) {
         $ret['message'] = 'Invalid login name. Please type between 2 and 32 characters and use only lowercase alphanumeric characters.';
         return $ret;
     }
     // Count records with the given username
     $total = \Hubzero\User\User::all()->whereEquals('username', $username)->total();
     if ($total > 0) {
         $ret['message'] = 'User login name is not available. Please select another one.';
         return $ret;
     }
     $ret['status'] = 'ok';
     $ret['message'] = 'User login name is available';
     return $ret;
 }
コード例 #5
0
ファイル: members.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Render the events
  *
  * @param      array     Array of group events
  * @return     string
  */
 private function renderMembers($group, $members)
 {
     $content = '<div class="member_browser">';
     if (count($members) > 0) {
         $profiles = \Hubzero\User\User::all()->whereIn('id', $members)->rows();
         foreach ($profiles as $profile) {
             $content .= '<a href="' . Route::url($profile->link()) . '" class="member" title="Go to ' . stripslashes($profile->get('name')) . '\'s Profile.">';
             $content .= '<img src="' . $profile->picture() . '" alt="' . stripslashes($profile->get('name')) . '" class="member-border" width="50px" height="50px" />';
             $content .= '<span class="name">' . stripslashes($profile->get('name')) . '</span>';
             $content .= '<span class="org">' . stripslashes($profile->get('organization')) . '</span>';
             $content .= '</a>';
         }
     }
     $content .= '</div><!-- /.member_browser -->';
     return $content;
 }