예제 #1
0
 public function actionRemove($instagram_id = 0)
 {
     $user = User::model()->findByPk(Yii::app()->user->id);
     $user_child_id = User::instagramIdToId($instagram_id);
     UserChild::model()->deleteAll('user_id=:user_id AND user_child_id=:user_child_id', array(':user_child_id' => $user_child_id, ':user_id' => $user->id));
     $this->redirect('/user/account');
 }
예제 #2
0
파일: Record.php 프로젝트: ruchida/X2Engine
	public static function convert($records) {
		$arr=array();
		$id=1;
		
		foreach ($records as $record) {
			$user=UserChild::model()->findByAttributes(array('username'=>$record->updatedBy));
			$name=$user->firstName." ".$user->lastName;
			if ($record instanceof Contacts) {
				$temp=array();
				$temp['id']=$id;
					$id++;
				$temp['name']=$record->firstName.' '.$record->lastName;
				$temp['description']=$record->backgroundInfo;
				$temp['link']='/contacts/'.$record->id;
				$temp['type']='Contact';
				$temp['lastUpdated']=$record->lastUpdated;
				$temp['updatedBy']=$name;
				$arr[]=$temp;
			} elseif ($record instanceof Actions) {
				$temp=array();
				$temp['id']=$id;
					$id++;
				$temp['name']=empty($record->type)? Yii::t('actions','Action') : Yii::t('actions','Action: ').ucfirst($record->type);
				$temp['description']=$record->actionDescription;
				$temp['link']='/actions/'.$record->id;
				$temp['type']='Action';
				$temp['lastUpdated']=$record->lastUpdated;
				$temp['updatedBy']=$name;
				$arr[]=$temp;
			} else {
				$temp=array();
				$temp['id']=$id;
					$id++;
				$temp['name']=$record->name;
				$temp['description']=$record->description;
				
				$temp['lastUpdated']=$record->lastUpdated;
				$temp['updatedBy']=$name;
				
				if($record instanceof Sales){
					$temp['link']='/sales/'.$record->id;
					$temp['type']='Sale';
				}
				elseif ($record instanceof Accounts){
					$temp['link']='/accounts/'.$record->id;
					$temp['type']='Account';
				}
				elseif($record instanceof Projects)
					$temp['link']='/projects/'.$record->id;
				elseif($record instanceof Cases)
					$temp['link']='/cases/'.$record->id;
				elseif($record instanceof Marketing)
					$temp['link']='/marketing/'.$record->id;

				$arr[]=$temp;
			}
		}
		return $arr;
	}
예제 #3
0
	public function authenticate() {
		$user = UserChild::model()->findByAttributes(array('username' => $this->username));
		if ($user === null || $user->status < 1)
			$this->errorCode = self::ERROR_USERNAME_INVALID;
		else if ($user->password !== md5($this->password))
			$this->errorCode = self::ERROR_PASSWORD_INVALID;
		else {
			$this->_id = $user->id;
			//$this->setState('lastLoginTime', $user->lastLoginTime); //not yet set up
			$this->errorCode = self::ERROR_NONE;
		}
		return !$this->errorCode;
	}
예제 #4
0
	public function actionIndex(){
		
		$user=UserChild::model()->findByPk(Yii::app()->user->getId());
		$topList=$user->topContacts;
		$pieces=explode(',',$topList);
		$contacts=array();
		foreach($pieces as $piece){
			$contact=ContactChild::model()->findByPk($piece); 
			if(isset($contact))
				$contacts[]=$contact;
		}
		$dataProvider=new CActiveDataProvider('Contacts');
		$dataProvider->setData($contacts);
		
		$this->render('index',array(
			'dataProvider'=>$dataProvider,
		));
	}
예제 #5
0
	public static function getEmails(){
		$userArray=UserChild::model()->findAll();
		$emails=array('Anyone'=>Yii::app()->params['adminEmail']);
		foreach($userArray as $user){
			$emails[$user->username]=$user->emailAddress;
		}
		return $emails;
	}
예제 #6
0
	<!-- sidebar -->
	<?php 
if (isset($this->actionMenu)) {
    $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('app', 'Actions'), 'id' => 'actions'));
    $this->widget('zii.widgets.CMenu', array('items' => $this->actionMenu));
    $this->endWidget();
}
if (isset($this->modelClass) && $this->modelClass == 'Actions' && $this->showActions !== null) {
    $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('actions', 'Show Actions'), 'id' => 'actions-filter'));
    echo '<div class="form" style="border: none;">';
    echo CHtml::dropDownList('show-actions', $this->showActions, array('uncomplete' => Yii::t('actions', 'Uncomplete'), 'complete' => Yii::t('actions', 'Complete'), 'all' => Yii::t('actions', 'All')), array('id' => 'dropdown-show-actions', 'onChange' => 'toggleShowActions();'));
    echo '</div>';
    $this->endWidget();
}
if (isset($this->modelClass) && $this->modelClass == 'Calendar') {
    $user = UserChild::model()->findByPk(Yii::app()->user->getId());
    $showCalendars = json_decode($user->showCalendars, true);
    $editableCalendars = X2Calendar::getEditableCalendarNames();
    // list of calendars current user can edit
    $editableUserCalendars = X2Calendar::getEditableUserCalendarNames();
    // list of user calendars current user can edit
    if (isset($this->sharedCalendars) && $this->sharedCalendars !== null) {
        $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('calendar', 'Calendars'), 'id' => 'shared-calendar'));
        $showSharedCalendars = $showCalendars['sharedCalendars'];
        echo '<ul style="font-size: 0.8em; font-weight: bold; color: black;">';
        foreach ($this->sharedCalendars as $calendarId => $calendarName) {
            if (isset($editableCalendars[$calendarId])) {
                // check if current user has permission to edit calendar
                $editable = 'true';
            } else {
                $editable = 'false';
예제 #7
0
	private function globalExport() {
		
		$file='file.csv';
		$fp = fopen($file, 'w+');
		
		$users=UserChild::model()->findAll();
		$contacts=ContactChild::model()->findAll();
		$actions=ActionChild::model()->findAll();
		$sales=SaleChild::model()->findAll();
		$accounts=AccountChild::model()->findAll();
		$docs=Docs::model()->findAll();
		$profiles=Profile::model()->findAll();
		
		fputcsv($fp,array("0.9.1"));
		
		$userList=array();
		foreach($users as $user) {
			$userList[]=$user->attributes;
		}
		foreach ($userList as $fields) {
			unset($fields['id']);
			unset($fields['updatePassword']);
			$fields[]='user';
			fputcsv($fp, $fields);
			
		}
		
	
		$contactList=array();
		foreach($contacts as $contact) {
			$contactList[]=$contact->attributes;
		}
		foreach ($contactList as $fields) {
			unset($fields['id']);
			$fields[]='contact';
			fputcsv($fp, $fields);
			
		}
		
		$actionList=array();
		foreach($actions as $action) {
			$actionList[]=$action->attributes;
		}
		foreach ($actionList as $fields) {
			unset($fields['id']);
			$fields[]='action';
			fputcsv($fp, $fields);
			
		}
		
		$saleList=array();
		foreach($sales as $sale) {
			$saleList[]=$sale->attributes;
		}
		foreach ($saleList as $fields) {
			unset($fields['id']);
			$fields[]='sale';
			fputcsv($fp, $fields);
			
		}
		
		$accountList=array();
		foreach($accounts as $account) {
			$accountList[]=$account->attributes;
		}
		foreach ($accountList as $fields) {
			unset($fields['id']);
			$fields[]='account';
			fputcsv($fp, $fields);
			
		}
		
		$docList=array();
		foreach($docs as $doc) {
			$docList[]=$doc->attributes;
		}
		foreach ($docList as $fields) {
			unset($fields['id']);
			$fields[]='doc';
			fputcsv($fp, $fields);
			
		}
		
		$profileList=array();
		foreach($profiles as $profile) {
			if($profile->username!='admin')
				$profileList[]=$profile->attributes;
		}
		foreach ($profileList as $fields) {
			unset($fields['id']);
			unset($fields['avatar']);
			$fields[]='profile';
			fputcsv($fp, $fields);
			
		}


		fclose($fp);

	}
예제 #8
0
 public static function convert($records, $whatsNew = true)
 {
     $arr = array();
     foreach ($records as $record) {
         $user = UserChild::model()->findByAttributes(array('username' => $record->updatedBy));
         if (isset($user)) {
             $name = $user->firstName . " " . $user->lastName;
             $userId = $user->id;
         } else {
             $name = 'web admin';
             $userId = 1;
         }
         if ($record instanceof Contacts) {
             $temp = array();
             $temp['id'] = $record->id;
             $temp['name'] = $record->firstName . ' ' . $record->lastName;
             $temp['description'] = $record->backgroundInfo;
             $temp['link'] = '/contacts/default/view/id/' . $record->id;
             $temp['type'] = 'Contact';
             $temp['lastUpdated'] = $record->lastUpdated;
             $temp['updatedBy'] = CHtml::link($name, array('profile/' . $userId));
             while (isset($arr[$temp['lastUpdated']])) {
                 $temp['lastUpdated']++;
             }
             $arr[$temp['lastUpdated']] = $temp;
         } elseif ($record instanceof Actions) {
             $temp = array();
             $temp['id'] = $record->id;
             $temp['name'] = empty($record->type) ? Yii::t('actions', 'Action') : Yii::t('actions', 'Action: ') . ucfirst($record->type);
             $temp['description'] = $record->actionDescription;
             $temp['link'] = '/actions/default/view/id/' . $record->id;
             $temp['type'] = 'Action';
             $temp['lastUpdated'] = $record->lastUpdated;
             $temp['updatedBy'] = $name;
             while (isset($arr[$temp['lastUpdated']])) {
                 $temp['lastUpdated']++;
             }
             $arr[$temp['lastUpdated']] = $temp;
         } else {
             $temp = array();
             $temp['id'] = $record->id;
             $temp['name'] = $record->name;
             if (!is_null($record->description)) {
                 $temp['description'] = $record->description;
             } else {
                 $temp['description'] = "";
             }
             $temp['lastUpdated'] = $record->lastUpdated;
             $temp['updatedBy'] = $name;
             if ($record instanceof Sales) {
                 $temp['link'] = '/sales/default/view/id/' . $record->id;
                 $temp['type'] = 'Sale';
             } elseif ($record instanceof Accounts) {
                 $temp['link'] = '/accounts/default/view/id/' . $record->id;
                 $temp['type'] = 'Account';
             } else {
                 $temp['link'] = '/' . strtolower(get_class($record)) . '/default/view/id/' . $record->id;
             }
             while (isset($arr[$temp['lastUpdated']])) {
                 $temp['lastUpdated']++;
             }
             if ($whatsNew) {
                 $arr[$temp['lastUpdated']] = $temp;
             } else {
                 $arr[] = $temp;
             }
         }
     }
     if ($whatsNew) {
         ksort($arr);
         return array_values(array_reverse($arr));
     } else {
         return array_values($arr);
     }
 }
예제 #9
0
	public function actionLogout() {
		$user = UserChild::model()->findByPk(Yii::app()->user->getId());
		$user->lastLogin=time();
		$user->save();
		Yii::app()->user->logout();
		$this->redirect(Yii::app()->homeUrl);
	}
예제 #10
0
	public static function editUsersInverse($arr) {
		
		$data=array();
		
		foreach($arr as $username){
			if($username!='')
				$data[]=UserChild::model()->findByAttributes(array('username'=>$username));
		}
		
		$temp=array();
		if(isset($data)){
			foreach($data as $item){
				if(isset($item))
					$temp[$item->username]=$item->firstName.' '.$item->lastName;
			}
		}
		return $temp;
	}
예제 #11
0
    public function actionGetMessages() {
        $time=time();
		$sinceMidnight=(3600*date("H"))+(60*date("i"))+date("s");
        $latest = '';
        if (isSet($_GET['latest']))
            $latest = $_GET['latest'];
        $retrys = 20;
        $content = array();
        $records = array();
        while (true) {
            $str = '';
            $chatLog = new CActiveDataProvider('Social', array(
                        'criteria' => array(
                            'order' => 'timestamp DESC',
                            'condition' => 'type="chat" AND timestamp > '. (($latest != '') ? (''.$latest) : ''.($time-$sinceMidnight))
                        ),
                        'pagination' => array(),
                    ));
            $records = $chatLog->getData();
            if (sizeof($records) > 0) {
                foreach ($records as $chat) {
                    if ($latest != '' && $chat->timestamp < $latest)
                        continue;
                    $user = UserChild::model()->findByAttributes(array('username' => $chat->user));
                    if ($user != null)
                        $content[] = array('username' => $chat->user,
                            'userid' => $user->id,
                            'message' => $chat->data,
                            'timestamp' => $chat->timestamp,
                            'when' => date('g:i:s A',$chat->timestamp));
                }
                if (sizeof($content) > 0) {
                    $str = json_encode($content);
                    echo $str;
                    break;
                }
            }
            if (--$retrys > 0) {
                sleep(1);
            } else {
                echo $str;
                break;
            }
        }
    }
예제 #12
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 the ID of the model to be loaded
	 */
	public function loadModel($id) {
		$model=UserChild::model()->findByPk((int)$id);
		if($model===null)
			throw new CHttpException(404,Yii::t('app','The requested page does not exist.'));
		return $model;
	}