/** * 检查签到任务 * * @param array $task * @param int $uid * * @return mixed */ public function check($task, $uid) { $this->task = $task; $this->uid = $uid; /** * 签到任务是否以前签过到了 */ $model = new Model(); $check_sign = $model->find('select * from video_user_check_sign where uid=:uid', array('uid' => $uid)); if (!$check_sign) { return 'can_apply'; } if ($task['relatedid']) { $isDo = $model->find('select * from video_task_user where relatedid=? and uid=?', array($task['relatedid'], $user['uid'])); // 当没有申请或者没有完成父任务时 if (!$isDo || $isDo['status'] != 1) { return 'can_apply'; } } /** * 计算差值 */ $s = date('Ymd', time()) - date('Ymd', strtotime($check_sign['last_time'])); if ($s == 0) { return 'all'; } if ($s >= 1) { return 'can_apply'; } }
/** * 检测用户任务对应的状态的问题 * @param $task array 某条任务 * @param $uid int 某个用户 * * @return mixed * <p> * 返回 FALSE 则表示任务失败 * 返回 TRUE 则表示任务用户可以做 * 返回 array进度的数组 则根据情况更新 * </p> */ public function checkTask($task, $uid) { $this->task = $task; $this->user = $uid; /** * 当为period 为 0 一次性的任务的时候 判断是否已经完成 * 后面各种任务脚本中就不用再判断此任务了 */ if ($task['period'] == 0) { $model = new Model(); $taskUser = $model->find('select * from video_task_user where vtask_id=' . $task['vtask_id'] . ' and uid=' . $uid); // 当task_user 的status 为 1的时候就表示完成且领奖了 if ($taskUser && $taskUser['status'] == 1) { return 'all'; } } /** * 进行检查和更新各个任务的状态 调用各任务脚本 */ $script = $task['script_name']; $className = 'App\\Service\\Task\\TaskScript\\' . ucfirst($this->script[$script]); // 暂时做了doctrine($this->em)的手动注入 未走service $class = new $className(); return $class->check($task, $uid); }
/** * 提升用户的等级 到 多少级 * * @param $gift int 提升等级 * @param $uid int 用户uid */ public function present($gift, $uid) { $model = new Model(); $this->setRedis(); $userinfo = $this->_redisInstance->hGetAll('huser_info:' . $uid); // 判断是否要提升到的等级是否小于本身用户的等级了,如果小于就不提升了 if ($userinfo['lv_rich'] >= $gift) { return true; } else { $lv_rich = $gift; // 根据等级计算 对应的值 $lvs = $this->getLvRich(); $rich = $lvs[$lv_rich]['level_value']; } $data = array('lv_rich' => $lv_rich, 'rich' => $rich); $result = $model->flush('video_user', $data, array('uid' => $uid)); // 更新用户的等级的redis if ($result !== false) { $this->_redisInstance->hset('huser_info:' . $uid, 'lv_rich', $lv_rich); $this->_redisInstance->hset('huser_info:' . $uid, 'rich', $rich); // 记录日志 $exp_log = array('uid' => $uid, 'exp' => $rich - $userinfo['rich'], 'type' => 1, 'status' => 2, 'roled' => $userinfo['roled'], 'admin_id' => 10000, 'init_time' => date('Y-m-d H:i:s'), 'dml_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1, 'curr_exp' => $userinfo['rich']); $model->add('video_user_mexp', $exp_log); return true; } return false; }
/** * 添加用户的礼物到背包中 * * @param $gifts * @param $uid */ public function present($gifts, $uid) { // 暂时性的屏蔽掉 return true; $model = new Model(); $gift = $gifts[0]; $data = array('uid' => $uid, 'icon_id' => $gift['id'], 'type' => 1, 'init_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1); $model->add('video_user_icon', $data); }
/** * 获取等级对应的经验的值 * * @return array */ protected function getLvRich() { $model = new Model(); $lvs = $model->findAll('select * from video_level_rich'); $data = array(); foreach ($lvs as $lv) { $data[$lv['level_id']] = $lv; } return $data; }
/** * 送钻石 * * @param $gift * @param $uid * @return mixed */ public function present($gift, $uid) { $model = new Model(); $this->setRedis(); $userinfo = $this->_redisInstance->hGetAll('huser_info:' . $uid); $points = $userinfo['points'] + $gift; $result = $model->flush('video_user', array('points' => $points), array('uid' => $uid)); if ($result !== false) { $this->_redisInstance->hset('huser_info:' . $uid, 'points', $points); return true; } return false; }
/** * 添加用户 * * @param $gifts * @param $uid */ public function present($gifts, $uid) { $model = new Model(); $gift = $gifts[0]; $data = array('icon_id' => $gift['id']); $result = $model->flush('video_user', $data, array('uid' => $uid)); if ($result !== false) { $this->setRedis(); $this->_redisInstance->hset('huser_info:' . $uid, 'icon_id', $gift['id']); return true; } return false; }
public function __construct($OSE = array(), $FROM = self::FROM_BDD) { parent::__construct(); $this->teatre = array("te_id" => 0, "te_nom" => "", "te_nomVisible" => "", "te_configuracio" => 0); switch ($FROM) { case self::FROM_BDD: foreach ($this->teatre as $K => $V) { $this->teatre[$K] = $OSE[$K]; if ($K == 'te_configuracio') { $this->teatre['te_configuracio'] = json_decode($OSE['te_configuracio'], true); } } break; case self::FROM_JSON: $S = $OSE['teatre']; foreach ($this->teatre as $K => $V) { if (!isset($S[$K])) { throw new MyException("Falta entrar el camp, {$K}"); } else { $this->teatre[$K] = $S[$K]; //if($K == 'te_configuracio') $this->teatre['te_configuracio'] = json_encode($S[$K]); } } break; case self::FROM_EMPTY: $this->teatre['te_id'] = 0; break; } }
public function __construct($OT = array(), $FROM = self::FROM_BDD) { parent::__construct(); $this->espectacle['e_id'] = 0; $this->espectacle['e_Titol'] = ''; $this->espectacle['e_SrcMin'] = ''; $this->espectacle['e_Resum'] = ''; $this->espectacle['e_Tipus'] = ''; $this->espectacle['e_Html'] = ''; $this->espectacle['e_Imatge'] = ''; $this->espectacle['e_OrganitzadorCif'] = ''; $this->espectacle['e_OrganitzadorNom'] = ''; $this->espectacle['e_Correcte'] = 0; $this->espectacle['e_Companyia'] = ""; switch ($FROM) { case self::FROM_BDD: foreach ($this->espectacle as $K => $V) { $this->espectacle[$K] = $OT[$K]; } break; case self::FROM_JSON: foreach ($this->espectacle as $K => $V) { $this->espectacle[$K] = $OT['espectacle'][$K]; } break; case self::FROM_EMPTY: $this->espectacle['e_id'] = 0; break; } }
public function __construct($OT = NULL, $FROM = self::FROM_EMPTY) { parent::__construct(); $this->localitat['l_zona'] = 0; $this->localitat['l_fila'] = 0; $this->localitat['l_seient'] = 0; $this->localitat['l_idSessio'] = 0; $this->localitat['l_estat'] = ''; $this->localitat['l_pagament'] = ''; $this->localitat['l_data'] = ''; $this->localitat['l_idComanda'] = 0; $this->localitat['l_idPreu'] = ''; $this->localitat['l_codi'] = ''; $this->localitat['l_horaArribada'] = NULL; $this->extres['isNew'] = false; switch ($FROM) { case self::FROM_BDD: foreach ($this->localitat as $K => $V) { $this->localitat[$K] = $OT[$K]; } $this->localitat['l_idPreu'] = json_decode($this->localitat['l_idPreu'], true); $this->localitat['nom_seient'] = $this->localitat['l_zona'] . '-' . $this->localitat['l_fila'] . '-' . $this->localitat['l_seient']; $this->localitat['nom_estat'] = $this->estats[$this->localitat['l_estat']]; break; case self::FROM_JSON: foreach ($this->localitat as $K => $V) { $this->localitat[$K] = $OT['localitat'][$K]; } break; case self::FROM_EMPTY: break; } }
/** * Call the parent construct */ function __construct() { parent::__construct(); $this->moviesql = 'SELECT * FROM ' . PREFIX . 'movie'; $this->yearsql = 'SELECT ' . PREFIX . 'movie.title, ' . PREFIX . 'movie.description, ' . PREFIX . 'movie.seoname FROM ' . PREFIX . 'movie_year INNER JOIN ' . PREFIX . 'movie ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_year.movie_id INNER JOIN ' . PREFIX . 'yr ON ' . PREFIX . 'yr.id = ' . PREFIX . 'movie_year.year_id WHERE ' . PREFIX . 'yr.yr=:yr'; $this->actorsql = 'SELECT ' . PREFIX . 'movie.title, ' . PREFIX . 'movie.description, ' . PREFIX . 'movie.seoname FROM ' . PREFIX . 'movie_actor INNER JOIN ' . PREFIX . 'movie ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_actor.movie_id INNER JOIN ' . PREFIX . 'actor ON ' . PREFIX . 'actor.id = ' . PREFIX . 'movie_actor.actor_id WHERE ' . PREFIX . 'actor.actorseo=:actor'; $this->genresql = 'SELECT ' . PREFIX . 'movie.title, ' . PREFIX . 'movie.description, ' . PREFIX . 'movie.seoname FROM ' . PREFIX . 'movie_genre INNER JOIN ' . PREFIX . 'movie ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_genre.movie_id INNER JOIN ' . PREFIX . 'genre ON ' . PREFIX . 'genre.id = ' . PREFIX . 'movie_genre.genre_id WHERE ' . PREFIX . 'genre.seogenre=:genre'; $this->countrysql = 'SELECT ' . PREFIX . 'movie.title, ' . PREFIX . 'movie.description, ' . PREFIX . 'movie.seoname FROM ' . PREFIX . 'movie_origin INNER JOIN ' . PREFIX . 'movie ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_origin.movie_id INNER JOIN ' . PREFIX . 'origin ON ' . PREFIX . 'origin.id = ' . PREFIX . 'movie_origin.origin_id WHERE ' . PREFIX . 'origin.countryseo=:country'; $this->languagesql = 'SELECT ' . PREFIX . 'movie.title, ' . PREFIX . 'movie.description, ' . PREFIX . 'movie.seoname FROM ' . PREFIX . 'movie_languages INNER JOIN ' . PREFIX . 'movie ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_languages.movie_id INNER JOIN ' . PREFIX . 'language ON ' . PREFIX . 'language.id = ' . PREFIX . 'movie_languages.language_id WHERE ' . PREFIX . 'language.languageseo=:language'; $this->ratingsql = 'SELECT ' . PREFIX . 'movie.title, ' . PREFIX . 'movie.description, ' . PREFIX . 'movie.seoname FROM ' . PREFIX . 'movie_rating INNER JOIN ' . PREFIX . 'movie ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_rating.movie_id INNER JOIN ' . PREFIX . 'rating ON ' . PREFIX . 'rating.id = ' . PREFIX . 'movie_rating.rating_id WHERE ' . PREFIX . 'rating.seorating=:rating'; }
public function __construct($OSE = array(), $FROM = self::FROM_BDD) { parent::__construct(); $this->sessio = array("s_id" => 0, "s_idEspectacle" => 0, "s_idTeatre" => 0, "s_Preus" => array(), "s_SeientsLliures" => 0, "s_Localitats" => 0, "s_DataHora" => 0, "s_Correcte" => 0, "s_VisibleWeb" => 0, "s_PermetCompraOnline" => 1, "s_NomesCompraAmics" => 0, "s_DataHoraCompra" => 0); $this->espectacle = new EspectacleTableObject(null, EspectacleTableObject::FROM_EMPTY); switch ($FROM) { case self::FROM_BDD: foreach ($this->sessio as $K => $V) { $this->sessio[$K] = $OSE[$K]; } if (isset($OSE['e_Titol'])) { $this->espectacle = new EspectacleTableObject($OSE, EspectacleTableObject::FROM_BDD); } $this->generaExtres(); break; case self::FROM_JSON: $S = $OSE['sessio']; foreach ($this->sessio as $K => $V) { if (!isset($S[$K])) { throw new MyException("Falta entrar el camp, {$K}"); } else { $this->sessio[$K] = $S[$K]; } } $this->sessio['s_Preus'] = json_encode($this->sessio['s_Preus']); $this->generaExtres(); break; case self::FROM_FORM: $S = $OSE['sessio']; foreach ($this->sessio as $K => $V) { if (!isset($S[$K])) { throw new MyException("Falta entrar el camp, {$K}"); } else { $this->sessio[$K] = $S[$K]; } } if (!isset($OSE['sessio']['tmp_Hora']) || !isset($OSE['sessio']['tmp_Dia'])) { throw new MyException("Has d'entrar algun dia i hora per la sessió."); } else { //Guardo el dia i hora de la sessió $this->sessio['tmp_Hora'] = $OSE['sessio']['tmp_Hora']; $this->sessio['tmp_Dia'] = $OSE['sessio']['tmp_Dia']; $this->sessio['s_Preus'] = json_encode($this->sessio['s_Preus']); } if (!isset($OSE['sessio']['tmp_HoraCompra']) || empty($OSE['sessio']['tmp_HoraCompra']) || !isset($OSE['sessio']['tmp_DiaCompra']) || empty($OSE['sessio']['tmp_DiaCompra'])) { throw new MyException("Has d'entrar algun dia i hora per començar a vendre entrades."); } else { //Guardo el dia i hora de la sessió $this->sessio['tmp_HoraCompra'] = $OSE['sessio']['tmp_HoraCompra']; $this->sessio['tmp_DiaCompra'] = $OSE['sessio']['tmp_DiaCompra']; } $this->generaExtres(self::FROM_FORM); break; case self::FROM_EMPTY: $this->sessio['s_id'] = 0; $this->sessio['s_Preus'] = array(); break; } }
function __construct() { parent::__construct(); $this->pathcache = ROOT . DS . "cache" . DS . "iso3166"; if (!file_exists($this->pathcache)) { mkdir($this->pathcache); } }
public function save() { //Hash password if new or password changed if (is_null($this->id) || $this->hashNeeded()) { $this->passwordHash(); } parent::save(); //Then return to original functionality }
/** * 检查首次预约的任务 * * @param $task * @param $uid * * @return mixed */ public function check($task, $uid) { $this->task = $task; $this->uid = $uid; $model = new Model(); $userTask = $model->find('select * from video_task_user where vtask_id=' . $task['vtask_id'] . ' and uid=' . $uid); $user = $model->find('select * from video_user where uid=' . $uid); if ($task['pre_vtask_id']) { $isDo = $model->find('select * from video_task_user where vtask_id=? and uid=?', array($task['pre_vtask_id'], $user['uid'])); // 当没有申请或者没有完成父任务时 if (!$isDo || $isDo['status'] != 1) { return 'can_apply'; } } /** * 如果没有接任务的话,就判断是否可以自动申请任务 */ if (!$userTask) { /** * 只要用户满足做这个任务的条件就要插入一条数据 等待预约的验证 */ $c = serialize(array('csc' => 0, 'update_time' => time())); $data = array('uid' => $uid, 'vtask_id' => $task['vtask_id'], 'status' => 0, 'csc' => $c, 'apply_date' => time(), 'init_time' => date('Y-m-d H:i:s'), 'dml_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1); $model->add('video_task_user', $data); // 增加一个申请人数 $this->updateTaskApplicants($task); return 'doing'; } $ut = $userTask; $csc = unserialize($ut['csc']); if ($ut['status'] == 1) { return 'all'; } if ($ut['status'] == -1) { return 'failed'; } if ($ut['status'] == 0 && $csc['csc'] == 100) { return 'success'; } /** * 当没有完成的时候要检查进度 */ if ($ut['status'] == 0 && $csc['csc'] != 100) { /** * 检查是否完成了预约,是就更新状态 * 要求在申请任务之后 预约的才算 */ $invite = $model->find('select * from video_room_duration where invitetime>? and reuid=?', array($ut['apply_date'], $uid)); if ($invite) { $data = array(); $csc['csc'] = 100; $csc['update_time'] = time(); $data['csc'] = serialize($csc); $model->flush('video_task_user', $data, array('auto_id' => $ut['auto_id'])); return 'success'; } return 'doing'; } }
public function delete($id) { $res = parent::delete($id); if ($res === false) { return false; } else { $this->db->delete('roles_privs', 'id_role=:id_role', ['id_role' => $id]); } return true; }
public function delete($id) { $children = $this->getByParent($id); if ($children != null) { return $children; } else { $res = parent::delete($id); return $res; } }
public function delete($id) { $file = $this->one($id)['file']; $res = parent::delete($id); if ($res !== false) { unlink(__DIR__ . '/../' . $file); $res = true; } else { $res = false; } return $res; }
/** * 添加用户的礼物到背包中 * * @param $gifts * @param $uid */ public function present($gifts, $uid) { $model = new Model(); $flag = false; foreach ($gifts as $gift) { $has_gif = $model->find('select * from video_pack where uid=? and gid=?', array($uid, $gift['id'])); if ($has_gif) { if (!empty($gift['exp'])) { $expires = $has_gif['expires'] + $gift['exp'] * 24 * 3600; $model->flush('video_pack', array('expires' => $expires), array('uid' => $uid, 'gid' => $gift['id'])); } $flag = true; } else { $exp = time() + $gift['exp'] * 24 * 3600; $result = $model->add('video_pack', array('uid' => $uid, 'gid' => $gift['id'], 'num' => $gift['num'], 'expires' => $exp)); if ($result !== false) { $flag = true; } else { $flag = false; } } } return $flag; }
public function __construct() { parent::__construct(); self::$_settings = $this->cache->get('app_user_group_settings'); if (!is_array(self::$_settings)) { $settings = []; $rows = $this->db->select('*')->from(':user_group_custom')->all(); foreach ($rows as $row) { if (!\Phpfox::isModule($row['module_id'])) { $settings[$row['user_group_id']][$row['name']] = $row['default_value']; } } $this->cache->set('app_user_group_settings', $settings); self::$_settings = $this->cache->get('app_user_group_settings'); } }
public function delete($id) { $user = $this->one($id); $id_image = $user['id_image']; $file = $user['file']; $res = parent::delete($id); if ($res === false) { return false; } else { if ($file != null) { if (Image::app()->delete($id_image) === true) { return true; } else { return false; } } } return true; }
public function __construct($flavorId = null) { parent::__construct(); if ($flavorId !== null) { self::$_active = $this->db->select('t.*, ts.folder AS flavor_folder')->from(':theme_style', 'ts')->join(':theme', 't', ['t.theme_id' => ['=' => 'ts.theme_id']])->where(['ts.style_id' => (int) $flavorId])->get(); if (!self::$_active) { throw new \Exception('Not a valid flavor.'); } } if (!self::$_active) { $cookie = \Phpfox::getCookie('flavor_id'); if ($cookie) { self::$_active = $this->db->select('t.*, ts.folder AS flavor_folder')->from(':theme_style', 'ts')->join(':theme', 't', ['t.theme_id' => ['=' => 'ts.theme_id']])->where(['ts.style_id' => (int) $cookie])->get(); } else { self::$_active = $this->db->select('t.*, ts.folder AS flavor_folder')->from(':theme', 't')->join(':theme_style', 'ts', ['t.theme_id' => ['=' => 'ts.theme_id'], 'ts.is_default' => 1])->where($cookie ? ['t.theme_id' => (int) $cookie] : ['t.is_default' => 1])->get(); } if (!self::$_active || defined('PHPFOX_CSS_FORCE_DEFAULT')) { self::$_active = ['name' => 'Default', 'folder' => 'default', 'flavor_folder' => 'default']; } } }
public function __construct($OC = array(), $FROM = self::FROM_EMPTY) { parent::__construct(); $this->comanda['co_idComanda'] = NULL; $this->comanda['co_IdClient'] = 0; $this->comanda['co_data'] = NULL; $this->comanda['co_estat'] = NULL; $this->comanda['co_sessiophp'] = NULL; $this->comanda['co_TipusPagament'] = NULL; $this->comanda['co_TipusComanda'] = NULL; $this->comanda['co_TpvOrder'] = NULL; $this->comanda['co_TpvCode'] = NULL; $this->comanda['co_NomCompra'] = NULL; $this->comanda['co_EmailCompra'] = NULL; $this->comanda['co_TelefonCompra'] = NULL; $this->comanda['co_PreuFinal'] = NULL; $this->comanda['co_LlocCompra'] = NULL; $this->comanda['co_Codi'] = NULL; $this->extres['NomTipusPagament'] = NULL; $this->extres['NomTipusComanda'] = NULL; $this->extres['NomEstat'] = NULL; $this->extres['NomLlocCompra'] = NULL; $this->localitats = array(); //Aquí hi van les localitats switch ($FROM) { case self::FROM_BDD: foreach ($this->comanda as $K => $V) { $this->comanda[$K] = $OC[$K]; $this->CarregaExtres(); } break; case self::FROM_JSON: foreach ($this->comanda as $K => $V) { $this->comanda[$K] = $OT['comanda'][$K]; } break; case self::FROM_EMPTY: break; } }
public function edit($id, $fields, $tags, $file) { if ($file['name'] != '') { $id_image = Image::app()->add($file); if ($id_image === false) { return false; } else { $fields['id_image'] = $id_image; } } $res = parent::edit($id, $fields); if ($res != false) { $this->db->delete('posts_tags', 'id_post=:id_post', ['id_post' => $id]); if (count($tags) > 0) { foreach ($tags as $key => $tag) { $this->db->insert('posts_tags', ['id_post' => $id, 'id_tag' => $tag]); } } } elseif ($res == false && $id_image != null) { Image::app()->delete($id_image); } return $res; }
public function __construct($OT = array(), $FROM = self::FROM_EMPTY) { parent::__construct(); $this->client['c_id'] = 0; $this->client['c_Nom'] = ''; $this->client['c_Cognoms'] = ''; $this->client['c_Email'] = ''; $this->client['c_Password'] = ''; $this->client['c_Telefon'] = ''; $this->client['c_Adreca'] = ''; $this->client['c_Ciutat'] = ''; $this->client['c_CodiPostal'] = ''; $this->client['c_Permisos'] = 'R'; //Pot ser 'R' (Registrat), 'V' (Venedor), 'A' (Administrador) $this->client['c_Estat'] = 'A'; //Pot ser 'A' o 'B' ( Alta o Baixa ) $this->client['c_DataCanviEstat'] = date('U', time()); $this->password = ''; //Ho guardo aquí perquè el camp el deixo buit... aquest és el password de BDD switch ($FROM) { case self::FROM_BDD: foreach ($this->client as $K => $V) { $this->client[$K] = $OT[$K]; } $this->password = $this->client['c_Password']; $this->client['c_Password'] = ""; break; case self::FROM_JSON: foreach ($this->client as $K => $V) { $this->client[$K] = $OT['client'][$K]; } break; case self::FROM_EMPTY: $this->client['c_id'] = 0; break; } }
public function __construct() { if (self::$_settings === null) { parent::__construct(); self::$_settings = $this->cache->get('app_settings'); if (is_bool(self::$_settings)) { $App = new \Core\App(); foreach ($App->all() as $_app) { if ($_app->settings) { foreach ($_app->settings as $key => $value) { $thisValue = isset($value->value) ? $value->value : null; $value = $this->db->select('*')->from(':setting')->where(['product_id' => $_app->id, 'var_name' => $key])->get(); if (isset($value['value_actual'])) { $thisValue = $value['value_actual']; } self::$_settings[$key] = $thisValue; } } } $this->cache->set('app_settings', self::$_settings); self::$_settings = $this->cache->get('app_settings'); } } }
/** * Call the parent construct */ public function __construct() { parent::__construct(); }
public function __construct() { parent::__construct(); $this->t_atom = date(DATE_ATOM); }
protected function __construct() { parent::__construct('sessions', 'id_session'); }
function __construct() { parent::__construct(); $this->db = Database::get(); }