/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     // check permission
     // only subscriber can invite
     if (!AccountSubscription::model()->isSubscriber(Yii::app()->user->id)) {
         throw new CHttpException(401, 'You must be a subscriber to invite someone.');
         return;
     }
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['AccountInvitation'])) {
         $model->attributes = $_POST['AccountInvitation'];
         //$model->account_invitation_message;
         if ($this->createAccountInvitation($model)) {
             $this->redirect(array('view', 'id' => $model->account_invitation_id));
         }
     }
     $this->render('update', array('model' => $model));
 }
Пример #2
0
 public function authenticate()
 {
     $username = strtolower($this->username);
     $user = Account::model()->find('LOWER(account_email)=?', array($username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->account_id;
             // get Profile detail
             //$accountContact = CompanyContact::model()->find('account_id=?', array($user->account_id));
             $accountProfile = AccountProfile::model()->find('account_id = ?', array($user->account_id));
             $accountSubscriptions = AccountSubscription::model()->findSubscriptions($user->account_id);
             // set currently selected subscription default as first on the list
             reset($accountSubscriptions);
             $this->setState('linx_app_selected_subscription', key($accountSubscriptions));
             $this->username = $user->account_email;
             $this->setState('account_email', $user->account_email);
             $this->setState('account_subscriptions', $accountSubscriptions);
             $tz = $user->account_timezone;
             if (trim($tz) == '') {
                 $tz = 'Asia/Singapore';
             }
             $this->setState('timezone', $tz);
             //$this->setState('isMasterAccount', Account::model()->isMasterAccount($user->account_id) ? YES : NO);
             if ($accountProfile === null) {
                 $this->setState('account_contact_surname', '');
                 $this->setState('account_contact_given_name', '');
             } else {
                 $this->setState('account_profile_surname', $accountProfile->account_profile_surname);
                 $this->setState('account_profile_given_name', $accountProfile->account_profile_given_name);
                 $this->setState('account_profile_preferred_display_name', $accountProfile->account_profile_preferred_display_name);
                 $this->setState('account_profile_short_name', $accountProfile->getShortFullName());
             }
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Пример #3
0
 /**
  * Set id of current subscription view
  * 
  * @param int $id
  */
 public static function setCurrentlySelectedSubscription($id)
 {
     if (!isset(Yii::app()->user->linx_app_selected_subscription)) {
         return false;
     }
     // check if this user is master account
     $is_master = Account::model()->isMasterAccount($id);
     // or a member of this subscription
     $master_account_id = AccountSubscription::model()->getSubscriptionOwnerID($id);
     $is_member = AccountTeamMember::model()->isValidMember($master_account_id, Yii::app()->user->id);
     if ($is_master || $is_member) {
         Yii::app()->user->linx_app_selected_subscription = $id;
         return true;
     }
     return false;
 }
Пример #4
0
		
	<div data-role="header" data-theme="b" role="banner" style="border-top: solid 5px #5DA028; padding-top: 5px;">
	  	<center><img src="<?php 
echo Yii::app()->baseUrl;
?>
/images/linxlogo_mobile.png" height="28"/></center>
	 	<a href="#linx-app-menu-panel" data-iconpos="notext" data-theme="b" 
	 		data-role="button" data-icon="bars" title=" Navigation" data-wrapperels="span"
	 		style="margin-top: 4px;"> </a>
	</div>


			<?php 
$linx_app_menu_subscription_items = array();
if (!Yii::app()->user->isGuest) {
    $linx_app_account_subscriptions = AccountSubscription::model()->findSubscriptions(Yii::app()->user->id);
    foreach ($linx_app_account_subscriptions as $sub_id => $subscription) {
        $label = $subscription;
        if (isset(Yii::app()->user->linx_app_selected_subscription) && $sub_id == Yii::app()->user->linx_app_selected_subscription) {
            $label .= ' <i class="icon-ok"></i>';
        }
        $linx_app_menu_subscription_items[] = array('label' => $label, 'url' => array('site/subscription', 'id' => $sub_id), 'visible' => !Yii::app()->user->isGuest);
    }
}
?>
	
	<?php 
echo $content;
?>
	
	</div> <!--  datarole page -->
Пример #5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     // if user is already logged in
     // redirect to dash board
     if (!Yii::app()->user->isGuest) {
         $this->redirect(array('project/index'));
     }
     $model = new Account();
     //$companyModel = new Company();
     //$companyContactModel = new CompanyContact();
     $accountSubscriptionModel = new AccountSubscription();
     $accountProfile = new AccountProfile();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     /**
      * Process form's submission
      * param's name must be in this format, e.g. "Account[account_email]"
      */
     if (isset($_POST['Account'])) {
         $model->attributes = $_POST['Account'];
         $model->account_id = null;
         //$companyModel->attributes = $_POST['Company'];
         //$companyContactModel->attributes = $_POST['CompanyContact'];
         $accountSubscriptionModel->attributes = $_POST['AccountSubscription'];
         $accountProfile->attributes = $_POST['AccountProfile'];
         /**
         			$model->account_company_name = $companyModel->company_name;
         			$model->account_contact_surname = $companyContactModel->contact_surname;
         			$model->account_contact_given_name = $companyContactModel->contact_given_name;
         			$model->account_subscription_package_id = $accountSubscriptionModel->account_subscription_package_id;
         			**/
         // SAVE ACCOUNT
         //$model->account_password = $model->hashPassword($model->account_password);
         $model->account_status = ACCOUNT_STATUS_ACTIVATED;
         // ACCOUNT_STATUS_NOT_ACTIVATED;
         $save_result = '';
         // save user account record to database
         $save_result = $model->save();
         if ($save_result) {
             // create/update subscription record
             $accountSubscriptionModel->account_id = $model->account_id;
             $accountSubscriptionModel->account_subscription_start_date = date('Y-m-d H:i');
             $accountSubscriptionModel->account_subscription_status_id = 1;
             $accountSubscriptionModel->save();
             // create account profile
             $accountProfile->account_id = $model->account_id;
             $accountProfile->account_profile_preferred_display_name = $accountProfile->account_profile_given_name . ' ' . $accountProfile->account_profile_surname;
             $accountProfile->save();
             /**
             				// create company record
             				$companyModel->company_master_account_id = $model->account_id;
             				$companyModel->company_is_master = COMPANY_IS_MASTER;
             			
             				// save company record to database,
             				// if successful, create contact record
             				if ($companyModel->save()) {
             					// create contact record
             					$companyContactModel->contact_email1 = $model->account_email;
             					$companyContactModel->company_id = $companyModel->company_id;
             					$companyContactModel->account_id = $model->account_id;
             					// save contact record to database
             					$companyContactModel->save();
             				}**/
             // notify user through email
             $model->sendSuccessfulSignupEmailNotification();
         }
         // redirect to view
         if ($save_result) {
             //$this->redirect(array('view','id'=>$model->account_id));
             $this->redirect(Yii::app()->baseUrl . '/product/signup-success.php');
         }
     }
     /** 
      * otherwise just show creation form
      */
     $active_subscription_packages = SubscriptionPackage::getActivePackages();
     $active_subscription_package_names = array();
     foreach ($active_subscription_packages as $item) {
         $active_subscription_package_names[$item->subscription_package_id] = $item->subscription_package_name;
     }
     $data = array('model' => $model, 'accountProfileModel' => $accountProfile, 'accountSubscriptionModel' => $accountSubscriptionModel, 'active_subscription_packages' => $active_subscription_package_names);
     LBApplication::render($this, 'create', $data);
     //$this->render('create',);
 }
Пример #6
0
 public function checkModules($module_name, $per_value, $created_by = false)
 {
     $user_id = Yii::app()->user->id;
     $canAdd = BasicPermission::model()->checkPerModule($module_name, 'add');
     $canEditOwn = BasicPermission::model()->checkPerModule($module_name, 'update own');
     $canEditAll = BasicPermission::model()->checkPerModule($module_name, 'update all');
     $canDeleteOwn = BasicPermission::model()->checkPerModule($module_name, 'delete own');
     $canDeleteAll = BasicPermission::model()->checkPerModule($module_name, 'delete all');
     $canViewOwn = BasicPermission::model()->checkPerModule($module_name, 'view own');
     $canViewAll = BasicPermission::model()->checkPerModule($module_name, 'view all');
     $canListOwn = BasicPermission::model()->checkPerModule($module_name, 'list own');
     $canListAll = BasicPermission::model()->checkPerModule($module_name, 'list all');
     $ownSub = AccountSubscription::model()->checkIsSubscriptionOwner(LBApplication::getCurrentlySelectedSubscription());
     $result = false;
     if ($ownSub) {
         $result = true;
         if ($per_value == "list") {
             $result = FALSE;
         }
     } else {
         if ($per_value == "add") {
             $result = $canAdd;
         } else {
             if ($per_value == "update") {
                 if ($canEditAll) {
                     $result = true;
                 } elseif ($canEditOwn && $user_id == $created_by) {
                     $result = true;
                 }
             } else {
                 if ($per_value == "delete") {
                     if ($canDeleteAll) {
                         $result = true;
                     } elseif ($canDeleteOwn && $user_id == $created_by) {
                         $result = true;
                     }
                 } else {
                     if ($per_value == "view") {
                         if ($canViewAll) {
                             $result = true;
                         } elseif ($canViewOwn && $user_id == $created_by) {
                             $result = true;
                         }
                     } else {
                         if ($per_value == "list") {
                             $result = -1;
                             if ($canListAll) {
                                 $result = false;
                             } else {
                                 if ($canListOwn) {
                                     $result = Yii::app()->user->id;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Пример #7
0
 /**
  * Get the user id of the owner of the subscription that this model belongs to
  * This method is useful for determining ownership of a record.
  * 
  * @return int Account ID of the owner
  * @access public
  */
 function getSubscriptionOwnerAccountID()
 {
     $coreEntity = $this->getCoreEntity();
     if ($coreEntity) {
         $subscription_id = $coreEntity->lb_subscription_id;
         $accountSubscription = AccountSubscription::model()->findByPk($subscription_id);
         // return user account id
         if ($accountSubscription) {
             return $accountSubscription->account_id;
         }
     }
     return 0;
 }
 /**
  * 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 AccountSubscription the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = AccountSubscription::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #9
0
    /**
     * Check if current user account is a master account of this subscription
     */
    public function isMasterAccount($subscription_id, $account_id = 0)
    {
        if ($account_id == 0) {
            $account_id = Yii::app()->user->id;
        }
        $subscription = AccountSubscription::model()->find('account_subscription_id = :account_subscription_id AND
				account_id = :account_id', array(':account_subscription_id' => $subscription_id, ':account_id' => $account_id));
        if ($subscription && $subscription->account_subscription_id > 0) {
            return true;
        }
        /**$subscriptions = AccountSubscription::model()->findSubscriptions($account_id, true);
        		foreach ($subscriptions as $subsc) 
        		{
        			if ($subsc->account_subscription_id == $subscription_id 
        					&& $subsc->account_id == $account_id)
        				return true;
        		}**/
        return false;
    }
Пример #10
0
 public function save($runValidation = true, $attributes = NULL)
 {
     // check permission
     // only subscriber can invite
     // but if we're updating status of an invitation, as long as key and invitation id are correct, let it pass
     if (!AccountSubscription::model()->isSubscriber(Yii::app()->user->id)) {
         if ($this->account_invitation_id > 0) {
             //if (isset($_GET['key']) && $_GET['key'] == $this->account_invitation_rand_key)
             return parent::save($runValidation = true, $attributes = NULL);
         }
         throw new CHttpException(401, 'You must be a subscriber to invite someone. Subscribe here.');
         return false;
     }
     if ($this->account_invitation_type == null) {
         $this->account_invitation_type = AccountInvitation::ACCOUNT_INVITATION_TYPE_MEMBER;
     }
     return parent::save($runValidation = true, $attributes = NULL);
 }
Пример #11
0
 /**
  * Get account id of the owner of this subscription
  * 
  * @param number $subscription_id
  * @return unknown
  */
 public function getSubscriptionOwnerID($subscription_id = 0)
 {
     $subscription = $this;
     if ($subscription_id > 0) {
         $subscription = AccountSubscription::model()->findByPk($subscription_id);
     }
     return $subscription->account_id;
 }
Пример #12
0
 /**
  * Get master account for a project that this user belongs to.
  * This is use to find master account of a project that this user is involved with.
  * This user is assumed to be NOT a master account user
  * 
  * @param integer $member_account_id
  * @param number $project_id
  * @return mix Array of master account ids, master account id if project id is passed in.
  */
 public function getMasterAccountIDs($member_account_id, $project_id = 0)
 {
     // find all the records that reflect team membership of this account
     $teamMembers = AccountTeamMember::model()->findAll('member_account_id = :member_account_id', array(':member_account_id' => $member_account_id));
     // if we filter project
     if ($project_id > 0) {
         foreach ($teamMembers as $membership) {
             // get subscription id
             $sub = AccountSubscription::model()->find('account_id = :account_id AND account_subscription_status_id = 1', array(':account_id' => $membership->master_account_id));
             // get project
             if ($sub) {
                 // if matched project, return master account id
                 $project = Project::model()->find('project_id = :project_id AND account_subscription_id = :account_subscription_id', array(':project_id' => $project_id, ':account_subscription_id' => $sub->account_subscription_id));
                 if ($project && $project->project_id > 0) {
                     return $sub->account_id;
                 }
             }
         }
         return 0;
     }
     // get ids of master account
     $master_acc_ids = array();
     foreach ($teamMembers as $mem) {
         $master_acc_ids[] = $mem->master_account_id;
     }
     // return array of master account ids
     return $master_acc_ids;
 }
Пример #13
0
 public function checkHiddenModule($mod_directory)
 {
     $user_id = YII::app()->user->id;
     // Kiểm tra tai khoản admin
     $ownSub = AccountSubscription::model()->checkIsSubscriptionOwner(LBApplication::getCurrentlySelectedSubscription());
     //END
     $criteria = new CDbCriteria();
     $criteria->condition = 'module_directory = "' . $mod_directory . '" AND module_hidden = 1';
     $module = $this->getOneRecords($criteria);
     $basic_account = array();
     if ($module) {
         // Kierm tra user da duoc gan module nay chua
         $checkModule = false;
         $basic_account = AccountBasicPermission::model()->findAll('module_id = "' . $module->lb_record_primary_key . '" AND account_id = ' . intval($user_id));
         if (count($basic_account) > 0) {
             $checkModule = true;
         }
         // Kiem tra uer da duoc gan role ma co module nay chua
         $checkModuleRole = false;
         $role = AccountRoles::model()->findAll('accout_id=' . intval($user_id));
         foreach ($role as $roleItem) {
             $basic_role = RolesBasicPermission::model()->findAll('role_id=' . intval($roleItem->role_id) . ' AND module_id = ' . intval($module->lb_record_primary_key));
             if (count($basic_role) > 0) {
                 $checkModuleRole = true;
             }
         }
     }
     // Kiem tra user co dc xem modules nay ko
     //            $assignModulesUser = AccountBasicPermission::model()->findAll('account_id = '.intval($user_id).' AND module_id='.intval($dataProvider->data->module_id));
     if (count($module) > 0 && $ownSub) {
         return true;
     } else {
         if (count($module) > 0 && ($checkModule == true || $checkModuleRole == true)) {
             return true;
         }
     }
     return false;
 }
Пример #14
0
<?php

/* @var $this AccountTeamMemberController */
/* @var $memberCADataProvider CActiveDataProvider for AccountTeamMember */
/* @var $otherMemberCADataProvider for team members that this user is NOT master account of */
// echo $model->lb_record_primary_key;
echo '<div id="lb-container-header">';
echo '<div class="lb-header-right" style="margin-left:-11px;" ><h4>Team Members</h4></div>';
echo '<div class="lb-header-left">';
echo '&nbsp;';
echo '</div>';
echo '</div><br>';
// see if this user has any subscription
$subscriptions = AccountSubscription::model()->findSubscriptions(Yii::app()->user->id, true);
if (count($subscriptions)) {
    echo "<h4>Company: " . AccountSubscription::model()->getSubscriptionName(Yii::app()->user->linx_app_selected_subscription) . '</h4>';
    $this->widget('bootstrap.widgets.TbGridView', array('type' => 'striped', 'dataProvider' => $memberCADataProvider, 'columns' => array(array('type' => 'raw', 'value' => 'AccountProfile::model()->getProfilePhoto($data->member_account_id)'), array('name' => 'member_account.account_profile.account_profile_preferred_display_name', 'header' => ''), array('name' => 'member_account.account_email', 'header' => ''), array('type' => 'raw', 'value' => ' ($data->is_customer == ACCOUNT_TEAM_MEMBER_IS_CUSTOMER ? "Customer" : "")'), array('type' => 'raw', 'value' => ' ($data->is_active == AccountTeamMember::ACCOUNT_TEAM_MEMBER_IS_DEACTIVATED ? 
						"<i class=\'blur-summary\'>Deactivated</i>" : "")'), array('header' => '', 'type' => 'raw', 'value' => '
						CHtml::link("<i class=\'icon-eye-open\'></i>",
							array("account/view/", "id" => $data->member_account_id),
							array("rel" => "tooltip", 
									"data-original-title" => "Update")).
						CHtml::link("<i class=\'icon-pencil\'></i>",
							array("accountTeamMember/update", "id" => $data->account_team_member_id),
							array("rel" => "tooltip", 
									"data-original-title" => "Update")) . 
						/**LBApplication::generateManualAjaxLink("<i class=\'icon-trash\'></i>",
							array("url" => array("accountTeamMember/delete", "id" => $data->account_team_member_id),
								"type" => "POST",
								"cache"=> FALSE,
								"data"=>"jQuery(this).parents(\\"form\\").serialize()",