Ejemplo n.º 1
0
     $list = new ae_PageList($filter);
 } else {
     if (isset($_GET['post'])) {
         $area = 'post';
         $areaName = 'Posts';
         if (ae_PostModel::isValidStatus($status)) {
             $filter['WHERE'] = 'po_status = "' . $status . '"';
         } else {
             $filter['WHERE'] = 'po_status != "trash"';
         }
         $list = new ae_PostList($filter);
     } else {
         if (isset($_GET['user'])) {
             $area = 'user';
             $areaName = 'Users';
             if (ae_UserModel::isValidStatus($status)) {
                 $filter['WHERE'] = 'u_status = "' . $status . '"';
             }
             $list = new ae_UserList($filter);
         } else {
             $area = 'comment';
             $areaName = 'Comments';
             if (ae_CommentModel::isValidStatus($status)) {
                 $filter['WHERE'] = 'co_status = "' . $status . '"';
             } else {
                 $filter['WHERE'] = 'co_status != "trash" AND co_status != "spam"';
             }
             $list = new ae_CommentList($filter);
         }
     }
 }
Ejemplo n.º 2
0
        $mainArea = 'media';
        $modelName = 'ae_MediaModel';
        $preDelete = ae_MediaModel::STATUS_TRASH;
        break;
    case 'page':
        $isValidStatus = $status == 'delete' ? TRUE : ae_PageModel::isValidStatus($status);
        $modelName = 'ae_PageModel';
        $preDelete = ae_PageModel::STATUS_TRASH;
        break;
    case 'post':
        $isValidStatus = $status == 'delete' ? TRUE : ae_PostModel::isValidStatus($status);
        $modelName = 'ae_PostModel';
        $preDelete = ae_PostModel::STATUS_TRASH;
        break;
    case 'user':
        $isValidStatus = $status == 'delete' ? TRUE : ae_UserModel::isValidStatus($status);
        $modelName = 'ae_UserModel';
        $preDelete = ae_UserModel::STATUS_SUSPENDED;
        break;
    default:
        $isValidStatus = FALSE;
}
$table = constant($modelName . '::TABLE');
$idField = constant($modelName . '::TABLE_ID_FIELD');
if (!$isValidStatus) {
    header('Location: ../admin.php?error=invalid_status');
    exit;
}
$prefix = explode('_', $idField);
$prefix = $prefix[0];
// Delete all selected
Ejemplo n.º 3
0
                $area = 'media';
                $mainArea = 'media';
                $model = new ae_MediaModel();
                $model->setMediaPath('../../media/');
            } else {
                if (isset($_GET['page']) && ae_Validate::id($_GET['page'])) {
                    $area = 'page';
                    $model = new ae_PageModel();
                } else {
                    if (isset($_GET['post']) && ae_Validate::id($_GET['post'])) {
                        $area = 'post';
                        $model = new ae_PostModel();
                    } else {
                        if (isset($_GET['user']) && ae_Validate::id($_GET['user'])) {
                            $area = 'user';
                            $model = new ae_UserModel();
                        } else {
                            header('Location: ../admin.php?error=unknown_area_or_invalid_id');
                            exit;
                        }
                    }
                }
            }
        }
    }
}
$model->load($_GET[$area]);
$prevStatus = $model->getStatus();
if ($_GET['status'] == 'delete') {
    if (!$model->delete()) {
        header('Location: ../admin.php?area=' . $mainArea . '&' . $area . '&status=' . $prevStatus . '&error=delete');
Ejemplo n.º 4
0
        $statuses = ae_CommentfilterModel::listStatuses();
    } else {
        if ($area == 'comment') {
            $statuses = ae_CommentModel::listStatuses();
        } else {
            if ($area == 'media') {
                $statuses = ae_MediaModel::listStatuses();
            } else {
                if ($area == 'page') {
                    $statuses = ae_PageModel::listStatuses();
                } else {
                    if ($area == 'post') {
                        $statuses = ae_PostModel::listStatuses();
                    } else {
                        if ($area == 'user') {
                            $statuses = ae_UserModel::listStatuses();
                        }
                    }
                }
            }
        }
    }
}
$select = ae_Forms::selectStatus('bulk-status-change', $statuses);
if (isset($_GET['status']) && $_GET['status'] == 'trash') {
    $select = str_replace('trash', 'delete', $select);
} else {
    if (isset($_GET['status']) && $_GET['status'] == 'inactive' && $area == 'cofilter') {
        $select = str_replace('inactive', 'delete', $select);
    }
}
Ejemplo n.º 5
0
 public function testSetStatus()
 {
     $u = new ae_UserModel();
     $this->assertTrue(ae_UserModel::isValidStatus($u->getStatus()));
     $u->setStatus(ae_UserModel::STATUS_ACTIVE);
     $this->assertEquals($u->getStatus(), ae_UserModel::STATUS_ACTIVE);
     $this->setExpectedException('Exception');
     $u->setStatus(TRUE);
 }
Ejemplo n.º 6
0
 /**
  * Get the user ID.
  * @return {int|boolean} The user ID or FALSE on failure.
  */
 public static function getUserId()
 {
     if (!self::isUser()) {
         $msg = sprintf('[%s] Permalink does not represent a user.', get_class());
         throw new Exception($msg);
     }
     $model = new ae_UserModel();
     if (isset($_GET[PERMALINK_GET_USER])) {
         $permalink = $_GET[PERMALINK_GET_USER];
     } else {
         $permalink = mb_substr(self::$url, 1);
         $permalink = preg_replace(';^' . PERMALINK_BASE_USER . ';i', '', $permalink);
     }
     if (!$model->loadFromPermalink($permalink)) {
         return FALSE;
     }
     return $model->getId();
 }
Ejemplo n.º 7
0
                    $editArea = 'Page';
                    $areaId = 'page';
                    $model = new ae_PageModel();
                    $model->load($_GET['page']);
                } else {
                    if (isset($_GET['post']) && ae_Validate::id($_GET['post'])) {
                        $editArea = 'Post';
                        $areaId = 'post';
                        $model = new ae_PostModel();
                        $model->load($_GET['post']);
                        $model->loadCategoryIds();
                    } else {
                        if (isset($_GET['user']) && ae_Validate::id($_GET['user'])) {
                            $editArea = 'User';
                            $areaId = 'user';
                            $model = new ae_UserModel();
                            $model->load($_GET['user']);
                        } else {
                            header('Location: admin.php?error=unknown_edit_area');
                            exit;
                        }
                    }
                }
            }
        }
    }
}
?>
<h1>Edit: <?php 
echo $editArea;
?>
Ejemplo n.º 8
0
/**
 * Create the user.
 * @return {int} ID of the new user.
 */
function createUser()
{
    if (!isset($_POST['user-name-internal'], $_POST['user-name-external'], $_POST['user-permalink'], $_POST['user-password'])) {
        header('Location: ../admin.php?error=missing_data_for_user');
        exit;
    }
    $permalink = trim($_POST['user-permalink']);
    $status = isset($_POST['user-status-suspended']) ? ae_UserModel::STATUS_SUSPENDED : ae_UserModel::STATUS_ACTIVE;
    $user = new ae_UserModel();
    if (isset($_POST['edit-id'])) {
        if (!$user->load($_POST['edit-id'])) {
            return FALSE;
        }
    }
    $user->setNameInternal($_POST['user-name-internal']);
    $user->setNameExternal($_POST['user-name-external']);
    if ($permalink != '') {
        $user->setPermalink($permalink);
    }
    if ($_POST['user-password'] !== '') {
        $user->setPasswordHash(ae_Security::hash($_POST['user-password']));
    }
    $user->setStatus($status);
    $user->save();
    return $user->getId();
}