streams/mod/new_channel.php

124 lines
3 KiB
PHP
Raw Normal View History

<?php
2012-08-24 08:14:42 +00:00
require_once('include/identity.php');
2012-10-30 04:59:49 +00:00
function new_channel_init(&$a) {
$cmd = ((argc() > 1) ? argv(1) : '');
if($cmd === 'autofill.json') {
require_once('library/urlify/URLify.php');
$result = array('error' => false, 'message' => '');
$n = trim($_REQUEST['name']);
$x = strtolower(URLify::transliterate($n));
$test = array();
// first name
if(strpos($x,' '))
$test[] = legal_webbie(substr($x,0,strpos($x,' ')));
if($test[0]) {
// first name plus first initial of last
$test[] = ((strpos($x,' ')) ? $test[0] . legal_webbie(trim(substr($x,strpos($x,' '),2))) : '');
// first name plus random number
$test[] = $test[0] . mt_rand(1000,9999);
}
// fullname
$test[] = legal_webbie($x);
// fullname plus random number
$test[] = legal_webbie($x) . mt_rand(1000,9999);
2012-08-09 01:50:04 +00:00
json_return_and_die(check_webbie($test));
}
if($cmd === 'checkaddr.json') {
require_once('library/urlify/URLify.php');
$result = array('error' => false, 'message' => '');
2012-08-24 03:00:10 +00:00
$n = trim($_REQUEST['nick']);
$x = strtolower(URLify::transliterate($n));
$test = array();
$n = legal_webbie($x);
if(strlen($n)) {
$test[] = $n;
$test[] = $n . mt_rand(1000,9999);
}
for($y = 0; $y < 100; $y ++)
$test[] = 'id' . mt_rand(1000,9999);
2012-08-09 01:50:04 +00:00
json_return_and_die(check_webbie($test));
}
}
2012-10-30 04:59:49 +00:00
function new_channel_post(&$a) {
2012-08-24 08:14:42 +00:00
$arr = $_POST;
2012-08-27 06:05:00 +00:00
if(($arr['account_id'] = get_account_id()) === false) {
2012-08-24 08:14:42 +00:00
notice( t('Permission denied.') . EOL );
return;
}
2012-08-24 08:14:42 +00:00
$result = create_identity($arr);
2012-08-24 08:14:42 +00:00
if(! $result['success']) {
notice($result['message']);
return;
}
2012-10-02 02:04:21 +00:00
$newuid = $result['channel']['channel_id'];
change_channel($result['channel']['channel_id']);
if(! strlen($next_page = get_config('system','workflow_channel_next')))
$next_page = 'settings';
goaway(z_root() . '/' . $next_page);
}
2012-10-30 04:59:49 +00:00
function new_channel_content(&$a) {
2012-08-27 06:05:00 +00:00
if(! get_account_id()) {
notice( t('Permission denied.') . EOL);
return;
}
2012-08-27 06:05:00 +00:00
$name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : "" );
$nickname = ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : "" );
2012-10-30 04:59:49 +00:00
$o = replace_macros(get_markup_template('new_channel.tpl'), array(
2012-09-02 09:29:17 +00:00
'$title' => t('Add a Channel'),
'$desc' => t('A channel is your own collection of related web pages. A channel can be used to hold social network profiles, blogs, conversation groups and forums, celebrity pages, and much more. You may create as many channels as your service provider allows.'),
2012-08-24 03:00:10 +00:00
2012-09-02 09:29:17 +00:00
'$label_name' => t('Channel Name'),
'$help_name' => t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group" '),
2012-08-24 03:00:10 +00:00
'$label_nick' => t('Choose a short nickname'),
'$nick_desc' => t('Your nickname will be used to create an easily remembered channel address (like an email address) which you can share with others.'),
2012-09-02 08:59:11 +00:00
'$label_import' => t('Check this box to import an existing channel file from another location'),
2012-08-24 03:00:10 +00:00
'$name' => $name,
'$nickname' => $nickname,
'$submit' => t('Create')
));
return $o;
}