Esempio n. 1
0
File: In.php Progetto: avz/php-b2
 public function toString(\b2\Quote $quote)
 {
     if (!$this->cases) {
         throw new \b2\Exception('IN is empty');
     }
     $call = new Call('IN', $this->cases);
     return $this->expression->toString($quote) . ' ' . $call->toString($quote);
 }
 public static function createCall()
 {
     $time = mt_rand();
     $name = 'Call';
     $call = new Call();
     $call->name = $name . $time;
     $call->save();
     self::$_createdCalls[] = $call;
     return $call;
 }
Esempio n. 3
0
 public function run()
 {
     $data = new Call();
     $data->level_id = 1;
     $data->function = 'backgroundObj';
     $data->x = 0;
     $data->y = 85;
     $data->width = 700;
     $data->height = 15;
     $data->color = 'black';
     $data->save();
 }
 public function test_treeByTeams()
 {
     /** === Test Data === */
     $asCustId = 'customer';
     $asParentId = 'parent';
     $id1 = 1;
     $id2 = 2;
     $id3 = 3;
     $data = [[$asCustId => $id1, $asParentId => $id1], [$asCustId => $id2, $asParentId => $id1], [$asCustId => $id3, $asParentId => $id2]];
     /** === Setup Mocks === */
     /** === Call and asserts  === */
     $req = new Request\TreeByTeams();
     $req->setDataToMap($data);
     $req->setAsCustomerId($asCustId);
     $req->setAsParentId($asParentId);
     $resp = $this->obj->treeByTeams($req);
     $this->assertTrue($resp->isSucceed());
     $mapped = $resp->getMapped();
     $this->assertTrue(is_array($mapped));
     $this->assertEquals(2, count($mapped));
     $custId = reset($mapped[$id1]);
     $this->assertEquals($id2, $custId);
     $custId = reset($mapped[$id2]);
     $this->assertEquals($id3, $custId);
 }
Esempio n. 5
0
 public function indexAction()
 {
     $model = new SettingsModel();
     $form = Call::form('Index');
     $countrysList = $model->getCountryList();
     if (isPost()) {
         if ($form->isValid(allPost()) and (isset($form->data["email"]) or isset($form->data["password"]) and isset($form->data["password1"]))) {
             if (Request::getParam('user')->password == md5($form->data['password'])) {
                 $data = [];
                 if ($form->data['password1'] != '') {
                     $data['password'] = md5($form->data['password1']);
                 }
                 if (isset($form->data['email'])) {
                     $data['email'] = $form->data["email"];
                 }
                 if ($form->data['news'] == 1) {
                     $data['newsletter'] = $form->data["news"];
                 }
                 $model->setSettings(Request::getParam('user')->id, $data);
                 redirect(url('settings'));
             }
         } else {
             $this->view->error = printError($form->error, 'INDEX_ERROR_');
         }
     }
     $this->view->countrysList = $countrysList;
     $this->view->title = Lang::translate('INDEX_TITLE');
 }
Esempio n. 6
0
    /**
     * Add a Call object to the CallChain
     * 
     * @param mixed $call           Either a Call object, or a table name (from which a Call object will be created)
     * @param array $plugins        (Optional) An array of plugins
     * 
     * @return void
     */
    public function push($call, array $plugins = array())
    {
        if (! ($call instanceof Call))
        {
            $table       = (string) $call;
            $call        = new Call();
            $call->table = $table;
        }
        
        foreach ($plugins as $plugin)
        {
            $call->apply($plugin);
        }

        $this->_calls[] = $call;

        return;
    }
 public function optimize(array $expression, Call $call, CompilationContext $context)
 {
     /**
      * Process the expected symbol to be returned
      */
     $call->processExpectedReturn($context);
     $symbolVariable = $call->getSymbolVariable();
     if ($symbolVariable->isNotVariableAndString()) {
         throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
     }
     if ($call->mustInitSymbolVariable()) {
         $symbolVariable->initVariant($context);
     }
     $context->headersManager->add('my_mandelbrot');
     $symbolVariable->setDynamicTypes('bool');
     $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression);
     $context->codePrinter->output('ZVAL_BOOL(' . $symbolVariable->getRealName() . ', my_mandelbrot_to_file(' . $resolvedParams[0] . ', ' . $resolvedParams[1] . ', ' . $resolvedParams[2] . ', ' . $resolvedParams[3] . '));');
     return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
 }
Esempio n. 8
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // $validator = new Validator::make(Input::all(), ObjectsData::$rules);
     // if( $validator->fails())
     // {
     // 	return Redirect::back()->withInput()->withErrors($validator);
     // } else {
     // $oldData = ObjectsData::were('level_id', 1)->get();
     // dd($oldData);
     $prev = Level::where('next_level', '=', NULL)->first();
     $lvl = new Level();
     $lvl->game_id = 1;
     $lvl->level_name = Input::get('level_name');
     $lvl->next_level = null;
     $lvl->save();
     $prev->next_level = $lvl->id;
     $prev->save();
     // $oldData = Call::where('level_id', $lvl->id)->get();
     // foreach($oldData as $old)
     // {
     // 	$old->destroy($old->id);
     // }
     $lines = explode('*', Input::get('csvString'));
     foreach ($lines as $line) {
         $data = explode(',', $line);
         $submit = new Call();
         $submit->level_id = $lvl->id;
         $submit->function = $data[0];
         $submit->x = $data[1];
         $submit->y = $data[2];
         $submit->width = $data[3];
         $submit->height = $data[4];
         $submit->color = $data[5];
         $submit->save();
     }
     if ($submit) {
         return Redirect::action('GamesController@show', $lvl->id);
     } else {
         return Redirect::action('GamesController@create')->withInput();
     }
     // }
 }
Esempio n. 9
0
 public function process()
 {
     parent::process();
     $params = $this->initParams();
     $call = new Call();
     try {
         $result = $call->createTransaction($params);
     } catch (Exception $e) {
         //d($e);
     }
     if (isset($result->CreateTransactionResult) && isset($result->CreateTransactionResult->TransportKey) && $result->CreateTransactionResult->TransportKey != '') {
         self::$smarty->assign('formLink', $this->_paymentLink[Configuration::get('MERCHANT_WARE_MODE')]);
         self::$smarty->assign('transportKey', Tools::safeOutput($result->CreateTransactionResult->TransportKey));
     } elseif (isset($result->CreateTransactionResult)) {
         Logger::addLog('Module merchantware: ' . $result->CreateTransactionResult->Messages->Message[0]->Information, 2);
         self::$smarty->assign('error', true);
     } else {
         self::$smarty->assign('error', true);
         Logger::addLog('Module merchantware: no message returned', 2);
     }
 }
Esempio n. 10
0
 /**
  * Führt den Request aus
  * 
  * Gibt die Ausgabe des Calls vom Controller zurück
  * wenn man den Request nicht selbst erstellen will, kann man
  *
  * \Psc\URL\Service\Request::infer();
  *
  * benutzen.
  */
 public function process(Request $request)
 {
     // required
     $service = $this->getRegisteredService($request->getPart(1));
     $call = new Call(mb_strtolower($request->getMethod()));
     // identifier ist optional
     if (($identifier = $request->getPart(2)) !== NULL) {
         $call->addParameter($identifier);
         /* alle Subs weitergeben als weitere Parameter */
         foreach ($request->getPartsFrom(3) as $p) {
             $call->addParameter($p);
         }
     } else {
         $call->setName('index');
     }
     if ($request->getMethod() === Request::POST || $request->getMethod() === Request::PUT) {
         $call->addParameter($request->getBody());
     }
     $this->call = $call;
     $this->service = $service;
     return $this->call();
 }
 public function test_getCurrentStock_noCustomer_noLink()
 {
     /** === Test Data === */
     $CUST_ID = 21;
     $STOCK_ID = 32;
     $LINK = new \Praxigento\Warehouse\Data\Entity\Customer();
     $LINK->setStockRef($STOCK_ID);
     /** === Setup Mocks === */
     // $custId = $this->_session->getCustomerId();
     $this->mSession->shouldReceive('getCustomerId')->once()->andReturn($CUST_ID);
     // $link = $this->_repoCustomer->getById($custId);
     $this->mRepoCustomer->shouldReceive('getById')->once()->andReturn(null);
     // $stockId = $this->_subRepo->getStockId();
     $this->mSubRepo->shouldReceive('getStockId')->once()->andReturn($STOCK_ID);
     // $this->_repoCustomer->create($data);
     $this->mRepoCustomer->shouldReceive('create')->once();
     /** === Call and asserts  === */
     $req = new Request\GetCurrentStock();
     $resp = $this->obj->getCurrentStock($req);
     $this->assertTrue($resp->isSucceed());
     $this->assertEquals($STOCK_ID, $resp->getStockId());
 }
 public function test_reset()
 {
     /** === Test Data === */
     $DATESTAMP_FROM = '20151123';
     $ROWS_DELETED = 5;
     /** === Setup Mocks === */
     // $rows = $this->_repoBalance->delete($where);
     $this->mRepoBalance->shouldReceive('delete')->once()->andReturn($ROWS_DELETED);
     /** === Call and asserts  === */
     $req = new Request\Reset();
     $req->setDateFrom($DATESTAMP_FROM);
     $res = $this->obj->reset($req);
     $this->assertTrue($res->isSucceed());
     $this->assertEquals($ROWS_DELETED, $res->getRowsDeleted());
 }
 public function test_getStateOnDate()
 {
     /** === Test Data === */
     $dstamp = '20151206';
     $rows = 'rows';
     /** === Setup Mocks === */
     // $rows = $this->_repoSnap->getStateOnDate($dateOn);
     $this->mRepoSnap->shouldReceive('getStateOnDate')->once()->andReturn($rows);
     /** === Call and asserts  === */
     $req = new Request\GetStateOnDate();
     $req->setDatestamp($dstamp);
     $resp = $this->obj->getStateOnDate($req);
     $this->assertTrue($resp->isSucceed());
     $this->assertEquals($rows, $resp->getData());
 }
 public function test_registerSale()
 {
     /** === Test Data === */
     $ITEM_ID = 32;
     $PROD_ID = 16;
     $STOCK_ID = 2;
     $QTY = 4;
     $REQ = $this->_mock(Request\RegisterSale::class);
     /** === Setup Mocks === */
     // $def = $this->_manTrans->begin();
     $mDef = $this->_mockTransactionDefinition();
     $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef);
     // $reqItems = $req->getSaleItems();
     $mReqItem = $this->_mock(\Praxigento\Warehouse\Service\QtyDistributor\Data\Item::class);
     $REQ->shouldReceive('getSaleItems')->once()->andReturn([$mReqItem]);
     // $itemId = $item->getItemId();
     $mReqItem->shouldReceive('getItemId')->once()->andReturn($ITEM_ID);
     // $prodId = $item->getProductId();
     $mReqItem->shouldReceive('getProductId')->once()->andReturn($PROD_ID);
     // $stockId = $item->getStockId();
     $mReqItem->shouldReceive('getStockId')->once()->andReturn($STOCK_ID);
     // $qty = $item->getQuantity();
     $mReqItem->shouldReceive('getQuantity')->once()->andReturn($QTY);
     // $lots = $this->_subRepo->getLotsByProductId($prodId, $stockId);
     $mLots = ['lots'];
     $this->mSubRepo->shouldReceive('getLotsByProductId')->once()->andReturn($mLots);
     // $this->_subRepo->registerSaleItemQty($itemId, $qty, $lots);
     $this->mSubRepo->shouldReceive('registerSaleItemQty')->once()->with($ITEM_ID, $QTY, $mLots);
     // $this->_manTrans->commit($def);
     $this->mManTrans->shouldReceive('commit')->once()->with($mDef);
     // $this->_manTrans->end($def);
     $this->mManTrans->shouldReceive('end')->once()->with($mDef);
     /** === Call and asserts  === */
     $res = $this->obj->registerSale($REQ);
     $this->assertTrue($res->isSucceed());
 }
Esempio n. 15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Auth::check()) {
         $level = Level::find($id);
         $previous = Level::where('next_level', '=', $level->id)->first();
         $previous->next_level = $level->next_level;
         $previous->save();
         $calls = Call::where('level_id', '=', $id)->get();
         foreach ($calls as $call) {
             $call->delete();
         }
         $level = Level::find($id);
         $level->delete();
         return $this->index();
     }
     return 'you are not authorized to do this';
 }
Esempio n. 16
0
 function get_calls($offset = 0, $page_size = 20)
 {
     $output = array();
     $page_cache_key = $this->cache_key . "_{$offset}_{$page_size}";
     $total_cache_key = $this->cache_key . '_total';
     if (function_exists('apc_fetch')) {
         $success = FALSE;
         $total = apc_fetch($total_cache_key, $success);
         if ($total and $success) {
             $this->total = $total;
         }
         $data = apc_fetch($page_cache_key, $success);
         if ($data and $success) {
             $output = @unserialize($data);
             if (is_array($output)) {
                 return $output;
             }
         }
     }
     $page = floor(($offset + 1) / $page_size);
     $params = array('num' => $page_size, 'page' => $page);
     $response = $this->twilio->request("Accounts/{$this->twilio_sid}/Calls", 'GET', $params);
     if ($response->IsError) {
         throw new VBX_CallException($response->ErrorMessage, $response->HttpStatus);
     } else {
         $this->total = (string) $response->ResponseXml->Calls['total'];
         $records = $response->ResponseXml->Calls->Call;
         foreach ($records as $record) {
             $item = new stdClass();
             $item->id = (string) $record->Sid;
             $item->caller = format_phone($record->Caller);
             $item->called = format_phone($record->Called);
             $item->status = Call::get_status((string) $record->Status);
             $item->start = isset($record->StartTime) ? strtotime($record->StartTime) : null;
             $item->end = isset($record->EndTime) ? strtotime($record->EndTime) : null;
             $item->seconds = isset($record->Duration) ? (string) $record->Duration : 0;
             $output[] = $item;
         }
     }
     if (function_exists('apc_store')) {
         apc_store($page_cache_key, serialize($output), self::CACHE_TIME_SEC);
         apc_store($total_cache_key, $this->total, self::CACHE_TIME_SEC);
     }
     return $output;
 }
Esempio n. 17
0
 public function lang_newsAction()
 {
     $model = new AdminModel();
     $form = Call::form('Lang_news');
     $news = $model->getNewsByID(Request::getUri()[0]);
     if (!$news->id) {
         error404();
     }
     if (isPost()) {
         $dataPost = array('name' => post('name'), 'lang' => 'en', 'text' => post('text'));
         // allPost()
         $lnid = post('lnid', 'int');
         if ($form->isValid($dataPost)) {
             $data = $form->data;
             $data['nid'] = $news->id;
             $data['uid'] = Request::getParam('user')->id;
             $data['time'] = time();
             if ($lnid) {
                 $model->update('news_lang', $data, "`id` = '{$lnid}'");
                 setNotice(Lang::translate('LANG_NEWS_EDITED'));
             } else {
                 $id = $model->insert('news_lang', $data);
                 $lnid = $id;
                 if ($id) {
                     setNotice(Lang::translate('LANG_NEWS_ADDED'));
                 }
             }
             $dataImg['path'] = 'public/news/';
             $dataImg['new_name'] = $lnid;
             $dataImg['resize'] = 2;
             $dataImg['mkdir'] = true;
             $dataImg['min_width'] = 600;
             $dataImg['min_height'] = 400;
             if ($_FILES['image']['name']) {
                 $f = File::LoadImg($_FILES['image'], $dataImg);
             }
         } else {
             setNotice(Lang::translate('SOME_ERROR'));
         }
         //redirect(url('admin', 'lang_news', $news->id));
     }
     $this->view->list = $model->getLangNewsList($news->id);
     $this->view->news = $news;
     $this->view->title = $news->name;
 }
Esempio n. 18
0
 public function test_orderSave()
 {
     /** === Test Data === */
     $ORDER_ID_MAGE = 4;
     $ORDER_ID_ODOO = 16;
     $REQ = new \Praxigento\Odoo\Service\Replicate\Request\OrderSave();
     /** === Setup Mocks === */
     // $mageOrder = $req->getSaleOrder();
     $mMageOrder = $this->_mock(\Magento\Sales\Api\Data\OrderInterface::class);
     $REQ->setSaleOrder($mMageOrder);
     // $orderIdMage = $mageOrder->getEntityId();
     $mMageOrder->shouldReceive('getEntityId')->once()->andReturn($ORDER_ID_MAGE);
     // $registeredOrder = $this->_repoEntitySaleOrder->getById($orderIdMage);
     $mRegisteredOrder = null;
     $this->mRepoEntitySaleOrder->shouldReceive('getById')->once()->with($ORDER_ID_MAGE)->andReturn($mRegisteredOrder);
     // $odooOrder = $this->_subCollector->getSaleOrder($mageOrder);
     $mOdooOrder = $this->_mock(\Praxigento\Odoo\Data\Odoo\SaleOrder::class);
     $this->mSubCollector->shouldReceive('getSaleOrder')->once()->andReturn($mOdooOrder);
     // $def = $this->_manTrans->begin();
     $mDef = $this->_mockTransactionDefinition();
     $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef);
     // $resp = $this->_repoOdooSaleOrder->save($odooOrder);
     $mResp = $this->_mock(\Praxigento\Odoo\Data\Odoo\SaleOrder\Response::class);
     $this->mRepoOdooSaleOrder->shouldReceive('save')->once()->andReturn($mResp);
     // $mageId = $mageOrder->getEntityId();
     $mMageOrder->shouldReceive('getEntityId')->once()->andReturn($ORDER_ID_MAGE);
     // $odooId = $resp->getIdOdoo();
     $mResp->shouldReceive('getIdOdoo')->once()->andReturn($ORDER_ID_ODOO);
     // $this->_repoEntitySaleOrder->create($registry);
     $this->mRepoEntitySaleOrder->shouldReceive('create')->once();
     // $this->_manTrans->commit($def);
     $this->mManTrans->shouldReceive('commit')->once();
     // $this->_manTrans->end($def);
     $this->mManTrans->shouldReceive('end')->once();
     /** === Call and asserts  === */
     $res = $this->obj->orderSave($REQ);
     $this->assertTrue($res instanceof \Praxigento\Odoo\Service\Replicate\Response\OrderSave);
     $this->assertTrue($res->isSucceed());
 }
Esempio n. 19
0
 /**
  * login
  *
  * The script checks provided name and password against remote server.
  *
  * This is done by transmitting the user name and the password to the origin server,
  * through a XML-RPC call ([code]drupal.login[/code]).
  * On success the origin server will provide the original id for the user profile.
  * Else a null id will be returned.
  *
  * @link http://drupal.org/node/312 Using distributed authentication (drupal.org)
  *
  * @param string the nickname or the email address of the user
  * @param string the submitted password
  * @return TRUE on succesful authentication, FALSE othewise
  */
 function login($name, $password)
 {
     global $context;
     // we need some parameters
     if (!isset($this->attributes['authenticator_parameters']) || !$this->attributes['authenticator_parameters']) {
         Logger::error(i18n::s('Please provide parameters to the authenticator.'));
         return FALSE;
     }
     // submit credentials to the authenticating server
     include_once $context['path_to_root'] . 'services/call.php';
     $result = Call::invoke($this->attributes['authenticator_parameters'], 'drupal.login', array($name, $password), 'XML-RPC');
     // invalid result
     if (!$result || @count($result) < 2) {
         Logger::error(sprintf(i18n::s('Impossible to complete XML-RPC call to %s.'), $this->attributes['authenticator_parameters']));
         return FALSE;
     }
     // successful authentication
     if ($result[0] && $result[1] > 0) {
         return TRUE;
     }
     // failed authentication
     return FALSE;
 }
Esempio n. 20
0
 public function testParentsAreRelatedDuringImport()
 {
     $file = 'upload://test50438.csv';
     $ret = file_put_contents($file, $this->fileArr);
     $this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . var_export($this->fileArr, true));
     $importSource = new ImportFile($file, ',', '"');
     $bean = loadBean('Calls');
     $_REQUEST['columncount'] = 5;
     $_REQUEST['colnum_0'] = 'id';
     $_REQUEST['colnum_1'] = 'subject';
     $_REQUEST['colnum_2'] = 'status';
     $_REQUEST['colnum_3'] = 'parent_type';
     $_REQUEST['colnum_4'] = 'parent_id';
     $_REQUEST['import_module'] = 'Contacts';
     $_REQUEST['importlocale_charset'] = 'UTF-8';
     $_REQUEST['importlocale_timezone'] = 'GMT';
     $_REQUEST['importlocale_default_currency_significant_digits'] = '2';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_dec_sep'] = '.';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_default_locale_name_format'] = 's f l';
     $_REQUEST['importlocale_num_grp_sep'] = ',';
     $_REQUEST['importlocale_dateformat'] = 'm/d/y';
     $_REQUEST['importlocale_timeformat'] = 'h:i:s';
     $importer = new Importer($importSource, $bean);
     $importer->import();
     //fetch the bean using the passed in id and get related contacts
     require_once 'modules/Calls/Call.php';
     $call = new Call();
     $call->retrieve($this->call_id);
     $call->load_relationship('contacts');
     $related_contacts = $call->contacts->get();
     //test that the contact id is in the array of related contacts.
     $this->assertContains($this->contact->id, $related_contacts, ' Contact was not related during simulated import despite being set in related parent id');
     unset($call);
     /*
     if (is_file($file)) {
         unlink($file);
     }
     */
 }
Esempio n. 21
0
File: links.php Progetto: rair/yacs
 /**
  * attempt to use the pingback interface
  *
  * @param string - some text, extracted from the target site, to extract the broker URL, if any
  * @param string - the source address
  * @param string - the target address from which the text has been extracted
  * @return TRUE if the target site has been pinged back, FALSE otherwise
  *
  * @link http://www.hixie.ch/specs/pingback/pingback Pingback specification
  */
 public static function ping_as_pingback($text, $source, $target)
 {
     global $context;
     // extract all <link... /> tags
     preg_match_all('/<link(.+?)\\/?>/mi', $text, $links);
     // nothing to do
     if (!@count($links[1])) {
         return FALSE;
     }
     // look for the broker
     $broker = array();
     foreach ($links[1] as $link) {
         // seek the pingback interface
         if (!preg_match('/rel="pingback"/mi', $link)) {
             continue;
         }
         // extract the broker link
         if (preg_match('/href="([^"]+)"/mi', $link, $broker)) {
             break;
         }
     }
     // pingback interface not supported here
     if (!isset($broker[1])) {
         return FALSE;
     }
     // actual pingback, through XML-RPC
     include_once $context['path_to_root'] . 'services/call.php';
     $result = Call::invoke($broker[1], 'pingback.ping', array($source, $target), 'XML-RPC');
     return TRUE;
 }
Esempio n. 22
0
 /**
  * @expectedException Respect\Validation\Exceptions\CallException
  */
 public function testCallbackFailedShouldThrowCallException()
 {
     $v = new Call('strrev', new Arr());
     $this->assertFalse($v->validate('test'));
     $this->assertFalse($v->assert('test'));
 }
Esempio n. 23
0
     require "custom/modules/Asterisk/language/" . $current_language . ".lang.php";
     $cUser = new User();
     $cUser->retrieve($_SESSION['authenticated_user_id']);
     // query log
     // Very basic santization
     $contactId = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $_REQUEST['contact_id']);
     // mysql_real_escape_string($_REQUEST['ui_state']);
     $callRecord = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $_REQUEST['call_record']);
     // mysql_real_escape_string($_REQUEST['call_record']);
     $query = "update asterisk_log set contact_id=\"{$contactId}\" where call_record_id=\"{$callRecord}\"";
     $resultSet = $cUser->db->query($query, false);
     if ($cUser->db->checkError()) {
         trigger_error("Update setContactId-Query failed: {$query}");
     }
     // Adds the new relationship!  (This must be done here in case the call has already been hungup as that's when asteriskLogger sets relations)
     $focus = new Call();
     $focus->retrieve($callRecord);
     $focus->load_relationship('contacts');
     // Remove any contacts already associated with call (if there are any)
     foreach ($focus->contacts->getBeans() as $contact) {
         $focus->contacts->delete($callRecord, $contact->id);
     }
     $focus->contacts->add($contactId);
     // Add the new one!
     $contactBean = new Contact();
     $contactBean->retrieve($contactId);
     $focus->parent_id = $contactBean->account_id;
     $focus->parent_type = "Accounts";
     $focus->save();
 } else {
     if ($_REQUEST['action'] == "call") {
Esempio n. 24
0
	function save($check_notify = FALSE) {
		global $timedate,$current_user;

	    if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes))
        {
    	    $td = $timedate->fromDb($this->date_start);
    	    if($td)
    	    {
	        	$this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb();
    	    }
        }

		if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') {
			$check_notify = true;
        } else {
			$check_notify = false;
		}
		if(empty($_REQUEST['send_invites'])) {
			if(!empty($this->id)) {
				$old_record = new Call();
				$old_record->retrieve($this->id);
				$old_assigned_user_id = $old_record->assigned_user_id;
			}
			if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){
				$this->special_notification = true;
				if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) {
					$check_notify = true;
				}
                if(isset($_REQUEST['assigned_user_name'])) {
                    $this->new_assigned_user_name = $_REQUEST['assigned_user_name'];
                }
			}
		}
        if (empty($this->status) ) {
            $this->status = $this->getDefaultStatus();
        }

		// prevent a mass mailing for recurring meetings created in Calendar module
		if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) {
			$check_notify = false;
		}
		/*nsingh 7/3/08  commenting out as bug #20814 is invalid
		if($current_user->getPreference('reminder_time')!= -1 &&  isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0  && $_POST['reminder_time']==-1){
			$this->reminder_checked = '1';
			$this->reminder_time = $current_user->getPreference('reminder_time');
		}*/

        $return_id = parent::save($check_notify);
        global $current_user;


        if($this->update_vcal) {
			vCal::cache_sugar_vcal($current_user);
        }

        return $return_id;
	}
Esempio n. 25
0
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 * 
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
global $json, $current_user;
if ($_REQUEST['object_type'] == "Meeting") {
    $focus = new Meeting();
    $focus->id = $_REQUEST['object_id'];
    $test = $focus->set_accept_status($current_user, $_REQUEST['accept_status']);
} else {
    if ($_REQUEST['object_type'] == "Call") {
        $focus = new Call();
        $focus->id = $_REQUEST['object_id'];
        $test = $focus->set_accept_status($current_user, $_REQUEST['accept_status']);
    }
}
print 1;
exit;
Esempio n. 26
0
 private function _createUpcomingActivities()
 {
     $GLOBALS['current_user']->setPreference('datef', 'Y-m-d');
     $GLOBALS['current_user']->setPreference('timef', 'H:i');
     $date1 = $GLOBALS['timedate']->to_display_date_time(gmdate("Y-m-d H:i:s", gmmktime() + 3600 * 24 * 2), true, true, $GLOBALS['current_user']);
     //Two days from today
     $date2 = $GLOBALS['timedate']->to_display_date_time(gmdate("Y-m-d H:i:s", gmmktime() + 3600 * 24 * 4), true, true, $GLOBALS['current_user']);
     //Two days from today
     $callID = uniqid();
     $c = new Call();
     $c->id = $callID;
     $c->new_with_id = TRUE;
     $c->status = 'Not Planned';
     $c->date_start = $date1;
     $c->name = "UNIT TEST";
     $c->assigned_user_id = $this->_user->id;
     $c->save(FALSE);
     $callID = uniqid();
     $c = new Call();
     $c->id = $callID;
     $c->new_with_id = TRUE;
     $c->status = 'Planned';
     $c->date_start = $date1;
     $c->name = "UNIT TEST";
     $c->assigned_user_id = $this->_user->id;
     $c->save(FALSE);
     $taskID = uniqid();
     $t = new Task();
     $t->id = $taskID;
     $t->new_with_id = TRUE;
     $t->status = 'Not Started';
     $t->date_due = $date2;
     $t->name = "UNIT TEST";
     $t->assigned_user_id = $this->_user->id;
     $t->save(FALSE);
     return array($callID, $taskID);
 }
Esempio n. 27
0
 /**
  * @expectedException Respect\Validation\Exceptions\CallException
  */
 public function test_callback_failed_should_throw_CallException()
 {
     $v = new Call('strrev', new Arr());
     $this->assertFalse($v->validate('test'));
     $this->assertFalse($v->assert('test'));
 }
Esempio n. 28
0
File: ping.php Progetto: rair/yacs
    // anonymous users are invited to log in or to register
} elseif (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('servers/ping.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // do the ping
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ping') {
    // list servers to be advertised
    if ($servers = Servers::list_for_ping(0, 20, 'ping')) {
        $context['text'] .= '<p>' . i18n::s('Servers that have been notified') . '</p><ul>';
        // ping each server
        foreach ($servers as $server_url => $attributes) {
            list($server_ping, $server_label) = $attributes;
            $milestone = get_micro_time();
            $result = @Call::invoke($server_ping, 'weblogUpdates.ping', array(strip_tags($context['site_name']), $context['url_to_home'] . $context['url_to_root']), 'XML-RPC');
            if ($result[0]) {
                $label = round(get_micro_time() - $milestone, 2) . ' sec.';
            } else {
                $label = @$result[1];
            }
            $context['text'] .= '<li>' . $server_label . ' (' . $label . ')</li>';
        }
        $context['text'] .= '</ul>';
        // no server to ping
    } else {
        $context['text'] .= '<p>' . i18n::s('No server has been created yet.') . '</p>';
    }
    // back to the index of servers
    $menu = array('servers/' => i18n::s('Servers'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
 /**
  * @brief Validate a payment, verify if everything is right
  */
 public function validation()
 {
     $token = (int) Tools::getValue('Token');
     $id_cart = (int) Tools::getValue('TransactionID');
     $link = new Link();
     $this->context->cart = new Cart($id_cart);
     $this->context->link = $link;
     if (Validate::isLoadedObject($this->context->cart)) {
         $call = new Call();
         try {
             $result = $call->getTransaction($token);
         } catch (Exception $e) {
             Logger::AddLog('[MerchantWare] Problem to verify a payment. Cart id: ' . $id_cart . ', token: ' . $token . '.', 2);
         }
         if (isset($result->TransactionsByReferenceResult->TransactionReference4->ApprovalStatus)) {
             if ($result->TransactionsByReferenceResult->TransactionReference4->ApprovalStatus == 'APPROVED') {
                 $amount = str_replace(',', '', $result->TransactionsByReferenceResult->TransactionReference4->Amount);
                 $tokenTransaction = new TokenTransaction((int) $this->context->cart->id);
                 $tokenTransaction->setToken($token);
                 $this->validateOrder((int) $this->context->cart->id, Configuration::get('PS_OS_PAYMENT'), $amount, 'merchantware', NULL, array(), NULL, false, $this->context->cart->secure_key);
             } else {
                 $this->validateOrder((int) $this->context->cart->id, Configuration::get('PS_OS_ERROR'), $amount, 'merchantware', NULL, array(), NULL, false, $this->context->cart->secure_key);
             }
         } else {
             Logger::AddLog('[MerchantWare] Problem to verify a payment. Cart id: ' . (int) $id_cart . ', token: ' . Tools::safeOutput($token) . '.', 2);
         }
     } else {
         Logger::AddLog('[MerchantWare] The Shopping cart #' . (int) $id_cart . ' was not found during the payment validation step.', 2);
     }
     $url = 'index.php?controller=order-confirmation&';
     if (_PS_VERSION_ < '1.5') {
         $url = 'order-confirmation.php?';
     }
     header('location:' . __PS_BASE_URI__ . $url . 'id_module=' . (int) $this->id . '&id_cart=' . (int) $this->context->cart->id . '&key=' . $this->context->customer->secure_key);
     exit;
 }
 function CreateTaskAndCallForNewOpportunity($bean)
 {
     $timeDate = new TimeDate();
     if (empty($bean->fetched_row['id'])) {
         $task = new Task();
         $task->name = "Send Proposal";
         $task->priority = "High";
         $task->status = "Not Started";
         $task->date_due = $timeDate->getNow(true)->modify("+1 days")->asDb();
         $task->parent_type = "Opportunities";
         $task->parent_id = $bean->id;
         $task->assigned_user_id = $bean->assigned_user_id;
         $task->save();
         $call = new Call();
         $call->name = "Follow up";
         $call->direction = "Outbound";
         $call->status = "Planned";
         $call->duration_hours = 0;
         $call->duration_minutes = 15;
         $call->date_start = $timeDate->getNow(true)->modify("+2 days")->asDb();
         $call->parent_type = "Opportunities";
         $call->parent_id = $bean->id;
         $call->assigned_user_id = $bean->assigned_user_id;
         $call->save();
     }
 }