Esempio n. 1
0
 public function shutdown_hub()
 {
     if ($this->hub) {
         $this->hub->shutdown();
         $this->hub = null;
         $this->save();
     }
 }
Esempio n. 2
0
 /**
  * Должен дублировать сообщения в логеры.
  */
 public function testLog()
 {
     $logA = $this->getMock('Psr\\Log\\LoggerInterface');
     $logB = $this->getMock('Psr\\Log\\LoggerInterface');
     $logA->expects($this->once())->method('log');
     $logB->expects($this->once())->method('log');
     $hub = new Hub();
     $hub->attach($logA);
     $hub->attach($logB);
     $hub->info('test');
 }
Esempio n. 3
0
 public function run($id = null, $page = 1, $size = 2)
 {
     $this->controller->pageTitle = "Profile";
     if (Yii::app()->request->isAjaxRequest) {
         if (!$id) {
             $id = Yii::app()->user->id;
         }
         $post = new CPost();
         $result = $post->getProfileList($id, $page, $size);
         echo CJSON::encode(array('code' => 200, 'mes' => 'success', 'data' => array('list' => $result['data'])));
     } else {
         if ($id) {
             $user = User::model()->with('companyid')->findByAttributes(array('id' => $id));
             $company = Company::model()->findByAttributes(array('ownerId' => $user['id']));
             $location = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getProfileList($id);
         } else {
             $id = Yii::app()->user->id;
             $user = User::model()->with('companyid')->findByAttributes(array('id' => $id));
             $company = Company::model()->findByAttributes(array('ownerId' => $user['id']));
             $location = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getProfileList($id);
         }
         $this->controller->render('profile', array('user' => $user, 'companylocation' => $location['location'], 'postlist' => $postlist['data']));
     }
 }
Esempio n. 4
0
 public function getHubInfo($id)
 {
     $result = Hub::model()->findByAttributes(array('status' => 1, 'id' => $id));
     if ($result) {
         $data = array('code' => 200, 'message' => 'SUCCESS', 'data' => $result);
     }
     return $data;
 }
 /**
  * Display customer profile
  *
  * @param $profile
  * @return Response
  */
 public function show($profile)
 {
     $p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first();
     $page = Page::where('title', '=', 'faq-customer')->first();
     $follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get();
     $follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get();
     $wall = new \Illuminate\Database\Eloquent\Collection();
     $events = new \Illuminate\Database\Eloquent\Collection();
     $comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get();
     $hidden = unserialize(Cookie::get('hide'));
     //dd( Cookie::get('hide') );
     if (count($follow) > 0) {
         foreach ($follow as $f) {
             $s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get();
             $e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get();
             $wall = $wall->merge($s);
             $events = $events->merge($e);
         }
     }
     if (count($follow_hub) > 0) {
         foreach ($follow_hub as $h) {
             $hub = Hub::where('id', '=', $h->hub)->first();
             if (!is_null($hub)) {
                 $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
                 $artists_list = [];
                 $songs = [];
                 $events = [];
                 foreach ($artists as $a) {
                     $artists_list[] = $a->id;
                 }
                 if (count($artists_list) > 0) {
                     $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
                     $events = ArtistEvent::whereIn('artist', $artists_list)->get();
                 }
                 $news = News::where('hub', '=', $hub->id)->take(3)->get();
                 $wall = $wall->merge($songs);
                 $events = $events->merge($events);
             }
         }
     }
     $purchased = Purchase::where('customer', '=', $p->id)->get();
     foreach ($purchased as $pp) {
         $song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get();
         $download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first();
         $song_purchased[0]->purchased = true;
         if (isset($download)) {
             $song_purchased[0]->link = $download->url;
         }
         $wall = $wall->merge($song_purchased);
     }
     $wall->sortByDesc('created_at');
     if (!isset($news)) {
         $news = null;
     }
     return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]);
 }
Esempio n. 6
0
 public function getNumber($date, $hubId = '')
 {
     $date = date('YmdHis', strtotime($date . ' 10:00:00'));
     $hub = new Hub();
     $hublist = $hub->getHUb();
     if ($hubId) {
         $result = Reservations::model()->count('status !=0 and type=1 and startTime=' . $date . ' and hubId=' . $hubId);
     } else {
         $result = array();
         foreach ($hublist as $key) {
             $result[] = Reservations::model()->count('status !=0 and type=1 and startTime=' . $date . ' and hubId=' . $key['id']);
         }
     }
     if ($result) {
         $data = array('code' => 200, 'message' => 'SUCCESS', 'count' => $result);
     } else {
         $data = array('code' => 200, 'message' => 'SUCCESS', 'count' => 0);
     }
     return $data;
 }
Esempio n. 7
0
 /**
  * Downvotes the specific comment.
  * @param string $title
  * @param string $slug
  * @return Response
  */
 public function downvote($title, $slug)
 {
     $post = Post::where('slug', '=', $slug)->firstOrFail();
     $hub = Hub::where('name', '=', $title)->firstOrFail();
     if ($post->hub_id === $hub->id) {
         $voted = explode(',', $post->voted);
         if (!in_array(Auth::user()->id, $voted)) {
             $post->voted .= Auth::user()->id . ',';
             $post->downvotes += 1;
             $post->push();
             return response()->json(["success" => true]);
         }
     }
 }
Esempio n. 8
0
 public function run($id = null, $page = 1, $size = 2)
 {
     $this->controller->pageTitle = "Company";
     if (Yii::app()->request->isAjaxRequest) {
         if (!$id) {
             $id = User::model()->findByAttributes(array('id' => Yii::app()->user->id))->company;
         }
         $post = new CPost();
         $result = $post->getCompanyList($id, $page, $size);
         echo CJSON::encode(array('code' => 200, 'mes' => 'success', 'data' => array('list' => $result['data'])));
     } else {
         if ($id) {
             $company = Company::model()->findByAttributes(array('id' => $id));
             $service = Service_company::model()->findAllByAttributes(array('companyId' => $id, 'status' => 1));
             if ($service) {
                 foreach ($service as $list) {
                     $servicelist[] = Service::model()->findByAttributes(array('id' => $list['serviceId']));
                 }
             }
             $hub = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getCompanyList($id, $page, $size);
             //取出公司所有成员
             $member = User::model()->findAllByAttributes(array('company' => $id));
         } else {
             $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
             $company = Company::model()->findByAttributes(array('id' => $user['company']));
             $service = Service_company::model()->findAllByAttributes(array('companyId' => $company['id'], 'status' => 1));
             if ($service) {
                 foreach ($service as $list) {
                     $servicelist[] = Service::model()->findByAttributes(array('id' => $list['serviceId']));
                 }
             }
             $hub = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getCompanyList($company->id, $page, $size);
             $member = User::model()->findAllByAttributes(array('company' => $user['company']));
         }
         // print_r($company);die;
         $this->controller->render('profile', array('company' => $company, 'service' => $servicelist, 'location' => $hub['location'], 'postlist' => $postlist['data'], 'member' => $member));
     }
 }
 public function follow($slug)
 {
     $hub = Hub::where('slug', '=', $slug)->first();
     $user = Auth::user();
     if (!is_null($hub)) {
         $f = Follow::where('user', '=', $user->id)->where('hub', '=', $hub->id)->first();
         if (is_null($f)) {
             $f = new Follow();
             $f->hub = $hub->id;
             $f->user = $user->id;
             $f->save();
             return Redirect::to('hubs/' . $hub->slug);
         } else {
             $f->delete();
             return Redirect::to('hubs/' . $hub->slug);
         }
     } else {
         App::abort('404');
     }
 }
 /**
  * Displaying artist profile settings form
  *
  * @return Response
  */
 public function profile()
 {
     $profile = User::find(Auth::user()->id);
     $hubs = Hub::all();
     return View::make('artist.settings', ['profile' => $profile, 'hubs' => $hubs]);
 }
 /**
  * Handle hub form (add/edit)
  *
  * @return Response
  */
 public function post_hub()
 {
     $hub = null;
     if (Input::has('id')) {
         $hub = Hub::find(Input::get('id'));
     }
     if (is_null($hub)) {
         $hub = new Hub();
     }
     $geo = Geocoder::getCoordinatesForQuery(Input::get('location'));
     $hub->name = Input::get('name');
     $hub->description = Input::get('description');
     $hub->location = Input::get('location');
     $hub->facebook = Input::get('facebook');
     $hub->google = Input::get('google');
     $hub->twitter = Input::get('twitter');
     $hub->slug = Str::slug($hub->name);
     if ($geo != 'NOT_FOUND') {
         $hub->lat = $geo['lat'];
         $hub->lng = $geo['lng'];
     }
     if (Input::has('art')) {
         $image = Input::get('art');
         $exp = explode(",", $image);
         $name = str_random(15);
         $data = base64_decode($exp[1]);
         $tempfile = storage_path() . "/temp/" . $name . "";
         file_put_contents($tempfile, $data);
         Image::make($tempfile)->resize(210, 210)->save(storage_path() . "/pictures/" . $name . ".png");
         unlink($tempfile);
         $p = new Picture();
         $p->name = $name;
         $p->user = 0;
         $p->extension = '.png';
         $p->save();
         $hub->picture = $p->id;
     }
     $hub->save();
     return Redirect::to('admin/hubs');
 }
Esempio n. 12
0
    public $phone;
    function __construct($a = "hi", $b = "12hi", $c = 666)
    {
        $this->username = $a;
        $this->userpasd = $b;
        $this->phone = $c;
    }
    public function push()
    {
        echo "my name:{$this->username}<br>";
    }
}
class Hub extends Git
{
    var $email = "*****@*****.**";
    public function check()
    {
        echo "{$this->phone} is a boy<br>";
    }
    public function push()
    {
        parent::push();
        echo "your phonenumber is :{$this->phone}<br>";
        echo "this is my email :{$this->email}<br>";
    }
}
$git = new Hub("do", "", 999);
$lab = new Hub("wu", "12yu", 888);
$git->push();
$git->check();
$lab->check();