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'); }
private function getForm($type='blog', $edit=false, $item=false) { $source = StuffpressModel::forUser($this->_application->user->id); $item_id = $item ? $item->getID() : 0; $source_id = $item ? $item->getSource() : $source->getID(); $date = $item ? $item->getTimestamp() : false; // Crappy code !! TODO $lat = $item ? $item->getLatitude() : false; $lon = $item ? $item->getLongitude() : false; // get the tags if any if ($item && $item->getTagCount()>0) { $tags_table = new Tags(); $tags = $tags_table->getTags($source_id, $item_id); $strings = array(); foreach($tags as $tag) { $strings[] = $tag['tag']; } $tags = implode(', ', $strings); } else { $tags = false; } if ($type == SourceItem::STATUS_TYPE) { $status = $item ? $item->getStatus() : ''; $form = $this->getFormStatus($source_id,$item_id, $status, $date, $edit, $tags, $lat, $lon); } elseif ($type == SourceItem::BLOG_TYPE) { $title = $item ? $item->getTitle() : ''; $text = $item ? $item->getContent() : ''; $form = $this->getFormText($source_id,$item_id, $title, $text, $date, $edit, $tags, $lat, $lon); } elseif ($type == SourceItem::LINK_TYPE) { $title = $item ? $item->getTitle() : ''; $link = $item ? $item->getLink() : ''; $desc = $item ? $item->getDescription() : ''; $form = $this->getFormLink($source_id, $item_id, $link, $title, $desc, $date, $edit, $tags, $lat, $lon); } elseif ($type == SourceItem::IMAGE_TYPE) { $title = $item ? $item->getTitle() : ''; $desc = $item ? $item->getDescription() : ''; $form = $this->getFormImage($source_id, $item_id, $title, $desc, $date, $edit, $tags, $lat, $lon); } elseif ($type == SourceItem::AUDIO_TYPE) { $title = $item ? $item->getTitle() : ''; $desc = $item ? $item->getDescription() : ''; $form = $this->getFormAudio($source_id, $item_id, $title, $desc, $date, $edit, $tags, $lat, $lon); } elseif ($type == SourceItem::VIDEO_TYPE) { $title = $item ? $item->getTitle() : ''; $desc = $item ? $item->getDescription() : ''; $embed = $item ? $item->getEmbedCode() : ''; $form = $this->getFormVideo($source_id, $item_id, $title, $desc, $embed, $date, $edit, $tags, $lat, $lon); } return $form; }
private function post($user_id, $data) { $source = StuffpressModel::forUser($user_id); $item_id = $source->addItem($data, $data['published'], $data['type'], false, false, false, $data['title']); $source_id = $source->getID(); // Send notification if twitter post is enabled if ($this->_properties->getProperty('twitter_auth') && in_array($source_id, unserialize($this->_properties->getProperty('twitter_services')))) { try { $this->notifyTwitter($item_id, $source_id); } catch (Exception $e) { // } } // Ping blog search engines $this->ping(); // Return the id so we can move on ! return $item_id; }
/** * @param array $data * @return StuffpressItem */ protected function _updateItem($data, $source_id, $item_id) { // Update the item $source = StuffpressModel::forUser($this->_application->user->id); $data_table = new Data(); $source->updateItem($item_id, $data, $data['published']); // Fetch the newly updated item $item = $data_table->getItem($source_id, $item_id); return $item; }