Пример #1
0
 public function changeStatusToExpired()
 {
     $this->status = Connection::AUTH_STATUS_EXPIRED;
     $this->save();
     BpmFlow::removeFlows($this->connection_id);
 }
Пример #2
0
 public static function continueWorkflows($id, $asking = true)
 {
     Yii::trace("CONTINUA WORKFLOWS");
     $paths = ConnectionPath::find()->select('DISTINCT `domain`')->where(['conn_id' => $id])->all();
     Yii::trace("Dominios envolvidos:");
     foreach ($paths as $path) {
         Yii::trace($path->domain);
     }
     //Analisa se existem pedidos em espera. Neste momento, realiza as perguntas aos admins.
     foreach ($paths as $path) {
         if (Connection::findOne(['id' => $id])->auth_status == self::AUTH_STATUS_REJECTED) {
             break;
         } else {
             $domain = Domain::findOne(['name' => $path->domain]);
             if (isset($domain)) {
                 BpmFlow::doRequest($id, $domain->name, $asking);
             }
         }
         if (ConnectionAuth::find()->where(['connection_id' => $id, 'status' => self::AUTH_STATUS_PENDING])->count() > 0) {
             break;
         }
         //Se tem uma pergunta ativa.
     }
     if (!$asking || ConnectionAuth::find()->where(['connection_id' => $id, 'status' => self::AUTH_STATUS_PENDING])->count() > 0) {
         return;
     }
     $conn = Connection::findOne(['id' => $id]);
     if ($conn->auth_status == self::AUTH_STATUS_PENDING) {
         $conn->auth_status = self::AUTH_STATUS_APPROVED;
         if (!$conn->save()) {
         }
         if (!$conn->isCancelStatus()) {
             $conn->requestProvision();
         }
     }
     //Remove fluxos não finalizados
     BpmFlow::removeFlows($id);
 }