Example #1
0
 /**
  * Function to format the Vacancy parameters before saving
  *
  * @return array   Formated array before being used for create/update Vacancy
  */
 public static function formatParams($params)
 {
     $formattedParams = array();
     $instance = new self();
     $fields = $instance->fields();
     foreach ($fields as $name => $dontCare) {
         if (strpos($name, '_date') !== FALSE && strpos($name, 'created_') === FALSE) {
             $time = empty($params[$name . '_time']) ? NULL : $params[$name . '_time'];
             $formattedParams[$name] = CRM_Utils_Date::processDate($params[$name], $time);
         } elseif (isset($params[$name])) {
             $formattedParams[$name] = $params[$name];
         }
     }
     return $formattedParams;
 }
Example #2
0
 /**
  * Finds webhook configs by even
  *
  * @param   string   $eventName     Event type
  * @param   int      $farmId    The identifier of the farm
  * @param   int      $accountId The identifier of the client's account
  * @param   int      $envId     The identifier of the environment
  * @return  ArrayCollection Gets collection of the WebhookConfig objects
  */
 public static function findByEvent($eventName, $farmId, $accountId, $envId)
 {
     $ret = new ArrayCollection();
     $cfg = new self();
     $res = $cfg->db()->Execute("\n            SELECT " . $cfg->fields('c') . "\n            FROM " . $cfg->table() . " c\n            JOIN `webhook_config_events` ce ON ce.webhook_id = c.webhook_id\n            WHERE ce.event_type = ?\n            AND (\n                (c.account_id = ? AND c.env_id = ? AND `level` = 4) OR\n                (c.account_id = ? AND c.env_id IS NULL AND `level` = 2) OR\n                (c.account_id IS NULL AND c.env_id IS NULL AND `level` = 1)\n            )\n            AND EXISTS (\n                SELECT 1 FROM `webhook_config_farms` cf\n                WHERE cf.webhook_id = c.webhook_id\n                AND (cf.farm_id = 0 OR cf.farm_id = ?)\n            )\n        ", array($eventName, $accountId, $envId, $accountId, $farmId));
     while ($item = $res->FetchRow()) {
         $cfg = new self();
         $cfg->load($item);
         $ret->append($cfg);
         unset($cfg);
     }
     return $ret;
 }