Ejemplo n.º 1
0
 public function run()
 {
     $this->controller->pageTitle = "Profile";
     if (Yii::app()->request->isAjaxRequest) {
         $id = Yii::app()->user->id;
         $user = User::model()->findByAttributes(array('id' => $id));
         $user->nickName = Yii::app()->request->getParam('nickName');
         $user->portrait = Yii::app()->request->getParam('portrait');
         Yii::app()->user->setState('portrait', Yii::app()->request->getParam('portrait'));
         $user->background = Yii::app()->request->getParam('background');
         $user->title = Yii::app()->request->getParam('title');
         $user->website = Yii::app()->request->getParam('website');
         $user->description = Assist::removeXSS(Yii::app()->request->getParam('description'));
         $user->birthday = Yii::app()->request->getParam('birthday');
         $user->gender = Yii::app()->request->getParam('gender');
         $user->location = Yii::app()->request->getParam('hub');
         $skills = preg_replace('/,+/', ',', Yii::app()->request->getParam('skills'));
         $skills = preg_replace('/,+/', ',', $skills);
         $user->skills = trim($skills, ',');
         $interests = preg_replace('/,+/', ',', Yii::app()->request->getParam('interests'));
         $interests = preg_replace('/,+/', ',', $interests);
         $user->interests = trim($interests, ',');
         //$user->wechatid = Yii::app()->request->getParam('wechatid');
         $user->facebookid = Yii::app()->request->getParam('facebookid');
         $user->twitterid = Yii::app()->request->getParam('twitterid');
         $user->linkedinid = Yii::app()->request->getParam('linkedinid');
         $user->instagramid = Yii::app()->request->getParam('instagramid');
         $status = Yii::app()->request->getParam('status');
         $code = Code::model()->findByAttributes(array('userId' => $id));
         if ($status == 1) {
             $user->status = 2;
         }
         $havecode = empty($code) ? 0 : 1;
         if ($user->save()) {
             echo CJSON::encode(array('code' => 200, 'message' => 'success', 'data' => $havecode));
         }
     } else {
         $id = Yii::app()->user->id;
         $user = User::model()->findByAttributes(array('id' => $id));
         $proxy = new CHub();
         $hub = $proxy->getHubList();
         $this->controller->render('updateProfile', array('user' => $user, 'hub' => $hub['data']));
     }
 }
Ejemplo n.º 2
0
 public function run()
 {
     $this->controller->pageTitle = "New Post";
     $this->controller->pageTitle = "New Post";
     if (Yii::app()->request->isAjaxRequest) {
         $img = Yii::app()->request->getParam('img');
         $content = CHtml::encode(Assist::removeXSS(Yii::app()->request->getParam('content')));
         $content = preg_replace('/\\n/mi', '<br/>', $content);
         $proxy = new Posts();
         $proxy->content = $content;
         $proxy->picture = $img;
         $proxy->userId = Yii::app()->user->id;
         $proxy->createTime = date('Y-m-d H:i:s', time());
         $proxy->save();
         echo CJSON::encode(array('code' => 200, 'message' => 'SUCCESS'));
     } else {
         $this->controller->render('newpost');
     }
 }
Ejemplo n.º 3
0
				<p class="companyName"><?php 
    echo $value['companyName'];
    ?>
</p>
				<p class="location"><?php 
    echo $value['location'];
    ?>
</p>
				<p class="time"><?php 
    echo CDate::dgm($value['createTime']);
    ?>
</p>
			</div>
			<p class="content">
				<?php 
    echo Assist::removeXSS(Assist::removeEmoji($value['content']));
    ?>
			</p>
			<?php 
    if ($value['picture']) {
        ?>
			<img src="<?php 
        echo $value['picture'];
        ?>
" alt="" class="face">
			<?php 
    }
    ?>
		</div>
		<?php 
}
Ejemplo n.º 4
0
			<p class="companyName"><?php 
echo $data['post']['companyName'];
?>
</p>
			<p class="location"><?php 
echo $data['post']['location'];
?>
</p>
			<p class="time"><?php 
echo CDate::dgm($data['post']['createTime']);
?>
</p>
		</div>
		<p class="content">
			<?php 
echo Assist::removeXSS(Assist::removeEmoji($data['post']['content']));
?>
		</p>
		<?php 
if ($data['post']['picture']) {
    ?>
		<img src="<?php 
    echo $data['post']['picture'];
    ?>
" alt="" class="face">
		<?php 
}
?>
		<div class="footerWrapper">
			<p><span class="like_num"><?php 
echo $data['post']['like_num'];
Ejemplo n.º 5
0
 public static function updateLastMsg($senderId, $recId, $msg)
 {
     $lastMsg = mb_substr(Assist::removeXSS($msg), 0, 50, 'utf-8');
     if ($senderId == 0) {
         //系统消息/通知
         $mr = MessageRelation::model()->findBySql('select * from messageRelation where id1=:senderId and id2=0', array(':senderId' => Yii::app()->user->id));
         $senderID = Yii::app()->user->id;
         $RecID = 0;
     } else {
         //私聊
         $mr = MessageRelation::model()->findBySql('select * from messageRelation where (id1=:senderId and id2=:recId) or (id1=:recId and id2=:senderId)', array(':senderId' => $senderId, ':recId' => $recId));
         $senderID = $senderId;
         $RecID = $recId;
     }
     if ($mr) {
         $mr->lastMsg = $lastMsg;
         $mr->utime = time();
         $mr->save();
     } else {
         $mrelation = new MessageRelation();
         $mrelation->id1 = $senderID;
         $mrelation->id2 = $RecID;
         $mrelation->lastMsg = $lastMsg;
         $mrelation->utime = time();
         $mrelation->save();
         //新建用户关系时添加对方为当前登录用户的好友
         usleep(200 * 1000);
         if ($RecID == 0) {
             self::getInstance()->addFriend(Yii::app()->user->id, Yii::app()->params['partner']['emchat']['sysAccount']['name']);
         } elseif ($senderID == Yii::app()->user->id) {
             self::getInstance()->addFriend($senderID, $RecID);
         } else {
             self::getInstance()->addFriend($RecID, $senderID);
         }
     }
 }
Ejemplo n.º 6
0
 public function run($id = null)
 {
     $this->controller->pageTitle = "Company";
     if (!$id) {
         if (Yii::app()->request->isAjaxRequest) {
             $id = Yii::app()->request->getParam('id');
             $name = Yii::app()->request->getParam('name');
             $service = Yii::app()->request->getParam('service');
             $result = Company::model()->findByAttributes(array('name' => $name));
             if ($result && $result['ownerId'] != Yii::app()->user->id) {
                 echo CJSON::encode(array('code' => 400, 'message' => 'HAVING'));
                 die;
             } else {
                 if (!$id) {
                     $company = new Company();
                     $now = date('Y-m-d H:i:s');
                     $company->createTime = $now;
                     $company->save();
                     $companyid = Company::model()->findByAttributes(array('createTime' => $now));
                     for ($i = 0; $i < count($service); $i++) {
                         $proxy = new Service_company();
                         $proxy->serviceId = $service[$i];
                         $proxy->companyId = $companyid['id'];
                         $proxy->save();
                     }
                 } else {
                     $company = Company::model()->findByAttributes(array('id' => $id));
                     $company->updateTime = date('Y-m-d H:i:s');
                     $proxy = Service_company::model()->findAllByAttributes(array('companyId' => $id));
                     foreach ($proxy as $list) {
                         $list->status = 0;
                         $list->save();
                     }
                     for ($i = 0; $i < count($service); $i++) {
                         $dp = new Service_company();
                         $dp->serviceId = $service[$i];
                         $dp->companyId = $company['id'];
                         $dp->save();
                     }
                 }
                 $company->name = $name;
                 $company->ownerId = Yii::app()->user->id;
                 // FIXME
                 $company->email = Yii::app()->request->getParam('email');
                 $company->phone = Yii::app()->request->getParam('phone');
                 $company->website = Yii::app()->request->getParam('website');
                 $company->logo = Yii::app()->request->getParam('logo');
                 $company->location = User::model()->findByAttributes(array('id' => Yii::app()->user->id))['location'];
                 $company->background = Yii::app()->request->getParam('background');
                 $company->introduction = Assist::removeXSS(Yii::app()->request->getParam('introduction'));
                 $company->facebookid = Yii::app()->request->getParam('facebookid');
                 $company->linkedinid = Yii::app()->request->getParam('linkedinid');
                 $company->save();
                 $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
                 if ($user['type'] == 1) {
                     $user->status = 4;
                 } else {
                     if ($user['type'] == 3) {
                         $user->status = 4;
                     }
                 }
                 $user->company = $company->id;
                 $user->save();
                 //所有公司员工设置公司
                 $code = Code::model()->findAllByAttributes(array('userId' => Yii::app()->user->id, 'status' => 1));
                 if ($code) {
                     foreach ($code as $list) {
                         $user = CodeUsed::model()->findAll('codeId=' . $list['id']);
                         if ($user) {
                             foreach ($user as $value) {
                                 $item = User::model()->findByAttributes(array('id' => $value['userId']));
                                 $item->company = $company->id;
                                 $item->save();
                             }
                         }
                     }
                 }
                 echo CJSON::encode(array('code' => 200, 'message' => 'SUCCESS', 'data' => array('status' => $status)));
             }
         } else {
             $firservice = Service::model()->findAll("parentId is null");
             foreach ($firservice as $key) {
                 $a[$key['name']] = Service::model()->findAllByAttributes(array('parentId' => $key['id']));
                 // array_push($a,$key['name']);
             }
             $this->controller->render('updateProfile', array('totalservice' => $a));
         }
     } else {
         $id = Yii::app()->request->getParam('id');
         $company = Company::model()->findByAttributes(array('id' => $id));
         $myservice = Service_company::model()->findAllByAttributes(array('companyId' => $company['id'], 'status' => 1));
         $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
         foreach ($myservice as $list) {
             $array[] = Service::model()->findByAttributes(array('id' => $list['serviceId']));
         }
         $firservice = Service::model()->findAll("parentId is null");
         foreach ($firservice as $key) {
             $a[$key['name']] = Service::model()->findAllByAttributes(array('parentId' => $key['id']));
             // array_push($a,$key['name']);
         }
         // var_dump($a);die;
         $this->controller->render('updateProfile', array('company' => $company, 'status' => $user['status'], 'myservice' => $array, 'totalservice' => $a));
     }
 }