/**
  * Show the menu
  *
  * @return void
  */
 function show()
 {
     $user = common_current_user();
     if (empty($user)) {
         throw new ServerException('Cannot show personal group navigation without a current user.');
     }
     $user_profile = $user->getProfile();
     $nickname = $user->nickname;
     $name = $user_profile->getBestName();
     $action = $this->actionName;
     $mine = $this->action->arg('nickname') == $nickname;
     // @fixme kinda vague
     $this->out->elementStart('ul', array('class' => 'nav'));
     if (Event::handle('StartPersonalGroupNav', array($this))) {
         $this->out->menuItem(common_local_url('all', array('nickname' => $nickname)), _m('MENU', 'Home'), sprintf(_('%s and friends'), $name), $mine && $action == 'all', 'nav_timeline_personal');
         $this->out->menuItem(common_local_url('showstream', array('nickname' => $nickname)), _m('MENU', 'Profile'), _('Your profile'), $mine && $action == 'showstream', 'nav_profile');
         $this->out->menuItem(common_local_url('replies', array('nickname' => $nickname)), _m('MENU', 'Replies'), sprintf(_('Replies to %s'), $name), $mine && $action == 'replies', 'nav_timeline_replies');
         $this->out->menuItem(common_local_url('showfavorites', array('nickname' => $nickname)), _m('MENU', 'Favorites'), sprintf(_('%s\'s favorite notices'), $user_profile ? $name : _m('FIXME', 'User')), $mine && $action == 'showfavorites', 'nav_timeline_favorites');
         $cur = common_current_user();
         if ($cur && $cur->id == $user->id && !common_config('singleuser', 'enabled')) {
             $this->out->menuItem(common_local_url('inbox', array('nickname' => $nickname)), _m('MENU', 'Messages'), _('Your incoming messages'), $mine && $action == 'inbox');
         }
         Event::handle('EndPersonalGroupNav', array($this));
     }
     $this->out->elementEnd('ul');
 }
 /**
  * Data elements of the form
  *
  * @return void
  */
 function formData()
 {
     $this->out->hidden('subaction', 'authverify');
     $this->out->elementStart('fieldset');
     $this->out->elementStart('p');
     // TRANS: Form instructions.
     $this->out->text(_m('Follow this link to confirm authorization at Yammer; you will be prompted to log in if necessary:'));
     $this->out->elementEnd('p');
     // iframe would be nice to avoid leaving -- since they don't seem to have callback url O_O
     /*
     $this->out->element('iframe', array('id' => 'yammer-oauth',
                                         'src' => $this->runner->getAuthUrl()));
     */
     // yeah, it ignores the callback_url
     // soo... crappy link. :(
     $this->out->elementStart('p', array('class' => 'magiclink'));
     $this->out->element('a', array('href' => $this->runner->getAuthUrl(), 'target' => '_blank'), _m('Open Yammer authentication window'));
     $this->out->elementEnd('p');
     // TRANS: Form instructions.
     $this->out->element('p', array(), _m('Copy the verification code you are given below:'));
     $this->out->elementStart('ul', array('class' => 'form_data'));
     $this->out->elementStart('li');
     // TRANS: Field label.
     $this->out->input('verify_token', _m('Verification code:'));
     $this->out->elementEnd('li');
     $this->out->elementEnd('ul');
     // TRANS: Button text for saving  Yammer authorisation data and starting Yammer import.
     $this->out->submit('submit', _m('BUTTON', 'Continue'), 'submit', null, _m('Save the verification code and begin import.'));
     $this->out->elementEnd('fieldset');
 }
 /**
  * Show the menu
  *
  * @return void
  */
 function show()
 {
     $cur = common_current_user();
     $action = $this->action->trimmed('action');
     $this->out->elementStart('ul', array('class' => 'nav'));
     if (Event::handle('StartSubGroupNav', array($this))) {
         $this->out->menuItem(common_local_url('showstream', array('nickname' => $this->user->nickname)), _m('MENU', 'Profile'), empty($profile) ? $this->user->nickname : $profile->getBestName(), $action == 'showstream', 'nav_profile');
         $this->out->menuItem(common_local_url('subscriptions', array('nickname' => $this->user->nickname)), _m('MENU', 'Subscriptions'), sprintf(_('People %s subscribes to.'), $this->user->nickname), $action == 'subscriptions', 'nav_subscriptions');
         $this->out->menuItem(common_local_url('subscribers', array('nickname' => $this->user->nickname)), _m('MENU', 'Subscribers'), sprintf(_('People subscribed to %s.'), $this->user->nickname), $action == 'subscribers', 'nav_subscribers');
         if ($cur && $cur->id == $this->user->id) {
             // Possibly site admins should be able to get in here too
             $pending = $this->countPendingSubs();
             if ($pending || $cur->subscribe_policy == User::SUBSCRIBE_POLICY_MODERATE) {
                 $this->out->menuItem(common_local_url('subqueue', array('nickname' => $this->user->nickname)), sprintf(_m('MENU', 'Pending (%d)'), $pending), sprintf(_('Approve pending subscription requests.'), $this->user->nickname), $action == 'subqueueaction', 'nav_subscribers');
             }
         }
         $this->out->menuItem(common_local_url('usergroups', array('nickname' => $this->user->nickname)), _m('MENU', 'Groups'), sprintf(_('Groups %s is a member of.'), $this->user->nickname), $action == 'usergroups', 'nav_usergroups');
         $this->out->menuItem(common_local_url('peopletagsubscriptions', array('nickname' => $this->user->nickname)), _m('MENU', 'Lists'), sprintf(_('List subscriptions by %s.'), $this->user->nickname), in_array($action, array('peopletagsbyuser', 'peopletagsubscriptions', 'peopletagsforuser')), 'nav_timeline_peopletags');
         if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) {
             $this->out->menuItem(common_local_url('invite'), _m('MENU', 'Invite'), sprintf(_('Invite friends and colleagues to join you on %s.'), common_config('site', 'name')), $action == 'invite', 'nav_invite');
         }
         Event::handle('EndSubGroupNav', array($this));
     }
     $this->out->elementEnd('ul');
 }
Exemple #4
0
 function prepare($args)
 {
     parent::prepare($args);
     $this->uri = $this->trimmed('uri');
     $this->uri = Discovery::normalize($this->uri);
     if (Discovery::isWebfinger($this->uri)) {
         $parts = explode('@', substr(urldecode($this->uri), 5));
         if (count($parts) == 2) {
             list($nick, $domain) = $parts;
             // @fixme confirm the domain too
             // @fixme if domain checking is added, ensure that it will not
             //        cause problems with sites that have changed domains!
             $nick = common_canonical_nickname($nick);
             $this->user = User::staticGet('nickname', $nick);
         }
     } else {
         $this->user = User::staticGet('uri', $this->uri);
         if (empty($this->user)) {
             // try and get it by profile url
             $profile = Profile::staticGet('profileurl', $this->uri);
             if (!empty($profile)) {
                 $this->user = User::staticGet('id', $profile->id);
             }
         }
     }
     if (!$this->user) {
         $this->clientError(_m('No such user.'), 404);
         return false;
     }
     return true;
 }
Exemple #5
0
 function showContent()
 {
     $tags = $this->getTags();
     if (!$tags) {
         // TRANS: Content displayed in a tag cloud section if there are no tags.
         $this->out->element('p', null, _m('NOTAGS', 'None'));
         return false;
     }
     $cnt = 0;
     $tw = array();
     $sum = 0;
     while ($tags->fetch() && ++$cnt <= TAGS_PER_SECTION) {
         $tw[$tags->tag] = $tags->weight;
         $sum += $tags->weight;
     }
     if ($cnt == 0) {
         // TRANS: Content displayed in a tag cloud section if there are no tags.
         $this->out->element('p', null, _m('NOTAGS', 'None'));
         return false;
     }
     ksort($tw);
     $this->out->elementStart('ul', 'tags xoxo tag-cloud');
     foreach ($tw as $tag => $weight) {
         $this->showTag($tag, $weight, $sum == 0 ? 0 : $weight / $sum);
     }
     $this->out->elementEnd('ul');
     return $cnt > TAGS_PER_SECTION;
 }
Exemple #6
0
 public function getKeyPair($signer_uri)
 {
     $disco = new Discovery();
     try {
         $xrd = $disco->lookup($signer_uri);
     } catch (Exception $e) {
         return false;
     }
     if ($xrd->links) {
         if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
             $keypair = false;
             $parts = explode(',', $link['href']);
             if (count($parts) == 2) {
                 $keypair = $parts[1];
             } else {
                 // Backwards compatibility check for separator bug in 0.9.0
                 $parts = explode(';', $link['href']);
                 if (count($parts) == 2) {
                     $keypair = $parts[1];
                 }
             }
             if ($keypair) {
                 return $keypair;
             }
         }
     }
     // TRANS: Exception.
     throw new Exception(_m('Unable to locate signer public key.'));
 }
 /**
  * Data elements of the form
  *
  * @return void
  */
 function formData()
 {
     $this->out->hidden('subaction', 'apikey');
     $this->out->elementStart('fieldset');
     $this->out->elementStart('p');
     // TRANS: Explanation of what needs to be done to connect to a Yammer network.
     $this->out->text(_m('Before we can connect to your Yammer network, ' . 'you will need to register the importer as an ' . 'application authorized to pull data on your behalf. ' . 'This registration will work only for your own network. ' . 'Follow this link to register the app at Yammer; ' . 'you will be prompted to log in if necessary:'));
     $this->out->elementEnd('p');
     $this->out->elementStart('p', array('class' => 'magiclink'));
     $this->out->element('a', array('href' => 'https://www.yammer.com/client_applications/new', 'target' => '_blank'), _m('Open Yammer application registration form'));
     $this->out->elementEnd('p');
     // TRANS: Instructions.
     $this->out->element('p', array(), _m('Copy the consumer key and secret you are given into the form below:'));
     $this->out->elementStart('ul', array('class' => 'form_data'));
     $this->out->elementStart('li');
     // TRANS: Field label for a Yammer consumer key.
     $this->out->input('consumer_key', _m('Consumer key:'), common_config('yammer', 'consumer_key'));
     $this->out->elementEnd('li');
     $this->out->elementStart('li');
     // TRANS: Field label for a Yammer consumer secret.
     $this->out->input('consumer_secret', _m('Consumer secret:'), common_config('yammer', 'consumer_secret'));
     $this->out->elementEnd('li');
     $this->out->elementEnd('ul');
     // TRANS: Button text for saving a Yammer API registration.
     $this->out->submit('submit', _m('BUTTON', 'Save'), 'submit', null, _m('Save the entered consumer key and consumer secret.'));
     $this->out->elementEnd('fieldset');
 }
 function handle($channel)
 {
     $cur = $this->user;
     $all = new SearchSub();
     $all->profile_id = $cur->id;
     $all->find();
     if ($all->N == 0) {
         // TRANS: Error text shown a user tries to disable all a search subscriptions with track off command, but has none.
         $channel->error($cur, _m('You are not tracking any searches.'));
         return;
     }
     $profile = $cur->getProfile();
     while ($all->fetch()) {
         try {
             SearchSub::cancel($profile, $all->search);
         } catch (Exception $e) {
             // TRANS: Message given having failed to cancel one of the search subs with 'track off' command.
             // TRANS: %s is the search for which the subscription removal failed.
             $channel->error($cur, sprintf(_m('Error disabling search subscription for query "%s".'), $all->search));
             return;
         }
     }
     // TRANS: Message given having disabled all search subscriptions with 'track off'.
     $channel->output($cur, _m('Disabled all your search subscriptions.'));
 }
Exemple #9
0
 function doModel()
 {
     switch ($this->action) {
         case 'latestsearches':
             //calling the comments settings view
             $this->doView('settings/searches.php');
             break;
         case 'latestsearches_post':
             // updating comment
             osc_csrf_check();
             if (Params::getParam('save_latest_searches') == 'on') {
                 osc_set_preference('save_latest_searches', 1);
             } else {
                 osc_set_preference('save_latest_searches', 0);
             }
             if (Params::getParam('customPurge') == '') {
                 osc_add_flash_error_message(_m('Custom number could not be left empty'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=latestsearches');
             } else {
                 osc_set_preference('purge_latest_searches', Params::getParam('customPurge'));
                 osc_add_flash_ok_message(_m('Last search settings have been updated'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=latestsearches');
             }
             break;
     }
 }
Exemple #10
0
 function error($from, $msg)
 {
     $this->log(LOG_INFO, "Error: {$from} {$msg}");
     $headers['To'] = $from;
     $headers['Subject'] = _m('Error');
     return mail_send(array($from), $headers, $msg);
 }
Exemple #11
0
 /**
  * Show the menu
  *
  * @return void
  */
 function show()
 {
     $this->actionName = $this->action->trimmed('action');
     $this->action->elementStart('ul', array('class' => 'nav'));
     if (Event::handle('StartPublicGroupNav', array($this))) {
         if (!common_config('singleuser', 'enabled')) {
             // TRANS: Menu item in search group navigation panel.
             $this->out->menuItem(common_local_url('public'), _m('MENU', 'Public'), _('Public timeline'), $this->actionName == 'public', 'nav_timeline_public');
         }
         // TRANS: Menu item in search group navigation panel.
         $this->out->menuItem(common_local_url('groups'), _m('MENU', 'Groups'), _('User groups'), $this->actionName == 'groups', 'nav_groups');
         if (!common_config('performance', 'high')) {
             // TRANS: Menu item in search group navigation panel.
             $this->out->menuItem(common_local_url('publictagcloud'), _m('MENU', 'Recent tags'), _('Recent tags'), $this->actionName == 'publictagcloud', 'nav_recent-tags');
         }
         if (count(common_config('nickname', 'featured')) > 0) {
             // TRANS: Menu item in search group navigation panel.
             $this->out->menuItem(common_local_url('featured'), _m('MENU', 'Featured'), _('Featured users'), $this->actionName == 'featured', 'nav_featured');
         }
         if (!common_config('singleuser', 'enabled')) {
             // TRANS: Menu item in search group navigation panel.
             $this->out->menuItem(common_local_url('favorited'), _m('MENU', 'Popular'), _('Popular notices'), $this->actionName == 'favorited', 'nav_timeline_favorited');
         }
         Event::handle('EndPublicGroupNav', array($this));
     }
     $this->action->elementEnd('ul');
 }
 function show()
 {
     $user = common_current_user();
     $this->action->elementStart('ul', array('id' => 'nav_local_default'));
     if (Event::handle('StartDefaultLocalNav', array($this, $user))) {
         if (!empty($user)) {
             $pn = new PersonalGroupNav($this->action);
             // TRANS: Menu item in default local navigation panel.
             $this->submenu(_m('MENU', 'Home'), $pn);
         }
         $bn = new PublicGroupNav($this->action);
         // TRANS: Menu item in default local navigation panel.
         $this->submenu(_m('MENU', 'Public'), $bn);
         if (!empty($user)) {
             $sn = new GroupsNav($this->action, $user);
             if ($sn->haveGroups()) {
                 // TRANS: Menu item in default local navigation panel.
                 $this->submenu(_m('MENU', 'Groups'), $sn);
             }
         }
         if (!empty($user)) {
             $sn = new ListsNav($this->action, $user->getProfile());
             if ($sn->hasLists()) {
                 // TRANS: Menu item in default local navigation panel.
                 $this->submenu(_m('MENU', 'Lists'), $sn);
             }
         }
         Event::handle('EndDefaultLocalNav', array($this, $user));
     }
     $this->action->elementEnd('ul');
 }
Exemple #13
0
 /**
  * Class handler.
  *
  * @param array $args query arguments
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $profile = AnonymousFavePlugin::getAnonProfile();
     if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
         // TRANS: Client error.
         $this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.'));
     }
     $id = $this->trimmed('notice');
     $notice = Notice::getKV($id);
     $token = $this->checkSessionToken();
     // Throws exception
     $stored = Fave::addNew($profile, $notice);
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title.
         $this->element('title', null, _m('Disfavor favorite'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $disfavor = new AnonDisFavorForm($this, $notice);
         $disfavor->show();
         $this->elementEnd('body');
         $this->endHTML();
     } else {
         $this->returnToPrevious();
     }
 }
Exemple #14
0
 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     $nickname = Nickname::normalize($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->trimmed('action'), $args), 301);
     }
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when referring to a non-existing user.
         $this->clientError(_m('No such user.'), 404);
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->serverError(_m('User has no profile.'));
     }
     $page = $this->trimmed('page');
     if (!empty($page) && Validate::number($page)) {
         $this->page = $page + 0;
     } else {
         $this->page = 1;
     }
     $this->notices = empty($this->tag) ? $this->user->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1) : $this->user->getTaggedNotices($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
     return true;
 }
 /**
  * Handle input, produce output
  *
  * Switches based on GET or POST method. On GET, shows a form
  * for posting a notice. On POST, saves the results of that form.
  *
  * Results may be a full page, or just a single notice list item,
  * depending on whether AJAX was requested.
  *
  * @param array $args $_REQUEST contents
  *
  * @return void
  */
 function handle($args)
 {
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             // check for this before token since all POST and FILES data
             // is losts when size is exceeded
             if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) {
                 // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
                 // TRANS: %s is the number of bytes of the CONTENT_LENGTH.
                 $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
                 $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
             }
             parent::handle($args);
             $user = common_current_user();
             $group = User_group::staticGet('id', $this->trimmed('groupid'));
             $taskid = $this->trimmed('taskid');
             try {
                 $this->saveNewNotice();
                 Task::completeTask($user->id, $taskid);
             } catch (Exception $e) {
                 $this->ajaxErrorMsg($e->getMessage(), $taskid, $group);
                 return;
             }
         }
     }
 }
Exemple #16
0
 function handle($args)
 {
     parent::handle($args);
     $secret = common_config('facebook', 'secret');
     $sig = '';
     ksort($_POST);
     foreach ($_POST as $key => $val) {
         if (substr($key, 0, 7) == 'fb_sig_') {
             $sig .= substr($key, 7) . '=' . $val;
         }
     }
     $sig .= $secret;
     $verify = md5($sig);
     if ($verify == $this->arg('fb_sig')) {
         $flink = Foreign_link::getByForeignID($this->arg('fb_sig_user'), 2);
         common_debug("Removing foreign link to Facebook - local user ID: {$flink->user_id}, Facebook ID: {$flink->foreign_id}");
         $result = $flink->delete();
         if (!$result) {
             common_log_db_error($flink, 'DELETE', __FILE__);
             $this->serverError(_m('Couldn\'t remove Facebook user.'));
             return;
         }
     } else {
         # Someone bad tried to remove facebook link?
         common_log(LOG_ERR, "Someone from {$_SERVER['REMOTE_ADDR']} " . 'unsuccessfully tried to remove a foreign link to Facebook!');
     }
 }
Exemple #17
0
 /**
  * Handle the request
  *
  * Grab the file from the 'media' param, then store, and shorten
  *
  * @todo Upload throttle!
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     // Workaround for PHP returning empty $_POST and $_FILES when POST
     // length > post_max_size in php.ini
     if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
         // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
         // TRANS: %s is the number of bytes of the CONTENT_LENGTH.
         $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
         $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
         return;
     }
     $upload = null;
     try {
         $upload = MediaFile::fromUpload('media', $this->auth_user);
     } catch (Exception $e) {
         $this->clientError($e->getMessage(), $e->getCode());
         return;
     }
     if (isset($upload)) {
         $this->showResponse($upload);
     } else {
         $this->clientError(_('Upload failed.'));
         return;
     }
 }
 function showTagsDropdown()
 {
     $tag = $this->trimmed('tag');
     $tags = $this->getAllTags();
     $content = array();
     foreach ($tags as $t) {
         $content[$t] = $t;
     }
     if ($tags) {
         $this->elementStart('dl', array('id' => 'filter_tags'));
         $this->element('dt', null, _('Tags'));
         $this->elementStart('dd');
         $this->elementStart('ul');
         $this->elementStart('li', array('id' => 'filter_tags_all', 'class' => 'child_1'));
         $this->element('a', array('href' => common_local_url($this->trimmed('action'), array('nickname' => $this->target->getNickname()))), _m('TAGS', 'All'));
         $this->elementEnd('li');
         $this->elementStart('li', array('id' => 'filter_tags_item'));
         $this->elementStart('form', array('name' => 'bytag', 'id' => 'form_filter_bytag', 'action' => common_path('?action=' . $this->getActionName()), 'method' => 'post'));
         $this->elementStart('fieldset');
         // TRANS: Fieldset legend on gallery action page.
         $this->element('legend', null, _('Select tag to filter'));
         // TRANS: Dropdown field label on gallery action page for a list containing tags.
         $this->dropdown('tag', _('Tag'), $content, _('Choose a tag to narrow list.'), false, $tag);
         $this->hidden('nickname', $this->target->getNickname());
         // TRANS: Submit button text on gallery action page.
         $this->submit('submit', _m('BUTTON', 'Go'));
         $this->elementEnd('fieldset');
         $this->elementEnd('form');
         $this->elementEnd('li');
         $this->elementEnd('ul');
         $this->elementEnd('dd');
         $this->elementEnd('dl');
     }
 }
 function __construct()
 {
     parent::__construct();
     // check if is moderator and can enter to this page
     if ($this->isModerator()) {
         if (!in_array($this->page, osc_apply_filter('moderator_access', array('items', 'comments', 'media', 'login', 'admins', 'ajax', 'stats', '')))) {
             osc_add_flash_error_message(_m("You don't have enough permissions"), 'admin');
             $this->redirectTo(osc_admin_base_url());
         }
     }
     osc_run_hook('init_admin');
     $config_version = str_replace('.', '', OSCLASS_VERSION);
     $config_version = preg_replace('|-.*|', '', $config_version);
     if ($config_version > osc_get_preference('version')) {
         if (get_class($this) == 'CAdminTools') {
         } else {
             if (get_class($this) != 'CAdminUpgrade') {
                 $this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
             }
         }
     }
     // show donation successful
     if (Params::getParam('donation') == 'successful') {
         osc_add_flash_ok_message(_m('Thank you very much for your donation'), 'admin');
     }
     // enqueue scripts
     osc_enqueue_script('jquery');
     osc_enqueue_script('jquery-ui');
     osc_enqueue_script('admin-osc');
     osc_enqueue_script('admin-ui-osc');
 }
 function handlePost()
 {
     $source = $this->arg('source');
     $target = $this->arg('target');
     header('Content-Type: text/plain; charset=utf-8');
     if (!$source) {
         echo _m('"source" is missing') . "\n";
         throw new ServerException(_m('"source" is missing'), 400);
     }
     if (!$target) {
         echo _m('"target" is missing') . "\n";
         throw new ServerException(_m('"target" is missing'), 400);
     }
     $response = linkback_get_source($source, $target);
     if (!$response) {
         echo _m('Source does not link to target.') . "\n";
         throw new ServerException(_m('Source does not link to target.'), 400);
     }
     $notice = linkback_get_target($target);
     if (!$notice) {
         echo _m('Target not found') . "\n";
         throw new ServerException(_m('Target not found'), 404);
     }
     $url = linkback_save($source, $target, $response, $notice);
     if (!$url) {
         echo _m('An error occured while saving.') . "\n";
         throw new ServerException(_m('An error occured while saving.'), 500);
     }
     echo $url . "\n";
     return true;
 }
 protected function doPost()
 {
     try {
         $request = Subscription_queue::pkeyGet(array('subscriber' => $this->scoped->id, 'subscribed' => $this->target->id));
         if ($request instanceof Subscription_queue) {
             $request->abort();
         }
     } catch (AlreadyFulfilledException $e) {
         common_debug('Tried to cancel a non-existing pending subscription');
     }
     if (GNUsocial::isAjax()) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title after unsubscribing from a group.
         $this->element('title', null, _m('TITLE', 'Unsubscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $subscribe = new SubscribeForm($this, $this->target);
         $subscribe->show();
         $this->elementEnd('body');
         $this->endHTML();
         exit;
     }
     common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->getNickname())), 303);
 }
 /**
  * Instead of showing notices, link to the original offsite profile.
  */
 function showNotices()
 {
     $url = $this->profile->profileurl;
     $host = parse_url($url, PHP_URL_HOST);
     $markdown = sprintf(_m('This remote profile is registered on another site; see [%1$s\'s original profile page on %2$s](%3$s).'), $this->profile->nickname, $host, $url);
     $html = common_markup_to_html($markdown);
     $this->raw($html);
     if ($this->profile->hasRole(Profile_role::SILENCED)) {
         // TRANS: Message on blocked remote profile page.
         $markdown = _m('Site moderators have silenced this profile, which prevents delivery of new messages to any users on this site.');
         $this->raw(common_markup_to_html($markdown));
     } else {
         $pnl = null;
         if (Event::handle('ShowStreamNoticeList', array($this->notice, $this, &$pnl))) {
             $pnl = new ProfileNoticeList($this->notice, $this);
         }
         $cnt = $pnl->show();
         if (0 == $cnt) {
             $this->showEmptyListMessage();
         }
         $args = array('id' => $this->profile->id);
         if (!empty($this->tag)) {
             $args['tag'] = $this->tag;
         }
         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'remoteprofile', $args);
     }
 }
 /**
  * Handle the arguments. In our case, show a service document.
  *
  * @param Array $args unused.
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     header('Content-Type: application/atomsvc+xml');
     $this->startXML();
     $this->elementStart('service', array('xmlns' => 'http://www.w3.org/2007/app', 'xmlns:atom' => 'http://www.w3.org/2005/Atom', 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/'));
     $this->elementStart('workspace');
     // TRANS: Title for Atom feed.
     $this->element('atom:title', null, _m('ATOM', 'Main'));
     $this->elementStart('collection', array('href' => common_local_url('ApiTimelineUser', array('id' => $this->user->id, 'format' => 'atom'))));
     $this->element('atom:title', null, sprintf(_("%s timeline"), $this->user->nickname));
     $this->element('accept', null, 'application/atom+xml;type=entry');
     $this->element('activity:verb', null, ActivityVerb::POST);
     $this->elementEnd('collection');
     $this->elementStart('collection', array('href' => common_local_url('AtomPubSubscriptionFeed', array('subscriber' => $this->user->id))));
     $this->element('atom:title', null, sprintf(_("%s subscriptions"), $this->user->nickname));
     $this->element('accept', null, 'application/atom+xml;type=entry');
     $this->element('activity:verb', null, ActivityVerb::FOLLOW);
     $this->elementEnd('collection');
     $this->elementStart('collection', array('href' => common_local_url('AtomPubFavoriteFeed', array('profile' => $this->user->id))));
     $this->element('atom:title', null, sprintf(_("%s favorites"), $this->user->nickname));
     $this->element('accept', null, 'application/atom+xml;type=entry');
     $this->element('activity:verb', null, ActivityVerb::FAVORITE);
     $this->elementEnd('collection');
     $this->elementStart('collection', array('href' => common_local_url('AtomPubMembershipFeed', array('profile' => $this->user->id))));
     $this->element('atom:title', null, sprintf(_("%s memberships"), $this->user->nickname));
     $this->element('accept', null, 'application/atom+xml;type=entry');
     $this->element('activity:verb', null, ActivityVerb::JOIN);
     $this->elementEnd('collection');
     $this->elementEnd('workspace');
     $this->elementEnd('service');
     $this->endXML();
 }
 function handle($args)
 {
     // Trigger short error responses; not a human-readable web page.
     StatusNet::setApi(true);
     // We're not a general oEmbed proxy service; limit to valid sessions.
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_m('There was a problem with your session token. ' . 'Try again, please.'));
     }
     $format = $this->arg('format');
     if ($format && $format != 'json') {
         // TRANS: Client exception thrown when requesting a different format than JSON.
         throw new ClientException(_m('Invalid format; only JSON supported.'));
     }
     $url = $this->arg('url');
     if (!common_valid_http_url($url)) {
         // TRANS: Client exception thrown when not providing a valid URL.
         throw new ClientException(_m('Invalid URL.'));
     }
     $params = array();
     if ($this->arg('maxwidth')) {
         $params['maxwidth'] = $this->arg('maxwidth');
     }
     if ($this->arg('maxheight')) {
         $params['maxheight'] = $this->arg('maxheight');
     }
     $data = oEmbedHelper::getObject($url, $params);
     $this->init_document('json');
     print json_encode($data);
 }
 function notifyBackupFile($user, $fileName)
 {
     $fileUrl = File::url($fileName);
     $body = sprintf(_m("The backup file you requested is ready for download.\n\n" . "%s\n" . "Thanks for your time,\n", "%s\n"), $fileUrl, common_config('site', 'name'));
     $headers = _mail_prepare_headers('offlinebackup', $user->nickname, $user->nickname);
     mail_to_user($user, _('Backup file ready for download'), $body, $headers);
 }
Exemple #26
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'delete':
             $ids = Params::getParam("id");
             if ($ids != '') {
                 foreach ($ids as $id) {
                     osc_deleteResource($id);
                 }
                 $this->resourcesManager->delete(array(DB_CUSTOM_COND => 'pk_i_id IN (' . implode(', ', $ids) . ')'));
             }
             osc_add_flash_message(_m('Resource deleted'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . "?page=media");
             break;
         default:
             $resourceId = Params::getParam("id");
             if ($resourceId != '') {
                 $resources = $this->resourcesManager->getAllResources($resourceId);
             } else {
                 $resources = $this->resourcesManager->getAllResources(NULL);
             }
             //calling the view...
             $this->_exportVariableToView("resources", $resources);
             $this->_exportVariableToView("resourceId", $resourceId);
             $this->doView('media/index.php');
     }
 }
/**
 * Get the bookmarks file as a string
 *
 * Uses the -f or --file parameter to open and read a
 * a bookmarks file
 *
 * @return string Contents of the file
 */
function getBookmarksFile()
{
    $filename = get_option_value('f', 'file');
    if (empty($filename)) {
        show_help();
        exit(1);
    }
    if (!file_exists($filename)) {
        // TRANS: Exception thrown when a file upload cannot be found.
        // TRANS: %s is the file that could not be found.
        throw new Exception(sprintf(_m('No such file "%s".'), $filename));
    }
    if (!is_file($filename)) {
        // TRANS: Exception thrown when a file upload is incorrect.
        // TRANS: %s is the irregular file.
        throw new Exception(sprintf(_m('Not a regular file: "%s".'), $filename));
    }
    if (!is_readable($filename)) {
        // TRANS: Exception thrown when a file upload is not readable.
        // TRANS: %s is the file that could not be read.
        throw new Exception(sprintf(_m('File "%s" not readable.'), $filename));
    }
    // TRANS: %s is the filename that contains a backup for a user.
    printfv(_m('Getting backup from file "%s".') . "\n", $filename);
    $html = file_get_contents($filename);
    return $html;
}
Exemple #28
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add_post':
             if (Params::getParam('field_name') != '') {
                 $field = $this->fieldManager->findByName(Params::getParam('field_name'));
                 if (!isset($field['pk_i_id'])) {
                     $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower(Params::getParam("field_slug"))));
                     $this->fieldManager->insertField(Params::getParam("field_name"), Params::getParam("field_type_new"), $slug, Params::getParam("field_required") == "1" ? 1 : 0, Params::getParam('field_options'), Params::getParam('categories'));
                     osc_add_flash_ok_message(_m("New custom field added"), "admin");
                 } else {
                     osc_add_flash_error_message(_m("Sorry, you already have one field with that name"), "admin");
                 }
             } else {
                 osc_add_flash_error_message(_m("Name can not be empty"), "admin");
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=cfields");
             break;
         default:
             $categories = Category::newInstance()->toTreeAll();
             $selected = array();
             foreach ($categories as $c) {
                 $selected[] = $c['pk_i_id'];
                 foreach ($c['categories'] as $cc) {
                     $selected[] = $cc['pk_i_id'];
                 }
             }
             $this->_exportVariableToView("categories", $categories);
             $this->_exportVariableToView("default_selected", $selected);
             $this->_exportVariableToView("fields", $this->fieldManager->listAll());
             $this->doView("fields/index.php");
     }
 }
Exemple #29
0
 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->trimmed('action'), $args), 301);
         return false;
     }
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         $this->clientError(_m('No such user.'), 404);
         return false;
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         $this->serverError(_m('User has no profile.'));
         return false;
     }
     $page = $this->trimmed('page');
     if (!empty($page) && Validate::number($page)) {
         $this->page = $page + 0;
     } else {
         $this->page = 1;
     }
     $this->notices = empty($this->tag) ? $this->user->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1) : $this->user->getTaggedNotices($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
     return true;
 }
 static function saveNew($profile_id, $album_id, $thumb_uri, $uri, $source, $insert_now, $title = null, $photo_description = null)
 {
     $photo = new GNUsocialPhoto();
     $photo->thumb_uri = $thumb_uri;
     $photo->uri = $uri;
     $photo->album_id = $album_id;
     if (!empty($title)) {
         $photo->title = $title;
     }
     if (!empty($photo_description)) {
         $photo->photo_description = (string) $photo_description;
     }
     if ($insert_now) {
         $notice = Notice::saveNew($profile_id, $uri, $source);
         $photo->notice_id = $notice->id;
         $photo_id = $photo->insert();
         if (!$photo_id) {
             common_log_db_error($photo, 'INSERT', __FILE__);
             throw new ServerException(_m('Problem Saving Photo.'));
         }
     } else {
         GNUsocialPhotoTemp::$tmp = $photo;
         Notice::saveNew($profile_id, $uri, $source);
     }
 }