public static function handleBrowseRequest($options = [], $conditions = [], $responseID = null, $responseData = [])
 {
     // apply status filter
     if (empty($_GET['status'])) {
         $status = 'open';
     } elseif ($_GET['status'] == 'any') {
         $status = null;
     } elseif (in_array($_GET['status'], AbstractAlert::getFieldOptions('Status', 'values'))) {
         $status = $_GET['status'];
     } else {
         $status = 'open';
     }
     if ($status) {
         $responseData['status'] = $conditions['Status'] = $status;
     }
     // apply endpoint filter
     if (!empty($_GET['endpoint'])) {
         if (!($Endpoint = Endpoint::getByHandle($_GET['endpoint']))) {
             return static::throwNotFoundError('Endpoint not found');
         }
     }
     if (isset($Endpoint)) {
         $conditions['EndpointID'] = $Endpoint->ID;
         $responseData['Endpoint'] = $Endpoint;
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = array(), $conditions = array(), $responseID = null, $responseData = array())
 {
     if ($_REQUEST['q'] != 'all') {
         $conditions[] = 'AccountLevel != "Disabled"';
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = [], $conditions = [], $responseID = null, $responseData = [])
 {
     if (!empty($_GET['ProjectID']) && ctype_digit($_GET['ProjectID']) && ($Project = Project::getByID($_GET['ProjectID']))) {
         $conditions['ProjectID'] = $Project->ID;
         $responseData['Project'] = $Project;
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = array(), $conditions = array(), $responseID = null, $responseData = array())
 {
     if (!$GLOBALS['Session']->hasAccountLevel('Staff') || empty($_GET['showall'])) {
         $conditions['Status'] = 'Published';
         $conditions[] = 'Published IS NULL OR Published <= CURRENT_TIMESTAMP';
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = [], $conditions = [], $responseID = null, $responseData = [])
 {
     // apply endpoint filter
     if (!empty($_REQUEST['endpoint'])) {
         if (!($Endpoint = Endpoint::getByHandle($_REQUEST['endpoint']))) {
             return static::throwNotFoundError('Endpoint not found');
         }
         $conditions['EndpointID'] = $Endpoint->ID;
         $responseData['Endpoint'] = $Endpoint;
     }
     // apply method filter
     if (!empty($_REQUEST['method'])) {
         $conditions['Method'] = $_REQUEST['method'];
     }
     // apply path filter
     if (!empty($_REQUEST['path-substring'])) {
         $conditions[] = 'Path LIKE "%' . DB::escape($_REQUEST['path-substring']) . '%"';
     }
     // apply path filter
     if (!empty($_REQUEST['query-substring'])) {
         $conditions[] = 'Query LIKE "%' . DB::escape($_REQUEST['query-substring']) . '%"';
     }
     // apply IP filter
     if (!empty($_REQUEST['ip'])) {
         if (!filter_var($_REQUEST['ip'], FILTER_VALIDATE_IP)) {
             return static::throwError('IP is invalid');
         }
         $conditions['ClientIP'] = ip2long($_REQUEST['ip']);
     }
     // apply key filter
     if (!empty($_REQUEST['key'])) {
         if (!($Key = Key::getByKey($_REQUEST['key']))) {
             return static::throwError('key is invalid');
         }
         $conditions['KeyID'] = $Key->ID;
     }
     // apply time filter
     if (!empty($_REQUEST['time-max']) && ($timeMax = strtotime($_REQUEST['time-max']))) {
         $conditions[] = 'Created <= "' . date('Y-m-d H:i:s', $timeMax) . '"';
     }
     if (!empty($_REQUEST['time-min']) && ($timeMin = strtotime($_REQUEST['time-min']))) {
         $conditions[] = 'Created >= "' . date('Y-m-d H:i:s', $timeMin) . '"';
     }
     // apply type filter
     if (!empty($_REQUEST['type'])) {
         if ($_REQUEST['type'] == 'ping') {
             $conditions['Class'] = PingTransaction::class;
         } elseif ($_REQUEST['type'] == 'consumer') {
             $conditions['Class'] = Transaction::class;
         }
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = array(), $conditions = array(), $responseID = null, $responseData = array())
 {
     if (!empty($_GET['competency'])) {
         if (ctype_digit($_GET['competency'])) {
             $Competency = Competency::getByID($_GET['competency']);
         } else {
             $Competency = Competency::getByCode($_GET['competency']);
         }
         if (!$Competency) {
             return static::throwNotFoundError('Competency not found');
         }
         $conditions['CompetencyID'] = $Competency->ID;
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = array(), $conditions = array(), $responseID = null, $responseData = array())
 {
     if (!empty($_GET['skill']) && ctype_digit($_GET['skill'])) {
         // TODO: implement this as a lower-level override to the generated browse query so it can be a FROM subquery
         try {
             $demonstrations = DB::allValues('DemonstrationID', 'SELECT DemonstrationID FROM `%s` WHERE SkillID = %u', [DemonstrationSkill::$tableName, $_GET['skill']]);
         } catch (TableNotFoundException $e) {
             $demonstrations = [];
         }
         $conditions[] = 'ID IN (' . implode($demonstrations, ',') . ')';
     }
     if (!empty($_GET['student']) && ctype_digit($_GET['student'])) {
         $conditions['StudentID'] = $_GET['student'];
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = [], $conditions = [], $responseID = null, $responseData = [])
 {
     // apply tag filter
     if (!empty($_REQUEST['tag'])) {
         // get tag
         if (!($Tag = Tag::getByHandle($_REQUEST['tag']))) {
             return static::throwNotFoundError('Tag not found');
         }
         $conditions[] = 'ID IN (SELECT ContextID FROM tag_items WHERE TagID = ' . $Tag->ID . ' AND ContextClass = "Laddr\\\\Project")';
     }
     // apply stage filter
     if (!empty($_REQUEST['stage'])) {
         $conditions['Stage'] = $_REQUEST['stage'];
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }
 public static function handleBrowseRequest($options = array(), $conditions = array(), $responseID = null, $responseData = array())
 {
     // apply tag filter
     if (!empty($_REQUEST['tag'])) {
         // get tag
         if (!($Tag = Tag::getByHandle($_REQUEST['tag']))) {
             return static::throwNotFoundError('Tag not found');
         }
         $conditions[] = 'ID IN (SELECT ContextID FROM tag_items WHERE TagID = ' . $Tag->ID . ' AND ContextClass = "Product")';
     }
     // apply context filter
     if (!empty($_REQUEST['ContextClass'])) {
         $conditions['ContextClass'] = $_REQUEST['ContextClass'];
     }
     if (!empty($_REQUEST['ContextID']) && is_numeric($_REQUEST['ContextID'])) {
         $conditions['ContextID'] = $_REQUEST['ContextID'];
     }
     return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
 }