示例#1
0
文件: User.php 项目: Victopia/prefw
 /**
  * Remove all sessions upon delete.
  */
 function afterDelete()
 {
     Node::delete(array(NODE_FIELD_COLLECTION => FRAMEWORK_COLLECTION_SESSION, 'username' => $this->identity()));
     $this->deleteAncestors(static::GROUP_RELATION);
     return parent::afterDelete();
 }
示例#2
0
<?php

/*! SessionSweeper.php | Clean up expired sessions. */
require_once '.private/scripts/Initialize.php';
use core\Node;
use framework\Session;
Node::delete(array(Node::FIELD_COLLECTION => FRAMEWORK_COLLECTION_SESSION, 'timestamp' => date("< 'Y-m-d H:i:s'", strtotime(Session::DELETE_TIME))));
示例#3
0
 private function setContents()
 {
     $cObj = $this;
     // Trace upwards until root for the object.
     while ($pObj = $cObj->getParentObject()) {
         $cObj = $pObj;
     }
     unset($pObj);
     $confObj = $cObj->getContents();
     $confKey = $cObj->getKey();
     $filter = array(Node::FIELD_COLLECTION => FRAMEWORK_COLLECTION_CONFIGURATION, '@key' => $confKey);
     if (!$confObj) {
         Node::delete($filter);
     } else {
         Node::set($filter + $confObj);
     }
 }
示例#4
0
// Log the process output if available
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
if ("{$stdout}{$stderr}") {
    $method = $stderr ? 'error' : 'info';
    Log::$method(sprintf('Output captured from command line: %s', $process['command']), array_filter(array('stdout' => $stdout, 'stderr' => $stderr)));
    unset($method);
}
unset($stdout, $stderr);
// Handles cleanup after process exit
switch (strtolower($process['type'])) {
    // Permanent processes will be restarted upon death
    case 'permanent':
        core\Database::query('UPDATE `' . FRAMEWORK_COLLECTION_PROCESS . '` SET `pid` = NULL WHERE `id` = ?', $process['id']);
        Log::debug('Permanent process died, clearing pid.', [$res, $process]);
        break;
        // Sets pid to 0, prevents it fire again and double enqueue of the same time slot.
    // Sets pid to 0, prevents it fire again and double enqueue of the same time slot.
    case 'cron':
        core\Database::query('UPDATE `' . FRAMEWORK_COLLECTION_PROCESS . '` SET `pid` = 0 WHERE `id` = ?', $process['id']);
        break;
        // Deletes the process object upon exit
    // Deletes the process object upon exit
    default:
        $process = array_select($process, array(Node::FIELD_COLLECTION, 'id', 'pid'));
        $res = Node::delete($process);
        Log::debug("Deleting finished process, affected rows: {$res}.", [$res, $process]);
        break;
}
// Recursive process, spawn another worker.
Process::spawnWorker(@$_SERVER['env']);
示例#5
0
 /**
  * Delete this model from database.
  */
 function delete(&$isDeleted = false)
 {
     $filter = [Node::FIELD_COLLECTION => self::collectionName(), '@limit' => 1];
     if ($this->identity()) {
         $filter[$this->_primaryKey] = $this->identity();
     } else {
         $filter += $this->data();
     }
     $this->beforeDelete($filter);
     if ($filter !== false) {
         $isDeleted = (bool) Node::delete($filter);
         if ($isDeleted) {
             $this->afterDelete();
         }
     }
     return $this;
 }
示例#6
0
 /**
  * Remove a scheduled process with specified name.
  */
 public static function unschedule($name)
 {
     return Node::delete(array(Node::FIELD_COLLECTION => FRAMEWORK_COLLECTION_PROCESS_SCHEDULE, 'name' => $name));
 }