Ejemplo n.º 1
0
 /**
  * Get a {@link XoopsForm} object for creating/editing Spotlight articles
  *
  * @return object
  */
 function getForm($action = false)
 {
     if ($action === false) {
         $action = $_SERVER['REQUEST_URI'];
     }
     $title = _AMS_AM_SPOTLIGHT;
     include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
     include_once XOOPS_ROOT_PATH . "/modules/AMS/class/formimageselect.php";
     $form = new XoopsThemeForm($title, 'spotlightform', $action);
     if (!$this->isNew()) {
         $form->addElement(new XoopsFormHidden('id', $this->getVar('spotlightid')));
     }
     $mode_select = new XoopsFormRadio('', 'mode', $this->getVar('mode'));
     $mode_select->addOption(1, _AMS_AM_SPOT_LATESTARTICLE);
     $mode_select->addOption(2, _AMS_AM_SPOT_LATESTINTOPIC);
     $mode_select->addOption(3, _AMS_AM_SPOT_SPECIFICARTICLE);
     $mode_select->addOption(4, _AMS_AM_SPOT_CUSTOM);
     include_once XOOPS_ROOT_PATH . "/class/tree.php";
     include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newstopic.php";
     include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newsstory.php";
     $xt = new AmsTopic($GLOBALS['xoopsDB']->prefix("ams_topics"));
     $allTopics = $xt->getAllTopics();
     $topic_obj_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid');
     $topic_select = new XoopsFormLabel(_AMS_AM_TOPIC, $topic_obj_tree->makeSelBox('topicid', 'topic_title', '--', $this->getVar('topicid'), false));
     $topic_select->setDescription(_AMS_AM_SPOT_TOPIC_DESC);
     $article_select = new XoopsFormSelect(_AMS_AM_ARTICLE, 'storyid', $this->getVar('storyid'));
     $article_select->addOptionArray(AmsStory::getAllPublished($GLOBALS['xoopsModuleConfig']['spotlight_art_num'], 0, false, 0, 1, false));
     $article_select->setDescription(_AMS_AM_SPOT_ARTICLE_DESC);
     $mode_tray = new XoopsFormElementTray(_AMS_AM_SPOT_MODE_SELECT);
     $mode_tray->addElement($mode_select);
     $showimage_select = new XoopsFormRadio(_AMS_AM_SPOT_SHOWIMAGE, 'showimage', $this->getVar('showimage'));
     $showimage_select->addOption(0, _AMS_AM_SPOT_SPECIFYIMAGE);
     $showimage_select->addOption(1, _AMS_AM_SPOT_TOPICIMAGE);
     $showimage_select->addOption(2, _AMS_AM_SPOT_AUTHORIMAGE);
     $showimage_select->addOption(3, _AMS_AM_SPOT_NOIMAGE);
     $showimage_select->setDescription(_AMS_AM_SPOT_SHOWIMAGE_DESC);
     $image_select = new XoopsFormImageSelect(_AMS_AM_SPOT_IMAGE, 'image', $this->getVar('image', 'e'), 70, 255);
     $autoteaser_select = new XoopsFormRadioYN(_AMS_AM_SPOT_AUTOTEASER, 'autoteaser', $this->getVar('autoteaser'));
     $teaser_text = new XoopsFormDhtmlTextArea(_AMS_AM_SPOT_TEASER, 'teaser', $this->getVar('teaser', 'e'));
     $maxlength_text = new XoopsFormText(_AMS_AM_SPOT_MAXLENGTH, 'maxlength', 10, 10, $this->getVar('maxlength'));
     $display_select = new XoopsFormRadioYN(_AMS_AM_SPOT_DISPLAY, 'display', $this->getVar('display'));
     $weight_text = new XoopsFormText(_AMS_AM_SPOT_WEIGHT, 'weight', 10, 10, $this->getVar('weight'));
     $form->addElement($mode_tray);
     $form->addElement($topic_select);
     $form->addElement($article_select);
     $form->addElement($showimage_select);
     $form->addElement($image_select);
     $form->addElement($autoteaser_select);
     $form->addElement($maxlength_text);
     $form->addElement($teaser_text);
     $form->addElement($display_select);
     $form->addElement($weight_text);
     $form->addElement(new XoopsFormHidden('op', 'save'));
     $form->addElement(new XoopsFormButton('', 'spotlightsubmit', _AMS_AM_SUBMIT, 'submit'));
     return $form;
 }
Ejemplo n.º 2
0
function b_ams_topicsnav_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newstopic.php";
    global $xoopsDB, $xoopsUser;
    $block = array();
    $topics = AmsTopic::getAllTopics($options[0]);
    foreach ($topics as $topic) {
        $block['topics'][] = array('id' => $topic->topic_id, 'title' => $topic->topic_title());
    }
    return $block;
}
Ejemplo n.º 3
0
function addTopic()
{
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
    $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0;
    $xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
    if (!$xt->topicExists($topicpid, $_POST['topic_title'])) {
        $xt->setTopicPid($topicpid);
        if (empty($_POST['topic_title']) || trim($_POST['topic_title']) == '') {
            redirect_header("index.php?op=topicsmanager", 2, _AMS_AM_ERRORTOPICNAME);
        }
        $xt->setTopicTitle($_POST['topic_title']);
        if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != "") {
            $xt->setTopicImgurl($_POST['topic_imgurl']);
        }
        if (isset($_POST['xoops_upload_file'])) {
            $fldname = $_FILES[$_POST['xoops_upload_file'][0]];
            $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
            if (trim($fldname != '')) {
                $sfiles = new sFiles();
                $dstpath = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . '/images/topics';
                $destname = $sfiles->createUploadName($dstpath, $fldname, true);
                $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
                $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
                $uploader->setTargetFileName($destname);
                if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                    if ($uploader->upload()) {
                        $xt->setTopicImgurl(basename($destname));
                    } else {
                        echo _AMS_AM_UPLOAD_ERROR;
                    }
                } else {
                    echo $uploader->getErrors();
                }
            }
        }
        $xt->banner_inherit = isset($_POST['banner_inherit']) ? 1 : 0;
        $xt->banner = $_POST['banner'];
        $xt->forum_id = isset($_POST['forum_id']) ? intval($_POST['forum_id']) : 0;
        if ($xt->store()) {
            //This will set default audience
            global $xoopsModule;
            $allTopics = $xt->getAllTopics();
            $totaltopics = count($allTopics);
            if ($totaltopics = 1) {
                //Make sure xoopsModule is AMS.
                if (!isset($xoopsModule) || $xoopsModule->getVar('dirname') != "AMS") {
                    $mod_handler =& xoops_gethandler('module');
                    $amsModule =& $mod_handler->getByDirname('AMS');
                } else {
                    $amsModule =& $xoopsModule;
                }
                // Check audience, and set default value if not yet exist
                if (!ams_isaudiencesetup($amsModule->getVar('mid'))) {
                    $gperm_handler =& xoops_gethandler('groupperm');
                    $member_handler =& xoops_gethandler('member');
                    $group_id_ref =& $member_handler->getGroups(null, true);
                    //insert all groups into default audience
                    foreach (array_keys($group_id_ref) as $i) {
                        $gperm_handler->addRight("ams_audience", 1, intval($group_id_ref[$i]->getVar('groupid')), intval($amsModule->getVar('mid')));
                    }
                }
            }
            //Added in AMS 2.50 Final. Use News 1.62 permission style
            // Permissions
            $gperm_handler =& xoops_gethandler('groupperm');
            if (isset($_POST['groups_AMS_can_approve'])) {
                foreach ($_POST['groups_AMS_can_approve'] as $onegroup_id) {
                    $gperm_handler->addRight('ams_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
                }
            }
            if (isset($_POST['groups_AMS_can_submit'])) {
                foreach ($_POST['groups_AMS_can_submit'] as $onegroup_id) {
                    $gperm_handler->addRight('ams_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
                }
            }
            if (isset($_POST['groups_AMS_can_view'])) {
                foreach ($_POST['groups_AMS_can_view'] as $onegroup_id) {
                    $gperm_handler->addRight('ams_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid'));
                }
            }
            AMS_updateCache();
            $notification_handler =& xoops_gethandler('notification');
            $tags = array();
            $tags['TOPIC_NAME'] = $_POST['topic_title'];
            $notification_handler->triggerEvent('global', 0, 'new_category', $tags);
            redirect_header('index.php?op=topicsmanager', 1, _AMS_AM_DBUPDATED);
            exit;
        }
    } else {
        redirect_header('index.php?op=topicsmanager', 2, _AMS_AM_ADD_TOPIC_ERROR);
        exit;
    }
}
Ejemplo n.º 4
0
function b_ams_top_edit($options)
{
    global $xoopsDB;
    include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
    $form = new XoopsFormElementTray('', '<br/><br />');
    $order_select = new XoopsFormSelect(_AMS_MB_NEWS_ORDER, 'options[0]', $options[0]);
    $order_select->addOption('published', _AMS_MB_NEWS_DATE);
    $order_select->addOption('counter', _AMS_MB_NEWS_HITS);
    $order_select->addOption('rating', _AMS_MB_NEWS_RATING);
    $form->addElement($order_select);
    $form->addElement(new XoopsFormText(_AMS_MB_NEWS_DISP . " x " . _AMS_MB_NEWS_ARTCLS, 'options[1]', 10, 10, $options[1]));
    $form->addElement(new XoopsFormText(_AMS_MB_NEWS_CHARS . " x " . _AMS_MB_NEWS_LENGTH, 'options[2]', 10, 10, $options[2]));
    $form->addElement(new XoopsFormText(_AMS_MB_NEWS_TEASER, 'options[3]', 10, 10, $options[3]));
    if (!isset($options[4])) {
        $topics = array(0);
    } elseif (is_array($options[4])) {
        $topics = $options[4];
    } else {
        $topics = array_slice($options, 4);
    }
    $topics_select = new XoopsFormSelect(_AMS_MB_TOPIC, 'options[4]', $topics, 7, true);
    include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newstopic.php";
    $xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
    $alltopics = $xt->getAllTopics();
    $topics_select->addOption(0, _AMS_MB_NEWS_ALLTOPICS);
    foreach ($alltopics as $topicid => $topic) {
        $topics_select->addOption($topicid, $topic->topic_title());
    }
    $form->addElement($topics_select);
    return $form->render();
}
Ejemplo n.º 5
0
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
include_once XOOPS_ROOT_PATH . "/class/tree.php";
$fform = new XoopsThemeForm(_AMS_AM_FILTER, "filterform", 'index.php');
$fform->setExtra('enctype="multipart/form-data"');
$first_row = new XoopsFormElementTray(_OPTIONS);
$first_row->addElement(new XoopsFormText(_AMS_AM_TITLE, 'title', 50, 80, $title));
global $xoopsDB;
$xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
$alltopics = $xt->getAllTopics();
$topic_obj_tree = new XoopsObjectTree($alltopics, 'topic_id', 'topic_pid');
$first_row->addElement(new XoopsFormLabel(_AMS_AM_TOPIC, $topic_obj_tree->makeSelBox('topicid', 'topic_title', '--', $topicid, true)));
$author_select = new XoopsFormSelect(_AMS_AM_POSTER, 'author', $author, 5, true);
$authors = $xt->getAllAuthors();
//$authors = array_flip($authors);
foreach ($authors as $key => $user_arr) {
    $author_select->addOption($user_arr['uid'], $user_arr['uname']);
}
$first_row->addElement($author_select);
$second_row = new XoopsFormElementTray(_AMS_AM_SORTING);
$status_select = new XoopsFormSelect(_AMS_AM_STATUS, 'status', $status);
$status_select->addOption('none', '---');
$status_select->addOption('published', _AMS_AM_PUBLISHED);
$status_select->addOption('expired', _AMS_AM_EXPIRED);
$second_row->addElement($status_select);
Ejemplo n.º 6
0
        include_once XOOPS_ROOT_PATH . "/class/xoopseditor/koivi/language/" . $xoopsConfig['language'] . ".php";
    } else {
        include_once XOOPS_ROOT_PATH . "/class/xoopseditor/koivi/language/english.php";
    }
} else {
    // if none of editor installed
    include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
}
$sform = new XoopsThemeForm(_AMS_NW_SUBMITNEWS, "storyform", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php');
$sform->setExtra('enctype="multipart/form-data"');
$sform->addElement(new XoopsFormText(_AMS_NW_TITLE, 'title', 50, 80, $story->title('Edit')), true);
//Todo: Change to only display topics, which a user has submit privileges for
if (!isset($xt)) {
    $xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
}
$alltopics = $xt->getAllTopics(true, "ams_submit");
if (count($alltopics) == 0) {
    redirect_header(XOOPS_URL . '/modules/AMS/index.php', 3, _AMS_NW_NOTOPICS);
}
$topic_obj_tree = new XoopsObjectTree($alltopics, 'topic_id', 'topic_pid');
$sform->addElement(new XoopsFormLabel(_AMS_NW_TOPIC, $topic_obj_tree->makeSelBox('topic_id', 'topic_title', '--', $story->topicid())));
//If admin - show admin form
//TODO: Change to "If submit privilege"
if ($approveprivilege) {
    //Show topic image?
    $topic_img = new XoopsFormRadio(_AMS_AM_TOPICDISPLAY, 'topicdisplay', $story->topicdisplay());
    $topic_img->addOption(0, _AMS_AM_NONE);
    $topic_img->addOption(1, _AMS_AM_TOPIC);
    $topic_img->addOption(2, _AMS_AM_AUTHOR);
    $sform->addElement($topic_img);
    //Select image position
Ejemplo n.º 7
0
 function topic($single_topic = false)
 {
     if (!$this->newstopic) {
         if (false == $single_topic) {
             $topics = AmsTopic::getAllTopics();
             $this->newstopic = $topics[$this->topicid()];
         } else {
             $this->newstopic = new AmsTopic($this->topicstable, $this->topicid());
         }
     }
     return $this->newstopic;
 }
Ejemplo n.º 8
0
        $xoopsTpl->assign('pagenav', '');
    }
    if ($xoopsOption['storytopic'] > 0) {
        if (!isset($xt)) {
            $xt = new AmsTopic($xoopsDB->prefix('ams_topics'));
        }
        $xt->getTopic($xoopsOption['storytopic']);
        $pagetitle .= ' - ' . $xt->topic_title();
        $xoopsTpl->assign('breadcrumb', $xt->getTopicPath(true));
    } else {
        $xoopsTpl->assign('breadcrumb', '');
    }
} else {
    include_once XOOPS_ROOT_PATH . "/class/tree.php";
    $xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
    $allTopics = $xt->getAllTopics($xoopsModuleConfig['restrictindex']);
    $topic_obj_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid');
    $alltopics = $topic_obj_tree->getFirstChild(0);
    $article_counts = AmsStory::countPublishedOrderedByTopic();
    $smarty_topics = array();
    foreach (array_keys($alltopics) as $i) {
        $allstories[$i] = AmsStory::getAllPublished($xoopsOption['storynum'], 0, false, $i, 0);
        if (count($allstories[$i]) > 0) {
            foreach ($allstories[$i] as $thisstory) {
                $uids[$thisstory->uid()] = $thisstory->uid();
            }
        }
        if (!isset($article_counts[$i])) {
            $article_counts[$i] = 0;
        }
    }