Ejemplo n.º 1
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     if ($args['commandName'] == 'cancel') {
         $url = ModUtil::url('Scribite', 'admin', 'main');
         return $view->redirect($url);
     } else {
         if ($args['commandName'] == 'restore') {
             $classname = 'ModulePlugin_Scribite_' . $this->editor . '_Plugin';
             if (method_exists($classname, 'getDefaults')) {
                 $defaults = $classname::getDefaults();
                 if (!empty($defaults)) {
                     ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $defaults);
                     LogUtil::registerStatus('Defaults succesfully restored.');
                 }
             }
             return true;
         }
     }
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     $data = $view->getValues();
     ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $data);
     LogUtil::registerStatus($this->__('Done! Module configuration updated.'));
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Handle form submission.
  *
  * @param Zikula_Form_View $view  Current Zikula_Form_View instance.
  * @param array            &$args Args.
  *
  * @return boolean
  */
 public function handleCommand(Zikula_Form_View $view, &$args)
 {
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     // load form values
     $data = $view->getValues();
     $user = $this->_user;
     // merge attributes
     foreach ($data['attributes'] as $name => $value) {
         $user->setAttribute($name, $value);
     }
     // merge metadata
     $metadata = $user->getMetadata();
     if ($metadata == null) {
         $metadata = new ExampleDoctrine_Entity_UserMetadata($user);
         $user->setMetadata($metadata);
     }
     $metadata->merge($data['meta']);
     unset($data['attributes'], $data['meta']);
     // merge user and save everything
     $user->merge($data);
     $this->entityManager->persist($user);
     $this->entityManager->flush();
     return $view->redirect(ModUtil::url('ExampleDoctrine', 'user', 'view'));
 }
Ejemplo n.º 3
0
    public function handleCommand(Zikula_Form_View $view, &$args)
    {
        switch($args['commandName']) {
            case 'cancel':
                break;
            case 'save':
                if (!$view->isValid()) {
                    return false;
                }
                $formValues = $view->getValues();
                $toname = (string)$formValues['toname'];
                $toaddress = (string)$formValues['toaddress'];
                $subject = (string)$formValues['subject'];
                $msgtype = (string)$formValues['msgtype'];
                $textBody = (string)$formValues['mailer_textbody'];
                $htmlBody = (string)$formValues['mailer_body'];

                $html = in_array($msgtype, array('html', 'multipart')) ? true : false;
                if ($html) {
                    $msgBody = $htmlBody;
                    $altBody = $textBody;
                } else {
                    $msgBody = $textBody;
                    $altBody = '';
                }

                // set the email
                $result = ModUtil::apiFunc('Mailer', 'user', 'sendmessage', array(
                    'toname' => $toname,
                    'toaddress' => $toaddress,
                    'subject' => $subject,
                    'body' => $msgBody,
                    'altbody' => $altBody,
                    'html' => $html)
                );

                // check our result and return the correct error code
                if ($result === true) {
                    // Success
                    LogUtil::registerStatus($this->__('Done! Message sent.'));
                } elseif ($result === false) {
                    // Failiure
                    LogUtil::registerError($this->__f('Error! Could not send message. %s', ''));
                } else {
                    // Failiure with error
                    LogUtil::registerError($this->__f('Error! Could not send message. %s', $result));
                }

                break;
        }

        return $view->redirect(ModUtil::url('Mailer', 'admin', 'testconfig'));
    }
Ejemplo n.º 4
0
    public function handleCommand(Zikula_Form_View $view, &$args)
    {
        switch($args['commandName']) {
            case 'cancel':
                break;
            case 'save':
                if (!$view->isValid()) {
                    return false;
                }
                $this->formValues = $view->getValues();

                // set our new module variable values
                $vars = array();
                $vars['mailertype'] = (int)$this->getFormValue('mailertype', 1);

                $vars['charset'] = (string)$this->getFormValue('charset', ZLanguage::getEncoding());

                $vars['encoding'] = (string)$this->getFormValue('encoding', '8bit');

                $vars['html'] = (bool)$this->getFormValue('html', false);

                $vars['wordwrap'] = (int)$this->getFormValue('wordwrap', 50);

                $vars['msmailheaders'] = (bool)$this->getFormValue('msmailheaders', false);

                $vars['sendmailpath'] = (string)$this->getFormValue('sendmailpath', '/usr/sbin/sendmail');

                $vars['smtpauth'] = (bool)$this->getFormValue('smtpauth', false);

                $vars['smtpserver'] = (string)$this->getFormValue('smtpserver', 'localhost');

                $vars['smtpport'] = (int)$this->getFormValue('smtpport', 25);

                $vars['smtptimeout'] = (int)$this->getFormValue('smtptimeout', 10);

                $vars['smtpusername'] = (string)$this->getFormValue('smtpusername', '');

                $vars['smtppassword'] = (string)$this->getFormValue('smtppassword', '');

                $vars['smtpsecuremethod'] = (string)$this->getFormValue('smtpsecuremethod', '');

                $this->setVars($vars);

                // the module configuration has been updated successfuly
                LogUtil::registerStatus($this->__('Done! Saved module configuration.'));
                break;
        }

        return $view->redirect(ModUtil::url('Mailer', 'admin', 'modifyconfig'));
    }
Ejemplo n.º 5
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     $url = ModUtil::url('Scribite', 'admin', 'main');
     if ($args['commandName'] == 'cancel') {
         return $view->redirect($url);
     }
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     // get passed args and store to array
     $data = $view->getValues();
     $this->setVars($data);
     LogUtil::registerStatus($this->__('Done! Module configuration updated.'));
     return $view->redirect($url);
 }
Ejemplo n.º 6
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     if ($args['commandName'] == 'cancel') {
         $url = ModUtil::url('BBSmile', 'admin', 'main');
         return $view->redirect($url);
     }
     // Security check
     if (!SecurityUtil::checkPermission('BBSmile::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError(ModUtil::url('BBSmile', 'admin', 'main'));
     }
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     $ok = true;
     $data = $view->getValues();
     $ossmiliepath = DataUtil::formatForOS($data['smiliepath']);
     if (!file_exists($ossmiliepath) || !is_readable($ossmiliepath)) {
         $ifield = $this->view->getPluginById('smiliepath');
         $ifield->setError(DataUtil::formatForDisplay($this->__('The path does not exists or the system cannot read it.')));
         $ok = false;
     }
     $osautosmiliepath = DataUtil::formatForOS($data['smiliepath_auto']);
     if (!file_exists($osautosmiliepath) || !is_readable($osautosmiliepath)) {
         $ifield = $this->view->getPluginById('smiliepath_auto');
         $ifield->setError(DataUtil::formatForDisplay($this->__('The path does not exists or the system cannot read it.')));
         $ok = false;
     }
     if ($ok == false) {
         return false;
     }
     $this->setVar('smiliepath', $data['smiliepath']);
     $this->setVar('smiliepath_auto', $data['smiliepath_auto']);
     $this->setVar('activate_auto', $data['activate_auto']);
     $this->setVar('remove_inactive', $data['remove_inactive']);
     LogUtil::registerStatus($this->__('BBSmile configuration updated'));
     return true;
 }
Ejemplo n.º 7
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     // Security check
     if (!SecurityUtil::checkPermission('Avatar::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     if ($args['commandName'] == 'submit') {
         if (!$view->IsValid()) {
             return false;
         }
         $data = $view->getValues();
         if (array_key_exists('forumdir', $data)) {
             ModUtil::setVar('Avatar', 'forumdir', $data['forumdir']);
         }
         ModUtil::setVar('Users', 'avatarpath', $data['avatarpath']);
         ModUtil::setVar('Avatar', 'allow_resize', $data['allow_resize']);
         ModUtil::setVar('Avatar', 'maxsize', $data['maxsize']);
         ModUtil::setVar('Avatar', 'maxheight', $data['maxheight']);
         ModUtil::setVar('Avatar', 'maxwidth', $data['maxwidth']);
         ModUtil::setVar('Avatar', 'allowed_extensions', $data['allowed_extensions']);
         ModUtil::setVar('Avatar', 'allow_multiple', $data['allow_multiple']);
     }
     return true;
 }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 9
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'));
 }