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 getAllTopics($checkRight = false, $permission = "ams_view")
 {
     static $topics_arr = array();
     $db =& Database::getInstance();
     $table = $db->prefix('ams_topics');
     if (!isset($topics_arr['checked']) && false != $checkRight || !isset($topics_arr['unchecked']) && false == $checkRight) {
         $sql = "SELECT * FROM " . $table;
         if (false != $checkRight) {
             global $xoopsUser, $xoopsModule;
             if (!isset($xoopsModule) || $xoopsModule->getVar('dirname') != "AMS") {
                 $module_handler =& xoops_gethandler('module');
                 $newsModule =& $module_handler->getByDirname('AMS');
             } else {
                 $newsModule =& $xoopsModule;
             }
             $groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
             $gperm_handler =& xoops_gethandler('groupperm');
             $topics = $gperm_handler->getItemIds($permission, $groups, $newsModule->getVar('mid'));
             if (count($topics) == 0) {
                 return array();
             }
             $topics = implode(',', $topics);
             $sql .= " WHERE topic_id IN (" . $topics . ")";
         }
         $sql .= " ORDER BY weight";
         $result = $db->query($sql);
         while ($array = $db->fetchArray($result)) {
             $topic = new AmsTopic($table);
             $topic->makeTopic($array);
             if ($checkRight) {
                 $topics_arr['checked'][$array['topic_id']] = $topic;
             } else {
                 $topics_arr['unchecked'][$array['topic_id']] = $topic;
             }
             unset($topic);
         }
     }
     return $checkRight ? isset($topics_arr['checked']) ? $topics_arr['checked'] : array() : (isset($topics_arr['unchecked']) ? $topics_arr['unchecked'] : array());
 }
Ejemplo n.º 5
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.º 6
0
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  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);
Ejemplo n.º 7
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 '../../../include/cp_header.php';
include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newstopic.php";
include_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
include_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php';
include_once "functions.php";
xoops_cp_header();
adminmenu(3);
$module_id = $xoopsModule->getVar('mid');
$xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
$allTopics = $xt->getAllTopics();
$totaltopics = count($allTopics);
if ($totaltopics > 0) {
    //Approver Form
    $approveform = new XoopsGroupPermForm(_AMS_AM_APPROVEFORM, $module_id, "ams_approve", _AMS_AM_APPROVEFORM_DESC);
    //Submitter Form
    $submitform = new XoopsGroupPermForm(_AMS_AM_SUBMITFORM, $module_id, "ams_submit", _AMS_AM_SUBMITFORM_DESC);
    //Viewer Form
    $viewform = new XoopsGroupPermForm(_AMS_AM_VIEWFORM, $module_id, "ams_view", _AMS_AM_VIEWFORM_DESC);
    foreach ($allTopics as $topic_id => $topic) {
        $approveform->addItem($topic_id, $topic->topic_title(), $topic->topic_pid());
        $submitform->addItem($topic_id, $topic->topic_title(), $topic->topic_pid());
        $viewform->addItem($topic_id, $topic->topic_title(), $topic->topic_pid());
    }
    echo $approveform->render();
Ejemplo n.º 8
0
     echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">";
     echo "<h4>" . _AMS_AM_EDITARTICLE . "</h4>";
     if ($story->published() > 0) {
         $story->setApproved(1);
     } else {
         $story->setApproved(0);
     }
     $edit = true;
     $type = $story->type();
     $story->uname();
     $author = $story->uname;
     include "include/storyform.inc.php";
     echo "</td></tr></table>";
     break;
 case "preview":
     $xt = new AmsTopic($xoopsDB->prefix("ams_topics"), $_POST['topic_id']);
     //$hometext = $_POST['hometext'];
     //$bodytext = $_POST['bodytext'];
     if (isset($_POST['storyid'])) {
         $story = new AmsStory($storyid);
         $edit = true;
     } else {
         $story = new AmsStory();
         $story->setPublished(0);
         $story->setExpired(0);
         $edit = false;
     }
     $story->setTopicId($_POST['topic_id']);
     $story->setTitle($_POST['title']);
     $story->setHometext($hometext);
     $story->setBodytext($bodytext);
Ejemplo n.º 9
0
    include_once XOOPS_ROOT_PATH . "/class/xoopseditor/koivi/formwysiwygtextarea.php";
    if (file_exists(XOOPS_ROOT_PATH . "/class/xoopseditor/koivi/language/" . $xoopsConfig['language'] . ".php")) {
        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);
Ejemplo n.º 10
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.º 11
0
    $xoopsTpl->assign('topics', $smarty_topics);
    $xoopsTpl->assign('columns', $column_count);
    $xoopsTpl->assign('breadcrumb', '');
}
if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule']) {
    $showcomments = 1;
} else {
    $showcomments = 0;
}
$xoopsTpl->assign('showcomments', $showcomments);
$xoopsTpl->assign('xoops_pagetitle', $pagetitle);
$xoopsTpl->assign('lang_go', _GO);
$xoopsTpl->assign('lang_on', _ON);
$xoopsTpl->assign('lang_printerpage', _AMS_NW_PRINTERFRIENDLY);
$xoopsTpl->assign('lang_sendstory', _AMS_NW_SENDSTORY);
$xoopsTpl->assign('lang_postedby', _POSTEDBY);
$xoopsTpl->assign('lang_reads', _READS);
$xoopsTpl->assign('lang_morereleases', _AMS_NW_MORERELEASES);
$xoopsTpl->assign('lang_postnewarticle', _AMS_NW_POSTNEWARTICLE);
if ($xoopsOption['storytopic'] > 0) {
    $topic = new AmsTopic($xoopsDB->prefix('ams_topics'), $xoopsOption['storytopic']);
    $xoopsTpl->assign('topicbanner', $myts->displayTarea($topic->getBanner(), 1));
}
include_once XOOPS_ROOT_PATH . '/footer.php';
function findKey($array, $suggested_key)
{
    if (isset($array[$suggested_key])) {
        return findKey($array, $suggested_key + 1);
    }
    return $suggested_key;
}