Пример #1
0
 /**
  * Loads the application
  */
 public function load()
 {
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_before_application_load', $this);
     $this->_pm->getLogger()->logPrefixed('Trying to load application...');
     $this->_adapter->load();
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_after_application_load', $this);
 }
Пример #2
0
 /**
  * 
  */
 public function indexAction()
 {
     add_thickbox();
     $this->_pm->getLogger()->logPrefixed('Executing ' . get_class($this) . ':indexAction()');
     $this->_pm->getBootstrap()->getSelftester()->performTests();
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Menu/Help.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/Container.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/PremiumAd.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/PluginInfo.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/PluginStatus.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Metabox/IfwFeed.php';
     require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Admin/Metabox/Rules.php';
     // set up contextual help
     $help = new IfwPsn_Wp_Plugin_Menu_Help($this->_pm);
     $help->setTitle(__('Overview', 'psn'))->setHelp($this->_getHelpText())->setSidebar($this->_getHelpSidebar())->load();
     // set up metaboxes
     $metaBoxContainerLeft = new IfwPsn_Wp_Plugin_Metabox_Container('column1', $this->_pageHook, 'left');
     IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_before_metabox_left', $metaBoxContainerLeft);
     $metaBoxContainerLeft->addMetabox(new Psn_Admin_Metabox_Rules($this->_pm));
     IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_after_metabox_left', $metaBoxContainerLeft);
     $metaBoxContainerRight = new IfwPsn_Wp_Plugin_Metabox_Container('column2', $this->_pageHook, 'right');
     IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_before_metabox_right', $metaBoxContainerRight);
     if ($this->_pm->hasPremium() && $this->_pm->isPremium() == false) {
         $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_PremiumAd($this->_pm));
     }
     $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_PluginInfo($this->_pm));
     $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_PluginStatus($this->_pm));
     $metaBoxContainerRight->addMetabox(new IfwPsn_Wp_Plugin_Metabox_IfwFeed($this->_pm));
     IfwPsn_Wp_Proxy_Action::doAction('psn_admin_overview_after_metabox_right', $metaBoxContainerRight);
     $this->view->metaBoxContainerLeft = $metaBoxContainerLeft;
     $this->view->metaBoxContainerRight = $metaBoxContainerRight;
 }
Пример #3
0
 public function activate()
 {
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_selftester_activate', $this);
     $this->_pm->getBootstrap()->getOptionsManager()->registerExternalOption($this->_timestampOptionName);
     $this->_pm->getBootstrap()->getOptionsManager()->registerExternalOption($this->_statusOptionName);
     if (!$this->_skipAutorun()) {
         $this->_initAutorun();
     }
 }
Пример #4
0
 /**
  * @param IfwPsn_Vendor_Zend_Form_Element|string $element
  * @param null $name
  * @param null $options
  * @return IfwPsn_Vendor_Zend_Form
  * @throws IfwPsn_Vendor_Zend_Form_Exception
  */
 public function addElement($element, $name = null, $options = null)
 {
     if ($element instanceof IfwPsn_Vendor_Zend_Form_Element) {
         $name = $element->getName();
     }
     IfwPsn_Wp_Proxy_Action::doAction($this->getName() . '_before_' . $name, $this);
     $result = parent::addElement($element, $name, $options);
     $decoratorHtml = $result->getElement($name)->getDecorator('HtmlTag');
     if ($decoratorHtml) {
         $decoratorHtml->setOption('id', 'form_element_' . $name);
     }
     IfwPsn_Wp_Proxy_Action::doAction($this->getName() . '_after_' . $name, $this);
     return $result;
 }
Пример #5
0
 /**
  * @param WP_Post $post
  */
 public function __construct($post = null)
 {
     if ($post === null) {
         $this->_post = $this->_getPostMockup();
     } else {
         // real post object with data
         $this->_post = $post;
     }
     $options = array('auto_delimiters' => true, 'lazy_filter_prefix' => 'psn_load_placeholder_value_');
     parent::__construct($this->_getNotificationPlaceholders(), $options);
     $this->_addDynamicPlaceholders();
     $this->_addArrayData();
     IfwPsn_Wp_Proxy_Action::doAction('psn_notification_placeholders_loaded', $this);
     if (!$this->isMockUpPost()) {
         $this->prepareTwigContext();
     }
 }
Пример #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();
 }
Пример #7
0
 /**
  * (non-PHPdoc)
  * @see IfwPsn_Vendor_Zend_Controller_Action::preDispatch()
  */
 public function preDispatch()
 {
     if ($this->_request->getActionName() == 'index') {
         $this->_listTable = $this->getListTable();
         if ($this->_listTable->hasValidBulkRequest()) {
             $action = $this->_listTable->getBulkAction();
             if ($action == 'bulk_delete' && is_array($this->_request->getPost($this->getSingular()))) {
                 // bulk action delete
                 $this->_bulkDelete($this->_request->getPost($this->getSingular()));
             } elseif ($action == 'bulk_export' && is_array($this->_request->getPost($this->getSingular())) && method_exists($this, '_bulkExport')) {
                 // bulk action export
                 $this->_bulkExport($this->_request->getPost($this->getSingular()));
             } else {
                 if (method_exists($this, 'handleBulkAction')) {
                     $this->handleBulkAction($action);
                 }
                 $actionFormat = '%s_%s_action-%s';
                 IfwPsn_Wp_Proxy_Action::doAction(sprintf($actionFormat, $this->getPluginAbbr(), $this->getPlural(), $action), $this);
             }
         }
     }
 }
Пример #8
0
 public function _load()
 {
     if ($this->_pm->getAccess()->isPlugin() || isset($_POST['option_page']) && $_POST['option_page'] == $this->_pageId) {
         // init the option objects only if it is a exact plugin admin page access or save request
         $generalOptions = new IfwPsn_Wp_Options_Section('general', __('General', 'ifw'));
         IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_general_options_init', $generalOptions);
         $this->addSection($generalOptions);
         $externalOptions = new IfwPsn_Wp_Options_Section('external', '');
         IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_external_options_init', $externalOptions);
         $this->addSection($externalOptions);
         do_action($this->_pm->getAbbrLower() . '_on_options_load');
     }
 }
Пример #9
0
 /**
  * load default services
  */
 protected function _loadServices()
 {
     require_once $this->_pm->getPathinfo()->getRootLib() . 'Psn/Notification/Service/Email.php';
     $this->addService(new Psn_Notification_Service_Email());
     IfwPsn_Wp_Proxy_Action::doAction('psn_after_load_services', $this);
 }
Пример #10
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);
 }
Пример #11
0
 /**
  * @param string $name
  * @param array $arguments
  */
 public function __call($name, $arguments)
 {
     $controller = $this->_request->get('controller');
     $controller = esc_attr($controller);
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_' . $controller . '_action-' . str_replace('Action', '', $name), $this, $arguments);
 }
Пример #12
0
 /**
  * @param IfwPsn_Util_Version $presentVersion
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @throws IfwPsn_Wp_Plugin_Update_Patch_Exception
  */
 public function execute(IfwPsn_Util_Version $presentVersion, IfwPsn_Wp_Plugin_Manager $pm)
 {
     $this->updateRulesTable();
     IfwPsn_Wp_Proxy_Action::doAction('psn_patch_db');
 }
Пример #13
0
 /**
  * Runs after the plugin bootstrap
  */
 private function _postBootstrap()
 {
     // trigger action after_bootstrap
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_after_bootstrap', $this);
     $this->_notifyObservers(self::OBSERVER_POST_BOOTSTRAP);
 }
Пример #14
0
 /**
  * Adds a content block
  *
  * @param $id
  * @param string $label
  * @param string $content
  * @param string $iconClass
  */
 public function addBlock($id, $label, $content, $iconClass)
 {
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_plugininfo_before_' . $id, $this);
     $this->_infoBlocks[] = array('id' => $id, 'label' => $label, 'content' => $content, 'iconClass' => $iconClass);
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_plugininfo_after_' . $id, $this);
 }
Пример #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;
 }
Пример #16
0
 /**
  * Prepares TO, CC and BCC recipients
  *
  * @param Psn_Model_Rule $rule
  * @param $post
  */
 protected function _prepareRecipients(Psn_Model_Rule $rule, $post)
 {
     // recipient handling (To, Cc, Bcc)
     $recipientSelections = array(array('name' => 'recipient_selection', 'modelGetter' => 'getRecipient', 'serviceAdder' => 'addTo', 'custom_field_name' => 'to'), array('name' => 'cc_selection', 'modelGetter' => 'getCcSelect', 'serviceAdder' => 'addCc', 'custom_field_name' => 'cc'), array('name' => 'bcc_selection', 'modelGetter' => 'getBccSelect', 'serviceAdder' => 'addBcc', 'custom_field_name' => 'bcc'));
     foreach ($recipientSelections as $recSel) {
         $recipient = $rule->{$recSel}['modelGetter']();
         if (in_array('admin', $recipient)) {
             $this->{$recSel}['serviceAdder'](IfwPsn_Wp_Proxy_Blog::getAdminEmail());
         }
         if (in_array('author', $recipient)) {
             $this->{$recSel}['serviceAdder'](IfwPsn_Wp_Proxy_User::getEmail($post->post_author));
         }
         // handle dynamic recipients managed by modules
         IfwPsn_Wp_Proxy_Action::doAction('psn_service_email_' . $recSel['name'], $this);
         // check for custom recipient
         $custom_recipient = $rule->get($recSel['custom_field_name']);
         if (!empty($custom_recipient)) {
             $custom_recipient = $rule->getReplacer()->replace($custom_recipient);
             $customRecipientStack = explode(',', $custom_recipient);
             foreach ($customRecipientStack as $customRecipientEmail) {
                 $this->{$recSel}['serviceAdder'](trim($customRecipientEmail));
             }
         }
     }
 }