function removeWork($uid, $params)
{
    $objResponse =& new xajaxResponse();
    if (!$uid) {
        $uid = get_uid(false);
    }
    $uid = intval($uid);
    $work_id = intval($params['id']);
    $prof_id = intval($params['prof_id']);
    if ($uid != get_uid(false) || !get_uid(false) || $work_id < 0) {
        return $objResponse;
    }
    $deleted = portfolio::DelPortf($uid, $work_id);
    if (!$deleted) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
        $stop_words = new stop_words(hasPermissions('users'));
        $profession = new professions();
        $portfolio = new portfolio();
        $user = new users();
        $user->login = $_SESSION['login'];
        $user->uid = $_SESSION['uid'];
        $user->is_pro = is_pro() ? 't' : 'f';
        $is_owner = $uid == $_SESSION['uid'];
        $pinfo = current(portfolio::getPortfolioCategory($prof_id));
        $pinfo['mainprofname'] = $pinfo['group_name'];
        $pinfo['profname'] = $pinfo['prof_name'];
        $pinfo['gr_prevs'] = $pinfo['show_preview'];
        $pinfo = $profession->prepareCostText($pinfo, $stop_words);
        $works = $portfolio->GetPortf($uid, $prof_id, true);
        if (!empty($works)) {
            $result = portfolio::prepareDataPortfolio($works, $uid, $stop_words, true);
            extract($result);
            $work[0]['id'] = 100;
            ob_start();
            include_once $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
            $sWorks = ob_get_contents();
            ob_end_clean();
        } else {
            $work[0]['id'] = null;
            $pp_noblocks[$prof_id] = array();
            ob_start();
            include $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
            $sWorks = ob_get_contents();
            ob_end_clean();
        }
        if ($sWorks != '') {
            $objResponse->assign("prof_works_{$prof_id}", 'innerHTML', $sWorks);
        }
        $objResponse->script("\$('portfolio_work_edit').getParent().dispose()");
    } else {
        $objResponse->call('alert', 'Ошибка, работу удалить не удалось.');
    }
    return $objResponse;
}
Beispiel #2
0
 /**
  * Рассортировываем портфолио.
  * 
  * @param array   $prjs       Работы портфолио @see self::GetPortf();
  * @param integer $uid        Ид пользователя
  * @param object  $stop_words @see class new stop_words()
  * @param integer $one_select Костыль для подгрузки работ в определенную категорию профессии, создает переменную $prjs которая необходима в шаблоне 
  */
 public function prepareDataPortfolio($works, $uid, $stop_words, $one_select = false)
 {
     $i = $block = 0;
     $size_block = 3;
     $is_owner = $uid == get_uid(false);
     // Рассортировываем портфолио
     foreach ($works as $prj) {
         if ($prj['is_blocked'] == 't' && $uid != get_uid(false) && !hasPermissions('users')) {
             continue;
         }
         if ($i >= $size_block || $prj['prof_id'] != $old_prof) {
             ++$block;
             $i = 0;
             //$i = $is_owner && !$add_work_block[$prj['prof_id']] ? 1 : 0;
             //$add_work_block[$prj['prof_id']] = true;
         }
         if ($one_select) {
             $prjs[$block][] = $prj;
         }
         $pp[$prj['prof_id']][$block][] = $prj;
         $pp_noblocks[$prj['prof_id']][] = $prj;
         $sName = $prj['name'];
         $pt[$prj['prof_id']][$block][$prj['id']] = $sName;
         if (!isset($pname[$prj['prof_id']])) {
             $prj = professions::prepareCostText($prj, $stop_words);
             $pname[$prj['prof_id']] = $prj;
         }
         ++$i;
         $old_prof = $prj['prof_id'];
         // Ключевые слова
         if (empty($ukeys[$prj['prof_id']])) {
             $ukeys[$prj['prof_id']] = professions::loadProfessionUserKeyword($uid, $prj['prof_id']);
         }
     }
     $result = array('add_work_block' => $add_work_block, 'pp' => $pp, 'pp_noblocks' => $pp_noblocks, 'pt' => $pt, 'pname' => $pname, 'ukeys' => $ukeys);
     if ($one_select) {
         $result['prjs'] = $prjs;
     }
     return $result;
 }