protected function doPreparation()
 {
     // showstream requires a nickname
     $nickname_arg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->getActionName(), $args), 301);
     }
     try {
         $user = User::getByNickname($nickname);
     } catch (NoSuchUserException $e) {
         $group = Local_group::getKV('nickname', $nickname);
         if ($group instanceof Local_group) {
             common_redirect($group->getProfile()->getUrl());
         }
         // No user nor group found, throw the NoSuchUserException again
         throw $e;
     }
     $this->target = $user->getProfile();
 }
 protected function doStreamPreparation()
 {
     $this->target = User::getByNickname($this->trimmed('nickname'))->getProfile();
 }
Example #3
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$helptext = <<<END_OF_PASSWORD_HELP
setpassword.php <username> <password>

Sets the password of user with name <username> to <password>

END_OF_PASSWORD_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (count($args) < 2) {
    show_help();
}
$nickname = $args[0];
$password = $args[1];
if (mb_strlen($password) < 6) {
    print "Password must be 6 characters or more.\n";
    exit(1);
}
try {
    $user = User::getByNickname($nickname);
    $user->setPassword($password);
} catch (NoSuchUserException $e) {
    print $e->getMessage();
    exit(1);
}
print "Password for user '{$nickname}' updated.\n";