public static function sendNotification($fromMember, $toMember, $diaryId)
 {
     $url = '/diary/' . $diaryId;
     sfApplicationConfiguration::getActive()->loadHelpers(array('I18N'));
     $message = format_number_choice('[1]1 diary has new comments|(1,Inf]%1% diaries have new comments', array('%1%' => '1'), 1);
     opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'other', 'url' => $url, 'icon_url' => null));
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->checkPluginExists($arguments['plugin']);
     $this->pluginDir = sfApplicationConfiguration::getActive()->getPluginConfiguration($arguments['plugin'])->getRootDir();
     $this->interactive = !$options['non-interactive'];
     $cleanup = array();
     if (!file_exists($this->pluginDir . '/package.xml')) {
         $cleanup['temp_files'] = array();
         foreach (sfFinder::type('dir')->in($this->pluginDir) as $dir) {
             if (!sfFinder::type('any')->maxdepth(0)->in($dir)) {
                 $this->getFilesystem()->touch($file = $dir . '/.sf');
                 $cleanup['temp_files'][] = $file;
             }
         }
         $cleanup['package_file'] = true;
         $this->generatePackageFile($arguments, $options);
     }
     $cwd = getcwd();
     chdir($this->pluginDir);
     $this->getPluginManager()->configure();
     require_once 'PEAR/Packager.php';
     $packager = new PEAR_Packager();
     $package = $packager->package($this->pluginDir . '/package.xml', !$options['nocompress']);
     chdir($cwd);
     if (PEAR::isError($package)) {
         if (isset($cleanup['package_file'])) {
             $cleanup['package_file'] = '.error';
         }
         $this->cleanup($cleanup);
         throw new sfCommandException($package->getMessage());
     }
     $this->cleanup($cleanup);
 }
Ejemplo n.º 3
0
 public function Header()
 {
     $appConf = sfApplicationConfiguration::getActive();
     if (method_exists($appConf, 'configGet')) {
         $pdfLogo = $appConf->configGet('app_pdf_logo');
     } else {
         $pdfLogo = sfConfig::get('app_pdf_logo');
     }
     $logos = array("af" => sfConfig::get("app_appFlower_logo"), "partner" => $pdfLogo);
     if (!$logos["af"] || !file_exists($logos["af"]["file"])) {
         $logos["af"]["file"] = sfConfig::get("sf_root_dir") . "/plugins/appFlowerPlugin/web/images/logo.png";
     }
     $ps = $this->orientation == "P" ? 210 : 297;
     $this->Image($logos["af"]["file"], 10, 5, 0, 0, '', $logos["af"]["url"]);
     $p1 = getimagesize($logos["af"]["file"]);
     if ($logos["partner"]) {
         if (!file_exists($logos["partner"]["file"])) {
             $logos["partner"]["file"] = sfConfig::get("sf_root_dir") . "/web" . $logos["partner"]["file"];
         }
         if (file_exists($logos["partner"]["file"]) && is_file($logos["partner"]["file"])) {
             $p2 = getimagesize($logos["partner"]["file"]);
             $this->Image($logos["partner"]["file"], $ps - $this->getMMValue($p2[0]) - 10, 5, 0, 0, '', $logos["partner"]["url"]);
         } else {
             $p2 = array(0, 0);
         }
     } else {
         $p2 = array(0, 0);
     }
     $mh = max(array($p1[1], $p2[1]));
     $this->setY($mh / 72 * 25.4 + 5);
     $this->SetFont('Arial', 'B', 10);
     $this->Cell(0, 10, ucwords($this->widget["title"]) . " Widget", "B", 1, "L");
     $this->Ln(5);
 }
Ejemplo n.º 4
0
 private function AddComment(sfWebRequest $request)
 {
     $text = $request->getParameter('comment_text');
     if ($request->isMethod("GET")) {
         $text = urldecode($text);
     }
     if ($this->getRequestParameter('comment_picture_url')) {
         $filename = jrFileUploader::UploadRemote($request->getParameter('comment_picture_url'));
         if ($text) {
             $text .= "<br/>";
         }
         $text .= "<img src='http://" . $request->getHost() . "/uploads/" . $filename . "' />";
     }
     if (!trim($text)) {
         return;
     }
     sfApplicationConfiguration::getActive()->loadHelpers(array('Parse', 'Text', 'Tag', 'I18N', 'Url'));
     $user = $this->getUser()->getGuardUser();
     $comment = new PostComment();
     $comment->setUser($user);
     $comment->setPost($this->post);
     if ($this->parent) {
         $comment->setParent($this->parent);
     }
     $comment->setComment(parsetext($text));
     $comment->setCommentOriginal($text);
     $comment->save();
     $this->curUser = $this->getUser()->getGuardUser();
     if ($this->curUser) {
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId(), $this->post->getAllComments('count'), time() + 24 * 60 * 60);
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
     }
 }
 public function executeIndex()
 {
     $response = $this->getResponse();
     $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/shortcuts.js'));
     $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalAdminPlugin/js/shortcuts.js'));
     if (sfSympalConfig::get('check_for_upgrades_on_dashboard', null, false)) {
         $this->upgrade = new sfSympalUpgradeFromWeb($this->getContext()->getConfiguration(), $this->getContext()->getEventDispatcher(), new sfFormatter());
         $this->hasNewVersion = $this->upgrade->hasNewVersion();
     } else {
         $this->hasNewVersion = false;
     }
     $this->dashboardRight = new sfSympalMenu('Sympal Dashboard Right');
     $numUsers = Doctrine_Core::getTable('sfGuardUser')->count();
     $this->dashboardRight->addChild(sprintf('<label>Users</label> %s', $numUsers), '@sympal_users');
     $numSites = Doctrine_Core::getTable('sfSympalSite')->count();
     $this->dashboardRight->addChild(sprintf('<label>Sites</label> %s', $numSites), '@sympal_sites');
     $numContentTypes = Doctrine_Core::getTable('sfSympalContentType')->count();
     $this->dashboardRight->addChild(sprintf('<label>Content Types</label> %s', $numContentTypes), '@sympal_content_types');
     $contentTypes = Doctrine::getTable('sfSympalContentType')->getAllContentTypes();
     foreach ($contentTypes as $contentType) {
         $numPublishedContent = Doctrine_Core::getTable('sfSympalContent')->createQuery('c')->where('c.date_published < NOW()')->andWhere('c.content_type_id = ?', $contentType->getId())->count();
         $this->dashboardRight->addChild(sprintf('<label>Published %s Content</label> %s', $contentType->getLabel(), $numPublishedContent), '@sympal_content_list_type?type=' . $contentType->getId() . '&published=1');
         $numUnPublishedContent = Doctrine_Core::getTable('sfSympalContent')->createQuery('c')->where('c.date_published >= NOW() OR c.date_published IS NULL')->andWhere('c.content_type_id = ?', $contentType->getId())->count();
         $this->dashboardRight->addChild(sprintf('<label>Un-Published %s Content</label> %s', $contentType->getLabel(), $numUnPublishedContent), '@sympal_content_list_type?type=' . $contentType->getId() . '&published=0');
     }
     sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($this->dashboardRight, 'sympal.load_dashboard_right'));
 }
Ejemplo n.º 6
0
function get_sympal_admin_menu_object($class = 'sfSympalMenuAdminMenu')
{
    static $menu;
    if (!$menu) {
        $sympalContext = sfSympalContext::getInstance();
        $menu = new $class('Sympal Admin', '@sympal_dashboard');
        if ($sympalContext->isAdminModule()) {
            $menu->addChild(sprintf('Go to %s', $sympalContext->getSite()->getTitle()), '@homepage', 'id=sympal_go_to_switch');
        } else {
            if (sfContext::getInstance()->getUser()->hasCredential('ViewDashboard')) {
                $menu->addChild('Go to Admin', '@sympal_dashboard', 'id=sympal_go_to_switch');
            }
        }
        if (sfContext::getInstance()->getUser()->hasCredential('ClearCache')) {
            $menu->addChild('Clear Cache', '@sympal_clear_cache', 'id=sympal_clear_cache_fancybox');
        }
        $menu->addChild('Content', '@sympal_content_types_index', array('label' => 'Site Content'));
        $menu->addChild('Site Administration', '@sympal_sites_edit?id=' . $sympalContext->getSite()->getId(), array('label' => 'Site Setup'));
        $menu->addChild('Security', '@sympal_users', array('label' => 'Users & Security'));
        $menu->addChild('Administration', '@sympal_sites', array('label' => 'Global Setup'));
        sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_admin_menu'));
        $sympalContext = sfSympalContext::getInstance();
        $contentRecord = $sympalContext->getCurrentContent();
        $menuItem = $sympalContext->getCurrentMenuItem();
        if ($contentRecord) {
            sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_editor', array('content' => $contentRecord, 'menuItem' => $menuItem)));
        }
    }
    return $menu;
}
 protected function execute($arguments = array(), $options = array())
 {
     $pluginDir = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfTwigPlugin')->getRootDir();
     $helperDir = sfApplicationConfiguration::getActive()->getSymfonyLibDir() . '/helper/';
     $command = sprintf('cd %s; ./helpers.sh %s', $pluginDir, $helperDir);
     exec($command, $output);
     echo implode(PHP_EOL, $output), "\n";
 }
 public static function sendNewCommentNotification($fromMember, $toMember, $topicId)
 {
     $rootPath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot();
     $url = $rootPath . '/communityTopic/' . $topicId;
     sfApplicationConfiguration::getActive()->loadHelpers(array('I18N'));
     $message = format_number_choice('[1]1 topic has new comments|(1,Inf]%1% topics have new comments', array('%1%' => '1'), 1);
     opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'other', 'url' => $url, 'icon_url' => null));
 }
Ejemplo n.º 9
0
 /**
  * Checks if a plugin exists.
  * 
  * The plugin directory must exist and have at least one file or folder
  * inside for that plugin to exist.
  * 
  * @param   string  $plugin
  * @param   boolean $boolean Whether to throw exception if plugin exists (false) or doesn't (true)
  * 
  * @throws  sfException If the plugin does not exist
  */
 public static function checkPluginExists($plugin, $boolean = true)
 {
     try {
         sfApplicationConfiguration::getActive()->getPluginConfiguration($plugin);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 10
0
 /**
  * Checks if a plugin exists.
  *
  * The plugin directory must exist and have at least one file or folder
  * inside for that plugin to exist.
  *
  * @param   string  $plugin
  *
  * @return  boolean True if the plugin exist, false otherwise
  */
 protected function checkPluginExists($plugin)
 {
     try {
         sfApplicationConfiguration::getActive()->getPluginConfiguration($plugin);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 11
0
 public function save()
 {
     $array = $this->_buildArrayToWrite();
     $this->_path = sfConfig::get('sf_app_dir') . '/config/app.yml';
     file_put_contents($this->_path, sfYaml::dump($array, 4));
     chdir(sfConfig::get('sf_root_dir'));
     $task = new sfCacheClearTask(sfApplicationConfiguration::getActive()->getEventDispatcher(), new sfFormatter());
     $task->run(array(), array('type' => 'config'));
 }
Ejemplo n.º 12
0
 /**
  * Perform the check to determine if we are in edit mode or not
  *
  * @return void
  */
 public function doIsEditModeCheck()
 {
     $content = sfSympalContext::getInstance()->getCurrentContent();
     if ($content && $content->getPubliclyEditable() || $content && $content->getAllEditPermissions() && $this->hasCredential($content->getAllEditPermissions()) || $this->isAuthenticated() && $this->hasCredential('ManageContent')) {
         $this->_isEditMode = true;
     } else {
         $this->_isEditMode = false;
     }
     $this->_isEditMode = sfApplicationConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_is_edit_mode'), $this->_isEditMode)->getReturnValue();
 }
Ejemplo n.º 13
0
 public function preExecute()
 {
     parent::preExecute();
     if ($this->getUser()->hasAttribute('api_log')) {
         $dispatcher = sfApplicationConfiguration::getActive()->getEventDispatcher();
         $string = $this->getUser()->getAttribute('api_log');
         $dispatcher->notify(new sfEvent('Api', 'application.log', array('priority' => sfLogger::WARNING, $string)));
         $this->getUser()->getAttributeHolder()->remove('api_log');
     }
 }
 /**
  * Builds and returns an array with the widget and validator to use with
  * any choice field for a theme
  *
  * @return array $widgetAndValidator
  */
 public function getThemeWidgetAndValidator()
 {
     $themes = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeManager()->getAvailableThemes();
     $options = array('' => '');
     foreach ($themes as $name => $theme) {
         $options[$name] = sfInflector::humanize($name);
     }
     $widget = new sfWidgetFormChoice(array('choices' => $options));
     $validator = new sfValidatorChoice(array('choices' => array_keys($options), 'required' => false));
     return array('widget' => $widget, 'validator' => $validator);
 }
 protected function init()
 {
     sfApplicationConfiguration::getActive()->loadHelpers(array('Url'));
     $header1 = new ListHeader();
     $header1->populateFromArray(array('name' => 'Report Name', 'width' => '400', 'isSortable' => true, 'sortField' => 'name', 'elementType' => 'label', 'elementProperty' => array('getter' => 'getName')));
     $header2 = new ListHeader();
     $header2->populateFromArray(array('name' => '', 'width' => '95', 'isSortable' => false, 'elementType' => 'link', 'textAlignmentStyle' => 'left', 'elementProperty' => array('label' => __('Run'), 'placeholderGetters' => array('id' => 'getReportId'), 'urlPattern' => url_for('core/displayPredefinedReport') . '?reportId={id}')));
     $header3 = new ListHeader();
     $header3->populateFromArray(array('name' => '', 'width' => '95', 'isSortable' => false, 'elementType' => 'link', 'textAlignmentStyle' => 'left', 'elementProperty' => array('label' => __('Edit'), 'placeholderGetters' => array('id' => 'getReportId'), 'urlPattern' => url_for('core/definePredefinedReport') . '?reportId={id}')));
     $this->headers = array($header1, $header2, $header3);
 }
/**
 * Renders the inline edit menu, which consists of buttons such as the
 * assets and links buttons
 * 
 * @return string
 */
function get_sympal_inline_edit_bar_buttons()
{
    $sympalContext = sfSympalContext::getInstance();
    $content = $sympalContext->getCurrentContent();
    $menuItem = $sympalContext->getCurrentMenuItem();
    $menu = new sfSympalMenuInlineEditBarButtons('Inline Edit Bar Buttons');
    $menu->setUlClass('sympal_inline_edit_bar_buttons');
    if ($content->getEditableSlotsExistOnPage()) {
        $menu->addChild('Links', '@sympal_editor_links')->isEditModeButton(true)->setShortcut('Ctrl+Shift+L')->setInputClass('toggle_sympal_links')->setCredentials('InsertLinks');
    }
    sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_inline_edit_bar_buttons', array('content' => $content, 'menuItem' => $menuItem)));
    return $menu->render();
}
 public function configure()
 {
     sfApplicationConfiguration::getActive()->loadHelpers('I18N');
     unset($this['collectIcqStatus'], $this['user_id'], $this['validate'], $this['created_at'], $this['updated_at'], $this['rating'], $this['isNew']);
     $this->setWidget('ljpassword', new sfWidgetFormInputPassword(array('always_render_empty' => false)));
     $this->setWidget('avatar', new sfWidgetFormInputFileEditable(array('file_src' => $this->getObject()->getAvatar(), 'is_image' => true, 'edit_mode' => $this->getObject()->getAvatar(), 'with_delete' => $this->getObject()->getAvatar(), 'template' => '<div>%file%<br />%input%<br />%delete% %delete_label%</div>', 'delete_label' => __('Удалить аватар'))));
     $this->validatorSchema['avatar'] = new sfValidatorFile(array('path' => sfConfig::get('sf_upload_dir'), 'validated_file_class' => 'sfResizedFile', 'mime_types' => 'web_images', 'required' => false));
     $this->widgetSchema->setLabels(array('email' => 'Адрес E-Mail:', 'fullname' => 'Имя и фамилия:', 'icq' => 'Номер ICQ:', 'jabber' => 'Jabber/GoogleTalk:', 'commentsToJabber' => 'Отправлять уведомления в Jabber:', 'commentsToIcq' => 'Отправлять уведомления в ICQ:', 'commentsToMail' => 'Отправлять уведомления по почте:', 'useCrossposting' => 'Использовать кросспостинг в ЖЖ:', 'collectJabberStatus' => 'Собирать jabber-статусы', 'notifyFriendline' => 'Уведомлять о новых постах друзей', 'ljlogin' => 'Живой Журнал:', 'ljpassword' => 'Пароль от ЖЖ:', 'avatar' => 'Аватар:', 'about' => 'О себе:'));
     $this->validatorSchema->setOption('allow_extra_fields', true);
     $this->validatorSchema->setOption('filter_extra_fields', false);
     $this->widgetSchema->setFormFormatterName('list');
     $this->widgetSchema->setNameFormat('sfApplySettings[%s]');
 }
Ejemplo n.º 18
0
 public function executeUser(sfWebRequest $request)
 {
     sfApplicationConfiguration::getActive()->loadHelpers(array('I18N', 'Parse'));
     $this->user = sfGuardUser::getUserByUsername($request->getParameter('username'));
     $this->forward404Unless($this->user);
     if ($request->getParameter('id')) {
         $this->blog = Doctrine::getTable('Blog')->find(array($request->getParameter('id')));
     } else {
         $this->blog = Blog::getByTag($request->getParameter('name'));
     }
     $this->forward404Unless($this->blog);
     $this->getResponse()->setTitle($this->blog->getName() . " / " . $this->user->getUsername() . " / " . __("JoyReactor – твое хорошее настроние. Картинки, приколы, видео, демотиваторы."));
 }
 /**
  * Calls provider's OAuth request token service 
  * and returns whatever it gets from it
  * 
  * @param String $provider
  * @return Array
  */
 public static function getRequestToken($provider)
 {
     sfApplicationConfiguration::getActive()->loadHelpers(array('Url'));
     $config = sfConfig::get('app_cacophony');
     $oauth = self::getInstance($provider);
     try {
         return $oauth->getRequestToken($config['providers'][$provider]['request_token_url'], sfContext::getInstance()->getRouting()->hasRouteName('sf_cacophony_callback') ? url_for(sprintf('@sf_cacophony_callback?provider=%s', $provider), true) : 'oob');
     } catch (OAuthException $e) {
         if (sfConfig::get('sf_logging_enabled')) {
             sfContext::getInstance()->getLogger()->err($e->lastResponse);
         }
         return false;
     }
 }
  public function __construct($comment = null, array $options = null)
  {
    sfApplicationConfiguration::getActive()->loadHelpers(array('Tag', 'Date', 'Partial'));

    $this->_comment = $comment;
    if (null !== $options)
    {
      $this->_rootListType = $options['root']['list-type'];
      $this->_rootListClass = $options['root']['list-class'];
      $this->_childListType = $options['child']['list-type'];
      $this->_childListClass = $options['child']['list-class'];
      $this->_itemListClass = $options['item']['list-class'];
    }
  }
Ejemplo n.º 21
0
 public function setup()
 {
     parent::setup();
     // site slug is used to generate symfony app
     // but symfony restricts allowed characters for app name
     if ($this->isNew()) {
         $this->setValidator('slug', new sfValidatorAnd(array($this->getValidator('slug'), new sfValidatorRegex(array('pattern' => '/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/'), array('invalid' => 'Site slug must consist of only letters, digits and underscores. ' . 'It also must not start with digit.'))), array('required' => $this->getValidator('slug')->getOption('required'))));
     } else {
         $this->getWidget('slug')->setAttribute('readonly', 'readonly');
         $this->setValidator('slug', new sfValidatorChoice(array('choices' => array($this->getObject()->getSlug()))));
     }
     $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator();
     $this->widgetSchema['theme'] = $field['widget'];
     $this->validatorSchema['theme'] = $field['validator'];
 }
Ejemplo n.º 22
0
 public function postInsert($event)
 {
     sfApplicationConfiguration::getActive()->loadHelpers('Partial');
     $this->Post->setRating($this->Post->getRating() + $this->getPower());
     $this->Post->User->getProfile()->setRating($this->Post->User->getProfile()->getRating() + $this->getPower());
     $this->Post->User->save();
     if ($this->getPower() > 0) {
         $this->Post->save();
     } else {
         $uptime = $this->Post->getUpdatedAt();
         $this->Post->save();
         $this->Post->setUpdatedAt($uptime);
         $this->Post->save();
     }
 }
Ejemplo n.º 23
0
 public function executeMainPageTrigger(sfWebRequest $request)
 {
     sfApplicationConfiguration::getActive()->loadHelpers(array('Partial'));
     $this->filename = 'error';
     $post = Doctrine::getTable('Post')->find(array($this->getRequestParameter('post_id')));
     $admin = sfGuardUser::getAdminUser();
     if ($admin && $admin->getProfile()->getUsecrossposting() && urldecode($this->getRequestParameter('login')) == $admin->getProfile()->getLjlogin() && urldecode($this->getRequestParameter('pass')) == $admin->getProfile()->getLjpassword() && $post != null) {
         if (!$post->getLj() && $post->getRating() >= sfConfig::get('app_post_mainpage_threshold')) {
             func::crossposting($admin->getProfile()->getLjlogin(), $admin->getProfile()->getLjpassword(), get_partial('post/post_lj', array('post' => $post, 'showUsername' => 1)), $post->getMoodNameI18N(), $post->getMoodSmile());
             $post->setLj(1);
             $post->save();
             $this->filename = 'ok';
         }
     }
     return $this->renderPartial('upload', array('filename' => $this->filename));
 }
Ejemplo n.º 24
0
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $default_buttons = array('add_file' => 'Add files...', 'upload' => 'Start upload', 'cancel' => 'Cancel upload');
     $buttons = $this->getOption('buttons') + $default_buttons;
     $module_partial = $this->getOption('module_partial');
     if ($module_partial) {
         sfApplicationConfiguration::getActive()->loadHelpers('Partial');
         include_partial($module_partial, array('widget' => $this, 'name' => $name, 'value' => $value, 'attributes' => $attributes, 'errors' => $errors, 'buttons' => $buttons));
     } else {
         $context = sfContext::getInstance();
         $view = new sfPartialView($context, '', '', '');
         $plugin_path = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . 'laWidgetFileUploadPlugin';
         $view->setTemplate($plugin_path . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . '_upload_widget.php');
         $view->setPartialVars(array('widget' => $this, 'buttons' => $buttons));
         echo $view->render();
     }
 }
Ejemplo n.º 25
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeCreate(sfWebRequest $request)
 {
     sfApplicationConfiguration::getActive()->loadHelpers(array('I18N', 'Url'));
     if (!$this->getUser()->isAuthenticated() && $request->getParameter('noajax')) {
         return $this->forward("sfGuardAuth", "signin");
     }
     $this->post = Doctrine::getTable('Post')->find(array($request->getParameter('post_id')));
     $this->vote = $request->getParameter('vote');
     $this->user = $this->getUser()->getGuardUser();
     if ($this->getUser()->isAuthenticated() && $this->post->getUserId() != $this->user->getId() && $this->post && ($this->vote == 'plus' || $this->vote == 'minus') && !$this->post->isUserVoted($this->user)) {
         $this->post->addVote($this->user, $this->vote);
     }
     if ($request->getParameter('noajax')) {
         return $this->redirect(url_for('post/show?id=' . $this->post->getId()));
     } else {
         return $this->renderPartial('post_vote/link_content', array('post' => $this->post));
     }
 }
 public function setup()
 {
     parent::setup();
     sfApplicationConfiguration::getActive()->loadHelpers('I18N');
     $this->setWidgets(array());
     $this->setValidators(array());
     $this->setWidget('file', new sfWidgetFormInputFile());
     $this->setValidator('file', new sfValidatorFile(array('mime_types' => 'web_images')));
     if (sfConfig::get('app_sfTinyMceImageBrowserPlugin_allow_resize', true)) {
         $this->setWidget('width', new sfWidgetFormInput());
         $this->setValidator('width', new sfValidatorInteger(array('required' => false)));
         $this->setWidget('height', new sfWidgetFormInput());
         $this->setValidator('height', new sfValidatorInteger(array('required' => false)));
     }
     $this->setWidget('submit', new sfWidgetFormInput(array('type' => 'submit', 'label' => false), array('class' => 'submit-button', 'value' => __('Save changes'))));
     $this->setValidator('submit', new sfValidatorPass());
     $this->widgetSchema->setNameFormat('sf_tiny_mce_image[%s]');
 }
 /**
  * Get OAuth 2.0 access token
  * 
  * @param string $code
  */
 public static function getAccessToken($code)
 {
     $config = sfConfig::get('app_cacophony');
     sfApplicationConfiguration::getActive()->loadHelpers(array('Url'));
     $query_params = isset($config['providers']['instagram']['access_token_params']) ? $config['providers']['instagram']['access_token_params'] : array();
     $query_params = array_merge($query_params, array('client_id' => $config['providers']['instagram']['consumer_key'], 'redirect_uri' => sfContext::getInstance()->getRouting()->hasRouteName('sf_cacophony_callback') ? url_for('@sf_cacophony_callback?provider=instagram', true) : 'oob', 'client_secret' => $config['providers']['instagram']['consumer_secret'], 'code' => $code));
     // CURL
     $curl = curl_init($config['providers']['instagram']['access_token_url']);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($query_params));
     $response = curl_exec($curl);
     curl_close($curl);
     $params = json_decode($response, true);
     if (isset($params['code']) && 200 != $params['code']) {
         throw new Exception(sprintf('%s: %s', $params['error_type'], $params['error_message']));
     }
     return $params;
 }
 /**
  * Get OAuth 2.0 access token
  *
  * @param string $code
  * @throws Exception
  * @return array|null
  */
 public static function getAccessToken($code)
 {
     $config = sfConfig::get('app_cacophony');
     sfApplicationConfiguration::getActive()->loadHelpers(array('Url'));
     $query_params = array('client_id' => $config['providers']['facebook']['consumer_key'], 'redirect_uri' => sfContext::getInstance()->getRouting()->hasRouteName('sf_cacophony_callback') ? url_for('@sf_cacophony_callback?provider=facebook', true) : 'oob', 'client_secret' => $config['providers']['facebook']['consumer_secret'], 'code' => $code);
     $token_url = sprintf('%s?%s', $config['providers']['facebook']['access_token_url'], http_build_query($query_params));
     if (sfConfig::get('sf_environment') != 'test') {
         $response = self::fetch($token_url);
     } else {
         $response = sfCacophonyFacebookMock::getAccessToken($token_url);
     }
     $params = null;
     parse_str($response, $params);
     if (!is_array($params) || !count($params)) {
         throw new Exception('Unable to fetch access token');
     }
     $params['expires_at'] = date('c', time() + ($params['expires'] ?: 0));
     return $params;
 }
 public function setup()
 {
     parent::setup();
     $this->validatorSchema->setOption('allow_extra_fields', true);
     unset($this['site_id'], $this['created_at'], $this['updated_at'], $this['last_updated_by_id'], $this['slots_list'], $this['links_list'], $this['assets_list'], $this['comments_list']);
     $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator();
     $this->widgetSchema['theme'] = $field['widget'];
     $this->validatorSchema['theme'] = $field['validator'];
     // Sets up the template widget
     sfSympalFormToolkit::changeTemplateWidget($this);
     // Sets up the module widget
     sfSympalFormToolkit::changeModuleWidget($this);
     if (!$this->object->content_type_id) {
         $this->object->Type = Doctrine_Core::getTable('sfSympalContentType')->findOneBySlug('page');
     } else {
         $this->object->Type;
     }
     $this->configureMenuSection();
     $this->_embedTypeForm();
 }
 public function setup()
 {
     parent::setup();
     $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator();
     $this->widgetSchema['theme'] = $field['widget'];
     $this->validatorSchema['theme'] = $field['validator'];
     $this->widgetSchema['name']->setLabel('Model name');
     $models = Doctrine_Core::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine');
     // Sets up the template widget
     sfSympalFormToolkit::changeTemplateWidget($this);
     // Sets up the module widget
     sfSympalFormToolkit::changeModuleWidget($this);
     foreach ($models as $model) {
         $table = Doctrine_Core::getTable($model);
         if (!$table->hasTemplate('sfSympalContentTypeTemplate')) {
             unset($models[$model]);
         }
     }
     $models = array_merge(array('' => ''), $models);
     $this->widgetSchema['name'] = new sfWidgetFormChoice(array('choices' => $models));
 }