コード例 #1
1
ファイル: Contractors.php プロジェクト: seph-krueger/handyman
 public function deactivate($contractor_id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "user_type='contractor' AND userid=" . $contractor_id;
     Affiliates::model()->deleteAll($criteria);
     Referral::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "owner_user_type='contractor' AND owner_id=" . $contractor_id;
     Answers::model()->deleteAll($criteria);
     Questions::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "user_type='contractor' AND deleted_by=" . $contractor_id;
     Messagedeleted::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "from_user_type='contractor' AND from_id=" . $contractor_id;
     Messages::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "to_user_type='contractor' AND to_id=" . $contractor_id;
     Messages::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "viewed_user_type='contractor' AND viewed_by=" . $contractor_id;
     QuestionViews::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "referred_by_type='contractor' AND referred_by=" . $contractor_id;
     Referral::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "invited_id=" . $contractor_id;
     ContractorTeam::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "contractor_id=" . $contractor_id;
     ContractorBond::model()->deleteAll($criteria);
     ContractorLicense::model()->deleteAll($criteria);
     ContractorPoints::model()->deleteAll($criteria);
     ContractorSocials::model()->deleteAll($criteria);
     ContractorTeam::model()->deleteAll($criteria);
     ContractorViews::model()->deleteAll($criteria);
     Contractorphotos::model()->deleteAll($criteria);
     Feedback::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "ContractorId=" . $contractor_id;
     self::model()->deleteAll($criteria);
     return true;
 }
コード例 #2
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionRead()
 {
     $id = Yii::app()->request->getParam('id');
     $apId = (int) Yii::app()->request->getParam('apId');
     if (!$id) {
         throw404();
     }
     $user = User::model()->findByPk($id);
     Yii::app()->user->setState('menu_active', 'messages.read');
     $model = new $this->modelName();
     // выставляем флаг о прочитанности
     $unRealMessages = Messages::model()->unReadUser()->criteriaUser($id, Yii::app()->user->id)->findAll(array('select' => 'id'));
     $idArr = array();
     foreach ($unRealMessages as $item) {
         $idArr[] = (int) $item->id;
     }
     if (count($idArr) > 0) {
         Messages::model()->updateByPk($idArr, array('is_read' => Messages::STATUS_READ_USER, 'date_read' => new CDbExpression('NOW()')));
     }
     $allMessages = $pages = null;
     $return = Messages::getAllMessagesUser($id);
     if ($return) {
         $allMessages = $return['allMessages'];
         $pages = $return['pages'];
     }
     # если нет сообщений от выбранного пользователя
     /*if (!$allMessages)
     		throw404();*/
     $this->render('read', array('allMessages' => $allMessages, 'pages' => $pages, 'senderInfo' => $user, 'model' => $model, 'uid' => $id, 'apId' => $apId));
 }
コード例 #3
0
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect(array('site/index'));
     }
     $model = new Users();
     if (isset($_POST['Users'])) {
         $model->CreatedDate = date('Y-m-d H:i:s');
         $model->UserId = $this->getRandomNumber();
         $model->ActivationCode = $this->generateRandomString(15);
         $model->attributes = $_POST['Users'];
         if ($model->save()) {
             $message = Messages::model()->mailHeader();
             $message .= '<p>Dear ' . $model->UserName . '</p>';
             $message .= 'Thank you for registering with Getweiss.com';
             $message .= '<p>Please click the link below to activate your account</p>';
             $message .= '<p><a style="color:#FFF; text-decoration:none" href="' . Yii::app()->getBaseUrl(true) . '/site/activate/?ac=' . $model->ActivationCode . '">' . Yii::app()->getBaseUrl(true) . '/site/activate/?ac=' . $model->ActivationCode . '</a></p>';
             $message .= 'Regards<br/>Getweiss.com.';
             $message .= Messages::model()->mailFooter();
             // Messages::model()->sendMail('Get Weiss', 'Activation', Yii::app()->params['adminEmail'], $model->EmailAddress, $message);
             $adminmessage = Messages::model()->mailHeader();
             $adminmessage .= 'New User Registered in Getweiss.com';
             $adminmessage .= '<p><u>Name</u>: ' . $model->UserName . '</p>';
             $adminmessage .= '<p><u>Email</u>: ' . $model->EmailAddress . '</p>';
             $adminmessage .= Messages::model()->mailFooter();
             //Messages::model()->sendMail($model->UserName, 'New User Registration', $model->EmailAddress, Yii::app()->params['adminEmail'], $adminmessage);
             $this->redirect(array('index', 'msg' => 'success'));
         }
     }
     $this->render('index', array('model' => $model));
 }
コード例 #4
0
ファイル: MessagesController.php プロジェクト: reubsc/sds
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Messages::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, Yii::t('App', 'The requested page does not exist.'));
         }
     }
     return $this->_model;
 }
コード例 #5
0
ファイル: MessagesApi.php プロジェクト: romeo14/pow
 public static function getAllSentMessages($toUserId)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'to_user_id=:toUserId AND sent_active=:sentActive';
     $criteria->params = array(':toUserId' => $toUserId, ':sentActive' => '1');
     $messages = Messages::model()->findAll($criteria);
     if (!empty($messages)) {
         return $messages;
     } else {
         return false;
     }
 }
コード例 #6
0
 public function actionGetcount()
 {
     // un-read notification count
     $type = 'friend';
     $notification_count = array();
     $notification = Notification::model()->findAll("user_id=:uid AND is_read = 0 AND type != '{$type}'", array(':uid' => Yii::app()->user->userId));
     $message = Messages::model()->findAll('user_id=:uid AND is_read=0', array(':uid' => Yii::app()->user->userId));
     $friend = UserFriend::model()->findAll('friend_id=:uid AND is_read=0', array(':uid' => Yii::app()->user->userId));
     $notification_count['noti'] = count($notification);
     $notification_count['mess'] = count($message);
     $notification_count['friend'] = count($friend);
     print_r(json_encode($notification_count));
 }
コード例 #7
0
 public function actionContractor()
 {
     if (!Yii::app()->user->isGuest) {
         if (Yii::app()->user->role == 'contractor') {
             $this->pageTitle = 'Handyman.com - Contractor Dashboard';
             $this->cities = Cities::model()->findAll(array('order' => 'RAND()', 'limit' => 10));
             $contractor_id = Yii::app()->user->getId();
             $model = Contractors::model()->findByPk($contractor_id);
             $param['page'] = "dashboard";
             $param['model'] = $model;
             $criteria = new CDbCriteria();
             $criteria->condition = "to_id={$contractor_id} and to_user_type='contractor'";
             $param['message_count'] = Messages::model()->count($criteria);
             $this->render('contractor', $param);
         } else {
             $this->redirect(Yii::app()->homeUrl);
         }
     } else {
         $this->redirect(Yii::app()->homeUrl);
     }
 }
コード例 #8
0
 public function actionContractor()
 {
     if (!Yii::app()->user->isGuest) {
         if (Yii::app()->user->role == 'contractor') {
             $this->pageTitle = 'Handyman.com - Contractor Dashboard';
             $this->cities = Cities::model()->findAll(array('order' => 'RAND()', 'limit' => 10));
             $contractor_id = Yii::app()->user->getId();
             $model = Contractors::model()->findByPk($contractor_id);
             $param['page'] = "dashboard";
             $param['model'] = $model;
             $criteria = new CDbCriteria();
             $criteria->condition = "to_id={$contractor_id} and to_user_type='contractor'";
             $param['message_count'] = Messages::model()->count($criteria);
             $criteria2 = new CdbCriteria();
             $criteria2->condition = "contractor_id = {$contractor_id}";
             $param['views_count'] = ContractorViews::model()->count($criteria2);
             $oneWeekAgo = date("Y-m-d H:i:s", strtotime("-1 months"));
             $criteria3 = new CdbCriteria();
             $criteria3->addBetweenCondition('date_added', $oneWeekAgo, date("Y-m-d H:i:s"));
             $param['latest_project_count'] = Projects::model()->count($criteria3);
             $param['from'] = $oneWeekAgo;
             $param['to'] = date("Y-m-d H:i:s");
             $param['points'] = 0;
             $points = ContractorPoints::model()->findByAttributes(array('contractor_id' => $contractor_id));
             if (count($points) > 0) {
                 $param['points'] = $points->points;
             }
             $team_invites = ContractorTeam::model()->findbyAttributes(array('invited_id' => $contractor_id, 'confirmed' => 0));
             $param['team_invites'] = $team_invites;
             $this->render('contractor', $param);
         } else {
             $this->redirect(Yii::app()->homeUrl);
         }
     } else {
         $this->redirect(Yii::app()->homeUrl);
     }
 }
コード例 #9
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     $folder = Yii::getPathOfAlias('webroot') . '/../images/users/';
     UserText::model()->deleteAllByAttributes(array("UserId" => $id));
     UserOptions::model()->deleteAllByAttributes(array("UserId" => $id));
     MembershipUsers::model()->deleteAllByAttributes(array("UserId" => $id));
     Messages::model()->deleteAllByAttributes(array("SenderId" => $id));
     Messages::model()->deleteAllByAttributes(array("ReceiverId" => $id));
     if (UserImages::model()->findAllByAttributes(array("UserId" => $id))) {
         $imgList = UserImages::model()->findAllByAttributes(array("UserId" => $id));
         foreach ($imgList as $list) {
             unlink($folder . $list->ImagePath);
         }
     }
     UserImages::model()->deleteAllByAttributes(array("UserId" => $id));
     $this->loadModel($id)->delete();
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
     }
 }
コード例 #10
0
ファイル: Messages.php プロジェクト: barricade86/raui
 public static function getAllMessagesUser($idFrom = '')
 {
     $allMessages = $pages = null;
     if ($idFrom) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('(id_userFrom = :idFrom AND id_userTo = :idUserOwner) OR (id_userFrom = :idUserOwner AND id_userTo = :idFrom) AND status =:status AND is_deleted = :is_deleted');
         $criteria->addCondition('status = "' . self::MESSAGE_ACTIVE . '"');
         $criteria->params[':idFrom'] = $idFrom;
         $criteria->params[':idUserOwner'] = Yii::app()->user->id;
         $criteria->params[':status'] = self::MESSAGE_ACTIVE;
         $criteria->params[':is_deleted'] = self::MESSAGE_NOT_DELETED;
         $criteria->order = 'id DESC';
         $pages = new CPagination(count(Messages::model()->findAll($criteria)));
         $pages->pageSize = param('userPaginationPageSize', 20);
         $pages->applyLimit($criteria);
         $allMessages = Messages::model()->findAll($criteria);
     }
     return array('pages' => $pages, 'allMessages' => $allMessages);
 }
コード例 #11
0
ファイル: newMessages.php プロジェクト: reubsc/sds
<?php

$newMessages = Messages::model()->findAll('to_user_id = :to and message_read = 0', array(':to' => Yii::app()->user->id));
if ($newMessages) {
    echo '<div class="success">';
    echo Yii::t('UserModule.user', 'You have new Messages !');
    echo '<ul>';
    foreach ($newMessages as $message) {
        printf("<li>%s</li>", CHtml::link($message->title, array('messages/view', 'id' => $message->id)));
    }
    echo '</ul>';
    echo '</div>';
}
コード例 #12
0
ファイル: sent.php プロジェクト: brahmajiayatas/getweiss
 |
				<?php 
        echo CHtml::ajaxLink('Delete', array('message/trashSentMessage', 'id' => $model->Objid), array('success' => "function(data){\n\t\t\t\t\$('#message" . $model->Objid . "').html(data);\t\n\t\t\t\twindow.location.reload(true);\t\n\t\t\t\t}", 'beforeSend' => 'function() { 
				if(confirm("Are you sure want to delete this message?")){
				$("#loader' . $model->Objid . '").addClass("loading");
				return true;         
				}else{
				return false;
				}
				}', 'complete' => 'function() {
				$("#loader").removeClass("loading");
				}'));
        ?>
            </div>
            <p><?php 
        echo Messages::model()->limitWords($model->Subject, 5);
        ?>
</p>
            <div class="message_date"><span><?php 
        echo date('D, d M', strtotime($model->Date));
        ?>
</span></div>
            <div id="loader<?php 
        echo $model->Objid;
        ?>
" style="padding:19px 6px;"></div>
            <div class="clear"></div>
          </li>
          <?php 
    }
} else {
コード例 #13
0
 public function actionMessage($id)
 {
     $message = Messages::model()->with('sender', 'receiver')->findByPk($id);
     $this->breadcrumbs = array(_('Користувачі') => $this->createUrl('users'), 'Перегляд повідомлення');
     $this->render('message', array('message' => $message));
 }
コード例 #14
0
ファイル: ActionClass.php プロジェクト: VanyaAvchyan/Pol
 public static function getMessageCreators($id)
 {
     $messageCreatorIds = [];
     $requestUsersArray = [];
     $messagesArray = array();
     $requestsModel = Requests::model()->findByPk($id);
     if ($requestsModel) {
         foreach ($requestsModel->mstRequestUsers as $user) {
             $requestUsersArray[] = (int) $user->user_id;
         }
     }
     if (!empty($requestUsersArray)) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('request.id = ' . $requestsModel->id);
         $criteria->addCondition('t.status = 1');
         $criteria->order = 't.created_on DESC';
         $criteria->with = array('request');
         $modelArray = Messages::model()->findAll($criteria);
         foreach ($modelArray as $model) {
             $messagesArray = array('creator' => $model->created_by);
         }
     }
     return $messagesArray;
 }
コード例 #15
0
 /**
  * conversation with user
  */
 public function actionMessagesWith()
 {
     //Check if user is subnormal
     if (!Yii::app()->user->isGuest && Yii::app()->user->knights_name != $_GET['sir']) {
         //Check page
         $page = 1;
         //Is the first page
         if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) {
             $page = $_GET['page'];
         }
         $register_start = $page * Yii::app()->params['messages']['max_by_page'] - Yii::app()->params['messages']['max_by_page'];
         //$message_list = Messages::model()->findAll( "(from_user = :users_id1 AND to_user =:knight_users_id1) OR (from_user = :knight_users_id2 AND to_user =:users_id2) ORDER BY " );
         $paramsCondition = array(':users_id1' => Yii::app()->user->users_id, ':users_id2' => Yii::app()->user->users_id, ':knight_users_id1' => $this->knight->users_id, ':knight_users_id2' => $this->knight->users_id, ':status_delete' => Messages::STATUS_DELETED);
         $total_rows = Messages::model()->count('(from_user = :users_id1 AND to_user =:knight_users_id1) OR (from_user = :knight_users_id2 AND to_user =:users_id2) AND status != :status_delete', $paramsCondition);
         //Set params
         $params = array('messages' => Messages::getMessageWith(Yii::app()->user->users_id, $this->knight->users_id, $register_start, Yii::app()->params['messages']['max_by_page']), 'totalPages' => ceil($total_rows / Yii::app()->params['messages']['max_by_page']), 'page' => $page);
         $this->render('messagesWith', $params);
     } else {
         //No permitimos tener conversaciones con uno mismo.
         $this->redirect('/site/error');
     }
 }
コード例 #16
0
}
if (Yii::app()->controller->ID == 'businesspage' && Yii::app()->controller->action->ID == 'businesspages') {
    $busPages = 'true';
    $busCrPages = '';
} elseif (Yii::app()->controller->ID == 'businesspage' && Yii::app()->controller->action->ID == 'createpage') {
    $busCrPages = 'true';
    $busPages = '';
} else {
    $busPages = '';
    $busCrPages = '';
}
?>
 
        <?php 
//message cout
$messages = Messages::model()->findAll('user_id=:id AND is_read=:messgRead', array(':id' => Yii::app()->user->userId, ':messgRead' => 0));
$count = count($messages);
?>
        <?php 
$notification = Notification::model()->findAll('user_id=:uid AND is_read = 0', array(':uid' => Yii::app()->user->userId));
$notification_count = count($notification);
?>
        
        <?php 
$this->widget('bootstrap.widgets.BootMenu', array('type' => 'list', 'items' => array(array('label' => 'General'), array('label' => 'Home', 'icon' => 'home', 'url' => Yii::app()->baseUrl . '/index.php/user/dashboard', 'active' => $dashboard), array('label' => "Messages ({$count}) ", 'icon' => 'icon-envelope', 'url' => Yii::app()->baseUrl . '/index.php/user/inbux', 'active' => $inbox), array('label' => "Notification ({$notification_count}) ", 'icon' => 'icon-asterisk', 'url' => Yii::app()->baseUrl . '/index.php/notification/viewnotification'), array('label' => 'Properties Nearby', 'icon' => 'road', 'url' => '#'), array('label' => 'Properties Search', 'icon' => 'search', 'url' => '#'), array('label' => 'Pages'), array('label' => 'Create Page', 'icon' => 'lock', 'url' => Yii::app()->baseUrl . '/index.php/businesspage/createpage', 'active' => $busCrPages), array('label' => 'My Business Page', 'icon' => 'lock', 'url' => Yii::app()->baseUrl . '/index.php/businesspage/businesspages', 'active' => $busPages), array('label' => 'Settings'), array('label' => 'Profile', 'icon' => 'user', 'url' => Yii::app()->baseUrl . '/index.php/user/viewprofile/userId/' . Yii::app()->user->userId), array('label' => 'Pages', 'icon' => 'file', 'url' => '#'), array('label' => 'Settings', 'icon' => 'cog', 'url' => Yii::app()->baseUrl . '/index.php/user/settings', 'active' => $settings), array('label' => 'Help', 'icon' => 'flag', 'url' => '#')), 'htmlOptions' => array('class' => 'well')));
?>
    </div>
    <div class="span10">
        <?php 
echo $content;
?>
コード例 #17
0
ファイル: Messages.php プロジェクト: brahmajiayatas/getweiss
 public function getMessageCount($type)
 {
     $count = 0;
     $loginUserId = Yii::app()->user->getId();
     $criteria = new CDbCriteria();
     if ($type == 'inbox') {
         $criteria->condition = "ReceiverId={$loginUserId} AND ReceiverDeleteStatus=0";
     } else {
         if ($type == 'trash') {
             $criteria->condition = "ReceiverId={$loginUserId} AND ReceiverDeleteStatus=1";
         } else {
             if ($type == 'sent') {
                 $criteria->condition = "SenderId={$loginUserId} AND SenderDeleteStatus=0";
             }
         }
     }
     $count = Messages::model()->count($criteria);
     return $count;
 }
コード例 #18
0
ファイル: index.php プロジェクト: barricade86/raui
									<div class="list-mess-time">
										<span><?php 
    echo $message->date_read;
    ?>
</span>
									</div>
								</li>
								<?php 
}
?>
							</ul>
						</div>
					</div>
					<?php 
if (Yii::app()->request->getParam('id')) {
    $userMessage = Messages::model()->findByPk(Yii::app()->request->getParam('id'));
    $this->renderPartial('__read', ['message' => $userMessage]);
} else {
    $this->renderPartial('__read');
}
?>
				</div>
			</div>
		</div>
	</div>
	<!-- eof content zone DIV -->
</div>

<script>
	//меню
	$('.pCab_leftMenuItems li:has(ul.sub-menu)').addClass('has_sub');
コード例 #19
0
 public function actionViewMessage($messageId)
 {
     $this->layout = 'layout_user';
     $messages = MessageChat::model()->with('user', 'sender', 'message')->findAll('t.message_id=:messgId', array(':messgId' => $messageId));
     $model = Messages::model()->findByPk($messageId);
     $model->is_read = 1;
     $model->save();
     $this->render('detailmessage', array('message' => $messages));
 }
コード例 #20
0
ファイル: index.php プロジェクト: brahmajiayatas/getweiss
<div class="sidebar">
<div class="upgrade_profile_details">
  <div class="message_heading">
    <h3>Activity</h3>
  </div>
  <div class="activitytable">
 <?php 
/*?> <?php 
 ,'active'=>Yii::app()->controller->id=='search'
  ?><?php */
?>
  
  <?php 
$this->widget('zii.widgets.CMenu', array('items' => array(array('label' => 'Inbox<span>' . Messages::model()->getMessageCount('inbox') . '</sapn>', 'url' => array('/message'), 'active' => Yii::app()->controller->action->id == 'index'), array('label' => 'Sent<span>' . Messages::model()->getMessageCount('sent') . '</span>', 'url' => array('/message/sent'), 'active' => Yii::app()->controller->action->id == 'sent'), array('label' => 'Trash<span>' . Messages::model()->getMessageCount('trash') . '<span>', 'url' => array('/message/trash'), 'active' => Yii::app()->controller->action->id == 'trash')), 'encodeLabel' => false));
?>
  </div>
</div>
</div>
コード例 #21
0
 public function actionFree()
 {
     $loginUserId = Yii::app()->user->getId();
     $loginUserMail = Profile::model()->findByPk($loginUserId)->EmailAddress;
     $model = Memberships::model()->findByAttributes(array("Price" => 0));
     $months = $model->Duration;
     $membserShipId = $model->Objid;
     $details = MembershipUsers::model()->findByAttributes(array("UserId" => $loginUserId, "MembershipId" => $membserShipId));
     if (empty($details)) {
         $freeMember = new MembershipUsers();
         $freeMember->UserId = $loginUserId;
         $freeMember->MembershipId = $membserShipId;
         $freeMember->TransactionId = "0";
         $freeMember->MembershipStart = date('Y-m-d H:i:s');
         $freeMember->MembershipEnd = date('Y-m-d H:i:s', strtotime("+ " . $months . " month"));
         if ($freeMember->save()) {
             $info = MembershipUsers::model()->findByPk($freeMember->Objid);
             $message = Messages::model()->mailHeader();
             $message .= '<p>Free Membership successfully activated.</p>';
             $message .= '<p><u>Membership type</u>: ' . $info->membership->MemberShipType . ' </p>';
             $message .= '<p>' . $info->membership->Description . '</p>';
             $message .= '<p><u>Membership Expired</u>: ' . $info->MembershipEnd . '</p>';
             $message .= Messages::model()->mailFooter();
             Messages::model()->sendMail('E Heart Match', 'Membership Details', Yii::app()->params['adminEmail'], $loginUserMail, $message);
             $this->render('success', array('details' => $info));
         }
     } else {
         throw new CHttpException(404, 'Page not found');
     }
 }
コード例 #22
0
 public function loadsent($post)
 {
     $page = $post['page'];
     $per_page = 10;
     $pagination = "";
     $userid = Yii::app()->user->getId();
     $role = Yii::app()->user->role;
     $cur_page = $page;
     $criteria = new CDbCriteria();
     $criteria2 = new CDbCriteria();
     if ($role == "homeowner") {
         $criteria->condition = "from_id = {$userid} AND from_user_type='homeowner' AND message_id NOT IN (Select message_id from messagedeleted where deleted_by={$userid} and user_type='homeowner')";
         $criteria2->condition = "from_id = {$userid} AND from_user_type='homeowner' AND message_id NOT IN (Select message_id from messagedeleted where deleted_by={$userid} and user_type='homeowner')";
     } else {
         if ($role == "contractor") {
             $criteria->condition = "from_id = {$userid} AND from_user_type='contractor' AND message_id NOT IN (Select message_id from messagedeleted where deleted_by={$userid} and user_type='contractor')";
             $criteria2->condition = "from_id = {$userid} AND from_user_type='contractor' AND message_id NOT IN (Select message_id from messagedeleted where deleted_by={$userid} and user_type='contractor')";
         }
     }
     $criteria->order = 'message_id DESC';
     $num_rows = Messages::model()->count($criteria);
     if ($num_rows < $per_page) {
         $per_page = $num_rows;
     }
     $prev_page = $page - 1;
     // previous page is this page, minus 1 page.
     $next_page = $page + 1;
     $page_start = $per_page * $page - $per_page;
     //where does our page index start
     if ($num_rows <= $per_page) {
         $num_pages = 1;
         //we checked to see if the rows we received were less than 15.
         //if true, then we only have 1 page.
     } else {
         if ($num_rows % $per_page == 0) {
             $num_pages = $num_rows / $per_page;
         } else {
             $num_pages = $num_rows / $per_page + 1;
             $num_pages = (int) $num_pages;
         }
     }
     $criteria2->limit = $per_page;
     $criteria2->offset = $page_start;
     $criteria2->order = 'message_id DESC';
     //$pagination .= '<span class="pagination-info">'.$page_start.'-'.$per_page.' of '.$num_rows.'</span>';
     if ($prev_page) {
         $pagination .= ' <a class="btn btn-sm blue prev_link" href="javascript:void(0)" id="prev-' . $prev_page . '"> <i class="fa fa-angle-left"></i></a>';
     }
     if ($page != $num_pages) {
         $pagination .= ' <a class="btn btn-sm blue next_link" href="javascript:void(0)" id="next-' . $next_page . '"><i class="fa fa-angle-right"></i></a>';
     }
     $htmlParams['sent'] = Messages::model()->findAll($criteria2);
     $return['pagination'] = $pagination;
     $return['html'] = $this->renderPartial('table-sent', $htmlParams, true);
     $this->renderJSON($return, true);
 }
コード例 #23
0
ファイル: MessagesController.php プロジェクト: kosenka/yboard
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Messages the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Messages::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #24
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionKill($id)
 {
     $message = Messages::model()->findByPk($id);
     $message->delete();
     $this->redirect('/messages');
 }
コード例 #25
0
ファイル: ApiController.php プロジェクト: VanyaAvchyan/Pol
 public function actionChatAct()
 {
     $id = (int) Yii::app()->request->getParam('id', 0);
     $act = Yii::app()->request->getParam('act', false);
     $returnArray = array();
     $status = false;
     $msg = '';
     if ($id > 0 && $act) {
         $model = Messages::model()->findByPk($id);
         if ($model != null && $model->created_by == Yii::app()->user->getInfo()) {
             if ($act == 'delete') {
                 $model->status = 0;
                 if ($model->save()) {
                     $status = true;
                     $msg = 'Successfully done';
                 } else {
                     $msg = $model->getErrors();
                 }
             }
         }
     }
     $returnArray['status'] = $status;
     $returnArray['msg'] = $msg;
     header('Content-Type: application/json');
     $return = json_encode($returnArray);
     echo $return;
     Yii::app()->end();
 }
コード例 #26
0
ファイル: Homeowners.php プロジェクト: seph-krueger/handyman
 public function deactivate($homeowner_id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "user_type='homeowner' AND userid=" . $homeowner_id;
     Affiliates::model()->deleteAll($criteria);
     Referral::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "owner_user_type='homeowner' AND owner_id=" . $homeowner_id;
     Answers::model()->deleteAll($criteria);
     Questions::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "user_type='homeowner' AND deleted_by=" . $homeowner_id;
     Messagedeleted::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "from_user_type='homeowner' AND from_id=" . $homeowner_id;
     Messages::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "to_user_type='homeowner' AND to_id=" . $homeowner_id;
     Messages::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "project_id NOT IN (Select project_id from projects where homeowner_id = {$homeowner_id} )";
     Projectphotos::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "viewed_user_type='homeowner' AND viewed_by=" . $homeowner_id;
     QuestionViews::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "referred_by_type='homeowner' AND referred_by=" . $homeowner_id;
     Referral::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "homeowner_id=" . $homeowner_id;
     HomeownerPoints::model()->deleteAll($criteria);
     Feedback::model()->deleteAll($criteria);
     HomeownerViews::model()->deleteAll($criteria);
     Projects::model()->deleteAll($criteria);
     self::model()->deleteAll($criteria);
     return true;
 }
コード例 #27
0
 public function countUnreadMsg($uid)
 {
     return Messages::model()->count('is_read=0 and to_uid=:to_uid', array(':to_uid' => $uid));
 }
コード例 #28
0
 public function actionViewMessage($id)
 {
     $this->breadcrumbs = array('Головна' => $this->createUrl('site/index'), 'Мої повідомлення' => $this->createUrl('messages'), 'Перегляд повідомлення');
     /** @var $model Messages */
     $model = Messages::model()->with('sender', 'receiver')->findByPk($id);
     if (!$model) {
         throw new CHttpException(404);
     }
     $model->markAsRead();
     $user = $model->receiver_id == Yii::app()->user->id ? $model->getSender() : $model->getReceiver();
     $messageForm = new MessageForm();
     $messageForm->setReceiverId($user->id);
     $this->render('view-message', array('model' => $model, 'isReceived' => $model->receiver_id == Yii::app()->user->id, 'user' => $user, 'messageForm' => $messageForm, 'sendMessageHandlerUrl' => $this->createUrl('SendMessageHandler')));
 }