. * * @category GNUSocial * @package StatusNet * @author Shashi Gowda * @copyright 2009, 2010, StatusNet, Inc. * @copyright 2010, Free Software Foundation, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://daisycha.in */ if (!defined('STATUSNET')) { exit(1); } class NewSocialObjectAction extends NewnoticeAction { private $slug=null; private $dbclass=null; function saveNewNotice($metadata=array()) { $this->validate(); # summarize social-object data to be put in as notice content # should be usable in xmpp, email etc. $content = $this->getSummary(); $replyto = $this->getReplyTo(); $metadata['replies'] = $this->getMentions(); $metadata['urls'] = $this->getUrls(); $metadata['groups'] = $this->getGroups(); $metadata['tags'] = $this->getTags(); # this is largely copied from parent::saveNewNotice $user = common_current_user(); assert($user); // XXX: maybe an error instead... #If an ID of 0 is wrongly passed here, it will cause a database error, #so override it... if ($replyto == 0) { $replyto = 'false'; } $upload = null; $upload = MediaFile::fromUpload('attach'); if (isset($upload)) { $content_shortened .= ' ' . $upload->shortUrl(); if (Notice::contentTooLong($content_shortened)) { $upload->delete(); $this->clientError( sprintf( _('Max notice size is %d chars, including attachment URL.'), Notice::maxContent() ) ); } } $options = array('reply_to' => ($replyto == 'false') ? null : $replyto); if ($user->shareLocation()) { // use browser data if checked; otherwise profile data if ($this->arg('notice_data-geo')) { $locOptions = Notice::locationOptions($this->trimmed('lat'), $this->trimmed('lon'), $this->trimmed('location_id'), $this->trimmed('location_ns'), $user->getProfile()); } else { $locOptions = Notice::locationOptions(null, null, null, null, $user->getProfile()); } $options = array_merge($options, $locOptions, $metadata); ### $metadata too. } $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options); $this->saveNew($notice); ### <-- save me. if (isset($upload)) { $upload->attachToNotice($notice); } if ($this->boolean('ajax')) { header('Content-Type: text/xml;charset=utf-8'); $this->xw->startDocument('1.0', 'UTF-8'); $this->elementStart('html'); $this->elementStart('head'); $this->element('title', null, _('Notice posted')); $this->elementEnd('head'); $this->elementStart('body'); $this->showNotice($notice); $this->elementEnd('body'); $this->elementEnd('html'); } else { $returnto = $this->trimmed('returnto'); if ($returnto) { $url = common_local_url($returnto, array('nickname' => $user->nickname)); } else { $url = common_local_url('shownotice', array('notice' => $notice->id)); } common_redirect($url, 303); } } function validate() { return true; } function getSummary() { # have this function in the DB class, # respect Notice::MaxContent() } function getReplyTo() { return $this->trimmed('inreplyto'); } function getMentions() { } function getUrls() { } function getTags() { } function getGroups() { } function save() { # save your custom data, video, event or whatever. } function saveNew() { # save new social-object to its table. } function showPage() { if ($this->boolean('ajax')) { header('Content-Type: text/xml;charset=utf-8'); $this->xw->startDocument('1.0', 'UTF-8'); $this->elementStart('html'); $this->elementStart('head'); $this->elementEnd('head'); $this->elementStart('body'); $this->showSocialObjectForm(); $this->elementEnd('body'); $this->elementEnd('html'); return false; } else { parent::showPage(); } } function showNoticeForm() { $this->showSocialObjectForm(); } # when user choses to post a social object, # the existing notice box will be replaced # with this. # abstracted out in SocialLayout plugin # has autocomplete for replies and groupnames function showSocialObjectForm() { # show some awesome variation of SocialObjectForm } }