コード例 #1
0
ファイル: Singlesignon.php プロジェクト: noikiy/PD
 public static function createUser($data)
 {
     $db = JO_Db::getDefaultAdapter();
     if (!$data['username'] || Model_Users::getByUsername($data['username'])) {
         return false;
     }
     if (!$data['email'] || Model_Users::getByEmail($data['email'])) {
         return false;
     }
     $db->insert(Model_Users::getPrefixDB() . 'users', array('username' => $data['username'], 'password' => $data['password'], 'email' => $data['email'], 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'firmname' => $data['firmname'], 'profile_title' => $data['profile_title'], 'profile_desc' => $data['profile_desc'], 'register_datetime' => $data['register_datetime'], 'status' => 'activate'));
     $user_id = $db->lastInsertId();
     if ($user_id) {
         $upload_path = BASE_PATH . '/uploads';
         $user_path = '/users/' . JO_Date::getInstance($data['register_datetime'], 'yy/mm/')->toString() . $user_id . '/';
         $upload_path .= $user_path;
         if ($data['avatar'] && @getimagesize($data['avatar'])) {
             $name = basename($data['avatar']);
             if (copy($data['avatar'], $upload_path . $name)) {
                 $db->update('users', array('avatar' => $user_path . $name), array('user_id' => $user_id));
             }
         }
         if ($data['homeimage'] && @getimagesize($data['homeimage'])) {
             $name = basename($data['homeimage']);
             if (copy($data['homeimage'], $upload_path . $name)) {
                 $db->update('users', array('homeimage' => $user_path . $name), array('user_id' => $user_id));
             }
         }
         return Model_Users::getUser($user_id);
     }
 }
コード例 #2
0
ファイル: Login.php プロジェクト: NareshChennuri/pyng
 public function __construct($username, $password)
 {
     $db = JO_Db::getDefaultAdapter();
     //select default pin data
     $query = self::getListUsersQuery();
     $query->where('email = ? OR username = ?', (string) $username);
     $query->where('password = ?', (string) md5($password))->limit(1);
     $response = $db->fetchRow($query);
     $response = is_array($response) ? $response : array();
     if ($response) {
         $groups = unserialize($response['groups']);
         if (is_array($groups) && count($groups) > 0) {
             $query_group = $db->select()->from('user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups))));
             $fetch_all = $db->fetchAll($query_group);
             $response['access'] = array();
             if ($fetch_all) {
                 foreach ($fetch_all as $row) {
                     $modules = unserialize($row['rights']);
                     if (is_array($modules)) {
                         foreach ($modules as $module => $ison) {
                             foreach ($ison as $m => $on) {
                                 $response['access'][$module][$m] = $m;
                             }
                         }
                     }
                 }
             }
         }
         parent::__construct($response);
         new Model_Users_Edit($response['user_id'], array('last_login' => new JO_Db_Expr('NOW()')));
     }
 }
コード例 #3
0
ファイル: Pin.php プロジェクト: NareshChennuri/pyng
 public function __construct($pin_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = self::getListPinsQuery();
     //$query->columns(array('pin_next'=>new JO_Db_Expr('('.$db->select()->from(array('next'=>'pins'),'pin_id')->where('pin_id > ?', (string)$pin_id)->order('pin_id ASC')->limit(1).')')));
     //$query->columns(array('pin_prev'=>new JO_Db_Expr('('.$db->select()->from(array('prev'=>'pins'),'pin_id')->where('pin_id < ?', (string)$pin_id)->order('pin_id DESC')->limit(1).')')));
     if (JO_Session::get('user[user_id]')) {
         $query->columns(array('following_board' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . ')-(' . $db->select()->from('users_following_ignore', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . '))')));
         $query->columns(array('following_user' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . '))')));
         $query->columns(array('following_via' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.via')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.via')->where('board_id = pins.board_id')->limit(1) . '))')));
     } else {
         $query->columns(array('following_board' => new JO_Db_Expr("0")));
         $query->columns(array('following_user' => new JO_Db_Expr("0")));
         $query->columns(array('following_via' => new JO_Db_Expr("0")));
     }
     $rows_source = self::describeTable('pins_sources', 'source_');
     $query->joinLeft('pins_sources', 'pins.source_id = pins_sources.source_id', $rows_source);
     $query->where('pins.pin_id = ?', (string) $pin_id);
     //v2.2
     if (Helper_Config::get('config_enable_follow_private_profile')) {
         $query = self::filterFriend($query);
     }
     $response = $db->fetchRow($query);
     $response = is_array($response) ? $response : array();
     $this->data = $response;
     // 		parent::__construct($response);
 }
コード例 #4
0
ファイル: Collections.php プロジェクト: noikiy/PD
 public static function deleteCollection($id)
 {
     $db = JO_Db::getDefaultAdapter();
     $db->delete('collections', array('id = ?' => (int) $id));
     $db->delete('items_collections', array('collection_id = ?' => (int) $id));
     $db->delete('collections_rates', array('collection_id = ?' => (int) $id));
 }
コード例 #5
0
ファイル: Categories.php プロジェクト: noikiy/amatteur
 public static function getSubCategoriesAPP($category_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('category', array('title', 'category_id', 'sort_order'))->where('parent_id = ?', $category_id)->where('status = ?', 1)->order('category.sort_order ASC');
     $result = $db->fetchAll($query);
     return $result;
 }
コード例 #6
0
ファイル: Percentes.php プロジェクト: noikiy/PD
 public function getPercentRow($user)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from(Model_Users::getPrefixDB() . 'users', 'commission_percent')->where('user_id= ?', $user['user_id'])->limit(1, 0);
     $user_data = $db->fetchRow($query);
     if ($user_data && round($user_data['commission_percent']) > 0) {
         return array('percent' => floatval($user_data['commission_percent']), 'to' => 0);
     }
     $no_exclusive_author_percent = 30;
     if (JO_Registry::get('no_exclusive_author_percent')) {
         $no_exclusive_author_percent = (int) JO_Registry::get('no_exclusive_author_percent');
     }
     $exclusive_author_percent = 40;
     if (JO_Registry::get('exclusive_author_percent')) {
         $exclusive_author_percent = (int) JO_Registry::get('exclusive_author_percent');
     }
     if ($user['exclusive_author'] == 'false') {
         $percent = array('percent' => $no_exclusive_author_percent, 'to' => 0);
     } else {
         $query = $db->select()->from(Model_Users::getPrefixDB() . 'percents')->where("`from` <= ? AND (`to` > ? OR `to` = 0)", $user['sold']);
         $data = $db->fetchRow($query);
         if (count($data) == 0) {
             $percent = array('percent' => $exclusive_author_percent, 'to' => 0);
         } else {
             $percent = $data;
         }
     }
     return $percent;
 }
コード例 #7
0
ファイル: Users.php プロジェクト: noikiy/PD
 public static function initSession($user_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from(self::getPrefixDB() . 'users')->where('user_id = ?', (int) $user_id)->limit(1, 0);
     $user_data = $db->fetchRow($query);
     if ($user_data && $user_data['status'] == 'activate') {
         $groups = unserialize($user_data['groups']);
         if (is_array($groups) && count($groups) > 0) {
             $query_group = $db->select()->from(self::getPrefixDB() . 'user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups))));
             $fetch_all = $db->fetchAll($query_group);
             $user_data['access'] = array();
             if ($fetch_all) {
                 foreach ($fetch_all as $row) {
                     $modules = unserialize($row['rights']);
                     if (is_array($modules)) {
                         foreach ($modules as $module => $ison) {
                             $user_data['access'][$module] = $module;
                         }
                     }
                 }
             }
         }
         if (isset($user_data['access']) && count($user_data['access'])) {
             $user_data['is_admin'] = true;
         }
         $db->update(self::getPrefixDB() . 'users', array('last_login_datetime' => new JO_Db_Expr('NOW()'), 'ip_address' => JO_Request::getInstance()->getClientIp()), array('user_id = ?' => (int) $user_id));
         JO_Session::set($user_data);
     }
     return $user_data;
 }
コード例 #8
0
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     //select default pin data
     $query = self::getListPinsQueryLite();
     if (isset($data['cover']) && $data['cover']) {
         $query->where('pins.pin_id = ?', (string) $data['cover']);
     } else {
         $query->where('pins.pin_id = 0');
     }
     if (isset($data['pins']) && count($data['pins'])) {
         $query->orWhere('pins.pin_id IN (?)', new JO_Db_Expr(implode(',', $data['pins'])));
     } else {
         $query->orWhere('pins.pin_id = 0');
     }
     //v2.2
     if (Helper_Config::get('config_enable_follow_private_profile')) {
         $query = self::filterFriend($query);
     }
     //sort and limit add to query from Model_Pins_Abstract
     if (isset($data['cover']) && $data['cover']) {
         if (isset($data['pins']) && count($data['pins'])) {
             $query->order(new JO_Db_Expr('FIELD(pins.pin_id,' . (string) $data['cover'] . ',' . implode(',', $data['pins']) . '), pins.pin_id DESC'));
         } else {
             $query->order(new JO_Db_Expr('FIELD(pins.pin_id,' . (string) $data['cover'] . '), pins.pin_id DESC'));
         }
     } else {
         $query->order('pins.pin_id DESC');
     }
     $this->data = $db->fetchAll($query);
     // 		parent::__construct($db->fetchAll($query));
 }
コード例 #9
0
ファイル: Create.php プロジェクト: NareshChennuri/pyng
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     try {
         $db->beginTransaction();
         $data['user_id'] = isset($data['user_id']) ? $data['user_id'] : JO_Session::get('user[user_id]');
         $data['public'] = isset($data['public']) ? (int) $data['public'] : 1;
         $data['date_added'] = date('Y-m-d H:i:s');
         $board_id = Helper_Db::create('boards', $data);
         if (!$board_id) {
             return $this;
         }
         Helper_Db::insert('users_boards', array('user_id' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]'), 'board_id' => $board_id, 'is_author' => 1));
         if (isset($data['friends'])) {
             foreach ($data['friends'] as $fr) {
                 Helper_Db::insert('users_boards', array('user_id' => $fr, 'board_id' => $board_id));
             }
         }
         $config_private_boards = Helper_Config::get('config_private_boards');
         Helper_Db::update('users', array('boards' => new JO_Db_Expr("(SELECT COUNT(board_id) FROM boards WHERE user_id = '" . (isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]')) . "' " . ($config_private_boards ? ' AND public = 1' : '') . ")")), array('user_id = ?' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]')));
         ////autoseo
         new Model_Boards_Autoseo($board_id);
         $this->board_id = $board_id;
         $db->commit();
     } catch (JO_Exception $e) {
         $db->rollBack();
         $this->error = $e->getMessage();
     }
 }
コード例 #10
0
ファイル: Reports.php プロジェクト: noikiy/PD
 public static function getWithdraws($from, $to)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from(Model_Users::getPrefixDB() . 'withdraw')->where("`paid` = 'true'")->order('paid_datetime');
     $d = explode('-', $from);
     if (count($d) == 3 && checkdate($d[1], $d[2], $d[0])) {
         $query->where('`paid_datetime` >= ?', $from);
     }
     $d = explode('-', $to);
     if (count($d) == 3 && checkdate($d[1], $d[2], $d[0])) {
         $query->where('`paid_datetime` <= ?', $to);
     }
     $results = $db->fetchAll($query);
     $return = array();
     if ($results) {
         foreach ($results as $result) {
             $date = explode(' ', $result['paid_datetime']);
             $date = $date[0];
             if (!isset($return[$date]['amount'])) {
                 $return[$date]['amount'] = 0;
             }
             $return[$date]['amount'] += $result['amount'];
         }
     }
     return $return;
 }
コード例 #11
0
ファイル: Mails.php プロジェクト: noikiy/amatteur
 public static function replyMail($data)
 {
     $db = JO_Db::getDefaultAdapter();
     $db->insert('users_mails', array('from_user_id' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]'), 'date_mail' => new JO_Db_Expr('NOW()'), 'text_mail' => (string) $data['text'], 'parent_mail_id' => isset($data['parent']) ? (string) $data['parent'] : 0));
     $mail_id = $db->lastInsertId();
     if (!$mail_id) {
         return false;
     }
     $replies = self::getReplyConversation($data['parent']);
     $recipients = "";
     foreach ($replies as $reply) {
         if ($reply["from_user_id"] != JO_Session::get('user[user_id]')) {
             $pos = strpos($recipients, $reply["from_user_id"] . ",");
             if ($pos === false) {
                 $recipients .= $reply["from_user_id"] . ",";
                 $db->insert('users_mails_to', array('user_id' => $reply["from_user_id"], 'mail_id' => $mail_id));
             }
         }
         if ($reply["user_id"] != JO_Session::get('user[user_id]')) {
             $pos = strpos($recipients, $reply["user_id"] . ",");
             if ($pos === false) {
                 $recipients .= $reply["user_id"] . ",";
                 $db->insert('users_mails_to', array('user_id' => $reply["user_id"], 'mail_id' => $mail_id));
             }
         }
     }
     return array('status' => "OK");
 }
コード例 #12
0
ファイル: Gallery.php プロジェクト: NareshChennuri/pyng
 public function __construct($pin_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pins_gallery')->where('pin_id = ?', $pin_id)->order('sort_order ASC');
     $this->data = $db->fetchAll($query);
     // 		parent::__construct($result);
 }
コード例 #13
0
ファイル: Config.php プロジェクト: NareshChennuri/pyng
 public static function get($key = null)
 {
     /*self::getInstance();
     		if($key === null) {
     			return self::$data;
     		} else {
     			if(isset(self::$data[$key])) {
     				return self::$data[$key];
     			} else if(JO_Registry::isRegistered($key)) {
     				JO_Registry::get($key);
     			} else {
     				return null;
     			}
     		}*/
     if (isset(self::$data[$key])) {
         return self::$data[$key];
     } else {
         $db = JO_Db::getDefaultAdapter();
         $query = $db->select()->from('system')->where('`key` = ?', $key)->limit(1);
         $result = $db->fetchRow($query);
         if ($result) {
             if ($result['serialize']) {
                 self::$data[$key] = unserialize($result['value']);
             } else {
                 self::$data[$key] = $result['value'];
             }
             return self::$data[$key];
         }
     }
     return null;
 }
コード例 #14
0
ファイル: HomePage.php プロジェクト: NareshChennuri/pyng
 private function getRandum($query, $data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     //// load from cache
     $check = $db->select()->from('cache_index')->where('start_limit = ?', 'home')->limit(1);
     $cache = $db->fetchRow($check);
     if (!isset($cache['data']) || !$cache['data']) {
         $query->where('pins.pin_id = 0');
         return $query;
     }
     if ($cache && $cache['data']) {
         $query->where('pins.pin_id IN (' . $cache['data'] . ')');
     } else {
         $query->where('pins.pin_id = 0');
     }
     //v2.2
     if (Helper_Config::get('config_enable_follow_private_profile')) {
         $query = self::filterFriend($query);
     }
     //sort and limit add to query from Model_Pins_Abstract
     $query = self::sortOrderLimit($query, $data);
     $query->reset(JO_Db_Select::ORDER);
     $query->order(new JO_Db_Expr('FIELD(pins.pin_id,' . $cache['data'] . ')'));
     return $query;
 }
コード例 #15
0
ファイル: Delete.php プロジェクト: NareshChennuri/pyng
 public function __construct($board_id)
 {
     $db = JO_Db::getDefaultAdapter();
     try {
         $db->beginTransaction();
         $board_info = new Model_Boards_Board($board_id);
         if (!$board_info->count()) {
             return $this;
         }
         $result = null;
         if ($board_info['board_pins'] > 0) {
             $pins_query = $db->select()->from('pins')->where('board_id = ?', $board_id)->where('user_id = ?', $board_info['user_user_id']);
             $pins = $db->fetchAll($pins_query);
             if ($pins) {
                 foreach ($pins as $pin) {
                     $deleted = new Model_Pins_Delete($pin['pin_id']);
                     if (!$result) {
                         $result = $deleted;
                     }
                 }
             }
         }
         $res = Helper_Db::delete('users_following', array('board_id = ?' => $board_id));
         if (!$result) {
             $result = $res;
         }
         $res = Helper_Db::delete('users_following_ignore', array('board_id = ?' => $board_id));
         if (!$result) {
             $result = $res;
         }
         $res = Helper_Db::delete('users_boards', array('board_id = ?' => $board_id));
         if (!$result) {
             $result = $res;
         }
         $res = Helper_Db::delete('users_history', array('board_id = ?' => $board_id));
         if (!$result) {
             $result = $res;
         }
         $res = Helper_Db::delete('url_alias', array('query = ?' => 'board_id=' . $board_id));
         if (!$result) {
             $result = $res;
         }
         $res = Helper_Db::delete('boards', array('board_id = ?' => $board_id));
         if (!$result) {
             $result = $res;
         }
         $res = Helper_Db::update('users', array('boards' => new JO_Db_Expr("(SELECT COUNT(board_id) FROM boards WHERE user_id = '" . $board_info['user_user_id'] . "')")), array('user_id = ?' => $board_info['user_user_id']));
         if (!$result) {
             $result = $res;
         }
         if ($board_info['board_pins'] > 0) {
             ///////////////// update latest pins for user /////////////////////
             new Model_Users_UpdateLatestPins($board_info['user_user_id']);
         }
         $this->affected_rows = $result;
         $db->commit();
     } catch (JO_Exception $e) {
         $db->rollBack();
     }
 }
コード例 #16
0
ファイル: Pages.php プロジェクト: noikiy/PD
 public static function getPageParents($id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pages')->joinLeft('pages_description', 'pages_description.id = pages.id AND pages_description.lid = \'' . JO_Session::get('language_id') . '\'', array('lid', 'name', 'text'))->where('visible = ?', 'true')->order('sub_of DESC');
     $results = $db->fetchAll($query);
     $return = array();
     $cnt = count($results);
     for ($i = 0; $i < $cnt; $i++) {
         if ($results[$i]['id'] == $id) {
             $return[] = $results[$i];
             $sub_of = $results[$i]['sub_of'];
             break;
         }
     }
     $i--;
     while ($sub_of > 0 && $i >= 0) {
         if ($sub_of == $results[$i]['id']) {
             $return[] = $results[$i];
             $sub_of = $results[$i]['sub_of'];
         }
         $i--;
     }
     $return = array_reverse($return);
     return $return;
 }
コード例 #17
0
ファイル: GetComment.php プロジェクト: NareshChennuri/pyng
 public function __construct($comment_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pins_comments')->where('comment_id = ?', $comment_id)->limit(1);
     $result = $db->fetchRow($query);
     $this->data = is_array($result) ? $result : array();
     // 		parent::__construct($result);
 }
コード例 #18
0
ファイル: Statistics.php プロジェクト: NareshChennuri/pyng
 public function stats()
 {
     $db = JO_Db::getDefaultAdapter();
     Helper_Db::delete('statistics', array());
     Helper_Db::query("INSERT INTO `statistics`(`id`, `total`, `type`) SELECT DATE_FORMAT(`date_added`, '%Y%m'),COUNT(pin_id),1 FROM pins GROUP BY DATE_FORMAT(`date_added`, '%Y%m');");
     Helper_Db::query("INSERT INTO `statistics`(`id`, `total`, `type`) SELECT DATE_FORMAT(`date_added`, '%Y%m'),COUNT(user_id),2 FROM users GROUP BY DATE_FORMAT(`date_added`, '%Y%m');");
     Helper_Db::query("INSERT INTO `statistics`(`id`, `total`, `type`) SELECT DATE_FORMAT(`date_added`, '%Y%m'),COUNT(board_id),3 FROM boards GROUP BY DATE_FORMAT(`date_added`, '%Y%m');");
 }
コード例 #19
0
ファイル: Bulletin.php プロジェクト: noikiy/PD
 public function add($data)
 {
     if (Model_Bulletin::checkMail($data['email'])) {
         return false;
     }
     $db = JO_Db::getDefaultAdapter();
     $db->insert('bulletin_emails', array('firstname' => $data['fname'], 'lastname' => $data['lname'], 'email' => $data['email'], 'bulletin_subscribe' => 'true'));
 }
コード例 #20
0
ファイル: Source.php プロジェクト: NareshChennuri/pyng
 public function __construct($source_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pins_sources')->where('source_id = ?', (string) $source_id)->limit(1);
     $response = $db->fetchRow($query);
     $response = is_array($response) ? $response : array();
     parent::__construct($response);
 }
コード例 #21
0
ファイル: Extensions.php プロジェクト: noikiy/PD
 public function uninstall($key)
 {
     if (!self::isInstaled($key)) {
         return;
     }
     $db = JO_Db::getDefaultAdapter();
     return $db->delete('extensions', array('code = ?' => $key));
 }
コード例 #22
0
ファイル: PercentsController.php プロジェクト: noikiy/PD
 public static function config()
 {
     $is_singlesignon = false;
     if (JO_Registry::get('singlesignon_db_users') && JO_Registry::get('singlesignon_db_users') != JO_Db::getDefaultAdapter()->getConfig('dbname')) {
         $is_singlesignon = true;
     }
     return array('name' => self::translate('Percentages'), 'has_permision' => true, 'menu' => self::translate('Systems'), 'in_menu' => true, 'permision_key' => 'system', 'sort_order' => 80200, 'is_singlesignon' => $is_singlesignon);
 }
コード例 #23
0
 public function __construct($user_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $user_info = new Model_Users_User($user_id);
     if ($user_info->count()) {
         $config_private_boards = Helper_Config::get('config_private_boards');
         Helper_Db::update('users', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE user_id = users.user_id ' . ($config_private_boards ? ' AND (public = 1 OR user_id = users.user_id)' : '') . ')'), 'boards' => new JO_Db_Expr('(SELECT COUNT(DISTINCT board_id) FROM boards WHERE user_id = users.user_id ' . ($config_private_boards ? ' AND (public = 1 OR user_id = users.user_id)' : '') . ')'), 'likes' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins_likes WHERE user_id = users.user_id)'), 'following' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT following_id) FROM users_following_user WHERE user_id = users.user_id AND following_id != users.user_id LIMIT 1) + (SELECT COUNT(DISTINCT following_id) FROM users_following WHERE user_id = users.user_id AND following_id != users.user_id LIMIT 1) )'), 'followers' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = users.user_id AND user_id != users.user_id LIMIT 1) + (SELECT COUNT(DISTINCT user_id) FROM users_following WHERE following_id = users.user_id AND user_id != users.user_id LIMIT 1) )'), 'latest_pins' => new JO_Db_Expr('( SUBSTRING_INDEX( (SELECT GROUP_CONCAT(pin_id ORDER BY `pin_id` DESC) FROM `pins` WHERE user_id = users.user_id), \',\', 15 ) )')), array('user_id = ?' => $user_id));
     }
 }
コード例 #24
0
ファイル: Users.php プロジェクト: NareshChennuri/pyng
 public static function isExistUsername($username, $old_username = FALSE)
 {
     if ($username == $old_username) {
         return false;
     }
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('users', new JO_Db_Expr('COUNT(user_id)'))->where('username = ?', $username);
     return $db->fetchOne($query) > 0 ? true : false;
 }
コード例 #25
0
ファイル: Membership.php プロジェクト: noikiy/PD
    public static function buy($id)
    {
        $db = JO_Db::getDefaultAdapter();
        $query = 'UPDATE membership SET downloads = downloads + 1 
				WHERE user_id = \'' . (int) $id . '\'
					AND DATE(datetime) > SUBDATE(NOW(), interval 1 MONTH)
					AND paid = \'true\'';
        $db->query($query);
    }
コード例 #26
0
ファイル: Crons.php プロジェクト: noikiy/amatteur
 public static function updateStats()
 {
     $db = JO_Db::getDefaultAdapter();
     $db->delete('users_following_user', array('user_id NOT IN (SELECT user_id FROM users)' => 1));
     $db->delete('users_following_user', array('following_id NOT IN (SELECT user_id FROM users)' => 1));
     $db->update('users', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE user_id = users.user_id)'), 'boards' => new JO_Db_Expr('(SELECT COUNT(DISTINCT board_id) FROM boards WHERE user_id = users.user_id)'), 'likes' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins_likes WHERE user_id = users.user_id)'), 'following' => new JO_Db_Expr('(SELECT COUNT(DISTINCT following_id) FROM users_following_user WHERE user_id = users.user_id AND following_id != users.user_id)'), 'followers' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = users.user_id AND user_id != users.user_id)')));
     $db->update('boards', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE board_id = boards.board_id)'), 'followers' => new JO_Db_Expr('(SELECT COUNT(DISTINCT users_following_id) FROM users_following WHERE board_id = boards.board_id)')));
     $db->update('pins', array('likes' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM pins_likes WHERE pin_id = pins.pin_id)'), 'comments' => new JO_Db_Expr('(SELECT COUNT(DISTINCT comment_id) FROM pins_comments WHERE pin_id = pins.pin_id)')));
 }
コード例 #27
0
 public function __construct($board_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $board_info = new Model_Boards_Board($board_id);
     if ($board_info->count()) {
         $config_private_boards = Helper_Config::get('config_private_boards');
         $db->update('boards', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE board_id = boards.board_id ' . ($config_private_boards ? ' AND (public = 1 OR board_id = boards.board_id)' : '') . ')'), 'followers' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = boards.user_id AND user_id != boards.user_id LIMIT 1) + (SELECT COUNT(DISTINCT user_id) FROM users_following WHERE following_id = boards.user_id AND user_id != boards.user_id LIMIT 1) - (SELECT COUNT(DISTINCT user_id) FROM users_following_ignore WHERE following_id = boards.user_id AND board_id = boards.board_id AND user_id != boards.user_id LIMIT 1) )'), 'latest_pins' => new JO_Db_Expr('( SUBSTRING_INDEX( (SELECT GROUP_CONCAT(pin_id ORDER BY `pin_id` DESC) FROM `pins` WHERE board_id = boards.board_id), \',\', 15 ) )')), array('board_id = ?' => (string) $board_id));
     }
 }
コード例 #28
0
ファイル: Gallery.php プロジェクト: NareshChennuri/pyng
 public static function getGalleryImages($gallery_id, $controller = '')
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('gallery_images')->where('gallery_images.gallery_id = ?', (int) $gallery_id)->order('gallery_images.sort_order ASC');
     if ($controller) {
         $query->where('controller = ?', $controller);
     }
     return $db->fetchAll($query);
 }
コード例 #29
0
ファイル: History.php プロジェクト: noikiy/PD
 public static function add($action, $transactionID, $userID = 0)
 {
     if ($userID == 0) {
         $userID = JO_Session::get('user_id');
     }
     $db = JO_Db::getDefaultAdapter();
     $db->insert(Model_Users::getPrefixDB() . 'history', array('user_id' => $userID, 'action' => $action, 'transaction_id' => $transactionID, 'datetime' => new JO_Db_Expr('NOW()')));
     return true;
 }
コード例 #30
0
ファイル: UserByEmail.php プロジェクト: NareshChennuri/pyng
 public function __construct($email)
 {
     $db = JO_Db::getDefaultAdapter();
     //select default pin data
     $query = self::getListUsersQuery();
     $query->where('users.email = ?', (string) $email)->limit(1);
     $response = $db->fetchRow($query);
     $response = is_array($response) ? $response : array();
     parent::__construct($response);
 }