Changeset 2851
- Timestamp:
- 01/10/11 21:27:04 (13 years ago)
- Location:
- plugins/subscription
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/subscription/_public.php
r2842 r2851 16 16 # ***** END LICENSE BLOCK ***** 17 17 18 18 19 $core->url->register('subscription','subscribe','^subscribe(/(.*))?$',array('urlSubscription','create')); 19 20 21 $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates'); 22 20 23 $core->tpl->addBlock('SubscriptionIf',array('tplSubscription','SubscriptionIf')); 24 21 25 $core->tpl->addValue('SubscriptionURL',array('tplSubscription','SubscriptionURL')); 22 26 $core->tpl->addValue('SubscriptionMsgSuccess',array('tplSubscription','SubscriptionMsgSuccess')); … … 79 83 } 80 84 81 82 85 try 83 86 { 87 # Checks provided fields 88 if (empty($_POST['s_name'])) { 89 throw new Exception(__('You must provide a name.')); 90 } 91 92 if (!text::isEmail($_POST['s_mail'])) { 93 throw new Exception(__('You must provide a valid email address.')); 94 } 95 96 if (empty($_POST['s_login'])) { 97 throw new Exception(__('You must provide a login.')); 98 } 99 100 if (empty($_POST['s_password'])) { 101 throw new Exception(__('You must provide a password.')); 102 } 103 104 if ($_POST['s_password_confirm'] !== $_POST['s_password']) { 105 throw new Exception(__("Passwords don't match")); 106 } 107 108 if (empty($_POST['s_blog_name'])) { 109 throw new Exception(__('You must provide a name for you blog.')); 110 } 111 112 if (empty($_POST['s_blog_url'])) { 113 throw new Exception(__('You must provide an url for your blog.')); 114 } 115 84 116 $_ctx->subscription['name'] = preg_replace('/[\n\r]/','',$_POST['s_name']); 85 117 $_ctx->subscription['mail'] = preg_replace('/[\n\r]/','',$_POST['s_mail']); … … 89 121 $_ctx->subscription['blog_name'] = preg_replace('/[\n\r]/','',$_POST['s_blog_name']); 90 122 $_ctx->subscription['blog_url'] = preg_replace('/[\n\r]/','',$_POST['s_blog_url']); 91 92 # Checks provided fields 93 if (empty($_POST['s_name'])) { 94 throw new Exception(__('You must provide a name.')); 95 } 96 97 if (!text::isEmail($_POST['s_mail'])) { 98 throw new Exception(__('You must provide a valid email address.')); 99 } 100 101 if (empty($_POST['s_login'])) { 102 throw new Exception(__('You must provide a login.')); 103 } 104 105 if (empty($_POST['s_password'])) { 106 throw new Exception(__('You must provide a password.')); 107 } 108 109 if ($_POST['s_password_confirm'] !== $_POST['s_password']) { 110 throw new Exception(__("Passwords don't match")); 111 } 112 113 if (empty($_POST['s_blog_name'])) { 114 throw new Exception(__('You must provide a name for you blog.')); 115 } 116 117 if (empty($_POST['s_blog_url'])) { 118 throw new Exception(__('You must provide an url for your blog.')); 119 } 120 121 //creating user and blog 122 $core->blog->settings->setNamespace('subscription2'); 123 $blogs_folder_path = $core->blog->settings->get('blogs_folder_path'); 124 $dotclear_folder_path = $core->blog->settings->get('dotclear_folder_path'); 125 126 127 if($core->userExists($_ctx->subscription['login'])) { 128 throw new Exception(__('User already exists')); 129 } 130 131 if($core->blogExists($_ctx->subscription['blog_url'])) { 132 throw new Exception(__('A blog already exists at this URL')); 133 } 134 135 136 //augmentation des droits TODO : changer admin par un recuperation de login 137 $core->auth->checkUser('marc'); 138 139 //user 140 $cur = $core->con->openCursor($core->prefix.'user'); 141 142 $cur->user_id = $_ctx->subscription['login']; 143 $cur->user_super = 0; 144 $cur->user_email = $_ctx->subscription['mail']; 145 $cur->user_pwd = $_ctx->subscription['password']; 146 147 if (!preg_match('/^[A-Za-z0-9._-]{2,}$/',$cur->user_id)) { 148 throw new Exception(__('User ID must contain at least 2 characters using letters, numbers or symbols.')); 149 } 150 if ($cur->user_creadt === null) { 151 $cur->user_creadt = array('NOW()'); 152 } 153 154 //$cur->insert(); 155 $core->addUser($cur); 156 157 158 //blog 159 160 $root_url = 'http://'.$_ctx->subscription['blog_url'].'.'.self::getDomainName().'/'; 161 162 $cur = $core->con->openCursor($core->prefix.'blog'); 163 164 $cur->blog_id = $_ctx->subscription['blog_url']; 165 $cur->blog_url = $root_url.'index.php/'; 166 $cur->blog_name = $_ctx->subscription['blog_name']; 167 168 $core->addBlog($cur); 169 170 //permissions du blog 171 172 $core->setUserBlogPermissions($_ctx->subscription['login'], $_ctx->subscription['blog_url'], array('admin'=>1, 'blogroll'=>1), true); 173 174 $core->blogDefaults($cur->blog_id); 175 176 $blog_settings = new dcSettings($core,$_ctx->subscription['blog_url']); 177 $blog_settings->setNameSpace('system'); 178 $blog_settings->put('lang',http::getAcceptLanguage()); 179 180 $blog_settings->put('themes_path',$core->blog->themes_path); 181 $blog_settings->put('themes_url',$core->blog->themes_path); //TODO : injection via la config 182 183 //creating blog folder and index.php file 184 $path = $blogs_folder_path.$_ctx->subscription['blog_url']; 185 if(!file_exists($path)){ 186 mkdir ($path); 187 chmod ($path, 0755); 188 mkdir ($path."/public"); 189 chmod ($path."/public", 0755); 190 } 191 192 file_put_contents($path.'/index.php',"<?php\n\n". 193 "define('DC_BLOG_ID','".$_ctx->subscription['blog_url']."'); # identifiant du blog\n". 194 "require '".realpath($dotclear_folder_path.'/inc/public/prepend.php')."';\n\n?>"); //TODO : param dans la conf pour le path de dotclear 195 196 197 123 124 Subscription::subscribe($_ctx->subscription); 125 198 126 http::redirect($core->blog->url.$core->url->getBase('subscription2').'/created'); 199 127 } … … 206 134 } 207 135 208 $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');209 136 self::serveDocument('new_blog.html'); 210 137 exit; … … 241 168 { 242 169 $f = $GLOBALS['core']->tpl->getFilters($attr); 243 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("subscription 2")').'; ?>';170 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("subscription")').'; ?>'; 244 171 } 245 172 … … 259 186 public static function SubscriptionDomainName() { 260 187 $domain_name = urlSubscription::getDomainName(); 261 return "<?php echo $domain_name; ?>";188 return "<?php echo '$domain_name'; ?>"; 262 189 } 263 190 -
plugins/subscription/default-templates/new_blog.html
r2842 r2851 48 48 <tpl:SubscriptionIf created="1">{{tpl:SubscriptionMsgSuccess}}</tpl:SubscriptionIf> 49 49 50 <tpl:SubscriptionIf error="1">{{tpl:SubscriptionMsgError}}</tpl:SubscriptionIf> 50 <tpl:SubscriptionIf error="1"> 51 <div class="error"> 52 {{tpl:SubscriptionMsgError}} 53 </div> 54 </tpl:SubscriptionIf> 51 55 52 56 <tpl:SubscriptionIf created="0"> -
plugins/subscription/index.php
r2842 r2851 16 16 # ***** END LICENSE BLOCK ***** 17 17 18 19 $blogs_folder_path = $core->blog->settings->get('blogs_folder_path'); 20 $dotclear_folder_path = $core->blog->settings->get('dotclear_folder_path'); 21 $notify_mail_adress = $core->blog->settings->get('notify_mail_adress'); 22 18 $core->blog->settings->setNamespace('subscription'); 23 19 24 20 //Liste des SuperUsers (pour affichage des mails) … … 45 41 } 46 42 47 $core->blog->settings->setNamespace('subscription 2');43 $core->blog->settings->setNamespace('subscription'); 48 44 49 45 $core->blog->settings->put('blogs_folder_path', $blogs_folder_path, 'string', 'Blogs storage folder path', true, true); … … 81 77 '<fieldset><legend>'.__('Paths').'</legend>'. 82 78 '<p>'.__('Set absolute paths for Doctclear installation and blogs storage folder.').'</p>'. 83 '<p><label>'.__('Dotclear path:').' '.form::field('dotclear_folder_path',40,300,$ dotclear_folder_path).'</label></p>'.84 '<p><label>'.__('Blogs path:').' '.form::field('blogs_folder_path',40,300,$ blogs_folder_path).'</label></p>'.79 '<p><label>'.__('Dotclear path:').' '.form::field('dotclear_folder_path',40,300,$core->blog->settings->dotclear_folder_path).'</label></p>'. 80 '<p><label>'.__('Blogs path:').' '.form::field('blogs_folder_path',40,300,$core->blog->settings->blogs_folder_path).'</label></p>'. 85 81 '</fieldset>'. 86 82 '<fieldset><legend>'.__('Email adress for notification').'</legend>'. 87 83 '<p><label>'.__('Adress to notify blog creation to administrator'). 88 form::combo('notify_mail_adress',$ulist, $ notify_mail_adress).84 form::combo('notify_mail_adress',$ulist, $core->blog->settings->notify_mail_adress). 89 85 '</label></p>'. 90 86
Note: See TracChangeset
for help on using the changeset viewer.