Ejemplo n.º 1
0
 /**
  * @desc Envía correo de aprobación de publicación
  * @param Object $res Publicación
  **/
 function mail_approved(RDResource &$res)
 {
     global $xoopsModuleConfig, $xoopsConfig;
     $config_handler =& xoops_gethandler('config');
     $mconfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER);
     $errors = '';
     $user = new XoopsUser($res->getVar('owner'));
     $member_handler =& xoops_gethandler('member');
     $method = $user->getVar('notify_method');
     $mailer = new RMMailer('text/plain');
     $mailer->add_xoops_users($user);
     $mailer->set_subject(sprintf(__('Publication <%s> approved!', 'docs'), $res->getVar('title')));
     $mailer->assign('dear_user', $user->getVar('name') != '' ? $user->getVar('name') : $user->getVar('uname'));
     $mailer->assign('link_to_resource', $res->permalink());
     $mailer->assign('site_name', $xoopsConfig['sitename']);
     $mailer->assign('resource_name', $res->getVar('title'));
     $mailer->template(RMTemplate::get()->get_template('mail/resource_approved.php', 'module', 'docs'));
     switch ($method) {
         case '1':
             $mailer->set_from_xuser($mconfig['fromuid']);
             $ret = $mailer->send_pm();
             break;
         case '2':
             $ret = $mailer->send();
             break;
     }
     $page = rmc_server_var($_POST, 'page', 1);
     return $ret;
 }
Ejemplo n.º 2
0
/**
* desc Elimina de la base de datos los elementos
**/
function dt_delete_items()
{
    global $xoopsModuleConfig, $xoopsConfig, $xoopsModule, $xoopsSecurity, $rmc_config, $xoopsUser;
    $ids = rmc_server_var($_POST, 'ids', array());
    $page = rmc_server_var($_POST, 'page', 1);
    $search = rmc_server_var($_POST, 'search', '');
    $sort = rmc_server_var($_POST, 'sort', 'id_soft');
    $mode = rmc_server_var($_POST, 'mode', 1);
    $cat = rmc_server_var($_POST, 'cat', 0);
    $type = rmc_server_var($_POST, 'type', '');
    $params = '?pag=' . $page . '&search=' . $search . '&sort=' . $sort . '&mode=' . $mode . '&cat=' . $cat . '&type=' . $type;
    //Verificamos que el software sea válido
    if (!is_array($ids) && $ids <= 0) {
        redirectMsg('items.php' . $params, __('You must select at least one download item to delete!', 'dtransport'), RMMSG_WARN);
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('items.php' . $params, __('Session token expired!', 'dtransport'), RMMSG_ERROR);
    }
    $errors = '';
    $mailer = new RMMailer('text/html');
    $etpl = DT_PATH . '/lang/deletion_' . $rmc_config['lang'] . '.php';
    if (!file_exists($etpl)) {
        $etpl = DT_PATH . '/lang/deletion_en.php';
    }
    $mailer->template($etpl);
    $mailer->assign('siteurl', XOOPS_URL);
    $mailer->assign('dturl', $xoopsModuleConfig['permalinks'] ? XOOPS_URL . '/' . trim($xoopsModuleConfig['htbase'], '/') : DT_URL);
    $mailer->assign('downcp', $xoopsModuleConfig['permalinks'] ? XOOPS_URL . '/' . trim($xoopsModuleConfig['htbase'], '/') . '/cp/' : DT_URL . '/?p=cpanel');
    $mailer->assign('dtname', $xoopsModule->name());
    $mailer->assign('sitename', $xoopsConfig['sitename']);
    foreach ($ids as $id) {
        $sw = new DTSoftware($id);
        if ($sw->isNew()) {
            continue;
        }
        if (!$sw->delete()) {
            $errors .= $sw->errors();
            continue;
        }
        $xu = new XoopsUser($sw->getVar('uid'));
        $mailer->add_users(array($xu));
        $mailer->assign('uname', $xu->name() != '' ? $xu->name() : $xu->uname());
        $mailer->assign('download', $sw->getVar('name'));
        $mailer->assign('email', $xu->getVar('email'));
        $mailer->assign('method', $xu->getVar('notify_method'));
        $mailer->set_subject(sprintf(__('Your download %s has been deleted!', 'dtransport'), $sw->getVar('name')));
        if ($xu->getVar('notify_method') == 1) {
            $mailer->set_from_xuser($xoopsUser);
            $mailer->send_pm();
        } else {
            $mailer->send();
        }
    }
    if ($errors != '') {
        redirectMsg('items.php' . $params, __('Errors ocurred while trying to delete selected downloads!', 'dtransport') . '<br />' . $errors, RMMSG_ERROR);
    }
    redirectMsg('items.php' . $params, __('Downloads deleted successfully!', 'dtransport'), RMMSG_SUCCESS);
}
Ejemplo n.º 3
0
/**
* @desc Almacena información perteneciente a una publicación
**/
function savePublish()
{
    global $xoopsSecurity, $xoopsModuleConfig, $xoopsUser, $xoopsConfig;
    $config_handler =& xoops_gethandler('config');
    $xconfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER);
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    if ($xoopsModuleConfig['permalinks']) {
        $purl = RDFunctions::url() . '/publish/';
    } else {
        $purl = RDFunctions::url() . '?page=publish&action=publish';
    }
    if (!$xoopsSecurity->check()) {
        redirect_header($prul, 1, __('Session token expired!', 'docs'));
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Comprueba que el título de publicación no exista
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources') . " WHERE title='{$title}' ";
    list($num) = $db->fetchRow($db->queryF($sql));
    if ($num > 0) {
        redirect_header($purl, 1, __('Already exists a Document with same name!', 'docs'));
        die;
    }
    $res = new RDResource();
    //Genera $nameid Nombre identificador
    $found = false;
    $i = 0;
    do {
        $nameid = TextCleaner::getInstance()->sweetstring($title) . ($found ? $i : '');
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources') . " WHERE nameid = '{$nameid}'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            $found = true;
            $i++;
        } else {
            $found = false;
        }
    } while ($found == true);
    $res->setVar('title', $title);
    $res->setVar('description', $desc);
    $res->setVar('created', time());
    $res->setVar('modified', time());
    $res->setVar('editors', $editors);
    $res->setVar('groups', $groups);
    $res->setVar('public', 1);
    $res->setVar('quick', $quick);
    $res->setVar('nameid', $nameid);
    $res->setVar('owner', $xoopsUser->uid());
    $res->setVar('owname', $xoopsUser->uname());
    $res->setVar('approved', $xoopsModuleConfig['approved']);
    $res->setVar('single', $single);
    if (!$res->save()) {
        redirect_header($prul, 1, __('Document could not be created!', 'docs'));
    } else {
        //Si no se aprobó la publicación enviamos correo al administrador
        if (!$xoopsModuleConfig['approved']) {
            $mailer = new RMMailer('text/plain');
            $mailer->add_user($xconfig['from'], $xconfig['fromname'], 'to');
            $mailer->set_subject(__('New Document created at RapidDocs is waiting for approval', 'rmcommon'));
            $mailer->assign('to_name', $xconfig['fromname']);
            $mailer->assign('link_to_resource', XOOPS_URL . '/modules/docs/admin/resources.php?action=edit&id=' . $res->id());
            $mailer->template(RMTemplate::get()->get_template('mail/resource_for_approval.php', 'module', 'docs'));
            if (!$mailer->send()) {
                redirect_header(RDFunctions::url(), 1, __('Your Document has been created, however the email to administrator could no be sent.', 'docs'));
                die;
            }
            redirect_header(RDFunctions::url(), 1, __('Your Document has been created and is pending for approval. We will sent an email when you can access to it and add content.', 'docs'));
            die;
        }
        if ($xoopsModuleConfig['permalinks']) {
            $purl = RDFunctions::url() . '/list/' . $res->id() . '/';
        } else {
            $purl = RDFunctions::url() . '?page=edit&action=list&id=' . $res->id();
        }
        redirect_header($purl, 1, __('Document created successfully!', 'docs'));
        die;
    }
}
Ejemplo n.º 4
0
/**
* Send mail to selected users using Swift
*/
function send_mail()
{
    global $rmc_config, $xoopsConfig;
    extract($_POST);
    // Creating a message
    $mailer = new RMMailer($type == 'html' ? 'text/html' : 'text/plain');
    $mailer->add_xoops_users($mailer_users);
    $mailer->set_subject($subject);
    $message = $type == 'html' ? TextCleaner::getInstance()->to_display($message) : $message;
    $mailer->set_body($message);
    if (!$mailer->batchSend()) {
        xoops_cp_header();
        echo "<h3>" . __('There was errors while sending this emails', 'rmcommon') . "</h3>";
        foreach ($mailer->errors() as $error) {
            echo "<div class='even'>" . $error . "</div>";
        }
        xoops_cp_footer();
    }
    redirectMsg('users.php?' . base64_decode($query), __('Message sent successfully!', 'rmcommon'), 0);
}