// require('includes/application_top.php'); require('includes/functions/news_general.php'); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'setflag': if (($_GET['flag'] == '0') || ($_GET['flag'] == '1')) { if (isset($_GET['aID']) && zen_not_null($_GET['aID'])) { $sql_data_array = array('status' => zen_db_prepare_input($_GET['flag'])); zen_db_perform(TABLE_NEWS_AUTHORS, $sql_data_array, 'update', 'authors_id = \'' . (int)$_GET['aID'] . '\''); $messageStack->add(SUCCESS_STATUS, 'success'); } } break; } } if ($_POST) { $authors_id = zen_db_prepare_input($_GET['aID']); $author_name = zen_db_prepare_input($_POST['author_name']); $author_email = zen_db_prepare_input($_POST['author_email']); } switch ($_GET['query']) { case 'add_author': // Check if all fields are filled up if (!zen_not_null($author_name)) { $error = true; $messageStack->add(ERROR_BLANK_AUTHOR_NAME, 'error'); } if (!zen_not_null($author_email)) { $error = true; $messageStack->add(ERROR_BLANK_AUTHOR_EMAIL, 'error'); } // Check if user exists $user_exists = $db->Execute("select * from " . TABLE_NEWS_AUTHORS . " where author_name = '" . zen_db_input($author_name) . "'"); if ($user_exists->RecordCount() > 0) { $error = true; $messageStack->add(ERROR_AUTHOR_EXISTS, 'error'); } // Check if email exists $email_exists = $db->Execute("select * from " . TABLE_NEWS_AUTHORS . " where lower(author_email) = '" . strtolower(zen_db_input($author_email)) . "'"); if ($email_exists->RecordCount() > 0) { $error = true; $messageStack->add(ERROR_EMAIL_EXISTS, 'error'); } if (!$error) { $sql_data_array = array( 'author_name' => $author_name, 'author_email' => $author_email, 'status' => '1', ); zen_db_perform(TABLE_NEWS_AUTHORS, $sql_data_array); $new_authors_id = $db->Insert_ID(); $messageStack->add_session(SUCCESS_NEW_AUTHOR, 'success'); zen_redirect(zen_href_link(FILENAME_NEWS_AUTHORS, 'page=' . $_GET['page'] . '&aID=' . $new_authors_id)); } break; case 'delete_author': $has_articles = zen_db_prepare_input($_POST['has_articles']); $delete_articles = zen_db_prepare_input($_POST['delete_articles']); $new_authors_id = zen_db_prepare_input($_POST['new_authors_id']); if ($has_articles) { if (($delete_articles)) { $articles = $db->Execute("select article_id from " . TABLE_NEWS_ARTICLES . " where authors_id = '" . (int)$authors_id . "'"); while (!$articles->EOF) { news_remove_article($articles->fields['article_id']); $articles->MoveNext(); } $messageStack->add_session(SUCCESS_ARTICLES_DELETED, 'success'); } else { if (!zen_not_null($new_authors_id)) { $error = true; $messageStack->add(ERROR_SELECT_AUTHOR, 'error'); break; } else { $sql_data_array = array('authors_id' => $new_authors_id); if (zen_db_perform(TABLE_NEWS_ARTICLES, $sql_data_array, 'update', 'authors_id = \'' . (int)$authors_id . '\'')) { $messageStack->add_session(SUCCESS_ARTICLES_REASSIGNED, 'success'); } } } } $db->Execute("delete from " . TABLE_NEWS_AUTHORS . " where authors_id = '" . (int)$authors_id . "'"); $messageStack->add_session(SUCCESS_DELETE_AUTHOR, 'success'); zen_redirect(zen_href_link(FILENAME_NEWS_AUTHORS, 'page=' . $_GET['page'] . (($new_authors_id) ? '&aID=' . $new_authors_id : ''))); break; case 'update_author': // Check if all fields are filled up if (!zen_not_null($author_name)) { $error = true; $messageStack->add(ERROR_BLANK_AUTHOR_NAME, 'error'); } if (!zen_not_null($author_email)) { $error = true; $messageStack->add(ERROR_BLANK_AUTHOR_EMAIL, 'error'); } // Check if name exists $user_exists = $db->Execute("select * from " . TABLE_NEWS_AUTHORS . " where author_name = '" . zen_db_input($author_name) . "' and authors_id != '" . (int)$authors_id . "'"); if ($user_exists->RecordCount() > 0) { $error = true; $messageStack->add(ERROR_AUTHOR_EXISTS, 'error'); } // Check if email exists $email_exists = $db->Execute("select * from " . TABLE_NEWS_AUTHORS . " where lower(author_email) = '" . strtolower(zen_db_input($author_email)) . "' and authors_id != '" . (int)$authors_id . "'"); if ($email_exists->RecordCount() > 0) { $error = true; $messageStack->add(ERROR_EMAIL_EXISTS, 'error'); } if (!$error) { $sql_data_array = array( 'author_name' => $author_name, 'author_email' => $author_email, ); zen_db_perform(TABLE_NEWS_AUTHORS, $sql_data_array, 'update', 'authors_id = \'' . (int)$authors_id . '\''); $messageStack->add_session(SUCCESS_UPDATE_AUTHOR, 'success'); zen_redirect(zen_href_link(FILENAME_NEWS_AUTHORS, 'page=' . $_GET['page'] . '&aID=' . $authors_id)); } break; } // start page output echo ''. "\n" . '' . '' . '' . '' . TITLE . '' . '' . '' . '' . '' . '' . '' . '' . '
' . ''; require(DIR_WS_INCLUDES . 'header.php'); echo '' . '' . '' . '' . '' . '' . '' . '' . '
' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '
' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '
ΝΌΚΎ
' . TEXT_NEWS_LEGEND_STATUS_OFF . '' . TEXT_NEWS_LEGEND_STATUS_ON . '' . TEXT_NEWS_LEGEND_EDIT . '' . TEXT_NEWS_LEGEND_DELETE . '' . TEXT_NEWS_LEGEND_INFO . '
' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . '' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '
' . '
' . zen_draw_separator('pixel_trans.gif', '1', '10') . '
' . '' . '' . '' . '' . '' . '
' . HEADING_TITLE . '' . zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '
' . '
' . '' . '' . ''; $heading = array(); $contents = array(); switch ($_GET['action']) { case 'new': $heading[] = array('text' => '' . TEXT_HEADING_NEW_AUTHOR . ''); $contents = array('form' => zen_draw_form('new_author', FILENAME_NEWS_AUTHORS, 'page=' . $_GET['page'] . '&aID=' . $aInfo->authors_id . '&query=add_author&action=new', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_NEW_INTRO); $contents[] = array('text' => '
' . TEXT_AUTHOR_NAME . '
' . zen_draw_input_field('author_name', (($author_name) ? $author_name : ''))); $contents[] = array('text' => TEXT_AUTHOR_EMAIL . '
' . zen_draw_input_field('author_email', (($author_email) ? $author_email : ''))); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'edit': $heading[] = array('text' => '' . TEXT_HEADING_EDIT_AUTHOR . ''); $contents = array('form' => zen_draw_form('edit_author', FILENAME_NEWS_AUTHORS, 'page=' . $_GET['page'] . '&aID=' . $aInfo->authors_id . '&query=update_author&action=edit', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_EDIT_INTRO); $contents[] = array('text' => '
' . TEXT_AUTHOR_NAME . '
' . zen_draw_input_field('author_name', (($author_name) ? $author_name : $aInfo->author_name))); $contents[] = array('text' => TEXT_AUTHOR_EMAIL . '
' . zen_draw_input_field('author_email', (($author_email) ? $author_email : $aInfo->author_email))); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'delete': $heading[] = array('text' => '' . TEXT_HEADING_DELETE_AUTHOR . ''); $contents = array('form' => zen_draw_form('delete_author', FILENAME_NEWS_AUTHORS, 'page=' . $_GET['page'] . '&aID=' . $aInfo->authors_id . '&query=delete_author&action=delete')); $contents[] = array('text' => TEXT_DELETE_INTRO); $contents[] = array('text' => '
' . $aInfo->author_name . ''); if ($aInfo->articles_count > 0) { $contents[] = array('text' => zen_draw_hidden_field('has_articles', '1') . '
' . sprintf(TEXT_DELETE_ARTICLES_PRODUCTS, $aInfo->articles_count) . '
' . zen_draw_radio_field('delete_articles', '1') . ' ' . TEXT_DELETE_ARTICLES . '
' . zen_draw_radio_field('delete_articles', '0', true) . TEXT_REASSIGN_ARTICLES . ' ' . zen_draw_pull_down_menu('new_authors_id', $authors_array, (($new_authors_id) ? $new_authors_id : ''))); } else { $contents[] = array('text' => zen_draw_hidden_field('has_articles', '0')); } $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (is_object($aInfo)) { $heading[] = array('text' => '' . $aInfo->author_name . ''); $contents[] = array('align' => 'center', 'text' => '' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('text' => '
' . TEXT_NO_OF_ARTICLES . ' ' . $aInfo->articles_count); } break; } if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) { $box = new box; echo ''; } echo '' . '
' . '' . '' . '' . '' . '' . '' . ''; $authors_array = array( array( 'id' => '', 'text' => TEXT_PLEASE_SELECT, ), ); $authors_query_raw = "select * from " . TABLE_NEWS_AUTHORS . " order by authors_id"; $authors_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $authors_query_raw, $authors_query_numrows); $authors = $db->Execute($authors_query_raw); while (!$authors->EOF) { if (($_GET['aID'] != $authors->fields['authors_id']) && ($_GET['action'] == 'delete')) { $authors_array[] = array( 'id' => $authors->fields['authors_id'], 'text' => $authors->fields['author_name'], ); } if (((!$_GET['aID']) || (@$_GET['aID'] == $authors->fields['authors_id'])) && (!$aInfo) && (substr($_GET['action'], 0, 3) != 'new')) { $authors_articles = $db->Execute("select count(*) as articles_count from " . TABLE_NEWS_ARTICLES . " where authors_id = '" . (int)$authors->fields['authors_id'] . "'"); $authors->fields = array_merge($authors->fields, $authors_articles->fields); $aInfo = new objectInfo($authors->fields); } if ( (is_object($aInfo)) && ($authors->fields['authors_id'] == $aInfo->authors_id) ) { echo ''; } else { echo ''; } echo '' . '' . '' . '' . ''; $authors->MoveNext(); } echo '' . '' . ''; if ($_GET['action'] != 'new') { echo '' . '' . ''; } echo '
' . TABLE_HEADING_AUTHOR . '' . TABLE_HEADING_EMAIL . '' . TABLE_HEADING_STATUS . '' . TABLE_HEADING_ACTION . ' 
' . $authors->fields['author_name'] . '<' . $authors->fields['author_email'] . '>'; if ($authors->fields['status'] == '1') { echo '' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . ''; } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . ''; } echo '' . '' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . ' ' . '' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . ' '; if ( (is_object($aInfo)) && ($authors->fields['authors_id'] == $aInfo->authors_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif') . ' '; } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' '; } echo '
' . '' . '' . '' . '' . '' . '
' . $authors_split->display_count($authors_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_AUTHORS) . '' . $authors_split->display_links($authors_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']) . '
' . '
' . zen_image_button('button_insert.gif', IMAGE_INSERT) . '
' . '
' . $box->infoBox($heading, $contents) . '
' . '
' . '
' . '' . ''; require(DIR_WS_INCLUDES . 'footer.php'); echo '' . ''. ''; require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>