Exemplo n.º 1
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Form render object.
  *
  * @return string The rendered output
  */
 function render(Zikula_Form_View $view)
 {
     $imageURL = $this->imageURL == null ? 'images/icons/extrasmall/tab_right.png' : $this->imageURL;
     $menuPlugin = $view->getPluginById($this->menuId);
     $menuId = $menuPlugin->id;
     $html = "<img src=\"{$imageURL}\" alt=\"\" class=\"contextMenu\" onclick=\"Form.contextMenu.showMenu(event, '{$menuId}', '{$this->commandArgument}')\" />";
     return $html;
 }
Exemplo n.º 2
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     // Security check
     if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     if ($args['commandName'] == 'submit') {
         $ok = $view->isValid();
         $data = $view->getValues();
         // TODO reduce this to a loop
         if (empty($data['ezcomments_itemsperpage'])) {
             $ifield = $view->getPluginById('ezcomments_itemsperpage');
             $ifield->setError(DataUtil::formatForDisplay($this->__('missing value')));
             $ok = false;
         }
         if (empty($data['ezcomments_modlinkcount'])) {
             $ifield = $view->getPluginById('ezcomments_modlinkcount');
             $ifield->setError(DataUtil::formatForDisplay($this->__('missing value')));
             $ok = false;
         }
         if (empty($data['ezcomments_blacklinkcount'])) {
             $ifield = $view->getPluginById('ezcomments_blacklinkcount');
             $ifield->setError(DataUtil::formatForDisplay($this->__('missing value')));
             $ok = false;
         }
         if (empty($data['ezcomments_feedcount'])) {
             $ifield = $view->getPluginById('ezcomments_feedcount');
             $ifield->setError(DataUtil::formatForDisplay($this->__('missing value')));
             $ok = false;
         }
         if (empty($data['ezcomments_commentsperpage'])) {
             $ifield = $view->getPluginById('ezcomments_commentsperpage');
             $ifield->setError(DataUtil::formatForDisplay($this->__('missing value')));
             $ok = false;
         }
         if (!$ok) {
             return false;
         }
         $this->setVar('MailToAdmin', $data['ezcomments_MailToAdmin']);
         $this->setVar('moderationmail', $data['ezcomments_moderationmail']);
         $this->setVar('template', $data['ezcomments_template']);
         $this->setVar('css', $data['ezcomments_css']);
         $this->setVar('itemsperpage', $data['ezcomments_itemsperpage']);
         $this->setVar('anonusersinfo', $data['ezcomments_anonusersinfo']);
         $this->setVar('moderation', $data['ezcomments_moderation']);
         $this->setVar('enablepager', $data['ezcomments_enablepager']);
         $this->setVar('dontmoderateifcommented', $data['ezcomments_dontmoderateifcommented']);
         $this->setVar('modlinkcount', $data['ezcomments_modlinkcount']);
         $this->setVar('modlist', $data['ezcomments_modlist']);
         $this->setVar('blacklinkcount', $data['ezcomments_blacklinkcount']);
         $this->setVar('blacklist', $data['ezcomments_blacklist']);
         $this->setVar('alwaysmoderate', $data['ezcomments_alwaysmoderate']);
         $this->setVar('proxyblacklist', $data['ezcomments_proxyblacklist']);
         $this->setVar('logip', $data['ezcomments_logip']);
         $this->setVar('feedtype', $data['ezcomments_feedtype']);
         $this->setVar('feedcount', $data['ezcomments_feedcount']);
         $this->setVar('commentsperpage', $data['ezcomments_commentsperpage']);
         $this->setVar('enablepager', $data['ezcomments_enablepager']);
         $this->setVar('akismet', isset($data['ezcomments_akismet']) ? $data['ezcomments_akismet'] : false);
         $this->setVar('akismetstatus', isset($data['ezcomments_akismetstatus']) ? $data['ezcomments_akismetstatus'] : 1);
         $this->setVar('anonusersrequirename', $data['ezcomments_anonusersrequirename']);
         $this->setVar('modifyowntime', $data['ezcomments_modifyowntime']);
         $this->setVar('useaccountpage', $data['ezcomments_useaccountpage']);
         LogUtil::registerStatus($this->__('Done! Module configuration updated.'));
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * PostRender event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return void
  */
 function postRender(Zikula_Form_View $view)
 {
     $plugin = $view->getPluginById($this->for);
     if ($plugin != null) {
         $plugin->myLabel = $view->translateForDisplay($this->text, $this->html == 1 ? false : true);
     }
 }
Exemplo n.º 4
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     // Security check
     $securityCheck = ModUtil::apiFunc('EZComments', 'user', 'checkPermission', array('module' => '', 'objectid' => '', 'commentid' => $this->id, 'level' => ACCESS_EDIT));
     if (!$securityCheck) {
         return LogUtil::registerPermissionError(ModUtil::url('EZComments', 'admin', 'main'));
     }
     $ok = $view->isValid();
     $data = $view->getValues();
     $comment = ModUtil::apiFunc('EZComments', 'user', 'get', array('id' => $this->id));
     switch ($args['commandName']) {
         case 'cancel':
             // nothing to do
             break;
         case 'delete':
             // delete the comment
             // The API function is called.
             // note: the api call is a little different here since we'll really calling a hook function that will
             // normally be executed when a module is deleted. The extra nesting of the modname inside an extrainfo
             // array reflects this
             if (ModUtil::apiFunc('EZComments', 'admin', 'delete', array('id' => $this->id))) {
                 // Success
                 LogUtil::registerStatus($this->__('Done! Comment deleted.'));
                 // clear respective cache
                 ModUtil::apiFunc('EZComments', 'user', 'clearItemCache', $comment);
             }
             break;
         case 'submit':
             if (!empty($comment['anonname'])) {
                 // poster is anonymous
                 // check anon fields
                 if (empty($data['ezcomments_anonname'])) {
                     $ifield = $view->getPluginById('ezcomments_anonname');
                     $ifield->setError(DataUtil::formatForDisplay($this->__('Name for anonymous user is missing.')));
                     $ok = false;
                 }
                 // anonmail must be valid - really necessary if an admin changes this?
                 if (empty($data['ezcomments_anonmail']) || !System::varValidate($data['ezcomments_anonmail'], 'email')) {
                     $ifield = $view->getPluginById('ezcomments_anonmail');
                     $ifield->setError(DataUtil::formatForDisplay($this->__('Email address of anonymous user is missing or invalid.')));
                     $ok = false;
                 }
                 // anonwebsite must be valid
                 if (!empty($data['ezcomments_anonwebsite']) && !System::varValidate($data['ezcomments_anonmail'], 'url')) {
                     $ifield = $view->getPluginById('ezcomments_anonwebsite');
                     $ifield->setError(DataUtil::formatForDisplay($this->__('Website of anonymous user is invalid.')));
                     $ok = false;
                 }
             } else {
                 // user has not posted as anonymous, continue normally
             }
             // no check on ezcomments_subject as this may be empty
             if (empty($data['ezcomments_comment'])) {
                 $ifield = $view->getPluginById('ezcomments_comment');
                 $ifield->setError(DataUtil::formatForDisplay($this->__('Error! The comment contains no text.')));
                 $ok = false;
             }
             if (!$ok) {
                 return false;
             }
             // Call the API to update the item.
             if (ModUtil::apiFunc('EZComments', 'admin', 'update', array('id' => $this->id, 'subject' => $data['ezcomments_subject'], 'comment' => $data['ezcomments_comment'], 'status' => (int) $data['ezcomments_status'], 'anonname' => $data['ezcomments_anonname'], 'anonmail' => $data['ezcomments_anonmail'], 'anonwebsite' => $data['ezcomments_anonwebsite']))) {
                 // Success
                 LogUtil::registerStatus($this->__('Done! Comment updated.'));
                 // clear respective cache
                 ModUtil::apiFunc('EZComments', 'user', 'clearItemCache', $comment);
             }
             break;
     }
     if ($data['ezcomments_sendmeback'] == true) {
         return System::redirect($comment['url'] . "#comments_{$comment['modname']}_{$comment['objectid']}");
     }
     return System::redirect(ModUtil::url('EZComments', 'admin', 'main'));
 }