public function run() { Cache::disableCache(); Loader::library('database_indexed_search'); $is = new IndexedSearch(); if ($_GET['force'] == 1) { Loader::model('attribute/categories/collection'); Loader::model('attribute/categories/file'); Loader::model('attribute/categories/user'); $attributes = CollectionAttributeKey::getList(); $attributes = array_merge($attributes, FileAttributeKey::getList()); $attributes = array_merge($attributes, UserAttributeKey::getList()); foreach($attributes as $ak) { $ak->updateSearchIndex(); } $result = $is->reindexAll(true); } else { $result = $is->reindexAll(); } if ($result->count == 0) { return t('Indexing complete. Index is up to date'); } else { if ($result->count == $is->searchBatchSize) { return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count); } else { return t('Index updated. %s %s required reindexing.', $result->count, $result->count == 1 ? t('page') : t('pages')); } } }
public function run() { Cache::disableAll(); $is = new IndexedSearch(); if ($_GET['force'] == 1) { $attributes = \CollectionAttributeKey::getList(); $attributes = array_merge($attributes, \FileAttributeKey::getList()); $attributes = array_merge($attributes, \UserAttributeKey::getList()); foreach ($attributes as $ak) { $ak->updateSearchIndex(); } $result = $is->reindexAll(true); } else { $result = $is->reindexAll(); } if ($result->count == 0) { return t('Indexing complete. Index is up to date'); } else { if ($result->count == $is->searchBatchSize) { return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count); } else { return t('Index updated.') . ' ' . t2('%d page required reindexing.', '%d pages required reindexing.', $result->count, $result->count); } } }
public function add_user_attribute_key($handle, $name, $type = 'text') { $ak = UserAttributeKey::getByHandle($handle); if (!is_object($ak)) { UserAttributeKey::add($type, array('akHandle' => $handle, 'akName' => t($name)), $pkg); } }
public function filterByKeywords($keywords) { $db = Loader::db(); $qkeywords = $db->quote('%' . $keywords . '%'); $keys = UserAttributeKey::getSearchableIndexedList(); $emailSearchStr=' OR u.uEmail like '.$qkeywords.' '; $attribsStr = ''; foreach ($keys as $ak) { $cnt = $ak->getController(); $attribsStr.=' OR ' . $cnt->searchKeywords($keywords); } $this->filter(false, '( u.uName like ' . $qkeywords . $emailSearchStr . $attribsStr . ')'); }
public function view() { $userList = new UserList(); $userList->sortBy('uName', 'asc'); $keywords = $this->get('keywords'); if ($keywords != '') { $userList->filterByKeywords($keywords); } $users = $userList->getPage(); $this->set('userList', $userList); $this->set('users', $users); $this->set('attribs', UserAttributeKey::getMemberListList()); $this->set('keywords', htmlentities($keywords, ENT_COMPAT, APP_CHARSET)); $this->addHeaderItem(Loader::helper('html')->css('ccm.profile.css')); }
public function start(Zend_Queue $q) { Loader::library('database_indexed_search'); $this->is = new IndexedSearch(); Loader::model('attribute/categories/collection'); Loader::model('attribute/categories/file'); Loader::model('attribute/categories/user'); $attributes = CollectionAttributeKey::getList(); $attributes = array_merge($attributes, FileAttributeKey::getList()); $attributes = array_merge($attributes, UserAttributeKey::getList()); foreach ($attributes as $ak) { $ak->updateSearchIndex(); } $db = Loader::db(); $db->Execute('truncate table PageSearchIndex'); $r = $db->Execute('select Pages.cID from Pages left join CollectionSearchIndexAttributes csia on Pages.cID = csia.cID where (ak_exclude_search_index is null or ak_exclude_search_index = 0) and cIsActive = 1'); while ($row = $r->FetchRow()) { $q->send($row['cID']); } }
public function install() { Loader::library('mootools/attribute', FRONTEND_DEVELOPER_PACKAGE_HANDLE); $pkg = parent::install(); Loader::model('single_page'); Loader::model('attribute/categories/user'); Loader::model('attribute/categories/file'); $singlePages = array("/dashboard/mootools" => array('cName' => t('Mootools Plugin Developer'), 'cDescription' => t('Management of mootools plugin')), "/dashboard/mootools/plugin" => array('cName' => t('plugin'), 'cDescription' => t('Management of Mootools Plugin that does import')), "/dashboard/mootools/importer" => array('cName' => t('import'), 'cDescription' => t('Import from repository'))); foreach ($singlePages as $key => $page) { $collection = SinglePage::add($key, $pkg); if (!empty($collection)) { $collection->update($page); } } //The name of the user of github is added to the attribute. $values = array("akHandle" => MOOTOOLS_GITHUB_USER, "akName" => t("Name of user of github"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true); $key = UserAttributeKey::add("text", $values, $pkg); $fileAttributes = array(array("type" => "boolean", "values" => array("akHandle" => MOOTOOLS_PLUGIN, "akName" => t("This file is a plugin of Mootools"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_COMPONENT_NAME, "akName" => t("Component name of Mootools"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_PLUGIN_LICENSE, "akName" => t("License of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_PLUGIN_AUTHORS, "akName" => t("Authors of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "select", "values" => array("akHandle" => MOOTOOLS_PLUGIN_DEPENDENCES, "akName" => t("Dependence of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "number", "values" => array("akHandle" => MOOTOOLS_PLUGIN_DISPLAY_ORDER, "akName" => t("The order of display of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true))); $attributesKeys = array(); foreach ($fileAttributes as $key => $attr) { $type = $attr["type"]; $values = $attr["values"]; $handle = $values["akHandle"]; $attributesKeys[$handle] = FileAttributeKey::add($type, $values, $pkg); } if (!empty($attributesKeys[MOOTOOLS_PLUGIN_DEPENDENCES])) { $key = $attributesKeys[MOOTOOLS_PLUGIN_DEPENDENCES]; $db = Loader::db(); $db->Replace('atSelectSettings', array('akID' => $key->getAttributeKeyID(), 'akSelectAllowMultipleValues' => true), array('akID'), true); } BlockType::installBlockTypeFromPackage("mootools_plugin_build_form", $pkg); BlockType::installBlockTypeFromPackage("github_tags", $pkg); BlockType::installBlockTypeFromPackage("github_issues", $pkg); BlockType::installBlockTypeFromPackage("github_repository", $pkg); PageTheme::add('small_project', $pkg); }
foreach ($slist as $sk) { $selectedAKIDs[] = $sk->getAttributeKeyID(); } if ($_POST['task'] == 'update_columns') { Loader::model('attribute/category'); $sc = AttributeKeyCategory::getByHandle('user'); $sc->clearAttributeKeyCategoryColumnHeaders(); if (is_array($_POST['akID'])) { foreach ($_POST['akID'] as $akID) { $ak = UserAttributeKey::getByID($akID); $ak->setAttributeKeyColumnHeader(1); } } exit; } $list = UserAttributeKey::getList(); ?> <form method="post" id="ccm-user-customize-search-columns-form" action="<?php echo REL_DIR_FILES_TOOLS_REQUIRED; ?> /users/customize_search_columns/"> <?php echo $form->hidden('task', 'update_columns'); ?> <h1><?php echo t('Additional Searchable Attributes'); ?> </h1>
public function do_register() { $registerData['success']=0; $userHelper = Loader::helper('concrete/user'); $e = Loader::helper('validation/error'); $ip = Loader::helper('validation/ip'); $txt = Loader::helper('text'); $vals = Loader::helper('validation/strings'); $valc = Loader::helper('concrete/validation'); $username = $_POST['uName']; $password = $_POST['uPassword']; $passwordConfirm = $_POST['uPasswordConfirm']; // clean the username $username = trim($username); $username = preg_replace("/ +/", " ", $username); if (!$ip->check()) { $e->add($ip->getErrorMessage()); } if (ENABLE_REGISTRATION_CAPTCHA) { $captcha = Loader::helper('validation/captcha'); if (!$captcha->check()) { $e->add(t("Incorrect image validation code. Please check the image and re-enter the letters or numbers as necessary.")); } } if (!$vals->email($_POST['uEmail'])) { $e->add(t('Invalid email address provided.')); } else if (!$valc->isUniqueEmail($_POST['uEmail'])) { $e->add(t("The email address %s is already in use. Please choose another.", $_POST['uEmail'])); } //if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == false) { if (strlen($username) < USER_USERNAME_MINIMUM) { $e->add(t('A username must be between at least %s characters long.', USER_USERNAME_MINIMUM)); } if (strlen($username) > USER_USERNAME_MAXIMUM) { $e->add(t('A username cannot be more than %s characters long.', USER_USERNAME_MAXIMUM)); } if (strlen($username) >= USER_USERNAME_MINIMUM && !$valc->username($username)) { if(USER_USERNAME_ALLOW_SPACES) { $e->add(t('A username may only contain letters, numbers and spaces.')); } else { $e->add(t('A username may only contain letters or numbers.')); } } if (!$valc->isUniqueUsername($username)) { $e->add(t("The username %s already exists. Please choose another", $username)); } //} if ($username == USER_SUPER) { $e->add(t('Invalid Username')); } /* if ((strlen($password) < USER_PASSWORD_MINIMUM) || (strlen($password) > USER_PASSWORD_MAXIMUM)) { $e->add(t('A password must be between %s and %s characters', USER_PASSWORD_MINIMUM, USER_PASSWORD_MAXIMUM)); } if (strlen($password) >= USER_PASSWORD_MINIMUM && !$valc->password($password)) { $e->add(t('A password may not contain ", \', >, <, or any spaces.')); } */ $userHelper->validNewPassword($password,$e); if ($password) { if ($password != $passwordConfirm) { $e->add(t('The two passwords provided do not match.')); } } $aks = UserAttributeKey::getRegistrationList(); foreach($aks as $uak) { if ($uak->isAttributeKeyRequiredOnRegister()) { $e1 = $uak->validateAttributeForm(); if ($e1 == false) { $e->add(t('The field "%s" is required', $uak->getAttributeKeyName())); } else if ($e1 instanceof ValidationErrorHelper) { $e->add($e1); } } } if (!$e->has()) { // do the registration $data = $_POST; $data['uName'] = $username; $data['uPassword'] = $password; $data['uPasswordConfirm'] = $passwordConfirm; $process = UserInfo::register($data); if (is_object($process)) { foreach($aks as $uak) { $uak->saveAttributeForm($process); } if (REGISTER_NOTIFICATION) { //do we notify someone if a new user is added? $mh = Loader::helper('mail'); if(EMAIL_ADDRESS_REGISTER_NOTIFICATION) { $mh->to(EMAIL_ADDRESS_REGISTER_NOTIFICATION); } else { $adminUser = UserInfo::getByID(USER_SUPER_ID); if (is_object($adminUser)) { $mh->to($adminUser->getUserEmail()); } } $mh->addParameter('uName', $process->getUserName()); $mh->addParameter('uID', $process->getUserID()); $mh->addParameter('uEmail', $process->getUserEmail()); $attribs = UserAttributeKey::getRegistrationList(); foreach($attribs as $ak) { $attribValues[] = $ak->getAttributeKeyDisplayHandle() . ': ' . $process->getAttribute($ak->getAttributeKeyHandle(), 'display'); } $mh->addParameter('attribs', $attribValues); if (defined('EMAIL_ADDRESS_REGISTER_NOTIFICATION_FROM')) { $mh->from(EMAIL_ADDRESS_REGISTER_NOTIFICATION_FROM, t('Website Registration Notification')); } else { $adminUser = UserInfo::getByID(USER_SUPER_ID); if (is_object($adminUser)) { $mh->from($adminUser->getUserEmail(), t('Website Registration Notification')); } } if(REGISTRATION_TYPE == 'manual_approve') { $mh->load('user_register_approval_required'); } else { $mh->load('user_register'); } $mh->sendMail(); } // now we log the user in if (USER_REGISTRATION_WITH_EMAIL_ADDRESS) { $u = new User($_POST['uEmail'], $_POST['uPassword']); } else { $u = new User($_POST['uName'], $_POST['uPassword']); } // if this is successful, uID is loaded into session for this user $rcID = $this->post('rcID'); $nh = Loader::helper('validation/numbers'); if (!$nh->integer($rcID)) { $rcID = 0; } // now we check whether we need to validate this user's email address if (defined("USER_VALIDATE_EMAIL") && USER_VALIDATE_EMAIL) { if (USER_VALIDATE_EMAIL > 0) { $uHash = $process->setupValidation(); $mh = Loader::helper('mail'); if (defined('EMAIL_ADDRESS_VALIDATE')) { $mh->from(EMAIL_ADDRESS_VALIDATE, t('Validate Email Address')); } $mh->addParameter('uEmail', $_POST['uEmail']); $mh->addParameter('uHash', $uHash); $mh->to($_POST['uEmail']); $mh->load('validate_user_email'); $mh->sendMail(); //$this->redirect('/register', 'register_success_validate', $rcID); $redirectMethod='register_success_validate'; $registerData['msg']= join('<br><br>',$this->getRegisterSuccessValidateMsgs()); $u->logout(); } } else if(defined('USER_REGISTRATION_APPROVAL_REQUIRED') && USER_REGISTRATION_APPROVAL_REQUIRED) { $ui = UserInfo::getByID($u->getUserID()); $ui->deactivate(); //$this->redirect('/register', 'register_pending', $rcID); $redirectMethod='register_pending'; $registerData['msg']=$this->getRegisterPendingMsg(); $u->logout(); } if (!$u->isError()) { //$this->redirect('/register', 'register_success', $rcID); if(!$redirectMethod){ $redirectMethod='register_success'; $registerData['msg']=$this->getRegisterSuccessMsg(); } $registerData['uID']=intval($u->uID); } $registerData['success']=1; if($_REQUEST['format']!='JSON') $this->redirect('/register', $redirectMethod, $rcID); } } else { $ip->logSignupRequest(); if ($ip->signupRequestThreshholdReached()) { $ip->createIPBan(); } $this->set('error', $e); $registerData['errors'] = $e->getList(); } if( $_REQUEST['format']=='JSON' ){ $jsonHelper=Loader::helper('json'); echo $jsonHelper->encode($registerData); die; } }
print t('Unknown'); break; case '0': print t('No'); break; case '1': print t('Yes'); break; }?> </strong></p> <? } ?> <br/> <? $attribs = UserAttributeKey::getList(true); if (count($attribs) > 0) { ?> <h3><?=t('User Attributes')?></h3><br/> <? for ($i = 0; $i < count($attribs); $i++) { $uk = $attribs[$i]; if ($pk->validate($uk)) { ?> <div class="row"> <div class="span5" style=""><p><strong><?=$uk->getAttributeKeyDisplayHandle()?></strong></p></div> <div class="span5"><p> <?=$uo->getAttribute($uk->getAttributeKeyHandle(), 'displaySanitized', 'display')?> </p></div>
echo $ui->getUserEmail(); ?> "><?php echo $txt->highlightSearch($ui->getUserEmail(), $keywords); ?> </a></td> <td><?php echo date(DATE_APP_DASHBOARD_SEARCH_RESULTS_USERS, strtotime($ui->getUserDateAdded('user'))); ?> </td> <td><?php echo $ui->getNumLogins(); ?> </td> <?php $slist = UserAttributeKey::getColumnHeaderList(); foreach ($slist as $ak) { ?> <td><?php $vo = $ui->getAttributeValueObject($ak); if (is_object($vo)) { print $vo->getValue('display'); } ?> </td> <?php } ?> <td> </td> </tr>
<?php defined('C5_EXECUTE') or die("Access Denied."); $form = Loader::helper('form'); $searchFields = array('date_added' => t('Registered Between'), 'is_active' => t('Activated Users')); if (Config::get('concrete.permissions_model') == 'advanced') { $searchFields['group_set'] = t('Group Set'); } $searchFieldAttributes = UserAttributeKey::getSearchableList(); foreach ($searchFieldAttributes as $ak) { $searchFields[$ak->getAttributeKeyID()] = $ak->getAttributeKeyDisplayName(); } $ek = PermissionKey::getByHandle('edit_user_properties'); $ik = PermissionKey::getByHandle('activate_user'); $dk = PermissionKey::getByHandle('delete_user'); $flr = new \Concrete\Core\Search\StickyRequest('users'); $searchRequest = $flr->getSearchRequest(); ?> <script type="text/template" data-template="search-form"> <form role="form" data-search-form="users" action="<?php echo URL::to('/ccm/system/search/users/submit'); ?> " class="form-inline ccm-search-fields"> <div class="ccm-search-fields-row"> <div class="form-group"> <select data-bulk-action="users" disabled class="ccm-search-bulk-action form-control"> <option value=""><?php echo t('Items Selected'); ?> </option>
protected function createUser() { // Make sure that this extractor supports everything we need. if (!$this->supportsEmail() && $this->supportsUniqueId()) { throw new Exception('Email and unique ID support are required for user creation.'); } // Make sure that email is verified if the extractor supports it. if ($this->supportsVerifiedEmail() && !$this->isEmailVerified()) { throw new Exception('Please verify your email with this service before attempting to log in.'); } $email = $this->getEmail(); if (\UserInfo::getByEmail($email)) { throw new Exception('Email is already in use.'); } $first_name = ""; $last_name = ""; $name_support = array('full' => $this->supportsFullName(), 'first' => $this->supportsFirstName(), 'last' => $this->supportsLastName()); if ($name_support['first'] && $name_support['last']) { $first_name = $this->getFirstName(); $last_name = $this->getLastName(); } elseif ($name_support['full']) { $reversed_full_name = strrev($this->getFullName()); list($reversed_last_name, $reversed_first_name) = explode(' ', $reversed_full_name, 2); $first_name = strrev($reversed_first_name); $last_name = strrev($reversed_last_name); } $username = null; if ($this->supportsUsername()) { $username = $this->getUsername(); } if ($username === null) { if ($first_name || $last_name) { $username = preg_replace('/[^a-z0-9\\_]/', '_', strtolower($first_name . ' ' . $last_name)); $username = trim(preg_replace('/_{2,}/', '_', $username), '_'); } else { $username = preg_replace('/[^a-zA-Z0-9\\_]/i', '_', strtolower(substr($email, 0, strpos($email, '@')))); $username = trim(preg_replace('/_{2,}/', '_', $username), '_'); } } $unique_username = $username; $append = 1; while (\UserInfo::getByUserName($unique_username)) { // This is a heavy handed way to do this, but it must be done. $unique_username = $username . '_' . $append++; } $username = $unique_username; $data = array(); $data['uName'] = $username; $data['uPassword'] = ""; $data['uEmail'] = $email; $data['uIsValidated'] = 1; $user_info = \UserInfo::add($data); if (!$user_info) { throw new Exception('Unable to create new account.'); } if ($group_id = intval($this->registrationGroupID(), 10)) { $group = \Group::getByID($group_id); if ($group && is_object($group) && !$group->isError()) { $user = \User::getByUserID($user_info->getUserID()); $user->enterGroup($group); } } $key = \UserAttributeKey::getByHandle('first_name'); if ($key) { $user_info->setAttribute($key, $first_name); } $key = \UserAttributeKey::getByHandle('last_name'); if ($key) { $user_info->setAttribute($key, $last_name); } \User::loginByUserID($user_info->getUserID()); $this->bindUser($user = \User::getByUserID($user_info->getUserID()), $this->getUniqueId()); return $user; }
defined('C5_EXECUTE') or die("Access Denied."); $token = \Core::make('Concrete\\Core\\Validation\\CSRF\\Token'); ?> <div class="row"> <div class="col-sm-10 col-sm-offset-1"> <div class="page-header"> <h1><?php echo t('Site Registration'); ?> </h1> </div> </div> </div> <?php $attribs = UserAttributeKey::getRegistrationList(); if ($registerSuccess) { ?> <div class="row"> <div class="col-sm-10 col-sm-offset-1"> <?php switch ($registerSuccess) { case "registered": ?> <p><strong><?php echo $successMsg; ?> </strong><br/><br/> <a href="<?php echo $view->url('/'); ?>
private function installUserAttributes($pkg) { $uakc = AttributeKeyCategory::getByHandle('user'); // Multiple means an attribute can be in more than one set, but you // can't choose what set they show up in for the gui // $uakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_MULTIPLE); // $uakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_NONE); $uakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE); $bua = $uakc->addSet('c5_boilerplate_user_attributes', t('Boilerplate User Attributes'), $pkg); //add boolean attributes $bp_boolean = UserAttributeKey::getByHandle('bp_boolean'); if (!$bp_boolean instanceof UserAttributeKey) { $bp_boolean = UserAttributeKey::add('boolean', array('akHandle' => 'bp_boolean', 'akName' => t('Boolean Name'), 'akIsSearchable' => true, 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($bua); } //add text attributes $bp_text = UserAttributeKey::getByHandle('bp_text'); if (!$bp_text instanceof UserAttributeKey) { $bp_text = UserAttributeKey::add('text', array('akHandle' => 'bp_text', 'akName' => t('Text Name'), 'akIsSearchable' => true, 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($bua); } }
protected function upgradeUserAttributes() { $messages = array(); $db = Loader::db(); $r = $db->Execute('select _UserAttributeKeys.* from _UserAttributeKeys order by displayOrder asc'); while ($row = $r->FetchRow()) { $cleanHandle = preg_replace("/[^A-Za-z0-9\_]/",'',$row['ukHandle']); // remove spaces, chars that'll mess up our index tables $existingAKID = $db->GetOne('select akID from AttributeKeys where akHandle = ?', array($cleanHandle) ); if ($existingAKID < 1) { if(!$row['ukHandle']) continue; $args = array( 'akHandle' => $cleanHandle, 'akIsSearchable' => 1, 'akIsEditable' => 1, 'akName' => $row['ukName'], 'uakIsActive' => ($row['ukHidden']?0:1), 'uakProfileEditRequired' => $row['ukRequired'], 'uakProfileDisplay' => ($row['ukPrivate'] == 0), 'uakRegisterEdit' => $row['ukDisplayedOnRegister'] ); $sttype = $row['ukType']; if ($sttype == 'TEXTAREA') { $sttype = 'TEXT'; } if ($sttype == 'RADIO') { $sttype = 'SELECT'; } $type = AttributeType::getByHandle(strtolower($sttype)); $ak = UserAttributeKey::add($type, $args); if ($sttype == 'SELECT') { $selectOptions = explode("\n", $row['ukValues']); foreach($selectOptions as $so) { if ($so != '') { SelectAttributeTypeOption::add($ak, $so); } } } } else { $ak = UserAttributeKey::getByID($existingAKID); } $r2 = $db->Execute('select * from _UserAttributeValues where ukID = ? and isImported = 0', $row['ukID']); while ($row2 = $r2->FetchRow()) { $ui = UserInfo::getByID($row2['uID']); if(is_object($ui)) { $value = $row2['value']; $ui->setAttribute($ak, $value); } unset($ui); $db->Execute('update _UserAttributeValues set isImported = 1 where ukID = ? and uID = ?', array($row['ukID'], $row2['uID'])); $this->incrementImported(); } unset($ak); unset($row2); $r2->Close(); unset($r2); } unset($row); $r->Close(); unset($r); return $messages; }
protected function finishLogin($loginData = array()) { $u = new User(); if ($this->post('uMaintainLogin')) { $u->setUserForeverCookie(); } if (count($this->locales) > 0) { if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN') && $this->post('USER_LOCALE') != '') { $u->setUserDefaultLanguage($this->post('USER_LOCALE')); } } // Verify that the user has filled out all // required items that are required on register // That means users logging in after new user attributes // have been created and required will be prompted here to // finish their profile $this->set('invalidRegistrationFields', false); Loader::model('attribute/categories/user'); $ui = UserInfo::getByID($u->getUserID()); $aks = UserAttributeKey::getRegistrationList(); $unfilledAttributes = array(); foreach ($aks as $uak) { if ($uak->isAttributeKeyRequiredOnRegister()) { $av = $ui->getAttributeValueObject($uak); if (!is_object($av)) { $unfilledAttributes[] = $uak; } } } if ($this->post('completePartialProfile')) { foreach ($unfilledAttributes as $uak) { $e1 = $uak->validateAttributeForm(); if ($e1 == false) { $this->error->add(t('The field "%s" is required', $uak->getAttributeKeyName())); } else { if ($e1 instanceof ValidationErrorHelper) { $this->error->add($e1); } } } if (!$this->error->has()) { // the user has needed to complete a partial profile, and they have done so, // and they have no errors. So we save our profile data against the account. foreach ($unfilledAttributes as $uak) { $uak->saveAttributeForm($ui); $unfilledAttributes = array(); } } } if (count($unfilledAttributes) > 0) { $u->logout(); $this->set('invalidRegistrationFields', true); $this->set('unfilledAttributes', $unfilledAttributes); } $txt = Loader::helper('text'); $rcID = $this->post('rcID'); $nh = Loader::helper('validation/numbers'); //set redirect url if ($nh->integer($rcID)) { $nh = Loader::helper('navigation'); $rc = Page::getByID($rcID); $url = $nh->getLinkToCollection($rc, true); $loginData['redirectURL'] = $url; } elseif (strlen($rcID)) { $rcID = trim($rcID, '/'); $nc2 = Page::getByPath('/' . $rcID); if (is_object($nc2) && !$nc2->isError()) { $loginData['redirectURL'] = BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '/' . $rcID; } } /* //full page login redirect (non-ajax login) if( strlen($loginData['redirectURL']) && $_REQUEST['format']!='JSON' ){ header('Location: ' . $loginData['redirectURL']); exit; } */ $dash = Page::getByPath("/dashboard", "RECENT"); $dbp = new Permissions($dash); Events::fire('on_user_login', $this); //End JSON Login if ($_REQUEST['format'] == 'JSON') { return $loginData; } //should administrator be redirected to dashboard? defaults to yes if not set. $adminToDash = intval(Config::get('LOGIN_ADMIN_TO_DASHBOARD')); //Full page login, standard redirection $u = new User(); // added for the required registration attribute change above. We recalc the user and make sure they're still logged in if ($u->isRegistered()) { if ($u->config('NEWSFLOW_LAST_VIEWED') == 'FIRSTRUN') { $u->saveConfig('NEWSFLOW_LAST_VIEWED', 0); } if ($loginData['redirectURL']) { //make double secretly sure there's no caching going on header("Cache-Control: no-store, no-cache, must-revalidate"); header("Pragma: no-cache"); header('Expires: Fri, 30 Oct 1998 14:19:41 GMT'); //in the past $this->externalRedirect($loginData['redirectURL']); } else { if ($dbp->canRead() && $adminToDash) { $this->redirect('/dashboard'); } else { //options set in dashboard/users/registration $login_redirect_cid = intval(Config::get('LOGIN_REDIRECT_CID')); $login_redirect_mode = Config::get('LOGIN_REDIRECT'); //redirect to user profile if ($login_redirect_mode == 'PROFILE' && ENABLE_USER_PROFILES) { $this->redirect('/profile/', $u->uID); //redirect to custom page } elseif ($login_redirect_mode == 'CUSTOM' && $login_redirect_cid > 0) { $redirectTarget = Page::getByID($login_redirect_cid); if (intval($redirectTarget->cID) > 0) { $this->redirect($redirectTarget->getCollectionPath()); } else { $this->redirect('/'); } //redirect home } else { $this->redirect('/'); } } } } }
public function getAttributeField($ak) { Loader::model('attribute/categories/user'); if (!is_object($ak)) { $ak = UserAttributeKey::getByHandle($ak); } $value = $this->getAttributeValueObject($ak); $ak->render('form', $value); }
public function edit_attribute() { $uo = UserInfo::getByID($_POST['uID']); $u = new User(); if ($uo->getUserID() == USER_SUPER_ID && !$u->isSuperUser()) { throw new Exception(t('Only the super user may edit this account.')); } $akID = $_REQUEST['uakID']; $ak = UserAttributeKey::get($akID); if ($_POST['task'] == 'update_extended_attribute') { $ak->saveAttributeForm($uo); $val = $uo->getAttributeValueObject($ak); print $val->getValue('displaySanitized', 'display'); exit; } if ($_POST['task'] == 'clear_extended_attribute') { $uo->clearAttribute($ak); $val = $uo->getAttributeValueObject($ak); print '<div class="ccm-attribute-field-none">' . t('None') . '</div>'; exit; } }
public function view() { $assignment = PermissionKey::getByHandle('edit_user_properties')->getMyAssignment(); $vals = Loader::helper('validation/strings'); $valt = Loader::helper('validation/token'); $valc = Loader::helper('concrete/validation'); if ($_POST['create']) { $username = trim($_POST['uName']); $username = preg_replace("/\\s+/", " ", $username); $_POST['uName'] = $username; $password = $_POST['uPassword']; if (!$vals->email($_POST['uEmail'])) { $this->error->add(t('Invalid email address provided.')); } else { if (!$valc->isUniqueEmail($_POST['uEmail'])) { $this->error->add(t("The email address '%s' is already in use. Please choose another.", $_POST['uEmail'])); } } if (strlen($username) < USER_USERNAME_MINIMUM) { $this->error->add(t('A username must be between at least %s characters long.', USER_USERNAME_MINIMUM)); } if (strlen($username) > USER_USERNAME_MAXIMUM) { $this->error->add(t('A username cannot be more than %s characters long.', USER_USERNAME_MAXIMUM)); } if (strlen($username) >= USER_USERNAME_MINIMUM && !$valc->username($username)) { if (USER_USERNAME_ALLOW_SPACES) { $this->error->add(t('A username may only contain letters, numbers and spaces.')); } else { $this->error->add(t('A username may only contain letters or numbers.')); } } if (!$valc->isUniqueUsername($username)) { $this->error->add(t("The username '%s' already exists. Please choose another", $username)); } if ($username == USER_SUPER) { $this->error->add(t('Invalid Username')); } if (strlen($password) < USER_PASSWORD_MINIMUM || strlen($password) > USER_PASSWORD_MAXIMUM) { $this->error->add(t('A password must be between %s and %s characters', USER_PASSWORD_MINIMUM, USER_PASSWORD_MAXIMUM)); } if (strlen($password) >= USER_PASSWORD_MINIMUM && !$valc->password($password)) { $this->error->add(t('A password may not contain ", \', >, <, or any spaces.')); } if (!$valt->validate('create_account')) { $this->error->add($valt->getErrorMessage()); } Loader::model("attribute/categories/user"); $aks = UserAttributeKey::getRegistrationList(); foreach ($aks as $uak) { if ($uak->isAttributeKeyRequiredOnRegister()) { $e1 = $uak->validateAttributeForm(); if ($e1 == false) { $this->error->add(t('The field "%s" is required', $uak->getAttributeKeyName())); } else { if ($e1 instanceof ValidationErrorHelper) { $this->error->add($e1->getList()); } } } } if (!$this->error->has()) { // do the registration $data = array('uName' => $username, 'uPassword' => $password, 'uEmail' => $_POST['uEmail'], 'uDefaultLanguage' => $_POST['uDefaultLanguage']); $uo = UserInfo::add($data); if (is_object($uo)) { $av = Loader::helper('concrete/avatar'); if ($assignment->allowEditAvatar()) { if (is_uploaded_file($_FILES['uAvatar']['tmp_name'])) { $uHasAvatar = $av->updateUserAvatar($_FILES['uAvatar']['tmp_name'], $uo->getUserID()); } } foreach ($aks as $uak) { if (in_array($uak->getAttributeKeyID(), $assignment->getAttributesAllowedArray())) { $uak->saveAttributeForm($uo); } } $gak = PermissionKey::getByHandle('assign_user_groups'); $gIDs = array(); if (is_array($_POST['gID'])) { foreach ($_POST['gID'] as $gID) { if ($gak->validate($gID)) { $gIDs[] = $gID; } } } $uo->updateGroups($gIDs); $uID = $uo->getUserID(); $this->redirect('/dashboard/users/search?uID=' . $uID . '&user_created=1'); } else { $this->error->add(t('An error occurred while trying to create the account.')); $this->set('error', $this->error); } } else { $this->set('error', $this->error); } } }
public function edit($akID = 0) { if ($this->post('akID')) { $akID = $this->post('akID'); } $key = UserAttributeKey::getByID($akID); if (!is_object($key) || $key->isAttributeKeyInternal()) { $this->redirect('/dashboard/users/attributes'); } $type = $key->getAttributeType(); $this->set('key', $key); $this->set('type', $type); if ($this->isPost()) { $cnt = $type->getController(); $cnt->setAttributeKey($key); $e = $cnt->validateKey($this->post()); if ($e->has()) { $this->set('error', $e); } else { $key->update($this->post()); $this->redirect('/dashboard/users/attributes', 'attribute_updated'); } } }
protected function setProfile() { $u = new User(); $ui = UserInfo::getById($u->getUserId()); $ui->setAttribute("{$this->network}_id", $this->user->identifier); if ($ui->getAttribute('first_name') == '') { $ui->setAttribute('first_name', $this->user->firstName); } if ($ui->getAttribute('last_name') == '') { $ui->setAttribute('last_name', $this->user->lastName); } $this->setPicture($ui); if ($this->network == 'linkedin') { $this->auth->api()->setResponseFormat('JSON'); $resp = $this->auth->api()->profile('~:(id,first-name,last-name,industry,positions)'); $profile = json_decode($resp['linkedin']); if (UserAttributeKey::getByHandle('company')) { $company = $profile->positions->values[0]->company->name; $ui->setAttribute('company', $company); } if (UserAttributeKey::getByHandle('title')) { $title = $profile->positions->values[0]->title; $ui->setAttribute('title', $title); } } }
public function edit_attribute() { $uo = UserInfo::getByID($_POST['uID']); $u = new User(); if ($uo->getUserID() == USER_SUPER_ID && (!$u->isSuperUser())) { throw new Exception(t('Only the super user may edit this account.')); } $assignment = PermissionKey::getByHandle('edit_user_properties')->getMyAssignment(); $akID = $_REQUEST['uakID']; if (!in_array($akID, $assignment->getAttributesAllowedArray())) { throw new Exception(t('You do not have permission to modify this attribute.')); } $ak = UserAttributeKey::get($akID); if ($_POST['task'] == 'update_extended_attribute') { $ak->saveAttributeForm($uo); $val = $uo->getAttributeValueObject($ak); print $val->getValue('displaySanitized','display'); exit; } if ($_POST['task'] == 'clear_extended_attribute') { $uo->clearAttribute($ak); $val = $uo->getAttributeValueObject($ak); print '<div class="ccm-attribute-field-none">' . t('None') . '</div>'; exit; } }
?> </div> </div> <?php } else { ?> <div id="ccm-profile-wrapper"> <div id="ccm-profile-body"> <div id="ccm-profile-body-attributes"> <div class="ccm-profile-body-item"> <h1><?php echo $profile->getUserName(); ?> </h1> <?php foreach (UserAttributeKey::getPublicProfileList() as $ua) { ?> <div> <label><?php echo tc('AttributeKeyName', $ua->getAttributeKeyName()); ?> </label> <?php echo $profile->getAttribute($ua, 'displaySanitized', 'display'); ?> </div> <?php } ?> <div> <label><?php
echo $view->action('add'); ?> " id="ccm-attribute-key-form"> <?php Loader::element("attribute/type_form_required", array('category' => $category, 'type' => $type)); ?> </form> <?php } ?> <?php } else { $attribs = UserAttributeKey::getList(); Loader::element('dashboard/attributes_table', array('types' => $types, 'category' => $category, 'attribs' => $attribs, 'editURL' => '/dashboard/users/attributes', 'sortable' => true)); } } ?> <script type="text/javascript"> $(function() { $("ul.ccm-sortable-attribute-list-wrapper").sortable({ handle: 'i.ccm-item-select-list-sort', cursor: 'move', opacity: 0.5, stop: function() { var ualist = $(this).sortable('serialize'); ualist += '&ccm_token=' + '<?php
function updateAttributesDisplayOrder($uats) { $db = Loader::db(); for ($i = 0; $i < count($uats); $i++) { $uak = UserAttributeKey::getByID($uats[$i]); $uak->refreshCache(); $v = array($uats[$i]); $db->query("update UserAttributeKeys set displayOrder = {$i} where akID = ?", $v); } }
<?php echo t2('Badge', 'Badges', count($badges)); ?> </a> </div> <div class="clearfix"></div> </div> <div id="ccm-profile-wrapper"> <div id="ccm-profile-detail"> <?php $uaks = UserAttributeKey::getPublicProfileList(); foreach ($uaks as $ua) { ?> <div> <h4><?php echo $ua->getKeyName(); ?> </h4> <?php $r = $profile->getAttribute($ua, 'displaySanitized', 'display'); if ($r) { print $r; } else { print t('None'); } ?>
$fakID = $_REQUEST['fakID']; $value = ''; $ak = UserAttributeKey::get($fakID); foreach ($users as $ui) { if ($ek->validate($ak)) { $ak->saveAttributeForm($ui); } } $val = $ui->getAttributeValueObject($ak); print $val->getValue('display'); exit; } if ($_POST['task'] == 'clear_extended_attribute') { $fakID = $_REQUEST['fakID']; $value = ''; $ak = UserAttributeKey::get($fakID); foreach ($users as $ui) { if ($ek->validate($ak)) { $ui->clearAttribute($ak); } } print '<div class="ccm-attribute-field-none">' . t('None') . '</div>'; exit; } function printAttributeRow($ak, $ek) { global $users, $form; $value = ''; for ($i = 0; $i < count($users); $i++) { $lastValue = $value; $ui = $users[$i];
} } ?> <h1 class="profilin"><?php echo t('Edit Profile'); ?> </h1> <div class="ccm-form"> <form method="post" action="<?php echo $this->action('save'); ?> " id="profile-edit-form" enctype="multipart/form-data"> <?php $attribs = UserAttributeKey::getEditableInProfileList(); if (is_array($attribs) && count($attribs)) { ?> <fieldset> <div class="ccm-profile-attribute"> <?php echo $form->label('uEmail', t('Email')); ?> <span class="ccm-required">*</span><br/> <?php echo $form->text('uEmail', $ui->getUserEmail()); ?> </div> <?php if (ENABLE_USER_TIMEZONES) { ?>
public function save() { $ui = $this->get('ui'); $uh = Loader::helper('concrete/user'); $th = Loader::helper('text'); $vsh = Loader::helper('validation/strings'); $cvh = Loader::helper('concrete/validation'); $e = Loader::helper('validation/error'); $data = $this->post(); /* * Validation */ // validate the user's email $email = $this->post('uEmail'); if (!$vsh->email($email)) { $e->add(t('Invalid email address provided.')); } else if (!$cvh->isUniqueEmail($email) && $ui->getUserEmail() != $email) { $e->add(t("The email address '%s' is already in use. Please choose another.",$email)); } // password if(strlen($data['uPasswordNew'])) { $passwordNew = $data['uPasswordNew']; $passwordNewConfirm = $data['uPasswordNewConfirm']; if ((strlen($passwordNew) < USER_PASSWORD_MINIMUM) || (strlen($passwordNew) > USER_PASSWORD_MAXIMUM)) { $e->add(t('A password must be between %s and %s characters', USER_PASSWORD_MINIMUM, USER_PASSWORD_MAXIMUM)); } if (strlen($passwordNew) >= USER_PASSWORD_MINIMUM && !$cvh->password($passwordNew)) { $e->add(t('A password may not contain ", \', >, <, or any spaces.')); } if ($passwordNew) { if ($passwordNew != $passwordNewConfirm) { $e->add(t('The two passwords provided do not match.')); } } $data['uPasswordConfirm'] = $passwordNew; $data['uPassword'] = $passwordNew; } $aks = UserAttributeKey::getEditableInProfileList(); foreach($aks as $uak) { if ($uak->isAttributeKeyRequiredOnProfile()) { $e1 = $uak->validateAttributeForm(); if ($e1 == false) { $e->add(t('The field "%s" is required', $uak->getAttributeKeyName())); } else if ($e1 instanceof ValidationErrorHelper) { $e->add($e1); } } } if (!$e->has()) { $data['uEmail'] = $email; if(ENABLE_USER_TIMEZONES) { $data['uTimezone'] = $this->post('uTimezone'); } $ui->update($data); foreach($aks as $uak) { $uak->saveAttributeForm($ui); } $this->redirect("/profile/edit", "save_complete"); } else { $this->set('error', $e); } }