本文整理汇总了PHP中ApplicationLogs类的典型用法代码示例。如果您正苦于以下问题:PHP ApplicationLogs类的具体用法?PHP ApplicationLogs怎么用?PHP ApplicationLogs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ApplicationLogs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show dashboard index page
*
* @param void
* @return null
*/
function index()
{
$logged_user = logged_user();
$active_projects = $logged_user->getActiveProjects();
$activity_log = null;
if (is_array($active_projects) && count($active_projects)) {
$include_private = $logged_user->isMemberOfOwnerCompany();
$include_silent = $logged_user->isAdministrator();
$project_ids = array();
foreach ($active_projects as $active_project) {
$project_ids[] = $active_project->getId();
}
// if
$activity_log = ApplicationLogs::getOverallLogs($include_private, $include_silent, $project_ids, config_option('dashboard_logs_count', 15));
}
// if
tpl_assign('today_milestones', $logged_user->getTodayMilestones());
tpl_assign('late_milestones', $logged_user->getLateMilestones());
tpl_assign('active_projects', $active_projects);
tpl_assign('activity_log', $activity_log);
// Sidebar
tpl_assign('online_users', Users::getWhoIsOnline());
tpl_assign('my_projects', $active_projects);
$this->setSidebar(get_template_path('index_sidebar', 'dashboard'));
}
示例2: purge_trash
function purge_trash()
{
Env::useHelper("permissions");
$days = config_option("days_on_trash", 0);
$count = 0;
if ($days > 0) {
$date = DateTimeValueLib::now()->add("d", -$days);
$objects = Objects::findAll(array("conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
foreach ($objects as $object) {
$concrete_object = Objects::findObject($object->getId());
if (!$concrete_object instanceof ContentDataObject) {
continue;
}
if ($concrete_object instanceof MailContent && $concrete_object->getIsDeleted() > 0) {
continue;
}
try {
DB::beginWork();
if ($concrete_object instanceof MailContent) {
$concrete_object->delete(false);
} else {
$concrete_object->delete();
}
ApplicationLogs::createLog($concrete_object, ApplicationLogs::ACTION_DELETE);
DB::commit();
$count++;
} catch (Exception $e) {
DB::rollback();
Logger::log("Error delting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
}
}
}
return $count;
}
示例3: index
/**
* Show dashboard index page
*
* @param void
* @return null
*/
function index()
{
trace(__FILE__, 'index() - begin');
$logged_user = logged_user();
$active_projects = $logged_user->getActiveProjects();
$activity_log = null;
$projects_activity_log = array();
if (is_array($active_projects) && count($active_projects)) {
$include_private = $logged_user->isMemberOfOwnerCompany();
$include_silent = $logged_user->isAdministrator();
$project_ids = array();
foreach ($active_projects as $active_project) {
$project_ids[] = $active_project->getId();
$temp_project_logs = ApplicationLogs::getProjectLogs($active_project, $include_private, $include_silent, config_option('dashboard_project_logs_count', 7));
if (isset($temp_project_logs) && is_array($temp_project_logs) && count($temp_project_logs)) {
$projects_activity_log[$temp_project_logs[0]->getCreatedOn()->getTimestamp()] = $temp_project_logs;
}
krsort($projects_activity_log);
}
// if
$activity_log = ApplicationLogs::getOverallLogs($include_private, $include_silent, $project_ids, config_option('dashboard_logs_count', 15));
}
// if
trace(__FILE__, 'index() - tpl_assign...');
tpl_assign('today_milestones', $logged_user->getTodayMilestones());
tpl_assign('late_milestones', $logged_user->getLateMilestones());
tpl_assign('active_projects', $active_projects);
tpl_assign('activity_log', $activity_log);
tpl_assign('projects_activity_log', $projects_activity_log);
// Sidebar
tpl_assign('online_users', Users::getWhoIsOnline());
tpl_assign('my_projects', $active_projects);
$this->setSidebar(get_template_path('index_sidebar', 'dashboard'));
trace(__FILE__, 'index() - end');
}
示例4: delete
/**
* Delete specific user
*
* @access public
* @param void
* @return null
*/
function delete()
{
$this->setTemplate('del_user');
$user = Users::findById(get_id());
if (!$user instanceof User) {
flash_error(lang('user dnx'));
$this->redirectTo('administration');
}
// if
if (!$user->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
$delete_data = array_var($_POST, 'deleteUser');
tpl_assign('user', $user);
tpl_assign('delete_data', $delete_data);
if (!is_array($delete_data)) {
$delete_data = array('really' => 0, 'password' => '');
// array
tpl_assign('delete_data', $delete_data);
} else {
if ($delete_data['really'] == 1) {
$password = $delete_data['password'];
if (trim($password) == '') {
tpl_assign('error', new Error(lang('password value missing')));
return $this->render();
}
if (!logged_user()->isValidPassword($password)) {
tpl_assign('error', new Error(lang('invalid login data')));
return $this->render();
}
try {
DB::beginWork();
$user->delete();
ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_DELETE);
DB::commit();
flash_success(lang('success delete user', $user->getDisplayName()));
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete user'));
}
// try
$this->redirectToUrl($user->getCompany()->getViewUrl());
} else {
flash_error(lang('error delete user'));
$this->redirectToUrl($user->getCompany()->getViewUrl());
}
}
}
示例5: purge_trash
function purge_trash()
{
Env::useHelper("permissions");
$days = config_option("days_on_trash", 0);
$count = 0;
if ($days > 0) {
$date = DateTimeValueLib::now()->add("d", -$days);
$managers = array('Comments', 'Companies', 'Contacts', 'MailContents', 'ProjectCharts', 'ProjectEvents', 'ProjectFiles', 'ProjectFileRevisions', 'ProjectForms', 'ProjectMessages', 'ProjectMilestones', 'ProjectTasks', 'ProjectWebpages');
foreach ($managers as $manager_class) {
$manager = new $manager_class();
$prevcount = -1;
while ($prevcount != $count) {
$prevcount = $count;
if ($manager_class == 'MailContents') {
$objects = $manager->findAll(array("include_trashed" => true, "conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ? AND `is_deleted` = 0", $date), "limit" => 100));
} else {
$objects = $manager->findAll(array("include_trashed" => true, "conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
}
if (is_array($objects)) {
// delete one by one because each one knows what else to delete
foreach ($objects as $o) {
try {
DB::beginWork();
$ws = $o->getWorkspaces();
if ($o instanceof MailContent) {
$o->delete(false);
} else {
$o->delete();
}
ApplicationLogs::createLog($o, $ws, ApplicationLogs::ACTION_DELETE);
DB::commit();
$count++;
} catch (Exception $e) {
DB::rollback();
Logger::log("Error deleting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
}
}
}
}
}
}
return $count;
}
示例6: delete_comment
/**
* Delete comment
*
* @access public
* @param void
* @return null
*/
function delete_comment()
{
$comment = MessageComments::findById(get_id());
if (!$comment instanceof MessageComment) {
flash_error(lang('comment dnx'));
$this->redirectTo('message');
}
// if
$message = $comment->getMessage();
if (!$message instanceof ProjectMessage) {
flash_error(lang('message dnx'));
$this->redirectTo('message');
}
// if
if (!$comment->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToUrl($message->getViewUrl());
}
// if
try {
DB::beginWork();
$comment->delete();
ApplicationLogs::createLog($comment, active_project(), ApplicationLogs::ACTION_DELETE);
DB::commit();
flash_success(lang('success delete comment'));
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete comment'));
}
// try
$this->redirectToUrl($message->getViewUrl());
}
示例7: manager
/**
* Return manager instance
*
* @access protected
* @param void
* @return ApplicationLogs
*/
function manager()
{
if (!$this->manager instanceof ApplicationLogs) {
$this->manager = ApplicationLogs::instance();
}
return $this->manager;
}
示例8: delete
/**
* Delete specific project form
*
* @param void
* @return null
*/
function delete()
{
$project_form = ProjectForms::findById(get_id());
if (!$project_form instanceof ProjectForm) {
flash_error(lang('project form dnx'));
if (ProjectForm::canAdd(logged_user(), active_project())) {
$this->redirectTo('form');
} else {
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
}
// if
if (!$project_form->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
if (ProjectForm::canAdd(logged_user(), active_project())) {
$this->redirectTo('form');
} else {
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
}
// if
if ($project_form->delete()) {
ApplicationLogs::createLog($project_form, active_project(), ApplicationLogs::ACTION_DELETE, true);
flash_success(lang('success delete project form', $project_form->getName()));
} else {
flash_error(lang('error delete project form'));
}
// if
$this->redirectTo('form');
}
示例9: project_activities
/**
* List project activities as a RSS feed
*
* @param void
* @return null
*/
function project_activities()
{
$this->setLayout('xml');
$logged_user = $this->loginUserByToken();
if (!$logged_user instanceof User) {
header("HTTP/1.0 404 Not Found");
die;
}
// if
$project = Projects::findById(array_var($_GET, 'project'));
if (!$project instanceof Project) {
header("HTTP/1.0 404 Not Found");
die;
}
// if
if (!$logged_user->isProjectUser($project)) {
header("HTTP/1.0 404 Not Found");
die;
}
// if
$include_private = $logged_user->isMemberOfOwnerCompany();
$include_silent = $logged_user->isAdministrator();
$activity_log = ApplicationLogs::getOverallLogs($include_private, $include_silent, array($project->getId()), config_option('feed_logs_count', 50));
$feed = new Angie_Feed(lang('recent project activities feed', $project->getName()), undo_htmlspecialchars($project->getOverviewUrl()));
$feed = $this->populateFeedFromLog($feed, $activity_log);
$this->renderText($feed->renderRSS2(), true);
}
示例10: delete
/**
* Delete specific comment
*
* @param void
* @return null
*/
function delete()
{
$comment = Comments::findById(get_id());
if (!$comment instanceof Comment) {
flash_error(lang('comment dnx'));
ajx_current("empty");
return;
}
// if
$object = $comment->getRelObject();
if (!$object instanceof ContentDataObject) {
flash_error(lang('object dnx'));
ajx_current("empty");
return;
}
// if
if (trim($object->getObjectUrl())) {
$redirect_to = $object->getObjectUrl();
}
if (!$comment->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
try {
DB::beginWork();
$comment->trash();
ApplicationLogs::createLog($comment, ApplicationLogs::ACTION_TRASH);
DB::commit();
flash_success(lang('success delete comment'));
ajx_current("reload");
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete comment'));
ajx_current("empty");
}
// try
}
示例11: delete_logo
/**
* Delete company logo
*
* @param void
* @return null
*/
function delete_logo()
{
if (!logged_user()->isAdministrator(owner_company())) {
flash_error(lang('no access permissions'));
$this->redirectTo('dashboard');
}
// if
$company = Companies::findById(get_id());
if (!$company instanceof Company) {
flash_error(lang('company dnx'));
$this->redirectToReferer(get_url('administration', 'clients'));
}
// if
try {
DB::beginWork();
$company->deleteLogo();
$company->save();
ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_EDIT);
DB::commit();
flash_success(lang('success delete company logo'));
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete company logo'));
}
// try
$this->redirectToUrl($company->getEditLogoUrl());
}
示例12: restore_user
function restore_user()
{
$user = Contacts::findById(get_id());
if (!($user instanceof Contact && $user->isUser())) {
flash_error(lang('user dnx'));
ajx_current("empty");
return;
}
if (!$user->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
try {
DB::beginWork();
$user->setDisabled(false);
$user->unarchive();
ApplicationLogs::createLog($user, ApplicationLogs::ACTION_UNTRASH);
$ret = null;
Hook::fire("user_restored", $user, $ret);
DB::commit();
flash_success('success delete user');
ajx_current("reload");
} catch (Exception $e) {
flash_error($e->getMessage());
DB::rollback();
ajx_current("empty");
}
}
示例13: setIsPrivateForType
/**
* Mass set is_private for a given type. If $ids is present limit update only to object with given ID-s
*
* @param boolean $is_private
* @param string $type
* @parma array $ids
* @return boolean
*/
static function setIsPrivateForType($is_private, $type, $ids = null)
{
$limit_ids = null;
if (is_array($ids)) {
$limit_ids = array();
foreach ($ids as $id) {
$limit_ids[] = DB::escape($id);
}
// if
$limit_ids = count($limit_ids) > 0 ? implode(',', $limit_ids) : null;
}
// if
$sql = DB::prepareString('UPDATE ' . ApplicationLogs::instance()->getTableName(true) . ' SET `is_private` = ? WHERE `rel_object_manager` = ?', array($is_private, $type));
if ($limit_ids !== null) {
$sql .= " AND `rel_object_id` IN ({$limit_ids})";
}
// if
return DB::execute($sql);
}
示例14: delete_chart
function delete_chart()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$chart = ProjectCharts::findById(get_id());
if (!$chart instanceof ProjectChart) {
flash_error(lang('chart dnx'));
ajx_current("empty");
return;
}
// if
if (!$chart->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
try {
DB::beginWork();
$chart->trash();
ApplicationLogs::createLog($chart, $chart->getWorkspaces(), ApplicationLogs::ACTION_TRASH);
DB::commit();
flash_success(lang('success deleted chart', $chart->getTitle()));
ajx_current("back");
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete chart'));
ajx_current("empty");
}
// try
}
示例15: repetitive_task_related_edit
function repetitive_task_related_edit($task, $task_data)
{
$was_template = $task->getIsTemplate();
$task->setFromAttributes($task_data);
$task->setIsTemplate($was_template);
// is_template value must not be changed from ui
$totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes');
$task->setTimeEstimate($totalMinutes);
if ($task->getParentId() > 0 && $task->hasChild($task->getParentId())) {
flash_error(lang('task child of child error'));
ajx_current("empty");
return;
}
DB::beginWork();
$task->save();
$task->setObjectName(array_var($task_data, 'name'));
$task->save();
// dependencies
if (config_option('use tasks dependencies')) {
$previous_tasks = array_var($task_data, 'previous');
if (is_array($previous_tasks)) {
foreach ($previous_tasks as $ptask) {
if ($ptask == $task->getId()) {
continue;
}
$dep = ProjectTaskDependencies::findById(array('previous_task_id' => $ptask, 'task_id' => $task->getId()));
if (!$dep instanceof ProjectTaskDependency) {
$dep = new ProjectTaskDependency();
$dep->setPreviousTaskId($ptask);
$dep->setTaskId($task->getId());
$dep->save();
}
}
$saved_ptasks = ProjectTaskDependencies::findAll(array('conditions' => 'task_id = ' . $task->getId()));
foreach ($saved_ptasks as $pdep) {
if (!in_array($pdep->getPreviousTaskId(), $previous_tasks)) {
$pdep->delete();
}
}
} else {
ProjectTaskDependencies::delete('task_id = ' . $task->getId());
}
}
// Add assigned user to the subscibers list
if ($task->getAssignedToContactId() > 0 && Contacts::instance()->findById($task->getAssignedToContactId())) {
if (!isset($_POST['subscribers'])) {
$_POST['subscribers'] = array();
}
$_POST['subscribers']['user_' . $task->getAssignedToContactId()] = 'checked';
}
$object_controller = new ObjectController();
$object_controller->add_to_members($task, array_var($task_data, 'members'));
$object_controller->add_subscribers($task);
$object_controller->link_to_new_object($task);
$object_controller->add_custom_properties($task);
$object_controller->add_reminders($task);
// apply values to subtasks
$assigned_to = $task->getAssignedToContactId();
$subtasks = $task->getAllSubTasks();
$milestone_id = $task->getMilestoneId();
$apply_ms = array_var($task_data, 'apply_milestone_subtasks') == "checked";
$apply_at = array_var($task_data, 'apply_assignee_subtasks', '') == "checked";
foreach ($subtasks as $sub) {
$modified = false;
if ($apply_at || !($sub->getAssignedToContactId() > 0)) {
$sub->setAssignedToContactId($assigned_to);
$modified = true;
}
if ($apply_ms) {
$sub->setMilestoneId($milestone_id);
$modified = true;
}
if ($modified) {
$sub->save();
}
}
$task->resetIsRead();
ApplicationLogs::createLog($task, ApplicationLogs::ACTION_EDIT);
DB::commit();
}