Beispiel #1
0
 public function actionUrls_mass()
 {
     if (!Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     $action = $_GET['action'];
     if (isset($_POST['extendedSelect'])) {
         AdvancedSelectableGridView::mapUrlToGET();
         $dataProvider = Url::searchDataProvider();
         $criteria = AdvancedSelectableGridView::getExtendedSelectCriteria('Url', $dataProvider);
         if (!$criteria->condition) {
             $criteria->condition = "1=1";
         }
         if ($action == 'download') {
             Url::model()->downloadUrls($criteria->condition, $criteria->params);
         } elseif ($action == 'delete') {
             Url::model()->deleteUrls($criteria->condition, $criteria->params);
         } elseif ($action == 'enable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=1 WHERE " . $criteria->condition)->execute($criteria->params);
         } elseif ($action == 'disable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=0 WHERE " . $criteria->condition)->execute($criteria->params);
         }
     } elseif (isset($_POST['selected']) && is_array($_POST['selected']) && count($_POST['selected'])) {
         foreach ($_POST['selected'] as $k => $v) {
             // value must be integer
             $_POST['selected'][$k] = (int) $v;
         }
         if (count($_POST['selected']) == 1) {
             $condition = "id_url=" . $_POST['selected'][0];
         } else {
             $condition = "id_url='" . implode("' OR id_url='", $_POST['selected']) . '\'';
         }
         if ($action == 'download') {
             Url::model()->downloadUrls($condition);
         } elseif ($action == 'delete') {
             Url::model()->deleteUrls($condition);
         } elseif ($action == 'enable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=1 WHERE " . $condition)->execute();
         } elseif ($action == 'disable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=0 WHERE " . $condition)->execute();
         }
     } else {
         throw new CHttpException(400, 'Bad request.');
     }
     header("Location: " . $_SERVER['HTTP_REFERER']);
     die;
 }
Beispiel #2
0
 public function actionBogus_mass()
 {
     if (!Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     $action = $_GET['action'];
     $message = false;
     if (isset($_POST['extendedSelect'])) {
         AdvancedSelectableGridView::mapUrlToGET();
         $dataProvider = Url::searchDataProvider();
         $criteria = AdvancedSelectableGridView::getExtendedSelectCriteria('Url', $dataProvider);
         if (!$criteria->condition) {
             $criteria->condition = "1=1";
         }
         if ($action == 'unpack') {
             Yii::app()->db->createCommand("UPDATE bogus_archives_bga SET pending_action_bga='Rescan' WHERE {$criteria->condition}")->execute($criteria->params);
         } elseif ($action == 'delete') {
             Yii::app()->db->createCommand("UPDATE bogus_archives_bga SET pending_action_bga='Delete' WHERE {$criteria->condition}")->execute($criteria->params);
         }
     } elseif (isset($_POST['selected']) && is_array($_POST['selected']) && count($_POST['selected'])) {
         foreach ($_POST['selected'] as $k => $v) {
             // value must be integer
             $_POST['selected'][$k] = (int) $v;
         }
         if (count($_POST['selected']) == 1) {
             $condition = "id_bga=" . $_POST['selected'][0];
         } else {
             $condition = "id_bga='" . implode("' OR id_bga='", $_POST['selected']) . '\'';
         }
         $number = Yii::app()->db->createCommand("SELECT count(*) 'nr' FROM bogus_archives_bga WHERE {$condition}")->queryRow();
         $number = $number['nr'];
         if ($action == 'unpack') {
             Yii::app()->db->createCommand("UPDATE bogus_archives_bga SET pending_action_bga='Rescan' WHERE {$condition}")->execute();
             Yii::app()->user->setFlash('_success', $number . ' archives will be reprocessed!');
         } elseif ($action == 'delete') {
             Yii::app()->db->createCommand("UPDATE bogus_archives_bga SET pending_action_bga='Delete' WHERE {$condition}")->execute();
             Yii::app()->user->setFlash('_success', $number . ' archives will be deleted!');
         }
     } else {
         throw new CHttpException(400, 'Bad request.');
     }
     header("Location: " . $_SERVER['HTTP_REFERER']);
 }