public function signupAction() { if (!$this->getRequest()->isPost()) { $this->addErrorMessage("Form was not properly posted."); $this->_forward('index'); } // Retrieve the form values and its values $form = $this->getForm(); $valid = $form->isValid($_POST); $values = $form->getValues(); $username = $values['username']; $email = $values['email']; $password = $values['password']; // Validate the form itself if (!$form->isValid($_POST)) { // Failed validation; redisplay form $this->view->form = $form; $this->addErrorMessage("Your form contains some errors, please correct them and submit this form again"); return $this->_forward('register'); } // Register user $users = new Users(); $user = $users->addUser($username, $password, $email); // Add some default widgets to the user $widgets = new Widgets(array(Stuffpress_Db_Table::USER => $user->id)); $widgets->addWidget('search'); $widgets->addWidget('rsslink'); $widgets->addWidget('links'); $widgets->addWidget('lastcomments'); $widgets->addWidget('archives'); $widgets->addWidget('logo'); // Add some default properties $properties = new Properties(array(Stuffpress_Db_Properties::KEY => $user->id)); $properties->setProperty('theme', 'clouds'); $properties->setProperty('title', ucfirst($username)); $properties->setProperty('subtitle', "my life online"); // Add the storytlr data source StuffpressModel::forUser($user->id); // Add default pages $pages = new Pages(array(Stuffpress_Db_Table::USER => $user->id)); //$pages->addPage('dashboard', 'Home'); $pages->addPage('lifestream', 'Stream'); $pages->addPage('stories', 'Stories'); // Send the user a verification email Stuffpress_Emails::sendWelcomeEmail($email, $username, $password, $user->token); // Done ! $this->view->username = $username; $this->view->email = $email; $this->render('success'); }
public function addAction() { // Get, check and setup the parameters $prefix = $this->getRequest()->getParam("widget"); // Is the widget available $widgets = new Widgets(); $available = $widgets->getAvailableWidgets(); if (!isset($available[$prefix])) { return; } // Add the widget $widget_id = $widgets->addWidget($prefix); $widget = $widgets->getWidget($widget_id); // Find the widget position $total = count($widgets->getWidgets()); // Set the position $widgets->setPosition($widget_id, $total); // Return the new widget $this->view->widget = $widget; }