示例#1
0
 public function actionList($id = null)
 {
     $list = X2List::load($id);
     if (!isset($list)) {
         Yii::app()->user->setFlash('error', Yii::t('app', 'The requested page does not exist.'));
         $this->redirect(array('lists'));
     }
     $model = new Contacts('search');
     Yii::app()->user->setState('vcr-list', $id);
     $dataProvider = $model->searchList($id);
     $list->count = $dataProvider->totalItemCount;
     $list->runWithoutBehavior('X2FlowTriggerBehavior', function () use($list) {
         $list->save();
     });
     X2Flow::trigger('RecordViewTrigger', array('model' => $list));
     $this->render('list', array('listModel' => $list, 'dataProvider' => $dataProvider, 'model' => $model));
 }
示例#2
0
//convert session var to sql
$order = preg_replace('/\\.desc$/', ' DESC', $order);
// ensure that order attribute is valid
$orderAttr = preg_replace('/ DESC$/', '', $order);
if (!is_string($orderAttr) || !Contacts::model()->hasAttribute(trim($orderAttr))) {
    $order = '';
}
//look up all ids of the list we are currently viewing
//find position of model in the list
$moduleTitle = Modules::displayName();
// decide which data provider to use
if (is_numeric($listId)) {
    $list = X2Model::model('X2List')->findByPk($listId);
    if (isset($list)) {
        $listLink = CHtml::link($list->name, array('/contacts/contacts/list', 'id' => $listId));
        $vcrDataProvider = $searchModel->searchList($listId);
    } else {
        // default to All Contacts
        $listLink = CHtml::link(Yii::t('contacts', 'All {module}', array('{module}' => $moduleTitle)), array('/contact/contacts/index'));
        $vcrDataProvider = $searchModel->searchAll();
    }
} elseif ($listId == 'myContacts') {
    $listLink = CHtml::link(Yii::t('contacts', 'My {module}', array('{module}' => $moduleTitle)), array('/contacts/contacts/myContacts'));
    $vcrDataProvider = $searchModel->searchMyContacts();
} elseif ($listId == 'newContacts') {
    $listLink = CHtml::link(Yii::t('contacts', 'New {module}', array('{module}' => $moduleTitle)), array('/contacts/contacts/newContacts'));
    $vcrDataProvider = $searchModel->searchNewContacts();
} elseif ($tagFlag) {
    $listLink = CHtml::link(Yii::t('contacts', 'Tag Search'), array('/search/search', 'term' => $listId));
    $_GET['tagField'] = $listId;
    $vcrDataProvider = $searchModel->searchAll();
示例#3
0
 /**
  * Gets a list of contacts.
  */
 public function actionList()
 {
     $listId = $_POST['id'];
     $list = X2List::model()->findByPk($listId);
     if (isset($list)) {
         //$list=X2List::load($listId);
     } else {
         $list = X2List::model()->findByAttributes(array('name' => $listId));
         if (isset($list)) {
             $listId = $list->id;
             //$list=X2List::load($listId);
         } else {
             $this->_sendResponse(404, 'No list found with id: ' . $_POST['id']);
         }
     }
     $model = new Contacts('search');
     $dataProvider = $model->searchList($listId, 10);
     $data = $dataProvider->getData();
     $this->_sendResponse(200, json_encode($data), true);
 }
 public function actionList()
 {
     $id = isset($_GET['id']) ? $_GET['id'] : 'all';
     if (is_numeric($id)) {
         $list = CActiveRecord::model('X2List')->findByPk($id);
     }
     if (isset($list)) {
         $model = new Contacts('searchList');
         $dataProvider = $model->searchList($id);
         $list->count = $dataProvider->totalItemCount;
         $list->save();
         $this->render('list', array('listModel' => $list, 'dataProvider' => $dataProvider, 'model' => $model));
     } else {
         if ($id == 'my') {
             $this->redirect(array('/contacts/myContacts'));
         } elseif ($id == 'new') {
             $this->redirect(array('/contacts/newContacts'));
         } else {
             $this->redirect(array('/contacts/allContacts'));
         }
     }
 }