Example #1
0
 /**
  * (non-PHPdoc)
  * @see IfwPsn_Wp_Plugin_Bootstrap_Abstract::bootstrap()
  */
 public function bootstrap()
 {
     $featureLoader = new Psn_Feature_Loader($this->_pm);
     $featureLoader->load();
     if ($this->_pm->getAccess()->isAdmin()) {
         // on admin access
         // add plugin menu links
         IfwPsn_Wp_Proxy_Filter::addPluginActionLinks($this->_pm, array($this, 'addPluginActionLinks'));
         // set installer / uninstaller
         require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Installer/Activation.php';
         require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Installer/Uninstall.php';
         $this->getInstaller()->addActivation(new Psn_Installer_Activation());
         $this->getInstaller()->addUninstall(new Psn_Installer_Uninstall());
         // load options handler
         require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Admin/Options/Handler.php';
         $optionsHandler = new Psn_Admin_Options_Handler($this->_pm);
         $optionsHandler->load();
     }
     if ($this->_pm->getAccess()->isPlugin()) {
         // register patches
         require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Patch/Database.php';
         $this->getUpdateManager()->getPatcher()->addPatch(new Psn_Patch_Database());
         // register selftests
         IfwPsn_Wp_Proxy_Action::addPlugin($this->_pm, 'selftester_activate', array($this, 'addSelftests'));
     }
     require_once $this->_pm->getPathinfo()->getRootLib() . '/Psn/Notification/Manager.php';
     $this->_notificationManager = new Psn_Notification_Manager($this->_pm);
     $this->_notificationManager->setDeferredExecution();
     //IfwPsn_Wp_Proxy_Action::addInit(array($this, 'test'));
 }
Example #2
0
 protected function _init()
 {
     if (IfwPsn_Wp_Proxy_Screen::isLoadedCurrentScreen()) {
         $this->_pm->getLogger()->error('Screen option must be initialized before page load.');
     }
     $this->_type = $this->getType();
     IfwPsn_Wp_Proxy_Filter::addSetScreenOption(array($this, 'setScreenOptionCallback'), 10, 3);
     IfwPsn_Wp_Proxy_Action::addCurrentScreen(array($this, 'registerOption'));
 }
Example #3
0
 public function init()
 {
     if ($this->_pm->getConfig()->plugin->autoupdate == 1) {
         $updateApi = IfwPsn_Wp_Plugin_Update_Api_Factory::get($this->_pm);
         // check for custom update message
         IfwPsn_Wp_Proxy_Action::add('in_plugin_update_message-' . $this->_pm->getPathinfo()->getFilenamePath(), array($updateApi, 'getUpdateInlineMessage'), 10, 3);
         IfwPsn_Wp_Proxy_Filter::add('pre_set_site_transient_update_plugins', array($updateApi, 'getUpdateData'));
         if ($this->_pm->isPremium()) {
             // check for premium get update info
             IfwPsn_Wp_Proxy_Filter::add('plugins_api', array($updateApi, 'getPluginInformation'), 10, 3);
         }
     }
     $this->_pm->getBootstrap()->getOptionsManager()->registerExternalOption('present_version');
 }
Example #4
0
 /**
  * @return void
  */
 public function init()
 {
     $this->setMethod('post')->setName('psn_test_mail')->setAttrib('accept-charset', 'utf-8');
     $this->setAttrib('class', 'ifw-wp-zend-form-ul');
     $this->setDecorators(array('FormElements', 'Form'));
     $this->_fieldDecorators = array(new IfwPsn_Zend_Form_Decorator_SimpleInput(), array('HtmlTag', array('tag' => 'li')), 'Errors', 'Description');
     $recipients = IfwPsn_Wp_Proxy_Filter::apply('psn_testmail_form_recipients_options', array('admin' => __('Blog admin', 'psn')));
     $recipient = $this->createElement('select', 'recipient');
     $recipient->setLabel(__('Recipient', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array('StringTrim', 'StripTags'))->addMultiOptions($recipients)->setOrder(40);
     $this->addElement($recipient);
     $this->setNonce('psn-form-test-mail');
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => __('Send test email', 'psn'), 'class' => 'button-primary', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'li'))), 'order' => 120));
 }
Example #5
0
 /**
  * @param array $options
  */
 protected function _init(array $options)
 {
     $this->initShortcode();
     // add default filters
     IfwPsn_Wp_Proxy_Filter::addWidgetText('do_shortcode');
     IfwPsn_Wp_Proxy_Filter::addTheExcerpt('do_shortcode');
     IfwPsn_Wp_Proxy_Filter::addTheExcerptFeed('do_shortcode');
     IfwPsn_Wp_Proxy_Filter::addTheExcerptRss('do_shortcode');
     IfwPsn_Wp_Proxy_Filter::addTheContentFeed('do_shortcode');
     IfwPsn_Wp_Proxy_Filter::addTheContentRss('do_shortcode');
     // add additional custom filters
     if (isset($options['filters']) && is_array($options['filters'])) {
         foreach ($options['filters'] as $filter) {
             IfwPsn_Wp_Proxy_Filter::add($filter, 'do_shortcode');
         }
     }
 }
Example #6
0
 /**
  *
  */
 public function sendTestMailAction()
 {
     if (!$this->_verifyNonce('psn-form-test-mail')) {
         $this->getAdminNotices()->persistError(__('Invalid access.', 'psn'));
         $this->_gotoIndex();
     }
     $this->_email = new IfwPsn_Wp_Email();
     $subject = sprintf(__('Test Email from %s', 'psn'), $this->_pm->getEnv()->getName());
     $body = IfwPsn_Wp_Proxy_Filter::apply('psn_send_test_mail_body', sprintf(__('This is a test email generated by %s on %s (%s)', 'psn'), $this->_pm->getEnv()->getName(), IfwPsn_Wp_Proxy_Blog::getName(), IfwPsn_Wp_Proxy_Blog::getUrl()), $this->_email);
     switch (trim($this->_request->get('recipient'))) {
         case 'custom':
             $recipient = esc_attr($_POST['custom_recipient']);
             break;
         case 'admin':
         default:
             $recipient = IfwPsn_Wp_Proxy_Blog::getAdminEmail();
             break;
     }
     $recipient = IfwPsn_Wp_Proxy_Filter::apply('psn_send_test_mail_recipient', $recipient);
     if (empty($recipient)) {
         $resultMsg = __('Invalid recipient.', 'psn') . ' ' . __('Test email could not be sent.', 'psn');
         $this->getAdminNotices()->persistError($resultMsg);
     } else {
         $this->_email->setTo($recipient)->setSubject($subject)->setMessage($body);
         IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail', $this->_email);
         if ($this->_email->send()) {
             // mail sent successfully
             $resultMsg = __('Test email has been sent successfully.', 'psn');
             $this->getAdminNotices()->persistUpdated($resultMsg);
             IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail_success', $this);
         } else {
             // email could not be sent
             $resultMsg = __('Test email could not be sent.', 'psn');
             $this->getAdminNotices()->persistError($resultMsg);
             IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail_failure', $this);
         }
         IfwPsn_Wp_Proxy_Action::doAction('psn_after_test_email_send', $this->_email);
     }
     $this->_gotoIndex();
 }
Example #7
0
 /** (non-PHPdoc)
  * @see IfwPsn_Wp_Plugin_Installer_UninstallInterface::execute()
  */
 public static function execute($pm, $networkwide = false)
 {
     // handle the DB
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             self::_dropTable($pm);
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         self::_dropTable($pm);
     }
     // remove update action
     if ($pm->getConfig()->plugin->autoupdate == 1) {
         IfwPsn_Wp_Proxy_Action::remove('in_plugin_update_message-' . $pm->getPathinfo()->getFilenamePath(), array($pm->getBootstrap()->getUpdateManager(), 'onPluginUpdateMessage'), 10, 3);
         IfwPsn_Wp_Proxy_Filter::remove('pre_set_site_transient_update_plugins', array($pm->getBootstrap()->getUpdateManager(), 'checkForPremiumUpdate'));
         if ($pm->isPremium()) {
             IfwPsn_Wp_Proxy_Filter::remove('plugins_api', array($pm->getBootstrap()->getUpdateManager(), 'getPluginInfo'), 10, 3);
         }
     }
 }
Example #8
0
 public static function getMax()
 {
     // please respect my work for this plugin and buy the premium version
     // at http://codecanyon.net/item/post-status-notifier/4809420?ref=ifeelweb
     // otherwise I can not continue updating this plugin with new features
     return IfwPsn_Wp_Proxy_Filter::apply('psn_max_rules', 2);
 }
Example #9
0
 /**
  * @return bool
  */
 public function isPremium()
 {
     return IfwPsn_Wp_Proxy_Filter::apply($this->getAbbrLower() . '_is_premium', false);
 }
Example #10
0
 /**
  * @param $statusAfter
  * @param $statusBefore
  * @param $post
  */
 public function handlePostStatusTransition($statusAfter, $statusBefore, $post)
 {
     /**
      * Block
      * check for block setting
      */
     if ($this->isBlockNotifications($post->ID)) {
         // skip if option to block notifications is set
         return;
     }
     /**
      * Postponed
      * check if post should be postponed
      */
     if ($this->_postponedHandler instanceof Psn_Notification_Postponed && $this->_postponedHandler->applies()) {
         $this->_postponedHandler->add($statusAfter, $statusBefore, $post);
         return;
     }
     $this->_pm->getErrorHandler()->enableErrorReporting();
     $this->_statusBefore = $statusBefore;
     $this->_statusAfter = $statusAfter;
     // get all active rules
     $activeRules = IfwPsn_Wp_ORM_Model::factory('Psn_Model_Rule')->filter('active')->find_many();
     if (Psn_Model_Rule::hasMax()) {
         $activeRules = array_slice($activeRules, 0, Psn_Model_Rule::getMax());
     }
     if ($this->isDeferredExecution()) {
         $deferredHandler = new Psn_Notification_Deferred_Handler();
     }
     /**
      * @var $rule Psn_Model_Rule
      */
     foreach ($activeRules as $rule) {
         if ($this->_pm->hasOption('psn_ignore_status_inherit')) {
             $rule->setIgnoreInherit(true);
         }
         // to skip a rulematch return false
         $doMatch = IfwPsn_Wp_Proxy_Filter::apply('psn_do_match', true, array('rule' => $rule, 'post' => $post, 'status_before' => $statusBefore, 'status_after' => $statusAfter));
         if (!is_bool($doMatch)) {
             // for safety:
             $doMatch = true;
         }
         if ($doMatch && $rule->matches($post, $statusBefore, $statusAfter)) {
             // rule matches
             /**
              * Execute all registered notification services
              *
              * @var $service Psn_Notification_Service_Interface
              */
             foreach ($this->getServices() as $service) {
                 if ($this->isDeferredExecution()) {
                     // prepare for deferred execution
                     $deferredContainer = new Psn_Notification_Deferred_Container();
                     $deferredContainer->setService($service)->setRule($rule)->setPost($post);
                     $deferredHandler->addCotainer($deferredContainer);
                 } else {
                     // execute directly
                     // set the replacer
                     $rule->setReplacer(Psn_Notification_Placeholders::getInstance($post));
                     $service->execute($rule, $post);
                 }
             }
         }
     }
     $this->_pm->getErrorHandler()->disableErrorReporting();
 }
Example #11
0
 /**
  * Initializes commonly used properties
  */
 protected function _initFormView()
 {
     require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Patch/Database.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Admin/Form/NotificationRule.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Notification/Placeholders.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Menu/Help.php';
     $dbPatcher = new Psn_Patch_Database();
     $this->view->dbPatcher = $dbPatcher;
     if (!$this->_pm->isPremium()) {
         IfwPsn_Wp_Proxy_Filter::add('psn_rule_form_description_cc', create_function('$var', 'return $var . " " .
             __("Limited to 1. Get the Premium version for unlimited Cc emails.", "psn");'));
         IfwPsn_Wp_Proxy_Filter::add('psn_rule_form_description_bcc', create_function('$var', 'return $var . " " .
             __("(Premium feature)", "psn");'));
     }
     $formOptions = array();
     if ($this->_pm->getOptionsManager()->getOption('psn_hide_nonpublic_posttypes') != null) {
         $formOptions['hide_nonpublic_posttypes'] = true;
     }
     $this->_form = new Psn_Admin_Form_NotificationRule($formOptions);
     if (!$this->_pm->isPremium()) {
         $this->_form->getElement('recipient')->setDescription(__('Get additional recipients like user roles (including custom roles) or all users with the Premium version.', 'psn'));
     }
     $this->_helper->viewRenderer('form');
     $placeholders = new Psn_Notification_Placeholders();
     $help = new IfwPsn_Wp_Plugin_Menu_Help($this->_pm);
     $help->setTitle(__('Placeholders', 'psn'))->setId('placeholders')->setHelp($placeholders->getOnScreenHelp())->setSidebar($this->_getHelpSidebar())->load();
     $help = new IfwPsn_Wp_Plugin_Menu_Help($this->_pm);
     $help->setTitle(__('Conditions', 'psn'))->setId('conditions')->setHelp(IfwPsn_Wp_Tpl::getFilesytemInstance($this->_pm)->render('admin_help_conditions.html.twig', array('pm' => $this->_pm)))->setSidebar($this->_getHelpSidebar())->load();
     $this->view->langListOfPlaceholdersLabel = __('Show list of placeholders available for subject and text', 'psn');
     $this->view->langListOfPlaceholdersLink = __('List of placeholders', 'psn');
     $this->view->langHelp = __('Help', 'ifw');
     if (Psn_Model_Rule::hasMax() && Psn_Model_Rule::reachedMax() && $this->getRequest()->getActionName() == 'create') {
         $this->view->maxReached = __(sprintf('You reached the maximum number of rules (%s) for the free version. Get the <a href="%s" target="_blank">Premium Version</a> for unlimmited rules and more features.', Psn_Model_Rule::getMax(), $this->_pm->getConfig()->plugin->premiumUrl), 'psn');
     }
     if ($this->_request->getActionName() == 'create') {
         $this->view->langHeadline = __('Create new rule', 'psn');
         IfwPsn_Wp_Proxy_Script::loadAdmin('psn_rule_examples', $this->_pm->getEnv()->getUrlAdminJs() . 'rule_examples.js', array(), $this->_pm->getEnv()->getVersion());
         IfwPsn_Wp_Proxy_Script::localize('psn_rule_examples', 'PsnExampleRule', array('ThePendingPost' => __('The pending post', 'psn'), 'ThePendingPostSubject' => __('[blog_name]: New post is waiting for review', 'psn'), 'ThePendingPostBody' => str_replace('<br>', "\n", __('Howdy admin,<br>there is a new post by [author_display_name] waiting for review:<br>"[post_title]".<br><br>Here is the permalink: [post_permalink]<br><br>Here is the backend edit link: [post_editlink]<br><br>The author\'s email address is [author_email]<br><br>[blog_wpurl]', 'psn')), 'TheHappyAuthor' => __('The happy author', 'psn'), 'TheHappyAuthorSubject' => __('Your post on [blog_name] got published!', 'psn'), 'TheHappyAuthorBody' => str_replace('<br>', "\n", __('Howdy [author_display_name],<br>we are happy to tell you that your post "[post_title]" got published.<br><br>Here is the permalink: [post_permalink]<br><br>Thanks for your good work,<br>your [blog_name]-Team<br><br>[blog_wpurl]', 'psn')), 'ThePedanticAdmin' => __('The pedantic admin', 'psn'), 'ThePedanticAdminSubject' => __('[blog_name]: Post status transition from [post_status_before] to [post_status_after]', 'psn'), 'ThePedanticAdminBody' => str_replace('<br>', "\n", __('Howdy admin,<br>a post status transition was a detected on "[post_title]".<br><br>Status before: [post_status_before]<br>Status after: [post_status_after]<br><br>Post permalink: [post_permalink]', 'psn'))));
         IfwPsn_Wp_Proxy_Style::loadAdmin('psn_rule_examples', $this->_pm->getEnv()->getUrlAdminCss() . 'rule_examples.css');
         $this->view->langExamples = __('Examples', 'psn');
         $this->view->langExamplesDesc = __('Click the buttons below to get an idea of how you can set up notification rules.', 'psn');
         $this->view->langExamplesRuleThePendingPost = __('The pending post', 'psn');
         $this->view->langExamplesRuleThePendingPostDesc = __('This rule sends a notification when a new post got submitted for review.', 'psn');
         $this->view->langExamplesRuleTheHappyAuthor = __('The happy author', 'psn');
         $this->view->langExamplesRuleTheHappyAuthorDesc = __('This rule sends an email to the author of a post when it got published.', 'psn');
         $this->view->langExamplesRuleThePedanticAdmin = __('The pedantic admin', 'psn');
         $this->view->langExamplesRuleThePedanticAdminDesc = __('This rule is for blog admins who want to be informed about every single post status change.', 'psn');
         $this->view->langExamplesRuleDebug = __('Debug rule', 'psn');
         $this->view->langExamplesRuleDebugDesc = __('This rule is just for creating log entries to monitor all available values when the rule matched. Remember to activate option Logger / Log rule matches.', 'psn') . ' ' . sprintf('<a href="%s" target="_blank">' . __('More details', 'psn') . '</a>', $this->_pm->getConfig()->plugin->docUrl . 'rules.html#debug-rule');
     } else {
         $this->view->langHeadline = __('Edit notification rule', 'psn');
         $this->_form->getElement('submit')->setLabel(__('Update', 'psn'));
         $this->_form->getElement('submit_and_stay')->setLabel(__('Update and stay on page', 'psn'));
     }
     $this->view->actionName = $this->_request->getActionName();
     IfwPsn_Wp_Proxy_Script::loadAdmin('psn_rule_form', $this->_pm->getEnv()->getUrlAdminJs() . 'rule_form.js', array(), $this->_pm->getEnv()->getVersion());
     IfwPsn_Wp_Proxy_Script::localize('psn_rule_form', 'psn', array('is_premium' => $this->_pm->isPremium()));
     IfwPsn_Wp_Proxy_Script::localize('psn_rule_form', 'psn_taxonomies', array_merge(IfwPsn_Wp_Proxy_Post::getAllTypesCategories(), array('lang_Categories' => __('Categories', 'psn'), 'lang_categories_help' => sprintf(__('To select multiple categories hold down the control button (ctrl) on Windows or command button (cmd) on Mac.<br>If nothing is selected, all categories get included.<br>Exclude is dominant. See the <a href="%s" target="_blank">docs</a> for more details.', 'psn'), 'http://docs.ifeelweb.de/post-status-notifier/rules.html#category-filter'), 'lang_include_categories' => __('Include only these categories', 'psn'), 'lang_exclude_categories' => __('Exclude categories', 'psn'), 'lang_select_all' => __('select all', 'psn'), 'lang_remove_all' => __('remove all', 'psn'), 'lang_no_categories' => __('Post type "%s" has no categories.', 'psn'), 'lang_premium_feature' => sprintf(__('This is a <a href="%s" target="_blank">Premium</a> feature.', 'psn'), $this->_pm->getConfig()->plugin->premiumUrl))));
     IfwPsn_Wp_Proxy_Action::doAction('psn_rule_form', $this->_form);
 }
Example #12
0
 /**
  * Alias for get_option
  *
  * @param $option
  * @param bool $default
  * @return mixed|void
  */
 public static function getOption($option, $default = false)
 {
     $filterTag = $option;
     return IfwPsn_Wp_Proxy_Filter::apply($filterTag, get_option($option, $default));
 }
Example #13
0
 /**
  * @param $placeholder
  * @return mixed|void
  */
 protected function _lazyGetValue($placeholder)
 {
     return IfwPsn_Wp_Proxy_Filter::apply($this->_lazyFilterPrefix . $placeholder, '', $placeholder, $this);
 }
Example #14
0
 /**
  * @return array
  */
 protected function _getBloginfo()
 {
     $result = array();
     $whitelist = IfwPsn_Wp_Proxy_Filter::apply('psn_notification_placeholders_bloginfo_whitelist', array('name', 'description', 'wpurl', 'url', 'admin_email', 'version'));
     foreach ($whitelist as $v) {
         $result['blog_' . $v] = get_bloginfo($v);
     }
     //$result['blog_admin_display_name'] = IfwPsn_Wp_Proxy_User::getAdminDisplayName();
     return $result;
 }
Example #15
0
 /**
  * @param $to
  * @param $subject
  * @param $message
  * @param $headers
  * @param $attachments
  * @return bool
  */
 protected function _processEmail($to, $subject, $message, $headers, $attachments)
 {
     $result = true;
     $emailParams = array('to' => $to, 'subject' => $subject, 'message' => $message, 'headers' => $headers, 'attachments' => $attachments);
     // pass the email params to the filter which can decide if the sending process should be executed directly
     $process = IfwPsn_Wp_Proxy_Filter::apply('ifwpsn_callback_email_process', true, $emailParams, $this);
     if ($process) {
         IfwPsn_Wp_Proxy_Action::doAction('ifwpsn_callback_before_email_send', $emailParams, $this);
         $result = IfwPsn_Wp_Proxy::mail($to, $subject, $message, $headers, $attachments);
         IfwPsn_Wp_Proxy_Action::doAction('ifwpsn_callback_after_email_send', $result, $emailParams, $this);
     }
     return $result;
 }
Example #16
0
 /**
  * @return string
  */
 public function getName()
 {
     return IfwPsn_Wp_Proxy_Filter::apply($this->_pathinfo->getDirname() . '_plugin_name', $this->_name);
 }
Example #17
0
 /**
  * @return mixed|void
  */
 protected function _getLicenseCode()
 {
     return IfwPsn_Wp_Proxy_Filter::apply('envato_license_code', $this->_pm->getOptionsManager()->getOption('license_code'));
 }
Example #18
0
 /**
  * @return array
  */
 protected function _getColumns()
 {
     return IfwPsn_Wp_Proxy_Filter::apply($this->_pm->getAbbrLower() . '_' . $this->_id . '_get_columns', $this->getColumns());
 }
Example #19
0
 /**
  * @return void
  */
 public function init()
 {
     $this->setMethod('post')->setName('psn_form_rule')->setAttrib('accept-charset', 'utf-8');
     $this->setAttrib('class', 'ifw-wp-zend-form-ul');
     $this->setDecorators(array('FormElements', 'Form'));
     $this->_fieldDecorators = array(new IfwPsn_Zend_Form_Decorator_SimpleInput(), array('HtmlTag', array('tag' => 'li')), 'Errors', 'Description');
     $this->addElement('text', 'name', array('label' => __('Rule name', 'psn'), 'description' => __('Name of the rule', 'psn'), 'required' => true, 'filters' => array(new IfwPsn_Zend_Filter_SanitizeTextField()), 'maxlength' => 80, 'validators' => $_GET['appaction'] == 'create' ? array(new Psn_Admin_Form_Validate_Max()) : array(), 'decorators' => $this->getFieldDecorators(), 'order' => 10));
     $postTypeOptions = array();
     if ($this->isHideNonPublicPostTypes()) {
         $postTypeOptions['public'] = true;
     }
     /**
      * Post Type
      */
     $postType = $this->createElement('select', 'posttype');
     $postTypeOptions = array_merge(array('all' => __('all types', 'psn')), IfwPsn_Wp_Proxy_Post::getAllTypesWithLabels($postTypeOptions));
     unset($postTypeOptions['attachment']);
     unset($postTypeOptions['nav_menu_item']);
     $postType->setLabel(__('Post type', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array(new IfwPsn_Zend_Filter_SanitizeTextField()))->addMultiOptions($postTypeOptions)->setOrder(20);
     $this->addElement($postType);
     /**
      * Post status
      */
     $statusValues = array_merge(array('new' => __('New', 'ifw'), 'not_published' => __('Not published', 'psn'), 'not_private' => __('Not private', 'psn'), 'not_pending' => __('Not pending', 'psn'), 'not_trash' => __('Not trash', 'psn')), IfwPsn_Wp_Proxy_Post::getAllStatusesWithLabels(array('show_domain' => true)));
     natcasesort($statusValues);
     $statusValues = array_merge(array('anything' => __('anything', 'psn')), $statusValues);
     /**
      * Status before
      */
     $statusBefore = $this->createElement('select', 'status_before');
     $statusBefore->setLabel(__('Status before', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array(new IfwPsn_Zend_Filter_SanitizeTextField()))->addMultiOptions($statusValues)->setOrder(30);
     $this->addElement($statusBefore);
     /**
      * Status after
      */
     $statusAfter = $this->createElement('select', 'status_after');
     $statusAfter->setLabel(__('Status after', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array(new IfwPsn_Zend_Filter_SanitizeTextField()))->addMultiOptions($statusValues)->setOrder(40);
     $this->addElement($statusAfter);
     /**
      * Subject
      */
     $this->addElement('text', 'notification_subject', array('label' => __('Subject', 'psn'), 'description' => sprintf(__('Open the help menu in the upper right corner to see a list of all <a %s>supported placeholders</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"') . ' ' . sprintf(__('Supports <a %s>conditions</a> (if activated in the options).', 'psn'), 'href="javascript:void(0)" class="conditions_help"'), 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'maxlength' => 200, 'decorators' => $this->getFieldDecorators(), 'order' => 50));
     $this->getElement('notification_subject')->getDecorator('Description')->setEscape(false);
     /**
      * Body
      */
     $this->addElement('textarea', 'notification_body', array('label' => __('Text', 'psn'), 'description' => sprintf(__('Open the help menu in the upper right corner to see a list of all <a %s>supported placeholders</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"') . ' ' . sprintf(__('Supports <a %s>conditions</a> (if activated in the options).', 'psn'), 'href="javascript:void(0)" class="conditions_help"'), 'validators' => array(new Psn_Admin_Form_Validate_MailBody()), 'required' => false, 'filters' => array('StringTrim', 'HtmlEntities'), 'cols' => 80, 'rows' => 10, 'allowempty' => false, 'decorators' => $this->getFieldDecorators(), 'order' => 60));
     $this->getElement('notification_body')->getDecorator('Description')->setEscape(false);
     /**
      * Recipients
      */
     $recipients = IfwPsn_Wp_Proxy_Filter::apply('psn_rule_form_recipients_options', array('admin' => __('Blog admin', 'psn'), 'author' => __('Post author', 'psn')));
     /**
      * TO
      */
     $recipient = $this->createElement('multiselect', 'recipient');
     $recipient->setLabel(__('Recipient', 'psn'))->setDescription(__('To select multiple recipients hold down the control button (ctrl) on Windows or command button (cmd) on Mac.', 'psn'))->setRequired(false)->setValidators(array(new Psn_Admin_Form_Validate_ToEmail()))->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setDecorators($this->getFieldDecorators())->setFilters(array('StringTrim', 'StripTags'))->setAttrib('size', 10)->addMultiOptions($recipients)->setOrder(70);
     $this->addElement($recipient);
     /**
      * CC
      */
     $cc_select = $this->createElement('multiselect', 'cc_select');
     $cc_select->setLabel(__('CC', 'psn'))->setDescription(__('To select multiple cc recipients hold down the control button (ctrl) on Windows or command button (cmd) on Mac.', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array('StringTrim', 'StripTags'))->setAttrib('size', 10)->addMultiOptions($recipients)->setOrder(80);
     $this->addElement($cc_select);
     $this->addElement('textarea', 'cc', array('label' => __('Custom CC', 'psn'), 'description' => IfwPsn_Wp_Proxy_Filter::apply('psn_rule_form_description_cc', sprintf(__('Add additional recipient emails. Comma separated. Supports placeholders like [author_email], [blog_admin_email], [current_user_email] or the dynamic [recipient_*] placeholders. Check the <a %s>placeholders help</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"')), 'filters' => array('StringTrim', 'HtmlEntities', new Psn_Admin_Form_Filter_Cc(IfwPsn_Wp_Plugin_Manager::getInstance('Psn')->isPremium())), 'cols' => 80, 'rows' => 1, 'decorators' => $this->getFieldDecorators(), 'order' => 85));
     $this->getElement('cc')->getDecorator('Description')->setEscape(false);
     /**
      * BCC
      */
     $bcc_select = $this->createElement('multiselect', 'bcc_select');
     $bcc_select->setLabel(__('BCC', 'psn'))->setDescription(__('To select multiple bcc recipients hold down the control button (ctrl) on Windows or command button (cmd) on Mac.', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array('StringTrim', 'StripTags'))->setAttrib('size', 10)->addMultiOptions($recipients)->setOrder(90);
     $this->addElement($bcc_select);
     $this->addElement('textarea', 'bcc', array('label' => __('Custom BCC', 'psn'), 'description' => IfwPsn_Wp_Proxy_Filter::apply('psn_rule_form_description_bcc', sprintf(__('Add bcc recipient emails. Comma separated. Supports placeholders like [author_email], [blog_admin_email], [current_user_email] or the dynamic [recipient_*] placeholders. Check the <a %s>placeholders help</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"')), 'escape' => false, 'filters' => array('StringTrim', 'HtmlEntities', new Psn_Admin_Form_Filter_Bcc(IfwPsn_Wp_Plugin_Manager::getInstance('Psn')->isPremium())), 'cols' => 80, 'rows' => 1, 'decorators' => $this->getFieldDecorators(), 'order' => 95));
     $this->getElement('bcc')->getDecorator('Description')->setEscape(false);
     /**
      * Active
      */
     $active = $this->createElement('checkbox', 'active');
     $active->setLabel(__('Active', 'psn'))->setDecorators($this->getFieldDecorators())->setDescription(__('Only active rules take affect on post transition changes', 'psn'))->setChecked(true)->setCheckedValue(1)->setOrder(100);
     $this->addElement($active);
     /**
      * Service email
      */
     $email = $this->createElement('checkbox', 'service_email');
     $email->setLabel(__('Email', 'psn'))->setDecorators($this->getFieldDecorators())->setDescription(__('When the rule matches, an email will be send to the recipient with subject and text', 'psn'))->setChecked(true)->setCheckedValue(1)->setOrder(110);
     $this->addElement($email);
     if (isset($_REQUEST['id'])) {
         $this->addElement('hidden', 'id', array('value' => $_REQUEST['id'], 'decorators' => array('ViewHelper')));
     }
     $this->setNonce('psn-form-rule');
     $this->addElement('note', 'p', array('label' => '-', 'value' => '&nbsp;', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'p'))), 'order' => 999));
     /**
      * Submit button
      */
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => __('Save', 'psn'), 'class' => 'button-primary', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'span'))), 'order' => 1000));
     $this->addElement('note', 'divider', array('label' => '-', 'value' => '&nbsp;&mdash;&nbsp;', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'span'))), 'order' => 1001));
     $this->addElement('submit', 'submit_and_stay', array('ignore' => true, 'label' => __('Save and stay on page', 'psn'), 'class' => 'button', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'span'))), 'order' => 1002));
 }
Example #20
0
 /**
  * @return array
  */
 public function get_bulk_actions()
 {
     $actions = array();
     if (!$this->isMetaboxEmbedded()) {
         $actions = array('bulk_delete' => __('Delete'), 'activate' => __('Activate', 'psn'), 'deactivate' => __('Deactivate', 'psn'));
         $actions = IfwPsn_Wp_Proxy_Filter::apply('psn_rules_bulk_actions', $actions);
     }
     return $actions;
 }
Example #21
0
 /**
  * @param Psn_Model_Rule $rule
  * @return mixed|void
  */
 protected function _getPreparedSubject(Psn_Model_Rule $rule)
 {
     $subject = $rule->getNotificationSubject();
     /**
      * Final subject filter
      * @param string the email subject
      */
     return IfwPsn_Wp_Proxy_Filter::apply('psn_service_email_subject', $subject, $this);
 }
Example #22
0
 /**
  * @return bool
  */
 public function isValid()
 {
     $ruleFields = array('id', 'name', 'posttype', 'status_before', 'status_after', 'notification_subject', 'notification_body', 'recipient', 'cc', 'cc_select', 'bcc', 'bcc_select', 'active', 'service_email', 'service_log', 'categories', 'from');
     $diff = array_diff(IfwPsn_Wp_Proxy_Filter::apply('psn_db_patcher_rule_fields', $ruleFields), IfwPsn_Wp_Proxy_Db::getTableFieldNames('psn_rules'));
     return empty($diff);
 }