Exemplo n.º 1
0
 public function appList($id, $offset = 0)
 {
     $user_app_list = $this->findAll(array('condition' => 'user_id=' . $id, 'select' => 'app_id', 'order' => 'added DESC', 'limit' => Yii::app()->params->maxAppsPerRequest, 'offset' => $offset));
     $uappids = array();
     if (empty($user_app_list)) {
         $cond = '0';
     } else {
         foreach ($user_app_list as $v) {
             $uappids[] = $v->app_id;
         }
         $cond = implode(' OR id=', $uappids);
     }
     $ua = Apps::model()->findAll(array('condition' => 'id=' . $cond, 'order' => 'users DESC'));
     $ua2 = array();
     foreach ($ua as $v) {
         $ua2[$v->id] = $v;
     }
     $userapps = array();
     foreach ($user_app_list as $v) {
         $userapps[] = $ua2[$v->app_id];
     }
     return $userapps;
 }
Exemplo n.º 2
0
 public function actionLoadMore($id)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $lastOffset = Yii::app()->getRequest()->getPost('lastOffset');
         $list = Yii::app()->getRequest()->getPost('list');
         if ($list == 'all') {
             $apps = Apps::model()->appList($lastOffset);
         } else {
             $apps = UserApps::model()->appList($id, $lastOffset);
         }
         $user_apps_ids = UserApps::model()->userAppIds($id);
         $res = $this->renderPartial('_appTable', array('apps' => $apps, 'user_apps_ids' => $user_apps_ids, $display = 'none'), true);
         $lastOffset += Yii::app()->params->maxAppsPerRequest;
         echo json_encode(array('status' => 'ok', 'offset' => $lastOffset, 'data' => $res));
     } else {
         throw new CException('Not Found', 404);
     }
 }
Exemplo n.º 3
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 Apps the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Apps::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 4
0
                <a href="<?php 
            echo $appDelete . $ca->id;
            ?>
" onCLick="return confirm('Удалить приложение?');"><div class="setupBtn" style="margin-top:10px;">удалить</div></a>
				<?php 
        }
        ?>
			</div>
		</div>
		<a href="<?php 
        echo $appAction . $ca->id;
        ?>
"><?php 
        echo CHtml::encode($ca->caption);
        ?>
</a><br />
		<font class="usersCount">Пользователей: <?php 
        echo Apps::model()->explodeToTreads($ca->users);
        ?>
</font>
	</div>
	</td>
	<?php 
        $aid++;
    }
    ?>
</tr>
<?php 
}
?>
</table>