Beispiel #1
0
 /**
  * Создание отложенной платной опции на основе опции созданной в мастере
  *  
  * @param type $option  Данные опции созданной в мастере @see table - wizad_billing
  * @return null|boolean     
  */
 public function createDraftAccountOperation($option)
 {
     global $DB;
     switch ($option['op_code']) {
         // Публикация конкурса
         case 9:
         case 106:
             $descr = "Публикация конкурса";
             $count = 1;
             $op_type = 'contest';
             $parent_id = $option['parent'];
             $src_id = $str_option = null;
             break;
             // Платный проект/конкурс
         // Платный проект/конкурс
         case 53:
             $step_emp = new step_employer();
             $project = $step_emp->getProjectById($option['parent']);
             $parent_id = $option['parent'];
             if ($project['kind'] == 7) {
                 $title = "конкурс";
                 $op_type = 'contest';
             } else {
                 $title = "проект";
                 $op_type = 'project';
             }
             $count = 1;
             $src_id = $str_option = null;
             $descr = "Платный {$title} / ";
             switch ($option['option']) {
                 case step_employer::PROJECT_OPTION_TOP:
                     $str_option = 'top';
                     $count = $project['top_count'];
                     $descr .= "закрепление наверху на " . (int) $project['top_count'] . " " . ending($project['top_count'], "день", "дня", "дней");
                     break;
                 case step_employer::PROJECT_OPTION_COLOR:
                     $str_option = 'color';
                     $descr .= "подсветка фоном";
                     break;
                 case step_employer::PROJECT_OPTION_BOLD:
                     $str_option = 'bold';
                     $descr .= "жирный шрифт";
                     break;
                 case step_employer::PROJECT_OPTION_LOGO:
                     $str_option = 'logo';
                     $descr .= "логотип";
                     $src_id = $project['logo_id'];
                     break;
             }
             break;
             // Покупка аккаунта ПРО
         // Покупка аккаунта ПРО
         case 48:
         case 49:
         case 50:
         case 51:
         case 76:
         case 15:
             $descr = "Аккаунт PRO";
             $count = 1;
             $src_id = $parent_id = $str_option = $op_type = null;
             break;
             // Покупка платных ответов
         // Покупка платных ответов
         case step_freelancer::OFFERS_OP_CODE:
             $descr = "Покупка ответов на проекты (кол-во: {$option['option']})";
             $count = $option['option'];
             $src_id = $parent_id = $str_option = $op_type = null;
             break;
     }
     $pay_options = array("uid" => wizard::getUserIDReg(), "op_code" => $option['op_code'], "op_type" => $op_type, "option" => $str_option, "parent_id" => $parent_id, "src_id" => $src_id, "op_count" => $count, "ammount" => $option['ammount'], "descr" => $descr, "comment" => $descr, "status" => null);
     $id = $DB->insert("draft_account_operations", $pay_options, 'id');
     if ($id) {
         $this->draft[] = $id;
         return $option['id'];
     }
     return false;
 }
 public function completeData($type_role = 1)
 {
     if ($this->isDisable()) {
         header("Location: /wizard/registration/?step=1");
         exit;
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/employer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/city.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/country.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/blogs.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/commune.php";
     $themes_blogs = blogs::getRandomThemes(5);
     $themes_commune = commune::getRandomCommunes(3);
     $month = array('1' => 'января', '2' => 'февраля', '3' => 'марта', '4' => 'апреля', '5' => 'мая', '6' => 'июня', '7' => 'июля', '8' => 'августа', '9' => 'сентября', '10' => 'октября', '11' => 'ноября', '12' => 'декабря');
     if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
         $user = new employer();
         $checkPRO = $this->checkWizardPRO(array(step_employer::OP_CODE_PRO));
         $pro_emp = $checkPRO['id'] > 0 ? 1 : 0;
         if ($pro_emp) {
             $week_pro = round($checkPRO['ammount'] / 10);
         }
     } else {
         $user = new freelancer();
         $checkPRO = $this->checkWizardPRO(step_freelancer::getOperationCodePRO());
         $pro_frl = $checkPRO['id'] > 0 ? 1 : 0;
         if ($pro_frl) {
             $op_code = $checkPRO['op_code'];
         }
     }
     $user->GetUserByUID(wizard::getUserIDReg());
     $info_for_reg = unserialize($user->info_for_reg);
     $uname = $user->uname;
     $usurname = $user->usurname;
     $sex = $user->sex == 't' ? 1 : ($user->sex == 'f' ? 0 : -1);
     $birthday = strtotime($user->birthday);
     if ($birthday) {
         $bday = date('d', $birthday);
         $bmonth = (int) date('m', $birthday);
         $bmonth_value = $month[$bmonth];
         $byear = date('Y', $birthday);
     } else {
         $bday = '';
         $bmonth = (int) date('m', $birthday);
         $bmonth_value = $month[$bmonth];
         $byear = '';
     }
     $city = $user->city;
     if ($city) {
         $city_value = city::GetCityName($city);
     }
     $country = $user->country;
     if ($country) {
         $country_value = country::GetCountryName($country);
     }
     if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
         $company = $user->compname;
         $about_company = $user->company;
         $logo_name = $user->logo;
         $dir = "users/" . substr($user->login, 0, 2) . "/" . $user->login . "/logo/";
         $logo_path = WDCPREFIX . "/" . $dir . $user->logo;
     }
     $info['site'] = $this->loadMultiVal('site', 'site', $user);
     $info['email'] = $this->loadMultiVal('second_email', 'email', $user);
     $info['phone'] = $this->loadMultiVal('phone', 'phone', $user);
     $info['icq'] = $this->loadMultiVal('icq', 'icq', $user);
     $info['skype'] = $this->loadMultiVal('skype', 'skype', $user);
     $info['jabber'] = $this->loadMultiVal('jabber', 'jabber', $user);
     $info['lj'] = $this->loadMultiVal('ljuser', 'lj', $user);
     $action = __paramInit('string', null, 'action');
     if ($action == 'upd_info') {
         $info_for_reg = $_POST['info_for_reg'];
         if ($info_for_reg['email_0'] !== null) {
             $info_for_reg['second_email'] = $info_for_reg['email_0'];
             unset($info_for_reg['email_0']);
         }
         if ($info_for_reg['phone_0'] !== null) {
             $info_for_reg['phone'] = $info_for_reg['phone_0'];
             unset($info_for_reg['phone_0']);
         }
         if ($info_for_reg['site_0'] !== null) {
             $info_for_reg['site'] = $info_for_reg['site_0'];
             unset($info_for_reg['site_0']);
         }
         if ($info_for_reg['lj_0'] !== null) {
             $info_for_reg['ljuser'] = $info_for_reg['lj_0'];
             unset($info_for_reg['lj_0']);
         }
         if ($info_for_reg['jabber_0'] !== null) {
             $info_for_reg['jabber'] = $info_for_reg['jabber_0'];
             unset($info_for_reg['jabber_0']);
         }
         if ($info_for_reg['skype_0'] !== null) {
             $info_for_reg['skype'] = $info_for_reg['skype_0'];
             unset($info_for_reg['skype_0']);
         }
         if ($info_for_reg['icq_0'] !== null) {
             $info_for_reg['icq'] = $info_for_reg['icq_0'];
             unset($info_for_reg['icq_0']);
         }
         if ($info_for_reg['compname'] !== null) {
             $info_for_reg['company'] = $info_for_reg['compname'];
             unset($info_for_reg['compname']);
         }
         $info_for_reg = array_map('intval', $info_for_reg);
         $user->info_for_reg = serialize($info_for_reg);
         $uname = __paramInit('string', null, 'uname', null, 21);
         $usurname = __paramInit('string', null, 'usurname', null, 21);
         if ($uname == '') {
             $error['uname'] = "Поле заполнено некорректно";
         }
         if ($usurname == '') {
             $error['usurname'] = "Поле заполнено некорректно";
         }
         if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $uname)) {
             $error['uname'] = "Поле заполнено некорректно";
         } else {
             $user->uname = $uname;
         }
         if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $usurname)) {
             $error['usurname'] = "Поле заполнено некорректно";
         } else {
             $user->usurname = $usurname;
         }
         $sex = __paramInit('int', null, 'sex', 1);
         // по умолчанию мужской пол
         $user->sex = $sex == 1 ? 't' : 'f';
         $bday = __paramInit('int', null, 'bday', null);
         $bmonth = __paramInit('int', null, 'bmonth_db_id', 1);
         $bmonth_value = __paramInit('string', null, 'bmonth');
         $byear = __paramInit('int', null, 'byear', null);
         if ($bday != null && $byear != null) {
             if (!is_numeric($bday) || !is_numeric($byear) || !checkdate($bmonth, $bday, $byear) || $byear < 1945 || $byear > date('Y')) {
                 $error['birthday'] = "Поле заполнено некорректно";
             } else {
                 $user->birthday = dateFormat("Y-m-d", $byear . "-" . $bmonth . "-" . $bday);
             }
         } else {
             $user->birthday = "1910-01-01";
         }
         if (!$error['birthday'] && $user->birthday && date("Y", strtotime($user->birthday)) >= date("Y")) {
             $error['birthday'] = "Поле заполнено некорректно";
         }
         $city = __paramInit('int', null, 'city_db_id', 0);
         $city_value = __paramInit('string', null, 'city', false);
         $country = __paramInit('int', null, 'country_db_id', 0);
         $country_value = __paramInit('string', null, 'country', false);
         if ($city == 0 && strlen($city_value) != 0) {
             $error['city'] = 'Поле заполнено некорректно';
         }
         if ($country == 0 && strlen($country_value) != 0) {
             $error['country'] = 'Поле заполнено некорректно';
         }
         $user->country = $country;
         $user->city = $city;
         $company = __paramInit('string', null, 'company') ? substr(__paramInit('string', null, 'company'), 0, 64) : '';
         $about_company = __paramInit('string', null, 'about_company');
         $user->compname = $company;
         if (strlen($about_company) > 500) {
             $error['company'] = "Количество знаков в тексте о компании превышает допустимое значение";
         } else {
             $user->company = $about_company;
         }
         $logo_id = __paramInit('int', null, 'logo_company');
         $logo_name = __paramInit('string', null, 'logo_name');
         if ($logo_name) {
             $user->logo = $logo_name;
             $user->Update(wizard::getUserIDReg(), $res);
         }
         $info['site'] = $this->initMultiVal('site');
         $info['email'] = $this->initMultiVal('email');
         $info['phone'] = $this->initMultiVal('phone');
         $info['icq'] = $this->initMultiVal('icq');
         $info['skype'] = $this->initMultiVal('skype');
         $info['jabber'] = $this->initMultiVal('jabber');
         $info['lj'] = $this->initMultiVal('lj');
         if (!empty($info['site'])) {
             foreach ($info['site'] as $i => $value) {
                 $name = 'site' . ($i != 0 ? "_{$i}" : "");
                 if (!url_validate(addhttp($value), true) && trimhttp($value) != '') {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = addhttp($value);
                 }
             }
         }
         if (!empty($info['email'])) {
             foreach ($info['email'] as $i => $value) {
                 if ($i == 0) {
                     $name_save = "second_email";
                 } else {
                     $name_save = "email_{$i}";
                 }
                 $name = 'email' . ($i != 0 ? "_{$i}" : "");
                 if (!is_email($value) && $value != '') {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name_save} = $value;
                 }
             }
         }
         if (!empty($info['phone'])) {
             foreach ($info['phone'] as $i => $value) {
                 $name = 'phone' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[-+0-9)( #]*\$/", $value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['icq'])) {
             foreach ($info['icq'] as $i => $value) {
                 $name = 'icq' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[-0-9\\s]*\$/", $value) && !is_email($value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['skype'])) {
             foreach ($info['skype'] as $i => $value) {
                 $name = 'skype' . ($i != 0 ? "_{$i}" : "");
                 $user->{$name} = $value;
             }
         }
         if (!empty($info['jabber'])) {
             foreach ($info['jabber'] as $i => $value) {
                 $name = 'jabber' . ($i != 0 ? "_{$i}" : "");
                 if (strlen($value) > 255) {
                     $error[$name] = "Количество знаков превышает допустимое значение";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['lj'])) {
             foreach ($info['lj'] as $i => $value) {
                 if ($i == 0) {
                     $name_save = "ljuser";
                 } else {
                     $name_save = "lj_{$i}";
                 }
                 $name = 'lj' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[a-zA-Z0-9_-]*\$/", $value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name_save} = $value;
                 }
             }
         }
         if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
             $pro_emp = __paramInit('int', null, 'pro-emp', false);
             if ($pro_emp) {
                 $week_pro = round(__paramInit('int', null, 'week_pro', 0));
             }
         } else {
             $ammount = 0;
             $pro_frl = __paramInit('int', null, 'pro-frl', false);
             if ($pro_frl) {
                 $pro = __paramInit('string', null, 'pro', -1);
                 switch ($pro) {
                     case "1week":
                         $op_code = 76;
                         $ammount = 7;
                         break;
                     case "1":
                         $op_code = 48;
                         $ammount = 19;
                         break;
                     case "3":
                         $op_code = 49;
                         $ammount = 54;
                         break;
                     case "6":
                         $op_code = 50;
                         $ammount = 102;
                         break;
                     case "12":
                         $op_code = 51;
                         $ammount = 180;
                         break;
                     case "-1":
                     default:
                         $ammount = 0;
                         break;
                 }
             }
         }
         if (!$error && wizard::getUserIDReg()) {
             $error['save'] = $user->Update(wizard::getUserIDReg(), $res);
             if (!$error['save']) {
                 if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
                     $ammount = $week_pro * 10;
                     if ($ammount > 0) {
                         $checkPRO = $this->checkWizardPRO(step_employer::OP_CODE_PRO);
                         if ($checkPRO['id'] > 0) {
                             $update = array("ammount" => $ammount);
                             wizard_billing::editPaidOption($update, $checkPRO['id']);
                         } else {
                             $insert = array("wiz_uid" => step_wizard::getWizardUserID(), "op_code" => step_employer::OP_CODE_PRO, "type" => 3, "ammount" => $ammount, "parent" => wizard::getUserIDReg());
                             wizard_billing::addPaidOption($insert);
                         }
                     } else {
                         $sql = "DELETE FROM wizard_billing WHERE wiz_uid = ? AND op_code = ?";
                         $this->_db->query($sql, step_wizard::getWizardUserID(), step_employer::OP_CODE_PRO);
                     }
                 } else {
                     // Чистим
                     $sql = "DELETE FROM wizard_billing WHERE wiz_uid = ? AND op_code IN (?l)";
                     $this->_db->query($sql, step_wizard::getWizardUserID(), step_freelancer::getOperationCodePRO());
                     if ($ammount > 0) {
                         $insert = array("wiz_uid" => step_wizard::getWizardUserID(), "op_code" => $op_code, "type" => 4, "ammount" => $ammount, "parent" => wizard::getUserIDReg());
                         wizard_billing::addPaidOption($insert);
                     }
                 }
                 $this->parent->setCompliteStep(true);
                 $this->parent->setNextStep($this->parent->getPosition() + 1);
                 header("Location: /wizard/registration/");
                 exit;
             }
         }
         if ($logo_id > 0) {
             $file = new CFile($logo_id);
             $logo_path = WDCPREFIX . "/" . $file->path . $file->name;
         }
     }
     include $_SERVER['DOCUMENT_ROOT'] . "/wizard/registration/steps/tpl.step.info.php";
 }
 /**
  * Переносим ответы на проекты в работающие таблицы
  * 
  * @param array $offers  Ответы на проекты
  * @return array
  */
 public function transferOffers($offers)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects_offers.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/contest.php";
     foreach ($offers as $k => $offer) {
         $pict1 = str_replace("sm_", "", $offer['pict1']);
         $pict2 = str_replace("sm_", "", $offer['pict2']);
         $pict3 = str_replace("sm_", "", $offer['pict3']);
         // Переносим файлы в рабочие папки сайта
         $files = $this->_db->rows("SELECT DISTINCT id FROM file_wizard WHERE fname IN (?l)", array($pict1, $pict2, $pict3));
         if ($files) {
             $dir = "users/" . substr($this->user->login, 0, 2) . "/" . $this->user->login . "/upload/";
             $table = 'file';
             $picts = $this->transferFiles($files, $table, $dir, false);
             $sm_files = $this->_db->rows("SELECT DISTINCT id FROM file_wizard WHERE fname IN (?l)", array($offer['pict1'], $offer['pict2'], $offer['pict3']));
             if ($sm_files) {
                 $sm_picts = $this->transferFiles($sm_files, $table, $dir, false);
             }
         }
         if ($offer['kind'] != 7) {
             $error = projects_offers::AddOffer(wizard::getUserIDReg(), $offer['project_id'], $offer['cost_from'], $offer['cost_to'], $offer['cost_currency'], $offer['time_from'], $offer['time_to'], $offer['time_type'], $offer['descr'], 0, 0, 0, null, null, null, null, null, null, $picts[0]['fname'], $picts[1]['fname'], $picts[2]['fname'], $sm_picts[0]['fname'], $sm_picts[1]['fname'], $sm_picts[2]['fname']);
         } else {
             // Пишем ответ на конкурс
             $contest = new contest($offer['project_id'], wizard::getUserIDReg());
             $error = $contest->CreateOffer($offer['descr'], implode('/', $files), false);
             if ($picts && $contest->new_oid) {
                 $content_pict = array();
                 foreach ($picts as $k => $pict) {
                     $content_pict[] = array('uid' => wizard::getUserIDReg(), 'file' => $pict['id'], 'prev' => $sm_picts[$k]['id'], 'orig_name' => $pict['orig_name'], 'post_date' => date('Y-m-d H:i:s'));
                 }
                 $contest->addOfferFiles($contest->new_oid, $content_pict);
             }
         }
         if (!$error) {
             $delete_offers[] = $offer['id'];
         } else {
             $error_offer[] = $error . " - ответ на проект #{$offer['id']}";
         }
         unset($error);
     }
     // Очищаем перенесенные данные если нет ошибок если есть выводим
     if ($error_offer) {
         foreach ($error_offer as $error) {
             $this->log->writeln("Error transfer offer content - user (" . wizard::getUserIDReg() . "|" . $this->getWizardUserID() . ") - Error: {$error}");
         }
     } else {
         if ($delete_offers) {
             $this->_db->query("DELETE FROM wizard_offers WHERE id IN (?l) AND wiz_uid = ?", $delete_offers, $this->getWizardUserID());
         }
     }
     return $error_offer;
 }
Beispiel #4
0
 /**
  * Создание отложенной платной опции на основе опции созданной в мастере.
  *  
  * @param type $option Данные опции созданной в мастере @see table - wizad_billing
  *
  * @return null|bool
  */
 public function createDraftAccountOperation($option)
 {
     global $DB;
     switch ($option['op_code']) {
         // Публикация конкурса
         case 9:
         case 106:
             $descr = 'Публикация конкурса';
             $count = 1;
             $op_type = 'contest';
             $parent_id = $option['parent'];
             $src_id = $str_option = null;
             break;
             // Платный проект/конкурс
         // Платный проект/конкурс
         case 53:
             $step_emp = new step_employer();
             $project = $step_emp->getProjectById($option['parent']);
             $parent_id = $option['parent'];
             if ($project['kind'] == 7) {
                 $title = 'конкурс';
                 $op_type = 'contest';
             } else {
                 $title = 'проект';
                 $op_type = 'project';
             }
             $count = 1;
             $src_id = $str_option = null;
             $descr = "Платный {$title} / ";
             switch ($option['option']) {
                 case step_employer::PROJECT_OPTION_TOP:
                     $str_option = 'top';
                     $count = $project['top_count'];
                     $descr .= 'закрепление наверху на ' . (int) $project['top_count'] . ' ' . ending($project['top_count'], 'день', 'дня', 'дней');
                     break;
                 case step_employer::PROJECT_OPTION_COLOR:
                     $str_option = 'color';
                     $descr .= 'подсветка фоном';
                     break;
                 case step_employer::PROJECT_OPTION_BOLD:
                     $str_option = 'bold';
                     $descr .= 'жирный шрифт';
                     break;
                 case step_employer::PROJECT_OPTION_LOGO:
                     $str_option = 'logo';
                     $descr .= 'логотип';
                     $src_id = $project['logo_id'];
                     break;
             }
             break;
             // Покупка аккаунта ПРО
         // Покупка аккаунта ПРО
         case 48:
         case 49:
         case 50:
         case 51:
         case 76:
         case 15:
             $descr = 'Аккаунт PRO';
             $count = 1;
             $src_id = $parent_id = $str_option = $op_type = null;
             break;
             // Покупка платных ответов
         // Покупка платных ответов
         case step_freelancer::OFFERS_OP_CODE:
             $descr = "Покупка ответов на проекты (кол-во: {$option['option']})";
             $count = $option['option'];
             $src_id = $parent_id = $str_option = $op_type = null;
             break;
     }
     $pay_options = array('uid' => wizard::getUserIDReg(), 'op_code' => $option['op_code'], 'op_type' => $op_type, 'option' => $str_option, 'parent_id' => $parent_id, 'src_id' => $src_id, 'op_count' => $count, 'ammount' => $option['ammount'], 'descr' => $descr, 'comment' => $descr, 'status' => null);
     $id = $DB->insert('draft_account_operations', $pay_options, 'id');
     if ($id) {
         $this->draft[] = $id;
         return $option['id'];
     }
     return false;
 }
Beispiel #5
0
 /**
  * Записываем определенный статус шагу мастера.
  * 
  * @param int $status Статус @see self::STATUS_*
  *
  * @return bool
  */
 public function setStatusStep($status)
 {
     if (!$this->action_id) {
         return false;
     }
     return $this->_db->update('wizard_action', array('status' => $status, 'reg_uid' => wizard::getUserIDReg()), 'id = ?', $this->action_id);
 }
Beispiel #6
0
 /**
  * Инциализируем пути для перекидывания файлов.
  */
 public function setPath()
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
     $user = new users();
     $user->GetUserByUID(wizard::getUserIDReg());
     $login = $user->login;
     $cfile = new CFile();
     $tmp_path = 'users/' . substr($login, 0, 2) . '/' . $login . '/';
     $this->tmpAbsDir = $tmp_path . tmp_project::TMP_DIR . '/';
     $month = date('Ym');
     $this->dstAbsDir = 'projects/upload/' . $month . '/';
 }
Beispiel #7
0
 /**
  * Записываем определенный статус шагу мастера
  * 
  * @param integer $status  Статус @see self::STATUS_*
  * @return boolean 
  */
 public function setStatusStep($status)
 {
     if (!$this->action_id) {
         return false;
     }
     return $this->_db->update("wizard_action", array("status" => $status, "reg_uid" => wizard::getUserIDReg()), "id = ?", $this->action_id);
 }