Exemple #1
0
 public function run()
 {
     if (!$this->stopOnFail) {
         return $this->taskExec($this->getCommand())->run();
     }
     foreach ($this->exec as $command) {
         $result = $this->taskExec($command)->run();
         if (!$result->wasSuccessful()) {
             return $result;
         }
     }
     return Result::success($this);
 }
Exemple #2
0
    $agents = $request->param('logAgents');
    $result = Logs::updateLog($id, $logData, $agents);
    if ($result > 0) {
        $response->json(Result::success('Log Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Log not Updated.'));
    } else {
        $response->json(Result::error('Log not found'));
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $logData = Logs::getLog($id);
    $agents = Agents::getLogAgents($id);
    $notes = Notes::getLogNotes($id);
    $result = array("logData" => $logData, "logAgents" => $agents, "logNotes" => $notes);
    if ($logData) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Log not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Logs::deleteLog($id);
    if ($result > 0) {
        $response->json(Result::success('Log Deleted.'));
    } else {
        $response->json(Result::error('Log not Deleted'));
    }
});
Exemple #3
0
    $result = User::login($request->param('username', 'none'), $request->param('password', 'none'), $request->param('rememberMe', true));
    if ($result === true) {
        $response->json(Result::success('logged in successfully', ['REMEMBERMECOOKIE' => $_SESSION['REMEMBERMECOOKIE'], 'SESSIONID' => session_id()]));
    } else {
        $response->json(Result::error($result));
    }
});
//$this->respond(['GET','POST'], '/register', function ($request, $response, $service) {
//    $result = User::register($request->param('userName','none'),$request->param('mail','none'),
//        $request->param('password','none'),$request->param('passwordRepeat','none'));
//    if ($result != -1) {
//        $response->json(Result::success('registered successfuly',['id'=>$result]));
//    }
//    else
//        $response->json(Result::error($result));
//});
$this->respond(['GET', 'POST'], '/logout', function ($request, $response, $service) {
    if (User::isLoggedIn() !== true) {
        $response->json(Result::error('Can\'t Logout: Not logged in.'));
    } else {
        User::logout();
        $response->json(Result::success('Logged out successfully'));
    }
});
$this->respond(['GET', 'POST'], '/isLoggedIn', function ($request, $response, $service) {
    if (User::isLoggedIn() !== true) {
        $response->json(Result::error('You"re not logged in', [false]));
    } else {
        $response->json(Result::success('You"re logged in', array('userId' => User::currentUserID())));
    }
});
<?php

$this->respond(['GET', 'POST'], '/get/crm', function ($request, $response, $service, $app) {
    $investors = Investors::getInvestorsForControlPanel();
    $result = array("investors" => $investors);
    $response->json(Result::success('', $result));
});
Exemple #5
0
<?php

$this->respond(['GET', 'POST'], '/uploadFile', function ($request, $response, $service, $app) {
    $ans = FileUploader::uploadFile();
    if ($ans != -1) {
        $response->json(Result::success('file uploaded.', ['path' => $ans]));
    } else {
        $response->json(Result::error('file upload Failed.'));
    }
});
Exemple #6
0
    $data = json_decode($request->body(), true);
    // Access only for Current Agent
    if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
        $response->json(Result::error('Access is denied'));
    } else {
        $result = Agents::updateAgent($id, $data);
        if ($result > 0) {
            $response->json(Result::success('Agent Updated.'));
        } elseif ($result === 0) {
            $response->json(Result::success('Agent not Updated.'));
        } else {
            $response->json(Result::error('Agent not found'));
        }
    }
});
$this->respond(['GET', 'POST'], '/edit/password/[:id]', function ($request, $response, $service) {
    $id = $request->param('id');
    $oldPassword = $request->param('oldPassword', '');
    $newPassword = $request->param('newPassword', '');
    // Access only for Current Agent
    if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
        $response->json(Result::error('Access is denied'));
    } else {
        $result = User::editPassword($oldPassword, $newPassword, $newPassword);
        if ($result === true) {
            $response->json(Result::success('edited password successfully'));
        } else {
            $response->json(Result::error($result));
        }
    }
});
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Demands::getDemand($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Demand not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body());
    $result = Demands::updateDemand($id, $data);
    if ($result > 0) {
        $response->json(Result::success('Demand Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Demand not Updated.'));
    } else {
        $response->json(Result::error('Demand not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Demands::deleteDemand($id);
    if ($result > 0) {
        $response->json(Result::success('Demand Deleted.'));
    } else {
        $response->json(Result::error('Demand not Deleted'));
    }
});
    $id = $request->param('id');
    $result = Conversations::getConversation($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Conversation not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body(), true);
    $oldConv = Conversations::getConversation($id);
    Logs::createLogOnConversationSave($data, $oldConv);
    $result = Conversations::updateConversation($id, $data);
    if ($result > 0) {
        $response->json(Result::success('Conversation Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Conversation not Updated.'));
    } else {
        $response->json(Result::error('Conversation not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Conversations::deleteConversation($id);
    if ($result > 0) {
        $response->json(Result::success('Conversation Deleted.'));
    } else {
        $response->json(Result::error('Conversation not Deleted'));
    }
});
    } else {
        $response->json(Result::error('Contact not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $contactResult = Contacts::deleteContact($id);
    Conversations::deleteContactConversations($id);
    if ($contactResult > 0) {
        $response->json(Result::success('Contact Deleted.'));
    } else {
        $response->json(Result::error('Contact not Deleted'));
    }
});
$this->respond(['GET', 'POST'], '/get/all-for-index', function ($request, $response, $service, $app) {
    $result = Contacts::getAllContactsForIndex();
    $response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
    $result = Contacts::getAllContacts();
    $response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/get-investor-contacts/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $contacts = Contacts::getInvestorCrmContacts($id);
    if ($contacts) {
        $response->json(Result::success('', $contacts));
    } else {
        $response->json(Result::error('Contact not found'));
    }
});
Exemple #10
0
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Notes::getNote($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Note not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body());
    $result = Notes::updateNote($id, $data);
    if ($result > 0) {
        $response->json(Result::success('Note Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Note not Updated.'));
    } else {
        $response->json(Result::error('Note not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Notes::deleteNote($id);
    if ($result > 0) {
        $response->json(Result::success('Note Deleted.'));
    } else {
        $response->json(Result::error('Note not Deleted'));
    }
});
Exemple #11
0
 /**
  * Tries to execute the given function and returns a result representing the
  * outcome, i.e. if the function returns normally, a successful result is
  * returned containing the return value and if the function throws an exception,
  * an error result is returned containing the error
  * 
  * $f should take no arguments and return a value that will be wrapped in a
  * success if the computation completes successfully
  * 
  * The _ is required if we want to use the word try since it is keyword
  */
 public static function _try(callable $f)
 {
     try {
         return Result::success($f());
     } catch (\Exception $error) {
         return Result::error($error);
     }
 }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = RentAreas::getRentArea($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('RentArea not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body());
    $result = RentAreas::updateRentArea($id, $data);
    if ($result > 0) {
        $response->json(Result::success('RentArea Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('RentArea not Updated.'));
    } else {
        $response->json(Result::error('RentArea not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = RentAreas::deleteRentArea($id);
    if ($result > 0) {
        $response->json(Result::success('RentArea Deleted.'));
    } else {
        $response->json(Result::error('RentArea not Deleted'));
    }
});
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = TrackedAssets::getTrackedAsset($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('TrackedAsset not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body());
    $result = TrackedAssets::updateTrackedAsset($id, $data);
    if ($result > 0) {
        $response->json(Result::success('TrackedAsset Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('TrackedAsset not Updated.'));
    } else {
        $response->json(Result::error('TrackedAsset not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = TrackedAssets::deleteTrackedAsset($id);
    if ($result > 0) {
        $response->json(Result::success('TrackedAsset Deleted.'));
    } else {
        $response->json(Result::error('TrackedAsset not Deleted'));
    }
});