/**
 * Сохранение уточнения к разделам в портфолио
 * 
 * @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();");
    }
}
Exemple #2
0
 /**
  * Уточнения к разделам в портфолио. Утверждение/удаление записи
  * 
  * @param  string $stream_id идентификатор потока
  * @param  int $user_id идентификатор модератора
  * @param  int $from_id идентификатор пользователя
  * @param  int $rec_id идентификатор записи
  * @param  int $rec_type тип записи 
  * @param  int $action действие: 1 - утверждено, 2 - удалено
  * @param  string $is_sent было ли отправлено уведомление
  * @param  string $reason причина удаления
  */
 function resolvePortfChoice($stream_id = '', $user_id = 0, $from_id = 0, $rec_id = 0, $rec_type = 0, $action = 1, $is_sent = '', $reason = '')
 {
     $bRet = false;
     $aChange = $GLOBALS['DB']->row('SELECT c.prof_id, c.ucolumn, c.old_val, u.login, u.uname, u.usurname 
         FROM portf_choise_change c 
         INNER JOIN moderation m ON m.rec_id = c.id 
         INNER JOIN users u ON u.uid = c.user_id 
         WHERE c.id = ?i AND m.rec_type = ?i AND m.stream_id = ?', $rec_id, self::MODER_PORTF_CHOISE, $stream_id);
     if ($aChange) {
         $bRet = true;
         if ($action == 2) {
             // возвращаем старые значения
             if ($aChange['ucolumn'] == 'text') {
                 if (!$aChange['old_val']) {
                     $aChange['old_val'] = null;
                 }
                 $GLOBALS['DB']->query("UPDATE portf_choise SET portf_text = ? WHERE user_id = ?i AND prof_id = ?i", $aChange['old_val'], $from_id, $aChange['prof_id']);
             } else {
                 require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/kwords.php';
                 $kwords = new kwords();
                 $kwords->delUserKeys($from_id, $aChange['prof_id']);
                 if ($aChange['old_val']) {
                     $aKwords = explode(',', $aChange['old_val']);
                     $kwords->addUserKeys($from_id, $aKwords, $aChange['prof_id']);
                 }
             }
         }
         $GLOBALS['DB']->query('DELETE FROM portf_choise_change WHERE id = ?i', $rec_id);
         $GLOBALS['DB']->query('DELETE FROM moderation WHERE rec_id = ?i AND rec_type = ?i', $rec_id, self::MODER_PORTF_CHOISE);
     }
     return $bRet;
 }
Exemple #3
0
         $error_serv = 'Данные не сохранены<br /><br />' . $error_serv;
     }
     if (!$error_serv) {
         $info_serv = "Изменения внесены";
         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 = "Изменения внесены";
Exemple #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);
 }