Ejemplo n.º 1
0
 /**
  * Создает xml файл webprof
  * 
  * @return text $filename полный путь к файлу куда webdav должен сохранить получившийся xml
  */
 public function webprofGenerateRss($filename)
 {
     global $DB, $GLOBALS;
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/kwords.php";
     function getProfessionName($id, $professions)
     {
         foreach ($professions as $profession) {
             if ($profession['id'] == $id) {
                 return "{$profession['groupname']} / {$profession['profname']}";
             }
         }
     }
     $spec = array(9, 37, 27, 86, 8, 164, 10);
     $users = self::getListForWebprof($spec);
     $professions = professions::GetAllProfessions();
     $xml = '';
     $host = str_replace(HTTP_PREFIX, '', $GLOBALS['host']);
     $HTTP_PREFIX = "https://";
     $XMLData = '';
     $xml .= '<?xml version="1.0" encoding="utf-8"?>' . "\n";
     $xml .= '<!DOCTYPE source>' . "\n";
     $xml .= '<source creation-time="' . date('Y-m-d H:i:s') . ' GMT+3" host="' . $host . '">' . "\n";
     $xml .= '   <users>' . "\n";
     if (is_array($users) && count($users)) {
         $XMLData = '';
         foreach ($users as $user) {
             $frl_name = trim("{$user['uname']} {$user['usurname']}");
             $frl_name = iconv('CP1251', 'UTF-8', htmlspecialchars($frl_name, ENT_QUOTES));
             $frl_spec_main = iconv('CP1251', 'UTF-8', htmlspecialchars(getProfessionName($user['spec'], $professions), ENT_QUOTES));
             switch ($user['status_type']) {
                 case '0':
                     $frl_status = 'free';
                     break;
                 case '1':
                     $frl_status = 'busy';
                     break;
                 case '2':
                     $frl_status = 'absent';
                     break;
                 default:
                     $frl_status = 'no status';
                     break;
             }
             $frl_spec_ext = '';
             $spec_ext_ids = professions::GetProfsAddSpec($user['uid']);
             if ($spec_ext_ids) {
                 foreach ($spec_ext_ids as $spec_id) {
                     $frl_spec_ext .= "<spec>" . iconv('CP1251', 'UTF-8', htmlspecialchars(getProfessionName($spec_id, $professions), ENT_QUOTES)) . "</spec>";
                 }
             }
             $frl_tags = '';
             $tags = kwords::getUserKeys($user['uid'], $user['spec']);
             $bIsModer = kwords::isModerUserKeys($user['uid'], $user['spec']);
             if ($tags && !$bIsModer) {
                 foreach ($tags as $tag) {
                     $frl_tags .= "<tag>" . iconv('CP1251', 'UTF-8', htmlspecialchars($tag, ENT_QUOTES)) . "</tag>";
                 }
             }
             $frl_cost_hour = '';
             $frl_cost_month = '';
             if ($user['cost_hour'] != 0) {
                 $frl_cost_hour = (double) $user['cost_hour'];
                 switch ($user['cost_type_hour']) {
                     case '1':
                         $frl_cost_hour .= " Euro";
                         break;
                     case '2':
                         $frl_cost_hour .= " Руб";
                         break;
                     case '3':
                         $frl_cost_hour .= " FM";
                         break;
                     default:
                         $frl_cost_hour .= " USD";
                         break;
                 }
                 $frl_cost_hour = iconv('CP1251', 'UTF-8', $frl_cost_hour);
             }
             if ($user['cost_month'] != 0) {
                 $frl_cost_month = (double) $user['cost_month'];
                 switch ($user['cost_type_month']) {
                     case '1':
                         $frl_cost_month .= " Euro";
                         break;
                     case '2':
                         $frl_cost_month .= " Руб";
                         break;
                     case '3':
                         $frl_cost_month .= " FM";
                         break;
                     default:
                         $frl_cost_month .= " USD";
                         break;
                 }
                 $frl_cost_month = iconv('CP1251', 'UTF-8', $frl_cost_month);
             }
             $XMLData .= "<user>";
             $XMLData .= "<name>{$frl_name}</name>";
             $XMLData .= "<spec_main>{$frl_spec_main}</spec_main>";
             $XMLData .= "<spec_ext>{$frl_spec_ext}</spec_ext>";
             $XMLData .= "<status>{$frl_status}</status>";
             $XMLData .= "<rating>{$user['rating']}</rating>";
             $XMLData .= "<cost_from_hour>{$frl_cost_hour}</cost_from_hour>";
             $XMLData .= "<cost_from_month>{$frl_cost_month}</cost_from_month>";
             $XMLData .= "<url>" . $HTTP_PREFIX . "{$host}/users/{$user['login']}</url>";
             $XMLData .= "<tags>{$frl_tags}</tags>";
             $XMLData .= "</user>\n";
         }
     }
     $xml .= $XMLData . "\n";
     $xml .= '   </users>' . "\n";
     $xml .= '</source>' . "\n";
     $file = new CFile();
     return $file->putContent($filename, $xml);
 }
Ejemplo n.º 2
0
 foreach ($prjs as $ikey => $prj) {
     if (!$prj['id']) {
         continue;
     }
     $prof_id = $prj['prof_id'];
     if ($prj['is_blocked'] == 't' && $user->uid != get_uid(false) && !hasPermissions('users')) {
         continue;
     }
     if ($prj['prof_id'] == professions::BEST_PROF_ID || $prj['prof_id'] == professions::CLIENTS_PROF_ID) {
         continue;
     }
     $links_keyword = array();
     $links_keyword_hide = array();
     $is_count_project = true;
     $user_keys = kwords::getUserKeys($user->uid, $prof_id);
     $bIsModer = kwords::isModerUserKeys($user->uid, $prof_id);
     $c = $kword_count = 0;
     if ($user_keys) {
         $kword_count = count($user_keys);
         foreach ($user_keys as $key) {
             $sKey = stripslashes($bIsModer ? $stop_words->replace($key, 'plain') : $key);
             if (++$c > kwords::MAX_KWORDS_PORTFOLIO) {
                 $links_keyword_hide[] = urlencode($sKey) . ',,' . change_q_x($sKey, true, false);
             } else {
                 $links_keyword[] = sprintf($html_keyword, urlencode($sKey), change_q_x($sKey, true, false));
             }
         }
     }
     $curprof = $prj['prof_id'];
     if ($lastprof != $curprof) {
         $i = 1;
Ejemplo n.º 3
0
 public function loadProfessionUserKeyword($uid, $prof_id)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/kwords.php";
     $html_keyword_js = '<a href="/freelancers/?word=$1" class="inherit">$2</a>';
     $html_keyword = preg_replace('/\\$\\d/', '%s', $html_keyword_js);
     $stop_words = new stop_words(hasPermissions('users'));
     $wkeys = kwords::getUserKeys($uid, $prof_id);
     $modkey = kwords::isModerUserKeys($uid, $prof_id);
     $kword_count = 0;
     $c = 0;
     if ($wkeys) {
         $links_keyword = array();
         $links_keyword_hide = array();
         $kword_count = count($wkeys);
         foreach ($wkeys as $key) {
             $sKey = stripslashes($modkey ? $stop_words->replace($key, 'plain') : $key);
             if (++$c > kwords::MAX_KWORDS_PORTFOLIO) {
                 $links_keyword_hide[] = urlencode($sKey) . ',,' . change_q_x($sKey, true, false);
             } else {
                 $links_keyword[] = sprintf($html_keyword, urlencode($sKey), change_q_x($sKey, true, false));
             }
         }
         $wkeys['links_keyword'] = $links_keyword;
         $wkeys['links_keyword_hide'] = $links_keyword_hide;
         $wkeys['count'] = $kword_count;
     }
     return $wkeys;
 }