示例#1
0
 /**
  * Добавляем ключевые слова к статье.
  *
  * @param integer $article_id ИД Статьи
  * @param array   $tags       Ключевые слова (теги)
  *
  * @return boolean
  */
 public function addArticleTags($article_id, $tags)
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/kwords.php';
     $kwords = new kwords();
     $ids = $kwords->add($tags, true);
     self::clearArticleTags($article_id);
     $sql = 'INSERT INTO articles_word (article_id, word_id, pos) VALUES ';
     if ($ids) {
         foreach ($ids as $position => $word_id) {
             $data[] = "({$article_id}, {$word_id}, {$position})";
         }
     }
     if (count($data) > 0) {
         $sql .= implode(', ', $data);
         $res = $DB->squery($sql);
         $tags = implode(', ', $tags);
         $sql = 'UPDATE articles_new SET keywords = ? WHERE id = ?';
         $DB->query($sql, $tags, $article_id);
         return $res;
     }
     return false;
 }
示例#2
0
         header_location_exit("/users/{$login}");
     }
     break;
 case "prof_change":
     // Ключевые слова !!! старые удаляются, новые добавляются не зависимо от результата обновления профессии UpdateProfDesc
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/kwords.php";
     $kwords = new kwords();
     if (count($_POST['prof_keys']) > 0) {
         foreach ($_POST['prof_keys'] as $prof_id => $keys) {
             $aOldIds = array_keys($kwords->getUserKeys($uid, $prof_id));
             $ids = array();
             $kwords->delUserKeys($uid, $prof_id);
             if (trim($keys)) {
                 $ukey = explode(",", $keys);
                 if (count($ukey) > 0) {
                     $ids = $kwords->add($ukey, true);
                     $kwords->addUserKeys($uid, $ids, $prof_id);
                 }
             }
             $kwords->moderUserKeys($uid, $prof_id, $aOldIds, $ids, $uid, $keys);
         }
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
     $obj_prof = new professions();
     $error_prof .= $obj_prof->UpdateProfDesc($uid, $_POST['prof_id'], str_replace(" ", "", $_POST['prof_cost_from']), str_replace(" ", "", $_POST['prof_cost_to']), str_replace(" ", "", $_POST['prof_cost_hour']), str_replace(" ", "", $_POST['prof_cost_1000']), $_POST['prof_cost_type'], $_POST['prof_cost_type_hour'], $_POST['prof_time_type'], $_POST['prof_time_from'], $_POST['prof_time_to'], $_POST['prof_text'], $errorProfText);
     if (!$error_prof) {
         $info_prof = "Изменения внесены";
     }
     $saved_prof_id = intval($_POST['prof_id']);
     break;
 case "spec_change":
/**
 * Сохранение уточнения к разделам в портфолио
 * 
 * @param object $objResponse xajaxResponse
 * @param  string $user_id UID пользователя
 * @param string $rec_type тип записи
 * @param array $aForm массив данных
 * @param string $sDrawFunc имя функции для выполнения после сохранения
 */
function _admEditPortfChoiceSaveForm(&$objResponse, $user_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '')
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/kwords.php';
    $kwords = new kwords();
    $aOldIds = array_keys($kwords->getUserKeys($user_id, $aForm['prof_id']));
    $ids = array();
    $kwords->delUserKeys($user_id, $aForm['prof_id']);
    if (trim($aForm['prof_keys'])) {
        $ukey = explode(',', $aForm['prof_keys']);
        if (count($ukey) > 0) {
            $ids = $kwords->add($ukey, true);
            $kwords->addUserKeys($user_id, $ids, $aForm['prof_id']);
        }
    }
    $kwords->moderUserKeys($user_id, $aForm['prof_id'], $aOldIds, $ids, $_SESSION['uid']);
    $sReason = _parseReason($aForm['user_id'], $aForm['adm_edit_text']);
    $obj_prof = new professions();
    $error_prof = $obj_prof->UpdateProfDesc($user_id, $aForm['prof_id'], str_replace(" ", "", $aForm['prof_cost_from']), str_replace(" ", "", $aForm['prof_cost_to']), str_replace(" ", "", $aForm['prof_cost_hour']), str_replace(" ", "", $aForm['prof_cost_1000']), $aForm['prof_cost_type'], $aForm['prof_cost_type_hour'], $aForm['prof_time_type'], $aForm['prof_time_from'], $aForm['prof_time_to'], $aForm['prof_text'], $errorProfText, $_SESSION['uid'], $sReason);
    if (!$error_prof) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/portfolio.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
        $user = new users();
        $projs = array();
        $user->GetUserByUID($user_id);
        if ($user->is_pro == 't') {
            $show_preview = isset($aForm['show_preview']) && $aForm['show_preview'] ? $aForm['show_preview'] : 0;
            portfolio::ChangeGrPrev($user_id, $aForm['prof_id'], $projs, $show_preview);
        }
        messages::portfChoiceModifiedNotification($user_id, $aForm['prof_id'], $sReason);
        $objResponse->script('adm_edit_content.cancel();');
        if ($sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2') {
            // если случаев будет больше - вынести в отдельную функцию
            $objResponse->script('parent.adm_edit_content.cancel();');
            $objResponse->script('user_content.getContents()');
        } elseif ($sDrawFunc == 'suspect') {
            // шерстим все профили на наличие контактов в админке
            $objResponse->script("window.location = '/siteadmin/suspicious_contacts/?site={$aForm['p_site']}&action=resolve&sid={$aForm['p_sid']}&page={$aForm['p_page']}'");
        } else {
            // действие после редактирования по умолчанию
            $objResponse->script('window.location.reload(true)');
        }
    } else {
        $sParent = $sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2' ? 'parent.' : '';
        $error_prof = str_replace(array('<br />', '<br/>', '<br>'), "\n", $error_prof);
        $objResponse->alert($error_prof);
        $objResponse->script("{$sParent}adm_edit_content.disabled = false; {$sParent}adm_edit_content.button();");
    }
}
示例#4
0
 public function updateUserKeywordsProfessions($uid, $prof_id, $keywords)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/kwords.php";
     $kwords = new kwords();
     $aOldIds = array_keys($kwords->getUserKeys($uid, $prof_id));
     $ids = array();
     $kwords->delUserKeys($uid, $prof_id);
     if (trim($keywords)) {
         $ukey = explode(",", $keywords);
         if (count($ukey) > 0) {
             $ukey = array_map('antispam', $ukey);
             $ids = $kwords->add($ukey, true);
             $kwords->addUserKeys($uid, $ids, $prof_id);
         }
     }
     $kwords->moderUserKeys($uid, $prof_id, $aOldIds, $ids, $uid, $keywords);
 }